From 9865c336b9f7679768823e04ea8af37dcb06f732 Mon Sep 17 00:00:00 2001 From: leantOnSol Date: Mon, 23 Jun 2025 17:16:20 +0200 Subject: [PATCH 1/5] rm wlv1, mpv1 handlers + tests --- .github/workflows/test-js-anchor.yml | 1 - .../tests/twhitelist/mint_proof.test.ts | 122 ---- clients/js/package.json | 2 +- .../generated/instructions/freezeWhitelist.ts | 327 ----------- .../js/src/generated/instructions/index.ts | 5 - .../instructions/initUpdateMintProof.ts | 359 ------------ .../instructions/initUpdateWhitelist.ts | 390 ------------- .../instructions/reallocWhitelist.ts | 324 ----------- .../instructions/unfreezeWhitelist.ts | 327 ----------- .../src/generated/programs/tensorWhitelist.ts | 80 --- .../instructions/freeze_whitelist.rs | 422 -------------- .../instructions/init_update_mint_proof.rs | 476 ---------------- .../instructions/init_update_whitelist.rs | 537 ------------------ .../rust/src/generated/instructions/mod.rs | 10 - .../instructions/realloc_whitelist.rs | 420 -------------- .../instructions/unfreeze_whitelist.rs | 422 -------------- program/idl.json | 231 -------- program/src/instructions/freeze_whitelist.rs | 34 -- .../instructions/init_update_mint_proof.rs | 69 --- .../src/instructions/init_update_whitelist.rs | 97 ---- program/src/instructions/mod.rs | 10 - program/src/instructions/realloc_whitelist.rs | 52 -- .../src/instructions/unfreeze_whitelist.rs | 35 -- program/src/lib.rs | 35 -- 24 files changed, 1 insertion(+), 4786 deletions(-) delete mode 100644 clients/anchor/tests/twhitelist/mint_proof.test.ts delete mode 100644 clients/js/src/generated/instructions/freezeWhitelist.ts delete mode 100644 clients/js/src/generated/instructions/initUpdateMintProof.ts delete mode 100644 clients/js/src/generated/instructions/initUpdateWhitelist.ts delete mode 100644 clients/js/src/generated/instructions/reallocWhitelist.ts delete mode 100644 clients/js/src/generated/instructions/unfreezeWhitelist.ts delete mode 100644 clients/rust/src/generated/instructions/freeze_whitelist.rs delete mode 100644 clients/rust/src/generated/instructions/init_update_mint_proof.rs delete mode 100644 clients/rust/src/generated/instructions/init_update_whitelist.rs delete mode 100644 clients/rust/src/generated/instructions/realloc_whitelist.rs delete mode 100644 clients/rust/src/generated/instructions/unfreeze_whitelist.rs delete mode 100644 program/src/instructions/freeze_whitelist.rs delete mode 100644 program/src/instructions/init_update_mint_proof.rs delete mode 100644 program/src/instructions/init_update_whitelist.rs delete mode 100644 program/src/instructions/realloc_whitelist.rs delete mode 100644 program/src/instructions/unfreeze_whitelist.rs diff --git a/.github/workflows/test-js-anchor.yml b/.github/workflows/test-js-anchor.yml index fdb38ae9..9aac8a63 100644 --- a/.github/workflows/test-js-anchor.yml +++ b/.github/workflows/test-js-anchor.yml @@ -16,7 +16,6 @@ jobs: matrix: node: - glob: tests/twhitelist/whitelist.test.ts - - glob: tests/twhitelist/mint_proof.test.ts - glob: tests/twhitelist/merkle_tree.test.ts steps: diff --git a/clients/anchor/tests/twhitelist/mint_proof.test.ts b/clients/anchor/tests/twhitelist/mint_proof.test.ts deleted file mode 100644 index b50f1be8..00000000 --- a/clients/anchor/tests/twhitelist/mint_proof.test.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { Keypair, PublicKey } from "@solana/web3.js"; -import { expect } from "chai"; -import { MAX_PROOF_LEN, TensorWhitelistSDK } from "../../src"; -import { - buildAndSendTx, - generateTreeOfSize, - testInitWLAuthority, - TEST_PROVIDER, - wlSdk, -} from "../shared"; -import { createAndFundAta, createFundedWallet } from "../tswap/common"; -import { testInitUpdateMintProof } from "./common"; - -// ---------------------------- Mint proofs - -describe("tensor_whitelist mint proofs", () => { - let authPda: PublicKey; - - // inits authority - before(async () => { - ({ authPda } = await testInitWLAuthority()); - }); - - it("init update mint proof", async () => { - const uuidBuffer = TensorWhitelistSDK.uuidToBuffer( - wlSdk.genWhitelistUUID() - ); - const nameBuffer = TensorWhitelistSDK.nameToBuffer("hello_world"); - const owner = await createFundedWallet(); - const { mint } = await createAndFundAta({ owner }); - const { mint: badMint } = await createAndFundAta({ owner }); - const { - root, - proofs: [wlNft], - } = generateTreeOfSize(100, [mint]); - - const { - tx: { ixs }, - whitelistPda, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - rootHash: root, - name: nameBuffer, - }); - await buildAndSendTx({ ixs }); - - // Create valid mint proof. - await testInitUpdateMintProof({ - user: owner, - mint, - whitelist: whitelistPda, - proof: wlNft.proof, - expectedProofLen: 7, // floor(log_2(100)) + 1 => 7 - }); - - // Bad mint/proof fails. - for (const { curMint, proof } of [ - { curMint: mint, proof: [Keypair.generate().publicKey.toBuffer()] }, - { curMint: badMint, proof: wlNft.proof }, - ]) { - const { - tx: { ixs }, - } = await wlSdk.initUpdateMintProof({ - user: TEST_PROVIDER.publicKey, - mint: curMint, - whitelist: whitelistPda, - // Invalid proof - proof, - }); - await expect(buildAndSendTx({ ixs })).rejectedWith( - wlSdk.getErrorCodeHex("FailedMerkleProofVerification") - ); - } - - // Too long proof fails. - // NB: ProofTooLong isn't thrown b/c we hit transaction size limit first. - { - const { - tx: { ixs }, - } = await wlSdk.initUpdateMintProof({ - user: TEST_PROVIDER.publicKey, - mint, - whitelist: whitelistPda, - // Proof too long - proof: Array(MAX_PROOF_LEN + 1) - .fill(null) - .map((_) => Keypair.generate().publicKey.toBuffer()), - }); - await expect(buildAndSendTx({ ixs })).rejectedWith( - "Transaction too large" - ); - } - - // Update our whitelist and then update mint proof should work. - { - // Update whitelist w/ new root - const { - root, - proofs: [wlNft2], - // Different sized proof. - } = generateTreeOfSize(2, [mint]); - const { - tx: { ixs }, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - rootHash: root, - }); - await buildAndSendTx({ ixs }); - - // Update mint proof. - await testInitUpdateMintProof({ - user: owner, - mint, - whitelist: whitelistPda, - proof: wlNft2.proof, - expectedProofLen: 2, // floor(log_2(2)) + 1 => 2 - }); - } - }); -}); diff --git a/clients/js/package.json b/clients/js/package.json index 960f0175..89352b36 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -1,6 +1,6 @@ { "name": "@tensor-foundation/whitelist", - "version": "1.0.0-beta.1", + "version": "1.0.0", "description": "Verify your collection on-chain", "sideEffects": false, "module": "./dist/src/index.mjs", diff --git a/clients/js/src/generated/instructions/freezeWhitelist.ts b/clients/js/src/generated/instructions/freezeWhitelist.ts deleted file mode 100644 index d5b4eda6..00000000 --- a/clients/js/src/generated/instructions/freezeWhitelist.ts +++ /dev/null @@ -1,327 +0,0 @@ -/** - * This code was AUTOGENERATED using the codama library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun codama to update it. - * - * @see https://github.com/codama-idl/codama - */ - -import { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type IAccountMeta, - type IAccountSignerMeta, - type IInstruction, - type IInstructionWithAccounts, - type IInstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/web3.js'; -import { findAuthorityPda } from '../pdas'; -import { TENSOR_WHITELIST_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const FREEZE_WHITELIST_DISCRIMINATOR = new Uint8Array([ - 248, 112, 12, 150, 175, 238, 38, 184, -]); - -export function getFreezeWhitelistDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - FREEZE_WHITELIST_DISCRIMINATOR - ); -} - -export type FreezeWhitelistInstruction< - TProgram extends string = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, - TAccountWhitelist extends string | IAccountMeta = string, - TAccountWhitelistAuthority extends string | IAccountMeta = string, - TAccountCosigner extends string | IAccountMeta = string, - TAccountSystemProgram extends - | string - | IAccountMeta = '11111111111111111111111111111111', - TRemainingAccounts extends readonly IAccountMeta[] = [], -> = IInstruction & - IInstructionWithData & - IInstructionWithAccounts< - [ - TAccountWhitelist extends string - ? WritableAccount - : TAccountWhitelist, - TAccountWhitelistAuthority extends string - ? ReadonlyAccount - : TAccountWhitelistAuthority, - TAccountCosigner extends string - ? WritableSignerAccount & - IAccountSignerMeta - : TAccountCosigner, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type FreezeWhitelistInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type FreezeWhitelistInstructionDataArgs = {}; - -export function getFreezeWhitelistInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: FREEZE_WHITELIST_DISCRIMINATOR }) - ); -} - -export function getFreezeWhitelistInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getFreezeWhitelistInstructionDataCodec(): Codec< - FreezeWhitelistInstructionDataArgs, - FreezeWhitelistInstructionData -> { - return combineCodec( - getFreezeWhitelistInstructionDataEncoder(), - getFreezeWhitelistInstructionDataDecoder() - ); -} - -export type FreezeWhitelistAsyncInput< - TAccountWhitelist extends string = string, - TAccountWhitelistAuthority extends string = string, - TAccountCosigner extends string = string, - TAccountSystemProgram extends string = string, -> = { - whitelist: Address; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - whitelistAuthority?: Address; - /** freezing only requires cosigner */ - cosigner: TransactionSigner; - systemProgram?: Address; -}; - -export async function getFreezeWhitelistInstructionAsync< - TAccountWhitelist extends string, - TAccountWhitelistAuthority extends string, - TAccountCosigner extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, ->( - input: FreezeWhitelistAsyncInput< - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - FreezeWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TENSOR_WHITELIST_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - whitelist: { value: input.whitelist ?? null, isWritable: true }, - whitelistAuthority: { - value: input.whitelistAuthority ?? null, - isWritable: false, - }, - cosigner: { value: input.cosigner ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.whitelistAuthority.value) { - accounts.whitelistAuthority.value = await findAuthorityPda(); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.whitelist), - getAccountMeta(accounts.whitelistAuthority), - getAccountMeta(accounts.cosigner), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getFreezeWhitelistInstructionDataEncoder().encode({}), - } as FreezeWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >; - - return instruction; -} - -export type FreezeWhitelistInput< - TAccountWhitelist extends string = string, - TAccountWhitelistAuthority extends string = string, - TAccountCosigner extends string = string, - TAccountSystemProgram extends string = string, -> = { - whitelist: Address; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - whitelistAuthority: Address; - /** freezing only requires cosigner */ - cosigner: TransactionSigner; - systemProgram?: Address; -}; - -export function getFreezeWhitelistInstruction< - TAccountWhitelist extends string, - TAccountWhitelistAuthority extends string, - TAccountCosigner extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, ->( - input: FreezeWhitelistInput< - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): FreezeWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TENSOR_WHITELIST_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - whitelist: { value: input.whitelist ?? null, isWritable: true }, - whitelistAuthority: { - value: input.whitelistAuthority ?? null, - isWritable: false, - }, - cosigner: { value: input.cosigner ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.whitelist), - getAccountMeta(accounts.whitelistAuthority), - getAccountMeta(accounts.cosigner), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getFreezeWhitelistInstructionDataEncoder().encode({}), - } as FreezeWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedFreezeWhitelistInstruction< - TProgram extends string = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, - TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], -> = { - programAddress: Address; - accounts: { - whitelist: TAccountMetas[0]; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - - whitelistAuthority: TAccountMetas[1]; - /** freezing only requires cosigner */ - cosigner: TAccountMetas[2]; - systemProgram: TAccountMetas[3]; - }; - data: FreezeWhitelistInstructionData; -}; - -export function parseFreezeWhitelistInstruction< - TProgram extends string, - TAccountMetas extends readonly IAccountMeta[], ->( - instruction: IInstruction & - IInstructionWithAccounts & - IInstructionWithData -): ParsedFreezeWhitelistInstruction { - if (instruction.accounts.length < 4) { - // TODO: Coded error. - throw new Error('Not enough accounts'); - } - let accountIndex = 0; - const getNextAccount = () => { - const accountMeta = instruction.accounts![accountIndex]!; - accountIndex += 1; - return accountMeta; - }; - return { - programAddress: instruction.programAddress, - accounts: { - whitelist: getNextAccount(), - whitelistAuthority: getNextAccount(), - cosigner: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getFreezeWhitelistInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index ce54d1ee..8ea78a8e 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -9,14 +9,9 @@ export * from './closeMintProofV2'; export * from './closeWhitelistV2'; export * from './createWhitelistV2'; -export * from './freezeWhitelist'; export * from './freezeWhitelistV2'; export * from './initUpdateAuthority'; -export * from './initUpdateMintProof'; export * from './initUpdateMintProofV2'; -export * from './initUpdateWhitelist'; export * from './reallocAuthority'; -export * from './reallocWhitelist'; -export * from './unfreezeWhitelist'; export * from './unfreezeWhitelistV2'; export * from './updateWhitelistV2'; diff --git a/clients/js/src/generated/instructions/initUpdateMintProof.ts b/clients/js/src/generated/instructions/initUpdateMintProof.ts deleted file mode 100644 index 0e869cd1..00000000 --- a/clients/js/src/generated/instructions/initUpdateMintProof.ts +++ /dev/null @@ -1,359 +0,0 @@ -/** - * This code was AUTOGENERATED using the codama library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun codama to update it. - * - * @see https://github.com/codama-idl/codama - */ - -import { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getArrayDecoder, - getArrayEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type IAccountMeta, - type IAccountSignerMeta, - type IInstruction, - type IInstructionWithAccounts, - type IInstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/web3.js'; -import { findMintProofPda } from '../pdas'; -import { TENSOR_WHITELIST_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const INIT_UPDATE_MINT_PROOF_DISCRIMINATOR = new Uint8Array([ - 30, 77, 123, 9, 191, 37, 52, 159, -]); - -export function getInitUpdateMintProofDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - INIT_UPDATE_MINT_PROOF_DISCRIMINATOR - ); -} - -export type InitUpdateMintProofInstruction< - TProgram extends string = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, - TAccountWhitelist extends string | IAccountMeta = string, - TAccountMint extends string | IAccountMeta = string, - TAccountMintProof extends string | IAccountMeta = string, - TAccountUser extends string | IAccountMeta = string, - TAccountSystemProgram extends - | string - | IAccountMeta = '11111111111111111111111111111111', - TRemainingAccounts extends readonly IAccountMeta[] = [], -> = IInstruction & - IInstructionWithData & - IInstructionWithAccounts< - [ - TAccountWhitelist extends string - ? ReadonlyAccount - : TAccountWhitelist, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountMintProof extends string - ? WritableAccount - : TAccountMintProof, - TAccountUser extends string - ? WritableSignerAccount & IAccountSignerMeta - : TAccountUser, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type InitUpdateMintProofInstructionData = { - discriminator: ReadonlyUint8Array; - proof: Array; -}; - -export type InitUpdateMintProofInstructionDataArgs = { - proof: Array; -}; - -export function getInitUpdateMintProofInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['proof', getArrayEncoder(fixEncoderSize(getBytesEncoder(), 32))], - ]), - (value) => ({ - ...value, - discriminator: INIT_UPDATE_MINT_PROOF_DISCRIMINATOR, - }) - ); -} - -export function getInitUpdateMintProofInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['proof', getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32))], - ]); -} - -export function getInitUpdateMintProofInstructionDataCodec(): Codec< - InitUpdateMintProofInstructionDataArgs, - InitUpdateMintProofInstructionData -> { - return combineCodec( - getInitUpdateMintProofInstructionDataEncoder(), - getInitUpdateMintProofInstructionDataDecoder() - ); -} - -export type InitUpdateMintProofAsyncInput< - TAccountWhitelist extends string = string, - TAccountMint extends string = string, - TAccountMintProof extends string = string, - TAccountUser extends string = string, - TAccountSystemProgram extends string = string, -> = { - whitelist: Address; - mint: Address; - mintProof?: Address; - user: TransactionSigner; - systemProgram?: Address; - proof: InitUpdateMintProofInstructionDataArgs['proof']; -}; - -export async function getInitUpdateMintProofInstructionAsync< - TAccountWhitelist extends string, - TAccountMint extends string, - TAccountMintProof extends string, - TAccountUser extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, ->( - input: InitUpdateMintProofAsyncInput< - TAccountWhitelist, - TAccountMint, - TAccountMintProof, - TAccountUser, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - InitUpdateMintProofInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountMint, - TAccountMintProof, - TAccountUser, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TENSOR_WHITELIST_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - whitelist: { value: input.whitelist ?? null, isWritable: false }, - mint: { value: input.mint ?? null, isWritable: false }, - mintProof: { value: input.mintProof ?? null, isWritable: true }, - user: { value: input.user ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.mintProof.value) { - accounts.mintProof.value = await findMintProofPda({ - mint: expectAddress(accounts.mint.value), - whitelist: expectAddress(accounts.whitelist.value), - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.whitelist), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.mintProof), - getAccountMeta(accounts.user), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitUpdateMintProofInstructionDataEncoder().encode( - args as InitUpdateMintProofInstructionDataArgs - ), - } as InitUpdateMintProofInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountMint, - TAccountMintProof, - TAccountUser, - TAccountSystemProgram - >; - - return instruction; -} - -export type InitUpdateMintProofInput< - TAccountWhitelist extends string = string, - TAccountMint extends string = string, - TAccountMintProof extends string = string, - TAccountUser extends string = string, - TAccountSystemProgram extends string = string, -> = { - whitelist: Address; - mint: Address; - mintProof: Address; - user: TransactionSigner; - systemProgram?: Address; - proof: InitUpdateMintProofInstructionDataArgs['proof']; -}; - -export function getInitUpdateMintProofInstruction< - TAccountWhitelist extends string, - TAccountMint extends string, - TAccountMintProof extends string, - TAccountUser extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, ->( - input: InitUpdateMintProofInput< - TAccountWhitelist, - TAccountMint, - TAccountMintProof, - TAccountUser, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): InitUpdateMintProofInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountMint, - TAccountMintProof, - TAccountUser, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TENSOR_WHITELIST_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - whitelist: { value: input.whitelist ?? null, isWritable: false }, - mint: { value: input.mint ?? null, isWritable: false }, - mintProof: { value: input.mintProof ?? null, isWritable: true }, - user: { value: input.user ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.whitelist), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.mintProof), - getAccountMeta(accounts.user), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitUpdateMintProofInstructionDataEncoder().encode( - args as InitUpdateMintProofInstructionDataArgs - ), - } as InitUpdateMintProofInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountMint, - TAccountMintProof, - TAccountUser, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedInitUpdateMintProofInstruction< - TProgram extends string = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, - TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], -> = { - programAddress: Address; - accounts: { - whitelist: TAccountMetas[0]; - mint: TAccountMetas[1]; - mintProof: TAccountMetas[2]; - user: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - }; - data: InitUpdateMintProofInstructionData; -}; - -export function parseInitUpdateMintProofInstruction< - TProgram extends string, - TAccountMetas extends readonly IAccountMeta[], ->( - instruction: IInstruction & - IInstructionWithAccounts & - IInstructionWithData -): ParsedInitUpdateMintProofInstruction { - if (instruction.accounts.length < 5) { - // TODO: Coded error. - throw new Error('Not enough accounts'); - } - let accountIndex = 0; - const getNextAccount = () => { - const accountMeta = instruction.accounts![accountIndex]!; - accountIndex += 1; - return accountMeta; - }; - return { - programAddress: instruction.programAddress, - accounts: { - whitelist: getNextAccount(), - mint: getNextAccount(), - mintProof: getNextAccount(), - user: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getInitUpdateMintProofInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/clients/js/src/generated/instructions/initUpdateWhitelist.ts b/clients/js/src/generated/instructions/initUpdateWhitelist.ts deleted file mode 100644 index 01787adb..00000000 --- a/clients/js/src/generated/instructions/initUpdateWhitelist.ts +++ /dev/null @@ -1,390 +0,0 @@ -/** - * This code was AUTOGENERATED using the codama library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun codama to update it. - * - * @see https://github.com/codama-idl/codama - */ - -import { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getOptionDecoder, - getOptionEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type IAccountMeta, - type IAccountSignerMeta, - type IInstruction, - type IInstructionWithAccounts, - type IInstructionWithData, - type Option, - type OptionOrNullable, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/web3.js'; -import { findAuthorityPda, findWhitelistPda } from '../pdas'; -import { TENSOR_WHITELIST_PROGRAM_ADDRESS } from '../programs'; -import { - expectSome, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const INIT_UPDATE_WHITELIST_DISCRIMINATOR = new Uint8Array([ - 255, 1, 192, 134, 111, 49, 212, 131, -]); - -export function getInitUpdateWhitelistDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - INIT_UPDATE_WHITELIST_DISCRIMINATOR - ); -} - -export type InitUpdateWhitelistInstruction< - TProgram extends string = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, - TAccountWhitelist extends string | IAccountMeta = string, - TAccountWhitelistAuthority extends string | IAccountMeta = string, - TAccountCosigner extends string | IAccountMeta = string, - TAccountSystemProgram extends - | string - | IAccountMeta = '11111111111111111111111111111111', - TRemainingAccounts extends readonly IAccountMeta[] = [], -> = IInstruction & - IInstructionWithData & - IInstructionWithAccounts< - [ - TAccountWhitelist extends string - ? WritableAccount - : TAccountWhitelist, - TAccountWhitelistAuthority extends string - ? ReadonlyAccount - : TAccountWhitelistAuthority, - TAccountCosigner extends string - ? WritableSignerAccount & - IAccountSignerMeta - : TAccountCosigner, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type InitUpdateWhitelistInstructionData = { - discriminator: ReadonlyUint8Array; - uuid: ReadonlyUint8Array; - rootHash: Option; - name: Option; - voc: Option
; - fvc: Option
; -}; - -export type InitUpdateWhitelistInstructionDataArgs = { - uuid: ReadonlyUint8Array; - rootHash: OptionOrNullable; - name: OptionOrNullable; - voc: OptionOrNullable
; - fvc: OptionOrNullable
; -}; - -export function getInitUpdateWhitelistInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['uuid', fixEncoderSize(getBytesEncoder(), 32)], - ['rootHash', getOptionEncoder(fixEncoderSize(getBytesEncoder(), 32))], - ['name', getOptionEncoder(fixEncoderSize(getBytesEncoder(), 32))], - ['voc', getOptionEncoder(getAddressEncoder())], - ['fvc', getOptionEncoder(getAddressEncoder())], - ]), - (value) => ({ - ...value, - discriminator: INIT_UPDATE_WHITELIST_DISCRIMINATOR, - }) - ); -} - -export function getInitUpdateWhitelistInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['uuid', fixDecoderSize(getBytesDecoder(), 32)], - ['rootHash', getOptionDecoder(fixDecoderSize(getBytesDecoder(), 32))], - ['name', getOptionDecoder(fixDecoderSize(getBytesDecoder(), 32))], - ['voc', getOptionDecoder(getAddressDecoder())], - ['fvc', getOptionDecoder(getAddressDecoder())], - ]); -} - -export function getInitUpdateWhitelistInstructionDataCodec(): Codec< - InitUpdateWhitelistInstructionDataArgs, - InitUpdateWhitelistInstructionData -> { - return combineCodec( - getInitUpdateWhitelistInstructionDataEncoder(), - getInitUpdateWhitelistInstructionDataDecoder() - ); -} - -export type InitUpdateWhitelistAsyncInput< - TAccountWhitelist extends string = string, - TAccountWhitelistAuthority extends string = string, - TAccountCosigner extends string = string, - TAccountSystemProgram extends string = string, -> = { - whitelist?: Address; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - whitelistAuthority?: Address; - /** only cosigner has to sign for unfrozen, for frozen owner also has to sign */ - cosigner: TransactionSigner; - systemProgram?: Address; - uuid: InitUpdateWhitelistInstructionDataArgs['uuid']; - rootHash: InitUpdateWhitelistInstructionDataArgs['rootHash']; - name: InitUpdateWhitelistInstructionDataArgs['name']; - voc: InitUpdateWhitelistInstructionDataArgs['voc']; - fvc: InitUpdateWhitelistInstructionDataArgs['fvc']; -}; - -export async function getInitUpdateWhitelistInstructionAsync< - TAccountWhitelist extends string, - TAccountWhitelistAuthority extends string, - TAccountCosigner extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, ->( - input: InitUpdateWhitelistAsyncInput< - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - InitUpdateWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TENSOR_WHITELIST_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - whitelist: { value: input.whitelist ?? null, isWritable: true }, - whitelistAuthority: { - value: input.whitelistAuthority ?? null, - isWritable: false, - }, - cosigner: { value: input.cosigner ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.whitelist.value) { - accounts.whitelist.value = await findWhitelistPda({ - uuid: expectSome(args.uuid), - }); - } - if (!accounts.whitelistAuthority.value) { - accounts.whitelistAuthority.value = await findAuthorityPda(); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.whitelist), - getAccountMeta(accounts.whitelistAuthority), - getAccountMeta(accounts.cosigner), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitUpdateWhitelistInstructionDataEncoder().encode( - args as InitUpdateWhitelistInstructionDataArgs - ), - } as InitUpdateWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >; - - return instruction; -} - -export type InitUpdateWhitelistInput< - TAccountWhitelist extends string = string, - TAccountWhitelistAuthority extends string = string, - TAccountCosigner extends string = string, - TAccountSystemProgram extends string = string, -> = { - whitelist: Address; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - whitelistAuthority: Address; - /** only cosigner has to sign for unfrozen, for frozen owner also has to sign */ - cosigner: TransactionSigner; - systemProgram?: Address; - uuid: InitUpdateWhitelistInstructionDataArgs['uuid']; - rootHash: InitUpdateWhitelistInstructionDataArgs['rootHash']; - name: InitUpdateWhitelistInstructionDataArgs['name']; - voc: InitUpdateWhitelistInstructionDataArgs['voc']; - fvc: InitUpdateWhitelistInstructionDataArgs['fvc']; -}; - -export function getInitUpdateWhitelistInstruction< - TAccountWhitelist extends string, - TAccountWhitelistAuthority extends string, - TAccountCosigner extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, ->( - input: InitUpdateWhitelistInput< - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): InitUpdateWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TENSOR_WHITELIST_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - whitelist: { value: input.whitelist ?? null, isWritable: true }, - whitelistAuthority: { - value: input.whitelistAuthority ?? null, - isWritable: false, - }, - cosigner: { value: input.cosigner ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.whitelist), - getAccountMeta(accounts.whitelistAuthority), - getAccountMeta(accounts.cosigner), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitUpdateWhitelistInstructionDataEncoder().encode( - args as InitUpdateWhitelistInstructionDataArgs - ), - } as InitUpdateWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedInitUpdateWhitelistInstruction< - TProgram extends string = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, - TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], -> = { - programAddress: Address; - accounts: { - whitelist: TAccountMetas[0]; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - - whitelistAuthority: TAccountMetas[1]; - /** only cosigner has to sign for unfrozen, for frozen owner also has to sign */ - cosigner: TAccountMetas[2]; - systemProgram: TAccountMetas[3]; - }; - data: InitUpdateWhitelistInstructionData; -}; - -export function parseInitUpdateWhitelistInstruction< - TProgram extends string, - TAccountMetas extends readonly IAccountMeta[], ->( - instruction: IInstruction & - IInstructionWithAccounts & - IInstructionWithData -): ParsedInitUpdateWhitelistInstruction { - if (instruction.accounts.length < 4) { - // TODO: Coded error. - throw new Error('Not enough accounts'); - } - let accountIndex = 0; - const getNextAccount = () => { - const accountMeta = instruction.accounts![accountIndex]!; - accountIndex += 1; - return accountMeta; - }; - return { - programAddress: instruction.programAddress, - accounts: { - whitelist: getNextAccount(), - whitelistAuthority: getNextAccount(), - cosigner: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getInitUpdateWhitelistInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/clients/js/src/generated/instructions/reallocWhitelist.ts b/clients/js/src/generated/instructions/reallocWhitelist.ts deleted file mode 100644 index 86a22a84..00000000 --- a/clients/js/src/generated/instructions/reallocWhitelist.ts +++ /dev/null @@ -1,324 +0,0 @@ -/** - * This code was AUTOGENERATED using the codama library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun codama to update it. - * - * @see https://github.com/codama-idl/codama - */ - -import { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type IAccountMeta, - type IAccountSignerMeta, - type IInstruction, - type IInstructionWithAccounts, - type IInstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/web3.js'; -import { findAuthorityPda } from '../pdas'; -import { TENSOR_WHITELIST_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const REALLOC_WHITELIST_DISCRIMINATOR = new Uint8Array([ - 173, 147, 168, 152, 181, 46, 55, 60, -]); - -export function getReallocWhitelistDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REALLOC_WHITELIST_DISCRIMINATOR - ); -} - -export type ReallocWhitelistInstruction< - TProgram extends string = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, - TAccountWhitelist extends string | IAccountMeta = string, - TAccountWhitelistAuthority extends string | IAccountMeta = string, - TAccountCosigner extends string | IAccountMeta = string, - TAccountSystemProgram extends - | string - | IAccountMeta = '11111111111111111111111111111111', - TRemainingAccounts extends readonly IAccountMeta[] = [], -> = IInstruction & - IInstructionWithData & - IInstructionWithAccounts< - [ - TAccountWhitelist extends string - ? WritableAccount - : TAccountWhitelist, - TAccountWhitelistAuthority extends string - ? ReadonlyAccount - : TAccountWhitelistAuthority, - TAccountCosigner extends string - ? WritableSignerAccount & - IAccountSignerMeta - : TAccountCosigner, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type ReallocWhitelistInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type ReallocWhitelistInstructionDataArgs = {}; - -export function getReallocWhitelistInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: REALLOC_WHITELIST_DISCRIMINATOR }) - ); -} - -export function getReallocWhitelistInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getReallocWhitelistInstructionDataCodec(): Codec< - ReallocWhitelistInstructionDataArgs, - ReallocWhitelistInstructionData -> { - return combineCodec( - getReallocWhitelistInstructionDataEncoder(), - getReallocWhitelistInstructionDataDecoder() - ); -} - -export type ReallocWhitelistAsyncInput< - TAccountWhitelist extends string = string, - TAccountWhitelistAuthority extends string = string, - TAccountCosigner extends string = string, - TAccountSystemProgram extends string = string, -> = { - whitelist: Address; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - whitelistAuthority?: Address; - cosigner: TransactionSigner; - systemProgram?: Address; -}; - -export async function getReallocWhitelistInstructionAsync< - TAccountWhitelist extends string, - TAccountWhitelistAuthority extends string, - TAccountCosigner extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, ->( - input: ReallocWhitelistAsyncInput< - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - ReallocWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TENSOR_WHITELIST_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - whitelist: { value: input.whitelist ?? null, isWritable: true }, - whitelistAuthority: { - value: input.whitelistAuthority ?? null, - isWritable: false, - }, - cosigner: { value: input.cosigner ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.whitelistAuthority.value) { - accounts.whitelistAuthority.value = await findAuthorityPda(); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.whitelist), - getAccountMeta(accounts.whitelistAuthority), - getAccountMeta(accounts.cosigner), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getReallocWhitelistInstructionDataEncoder().encode({}), - } as ReallocWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >; - - return instruction; -} - -export type ReallocWhitelistInput< - TAccountWhitelist extends string = string, - TAccountWhitelistAuthority extends string = string, - TAccountCosigner extends string = string, - TAccountSystemProgram extends string = string, -> = { - whitelist: Address; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - whitelistAuthority: Address; - cosigner: TransactionSigner; - systemProgram?: Address; -}; - -export function getReallocWhitelistInstruction< - TAccountWhitelist extends string, - TAccountWhitelistAuthority extends string, - TAccountCosigner extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, ->( - input: ReallocWhitelistInput< - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): ReallocWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TENSOR_WHITELIST_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - whitelist: { value: input.whitelist ?? null, isWritable: true }, - whitelistAuthority: { - value: input.whitelistAuthority ?? null, - isWritable: false, - }, - cosigner: { value: input.cosigner ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.whitelist), - getAccountMeta(accounts.whitelistAuthority), - getAccountMeta(accounts.cosigner), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getReallocWhitelistInstructionDataEncoder().encode({}), - } as ReallocWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountCosigner, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedReallocWhitelistInstruction< - TProgram extends string = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, - TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], -> = { - programAddress: Address; - accounts: { - whitelist: TAccountMetas[0]; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - - whitelistAuthority: TAccountMetas[1]; - cosigner: TAccountMetas[2]; - systemProgram: TAccountMetas[3]; - }; - data: ReallocWhitelistInstructionData; -}; - -export function parseReallocWhitelistInstruction< - TProgram extends string, - TAccountMetas extends readonly IAccountMeta[], ->( - instruction: IInstruction & - IInstructionWithAccounts & - IInstructionWithData -): ParsedReallocWhitelistInstruction { - if (instruction.accounts.length < 4) { - // TODO: Coded error. - throw new Error('Not enough accounts'); - } - let accountIndex = 0; - const getNextAccount = () => { - const accountMeta = instruction.accounts![accountIndex]!; - accountIndex += 1; - return accountMeta; - }; - return { - programAddress: instruction.programAddress, - accounts: { - whitelist: getNextAccount(), - whitelistAuthority: getNextAccount(), - cosigner: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getReallocWhitelistInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/clients/js/src/generated/instructions/unfreezeWhitelist.ts b/clients/js/src/generated/instructions/unfreezeWhitelist.ts deleted file mode 100644 index 09107b2f..00000000 --- a/clients/js/src/generated/instructions/unfreezeWhitelist.ts +++ /dev/null @@ -1,327 +0,0 @@ -/** - * This code was AUTOGENERATED using the codama library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun codama to update it. - * - * @see https://github.com/codama-idl/codama - */ - -import { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type IAccountMeta, - type IAccountSignerMeta, - type IInstruction, - type IInstructionWithAccounts, - type IInstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/web3.js'; -import { findAuthorityPda } from '../pdas'; -import { TENSOR_WHITELIST_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UNFREEZE_WHITELIST_DISCRIMINATOR = new Uint8Array([ - 215, 119, 9, 92, 160, 139, 226, 253, -]); - -export function getUnfreezeWhitelistDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UNFREEZE_WHITELIST_DISCRIMINATOR - ); -} - -export type UnfreezeWhitelistInstruction< - TProgram extends string = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, - TAccountWhitelist extends string | IAccountMeta = string, - TAccountWhitelistAuthority extends string | IAccountMeta = string, - TAccountOwner extends string | IAccountMeta = string, - TAccountSystemProgram extends - | string - | IAccountMeta = '11111111111111111111111111111111', - TRemainingAccounts extends readonly IAccountMeta[] = [], -> = IInstruction & - IInstructionWithData & - IInstructionWithAccounts< - [ - TAccountWhitelist extends string - ? WritableAccount - : TAccountWhitelist, - TAccountWhitelistAuthority extends string - ? ReadonlyAccount - : TAccountWhitelistAuthority, - TAccountOwner extends string - ? WritableSignerAccount & - IAccountSignerMeta - : TAccountOwner, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type UnfreezeWhitelistInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type UnfreezeWhitelistInstructionDataArgs = {}; - -export function getUnfreezeWhitelistInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: UNFREEZE_WHITELIST_DISCRIMINATOR }) - ); -} - -export function getUnfreezeWhitelistInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getUnfreezeWhitelistInstructionDataCodec(): Codec< - UnfreezeWhitelistInstructionDataArgs, - UnfreezeWhitelistInstructionData -> { - return combineCodec( - getUnfreezeWhitelistInstructionDataEncoder(), - getUnfreezeWhitelistInstructionDataDecoder() - ); -} - -export type UnfreezeWhitelistAsyncInput< - TAccountWhitelist extends string = string, - TAccountWhitelistAuthority extends string = string, - TAccountOwner extends string = string, - TAccountSystemProgram extends string = string, -> = { - whitelist: Address; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - whitelistAuthority?: Address; - /** unfreezing requires owner */ - owner: TransactionSigner; - systemProgram?: Address; -}; - -export async function getUnfreezeWhitelistInstructionAsync< - TAccountWhitelist extends string, - TAccountWhitelistAuthority extends string, - TAccountOwner extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, ->( - input: UnfreezeWhitelistAsyncInput< - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountOwner, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - UnfreezeWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountOwner, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TENSOR_WHITELIST_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - whitelist: { value: input.whitelist ?? null, isWritable: true }, - whitelistAuthority: { - value: input.whitelistAuthority ?? null, - isWritable: false, - }, - owner: { value: input.owner ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.whitelistAuthority.value) { - accounts.whitelistAuthority.value = await findAuthorityPda(); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.whitelist), - getAccountMeta(accounts.whitelistAuthority), - getAccountMeta(accounts.owner), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getUnfreezeWhitelistInstructionDataEncoder().encode({}), - } as UnfreezeWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountOwner, - TAccountSystemProgram - >; - - return instruction; -} - -export type UnfreezeWhitelistInput< - TAccountWhitelist extends string = string, - TAccountWhitelistAuthority extends string = string, - TAccountOwner extends string = string, - TAccountSystemProgram extends string = string, -> = { - whitelist: Address; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - whitelistAuthority: Address; - /** unfreezing requires owner */ - owner: TransactionSigner; - systemProgram?: Address; -}; - -export function getUnfreezeWhitelistInstruction< - TAccountWhitelist extends string, - TAccountWhitelistAuthority extends string, - TAccountOwner extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, ->( - input: UnfreezeWhitelistInput< - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountOwner, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): UnfreezeWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountOwner, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TENSOR_WHITELIST_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - whitelist: { value: input.whitelist ?? null, isWritable: true }, - whitelistAuthority: { - value: input.whitelistAuthority ?? null, - isWritable: false, - }, - owner: { value: input.owner ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.whitelist), - getAccountMeta(accounts.whitelistAuthority), - getAccountMeta(accounts.owner), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getUnfreezeWhitelistInstructionDataEncoder().encode({}), - } as UnfreezeWhitelistInstruction< - TProgramAddress, - TAccountWhitelist, - TAccountWhitelistAuthority, - TAccountOwner, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedUnfreezeWhitelistInstruction< - TProgram extends string = typeof TENSOR_WHITELIST_PROGRAM_ADDRESS, - TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], -> = { - programAddress: Address; - accounts: { - whitelist: TAccountMetas[0]; - /** - * there can only be 1 whitelist authority (due to seeds), - * and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - */ - - whitelistAuthority: TAccountMetas[1]; - /** unfreezing requires owner */ - owner: TAccountMetas[2]; - systemProgram: TAccountMetas[3]; - }; - data: UnfreezeWhitelistInstructionData; -}; - -export function parseUnfreezeWhitelistInstruction< - TProgram extends string, - TAccountMetas extends readonly IAccountMeta[], ->( - instruction: IInstruction & - IInstructionWithAccounts & - IInstructionWithData -): ParsedUnfreezeWhitelistInstruction { - if (instruction.accounts.length < 4) { - // TODO: Coded error. - throw new Error('Not enough accounts'); - } - let accountIndex = 0; - const getNextAccount = () => { - const accountMeta = instruction.accounts![accountIndex]!; - accountIndex += 1; - return accountMeta; - }; - return { - programAddress: instruction.programAddress, - accounts: { - whitelist: getNextAccount(), - whitelistAuthority: getNextAccount(), - owner: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getUnfreezeWhitelistInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/clients/js/src/generated/programs/tensorWhitelist.ts b/clients/js/src/generated/programs/tensorWhitelist.ts index b0da0551..a6824a4c 100644 --- a/clients/js/src/generated/programs/tensorWhitelist.ts +++ b/clients/js/src/generated/programs/tensorWhitelist.ts @@ -17,15 +17,10 @@ import { type ParsedCloseMintProofV2Instruction, type ParsedCloseWhitelistV2Instruction, type ParsedCreateWhitelistV2Instruction, - type ParsedFreezeWhitelistInstruction, type ParsedFreezeWhitelistV2Instruction, type ParsedInitUpdateAuthorityInstruction, - type ParsedInitUpdateMintProofInstruction, type ParsedInitUpdateMintProofV2Instruction, - type ParsedInitUpdateWhitelistInstruction, type ParsedReallocAuthorityInstruction, - type ParsedReallocWhitelistInstruction, - type ParsedUnfreezeWhitelistInstruction, type ParsedUnfreezeWhitelistV2Instruction, type ParsedUpdateWhitelistV2Instruction, } from '../instructions'; @@ -106,13 +101,8 @@ export function identifyTensorWhitelistAccount( } export enum TensorWhitelistInstruction { - FreezeWhitelist, InitUpdateAuthority, - InitUpdateMintProof, - InitUpdateWhitelist, ReallocAuthority, - ReallocWhitelist, - UnfreezeWhitelist, CreateWhitelistV2, CloseWhitelistV2, UpdateWhitelistV2, @@ -126,17 +116,6 @@ export function identifyTensorWhitelistInstruction( instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array ): TensorWhitelistInstruction { const data = 'data' in instruction ? instruction.data : instruction; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([248, 112, 12, 150, 175, 238, 38, 184]) - ), - 0 - ) - ) { - return TensorWhitelistInstruction.FreezeWhitelist; - } if ( containsBytes( data, @@ -148,28 +127,6 @@ export function identifyTensorWhitelistInstruction( ) { return TensorWhitelistInstruction.InitUpdateAuthority; } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([30, 77, 123, 9, 191, 37, 52, 159]) - ), - 0 - ) - ) { - return TensorWhitelistInstruction.InitUpdateMintProof; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([255, 1, 192, 134, 111, 49, 212, 131]) - ), - 0 - ) - ) { - return TensorWhitelistInstruction.InitUpdateWhitelist; - } if ( containsBytes( data, @@ -181,28 +138,6 @@ export function identifyTensorWhitelistInstruction( ) { return TensorWhitelistInstruction.ReallocAuthority; } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([173, 147, 168, 152, 181, 46, 55, 60]) - ), - 0 - ) - ) { - return TensorWhitelistInstruction.ReallocWhitelist; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([215, 119, 9, 92, 160, 139, 226, 253]) - ), - 0 - ) - ) { - return TensorWhitelistInstruction.UnfreezeWhitelist; - } if ( containsBytes( data, @@ -288,27 +223,12 @@ export function identifyTensorWhitelistInstruction( export type ParsedTensorWhitelistInstruction< TProgram extends string = 'TL1ST2iRBzuGTqLn1KXnGdSnEow62BzPnGiqyRXhWtW', > = - | ({ - instructionType: TensorWhitelistInstruction.FreezeWhitelist; - } & ParsedFreezeWhitelistInstruction) | ({ instructionType: TensorWhitelistInstruction.InitUpdateAuthority; } & ParsedInitUpdateAuthorityInstruction) - | ({ - instructionType: TensorWhitelistInstruction.InitUpdateMintProof; - } & ParsedInitUpdateMintProofInstruction) - | ({ - instructionType: TensorWhitelistInstruction.InitUpdateWhitelist; - } & ParsedInitUpdateWhitelistInstruction) | ({ instructionType: TensorWhitelistInstruction.ReallocAuthority; } & ParsedReallocAuthorityInstruction) - | ({ - instructionType: TensorWhitelistInstruction.ReallocWhitelist; - } & ParsedReallocWhitelistInstruction) - | ({ - instructionType: TensorWhitelistInstruction.UnfreezeWhitelist; - } & ParsedUnfreezeWhitelistInstruction) | ({ instructionType: TensorWhitelistInstruction.CreateWhitelistV2; } & ParsedCreateWhitelistV2Instruction) diff --git a/clients/rust/src/generated/instructions/freeze_whitelist.rs b/clients/rust/src/generated/instructions/freeze_whitelist.rs deleted file mode 100644 index 4c5bed2f..00000000 --- a/clients/rust/src/generated/instructions/freeze_whitelist.rs +++ /dev/null @@ -1,422 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::BorshDeserialize; -use borsh::BorshSerialize; - -/// Accounts. -pub struct FreezeWhitelist { - pub whitelist: solana_program::pubkey::Pubkey, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: solana_program::pubkey::Pubkey, - /// freezing only requires cosigner - pub cosigner: solana_program::pubkey::Pubkey, - - pub system_program: solana_program::pubkey::Pubkey, -} - -impl FreezeWhitelist { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.whitelist, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.whitelist_authority, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - self.cosigner, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = FreezeWhitelistInstructionData::new().try_to_vec().unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::TENSOR_WHITELIST_ID, - accounts, - data, - } - } -} - -#[derive(BorshDeserialize, BorshSerialize)] -pub struct FreezeWhitelistInstructionData { - discriminator: [u8; 8], -} - -impl FreezeWhitelistInstructionData { - pub fn new() -> Self { - Self { - discriminator: [248, 112, 12, 150, 175, 238, 38, 184], - } - } -} - -impl Default for FreezeWhitelistInstructionData { - fn default() -> Self { - Self::new() - } -} - -/// Instruction builder for `FreezeWhitelist`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whitelist -/// 1. `[]` whitelist_authority -/// 2. `[writable, signer]` cosigner -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct FreezeWhitelistBuilder { - whitelist: Option, - whitelist_authority: Option, - cosigner: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl FreezeWhitelistBuilder { - pub fn new() -> Self { - Self::default() - } - #[inline(always)] - pub fn whitelist(&mut self, whitelist: solana_program::pubkey::Pubkey) -> &mut Self { - self.whitelist = Some(whitelist); - self - } - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[inline(always)] - pub fn whitelist_authority( - &mut self, - whitelist_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.whitelist_authority = Some(whitelist_authority); - self - } - /// freezing only requires cosigner - #[inline(always)] - pub fn cosigner(&mut self, cosigner: solana_program::pubkey::Pubkey) -> &mut Self { - self.cosigner = Some(cosigner); - self - } - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = FreezeWhitelist { - whitelist: self.whitelist.expect("whitelist is not set"), - whitelist_authority: self - .whitelist_authority - .expect("whitelist_authority is not set"), - cosigner: self.cosigner.expect("cosigner is not set"), - system_program: self - .system_program - .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `freeze_whitelist` CPI accounts. -pub struct FreezeWhitelistCpiAccounts<'a, 'b> { - pub whitelist: &'b solana_program::account_info::AccountInfo<'a>, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// freezing only requires cosigner - pub cosigner: &'b solana_program::account_info::AccountInfo<'a>, - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, -} - -/// `freeze_whitelist` CPI instruction. -pub struct FreezeWhitelistCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - - pub whitelist: &'b solana_program::account_info::AccountInfo<'a>, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// freezing only requires cosigner - pub cosigner: &'b solana_program::account_info::AccountInfo<'a>, - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, -} - -impl<'a, 'b> FreezeWhitelistCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: FreezeWhitelistCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whitelist: accounts.whitelist, - whitelist_authority: accounts.whitelist_authority, - cosigner: accounts.cosigner, - system_program: accounts.system_program, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.whitelist.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.whitelist_authority.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.cosigner.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = FreezeWhitelistInstructionData::new().try_to_vec().unwrap(); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::TENSOR_WHITELIST_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whitelist.clone()); - account_infos.push(self.whitelist_authority.clone()); - account_infos.push(self.cosigner.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `FreezeWhitelist` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whitelist -/// 1. `[]` whitelist_authority -/// 2. `[writable, signer]` cosigner -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct FreezeWhitelistCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> FreezeWhitelistCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(FreezeWhitelistCpiBuilderInstruction { - __program: program, - whitelist: None, - whitelist_authority: None, - cosigner: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - #[inline(always)] - pub fn whitelist( - &mut self, - whitelist: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whitelist = Some(whitelist); - self - } - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[inline(always)] - pub fn whitelist_authority( - &mut self, - whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whitelist_authority = Some(whitelist_authority); - self - } - /// freezing only requires cosigner - #[inline(always)] - pub fn cosigner( - &mut self, - cosigner: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cosigner = Some(cosigner); - self - } - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - let instruction = FreezeWhitelistCpi { - __program: self.instruction.__program, - - whitelist: self.instruction.whitelist.expect("whitelist is not set"), - - whitelist_authority: self - .instruction - .whitelist_authority - .expect("whitelist_authority is not set"), - - cosigner: self.instruction.cosigner.expect("cosigner is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct FreezeWhitelistCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>, - whitelist_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, -} diff --git a/clients/rust/src/generated/instructions/init_update_mint_proof.rs b/clients/rust/src/generated/instructions/init_update_mint_proof.rs deleted file mode 100644 index 4177a1f1..00000000 --- a/clients/rust/src/generated/instructions/init_update_mint_proof.rs +++ /dev/null @@ -1,476 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::BorshDeserialize; -use borsh::BorshSerialize; - -/// Accounts. -pub struct InitUpdateMintProof { - pub whitelist: solana_program::pubkey::Pubkey, - - pub mint: solana_program::pubkey::Pubkey, - - pub mint_proof: solana_program::pubkey::Pubkey, - - pub user: solana_program::pubkey::Pubkey, - - pub system_program: solana_program::pubkey::Pubkey, -} - -impl InitUpdateMintProof { - pub fn instruction( - &self, - args: InitUpdateMintProofInstructionArgs, - ) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitUpdateMintProofInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.whitelist, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - self.mint_proof, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - self.user, true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = InitUpdateMintProofInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::TENSOR_WHITELIST_ID, - accounts, - data, - } - } -} - -#[derive(BorshDeserialize, BorshSerialize)] -pub struct InitUpdateMintProofInstructionData { - discriminator: [u8; 8], -} - -impl InitUpdateMintProofInstructionData { - pub fn new() -> Self { - Self { - discriminator: [30, 77, 123, 9, 191, 37, 52, 159], - } - } -} - -impl Default for InitUpdateMintProofInstructionData { - fn default() -> Self { - Self::new() - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitUpdateMintProofInstructionArgs { - pub proof: Vec<[u8; 32]>, -} - -/// Instruction builder for `InitUpdateMintProof`. -/// -/// ### Accounts: -/// -/// 0. `[]` whitelist -/// 1. `[]` mint -/// 2. `[writable]` mint_proof -/// 3. `[writable, signer]` user -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitUpdateMintProofBuilder { - whitelist: Option, - mint: Option, - mint_proof: Option, - user: Option, - system_program: Option, - proof: Option>, - __remaining_accounts: Vec, -} - -impl InitUpdateMintProofBuilder { - pub fn new() -> Self { - Self::default() - } - #[inline(always)] - pub fn whitelist(&mut self, whitelist: solana_program::pubkey::Pubkey) -> &mut Self { - self.whitelist = Some(whitelist); - self - } - #[inline(always)] - pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - #[inline(always)] - pub fn mint_proof(&mut self, mint_proof: solana_program::pubkey::Pubkey) -> &mut Self { - self.mint_proof = Some(mint_proof); - self - } - #[inline(always)] - pub fn user(&mut self, user: solana_program::pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - #[inline(always)] - pub fn proof(&mut self, proof: Vec<[u8; 32]>) -> &mut Self { - self.proof = Some(proof); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = InitUpdateMintProof { - whitelist: self.whitelist.expect("whitelist is not set"), - mint: self.mint.expect("mint is not set"), - mint_proof: self.mint_proof.expect("mint_proof is not set"), - user: self.user.expect("user is not set"), - system_program: self - .system_program - .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), - }; - let args = InitUpdateMintProofInstructionArgs { - proof: self.proof.clone().expect("proof is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `init_update_mint_proof` CPI accounts. -pub struct InitUpdateMintProofCpiAccounts<'a, 'b> { - pub whitelist: &'b solana_program::account_info::AccountInfo<'a>, - - pub mint: &'b solana_program::account_info::AccountInfo<'a>, - - pub mint_proof: &'b solana_program::account_info::AccountInfo<'a>, - - pub user: &'b solana_program::account_info::AccountInfo<'a>, - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, -} - -/// `init_update_mint_proof` CPI instruction. -pub struct InitUpdateMintProofCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - - pub whitelist: &'b solana_program::account_info::AccountInfo<'a>, - - pub mint: &'b solana_program::account_info::AccountInfo<'a>, - - pub mint_proof: &'b solana_program::account_info::AccountInfo<'a>, - - pub user: &'b solana_program::account_info::AccountInfo<'a>, - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitUpdateMintProofInstructionArgs, -} - -impl<'a, 'b> InitUpdateMintProofCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: InitUpdateMintProofCpiAccounts<'a, 'b>, - args: InitUpdateMintProofInstructionArgs, - ) -> Self { - Self { - __program: program, - whitelist: accounts.whitelist, - mint: accounts.mint, - mint_proof: accounts.mint_proof, - user: accounts.user, - system_program: accounts.system_program, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.whitelist.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.mint_proof.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.user.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = InitUpdateMintProofInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::TENSOR_WHITELIST_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + 1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whitelist.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.mint_proof.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitUpdateMintProof` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whitelist -/// 1. `[]` mint -/// 2. `[writable]` mint_proof -/// 3. `[writable, signer]` user -/// 4. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitUpdateMintProofCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitUpdateMintProofCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitUpdateMintProofCpiBuilderInstruction { - __program: program, - whitelist: None, - mint: None, - mint_proof: None, - user: None, - system_program: None, - proof: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - #[inline(always)] - pub fn whitelist( - &mut self, - whitelist: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whitelist = Some(whitelist); - self - } - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - #[inline(always)] - pub fn mint_proof( - &mut self, - mint_proof: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_proof = Some(mint_proof); - self - } - #[inline(always)] - pub fn user(&mut self, user: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - #[inline(always)] - pub fn proof(&mut self, proof: Vec<[u8; 32]>) -> &mut Self { - self.instruction.proof = Some(proof); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - let args = InitUpdateMintProofInstructionArgs { - proof: self.instruction.proof.clone().expect("proof is not set"), - }; - let instruction = InitUpdateMintProofCpi { - __program: self.instruction.__program, - - whitelist: self.instruction.whitelist.expect("whitelist is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - mint_proof: self.instruction.mint_proof.expect("mint_proof is not set"), - - user: self.instruction.user.expect("user is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitUpdateMintProofCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>, - mint: Option<&'b solana_program::account_info::AccountInfo<'a>>, - mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>, - user: Option<&'b solana_program::account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - proof: Option>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, -} diff --git a/clients/rust/src/generated/instructions/init_update_whitelist.rs b/clients/rust/src/generated/instructions/init_update_whitelist.rs deleted file mode 100644 index cb0aa718..00000000 --- a/clients/rust/src/generated/instructions/init_update_whitelist.rs +++ /dev/null @@ -1,537 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::BorshDeserialize; -use borsh::BorshSerialize; -use solana_program::pubkey::Pubkey; - -/// Accounts. -pub struct InitUpdateWhitelist { - pub whitelist: solana_program::pubkey::Pubkey, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: solana_program::pubkey::Pubkey, - /// only cosigner has to sign for unfrozen, for frozen owner also has to sign - pub cosigner: solana_program::pubkey::Pubkey, - - pub system_program: solana_program::pubkey::Pubkey, -} - -impl InitUpdateWhitelist { - pub fn instruction( - &self, - args: InitUpdateWhitelistInstructionArgs, - ) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitUpdateWhitelistInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.whitelist, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.whitelist_authority, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - self.cosigner, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = InitUpdateWhitelistInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_program::instruction::Instruction { - program_id: crate::TENSOR_WHITELIST_ID, - accounts, - data, - } - } -} - -#[derive(BorshDeserialize, BorshSerialize)] -pub struct InitUpdateWhitelistInstructionData { - discriminator: [u8; 8], -} - -impl InitUpdateWhitelistInstructionData { - pub fn new() -> Self { - Self { - discriminator: [255, 1, 192, 134, 111, 49, 212, 131], - } - } -} - -impl Default for InitUpdateWhitelistInstructionData { - fn default() -> Self { - Self::new() - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitUpdateWhitelistInstructionArgs { - pub uuid: [u8; 32], - pub root_hash: Option<[u8; 32]>, - pub name: Option<[u8; 32]>, - pub voc: Option, - pub fvc: Option, -} - -/// Instruction builder for `InitUpdateWhitelist`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whitelist -/// 1. `[]` whitelist_authority -/// 2. `[writable, signer]` cosigner -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitUpdateWhitelistBuilder { - whitelist: Option, - whitelist_authority: Option, - cosigner: Option, - system_program: Option, - uuid: Option<[u8; 32]>, - root_hash: Option<[u8; 32]>, - name: Option<[u8; 32]>, - voc: Option, - fvc: Option, - __remaining_accounts: Vec, -} - -impl InitUpdateWhitelistBuilder { - pub fn new() -> Self { - Self::default() - } - #[inline(always)] - pub fn whitelist(&mut self, whitelist: solana_program::pubkey::Pubkey) -> &mut Self { - self.whitelist = Some(whitelist); - self - } - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[inline(always)] - pub fn whitelist_authority( - &mut self, - whitelist_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.whitelist_authority = Some(whitelist_authority); - self - } - /// only cosigner has to sign for unfrozen, for frozen owner also has to sign - #[inline(always)] - pub fn cosigner(&mut self, cosigner: solana_program::pubkey::Pubkey) -> &mut Self { - self.cosigner = Some(cosigner); - self - } - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - #[inline(always)] - pub fn uuid(&mut self, uuid: [u8; 32]) -> &mut Self { - self.uuid = Some(uuid); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn root_hash(&mut self, root_hash: [u8; 32]) -> &mut Self { - self.root_hash = Some(root_hash); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn name(&mut self, name: [u8; 32]) -> &mut Self { - self.name = Some(name); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn voc(&mut self, voc: Pubkey) -> &mut Self { - self.voc = Some(voc); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn fvc(&mut self, fvc: Pubkey) -> &mut Self { - self.fvc = Some(fvc); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = InitUpdateWhitelist { - whitelist: self.whitelist.expect("whitelist is not set"), - whitelist_authority: self - .whitelist_authority - .expect("whitelist_authority is not set"), - cosigner: self.cosigner.expect("cosigner is not set"), - system_program: self - .system_program - .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), - }; - let args = InitUpdateWhitelistInstructionArgs { - uuid: self.uuid.clone().expect("uuid is not set"), - root_hash: self.root_hash.clone(), - name: self.name.clone(), - voc: self.voc.clone(), - fvc: self.fvc.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `init_update_whitelist` CPI accounts. -pub struct InitUpdateWhitelistCpiAccounts<'a, 'b> { - pub whitelist: &'b solana_program::account_info::AccountInfo<'a>, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// only cosigner has to sign for unfrozen, for frozen owner also has to sign - pub cosigner: &'b solana_program::account_info::AccountInfo<'a>, - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, -} - -/// `init_update_whitelist` CPI instruction. -pub struct InitUpdateWhitelistCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - - pub whitelist: &'b solana_program::account_info::AccountInfo<'a>, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// only cosigner has to sign for unfrozen, for frozen owner also has to sign - pub cosigner: &'b solana_program::account_info::AccountInfo<'a>, - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitUpdateWhitelistInstructionArgs, -} - -impl<'a, 'b> InitUpdateWhitelistCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: InitUpdateWhitelistCpiAccounts<'a, 'b>, - args: InitUpdateWhitelistInstructionArgs, - ) -> Self { - Self { - __program: program, - whitelist: accounts.whitelist, - whitelist_authority: accounts.whitelist_authority, - cosigner: accounts.cosigner, - system_program: accounts.system_program, - __args: args, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.whitelist.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.whitelist_authority.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.cosigner.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = InitUpdateWhitelistInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::TENSOR_WHITELIST_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whitelist.clone()); - account_infos.push(self.whitelist_authority.clone()); - account_infos.push(self.cosigner.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitUpdateWhitelist` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whitelist -/// 1. `[]` whitelist_authority -/// 2. `[writable, signer]` cosigner -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitUpdateWhitelistCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitUpdateWhitelistCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitUpdateWhitelistCpiBuilderInstruction { - __program: program, - whitelist: None, - whitelist_authority: None, - cosigner: None, - system_program: None, - uuid: None, - root_hash: None, - name: None, - voc: None, - fvc: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - #[inline(always)] - pub fn whitelist( - &mut self, - whitelist: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whitelist = Some(whitelist); - self - } - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[inline(always)] - pub fn whitelist_authority( - &mut self, - whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whitelist_authority = Some(whitelist_authority); - self - } - /// only cosigner has to sign for unfrozen, for frozen owner also has to sign - #[inline(always)] - pub fn cosigner( - &mut self, - cosigner: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cosigner = Some(cosigner); - self - } - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - #[inline(always)] - pub fn uuid(&mut self, uuid: [u8; 32]) -> &mut Self { - self.instruction.uuid = Some(uuid); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn root_hash(&mut self, root_hash: [u8; 32]) -> &mut Self { - self.instruction.root_hash = Some(root_hash); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn name(&mut self, name: [u8; 32]) -> &mut Self { - self.instruction.name = Some(name); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn voc(&mut self, voc: Pubkey) -> &mut Self { - self.instruction.voc = Some(voc); - self - } - /// `[optional argument]` - #[inline(always)] - pub fn fvc(&mut self, fvc: Pubkey) -> &mut Self { - self.instruction.fvc = Some(fvc); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - let args = InitUpdateWhitelistInstructionArgs { - uuid: self.instruction.uuid.clone().expect("uuid is not set"), - root_hash: self.instruction.root_hash.clone(), - name: self.instruction.name.clone(), - voc: self.instruction.voc.clone(), - fvc: self.instruction.fvc.clone(), - }; - let instruction = InitUpdateWhitelistCpi { - __program: self.instruction.__program, - - whitelist: self.instruction.whitelist.expect("whitelist is not set"), - - whitelist_authority: self - .instruction - .whitelist_authority - .expect("whitelist_authority is not set"), - - cosigner: self.instruction.cosigner.expect("cosigner is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitUpdateWhitelistCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>, - whitelist_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - uuid: Option<[u8; 32]>, - root_hash: Option<[u8; 32]>, - name: Option<[u8; 32]>, - voc: Option, - fvc: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, -} diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index 419743d6..c920ec67 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -8,29 +8,19 @@ pub(crate) mod r#close_mint_proof_v2; pub(crate) mod r#close_whitelist_v2; pub(crate) mod r#create_whitelist_v2; -pub(crate) mod r#freeze_whitelist; pub(crate) mod r#freeze_whitelist_v2; pub(crate) mod r#init_update_authority; -pub(crate) mod r#init_update_mint_proof; pub(crate) mod r#init_update_mint_proof_v2; -pub(crate) mod r#init_update_whitelist; pub(crate) mod r#realloc_authority; -pub(crate) mod r#realloc_whitelist; -pub(crate) mod r#unfreeze_whitelist; pub(crate) mod r#unfreeze_whitelist_v2; pub(crate) mod r#update_whitelist_v2; pub use self::r#close_mint_proof_v2::*; pub use self::r#close_whitelist_v2::*; pub use self::r#create_whitelist_v2::*; -pub use self::r#freeze_whitelist::*; pub use self::r#freeze_whitelist_v2::*; pub use self::r#init_update_authority::*; -pub use self::r#init_update_mint_proof::*; pub use self::r#init_update_mint_proof_v2::*; -pub use self::r#init_update_whitelist::*; pub use self::r#realloc_authority::*; -pub use self::r#realloc_whitelist::*; -pub use self::r#unfreeze_whitelist::*; pub use self::r#unfreeze_whitelist_v2::*; pub use self::r#update_whitelist_v2::*; diff --git a/clients/rust/src/generated/instructions/realloc_whitelist.rs b/clients/rust/src/generated/instructions/realloc_whitelist.rs deleted file mode 100644 index 1a1f83ad..00000000 --- a/clients/rust/src/generated/instructions/realloc_whitelist.rs +++ /dev/null @@ -1,420 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::BorshDeserialize; -use borsh::BorshSerialize; - -/// Accounts. -pub struct ReallocWhitelist { - pub whitelist: solana_program::pubkey::Pubkey, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: solana_program::pubkey::Pubkey, - - pub cosigner: solana_program::pubkey::Pubkey, - - pub system_program: solana_program::pubkey::Pubkey, -} - -impl ReallocWhitelist { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.whitelist, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.whitelist_authority, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - self.cosigner, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = ReallocWhitelistInstructionData::new().try_to_vec().unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::TENSOR_WHITELIST_ID, - accounts, - data, - } - } -} - -#[derive(BorshDeserialize, BorshSerialize)] -pub struct ReallocWhitelistInstructionData { - discriminator: [u8; 8], -} - -impl ReallocWhitelistInstructionData { - pub fn new() -> Self { - Self { - discriminator: [173, 147, 168, 152, 181, 46, 55, 60], - } - } -} - -impl Default for ReallocWhitelistInstructionData { - fn default() -> Self { - Self::new() - } -} - -/// Instruction builder for `ReallocWhitelist`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whitelist -/// 1. `[]` whitelist_authority -/// 2. `[writable, signer]` cosigner -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct ReallocWhitelistBuilder { - whitelist: Option, - whitelist_authority: Option, - cosigner: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl ReallocWhitelistBuilder { - pub fn new() -> Self { - Self::default() - } - #[inline(always)] - pub fn whitelist(&mut self, whitelist: solana_program::pubkey::Pubkey) -> &mut Self { - self.whitelist = Some(whitelist); - self - } - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[inline(always)] - pub fn whitelist_authority( - &mut self, - whitelist_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.whitelist_authority = Some(whitelist_authority); - self - } - #[inline(always)] - pub fn cosigner(&mut self, cosigner: solana_program::pubkey::Pubkey) -> &mut Self { - self.cosigner = Some(cosigner); - self - } - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = ReallocWhitelist { - whitelist: self.whitelist.expect("whitelist is not set"), - whitelist_authority: self - .whitelist_authority - .expect("whitelist_authority is not set"), - cosigner: self.cosigner.expect("cosigner is not set"), - system_program: self - .system_program - .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `realloc_whitelist` CPI accounts. -pub struct ReallocWhitelistCpiAccounts<'a, 'b> { - pub whitelist: &'b solana_program::account_info::AccountInfo<'a>, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - - pub cosigner: &'b solana_program::account_info::AccountInfo<'a>, - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, -} - -/// `realloc_whitelist` CPI instruction. -pub struct ReallocWhitelistCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - - pub whitelist: &'b solana_program::account_info::AccountInfo<'a>, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - - pub cosigner: &'b solana_program::account_info::AccountInfo<'a>, - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ReallocWhitelistCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: ReallocWhitelistCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whitelist: accounts.whitelist, - whitelist_authority: accounts.whitelist_authority, - cosigner: accounts.cosigner, - system_program: accounts.system_program, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.whitelist.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.whitelist_authority.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.cosigner.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = ReallocWhitelistInstructionData::new().try_to_vec().unwrap(); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::TENSOR_WHITELIST_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whitelist.clone()); - account_infos.push(self.whitelist_authority.clone()); - account_infos.push(self.cosigner.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ReallocWhitelist` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whitelist -/// 1. `[]` whitelist_authority -/// 2. `[writable, signer]` cosigner -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct ReallocWhitelistCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ReallocWhitelistCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ReallocWhitelistCpiBuilderInstruction { - __program: program, - whitelist: None, - whitelist_authority: None, - cosigner: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - #[inline(always)] - pub fn whitelist( - &mut self, - whitelist: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whitelist = Some(whitelist); - self - } - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[inline(always)] - pub fn whitelist_authority( - &mut self, - whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whitelist_authority = Some(whitelist_authority); - self - } - #[inline(always)] - pub fn cosigner( - &mut self, - cosigner: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cosigner = Some(cosigner); - self - } - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - let instruction = ReallocWhitelistCpi { - __program: self.instruction.__program, - - whitelist: self.instruction.whitelist.expect("whitelist is not set"), - - whitelist_authority: self - .instruction - .whitelist_authority - .expect("whitelist_authority is not set"), - - cosigner: self.instruction.cosigner.expect("cosigner is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ReallocWhitelistCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>, - whitelist_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, -} diff --git a/clients/rust/src/generated/instructions/unfreeze_whitelist.rs b/clients/rust/src/generated/instructions/unfreeze_whitelist.rs deleted file mode 100644 index 6e6e9ef9..00000000 --- a/clients/rust/src/generated/instructions/unfreeze_whitelist.rs +++ /dev/null @@ -1,422 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::BorshDeserialize; -use borsh::BorshSerialize; - -/// Accounts. -pub struct UnfreezeWhitelist { - pub whitelist: solana_program::pubkey::Pubkey, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: solana_program::pubkey::Pubkey, - /// unfreezing requires owner - pub owner: solana_program::pubkey::Pubkey, - - pub system_program: solana_program::pubkey::Pubkey, -} - -impl UnfreezeWhitelist { - pub fn instruction(&self) -> solana_program::instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.whitelist, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.whitelist_authority, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - self.owner, true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = UnfreezeWhitelistInstructionData::new() - .try_to_vec() - .unwrap(); - - solana_program::instruction::Instruction { - program_id: crate::TENSOR_WHITELIST_ID, - accounts, - data, - } - } -} - -#[derive(BorshDeserialize, BorshSerialize)] -pub struct UnfreezeWhitelistInstructionData { - discriminator: [u8; 8], -} - -impl UnfreezeWhitelistInstructionData { - pub fn new() -> Self { - Self { - discriminator: [215, 119, 9, 92, 160, 139, 226, 253], - } - } -} - -impl Default for UnfreezeWhitelistInstructionData { - fn default() -> Self { - Self::new() - } -} - -/// Instruction builder for `UnfreezeWhitelist`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whitelist -/// 1. `[]` whitelist_authority -/// 2. `[writable, signer]` owner -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct UnfreezeWhitelistBuilder { - whitelist: Option, - whitelist_authority: Option, - owner: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl UnfreezeWhitelistBuilder { - pub fn new() -> Self { - Self::default() - } - #[inline(always)] - pub fn whitelist(&mut self, whitelist: solana_program::pubkey::Pubkey) -> &mut Self { - self.whitelist = Some(whitelist); - self - } - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[inline(always)] - pub fn whitelist_authority( - &mut self, - whitelist_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { - self.whitelist_authority = Some(whitelist_authority); - self - } - /// unfreezing requires owner - #[inline(always)] - pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_program::instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { - let accounts = UnfreezeWhitelist { - whitelist: self.whitelist.expect("whitelist is not set"), - whitelist_authority: self - .whitelist_authority - .expect("whitelist_authority is not set"), - owner: self.owner.expect("owner is not set"), - system_program: self - .system_program - .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `unfreeze_whitelist` CPI accounts. -pub struct UnfreezeWhitelistCpiAccounts<'a, 'b> { - pub whitelist: &'b solana_program::account_info::AccountInfo<'a>, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// unfreezing requires owner - pub owner: &'b solana_program::account_info::AccountInfo<'a>, - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, -} - -/// `unfreeze_whitelist` CPI instruction. -pub struct UnfreezeWhitelistCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, - - pub whitelist: &'b solana_program::account_info::AccountInfo<'a>, - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// unfreezing requires owner - pub owner: &'b solana_program::account_info::AccountInfo<'a>, - - pub system_program: &'b solana_program::account_info::AccountInfo<'a>, -} - -impl<'a, 'b> UnfreezeWhitelistCpi<'a, 'b> { - pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, - accounts: UnfreezeWhitelistCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whitelist: accounts.whitelist, - whitelist_authority: accounts.whitelist_authority, - owner: accounts.owner, - system_program: accounts.system_program, - } - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.whitelist.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.whitelist_authority.key, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.owner.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = UnfreezeWhitelistInstructionData::new() - .try_to_vec() - .unwrap(); - - let instruction = solana_program::instruction::Instruction { - program_id: crate::TENSOR_WHITELIST_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whitelist.clone()); - account_infos.push(self.whitelist_authority.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) - } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UnfreezeWhitelist` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whitelist -/// 1. `[]` whitelist_authority -/// 2. `[writable, signer]` owner -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct UnfreezeWhitelistCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UnfreezeWhitelistCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UnfreezeWhitelistCpiBuilderInstruction { - __program: program, - whitelist: None, - whitelist_authority: None, - owner: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - #[inline(always)] - pub fn whitelist( - &mut self, - whitelist: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whitelist = Some(whitelist); - self - } - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[inline(always)] - pub fn whitelist_authority( - &mut self, - whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whitelist_authority = Some(whitelist_authority); - self - } - /// unfreezing requires owner - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) - } - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { - let instruction = UnfreezeWhitelistCpi { - __program: self.instruction.__program, - - whitelist: self.instruction.whitelist.expect("whitelist is not set"), - - whitelist_authority: self - .instruction - .whitelist_authority - .expect("whitelist_authority is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UnfreezeWhitelistCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>, - whitelist_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - owner: Option<&'b solana_program::account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, -} diff --git a/program/idl.json b/program/idl.json index fe9b65e7..9da58d7f 100644 --- a/program/idl.json +++ b/program/idl.json @@ -51,42 +51,6 @@ } ], "instructions": [ - { - "name": "freezeWhitelist", - "docs": [ - "Freeze a whitelist so that an extra signature is required to update it." - ], - "accounts": [ - { - "name": "whitelist", - "isMut": true, - "isSigner": false - }, - { - "name": "whitelistAuthority", - "isMut": false, - "isSigner": false, - "docs": [ - "there can only be 1 whitelist authority (due to seeds),", - "and we're checking that 1)the correct cosigner is present on it, and 2)is a signer" - ] - }, - { - "name": "cosigner", - "isMut": true, - "isSigner": true, - "docs": [ - "freezing only requires cosigner" - ] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, { "name": "initUpdateAuthority", "docs": [ @@ -132,132 +96,6 @@ } ] }, - { - "name": "initUpdateMintProof", - "docs": [ - "Initialize or update a mint proof." - ], - "accounts": [ - { - "name": "whitelist", - "isMut": false, - "isSigner": false - }, - { - "name": "mint", - "isMut": false, - "isSigner": false - }, - { - "name": "mintProof", - "isMut": true, - "isSigner": false - }, - { - "name": "user", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "proof", - "type": { - "vec": { - "array": [ - "u8", - 32 - ] - } - } - } - ] - }, - { - "name": "initUpdateWhitelist", - "docs": [ - "Initialize or update a whitelist." - ], - "accounts": [ - { - "name": "whitelist", - "isMut": true, - "isSigner": false - }, - { - "name": "whitelistAuthority", - "isMut": false, - "isSigner": false, - "docs": [ - "there can only be 1 whitelist authority (due to seeds),", - "and we're checking that 1)the correct cosigner is present on it, and 2)is a signer" - ] - }, - { - "name": "cosigner", - "isMut": true, - "isSigner": true, - "docs": [ - "only cosigner has to sign for unfrozen, for frozen owner also has to sign" - ] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "uuid", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "rootHash", - "type": { - "option": { - "array": [ - "u8", - 32 - ] - } - } - }, - { - "name": "name", - "type": { - "option": { - "array": [ - "u8", - 32 - ] - } - } - }, - { - "name": "voc", - "type": { - "option": "publicKey" - } - }, - { - "name": "fvc", - "type": { - "option": "publicKey" - } - } - ] - }, { "name": "reallocAuthority", "docs": [ @@ -286,75 +124,6 @@ ], "args": [] }, - { - "name": "reallocWhitelist", - "docs": [ - "Reallocate space on the whitelist." - ], - "accounts": [ - { - "name": "whitelist", - "isMut": true, - "isSigner": false - }, - { - "name": "whitelistAuthority", - "isMut": false, - "isSigner": false, - "docs": [ - "there can only be 1 whitelist authority (due to seeds),", - "and we're checking that 1)the correct cosigner is present on it, and 2)is a signer" - ] - }, - { - "name": "cosigner", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "unfreezeWhitelist", - "docs": [ - "Unfreeze a whitelist so that only one signature is required to update it." - ], - "accounts": [ - { - "name": "whitelist", - "isMut": true, - "isSigner": false - }, - { - "name": "whitelistAuthority", - "isMut": false, - "isSigner": false, - "docs": [ - "there can only be 1 whitelist authority (due to seeds),", - "and we're checking that 1)the correct cosigner is present on it, and 2)is a signer" - ] - }, - { - "name": "owner", - "isMut": true, - "isSigner": true, - "docs": [ - "unfreezing requires owner" - ] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, { "name": "createWhitelistV2", "docs": [ diff --git a/program/src/instructions/freeze_whitelist.rs b/program/src/instructions/freeze_whitelist.rs deleted file mode 100644 index 4089f552..00000000 --- a/program/src/instructions/freeze_whitelist.rs +++ /dev/null @@ -1,34 +0,0 @@ -use anchor_lang::prelude::*; - -use crate::state::{Authority, Whitelist}; - -#[derive(Accounts)] -pub struct FreezeWhitelist<'info> { - #[account( - mut, - seeds = [&whitelist.uuid], - bump = whitelist.bump - )] - pub whitelist: Box>, - - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[account( - seeds = [], - bump = whitelist_authority.bump, - has_one = cosigner, - )] - pub whitelist_authority: Box>, - - /// freezing only requires cosigner - #[account(mut)] - pub cosigner: Signer<'info>, - pub system_program: Program<'info, System>, -} - -pub fn process_freeze_whitelist(ctx: Context) -> Result<()> { - let whitelist = &mut ctx.accounts.whitelist; - whitelist.frozen = true; - - Ok(()) -} diff --git a/program/src/instructions/init_update_mint_proof.rs b/program/src/instructions/init_update_mint_proof.rs deleted file mode 100644 index bececae8..00000000 --- a/program/src/instructions/init_update_mint_proof.rs +++ /dev/null @@ -1,69 +0,0 @@ -use anchor_lang::prelude::*; -use anchor_spl::token_interface::Mint; -use tensor_toolbox::validate_proof; -use tensor_vipers::{throw_err, unwrap_int}; - -use crate::{ - error::ErrorCode, - state::{MintProof, Whitelist, MAX_PROOF_LEN, MINT_PROOF_SIZE}, -}; - -#[derive(Accounts)] -pub struct InitUpdateMintProof<'info> { - #[account( - seeds = [&whitelist.uuid], - bump = whitelist.bump - )] - pub whitelist: Box>, - - pub mint: Box>, - - // Seed derived from mint + whitelist addresses. - #[account( - init_if_needed, - payer = user, - seeds = [ - MintProof::PREFIX, - mint.key().as_ref(), - whitelist.key().as_ref(), - ], - bump, - space = MINT_PROOF_SIZE - )] - pub mint_proof: Box>, - - #[account(mut)] - pub user: Signer<'info>, - pub system_program: Program<'info, System>, -} - -pub fn process_init_update_mint_proof( - ctx: Context, - proof: Vec<[u8; 32]>, -) -> Result<()> { - let mint_proof = &mut ctx.accounts.mint_proof; - let leaf = anchor_lang::solana_program::keccak::hash(ctx.accounts.mint.key().as_ref()); - - // This won't happen currently b/c transaction size is hit before we can run into this. - // TODO: revisit + test. - if proof.len() > MAX_PROOF_LEN { - throw_err!(ErrorCode::ProofTooLong); - } - - require!( - validate_proof(&ctx.accounts.whitelist.root_hash, &leaf.0, &proof), - ErrorCode::FailedMerkleProofVerification, - ); - - // Upsert proof into the MintProof account. - mint_proof.proof_len = unwrap_int!(u8::try_from(proof.len()).ok()); - - // Zero out array. - for elem in mint_proof.proof.iter_mut() { - *elem = [0; 32]; - } - - mint_proof.proof[0..proof.len()].copy_from_slice(proof.as_slice()); - - Ok(()) -} diff --git a/program/src/instructions/init_update_whitelist.rs b/program/src/instructions/init_update_whitelist.rs deleted file mode 100644 index 170c145e..00000000 --- a/program/src/instructions/init_update_whitelist.rs +++ /dev/null @@ -1,97 +0,0 @@ -use anchor_lang::prelude::*; -use tensor_vipers::throw_err; - -use crate::{ - error::ErrorCode, - state::{Authority, Whitelist, WHITELIST_SIZE, ZERO_ARRAY}, - CURRENT_WHITELIST_VERSION, -}; - -#[derive(Accounts)] -#[instruction(uuid: [u8; 32])] -pub struct InitUpdateWhitelist<'info> { - #[account( - init_if_needed, - payer = cosigner, - seeds = [&uuid], - bump, - space = WHITELIST_SIZE - )] - pub whitelist: Box>, - - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[account( - seeds = [], - bump = whitelist_authority.bump, - has_one = cosigner, - )] - pub whitelist_authority: Box>, - - /// only cosigner has to sign for unfrozen, for frozen owner also has to sign - #[account(mut)] - pub cosigner: Signer<'info>, - pub system_program: Program<'info, System>, - //remainingAccounts: - //1. owner (signer, non-mut) -} - -/// Store min 1, max 3, check in priority order -pub fn process_init_update_whitelist( - ctx: Context, - uuid: [u8; 32], - root_hash: Option<[u8; 32]>, - name: Option<[u8; 32]>, - voc: Option, - fvc: Option, -) -> Result<()> { - let whitelist = &mut ctx.accounts.whitelist; - let auth = &ctx.accounts.whitelist_authority; - let iter = &mut ctx.remaining_accounts.iter(); - - //handle frozen whitelists - only updatable if owner signs off - if whitelist.frozen { - //will fail if extra acc not passed - let owner = next_account_info(iter).map_err(|_| ErrorCode::BadOwner)?; - //since passed in as optional acc, verify both 1)is signer and 2)is correct auth - if !owner.is_signer || auth.owner != *owner.key { - throw_err!(ErrorCode::BadOwner); - } - } - - whitelist.version = CURRENT_WHITELIST_VERSION; - whitelist.bump = ctx.bumps.whitelist; - // TODO: temp feature since for now we're keeping WL permissioned - whitelist.verified = true; - // set uuid (won't change after initialization) - whitelist.uuid = uuid; - whitelist.voc = voc; - whitelist.fvc = fvc; - - //at least one of 3 verification methods must be present - if (voc.is_none() || voc.unwrap() == Pubkey::default()) - && (fvc.is_none() || fvc.unwrap() == Pubkey::default()) - && (root_hash.is_none() || root_hash.unwrap() == ZERO_ARRAY) - { - throw_err!(ErrorCode::MissingVerification); - } - - // set root hash (can be empty as long as at least one other verification method present) - if let Some(root_hash) = root_hash { - whitelist.root_hash = root_hash; - } - - // set name (can't be empty if we're initializing it for the first time) - match name { - Some(name) => { - whitelist.name = name; - } - None => { - if whitelist.name == ZERO_ARRAY { - throw_err!(ErrorCode::MissingName); - } - } - } - - Ok(()) -} diff --git a/program/src/instructions/mod.rs b/program/src/instructions/mod.rs index 61563d07..121dec8f 100644 --- a/program/src/instructions/mod.rs +++ b/program/src/instructions/mod.rs @@ -1,18 +1,8 @@ -mod freeze_whitelist; mod init_update_authority; -mod init_update_mint_proof; -mod init_update_whitelist; mod realloc_authority; -mod realloc_whitelist; -mod unfreeze_whitelist; -pub use freeze_whitelist::*; pub use init_update_authority::*; -pub use init_update_mint_proof::*; -pub use init_update_whitelist::*; pub use realloc_authority::*; -pub use realloc_whitelist::*; -pub use unfreeze_whitelist::*; // V2 mod close_mint_proof_v2; diff --git a/program/src/instructions/realloc_whitelist.rs b/program/src/instructions/realloc_whitelist.rs deleted file mode 100644 index 6c544c77..00000000 --- a/program/src/instructions/realloc_whitelist.rs +++ /dev/null @@ -1,52 +0,0 @@ -use anchor_lang::prelude::*; -use tensor_vipers::{throw_err, Validate}; - -use crate::{ - error::ErrorCode, - state::{Authority, Whitelist, WHITELIST_SIZE}, - CURRENT_WHITELIST_VERSION, -}; - -#[derive(Accounts)] -pub struct ReallocWhitelist<'info> { - #[account(mut, - seeds = [&whitelist.uuid], - bump = whitelist.bump, - realloc = WHITELIST_SIZE, - realloc::payer = cosigner, - realloc::zero = true - )] - pub whitelist: Box>, - - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[account( - seeds = [], - bump = whitelist_authority.bump, - has_one = cosigner, - )] - pub whitelist_authority: Box>, - - #[account(mut)] - pub cosigner: Signer<'info>, - pub system_program: Program<'info, System>, -} - -impl<'info> Validate<'info> for ReallocWhitelist<'info> { - fn validate(&self) -> Result<()> { - //can only migrate those with old version, intentionally keeping hardcorded to avoid errors - if self.whitelist.version != 1 { - throw_err!(ErrorCode::BadWhitelist); - } - Ok(()) - } -} - -//incr space on whitelist -#[access_control(ctx.accounts.validate())] -pub fn process_realloc_whitelist(ctx: Context) -> Result<()> { - let whitelist = &mut ctx.accounts.whitelist; - whitelist.version = CURRENT_WHITELIST_VERSION; - - Ok(()) -} diff --git a/program/src/instructions/unfreeze_whitelist.rs b/program/src/instructions/unfreeze_whitelist.rs deleted file mode 100644 index 11089a92..00000000 --- a/program/src/instructions/unfreeze_whitelist.rs +++ /dev/null @@ -1,35 +0,0 @@ -use anchor_lang::prelude::*; - -use crate::state::{Authority, Whitelist}; - -#[derive(Accounts)] -pub struct UnfreezeWhitelist<'info> { - #[account( - mut, - seeds = [&whitelist.uuid], - bump = whitelist.bump - )] - pub whitelist: Box>, - - /// there can only be 1 whitelist authority (due to seeds), - /// and we're checking that 1)the correct cosigner is present on it, and 2)is a signer - #[account( - seeds = [], - bump = whitelist_authority.bump, - has_one = owner - )] - pub whitelist_authority: Box>, - - /// unfreezing requires owner - #[account(mut)] - pub owner: Signer<'info>, - pub system_program: Program<'info, System>, -} - -//separate ix coz requires different signer -pub fn process_unfreeze_whitelist(ctx: Context) -> Result<()> { - let whitelist = &mut ctx.accounts.whitelist; - whitelist.frozen = false; - - Ok(()) -} diff --git a/program/src/lib.rs b/program/src/lib.rs index cd09134c..fa912420 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -33,11 +33,6 @@ pub mod whitelist_program { use super::*; - /// Freeze a whitelist so that an extra signature is required to update it. - pub fn freeze_whitelist(ctx: Context) -> Result<()> { - instructions::process_freeze_whitelist(ctx) - } - /// Initialize or update the whitelist singleton authority. pub fn init_update_authority( ctx: Context, @@ -47,41 +42,11 @@ pub mod whitelist_program { instructions::process_init_update_authority(ctx, new_cosigner, new_owner) } - /// Initialize or update a mint proof. - pub fn init_update_mint_proof( - ctx: Context, - proof: Vec<[u8; 32]>, - ) -> Result<()> { - instructions::process_init_update_mint_proof(ctx, proof) - } - - /// Initialize or update a whitelist. - pub fn init_update_whitelist( - ctx: Context, - uuid: [u8; 32], - root_hash: Option<[u8; 32]>, - name: Option<[u8; 32]>, - voc: Option, - fvc: Option, - ) -> Result<()> { - instructions::process_init_update_whitelist(ctx, uuid, root_hash, name, voc, fvc) - } - /// Reallocate space on the whitelist authority singleton. pub fn realloc_authority(ctx: Context) -> Result<()> { instructions::process_realloc_authority(ctx) } - /// Reallocate space on the whitelist. - pub fn realloc_whitelist(ctx: Context) -> Result<()> { - instructions::process_realloc_whitelist(ctx) - } - - /// Unfreeze a whitelist so that only one signature is required to update it. - pub fn unfreeze_whitelist(ctx: Context) -> Result<()> { - instructions::process_unfreeze_whitelist(ctx) - } - /* ------Whitelist V2------ */ /// Create a new whitelist V2. From 9e36495b9c6370b588c431561d3c6afda12ddb15 Mon Sep 17 00:00:00 2001 From: leantOnSol Date: Mon, 23 Jun 2025 17:20:52 +0200 Subject: [PATCH 2/5] rm wlv1+mpv1 from rendering in clients --- clients/js/src/generated/accounts/index.ts | 2 - .../js/src/generated/accounts/mintProof.ts | 164 -------------- .../js/src/generated/accounts/whitelist.ts | 200 ------------------ clients/js/src/generated/pdas/index.ts | 2 - clients/js/src/generated/pdas/mintProof.ts | 39 ---- clients/js/src/generated/pdas/whitelist.ts | 34 --- .../src/generated/programs/tensorWhitelist.ts | 24 --- clients/js/src/helpers.ts | 10 - .../rust/src/generated/accounts/mint_proof.rs | 96 --------- clients/rust/src/generated/accounts/mod.rs | 4 - .../rust/src/generated/accounts/whitelist.rs | 89 -------- scripts/generate-clients.mjs | 59 +----- 12 files changed, 8 insertions(+), 715 deletions(-) delete mode 100644 clients/js/src/generated/accounts/mintProof.ts delete mode 100644 clients/js/src/generated/accounts/whitelist.ts delete mode 100644 clients/js/src/generated/pdas/mintProof.ts delete mode 100644 clients/js/src/generated/pdas/whitelist.ts delete mode 100644 clients/rust/src/generated/accounts/mint_proof.rs delete mode 100644 clients/rust/src/generated/accounts/whitelist.rs diff --git a/clients/js/src/generated/accounts/index.ts b/clients/js/src/generated/accounts/index.ts index 87ef6111..88bdb356 100644 --- a/clients/js/src/generated/accounts/index.ts +++ b/clients/js/src/generated/accounts/index.ts @@ -7,7 +7,5 @@ */ export * from './authority'; -export * from './mintProof'; export * from './mintProofV2'; -export * from './whitelist'; export * from './whitelistV2'; diff --git a/clients/js/src/generated/accounts/mintProof.ts b/clients/js/src/generated/accounts/mintProof.ts deleted file mode 100644 index cbd2df19..00000000 --- a/clients/js/src/generated/accounts/mintProof.ts +++ /dev/null @@ -1,164 +0,0 @@ -/** - * This code was AUTOGENERATED using the codama library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun codama to update it. - * - * @see https://github.com/codama-idl/codama - */ - -import { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getArrayDecoder, - getArrayEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/web3.js'; -import { MintProofSeeds, findMintProofPda } from '../pdas'; - -export const MINT_PROOF_DISCRIMINATOR = new Uint8Array([ - 227, 131, 106, 240, 190, 48, 219, 228, -]); - -export function getMintProofDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(MINT_PROOF_DISCRIMINATOR); -} - -export type MintProof = { - discriminator: ReadonlyUint8Array; - proofLen: number; - proof: Array; -}; - -export type MintProofArgs = { - proofLen: number; - proof: Array; -}; - -export function getMintProofEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['proofLen', getU8Encoder()], - [ - 'proof', - getArrayEncoder(fixEncoderSize(getBytesEncoder(), 32), { size: 28 }), - ], - ]), - (value) => ({ ...value, discriminator: MINT_PROOF_DISCRIMINATOR }) - ); -} - -export function getMintProofDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['proofLen', getU8Decoder()], - [ - 'proof', - getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32), { size: 28 }), - ], - ]); -} - -export function getMintProofCodec(): Codec { - return combineCodec(getMintProofEncoder(), getMintProofDecoder()); -} - -export function decodeMintProof( - encodedAccount: EncodedAccount -): Account; -export function decodeMintProof( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeMintProof( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getMintProofDecoder() - ); -} - -export async function fetchMintProof( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeMintProof(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeMintProof( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeMintProof(maybeAccount); -} - -export async function fetchAllMintProof( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeMintProof(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeMintProof( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeMintProof(maybeAccount)); -} - -export function getMintProofSize(): number { - return 28; -} - -export async function fetchMintProofFromSeeds( - rpc: Parameters[0], - seeds: MintProofSeeds, - config: FetchAccountConfig & { programAddress?: Address } = {} -): Promise> { - const maybeAccount = await fetchMaybeMintProofFromSeeds(rpc, seeds, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeMintProofFromSeeds( - rpc: Parameters[0], - seeds: MintProofSeeds, - config: FetchAccountConfig & { programAddress?: Address } = {} -): Promise> { - const { programAddress, ...fetchConfig } = config; - const [address] = await findMintProofPda(seeds, { programAddress }); - return await fetchMaybeMintProof(rpc, address, fetchConfig); -} diff --git a/clients/js/src/generated/accounts/whitelist.ts b/clients/js/src/generated/accounts/whitelist.ts deleted file mode 100644 index 91ff505d..00000000 --- a/clients/js/src/generated/accounts/whitelist.ts +++ /dev/null @@ -1,200 +0,0 @@ -/** - * This code was AUTOGENERATED using the codama library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun codama to update it. - * - * @see https://github.com/codama-idl/codama - */ - -import { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBooleanDecoder, - getBooleanEncoder, - getBytesDecoder, - getBytesEncoder, - getOptionDecoder, - getOptionEncoder, - getStructDecoder, - getStructEncoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type Option, - type OptionOrNullable, - type ReadonlyUint8Array, -} from '@solana/web3.js'; -import { WhitelistSeeds, findWhitelistPda } from '../pdas'; - -export const WHITELIST_DISCRIMINATOR = new Uint8Array([ - 204, 176, 52, 79, 146, 121, 54, 247, -]); - -export function getWhitelistDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(WHITELIST_DISCRIMINATOR); -} - -export type Whitelist = { - discriminator: ReadonlyUint8Array; - version: number; - bump: number; - /** DEPRECATED, doesn't do anything */ - verified: boolean; - /** in the case when not present will be [u8; 32] */ - rootHash: ReadonlyUint8Array; - uuid: ReadonlyUint8Array; - name: ReadonlyUint8Array; - frozen: boolean; - voc: Option
; - fvc: Option
; - reserved: ReadonlyUint8Array; -}; - -export type WhitelistArgs = { - version: number; - bump: number; - /** DEPRECATED, doesn't do anything */ - verified: boolean; - /** in the case when not present will be [u8; 32] */ - rootHash: ReadonlyUint8Array; - uuid: ReadonlyUint8Array; - name: ReadonlyUint8Array; - frozen: boolean; - voc: OptionOrNullable
; - fvc: OptionOrNullable
; - reserved: ReadonlyUint8Array; -}; - -export function getWhitelistEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['version', getU8Encoder()], - ['bump', getU8Encoder()], - ['verified', getBooleanEncoder()], - ['rootHash', fixEncoderSize(getBytesEncoder(), 32)], - ['uuid', fixEncoderSize(getBytesEncoder(), 32)], - ['name', fixEncoderSize(getBytesEncoder(), 32)], - ['frozen', getBooleanEncoder()], - ['voc', getOptionEncoder(getAddressEncoder())], - ['fvc', getOptionEncoder(getAddressEncoder())], - ['reserved', fixEncoderSize(getBytesEncoder(), 64)], - ]), - (value) => ({ ...value, discriminator: WHITELIST_DISCRIMINATOR }) - ); -} - -export function getWhitelistDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['version', getU8Decoder()], - ['bump', getU8Decoder()], - ['verified', getBooleanDecoder()], - ['rootHash', fixDecoderSize(getBytesDecoder(), 32)], - ['uuid', fixDecoderSize(getBytesDecoder(), 32)], - ['name', fixDecoderSize(getBytesDecoder(), 32)], - ['frozen', getBooleanDecoder()], - ['voc', getOptionDecoder(getAddressDecoder())], - ['fvc', getOptionDecoder(getAddressDecoder())], - ['reserved', fixDecoderSize(getBytesDecoder(), 64)], - ]); -} - -export function getWhitelistCodec(): Codec { - return combineCodec(getWhitelistEncoder(), getWhitelistDecoder()); -} - -export function decodeWhitelist( - encodedAccount: EncodedAccount -): Account; -export function decodeWhitelist( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeWhitelist( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getWhitelistDecoder() - ); -} - -export async function fetchWhitelist( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeWhitelist(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeWhitelist( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeWhitelist(maybeAccount); -} - -export async function fetchAllWhitelist( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeWhitelist(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeWhitelist( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeWhitelist(maybeAccount)); -} - -export function getWhitelistSize(): number { - return 238; -} - -export async function fetchWhitelistFromSeeds( - rpc: Parameters[0], - seeds: WhitelistSeeds, - config: FetchAccountConfig & { programAddress?: Address } = {} -): Promise> { - const maybeAccount = await fetchMaybeWhitelistFromSeeds(rpc, seeds, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeWhitelistFromSeeds( - rpc: Parameters[0], - seeds: WhitelistSeeds, - config: FetchAccountConfig & { programAddress?: Address } = {} -): Promise> { - const { programAddress, ...fetchConfig } = config; - const [address] = await findWhitelistPda(seeds, { programAddress }); - return await fetchMaybeWhitelist(rpc, address, fetchConfig); -} diff --git a/clients/js/src/generated/pdas/index.ts b/clients/js/src/generated/pdas/index.ts index 87ef6111..88bdb356 100644 --- a/clients/js/src/generated/pdas/index.ts +++ b/clients/js/src/generated/pdas/index.ts @@ -7,7 +7,5 @@ */ export * from './authority'; -export * from './mintProof'; export * from './mintProofV2'; -export * from './whitelist'; export * from './whitelistV2'; diff --git a/clients/js/src/generated/pdas/mintProof.ts b/clients/js/src/generated/pdas/mintProof.ts deleted file mode 100644 index 0c48b66a..00000000 --- a/clients/js/src/generated/pdas/mintProof.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This code was AUTOGENERATED using the codama library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun codama to update it. - * - * @see https://github.com/codama-idl/codama - */ - -import { - getAddressEncoder, - getProgramDerivedAddress, - getUtf8Encoder, - type Address, - type ProgramDerivedAddress, -} from '@solana/web3.js'; - -export type MintProofSeeds = { - /** The address of the mint account */ - mint: Address; - /** The address of the whitelist pda */ - whitelist: Address; -}; - -export async function findMintProofPda( - seeds: MintProofSeeds, - config: { programAddress?: Address | undefined } = {} -): Promise { - const { - programAddress = 'TL1ST2iRBzuGTqLn1KXnGdSnEow62BzPnGiqyRXhWtW' as Address<'TL1ST2iRBzuGTqLn1KXnGdSnEow62BzPnGiqyRXhWtW'>, - } = config; - return await getProgramDerivedAddress({ - programAddress, - seeds: [ - getUtf8Encoder().encode('mint_proof'), - getAddressEncoder().encode(seeds.mint), - getAddressEncoder().encode(seeds.whitelist), - ], - }); -} diff --git a/clients/js/src/generated/pdas/whitelist.ts b/clients/js/src/generated/pdas/whitelist.ts deleted file mode 100644 index e5681825..00000000 --- a/clients/js/src/generated/pdas/whitelist.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This code was AUTOGENERATED using the codama library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun codama to update it. - * - * @see https://github.com/codama-idl/codama - */ - -import { - fixEncoderSize, - getBytesEncoder, - getProgramDerivedAddress, - type Address, - type ProgramDerivedAddress, - type ReadonlyUint8Array, -} from '@solana/web3.js'; - -export type WhitelistSeeds = { - /** UUID of the whitelist */ - uuid: ReadonlyUint8Array; -}; - -export async function findWhitelistPda( - seeds: WhitelistSeeds, - config: { programAddress?: Address | undefined } = {} -): Promise { - const { - programAddress = 'TL1ST2iRBzuGTqLn1KXnGdSnEow62BzPnGiqyRXhWtW' as Address<'TL1ST2iRBzuGTqLn1KXnGdSnEow62BzPnGiqyRXhWtW'>, - } = config; - return await getProgramDerivedAddress({ - programAddress, - seeds: [fixEncoderSize(getBytesEncoder(), 32).encode(seeds.uuid)], - }); -} diff --git a/clients/js/src/generated/programs/tensorWhitelist.ts b/clients/js/src/generated/programs/tensorWhitelist.ts index a6824a4c..a8055018 100644 --- a/clients/js/src/generated/programs/tensorWhitelist.ts +++ b/clients/js/src/generated/programs/tensorWhitelist.ts @@ -31,9 +31,7 @@ export const TENSOR_WHITELIST_PROGRAM_ADDRESS = export enum TensorWhitelistAccount { Authority, MintProofV2, - MintProof, WhitelistV2, - Whitelist, } export function identifyTensorWhitelistAccount( @@ -62,17 +60,6 @@ export function identifyTensorWhitelistAccount( ) { return TensorWhitelistAccount.MintProofV2; } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([227, 131, 106, 240, 190, 48, 219, 228]) - ), - 0 - ) - ) { - return TensorWhitelistAccount.MintProof; - } if ( containsBytes( data, @@ -84,17 +71,6 @@ export function identifyTensorWhitelistAccount( ) { return TensorWhitelistAccount.WhitelistV2; } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([204, 176, 52, 79, 146, 121, 54, 247]) - ), - 0 - ) - ) { - return TensorWhitelistAccount.Whitelist; - } throw new Error( 'The provided account could not be identified as a tensorWhitelist account.' ); diff --git a/clients/js/src/helpers.ts b/clients/js/src/helpers.ts index 610ed2dc..04f02ea0 100644 --- a/clients/js/src/helpers.ts +++ b/clients/js/src/helpers.ts @@ -4,7 +4,6 @@ import { getAddressDecoder, getAddressEncoder, } from '@solana/web3.js'; -import { WhitelistSeeds, findWhitelistPda } from './generated'; export type NumberData = number[] | Uint8Array | Buffer; @@ -29,12 +28,3 @@ export const bufferToCollId = (buffer: number[]) => { 16 )}-${raw.slice(16, 20)}-${raw.slice(20)}`; }; - -export async function getWhitelistFromCollId(collId: string): Promise
{ - const uuid = collIdToBuffer(collId); - const whitelistSeeds: WhitelistSeeds = { - uuid: uuid, - }; - const [whitelistPda] = await findWhitelistPda(whitelistSeeds); - return whitelistPda; -} diff --git a/clients/rust/src/generated/accounts/mint_proof.rs b/clients/rust/src/generated/accounts/mint_proof.rs deleted file mode 100644 index afb77226..00000000 --- a/clients/rust/src/generated/accounts/mint_proof.rs +++ /dev/null @@ -1,96 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::BorshDeserialize; -use borsh::BorshSerialize; -use solana_program::pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MintProof { - pub discriminator: [u8; 8], - pub proof_len: u8, - pub proof: [[u8; 32]; 28], -} - -impl MintProof { - pub const LEN: usize = 28; - - /// Prefix values used to generate a PDA for this account. - /// - /// Values are positional and appear in the following order: - /// - /// 0. `MintProof::PREFIX` - /// 1. mint (`Pubkey`) - /// 2. whitelist (`Pubkey`) - pub const PREFIX: &'static [u8] = "mint_proof".as_bytes(); - - pub fn create_pda( - mint: Pubkey, - whitelist: Pubkey, - bump: u8, - ) -> Result { - solana_program::pubkey::Pubkey::create_program_address( - &[ - "mint_proof".as_bytes(), - mint.as_ref(), - whitelist.as_ref(), - &[bump], - ], - &crate::TENSOR_WHITELIST_ID, - ) - } - - pub fn find_pda(mint: &Pubkey, whitelist: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { - solana_program::pubkey::Pubkey::find_program_address( - &["mint_proof".as_bytes(), mint.as_ref(), whitelist.as_ref()], - &crate::TENSOR_WHITELIST_ID, - ) - } - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for MintProof { - type Error = std::io::Error; - - fn try_from( - account_info: &solana_program::account_info::AccountInfo<'a>, - ) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for MintProof { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for MintProof {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for MintProof { - fn owner() -> Pubkey { - crate::TENSOR_WHITELIST_ID - } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for MintProof {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for MintProof { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/clients/rust/src/generated/accounts/mod.rs b/clients/rust/src/generated/accounts/mod.rs index ee975bc0..b4979fc9 100644 --- a/clients/rust/src/generated/accounts/mod.rs +++ b/clients/rust/src/generated/accounts/mod.rs @@ -6,13 +6,9 @@ //! pub(crate) mod r#authority; -pub(crate) mod r#mint_proof; pub(crate) mod r#mint_proof_v2; -pub(crate) mod r#whitelist; pub(crate) mod r#whitelist_v2; pub use self::r#authority::*; -pub use self::r#mint_proof::*; pub use self::r#mint_proof_v2::*; -pub use self::r#whitelist::*; pub use self::r#whitelist_v2::*; diff --git a/clients/rust/src/generated/accounts/whitelist.rs b/clients/rust/src/generated/accounts/whitelist.rs deleted file mode 100644 index b5ce6909..00000000 --- a/clients/rust/src/generated/accounts/whitelist.rs +++ /dev/null @@ -1,89 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::BorshDeserialize; -use borsh::BorshSerialize; -use solana_program::pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Whitelist { - pub discriminator: [u8; 8], - pub version: u8, - pub bump: u8, - /// DEPRECATED, doesn't do anything - pub verified: bool, - /// in the case when not present will be [u8; 32] - pub root_hash: [u8; 32], - pub uuid: [u8; 32], - pub name: [u8; 32], - pub frozen: bool, - pub voc: Option, - pub fvc: Option, - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub reserved: [u8; 64], -} - -impl Whitelist { - pub const LEN: usize = 238; - - pub fn create_pda( - uuid: [u8; 32], - bump: u8, - ) -> Result { - solana_program::pubkey::Pubkey::create_program_address( - &[&uuid, &[bump]], - &crate::TENSOR_WHITELIST_ID, - ) - } - - pub fn find_pda(uuid: [u8; 32]) -> (solana_program::pubkey::Pubkey, u8) { - solana_program::pubkey::Pubkey::find_program_address(&[&uuid], &crate::TENSOR_WHITELIST_ID) - } - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Whitelist { - type Error = std::io::Error; - - fn try_from( - account_info: &solana_program::account_info::AccountInfo<'a>, - ) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Whitelist { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Whitelist {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Whitelist { - fn owner() -> Pubkey { - crate::TENSOR_WHITELIST_ID - } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Whitelist {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Whitelist { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/scripts/generate-clients.mjs b/scripts/generate-clients.mjs index c3b2c9ed..aea1d38e 100644 --- a/scripts/generate-clients.mjs +++ b/scripts/generate-clients.mjs @@ -21,25 +21,17 @@ codama.update( }), ); +// rm mintProofV1 / whitelistV1 accounts from rendering +codama.update( + c.deleteNodesVisitor([ + "[accountNode]mintProof", + "[accountNode]whitelist", + ]), +); + // Update accounts. codama.update( c.updateAccountsVisitor({ - mintProof: { - size: 28, - seeds: [ - c.constantPdaSeedNodeFromString("utf8", "mint_proof"), - c.variablePdaSeedNode( - "mint", - c.publicKeyTypeNode(), - "The address of the mint account", - ), - c.variablePdaSeedNode( - "whitelist", - c.publicKeyTypeNode(), - "The address of the whitelist pda", - ), - ], - }, mintProofV2: { size: 945, seeds: [ @@ -56,16 +48,6 @@ codama.update( ), ], }, - whitelist: { - size: 238, - seeds: [ - c.variablePdaSeedNode( - "uuid", - c.fixedSizeTypeNode(c.bytesTypeNode(), 32), - "UUID of the whitelist", - ), - ], - }, whitelistV2: { size: 239, seeds: [ @@ -117,31 +99,6 @@ codama.update( ]), ); -// Override whitelist default resolvers to V1 for V1 ixs. -codama.update( - c.updateInstructionsVisitor({ - initUpdateWhitelist: { - accounts: { - whitelist: { - defaultValue: c.pdaValueNode("whitelist", [ - c.pdaSeedValueNode("uuid", c.argumentValueNode("uuid")), - ]), - }, - }, - }, - initUpdateMintProof: { - accounts: { - mintProof: { - defaultValue: c.pdaValueNode("mintProof", [ - c.pdaSeedValueNode("mint", c.accountValueNode("mint")), - c.pdaSeedValueNode("whitelist", c.accountValueNode("whitelist")), - ]), - }, - }, - }, - }), -); - // Debug print the tree. // codama.accept(c.consoleLogVisitor(c.getDebugStringVisitor({ indent: true }))); From 0b86ae5ad3b34cb506d7d4e5920e67fc66bab555 Mon Sep 17 00:00:00 2001 From: leantOnSol Date: Mon, 23 Jun 2025 17:23:52 +0200 Subject: [PATCH 3/5] fix CI + adjust CODEOWNERS --- .github/CODEOWNERS | 2 +- .github/workflows/build-programs.yml | 2 +- .github/workflows/build-rust-client.yml | 2 +- .github/workflows/main.yml | 2 +- .github/workflows/publish-js-client.yml | 74 ++++--------------------- .github/workflows/test-js-anchor.yml | 2 +- .github/workflows/test-js-client.yml | 2 +- .github/workflows/test-programs.yml | 2 +- .github/workflows/test-rust-client.yml | 2 +- 9 files changed, 19 insertions(+), 71 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 41fd1ea0..2ca7f310 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @richardwu @samuelvanderwaal +* @richardwu @nftechie @leantOnSol diff --git a/.github/workflows/build-programs.yml b/.github/workflows/build-programs.yml index 2f1ece59..4b1b6602 100644 --- a/.github/workflows/build-programs.yml +++ b/.github/workflows/build-programs.yml @@ -54,7 +54,7 @@ jobs: toolchain: ${{ inputs.rust || env.RUST_VERSION }} - name: Install Solana - uses: tensor-foundation/actions/install-solana@v2 + uses: tensor-foundation/actions/install-solana@v3 with: version: ${{ inputs.solana || env.SOLANA_VERSION }} cache: ${{ env.CACHE }} diff --git a/.github/workflows/build-rust-client.yml b/.github/workflows/build-rust-client.yml index d0f9b1ae..21e36047 100644 --- a/.github/workflows/build-rust-client.yml +++ b/.github/workflows/build-rust-client.yml @@ -46,7 +46,7 @@ jobs: toolchain: ${{ inputs.rust || env.RUST_VERSION }} - name: Install Solana - uses: tensor-foundation/actions/install-solana@v2 + uses: tensor-foundation/actions/install-solana@v3 with: version: ${{ inputs.solana || env.SOLANA_VERSION }} cache: ${{ env.CACHE }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a9b97dc9..a734cb91 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -171,7 +171,7 @@ jobs: toolchain: ${{ env.RUST_VERSION }} - name: Install Solana - uses: tensor-foundation/actions/install-solana@v2 + uses: tensor-foundation/actions/install-solana@v3 with: version: ${{ env.SOLANA_VERSION }} cache: ${{ env.CACHE }} diff --git a/.github/workflows/publish-js-client.yml b/.github/workflows/publish-js-client.yml index 3003de52..e647358c 100644 --- a/.github/workflows/publish-js-client.yml +++ b/.github/workflows/publish-js-client.yml @@ -3,26 +3,13 @@ name: Publish JS Client on: workflow_dispatch: inputs: - bump: - description: Version bump - required: true - default: patch - type: choice - options: - - patch - - minor - - major - - prerelease - - prepatch - - preminor - - premajor tag: - description: NPM Tag (and preid for pre-releases) + description: NPM Tag required: true type: string default: latest - create_release: - description: Create a GitHub release + dry_run: + description: Dry run required: true type: boolean default: true @@ -33,17 +20,20 @@ env: jobs: build_programs: name: Programs + if: github.ref == 'refs/heads/main' || inputs.dry_run == true uses: ./.github/workflows/build-programs.yml secrets: inherit test_js: name: JS client + if: github.ref == 'refs/heads/main' || inputs.dry_run == true needs: build_programs uses: ./.github/workflows/test-js-client.yml secrets: inherit publish_js: name: JS client / Publish + if: github.ref == 'refs/heads/main' || inputs.dry_run == true runs-on: ubuntu-latest needs: test_js permissions: @@ -71,17 +61,11 @@ jobs: - name: Build working-directory: ./clients/js run: pnpm build - - - name: Bump - id: bump + + - name: Get version + id: get_version working-directory: ./clients/js - run: | - if [ "${{ startsWith(inputs.bump, 'pre') }}" == "true" ]; then - pnpm version ${{ inputs.bump }} --preid ${{ inputs.tag }} --no-git-tag-version - else - pnpm version ${{ inputs.bump }} --no-git-tag-version - fi - echo "new_version=$(pnpm pkg get version | sed 's/"//g')" >> $GITHUB_OUTPUT + run: echo "version=$(pnpm pkg get version | sed 's/"//g')" >> $GITHUB_OUTPUT - name: Set publishing config run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}" @@ -90,40 +74,4 @@ jobs: - name: Publish working-directory: ./clients/js - run: pnpm publish --no-git-checks --tag ${{ inputs.tag }} - - - name: Commit and tag new version - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Deploy JS client v${{ steps.bump.outputs.new_version }} - tagging_message: js@v${{ steps.bump.outputs.new_version }} - - - name: Create GitHub release - if: github.event.inputs.create_release == 'true' - uses: ncipollo/release-action@v1 - with: - tag: js@v${{ steps.bump.outputs.new_version }} - - deploy_js_docs: - name: JS client / Deploy docs - runs-on: ubuntu-latest - needs: publish_js - environment: - name: js-client-documentation - url: ${{ steps.deploy.outputs.url }} - steps: - - name: Git checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.ref }} - - - name: Load environment variables - run: cat .github/.env >> $GITHUB_ENV - - - name: Deploy to Vercel - id: deploy - env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - working-directory: ./clients/js - run: echo "url=$(vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }})" | tee $GITHUB_OUTPUT + run: pnpm publish --no-git-checks --tag ${{ inputs.tag }} ${{ inputs.dry_run && '--dry-run' || '' }} \ No newline at end of file diff --git a/.github/workflows/test-js-anchor.yml b/.github/workflows/test-js-anchor.yml index 9aac8a63..b4c367fa 100644 --- a/.github/workflows/test-js-anchor.yml +++ b/.github/workflows/test-js-anchor.yml @@ -26,7 +26,7 @@ jobs: run: cat .github/.env >> $GITHUB_ENV - name: Start validator - uses: tensor-foundation/actions/start-validator@v2 + uses: tensor-foundation/actions/start-validator@v3 with: node: "18.x" solana: ${{ env.SOLANA_VERSION }} diff --git a/.github/workflows/test-js-client.yml b/.github/workflows/test-js-client.yml index 08bed452..9bd5cdd4 100644 --- a/.github/workflows/test-js-client.yml +++ b/.github/workflows/test-js-client.yml @@ -20,7 +20,7 @@ jobs: run: cat .github/.env >> $GITHUB_ENV - name: Start validator - uses: tensor-foundation/actions/start-validator@v2 + uses: tensor-foundation/actions/start-validator@v3 with: node: ${{ matrix.node }} solana: ${{ env.SOLANA_VERSION }} diff --git a/.github/workflows/test-programs.yml b/.github/workflows/test-programs.yml index 9668bcd3..8fdd2cf1 100644 --- a/.github/workflows/test-programs.yml +++ b/.github/workflows/test-programs.yml @@ -36,7 +36,7 @@ jobs: toolchain: ${{ env.RUST_VERSION }} - name: Install Solana - uses: tensor-foundation/actions/install-solana@v2 + uses: tensor-foundation/actions/install-solana@v3 with: version: ${{ env.SOLANA_VERSION }} cache: ${{ env.CACHE }} diff --git a/.github/workflows/test-rust-client.yml b/.github/workflows/test-rust-client.yml index 0fa7a0b0..e022de5a 100644 --- a/.github/workflows/test-rust-client.yml +++ b/.github/workflows/test-rust-client.yml @@ -28,7 +28,7 @@ jobs: toolchain: ${{ env.RUST_VERSION }} - name: Install Solana - uses: tensor-foundation/actions/install-solana@v2 + uses: tensor-foundation/actions/install-solana@v3 with: version: ${{ env.SOLANA_VERSION }} cache: ${{ env.CACHE }} From dc3067acef31d5298a4a28e0afefb2cf13ba4645 Mon Sep 17 00:00:00 2001 From: leantOnSol Date: Mon, 23 Jun 2025 17:52:58 +0200 Subject: [PATCH 4/5] rm wlv1 anchor tests --- .../anchor/tests/twhitelist/whitelist.test.ts | 288 ------------------ 1 file changed, 288 deletions(-) diff --git a/clients/anchor/tests/twhitelist/whitelist.test.ts b/clients/anchor/tests/twhitelist/whitelist.test.ts index d2a0c777..960e7852 100644 --- a/clients/anchor/tests/twhitelist/whitelist.test.ts +++ b/clients/anchor/tests/twhitelist/whitelist.test.ts @@ -1,10 +1,8 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import chai, { expect } from "chai"; import chaiAsPromised from "chai-as-promised"; -import { TensorWhitelistSDK } from "../../src"; import { buildAndSendTx, - generateTreeOfSize, testInitWLAuthority, TEST_PROVIDER, waitMS, @@ -98,290 +96,4 @@ describe("tensor whitelist", () => { expect(authAcc.owner.toBase58()).to.eq(tlistOwner.publicKey.toBase58()); }); - // ---------------------------- Whitelist - - it("inits/updates whitelist", async () => { - // --------------------------------------- bad inits - - const uuid = wlSdk.genWhitelistUUID(); - const uuidBuffer = TensorWhitelistSDK.uuidToBuffer(uuid); - const name = "hello_world"; - const nameBuffer = TensorWhitelistSDK.nameToBuffer(name); - expect(uuidBuffer.length).to.eq(32); - expect(nameBuffer.length).to.eq(32); - const { root } = generateTreeOfSize(100, [Keypair.generate().publicKey]); - - //all 3 methods missing - const { - tx: { ixs: initWlBad }, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - }); - await expect(buildAndSendTx({ ixs: initWlBad })).to.be.rejectedWith( - "0x1771" - ); - - //name missing - const { - tx: { ixs: initWlBad2 }, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - rootHash: root, - }); - await expect(buildAndSendTx({ ixs: initWlBad2 })).to.be.rejectedWith( - "0x1772" - ); - - // --------------------------------------- merkle proof - - //init ok - const { - tx: { ixs: initWlGood }, - whitelistPda, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - rootHash: root, - name: nameBuffer, - }); - await buildAndSendTx({ ixs: initWlGood }); - - let wlAcc = await wlSdk.fetchWhitelist(whitelistPda); - expect(TensorWhitelistSDK.bufferToUuid(wlAcc.uuid)).to.eq(uuid); - expect(TensorWhitelistSDK.bufferToName(wlAcc.name)).to.eq(name); - expect(wlAcc.rootHash).to.deep.eq(root); - expect(wlAcc.voc).to.be.null; - expect(wlAcc.fvc).to.be.null; - - //update ok - const uuid2 = wlSdk.genWhitelistUUID(); - const name2 = "hello_world2222"; - const { root: root2 } = generateTreeOfSize(100, [ - Keypair.generate().publicKey, - ]); - - const { - tx: { ixs: initWlGood2 }, - whitelistPda: whitelistPda2, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: TensorWhitelistSDK.uuidToBuffer(uuid2), - rootHash: root2, - name: TensorWhitelistSDK.nameToBuffer(name2), - }); - await buildAndSendTx({ ixs: initWlGood2 }); - - wlAcc = await wlSdk.fetchWhitelist(whitelistPda2); - expect(TensorWhitelistSDK.bufferToUuid(wlAcc.uuid)).to.eq(uuid2); - expect(TensorWhitelistSDK.bufferToName(wlAcc.name)).to.eq(name2); - expect(wlAcc.rootHash).to.deep.eq(root2); - expect(wlAcc.voc).to.be.null; - expect(wlAcc.fvc).to.be.null; - - // --------------------------------------- voc - - const randomKey = Keypair.generate().publicKey; - - const { - tx: { ixs: initWlGood3 }, - whitelistPda: whitelistPda3, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - name: nameBuffer, - voc: randomKey, - }); - await buildAndSendTx({ ixs: initWlGood3 }); - - wlAcc = await wlSdk.fetchWhitelist(whitelistPda3); - expect(wlAcc.voc?.toBase58()).to.eq(randomKey.toBase58()); - expect(wlAcc.fvc).to.be.null; - - // --------------------------------------- fvc - - const { - tx: { ixs: initWlGood4 }, - whitelistPda: whitelistPda4, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - name: nameBuffer, - fvc: randomKey, - }); - await buildAndSendTx({ ixs: initWlGood4 }); - - wlAcc = await wlSdk.fetchWhitelist(whitelistPda4); - expect(wlAcc.voc).to.be.null; - expect(wlAcc.fvc?.toBase58()).to.eq(randomKey.toBase58()); - }); - - it("freezes/unfreezes/handles frozen whitelist", async () => { - const uuid = wlSdk.genWhitelistUUID(); - const uuidBuffer = TensorWhitelistSDK.uuidToBuffer(uuid); - const name = "hello_world"; - const nameBuffer = TensorWhitelistSDK.nameToBuffer(name); - expect(uuidBuffer.length).to.eq(32); - expect(nameBuffer.length).to.eq(32); - const { root } = generateTreeOfSize(100, [Keypair.generate().publicKey]); - const { root: root2 } = generateTreeOfSize(100, [ - Keypair.generate().publicKey, - ]); - const { root: root3 } = generateTreeOfSize(100, [ - Keypair.generate().publicKey, - ]); - - //create wl - const { - tx: { ixs: initWlGood }, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - rootHash: root, - name: nameBuffer, - }); - await buildAndSendTx({ ixs: initWlGood }); - - //freeze it - const { - tx: { ixs: freezeWlIxs }, - whitelistPda, - } = await wlSdk.freezeWhitelist({ - uuid: uuidBuffer, - cosigner: TEST_PROVIDER.publicKey, - }); - await buildAndSendTx({ ixs: freezeWlIxs, extraSigners: [] }); - let wlAcc = await wlSdk.fetchWhitelist(whitelistPda); - expect(wlAcc.frozen).to.be.true; - - //try to update a frozen WL w/o freeze auth sig (should fail) - const { - tx: { ixs: updateWlBadIxs }, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - rootHash: root2, - }); - await expect(buildAndSendTx({ ixs: updateWlBadIxs })).to.be.rejectedWith( - "0x1775" - ); - wlAcc = await wlSdk.fetchWhitelist(whitelistPda); - expect(wlAcc.rootHash).to.deep.eq(root); - - //try to update a frozen WL w/ wrong freeze auth (should fail) - const badOwner = Keypair.generate(); - const { - tx: { ixs: updateWlBadIxs2 }, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - owner: badOwner.publicKey, - uuid: uuidBuffer, - rootHash: root2, - }); - await expect( - buildAndSendTx({ ixs: updateWlBadIxs2, extraSigners: [badOwner] }) - ).to.be.rejectedWith("0x1775"); - wlAcc = await wlSdk.fetchWhitelist(whitelistPda); - expect(wlAcc.rootHash).to.deep.eq(root); - - //update w/ freeze auth (should succeed) - const { - tx: { ixs: updateWlOkIxs }, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - owner: tlistOwner.publicKey, - uuid: uuidBuffer, - rootHash: root2, - }); - await buildAndSendTx({ - ixs: updateWlOkIxs, - extraSigners: [tlistOwner], - }); - wlAcc = await wlSdk.fetchWhitelist(whitelistPda); - expect(wlAcc.rootHash).to.deep.eq(root2); - - //try to unfreeze with wrong authority (should fail) - const { - tx: { ixs: unfreezeWlBadIxs }, - } = await wlSdk.unfreezeWhitelist({ - uuid: uuidBuffer, - owner: badOwner.publicKey, - }); - await expect( - buildAndSendTx({ - ixs: unfreezeWlBadIxs, - extraSigners: [badOwner], - }) - ).to.be.rejectedWith("0x7d1"); - - //unfreeze it - const { - tx: { ixs: unfreezeWlIxs }, - } = await wlSdk.unfreezeWhitelist({ - uuid: uuidBuffer, - owner: tlistOwner.publicKey, - }); - await buildAndSendTx({ - ixs: unfreezeWlIxs, - extraSigners: [tlistOwner], - }); - wlAcc = await wlSdk.fetchWhitelist(whitelistPda); - expect(wlAcc.frozen).to.be.false; - - //update w/o freeze auth (should succeed) - const { - tx: { ixs: updateWlOkIxs2 }, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - rootHash: root3, - }); - await buildAndSendTx({ ixs: updateWlOkIxs2 }); - wlAcc = await wlSdk.fetchWhitelist(whitelistPda); - expect(wlAcc.rootHash).to.deep.eq(root3); - }); - - it("reallocs ok", async () => { - const uuid = wlSdk.genWhitelistUUID(); - const uuidBuffer = TensorWhitelistSDK.uuidToBuffer(uuid); - const name = "hello_world"; - const nameBuffer = TensorWhitelistSDK.nameToBuffer(name); - expect(uuidBuffer.length).to.eq(32); - expect(nameBuffer.length).to.eq(32); - const { root } = generateTreeOfSize(100, [Keypair.generate().publicKey]); - const { root: root2 } = generateTreeOfSize(100, [ - Keypair.generate().publicKey, - ]); - const { root: root3 } = generateTreeOfSize(100, [ - Keypair.generate().publicKey, - ]); - - //create wl - const { - tx: { ixs: initWlGood }, - } = await wlSdk.initUpdateWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: uuidBuffer, - rootHash: root, - name: nameBuffer, - }); - await buildAndSendTx({ ixs: initWlGood }); - - const { - tx: { ixs: reallocAuthIxs }, - } = await wlSdk.reallocAuthority({ cosigner: TEST_PROVIDER.publicKey }); - await buildAndSendTx({ ixs: reallocAuthIxs }); - - const { - tx: { ixs: reallocWlIxs }, - } = await wlSdk.reallocWhitelist({ - cosigner: TEST_PROVIDER.publicKey, - uuid: TensorWhitelistSDK.uuidToBuffer(uuid), - }); - //fails coz new version alerady stored - await expect(buildAndSendTx({ ixs: reallocWlIxs })).to.be.rejectedWith( - wlSdk.getErrorCodeHex("BadWhitelist") - ); - }); }); From afd64fca24fb8eb6e86dfa6746123be362ce8094 Mon Sep 17 00:00:00 2001 From: leantOnSol Date: Thu, 26 Jun 2025 00:07:25 +0200 Subject: [PATCH 5/5] verify builds --- .github/.env | 1 + .github/file-filters.yml | 2 +- ...programs.yml => build-verify-programs.yml} | 32 ++++++++++++++++--- .github/workflows/main.yml | 6 ++-- .github/workflows/publish-js-client.yml | 6 ++-- .github/workflows/publish-rust-client.yml | 6 ++-- package.json | 1 + 7 files changed, 39 insertions(+), 15 deletions(-) rename .github/workflows/{build-programs.yml => build-verify-programs.yml} (65%) diff --git a/.github/.env b/.github/.env index dcdec3ac..0d1c5d56 100644 --- a/.github/.env +++ b/.github/.env @@ -3,3 +3,4 @@ NODE_VERSION=20.x PROGRAMS=["program"] RUST_VERSION=1.75.0 SOLANA_VERSION=1.17.22 +VERIFY_BUILD_VERSION=0.2.11 diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 3b2c66ec..f8f6537f 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -5,7 +5,7 @@ # Programs. program_common: &program_common - - ".github/workflows/build-programs.yml" + - ".github/workflows/build-verify-programs.yml" - ".github/workflows/test-programs.yml" - ".github/workflows/main.yml" - ".github/file-filters.yml" diff --git a/.github/workflows/build-programs.yml b/.github/workflows/build-verify-programs.yml similarity index 65% rename from .github/workflows/build-programs.yml rename to .github/workflows/build-verify-programs.yml index 4b1b6602..fd899e43 100644 --- a/.github/workflows/build-programs.yml +++ b/.github/workflows/build-verify-programs.yml @@ -1,4 +1,4 @@ -name: Build Programs +name: Build Verify Programs on: workflow_call: @@ -26,6 +26,11 @@ on: default: 20.x required: true type: string + verify: + description: Verify build version + default: 0.2.11 + required: true + type: string env: CACHE: true @@ -33,7 +38,7 @@ env: RPC: ${{ secrets.SOLANA_MAINNET_RPC_URL }} jobs: - build_programs: + build_verify_programs: name: Build runs-on: ubuntu-latest steps: @@ -72,15 +77,32 @@ jobs: with: folder: "." key: programs + + - name: Dump mainnet binaries + run: pnpm programs:dump_binaries + + - name: Cache solana-verify + uses: actions/cache@v4 + id: cache-verify + with: + path: /home/runner/.cargo-install/solana-verify + key: solana-verify-${{ inputs.verify || env.VERIFY_BUILD_VERSION }}-${{ runner.os }} + + - name: Install verify build + if: steps.cache-verify.outputs.cache-hit != 'true' + run: cargo install solana-verify --force --root /home/runner/.cargo-install/solana-verify --version ${{ inputs.verify || env.VERIFY_BUILD_VERSION }} --locked - - name: Build programs + - name: Verify build program shell: bash - run: pnpm programs:build + run: | + /home/runner/.cargo-install/solana-verify/bin/solana-verify build --library-name whitelist_program | tee >(tail -n 1 > build_hash.txt) - name: Upload programs build uses: actions/upload-artifact@v4 with: name: programs-build # First wildcard ensures exported paths are consistently under the programs folder. - path: ./targe*/deploy/*.so + path: | + ./targe*/deploy/*.so + build_hash.txt if-no-files-found: error diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a734cb91..0600ce92 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -134,11 +134,11 @@ jobs: command: clippy args: --all-targets --all-features --no-deps -- -D warnings - build_programs: + build_verify_programs: name: Programs if: ${{ needs.changes.outputs.any == 'true' }} needs: [changes, lint_js, lint_rust] - uses: ./.github/workflows/build-programs.yml + uses: ./.github/workflows/build-verify-programs.yml secrets: inherit test_programs: @@ -153,7 +153,7 @@ jobs: generate_clients: name: Generate Clients if: ${{ needs.changes.outputs.any == 'true' }} - needs: [changes, build_programs] + needs: [changes, build_verify_programs] runs-on: ubuntu-latest steps: - name: Git checkout diff --git a/.github/workflows/publish-js-client.yml b/.github/workflows/publish-js-client.yml index e647358c..d7fca658 100644 --- a/.github/workflows/publish-js-client.yml +++ b/.github/workflows/publish-js-client.yml @@ -18,16 +18,16 @@ env: CACHE: true jobs: - build_programs: + build_verify_programs: name: Programs if: github.ref == 'refs/heads/main' || inputs.dry_run == true - uses: ./.github/workflows/build-programs.yml + uses: ./.github/workflows/build-verify-programs.yml secrets: inherit test_js: name: JS client if: github.ref == 'refs/heads/main' || inputs.dry_run == true - needs: build_programs + needs: build_verify_programs uses: ./.github/workflows/test-js-client.yml secrets: inherit diff --git a/.github/workflows/publish-rust-client.yml b/.github/workflows/publish-rust-client.yml index ff678f57..ceee50f1 100644 --- a/.github/workflows/publish-rust-client.yml +++ b/.github/workflows/publish-rust-client.yml @@ -31,9 +31,9 @@ env: CACHE: true jobs: - build_programs: + build_verify_programs: name: Programs - uses: ./.github/workflows/build-programs.yml + uses: ./.github/workflows/build-verify-programs.yml secrets: inherit build_rust_client: @@ -43,7 +43,7 @@ jobs: test_rust_client: name: Rust Client - needs: [build_programs, build_rust_client] + needs: [build_verify_programs, build_rust_client] uses: ./.github/workflows/test-rust-client.yml secrets: inherit diff --git a/package.json b/package.json index ea985bb4..e420885c 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "programs:clean": "zx ./scripts/program/clean.mjs", "programs:format": "zx ./scripts/program/format.mjs", "programs:lint": "zx ./scripts/program/lint.mjs", + "programs:dump_binaries": "zx ./scripts/program/dump.mjs", "generate:idls": "zx ./scripts/generate-idls.mjs", "generate": "pnpm generate:idls && pnpm generate:clients", "generate:clients": "zx ./scripts/generate-clients.mjs",