From 09eb53433f5c174b01845de5517135a23f6eceaf Mon Sep 17 00:00:00 2001 From: adpthegreat Date: Tue, 29 Oct 2024 23:02:20 +0100 Subject: [PATCH] updated token-minter code --- .../pda_mint_authority_program/.gitignore | 7 - .../.prettierignore | 7 - .../pda_mint_authority_program/Anchor.toml | 18 --- .../pda_mint_authority_program/Cargo.toml | 14 -- .../migrations/deploy.ts | 12 -- .../pda_mint_authority_program/package.json | 20 --- .../pda_mint_authority_program/Cargo.toml | 20 --- .../pda_mint_authority_program/Xargo.toml | 2 - .../pda_mint_authority_program/src/lib.rs | 16 -- .../tests/pda_mint_authority_program.ts | 16 -- .../ts-programs/package.json | 15 -- .../ts-programs/pnpm-lock.yaml | 22 --- .../src/pda_mint_authority_program.ts | 46 ------ .../pda_mint_authority_program/tsconfig.json | 10 -- .../poseidon/token-minter/Anchor.toml | 2 +- .../token-minter/migrations/deploy.ts | 4 +- .../programs/token-minter/src/lib.rs | 45 ++++-- .../token-minter/tests/bankrun.test.ts | 142 +++++------------- .../poseidon/token-minter/tests/test.ts | 0 .../token-minter/tests/token-minter.ts | 12 +- .../token-minter/ts-programs/package.json | 2 +- .../token-minter/ts-programs/pnpm-lock.yaml | 10 +- .../ts-programs/src/token-minter.ts | 46 ++---- 23 files changed, 96 insertions(+), 392 deletions(-) delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/.gitignore delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/.prettierignore delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/Anchor.toml delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/Cargo.toml delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/migrations/deploy.ts delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/package.json delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/Cargo.toml delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/Xargo.toml delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/src/lib.rs delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/tests/pda_mint_authority_program.ts delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/package.json delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/pnpm-lock.yaml delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/src/pda_mint_authority_program.ts delete mode 100644 tokens/pda-mint-authority/poseidon/pda_mint_authority_program/tsconfig.json delete mode 100644 tokens/pda-mint-authority/poseidon/token-minter/tests/test.ts diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/.gitignore b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/.gitignore deleted file mode 100644 index 2e0446b07..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.anchor -.DS_Store -target -**/*.rs.bk -node_modules -test-ledger -.yarn diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/.prettierignore b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/.prettierignore deleted file mode 100644 index 414258343..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/.prettierignore +++ /dev/null @@ -1,7 +0,0 @@ -.anchor -.DS_Store -target -node_modules -dist -build -test-ledger diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/Anchor.toml b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/Anchor.toml deleted file mode 100644 index 76e685f64..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/Anchor.toml +++ /dev/null @@ -1,18 +0,0 @@ -[toolchain] - -[features] -resolution = true -skip-lint = false - -[programs.localnet] -pda_mint_authority_program = "2dR87YancKtdVJSxfyrYGRCGd7GqGCsC2v1RutTC6ozz" - -[registry] -url = "https://api.apr.dev" - -[provider] -cluster = "Localnet" -wallet = "~/.config/solana/id.json" - -[scripts] -test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/Cargo.toml b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/Cargo.toml deleted file mode 100644 index f39770481..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[workspace] -members = [ - "programs/*" -] -resolver = "2" - -[profile.release] -overflow-checks = true -lto = "fat" -codegen-units = 1 -[profile.release.build-override] -opt-level = 3 -incremental = false -codegen-units = 1 diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/migrations/deploy.ts b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/migrations/deploy.ts deleted file mode 100644 index 82fb175fa..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/migrations/deploy.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Migrations are an early feature. Currently, they're nothing more than this -// single deploy script that's invoked from the CLI, injecting a provider -// configured from the workspace's Anchor.toml. - -const anchor = require("@coral-xyz/anchor"); - -module.exports = async function (provider) { - // Configure client to use the provider. - anchor.setProvider(provider); - - // Add your deploy script here. -}; diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/package.json b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/package.json deleted file mode 100644 index 04daffe1b..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "license": "ISC", - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" - }, - "dependencies": { - "@coral-xyz/anchor": "^0.30.1" - }, - "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/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/Cargo.toml b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/Cargo.toml deleted file mode 100644 index a5679859f..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "pda_mint_authority_program" -version = "0.1.0" -description = "Created with Anchor" -edition = "2021" - -[lib] -crate-type = ["cdylib", "lib"] -name = "pda_mint_authority_program" - -[features] -default = [] -cpi = ["no-entrypoint"] -no-entrypoint = [] -no-idl = [] -no-log-ix-name = [] -idl-build = ["anchor-lang/idl-build"] - -[dependencies] -anchor-lang = "0.30.1" diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/Xargo.toml b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/Xargo.toml deleted file mode 100644 index 475fb71ed..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/Xargo.toml +++ /dev/null @@ -1,2 +0,0 @@ -[target.bpfel-unknown-unknown.dependencies.std] -features = [] diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/src/lib.rs b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/src/lib.rs deleted file mode 100644 index cab20d1c1..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/programs/pda_mint_authority_program/src/lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -use anchor_lang::prelude::*; - -declare_id!("2dR87YancKtdVJSxfyrYGRCGd7GqGCsC2v1RutTC6ozz"); - -#[program] -pub mod pda_mint_authority_program { - use super::*; - - pub fn initialize(ctx: Context) -> Result<()> { - msg!("Greetings from: {:?}", ctx.program_id); - Ok(()) - } -} - -#[derive(Accounts)] -pub struct Initialize {} diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/tests/pda_mint_authority_program.ts b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/tests/pda_mint_authority_program.ts deleted file mode 100644 index 08b419448..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/tests/pda_mint_authority_program.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as anchor from "@coral-xyz/anchor"; -import { Program } from "@coral-xyz/anchor"; -import { PdaMintAuthorityProgram } from "../target/types/pda_mint_authority_program"; - -describe("pda_mint_authority_program", () => { - // Configure the client to use the local cluster. - anchor.setProvider(anchor.AnchorProvider.env()); - - const program = anchor.workspace.PdaMintAuthorityProgram as Program; - - it("Is initialized!", async () => { - // Add your test here. - const tx = await program.methods.initialize().rpc(); - console.log("Your transaction signature", tx); - }); -}); diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/package.json b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/package.json deleted file mode 100644 index bb6240a8f..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "ts-programs", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@solanaturbine/poseidon": "^0.0.4" - } -} diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/pnpm-lock.yaml b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/pnpm-lock.yaml deleted file mode 100644 index 0d5092821..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/pnpm-lock.yaml +++ /dev/null @@ -1,22 +0,0 @@ -lockfileVersion: '9.0' - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - -importers: - - .: - dependencies: - '@solanaturbine/poseidon': - specifier: ^0.0.4 - version: 0.0.4 - -packages: - - '@solanaturbine/poseidon@0.0.4': - resolution: {integrity: sha512-VNQRtqobzBT+Wkh8fdPb0WVt12aIlgRJuGDxptclkphXi5w+VHUfMPcBshWSFPZg1nheXYgJABwvffYcyirw1g==} - -snapshots: - - '@solanaturbine/poseidon@0.0.4': {} diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/src/pda_mint_authority_program.ts b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/src/pda_mint_authority_program.ts deleted file mode 100644 index e2bd936f5..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/ts-programs/src/pda_mint_authority_program.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { - Account, - AssociatedTokenAccount, - Mint, - Pubkey, - Seeds, - Signer, - SystemAccount, - TokenAccount, - TokenProgram, - UncheckedAccount, - u64, - u8, -} from "@solanaturbine/poseidon"; - -export default class PdaMintAuthorityrogram { - static PROGRAM_ID = new Pubkey("11111111111111111111111111111111"); - - create( - maker: Signer, - makerMint: Mint, - makerAta: AssociatedTokenAccount, - auth: UncheckedAccount, - seed: u64 - ) { - - } - mint( - maker: Signer, - makerMint: Mint, - makerAta: AssociatedTokenAccount, - auth: UncheckedAccount, - ) { - - } -} - - -export interface PdaMintState extends Account { - maker: Pubkey; - makerMint: Pubkey; - amount: u64; - seed: u64; - authBump: u8; - escrowBump: u8; -} diff --git a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/tsconfig.json b/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/tsconfig.json deleted file mode 100644 index cd5d2e3d0..000000000 --- a/tokens/pda-mint-authority/poseidon/pda_mint_authority_program/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["es2015"], - "module": "commonjs", - "target": "es6", - "esModuleInterop": true - } -} diff --git a/tokens/pda-mint-authority/poseidon/token-minter/Anchor.toml b/tokens/pda-mint-authority/poseidon/token-minter/Anchor.toml index c85da06e7..1c3403d1c 100644 --- a/tokens/pda-mint-authority/poseidon/token-minter/Anchor.toml +++ b/tokens/pda-mint-authority/poseidon/token-minter/Anchor.toml @@ -5,7 +5,7 @@ resolution = true skip-lint = false [programs.localnet] -token_minter = "EWEURHBPCLgFnxMV6yKmmj2xS9386Rcr2ixBah8Pyjjv" +token_minter = "AMXNdYTyDpcLLJ9CzVJQ1kw5gqE4JeZxjtUbH2MwntdD" [registry] url = "https://api.apr.dev" diff --git a/tokens/pda-mint-authority/poseidon/token-minter/migrations/deploy.ts b/tokens/pda-mint-authority/poseidon/token-minter/migrations/deploy.ts index 82fb175fa..64a1c3599 100644 --- a/tokens/pda-mint-authority/poseidon/token-minter/migrations/deploy.ts +++ b/tokens/pda-mint-authority/poseidon/token-minter/migrations/deploy.ts @@ -2,9 +2,9 @@ // single deploy script that's invoked from the CLI, injecting a provider // configured from the workspace's Anchor.toml. -const anchor = require("@coral-xyz/anchor"); +const anchor = require('@coral-xyz/anchor'); -module.exports = async function (provider) { +module.exports = async (provider) => { // Configure client to use the provider. anchor.setProvider(provider); diff --git a/tokens/pda-mint-authority/poseidon/token-minter/programs/token-minter/src/lib.rs b/tokens/pda-mint-authority/poseidon/token-minter/programs/token-minter/src/lib.rs index 49a17e0be..65d2bb2b5 100644 --- a/tokens/pda-mint-authority/poseidon/token-minter/programs/token-minter/src/lib.rs +++ b/tokens/pda-mint-authority/poseidon/token-minter/programs/token-minter/src/lib.rs @@ -1,34 +1,51 @@ use anchor_lang::prelude::*; use anchor_spl::{ - token::Mint, + token::{Mint, TokenAccount, Token}, associated_token::AssociatedToken, }; -declare_id!("EWEURHBPCLgFnxMV6yKmmj2xS9386Rcr2ixBah8Pyjjv"); +declare_id!("AMXNdYTyDpcLLJ9CzVJQ1kw5gqE4JeZxjtUbH2MwntdD"); #[program] pub mod token_minter { use super::*; - pub fn mint_token(ctx: Context, amount: u64) -> Result<()> { + pub fn create_token( + ctx: Context, + token_name: String, + token_symbol: String, + token_uri: String, + ) -> Result<()> { + Ok(()) + } + pub fn mint(ctx: Context) -> Result<()> { Ok(()) } } #[derive(Accounts)] -pub struct MintTokenContext<'info> { +pub struct CreateTokenContext<'info> { + #[account(mut)] + pub maker: Signer<'info>, + #[account()] + pub maker_associated_token_account: Account<'info, TokenAccount>, #[account()] /// CHECK: This acc is safe pub auth: UncheckedAccount<'info>, - #[account(mut)] - pub maker: Signer<'info>, + #[account()] + pub maker_mint: Account<'info, Mint>, + pub associated_token_program: Program<'info, AssociatedToken>, + pub token_program: Program<'info, Token>, +} +#[derive(Accounts)] +pub struct MintContext<'info> { + #[account(seeds = [b"mint"], bump)] + pub maker_mint: Account<'info, Mint>, #[account( init_if_needed, - payer = maker, - associated_token::mint = maker_mint_account, - associated_token::authority = auth, - has_one = maker, - has_one = maker_mint_account, + payer = payer, + associated_token::mint = maker_mint, + associated_token::authority = payer, )] - pub maker_associated_token_account: Account<'info, TokenAccount>, - #[account(seeds = [b"mint"], bump)] - pub maker_mint_account: Account<'info, Mint>, + pub maker_ata: Account<'info, TokenAccount>, + #[account(mut)] + pub payer: Signer<'info>, pub associated_token_program: Program<'info, AssociatedToken>, pub token_program: Program<'info, Token>, pub system_program: Program<'info, System>, diff --git a/tokens/pda-mint-authority/poseidon/token-minter/tests/bankrun.test.ts b/tokens/pda-mint-authority/poseidon/token-minter/tests/bankrun.test.ts index 5f8052038..e1e2b706c 100644 --- a/tokens/pda-mint-authority/poseidon/token-minter/tests/bankrun.test.ts +++ b/tokens/pda-mint-authority/poseidon/token-minter/tests/bankrun.test.ts @@ -1,27 +1,23 @@ -import { describe, it } from "node:test"; -import * as anchor from "@coral-xyz/anchor"; -import { createInitializeMintInstruction, createMint, getAssociatedTokenAddressSync } from "@solana/spl-token"; -import { Connection, PublicKey, SystemProgram, Transaction, TransactionInstruction } from "@solana/web3.js"; -import { BankrunProvider } from "anchor-bankrun"; -import { startAnchor } from "solana-bankrun"; -import type { TokenMinter } from "../target/types/token_minter"; -import { createV1, TokenStandard } from "@metaplex-foundation/mpl-token-metadata"; -import { createSignerFromKeypair, createUmi, generateSigner, percentAmount } from "@metaplex-foundation/umi"; - -const IDL = require("../target/idl/token_minter.json"); +import { describe, it } from 'node:test'; +import * as anchor from '@coral-xyz/anchor'; +import { getAssociatedTokenAddressSync } from '@solana/spl-token'; +import { PublicKey } from '@solana/web3.js'; +import { BankrunProvider } from 'anchor-bankrun'; +import { startAnchor } from 'solana-bankrun'; +import type { TokenMinter } from '../target/types/token_minter'; + +const IDL = require('../target/idl/token_minter.json'); const PROGRAM_ID = new PublicKey(IDL.address); -const METADATA_PROGRAM_ID = new PublicKey( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" -); +const METADATA_PROGRAM_ID = new PublicKey('metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s'); -describe("NFT Minter", async () => { +describe('NFT Minter', async () => { const context = await startAnchor( - "", + '', [ - { name: "token_minter", programId: PROGRAM_ID }, - { name: "token_metadata", programId: METADATA_PROGRAM_ID }, + { name: 'token_minter', programId: PROGRAM_ID }, + { name: 'token_metadata', programId: METADATA_PROGRAM_ID }, ], - [] + [], ); const provider = new BankrunProvider(context); anchor.setProvider(provider); @@ -30,98 +26,30 @@ describe("NFT Minter", async () => { // Derive the PDA to use as mint account address. // This same PDA is also used as the mint authority. - const [mintPDA, bump] = PublicKey.findProgramAddressSync( - [Buffer.from("mint")], - program.programId - ); + const [mintPDA] = PublicKey.findProgramAddressSync([Buffer.from('mint')], program.programId); const metadata = { - name: "Solana Gold", - symbol: "GOLDSOL", - uri: "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json", + name: 'Solana Gold', + symbol: 'GOLDSOL', + uri: 'https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json', }; - - const connection = new Connection("https://api.devnet.solana.com."); -// const umi = createUmi() -// Token has to be -// it("Create a token!", async () => { -// const transactionSignature = await program.methods -// .createToken(metadata.name, metadata.symbol, metadata.uri) -// .accounts({ -// payer: payer.publicKey, -// }) -// .rpc(); - -// console.log("Success!"); -// console.log(` Mint Address: ${mintPDA}`); -// console.log(` Transaction Signature: ${transactionSignature}`); -// }); - const transaction = new Transaction(); - - // Create the account for the SPL Token Mint - transaction.add( - SystemProgram.createAccount({ - fromPubkey: payer.publicKey, - newAccountPubkey: mintPDA, // The mint account public key - space: 1000, // Size of the mint account - lamports: await connection.getMinimumBalanceForRentExemption(1000), // Rent-exempt balance for mint - programId: PROGRAM_ID, // Program ID of the SPL Token program - }) - ); - - // Add the initialize mint instruction - transaction.add( - createInitializeMintInstruction( - mintPDA, // The mint account pda - 9, // Decimals (for example, 9 for 1 billionth precision like SOL) - mintPDA, // Mint authority set to the PDA - mintPDA, // Freeze authority set to the PDA (optional) - PROGRAM_ID // Program ID of the SPL Token program - ) - ); - - -// createMint( -// connection, - -// // Decimals (for example, 9 for 1 billionth precision like SOL) -// mintPDA, // Mint authority set to the PDA -// mintPDA, -// 9, // Freeze authority set to the PDA (optional) -// PROGRAM_ID // Program ID of the SPL Token program -// ) - -const instruction = new TransactionInstruction({ - keys: [ - { pubkey: mintPDA, isSigner: true, isWritable: true }, // PDA as signer - { pubkey: payer.publicKey, isSigner: true, isWritable: true }, - ], - programId: program.programId, // The program you are interacting with - data: Buffer.from([bump]), // Program will use the bump to validate the PDA -}); - -transaction.add(instruction) - + it('Create a token!', async () => { + const transactionSignature = await program.methods + .createToken(metadata.name, metadata.symbol, metadata.uri) + .accounts({ + payer: payer.publicKey, + }) + .rpc(); -// const mint = generateSigner(umi); - -// await createV1(umi, { -// mint, -// authority:mintPDA, -// name: metadata.name, -// symbol: metadata.symbol, -// uri:metadata.uri, -// sellerFeeBasisPoints: percentAmount(5.5), -// tokenStandard: TokenStandard.Fungible, -// }).sendAndConfirm(umi); + console.log('Success!'); + console.log(` Mint Address: ${mintPDA}`); + console.log(` Transaction Signature: ${transactionSignature}`); + }); - it("Mint 1 Token!", async () => { + it('Mint 1 Token!', async () => { // Derive the associated token address account for the mint and payer. - const associatedTokenAccountAddress = getAssociatedTokenAddressSync( - mintPDA, - payer.publicKey - ); + const associatedTokenAccountAddress = getAssociatedTokenAddressSync(mintPDA, payer.publicKey); // Amount of tokens to mint. const amount = new anchor.BN(100); @@ -134,10 +62,8 @@ transaction.add(instruction) }) .rpc(); - console.log("Success!"); - console.log( - ` Associated Token Account Address: ${associatedTokenAccountAddress}` - ); + console.log('Success!'); + console.log(` Associated Token Account Address: ${associatedTokenAccountAddress}`); console.log(` Transaction Signature: ${transactionSignature}`); }); }); diff --git a/tokens/pda-mint-authority/poseidon/token-minter/tests/test.ts b/tokens/pda-mint-authority/poseidon/token-minter/tests/test.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/tokens/pda-mint-authority/poseidon/token-minter/tests/token-minter.ts b/tokens/pda-mint-authority/poseidon/token-minter/tests/token-minter.ts index 4afd88cfc..0605d1012 100644 --- a/tokens/pda-mint-authority/poseidon/token-minter/tests/token-minter.ts +++ b/tokens/pda-mint-authority/poseidon/token-minter/tests/token-minter.ts @@ -1,16 +1,16 @@ -import * as anchor from "@coral-xyz/anchor"; -import { Program } from "@coral-xyz/anchor"; -import { TokenMinter } from "../target/types/token_minter"; +import * as anchor from '@coral-xyz/anchor'; +import { Program } from '@coral-xyz/anchor'; +import { TokenMinter } from '../target/types/token_minter'; -describe("token-minter", () => { +describe('token-minter', () => { // Configure the client to use the local cluster. anchor.setProvider(anchor.AnchorProvider.env()); const program = anchor.workspace.TokenMinter as Program; - it("Is initialized!", async () => { + it('Is initialized!', async () => { // Add your test here. const tx = await program.methods.initialize().rpc(); - console.log("Your transaction signature", tx); + console.log('Your transaction signature', tx); }); }); diff --git a/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/package.json b/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/package.json index bb6240a8f..e072b0f6c 100644 --- a/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/package.json +++ b/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/package.json @@ -10,6 +10,6 @@ "author": "", "license": "ISC", "dependencies": { - "@solanaturbine/poseidon": "^0.0.4" + "@solanaturbine/poseidon": "^0.0.9" } } diff --git a/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/pnpm-lock.yaml b/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/pnpm-lock.yaml index 0d5092821..62fcdf772 100644 --- a/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/pnpm-lock.yaml +++ b/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/pnpm-lock.yaml @@ -9,14 +9,14 @@ importers: .: dependencies: '@solanaturbine/poseidon': - specifier: ^0.0.4 - version: 0.0.4 + specifier: ^0.0.9 + version: 0.0.9 packages: - '@solanaturbine/poseidon@0.0.4': - resolution: {integrity: sha512-VNQRtqobzBT+Wkh8fdPb0WVt12aIlgRJuGDxptclkphXi5w+VHUfMPcBshWSFPZg1nheXYgJABwvffYcyirw1g==} + '@solanaturbine/poseidon@0.0.9': + resolution: {integrity: sha512-WH4klRUmLXpejXPBmLQ50nusj7tA/gDw87txLCWJIcVbwrj2Nart0YxzFxR1YZG4aR1WFj6xOunL8sIrLGvgyw==} snapshots: - '@solanaturbine/poseidon@0.0.4': {} + '@solanaturbine/poseidon@0.0.9': {} diff --git a/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/src/token-minter.ts b/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/src/token-minter.ts index 8f7a80479..d5aa4e572 100644 --- a/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/src/token-minter.ts +++ b/tokens/pda-mint-authority/poseidon/token-minter/ts-programs/src/token-minter.ts @@ -2,6 +2,7 @@ import { Account, AssociatedTokenAccount, Mint, + String as PoseidonString, Pubkey, Seeds, Signer, @@ -9,44 +10,29 @@ import { TokenAccount, TokenProgram, UncheckedAccount, - u64, u8, -} from "@solanaturbine/poseidon"; + u64, +} from '@solanaturbine/poseidon'; export default class TokenMinter { - static PROGRAM_ID = new Pubkey( - "EWEURHBPCLgFnxMV6yKmmj2xS9386Rcr2ixBah8Pyjjv" - ); + static PROGRAM_ID = new Pubkey('AMXNdYTyDpcLLJ9CzVJQ1kw5gqE4JeZxjtUbH2MwntdD'); -//Creating token metadata is not supported in poseidon currently so that will be done in the tests -//so for creating metadata and signing as pda, we will have to populate the anchor code manually -// createToken( -// maker: Signer, -// makerMint: Mint, -// makerAssociatedTokenAccount: AssociatedTokenAccount, -// auth: UncheckedAccount, -// token_name: String, -// token_symbol: String, -// token_uri: String, -// ) { -// } - mintToken( + //Creating token metadata is not supported in poseidon currently + createToken( maker: Signer, - makerMintAccount: Mint, + makerMint: Mint, makerAssociatedTokenAccount: AssociatedTokenAccount, auth: UncheckedAccount, - amount: u64 + token_name: PoseidonString<10>, + token_symbol: PoseidonString<10>, + token_uri: PoseidonString<10>, ) { - - TokenProgram.initializeMint( - - ) - makerMintAccount.derive(["mint"]); - - makerAssociatedTokenAccount - .derive(makerMintAccount, auth.key) - .has([maker, makerMintAccount]) - .initIfNeeded(); + //create_metadata_accounts_v3 function not yet implemented in poseidon + } + mint(payer: Signer, makerMint: Mint, makerAta: AssociatedTokenAccount) { + makerMint.derive(['mint']); + makerAta.derive(makerMint, payer.key).initIfNeeded(payer); + TokenProgram.initializeMint(makerMint, new u8(8), payer); } }