diff --git a/tests/anchor-cli-account/tests/account.ts b/tests/anchor-cli-account/tests/account.ts index c6754cc546..6249b910ff 100644 --- a/tests/anchor-cli-account/tests/account.ts +++ b/tests/anchor-cli-account/tests/account.ts @@ -3,7 +3,6 @@ import { Program } from "@coral-xyz/anchor"; import { AccountCommand } from "../target/types/account_command"; import { assert } from "chai"; import { execSync } from "child_process"; -import { sleep } from "@project-serum/common"; describe("Test CLI account commands", () => { // Configure the client to use the local cluster. @@ -24,11 +23,11 @@ describe("Test CLI account commands", () => { await program.methods .initialize( balance, - new anchor.BN(amount), + amount, memo, values.map((x) => new anchor.BN(x)) ) - .accounts({ + .accountsPartial({ myAccount: myAccount.publicKey, user: provider.wallet.publicKey, systemProgram: anchor.web3.SystemProgram.programId, @@ -51,26 +50,32 @@ describe("Test CLI account commands", () => { throw e; } } - - await sleep(5000); } - assert(output.balance === balance, "Balance deserialized incorrectly"); - assert( - output.delegate_pubkey === provider.wallet.publicKey.toBase58(), + assert.strictEqual( + output.balance, + balance, + "Balance deserialized incorrectly" + ); + assert.strictEqual( + output.delegate_pubkey, + provider.wallet.publicKey.toBase58(), "delegatePubkey deserialized incorrectly" ); - assert( - output.sub.state.Confirmed.amount === amount, + assert.strictEqual( + output.sub.state.Confirmed.amount, + amount, "Amount deserialized incorrectly" ); - assert( - output.sub.state.Confirmed.memo === memo, + assert.strictEqual( + output.sub.state.Confirmed.memo, + memo, "Memo deserialized incorrectly" ); for (let i = 0; i < values.length; i++) { - assert( - output.sub.values[i] == values[i], + assert.equal( + output.sub.values[i], + values[i], "Values deserialized incorrectly" ); } diff --git a/tests/anchor-cli-account/tsconfig.json b/tests/anchor-cli-account/tsconfig.json index cd5d2e3d06..3c43903cfd 100644 --- a/tests/anchor-cli-account/tsconfig.json +++ b/tests/anchor-cli-account/tsconfig.json @@ -1,10 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true - } + "extends": "../tsconfig.json" } diff --git a/tests/anchor-cli-idl/tsconfig.json b/tests/anchor-cli-idl/tsconfig.json index cd5d2e3d06..3c43903cfd 100644 --- a/tests/anchor-cli-idl/tsconfig.json +++ b/tests/anchor-cli-idl/tsconfig.json @@ -1,10 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true - } + "extends": "../tsconfig.json" } diff --git a/tests/auction-house/package.json b/tests/auction-house/package.json index cbc3449b89..f45ec3f249 100644 --- a/tests/auction-house/package.json +++ b/tests/auction-house/package.json @@ -17,6 +17,8 @@ "test": "anchor test --skip-lint" }, "dependencies": { + "@solana/spl-token": "^0.1.8", + "@solana/web3.js": "^1.68.0", "@metaplex/js": "^4.4.1" } } diff --git a/tests/bpf-upgradeable-state/tsconfig.json b/tests/bpf-upgradeable-state/tsconfig.json index b3b6656d38..3c43903cfd 100644 --- a/tests/bpf-upgradeable-state/tsconfig.json +++ b/tests/bpf-upgradeable-state/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/cashiers-check/tests/cashiers-check.js b/tests/cashiers-check/tests/cashiers-check.js index a5edd096e2..76cf83461a 100644 --- a/tests/cashiers-check/tests/cashiers-check.js +++ b/tests/cashiers-check/tests/cashiers-check.js @@ -1,34 +1,50 @@ const anchor = require("@coral-xyz/anchor"); -const serumCmn = require("@project-serum/common"); +const { Keypair, SystemProgram, PublicKey } = require("@solana/web3.js"); const { assert } = require("chai"); -const { TOKEN_PROGRAM_ID } = require("@solana/spl-token"); +const { + TOKEN_PROGRAM_ID, + createMint, + createAccount, + mintTo, + getAccount, + createInitializeAccountInstruction, +} = require("@solana/spl-token"); +const TOKEN_ACCOUNT_SIZE = 165; describe("cashiers-check", () => { // Configure the client to use the local cluster. const provider = anchor.AnchorProvider.env(); - // hack so we don't have to update serum-common library - // to the new AnchorProvider class and Provider interface provider.send = provider.sendAndConfirm; anchor.setProvider(provider); const program = anchor.workspace.CashiersCheck; + const connection = provider.connection; + const payer = provider.wallet.payer; + const walletKey = provider.wallet.publicKey; let mint = null; let god = null; let receiver = null; it("Sets up initial test state", async () => { - const [_mint, _god] = await serumCmn.createMintAndVault( - program.provider, - new anchor.BN(1000000) + mint = await createMint(connection, payer, walletKey, walletKey, 6); + + god = await createAccount( + connection, + payer, + mint, + walletKey, + Keypair.generate() ); - mint = _mint; - god = _god; + // Mint tokens to god account + await mintTo(connection, payer, mint, god, payer, 1_000_000); - receiver = await serumCmn.createTokenAccount( - program.provider, + receiver = await createAccount( + connection, + payer, mint, - program.provider.wallet.publicKey + walletKey, + Keypair.generate() ); }); @@ -38,11 +54,14 @@ describe("cashiers-check", () => { let checkSigner = null; it("Creates a check!", async () => { - let [_checkSigner, nonce] = await anchor.web3.PublicKey.findProgramAddress( + let [_checkSigner, nonce] = PublicKey.findProgramAddressSync( [check.publicKey.toBuffer()], program.programId ); checkSigner = _checkSigner; + const token_lamports = await connection.getMinimumBalanceForRentExemption( + TOKEN_ACCOUNT_SIZE + ); await program.rpc.createCheck(new anchor.BN(100), "Hello world", nonce, { accounts: { @@ -51,19 +70,29 @@ describe("cashiers-check", () => { checkSigner, from: god, to: receiver, - owner: program.provider.wallet.publicKey, + owner: walletKey, tokenProgram: TOKEN_PROGRAM_ID, rent: anchor.web3.SYSVAR_RENT_PUBKEY, }, signers: [check, vault], instructions: [ - await program.account.check.createInstruction(check, 300), - ...(await serumCmn.createTokenAccountInstrs( - program.provider, - vault.publicKey, - mint, - checkSigner - )), + await program.account.check.createInstruction( + check, + TOKEN_ACCOUNT_SIZE + ), + SystemProgram.createAccount({ + fromPubkey: walletKey, + newAccountPubkey: vault.publicKey, + space: TOKEN_ACCOUNT_SIZE, + programId: TOKEN_PROGRAM_ID, + lamports: token_lamports, + }), + + createInitializeAccountInstruction( + vault.publicKey, // account + mint, // mint + checkSigner // owner + ), ], }); @@ -76,11 +105,8 @@ describe("cashiers-check", () => { assert.strictEqual(checkAccount.nonce, nonce); assert.isFalse(checkAccount.burned); - let vaultAccount = await serumCmn.getTokenAccount( - program.provider, - checkAccount.vault - ); - assert.isTrue(vaultAccount.amount.eq(new anchor.BN(100))); + let vaultAccount = await getAccount(connection, checkAccount.vault); + assert.equal(vaultAccount.amount, BigInt(100)); }); it("Cashes a check", async () => { @@ -98,16 +124,10 @@ describe("cashiers-check", () => { const checkAccount = await program.account.check.fetch(check.publicKey); assert.isTrue(checkAccount.burned); - let vaultAccount = await serumCmn.getTokenAccount( - program.provider, - checkAccount.vault - ); - assert.isTrue(vaultAccount.amount.eq(new anchor.BN(0))); + let vaultAccount = await getAccount(connection, checkAccount.vault); + assert.equal(vaultAccount.amount, BigInt(0)); - let receiverAccount = await serumCmn.getTokenAccount( - program.provider, - receiver - ); - assert.isTrue(receiverAccount.amount.eq(new anchor.BN(100))); + let receiverAccount = await getAccount(connection, receiver); + assert.equal(receiverAccount.amount, BigInt(100)); }); }); diff --git a/tests/cpi-returns/tests/cpi-return.ts b/tests/cpi-returns/tests/cpi-return.ts index 0099ef45a2..d7eececed2 100644 --- a/tests/cpi-returns/tests/cpi-return.ts +++ b/tests/cpi-returns/tests/cpi-return.ts @@ -28,12 +28,15 @@ describe("CPI return", () => { const cpiReturn = anchor.web3.Keypair.generate(); - const confirmOptions: ConfirmOptions = { commitment: "confirmed" }; + const confirmOptions: ConfirmOptions = { + commitment: "confirmed", + maxRetries: 5, + }; it("can initialize", async () => { await calleeProgram.methods .initialize() - .accounts({ + .accountsPartial({ account: cpiReturn.publicKey, user: provider.wallet.publicKey, systemProgram: SystemProgram.programId, @@ -45,7 +48,7 @@ describe("CPI return", () => { it("can return u64 from a cpi", async () => { const tx = await callerProgram.methods .cpiCallReturnU64() - .accounts({ + .accountsPartial({ cpiReturn: cpiReturn.publicKey, cpiReturnProgram: calleeProgram.programId, }) @@ -86,7 +89,7 @@ describe("CPI return", () => { it("can return a struct from a cpi", async () => { const tx = await callerProgram.methods .cpiCallReturnStruct() - .accounts({ + .accountsPartial({ cpiReturn: cpiReturn.publicKey, cpiReturnProgram: calleeProgram.programId, }) @@ -124,7 +127,7 @@ describe("CPI return", () => { it("can return a vec from a cpi", async () => { const tx = await callerProgram.methods .cpiCallReturnVec() - .accounts({ + .accountsPartial({ cpiReturn: cpiReturn.publicKey, cpiReturnProgram: calleeProgram.programId, }) @@ -134,7 +137,7 @@ describe("CPI return", () => { }); const [key, data, buffer] = getReturnLog(t); - assert.equal(key, calleeProgram.programId); + assert.strictEqual(key, calleeProgram.programId.toBase58()); // Check for matching log on receive side let receiveLog = t.meta.logMessages.find( @@ -213,7 +216,7 @@ describe("CPI return", () => { try { await calleeProgram.methods .initialize() - .accounts({ + .accountsPartial({ account: cpiReturn.publicKey, user: provider.wallet.publicKey, systemProgram: SystemProgram.programId, diff --git a/tests/cpi-returns/tsconfig.json b/tests/cpi-returns/tsconfig.json index a99920d992..3c43903cfd 100644 --- a/tests/cpi-returns/tsconfig.json +++ b/tests/cpi-returns/tsconfig.json @@ -1,10 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/custom-coder/tests/spl-associated-token-coder.ts b/tests/custom-coder/tests/spl-associated-token-coder.ts index e0b7a17619..7e861bdbd1 100644 --- a/tests/custom-coder/tests/spl-associated-token-coder.ts +++ b/tests/custom-coder/tests/spl-associated-token-coder.ts @@ -34,7 +34,7 @@ describe("spl-associated-token-coder", () => { // act await program.methods .create() - .accounts({ + .accountsPartial({ associatedAccountAddress: associatedToken, fundingAddress: provider.wallet.publicKey, systemProgram: systemProgram.programId, @@ -47,7 +47,7 @@ describe("spl-associated-token-coder", () => { tokenProgram.account.mint.createInstruction(mintKeypair), tokenProgram.methods .initializeMint(mintDecimals, provider.wallet.publicKey, null) - .accounts({ + .accountsPartial({ mint: mintKeypair.publicKey, rent: SYSVAR_RENT_PUBKEY, }) diff --git a/tests/custom-coder/tests/spl-token-coder.ts b/tests/custom-coder/tests/spl-token-coder.ts index 566770ca04..018892a231 100644 --- a/tests/custom-coder/tests/spl-token-coder.ts +++ b/tests/custom-coder/tests/spl-token-coder.ts @@ -23,7 +23,7 @@ describe("spl-token", () => { it("Creates a mint", async () => { await program.methods .initializeMint(6, provider.wallet.publicKey, null) - .accounts({ + .accountsPartial({ mint: mintKeypair.publicKey, rent, }) @@ -45,7 +45,7 @@ describe("spl-token", () => { it("Creates a token account for alice", async () => { await program.methods .initializeAccount() - .accounts({ + .accountsPartial({ account: aliceTokenKeypair.publicKey, mint: mintKeypair.publicKey, owner: provider.wallet.publicKey, @@ -90,7 +90,7 @@ describe("spl-token", () => { it("Creates a token for bob", async () => { await program.methods .initializeAccount() - .accounts({ + .accountsPartial({ account: bobTokenKeypair.publicKey, mint: mintKeypair.publicKey, owner: provider.wallet.publicKey, diff --git a/tests/custom-coder/tsconfig.json b/tests/custom-coder/tsconfig.json index b3b6656d38..3c43903cfd 100644 --- a/tests/custom-coder/tsconfig.json +++ b/tests/custom-coder/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/declare-id/tests/declare-id.ts b/tests/declare-id/tests/declare-id.ts index fa90cd5710..64a9ac356f 100644 --- a/tests/declare-id/tests/declare-id.ts +++ b/tests/declare-id/tests/declare-id.ts @@ -1,6 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; import { AnchorError, Program } from "@coral-xyz/anchor"; -import splToken from "@solana/spl-token"; import { DeclareId } from "../target/types/declare_id"; import { assert } from "chai"; diff --git a/tests/declare-id/tsconfig.json b/tests/declare-id/tsconfig.json index dc2b28af30..3c43903cfd 100644 --- a/tests/declare-id/tsconfig.json +++ b/tests/declare-id/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai", "node"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/errors/tests/errors.ts b/tests/errors/tests/errors.ts index 09df19e7e0..2c79179de2 100644 --- a/tests/errors/tests/errors.ts +++ b/tests/errors/tests/errors.ts @@ -1,7 +1,7 @@ import * as anchor from "@coral-xyz/anchor"; import { Program, AnchorError } from "@coral-xyz/anchor"; import { Keypair, Transaction, TransactionInstruction } from "@solana/web3.js"; -import { TOKEN_PROGRAM_ID, Token } from "@solana/spl-token"; +import { createMint } from "@solana/spl-token"; import { assert, expect } from "chai"; import { Errors } from "../target/types/errors"; @@ -307,20 +307,19 @@ describe("errors", () => { }); it("Emits an AccountOwnedByWrongProgram error", async () => { - let client = await Token.createMint( + let client = await createMint( program.provider.connection, (provider.wallet as anchor.Wallet).payer, provider.wallet.publicKey, provider.wallet.publicKey, - 9, - TOKEN_PROGRAM_ID + 9 ); await withLogTest(async () => { try { const tx = await program.rpc.accountOwnedByWrongProgramError({ accounts: { - wrongAccount: client.publicKey, + wrongAccount: client, }, }); assert.fail( diff --git a/tests/errors/tsconfig.json b/tests/errors/tsconfig.json index dc2b28af30..3c43903cfd 100644 --- a/tests/errors/tsconfig.json +++ b/tests/errors/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai", "node"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/escrow/tests/escrow.ts b/tests/escrow/tests/escrow.ts index 2b1c8f392a..3ca502a6a9 100644 --- a/tests/escrow/tests/escrow.ts +++ b/tests/escrow/tests/escrow.ts @@ -1,7 +1,19 @@ import * as anchor from "@coral-xyz/anchor"; import { Program, BN, IdlAccounts } from "@coral-xyz/anchor"; -import { PublicKey, Keypair, SystemProgram } from "@solana/web3.js"; -import { TOKEN_PROGRAM_ID, Token } from "@solana/spl-token"; +import { + PublicKey, + Keypair, + SystemProgram, + LAMPORTS_PER_SOL, +} from "@solana/web3.js"; +import { + createMint, + TOKEN_PROGRAM_ID, + TOKEN_2022_PROGRAM_ID, + createAccount, + mintTo, + getAccount, +} from "@solana/spl-token"; import { assert } from "chai"; import { Escrow } from "../target/types/escrow"; @@ -10,10 +22,8 @@ type EscrowAccount = IdlAccounts["escrowAccount"]; describe("escrow", () => { const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); + const connection = provider.connection; - const TOKEN_2022_PROGRAM_ID = new anchor.web3.PublicKey( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - ); const TEST_PROGRAM_IDS = [ [TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID], [TOKEN_2022_PROGRAM_ID, TOKEN_2022_PROGRAM_ID], @@ -21,8 +31,8 @@ describe("escrow", () => { ]; const program = anchor.workspace.Escrow as Program; - let mintA: Token = null; - let mintB: Token = null; + let mintA: PublicKey = null; + let mintB: PublicKey = null; let initializerTokenAccountA: PublicKey = null; let initializerTokenAccountB: PublicKey = null; let takerTokenAccountA: PublicKey = null; @@ -50,69 +60,100 @@ describe("escrow", () => { await provider.connection.confirmTransaction( await provider.connection.requestAirdrop( payer.publicKey, - 10000000000 + 10 * LAMPORTS_PER_SOL ), "confirmed" ); - mintA = await Token.createMint( - provider.connection, - payer, - mintAuthority.publicKey, - null, - 0, - tokenProgramIdA - ); - - mintB = await Token.createMint( - provider.connection, - payer, - mintAuthority.publicKey, - null, - 0, - tokenProgramIdB - ); - - initializerTokenAccountA = await mintA.createAccount( - provider.wallet.publicKey - ); - takerTokenAccountA = await mintA.createAccount( - provider.wallet.publicKey - ); - - initializerTokenAccountB = await mintB.createAccount( - provider.wallet.publicKey - ); - takerTokenAccountB = await mintB.createAccount( - provider.wallet.publicKey + [mintA, mintB] = await Promise.all( + [ + { tokenProgram: tokenProgramIdA }, + { tokenProgram: tokenProgramIdB }, + ].map(({ tokenProgram }) => + createMint( + connection, + payer, + mintAuthority.publicKey, + undefined, + 0, + undefined, + undefined, + tokenProgram + ) + ) ); - await mintA.mintTo( + [ initializerTokenAccountA, - mintAuthority.publicKey, - [mintAuthority], - initializerAmount - ); - - await mintB.mintTo( + takerTokenAccountA, + initializerTokenAccountB, takerTokenAccountB, - mintAuthority.publicKey, - [mintAuthority], - takerAmount + ] = await Promise.all( + [ + { mint: mintA, tokenProgram: tokenProgramIdA }, + { mint: mintA, tokenProgram: tokenProgramIdA }, + { mint: mintB, tokenProgram: tokenProgramIdB }, + { mint: mintB, tokenProgram: tokenProgramIdB }, + ].map(({ mint, tokenProgram }) => + createAccount( + connection, + payer, + mint, + provider.wallet.publicKey, + Keypair.generate(), + undefined, + tokenProgram + ) + ) ); - let _initializerTokenAccountA = await mintA.getAccountInfo( - initializerTokenAccountA - ); - let _takerTokenAccountB = await mintB.getAccountInfo( - takerTokenAccountB - ); + await Promise.all([ + mintTo( + connection, + payer, + mintA, + initializerTokenAccountA, + mintAuthority.publicKey, + initializerAmount, + [mintAuthority], + undefined, + tokenProgramIdA + ), + + mintTo( + connection, + payer, + mintB, + takerTokenAccountB, + mintAuthority.publicKey, + takerAmount, + [mintAuthority], + undefined, + tokenProgramIdB + ), + ]); + + let [_initializerTokenAccountA, _takerTokenAccountB] = + await Promise.all([ + getAccount( + connection, + initializerTokenAccountA, + undefined, + tokenProgramIdA + ), + getAccount( + connection, + takerTokenAccountB, + undefined, + tokenProgramIdB + ), + ]); assert.strictEqual( - _initializerTokenAccountA.amount.toNumber(), - initializerAmount + _initializerTokenAccountA.amount, + BigInt(initializerAmount) ); - assert.strictEqual(_takerTokenAccountB.amount.toNumber(), takerAmount); + assert.strictEqual(_takerTokenAccountB.amount, BigInt(takerAmount)); }); it("Initialize escrow", async () => { @@ -133,15 +174,18 @@ describe("escrow", () => { ); // Get the PDA that is assigned authority to token account. - const [_pda, _nonce] = await PublicKey.findProgramAddress( + const [_pda, _nonce] = PublicKey.findProgramAddressSync( [Buffer.from(anchor.utils.bytes.utf8.encode("escrow"))], program.programId ); pda = _pda; - let _initializerTokenAccountA = await mintA.getAccountInfo( - initializerTokenAccountA + let _initializerTokenAccountA = await getAccount( + connection, + initializerTokenAccountA, + undefined, + tokenProgramIdA ); let _escrowAccount: EscrowAccount = @@ -182,24 +226,35 @@ describe("escrow", () => { initializerMainAccount: provider.wallet.publicKey, escrowAccount: escrowAccount.publicKey, pdaAccount: pda, - depositMint: mintB.publicKey, - receiveMint: mintA.publicKey, + depositMint: mintB, + receiveMint: mintA, depositTokenProgram: tokenProgramIdB, receiveTokenProgram: tokenProgramIdA, }, }); - let _takerTokenAccountA = await mintA.getAccountInfo( - takerTokenAccountA - ); - let _takerTokenAccountB = await mintB.getAccountInfo( - takerTokenAccountB - ); - let _initializerTokenAccountA = await mintA.getAccountInfo( - initializerTokenAccountA - ); - let _initializerTokenAccountB = await mintB.getAccountInfo( - initializerTokenAccountB + const accounts = [ + { address: takerTokenAccountA, tokenProgramId: tokenProgramIdA }, + { address: takerTokenAccountB, tokenProgramId: tokenProgramIdB }, + { + address: initializerTokenAccountA, + tokenProgramId: tokenProgramIdA, + }, + { + address: initializerTokenAccountB, + tokenProgramId: tokenProgramIdB, + }, + ]; + + const [ + _takerTokenAccountA, + _takerTokenAccountB, + _initializerTokenAccountA, + _initializerTokenAccountB, + ] = await Promise.all( + accounts.map(({ address, tokenProgramId }) => + getAccount(connection, address, undefined, tokenProgramId) + ) ); // Check that the initializer gets back ownership of their token account. @@ -208,26 +263,31 @@ describe("escrow", () => { ); assert.strictEqual( - _takerTokenAccountA.amount.toNumber(), - initializerAmount + _takerTokenAccountA.amount, + BigInt(initializerAmount) ); - assert.strictEqual(_initializerTokenAccountA.amount.toNumber(), 0); + assert.strictEqual(_initializerTokenAccountA.amount, BigInt(0)); assert.strictEqual( - _initializerTokenAccountB.amount.toNumber(), - takerAmount + _initializerTokenAccountB.amount, + BigInt(takerAmount) ); - assert.strictEqual(_takerTokenAccountB.amount.toNumber(), 0); + assert.strictEqual(_takerTokenAccountB.amount, BigInt(0)); }); let newEscrow = Keypair.generate(); it("Initialize escrow and cancel escrow", async () => { // Put back tokens into initializer token A account. - await mintA.mintTo( + await mintTo( + connection, + payer, + mintA, initializerTokenAccountA, mintAuthority.publicKey, + initializerAmount, [mintAuthority], - initializerAmount + undefined, + tokenProgramIdA ); await program.rpc.initializeEscrow( @@ -246,8 +306,11 @@ describe("escrow", () => { } ); - let _initializerTokenAccountA = await mintA.getAccountInfo( - initializerTokenAccountA + let _initializerTokenAccountA = await getAccount( + connection, + initializerTokenAccountA, + undefined, + tokenProgramIdA ); // Check that the new owner is the PDA. @@ -265,8 +328,11 @@ describe("escrow", () => { }); // Check the final owner should be the provider public key. - _initializerTokenAccountA = await mintA.getAccountInfo( - initializerTokenAccountA + _initializerTokenAccountA = await getAccount( + connection, + initializerTokenAccountA, + undefined, + tokenProgramIdA ); assert.isTrue( _initializerTokenAccountA.owner.equals(provider.wallet.publicKey) @@ -274,8 +340,8 @@ describe("escrow", () => { // Check all the funds are still there. assert.strictEqual( - _initializerTokenAccountA.amount.toNumber(), - initializerAmount + _initializerTokenAccountA.amount, + BigInt(initializerAmount) ); }); }); diff --git a/tests/escrow/tsconfig.json b/tests/escrow/tsconfig.json index c7f23d9eaf..3c43903cfd 100644 --- a/tests/escrow/tsconfig.json +++ b/tests/escrow/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai", "node"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/floats/tests/floats.ts b/tests/floats/tests/floats.ts index e17c3ea7eb..6c9c50feea 100644 --- a/tests/floats/tests/floats.ts +++ b/tests/floats/tests/floats.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { Program, getProvider } from "@coral-xyz/anchor"; +import { Program } from "@coral-xyz/anchor"; import { Keypair, SystemProgram } from "@solana/web3.js"; import { Floats } from "../target/types/floats"; import { assert } from "chai"; @@ -16,7 +16,7 @@ describe("floats", () => { await program.methods .create(1.0, 2.0) - .accounts({ + .accountsPartial({ account: accountKeypair.publicKey, authority: provider.wallet.publicKey, systemProgram: SystemProgram.programId, @@ -38,7 +38,7 @@ describe("floats", () => { await program.methods .create(1.0, 2.0) - .accounts({ + .accountsStrict({ account: accountKeypair.publicKey, authority: authorityPublicKey, systemProgram: SystemProgram.programId, @@ -52,7 +52,7 @@ describe("floats", () => { await program.methods .update(3.0, 4.0) - .accounts({ + .accountsStrict({ account: accountKeypair.publicKey, authority: authorityPublicKey, }) diff --git a/tests/floats/tsconfig.json b/tests/floats/tsconfig.json index b3b6656d38..3c43903cfd 100644 --- a/tests/floats/tsconfig.json +++ b/tests/floats/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/ido-pool/tests/ido-pool.js b/tests/ido-pool/tests/ido-pool.js index a0ed236a73..08e184bae3 100644 --- a/tests/ido-pool/tests/ido-pool.js +++ b/tests/ido-pool/tests/ido-pool.js @@ -1,17 +1,24 @@ const anchor = require("@coral-xyz/anchor"); const { assert } = require("chai"); +const { BN } = require("@coral-xyz/anchor"); const { - ASSOCIATED_TOKEN_PROGRAM_ID, + createAssociatedTokenAccountInstruction, TOKEN_PROGRAM_ID, - Token, + mintTo, + getAssociatedTokenAddress, } = require("@solana/spl-token"); +const { + Keypair, + SystemProgram, + PublicKey, + Transaction, +} = require("@solana/web3.js"); const { sleep, getTokenAccount, - createMint, + createTokenMint, createTokenAccount, } = require("./utils"); -const { token } = require("@coral-xyz/anchor/dist/cjs/utils"); describe("ido-pool", () => { const provider = anchor.AnchorProvider.local(); @@ -20,24 +27,24 @@ describe("ido-pool", () => { anchor.setProvider(provider); const program = anchor.workspace.IdoPool; + const connection = provider.connection; + const payer = provider.wallet.payer; // All mints default to 6 decimal places. - const watermelonIdoAmount = new anchor.BN(5000000); + const watermelonIdoAmount = 5_000_000; // These are all of the variables we assume exist in the world already and // are available to the client. - let usdcMintAccount = null; + let usdcMint = null; - let watermelonMintAccount = null; let watermelonMint = null; let idoAuthorityUsdc = null; let idoAuthorityWatermelon = null; it("Initializes the state-of-the-world", async () => { - usdcMintAccount = await createMint(provider); - watermelonMintAccount = await createMint(provider); - usdcMint = usdcMintAccount.publicKey; - watermelonMint = watermelonMintAccount.publicKey; + usdcMint = await createTokenMint(provider); + watermelonMint = await createTokenMint(provider); + idoAuthorityUsdc = await createTokenAccount( provider, usdcMint, @@ -48,19 +55,22 @@ describe("ido-pool", () => { watermelonMint, provider.wallet.publicKey ); - // Mint Watermelon tokens that will be distributed from the IDO pool. - await watermelonMintAccount.mintTo( + + await mintTo( + connection, + payer, + watermelonMint, idoAuthorityWatermelon, - provider.wallet.publicKey, - [], - watermelonIdoAmount.toString() + payer, + watermelonIdoAmount ); idoAuthority_watermelon_account = await getTokenAccount( provider, idoAuthorityWatermelon ); - assert.isTrue( - idoAuthority_watermelon_account.amount.eq(watermelonIdoAmount) + assert.equal( + idoAuthority_watermelon_account.amount, + BigInt(watermelonIdoAmount) ); }); @@ -72,45 +82,43 @@ describe("ido-pool", () => { it("Initializes the IDO pool", async () => { let bumps = new PoolBumps(); - const [idoAccount, idoAccountBump] = - await anchor.web3.PublicKey.findProgramAddress( - [Buffer.from(idoName)], - program.programId - ); + const [idoAccount, idoAccountBump] = PublicKey.findProgramAddressSync( + [Buffer.from(idoName)], + program.programId + ); bumps.idoAccount = idoAccountBump; const [redeemableMint, redeemableMintBump] = - await anchor.web3.PublicKey.findProgramAddress( + PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("redeemable_mint")], program.programId ); bumps.redeemableMint = redeemableMintBump; const [poolWatermelon, poolWatermelonBump] = - await anchor.web3.PublicKey.findProgramAddress( + PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("pool_watermelon")], program.programId ); bumps.poolWatermelon = poolWatermelonBump; - const [poolUsdc, poolUsdcBump] = - await anchor.web3.PublicKey.findProgramAddress( - [Buffer.from(idoName), Buffer.from("pool_usdc")], - program.programId - ); + const [poolUsdc, poolUsdcBump] = PublicKey.findProgramAddressSync( + [Buffer.from(idoName), Buffer.from("pool_usdc")], + program.programId + ); bumps.poolUsdc = poolUsdcBump; idoTimes = new IdoTimes(); - const nowBn = new anchor.BN(Date.now() / 1000); - idoTimes.startIdo = nowBn.add(new anchor.BN(5)); - idoTimes.endDeposits = nowBn.add(new anchor.BN(10)); - idoTimes.endIdo = nowBn.add(new anchor.BN(15)); - idoTimes.endEscrow = nowBn.add(new anchor.BN(16)); + const nowBn = new BN(Date.now() / 1000); + idoTimes.startIdo = nowBn.add(new BN(5)); + idoTimes.endDeposits = nowBn.add(new BN(10)); + idoTimes.endIdo = nowBn.add(new BN(15)); + idoTimes.endEscrow = nowBn.add(new BN(16)); await program.rpc.initializePool( idoName, bumps, - watermelonIdoAmount, + new BN(watermelonIdoAmount), idoTimes, { accounts: { @@ -122,7 +130,7 @@ describe("ido-pool", () => { redeemableMint, poolWatermelon, poolUsdc, - systemProgram: anchor.web3.SystemProgram.programId, + systemProgram: SystemProgram.programId, tokenProgram: TOKEN_PROGRAM_ID, }, } @@ -132,7 +140,7 @@ describe("ido-pool", () => { provider, idoAuthorityWatermelon ); - assert.isTrue(idoAuthorityWatermelonAccount.amount.eq(new anchor.BN(0))); + assert.equal(idoAuthorityWatermelonAccount.amount, BigInt(0)); }); // We're going to need to start using the associated program account for creating token accounts @@ -140,7 +148,7 @@ describe("ido-pool", () => { let userUsdc = null; // 10 usdc - const firstDeposit = new anchor.BN(10_000_349); + const firstDeposit = 10_000_349; it("Exchanges user USDC for redeemable tokens", async () => { // Wait until the IDO has opened. @@ -148,52 +156,42 @@ describe("ido-pool", () => { await sleep(idoTimes.startIdo.toNumber() * 1000 - Date.now() + 2000); } - const [idoAccount] = await anchor.web3.PublicKey.findProgramAddress( + const [idoAccount] = PublicKey.findProgramAddressSync( [Buffer.from(idoName)], program.programId ); - const [redeemableMint] = await anchor.web3.PublicKey.findProgramAddress( + const [redeemableMint] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("redeemable_mint")], program.programId ); - const [poolUsdc] = await anchor.web3.PublicKey.findProgramAddress( + const [poolUsdc] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("pool_usdc")], program.programId ); - userUsdc = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, + userUsdc = await getAssociatedTokenAddress( usdcMint, - program.provider.wallet.publicKey + provider.wallet.publicKey ); // Get the instructions to add to the RPC call - let createUserUsdcInstr = Token.createAssociatedTokenAccountInstruction( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, - usdcMint, - userUsdc, - program.provider.wallet.publicKey, - program.provider.wallet.publicKey - ); - let createUserUsdcTrns = new anchor.web3.Transaction().add( - createUserUsdcInstr - ); - await provider.sendAndConfirm(createUserUsdcTrns); - await usdcMintAccount.mintTo( + let createUserUsdcInstr = createAssociatedTokenAccountInstruction( + provider.wallet.publicKey, userUsdc, provider.wallet.publicKey, - [], - firstDeposit.toString() + usdcMint ); + let createUserUsdcTrns = new Transaction().add(createUserUsdcInstr); + await provider.sendAndConfirm(createUserUsdcTrns); + + await mintTo(connection, payer, usdcMint, userUsdc, payer, firstDeposit); // Check if we inited correctly userUsdcAccount = await getTokenAccount(provider, userUsdc); - assert.isTrue(userUsdcAccount.amount.eq(firstDeposit)); + assert.equal(userUsdcAccount.amount, BigInt(firstDeposit)); - const [userRedeemable] = await anchor.web3.PublicKey.findProgramAddress( + const [userRedeemable] = PublicKey.findProgramAddressSync( [ provider.wallet.publicKey.toBuffer(), Buffer.from(idoName), @@ -203,107 +201,107 @@ describe("ido-pool", () => { ); try { - const tx = await program.rpc.exchangeUsdcForRedeemable(firstDeposit, { - accounts: { - userAuthority: provider.wallet.publicKey, - userUsdc, - userRedeemable, - idoAccount, - usdcMint, - redeemableMint, - watermelonMint, - poolUsdc, - tokenProgram: TOKEN_PROGRAM_ID, - }, - instructions: [ - program.instruction.initUserRedeemable({ - accounts: { - userAuthority: provider.wallet.publicKey, - userRedeemable, - idoAccount, - redeemableMint, - systemProgram: anchor.web3.SystemProgram.programId, - tokenProgram: TOKEN_PROGRAM_ID, - }, - }), - ], - }); + const tx = await program.rpc.exchangeUsdcForRedeemable( + new anchor.BN(firstDeposit), + { + accounts: { + userAuthority: provider.wallet.publicKey, + userUsdc, + userRedeemable, + idoAccount, + usdcMint, + redeemableMint, + watermelonMint, + poolUsdc, + tokenProgram: TOKEN_PROGRAM_ID, + }, + instructions: [ + program.instruction.initUserRedeemable({ + accounts: { + userAuthority: provider.wallet.publicKey, + userRedeemable, + idoAccount, + redeemableMint, + systemProgram: SystemProgram.programId, + tokenProgram: TOKEN_PROGRAM_ID, + }, + }), + ], + } + ); } catch (err) { console.log("This is the error message", err.toString()); } poolUsdcAccount = await getTokenAccount(provider, poolUsdc); - assert.isTrue(poolUsdcAccount.amount.eq(firstDeposit)); + assert.equal(poolUsdcAccount.amount, BigInt(firstDeposit)); userRedeemableAccount = await getTokenAccount(provider, userRedeemable); - assert.isTrue(userRedeemableAccount.amount.eq(firstDeposit)); + assert.equal(userRedeemableAccount.amount, BigInt(firstDeposit)); }); // 23 usdc - const secondDeposit = new anchor.BN(23_000_672); + const secondDeposit = 23_000_672; let totalPoolUsdc, secondUserKeypair, secondUserUsdc; it("Exchanges a second users USDC for redeemable tokens", async () => { - const [idoAccount] = await anchor.web3.PublicKey.findProgramAddress( + const [idoAccount] = PublicKey.findProgramAddressSync( [Buffer.from(idoName)], program.programId ); - const [redeemableMint] = await anchor.web3.PublicKey.findProgramAddress( + const [redeemableMint] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("redeemable_mint")], program.programId ); - const [poolUsdc] = await anchor.web3.PublicKey.findProgramAddress( + const [poolUsdc] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("pool_usdc")], program.programId ); secondUserKeypair = anchor.web3.Keypair.generate(); - transferSolInstr = anchor.web3.SystemProgram.transfer({ + transferSolInstr = SystemProgram.transfer({ fromPubkey: provider.wallet.publicKey, lamports: 100_000_000_000, // 100 sol toPubkey: secondUserKeypair.publicKey, }); - secondUserUsdc = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, + secondUserUsdc = await getAssociatedTokenAddress( usdcMint, secondUserKeypair.publicKey ); - createSecondUserUsdcInstr = Token.createAssociatedTokenAccountInstruction( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, - usdcMint, + createSecondUserUsdcInstr = createAssociatedTokenAccountInstruction( + provider.wallet.publicKey, secondUserUsdc, secondUserKeypair.publicKey, - provider.wallet.publicKey + usdcMint ); - let createSecondUserUsdcTrns = new anchor.web3.Transaction(); + let createSecondUserUsdcTrns = new Transaction(); createSecondUserUsdcTrns.add(transferSolInstr); createSecondUserUsdcTrns.add(createSecondUserUsdcInstr); await provider.sendAndConfirm(createSecondUserUsdcTrns); - await usdcMintAccount.mintTo( + await mintTo( + connection, + payer, + usdcMint, secondUserUsdc, - provider.wallet.publicKey, - [], - secondDeposit.toString() + payer, + secondDeposit ); // Checking the transfer went through secondUserUsdcAccount = await getTokenAccount(provider, secondUserUsdc); - assert.isTrue(secondUserUsdcAccount.amount.eq(secondDeposit)); - - const [secondUserRedeemable] = - await anchor.web3.PublicKey.findProgramAddress( - [ - secondUserKeypair.publicKey.toBuffer(), - Buffer.from(idoName), - Buffer.from("user_redeemable"), - ], - program.programId - ); + assert.equal(secondUserUsdcAccount.amount, BigInt(secondDeposit)); + + const [secondUserRedeemable] = PublicKey.findProgramAddressSync( + [ + secondUserKeypair.publicKey.toBuffer(), + Buffer.from(idoName), + Buffer.from("user_redeemable"), + ], + program.programId + ); - await program.rpc.exchangeUsdcForRedeemable(secondDeposit, { + await program.rpc.exchangeUsdcForRedeemable(new BN(secondDeposit), { accounts: { userAuthority: secondUserKeypair.publicKey, userUsdc: secondUserUsdc, @@ -334,32 +332,32 @@ describe("ido-pool", () => { provider, secondUserRedeemable ); - assert.isTrue(secondUserRedeemableAccount.amount.eq(secondDeposit)); + assert.isTrue(secondUserRedeemableAccount.amount === BigInt(secondDeposit)); - totalPoolUsdc = firstDeposit.add(secondDeposit); + totalPoolUsdc = BigInt(firstDeposit) + BigInt(secondDeposit); poolUsdcAccount = await getTokenAccount(provider, poolUsdc); - assert.isTrue(poolUsdcAccount.amount.eq(totalPoolUsdc)); + assert.equal(poolUsdcAccount.amount, totalPoolUsdc); }); - const firstWithdrawal = new anchor.BN(2_000_000); + const firstWithdrawal = 2_000_000; it("Exchanges user Redeemable tokens for USDC", async () => { - const [idoAccount] = await anchor.web3.PublicKey.findProgramAddress( + const [idoAccount] = PublicKey.findProgramAddressSync( [Buffer.from(idoName)], program.programId ); - const [redeemableMint] = await anchor.web3.PublicKey.findProgramAddress( + const [redeemableMint] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("redeemable_mint")], program.programId ); - const [poolUsdc] = await anchor.web3.PublicKey.findProgramAddress( + const [poolUsdc] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("pool_usdc")], program.programId ); - const [userRedeemable] = await anchor.web3.PublicKey.findProgramAddress( + const [userRedeemable] = PublicKey.findProgramAddressSync( [ provider.wallet.publicKey.toBuffer(), Buffer.from(idoName), @@ -368,7 +366,7 @@ describe("ido-pool", () => { program.programId ); - const [escrowUsdc] = await anchor.web3.PublicKey.findProgramAddress( + const [escrowUsdc] = PublicKey.findProgramAddressSync( [ provider.wallet.publicKey.toBuffer(), Buffer.from(idoName), @@ -377,7 +375,7 @@ describe("ido-pool", () => { program.programId ); - await program.rpc.exchangeRedeemableForUsdc(firstWithdrawal, { + await program.rpc.exchangeRedeemableForUsdc(new BN(firstWithdrawal), { accounts: { userAuthority: provider.wallet.publicKey, escrowUsdc, @@ -396,18 +394,18 @@ describe("ido-pool", () => { escrowUsdc, idoAccount, usdcMint, - systemProgram: anchor.web3.SystemProgram.programId, + systemProgram: SystemProgram.programId, tokenProgram: TOKEN_PROGRAM_ID, }, }), ], }); - totalPoolUsdc = totalPoolUsdc.sub(firstWithdrawal); + totalPoolUsdc = totalPoolUsdc - BigInt(firstWithdrawal); poolUsdcAccount = await getTokenAccount(provider, poolUsdc); - assert.isTrue(poolUsdcAccount.amount.eq(totalPoolUsdc)); + assert.equal(poolUsdcAccount.amount, totalPoolUsdc); escrowUsdcAccount = await getTokenAccount(provider, escrowUsdc); - assert.isTrue(escrowUsdcAccount.amount.eq(firstWithdrawal)); + assert.equal(escrowUsdcAccount.amount, BigInt(firstWithdrawal)); }); it("Exchanges user Redeemable tokens for watermelon", async () => { @@ -416,22 +414,22 @@ describe("ido-pool", () => { await sleep(idoTimes.endIdo.toNumber() * 1000 - Date.now() + 3000); } - const [idoAccount] = await anchor.web3.PublicKey.findProgramAddress( + const [idoAccount] = PublicKey.findProgramAddressSync( [Buffer.from(idoName)], program.programId ); - const [poolWatermelon] = await anchor.web3.PublicKey.findProgramAddress( + const [poolWatermelon] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("pool_watermelon")], program.programId ); - const [redeemableMint] = await anchor.web3.PublicKey.findProgramAddress( + const [redeemableMint] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("redeemable_mint")], program.programId ); - const [userRedeemable] = await anchor.web3.PublicKey.findProgramAddress( + const [userRedeemable] = PublicKey.findProgramAddressSync( [ provider.wallet.publicKey.toBuffer(), Buffer.from(idoName), @@ -440,7 +438,7 @@ describe("ido-pool", () => { program.programId ); - let firstUserRedeemable = firstDeposit.sub(firstWithdrawal); + let firstUserRedeemable = BigInt(firstDeposit) - BigInt(firstWithdrawal); // TODO we've been lazy here and not used an ATA as we did with USDC userWatermelon = await createTokenAccount( provider, @@ -448,52 +446,53 @@ describe("ido-pool", () => { provider.wallet.publicKey ); - await program.rpc.exchangeRedeemableForWatermelon(firstUserRedeemable, { - accounts: { - payer: provider.wallet.publicKey, - userAuthority: provider.wallet.publicKey, - userWatermelon, - userRedeemable, - idoAccount, - watermelonMint, - redeemableMint, - poolWatermelon, - tokenProgram: TOKEN_PROGRAM_ID, - }, - }); + await program.rpc.exchangeRedeemableForWatermelon( + new BN(firstUserRedeemable.valueOf()), + { + accounts: { + payer: provider.wallet.publicKey, + userAuthority: provider.wallet.publicKey, + userWatermelon, + userRedeemable, + idoAccount, + watermelonMint, + redeemableMint, + poolWatermelon, + tokenProgram: TOKEN_PROGRAM_ID, + }, + } + ); poolWatermelonAccount = await getTokenAccount(provider, poolWatermelon); - let redeemedWatermelon = firstUserRedeemable - .mul(watermelonIdoAmount) - .div(totalPoolUsdc); - let remainingWatermelon = watermelonIdoAmount.sub(redeemedWatermelon); - assert.isTrue(poolWatermelonAccount.amount.eq(remainingWatermelon)); + let redeemedWatermelon = + (firstUserRedeemable * BigInt(watermelonIdoAmount)) / totalPoolUsdc; + let remainingWatermelon = BigInt(watermelonIdoAmount) - redeemedWatermelon; + assert.equal(poolWatermelonAccount.amount, remainingWatermelon); userWatermelonAccount = await getTokenAccount(provider, userWatermelon); - assert.isTrue(userWatermelonAccount.amount.eq(redeemedWatermelon)); + assert.equal(userWatermelonAccount.amount, redeemedWatermelon); }); it("Exchanges second user's Redeemable tokens for watermelon", async () => { - const [idoAccount] = await anchor.web3.PublicKey.findProgramAddress( + const [idoAccount] = PublicKey.findProgramAddressSync( [Buffer.from(idoName)], program.programId ); - const [redeemableMint] = await anchor.web3.PublicKey.findProgramAddress( + const [redeemableMint] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("redeemable_mint")], program.programId ); - const [secondUserRedeemable] = - await anchor.web3.PublicKey.findProgramAddress( - [ - secondUserKeypair.publicKey.toBuffer(), - Buffer.from(idoName), - Buffer.from("user_redeemable"), - ], - program.programId - ); + const [secondUserRedeemable] = PublicKey.findProgramAddressSync( + [ + secondUserKeypair.publicKey.toBuffer(), + Buffer.from(idoName), + Buffer.from("user_redeemable"), + ], + program.programId + ); - const [poolWatermelon] = await anchor.web3.PublicKey.findProgramAddress( + const [poolWatermelon] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("pool_watermelon")], program.programId ); @@ -504,7 +503,7 @@ describe("ido-pool", () => { secondUserKeypair.publicKey ); - await program.rpc.exchangeRedeemableForWatermelon(secondDeposit, { + await program.rpc.exchangeRedeemableForWatermelon(new BN(secondDeposit), { accounts: { payer: provider.wallet.publicKey, userAuthority: secondUserKeypair.publicKey, @@ -519,16 +518,16 @@ describe("ido-pool", () => { }); poolWatermelonAccount = await getTokenAccount(provider, poolWatermelon); - assert.isTrue(poolWatermelonAccount.amount.eq(new anchor.BN(0))); + assert.isTrue(poolWatermelonAccount.amount === BigInt(0)); }); it("Withdraws total USDC from pool account", async () => { - const [idoAccount] = await anchor.web3.PublicKey.findProgramAddress( + const [idoAccount] = PublicKey.findProgramAddressSync( [Buffer.from(idoName)], program.programId ); - const [poolUsdc] = await anchor.web3.PublicKey.findProgramAddress( + const [poolUsdc] = PublicKey.findProgramAddressSync( [Buffer.from(idoName), Buffer.from("pool_usdc")], program.programId ); @@ -546,9 +545,9 @@ describe("ido-pool", () => { }); poolUsdcAccount = await getTokenAccount(provider, poolUsdc); - assert.isTrue(poolUsdcAccount.amount.eq(new anchor.BN(0))); + assert.isTrue(poolUsdcAccount.amount === BigInt(0)); idoAuthorityUsdcAccount = await getTokenAccount(provider, idoAuthorityUsdc); - assert.isTrue(idoAuthorityUsdcAccount.amount.eq(totalPoolUsdc)); + assert.isTrue(idoAuthorityUsdcAccount.amount === BigInt(totalPoolUsdc)); }); it("Withdraws USDC from the escrow account after waiting period is over", async () => { @@ -557,12 +556,12 @@ describe("ido-pool", () => { await sleep(idoTimes.endEscrow.toNumber() * 1000 - Date.now() + 4000); } - const [idoAccount] = await anchor.web3.PublicKey.findProgramAddress( + const [idoAccount] = PublicKey.findProgramAddressSync( [Buffer.from(idoName)], program.programId ); - const [escrowUsdc] = await anchor.web3.PublicKey.findProgramAddress( + const [escrowUsdc] = PublicKey.findProgramAddressSync( [ provider.wallet.publicKey.toBuffer(), Buffer.from(idoName), @@ -571,7 +570,7 @@ describe("ido-pool", () => { program.programId ); - await program.rpc.withdrawFromEscrow(firstWithdrawal, { + await program.rpc.withdrawFromEscrow(new BN(firstWithdrawal), { accounts: { payer: provider.wallet.publicKey, userAuthority: provider.wallet.publicKey, @@ -584,7 +583,7 @@ describe("ido-pool", () => { }); userUsdcAccount = await getTokenAccount(provider, userUsdc); - assert.isTrue(userUsdcAccount.amount.eq(firstWithdrawal)); + assert.equal(userUsdcAccount.amount, BigInt(firstWithdrawal)); }); function PoolBumps() { diff --git a/tests/ido-pool/tests/utils/index.js b/tests/ido-pool/tests/utils/index.js index c96b9bfb24..e63457276e 100644 --- a/tests/ido-pool/tests/utils/index.js +++ b/tests/ido-pool/tests/utils/index.js @@ -1,13 +1,10 @@ -const spl = require("@solana/spl-token"); -const anchor = require("@coral-xyz/anchor"); -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() -); +const { + TOKEN_PROGRAM_ID, + getAccount, + createMint, + createAccount, +} = require("@solana/spl-token"); +const { Keypair } = require("@solana/web3.js"); // Our own sleep function. function sleep(ms) { @@ -16,39 +13,37 @@ function sleep(ms) { } async function getTokenAccount(provider, addr) { - return await serumCmn.getTokenAccount(provider, addr); + return await getAccount(provider.connection, addr); } -async function createMint(provider, authority) { +async function createTokenMint(provider, authority) { if (authority === undefined) { authority = provider.wallet.publicKey; } - const mint = await spl.Token.createMint( + const mint = await createMint( provider.connection, provider.wallet.payer, authority, null, - 6, - TOKEN_PROGRAM_ID + 6 ); return mint; } async function createTokenAccount(provider, mint, owner) { - const token = new spl.Token( + let vault = await createAccount( provider.connection, + provider.wallet.payer, mint, - TOKEN_PROGRAM_ID, - provider.wallet.payer + owner, + Keypair.generate() ); - let vault = await token.createAccount(owner); return vault; } module.exports = { - TOKEN_PROGRAM_ID, sleep, getTokenAccount, createTokenAccount, - createMint, + createTokenMint, }; diff --git a/tests/misc/tests/misc/misc.ts b/tests/misc/tests/misc/misc.ts index 257f3507cc..d649c9e414 100644 --- a/tests/misc/tests/misc/misc.ts +++ b/tests/misc/tests/misc/misc.ts @@ -11,8 +11,14 @@ import { } from "@solana/web3.js"; import { TOKEN_PROGRAM_ID, - Token, ASSOCIATED_TOKEN_PROGRAM_ID, + TOKEN_2022_PROGRAM_ID, + createMint, + getAssociatedTokenAddressSync, + getAccount, + getMint, + setAuthority, + AuthorityType, AccountLayout, MintLayout, } from "@solana/spl-token"; @@ -25,10 +31,6 @@ const utf8 = anchor.utils.bytes.utf8; const nativeAssert = require("assert"); const miscIdl = require("../../target/idl/misc.json"); -const TOKEN_2022_PROGRAM_ID = new anchor.web3.PublicKey( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" -); - const miscTest = ( program: anchor.Program | anchor.Program ) => { @@ -37,6 +39,7 @@ const miscTest = ( const provider = anchor.AnchorProvider.env(); const wallet = provider.wallet as Wallet; anchor.setProvider(provider); + const connection = provider.connection; describe("Data Account", () => { const data = anchor.web3.Keypair.generate(); @@ -535,11 +538,11 @@ const miscTest = ( }); it("Can create a token account from seeds pda", async () => { - const [mint, mint_bump] = await PublicKey.findProgramAddress( + const [mint] = PublicKey.findProgramAddressSync( [Buffer.from(anchor.utils.bytes.utf8.encode("my-mint-seed"))], program.programId ); - const [myPda, token_bump] = await PublicKey.findProgramAddress( + const [myPda] = PublicKey.findProgramAddressSync( [Buffer.from(anchor.utils.bytes.utf8.encode("my-token-seed"))], program.programId ); @@ -553,16 +556,9 @@ const miscTest = ( }, }); - const mintAccount = new Token( - program.provider.connection, - mint, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const account = await mintAccount.getAccountInfo(myPda); - // @ts-expect-error - assert.strictEqual(account.state, 1); - assert.strictEqual(account.amount.toNumber(), 0); + const account = await getAccount(connection, myPda); + // assert.strictEqual(account.state, 1); + assert.strictEqual(account.amount, BigInt(0)); assert.isTrue(account.isInitialized); assert.isTrue(account.owner.equals(provider.wallet.publicKey)); assert.isTrue(account.mint.equals(mint)); @@ -661,13 +657,13 @@ const miscTest = ( }, signers: [mint], }); - const client = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const mintAccount = await client.getMintInfo(); + // const client = new Token( + // program.provider.connection, + // mint.publicKey, + // TOKEN_PROGRAM_ID, + // wallet.payer + // ); + const mintAccount = await getMint(connection, mint.publicKey); assert.strictEqual(mintAccount.decimals, 6); assert.isTrue( mintAccount.mintAuthority.equals(provider.wallet.publicKey) @@ -695,13 +691,8 @@ const miscTest = ( }), ], }); - const client = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const mintAccount = await client.getMintInfo(); + + const mintAccount = await getMint(connection, mint.publicKey); assert.strictEqual(mintAccount.decimals, 6); assert.isTrue( mintAccount.mintAuthority.equals(provider.wallet.publicKey) @@ -720,16 +711,10 @@ const miscTest = ( }, signers: [token], }); - const client = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const account = await client.getAccountInfo(token.publicKey); - // @ts-expect-error - assert.strictEqual(account.state, 1); - assert.strictEqual(account.amount.toNumber(), 0); + + const account = await getAccount(connection, token.publicKey); + // assert.strictEqual(account.state, 1); + assert.strictEqual(account.amount, BigInt(0)); assert.isTrue(account.isInitialized); assert.isTrue(account.owner.equals(provider.wallet.publicKey)); assert.isTrue(account.mint.equals(mint.publicKey)); @@ -754,16 +739,9 @@ const miscTest = ( }), ], }); - const client = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const account = await client.getAccountInfo(token.publicKey); - // @ts-expect-error - assert.strictEqual(account.state, 1); - assert.strictEqual(account.amount.toNumber(), 0); + const account = await getAccount(connection, token.publicKey); + // assert.strictEqual(account.state, 1); + assert.strictEqual(account.amount, BigInt(0)); assert.isTrue(account.isInitialized); assert.isTrue(account.owner.equals(provider.wallet.publicKey)); assert.isTrue(account.mint.equals(mint.publicKey)); @@ -788,16 +766,9 @@ const miscTest = ( }), ], }); - const client = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const account = await client.getAccountInfo(token.publicKey); - // @ts-expect-error - assert.strictEqual(account.state, 1); - assert.strictEqual(account.amount.toNumber(), 0); + const account = await getAccount(connection, token.publicKey); + // assert.strictEqual(account.state, 1); + assert.strictEqual(account.amount, BigInt(0)); assert.isTrue(account.isInitialized); assert.isTrue(account.owner.equals(provider.wallet.publicKey)); assert.isTrue(account.mint.equals(mint.publicKey)); @@ -809,7 +780,7 @@ const miscTest = ( const tx = await program.methods .testCompositePayer() - .accounts({ + .accountsPartial({ composite: { data: data1.publicKey, payer: provider.wallet.publicKey, @@ -877,7 +848,7 @@ const miscTest = ( ); const ataAccount = AccountLayout.decode(rawAccount.data); assert.strictEqual(ataAccount.state, 1); - assert.strictEqual(new anchor.BN(ataAccount.amount).toNumber(), 0); + assert.strictEqual(ataAccount.amount, BigInt(0)); assert.strictEqual( new PublicKey(ataAccount.owner).toString(), provider.wallet.publicKey.toString() @@ -891,28 +862,26 @@ const miscTest = ( describe("associated_token constraints", () => { let associatedToken = null; // apparently cannot await here so doing it in the 'it' statements - let client = Token.createMint( + + const client = createMint( program.provider.connection, wallet.payer, provider.wallet.publicKey, provider.wallet.publicKey, - 9, - TOKEN_PROGRAM_ID + 9 ); it("Can create an associated token account", async () => { const localClient = await client; - associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, - localClient.publicKey, + associatedToken = getAssociatedTokenAddressSync( + localClient, provider.wallet.publicKey ); await program.rpc.testInitAssociatedToken({ accounts: { token: associatedToken, - mint: localClient.publicKey, + mint: localClient, payer: provider.wallet.publicKey, systemProgram: anchor.web3.SystemProgram.programId, tokenProgram: TOKEN_PROGRAM_ID, @@ -920,13 +889,12 @@ const miscTest = ( }, }); - const account = await localClient.getAccountInfo(associatedToken); - // @ts-expect-error - assert.strictEqual(account.state, 1); - assert.strictEqual(account.amount.toNumber(), 0); + const account = await getAccount(connection, associatedToken); + // assert.strictEqual(account.state, 1); + assert.strictEqual(account.amount, BigInt(0)); assert.isTrue(account.isInitialized); assert.isTrue(account.owner.equals(provider.wallet.publicKey)); - assert.isTrue(account.mint.equals(localClient.publicKey)); + assert.isTrue(account.mint.equals(localClient)); }); it("Can create an associated token account with token program", async () => { @@ -941,11 +909,11 @@ const miscTest = ( signers: [newMint], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_2022_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( newMint.publicKey, - provider.wallet.publicKey + provider.wallet.publicKey, + false, + TOKEN_2022_PROGRAM_ID ); await program.rpc.testInitAssociatedTokenWithTokenProgram({ @@ -964,7 +932,7 @@ const miscTest = ( ); const ataAccount = AccountLayout.decode(rawAta.data); assert.strictEqual(ataAccount.state, 1); - assert.strictEqual(new anchor.BN(ataAccount.amount).toNumber(), 0); + assert.strictEqual(ataAccount.amount, BigInt(0)); assert.strictEqual( new PublicKey(ataAccount.owner).toString(), provider.wallet.publicKey.toString() @@ -1000,18 +968,17 @@ const miscTest = ( await program.rpc.testValidateAssociatedToken({ accounts: { token: associatedToken, - mint: localClient.publicKey, + mint: localClient, wallet: provider.wallet.publicKey, }, }); - let otherMint = await Token.createMint( - program.provider.connection, + const otherMint = await createMint( + connection, wallet.payer, provider.wallet.publicKey, provider.wallet.publicKey, - 9, - TOKEN_PROGRAM_ID + 9 ); await nativeAssert.rejects( @@ -1019,7 +986,7 @@ const miscTest = ( await program.rpc.testValidateAssociatedToken({ accounts: { token: associatedToken, - mint: otherMint.publicKey, + mint: otherMint, wallet: provider.wallet.publicKey, }, }); @@ -1036,17 +1003,18 @@ const miscTest = ( await program.rpc.testValidateAssociatedToken({ accounts: { token: associatedToken, - mint: localClient.publicKey, + mint: localClient, wallet: provider.wallet.publicKey, }, }); - await localClient.setAuthority( + await setAuthority( + connection, + wallet.payer, associatedToken, - anchor.web3.Keypair.generate().publicKey, - "AccountOwner", wallet.payer, - [] + AuthorityType.AccountOwner, + anchor.web3.Keypair.generate().publicKey ); await nativeAssert.rejects( @@ -1054,7 +1022,7 @@ const miscTest = ( await program.rpc.testValidateAssociatedToken({ accounts: { token: associatedToken, - mint: localClient.publicKey, + mint: localClient, wallet: provider.wallet.publicKey, }, }); @@ -1078,11 +1046,11 @@ const miscTest = ( signers: [mint], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_2022_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( mint.publicKey, - provider.wallet.publicKey + provider.wallet.publicKey, + false, + TOKEN_2022_PROGRAM_ID ); await program.rpc.testInitAssociatedTokenWithTokenProgram({ @@ -1126,9 +1094,7 @@ const miscTest = ( signers: [mint], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( mint.publicKey, provider.wallet.publicKey ); @@ -1384,14 +1350,7 @@ const miscTest = ( signers: [newMint], }); - const mintClient = new Token( - provider.connection, - newMint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - - const mintAccount = await mintClient.getMintInfo(); + const mintAccount = await getMint(provider.connection, newMint.publicKey); assert.strictEqual(mintAccount.decimals, 6); assert.strictEqual( mintAccount.mintAuthority.toString(), @@ -1401,7 +1360,7 @@ const miscTest = ( mintAccount.freezeAuthority.toString(), provider.wallet.publicKey.toString() ); - assert.strictEqual(mintAccount.supply.toNumber(), 0); + assert.strictEqual(mintAccount.supply, BigInt(0)); const rawAccount = await provider.connection.getAccountInfo( newMint.publicKey ); @@ -1426,14 +1385,8 @@ const miscTest = ( signers: [newMint], }); - const mintClient = new Token( - provider.connection, - newMint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); + const mintAccount = await getMint(provider.connection, newMint.publicKey); - const mintAccount = await mintClient.getMintInfo(); assert.strictEqual(mintAccount.decimals, 6); assert.strictEqual( mintAccount.mintAuthority.toString(), @@ -1443,7 +1396,7 @@ const miscTest = ( mintAccount.freezeAuthority.toString(), provider.wallet.publicKey.toString() ); - assert.strictEqual(mintAccount.supply.toNumber(), 0); + assert.strictEqual(mintAccount.supply, BigInt(0)); const rawAccount = await provider.connection.getAccountInfo( newMint.publicKey ); @@ -1477,14 +1430,11 @@ const miscTest = ( }, signers: [newToken], }); - const mintClient = new Token( + const tokenAccount = await getAccount( provider.connection, - newMint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer + newToken.publicKey ); - const tokenAccount = await mintClient.getAccountInfo(newToken.publicKey); - assert.strictEqual(tokenAccount.amount.toNumber(), 0); + assert.strictEqual(tokenAccount.amount, BigInt(0)); assert.strictEqual( tokenAccount.mint.toString(), newMint.publicKey.toString() @@ -1531,7 +1481,7 @@ const miscTest = ( newToken.publicKey ); const ataAccount = AccountLayout.decode(rawAccount.data); - assert.strictEqual(new anchor.BN(ataAccount.amount).toNumber(), 0); + assert.strictEqual(ataAccount.amount, BigInt(0)); assert.strictEqual( new PublicKey(ataAccount.mint).toString(), newMint.publicKey.toString() @@ -1559,9 +1509,7 @@ const miscTest = ( signers: [newMint], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( newMint.publicKey, provider.wallet.publicKey ); @@ -1578,14 +1526,8 @@ const miscTest = ( }, }); - const mintClient = new Token( - provider.connection, - newMint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const ataAccount = await mintClient.getAccountInfo(associatedToken); - assert.strictEqual(ataAccount.amount.toNumber(), 0); + const ataAccount = await getAccount(provider.connection, associatedToken); + assert.strictEqual(ataAccount.amount, BigInt(0)); assert.strictEqual( ataAccount.mint.toString(), newMint.publicKey.toString() @@ -1615,11 +1557,11 @@ const miscTest = ( signers: [newMint], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_2022_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( newMint.publicKey, - provider.wallet.publicKey + provider.wallet.publicKey, + false, + TOKEN_2022_PROGRAM_ID ); await program.rpc.testInitAssociatedTokenIfNeededWithTokenProgram({ @@ -1638,7 +1580,7 @@ const miscTest = ( associatedToken ); const ataAccount = AccountLayout.decode(rawAccount.data); - assert.strictEqual(new anchor.BN(ataAccount.amount).toNumber(), 0); + assert.strictEqual(ataAccount.amount, BigInt(0)); assert.strictEqual( new PublicKey(ataAccount.mint).toString(), newMint.publicKey.toString() @@ -2106,9 +2048,7 @@ const miscTest = ( signers: [mint], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( mint.publicKey, provider.wallet.publicKey ); @@ -2167,9 +2107,7 @@ const miscTest = ( signers: [mint2], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( mint.publicKey, provider.wallet.publicKey ); @@ -2217,9 +2155,7 @@ const miscTest = ( signers: [mint], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( mint.publicKey, provider.wallet.publicKey ); @@ -2281,9 +2217,7 @@ const miscTest = ( signers: [mint], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( mint.publicKey, provider.wallet.publicKey ); @@ -2324,11 +2258,11 @@ const miscTest = ( signers: [mint], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_2022_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( mint.publicKey, - provider.wallet.publicKey + provider.wallet.publicKey, + false, + TOKEN_2022_PROGRAM_ID ); await program.rpc.testInitAssociatedTokenWithTokenProgram({ @@ -2367,9 +2301,7 @@ const miscTest = ( signers: [mint], }); - const associatedToken = await Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, + const associatedToken = getAssociatedTokenAddressSync( mint.publicKey, provider.wallet.publicKey ); @@ -2463,12 +2395,12 @@ const miscTest = ( describe("Can validate PDAs derived from other program ids", () => { it("With bumps using create_program_address", async () => { const [firstPDA, firstBump] = - await anchor.web3.PublicKey.findProgramAddress( + anchor.web3.PublicKey.findProgramAddressSync( [anchor.utils.bytes.utf8.encode("seed")], ASSOCIATED_TOKEN_PROGRAM_ID ); const [secondPDA, secondBump] = - await anchor.web3.PublicKey.findProgramAddress( + anchor.web3.PublicKey.findProgramAddressSync( [anchor.utils.bytes.utf8.encode("seed")], program.programId ); @@ -2599,15 +2531,9 @@ const miscTest = ( payer: provider.wallet.publicKey, }, }); - const mintAccount = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const account = await mintAccount.getAccountInfo(token.publicKey); - assert.isTrue(account.owner.equals(provider.wallet.publicKey)); - assert.isTrue(account.mint.equals(mint.publicKey)); + const mintAccount = await getAccount(connection, token.publicKey); + assert.isTrue(mintAccount.owner.equals(provider.wallet.publicKey)); + assert.isTrue(mintAccount.mint.equals(mint.publicKey)); }); it("Token Constraint Test(no init) - Can make only token::authority", async () => { @@ -2640,13 +2566,8 @@ const miscTest = ( payer: provider.wallet.publicKey, }, }); - const mintAccount = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const account = await mintAccount.getAccountInfo(token.publicKey); + + const account = await getAccount(connection, token.publicKey); assert.isTrue(account.owner.equals(provider.wallet.publicKey)); }); @@ -2679,13 +2600,8 @@ const miscTest = ( mint: mint.publicKey, }, }); - const mintAccount = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const account = await mintAccount.getAccountInfo(token.publicKey); + + const account = await getAccount(connection, token.publicKey); assert.isTrue(account.mint.equals(mint.publicKey)); }); @@ -2718,10 +2634,7 @@ const miscTest = ( tokenTokenProgram: TOKEN_PROGRAM_ID, }, }); - - const account = await provider.connection.getAccountInfo( - token.publicKey - ); + const account = await connection.getAccountInfo(token.publicKey); assert.strictEqual( account.owner.toString(), TOKEN_PROGRAM_ID.toString() @@ -2929,13 +2842,7 @@ const miscTest = ( freezeAuthority: provider.wallet.publicKey, }, }); - const client = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const mintAccount = await client.getMintInfo(); + const mintAccount = await getMint(connection, mint.publicKey); assert.strictEqual(mintAccount.decimals, 6); assert.isTrue( mintAccount.mintAuthority.equals(provider.wallet.publicKey) @@ -3092,13 +2999,8 @@ const miscTest = ( mint: mint.publicKey, }, }); - const client = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const mintAccount = await client.getMintInfo(); + const mintAccount = await getMint(connection, mint.publicKey); + assert.strictEqual(mintAccount.decimals, 6); }); @@ -3121,13 +3023,7 @@ const miscTest = ( freezeAuthority: provider.wallet.publicKey, }, }); - const client = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const mintAccount = await client.getMintInfo(); + const mintAccount = await getMint(connection, mint.publicKey); assert.isTrue( mintAccount.mintAuthority.equals(provider.wallet.publicKey) ); @@ -3154,13 +3050,8 @@ const miscTest = ( mintAuthority: provider.wallet.publicKey, }, }); - const client = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const mintAccount = await client.getMintInfo(); + + const mintAccount = await getMint(connection, mint.publicKey); assert.isTrue( mintAccount.mintAuthority.equals(provider.wallet.publicKey) ); @@ -3184,13 +3075,8 @@ const miscTest = ( freezeAuthority: provider.wallet.publicKey, }, }); - const client = new Token( - program.provider.connection, - mint.publicKey, - TOKEN_PROGRAM_ID, - wallet.payer - ); - const mintAccount = await client.getMintInfo(); + + const mintAccount = await getMint(connection, mint.publicKey); assert.strictEqual(mintAccount.decimals, 6); assert.isTrue( mintAccount.freezeAuthority.equals(provider.wallet.publicKey) diff --git a/tests/misc/tests/remaining-accounts/remaining-accounts.ts b/tests/misc/tests/remaining-accounts/remaining-accounts.ts index b3160fc60c..5967bb3e07 100644 --- a/tests/misc/tests/remaining-accounts/remaining-accounts.ts +++ b/tests/misc/tests/remaining-accounts/remaining-accounts.ts @@ -1,7 +1,10 @@ import * as anchor from "@coral-xyz/anchor"; import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet"; -import { TOKEN_PROGRAM_ID, Token } from "@solana/spl-token"; +import { + createWrappedNativeAccount, + TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; import { assert } from "chai"; import { RemainingAccounts } from "../../target/types/remaining_accounts"; @@ -20,12 +23,15 @@ describe("remaining-accounts", () => { .accounts({ data: data.publicKey }) .signers([data]) .rpc(); - const ata = await Token.createWrappedNativeAccount( + + const ata = await createWrappedNativeAccount( program.provider.connection, - TOKEN_PROGRAM_ID, - payer.publicKey, payer, - 0 + payer.publicKey, + 0, + undefined, + undefined, + TOKEN_PROGRAM_ID ); // Data is not initialized diff --git a/tests/multiple-suites-run-single/tsconfig.json b/tests/multiple-suites-run-single/tsconfig.json index b3b6656d38..3c43903cfd 100644 --- a/tests/multiple-suites-run-single/tsconfig.json +++ b/tests/multiple-suites-run-single/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/multiple-suites/tsconfig.json b/tests/multiple-suites/tsconfig.json index b3b6656d38..3c43903cfd 100644 --- a/tests/multiple-suites/tsconfig.json +++ b/tests/multiple-suites/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/optional/tsconfig.json b/tests/optional/tsconfig.json index 35eaf7330e..3c43903cfd 100644 --- a/tests/optional/tsconfig.json +++ b/tests/optional/tsconfig.json @@ -1,12 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true, - "strict": true - } + "extends": "../tsconfig.json" } diff --git a/tests/package.json b/tests/package.json index 55d0e6ba6a..42d65b4e9d 100644 --- a/tests/package.json +++ b/tests/package.json @@ -54,10 +54,8 @@ "solang" ], "dependencies": { - "@project-serum/common": "^0.0.1-beta.3", - "@project-serum/serum": "^0.13.60", - "@solana/spl-token": "^0.1.8", - "@solana/web3.js": "^1.68.0" + "@solana/spl-token": "^0.4.9", + "@solana/web3.js": "^1.98.0" }, "devDependencies": { "@types/bn.js": "^5.1.1", @@ -69,6 +67,6 @@ "prettier": "^2.5.1", "ts-mocha": "^10.0.0", "tsc": "^2.0.4", - "typescript": "^4.4.4" + "typescript": "^5.7.2" } } diff --git a/tests/pda-derivation/tsconfig.json b/tests/pda-derivation/tsconfig.json index f6f918b7ec..3c43903cfd 100644 --- a/tests/pda-derivation/tsconfig.json +++ b/tests/pda-derivation/tsconfig.json @@ -1,12 +1,3 @@ { - "include": ["./target/types/pda_derivation.ts"], - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/pyth/tsconfig.json b/tests/pyth/tsconfig.json index cd5d2e3d06..3c43903cfd 100644 --- a/tests/pyth/tsconfig.json +++ b/tests/pyth/tsconfig.json @@ -1,10 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true - } + "extends": "../tsconfig.json" } diff --git a/tests/realloc/tests/realloc.ts b/tests/realloc/tests/realloc.ts index 34aa2daac2..c774f3e7e3 100644 --- a/tests/realloc/tests/realloc.ts +++ b/tests/realloc/tests/realloc.ts @@ -23,7 +23,7 @@ describe("realloc", () => { it("initialized", async () => { await program.methods .initialize() - .accounts({ authority: authority.publicKey, sample }) + .accountsPartial({ authority: authority.publicKey, sample }) .rpc(); const samples = await program.account.sample.all(); @@ -35,7 +35,7 @@ describe("realloc", () => { try { await program.methods .realloc(10250) - .accounts({ authority: authority.publicKey, sample }) + .accountsPartial({ authority: authority.publicKey, sample }) .rpc(); assert.ok(false); } catch (e) { @@ -51,7 +51,7 @@ describe("realloc", () => { it("realloc additive", async () => { await program.methods .realloc(5) - .accounts({ authority: authority.publicKey, sample }) + .accountsPartial({ authority: authority.publicKey, sample }) .rpc(); const s = await program.account.sample.fetch(sample); @@ -61,7 +61,7 @@ describe("realloc", () => { it("realloc substractive", async () => { await program.methods .realloc(1) - .accounts({ authority: authority.publicKey, sample }) + .accountsPartial({ authority: authority.publicKey, sample }) .rpc(); const s = await program.account.sample.fetch(sample); @@ -72,7 +72,7 @@ describe("realloc", () => { try { await program.methods .realloc2(1000) - .accounts({ + .accountsPartial({ authority: authority.publicKey, sample1: sample, sample2: sample, diff --git a/tests/realloc/tsconfig.json b/tests/realloc/tsconfig.json index cd5d2e3d06..3c43903cfd 100644 --- a/tests/realloc/tsconfig.json +++ b/tests/realloc/tsconfig.json @@ -1,10 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true - } + "extends": "../tsconfig.json" } diff --git a/tests/relations-derivation/tsconfig.json b/tests/relations-derivation/tsconfig.json index 3cc6b3ac71..3c43903cfd 100644 --- a/tests/relations-derivation/tsconfig.json +++ b/tests/relations-derivation/tsconfig.json @@ -1,12 +1,3 @@ { - "include": ["./target/types/relations_derivation.ts"], - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/safety-checks/tsconfig.json b/tests/safety-checks/tsconfig.json index cd5d2e3d06..4082f16a5d 100644 --- a/tests/safety-checks/tsconfig.json +++ b/tests/safety-checks/tsconfig.json @@ -1,10 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true - } + "extends": "../../tsconfig.json" } diff --git a/tests/solang/tsconfig.json b/tests/solang/tsconfig.json index b3b6656d38..3c43903cfd 100644 --- a/tests/solang/tsconfig.json +++ b/tests/solang/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/spl/token-extensions/tests/token-extensions.ts b/tests/spl/token-extensions/tests/token-extensions.ts index f2b498d953..e8d2d5b7cb 100644 --- a/tests/spl/token-extensions/tests/token-extensions.ts +++ b/tests/spl/token-extensions/tests/token-extensions.ts @@ -1,13 +1,12 @@ import * as anchor from "@coral-xyz/anchor"; import { Program } from "@coral-xyz/anchor"; -import { PublicKey, Keypair } from "@solana/web3.js"; +import { PublicKey, Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js"; import { TokenExtensions } from "../target/types/token_extensions"; -import { ASSOCIATED_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; import { it } from "node:test"; - -const TOKEN_2022_PROGRAM_ID = new anchor.web3.PublicKey( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" -); +import { + TOKEN_2022_PROGRAM_ID, + ASSOCIATED_TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; export function associatedAddress({ mint, @@ -18,7 +17,7 @@ export function associatedAddress({ }): PublicKey { return PublicKey.findProgramAddressSync( [owner.toBuffer(), TOKEN_2022_PROGRAM_ID.toBuffer(), mint.toBuffer()], - ASSOCIATED_PROGRAM_ID + ASSOCIATED_TOKEN_PROGRAM_ID )[0]; } @@ -32,7 +31,10 @@ describe("token extensions", () => { it("airdrop payer", async () => { await provider.connection.confirmTransaction( - await provider.connection.requestAirdrop(payer.publicKey, 10000000000), + await provider.connection.requestAirdrop( + payer.publicKey, + 10 * LAMPORTS_PER_SOL + ), "confirmed" ); }); @@ -64,7 +66,7 @@ describe("token extensions", () => { }), extraMetasAccount: extraMetasAccount, systemProgram: anchor.web3.SystemProgram.programId, - associatedTokenProgram: ASSOCIATED_PROGRAM_ID, + associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, tokenProgram: TOKEN_2022_PROGRAM_ID, }) .signers([mint, payer]) diff --git a/tests/spl/token-extensions/tsconfig.json b/tests/spl/token-extensions/tsconfig.json index c7f23d9eaf..4082f16a5d 100644 --- a/tests/spl/token-extensions/tsconfig.json +++ b/tests/spl/token-extensions/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai", "node"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../../tsconfig.json" } diff --git a/tests/spl/token-proxy/tests/token-proxy.js b/tests/spl/token-proxy/tests/token-proxy.js index c5826a00f9..5d31ac7e80 100644 --- a/tests/spl/token-proxy/tests/token-proxy.js +++ b/tests/spl/token-proxy/tests/token-proxy.js @@ -1,56 +1,87 @@ +const { PublicKey, Keypair } = require("@solana/web3.js"); const anchor = require("@coral-xyz/anchor"); +const { BN } = require("@coral-xyz/anchor"); const { assert } = require("chai"); + const { - splTokenProgram, - SPL_TOKEN_PROGRAM_ID, -} = require("@coral-xyz/spl-token"); + TOKEN_PROGRAM_ID, + TOKEN_2022_PROGRAM_ID, + createMint, + createAccount, + getAccount, + getMint, + ASSOCIATED_TOKEN_PROGRAM_ID, +} = require("@solana/spl-token"); describe("program", () => { const provider = anchor.AnchorProvider.local(); - const TEST_PROGRAM_IDS = [ - SPL_TOKEN_PROGRAM_ID, - new anchor.web3.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"), - ]; - const TOKEN_PROGRAMS = TEST_PROGRAM_IDS.map((programId) => - splTokenProgram({ - provider, - programId, - }) - ); + const TEST_PROGRAM_IDS = [TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID]; // Configure the client to use the local cluster. anchor.setProvider(provider); + const connection = provider.connection; + const payer = provider.wallet.payer; const program = anchor.workspace.TokenProxy; - - TOKEN_PROGRAMS.forEach((tokenProgram) => { - const name = tokenProgram.programId.equals(SPL_TOKEN_PROGRAM_ID) + /** + * create a mint by tokenProgramId for test. + * @param {*} tokenProgramId + * @returns pub key of the mint + */ + const createMintByTokenProgramId = async (tokenProgramId) => { + return createMint( + connection, + payer, + provider.wallet.publicKey, + undefined, + 0, + Keypair.generate(), + undefined, + tokenProgramId + ); + }; + + TEST_PROGRAM_IDS.forEach((tokenProgramId) => { + const name = tokenProgramId.equals(TOKEN_2022_PROGRAM_ID) ? "token" : "token-2022"; + describe(name, () => { let mint = null; let from = null; let to = null; it("Initializes test state", async () => { - mint = await createMint(tokenProgram); - from = await createTokenAccount( - tokenProgram, + mint = await createMintByTokenProgramId(tokenProgramId); + + from = await createAccount( + connection, + payer, mint, - provider.wallet.publicKey + provider.wallet.publicKey, + Keypair.generate(), + undefined, + tokenProgramId ); - to = await createTokenAccount( - tokenProgram, + + to = await createAccount( + connection, + payer, mint, - provider.wallet.publicKey + provider.wallet.publicKey, + Keypair.generate(), + // {commitment: "confirmed"}, + undefined, + tokenProgramId ); }); it("Creates a token account", async () => { - const newMint = await createMint(tokenProgram); + const newMint = await createMintByTokenProgramId(tokenProgramId); + const authority = provider.wallet.publicKey; - const [tokenAccount] = anchor.web3.PublicKey.findProgramAddressSync( + const [tokenAccount] = PublicKey.findProgramAddressSync( [ authority.toBytes(), newMint.toBytes(), @@ -64,26 +95,25 @@ describe("program", () => { mint: newMint, tokenAccount, systemProgram: anchor.web3.SystemProgram.programId, - tokenProgram: tokenProgram.programId, + tokenProgram: tokenProgramId, }, }); - const account = await getTokenAccount(provider, tokenAccount); - assert.isTrue(account.amount.eq(new anchor.BN(0))); + const account = await getAccount( + connection, + tokenAccount, + null, + tokenProgramId + ); + assert.isTrue(account.amount === BigInt(0)); }); it("Creates an associated token account", async () => { - const newMint = await createMint(tokenProgram); + const newMint = await createMintByTokenProgramId(tokenProgramId); const authority = provider.wallet.publicKey; - const associatedTokenProgram = new anchor.web3.PublicKey( - "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - ); - const [tokenAccount] = anchor.web3.PublicKey.findProgramAddressSync( - [ - authority.toBytes(), - tokenProgram.programId.toBytes(), - newMint.toBytes(), - ], - associatedTokenProgram + + const [tokenAccount] = PublicKey.findProgramAddressSync( + [authority.toBytes(), tokenProgramId.toBytes(), newMint.toBytes()], + ASSOCIATED_TOKEN_PROGRAM_ID ); await program.rpc.proxyCreateAssociatedTokenAccount({ @@ -92,17 +122,22 @@ describe("program", () => { mint: newMint, authority, systemProgram: anchor.web3.SystemProgram.programId, - tokenProgram: tokenProgram.programId, - associatedTokenProgram, + tokenProgram: tokenProgramId, + associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, }, }); - const account = await getTokenAccount(provider, tokenAccount); - assert.isTrue(account.amount.eq(new anchor.BN(0))); + const account = await getAccount( + connection, + tokenAccount, + undefined, + tokenProgramId + ); + assert.isTrue(account.amount === BigInt(0)); }); it("Creates a mint", async () => { const authority = provider.wallet.publicKey; - const [newMint] = anchor.web3.PublicKey.findProgramAddressSync( + const [newMint] = PublicKey.findProgramAddressSync( [ authority.toBytes(), Buffer.from(name), @@ -115,7 +150,7 @@ describe("program", () => { authority, mint: newMint, systemProgram: anchor.web3.SystemProgram.programId, - tokenProgram: tokenProgram.programId, + tokenProgram: tokenProgramId, }, }); }); @@ -126,71 +161,128 @@ describe("program", () => { authority: provider.wallet.publicKey, mint, to: from, - tokenProgram: tokenProgram.programId, + tokenProgram: tokenProgramId, }, }); - const fromAccount = await getTokenAccount(provider, from); + const fromAccount = await getAccount( + connection, + from, + undefined, + tokenProgramId + ); - assert.isTrue(fromAccount.amount.eq(new anchor.BN(1000))); + assert.isTrue(fromAccount.amount === BigInt(1000)); }); it("Transfers a token", async () => { - const preFromAccount = await getTokenAccount(provider, from); - const preToAccount = await getTokenAccount(provider, to); + const preFromAccount = await getAccount( + connection, + from, + undefined, + tokenProgramId + ); + const preToAccount = await getAccount( + connection, + to, + undefined, + tokenProgramId + ); - const transferAmount = new anchor.BN(400); + const transferAmount = new BN(400); await program.rpc.proxyTransfer(transferAmount, { accounts: { authority: provider.wallet.publicKey, to, from, - tokenProgram: tokenProgram.programId, + tokenProgram: tokenProgramId, }, }); - const postFromAccount = await getTokenAccount(provider, from); - const postToAccount = await getTokenAccount(provider, to); + const postFromAccount = await getAccount( + connection, + from, + undefined, + tokenProgramId + ); + const postToAccount = await getAccount( + connection, + to, + undefined, + tokenProgramId + ); assert.isTrue( - postFromAccount.amount.eq(preFromAccount.amount.sub(transferAmount)) + postFromAccount.amount === + preFromAccount.amount - BigInt(transferAmount) ); assert.isTrue( - postToAccount.amount.eq(preToAccount.amount.add(transferAmount)) + postToAccount.amount === preToAccount.amount + BigInt(transferAmount) ); }); it("Transfers a token with optional accounts", async () => { - const preFromAccount = await getTokenAccount(provider, from); - const preToAccount = await getTokenAccount(provider, to); + const preFromAccount = await getAccount( + connection, + from, + undefined, + tokenProgramId + ); + const preToAccount = await getAccount( + connection, + to, + undefined, + tokenProgramId + ); - const transferAmount = new anchor.BN(10); + const transferAmount = 10; - await program.rpc.proxyOptionalTransfer(transferAmount, { + await program.rpc.proxyOptionalTransfer(new BN(transferAmount), { accounts: { authority: provider.wallet.publicKey, to, from, mint, - tokenProgram: tokenProgram.programId, + tokenProgram: tokenProgramId, }, }); - const postFromAccount = await getTokenAccount(provider, from); - const postToAccount = await getTokenAccount(provider, to); + const postFromAccount = await getAccount( + connection, + from, + undefined, + tokenProgramId + ); + const postToAccount = await getAccount( + connection, + to, + undefined, + tokenProgramId + ); assert.isTrue( - postFromAccount.amount.eq(preFromAccount.amount.sub(transferAmount)) + postFromAccount.amount === + preFromAccount.amount - BigInt(transferAmount) ); assert.isTrue( - postToAccount.amount.eq(preToAccount.amount.add(transferAmount)) + postToAccount.amount === preToAccount.amount + BigInt(transferAmount) ); }); it("Does not transfer a token without optional accounts", async () => { - const preFromAccount = await getTokenAccount(provider, from); - const preToAccount = await getTokenAccount(provider, to); + const preFromAccount = await getAccount( + connection, + from, + undefined, + tokenProgramId + ); + const preToAccount = await getAccount( + connection, + to, + undefined, + tokenProgramId + ); const optionalTransferIx = await program.methods .proxyOptionalTransfer(new anchor.BN(10)) @@ -205,31 +297,53 @@ describe("program", () => { const tx = new anchor.web3.Transaction().add(optionalTransferIx); await provider.sendAndConfirm(tx); - const postFromAccount = await getTokenAccount(provider, from); - const postToAccount = await getTokenAccount(provider, to); + const postFromAccount = await getAccount( + connection, + from, + undefined, + tokenProgramId + ); + const postToAccount = await getAccount( + connection, + to, + undefined, + tokenProgramId + ); - assert.isTrue(postFromAccount.amount.eq(preFromAccount.amount)); - assert.isTrue(postToAccount.amount.eq(preToAccount.amount)); + assert.isTrue(postFromAccount.amount === preFromAccount.amount); + assert.isTrue(postToAccount.amount === preToAccount.amount); }); it("Burns a token", async () => { - const preAccount = await getTokenAccount(provider, to); - const burnAmount = new anchor.BN(300); - await program.rpc.proxyBurn(burnAmount, { + const preAccount = await getAccount( + connection, + to, + undefined, + tokenProgramId + ); + const burnAmount = 300; + await program.rpc.proxyBurn(new BN(burnAmount), { accounts: { authority: provider.wallet.publicKey, mint, from: to, - tokenProgram: tokenProgram.programId, + tokenProgram: tokenProgramId, }, }); - const postAccount = await getTokenAccount(provider, to); - assert.isTrue(postAccount.amount.eq(preAccount.amount.sub(burnAmount))); + const postAccount = await getAccount( + connection, + to, + undefined, + tokenProgramId + ); + assert.isTrue( + postAccount.amount === preAccount.amount - BigInt(burnAmount) + ); }); it("Set new mint authority", async () => { - const newMintAuthority = anchor.web3.Keypair.generate(); + const newMintAuthority = Keypair.generate(); await program.rpc.proxySetAuthority( { mintTokens: {} }, newMintAuthority.publicKey, @@ -237,12 +351,17 @@ describe("program", () => { accounts: { accountOrMint: mint, currentAuthority: provider.wallet.publicKey, - tokenProgram: tokenProgram.programId, + tokenProgram: tokenProgramId, }, } ); - const mintInfo = await getMintInfo(provider, mint); + const mintInfo = await getMint( + connection, + mint, + undefined, + tokenProgramId + ); assert.isTrue( mintInfo.mintAuthority.equals(newMintAuthority.publicKey) ); @@ -250,47 +369,3 @@ describe("program", () => { }); }); }); - -// SPL token client boilerplate for test initialization. Everything below here is -// mostly irrelevant to the point of the example. - -const serumCmn = require("@project-serum/common"); - -async function getTokenAccount(provider, addr) { - return await serumCmn.getTokenAccount(provider, addr); -} - -async function getMintInfo(provider, mintAddr) { - return await serumCmn.getMintInfo(provider, mintAddr); -} - -async function createMint(tokenProgram) { - const mint = anchor.web3.Keypair.generate(); - const authority = tokenProgram.provider.wallet.publicKey; - const createMintIx = await tokenProgram.account.mint.createInstruction(mint); - const initMintIx = await tokenProgram.methods - .initializeMint2(0, authority, null) - .accounts({ mint: mint.publicKey }) - .instruction(); - - const tx = new anchor.web3.Transaction(); - tx.add(createMintIx, initMintIx); - - await tokenProgram.provider.sendAndConfirm(tx, [mint]); - - return mint.publicKey; -} - -async function createTokenAccount(tokenProgram, mint, owner) { - const vault = anchor.web3.Keypair.generate(); - const tx = new anchor.web3.Transaction(); - const createTokenAccountIx = - await tokenProgram.account.account.createInstruction(vault); - const initTokenAccountIx = await tokenProgram.methods - .initializeAccount3(owner) - .accounts({ account: vault.publicKey, mint }) - .instruction(); - tx.add(createTokenAccountIx, initTokenAccountIx); - await tokenProgram.provider.sendAndConfirm(tx, [vault]); - return vault.publicKey; -} diff --git a/tests/spl/token-wrapper/tests/wrapper.ts b/tests/spl/token-wrapper/tests/wrapper.ts index 9872861313..0621be4665 100644 --- a/tests/spl/token-wrapper/tests/wrapper.ts +++ b/tests/spl/token-wrapper/tests/wrapper.ts @@ -1,17 +1,27 @@ import * as anchor from "@coral-xyz/anchor"; import { Program, BN, IdlAccounts } from "@coral-xyz/anchor"; -import { PublicKey, Keypair, SystemProgram } from "@solana/web3.js"; -import { TOKEN_PROGRAM_ID, Token } from "@solana/spl-token"; +import { + PublicKey, + Keypair, + SystemProgram, + LAMPORTS_PER_SOL, +} from "@solana/web3.js"; +import { + TOKEN_PROGRAM_ID, + TOKEN_2022_PROGRAM_ID, + createMint, + createAccount, + getAccount, + mintTo, +} from "@solana/spl-token"; import { assert } from "chai"; import { TokenWrapper } from "../target/types/token_wrapper"; describe("wrapper", () => { const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); + const connection = provider.connection; - const TOKEN_2022_PROGRAM_ID = new anchor.web3.PublicKey( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - ); const TEST_TOKEN_PROGRAM_IDS = [ [TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID], [TOKEN_2022_PROGRAM_ID, TOKEN_2022_PROGRAM_ID], @@ -20,8 +30,8 @@ describe("wrapper", () => { ]; const program = anchor.workspace.TokenWrapper as Program; - let depositMint: Token = null; - let wrappedMint: Token = null; + let depositMint: PublicKey = null; + let wrappedMintKP: Keypair = null; let initializerDepositTokenAccount: PublicKey = null; let userWrappedTokenAccount: PublicKey = null; let userDepositTokenAccount: PublicKey = null; @@ -48,42 +58,55 @@ describe("wrapper", () => { describe(name, () => { it("Initialise wrapper", async () => { // Airdropping tokens to a payer. - await provider.connection.confirmTransaction( - await provider.connection.requestAirdrop( + await connection.confirmTransaction( + await connection.requestAirdrop( payer.publicKey, - 10000000000 + 10 * LAMPORTS_PER_SOL ), "confirmed" ); - depositMint = await Token.createMint( - provider.connection, + depositMint = await createMint( + connection, payer, mintAuthority.publicKey, null, 6, + undefined, + undefined, depositTokenProgram ); + wrappedMintKP = new Keypair(); - initializerDepositTokenAccount = await depositMint.createAccount( - provider.wallet.publicKey + initializerDepositTokenAccount = await createAccount( + connection, + payer, + depositMint, + provider.wallet.publicKey, + Keypair.generate(), + undefined, + depositTokenProgram ); - await depositMint.mintTo( + await mintTo( + connection, + payer, + depositMint, initializerDepositTokenAccount, mintAuthority.publicKey, + initializerAmount, [mintAuthority], - initializerAmount + undefined, + depositTokenProgram ); - const wrappedMintKP = new Keypair(); const initializerWrappedTokenAccountKP = new Keypair(); // Get the PDA that is assigned authority to the deposit vault account const [_wrapperAuthority, _] = PublicKey.findProgramAddressSync( [ Buffer.from(anchor.utils.bytes.utf8.encode("wrapr")), - depositMint.publicKey.toBuffer(), + depositMint.toBuffer(), wrappedMintKP.publicKey.toBuffer(), ], program.programId @@ -94,7 +117,7 @@ describe("wrapper", () => { const [_depositTokenVault, __] = PublicKey.findProgramAddressSync( [ Buffer.from(anchor.utils.bytes.utf8.encode("vault")), - depositMint.publicKey.toBuffer(), + depositMint.toBuffer(), wrappedMintKP.publicKey.toBuffer(), ], program.programId @@ -104,7 +127,7 @@ describe("wrapper", () => { await program.rpc.initialize(new BN(initializerAmount), { accounts: { initializer: provider.wallet.publicKey, - depositMint: depositMint.publicKey, + depositMint: depositMint, wrappedMint: wrappedMintKP.publicKey, depositTokenVault, initializerDepositTokenAccount, @@ -118,51 +141,63 @@ describe("wrapper", () => { signers: [wrappedMintKP, initializerWrappedTokenAccountKP], }); - wrappedMint = new Token( - provider.connection, - wrappedMintKP.publicKey, - wrappedTokenProgram, - payer - ); - - let _initializerDepositTokenAccount = await depositMint.getAccountInfo( - initializerDepositTokenAccount + let _initializerDepositTokenAccount = await getAccount( + connection, + initializerDepositTokenAccount, + undefined, + depositTokenProgram ); - let _initializerWrappedTokenAccount = await wrappedMint.getAccountInfo( - initializerWrappedTokenAccountKP.publicKey + let _initializerWrappedTokenAccount = await getAccount( + connection, + initializerWrappedTokenAccountKP.publicKey, + undefined, + wrappedTokenProgram ); + assert.strictEqual(_initializerDepositTokenAccount.amount, BigInt(0)); assert.strictEqual( - _initializerDepositTokenAccount.amount.toNumber(), - 0 - ); - assert.strictEqual( - _initializerWrappedTokenAccount.amount.toNumber(), - initializerAmount + _initializerWrappedTokenAccount.amount, + BigInt(initializerAmount) ); }); it("Wrap", async () => { - userDepositTokenAccount = await depositMint.createAccount( - provider.wallet.publicKey + userDepositTokenAccount = await createAccount( + connection, + payer, + depositMint, + provider.wallet.publicKey, + Keypair.generate(), + undefined, + depositTokenProgram ); - - userWrappedTokenAccount = await wrappedMint.createAccount( - provider.wallet.publicKey + userWrappedTokenAccount = await createAccount( + connection, + payer, + wrappedMintKP.publicKey, + provider.wallet.publicKey, + Keypair.generate(), + undefined, + wrappedTokenProgram ); - await depositMint.mintTo( + await mintTo( + connection, + payer, + depositMint, userDepositTokenAccount, mintAuthority.publicKey, + wrapAmount, [mintAuthority], - wrapAmount + undefined, + depositTokenProgram ); await program.rpc.wrap(new BN(wrapAmount), { accounts: { signer: provider.wallet.publicKey, - depositMint: depositMint.publicKey, - wrappedMint: wrappedMint.publicKey, + depositMint: depositMint, + wrappedMint: wrappedMintKP.publicKey, depositTokenVault: depositTokenVault, userDepositTokenAccount, userWrappedTokenAccount, @@ -172,26 +207,29 @@ describe("wrapper", () => { }, }); - let _userDepositTokenAccount = await depositMint.getAccountInfo( - userDepositTokenAccount + let _userDepositTokenAccount = await getAccount( + connection, + userDepositTokenAccount, + undefined, + depositTokenProgram ); - let _userWrappedTokenAccount = await wrappedMint.getAccountInfo( - userWrappedTokenAccount + let _userWrappedTokenAccount = await getAccount( + connection, + userWrappedTokenAccount, + undefined, + wrappedTokenProgram ); - assert.strictEqual(_userDepositTokenAccount.amount.toNumber(), 0); - assert.strictEqual( - _userWrappedTokenAccount.amount.toNumber(), - wrapAmount - ); + assert.strictEqual(_userDepositTokenAccount.amount, BigInt(0)); + assert.strictEqual(_userWrappedTokenAccount.amount, BigInt(wrapAmount)); }); it("Unwrap", async () => { await program.rpc.unwrap(new BN(wrapAmount - 1), { accounts: { signer: provider.wallet.publicKey, - depositMint: depositMint.publicKey, - wrappedMint: wrappedMint.publicKey, + depositMint: depositMint, + wrappedMint: wrappedMintKP.publicKey, depositTokenVault: depositTokenVault, userDepositTokenAccount, userWrappedTokenAccount, @@ -201,18 +239,24 @@ describe("wrapper", () => { }, }); - let _userDepositTokenAccount = await depositMint.getAccountInfo( - userDepositTokenAccount + let _userDepositTokenAccount = await getAccount( + connection, + userDepositTokenAccount, + undefined, + depositTokenProgram ); - let _userWrappedTokenAccount = await wrappedMint.getAccountInfo( - userWrappedTokenAccount + let _userWrappedTokenAccount = await getAccount( + connection, + userWrappedTokenAccount, + undefined, + wrappedTokenProgram ); assert.strictEqual( - _userDepositTokenAccount.amount.toNumber(), - wrapAmount - 1 + _userDepositTokenAccount.amount, + BigInt(wrapAmount - 1) ); - assert.strictEqual(_userWrappedTokenAccount.amount.toNumber(), 1); + assert.strictEqual(_userWrappedTokenAccount.amount, BigInt(1)); }); }); }); diff --git a/tests/spl/token-wrapper/tsconfig.json b/tests/spl/token-wrapper/tsconfig.json index c7f23d9eaf..4082f16a5d 100644 --- a/tests/spl/token-wrapper/tsconfig.json +++ b/tests/spl/token-wrapper/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai", "node"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../../tsconfig.json" } diff --git a/tests/spl/transfer-hook/tests/transfer-hook.ts b/tests/spl/transfer-hook/tests/transfer-hook.ts index 249cded332..1dec5035b5 100644 --- a/tests/spl/transfer-hook/tests/transfer-hook.ts +++ b/tests/spl/transfer-hook/tests/transfer-hook.ts @@ -7,6 +7,7 @@ import { sendAndConfirmTransaction, Transaction, AccountInfo, + LAMPORTS_PER_SOL, } from "@solana/web3.js"; import { getExtraAccountMetaAddress, @@ -18,9 +19,9 @@ import { createAssociatedTokenAccountInstruction, getAssociatedTokenAddressSync, createMintToInstruction, - createTransferCheckedInstruction, getAccount, - addExtraAccountsToInstruction, + createTransferCheckedWithTransferHookInstruction, + TOKEN_2022_PROGRAM_ID, } from "@solana/spl-token"; import { assert } from "chai"; import { TransferHook } from "../target/types/transfer_hook"; @@ -29,9 +30,6 @@ describe("transfer hook", () => { const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); - const TOKEN_2022_PROGRAM_ID = new anchor.web3.PublicKey( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - ); const program = anchor.workspace.TransferHook as Program; const decimals = 2; @@ -132,7 +130,10 @@ describe("transfer hook", () => { ); await provider.connection.confirmTransaction( - await provider.connection.requestAirdrop(payer.publicKey, 10000000000), + await provider.connection.requestAirdrop( + payer.publicKey, + 10 * LAMPORTS_PER_SOL + ), "confirmed" ); @@ -255,19 +256,15 @@ describe("transfer hook", () => { ); }); - const ix = await addExtraAccountsToInstruction( + const ix = await createTransferCheckedWithTransferHookInstruction( provider.connection, - createTransferCheckedInstruction( - source, - mint.publicKey, - destination, - sourceAuthority.publicKey, - transferAmount, - decimals, - undefined, - TOKEN_2022_PROGRAM_ID - ), + source, mint.publicKey, + destination, + sourceAuthority.publicKey, + BigInt(transferAmount), + decimals, + [], undefined, TOKEN_2022_PROGRAM_ID ); diff --git a/tests/spl/transfer-hook/tsconfig.json b/tests/spl/transfer-hook/tsconfig.json index c7f23d9eaf..4082f16a5d 100644 --- a/tests/spl/transfer-hook/tsconfig.json +++ b/tests/spl/transfer-hook/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai", "node"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../../tsconfig.json" } diff --git a/tests/system-accounts/tests/system-accounts.js b/tests/system-accounts/tests/system-accounts.js index 3027176bac..e612ebe25c 100644 --- a/tests/system-accounts/tests/system-accounts.js +++ b/tests/system-accounts/tests/system-accounts.js @@ -21,23 +21,27 @@ describe("system_accounts", () => { }); it("Emits an AccountNotSystemOwned error", async () => { - const mint = await splToken.Token.createMint( + const mint = await splToken.createMint( program.provider.connection, authority, authority.publicKey, null, - 9, - splToken.TOKEN_PROGRAM_ID + 9 ); - const tokenAccount = await mint.createAssociatedTokenAccount( + const tokenAccount = await splToken.createAssociatedTokenAccount( + program.provider.connection, + authority, + mint, wallet.publicKey ); - await mint.mintTo( + await splToken.mintTo( + program.provider.connection, + authority, + mint, tokenAccount, - authority.publicKey, - [], + authority, 1 * anchor.web3.LAMPORTS_PER_SOL ); diff --git a/tests/tsconfig.json b/tests/tsconfig.json new file mode 100644 index 0000000000..c7f23d9eaf --- /dev/null +++ b/tests/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "types": ["mocha", "chai", "node"], + "typeRoots": ["./node_modules/@types"], + "lib": ["es2015"], + "module": "commonjs", + "target": "es6", + "esModuleInterop": true, + "skipLibCheck": true + } +} diff --git a/tests/typescript/tsconfig.json b/tests/typescript/tsconfig.json index cd5d2e3d06..3c43903cfd 100644 --- a/tests/typescript/tsconfig.json +++ b/tests/typescript/tsconfig.json @@ -1,10 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true - } + "extends": "../tsconfig.json" } diff --git a/tests/validator-clone/tsconfig.json b/tests/validator-clone/tsconfig.json index b3b6656d38..3c43903cfd 100644 --- a/tests/validator-clone/tsconfig.json +++ b/tests/validator-clone/tsconfig.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true, - "skipLibCheck": true - } + "extends": "../tsconfig.json" } diff --git a/tests/yarn.lock b/tests/yarn.lock index d6a982f802..f64bedf95c 100644 --- a/tests/yarn.lock +++ b/tests/yarn.lock @@ -30,6 +30,13 @@ dependencies: regenerator-runtime "^0.14.0" +"@babel/runtime@^7.25.0": + version "7.26.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1" + integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw== + dependencies: + regenerator-runtime "^0.14.0" + "@metaplex-foundation/mpl-auction@^0.0.2": version "0.0.2" resolved "https://registry.yarnpkg.com/@metaplex-foundation/mpl-auction/-/mpl-auction-0.0.2.tgz#3de3c982e88d6a88f0ef05be73453cf3cfaccf26" @@ -114,6 +121,13 @@ dependencies: "@noble/hashes" "1.3.2" +"@noble/curves@^1.4.2": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.7.0.tgz#0512360622439256df892f21d25b388f52505e45" + integrity sha512-UTMhXK9SeDhFJVrHeUJ5uZlI6ajXg10O6Ddocf9S6GjbSBVZsJo88HzKwXznNfGpMTRDyJkqMjNDPYgf0qFWnw== + dependencies: + "@noble/hashes" "1.6.0" + "@noble/ed25519@^1.7.0": version "1.7.0" resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.0.tgz#583ac38340a479314b9e348d4572101ed9492f9d" @@ -124,64 +138,26 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== +"@noble/hashes@1.6.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.6.0.tgz#d4bfb516ad6e7b5111c216a5cc7075f4cf19e6c5" + integrity sha512-YUULf0Uk4/mAA89w+k3+yUYh6NrEvxZa5T6SY3wlMvE2chHkxFUUIDI8/XW1QSC357iA5pSnqt7XEhvFOqmDyQ== + "@noble/hashes@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.2.tgz#e9e035b9b166ca0af657a7848eb2718f0f22f183" integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA== +"@noble/hashes@^1.4.0": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.6.1.tgz#df6e5943edcea504bac61395926d6fd67869a0d5" + integrity sha512-pq5D8h10hHBjyqX+cfBm0i8JUXJ0UhczFc4r74zbuT9XgewFo2E3J1cOaGtdZynILNmQ685YWGzGE1Zv6io50w== + "@noble/secp256k1@^1.6.3": version "1.6.3" resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.6.3.tgz#7eed12d9f4404b416999d0c87686836c4c5c9b94" integrity sha512-T04e4iTurVy7I8Sw4+c5OSN9/RkPlo1uKxAomtxQNLq8j1uPAqnsqG1bqvY3Jv7c13gyr6dui0zmh/I3+f/JaQ== -"@project-serum/anchor@^0.11.1": - version "0.11.1" - resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.11.1.tgz#155bff2c70652eafdcfd5559c81a83bb19cec9ff" - integrity sha512-oIdm4vTJkUy6GmE6JgqDAuQPKI7XM4TPJkjtoIzp69RZe0iAD9JP2XHx7lV1jLdYXeYHqDXfBt3zcq7W91K6PA== - dependencies: - "@project-serum/borsh" "^0.2.2" - "@solana/web3.js" "^1.17.0" - base64-js "^1.5.1" - bn.js "^5.1.2" - bs58 "^4.0.1" - buffer-layout "^1.2.0" - camelcase "^5.3.1" - crypto-hash "^1.3.0" - eventemitter3 "^4.0.7" - find "^0.3.0" - js-sha256 "^0.9.0" - pako "^2.0.3" - snake-case "^3.0.4" - toml "^3.0.0" - -"@project-serum/borsh@^0.2.2": - version "0.2.5" - resolved "https://registry.yarnpkg.com/@project-serum/borsh/-/borsh-0.2.5.tgz#6059287aa624ecebbfc0edd35e4c28ff987d8663" - integrity sha512-UmeUkUoKdQ7rhx6Leve1SssMR/Ghv8qrEiyywyxSWg7ooV7StdpPBhciiy5eB3T0qU1BXvdRNC8TdrkxK7WC5Q== - dependencies: - bn.js "^5.1.2" - buffer-layout "^1.2.0" - -"@project-serum/common@^0.0.1-beta.3": - version "0.0.1-beta.3" - resolved "https://registry.yarnpkg.com/@project-serum/common/-/common-0.0.1-beta.3.tgz#53586eaff9d9fd7e8938b1e12080c935b8b6ad07" - integrity sha512-gnQE/eUydTtto5okCgLWj1M97R9RRPJqnhKklikYI7jP/pnNhDmngSXC/dmfzED2GXSJEIKNIlxVw1k+E2Aw3w== - dependencies: - "@project-serum/serum" "^0.13.21" - bn.js "^5.1.2" - superstruct "0.8.3" - -"@project-serum/serum@^0.13.21", "@project-serum/serum@^0.13.60": - version "0.13.60" - resolved "https://registry.yarnpkg.com/@project-serum/serum/-/serum-0.13.60.tgz#abeb3355ebc1895d685250df5965f688502ebcbb" - integrity sha512-fGsp9F0ZAS48YQ2HNy+6CNoifJESFXxVsOLPd9QK1XNV8CTuQoECOnVXxV6s5cKGre8pLNq5hrhi5J6aCGauEQ== - dependencies: - "@project-serum/anchor" "^0.11.1" - "@solana/spl-token" "^0.1.6" - "@solana/web3.js" "^1.21.0" - bn.js "^5.1.2" - buffer-layout "^1.2.0" - "@solana/buffer-layout-utils@^0.2.0": version "0.2.0" resolved "https://registry.yarnpkg.com/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz#b45a6cab3293a2eb7597cceb474f229889d875ca" @@ -199,7 +175,91 @@ dependencies: buffer "~6.0.3" -"@solana/spl-token@^0.1.6", "@solana/spl-token@^0.1.8": +"@solana/buffer-layout@^4.0.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15" + integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA== + dependencies: + buffer "~6.0.3" + +"@solana/codecs-core@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/codecs-core/-/codecs-core-2.0.0-rc.1.tgz#1a2d76b9c7b9e7b7aeb3bd78be81c2ba21e3ce22" + integrity sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ== + dependencies: + "@solana/errors" "2.0.0-rc.1" + +"@solana/codecs-data-structures@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/codecs-data-structures/-/codecs-data-structures-2.0.0-rc.1.tgz#d47b2363d99fb3d643f5677c97d64a812982b888" + integrity sha512-rinCv0RrAVJ9rE/rmaibWJQxMwC5lSaORSZuwjopSUE6T0nb/MVg6Z1siNCXhh/HFTOg0l8bNvZHgBcN/yvXog== + dependencies: + "@solana/codecs-core" "2.0.0-rc.1" + "@solana/codecs-numbers" "2.0.0-rc.1" + "@solana/errors" "2.0.0-rc.1" + +"@solana/codecs-numbers@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/codecs-numbers/-/codecs-numbers-2.0.0-rc.1.tgz#f34978ddf7ea4016af3aaed5f7577c1d9869a614" + integrity sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ== + dependencies: + "@solana/codecs-core" "2.0.0-rc.1" + "@solana/errors" "2.0.0-rc.1" + +"@solana/codecs-strings@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/codecs-strings/-/codecs-strings-2.0.0-rc.1.tgz#e1d9167075b8c5b0b60849f8add69c0f24307018" + integrity sha512-9/wPhw8TbGRTt6mHC4Zz1RqOnuPTqq1Nb4EyuvpZ39GW6O2t2Q7Q0XxiB3+BdoEjwA2XgPw6e2iRfvYgqty44g== + dependencies: + "@solana/codecs-core" "2.0.0-rc.1" + "@solana/codecs-numbers" "2.0.0-rc.1" + "@solana/errors" "2.0.0-rc.1" + +"@solana/codecs@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/codecs/-/codecs-2.0.0-rc.1.tgz#146dc5db58bd3c28e04b4c805e6096c2d2a0a875" + integrity sha512-qxoR7VybNJixV51L0G1RD2boZTcxmwUWnKCaJJExQ5qNKwbpSyDdWfFJfM5JhGyKe9DnPVOZB+JHWXnpbZBqrQ== + dependencies: + "@solana/codecs-core" "2.0.0-rc.1" + "@solana/codecs-data-structures" "2.0.0-rc.1" + "@solana/codecs-numbers" "2.0.0-rc.1" + "@solana/codecs-strings" "2.0.0-rc.1" + "@solana/options" "2.0.0-rc.1" + +"@solana/errors@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/errors/-/errors-2.0.0-rc.1.tgz#3882120886eab98a37a595b85f81558861b29d62" + integrity sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ== + dependencies: + chalk "^5.3.0" + commander "^12.1.0" + +"@solana/options@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/options/-/options-2.0.0-rc.1.tgz#06924ba316dc85791fc46726a51403144a85fc4d" + integrity sha512-mLUcR9mZ3qfHlmMnREdIFPf9dpMc/Bl66tLSOOWxw4ml5xMT2ohFn7WGqoKcu/UHkT9CrC6+amEdqCNvUqI7AA== + dependencies: + "@solana/codecs-core" "2.0.0-rc.1" + "@solana/codecs-data-structures" "2.0.0-rc.1" + "@solana/codecs-numbers" "2.0.0-rc.1" + "@solana/codecs-strings" "2.0.0-rc.1" + "@solana/errors" "2.0.0-rc.1" + +"@solana/spl-token-group@^0.0.7": + version "0.0.7" + resolved "https://registry.yarnpkg.com/@solana/spl-token-group/-/spl-token-group-0.0.7.tgz#83c00f0cd0bda33115468cd28b89d94f8ec1fee4" + integrity sha512-V1N/iX7Cr7H0uazWUT2uk27TMqlqedpXHRqqAbVO2gvmJyT0E0ummMEAVQeXZ05ZhQ/xF39DLSdBp90XebWEug== + dependencies: + "@solana/codecs" "2.0.0-rc.1" + +"@solana/spl-token-metadata@^0.1.6": + version "0.1.6" + resolved "https://registry.yarnpkg.com/@solana/spl-token-metadata/-/spl-token-metadata-0.1.6.tgz#d240947aed6e7318d637238022a7b0981b32ae80" + integrity sha512-7sMt1rsm/zQOQcUWllQX9mD2O6KhSAtY1hFR2hfFwgqfFWzSY9E9GDvFVNYUI1F0iQKcm6HmePU9QbKRXTEBiA== + dependencies: + "@solana/codecs" "2.0.0-rc.1" + +"@solana/spl-token@^0.1.8": version "0.1.8" resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.1.8.tgz#f06e746341ef8d04165e21fc7f555492a2a0faa6" integrity sha512-LZmYCKcPQDtJgecvWOgT/cnoIQPWjdH+QVyzPcFvyDUiT0DiRjZaam4aqNUyvchLFhzgunv3d9xOoyE34ofdoQ== @@ -220,7 +280,18 @@ "@solana/buffer-layout-utils" "^0.2.0" buffer "^6.0.3" -"@solana/web3.js@^1.17.0", "@solana/web3.js@^1.21.0": +"@solana/spl-token@^0.4.9": + version "0.4.9" + resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.4.9.tgz#24d032d2935f237925c3b058ba6bb1e1ece5428c" + integrity sha512-g3wbj4F4gq82YQlwqhPB0gHFXfgsC6UmyGMxtSLf/BozT/oKd59465DbnlUK8L8EcimKMavxsVAMoLcEdeCicg== + dependencies: + "@solana/buffer-layout" "^4.0.0" + "@solana/buffer-layout-utils" "^0.2.0" + "@solana/spl-token-group" "^0.0.7" + "@solana/spl-token-metadata" "^0.1.6" + buffer "^6.0.3" + +"@solana/web3.js@^1.21.0": version "1.64.0" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.64.0.tgz#b7f5a976976039a0161242e94d6e1224ab5d30f9" integrity sha512-AcFaoy48GxSmzBryVwB88C/UPJd/UQa+nFrO/uPc8ww6RCjanZY2vEZxdfTZub+q1NMUckwXpPwF32jJLe7SPA== @@ -283,26 +354,33 @@ rpc-websockets "^7.5.1" superstruct "^0.14.2" -"@solana/web3.js@^1.68.0": - version "1.70.0" - resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.70.0.tgz#14ad207f431861397db85921aad8df4e8374e7c8" - integrity sha512-HwdI9LaHaszfpzgxJI44iP68mJWUeqK1TeSheKQsGkH5zlVyGWGmim50MyDWu2vXiuL8Akf2xEMSrDYyLordgg== +"@solana/web3.js@^1.68.0", "@solana/web3.js@^1.98.0": + version "1.98.0" + resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.0.tgz#21ecfe8198c10831df6f0cfde7f68370d0405917" + integrity sha512-nz3Q5OeyGFpFCR+erX2f6JPt3sKhzhYcSycBCSPkWjzSVDh/Rr1FqTVMRe58FKO16/ivTUcuJjeS5MyBvpkbzA== dependencies: - "@babel/runtime" "^7.12.5" - "@noble/ed25519" "^1.7.0" - "@noble/hashes" "^1.1.2" - "@noble/secp256k1" "^1.6.3" - "@solana/buffer-layout" "^4.0.0" + "@babel/runtime" "^7.25.0" + "@noble/curves" "^1.4.2" + "@noble/hashes" "^1.4.0" + "@solana/buffer-layout" "^4.0.1" + agentkeepalive "^4.5.0" bigint-buffer "^1.1.5" - bn.js "^5.0.0" + bn.js "^5.2.1" borsh "^0.7.0" bs58 "^4.0.1" - buffer "6.0.1" + buffer "6.0.3" fast-stable-stringify "^1.0.0" - jayson "^3.4.4" - node-fetch "2" - rpc-websockets "^7.5.0" - superstruct "^0.14.2" + jayson "^4.1.1" + node-fetch "^2.7.0" + rpc-websockets "^9.0.2" + superstruct "^2.0.2" + +"@swc/helpers@^0.5.11": + version "0.5.15" + resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.15.tgz#79efab344c5819ecf83a43f3f9f811fc84b516d7" + integrity sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g== + dependencies: + tslib "^2.8.0" "@types/bn.js@^4.11.5": version "4.11.6" @@ -386,6 +464,11 @@ resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== +"@types/uuid@^8.3.4": + version "8.3.4" + resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc" + integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw== + "@types/ws@^7.4.4": version "7.4.7" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702" @@ -393,6 +476,13 @@ dependencies: "@types/node" "*" +"@types/ws@^8.2.2": + version "8.5.13" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.13.tgz#6414c280875e2691d0d1e080b05addbf5cb91e20" + integrity sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA== + dependencies: + "@types/node" "*" + "@ungap/promise-all-settled@1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" @@ -406,7 +496,7 @@ JSONStream@^1.3.5: jsonparse "^1.2.0" through ">=2.2.7 <3" -agentkeepalive@^4.3.0: +agentkeepalive@^4.3.0, agentkeepalive@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.5.0.tgz#2673ad1389b3c418c5a20c5d7364f93ca04be923" integrity sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew== @@ -477,7 +567,7 @@ base-x@^3.0.2, base-x@^3.0.6: dependencies: safe-buffer "^5.0.1" -base64-js@^1.3.1, base64-js@^1.5.1: +base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== @@ -506,7 +596,7 @@ bindings@^1.3.0: dependencies: file-uri-to-path "1.0.0" -bn.js@^5.0.0, bn.js@^5.1.0, bn.js@^5.1.2: +bn.js@^5.0.0, bn.js@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== @@ -602,11 +692,6 @@ bufferutil@^4.0.1: dependencies: node-gyp-build "^4.3.0" -camelcase@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== - camelcase@^6.0.0: version "6.3.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" @@ -632,6 +717,11 @@ chalk@^4.1.0: ansi-styles "^4.1.0" supports-color "^7.1.0" +chalk@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385" + integrity sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w== + check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" @@ -680,6 +770,11 @@ combined-stream@^1.0.8: dependencies: delayed-stream "~1.0.0" +commander@^12.1.0: + version "12.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3" + integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA== + commander@^2.20.3: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" @@ -741,14 +836,6 @@ diff@^3.1.0: resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== -dot-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751" - integrity sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" - dotenv@10.0.0: version "10.0.0" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81" @@ -786,6 +873,11 @@ eventemitter3@^4.0.7: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== +eventemitter3@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" + integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== + eyes@^0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" @@ -816,13 +908,6 @@ find-up@5.0.0: locate-path "^6.0.0" path-exists "^4.0.0" -find@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/find/-/find-0.3.0.tgz#4082e8fc8d8320f1a382b5e4f521b9bc50775cb8" - integrity sha512-iSd+O4OEYV/I36Zl8MdYJO0xD82wH528SaCieTVHhclgiYNe9y+yPKSwK+A7/WsmHL1EZ+pYUJBXWTL5qofksw== - dependencies: - traverse-chain "~0.1.0" - flat@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" @@ -1009,10 +1094,23 @@ jayson@^4.1.0: uuid "^8.3.2" ws "^7.4.5" -js-sha256@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" - integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== +jayson@^4.1.1: + version "4.1.3" + resolved "https://registry.yarnpkg.com/jayson/-/jayson-4.1.3.tgz#db9be2e4287d9fef4fc05b5fe367abe792c2eee8" + integrity sha512-LtXh5aYZodBZ9Fc3j6f2w+MTNcnxteMOrb+QgIouguGOulWi0lieEkOUg+HkjjFs0DGoWDds6bi4E9hpNFLulQ== + dependencies: + "@types/connect" "^3.4.33" + "@types/node" "^12.12.54" + "@types/ws" "^7.4.4" + JSONStream "^1.3.5" + commander "^2.20.3" + delay "^5.0.0" + es6-promisify "^5.0.0" + eyes "^0.1.8" + isomorphic-ws "^4.0.1" + json-stringify-safe "^5.0.1" + uuid "^8.3.2" + ws "^7.5.10" js-yaml@4.1.0: version "4.1.0" @@ -1038,11 +1136,6 @@ jsonparse@^1.2.0: resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" integrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA= -kind-of@^6.0.2: - version "6.0.3" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" - integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== - locate-path@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" @@ -1063,13 +1156,6 @@ log-symbols@4.1.0: chalk "^4.1.0" is-unicode-supported "^0.1.0" -lower-case@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" - integrity sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg== - dependencies: - tslib "^2.0.3" - make-error@^1.1.1: version "1.3.6" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" @@ -1197,14 +1283,6 @@ nanoid@3.3.3: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25" integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w== -no-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" - integrity sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg== - dependencies: - lower-case "^2.0.2" - tslib "^2.0.3" - node-fetch@2: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" @@ -1212,7 +1290,7 @@ node-fetch@2: dependencies: whatwg-url "^5.0.0" -node-fetch@^2.6.12: +node-fetch@^2.6.12, node-fetch@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== @@ -1250,11 +1328,6 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" -pako@^2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pako/-/pako-2.0.4.tgz#6cebc4bbb0b6c73b0d5b8d7e8476e2b2fbea576d" - integrity sha512-v8tweI900AUkZN6heMU/4Uy4cXRc2AYNRggVmTR+dEncawDJgCdLMximOVA2p4qO57WMynangsfGRb5WD6L1Bg== - path-exists@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" @@ -1335,6 +1408,22 @@ rpc-websockets@^7.5.1: bufferutil "^4.0.1" utf-8-validate "^5.0.2" +rpc-websockets@^9.0.2: + version "9.0.4" + resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-9.0.4.tgz#9d8ee82533b5d1e13d9ded729e3e38d0d8fa083f" + integrity sha512-yWZWN0M+bivtoNLnaDbtny4XchdAIF5Q4g/ZsC5UC61Ckbp0QczwO8fg44rV3uYmY4WHd+EZQbn90W1d8ojzqQ== + dependencies: + "@swc/helpers" "^0.5.11" + "@types/uuid" "^8.3.4" + "@types/ws" "^8.2.2" + buffer "^6.0.3" + eventemitter3 "^5.0.1" + uuid "^8.3.2" + ws "^8.5.0" + optionalDependencies: + bufferutil "^4.0.1" + utf-8-validate "^5.0.2" + safe-buffer@^5.0.1, safe-buffer@^5.1.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" @@ -1347,14 +1436,6 @@ serialize-javascript@6.0.0: dependencies: randombytes "^2.1.0" -snake-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c" - integrity sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg== - dependencies: - dot-case "^3.0.4" - tslib "^2.0.3" - source-map-support@^0.5.6: version "0.5.20" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.20.tgz#12166089f8f5e5e8c56926b377633392dd2cb6c9" @@ -1394,19 +1475,16 @@ strip-json-comments@3.1.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -superstruct@0.8.3: - version "0.8.3" - resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.8.3.tgz#fb4d8901aca3bf9f79afab1bbab7a7f335cc4ef2" - integrity sha512-LbtbFpktW1FcwxVIJlxdk7bCyBq/GzOx2FSFLRLTUhWIA1gHkYPIl3aXRG5mBdGZtnPNT6t+4eEcLDCMOuBHww== - dependencies: - kind-of "^6.0.2" - tiny-invariant "^1.0.6" - superstruct@^0.14.2: version "0.14.2" resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.14.2.tgz#0dbcdf3d83676588828f1cf5ed35cda02f59025b" integrity sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ== +superstruct@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-2.0.2.tgz#3f6d32fbdc11c357deff127d591a39b996300c54" + integrity sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A== + supports-color@8.1.1: version "8.1.1" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" @@ -1431,11 +1509,6 @@ text-encoding-utf-8@^1.0.2: resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= -tiny-invariant@^1.0.6: - version "1.2.0" - resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.2.0.tgz#a1141f86b672a9148c72e978a19a73b9b94a15a9" - integrity sha512-1Uhn/aqw5C6RI4KejVeTg6mIS7IqxnLJ8Mv2tV5rTc0qWobay7pDUz6Wi392Cnc8ak1H0F2cjoRzb2/AW4+Fvg== - to-regex-range@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" @@ -1443,21 +1516,11 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -toml@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee" - integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w== - tr46@~0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= -traverse-chain@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/traverse-chain/-/traverse-chain-0.1.0.tgz#61dbc2d53b69ff6091a12a168fd7d433107e40f1" - integrity sha1-YdvC1Ttp/2CRoSoWj9fUMxB+QPE= - ts-mocha@^10.0.0: version "10.0.0" resolved "https://registry.yarnpkg.com/ts-mocha/-/ts-mocha-10.0.0.tgz#41a8d099ac90dbbc64b06976c5025ffaebc53cb9" @@ -1496,20 +1559,20 @@ tsconfig-paths@^3.5.0: minimist "^1.2.0" strip-bom "^3.0.0" -tslib@^2.0.3: - version "2.3.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" - integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== +tslib@^2.8.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== type-detect@^4.0.0, type-detect@^4.0.5: version "4.0.8" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== -typescript@^4.4.4: - version "4.4.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c" - integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA== +typescript@^5.7.2: + version "5.7.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.2.tgz#3169cf8c4c8a828cde53ba9ecb3d2b1d5dd67be6" + integrity sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg== utf-8-validate@^5.0.2: version "5.0.7" @@ -1577,6 +1640,11 @@ ws@^7.4.5: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.5.tgz#8b4bc4af518cfabd0473ae4f99144287b33eb881" integrity sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w== +ws@^7.5.10: + version "7.5.10" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" + integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== + ws@^8.5.0: version "8.9.0" resolved "https://registry.yarnpkg.com/ws/-/ws-8.9.0.tgz#2a994bb67144be1b53fe2d23c53c028adeb7f45e"