Skip to content

Commit

Permalink
ts, examples: Fix web3.js usage
Browse files Browse the repository at this point in the history
  • Loading branch information
armaniferrante committed Mar 31, 2021
1 parent 46a9ff9 commit 6576e0d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
10 changes: 8 additions & 2 deletions examples/spl/token-proxy/tests/token-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ describe("token", () => {
const serumCmn = require("@project-serum/common");
const TokenInstructions = require("@project-serum/serum").TokenInstructions;

// TODO: remove this constant once @project-serum/serum uses the same version
// of @solana/web3.js as anchor (or switch packages).
const TOKEN_PROGRAM_ID = new anchor.web3.PublicKey(
TokenInstructions.TOKEN_PROGRAM_ID.toString()
);

async function getTokenAccount(provider, addr) {
return await serumCmn.getTokenAccount(provider, addr);
}
Expand Down Expand Up @@ -102,7 +108,7 @@ async function createMintInstructions(provider, authority, mint) {
newAccountPubkey: mint,
space: 82,
lamports: await provider.connection.getMinimumBalanceForRentExemption(82),
programId: TokenInstructions.TOKEN_PROGRAM_ID,
programId: TOKEN_PROGRAM_ID,
}),
TokenInstructions.initializeMint({
mint,
Expand Down Expand Up @@ -139,7 +145,7 @@ async function createTokenAccountInstrs(
newAccountPubkey,
space: 165,
lamports,
programId: TokenInstructions.TOKEN_PROGRAM_ID,
programId: TOKEN_PROGRAM_ID,
}),
TokenInstructions.initializeAccount({
account: newAccountPubkey,
Expand Down
2 changes: 1 addition & 1 deletion ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@project-serum/borsh": "^0.1.0",
"@solana/web3.js": "^1.1.0",
"@solana/web3.js": "^1.2.0",
"@types/bn.js": "^4.11.6",
"@types/bs58": "^4.0.1",
"@types/crypto-hash": "^1.1.2",
Expand Down
1 change: 1 addition & 0 deletions ts/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async function getMultipleAccounts(
Array<null | { publicKey: PublicKey; account: AccountInfo<Buffer> }>
> {
const args = [publicKeys.map((k) => k.toBase58()), { commitment: "recent" }];
// @ts-ignore
const res = await connection._rpcRequest("getMultipleAccounts", args);
if (res.error) {
throw new Error(
Expand Down
8 changes: 4 additions & 4 deletions ts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -676,10 +676,10 @@
dependencies:
"@sinonjs/commons" "^1.7.0"

"@solana/web3.js@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.1.0.tgz#b31815c9fa7cabeefe8175034bfe300b9d4011e7"
integrity sha512-n8O5wvoogrwQJWe9rQml/QlN+lQu9VaBGueeSR/9oyefktzchZS9ar1hsatybCvqNSRQCnmTme9zQwY1kJkMGw==
"@solana/web3.js@^1.2.0":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.2.3.tgz#8d4c1f70b8c208c721eeca03c9624d3638ba3d7f"
integrity sha512-aDsFJhefIiKh9kb3xeWcX5rsAPdUqJtz61F9tplfp//mYVpzKZeWYZSUKB39PXo7c5ZrxVeBx7am4J7NB10Pcg==
dependencies:
"@babel/runtime" "^7.12.5"
bn.js "^5.0.0"
Expand Down

0 comments on commit 6576e0d

Please sign in to comment.