Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
Update to @solana/web3.js 0.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Nov 23, 2018
1 parent 4d3ee10 commit 50d435c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 21 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prettier": "^1.14.3"
},
"dependencies": {
"@solana/web3.js": "0.11.10",
"@solana/web3.js": "0.12.1",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
Expand Down
4 changes: 3 additions & 1 deletion program-bpf/src/tictactoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,11 @@ extern bool entrypoint(const uint8_t *input) {
uint64_t ka_len;
const uint8_t *instruction_data;
uint64_t instruction_data_len;
SolClusterInfo info;

sol_log("tic-tac-toe program entrypoint");

if (!sol_deserialize(input, ka, SOL_ARRAY_SIZE(ka), &ka_len, &instruction_data, &instruction_data_len)) {
if (!sol_deserialize(input, ka, SOL_ARRAY_SIZE(ka), &ka_len, &instruction_data, &instruction_data_len, &info)) {
sol_log("Error: deserialize failed");
return false;
}
Expand Down Expand Up @@ -333,6 +334,7 @@ extern bool entrypoint(const uint8_t *input) {
sol_log("Error: 3rd key is not a game account");
return false;
}
if (ka[2].owner
sol_log("Command_UpdateDashboard");
return dashboard_update(&state_data->dashboard, ka[2].key, &game_state_data->game);

Expand Down
8 changes: 4 additions & 4 deletions src/program/tic-tac-toe-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export class TicTacToeDashboard {
await sendAndConfirmTransaction(
'initDashboard',
connection,
dashboardAccount,
transaction,
dashboardAccount,
);
}

Expand All @@ -101,12 +101,12 @@ export class TicTacToeDashboard {
dashboardPublicKey: PublicKey,
): Promise<TicTacToeDashboard> {
const accountInfo = await connection.getAccountInfo(dashboardPublicKey);
const {programId} = accountInfo;
const {owner} = accountInfo;

const tempAccount = await newSystemAccountWithAirdrop(connection, 123);
const dashboard = new TicTacToeDashboard(
connection,
programId,
owner,
dashboardPublicKey,
tempAccount,
);
Expand All @@ -126,8 +126,8 @@ export class TicTacToeDashboard {
await sendAndConfirmTransaction(
'updateDashboard',
this.connection,
this.clientAccount,
transaction,
this.clientAccount,
);
}

Expand Down
10 changes: 4 additions & 6 deletions src/program/tic-tac-toe.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ export class TicTacToe {
await sendAndConfirmTransaction(
'initGame',
connection,
gameAccount,
transaction,
gameAccount,
);
}

Expand Down Expand Up @@ -183,8 +183,8 @@ export class TicTacToe {
await sendAndConfirmTransaction(
'joinGame',
connection,
playerOAccount,
transaction,
playerOAccount,
);
}

Expand All @@ -205,9 +205,8 @@ export class TicTacToe {
await sendAndConfirmTransaction(
'keepAlive',
this.connection,
this.playerAccount,
transaction,
true,
this.playerAccount,
);
}

Expand All @@ -231,9 +230,8 @@ export class TicTacToe {
await sendAndConfirmTransaction(
`move(${x + 1},${y + 1})`,
this.connection,
this.playerAccount,
transaction,
true,
this.playerAccount,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/new-program-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export async function newProgramAccount(
await sendAndConfirmTransaction(
'SystemProgram.createAccount',
connection,
from,
transaction,
from,
);
return stateAccount;
}
8 changes: 3 additions & 5 deletions src/util/send-and-confirm-transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,20 @@ export function onTransaction(callback: TransactionNotification) {
export async function sendAndConfirmTransaction(
title: string,
connection: Connection,
from: Account,
transaction: Transaction,
runtimeErrorOk: boolean = false,
...signers: Array<Account>
): Promise<void> {
const when = Date.now();

const signature = await realSendAndConfirmTransaction(
connection,
from,
transaction,
runtimeErrorOk,
...signers,
);

const body = {
time: new Date(when).toString(),
from: from.publicKey.toBase58(),
from: signers[0].publicKey.toBase58(),
signature,
instructions: transaction.instructions.map(i => {
return {
Expand Down

0 comments on commit 50d435c

Please sign in to comment.