Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on tokens with no freeze authority #270

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] if you are interested in using this service.
Reach out to [email protected] or in our in our discord (https://discord.gg/cardinallabs) if you are interested in using this service.

---

Expand Down
26 changes: 16 additions & 10 deletions api/time-invalidator-crank/invalidate-parallel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cardinal/token-manager",
"version": "1.5.6",
"version": "1.5.7",
"description": "Cardinal token manager SDK",
"keywords": [
"solana",
Expand Down
6 changes: 3 additions & 3 deletions programs/cardinal-paid-claim-approver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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" }
2 changes: 1 addition & 1 deletion programs/cardinal-payment-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions programs/cardinal-time-invalidator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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" }
2 changes: 1 addition & 1 deletion programs/cardinal-token-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 2 additions & 0 deletions programs/cardinal-token-manager/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ pub enum ErrorCode {
InvalidMintSupply,
#[msg("Invalid account discriminator")]
AccountDiscriminatorMismatch,
#[msg("Token misisng freeze authority")]
TokenMissingFreezeAuthority,
}
3 changes: 3 additions & 0 deletions programs/cardinal-token-manager/src/instructions/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub fn handler(ctx: Context<InitCtx>, 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));
Expand Down
6 changes: 3 additions & 3 deletions programs/cardinal-use-invalidator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions src/idl/cardinal_paid_claim_approver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type CardinalPaidClaimApprover = {
version: "1.5.0";
version: "1.5.7";
name: "cardinal_paid_claim_approver";
instructions: [
{
Expand Down Expand Up @@ -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: [
{
Expand Down
4 changes: 2 additions & 2 deletions src/idl/cardinal_payment_manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type CardinalPaymentManager = {
version: "1.5.0";
version: "1.5.7";
name: "cardinal_payment_manager";
instructions: [
{
Expand Down Expand Up @@ -301,7 +301,7 @@ export type CardinalPaymentManager = {
};

export const IDL: CardinalPaymentManager = {
version: "1.5.0",
version: "1.5.7",
name: "cardinal_payment_manager",
instructions: [
{
Expand Down
4 changes: 2 additions & 2 deletions src/idl/cardinal_time_invalidator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type CardinalTimeInvalidator = {
version: "1.5.0";
version: "1.5.7";
name: "cardinal_time_invalidator";
instructions: [
{
Expand Down Expand Up @@ -407,7 +407,7 @@ export type CardinalTimeInvalidator = {
};

export const IDL: CardinalTimeInvalidator = {
version: "1.5.0",
version: "1.5.7",
name: "cardinal_time_invalidator",
instructions: [
{
Expand Down
14 changes: 12 additions & 2 deletions src/idl/cardinal_token_manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type CardinalTokenManager = {
version: "1.5.0";
version: "1.5.7";
name: "cardinal_token_manager";
instructions: [
{
Expand Down Expand Up @@ -973,12 +973,17 @@ export type CardinalTokenManager = {
code: 6028;
name: "AccountDiscriminatorMismatch";
msg: "Invalid account discriminator";
},
{
code: 6029;
name: "TokenMissingFreezeAuthority";
msg: "Token misisng freeze authority";
}
];
};

export const IDL: CardinalTokenManager = {
version: "1.5.0",
version: "1.5.7",
name: "cardinal_token_manager",
instructions: [
{
Expand Down Expand Up @@ -1953,5 +1958,10 @@ export const IDL: CardinalTokenManager = {
name: "AccountDiscriminatorMismatch",
msg: "Invalid account discriminator",
},
{
code: 6029,
name: "TokenMissingFreezeAuthority",
msg: "Token misisng freeze authority",
},
],
};
4 changes: 2 additions & 2 deletions src/idl/cardinal_use_invalidator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type CardinalUseInvalidator = {
version: "1.5.0";
version: "1.5.7";
name: "cardinal_use_invalidator";
instructions: [
{
Expand Down Expand Up @@ -405,7 +405,7 @@ export type CardinalUseInvalidator = {
};

export const IDL: CardinalUseInvalidator = {
version: "1.5.0",
version: "1.5.7",
name: "cardinal_use_invalidator",
instructions: [
{
Expand Down
40 changes: 21 additions & 19 deletions src/programs/tokenManager/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -123,6 +141,7 @@ export const withRemainingAccountsForPayment = async (
isSigner: false,
isWritable: true,
},
...paymentRemainingAccounts,
...royaltiesRemainingAccounts,
],
];
Expand Down Expand Up @@ -152,7 +171,7 @@ export const withRemainingAccountsForPayment = async (
return [
issuerTokenAccountId,
feeCollectorTokenAccountId,
royaltiesRemainingAccounts,
[...paymentRemainingAccounts, ...royaltiesRemainingAccounts],
];
}
};
Expand Down Expand Up @@ -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;
};
3 changes: 2 additions & 1 deletion tools/getPaymentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
};
Expand Down
Loading