From 1557b10a01126b533c923b90b215cd55233cda7f Mon Sep 17 00:00:00 2001 From: acheron Date: Mon, 11 Sep 2023 16:22:30 +0200 Subject: [PATCH] Upgrade to `@coral-xyz/anchor` 0.28.0 --- basics/account-data/anchor/package.json | 24 +- basics/account-data/anchor/tests/test.ts | 14 +- basics/checking-accounts/anchor/package.json | 24 +- basics/checking-accounts/anchor/tests/test.ts | 28 +- .../close-account/anchor/migrations/deploy.ts | 2 +- basics/close-account/anchor/package.json | 34 +-- .../anchor/tests/close-account.ts | 151 ++++++----- basics/counter/anchor/migrations/deploy.ts | 2 +- basics/counter/anchor/package.json | 34 +-- basics/counter/anchor/tests/counter_anchor.ts | 20 +- basics/counter/seahorse/migrations/deploy.ts | 2 +- basics/counter/seahorse/package.json | 34 +-- .../seahorse/tests/counter_seahorse.ts | 16 +- basics/create-account/anchor/package.json | 24 +- basics/create-account/anchor/tests/test.ts | 26 +- .../anchor/package.json | 24 +- .../anchor/tests/test.ts | 52 ++-- basics/hello-solana/anchor/package.json | 24 +- basics/hello-solana/anchor/tests/test.ts | 9 +- .../hello_solana/migrations/deploy.ts | 2 +- .../seahorse/hello_solana/package.json | 34 +-- .../hello_solana/tests/hello_solana.ts | 17 +- basics/pda-rent-payer/anchor/package.json | 24 +- basics/pda-rent-payer/anchor/tests/test.ts | 51 ++-- .../anchor/package.json | 24 +- .../anchor/tests/test.ts | 17 +- .../anchor/package.json | 24 +- .../anchor/tests/test.ts | 19 +- basics/rent/anchor/package.json | 24 +- basics/rent/anchor/tests/test.ts | 30 +-- basics/repository-layout/anchor/package.json | 24 +- basics/repository-layout/anchor/tests/test.ts | 61 +++-- basics/transfer-sol/anchor/package.json | 24 +- basics/transfer-sol/anchor/tests/test.ts | 44 +-- basics/transfer-sol/seahorse/package.json | 34 +-- compression/cnft-vault/anchor/package.json | 40 +-- .../anchor/tests/scripts/constants.ts | 14 +- .../anchor/tests/scripts/withdraw.ts | 28 +- .../anchor/tests/scripts/withdrawTwo.ts | 52 ++-- .../tests/scripts/withdrawWithLookup.ts | 92 +++++-- compression/cnft-vault/anchor/tests/tests.ts | 254 ++++++++++-------- compression/cutils/package.json | 48 ++-- oracles/pyth/anchor/package.json | 34 +-- oracles/pyth/seahorse/package.json | 34 +-- tokens/create-token/anchor/package.json | 4 +- tokens/create-token/anchor/tests/test.ts | 67 +++-- tokens/nft-minter/anchor/package.json | 26 +- tokens/nft-minter/anchor/tests/test.ts | 94 ++++--- tokens/pda-mint-authority/anchor/package.json | 26 +- .../pda-mint-authority/anchor/tests/test.ts | 114 ++++---- tokens/spl-token-minter/anchor/package.json | 26 +- tokens/spl-token-minter/anchor/tests/test.ts | 65 +++-- tokens/token-2022/basics/anchor/package.json | 2 +- tokens/token-swap/anchor/package.json | 36 +-- tokens/transfer-tokens/anchor/package.json | 26 +- tokens/transfer-tokens/anchor/tests/test.ts | 196 +++++++------- tokens/transfer-tokens/seahorse/package.json | 34 +-- 57 files changed, 1185 insertions(+), 1124 deletions(-) diff --git a/basics/account-data/anchor/package.json b/basics/account-data/anchor/package.json index bcd1eb4c9..ab411155f 100644 --- a/basics/account-data/anchor/package.json +++ b/basics/account-data/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/account-data/anchor/tests/test.ts b/basics/account-data/anchor/tests/test.ts index 4f8039be5..016a15345 100644 --- a/basics/account-data/anchor/tests/test.ts +++ b/basics/account-data/anchor/tests/test.ts @@ -1,24 +1,20 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { AnchorProgramExample } from "../target/types/anchor_program_example"; describe("Account Data!", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const payer = provider.wallet as anchor.Wallet; - const program = anchor.workspace.AnchorProgramExample as anchor.Program; + const program = anchor.workspace + .AnchorProgramExample as anchor.Program; const addressInfoAccount = anchor.web3.Keypair.generate(); it("Create the address info account", async () => { console.log(`Payer Address : ${payer.publicKey}`); console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`); - await program.methods.createAddressInfo( - "Joe C", - 136, - "Mile High Dr.", - "Solana Beach", - ) + await program.methods + .createAddressInfo("Joe C", 136, "Mile High Dr.", "Solana Beach") .accounts({ addressInfo: addressInfoAccount.publicKey, payer: payer.publicKey, diff --git a/basics/checking-accounts/anchor/package.json b/basics/checking-accounts/anchor/package.json index bcd1eb4c9..ab411155f 100644 --- a/basics/checking-accounts/anchor/package.json +++ b/basics/checking-accounts/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/checking-accounts/anchor/tests/test.ts b/basics/checking-accounts/anchor/tests/test.ts index 3425e5555..b93907853 100644 --- a/basics/checking-accounts/anchor/tests/test.ts +++ b/basics/checking-accounts/anchor/tests/test.ts @@ -1,11 +1,11 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { AnchorProgramExample } from "../target/types/anchor_program_example"; describe("Anchor example", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); - const program = anchor.workspace.AnchorProgramExample as anchor.Program; + const program = anchor.workspace + .AnchorProgramExample as anchor.Program; const payer = provider.wallet as anchor.Wallet; // We'll create this ahead of time. @@ -15,25 +15,24 @@ describe("Anchor example", () => { const accountToCreate = anchor.web3.Keypair.generate(); it("Create an account owned by our program", async () => { - let ix = anchor.web3.SystemProgram.createAccount({ - fromPubkey: provider.wallet.publicKey, - newAccountPubkey: accountToChange.publicKey, - lamports: await provider.connection.getMinimumBalanceForRentExemption(0), - space: 0, - programId: program.programId, // Our program + fromPubkey: provider.wallet.publicKey, + newAccountPubkey: accountToChange.publicKey, + lamports: await provider.connection.getMinimumBalanceForRentExemption(0), + space: 0, + programId: program.programId, // Our program }); await anchor.web3.sendAndConfirmTransaction( - provider.connection, - new anchor.web3.Transaction().add(ix), - [payer.payer, accountToChange] + provider.connection, + new anchor.web3.Transaction().add(ix), + [payer.payer, accountToChange] ); }); it("Check accounts", async () => { - - await program.methods.checkAccounts() + await program.methods + .checkAccounts() .accounts({ payer: provider.wallet.publicKey, accountToCreate: accountToCreate.publicKey, @@ -42,6 +41,5 @@ describe("Anchor example", () => { }) .signers([payer.payer]) .rpc(); - }); }); diff --git a/basics/close-account/anchor/migrations/deploy.ts b/basics/close-account/anchor/migrations/deploy.ts index 5e3df0dc3..82fb175fa 100644 --- a/basics/close-account/anchor/migrations/deploy.ts +++ b/basics/close-account/anchor/migrations/deploy.ts @@ -2,7 +2,7 @@ // single deploy script that's invoked from the CLI, injecting a provider // configured from the workspace's Anchor.toml. -const anchor = require("@project-serum/anchor"); +const anchor = require("@coral-xyz/anchor"); module.exports = async function (provider) { // Configure client to use the provider. diff --git a/basics/close-account/anchor/package.json b/basics/close-account/anchor/package.json index 12ad64a84..7ce74a967 100644 --- a/basics/close-account/anchor/package.json +++ b/basics/close-account/anchor/package.json @@ -1,19 +1,19 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@project-serum/anchor": "^0.25.0" - }, - "devDependencies": { - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "typescript": "^4.3.5", - "prettier": "^2.6.2" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "typescript": "^4.3.5", + "prettier": "^2.6.2" + } } diff --git a/basics/close-account/anchor/tests/close-account.ts b/basics/close-account/anchor/tests/close-account.ts index 72394beca..8dde0730c 100644 --- a/basics/close-account/anchor/tests/close-account.ts +++ b/basics/close-account/anchor/tests/close-account.ts @@ -1,82 +1,99 @@ -import * as anchor from "@project-serum/anchor"; -import { Program } from "@project-serum/anchor"; -import {Keypair, LAMPORTS_PER_SOL} from "@solana/web3.js"; +import * as anchor from "@coral-xyz/anchor"; +import { Program } from "@coral-xyz/anchor"; +import { Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js"; import { CloseAccountProgram } from "../target/types/close_account_program"; -import {BlockheightBasedTransactionConfirmationStrategy, PublicKey} from "@solana/web3.js"; +import { + BlockheightBasedTransactionConfirmationStrategy, + PublicKey, +} from "@solana/web3.js"; import assert from "assert"; describe("close-an-account", () => { - // Configure the client to use the local cluster. - anchor.setProvider(anchor.AnchorProvider.env()); + // Configure the client to use the local cluster. + anchor.setProvider(anchor.AnchorProvider.env()); - const program = anchor.workspace.CloseAccountProgram as Program; - const connection = program.provider.connection; - const payer = Keypair.generate(); + const program = anchor.workspace + .CloseAccountProgram as Program; + const connection = program.provider.connection; + const payer = Keypair.generate(); - async function airdrop(receiver: PublicKey, amount: number) { - const sig = await program.provider.connection.requestAirdrop(receiver, amount); - const blockStats = await program.provider.connection.getLatestBlockhash(); - const strategy: BlockheightBasedTransactionConfirmationStrategy = { - signature: sig, - blockhash: blockStats.blockhash, - lastValidBlockHeight: blockStats.lastValidBlockHeight - } - await program.provider.connection.confirmTransaction(strategy, "confirmed"); - } + async function airdrop(receiver: PublicKey, amount: number) { + const sig = await program.provider.connection.requestAirdrop( + receiver, + amount + ); + const blockStats = await program.provider.connection.getLatestBlockhash(); + const strategy: BlockheightBasedTransactionConfirmationStrategy = { + signature: sig, + blockhash: blockStats.blockhash, + lastValidBlockHeight: blockStats.lastValidBlockHeight, + }; + await program.provider.connection.confirmTransaction(strategy, "confirmed"); + } - function getUserAccount(user: PublicKey): [PublicKey, number] { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("USER"), - user.toBuffer() - ], program.programId) - } + function getUserAccount(user: PublicKey): [PublicKey, number] { + return PublicKey.findProgramAddressSync( + [Buffer.from("USER"), user.toBuffer()], + program.programId + ); + } - it("Airdrop", async () => { - const balanceBefore = await connection.getBalance(payer.publicKey); - await airdrop(payer.publicKey, LAMPORTS_PER_SOL); - const balanceAfter = await connection.getBalance(payer.publicKey); - assert.equal(balanceAfter, balanceBefore + LAMPORTS_PER_SOL); - }); + it("Airdrop", async () => { + const balanceBefore = await connection.getBalance(payer.publicKey); + await airdrop(payer.publicKey, LAMPORTS_PER_SOL); + const balanceAfter = await connection.getBalance(payer.publicKey); + assert.equal(balanceAfter, balanceBefore + LAMPORTS_PER_SOL); + }); + it("Create Account", async () => { + const [userAccountAddress] = getUserAccount(payer.publicKey); + const userAccountBefore = await program.account.user.fetchNullable( + userAccountAddress, + "confirmed" + ); + assert.equal(userAccountBefore, null); - it("Create Account", async () => { - const [userAccountAddress] = getUserAccount(payer.publicKey); - const userAccountBefore = await program.account.user.fetchNullable(userAccountAddress, "confirmed"); - assert.equal(userAccountBefore, null); + await program.methods + .createUser({ + name: "John Doe", + }) + .accounts({ + payer: payer.publicKey, + userAccount: userAccountAddress, + }) + .signers([payer]) + .rpc({ commitment: "confirmed", skipPreflight: true }); - await program.methods - .createUser({ - name: "John Doe" - }) - .accounts({ - payer: payer.publicKey, - userAccount: userAccountAddress - }) - .signers([payer]) - .rpc({commitment: "confirmed", skipPreflight: true}); + const userAccountAfter = await program.account.user.fetchNullable( + userAccountAddress, + "confirmed" + ); + assert.notEqual(userAccountAfter, null); + assert.equal(userAccountAfter.name, "John Doe"); + assert.equal(userAccountAfter.user.toBase58(), payer.publicKey.toBase58()); + }); - const userAccountAfter = await program.account.user.fetchNullable(userAccountAddress, "confirmed"); - assert.notEqual(userAccountAfter, null); - assert.equal(userAccountAfter.name, "John Doe"); - assert.equal(userAccountAfter.user.toBase58(), payer.publicKey.toBase58()); - }) + it("Close Account", async () => { + const [userAccountAddress] = getUserAccount(payer.publicKey); + const userAccountBefore = await program.account.user.fetchNullable( + userAccountAddress, + "confirmed" + ); + assert.notEqual(userAccountBefore, null); - it("Close Account", async () => { - const [userAccountAddress] = getUserAccount(payer.publicKey); - const userAccountBefore = await program.account.user.fetchNullable(userAccountAddress, "confirmed"); - assert.notEqual(userAccountBefore, null); + await program.methods + .closeUser() + .accounts({ + user: payer.publicKey, + userAccount: userAccountAddress, + }) + .signers([payer]) + .rpc({ commitment: "confirmed" }); - await program.methods - .closeUser() - .accounts({ - user: payer.publicKey, - userAccount: userAccountAddress - }) - .signers([payer]) - .rpc({commitment: "confirmed"}); - - const userAccountAfter = await program.account.user.fetchNullable(userAccountAddress, "processed"); - assert.equal(userAccountAfter, null); - }) + const userAccountAfter = await program.account.user.fetchNullable( + userAccountAddress, + "processed" + ); + assert.equal(userAccountAfter, null); + }); }); diff --git a/basics/counter/anchor/migrations/deploy.ts b/basics/counter/anchor/migrations/deploy.ts index 5e3df0dc3..82fb175fa 100644 --- a/basics/counter/anchor/migrations/deploy.ts +++ b/basics/counter/anchor/migrations/deploy.ts @@ -2,7 +2,7 @@ // single deploy script that's invoked from the CLI, injecting a provider // configured from the workspace's Anchor.toml. -const anchor = require("@project-serum/anchor"); +const anchor = require("@coral-xyz/anchor"); module.exports = async function (provider) { // Configure client to use the provider. diff --git a/basics/counter/anchor/package.json b/basics/counter/anchor/package.json index 12ad64a84..7ce74a967 100644 --- a/basics/counter/anchor/package.json +++ b/basics/counter/anchor/package.json @@ -1,19 +1,19 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@project-serum/anchor": "^0.25.0" - }, - "devDependencies": { - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "typescript": "^4.3.5", - "prettier": "^2.6.2" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "typescript": "^4.3.5", + "prettier": "^2.6.2" + } } diff --git a/basics/counter/anchor/tests/counter_anchor.ts b/basics/counter/anchor/tests/counter_anchor.ts index 151086f9a..cabb4f26f 100644 --- a/basics/counter/anchor/tests/counter_anchor.ts +++ b/basics/counter/anchor/tests/counter_anchor.ts @@ -1,8 +1,6 @@ -import * as anchor from "@project-serum/anchor"; -import { Program } from "@project-serum/anchor"; -import { - Keypair -} from '@solana/web3.js' +import * as anchor from "@coral-xyz/anchor"; +import { Program } from "@coral-xyz/anchor"; +import { Keypair } from "@solana/web3.js"; import { assert } from "chai"; import { CounterAnchor } from "../target/types/counter_anchor"; @@ -22,7 +20,9 @@ describe("counter_anchor", () => { .accounts({ counter, payer: program.provider.publicKey }) .signers([counterKeypair]) .rpc({ skipPreflight: true, commitment: "confirmed" }); - let currentCount = (await program.account.counter.fetch(counter, "confirmed")).count.toNumber(); + let currentCount = ( + await program.account.counter.fetch(counter, "confirmed") + ).count.toNumber(); assert(currentCount === 0, "Expected initialized count to be 0"); // Increment counter @@ -30,7 +30,9 @@ describe("counter_anchor", () => { .increment() .accounts({ counter }) .rpc({ skipPreflight: true, commitment: "confirmed" }); - currentCount = (await program.account.counter.fetch(counter, "confirmed")).count.toNumber(); + currentCount = ( + await program.account.counter.fetch(counter, "confirmed") + ).count.toNumber(); assert(currentCount === 1, "Expected count to be 1"); // Increment counter @@ -38,7 +40,9 @@ describe("counter_anchor", () => { .increment() .accounts({ counter }) .rpc({ skipPreflight: true, commitment: "confirmed" }); - currentCount = (await program.account.counter.fetch(counter, "confirmed")).count.toNumber(); + currentCount = ( + await program.account.counter.fetch(counter, "confirmed") + ).count.toNumber(); assert(currentCount === 2, "Expected count to be 2"); }); }); diff --git a/basics/counter/seahorse/migrations/deploy.ts b/basics/counter/seahorse/migrations/deploy.ts index 5e3df0dc3..82fb175fa 100644 --- a/basics/counter/seahorse/migrations/deploy.ts +++ b/basics/counter/seahorse/migrations/deploy.ts @@ -2,7 +2,7 @@ // single deploy script that's invoked from the CLI, injecting a provider // configured from the workspace's Anchor.toml. -const anchor = require("@project-serum/anchor"); +const anchor = require("@coral-xyz/anchor"); module.exports = async function (provider) { // Configure client to use the provider. diff --git a/basics/counter/seahorse/package.json b/basics/counter/seahorse/package.json index 12ad64a84..7ce74a967 100644 --- a/basics/counter/seahorse/package.json +++ b/basics/counter/seahorse/package.json @@ -1,19 +1,19 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@project-serum/anchor": "^0.25.0" - }, - "devDependencies": { - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "typescript": "^4.3.5", - "prettier": "^2.6.2" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "typescript": "^4.3.5", + "prettier": "^2.6.2" + } } diff --git a/basics/counter/seahorse/tests/counter_seahorse.ts b/basics/counter/seahorse/tests/counter_seahorse.ts index 816fa0186..7d9c5a159 100644 --- a/basics/counter/seahorse/tests/counter_seahorse.ts +++ b/basics/counter/seahorse/tests/counter_seahorse.ts @@ -1,10 +1,6 @@ -import * as anchor from "@project-serum/anchor"; -import { Program } from "@project-serum/anchor"; -import { - Keypair, - PublicKey, - SystemProgram -} from '@solana/web3.js'; +import * as anchor from "@coral-xyz/anchor"; +import { Program } from "@coral-xyz/anchor"; +import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js"; import { assert } from "chai"; import { CounterSeahorse } from "../target/types/counter_seahorse"; @@ -33,11 +29,13 @@ describe("counter_seahorse", () => { await program.methods .increment() .accounts({ - counter + counter, }) .rpc(); - const count = (await program.account.counter.fetch(counter)).count.toNumber(); + const count = ( + await program.account.counter.fetch(counter) + ).count.toNumber(); assert(count === 1, "Expected count to be 1"); }); }); diff --git a/basics/create-account/anchor/package.json b/basics/create-account/anchor/package.json index bcd1eb4c9..ab411155f 100644 --- a/basics/create-account/anchor/package.json +++ b/basics/create-account/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/create-account/anchor/tests/test.ts b/basics/create-account/anchor/tests/test.ts index ccbb288b4..fcbb04191 100644 --- a/basics/create-account/anchor/tests/test.ts +++ b/basics/create-account/anchor/tests/test.ts @@ -1,26 +1,24 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { CreateSystemAccount } from "../target/types/create_system_account"; - describe("Create a system account", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const wallet = provider.wallet as anchor.Wallet; - const program = anchor.workspace.CreateSystemAccount as anchor.Program; + const program = anchor.workspace + .CreateSystemAccount as anchor.Program; it("Create the account", async () => { - const newKeypair = anchor.web3.Keypair.generate(); - - await program.methods.createSystemAccount() - .accounts({ - payer: wallet.publicKey, - newAccount: newKeypair.publicKey, - systemProgram: anchor.web3.SystemProgram.programId - }) - .signers([wallet.payer, newKeypair]) - .rpc(); + await program.methods + .createSystemAccount() + .accounts({ + payer: wallet.publicKey, + newAccount: newKeypair.publicKey, + systemProgram: anchor.web3.SystemProgram.programId, + }) + .signers([wallet.payer, newKeypair]) + .rpc(); }); }); diff --git a/basics/cross-program-invocation/anchor/package.json b/basics/cross-program-invocation/anchor/package.json index bcd1eb4c9..ab411155f 100644 --- a/basics/cross-program-invocation/anchor/package.json +++ b/basics/cross-program-invocation/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/cross-program-invocation/anchor/tests/test.ts b/basics/cross-program-invocation/anchor/tests/test.ts index a981d6e5d..ab72afcbc 100644 --- a/basics/cross-program-invocation/anchor/tests/test.ts +++ b/basics/cross-program-invocation/anchor/tests/test.ts @@ -1,9 +1,8 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { Hand } from "../target/types/hand"; import { Lever } from "../target/types/lever"; describe("CPI Example", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const hand = anchor.workspace.Hand as anchor.Program; @@ -12,37 +11,34 @@ describe("CPI Example", () => { const powerAccount = anchor.web3.Keypair.generate(); it("Initialize the lever!", async () => { - - await lever.methods.initialize() - .accounts({ - power: powerAccount.publicKey, - user: provider.wallet.publicKey, - systemProgram: anchor.web3.SystemProgram.programId, - }) - .signers([powerAccount]) - .rpc(); - + await lever.methods + .initialize() + .accounts({ + power: powerAccount.publicKey, + user: provider.wallet.publicKey, + systemProgram: anchor.web3.SystemProgram.programId, + }) + .signers([powerAccount]) + .rpc(); }); it("Pull the lever!", async () => { - - await hand.methods.pullLever("Chris") - .accounts({ - power: powerAccount.publicKey, - leverProgram: lever.programId, - }) - .rpc(); - + await hand.methods + .pullLever("Chris") + .accounts({ + power: powerAccount.publicKey, + leverProgram: lever.programId, + }) + .rpc(); }); it("Pull it again!", async () => { - - await hand.methods.pullLever("Ashley") - .accounts({ - power: powerAccount.publicKey, - leverProgram: lever.programId, - }) - .rpc(); - + await hand.methods + .pullLever("Ashley") + .accounts({ + power: powerAccount.publicKey, + leverProgram: lever.programId, + }) + .rpc(); }); }); diff --git a/basics/hello-solana/anchor/package.json b/basics/hello-solana/anchor/package.json index bcd1eb4c9..ab411155f 100644 --- a/basics/hello-solana/anchor/package.json +++ b/basics/hello-solana/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/hello-solana/anchor/tests/test.ts b/basics/hello-solana/anchor/tests/test.ts index b7e1fb693..5ff886423 100644 --- a/basics/hello-solana/anchor/tests/test.ts +++ b/basics/hello-solana/anchor/tests/test.ts @@ -1,8 +1,7 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { HelloSolana } from "../target/types/hello_solana"; describe("hello-solana", () => { - // Configure the Anchor provider & load the program IDL // The IDL gives you a typescript module // @@ -11,12 +10,8 @@ describe("hello-solana", () => { const program = anchor.workspace.HelloSolana as anchor.Program; it("Say hello!", async () => { - // Just run Anchor's IDL method to build a transaction! // - await program.methods.hello() - .accounts({}) - .rpc(); - + await program.methods.hello().accounts({}).rpc(); }); }); diff --git a/basics/hello-solana/seahorse/hello_solana/migrations/deploy.ts b/basics/hello-solana/seahorse/hello_solana/migrations/deploy.ts index 5e3df0dc3..82fb175fa 100644 --- a/basics/hello-solana/seahorse/hello_solana/migrations/deploy.ts +++ b/basics/hello-solana/seahorse/hello_solana/migrations/deploy.ts @@ -2,7 +2,7 @@ // single deploy script that's invoked from the CLI, injecting a provider // configured from the workspace's Anchor.toml. -const anchor = require("@project-serum/anchor"); +const anchor = require("@coral-xyz/anchor"); module.exports = async function (provider) { // Configure client to use the provider. diff --git a/basics/hello-solana/seahorse/hello_solana/package.json b/basics/hello-solana/seahorse/hello_solana/package.json index 87e752216..03847224a 100644 --- a/basics/hello-solana/seahorse/hello_solana/package.json +++ b/basics/hello-solana/seahorse/hello_solana/package.json @@ -1,19 +1,19 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "prettier": "^2.6.2", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "prettier": "^2.6.2", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/hello-solana/seahorse/hello_solana/tests/hello_solana.ts b/basics/hello-solana/seahorse/hello_solana/tests/hello_solana.ts index 2d3d48076..4a1890b5d 100644 --- a/basics/hello-solana/seahorse/hello_solana/tests/hello_solana.ts +++ b/basics/hello-solana/seahorse/hello_solana/tests/hello_solana.ts @@ -1,8 +1,7 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { HelloSolana } from "../target/types/hello_solana"; describe("hello_solana", () => { - // Configure the client to use the local cluster. const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); @@ -10,14 +9,14 @@ describe("hello_solana", () => { const payer = provider.wallet as anchor.Wallet; it("Say hello!", async () => { - // Just run Anchor's IDL method to build a transaction // and sign it via a signer. - await program.methods.hello() - .accounts({ - signer: provider.wallet.publicKey, - }) - .signers([payer.payer]) - .rpc(); + await program.methods + .hello() + .accounts({ + signer: provider.wallet.publicKey, + }) + .signers([payer.payer]) + .rpc(); }); }); diff --git a/basics/pda-rent-payer/anchor/package.json b/basics/pda-rent-payer/anchor/package.json index bcd1eb4c9..ab411155f 100644 --- a/basics/pda-rent-payer/anchor/package.json +++ b/basics/pda-rent-payer/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/pda-rent-payer/anchor/tests/test.ts b/basics/pda-rent-payer/anchor/tests/test.ts index 4f55f65d7..ea130a5dd 100644 --- a/basics/pda-rent-payer/anchor/tests/test.ts +++ b/basics/pda-rent-payer/anchor/tests/test.ts @@ -1,42 +1,43 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { PdaRentPayer } from "../target/types/pda_rent_payer"; describe("PDA Rent-Payer", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const wallet = provider.wallet as anchor.Wallet; const program = anchor.workspace.PdaRentPayer as anchor.Program; function deriveRentVaultPda() { - const pda = anchor.web3.PublicKey.findProgramAddressSync( - [Buffer.from("rent_vault")], - program.programId, - ) - console.log(`PDA: ${pda[0].toBase58()}`) - return pda + const pda = anchor.web3.PublicKey.findProgramAddressSync( + [Buffer.from("rent_vault")], + program.programId + ); + console.log(`PDA: ${pda[0].toBase58()}`); + return pda; } it("Initialize the Rent Vault", async () => { - const [rentVaultPda, _] = deriveRentVaultPda(); - await program.methods.initRentVault(new anchor.BN(1000000000)) - .accounts({ - rentVault: rentVaultPda, - payer: wallet.publicKey, - }) - .signers([wallet.payer]) - .rpc() + const [rentVaultPda, _] = deriveRentVaultPda(); + await program.methods + .initRentVault(new anchor.BN(1000000000)) + .accounts({ + rentVault: rentVaultPda, + payer: wallet.publicKey, + }) + .signers([wallet.payer]) + .rpc(); }); it("Create a new account using the Rent Vault", async () => { - const newAccount = anchor.web3.Keypair.generate(); - const [rentVaultPda, _] = deriveRentVaultPda(); - await program.methods.createNewAccount() - .accounts({ - newAccount: newAccount.publicKey, - rentVault: rentVaultPda, - }) - .signers([wallet.payer]) - .rpc() + const newAccount = anchor.web3.Keypair.generate(); + const [rentVaultPda, _] = deriveRentVaultPda(); + await program.methods + .createNewAccount() + .accounts({ + newAccount: newAccount.publicKey, + rentVault: rentVaultPda, + }) + .signers([wallet.payer]) + .rpc(); }); }); diff --git a/basics/processing-instructions/anchor/package.json b/basics/processing-instructions/anchor/package.json index bcd1eb4c9..ab411155f 100644 --- a/basics/processing-instructions/anchor/package.json +++ b/basics/processing-instructions/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/processing-instructions/anchor/tests/test.ts b/basics/processing-instructions/anchor/tests/test.ts index 4e26283b0..cb2ae1c8d 100644 --- a/basics/processing-instructions/anchor/tests/test.ts +++ b/basics/processing-instructions/anchor/tests/test.ts @@ -1,23 +1,16 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { ProcessingInstructions } from "../target/types/processing_instructions"; - describe("custom-instruction-data", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); - const program = anchor.workspace.ProcessingInstructions as anchor.Program; + const program = anchor.workspace + .ProcessingInstructions as anchor.Program; it("Go to the park!", async () => { - // Again, Anchor makes it super simple. // - await program.methods.goToPark("Jimmy", 3) - .accounts({}) - .rpc(); - await program.methods.goToPark("Mary", 10) - .accounts({}) - .rpc(); - + await program.methods.goToPark("Jimmy", 3).accounts({}).rpc(); + await program.methods.goToPark("Mary", 10).accounts({}).rpc(); }); }); diff --git a/basics/program-derived-addresses/anchor/package.json b/basics/program-derived-addresses/anchor/package.json index bcd1eb4c9..ab411155f 100644 --- a/basics/program-derived-addresses/anchor/package.json +++ b/basics/program-derived-addresses/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/program-derived-addresses/anchor/tests/test.ts b/basics/program-derived-addresses/anchor/tests/test.ts index c3349810f..8ce42912c 100644 --- a/basics/program-derived-addresses/anchor/tests/test.ts +++ b/basics/program-derived-addresses/anchor/tests/test.ts @@ -1,12 +1,12 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { AnchorProgramExample } from "../target/types/anchor_program_example"; describe("PDAs", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const payer = provider.wallet as anchor.Wallet; - const program = anchor.workspace.AnchorProgramExample as anchor.Program; + const program = anchor.workspace + .AnchorProgramExample as anchor.Program; let testUser = anchor.web3.Keypair.generate(); @@ -30,12 +30,13 @@ describe("PDAs", () => { function derivePageVisitsPda(userPubkey: anchor.web3.PublicKey) { return anchor.web3.PublicKey.findProgramAddressSync( [Buffer.from("page_visits"), userPubkey.toBuffer()], - program.programId, - )[0] + program.programId + )[0]; } it("Create the page visits tracking PDA", async () => { - await program.methods.createPageVisits() + await program.methods + .createPageVisits() .accounts({ pageVisits: derivePageVisitsPda(testUser.publicKey), user: testUser.publicKey, @@ -47,7 +48,8 @@ describe("PDAs", () => { }); it("Visit the page!", async () => { - await program.methods.incrementPageVisits() + await program.methods + .incrementPageVisits() .accounts({ pageVisits: derivePageVisitsPda(testUser.publicKey), user: testUser.publicKey, @@ -58,7 +60,8 @@ describe("PDAs", () => { }); it("Visit the page!", async () => { - await program.methods.incrementPageVisits() + await program.methods + .incrementPageVisits() .accounts({ pageVisits: derivePageVisitsPda(testUser.publicKey), user: testUser.publicKey, diff --git a/basics/rent/anchor/package.json b/basics/rent/anchor/package.json index dd6d2d7ed..ab411155f 100644 --- a/basics/rent/anchor/package.json +++ b/basics/rent/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "0.25.0" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/rent/anchor/tests/test.ts b/basics/rent/anchor/tests/test.ts index d014c9157..bac228f21 100644 --- a/basics/rent/anchor/tests/test.ts +++ b/basics/rent/anchor/tests/test.ts @@ -1,37 +1,37 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { RentExample, IDL } from "../target/types/rent_example"; - describe("Create a system account", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const wallet = provider.wallet as anchor.Wallet; const program = anchor.workspace.RentExample as anchor.Program; it("Create the account", async () => { - const newKeypair = anchor.web3.Keypair.generate(); const addressData: anchor.IdlTypes["AddressData"] = { name: "Marcus", - address: "123 Main St. San Francisco, CA" + address: "123 Main St. San Francisco, CA", }; // We're just going to serialize our object here so we can check // the size on the client side against the program logs // - const addressDataBuffer = new anchor.BorshCoder(IDL).types.encode("AddressData", addressData); + const addressDataBuffer = new anchor.BorshCoder(IDL).types.encode( + "AddressData", + addressData + ); console.log(`Address data buffer length: ${addressDataBuffer.length}`); - - await program.methods.createSystemAccount(addressData) - .accounts({ - payer: wallet.publicKey, - newAccount: newKeypair.publicKey, - systemProgram: anchor.web3.SystemProgram.programId - }) - .signers([wallet.payer, newKeypair]) - .rpc(); + await program.methods + .createSystemAccount(addressData) + .accounts({ + payer: wallet.publicKey, + newAccount: newKeypair.publicKey, + systemProgram: anchor.web3.SystemProgram.programId, + }) + .signers([wallet.payer, newKeypair]) + .rpc(); }); }); diff --git a/basics/repository-layout/anchor/package.json b/basics/repository-layout/anchor/package.json index bcd1eb4c9..ab411155f 100644 --- a/basics/repository-layout/anchor/package.json +++ b/basics/repository-layout/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/repository-layout/anchor/tests/test.ts b/basics/repository-layout/anchor/tests/test.ts index beb5c95dd..44ea7482b 100644 --- a/basics/repository-layout/anchor/tests/test.ts +++ b/basics/repository-layout/anchor/tests/test.ts @@ -1,57 +1,56 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { Carnival } from "../target/types/carnival"; - - describe("Carnival", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const wallet = provider.wallet as anchor.Wallet; const program = anchor.workspace.Carnival as anchor.Program; - async function sendCarnivalInstructions(instructionsList: anchor.web3.TransactionInstruction[]) { + async function sendCarnivalInstructions( + instructionsList: anchor.web3.TransactionInstruction[] + ) { let tx = new anchor.web3.Transaction(); for (var ix of instructionsList) { - tx.add(ix); - }; - await anchor.web3.sendAndConfirmTransaction( - provider.connection, - tx, - [wallet.payer] - ); -} - + tx.add(ix); + } + await anchor.web3.sendAndConfirmTransaction(provider.connection, tx, [ + wallet.payer, + ]); + } it("Go on some rides!", async () => { - await sendCarnivalInstructions([ - await program.methods.goOnRide("Jimmy", 36, 15, "Scrambler").instruction(), - await program.methods.goOnRide("Mary", 52, 1, "Ferris Wheel").instruction(), - await program.methods.goOnRide("Alice", 56, 15, "Scrambler").instruction(), - await program.methods.goOnRide("Bob", 49, 6, "Tilt-a-Whirl").instruction(), + await program.methods + .goOnRide("Jimmy", 36, 15, "Scrambler") + .instruction(), + await program.methods + .goOnRide("Mary", 52, 1, "Ferris Wheel") + .instruction(), + await program.methods + .goOnRide("Alice", 56, 15, "Scrambler") + .instruction(), + await program.methods + .goOnRide("Bob", 49, 6, "Tilt-a-Whirl") + .instruction(), ]); }); - it("Play some games!", async () => { - await sendCarnivalInstructions([ - await program.methods.playGame("Jimmy", 15, "I Got It!").instruction(), - await program.methods.playGame("Mary", 1, "Ring Toss").instruction(), - await program.methods.playGame("Alice", 15, "Ladder Climb").instruction(), - await program.methods.playGame("Bob", 6, "Ring Toss").instruction(), + await program.methods.playGame("Jimmy", 15, "I Got It!").instruction(), + await program.methods.playGame("Mary", 1, "Ring Toss").instruction(), + await program.methods.playGame("Alice", 15, "Ladder Climb").instruction(), + await program.methods.playGame("Bob", 6, "Ring Toss").instruction(), ]); }); - it("Eat some food!", async () => { - await sendCarnivalInstructions([ - await program.methods.eatFood("Jimmy", 15, "Taco Shack").instruction(), - await program.methods.eatFood("Mary", 1, "Larry's Pizza").instruction(), - await program.methods.eatFood("Alice", 15, "Dough Boy's").instruction(), - await program.methods.eatFood("Bob", 6, "Dough Boy's").instruction(), + await program.methods.eatFood("Jimmy", 15, "Taco Shack").instruction(), + await program.methods.eatFood("Mary", 1, "Larry's Pizza").instruction(), + await program.methods.eatFood("Alice", 15, "Dough Boy's").instruction(), + await program.methods.eatFood("Bob", 6, "Dough Boy's").instruction(), ]); }); }); diff --git a/basics/transfer-sol/anchor/package.json b/basics/transfer-sol/anchor/package.json index bcd1eb4c9..ab411155f 100644 --- a/basics/transfer-sol/anchor/package.json +++ b/basics/transfer-sol/anchor/package.json @@ -1,14 +1,14 @@ { - "dependencies": { - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/basics/transfer-sol/anchor/tests/test.ts b/basics/transfer-sol/anchor/tests/test.ts index 48288f177..b6a5e8c67 100644 --- a/basics/transfer-sol/anchor/tests/test.ts +++ b/basics/transfer-sol/anchor/tests/test.ts @@ -1,8 +1,7 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { TransferSol } from "../target/types/transfer_sol"; describe("transfer-sol", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const payer = provider.wallet as anchor.Wallet; @@ -14,10 +13,10 @@ describe("transfer-sol", () => { const test2Recipient2 = anchor.web3.Keypair.generate(); it("Transfer between accounts using the system program", async () => { - await getBalances(payer.publicKey, test1Recipient.publicKey, "Beginning"); - - await program.methods.transferSolWithCpi(new anchor.BN(transferAmount)) + + await program.methods + .transferSolWithCpi(new anchor.BN(transferAmount)) .accounts({ payer: payer.publicKey, recipient: test1Recipient.publicKey, @@ -27,11 +26,9 @@ describe("transfer-sol", () => { .rpc(); await getBalances(payer.publicKey, test1Recipient.publicKey, "Resulting"); - }); it("Create two accounts for the following test", async () => { - const ix = (pubkey: anchor.web3.PublicKey) => { return anchor.web3.SystemProgram.createAccount({ fromPubkey: payer.publicKey, @@ -39,24 +36,27 @@ describe("transfer-sol", () => { space: 0, lamports: 2 * anchor.web3.LAMPORTS_PER_SOL, programId: program.programId, - }) + }); }; await anchor.web3.sendAndConfirmTransaction( provider.connection, new anchor.web3.Transaction() .add(ix(test2Recipient1.publicKey)) - .add(ix(test2Recipient2.publicKey)) - , + .add(ix(test2Recipient2.publicKey)), [payer.payer, test2Recipient1, test2Recipient2] ); }); it("Transfer between accounts using our program", async () => { + await getBalances( + test2Recipient1.publicKey, + test2Recipient2.publicKey, + "Beginning" + ); - await getBalances(test2Recipient1.publicKey, test2Recipient2.publicKey, "Beginning"); - - await program.methods.transferSolWithProgram(new anchor.BN(transferAmount)) + await program.methods + .transferSolWithProgram(new anchor.BN(transferAmount)) .accounts({ payer: test2Recipient1.publicKey, recipient: test2Recipient2.publicKey, @@ -64,20 +64,24 @@ describe("transfer-sol", () => { }) .rpc(); - await getBalances(test2Recipient1.publicKey, test2Recipient2.publicKey, "Resulting"); - + await getBalances( + test2Recipient1.publicKey, + test2Recipient2.publicKey, + "Resulting" + ); }); async function getBalances( - payerPubkey: anchor.web3.PublicKey, - recipientPubkey: anchor.web3.PublicKey, + payerPubkey: anchor.web3.PublicKey, + recipientPubkey: anchor.web3.PublicKey, timeframe: string ) { - let payerBalance = await provider.connection.getBalance(payerPubkey); - let recipientBalance = await provider.connection.getBalance(recipientPubkey); + let recipientBalance = await provider.connection.getBalance( + recipientPubkey + ); console.log(`${timeframe} balances:`); console.log(` Payer: ${payerBalance}`); console.log(` Recipient: ${recipientBalance}`); - }; + } }); diff --git a/basics/transfer-sol/seahorse/package.json b/basics/transfer-sol/seahorse/package.json index 4de1ab3c2..7ce74a967 100644 --- a/basics/transfer-sol/seahorse/package.json +++ b/basics/transfer-sol/seahorse/package.json @@ -1,19 +1,19 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@coral-xyz/anchor": "^0.27.0" - }, - "devDependencies": { - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "typescript": "^4.3.5", - "prettier": "^2.6.2" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "typescript": "^4.3.5", + "prettier": "^2.6.2" + } } diff --git a/compression/cnft-vault/anchor/package.json b/compression/cnft-vault/anchor/package.json index ce1198451..fd19b2ee7 100644 --- a/compression/cnft-vault/anchor/package.json +++ b/compression/cnft-vault/anchor/package.json @@ -1,22 +1,22 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@metaplex-foundation/mpl-bubblegum": "^0.6.2", - "@project-serum/anchor": "^0.26.0", - "@solana/spl-account-compression": "^0.1.8", - "axios": "^1.4.0" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "prettier": "^2.6.2", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0", + "@metaplex-foundation/mpl-bubblegum": "^0.6.2", + "@solana/spl-account-compression": "^0.1.8", + "axios": "^1.4.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "prettier": "^2.6.2", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/compression/cnft-vault/anchor/tests/scripts/constants.ts b/compression/cnft-vault/anchor/tests/scripts/constants.ts index f104bc11d..4cbdbed1f 100644 --- a/compression/cnft-vault/anchor/tests/scripts/constants.ts +++ b/compression/cnft-vault/anchor/tests/scripts/constants.ts @@ -1,11 +1,15 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { CnftVault } from "../../target/types/cnft_vault"; import { loadWalletKey } from "../utils"; -import { IDL } from "../../target/types/cnft_vault" +import { IDL } from "../../target/types/cnft_vault"; -export const connection = new anchor.web3.Connection("https://api.devnet.solana.com"); +export const connection = new anchor.web3.Connection( + "https://api.devnet.solana.com" +); export const keypair = loadWalletKey("~/.config/solana/id.json"); export const wallet = new anchor.Wallet(keypair); export const provider = new anchor.AnchorProvider(connection, wallet, {}); -export const programID = new anchor.web3.PublicKey("CNftyK7T8udPwYRzZUMWzbh79rKrz9a5GwV2wv7iEHpk") -export const program = new anchor.Program(IDL, programID, provider); \ No newline at end of file +export const programID = new anchor.web3.PublicKey( + "CNftyK7T8udPwYRzZUMWzbh79rKrz9a5GwV2wv7iEHpk" +); +export const program = new anchor.Program(IDL, programID, provider); diff --git a/compression/cnft-vault/anchor/tests/scripts/withdraw.ts b/compression/cnft-vault/anchor/tests/scripts/withdraw.ts index 9c23d5828..3dbe63ce4 100644 --- a/compression/cnft-vault/anchor/tests/scripts/withdraw.ts +++ b/compression/cnft-vault/anchor/tests/scripts/withdraw.ts @@ -1,7 +1,10 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { decode, mapProof } from "../utils"; import { PROGRAM_ID as BUBBLEGUM_PROGRAM_ID } from "@metaplex-foundation/mpl-bubblegum"; -import { SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, SPL_NOOP_PROGRAM_ID } from "@solana/spl-account-compression"; +import { + SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, + SPL_NOOP_PROGRAM_ID, +} from "@solana/spl-account-compression"; import { getAsset, getAssetProof } from "../readAPI"; import { program, programID } from "./constants"; @@ -9,16 +12,20 @@ import { program, programID } from "./constants"; async function main() { const [vaultPDA, _bump] = anchor.web3.PublicKey.findProgramAddressSync( [Buffer.from("cNFT-vault", "utf8")], - programID, + programID ); - const tree = new anchor.web3.PublicKey("trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B") + const tree = new anchor.web3.PublicKey( + "trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B" + ); - const receiver = new anchor.web3.PublicKey("Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM") + const receiver = new anchor.web3.PublicKey( + "Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM" + ); const [treeAuthority, _bump2] = anchor.web3.PublicKey.findProgramAddressSync( [tree.toBuffer()], - BUBBLEGUM_PROGRAM_ID, + BUBBLEGUM_PROGRAM_ID ); const assetId = "DGWU3mHenDerCvjkeDsKYEbsvXbWvqdo1bVoXy3dkeTd"; @@ -34,7 +41,8 @@ async function main() { const nonce = new anchor.BN(asset.compression.leaf_id); const index = asset.compression.leaf_id; - const tx = await program.methods.withdrawCnft(root, dataHash, creatorHash, nonce, index) + const tx = await program.methods + .withdrawCnft(root, dataHash, creatorHash, nonce, index) .accounts({ leafOwner: vaultPDA, merkleTree: tree, @@ -43,11 +51,11 @@ async function main() { bubblegumProgram: BUBBLEGUM_PROGRAM_ID, compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, logWrapper: SPL_NOOP_PROGRAM_ID, - systemProgram: anchor.web3.SystemProgram.programId + systemProgram: anchor.web3.SystemProgram.programId, }) .remainingAccounts(proofPathAsAccounts) .rpc(); console.log(tx); -}; +} -main(); \ No newline at end of file +main(); diff --git a/compression/cnft-vault/anchor/tests/scripts/withdrawTwo.ts b/compression/cnft-vault/anchor/tests/scripts/withdrawTwo.ts index 8fb410bfd..d2b250038 100644 --- a/compression/cnft-vault/anchor/tests/scripts/withdrawTwo.ts +++ b/compression/cnft-vault/anchor/tests/scripts/withdrawTwo.ts @@ -1,37 +1,47 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { decode, mapProof } from "../utils"; import { PROGRAM_ID as BUBBLEGUM_PROGRAM_ID } from "@metaplex-foundation/mpl-bubblegum"; -import { SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, SPL_NOOP_PROGRAM_ID } from "@solana/spl-account-compression"; +import { + SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, + SPL_NOOP_PROGRAM_ID, +} from "@solana/spl-account-compression"; import { getAsset, getAssetProof } from "../readAPI"; import { AccountMeta } from "@solana/web3.js"; import { program, programID } from "./constants"; async function main() { - // TODO change all of these to your values const assetId1 = "DGWU3mHenDerCvjkeDsKYEbsvXbWvqdo1bVoXy3dkeTd"; - const assetId2 = "14JojSTdBZvP7f77rCxB3oQK78skTVD6DiXrXUL4objg";//"D2CoMLCRfsfv1EAiNbaBHfoU1Sqf1964KXLGxEfyUwWo"; + const assetId2 = "14JojSTdBZvP7f77rCxB3oQK78skTVD6DiXrXUL4objg"; //"D2CoMLCRfsfv1EAiNbaBHfoU1Sqf1964KXLGxEfyUwWo"; - const tree1 = new anchor.web3.PublicKey("trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B") - const tree2 = new anchor.web3.PublicKey("Feywkti8LLBLfxhSGmYgzUBqpq89qehfB1SMTYV1zCu") + const tree1 = new anchor.web3.PublicKey( + "trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B" + ); + const tree2 = new anchor.web3.PublicKey( + "Feywkti8LLBLfxhSGmYgzUBqpq89qehfB1SMTYV1zCu" + ); - const receiver1 = new anchor.web3.PublicKey("Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM") - const receiver2 = new anchor.web3.PublicKey("Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM") + const receiver1 = new anchor.web3.PublicKey( + "Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM" + ); + const receiver2 = new anchor.web3.PublicKey( + "Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM" + ); // --- const [vaultPDA, _bump] = anchor.web3.PublicKey.findProgramAddressSync( [Buffer.from("cNFT-vault", "utf8")], - programID, + programID ); const [treeAuthority1, _bump2] = anchor.web3.PublicKey.findProgramAddressSync( [tree1.toBuffer()], - BUBBLEGUM_PROGRAM_ID, + BUBBLEGUM_PROGRAM_ID ); const [treeAuthority2, _bump3] = anchor.web3.PublicKey.findProgramAddressSync( [tree2.toBuffer()], - BUBBLEGUM_PROGRAM_ID, + BUBBLEGUM_PROGRAM_ID ); const asset1 = await getAsset(assetId1); @@ -45,9 +55,13 @@ async function main() { const ixData1 = getInstructionData(asset1, proof1); const ixData2 = getInstructionData(asset2, proof2); - const remainingAccounts: AccountMeta[] = [...proofPathAsAccounts1, ...proofPathAsAccounts2]; + const remainingAccounts: AccountMeta[] = [ + ...proofPathAsAccounts1, + ...proofPathAsAccounts2, + ]; - const tx = await program.methods.withdrawTwoCnfts(...ixData1, ...ixData2) + const tx = await program.methods + .withdrawTwoCnfts(...ixData1, ...ixData2) .accounts({ leafOwner: vaultPDA, merkleTree1: tree1, @@ -59,15 +73,17 @@ async function main() { bubblegumProgram: BUBBLEGUM_PROGRAM_ID, compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, logWrapper: SPL_NOOP_PROGRAM_ID, - systemProgram: anchor.web3.SystemProgram.programId + systemProgram: anchor.web3.SystemProgram.programId, }) .remainingAccounts(remainingAccounts) .rpc(); console.log(tx); -}; +} -function getInstructionData(asset: any, proof: any): - [number[], number[], number[], anchor.BN, number, number] { +function getInstructionData( + asset: any, + proof: any +): [number[], number[], number[], anchor.BN, number, number] { const root = decode(proof.root); const dataHash = decode(asset.compression.data_hash); const creatorHash = decode(asset.compression.creator_hash); @@ -77,4 +93,4 @@ function getInstructionData(asset: any, proof: any): return [root, dataHash, creatorHash, nonce, index, proofLength]; } -main(); \ No newline at end of file +main(); diff --git a/compression/cnft-vault/anchor/tests/scripts/withdrawWithLookup.ts b/compression/cnft-vault/anchor/tests/scripts/withdrawWithLookup.ts index 9395f0714..a82821509 100644 --- a/compression/cnft-vault/anchor/tests/scripts/withdrawWithLookup.ts +++ b/compression/cnft-vault/anchor/tests/scripts/withdrawWithLookup.ts @@ -1,39 +1,58 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { decode, mapProof } from "../utils"; import { PROGRAM_ID as BUBBLEGUM_PROGRAM_ID } from "@metaplex-foundation/mpl-bubblegum"; -import { SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, SPL_NOOP_PROGRAM_ID } from "@solana/spl-account-compression"; +import { + SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, + SPL_NOOP_PROGRAM_ID, +} from "@solana/spl-account-compression"; import { getAsset, getAssetProof } from "../readAPI"; -import { AccountMeta, AddressLookupTableProgram, PublicKey, SystemProgram, Transaction, TransactionMessage, VersionedTransaction, sendAndConfirmTransaction } from "@solana/web3.js"; +import { + AccountMeta, + AddressLookupTableProgram, + PublicKey, + SystemProgram, + Transaction, + TransactionMessage, + VersionedTransaction, + sendAndConfirmTransaction, +} from "@solana/web3.js"; import { connection, keypair, program, programID } from "./constants"; async function main() { - // TODO change all of these to your values const assetId1 = "DGWU3mHenDerCvjkeDsKYEbsvXbWvqdo1bVoXy3dkeTd"; - const assetId2 = "14JojSTdBZvP7f77rCxB3oQK78skTVD6DiXrXUL4objg";//"D2CoMLCRfsfv1EAiNbaBHfoU1Sqf1964KXLGxEfyUwWo"; + const assetId2 = "14JojSTdBZvP7f77rCxB3oQK78skTVD6DiXrXUL4objg"; //"D2CoMLCRfsfv1EAiNbaBHfoU1Sqf1964KXLGxEfyUwWo"; - const tree1 = new anchor.web3.PublicKey("trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B") - const tree2 = new anchor.web3.PublicKey("trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B") + const tree1 = new anchor.web3.PublicKey( + "trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B" + ); + const tree2 = new anchor.web3.PublicKey( + "trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B" + ); - const receiver1 = new anchor.web3.PublicKey("Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM") - const receiver2 = new anchor.web3.PublicKey("Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM") + const receiver1 = new anchor.web3.PublicKey( + "Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM" + ); + const receiver2 = new anchor.web3.PublicKey( + "Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM" + ); // --- const lookupTable = await createLookupTable(); const [vaultPDA, _bump] = anchor.web3.PublicKey.findProgramAddressSync( [Buffer.from("cNFT-vault", "utf8")], - programID, + programID ); const [treeAuthority1, _bump2] = anchor.web3.PublicKey.findProgramAddressSync( [tree1.toBuffer()], - BUBBLEGUM_PROGRAM_ID, + BUBBLEGUM_PROGRAM_ID ); const [treeAuthority2, _bump3] = anchor.web3.PublicKey.findProgramAddressSync( [tree2.toBuffer()], - BUBBLEGUM_PROGRAM_ID, + BUBBLEGUM_PROGRAM_ID ); const asset1 = await getAsset(assetId1); @@ -47,9 +66,13 @@ async function main() { const ixData1 = getInstructionData(asset1, proof1); const ixData2 = getInstructionData(asset2, proof2); - const remainingAccounts: AccountMeta[] = [...proofPathAsAccounts1, ...proofPathAsAccounts2]; + const remainingAccounts: AccountMeta[] = [ + ...proofPathAsAccounts1, + ...proofPathAsAccounts2, + ]; - const ix = await program.methods.withdrawTwoCnfts(...ixData1, ...ixData2) + const ix = await program.methods + .withdrawTwoCnfts(...ixData1, ...ixData2) .accounts({ leafOwner: vaultPDA, merkleTree1: tree1, @@ -61,14 +84,19 @@ async function main() { bubblegumProgram: BUBBLEGUM_PROGRAM_ID, compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, logWrapper: SPL_NOOP_PROGRAM_ID, - systemProgram: anchor.web3.SystemProgram.programId + systemProgram: anchor.web3.SystemProgram.programId, }) .remainingAccounts(remainingAccounts) .instruction(); - - await extendLookupTable(lookupTable, proofPathAsAccounts1.map(acc => acc.pubkey)); - await extendLookupTable(lookupTable, proofPathAsAccounts2.map(acc => acc.pubkey)); + await extendLookupTable( + lookupTable, + proofPathAsAccounts1.map((acc) => acc.pubkey) + ); + await extendLookupTable( + lookupTable, + proofPathAsAccounts2.map((acc) => acc.pubkey) + ); const lookupTableAccount = await connection .getAddressLookupTable(lookupTable) @@ -79,7 +107,7 @@ async function main() { return; } - await new Promise(_ => setTimeout(_, 30000)); + await new Promise((_) => setTimeout(_, 30000)); const messageV0 = new TransactionMessage({ payerKey: keypair.publicKey, @@ -92,10 +120,12 @@ async function main() { const txid = await connection.sendTransaction(transactionV0); console.log(txid); -}; +} -function getInstructionData(asset: any, proof: any): - [number[], number[], number[], anchor.BN, number, number] { +function getInstructionData( + asset: any, + proof: any +): [number[], number[], number[], anchor.BN, number, number] { const root = decode(proof.root); const dataHash = decode(asset.compression.data_hash); const creatorHash = decode(asset.compression.creator_hash); @@ -107,21 +137,23 @@ function getInstructionData(asset: any, proof: any): main(); -async function extendLookupTable(lookupTableAddress: PublicKey, proofHashes: PublicKey[]) { - +async function extendLookupTable( + lookupTableAddress: PublicKey, + proofHashes: PublicKey[] +) { const extendInstruction = AddressLookupTableProgram.extendLookupTable({ payer: keypair.publicKey, authority: keypair.publicKey, lookupTable: lookupTableAddress, - addresses: [ - ...proofHashes - ], + addresses: [...proofHashes], }); const tx = new Transaction(); tx.add(extendInstruction); - const sx = await sendAndConfirmTransaction(connection, tx, [keypair], { commitment: "finalized" }); + const sx = await sendAndConfirmTransaction(connection, tx, [keypair], { + commitment: "finalized", + }); console.log(sx); console.log("ALT extended!"); } @@ -154,7 +186,9 @@ async function createLookupTable(): Promise { const tx = new Transaction(); tx.add(lookupTableInst).add(extendInstruction); - const sx = await sendAndConfirmTransaction(connection, tx, [keypair], { commitment: "finalized" }); + const sx = await sendAndConfirmTransaction(connection, tx, [keypair], { + commitment: "finalized", + }); console.log(sx); console.log("ALT created"); diff --git a/compression/cnft-vault/anchor/tests/tests.ts b/compression/cnft-vault/anchor/tests/tests.ts index 41fef66f1..f4b591f8d 100644 --- a/compression/cnft-vault/anchor/tests/tests.ts +++ b/compression/cnft-vault/anchor/tests/tests.ts @@ -1,131 +1,147 @@ -import * as anchor from "@project-serum/anchor"; +import * as anchor from "@coral-xyz/anchor"; import { loadWalletKey, decode, mapProof } from "./utils"; -import { IDL, CnftVault } from "../target/types/cnft_vault" +import { IDL, CnftVault } from "../target/types/cnft_vault"; import { PROGRAM_ID as BUBBLEGUM_PROGRAM_ID } from "@metaplex-foundation/mpl-bubblegum"; -import { SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, SPL_NOOP_PROGRAM_ID } from "@solana/spl-account-compression"; +import { + SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, + SPL_NOOP_PROGRAM_ID, +} from "@solana/spl-account-compression"; import { getAsset, getAssetProof } from "./readAPI"; import { AccountMeta } from "@solana/web3.js"; describe("cNFT Vault", () => { - - const provider = anchor.AnchorProvider.env(); - anchor.setProvider(provider); - const payer = provider.wallet as anchor.Wallet; - const program = anchor.workspace.CnftVault as anchor.Program; - - const [vaultPDA, _bump] = anchor.web3.PublicKey.findProgramAddressSync( - [Buffer.from("cNFT-vault", "utf8")], - program.programId, + const provider = anchor.AnchorProvider.env(); + anchor.setProvider(provider); + const payer = provider.wallet as anchor.Wallet; + const program = anchor.workspace.CnftVault as anchor.Program; + + const [vaultPDA, _bump] = anchor.web3.PublicKey.findProgramAddressSync( + [Buffer.from("cNFT-vault", "utf8")], + program.programId + ); + console.log("Vault address: " + vaultPDA.toBase58()); + + it("Withdraw a cNFT!", async () => { + // we expect the cNFT to already be in the vault + // you can send it there (to vaultPDA) using any regular wallet + // the cNFT has the following asset id + const assetId = "DGWU3mHenDerCvjkeDsKYEbsvXbWvqdo1bVoXy3dkeTd"; // TODO + // and is compressed in the following tree + const tree = new anchor.web3.PublicKey( + "trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B" + ); // TODO + + const receiver = payer.publicKey; // you can define any pubkey as the receiver here + + const [treeAuthority, _bump2] = + anchor.web3.PublicKey.findProgramAddressSync( + [tree.toBuffer()], + BUBBLEGUM_PROGRAM_ID + ); + + const asset = await getAsset(assetId); + + const proof = await getAssetProof(assetId); + const proofPathAsAccounts = mapProof(proof); + + const root = decode(proof.root); + const dataHash = decode(asset.compression.data_hash); + const creatorHash = decode(asset.compression.creator_hash); + const nonce = new anchor.BN(asset.compression.leaf_id); + const index = asset.compression.leaf_id; + + const sx = await program.methods + .withdrawCnft(root, dataHash, creatorHash, nonce, index) + .accounts({ + leafOwner: vaultPDA, + merkleTree: tree, + newLeafOwner: receiver, + treeAuthority: treeAuthority, + bubblegumProgram: BUBBLEGUM_PROGRAM_ID, + compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, + logWrapper: SPL_NOOP_PROGRAM_ID, + systemProgram: anchor.web3.SystemProgram.programId, + }) + .remainingAccounts(proofPathAsAccounts) + .rpc(); + + console.log("Success!"); + console.log(` Tx Signature: ${sx}`); + }); + + it("Withdraw two cNFTs!", async () => { + // TODO change all of these to your values + const assetId1 = "DGWU3mHenDerCvjkeDsKYEbsvXbWvqdo1bVoXy3dkeTd"; + const assetId2 = "14JojSTdBZvP7f77rCxB3oQK78skTVD6DiXrXUL4objg"; + + const tree1 = new anchor.web3.PublicKey( + "trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B" + ); + const tree2 = new anchor.web3.PublicKey( + "Feywkti8LLBLfxhSGmYgzUBqpq89qehfB1SMTYV1zCu" ); - console.log("Vault address: " + vaultPDA.toBase58()); - - it("Withdraw a cNFT!", async () => { - - // we expect the cNFT to already be in the vault - // you can send it there (to vaultPDA) using any regular wallet - // the cNFT has the following asset id - const assetId = "DGWU3mHenDerCvjkeDsKYEbsvXbWvqdo1bVoXy3dkeTd"; // TODO - // and is compressed in the following tree - const tree = new anchor.web3.PublicKey("trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B"); // TODO - - const receiver = payer.publicKey; // you can define any pubkey as the receiver here - - const [treeAuthority, _bump2] = anchor.web3.PublicKey.findProgramAddressSync( - [tree.toBuffer()], - BUBBLEGUM_PROGRAM_ID, - ); - - const asset = await getAsset(assetId); - - const proof = await getAssetProof(assetId); - const proofPathAsAccounts = mapProof(proof); - - const root = decode(proof.root); - const dataHash = decode(asset.compression.data_hash); - const creatorHash = decode(asset.compression.creator_hash); - const nonce = new anchor.BN(asset.compression.leaf_id); - const index = asset.compression.leaf_id; - - const sx = await program.methods.withdrawCnft(root, dataHash, creatorHash, nonce, index) - .accounts({ - leafOwner: vaultPDA, - merkleTree: tree, - newLeafOwner: receiver, - treeAuthority: treeAuthority, - bubblegumProgram: BUBBLEGUM_PROGRAM_ID, - compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, - logWrapper: SPL_NOOP_PROGRAM_ID, - systemProgram: anchor.web3.SystemProgram.programId - }) - .remainingAccounts(proofPathAsAccounts) - .rpc(); - - console.log("Success!"); - console.log(` Tx Signature: ${sx}`); - }); - - - it("Withdraw two cNFTs!", async () => { - - // TODO change all of these to your values - const assetId1 = "DGWU3mHenDerCvjkeDsKYEbsvXbWvqdo1bVoXy3dkeTd"; - const assetId2 = "14JojSTdBZvP7f77rCxB3oQK78skTVD6DiXrXUL4objg"; - - const tree1 = new anchor.web3.PublicKey("trezdkTFPKyj4gE9LAJYPpxn8AYVCvM7Mc4JkTb9X5B") - const tree2 = new anchor.web3.PublicKey("Feywkti8LLBLfxhSGmYgzUBqpq89qehfB1SMTYV1zCu") - - const receiver1 = new anchor.web3.PublicKey("Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM") - const receiver2 = new anchor.web3.PublicKey("Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM") - // --- - - const [treeAuthority1, _bump2] = anchor.web3.PublicKey.findProgramAddressSync( - [tree1.toBuffer()], - BUBBLEGUM_PROGRAM_ID, - ); - const [treeAuthority2, _bump3] = anchor.web3.PublicKey.findProgramAddressSync( - [tree2.toBuffer()], - BUBBLEGUM_PROGRAM_ID, - ); - - const asset1 = await getAsset(assetId1); - const asset2 = await getAsset(assetId2); - - const proof1 = await getAssetProof(assetId1); - const proofPathAsAccounts1 = mapProof(proof1); - const proof2 = await getAssetProof(assetId2); - const proofPathAsAccounts2 = mapProof(proof2); - - const ixData1 = getInstructionData(asset1, proof1); - const ixData2 = getInstructionData(asset2, proof2); - - const remainingAccounts: AccountMeta[] = [...proofPathAsAccounts1, ...proofPathAsAccounts2]; - - const sx = await program.methods.withdrawTwoCnfts(...ixData1, ...ixData2) - .accounts({ - leafOwner: vaultPDA, - merkleTree1: tree1, - newLeafOwner1: receiver1, - treeAuthority1: treeAuthority1, - merkleTree2: tree2, - newLeafOwner2: receiver2, - treeAuthority2: treeAuthority2, - bubblegumProgram: BUBBLEGUM_PROGRAM_ID, - compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, - logWrapper: SPL_NOOP_PROGRAM_ID, - systemProgram: anchor.web3.SystemProgram.programId - }) - .remainingAccounts(remainingAccounts) - .rpc(); - console.log("Success!"); - console.log(` Tx Signature: ${sx}`); - }); - + const receiver1 = new anchor.web3.PublicKey( + "Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM" + ); + const receiver2 = new anchor.web3.PublicKey( + "Andys9wuoMdUeRiZLgRS5aJwYNFv4Ut6qQi8PNDTAPEM" + ); + // --- + + const [treeAuthority1, _bump2] = + anchor.web3.PublicKey.findProgramAddressSync( + [tree1.toBuffer()], + BUBBLEGUM_PROGRAM_ID + ); + const [treeAuthority2, _bump3] = + anchor.web3.PublicKey.findProgramAddressSync( + [tree2.toBuffer()], + BUBBLEGUM_PROGRAM_ID + ); + + const asset1 = await getAsset(assetId1); + const asset2 = await getAsset(assetId2); + + const proof1 = await getAssetProof(assetId1); + const proofPathAsAccounts1 = mapProof(proof1); + const proof2 = await getAssetProof(assetId2); + const proofPathAsAccounts2 = mapProof(proof2); + + const ixData1 = getInstructionData(asset1, proof1); + const ixData2 = getInstructionData(asset2, proof2); + + const remainingAccounts: AccountMeta[] = [ + ...proofPathAsAccounts1, + ...proofPathAsAccounts2, + ]; + + const sx = await program.methods + .withdrawTwoCnfts(...ixData1, ...ixData2) + .accounts({ + leafOwner: vaultPDA, + merkleTree1: tree1, + newLeafOwner1: receiver1, + treeAuthority1: treeAuthority1, + merkleTree2: tree2, + newLeafOwner2: receiver2, + treeAuthority2: treeAuthority2, + bubblegumProgram: BUBBLEGUM_PROGRAM_ID, + compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, + logWrapper: SPL_NOOP_PROGRAM_ID, + systemProgram: anchor.web3.SystemProgram.programId, + }) + .remainingAccounts(remainingAccounts) + .rpc(); + console.log("Success!"); + console.log(` Tx Signature: ${sx}`); + }); }); - -function getInstructionData(asset: any, proof: any): - [number[], number[], number[], anchor.BN, number, number] { +function getInstructionData( + asset: any, + proof: any +): [number[], number[], number[], anchor.BN, number, number] { const root = decode(proof.root); const dataHash = decode(asset.compression.data_hash); const creatorHash = decode(asset.compression.creator_hash); @@ -133,4 +149,4 @@ function getInstructionData(asset: any, proof: any): const index = asset.compression.leaf_id; const proofLength = proof.proof.length; return [root, dataHash, creatorHash, nonce, index, proofLength]; -} \ No newline at end of file +} diff --git a/compression/cutils/package.json b/compression/cutils/package.json index 5b1ce7fdc..c08b28080 100644 --- a/compression/cutils/package.json +++ b/compression/cutils/package.json @@ -1,26 +1,26 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@coral-xyz/anchor": "^0.27.0", - "@metaplex-foundation/js": "^0.19.4", - "@metaplex-foundation/mpl-bubblegum": "^0.7.0", - "@solana/spl-account-compression": "^0.1.8", - "@solana/spl-token": "^0.3.8", - "@solana/web3.js": "^1.77.3", - "axios": "^1.4.0" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "prettier": "^2.6.2", - "ts-mocha": "^10.0.0", - "ts-node": "^10.9.1", - "typescript": "^4.3.5" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0", + "@metaplex-foundation/js": "^0.19.4", + "@metaplex-foundation/mpl-bubblegum": "^0.7.0", + "@solana/spl-account-compression": "^0.1.8", + "@solana/spl-token": "^0.3.8", + "@solana/web3.js": "^1.77.3", + "axios": "^1.4.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "prettier": "^2.6.2", + "ts-mocha": "^10.0.0", + "ts-node": "^10.9.1", + "typescript": "^4.3.5" + } } diff --git a/oracles/pyth/anchor/package.json b/oracles/pyth/anchor/package.json index 4de1ab3c2..7ce74a967 100644 --- a/oracles/pyth/anchor/package.json +++ b/oracles/pyth/anchor/package.json @@ -1,19 +1,19 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@coral-xyz/anchor": "^0.27.0" - }, - "devDependencies": { - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "typescript": "^4.3.5", - "prettier": "^2.6.2" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "typescript": "^4.3.5", + "prettier": "^2.6.2" + } } diff --git a/oracles/pyth/seahorse/package.json b/oracles/pyth/seahorse/package.json index 4de1ab3c2..7ce74a967 100644 --- a/oracles/pyth/seahorse/package.json +++ b/oracles/pyth/seahorse/package.json @@ -1,19 +1,19 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@coral-xyz/anchor": "^0.27.0" - }, - "devDependencies": { - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "typescript": "^4.3.5", - "prettier": "^2.6.2" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "typescript": "^4.3.5", + "prettier": "^2.6.2" + } } diff --git a/tokens/create-token/anchor/package.json b/tokens/create-token/anchor/package.json index 2f0e5c079..6d7b261f4 100644 --- a/tokens/create-token/anchor/package.json +++ b/tokens/create-token/anchor/package.json @@ -1,7 +1,7 @@ { "dependencies": { - "@metaplex-foundation/mpl-token-metadata": "^2.5.2", - "@project-serum/anchor": "^0.24.2" + "@coral-xyz/anchor": "^0.28.0", + "@metaplex-foundation/mpl-token-metadata": "^2.5.2" }, "devDependencies": { "@types/bn.js": "^5.1.0", diff --git a/tokens/create-token/anchor/tests/test.ts b/tokens/create-token/anchor/tests/test.ts index 29e708e77..d14ea37e3 100644 --- a/tokens/create-token/anchor/tests/test.ts +++ b/tokens/create-token/anchor/tests/test.ts @@ -1,12 +1,8 @@ -import { - PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID -} from '@metaplex-foundation/mpl-token-metadata'; -import * as anchor from "@project-serum/anchor"; +import { PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; +import * as anchor from "@coral-xyz/anchor"; import { CreateToken } from "../target/types/create_token"; - describe("Create Tokens", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const payer = provider.wallet as anchor.Wallet; @@ -14,26 +10,27 @@ describe("Create Tokens", () => { const tokenTitle = "Solana Gold"; const tokenSymbol = "GOLDSOL"; - const tokenUri = "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json"; + const tokenUri = + "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json"; it("Create an SPL Token!", async () => { - const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); - const metadataAddress = (await anchor.web3.PublicKey.findProgramAddress( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mintKeypair.publicKey.toBuffer(), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; + const metadataAddress = ( + await anchor.web3.PublicKey.findProgramAddress( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mintKeypair.publicKey.toBuffer(), + ], + TOKEN_METADATA_PROGRAM_ID + ) + )[0]; // SPL Token default = 9 decimals // - const sx = await program.methods.createTokenMint( - tokenTitle, tokenSymbol, tokenUri, 9 - ) + const sx = await program.methods + .createTokenMint(tokenTitle, tokenSymbol, tokenUri, 9) .accounts({ metadataAccount: metadataAddress, mintAccount: mintKeypair.publicKey, @@ -48,28 +45,28 @@ describe("Create Tokens", () => { .rpc(); console.log("Success!"); - console.log(` Mint Address: ${mintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${mintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); it("Create an NFT!", async () => { - const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); - const metadataAddress = (await anchor.web3.PublicKey.findProgramAddress( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mintKeypair.publicKey.toBuffer(), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; + const metadataAddress = ( + await anchor.web3.PublicKey.findProgramAddress( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mintKeypair.publicKey.toBuffer(), + ], + TOKEN_METADATA_PROGRAM_ID + ) + )[0]; // NFT default = 0 decimals // - const sx = await program.methods.createTokenMint( - tokenTitle, tokenSymbol, tokenUri, 0 - ) + const sx = await program.methods + .createTokenMint(tokenTitle, tokenSymbol, tokenUri, 0) .accounts({ metadataAccount: metadataAddress, mintAccount: mintKeypair.publicKey, @@ -84,7 +81,7 @@ describe("Create Tokens", () => { .rpc(); console.log("Success!"); - console.log(` Mint Address: ${mintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${mintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); }); diff --git a/tokens/nft-minter/anchor/package.json b/tokens/nft-minter/anchor/package.json index 2f0e5c079..24770e41c 100644 --- a/tokens/nft-minter/anchor/package.json +++ b/tokens/nft-minter/anchor/package.json @@ -1,15 +1,15 @@ { - "dependencies": { - "@metaplex-foundation/mpl-token-metadata": "^2.5.2", - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@metaplex-foundation/mpl-token-metadata": "^2.5.2", + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/tokens/nft-minter/anchor/tests/test.ts b/tokens/nft-minter/anchor/tests/test.ts index 0c559ba0f..44352bbad 100644 --- a/tokens/nft-minter/anchor/tests/test.ts +++ b/tokens/nft-minter/anchor/tests/test.ts @@ -1,13 +1,9 @@ -import { - PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID -} from '@metaplex-foundation/mpl-token-metadata'; -import * as anchor from "@project-serum/anchor"; -import { ASSOCIATED_PROGRAM_ID } from '@project-serum/anchor/dist/cjs/utils/token'; +import { PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; +import * as anchor from "@coral-xyz/anchor"; +import { ASSOCIATED_PROGRAM_ID } from "@project-serum/anchor/dist/cjs/utils/token"; import { NftMinter } from "../target/types/nft_minter"; - describe("NFT Minter", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const payer = provider.wallet as anchor.Wallet; @@ -15,24 +11,23 @@ describe("NFT Minter", () => { const nftTitle = "Homer NFT"; const nftSymbol = "HOMR"; - const nftUri = "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/nft.json"; + const nftUri = + "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/nft.json"; const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); - - it("Create an NFT!", async () => { - const metadataAddress = (anchor.web3.PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mintKeypair.publicKey.toBuffer(), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; + it("Create an NFT!", async () => { + const metadataAddress = anchor.web3.PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mintKeypair.publicKey.toBuffer(), + ], + TOKEN_METADATA_PROGRAM_ID + )[0]; - const sx = await program.methods.createToken( - nftTitle, nftSymbol, nftUri - ) + const sx = await program.methods + .createToken(nftTitle, nftSymbol, nftUri) .accounts({ metadataAccount: metadataAddress, mintAccount: mintKeypair.publicKey, @@ -47,37 +42,38 @@ describe("NFT Minter", () => { .rpc(); console.log("Success!"); - console.log(` Mint Address: ${mintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${mintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); it("Mint the NFT to your wallet!", async () => { + const metadataAddress = anchor.web3.PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mintKeypair.publicKey.toBuffer(), + ], + TOKEN_METADATA_PROGRAM_ID + )[0]; - const metadataAddress = (anchor.web3.PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mintKeypair.publicKey.toBuffer(), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; + const editionAddress = anchor.web3.PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mintKeypair.publicKey.toBuffer(), + Buffer.from("edition"), + ], + TOKEN_METADATA_PROGRAM_ID + )[0]; - const editionAddress = (anchor.web3.PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mintKeypair.publicKey.toBuffer(), - Buffer.from("edition"), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; + const associatedTokenAccountAddress = + await anchor.utils.token.associatedAddress({ + mint: mintKeypair.publicKey, + owner: payer.publicKey, + }); - const associatedTokenAccountAddress = await anchor.utils.token.associatedAddress({ - mint: mintKeypair.publicKey, - owner: payer.publicKey, - }); - - const sx = await program.methods.mintTo() + const sx = await program.methods + .mintTo() .accounts({ associatedTokenAccount: associatedTokenAccountAddress, editionAccount: editionAddress, @@ -94,8 +90,8 @@ describe("NFT Minter", () => { .signers([payer.payer]) .rpc(); - console.log("Success!"); - console.log(` ATA Address: ${associatedTokenAccountAddress}`); - console.log(` Tx Signature: ${sx}`); + console.log("Success!"); + console.log(` ATA Address: ${associatedTokenAccountAddress}`); + console.log(` Tx Signature: ${sx}`); }); }); diff --git a/tokens/pda-mint-authority/anchor/package.json b/tokens/pda-mint-authority/anchor/package.json index 2f0e5c079..8e29c29a4 100644 --- a/tokens/pda-mint-authority/anchor/package.json +++ b/tokens/pda-mint-authority/anchor/package.json @@ -1,15 +1,15 @@ { - "dependencies": { - "@metaplex-foundation/mpl-token-metadata": "^2.5.2", - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0", + "@metaplex-foundation/mpl-token-metadata": "^2.5.2" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/tokens/pda-mint-authority/anchor/tests/test.ts b/tokens/pda-mint-authority/anchor/tests/test.ts index 57eb49691..d229a86aa 100644 --- a/tokens/pda-mint-authority/anchor/tests/test.ts +++ b/tokens/pda-mint-authority/anchor/tests/test.ts @@ -1,13 +1,9 @@ -import { - PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID -} from '@metaplex-foundation/mpl-token-metadata'; -import * as anchor from "@project-serum/anchor"; -import { ASSOCIATED_PROGRAM_ID } from '@project-serum/anchor/dist/cjs/utils/token'; +import { PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; +import * as anchor from "@coral-xyz/anchor"; +import { ASSOCIATED_PROGRAM_ID } from "@project-serum/anchor/dist/cjs/utils/token"; import { NftMinter } from "../target/types/nft_minter"; - describe("NFT Minter", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const payer = provider.wallet as anchor.Wallet; @@ -15,18 +11,19 @@ describe("NFT Minter", () => { const mintAuthorityPublicKey = anchor.web3.PublicKey.findProgramAddressSync( [Buffer.from("mint_authority")], - program.programId, + program.programId )[0]; const nftTitle = "Homer NFT"; const nftSymbol = "HOMR"; - const nftUri = "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/nft.json"; + const nftUri = + "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/nft.json"; const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); it("Init Mint Authority PDA", async () => { - - const sx = await program.methods.init() + const sx = await program.methods + .init() .accounts({ mintAuthority: mintAuthorityPublicKey, payer: payer.publicKey, @@ -35,24 +32,22 @@ describe("NFT Minter", () => { .rpc(); console.log("Success!"); - console.log(` Mint Authority: ${mintKeypair.publicKey}`); - console.log(` Tx Signature : ${sx}`); + console.log(` Mint Authority: ${mintKeypair.publicKey}`); + console.log(` Tx Signature : ${sx}`); }); - - it("Create an NFT!", async () => { - const metadataAddress = (anchor.web3.PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mintKeypair.publicKey.toBuffer(), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; - - const sx = await program.methods.createToken( - nftTitle, nftSymbol, nftUri - ) + it("Create an NFT!", async () => { + const metadataAddress = anchor.web3.PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mintKeypair.publicKey.toBuffer(), + ], + TOKEN_METADATA_PROGRAM_ID + )[0]; + + const sx = await program.methods + .createToken(nftTitle, nftSymbol, nftUri) .accounts({ metadataAccount: metadataAddress, mintAccount: mintKeypair.publicKey, @@ -64,40 +59,41 @@ describe("NFT Minter", () => { tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID, }) .signers([mintKeypair, payer.payer]) - .rpc({skipPreflight: true}); + .rpc({ skipPreflight: true }); console.log("Success!"); - console.log(` Mint Address: ${mintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${mintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); it("Mint the NFT to your wallet!", async () => { - - const metadataAddress = (anchor.web3.PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mintKeypair.publicKey.toBuffer(), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; - - const editionAddress = (anchor.web3.PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mintKeypair.publicKey.toBuffer(), - Buffer.from("edition"), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; - - const associatedTokenAccountAddress = await anchor.utils.token.associatedAddress({ - mint: mintKeypair.publicKey, - owner: payer.publicKey, - }); - - const sx = await program.methods.mintTo() + const metadataAddress = anchor.web3.PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mintKeypair.publicKey.toBuffer(), + ], + TOKEN_METADATA_PROGRAM_ID + )[0]; + + const editionAddress = anchor.web3.PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mintKeypair.publicKey.toBuffer(), + Buffer.from("edition"), + ], + TOKEN_METADATA_PROGRAM_ID + )[0]; + + const associatedTokenAccountAddress = + await anchor.utils.token.associatedAddress({ + mint: mintKeypair.publicKey, + owner: payer.publicKey, + }); + + const sx = await program.methods + .mintTo() .accounts({ associatedTokenAccount: associatedTokenAccountAddress, editionAccount: editionAddress, @@ -114,8 +110,8 @@ describe("NFT Minter", () => { .signers([payer.payer]) .rpc(); - console.log("Success!"); - console.log(` ATA Address: ${associatedTokenAccountAddress}`); - console.log(` Tx Signature: ${sx}`); + console.log("Success!"); + console.log(` ATA Address: ${associatedTokenAccountAddress}`); + console.log(` Tx Signature: ${sx}`); }); }); diff --git a/tokens/spl-token-minter/anchor/package.json b/tokens/spl-token-minter/anchor/package.json index 2f0e5c079..8e29c29a4 100644 --- a/tokens/spl-token-minter/anchor/package.json +++ b/tokens/spl-token-minter/anchor/package.json @@ -1,15 +1,15 @@ { - "dependencies": { - "@metaplex-foundation/mpl-token-metadata": "^2.5.2", - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0", + "@metaplex-foundation/mpl-token-metadata": "^2.5.2" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/tokens/spl-token-minter/anchor/tests/test.ts b/tokens/spl-token-minter/anchor/tests/test.ts index 03bcbfe18..4d2682ed4 100644 --- a/tokens/spl-token-minter/anchor/tests/test.ts +++ b/tokens/spl-token-minter/anchor/tests/test.ts @@ -1,38 +1,36 @@ -import { - PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID -} from '@metaplex-foundation/mpl-token-metadata'; -import * as anchor from "@project-serum/anchor"; -import { ASSOCIATED_PROGRAM_ID } from '@project-serum/anchor/dist/cjs/utils/token'; +import { PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; +import * as anchor from "@coral-xyz/anchor"; +import { ASSOCIATED_PROGRAM_ID } from "@project-serum/anchor/dist/cjs/utils/token"; import { SplTokenMinter } from "../target/types/spl_token_minter"; - describe("SPL Token Minter", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const payer = provider.wallet as anchor.Wallet; - const program = anchor.workspace.SplTokenMinter as anchor.Program; + const program = anchor.workspace + .SplTokenMinter as anchor.Program; const tokenTitle = "Solana Gold"; const tokenSymbol = "GOLDSOL"; - const tokenUri = "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json"; + const tokenUri = + "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json"; const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); - - it("Create an SPL Token!", async () => { - const metadataAddress = (await anchor.web3.PublicKey.findProgramAddress( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mintKeypair.publicKey.toBuffer(), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; + it("Create an SPL Token!", async () => { + const metadataAddress = ( + await anchor.web3.PublicKey.findProgramAddress( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mintKeypair.publicKey.toBuffer(), + ], + TOKEN_METADATA_PROGRAM_ID + ) + )[0]; - const sx = await program.methods.createToken( - tokenTitle, tokenSymbol, tokenUri - ) + const sx = await program.methods + .createToken(tokenTitle, tokenSymbol, tokenUri) .accounts({ metadataAccount: metadataAddress, mintAccount: mintKeypair.publicKey, @@ -47,20 +45,19 @@ describe("SPL Token Minter", () => { .rpc(); console.log("Success!"); - console.log(` Mint Address: ${mintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${mintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); it("Mint some tokens to your wallet!", async () => { + const associatedTokenAccountAddress = + await anchor.utils.token.associatedAddress({ + mint: mintKeypair.publicKey, + owner: payer.publicKey, + }); - const associatedTokenAccountAddress = await anchor.utils.token.associatedAddress({ - mint: mintKeypair.publicKey, - owner: payer.publicKey, - }); - - const sx = await program.methods.mintTo( - new anchor.BN(150) - ) + const sx = await program.methods + .mintTo(new anchor.BN(150)) .accounts({ associatedTokenAccount: associatedTokenAccountAddress, mintAccount: mintKeypair.publicKey, @@ -75,7 +72,7 @@ describe("SPL Token Minter", () => { .rpc(); console.log("Success!"); - console.log(` Mint Address: ${mintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${mintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); }); diff --git a/tokens/token-2022/basics/anchor/package.json b/tokens/token-2022/basics/anchor/package.json index b5355136b..7ce74a967 100644 --- a/tokens/token-2022/basics/anchor/package.json +++ b/tokens/token-2022/basics/anchor/package.json @@ -4,7 +4,7 @@ "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" }, "dependencies": { - "@coral-xyz/anchor": "^0.27.0" + "@coral-xyz/anchor": "^0.28.0" }, "devDependencies": { "chai": "^4.3.4", diff --git a/tokens/token-swap/anchor/package.json b/tokens/token-swap/anchor/package.json index 055b7b27e..4f0291154 100644 --- a/tokens/token-swap/anchor/package.json +++ b/tokens/token-swap/anchor/package.json @@ -1,20 +1,20 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@coral-xyz/anchor": "^0.27.0", - "@solana/spl-token": "^0.3.8" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "prettier": "^2.6.2", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0", + "@solana/spl-token": "^0.3.8" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "prettier": "^2.6.2", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/tokens/transfer-tokens/anchor/package.json b/tokens/transfer-tokens/anchor/package.json index 2f0e5c079..8e29c29a4 100644 --- a/tokens/transfer-tokens/anchor/package.json +++ b/tokens/transfer-tokens/anchor/package.json @@ -1,15 +1,15 @@ { - "dependencies": { - "@metaplex-foundation/mpl-token-metadata": "^2.5.2", - "@project-serum/anchor": "^0.24.2" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } + "dependencies": { + "@coral-xyz/anchor": "^0.28.0", + "@metaplex-foundation/mpl-token-metadata": "^2.5.2" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } } diff --git a/tokens/transfer-tokens/anchor/tests/test.ts b/tokens/transfer-tokens/anchor/tests/test.ts index 33485e0fa..50352f9bc 100644 --- a/tokens/transfer-tokens/anchor/tests/test.ts +++ b/tokens/transfer-tokens/anchor/tests/test.ts @@ -1,25 +1,21 @@ -import { - PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID -} from '@metaplex-foundation/mpl-token-metadata'; -import * as anchor from "@project-serum/anchor"; -import { ASSOCIATED_PROGRAM_ID } from '@project-serum/anchor/dist/cjs/utils/token'; +import { PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; +import * as anchor from "@coral-xyz/anchor"; +import { ASSOCIATED_PROGRAM_ID } from "@project-serum/anchor/dist/cjs/utils/token"; import { TransferTokens } from "../target/types/transfer_tokens"; - describe("Transfer Tokens", () => { - const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); const payer = provider.wallet as anchor.Wallet; - const program = anchor.workspace.TransferTokens as anchor.Program; + const program = anchor.workspace + .TransferTokens as anchor.Program; const tokenMintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); const nftMintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); - + const recipientWallet: anchor.web3.Keypair = anchor.web3.Keypair.generate(); it("Create an SPL Token!", async () => { - const metadataAddress = anchor.web3.PublicKey.findProgramAddressSync( [ Buffer.from("metadata"), @@ -29,12 +25,13 @@ describe("Transfer Tokens", () => { TOKEN_METADATA_PROGRAM_ID )[0]; - const sx = await program.methods.createToken( - "Solana Gold", - "GOLDSOL", - "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json", - 9, - ) + const sx = await program.methods + .createToken( + "Solana Gold", + "GOLDSOL", + "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json", + 9 + ) .accounts({ metadataAccount: metadataAddress, mintAccount: tokenMintKeypair.publicKey, @@ -49,12 +46,11 @@ describe("Transfer Tokens", () => { .rpc(); console.log("Success!"); - console.log(` Mint Address: ${tokenMintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${tokenMintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); it("Create an NFT!", async () => { - const metadataAddress = anchor.web3.PublicKey.findProgramAddressSync( [ Buffer.from("metadata"), @@ -64,12 +60,13 @@ describe("Transfer Tokens", () => { TOKEN_METADATA_PROGRAM_ID )[0]; - const sx = await program.methods.createToken( - "Homer NFT", - "HOMR", - "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/nft.json", - 0, - ) + const sx = await program.methods + .createToken( + "Homer NFT", + "HOMR", + "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/nft.json", + 0 + ) .accounts({ metadataAccount: metadataAddress, mintAccount: nftMintKeypair.publicKey, @@ -84,20 +81,19 @@ describe("Transfer Tokens", () => { .rpc(); console.log("Success!"); - console.log(` Mint Address: ${nftMintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${nftMintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); it("Mint some tokens to your wallet!", async () => { + const associatedTokenAccountAddress = + await anchor.utils.token.associatedAddress({ + mint: tokenMintKeypair.publicKey, + owner: payer.publicKey, + }); - const associatedTokenAccountAddress = await anchor.utils.token.associatedAddress({ - mint: tokenMintKeypair.publicKey, - owner: payer.publicKey, - }); - - const sx = await program.methods.mintSpl( - new anchor.BN(150) - ) + const sx = await program.methods + .mintSpl(new anchor.BN(150)) .accounts({ associatedTokenAccount: associatedTokenAccountAddress, mintAccount: tokenMintKeypair.publicKey, @@ -112,37 +108,38 @@ describe("Transfer Tokens", () => { .rpc(); console.log("Success!"); - console.log(` Mint Address: ${tokenMintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${tokenMintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); it("Mint the NFT to your wallet!", async () => { + const metadataAddress = anchor.web3.PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + nftMintKeypair.publicKey.toBuffer(), + ], + TOKEN_METADATA_PROGRAM_ID + )[0]; - const metadataAddress = (anchor.web3.PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - nftMintKeypair.publicKey.toBuffer(), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; - - const editionAddress = (anchor.web3.PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - nftMintKeypair.publicKey.toBuffer(), - Buffer.from("edition"), - ], - TOKEN_METADATA_PROGRAM_ID - ))[0]; - - const associatedTokenAccountAddress = await anchor.utils.token.associatedAddress({ - mint: nftMintKeypair.publicKey, - owner: payer.publicKey, - }); - - const sx = await program.methods.mintNft() + const editionAddress = anchor.web3.PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + nftMintKeypair.publicKey.toBuffer(), + Buffer.from("edition"), + ], + TOKEN_METADATA_PROGRAM_ID + )[0]; + + const associatedTokenAccountAddress = + await anchor.utils.token.associatedAddress({ + mint: nftMintKeypair.publicKey, + owner: payer.publicKey, + }); + + const sx = await program.methods + .mintNft() .accounts({ associatedTokenAccount: associatedTokenAccountAddress, editionAccount: editionAddress, @@ -159,36 +156,35 @@ describe("Transfer Tokens", () => { .signers([payer.payer]) .rpc(); - console.log("Success!"); - console.log(` ATA Address: ${associatedTokenAccountAddress}`); - console.log(` Tx Signature: ${sx}`); + console.log("Success!"); + console.log(` ATA Address: ${associatedTokenAccountAddress}`); + console.log(` Tx Signature: ${sx}`); }); it("Prep a new test wallet for transfers", async () => { - await provider.connection.confirmTransaction( - await provider.connection.requestAirdrop( - recipientWallet.publicKey, - await provider.connection.getMinimumBalanceForRentExemption(0), - ) + await provider.connection.requestAirdrop( + recipientWallet.publicKey, + await provider.connection.getMinimumBalanceForRentExemption(0) + ) ); console.log(`Recipient Pubkey: ${recipientWallet.publicKey}`); }); it("Transfer some tokens to another wallet!", async () => { - - const fromAssociatedTokenAccountAddress = await anchor.utils.token.associatedAddress({ - mint: tokenMintKeypair.publicKey, - owner: payer.publicKey, - }); - const toAssociatedTokenAccountAddress = await anchor.utils.token.associatedAddress({ - mint: tokenMintKeypair.publicKey, - owner: recipientWallet.publicKey, - }); - - const sx = await program.methods.transferTokens( - new anchor.BN(150) - ) + const fromAssociatedTokenAccountAddress = + await anchor.utils.token.associatedAddress({ + mint: tokenMintKeypair.publicKey, + owner: payer.publicKey, + }); + const toAssociatedTokenAccountAddress = + await anchor.utils.token.associatedAddress({ + mint: tokenMintKeypair.publicKey, + owner: recipientWallet.publicKey, + }); + + const sx = await program.methods + .transferTokens(new anchor.BN(150)) .accounts({ mintAccount: tokenMintKeypair.publicKey, fromAssociatedTokenAccount: fromAssociatedTokenAccountAddress, @@ -205,24 +201,24 @@ describe("Transfer Tokens", () => { .rpc(); console.log("Success!"); - console.log(` Mint Address: ${tokenMintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${tokenMintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); it("Transfer the NFT to another wallet!", async () => { - - const fromAssociatedTokenAccountAddress = await anchor.utils.token.associatedAddress({ - mint: nftMintKeypair.publicKey, - owner: payer.publicKey, - }); - const toAssociatedTokenAccountAddress = await anchor.utils.token.associatedAddress({ - mint: nftMintKeypair.publicKey, - owner: recipientWallet.publicKey, - }); - - const sx = await program.methods.transferTokens( - new anchor.BN(1) - ) + const fromAssociatedTokenAccountAddress = + await anchor.utils.token.associatedAddress({ + mint: nftMintKeypair.publicKey, + owner: payer.publicKey, + }); + const toAssociatedTokenAccountAddress = + await anchor.utils.token.associatedAddress({ + mint: nftMintKeypair.publicKey, + owner: recipientWallet.publicKey, + }); + + const sx = await program.methods + .transferTokens(new anchor.BN(1)) .accounts({ mintAccount: nftMintKeypair.publicKey, fromAssociatedTokenAccount: fromAssociatedTokenAccountAddress, @@ -239,7 +235,7 @@ describe("Transfer Tokens", () => { .rpc(); console.log("Success!"); - console.log(` Mint Address: ${nftMintKeypair.publicKey}`); - console.log(` Tx Signature: ${sx}`); + console.log(` Mint Address: ${nftMintKeypair.publicKey}`); + console.log(` Tx Signature: ${sx}`); }); }); diff --git a/tokens/transfer-tokens/seahorse/package.json b/tokens/transfer-tokens/seahorse/package.json index 4de1ab3c2..7ce74a967 100644 --- a/tokens/transfer-tokens/seahorse/package.json +++ b/tokens/transfer-tokens/seahorse/package.json @@ -1,19 +1,19 @@ { - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@coral-xyz/anchor": "^0.27.0" - }, - "devDependencies": { - "chai": "^4.3.4", - "mocha": "^9.0.3", - "ts-mocha": "^10.0.0", - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "typescript": "^4.3.5", - "prettier": "^2.6.2" - } + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "chai": "^4.3.4", + "mocha": "^9.0.3", + "ts-mocha": "^10.0.0", + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "typescript": "^4.3.5", + "prettier": "^2.6.2" + } }