From c817472e8599beee57abecfe767051d4f9f2227f Mon Sep 17 00:00:00 2001 From: Giannis Chatziveroglou Date: Tue, 2 Aug 2022 00:38:28 -0400 Subject: [PATCH 1/6] Update withRemainingAccountsForPayment --- src/programs/tokenManager/utils.ts | 40 ++++++++++++++++-------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/programs/tokenManager/utils.ts b/src/programs/tokenManager/utils.ts index 2be48b961..19b115df5 100644 --- a/src/programs/tokenManager/utils.ts +++ b/src/programs/tokenManager/utils.ts @@ -70,6 +70,24 @@ export const withRemainingAccountsForPayment = async ( paymentMint, excludeCreators ); + const mintMetadataId = await Metadata.getPDA(mint); + const paymentRemainingAccounts = [ + { + pubkey: paymentMint, + isSigner: false, + isWritable: true, + }, + { + pubkey: mint, + isSigner: false, + isWritable: true, + }, + { + pubkey: mintMetadataId, + isSigner: false, + isWritable: true, + }, + ]; if (receiptMint) { const receiptMintLargestAccount = await connection.getTokenLargestAccounts( @@ -123,6 +141,7 @@ export const withRemainingAccountsForPayment = async ( isSigner: false, isWritable: true, }, + ...paymentRemainingAccounts, ...royaltiesRemainingAccounts, ], ]; @@ -152,7 +171,7 @@ export const withRemainingAccountsForPayment = async ( return [ issuerTokenAccountId, feeCollectorTokenAccountId, - royaltiesRemainingAccounts, + [...paymentRemainingAccounts, ...royaltiesRemainingAccounts], ]; } }; @@ -274,22 +293,5 @@ export const withRemainingAccountsForHanldePaymentWithRoyalties = async ( } } - return [ - { - pubkey: paymentMint, - isSigner: false, - isWritable: true, - }, - { - pubkey: mint, - isSigner: false, - isWritable: true, - }, - { - pubkey: mintMetadataId, - isSigner: false, - isWritable: true, - }, - ...creatorsRemainingAccounts, - ]; + return creatorsRemainingAccounts; }; From 24515f4082172a7bb7ae29d964b69e6066c19fa8 Mon Sep 17 00:00:00 2001 From: jpbogle Date: Tue, 2 Aug 2022 12:18:58 -0400 Subject: [PATCH 2/6] Skip close for reissuing tokens --- .../invalidate-parallel.ts | 26 ++++++++++++------- tools/getPaymentManager.ts | 3 ++- tools/updatePaymentManager.ts | 6 ++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/api/time-invalidator-crank/invalidate-parallel.ts b/api/time-invalidator-crank/invalidate-parallel.ts index b9948e26a..66409d978 100755 --- a/api/time-invalidator-crank/invalidate-parallel.ts +++ b/api/time-invalidator-crank/invalidate-parallel.ts @@ -5,7 +5,11 @@ import { } from "@cardinal/token-manager"; import { timeInvalidator } from "@cardinal/token-manager/dist/cjs/programs"; import { shouldTimeInvalidate } from "@cardinal/token-manager/dist/cjs/programs/timeInvalidator/utils"; -import { withRemainingAccountsForReturn } from "@cardinal/token-manager/dist/cjs/programs/tokenManager"; +import { + InvalidationType, + TokenManagerState, + withRemainingAccountsForReturn, +} from "@cardinal/token-manager/dist/cjs/programs/tokenManager"; import { utils } from "@project-serum/anchor"; import { SignerWallet } from "@saberhq/solana-contrib"; import { @@ -159,15 +163,17 @@ const main = async (cluster: string) => { remainingAccountsForReturn ) ); - transaction.add( - timeInvalidator.instruction.close( - connection, - new SignerWallet(wallet), - timeInvalidatorData.pubkey, - timeInvalidatorData.parsed.tokenManager, - timeInvalidatorData.parsed.collector - ) - ); + if (tokenManagerData.parsed.state === InvalidationType.Reissue) { + transaction.add( + timeInvalidator.instruction.close( + connection, + new SignerWallet(wallet), + timeInvalidatorData.pubkey, + timeInvalidatorData.parsed.tokenManager, + timeInvalidatorData.parsed.collector + ) + ); + } console.log( `[${chunkNum}/${chunks.length}][${ i / chunk.length diff --git a/tools/getPaymentManager.ts b/tools/getPaymentManager.ts index 421318ad3..0ef7186f3 100644 --- a/tools/getPaymentManager.ts +++ b/tools/getPaymentManager.ts @@ -16,7 +16,8 @@ const main = async (paymentManagerName: string, cluster = "mainnet") => { } else { console.log( `Got payment manager ${paymentManagerName} (${paymentManagerId.toString()})`, - paymentManagerData + paymentManagerData, + paymentManagerData.parsed.authority.toString() ); } }; diff --git a/tools/updatePaymentManager.ts b/tools/updatePaymentManager.ts index bcea20e93..207e62b39 100644 --- a/tools/updatePaymentManager.ts +++ b/tools/updatePaymentManager.ts @@ -22,7 +22,7 @@ export type PaymentManagerParams = { const main = async ( paymentManagerName: string, params: PaymentManagerParams, - cluster = "devnet" + cluster = "mainnet" ) => { const connection = connectionFor(cluster); const transaction = new web3Js.Transaction(); @@ -63,8 +63,8 @@ const paymentManagerName = "cardinal"; const params: PaymentManagerParams = { authority: new PublicKey("cpmaMZyBQiPxpeuxNsQhW7N8z1o9yaNdLgiPhWGUEiX"), feeCollector: new PublicKey("cpmaMZyBQiPxpeuxNsQhW7N8z1o9yaNdLgiPhWGUEiX"), - makerFeeBasisPoints: 300, - takerFeeBasisPoints: 300, + makerFeeBasisPoints: 600, + takerFeeBasisPoints: 0, }; main(paymentManagerName, params).catch((e) => console.log(e)); From aadd0b6749c8455944fe9de58b3f4205d3899c8f Mon Sep 17 00:00:00 2001 From: Giannis Chatziveroglou Date: Tue, 2 Aug 2022 13:51:35 -0400 Subject: [PATCH 3/6] bump version --- Cargo.lock | 10 +++++----- package.json | 2 +- programs/cardinal-paid-claim-approver/Cargo.toml | 6 +++--- programs/cardinal-payment-manager/Cargo.toml | 2 +- programs/cardinal-time-invalidator/Cargo.toml | 6 +++--- programs/cardinal-token-manager/Cargo.toml | 2 +- programs/cardinal-use-invalidator/Cargo.toml | 6 +++--- src/idl/cardinal_paid_claim_approver.ts | 4 ++-- src/idl/cardinal_payment_manager.ts | 4 ++-- src/idl/cardinal_time_invalidator.ts | 4 ++-- src/idl/cardinal_token_manager.ts | 4 ++-- src/idl/cardinal_use_invalidator.ts | 4 ++-- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca29df88e..7c8d1e9f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -412,7 +412,7 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cardinal-paid-claim-approver" -version = "1.5.0" +version = "1.5.7" dependencies = [ "anchor-lang", "anchor-spl", @@ -426,7 +426,7 @@ dependencies = [ [[package]] name = "cardinal-payment-manager" -version = "1.5.0" +version = "1.5.7" dependencies = [ "anchor-lang", "anchor-spl", @@ -439,7 +439,7 @@ dependencies = [ [[package]] name = "cardinal-time-invalidator" -version = "1.5.0" +version = "1.5.7" dependencies = [ "anchor-lang", "anchor-spl", @@ -453,7 +453,7 @@ dependencies = [ [[package]] name = "cardinal-token-manager" -version = "1.5.0" +version = "1.5.7" dependencies = [ "anchor-lang", "anchor-spl", @@ -466,7 +466,7 @@ dependencies = [ [[package]] name = "cardinal-use-invalidator" -version = "1.5.0" +version = "1.5.7" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/package.json b/package.json index e290fcea0..9357aacd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cardinal/token-manager", - "version": "1.5.6", + "version": "1.5.7", "description": "Cardinal token manager SDK", "keywords": [ "solana", diff --git a/programs/cardinal-paid-claim-approver/Cargo.toml b/programs/cardinal-paid-claim-approver/Cargo.toml index ecacdf14c..21c17f66b 100644 --- a/programs/cardinal-paid-claim-approver/Cargo.toml +++ b/programs/cardinal-paid-claim-approver/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cardinal-paid-claim-approver" -version = "1.5.0" +version = "1.5.7" description = "Cardinal paid claim approver" edition = "2021" homepage = "https://cardinal.so" @@ -25,8 +25,8 @@ anchor-spl = "0.24.2" spl-associated-token-account = "1.0.3" spl-token = { version = "3.2.0", features = ["no-entrypoint"] } solana-program = "1.9.28" -cardinal-token-manager = { version = "^1.5.0", path = "../cardinal-token-manager", features = ["cpi"] } -cardinal-payment-manager = { version = "^1.5.0", path = "../cardinal-payment-manager", features = ["cpi"] } +cardinal-token-manager = { version = "^1.5.7", path = "../cardinal-token-manager", features = ["cpi"] } +cardinal-payment-manager = { version = "^1.5.7", path = "../cardinal-payment-manager", features = ["cpi"] } [dev-dependencies] proptest = { version = "1.0" } \ No newline at end of file diff --git a/programs/cardinal-payment-manager/Cargo.toml b/programs/cardinal-payment-manager/Cargo.toml index 67c4197a3..8ed12e077 100644 --- a/programs/cardinal-payment-manager/Cargo.toml +++ b/programs/cardinal-payment-manager/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cardinal-payment-manager" -version = "1.5.0" +version = "1.5.7" description = "Cardinal payment manager" edition = "2021" homepage = "https://cardinal.so" diff --git a/programs/cardinal-time-invalidator/Cargo.toml b/programs/cardinal-time-invalidator/Cargo.toml index 3001b63af..75cfa0932 100644 --- a/programs/cardinal-time-invalidator/Cargo.toml +++ b/programs/cardinal-time-invalidator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cardinal-time-invalidator" -version = "1.5.0" +version = "1.5.7" description = "Program for a invalidating token managers based on time" edition = "2021" homepage = "https://cardinal.so" @@ -25,8 +25,8 @@ anchor-spl = "0.24.2" spl-associated-token-account = "1.0.3" spl-token = { version = "3.2.0", features = ["no-entrypoint"] } solana-program = "1.9.28" -cardinal-token-manager = { version = "^1.5.0", path = "../cardinal-token-manager", features = ["cpi"] } -cardinal-payment-manager = { version = "^1.5.0", path = "../cardinal-payment-manager", features = ["cpi"] } +cardinal-token-manager = { version = "^1.5.7", path = "../cardinal-token-manager", features = ["cpi"] } +cardinal-payment-manager = { version = "^1.5.7", path = "../cardinal-payment-manager", features = ["cpi"] } [dev-dependencies] proptest = { version = "1.0" } \ No newline at end of file diff --git a/programs/cardinal-token-manager/Cargo.toml b/programs/cardinal-token-manager/Cargo.toml index 7babab55d..7dff80e36 100644 --- a/programs/cardinal-token-manager/Cargo.toml +++ b/programs/cardinal-token-manager/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cardinal-token-manager" -version = "1.5.0" +version = "1.5.7" description = "Cardinal token manager" edition = "2021" homepage = "https://cardinal.so" diff --git a/programs/cardinal-use-invalidator/Cargo.toml b/programs/cardinal-use-invalidator/Cargo.toml index 1f740a705..56eac3b9c 100644 --- a/programs/cardinal-use-invalidator/Cargo.toml +++ b/programs/cardinal-use-invalidator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cardinal-use-invalidator" -version = "1.5.0" +version = "1.5.7" description = "Cardinal usage invalidator and counter" edition = "2021" homepage = "https://cardinal.so" @@ -25,8 +25,8 @@ anchor-spl = "0.24.2" spl-associated-token-account = "1.0.3" spl-token = { version = "3.2.0", features = ["no-entrypoint"] } solana-program = "1.9.28" -cardinal-token-manager = { version = "^1.5.0", path = "../cardinal-token-manager", features = ["cpi"] } -cardinal-payment-manager = { version = "^1.5.0", path = "../cardinal-payment-manager", features = ["cpi"] } +cardinal-token-manager = { version = "^1.5.7", path = "../cardinal-token-manager", features = ["cpi"] } +cardinal-payment-manager = { version = "^1.5.7", path = "../cardinal-payment-manager", features = ["cpi"] } mpl-token-metadata = { version = "1.3.3", features = ["no-entrypoint"] } arrayref = "0.3.6" diff --git a/src/idl/cardinal_paid_claim_approver.ts b/src/idl/cardinal_paid_claim_approver.ts index 2968ba4d2..ba0f0f456 100644 --- a/src/idl/cardinal_paid_claim_approver.ts +++ b/src/idl/cardinal_paid_claim_approver.ts @@ -1,5 +1,5 @@ export type CardinalPaidClaimApprover = { - version: "1.5.0"; + version: "1.5.7"; name: "cardinal_paid_claim_approver"; instructions: [ { @@ -253,7 +253,7 @@ export type CardinalPaidClaimApprover = { }; export const IDL: CardinalPaidClaimApprover = { - version: "1.5.0", + version: "1.5.7", name: "cardinal_paid_claim_approver", instructions: [ { diff --git a/src/idl/cardinal_payment_manager.ts b/src/idl/cardinal_payment_manager.ts index cc1b7b797..4216f0469 100644 --- a/src/idl/cardinal_payment_manager.ts +++ b/src/idl/cardinal_payment_manager.ts @@ -1,5 +1,5 @@ export type CardinalPaymentManager = { - version: "1.5.0"; + version: "1.5.7"; name: "cardinal_payment_manager"; instructions: [ { @@ -301,7 +301,7 @@ export type CardinalPaymentManager = { }; export const IDL: CardinalPaymentManager = { - version: "1.5.0", + version: "1.5.7", name: "cardinal_payment_manager", instructions: [ { diff --git a/src/idl/cardinal_time_invalidator.ts b/src/idl/cardinal_time_invalidator.ts index cc943fed5..b9ce0965f 100644 --- a/src/idl/cardinal_time_invalidator.ts +++ b/src/idl/cardinal_time_invalidator.ts @@ -1,5 +1,5 @@ export type CardinalTimeInvalidator = { - version: "1.5.0"; + version: "1.5.7"; name: "cardinal_time_invalidator"; instructions: [ { @@ -407,7 +407,7 @@ export type CardinalTimeInvalidator = { }; export const IDL: CardinalTimeInvalidator = { - version: "1.5.0", + version: "1.5.7", name: "cardinal_time_invalidator", instructions: [ { diff --git a/src/idl/cardinal_token_manager.ts b/src/idl/cardinal_token_manager.ts index fe8d5e843..0e9f7c28b 100644 --- a/src/idl/cardinal_token_manager.ts +++ b/src/idl/cardinal_token_manager.ts @@ -1,5 +1,5 @@ export type CardinalTokenManager = { - version: "1.5.0"; + version: "1.5.7"; name: "cardinal_token_manager"; instructions: [ { @@ -978,7 +978,7 @@ export type CardinalTokenManager = { }; export const IDL: CardinalTokenManager = { - version: "1.5.0", + version: "1.5.7", name: "cardinal_token_manager", instructions: [ { diff --git a/src/idl/cardinal_use_invalidator.ts b/src/idl/cardinal_use_invalidator.ts index 8bed4ac29..d8dcf6119 100644 --- a/src/idl/cardinal_use_invalidator.ts +++ b/src/idl/cardinal_use_invalidator.ts @@ -1,5 +1,5 @@ export type CardinalUseInvalidator = { - version: "1.5.0"; + version: "1.5.7"; name: "cardinal_use_invalidator"; instructions: [ { @@ -405,7 +405,7 @@ export type CardinalUseInvalidator = { }; export const IDL: CardinalUseInvalidator = { - version: "1.5.0", + version: "1.5.7", name: "cardinal_use_invalidator", instructions: [ { From e2f2bf80e10bad6ec268e7bda47eaa5402fabfc8 Mon Sep 17 00:00:00 2001 From: srust32 <94868588+srust32@users.noreply.github.com> Date: Tue, 2 Aug 2022 16:45:01 -0400 Subject: [PATCH 4/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 67a31211e..b093e856d 100644 --- a/README.md +++ b/README.md @@ -289,7 +289,7 @@ try { Cardinal also provides an image generator API. You provide your NFT metadata and image, or a URL to where its hosted, and use the url `https://api.cardinal.so/metadata/{mintId}` when minting the token and the API will dynamically update the image and metadata based on usages or expiration associated with it so that its always up to date forever and wherever it is viewed. -Reach out to team@cardinal.so if you are interested in using this service. +Reach out to team@cardinal.so or in our in our discord (https://discord.gg/cardinallabs) if you are interested in using this service. --- From 784bc2b850cc17bf02534ce6c1373b96320c448d Mon Sep 17 00:00:00 2001 From: Giannis Chatziveroglou Date: Wed, 3 Aug 2022 17:46:17 -0400 Subject: [PATCH 5/6] Cleanup --- tools/updateMetadata.ts | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/tools/updateMetadata.ts b/tools/updateMetadata.ts index 0f9aef92d..a00019083 100644 --- a/tools/updateMetadata.ts +++ b/tools/updateMetadata.ts @@ -17,46 +17,7 @@ const wallet = Keypair.fromSecretKey( utils.bytes.bs58.decode(process.env.AIRDROP_KEY || "") ); -const MINTS_IDS = [ - new PublicKey("7gkKNwhcGyp3oiCNijm118U8h7G5kTAiLbaCkm5mSSH"), - new PublicKey("5GD1mdhSJ2wjVdhArJwFjHbWTZdFmr7L47hQkiv9XUQ2"), - new PublicKey("9Z1P4GyMwPo3D2gWaYXkDqXyzs1fhzQwHzyTqDt3DXZm"), - new PublicKey("7v6NNfUN3EwDurFLPsyuyq44ssatqZAyGRs9sC877wfL"), - new PublicKey("FMqUXu4HuN9CJbFmtKKmk1E1Y3g8ZPNsz9PcjMMTVF3D"), - new PublicKey("JCGZ9PdscH1FWzFbTScCxEBL9iGvrug2zQBHNnwRsGhi"), - new PublicKey("Dt4Lc51xV6piVfpaE6fJrmzEEB325JwkKRmr9uLL3fCn"), - new PublicKey("JAaJZrzHcQuUyXnY5e4BbHo1KMmJjeJdpaxZUk1JqfEi"), - new PublicKey("DVQVG5uLjXsCJA4pZWDQkyUHPS2F7j8mjfx3FrMuYhir"), - new PublicKey("Hf2un8t9ajBehK8e8bqEKKzks7DG6xCBh6QibNi5oi8S"), - new PublicKey("A5Bf6PcyjNiAvRTsCNHdducBpZfEE4Rk4migNA9y8er8"), - new PublicKey("F6UhiD8xtZDQaRMh1MZA6Usd7ifP8y1jbVMGyLPyvsCD"), - new PublicKey("5fZZFSWu7Rw7fJmWe7UohsysK6pYtCNvbDWxcKyZRxB6"), - new PublicKey("98TvuhTSfQbkygBVT94gGH7XZSHvWGCd36gHbujrL1xP"), - new PublicKey("8DPW4KNkPYciMR1Q9V1mzv4dJ3CwrhusaxG2ekUzyD3f"), - new PublicKey("3xZFJQnDRqB3N2JWdH1jnAYPzT4q8nGfPNNjLxesXR14"), - new PublicKey("ACAqYSicApjopWFvh37AvVtKpugQPJwpy9WbtU33mmGk"), - new PublicKey("LffPS5XFcnfJQQciEgAUXfMQo4nskEFyh5STugH7Pp2"), - new PublicKey("EYhrXnyEboS2tJC8J1587Ke89zYMk5CDmbmdwV6YPkFJ"), - new PublicKey("53k1yzHW4gPWmAVp9u5rNWBMdg8eLUY3oeBWeJHA6yG2"), - new PublicKey("7zeaR2wbMpaTgziaDZJFZBKQ4ZoZBRkh6o4V2q71Tb7g"), - new PublicKey("3wkhPxc1N8adG4hDPxpcq4kSDCzHu4YDJS42F4Uigjz1"), - new PublicKey("5nDtP66ju8bDYMnMD1oMbZ3PKpL3dsCW54eFbLDKkXAq"), - new PublicKey("4y9KM9bFErmYWDBiwdv8KGEAKJmUxRMSmXVyJnhjtWUs"), - new PublicKey("E4AWbfwZ6BDtyh9xe1vxU7UekHJLyYXRCq5romQnX8u4"), - new PublicKey("4ZTG3yUTRFhUinx3Z6bk662PtXzvgAiWJQT7B9tueotK"), - new PublicKey("GPLRvoMGZigPPUS5E5kqqEFL5ESCySkkE32e4d1vYpej"), - new PublicKey("RqCbLCCVTrE9To3r49x7yLjtFbCUKUA3Fibk6j24WuT"), - new PublicKey("DVC6CakG6H3dxZFsTHDTiwWhetc1c7YJLW6mMCD6HcbG"), - new PublicKey("CnPjaP5p34hzvMk1vTa95cVTEVkSbatQzpMDnPXEYFKM"), - new PublicKey("6hQ3ko1ETk8NiLWgqptRqe98QXLEvaVbBoqS8jK3bXev"), - new PublicKey("JwebLajACksGfgkt9Ud8kCsVWhyvN8sMotD4wey3338"), - new PublicKey("3NqNXDsJuqd2s6ziVmsD9Cj3mZU8NgUiMJsaPUXBdoU1"), - new PublicKey("42AqaYUhR1MUzEeaaXnvYHpKtvLg2QrsckSuf1ByqjwS"), - new PublicKey("12GVQC6xSsFxUrXXEfyYfxy7LutjoEMcX1Gqvx2bm2LF"), - new PublicKey("BcE6FMqzRSu7iweCKmrTkVGgrTkXUX3FaExNnFe7fWTX"), - new PublicKey("7wXKfXyGn6cBj13w9QLjhtLB22171MnUTKseFHPH5swE"), - new PublicKey("DLUbtr7ERBUqwaQfamRfpYSyPbPrAQnYP2b5QjookJnG"), -]; +const MINTS_IDS: PublicKey[] = []; const DAY_MAPPING: { [day: string]: string } = { SUN: "Sunday", From ba88270884030e5a9328a2f29a7f94c2ef2900ee Mon Sep 17 00:00:00 2001 From: Giannis Chatziveroglou Date: Thu, 4 Aug 2022 01:36:20 -0400 Subject: [PATCH 6/6] Error on tokens with no freeze authority --- programs/cardinal-token-manager/src/errors.rs | 2 ++ .../cardinal-token-manager/src/instructions/init.rs | 3 +++ src/idl/cardinal_token_manager.ts | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/programs/cardinal-token-manager/src/errors.rs b/programs/cardinal-token-manager/src/errors.rs index 3f847a28d..38690d066 100644 --- a/programs/cardinal-token-manager/src/errors.rs +++ b/programs/cardinal-token-manager/src/errors.rs @@ -60,4 +60,6 @@ pub enum ErrorCode { InvalidMintSupply, #[msg("Invalid account discriminator")] AccountDiscriminatorMismatch, + #[msg("Token misisng freeze authority")] + TokenMissingFreezeAuthority, } diff --git a/programs/cardinal-token-manager/src/instructions/init.rs b/programs/cardinal-token-manager/src/instructions/init.rs index ef9a59fe8..7e9821d1c 100644 --- a/programs/cardinal-token-manager/src/instructions/init.rs +++ b/programs/cardinal-token-manager/src/instructions/init.rs @@ -50,6 +50,9 @@ pub fn handler(ctx: Context, ix: InitIx) -> Result<()> { if ix.num_invalidators > MAX_INVALIDATORS { return Err(error!(ErrorCode::MaximumInvalidatorsReached)); } + if ctx.accounts.mint.freeze_authority.is_none() && ix.kind != TokenManagerKind::Unmanaged as u8 { + return Err(error!(ErrorCode::TokenMissingFreezeAuthority)); + } let token_manager = &mut ctx.accounts.token_manager; if token_manager.state != TokenManagerState::Initialized as u8 { return Err(error!(ErrorCode::InvalidTokenManagerState)); diff --git a/src/idl/cardinal_token_manager.ts b/src/idl/cardinal_token_manager.ts index 0e9f7c28b..6c7a1c1a8 100644 --- a/src/idl/cardinal_token_manager.ts +++ b/src/idl/cardinal_token_manager.ts @@ -973,6 +973,11 @@ export type CardinalTokenManager = { code: 6028; name: "AccountDiscriminatorMismatch"; msg: "Invalid account discriminator"; + }, + { + code: 6029; + name: "TokenMissingFreezeAuthority"; + msg: "Token misisng freeze authority"; } ]; }; @@ -1953,5 +1958,10 @@ export const IDL: CardinalTokenManager = { name: "AccountDiscriminatorMismatch", msg: "Invalid account discriminator", }, + { + code: 6029, + name: "TokenMissingFreezeAuthority", + msg: "Token misisng freeze authority", + }, ], };