diff --git a/Cargo.lock b/Cargo.lock index cbf79d9f..66c596f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -388,7 +388,7 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cardinal-creator-standard" -version = "0.1.0" +version = "0.1.5" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/programs/cardinal-creator-standard/src/errors.rs b/programs/cardinal-creator-standard/src/errors.rs index d5e9ad02..8b7d4e80 100644 --- a/programs/cardinal-creator-standard/src/errors.rs +++ b/programs/cardinal-creator-standard/src/errors.rs @@ -32,4 +32,10 @@ pub enum ErrorCode { UnknownAccount, #[msg("Account not found in instruction")] AccountNotFound, + #[msg("Token already in use")] + TokenAlreadyInUse, + #[msg("Invalid token user")] + InvalidTokenUser, + #[msg("Token currently in use")] + TokenCurentlyInUse, } diff --git a/programs/cardinal-creator-standard/src/instructions/mint_manager/mod.rs b/programs/cardinal-creator-standard/src/instructions/mint_manager/mod.rs index 0a931f48..8aecf095 100644 --- a/programs/cardinal-creator-standard/src/instructions/mint_manager/mod.rs +++ b/programs/cardinal-creator-standard/src/instructions/mint_manager/mod.rs @@ -1,5 +1,9 @@ pub mod init_mint_manager; +pub mod remove_in_use_by; +pub mod set_in_use_by; pub mod update_mint_manager; pub use init_mint_manager::*; +pub use remove_in_use_by::*; +pub use set_in_use_by::*; pub use update_mint_manager::*; diff --git a/programs/cardinal-creator-standard/src/instructions/mint_manager/remove_in_use_by.rs b/programs/cardinal-creator-standard/src/instructions/mint_manager/remove_in_use_by.rs new file mode 100644 index 00000000..86a49219 --- /dev/null +++ b/programs/cardinal-creator-standard/src/instructions/mint_manager/remove_in_use_by.rs @@ -0,0 +1,17 @@ +use crate::errors::ErrorCode; +use crate::state::*; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct RemoveInUseByCtx<'info> { + #[account(mut)] + mint_manager: Box>, + #[account(constraint = mint_manager.in_use_by.expect("Token not in use") == user.key() @ ErrorCode::InvalidTokenUser)] + user: Signer<'info>, +} + +pub fn handler(ctx: Context) -> Result<()> { + let mint_manager = &mut ctx.accounts.mint_manager; + mint_manager.in_use_by = None; + Ok(()) +} diff --git a/programs/cardinal-creator-standard/src/instructions/mint_manager/set_in_use_by.rs b/programs/cardinal-creator-standard/src/instructions/mint_manager/set_in_use_by.rs new file mode 100644 index 00000000..cbb85a18 --- /dev/null +++ b/programs/cardinal-creator-standard/src/instructions/mint_manager/set_in_use_by.rs @@ -0,0 +1,29 @@ +use crate::errors::ErrorCode; +use crate::state::*; +use anchor_lang::prelude::*; +use anchor_spl::token::TokenAccount; + +#[derive(AnchorSerialize, AnchorDeserialize)] +pub struct SetInUseByIx { + pub in_use_by: Pubkey, +} + +#[derive(Accounts)] +pub struct SetInUseByCtx<'info> { + #[account(mut)] + mint_manager: Box>, + holder: Signer<'info>, + + #[account(constraint = holder_token_account.owner == holder.key() && holder_token_account.mint == mint_manager.mint @ ErrorCode::InvalidHolderTokenAccount)] + holder_token_account: Box>, +} + +pub fn handler(ctx: Context, ix: SetInUseByIx) -> Result<()> { + let mint_manager = &mut ctx.accounts.mint_manager; + + if mint_manager.in_use_by.is_some() { + return Err(error!(ErrorCode::TokenAlreadyInUse)); + } + mint_manager.in_use_by = Some(ix.in_use_by); + Ok(()) +} diff --git a/programs/cardinal-creator-standard/src/instructions/mod.rs b/programs/cardinal-creator-standard/src/instructions/mod.rs index 1e52c64d..4ac19526 100644 --- a/programs/cardinal-creator-standard/src/instructions/mod.rs +++ b/programs/cardinal-creator-standard/src/instructions/mod.rs @@ -1,5 +1,7 @@ pub mod mint_manager; pub use mint_manager::init_mint_manager::*; +pub use mint_manager::remove_in_use_by::*; +pub use mint_manager::set_in_use_by::*; pub use mint_manager::update_mint_manager::*; pub mod ruleset; diff --git a/programs/cardinal-creator-standard/src/instructions/token/approve.rs b/programs/cardinal-creator-standard/src/instructions/token/approve.rs index 267d6c02..95f43ea5 100644 --- a/programs/cardinal-creator-standard/src/instructions/token/approve.rs +++ b/programs/cardinal-creator-standard/src/instructions/token/approve.rs @@ -34,6 +34,10 @@ pub struct ApproveCtx<'info> { } pub fn handler(ctx: Context) -> Result<()> { + if ctx.accounts.mint_manager.in_use_by.is_some() { + return Err(error!(ErrorCode::TokenCurentlyInUse)); + } + let mint = ctx.accounts.mint.key(); let mint_manager_seeds = &[ MINT_MANAGER_SEED.as_bytes(), diff --git a/programs/cardinal-creator-standard/src/instructions/token/burn.rs b/programs/cardinal-creator-standard/src/instructions/token/burn.rs index f546bf84..be0e2d15 100644 --- a/programs/cardinal-creator-standard/src/instructions/token/burn.rs +++ b/programs/cardinal-creator-standard/src/instructions/token/burn.rs @@ -28,6 +28,10 @@ pub struct BurnCtx<'info> { } pub fn handler(ctx: Context) -> Result<()> { + if ctx.accounts.mint_manager.in_use_by.is_some() { + return Err(error!(ErrorCode::TokenCurentlyInUse)); + } + let mint_manager_key = ctx.accounts.mint.key(); let mint_manager_seeds = &[ MINT_MANAGER_SEED.as_bytes(), diff --git a/programs/cardinal-creator-standard/src/instructions/token/revoke.rs b/programs/cardinal-creator-standard/src/instructions/token/revoke.rs index b4fe2a10..db142861 100644 --- a/programs/cardinal-creator-standard/src/instructions/token/revoke.rs +++ b/programs/cardinal-creator-standard/src/instructions/token/revoke.rs @@ -32,6 +32,10 @@ pub struct RevokeCtx<'info> { } pub fn handler(ctx: Context) -> Result<()> { + if ctx.accounts.mint_manager.in_use_by.is_some() { + return Err(error!(ErrorCode::TokenCurentlyInUse)); + } + let mint = ctx.accounts.mint.key(); let mint_manager_seeds = &[ MINT_MANAGER_SEED.as_bytes(), diff --git a/programs/cardinal-creator-standard/src/instructions/token/transfer.rs b/programs/cardinal-creator-standard/src/instructions/token/transfer.rs index 6c5b53bf..069e207a 100644 --- a/programs/cardinal-creator-standard/src/instructions/token/transfer.rs +++ b/programs/cardinal-creator-standard/src/instructions/token/transfer.rs @@ -114,6 +114,10 @@ pub fn handler(ctx: Context) -> Result<()> { } //////////////////////////////////////////////////////////// + if ctx.accounts.mint_manager.in_use_by.is_some() { + return Err(error!(ErrorCode::TokenCurentlyInUse)); + } + let mint = ctx.accounts.mint.key(); let mint_manager_seeds = &[ MINT_MANAGER_SEED.as_bytes(), diff --git a/programs/cardinal-creator-standard/src/lib.rs b/programs/cardinal-creator-standard/src/lib.rs index f14eefb9..b01f6c05 100644 --- a/programs/cardinal-creator-standard/src/lib.rs +++ b/programs/cardinal-creator-standard/src/lib.rs @@ -9,6 +9,8 @@ solana_program::declare_id!("creatS3mfzrTGjwuLD1Pa2HXJ1gmq6WXb4ssnwUbJez"); #[program] pub mod cardinal_creator_standard { + use crate::instructions::mint_manager::{RemoveInUseByCtx, SetInUseByCtx, SetInUseByIx}; + use super::*; // mint_manager @@ -23,6 +25,14 @@ pub mod cardinal_creator_standard { mint_manager::update_mint_manager::handler(ctx, ix) } + pub fn set_in_use_by(ctx: Context, ix: SetInUseByIx) -> Result<()> { + mint_manager::set_in_use_by::handler(ctx, ix) + } + + pub fn remove_in_use_by(ctx: Context) -> Result<()> { + mint_manager::remove_in_use_by::handler(ctx) + } + // ruleset pub fn init_ruleset(ctx: Context, ix: InitRulesetIx) -> Result<()> { ruleset::init_ruleset::handler(ctx, ix) diff --git a/programs/cardinal-creator-standard/src/state.rs b/programs/cardinal-creator-standard/src/state.rs index 43fe3da5..693ec3fb 100644 --- a/programs/cardinal-creator-standard/src/state.rs +++ b/programs/cardinal-creator-standard/src/state.rs @@ -13,7 +13,7 @@ pub struct MintManager { pub mint: Pubkey, pub authority: Pubkey, pub ruleset: Pubkey, - pub in_use_by: Pubkey, + pub in_use_by: Option, } pub const RULESET_SEED: &str = "ruleset"; diff --git a/sdk/cardinal_creator_standard.json b/sdk/cardinal_creator_standard.json index a4aa2db3..2116cd92 100644 --- a/sdk/cardinal_creator_standard.json +++ b/sdk/cardinal_creator_standard.json @@ -1,5 +1,5 @@ { - "version": "0.1.0", + "version": "0.1.5", "name": "cardinal_creator_standard", "instructions": [ { @@ -96,6 +96,50 @@ } ] }, + { + "name": "setInUseBy", + "accounts": [ + { + "name": "mintManager", + "isMut": true, + "isSigner": false + }, + { + "name": "holder", + "isMut": false, + "isSigner": true + }, + { + "name": "holderTokenAccount", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "ix", + "type": { + "defined": "SetInUseByIx" + } + } + ] + }, + { + "name": "removeInUseBy", + "accounts": [ + { + "name": "mintManager", + "isMut": true, + "isSigner": false + }, + { + "name": "user", + "isMut": false, + "isSigner": true + } + ], + "args": [] + }, { "name": "initRuleset", "accounts": [ @@ -527,6 +571,12 @@ { "name": "ruleset", "type": "publicKey" + }, + { + "name": "inUseBy", + "type": { + "option": "publicKey" + } } ] } @@ -593,6 +643,18 @@ } ], "types": [ + { + "name": "SetInUseByIx", + "type": { + "kind": "struct", + "fields": [ + { + "name": "inUseBy", + "type": "publicKey" + } + ] + } + }, { "name": "UpdateMintManagerIx", "type": { @@ -769,6 +831,21 @@ "code": 6014, "name": "AccountNotFound", "msg": "Account not found in instruction" + }, + { + "code": 6015, + "name": "TokenAlreadyInUse", + "msg": "Token already in use" + }, + { + "code": 6016, + "name": "InvalidTokenUser", + "msg": "Invalid token user" + }, + { + "code": 6017, + "name": "TokenCurentlyInUse", + "msg": "Token currently in use" } ], "metadata": { diff --git a/sdk/generated/accounts/MintManager.ts b/sdk/generated/accounts/MintManager.ts index 3b133317..d4f571db 100644 --- a/sdk/generated/accounts/MintManager.ts +++ b/sdk/generated/accounts/MintManager.ts @@ -20,6 +20,7 @@ export type MintManagerArgs = { mint: web3.PublicKey authority: web3.PublicKey ruleset: web3.PublicKey + inUseBy: beet.COption } export const mintManagerDiscriminator = [202, 47, 44, 178, 55, 215, 117, 40] @@ -36,7 +37,8 @@ export class MintManager implements MintManagerArgs { readonly version: number, readonly mint: web3.PublicKey, readonly authority: web3.PublicKey, - readonly ruleset: web3.PublicKey + readonly ruleset: web3.PublicKey, + readonly inUseBy: beet.COption ) {} /** @@ -48,7 +50,8 @@ export class MintManager implements MintManagerArgs { args.version, args.mint, args.authority, - args.ruleset + args.ruleset, + args.inUseBy ) } @@ -115,36 +118,38 @@ export class MintManager implements MintManagerArgs { /** * Returns the byteSize of a {@link Buffer} holding the serialized data of - * {@link MintManager} + * {@link MintManager} for the provided args. + * + * @param args need to be provided since the byte size for this account + * depends on them */ - static get byteSize() { - return mintManagerBeet.byteSize + static byteSize(args: MintManagerArgs) { + const instance = MintManager.fromArgs(args) + return mintManagerBeet.toFixedFromValue({ + accountDiscriminator: mintManagerDiscriminator, + ...instance, + }).byteSize } /** * Fetches the minimum balance needed to exempt an account holding * {@link MintManager} data from rent * + * @param args need to be provided since the byte size for this account + * depends on them * @param connection used to retrieve the rent exemption information */ static async getMinimumBalanceForRentExemption( + args: MintManagerArgs, connection: web3.Connection, commitment?: web3.Commitment ): Promise { return connection.getMinimumBalanceForRentExemption( - MintManager.byteSize, + MintManager.byteSize(args), commitment ) } - /** - * Determines if the provided {@link Buffer} has the correct byte size to - * hold {@link MintManager} data. - */ - static hasCorrectByteSize(buf: Buffer, offset = 0) { - return buf.byteLength - offset === MintManager.byteSize - } - /** * Returns a readable version of {@link MintManager} properties * and can be used to convert to JSON and/or logging @@ -156,6 +161,7 @@ export class MintManager implements MintManagerArgs { mint: this.mint.toBase58(), authority: this.authority.toBase58(), ruleset: this.ruleset.toBase58(), + inUseBy: this.inUseBy, } } } @@ -164,7 +170,7 @@ export class MintManager implements MintManagerArgs { * @category Accounts * @category generated */ -export const mintManagerBeet = new beet.BeetStruct< +export const mintManagerBeet = new beet.FixableBeetStruct< MintManager, MintManagerArgs & { accountDiscriminator: number[] /* size: 8 */ @@ -177,6 +183,7 @@ export const mintManagerBeet = new beet.BeetStruct< ['mint', beetSolana.publicKey], ['authority', beetSolana.publicKey], ['ruleset', beetSolana.publicKey], + ['inUseBy', beet.coption(beetSolana.publicKey)], ], MintManager.fromArgs, 'MintManager' diff --git a/sdk/generated/errors/index.ts b/sdk/generated/errors/index.ts index a79f02ab..5f7b8d32 100644 --- a/sdk/generated/errors/index.ts +++ b/sdk/generated/errors/index.ts @@ -362,6 +362,75 @@ createErrorFromNameLookup.set( () => new AccountNotFoundError() ) +/** + * TokenAlreadyInUse: 'Token already in use' + * + * @category Errors + * @category generated + */ +export class TokenAlreadyInUseError extends Error { + readonly code: number = 0x177f + readonly name: string = 'TokenAlreadyInUse' + constructor() { + super('Token already in use') + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, TokenAlreadyInUseError) + } + } +} + +createErrorFromCodeLookup.set(0x177f, () => new TokenAlreadyInUseError()) +createErrorFromNameLookup.set( + 'TokenAlreadyInUse', + () => new TokenAlreadyInUseError() +) + +/** + * InvalidTokenUser: 'Invalid token user' + * + * @category Errors + * @category generated + */ +export class InvalidTokenUserError extends Error { + readonly code: number = 0x1780 + readonly name: string = 'InvalidTokenUser' + constructor() { + super('Invalid token user') + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, InvalidTokenUserError) + } + } +} + +createErrorFromCodeLookup.set(0x1780, () => new InvalidTokenUserError()) +createErrorFromNameLookup.set( + 'InvalidTokenUser', + () => new InvalidTokenUserError() +) + +/** + * TokenCurentlyInUse: 'Token currently in use' + * + * @category Errors + * @category generated + */ +export class TokenCurentlyInUseError extends Error { + readonly code: number = 0x1781 + readonly name: string = 'TokenCurentlyInUse' + constructor() { + super('Token currently in use') + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, TokenCurentlyInUseError) + } + } +} + +createErrorFromCodeLookup.set(0x1781, () => new TokenCurentlyInUseError()) +createErrorFromNameLookup.set( + 'TokenCurentlyInUse', + () => new TokenCurentlyInUseError() +) + /** * Attempts to resolve a custom program error from the provided error code. * @category Errors diff --git a/sdk/generated/instructions/index.ts b/sdk/generated/instructions/index.ts index f7c4fd3e..8438d05e 100644 --- a/sdk/generated/instructions/index.ts +++ b/sdk/generated/instructions/index.ts @@ -7,7 +7,9 @@ export * from './initMintManager' export * from './initRuleset' export * from './postTransfer' export * from './preTransfer' +export * from './removeInUseBy' export * from './revoke' +export * from './setInUseBy' export * from './transfer' export * from './updateMintManager' export * from './updateRuleset' diff --git a/sdk/generated/instructions/removeInUseBy.ts b/sdk/generated/instructions/removeInUseBy.ts new file mode 100644 index 00000000..6e143b47 --- /dev/null +++ b/sdk/generated/instructions/removeInUseBy.ts @@ -0,0 +1,74 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as beet from '@metaplex-foundation/beet' +import * as web3 from '@solana/web3.js' + +/** + * @category Instructions + * @category RemoveInUseBy + * @category generated + */ +export const removeInUseByStruct = new beet.BeetArgsStruct<{ + instructionDiscriminator: number[] /* size: 8 */ +}>( + [['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)]], + 'RemoveInUseByInstructionArgs' +) +/** + * Accounts required by the _removeInUseBy_ instruction + * + * @property [_writable_] mintManager + * @property [**signer**] user + * @category Instructions + * @category RemoveInUseBy + * @category generated + */ +export type RemoveInUseByInstructionAccounts = { + mintManager: web3.PublicKey + user: web3.PublicKey +} + +export const removeInUseByInstructionDiscriminator = [ + 52, 72, 171, 60, 254, 183, 37, 215, +] + +/** + * Creates a _RemoveInUseBy_ instruction. + * + * @param accounts that will be accessed while the instruction is processed + * @category Instructions + * @category RemoveInUseBy + * @category generated + */ +export function createRemoveInUseByInstruction( + accounts: RemoveInUseByInstructionAccounts, + programId = new web3.PublicKey('creatS3mfzrTGjwuLD1Pa2HXJ1gmq6WXb4ssnwUbJez') +) { + const [data] = removeInUseByStruct.serialize({ + instructionDiscriminator: removeInUseByInstructionDiscriminator, + }) + const keys: web3.AccountMeta[] = [ + { + pubkey: accounts.mintManager, + isWritable: true, + isSigner: false, + }, + { + pubkey: accounts.user, + isWritable: false, + isSigner: true, + }, + ] + + const ix = new web3.TransactionInstruction({ + programId, + keys, + data, + }) + return ix +} diff --git a/sdk/generated/instructions/setInUseBy.ts b/sdk/generated/instructions/setInUseBy.ts new file mode 100644 index 00000000..5219de06 --- /dev/null +++ b/sdk/generated/instructions/setInUseBy.ts @@ -0,0 +1,99 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as beet from '@metaplex-foundation/beet' +import * as web3 from '@solana/web3.js' +import { SetInUseByIx, setInUseByIxBeet } from '../types/SetInUseByIx' + +/** + * @category Instructions + * @category SetInUseBy + * @category generated + */ +export type SetInUseByInstructionArgs = { + ix: SetInUseByIx +} +/** + * @category Instructions + * @category SetInUseBy + * @category generated + */ +export const setInUseByStruct = new beet.BeetArgsStruct< + SetInUseByInstructionArgs & { + instructionDiscriminator: number[] /* size: 8 */ + } +>( + [ + ['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], + ['ix', setInUseByIxBeet], + ], + 'SetInUseByInstructionArgs' +) +/** + * Accounts required by the _setInUseBy_ instruction + * + * @property [_writable_] mintManager + * @property [**signer**] holder + * @property [] holderTokenAccount + * @category Instructions + * @category SetInUseBy + * @category generated + */ +export type SetInUseByInstructionAccounts = { + mintManager: web3.PublicKey + holder: web3.PublicKey + holderTokenAccount: web3.PublicKey +} + +export const setInUseByInstructionDiscriminator = [ + 26, 9, 136, 91, 41, 155, 85, 39, +] + +/** + * Creates a _SetInUseBy_ instruction. + * + * @param accounts that will be accessed while the instruction is processed + * @param args to provide as instruction data to the program + * + * @category Instructions + * @category SetInUseBy + * @category generated + */ +export function createSetInUseByInstruction( + accounts: SetInUseByInstructionAccounts, + args: SetInUseByInstructionArgs, + programId = new web3.PublicKey('creatS3mfzrTGjwuLD1Pa2HXJ1gmq6WXb4ssnwUbJez') +) { + const [data] = setInUseByStruct.serialize({ + instructionDiscriminator: setInUseByInstructionDiscriminator, + ...args, + }) + const keys: web3.AccountMeta[] = [ + { + pubkey: accounts.mintManager, + isWritable: true, + isSigner: false, + }, + { + pubkey: accounts.holder, + isWritable: false, + isSigner: true, + }, + { + pubkey: accounts.holderTokenAccount, + isWritable: false, + isSigner: false, + }, + ] + + const ix = new web3.TransactionInstruction({ + programId, + keys, + data, + }) + return ix +} diff --git a/sdk/generated/types/SetInUseByIx.ts b/sdk/generated/types/SetInUseByIx.ts new file mode 100644 index 00000000..56437336 --- /dev/null +++ b/sdk/generated/types/SetInUseByIx.ts @@ -0,0 +1,22 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as web3 from '@solana/web3.js' +import * as beetSolana from '@metaplex-foundation/beet-solana' +import * as beet from '@metaplex-foundation/beet' +export type SetInUseByIx = { + inUseBy: web3.PublicKey +} + +/** + * @category userTypes + * @category generated + */ +export const setInUseByIxBeet = new beet.BeetArgsStruct( + [['inUseBy', beetSolana.publicKey]], + 'SetInUseByIx' +) diff --git a/sdk/generated/types/index.ts b/sdk/generated/types/index.ts index 681b149c..8ceeeb4c 100644 --- a/sdk/generated/types/index.ts +++ b/sdk/generated/types/index.ts @@ -1,4 +1,5 @@ export * from './AccountBalance' export * from './InitRulesetIx' +export * from './SetInUseByIx' export * from './UpdateMintManagerIx' export * from './UpdateRulesetIx' diff --git a/sdk/idl/cardinal_creator_standard.ts b/sdk/idl/cardinal_creator_standard.ts index f92b95b3..1904d11f 100644 --- a/sdk/idl/cardinal_creator_standard.ts +++ b/sdk/idl/cardinal_creator_standard.ts @@ -1,1549 +1,1703 @@ export type CardinalCreatorStandard = { - "version": "0.1.0", - "name": "cardinal_creator_standard", - "instructions": [ + version: "0.1.5"; + name: "cardinal_creator_standard"; + instructions: [ { - "name": "initMintManager", - "accounts": [ + name: "initMintManager"; + accounts: [ { - "name": "mintManager", - "isMut": true, - "isSigner": false + name: "mintManager"; + isMut: true; + isSigner: false; }, { - "name": "mint", - "isMut": true, - "isSigner": false + name: "mint"; + isMut: true; + isSigner: false; }, { - "name": "ruleset", - "isMut": false, - "isSigner": false + name: "ruleset"; + isMut: false; + isSigner: false; }, { - "name": "holderTokenAccount", - "isMut": true, - "isSigner": false + name: "holderTokenAccount"; + isMut: true; + isSigner: false; }, { - "name": "collector", - "isMut": true, - "isSigner": false + name: "collector"; + isMut: true; + isSigner: false; }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "authority"; + isMut: false; + isSigner: true; }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "payer"; + isMut: true; + isSigner: true; }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram"; + isMut: false; + isSigner: false; }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + name: "systemProgram"; + isMut: false; + isSigner: false; } - ], - "args": [] + ]; + args: []; }, { - "name": "updateMintManager", - "accounts": [ + name: "updateMintManager"; + accounts: [ { - "name": "mintManager", - "isMut": true, - "isSigner": false + name: "mintManager"; + isMut: true; + isSigner: false; }, { - "name": "ruleset", - "isMut": false, - "isSigner": false + name: "ruleset"; + isMut: false; + isSigner: false; }, { - "name": "collector", - "isMut": true, - "isSigner": false + name: "collector"; + isMut: true; + isSigner: false; }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "authority"; + isMut: false; + isSigner: true; }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "payer"; + isMut: true; + isSigner: true; }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + name: "systemProgram"; + isMut: false; + isSigner: false; } - ], - "args": [ + ]; + args: [ { - "name": "ix", - "type": { - "defined": "UpdateMintManagerIx" - } + name: "ix"; + type: { + defined: "UpdateMintManagerIx"; + }; } - ] + ]; }, { - "name": "initRuleset", - "accounts": [ + name: "setInUseBy"; + accounts: [ { - "name": "ruleset", - "isMut": true, - "isSigner": false + name: "mintManager"; + isMut: true; + isSigner: false; }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "holder"; + isMut: false; + isSigner: true; }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "holderTokenAccount"; + isMut: false; + isSigner: false; + } + ]; + args: [ + { + name: "ix"; + type: { + defined: "SetInUseByIx"; + }; + } + ]; + }, + { + name: "removeInUseBy"; + accounts: [ + { + name: "mintManager"; + isMut: true; + isSigner: false; }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + name: "user"; + isMut: false; + isSigner: true; } - ], - "args": [ + ]; + args: []; + }, + { + name: "initRuleset"; + accounts: [ { - "name": "ix", - "type": { - "defined": "InitRulesetIx" - } + name: "ruleset"; + isMut: true; + isSigner: false; + }, + { + name: "authority"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + } + ]; + args: [ + { + name: "ix"; + type: { + defined: "InitRulesetIx"; + }; } - ] + ]; }, { - "name": "updateRuleset", - "accounts": [ + name: "updateRuleset"; + accounts: [ { - "name": "ruleset", - "isMut": true, - "isSigner": false + name: "ruleset"; + isMut: true; + isSigner: false; }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "authority"; + isMut: false; + isSigner: true; }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + name: "systemProgram"; + isMut: false; + isSigner: false; } - ], - "args": [ + ]; + args: [ { - "name": "ix", - "type": { - "defined": "UpdateRulesetIx" - } + name: "ix"; + type: { + defined: "UpdateRulesetIx"; + }; } - ] + ]; }, { - "name": "initMint", - "accounts": [ + name: "initMint"; + accounts: [ { - "name": "mintManager", - "isMut": true, - "isSigner": false + name: "mintManager"; + isMut: true; + isSigner: false; }, { - "name": "mint", - "isMut": true, - "isSigner": true + name: "mint"; + isMut: true; + isSigner: true; }, { - "name": "ruleset", - "isMut": false, - "isSigner": false + name: "ruleset"; + isMut: false; + isSigner: false; }, { - "name": "targetTokenAccount", - "isMut": true, - "isSigner": false + name: "targetTokenAccount"; + isMut: true; + isSigner: false; }, { - "name": "target", - "isMut": false, - "isSigner": true + name: "target"; + isMut: false; + isSigner: true; }, { - "name": "collector", - "isMut": true, - "isSigner": false + name: "collector"; + isMut: true; + isSigner: false; }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "authority"; + isMut: false; + isSigner: true; }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "payer"; + isMut: true; + isSigner: true; }, { - "name": "rent", - "isMut": false, - "isSigner": false + name: "rent"; + isMut: false; + isSigner: false; }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram"; + isMut: false; + isSigner: false; }, { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + name: "systemProgram"; + isMut: false; + isSigner: false; } - ], - "args": [] + ]; + args: []; }, { - "name": "initAccount", - "accounts": [ + name: "initAccount"; + accounts: [ { - "name": "mint", - "isMut": false, - "isSigner": false + name: "mint"; + isMut: false; + isSigner: false; }, { - "name": "tokenAccount", - "isMut": true, - "isSigner": false + name: "tokenAccount"; + isMut: true; + isSigner: false; }, { - "name": "tokenAccountOwner", - "isMut": false, - "isSigner": false + name: "tokenAccountOwner"; + isMut: false; + isSigner: false; }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "payer"; + isMut: true; + isSigner: true; }, { - "name": "rent", - "isMut": false, - "isSigner": false + name: "rent"; + isMut: false; + isSigner: false; }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram"; + isMut: false; + isSigner: false; }, { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + name: "systemProgram"; + isMut: false; + isSigner: false; } - ], - "args": [] + ]; + args: []; }, { - "name": "approve", - "accounts": [ + name: "approve"; + accounts: [ { - "name": "mintManager", - "isMut": false, - "isSigner": false + name: "mintManager"; + isMut: false; + isSigner: false; }, { - "name": "mint", - "isMut": false, - "isSigner": false + name: "mint"; + isMut: false; + isSigner: false; }, { - "name": "holderTokenAccount", - "isMut": true, - "isSigner": false + name: "holderTokenAccount"; + isMut: true; + isSigner: false; }, { - "name": "holder", - "isMut": true, - "isSigner": true + name: "holder"; + isMut: true; + isSigner: true; }, { - "name": "delegate", - "isMut": true, - "isSigner": false + name: "delegate"; + isMut: true; + isSigner: false; }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram"; + isMut: false; + isSigner: false; } - ], - "args": [] + ]; + args: []; }, { - "name": "revoke", - "accounts": [ + name: "revoke"; + accounts: [ { - "name": "mintManager", - "isMut": true, - "isSigner": false + name: "mintManager"; + isMut: true; + isSigner: false; }, { - "name": "mint", - "isMut": false, - "isSigner": false + name: "mint"; + isMut: false; + isSigner: false; }, { - "name": "holderTokenAccount", - "isMut": true, - "isSigner": false + name: "holderTokenAccount"; + isMut: true; + isSigner: false; }, { - "name": "holder", - "isMut": true, - "isSigner": true + name: "holder"; + isMut: true; + isSigner: true; }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram"; + isMut: false; + isSigner: false; } - ], - "args": [] + ]; + args: []; }, { - "name": "burn", - "accounts": [ + name: "burn"; + accounts: [ { - "name": "mintManager", - "isMut": true, - "isSigner": false + name: "mintManager"; + isMut: true; + isSigner: false; }, { - "name": "mint", - "isMut": true, - "isSigner": false + name: "mint"; + isMut: true; + isSigner: false; }, { - "name": "holderTokenAccount", - "isMut": true, - "isSigner": false + name: "holderTokenAccount"; + isMut: true; + isSigner: false; }, { - "name": "holder", - "isMut": false, - "isSigner": true + name: "holder"; + isMut: false; + isSigner: true; }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram"; + isMut: false; + isSigner: false; }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + name: "systemProgram"; + isMut: false; + isSigner: false; } - ], - "args": [] + ]; + args: []; }, { - "name": "close", - "accounts": [ + name: "close"; + accounts: [ { - "name": "mintManager", - "isMut": false, - "isSigner": false + name: "mintManager"; + isMut: false; + isSigner: false; }, { - "name": "mint", - "isMut": true, - "isSigner": false + name: "mint"; + isMut: true; + isSigner: false; }, { - "name": "tokenAccount", - "isMut": true, - "isSigner": false + name: "tokenAccount"; + isMut: true; + isSigner: false; }, { - "name": "owner", - "isMut": false, - "isSigner": true + name: "owner"; + isMut: false; + isSigner: true; }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram"; + isMut: false; + isSigner: false; }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + name: "systemProgram"; + isMut: false; + isSigner: false; } - ], - "args": [] + ]; + args: []; }, { - "name": "transfer", - "accounts": [ + name: "transfer"; + accounts: [ { - "name": "mintManager", - "isMut": false, - "isSigner": false + name: "mintManager"; + isMut: false; + isSigner: false; }, { - "name": "ruleset", - "isMut": false, - "isSigner": false + name: "ruleset"; + isMut: false; + isSigner: false; }, { - "name": "mint", - "isMut": false, - "isSigner": false + name: "mint"; + isMut: false; + isSigner: false; }, { - "name": "from", - "isMut": true, - "isSigner": false + name: "from"; + isMut: true; + isSigner: false; }, { - "name": "to", - "isMut": true, - "isSigner": false + name: "to"; + isMut: true; + isSigner: false; }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "authority"; + isMut: false; + isSigner: true; }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram"; + isMut: false; + isSigner: false; }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + name: "systemProgram"; + isMut: false; + isSigner: false; }, { - "name": "instructions", - "isMut": false, - "isSigner": false + name: "instructions"; + isMut: false; + isSigner: false; } - ], - "args": [] + ]; + args: []; }, { - "name": "preTransfer", - "accounts": [ + name: "preTransfer"; + accounts: [ { - "name": "accountBalances", - "isMut": true, - "isSigner": false + name: "accountBalances"; + isMut: true; + isSigner: false; }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "payer"; + isMut: true; + isSigner: true; }, { - "name": "instructions", - "isMut": false, - "isSigner": false + name: "instructions"; + isMut: false; + isSigner: false; } - ], - "args": [] + ]; + args: []; }, { - "name": "postTransfer", - "accounts": [ + name: "postTransfer"; + accounts: [ { - "name": "accountBalances", - "isMut": true, - "isSigner": false + name: "accountBalances"; + isMut: true; + isSigner: false; }, { - "name": "collector", - "isMut": true, - "isSigner": false + name: "collector"; + isMut: true; + isSigner: false; }, { - "name": "instructions", - "isMut": false, - "isSigner": false + name: "instructions"; + isMut: false; + isSigner: false; } - ], - "args": [] + ]; + args: []; } - ], - "accounts": [ + ]; + accounts: [ { - "name": "mintManager", - "type": { - "kind": "struct", - "fields": [ + name: "mintManager"; + type: { + kind: "struct"; + fields: [ + { + name: "bump"; + type: "u8"; + }, { - "name": "bump", - "type": "u8" + name: "version"; + type: "u8"; }, { - "name": "version", - "type": "u8" + name: "mint"; + type: "publicKey"; }, { - "name": "mint", - "type": "publicKey" + name: "authority"; + type: "publicKey"; }, { - "name": "authority", - "type": "publicKey" + name: "ruleset"; + type: "publicKey"; }, { - "name": "ruleset", - "type": "publicKey" + name: "inUseBy"; + type: { + option: "publicKey"; + }; } - ] - } + ]; + }; }, { - "name": "ruleset", - "type": { - "kind": "struct", - "fields": [ + name: "ruleset"; + type: { + kind: "struct"; + fields: [ { - "name": "bump", - "type": "u8" + name: "bump"; + type: "u8"; }, { - "name": "version", - "type": "u8" + name: "version"; + type: "u8"; }, { - "name": "authority", - "type": "publicKey" + name: "authority"; + type: "publicKey"; }, { - "name": "collector", - "type": "publicKey" + name: "collector"; + type: "publicKey"; }, { - "name": "checkSellerFeeBasisPoints", - "type": "bool" + name: "checkSellerFeeBasisPoints"; + type: "bool"; }, { - "name": "name", - "type": "string" + name: "name"; + type: "string"; }, { - "name": "disallowedAddresses", - "type": { - "vec": "publicKey" - } + name: "disallowedAddresses"; + type: { + vec: "publicKey"; + }; }, { - "name": "allowedPrograms", - "type": { - "vec": "publicKey" - } + name: "allowedPrograms"; + type: { + vec: "publicKey"; + }; } - ] - } + ]; + }; }, { - "name": "accountBalances", - "type": { - "kind": "struct", - "fields": [ + name: "accountBalances"; + type: { + kind: "struct"; + fields: [ { - "name": "balances", - "type": { - "vec": { - "defined": "AccountBalance" - } - } + name: "balances"; + type: { + vec: { + defined: "AccountBalance"; + }; + }; } - ] - } + ]; + }; } - ], - "types": [ + ]; + types: [ { - "name": "UpdateMintManagerIx", - "type": { - "kind": "struct", - "fields": [ + name: "SetInUseByIx"; + type: { + kind: "struct"; + fields: [ { - "name": "authority", - "type": "publicKey" + name: "inUseBy"; + type: "publicKey"; } - ] - } + ]; + }; }, { - "name": "InitRulesetIx", - "type": { - "kind": "struct", - "fields": [ + name: "UpdateMintManagerIx"; + type: { + kind: "struct"; + fields: [ { - "name": "name", - "type": "string" + name: "authority"; + type: "publicKey"; + } + ]; + }; + }, + { + name: "InitRulesetIx"; + type: { + kind: "struct"; + fields: [ + { + name: "name"; + type: "string"; }, { - "name": "collector", - "type": "publicKey" + name: "collector"; + type: "publicKey"; }, { - "name": "disallowedAddresses", - "type": { - "vec": "publicKey" - } + name: "disallowedAddresses"; + type: { + vec: "publicKey"; + }; }, { - "name": "allowedPrograms", - "type": { - "vec": "publicKey" - } + name: "allowedPrograms"; + type: { + vec: "publicKey"; + }; }, { - "name": "checkSellerFeeBasisPoints", - "type": "bool" + name: "checkSellerFeeBasisPoints"; + type: "bool"; } - ] - } + ]; + }; }, { - "name": "UpdateRulesetIx", - "type": { - "kind": "struct", - "fields": [ + name: "UpdateRulesetIx"; + type: { + kind: "struct"; + fields: [ { - "name": "authority", - "type": "publicKey" + name: "authority"; + type: "publicKey"; }, { - "name": "collector", - "type": "publicKey" + name: "collector"; + type: "publicKey"; }, { - "name": "checkSellerFeeBasisPoints", - "type": "bool" + name: "checkSellerFeeBasisPoints"; + type: "bool"; }, { - "name": "disallowedAddresses", - "type": { - "vec": "publicKey" - } + name: "disallowedAddresses"; + type: { + vec: "publicKey"; + }; }, { - "name": "allowedPrograms", - "type": { - "vec": "publicKey" - } + name: "allowedPrograms"; + type: { + vec: "publicKey"; + }; } - ] - } + ]; + }; }, { - "name": "AccountBalance", - "type": { - "kind": "struct", - "fields": [ + name: "AccountBalance"; + type: { + kind: "struct"; + fields: [ { - "name": "address", - "type": "publicKey" + name: "address"; + type: "publicKey"; }, { - "name": "mint", - "type": "publicKey" + name: "mint"; + type: "publicKey"; }, { - "name": "size", - "type": "u64" + name: "size"; + type: "u64"; }, { - "name": "balance", - "type": "u64" + name: "balance"; + type: "u64"; } - ] - } + ]; + }; } - ], - "errors": [ + ]; + errors: [ + { + code: 6000; + name: "InvalidMint"; + msg: "Invalid mint"; + }, + { + code: 6001; + name: "InvalidCollector"; + msg: "Invalid collector address"; + }, { - "code": 6000, - "name": "InvalidMint", - "msg": "Invalid mint" + code: 6002; + name: "InvalidAuthority"; + msg: "Invalid authority address"; }, { - "code": 6001, - "name": "InvalidCollector", - "msg": "Invalid collector address" + code: 6003; + name: "InvalidMintManager"; + msg: "Invalid mint manager"; }, { - "code": 6002, - "name": "InvalidAuthority", - "msg": "Invalid authority address" + code: 6004; + name: "InvlaidHolderTokenAccount"; + msg: "Invalid holder token account"; }, { - "code": 6003, - "name": "InvalidMintManager", - "msg": "Invalid mint manager" + code: 6005; + name: "InvalidTargetTokenAccount"; + msg: "Invalid target token account"; }, { - "code": 6004, - "name": "InvlaidHolderTokenAccount", - "msg": "Invalid holder token account" + code: 6006; + name: "InvalidCloseTokenAccount"; + msg: "Invalid token account to close"; }, { - "code": 6005, - "name": "InvalidTargetTokenAccount", - "msg": "Invalid target token account" + code: 6007; + name: "InvalidHolderTokenAccount"; + msg: "Invalid holder token account"; }, { - "code": 6006, - "name": "InvalidCloseTokenAccount", - "msg": "Invalid token account to close" + code: 6008; + name: "InvalidRuleset"; + msg: "Invalid ruleset"; }, { - "code": 6007, - "name": "InvalidHolderTokenAccount", - "msg": "Invalid holder token account" + code: 6009; + name: "InvalidPreTransferInstruction"; + msg: "Invalid pre transfer instruction"; }, { - "code": 6008, - "name": "InvalidRuleset", - "msg": "Invalid ruleset" + code: 6010; + name: "InvalidPostTransferInstruction"; + msg: "Invalid post transfer instruction"; }, { - "code": 6009, - "name": "InvalidPreTransferInstruction", - "msg": "Invalid pre transfer instruction" + code: 6011; + name: "ProgramDisallowed"; + msg: "Disallowed program included in transfer"; }, { - "code": 6010, - "name": "InvalidPostTransferInstruction", - "msg": "Invalid post transfer instruction" + code: 6012; + name: "ProgramNotAllowed"; + msg: "Program not allowed in allowed programs to transfer"; }, { - "code": 6011, - "name": "ProgramDisallowed", - "msg": "Disallowed program included in transfer" + code: 6013; + name: "UnknownAccount"; + msg: "Unknown account found in instruction"; }, { - "code": 6012, - "name": "ProgramNotAllowed", - "msg": "Program not allowed in allowed programs to transfer" + code: 6014; + name: "AccountNotFound"; + msg: "Account not found in instruction"; }, { - "code": 6013, - "name": "UnknownAccount", - "msg": "Unknown account found in instruction" + code: 6015; + name: "TokenAlreadyInUse"; + msg: "Token already in use"; }, { - "code": 6014, - "name": "AccountNotFound", - "msg": "Account not found in instruction" + code: 6016; + name: "InvalidTokenUser"; + msg: "Invalid token user"; + }, + { + code: 6017; + name: "TokenCurentlyInUse"; + msg: "Token currently in use"; } - ] + ]; }; export const IDL: CardinalCreatorStandard = { - "version": "0.1.0", - "name": "cardinal_creator_standard", - "instructions": [ + version: "0.1.5", + name: "cardinal_creator_standard", + instructions: [ { - "name": "initMintManager", - "accounts": [ + name: "initMintManager", + accounts: [ { - "name": "mintManager", - "isMut": true, - "isSigner": false + name: "mintManager", + isMut: true, + isSigner: false, }, { - "name": "mint", - "isMut": true, - "isSigner": false + name: "mint", + isMut: true, + isSigner: false, }, { - "name": "ruleset", - "isMut": false, - "isSigner": false + name: "ruleset", + isMut: false, + isSigner: false, }, { - "name": "holderTokenAccount", - "isMut": true, - "isSigner": false + name: "holderTokenAccount", + isMut: true, + isSigner: false, }, { - "name": "collector", - "isMut": true, - "isSigner": false + name: "collector", + isMut: true, + isSigner: false, }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "authority", + isMut: false, + isSigner: true, }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "payer", + isMut: true, + isSigner: true, }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram", + isMut: false, + isSigner: false, }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } + name: "systemProgram", + isMut: false, + isSigner: false, + }, ], - "args": [] + args: [], }, { - "name": "updateMintManager", - "accounts": [ + name: "updateMintManager", + accounts: [ { - "name": "mintManager", - "isMut": true, - "isSigner": false + name: "mintManager", + isMut: true, + isSigner: false, }, { - "name": "ruleset", - "isMut": false, - "isSigner": false + name: "ruleset", + isMut: false, + isSigner: false, }, { - "name": "collector", - "isMut": true, - "isSigner": false + name: "collector", + isMut: true, + isSigner: false, }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "authority", + isMut: false, + isSigner: true, }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "payer", + isMut: true, + isSigner: true, }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } + name: "systemProgram", + isMut: false, + isSigner: false, + }, ], - "args": [ + args: [ { - "name": "ix", - "type": { - "defined": "UpdateMintManagerIx" - } - } - ] + name: "ix", + type: { + defined: "UpdateMintManagerIx", + }, + }, + ], }, { - "name": "initRuleset", - "accounts": [ + name: "setInUseBy", + accounts: [ { - "name": "ruleset", - "isMut": true, - "isSigner": false + name: "mintManager", + isMut: true, + isSigner: false, }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "holder", + isMut: false, + isSigner: true, }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "holderTokenAccount", + isMut: false, + isSigner: false, }, + ], + args: [ { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } + name: "ix", + type: { + defined: "SetInUseByIx", + }, + }, ], - "args": [ + }, + { + name: "removeInUseBy", + accounts: [ { - "name": "ix", - "type": { - "defined": "InitRulesetIx" - } - } - ] + name: "mintManager", + isMut: true, + isSigner: false, + }, + { + name: "user", + isMut: false, + isSigner: true, + }, + ], + args: [], }, { - "name": "updateRuleset", - "accounts": [ + name: "initRuleset", + accounts: [ { - "name": "ruleset", - "isMut": true, - "isSigner": false + name: "ruleset", + isMut: true, + isSigner: false, }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "authority", + isMut: false, + isSigner: true, }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, ], - "args": [ + args: [ { - "name": "ix", - "type": { - "defined": "UpdateRulesetIx" - } - } - ] + name: "ix", + type: { + defined: "InitRulesetIx", + }, + }, + ], }, { - "name": "initMint", - "accounts": [ + name: "updateRuleset", + accounts: [ + { + name: "ruleset", + isMut: true, + isSigner: false, + }, + { + name: "authority", + isMut: false, + isSigner: true, + }, { - "name": "mintManager", - "isMut": true, - "isSigner": false + name: "systemProgram", + isMut: false, + isSigner: false, }, + ], + args: [ { - "name": "mint", - "isMut": true, - "isSigner": true + name: "ix", + type: { + defined: "UpdateRulesetIx", + }, }, + ], + }, + { + name: "initMint", + accounts: [ { - "name": "ruleset", - "isMut": false, - "isSigner": false + name: "mintManager", + isMut: true, + isSigner: false, }, { - "name": "targetTokenAccount", - "isMut": true, - "isSigner": false + name: "mint", + isMut: true, + isSigner: true, }, { - "name": "target", - "isMut": false, - "isSigner": true + name: "ruleset", + isMut: false, + isSigner: false, }, { - "name": "collector", - "isMut": true, - "isSigner": false + name: "targetTokenAccount", + isMut: true, + isSigner: false, }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "target", + isMut: false, + isSigner: true, }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "collector", + isMut: true, + isSigner: false, }, { - "name": "rent", - "isMut": false, - "isSigner": false + name: "authority", + isMut: false, + isSigner: true, }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "payer", + isMut: true, + isSigner: true, }, { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false + name: "rent", + isMut: false, + isSigner: false, }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, ], - "args": [] + args: [], }, { - "name": "initAccount", - "accounts": [ + name: "initAccount", + accounts: [ { - "name": "mint", - "isMut": false, - "isSigner": false + name: "mint", + isMut: false, + isSigner: false, }, { - "name": "tokenAccount", - "isMut": true, - "isSigner": false + name: "tokenAccount", + isMut: true, + isSigner: false, }, { - "name": "tokenAccountOwner", - "isMut": false, - "isSigner": false + name: "tokenAccountOwner", + isMut: false, + isSigner: false, }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "payer", + isMut: true, + isSigner: true, }, { - "name": "rent", - "isMut": false, - "isSigner": false + name: "rent", + isMut: false, + isSigner: false, }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram", + isMut: false, + isSigner: false, }, { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false + name: "associatedTokenProgram", + isMut: false, + isSigner: false, }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } + name: "systemProgram", + isMut: false, + isSigner: false, + }, ], - "args": [] + args: [], }, { - "name": "approve", - "accounts": [ + name: "approve", + accounts: [ { - "name": "mintManager", - "isMut": false, - "isSigner": false + name: "mintManager", + isMut: false, + isSigner: false, }, { - "name": "mint", - "isMut": false, - "isSigner": false + name: "mint", + isMut: false, + isSigner: false, }, { - "name": "holderTokenAccount", - "isMut": true, - "isSigner": false + name: "holderTokenAccount", + isMut: true, + isSigner: false, }, { - "name": "holder", - "isMut": true, - "isSigner": true + name: "holder", + isMut: true, + isSigner: true, }, { - "name": "delegate", - "isMut": true, - "isSigner": false + name: "delegate", + isMut: true, + isSigner: false, }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } + name: "tokenProgram", + isMut: false, + isSigner: false, + }, ], - "args": [] + args: [], }, { - "name": "revoke", - "accounts": [ + name: "revoke", + accounts: [ { - "name": "mintManager", - "isMut": true, - "isSigner": false + name: "mintManager", + isMut: true, + isSigner: false, }, { - "name": "mint", - "isMut": false, - "isSigner": false + name: "mint", + isMut: false, + isSigner: false, }, { - "name": "holderTokenAccount", - "isMut": true, - "isSigner": false + name: "holderTokenAccount", + isMut: true, + isSigner: false, }, { - "name": "holder", - "isMut": true, - "isSigner": true + name: "holder", + isMut: true, + isSigner: true, }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } + name: "tokenProgram", + isMut: false, + isSigner: false, + }, ], - "args": [] + args: [], }, { - "name": "burn", - "accounts": [ + name: "burn", + accounts: [ { - "name": "mintManager", - "isMut": true, - "isSigner": false + name: "mintManager", + isMut: true, + isSigner: false, }, { - "name": "mint", - "isMut": true, - "isSigner": false + name: "mint", + isMut: true, + isSigner: false, }, { - "name": "holderTokenAccount", - "isMut": true, - "isSigner": false + name: "holderTokenAccount", + isMut: true, + isSigner: false, }, { - "name": "holder", - "isMut": false, - "isSigner": true + name: "holder", + isMut: false, + isSigner: true, }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram", + isMut: false, + isSigner: false, }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } + name: "systemProgram", + isMut: false, + isSigner: false, + }, ], - "args": [] + args: [], }, { - "name": "close", - "accounts": [ + name: "close", + accounts: [ { - "name": "mintManager", - "isMut": false, - "isSigner": false + name: "mintManager", + isMut: false, + isSigner: false, }, { - "name": "mint", - "isMut": true, - "isSigner": false + name: "mint", + isMut: true, + isSigner: false, }, { - "name": "tokenAccount", - "isMut": true, - "isSigner": false + name: "tokenAccount", + isMut: true, + isSigner: false, }, { - "name": "owner", - "isMut": false, - "isSigner": true + name: "owner", + isMut: false, + isSigner: true, }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram", + isMut: false, + isSigner: false, }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } + name: "systemProgram", + isMut: false, + isSigner: false, + }, ], - "args": [] + args: [], }, { - "name": "transfer", - "accounts": [ + name: "transfer", + accounts: [ { - "name": "mintManager", - "isMut": false, - "isSigner": false + name: "mintManager", + isMut: false, + isSigner: false, }, { - "name": "ruleset", - "isMut": false, - "isSigner": false + name: "ruleset", + isMut: false, + isSigner: false, }, { - "name": "mint", - "isMut": false, - "isSigner": false + name: "mint", + isMut: false, + isSigner: false, }, { - "name": "from", - "isMut": true, - "isSigner": false + name: "from", + isMut: true, + isSigner: false, }, { - "name": "to", - "isMut": true, - "isSigner": false + name: "to", + isMut: true, + isSigner: false, }, { - "name": "authority", - "isMut": false, - "isSigner": true + name: "authority", + isMut: false, + isSigner: true, }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + name: "tokenProgram", + isMut: false, + isSigner: false, }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + name: "systemProgram", + isMut: false, + isSigner: false, }, { - "name": "instructions", - "isMut": false, - "isSigner": false - } + name: "instructions", + isMut: false, + isSigner: false, + }, ], - "args": [] + args: [], }, { - "name": "preTransfer", - "accounts": [ + name: "preTransfer", + accounts: [ { - "name": "accountBalances", - "isMut": true, - "isSigner": false + name: "accountBalances", + isMut: true, + isSigner: false, }, { - "name": "payer", - "isMut": true, - "isSigner": true + name: "payer", + isMut: true, + isSigner: true, }, { - "name": "instructions", - "isMut": false, - "isSigner": false - } + name: "instructions", + isMut: false, + isSigner: false, + }, ], - "args": [] + args: [], }, { - "name": "postTransfer", - "accounts": [ + name: "postTransfer", + accounts: [ { - "name": "accountBalances", - "isMut": true, - "isSigner": false + name: "accountBalances", + isMut: true, + isSigner: false, }, { - "name": "collector", - "isMut": true, - "isSigner": false + name: "collector", + isMut: true, + isSigner: false, }, { - "name": "instructions", - "isMut": false, - "isSigner": false - } + name: "instructions", + isMut: false, + isSigner: false, + }, ], - "args": [] - } + args: [], + }, ], - "accounts": [ + accounts: [ { - "name": "mintManager", - "type": { - "kind": "struct", - "fields": [ + name: "mintManager", + type: { + kind: "struct", + fields: [ { - "name": "bump", - "type": "u8" + name: "bump", + type: "u8", }, { - "name": "version", - "type": "u8" + name: "version", + type: "u8", }, { - "name": "mint", - "type": "publicKey" + name: "mint", + type: "publicKey", }, { - "name": "authority", - "type": "publicKey" + name: "authority", + type: "publicKey", }, { - "name": "ruleset", - "type": "publicKey" - } - ] - } + name: "ruleset", + type: "publicKey", + }, + { + name: "inUseBy", + type: { + option: "publicKey", + }, + }, + ], + }, }, { - "name": "ruleset", - "type": { - "kind": "struct", - "fields": [ + name: "ruleset", + type: { + kind: "struct", + fields: [ { - "name": "bump", - "type": "u8" + name: "bump", + type: "u8", }, { - "name": "version", - "type": "u8" + name: "version", + type: "u8", }, { - "name": "authority", - "type": "publicKey" + name: "authority", + type: "publicKey", }, { - "name": "collector", - "type": "publicKey" + name: "collector", + type: "publicKey", }, { - "name": "checkSellerFeeBasisPoints", - "type": "bool" + name: "checkSellerFeeBasisPoints", + type: "bool", }, { - "name": "name", - "type": "string" + name: "name", + type: "string", }, { - "name": "disallowedAddresses", - "type": { - "vec": "publicKey" - } + name: "disallowedAddresses", + type: { + vec: "publicKey", + }, }, { - "name": "allowedPrograms", - "type": { - "vec": "publicKey" - } - } - ] - } + name: "allowedPrograms", + type: { + vec: "publicKey", + }, + }, + ], + }, }, { - "name": "accountBalances", - "type": { - "kind": "struct", - "fields": [ + name: "accountBalances", + type: { + kind: "struct", + fields: [ { - "name": "balances", - "type": { - "vec": { - "defined": "AccountBalance" - } - } - } - ] - } - } + name: "balances", + type: { + vec: { + defined: "AccountBalance", + }, + }, + }, + ], + }, + }, ], - "types": [ + types: [ { - "name": "UpdateMintManagerIx", - "type": { - "kind": "struct", - "fields": [ + name: "SetInUseByIx", + type: { + kind: "struct", + fields: [ { - "name": "authority", - "type": "publicKey" - } - ] - } + name: "inUseBy", + type: "publicKey", + }, + ], + }, }, { - "name": "InitRulesetIx", - "type": { - "kind": "struct", - "fields": [ + name: "UpdateMintManagerIx", + type: { + kind: "struct", + fields: [ { - "name": "name", - "type": "string" + name: "authority", + type: "publicKey", }, + ], + }, + }, + { + name: "InitRulesetIx", + type: { + kind: "struct", + fields: [ { - "name": "collector", - "type": "publicKey" + name: "name", + type: "string", }, { - "name": "disallowedAddresses", - "type": { - "vec": "publicKey" - } + name: "collector", + type: "publicKey", }, { - "name": "allowedPrograms", - "type": { - "vec": "publicKey" - } + name: "disallowedAddresses", + type: { + vec: "publicKey", + }, }, { - "name": "checkSellerFeeBasisPoints", - "type": "bool" - } - ] - } + name: "allowedPrograms", + type: { + vec: "publicKey", + }, + }, + { + name: "checkSellerFeeBasisPoints", + type: "bool", + }, + ], + }, }, { - "name": "UpdateRulesetIx", - "type": { - "kind": "struct", - "fields": [ + name: "UpdateRulesetIx", + type: { + kind: "struct", + fields: [ { - "name": "authority", - "type": "publicKey" + name: "authority", + type: "publicKey", }, { - "name": "collector", - "type": "publicKey" + name: "collector", + type: "publicKey", }, { - "name": "checkSellerFeeBasisPoints", - "type": "bool" + name: "checkSellerFeeBasisPoints", + type: "bool", }, { - "name": "disallowedAddresses", - "type": { - "vec": "publicKey" - } + name: "disallowedAddresses", + type: { + vec: "publicKey", + }, }, { - "name": "allowedPrograms", - "type": { - "vec": "publicKey" - } - } - ] - } + name: "allowedPrograms", + type: { + vec: "publicKey", + }, + }, + ], + }, }, { - "name": "AccountBalance", - "type": { - "kind": "struct", - "fields": [ + name: "AccountBalance", + type: { + kind: "struct", + fields: [ { - "name": "address", - "type": "publicKey" + name: "address", + type: "publicKey", }, { - "name": "mint", - "type": "publicKey" + name: "mint", + type: "publicKey", }, { - "name": "size", - "type": "u64" + name: "size", + type: "u64", }, { - "name": "balance", - "type": "u64" - } - ] - } - } + name: "balance", + type: "u64", + }, + ], + }, + }, ], - "errors": [ + errors: [ { - "code": 6000, - "name": "InvalidMint", - "msg": "Invalid mint" + code: 6000, + name: "InvalidMint", + msg: "Invalid mint", }, { - "code": 6001, - "name": "InvalidCollector", - "msg": "Invalid collector address" + code: 6001, + name: "InvalidCollector", + msg: "Invalid collector address", }, { - "code": 6002, - "name": "InvalidAuthority", - "msg": "Invalid authority address" + code: 6002, + name: "InvalidAuthority", + msg: "Invalid authority address", }, { - "code": 6003, - "name": "InvalidMintManager", - "msg": "Invalid mint manager" + code: 6003, + name: "InvalidMintManager", + msg: "Invalid mint manager", }, { - "code": 6004, - "name": "InvlaidHolderTokenAccount", - "msg": "Invalid holder token account" + code: 6004, + name: "InvlaidHolderTokenAccount", + msg: "Invalid holder token account", }, { - "code": 6005, - "name": "InvalidTargetTokenAccount", - "msg": "Invalid target token account" + code: 6005, + name: "InvalidTargetTokenAccount", + msg: "Invalid target token account", }, { - "code": 6006, - "name": "InvalidCloseTokenAccount", - "msg": "Invalid token account to close" + code: 6006, + name: "InvalidCloseTokenAccount", + msg: "Invalid token account to close", }, { - "code": 6007, - "name": "InvalidHolderTokenAccount", - "msg": "Invalid holder token account" + code: 6007, + name: "InvalidHolderTokenAccount", + msg: "Invalid holder token account", }, { - "code": 6008, - "name": "InvalidRuleset", - "msg": "Invalid ruleset" + code: 6008, + name: "InvalidRuleset", + msg: "Invalid ruleset", }, { - "code": 6009, - "name": "InvalidPreTransferInstruction", - "msg": "Invalid pre transfer instruction" + code: 6009, + name: "InvalidPreTransferInstruction", + msg: "Invalid pre transfer instruction", }, { - "code": 6010, - "name": "InvalidPostTransferInstruction", - "msg": "Invalid post transfer instruction" + code: 6010, + name: "InvalidPostTransferInstruction", + msg: "Invalid post transfer instruction", }, { - "code": 6011, - "name": "ProgramDisallowed", - "msg": "Disallowed program included in transfer" + code: 6011, + name: "ProgramDisallowed", + msg: "Disallowed program included in transfer", }, { - "code": 6012, - "name": "ProgramNotAllowed", - "msg": "Program not allowed in allowed programs to transfer" + code: 6012, + name: "ProgramNotAllowed", + msg: "Program not allowed in allowed programs to transfer", }, { - "code": 6013, - "name": "UnknownAccount", - "msg": "Unknown account found in instruction" + code: 6013, + name: "UnknownAccount", + msg: "Unknown account found in instruction", }, { - "code": 6014, - "name": "AccountNotFound", - "msg": "Account not found in instruction" - } - ] + code: 6014, + name: "AccountNotFound", + msg: "Account not found in instruction", + }, + { + code: 6015, + name: "TokenAlreadyInUse", + msg: "Token already in use", + }, + { + code: 6016, + name: "InvalidTokenUser", + msg: "Invalid token user", + }, + { + code: 6017, + name: "TokenCurentlyInUse", + msg: "Token currently in use", + }, + ], }; diff --git a/tests/utils.ts b/tests/utils.ts index 6d932ee4..48204894 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -8,8 +8,6 @@ import { import { PublicKey, Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js"; import { PROGRAM_ADDRESS } from "../sdk/generated"; import { utils, Wallet } from "@project-serum/anchor"; -import { parseProgramLogs } from "../sdk/errors/parseTransactionLogs"; -import { formatInstructionLogsForConsole } from "../sdk/errors/formatLogs"; export async function newAccountWithLamports( connection: Connection,