diff --git a/clients/js/src/generated/instructions/applyPendingBurn.ts b/clients/js/src/generated/instructions/applyPendingBurn.ts new file mode 100644 index 000000000..e5ff9b810 --- /dev/null +++ b/clients/js/src/generated/instructions/applyPendingBurn.ts @@ -0,0 +1,214 @@ +/** + * 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 { + AccountRole, + combineCodec, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const APPLY_PENDING_BURN_DISCRIMINATOR = 42; + +export function getApplyPendingBurnDiscriminatorBytes() { + return getU8Encoder().encode(APPLY_PENDING_BURN_DISCRIMINATOR); +} + +export const APPLY_PENDING_BURN_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR = 5; + +export function getApplyPendingBurnConfidentialMintBurnDiscriminatorBytes() { + return getU8Encoder().encode( + APPLY_PENDING_BURN_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR + ); +} + +export type ApplyPendingBurnInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMint extends string | AccountMeta = string, + TAccountAuthority extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountMint extends string + ? WritableAccount + : TAccountMint, + TAccountAuthority extends string + ? ReadonlyAccount + : TAccountAuthority, + ...TRemainingAccounts, + ] + >; + +export type ApplyPendingBurnInstructionData = { + discriminator: number; + confidentialMintBurnDiscriminator: number; +}; + +export type ApplyPendingBurnInstructionDataArgs = {}; + +export function getApplyPendingBurnInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['confidentialMintBurnDiscriminator', getU8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: APPLY_PENDING_BURN_DISCRIMINATOR, + confidentialMintBurnDiscriminator: + APPLY_PENDING_BURN_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR, + }) + ); +} + +export function getApplyPendingBurnInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['confidentialMintBurnDiscriminator', getU8Decoder()], + ]); +} + +export function getApplyPendingBurnInstructionDataCodec(): FixedSizeCodec< + ApplyPendingBurnInstructionDataArgs, + ApplyPendingBurnInstructionData +> { + return combineCodec( + getApplyPendingBurnInstructionDataEncoder(), + getApplyPendingBurnInstructionDataDecoder() + ); +} + +export type ApplyPendingBurnInput< + TAccountMint extends string = string, + TAccountAuthority extends string = string, +> = { + /** The SPL Token mint. */ + mint: Address; + /** The mint's minting authority or its multisignature account. */ + authority: Address | TransactionSigner; + multiSigners?: Array; +}; + +export function getApplyPendingBurnInstruction< + TAccountMint extends string, + TAccountAuthority extends string, + TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS, +>( + input: ApplyPendingBurnInput, + config?: { programAddress?: TProgramAddress } +): ApplyPendingBurnInstruction< + TProgramAddress, + TAccountMint, + (typeof input)['authority'] extends TransactionSigner + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthority +> { + // Program address. + const programAddress = config?.programAddress ?? TOKEN_2022_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + mint: { value: input.mint ?? null, isWritable: true }, + authority: { value: input.authority ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Remaining accounts. + const remainingAccounts: AccountMeta[] = (args.multiSigners ?? []).map( + (signer) => ({ + address: signer.address, + role: AccountRole.READONLY_SIGNER, + signer, + }) + ); + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + return Object.freeze({ + accounts: [ + getAccountMeta(accounts.mint), + getAccountMeta(accounts.authority), + ...remainingAccounts, + ], + data: getApplyPendingBurnInstructionDataEncoder().encode({}), + programAddress, + } as ApplyPendingBurnInstruction< + TProgramAddress, + TAccountMint, + (typeof input)['authority'] extends TransactionSigner + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthority + >); +} + +export type ParsedApplyPendingBurnInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + /** The SPL Token mint. */ + mint: TAccountMetas[0]; + /** The mint's minting authority or its multisignature account. */ + authority: TAccountMetas[1]; + }; + data: ApplyPendingBurnInstructionData; +}; + +export function parseApplyPendingBurnInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedApplyPendingBurnInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { mint: getNextAccount(), authority: getNextAccount() }, + data: getApplyPendingBurnInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/js/src/generated/instructions/burnFromConfidentialBalance.ts b/clients/js/src/generated/instructions/burnFromConfidentialBalance.ts new file mode 100644 index 000000000..143e500ff --- /dev/null +++ b/clients/js/src/generated/instructions/burnFromConfidentialBalance.ts @@ -0,0 +1,380 @@ +/** + * 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 { + AccountRole, + combineCodec, + getI8Decoder, + getI8Encoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const BURN_FROM_CONFIDENTIAL_BALANCE_DISCRIMINATOR = 42; + +export function getBurnFromConfidentialBalanceDiscriminatorBytes() { + return getU8Encoder().encode(BURN_FROM_CONFIDENTIAL_BALANCE_DISCRIMINATOR); +} + +export const BURN_FROM_CONFIDENTIAL_BALANCE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR = 4; + +export function getBurnFromConfidentialBalanceConfidentialMintBurnDiscriminatorBytes() { + return getU8Encoder().encode( + BURN_FROM_CONFIDENTIAL_BALANCE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR + ); +} + +export type BurnFromConfidentialBalanceInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountToken extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountAuthority extends string | AccountMeta = string, + TAccountEqualityProofRecord extends string | AccountMeta = string, + TAccountCiphertextValidityProofRecord extends + | string + | AccountMeta = string, + TAccountRangeProofRecord extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountToken extends string + ? WritableAccount + : TAccountToken, + TAccountMint extends string + ? WritableAccount + : TAccountMint, + TAccountAuthority extends string + ? ReadonlyAccount + : TAccountAuthority, + TAccountEqualityProofRecord extends string + ? ReadonlyAccount + : TAccountEqualityProofRecord, + TAccountCiphertextValidityProofRecord extends string + ? ReadonlyAccount + : TAccountCiphertextValidityProofRecord, + TAccountRangeProofRecord extends string + ? ReadonlyAccount + : TAccountRangeProofRecord, + ...TRemainingAccounts, + ] + >; + +export type BurnFromConfidentialBalanceInstructionData = { + discriminator: number; + confidentialMintBurnDiscriminator: number; + /** The new decryptable available balance encrypted with the supply aes key */ + newDecryptableAvailableBalance: number; + /** The low part of the burn amount encrypted with the auditor aes key */ + burnAmountAuditorCiphertextLo: number; + /** The high part of the burn amount encrypted with the auditor aes key */ + burnAmountAuditorCiphertextHi: number; + /** + * Relative location of the + * `ProofInstruction::VerifyCiphertextCommitmentEquality` instruction + * to the `BurnFromConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + equalityProofInstructionOffset: number; + /** + * Relative location of the + * `ProofInstruction::VerifyBatchedGroupedCiphertext3HandlesValidity` instruction + * to the `BurnFromConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + ciphertextValidityProofInstructionOffset: number; + /** + * Relative location of the + * `ProofInstruction::VerifyBatchedRangeProofU128` instruction + * to the `BurnFromConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + rangeProofInstructionOffset: number; +}; + +export type BurnFromConfidentialBalanceInstructionDataArgs = { + /** The new decryptable available balance encrypted with the supply aes key */ + newDecryptableAvailableBalance: number; + /** The low part of the burn amount encrypted with the auditor aes key */ + burnAmountAuditorCiphertextLo: number; + /** The high part of the burn amount encrypted with the auditor aes key */ + burnAmountAuditorCiphertextHi: number; + /** + * Relative location of the + * `ProofInstruction::VerifyCiphertextCommitmentEquality` instruction + * to the `BurnFromConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + equalityProofInstructionOffset: number; + /** + * Relative location of the + * `ProofInstruction::VerifyBatchedGroupedCiphertext3HandlesValidity` instruction + * to the `BurnFromConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + ciphertextValidityProofInstructionOffset: number; + /** + * Relative location of the + * `ProofInstruction::VerifyBatchedRangeProofU128` instruction + * to the `BurnFromConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + rangeProofInstructionOffset: number; +}; + +export function getBurnFromConfidentialBalanceInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['confidentialMintBurnDiscriminator', getU8Encoder()], + ['newDecryptableAvailableBalance', getU8Encoder()], + ['burnAmountAuditorCiphertextLo', getU8Encoder()], + ['burnAmountAuditorCiphertextHi', getU8Encoder()], + ['equalityProofInstructionOffset', getI8Encoder()], + ['ciphertextValidityProofInstructionOffset', getI8Encoder()], + ['rangeProofInstructionOffset', getI8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: BURN_FROM_CONFIDENTIAL_BALANCE_DISCRIMINATOR, + confidentialMintBurnDiscriminator: + BURN_FROM_CONFIDENTIAL_BALANCE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR, + }) + ); +} + +export function getBurnFromConfidentialBalanceInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['confidentialMintBurnDiscriminator', getU8Decoder()], + ['newDecryptableAvailableBalance', getU8Decoder()], + ['burnAmountAuditorCiphertextLo', getU8Decoder()], + ['burnAmountAuditorCiphertextHi', getU8Decoder()], + ['equalityProofInstructionOffset', getI8Decoder()], + ['ciphertextValidityProofInstructionOffset', getI8Decoder()], + ['rangeProofInstructionOffset', getI8Decoder()], + ]); +} + +export function getBurnFromConfidentialBalanceInstructionDataCodec(): FixedSizeCodec< + BurnFromConfidentialBalanceInstructionDataArgs, + BurnFromConfidentialBalanceInstructionData +> { + return combineCodec( + getBurnFromConfidentialBalanceInstructionDataEncoder(), + getBurnFromConfidentialBalanceInstructionDataDecoder() + ); +} + +export type BurnFromConfidentialBalanceInput< + TAccountToken extends string = string, + TAccountMint extends string = string, + TAccountAuthority extends string = string, + TAccountEqualityProofRecord extends string = string, + TAccountCiphertextValidityProofRecord extends string = string, + TAccountRangeProofRecord extends string = string, +> = { + /** The SPL Token account. */ + token: Address; + /** The SPL Token mint. */ + mint: Address; + /** The mint's minting authority or its multisignature account. */ + authority: Address | TransactionSigner; + /** (Optional) Equality proof record account or context state account. */ + equalityProofRecord?: Address; + /** (Optional) Ciphertext validity proof record account or context state account. */ + ciphertextValidityProofRecord?: Address; + /** (Optional) Range proof record account or context state account. */ + rangeProofRecord?: Address; + newDecryptableAvailableBalance: BurnFromConfidentialBalanceInstructionDataArgs['newDecryptableAvailableBalance']; + burnAmountAuditorCiphertextLo: BurnFromConfidentialBalanceInstructionDataArgs['burnAmountAuditorCiphertextLo']; + burnAmountAuditorCiphertextHi: BurnFromConfidentialBalanceInstructionDataArgs['burnAmountAuditorCiphertextHi']; + equalityProofInstructionOffset: BurnFromConfidentialBalanceInstructionDataArgs['equalityProofInstructionOffset']; + ciphertextValidityProofInstructionOffset: BurnFromConfidentialBalanceInstructionDataArgs['ciphertextValidityProofInstructionOffset']; + rangeProofInstructionOffset: BurnFromConfidentialBalanceInstructionDataArgs['rangeProofInstructionOffset']; + multiSigners?: Array; +}; + +export function getBurnFromConfidentialBalanceInstruction< + TAccountToken extends string, + TAccountMint extends string, + TAccountAuthority extends string, + TAccountEqualityProofRecord extends string, + TAccountCiphertextValidityProofRecord extends string, + TAccountRangeProofRecord extends string, + TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS, +>( + input: BurnFromConfidentialBalanceInput< + TAccountToken, + TAccountMint, + TAccountAuthority, + TAccountEqualityProofRecord, + TAccountCiphertextValidityProofRecord, + TAccountRangeProofRecord + >, + config?: { programAddress?: TProgramAddress } +): BurnFromConfidentialBalanceInstruction< + TProgramAddress, + TAccountToken, + TAccountMint, + (typeof input)['authority'] extends TransactionSigner + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthority, + TAccountEqualityProofRecord, + TAccountCiphertextValidityProofRecord, + TAccountRangeProofRecord +> { + // Program address. + const programAddress = config?.programAddress ?? TOKEN_2022_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + token: { value: input.token ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: true }, + authority: { value: input.authority ?? null, isWritable: false }, + equalityProofRecord: { + value: input.equalityProofRecord ?? null, + isWritable: false, + }, + ciphertextValidityProofRecord: { + value: input.ciphertextValidityProofRecord ?? null, + isWritable: false, + }, + rangeProofRecord: { + value: input.rangeProofRecord ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Remaining accounts. + const remainingAccounts: AccountMeta[] = (args.multiSigners ?? []).map( + (signer) => ({ + address: signer.address, + role: AccountRole.READONLY_SIGNER, + signer, + }) + ); + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + return Object.freeze({ + accounts: [ + getAccountMeta(accounts.token), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.authority), + getAccountMeta(accounts.equalityProofRecord), + getAccountMeta(accounts.ciphertextValidityProofRecord), + getAccountMeta(accounts.rangeProofRecord), + ...remainingAccounts, + ], + data: getBurnFromConfidentialBalanceInstructionDataEncoder().encode( + args as BurnFromConfidentialBalanceInstructionDataArgs + ), + programAddress, + } as BurnFromConfidentialBalanceInstruction< + TProgramAddress, + TAccountToken, + TAccountMint, + (typeof input)['authority'] extends TransactionSigner + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthority, + TAccountEqualityProofRecord, + TAccountCiphertextValidityProofRecord, + TAccountRangeProofRecord + >); +} + +export type ParsedBurnFromConfidentialBalanceInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + /** The SPL Token account. */ + token: TAccountMetas[0]; + /** The SPL Token mint. */ + mint: TAccountMetas[1]; + /** The mint's minting authority or its multisignature account. */ + authority: TAccountMetas[2]; + /** (Optional) Equality proof record account or context state account. */ + equalityProofRecord?: TAccountMetas[3] | undefined; + /** (Optional) Ciphertext validity proof record account or context state account. */ + ciphertextValidityProofRecord?: TAccountMetas[4] | undefined; + /** (Optional) Range proof record account or context state account. */ + rangeProofRecord?: TAccountMetas[5] | undefined; + }; + data: BurnFromConfidentialBalanceInstructionData; +}; + +export function parseBurnFromConfidentialBalanceInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedBurnFromConfidentialBalanceInstruction { + if (instruction.accounts.length < 6) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === TOKEN_2022_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + token: getNextAccount(), + mint: getNextAccount(), + authority: getNextAccount(), + equalityProofRecord: getNextOptionalAccount(), + ciphertextValidityProofRecord: getNextOptionalAccount(), + rangeProofRecord: getNextOptionalAccount(), + }, + data: getBurnFromConfidentialBalanceInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/clients/js/src/generated/instructions/configureConfidentialTransferAccount.ts b/clients/js/src/generated/instructions/configureConfidentialTransferAccount.ts index 9c4296ae5..d49a5e7cb 100644 --- a/clients/js/src/generated/instructions/configureConfidentialTransferAccount.ts +++ b/clients/js/src/generated/instructions/configureConfidentialTransferAccount.ts @@ -97,7 +97,7 @@ export type ConfigureConfidentialTransferAccountInstructionData = { /** The decryptable balance (always 0) once the configure account succeeds. */ decryptableZeroBalance: DecryptableBalance; /** - * The maximum number of despots and transfers that an account can receiver + * The maximum number of deposits and transfers that an account can receive * before the `ApplyPendingBalance` is executed */ maximumPendingBalanceCreditCounter: bigint; @@ -114,7 +114,7 @@ export type ConfigureConfidentialTransferAccountInstructionDataArgs = { /** The decryptable balance (always 0) once the configure account succeeds. */ decryptableZeroBalance: DecryptableBalanceArgs; /** - * The maximum number of despots and transfers that an account can receiver + * The maximum number of deposits and transfers that an account can receive * before the `ApplyPendingBalance` is executed */ maximumPendingBalanceCreditCounter: number | bigint; diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index 8b526eaa4..130cf8085 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -8,11 +8,13 @@ export * from './amountToUiAmount'; export * from './applyConfidentialPendingBalance'; +export * from './applyPendingBurn'; export * from './approve'; export * from './approveChecked'; export * from './approveConfidentialTransferAccount'; export * from './burn'; export * from './burnChecked'; +export * from './burnFromConfidentialBalance'; export * from './closeAccount'; export * from './confidentialDeposit'; export * from './confidentialTransfer'; @@ -41,6 +43,7 @@ export * from './harvestWithheldTokensToMintForConfidentialTransferFee'; export * from './initializeAccount'; export * from './initializeAccount2'; export * from './initializeAccount3'; +export * from './initializeConfidentialMintBurn'; export * from './initializeConfidentialTransferFee'; export * from './initializeConfidentialTransferMint'; export * from './initializeDefaultAccountState'; @@ -65,12 +68,14 @@ export * from './initializeTransferFeeConfig'; export * from './initializeTransferHook'; export * from './mintTo'; export * from './mintToChecked'; +export * from './mintToConfidentialBalance'; export * from './pause'; export * from './reallocate'; export * from './recoverNestedAssociatedToken'; export * from './removeTokenMetadataKey'; export * from './resume'; export * from './revoke'; +export * from './rotateSupplyElGamalPubkey'; export * from './setAuthority'; export * from './setTransferFee'; export * from './syncNative'; @@ -80,6 +85,7 @@ export * from './transferChecked'; export * from './transferCheckedWithFee'; export * from './uiAmountToAmount'; export * from './updateConfidentialTransferMint'; +export * from './updateDecryptableSupply'; export * from './updateDefaultAccountState'; export * from './updateGroupMemberPointer'; export * from './updateGroupPointer'; diff --git a/clients/js/src/generated/instructions/initializeConfidentialMintBurn.ts b/clients/js/src/generated/instructions/initializeConfidentialMintBurn.ts new file mode 100644 index 000000000..0afa96246 --- /dev/null +++ b/clients/js/src/generated/instructions/initializeConfidentialMintBurn.ts @@ -0,0 +1,197 @@ +/** + * 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, + getAddressDecoder, + getAddressEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type AccountMeta, + type Address, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyUint8Array, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getDecryptableSupplyDecoder, + getDecryptableSupplyEncoder, + type DecryptableSupply, + type DecryptableSupplyArgs, +} from '../types'; + +export const INITIALIZE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR = 42; + +export function getInitializeConfidentialMintBurnDiscriminatorBytes() { + return getU8Encoder().encode(INITIALIZE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR); +} + +export const INITIALIZE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR = 42; + +export function getInitializeConfidentialMintBurnDiscriminatorBytes() { + return getU8Encoder().encode(INITIALIZE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR); +} + +export type InitializeConfidentialMintBurnInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMint extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountMint extends string + ? WritableAccount + : TAccountMint, + ...TRemainingAccounts, + ] + >; + +export type InitializeConfidentialMintBurnInstructionData = { + discriminator: number; + confidentialMintBurnDiscriminator: number; + /** The ElGamal pubkey used to encrypt the confidential supply. */ + supplyElgamalPubkey: Address; + /** The initial 0 supply encrypted with the supply aes key */ + decryptableSupply: DecryptableSupply; +}; + +export type InitializeConfidentialMintBurnInstructionDataArgs = { + /** The ElGamal pubkey used to encrypt the confidential supply. */ + supplyElgamalPubkey: Address; + /** The initial 0 supply encrypted with the supply aes key */ + decryptableSupply: DecryptableSupplyArgs; +}; + +export function getInitializeConfidentialMintBurnInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['confidentialMintBurnDiscriminator', getU8Encoder()], + ['supplyElgamalPubkey', getAddressEncoder()], + ['decryptableSupply', getDecryptableSupplyEncoder()], + ]), + (value) => ({ + ...value, + discriminator: INITIALIZE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR, + confidentialMintBurnDiscriminator: 0, + }) + ); +} + +export function getInitializeConfidentialMintBurnInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['confidentialMintBurnDiscriminator', getU8Decoder()], + ['supplyElgamalPubkey', getAddressDecoder()], + ['decryptableSupply', getDecryptableSupplyDecoder()], + ]); +} + +export function getInitializeConfidentialMintBurnInstructionDataCodec(): FixedSizeCodec< + InitializeConfidentialMintBurnInstructionDataArgs, + InitializeConfidentialMintBurnInstructionData +> { + return combineCodec( + getInitializeConfidentialMintBurnInstructionDataEncoder(), + getInitializeConfidentialMintBurnInstructionDataDecoder() + ); +} + +export type InitializeConfidentialMintBurnInput< + TAccountMint extends string = string, +> = { + /** The SPL Token mint. */ + mint: Address; + supplyElgamalPubkey: InitializeConfidentialMintBurnInstructionDataArgs['supplyElgamalPubkey']; + decryptableSupply: InitializeConfidentialMintBurnInstructionDataArgs['decryptableSupply']; +}; + +export function getInitializeConfidentialMintBurnInstruction< + TAccountMint extends string, + TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS, +>( + input: InitializeConfidentialMintBurnInput, + config?: { programAddress?: TProgramAddress } +): InitializeConfidentialMintBurnInstruction { + // Program address. + const programAddress = config?.programAddress ?? TOKEN_2022_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + mint: { value: input.mint ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + return Object.freeze({ + accounts: [getAccountMeta(accounts.mint)], + data: getInitializeConfidentialMintBurnInstructionDataEncoder().encode( + args as InitializeConfidentialMintBurnInstructionDataArgs + ), + programAddress, + } as InitializeConfidentialMintBurnInstruction< + TProgramAddress, + TAccountMint + >); +} + +export type ParsedInitializeConfidentialMintBurnInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + /** The SPL Token mint. */ + mint: TAccountMetas[0]; + }; + data: InitializeConfidentialMintBurnInstructionData; +}; + +export function parseInitializeConfidentialMintBurnInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedInitializeConfidentialMintBurnInstruction { + if (instruction.accounts.length < 1) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { mint: getNextAccount() }, + data: getInitializeConfidentialMintBurnInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/clients/js/src/generated/instructions/mintToConfidentialBalance.ts b/clients/js/src/generated/instructions/mintToConfidentialBalance.ts new file mode 100644 index 000000000..942669ec2 --- /dev/null +++ b/clients/js/src/generated/instructions/mintToConfidentialBalance.ts @@ -0,0 +1,380 @@ +/** + * 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 { + AccountRole, + combineCodec, + getI8Decoder, + getI8Encoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getDecryptableSupplyDecoder, + getDecryptableSupplyEncoder, + type DecryptableSupply, + type DecryptableSupplyArgs, +} from '../types'; + +export const MINT_TO_CONFIDENTIAL_BALANCE_DISCRIMINATOR = 42; + +export function getMintToConfidentialBalanceDiscriminatorBytes() { + return getU8Encoder().encode(MINT_TO_CONFIDENTIAL_BALANCE_DISCRIMINATOR); +} + +export const MINT_TO_CONFIDENTIAL_BALANCE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR = 3; + +export function getMintToConfidentialBalanceConfidentialMintBurnDiscriminatorBytes() { + return getU8Encoder().encode( + MINT_TO_CONFIDENTIAL_BALANCE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR + ); +} + +export type MintToConfidentialBalanceInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountToken extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountAuthority extends string | AccountMeta = string, + TAccountEqualityProofRecord extends string | AccountMeta = string, + TAccountCiphertextValidityProofRecord extends + | string + | AccountMeta = string, + TAccountRangeProofRecord extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountToken extends string + ? WritableAccount + : TAccountToken, + TAccountMint extends string + ? WritableAccount + : TAccountMint, + TAccountAuthority extends string + ? ReadonlyAccount + : TAccountAuthority, + TAccountEqualityProofRecord extends string + ? ReadonlyAccount + : TAccountEqualityProofRecord, + TAccountCiphertextValidityProofRecord extends string + ? ReadonlyAccount + : TAccountCiphertextValidityProofRecord, + TAccountRangeProofRecord extends string + ? ReadonlyAccount + : TAccountRangeProofRecord, + ...TRemainingAccounts, + ] + >; + +export type MintToConfidentialBalanceInstructionData = { + discriminator: number; + confidentialMintBurnDiscriminator: number; + /** The low part of the mint amount encrypted with the auditor aes key */ + mintAmountAuditorCiphertextLo: number; + /** The high part of the mint amount encrypted with the auditor aes key */ + mintAmountAuditorCiphertextHi: number; + /** + * Relative location of the + * `ProofInstruction::VerifyCiphertextCommitmentEquality` instruction + * to the `MintToConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + equalityProofInstructionOffset: number; + /** + * Relative location of the + * `ProofInstruction::VerifyBatchedGroupedCiphertext3HandlesValidity` instruction + * to the `MintToConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + ciphertextValidityProofInstructionOffset: number; + /** + * Relative location of the + * `ProofInstruction::VerifyBatchedRangeProofU128` instruction + * to the `MintToConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + rangeProofInstructionOffset: number; + /** The new decryptable supply encrypted with the supply aes key */ + newDecryptableSupply: DecryptableSupply; +}; + +export type MintToConfidentialBalanceInstructionDataArgs = { + /** The low part of the mint amount encrypted with the auditor aes key */ + mintAmountAuditorCiphertextLo: number; + /** The high part of the mint amount encrypted with the auditor aes key */ + mintAmountAuditorCiphertextHi: number; + /** + * Relative location of the + * `ProofInstruction::VerifyCiphertextCommitmentEquality` instruction + * to the `MintToConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + equalityProofInstructionOffset: number; + /** + * Relative location of the + * `ProofInstruction::VerifyBatchedGroupedCiphertext3HandlesValidity` instruction + * to the `MintToConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + ciphertextValidityProofInstructionOffset: number; + /** + * Relative location of the + * `ProofInstruction::VerifyBatchedRangeProofU128` instruction + * to the `MintToConfidentialBalance` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + rangeProofInstructionOffset: number; + /** The new decryptable supply encrypted with the supply aes key */ + newDecryptableSupply: DecryptableSupplyArgs; +}; + +export function getMintToConfidentialBalanceInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['confidentialMintBurnDiscriminator', getU8Encoder()], + ['mintAmountAuditorCiphertextLo', getU8Encoder()], + ['mintAmountAuditorCiphertextHi', getU8Encoder()], + ['equalityProofInstructionOffset', getI8Encoder()], + ['ciphertextValidityProofInstructionOffset', getI8Encoder()], + ['rangeProofInstructionOffset', getI8Encoder()], + ['newDecryptableSupply', getDecryptableSupplyEncoder()], + ]), + (value) => ({ + ...value, + discriminator: MINT_TO_CONFIDENTIAL_BALANCE_DISCRIMINATOR, + confidentialMintBurnDiscriminator: + MINT_TO_CONFIDENTIAL_BALANCE_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR, + }) + ); +} + +export function getMintToConfidentialBalanceInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['confidentialMintBurnDiscriminator', getU8Decoder()], + ['mintAmountAuditorCiphertextLo', getU8Decoder()], + ['mintAmountAuditorCiphertextHi', getU8Decoder()], + ['equalityProofInstructionOffset', getI8Decoder()], + ['ciphertextValidityProofInstructionOffset', getI8Decoder()], + ['rangeProofInstructionOffset', getI8Decoder()], + ['newDecryptableSupply', getDecryptableSupplyDecoder()], + ]); +} + +export function getMintToConfidentialBalanceInstructionDataCodec(): FixedSizeCodec< + MintToConfidentialBalanceInstructionDataArgs, + MintToConfidentialBalanceInstructionData +> { + return combineCodec( + getMintToConfidentialBalanceInstructionDataEncoder(), + getMintToConfidentialBalanceInstructionDataDecoder() + ); +} + +export type MintToConfidentialBalanceInput< + TAccountToken extends string = string, + TAccountMint extends string = string, + TAccountAuthority extends string = string, + TAccountEqualityProofRecord extends string = string, + TAccountCiphertextValidityProofRecord extends string = string, + TAccountRangeProofRecord extends string = string, +> = { + /** The SPL Token account. */ + token: Address; + /** The SPL Token mint. */ + mint: Address; + /** The mint's minting authority or its multisignature account. */ + authority: Address | TransactionSigner; + /** (Optional) Equality proof record account or context state account. */ + equalityProofRecord: Address; + /** (Optional) Ciphertext validity proof record account or context state account. */ + ciphertextValidityProofRecord: Address; + /** (Optional) Range proof record account or context state account. */ + rangeProofRecord: Address; + mintAmountAuditorCiphertextLo: MintToConfidentialBalanceInstructionDataArgs['mintAmountAuditorCiphertextLo']; + mintAmountAuditorCiphertextHi: MintToConfidentialBalanceInstructionDataArgs['mintAmountAuditorCiphertextHi']; + equalityProofInstructionOffset: MintToConfidentialBalanceInstructionDataArgs['equalityProofInstructionOffset']; + ciphertextValidityProofInstructionOffset: MintToConfidentialBalanceInstructionDataArgs['ciphertextValidityProofInstructionOffset']; + rangeProofInstructionOffset: MintToConfidentialBalanceInstructionDataArgs['rangeProofInstructionOffset']; + newDecryptableSupply: MintToConfidentialBalanceInstructionDataArgs['newDecryptableSupply']; + multiSigners?: Array; +}; + +export function getMintToConfidentialBalanceInstruction< + TAccountToken extends string, + TAccountMint extends string, + TAccountAuthority extends string, + TAccountEqualityProofRecord extends string, + TAccountCiphertextValidityProofRecord extends string, + TAccountRangeProofRecord extends string, + TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS, +>( + input: MintToConfidentialBalanceInput< + TAccountToken, + TAccountMint, + TAccountAuthority, + TAccountEqualityProofRecord, + TAccountCiphertextValidityProofRecord, + TAccountRangeProofRecord + >, + config?: { programAddress?: TProgramAddress } +): MintToConfidentialBalanceInstruction< + TProgramAddress, + TAccountToken, + TAccountMint, + (typeof input)['authority'] extends TransactionSigner + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthority, + TAccountEqualityProofRecord, + TAccountCiphertextValidityProofRecord, + TAccountRangeProofRecord +> { + // Program address. + const programAddress = config?.programAddress ?? TOKEN_2022_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + token: { value: input.token ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: true }, + authority: { value: input.authority ?? null, isWritable: false }, + equalityProofRecord: { + value: input.equalityProofRecord ?? null, + isWritable: false, + }, + ciphertextValidityProofRecord: { + value: input.ciphertextValidityProofRecord ?? null, + isWritable: false, + }, + rangeProofRecord: { + value: input.rangeProofRecord ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Remaining accounts. + const remainingAccounts: AccountMeta[] = (args.multiSigners ?? []).map( + (signer) => ({ + address: signer.address, + role: AccountRole.READONLY_SIGNER, + signer, + }) + ); + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + return Object.freeze({ + accounts: [ + getAccountMeta(accounts.token), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.authority), + getAccountMeta(accounts.equalityProofRecord), + getAccountMeta(accounts.ciphertextValidityProofRecord), + getAccountMeta(accounts.rangeProofRecord), + ...remainingAccounts, + ], + data: getMintToConfidentialBalanceInstructionDataEncoder().encode( + args as MintToConfidentialBalanceInstructionDataArgs + ), + programAddress, + } as MintToConfidentialBalanceInstruction< + TProgramAddress, + TAccountToken, + TAccountMint, + (typeof input)['authority'] extends TransactionSigner + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthority, + TAccountEqualityProofRecord, + TAccountCiphertextValidityProofRecord, + TAccountRangeProofRecord + >); +} + +export type ParsedMintToConfidentialBalanceInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + /** The SPL Token account. */ + token: TAccountMetas[0]; + /** The SPL Token mint. */ + mint: TAccountMetas[1]; + /** The mint's minting authority or its multisignature account. */ + authority: TAccountMetas[2]; + /** (Optional) Equality proof record account or context state account. */ + equalityProofRecord: TAccountMetas[3]; + /** (Optional) Ciphertext validity proof record account or context state account. */ + ciphertextValidityProofRecord: TAccountMetas[4]; + /** (Optional) Range proof record account or context state account. */ + rangeProofRecord: TAccountMetas[5]; + }; + data: MintToConfidentialBalanceInstructionData; +}; + +export function parseMintToConfidentialBalanceInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedMintToConfidentialBalanceInstruction { + if (instruction.accounts.length < 6) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + token: getNextAccount(), + mint: getNextAccount(), + authority: getNextAccount(), + equalityProofRecord: getNextAccount(), + ciphertextValidityProofRecord: getNextAccount(), + rangeProofRecord: getNextAccount(), + }, + data: getMintToConfidentialBalanceInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/clients/js/src/generated/instructions/rotateSupplyElGamalPubkey.ts b/clients/js/src/generated/instructions/rotateSupplyElGamalPubkey.ts new file mode 100644 index 000000000..8584d3fd1 --- /dev/null +++ b/clients/js/src/generated/instructions/rotateSupplyElGamalPubkey.ts @@ -0,0 +1,245 @@ +/** + * 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 { + AccountRole, + combineCodec, + getAddressDecoder, + getAddressEncoder, + getI8Decoder, + getI8Encoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type AccountMeta, + type Address, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const ROTATE_SUPPLY_EL_GAMAL_PUBKEY_DISCRIMINATOR = 42; + +export function getRotateSupplyElGamalPubkeyDiscriminatorBytes() { + return getU8Encoder().encode(ROTATE_SUPPLY_EL_GAMAL_PUBKEY_DISCRIMINATOR); +} + +export const ROTATE_SUPPLY_EL_GAMAL_PUBKEY_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR = 1; + +export function getRotateSupplyElGamalPubkeyConfidentialMintBurnDiscriminatorBytes() { + return getU8Encoder().encode( + ROTATE_SUPPLY_EL_GAMAL_PUBKEY_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR + ); +} + +export type RotateSupplyElGamalPubkeyInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMint extends string | AccountMeta = string, + TAccountEqualityProofRecord extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountMint extends string + ? WritableAccount + : TAccountMint, + TAccountEqualityProofRecord extends string + ? ReadonlyAccount + : TAccountEqualityProofRecord, + ...TRemainingAccounts, + ] + >; + +export type RotateSupplyElGamalPubkeyInstructionData = { + discriminator: number; + confidentialMintBurnDiscriminator: number; + /** The new ElGamal pubkey used to encrypt the confidential supply. */ + newSupplyElgamalPubkey: Address; + /** + * Relative location of the + * `ProofInstruction::VerifyCiphertextCiphertextEquality` instruction + * to the `RotateSupplyElGamalPubkey` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + cyphertextEqualityProofInstructionOffset: number; +}; + +export type RotateSupplyElGamalPubkeyInstructionDataArgs = { + /** The new ElGamal pubkey used to encrypt the confidential supply. */ + newSupplyElgamalPubkey: Address; + /** + * Relative location of the + * `ProofInstruction::VerifyCiphertextCiphertextEquality` instruction + * to the `RotateSupplyElGamalPubkey` instruction in the transaction. If the offset + * is `0`, then use a context state account for the proof. + */ + cyphertextEqualityProofInstructionOffset: number; +}; + +export function getRotateSupplyElGamalPubkeyInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['confidentialMintBurnDiscriminator', getU8Encoder()], + ['newSupplyElgamalPubkey', getAddressEncoder()], + ['cyphertextEqualityProofInstructionOffset', getI8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: ROTATE_SUPPLY_EL_GAMAL_PUBKEY_DISCRIMINATOR, + confidentialMintBurnDiscriminator: + ROTATE_SUPPLY_EL_GAMAL_PUBKEY_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR, + }) + ); +} + +export function getRotateSupplyElGamalPubkeyInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['confidentialMintBurnDiscriminator', getU8Decoder()], + ['newSupplyElgamalPubkey', getAddressDecoder()], + ['cyphertextEqualityProofInstructionOffset', getI8Decoder()], + ]); +} + +export function getRotateSupplyElGamalPubkeyInstructionDataCodec(): FixedSizeCodec< + RotateSupplyElGamalPubkeyInstructionDataArgs, + RotateSupplyElGamalPubkeyInstructionData +> { + return combineCodec( + getRotateSupplyElGamalPubkeyInstructionDataEncoder(), + getRotateSupplyElGamalPubkeyInstructionDataDecoder() + ); +} + +export type RotateSupplyElGamalPubkeyInput< + TAccountMint extends string = string, + TAccountEqualityProofRecord extends string = string, +> = { + /** The SPL Token mint. */ + mint: Address; + /** (Optional) Equality proof record account or context state account. */ + equalityProofRecord: Address; + newSupplyElgamalPubkey: RotateSupplyElGamalPubkeyInstructionDataArgs['newSupplyElgamalPubkey']; + cyphertextEqualityProofInstructionOffset: RotateSupplyElGamalPubkeyInstructionDataArgs['cyphertextEqualityProofInstructionOffset']; + multiSigners?: Array; +}; + +export function getRotateSupplyElGamalPubkeyInstruction< + TAccountMint extends string, + TAccountEqualityProofRecord extends string, + TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS, +>( + input: RotateSupplyElGamalPubkeyInput< + TAccountMint, + TAccountEqualityProofRecord + >, + config?: { programAddress?: TProgramAddress } +): RotateSupplyElGamalPubkeyInstruction< + TProgramAddress, + TAccountMint, + TAccountEqualityProofRecord +> { + // Program address. + const programAddress = config?.programAddress ?? TOKEN_2022_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + mint: { value: input.mint ?? null, isWritable: true }, + equalityProofRecord: { + value: input.equalityProofRecord ?? null, + isWritable: false, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Remaining accounts. + const remainingAccounts: AccountMeta[] = (args.multiSigners ?? []).map( + (signer) => ({ + address: signer.address, + role: AccountRole.READONLY_SIGNER, + signer, + }) + ); + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + return Object.freeze({ + accounts: [ + getAccountMeta(accounts.mint), + getAccountMeta(accounts.equalityProofRecord), + ...remainingAccounts, + ], + data: getRotateSupplyElGamalPubkeyInstructionDataEncoder().encode( + args as RotateSupplyElGamalPubkeyInstructionDataArgs + ), + programAddress, + } as RotateSupplyElGamalPubkeyInstruction< + TProgramAddress, + TAccountMint, + TAccountEqualityProofRecord + >); +} + +export type ParsedRotateSupplyElGamalPubkeyInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + /** The SPL Token mint. */ + mint: TAccountMetas[0]; + /** (Optional) Equality proof record account or context state account. */ + equalityProofRecord: TAccountMetas[1]; + }; + data: RotateSupplyElGamalPubkeyInstructionData; +}; + +export function parseRotateSupplyElGamalPubkeyInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedRotateSupplyElGamalPubkeyInstruction { + if (instruction.accounts.length < 2) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { mint: getNextAccount(), equalityProofRecord: getNextAccount() }, + data: getRotateSupplyElGamalPubkeyInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/clients/js/src/generated/instructions/updateDecryptableSupply.ts b/clients/js/src/generated/instructions/updateDecryptableSupply.ts new file mode 100644 index 000000000..b22230bb6 --- /dev/null +++ b/clients/js/src/generated/instructions/updateDecryptableSupply.ts @@ -0,0 +1,199 @@ +/** + * 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 { + AccountRole, + combineCodec, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type AccountMeta, + type Address, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getDecryptableSupplyDecoder, + getDecryptableSupplyEncoder, + type DecryptableSupply, + type DecryptableSupplyArgs, +} from '../types'; + +export const UPDATE_DECRYPTABLE_SUPPLY_DISCRIMINATOR = 42; + +export function getUpdateDecryptableSupplyDiscriminatorBytes() { + return getU8Encoder().encode(UPDATE_DECRYPTABLE_SUPPLY_DISCRIMINATOR); +} + +export const UPDATE_DECRYPTABLE_SUPPLY_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR = 2; + +export function getUpdateDecryptableSupplyConfidentialMintBurnDiscriminatorBytes() { + return getU8Encoder().encode( + UPDATE_DECRYPTABLE_SUPPLY_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR + ); +} + +export type UpdateDecryptableSupplyInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMint extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountMint extends string + ? WritableAccount + : TAccountMint, + ...TRemainingAccounts, + ] + >; + +export type UpdateDecryptableSupplyInstructionData = { + discriminator: number; + confidentialMintBurnDiscriminator: number; + /** The new decryptable supply encrypted with the supply aes key */ + newDecryptableSupply: DecryptableSupply; +}; + +export type UpdateDecryptableSupplyInstructionDataArgs = { + /** The new decryptable supply encrypted with the supply aes key */ + newDecryptableSupply: DecryptableSupplyArgs; +}; + +export function getUpdateDecryptableSupplyInstructionDataEncoder(): FixedSizeEncoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['confidentialMintBurnDiscriminator', getU8Encoder()], + ['newDecryptableSupply', getDecryptableSupplyEncoder()], + ]), + (value) => ({ + ...value, + discriminator: UPDATE_DECRYPTABLE_SUPPLY_DISCRIMINATOR, + confidentialMintBurnDiscriminator: + UPDATE_DECRYPTABLE_SUPPLY_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR, + }) + ); +} + +export function getUpdateDecryptableSupplyInstructionDataDecoder(): FixedSizeDecoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['confidentialMintBurnDiscriminator', getU8Decoder()], + ['newDecryptableSupply', getDecryptableSupplyDecoder()], + ]); +} + +export function getUpdateDecryptableSupplyInstructionDataCodec(): FixedSizeCodec< + UpdateDecryptableSupplyInstructionDataArgs, + UpdateDecryptableSupplyInstructionData +> { + return combineCodec( + getUpdateDecryptableSupplyInstructionDataEncoder(), + getUpdateDecryptableSupplyInstructionDataDecoder() + ); +} + +export type UpdateDecryptableSupplyInput = + { + /** The SPL Token mint. */ + mint: Address; + newDecryptableSupply: UpdateDecryptableSupplyInstructionDataArgs['newDecryptableSupply']; + multiSigners?: Array; + }; + +export function getUpdateDecryptableSupplyInstruction< + TAccountMint extends string, + TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS, +>( + input: UpdateDecryptableSupplyInput, + config?: { programAddress?: TProgramAddress } +): UpdateDecryptableSupplyInstruction { + // Program address. + const programAddress = config?.programAddress ?? TOKEN_2022_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + mint: { value: input.mint ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Remaining accounts. + const remainingAccounts: AccountMeta[] = (args.multiSigners ?? []).map( + (signer) => ({ + address: signer.address, + role: AccountRole.READONLY_SIGNER, + signer, + }) + ); + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + return Object.freeze({ + accounts: [getAccountMeta(accounts.mint), ...remainingAccounts], + data: getUpdateDecryptableSupplyInstructionDataEncoder().encode( + args as UpdateDecryptableSupplyInstructionDataArgs + ), + programAddress, + } as UpdateDecryptableSupplyInstruction); +} + +export type ParsedUpdateDecryptableSupplyInstruction< + TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + /** The SPL Token mint. */ + mint: TAccountMetas[0]; + }; + data: UpdateDecryptableSupplyInstructionData; +}; + +export function parseUpdateDecryptableSupplyInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUpdateDecryptableSupplyInstruction { + if (instruction.accounts.length < 1) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { mint: getNextAccount() }, + data: getUpdateDecryptableSupplyInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/clients/js/src/generated/programs/token2022.ts b/clients/js/src/generated/programs/token2022.ts index 510b3b398..c62a1c4c1 100644 --- a/clients/js/src/generated/programs/token2022.ts +++ b/clients/js/src/generated/programs/token2022.ts @@ -15,10 +15,12 @@ import { import { type ParsedAmountToUiAmountInstruction, type ParsedApplyConfidentialPendingBalanceInstruction, + type ParsedApplyPendingBurnInstruction, type ParsedApproveCheckedInstruction, type ParsedApproveConfidentialTransferAccountInstruction, type ParsedApproveInstruction, type ParsedBurnCheckedInstruction, + type ParsedBurnFromConfidentialBalanceInstruction, type ParsedBurnInstruction, type ParsedCloseAccountInstruction, type ParsedConfidentialDepositInstruction, @@ -46,6 +48,7 @@ import { type ParsedInitializeAccount2Instruction, type ParsedInitializeAccount3Instruction, type ParsedInitializeAccountInstruction, + type ParsedInitializeConfidentialMintBurnInstruction, type ParsedInitializeConfidentialTransferFeeInstruction, type ParsedInitializeConfidentialTransferMintInstruction, type ParsedInitializeDefaultAccountStateInstruction, @@ -69,12 +72,14 @@ import { type ParsedInitializeTransferFeeConfigInstruction, type ParsedInitializeTransferHookInstruction, type ParsedMintToCheckedInstruction, + type ParsedMintToConfidentialBalanceInstruction, type ParsedMintToInstruction, type ParsedPauseInstruction, type ParsedReallocateInstruction, type ParsedRemoveTokenMetadataKeyInstruction, type ParsedResumeInstruction, type ParsedRevokeInstruction, + type ParsedRotateSupplyElGamalPubkeyInstruction, type ParsedSetAuthorityInstruction, type ParsedSetTransferFeeInstruction, type ParsedSyncNativeInstruction, @@ -84,6 +89,7 @@ import { type ParsedTransferInstruction, type ParsedUiAmountToAmountInstruction, type ParsedUpdateConfidentialTransferMintInstruction, + type ParsedUpdateDecryptableSupplyInstruction, type ParsedUpdateDefaultAccountStateInstruction, type ParsedUpdateGroupMemberPointerInstruction, type ParsedUpdateGroupPointerInstruction, @@ -176,6 +182,12 @@ export enum Token2022Instruction { EnableNonConfidentialCredits, DisableNonConfidentialCredits, ConfidentialTransferWithFee, + InitializeConfidentialMintBurn, + RotateSupplyElGamalPubkey, + UpdateDecryptableSupply, + MintToConfidentialBalance, + BurnFromConfidentialBalance, + ApplyPendingBurn, InitializeDefaultAccountState, UpdateDefaultAccountState, Reallocate, @@ -421,6 +433,42 @@ export function identifyToken2022Instruction( ) { return Token2022Instruction.ConfidentialTransferWithFee; } + if ( + containsBytes(data, getU8Encoder().encode(42), 0) && + containsBytes(data, getU8Encoder().encode(42), 1) + ) { + return Token2022Instruction.InitializeConfidentialMintBurn; + } + if ( + containsBytes(data, getU8Encoder().encode(42), 0) && + containsBytes(data, getU8Encoder().encode(1), 1) + ) { + return Token2022Instruction.RotateSupplyElGamalPubkey; + } + if ( + containsBytes(data, getU8Encoder().encode(42), 0) && + containsBytes(data, getU8Encoder().encode(2), 1) + ) { + return Token2022Instruction.UpdateDecryptableSupply; + } + if ( + containsBytes(data, getU8Encoder().encode(42), 0) && + containsBytes(data, getU8Encoder().encode(3), 1) + ) { + return Token2022Instruction.MintToConfidentialBalance; + } + if ( + containsBytes(data, getU8Encoder().encode(42), 0) && + containsBytes(data, getU8Encoder().encode(4), 1) + ) { + return Token2022Instruction.BurnFromConfidentialBalance; + } + if ( + containsBytes(data, getU8Encoder().encode(42), 0) && + containsBytes(data, getU8Encoder().encode(5), 1) + ) { + return Token2022Instruction.ApplyPendingBurn; + } if ( containsBytes(data, getU8Encoder().encode(28), 0) && containsBytes(data, getU8Encoder().encode(0), 1) @@ -817,6 +865,24 @@ export type ParsedToken2022Instruction< | ({ instructionType: Token2022Instruction.ConfidentialTransferWithFee; } & ParsedConfidentialTransferWithFeeInstruction) + | ({ + instructionType: Token2022Instruction.InitializeConfidentialMintBurn; + } & ParsedInitializeConfidentialMintBurnInstruction) + | ({ + instructionType: Token2022Instruction.RotateSupplyElGamalPubkey; + } & ParsedRotateSupplyElGamalPubkeyInstruction) + | ({ + instructionType: Token2022Instruction.UpdateDecryptableSupply; + } & ParsedUpdateDecryptableSupplyInstruction) + | ({ + instructionType: Token2022Instruction.MintToConfidentialBalance; + } & ParsedMintToConfidentialBalanceInstruction) + | ({ + instructionType: Token2022Instruction.BurnFromConfidentialBalance; + } & ParsedBurnFromConfidentialBalanceInstruction) + | ({ + instructionType: Token2022Instruction.ApplyPendingBurn; + } & ParsedApplyPendingBurnInstruction) | ({ instructionType: Token2022Instruction.InitializeDefaultAccountState; } & ParsedInitializeDefaultAccountStateInstruction) diff --git a/clients/js/src/generated/types/decryptableSupply.ts b/clients/js/src/generated/types/decryptableSupply.ts new file mode 100644 index 000000000..63ced275a --- /dev/null +++ b/clients/js/src/generated/types/decryptableSupply.ts @@ -0,0 +1,42 @@ +/** + * 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, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +/** Authenticated encryption containing the confidential supply. */ +export type DecryptableSupply = ReadonlyUint8Array; + +export type DecryptableSupplyArgs = DecryptableSupply; + +export function getDecryptableSupplyEncoder(): FixedSizeEncoder { + return fixEncoderSize(getBytesEncoder(), 36); +} + +export function getDecryptableSupplyDecoder(): FixedSizeDecoder { + return fixDecoderSize(getBytesDecoder(), 36); +} + +export function getDecryptableSupplyCodec(): FixedSizeCodec< + DecryptableSupplyArgs, + DecryptableSupply +> { + return combineCodec( + getDecryptableSupplyEncoder(), + getDecryptableSupplyDecoder() + ); +} diff --git a/clients/js/src/generated/types/encryptedSupply.ts b/clients/js/src/generated/types/encryptedSupply.ts new file mode 100644 index 000000000..cd11393f9 --- /dev/null +++ b/clients/js/src/generated/types/encryptedSupply.ts @@ -0,0 +1,39 @@ +/** + * 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, + type FixedSizeCodec, + type FixedSizeDecoder, + type FixedSizeEncoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +/** ElGamal ciphertext containing the confidential supply. */ +export type EncryptedSupply = ReadonlyUint8Array; + +export type EncryptedSupplyArgs = EncryptedSupply; + +export function getEncryptedSupplyEncoder(): FixedSizeEncoder { + return fixEncoderSize(getBytesEncoder(), 64); +} + +export function getEncryptedSupplyDecoder(): FixedSizeDecoder { + return fixDecoderSize(getBytesDecoder(), 64); +} + +export function getEncryptedSupplyCodec(): FixedSizeCodec< + EncryptedSupplyArgs, + EncryptedSupply +> { + return combineCodec(getEncryptedSupplyEncoder(), getEncryptedSupplyDecoder()); +} diff --git a/clients/js/src/generated/types/extension.ts b/clients/js/src/generated/types/extension.ts index bcad0205e..ac67272af 100644 --- a/clients/js/src/generated/types/extension.ts +++ b/clients/js/src/generated/types/extension.ts @@ -52,6 +52,8 @@ import { getDecryptableBalanceEncoder, getEncryptedBalanceDecoder, getEncryptedBalanceEncoder, + getEncryptedSupplyDecoder, + getEncryptedSupplyEncoder, getTransferFeeDecoder, getTransferFeeEncoder, type AccountState, @@ -60,6 +62,8 @@ import { type DecryptableBalanceArgs, type EncryptedBalance, type EncryptedBalanceArgs, + type EncryptedSupply, + type EncryptedSupplyArgs, type TransferFee, type TransferFeeArgs, } from '.'; @@ -266,7 +270,13 @@ export type Extension = /** The member number. */ memberNumber: bigint; } - | { __kind: 'ConfidentialMintBurn' } + | { + __kind: 'ConfidentialMintBurnConfig'; + /** The ElGamal pubkey used to encrypt the confidential supply. */ + supplyElgamalPubkey: Address; + /** The decryptable confidential supply of the mint. */ + decryptableSupply: EncryptedSupply; + } | { __kind: 'ScaledUiAmountConfig'; authority: Address; @@ -479,7 +489,13 @@ export type ExtensionArgs = /** The member number. */ memberNumber: number | bigint; } - | { __kind: 'ConfidentialMintBurn' } + | { + __kind: 'ConfidentialMintBurnConfig'; + /** The ElGamal pubkey used to encrypt the confidential supply. */ + supplyElgamalPubkey: Address; + /** The decryptable confidential supply of the mint. */ + decryptableSupply: EncryptedSupplyArgs; + } | { __kind: 'ScaledUiAmountConfig'; authority: Address; @@ -786,7 +802,16 @@ export function getExtensionEncoder(): Encoder { getU16Encoder() ), ], - ['ConfidentialMintBurn', getUnitEncoder()], + [ + 'ConfidentialMintBurnConfig', + addEncoderSizePrefix( + getStructEncoder([ + ['supplyElgamalPubkey', getAddressEncoder()], + ['decryptableSupply', getEncryptedSupplyEncoder()], + ]), + getU16Encoder() + ), + ], [ 'ScaledUiAmountConfig', addEncoderSizePrefix( @@ -1113,7 +1138,16 @@ export function getExtensionDecoder(): Decoder { getU16Decoder() ), ], - ['ConfidentialMintBurn', getUnitDecoder()], + [ + 'ConfidentialMintBurnConfig', + addDecoderSizePrefix( + getStructDecoder([ + ['supplyElgamalPubkey', getAddressDecoder()], + ['decryptableSupply', getEncryptedSupplyDecoder()], + ]), + getU16Decoder() + ), + ], [ 'ScaledUiAmountConfig', addDecoderSizePrefix( @@ -1361,11 +1395,16 @@ export function extension( > ): GetDiscriminatedUnionVariant; export function extension( - kind: 'ConfidentialMintBurn' + kind: 'ConfidentialMintBurnConfig', + data: GetDiscriminatedUnionVariantContent< + ExtensionArgs, + '__kind', + 'ConfidentialMintBurnConfig' + > ): GetDiscriminatedUnionVariant< ExtensionArgs, '__kind', - 'ConfidentialMintBurn' + 'ConfidentialMintBurnConfig' >; export function extension( kind: 'ScaledUiAmountConfig', diff --git a/clients/js/src/generated/types/extensionType.ts b/clients/js/src/generated/types/extensionType.ts index 7b65d198c..d3a2c78d8 100644 --- a/clients/js/src/generated/types/extensionType.ts +++ b/clients/js/src/generated/types/extensionType.ts @@ -41,6 +41,7 @@ export enum ExtensionType { TransferHookAccount, ConfidentialTransferFee, ConfidentialTransferFeeAmount, + ConfidentialMintBurn, ScaledUiAmountConfig, PausableConfig, PausableAccount, diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts index bdd843910..c92c91678 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -9,7 +9,9 @@ export * from './accountState'; export * from './authorityType'; export * from './decryptableBalance'; +export * from './decryptableSupply'; export * from './encryptedBalance'; +export * from './encryptedSupply'; export * from './extension'; export * from './extensionType'; export * from './tokenMetadataField'; diff --git a/interface/idl.json b/interface/idl.json index 1b5b08fb7..f56a71ade 100644 --- a/interface/idl.json +++ b/interface/idl.json @@ -3365,7 +3365,7 @@ "kind": "instructionArgumentNode", "name": "maximumPendingBalanceCreditCounter", "docs": [ - "The maximum number of despots and transfers that an account can receiver", + "The maximum number of deposits and transfers that an account can receive", "before the `ApplyPendingBalance` is executed" ], "type": { @@ -4906,6 +4906,758 @@ } ] }, + { + "kind": "instructionNode", + "name": "initializeConfidentialMintBurn", + "docs": [ + "Initialize confidential mint and burn for a mint.", + "", + "The instruction must be included within the same transaction as TokenInstruction::InitializeMint.", + "Otherwise another party can initialize the configuration.", + "", + "The instruction fails if the TokenInstruction::InitializeMint instruction has already executed for the mint." + ], + "optionalAccountStrategy": "programId", + "accounts": [ + { + "kind": "instructionAccountNode", + "name": "mint", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The SPL Token mint."] + } + ], + "arguments": [ + { + "kind": "instructionArgumentNode", + "name": "discriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 42 + } + }, + { + "kind": "instructionArgumentNode", + "name": "confidentialMintBurnDiscriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 0 + } + }, + { + "kind": "instructionArgumentNode", + "name": "supplyElgamalPubkey", + "docs": ["The ElGamal pubkey used to encrypt the confidential supply."], + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "instructionArgumentNode", + "name": "decryptableSupply", + "docs": ["The initial 0 supply encrypted with the supply aes key"], + "type": { + "kind": "definedTypeLinkNode", + "name": "decryptableSupply" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + }, + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 1 + } + ] + }, + { + "kind": "instructionNode", + "name": "rotateSupplyElGamalPubkey", + "docs": [ + "Rotates the ElGamal pubkey used to encrypt confidential supply", + "", + "The pending burn amount must be zero in order for this instruction", + "to be processed successfully." + ], + "optionalAccountStrategy": "programId", + "accounts": [ + { + "kind": "instructionAccountNode", + "name": "mint", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The SPL Token mint."] + }, + { + "kind": "instructionAccountNode", + "name": "equalityProofRecord", + "isWritable": false, + "isSigner": false, + "isOptional": false, + "docs": [ + "(Optional) Equality proof record account or context state account." + ] + } + ], + "arguments": [ + { + "kind": "instructionArgumentNode", + "name": "discriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 42 + } + }, + { + "kind": "instructionArgumentNode", + "name": "confidentialMintBurnDiscriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 1 + } + }, + { + "kind": "instructionArgumentNode", + "name": "newSupplyElgamalPubkey", + "docs": ["The new ElGamal pubkey used to encrypt the confidential supply."], + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "instructionArgumentNode", + "name": "cyphertextEqualityProofInstructionOffset", + "docs": [ + "Relative location of the", + "`ProofInstruction::VerifyCiphertextCiphertextEquality` instruction", + "to the `RotateSupplyElGamalPubkey` instruction in the transaction. If the offset", + "is `0`, then use a context state account for the proof." + ], + "type": { + "kind": "numberTypeNode", + "format": "i8", + "endian": "le" + } + } + ], + "remainingAccounts": [ + { + "kind": "instructionRemainingAccountsNode", + "isOptional": true, + "isSigner": true, + "docs": [], + "value": { + "kind": "argumentValueNode", + "name": "multiSigners" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + }, + { + "kind": "fieldDiscriminatorNode", + "name": "confidentialMintBurnDiscriminator", + "offset": 1 + } + ] + }, + { + "kind": "instructionNode", + "name": "updateDecryptableSupply", + "docs": [ + "Updates the decryptable supply of the mint" + ], + "optionalAccountStrategy": "programId", + "accounts": [ + { + "kind": "instructionAccountNode", + "name": "mint", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The SPL Token mint."] + } + ], + "arguments": [ + { + "kind": "instructionArgumentNode", + "name": "discriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 42 + } + }, + { + "kind": "instructionArgumentNode", + "name": "confidentialMintBurnDiscriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 2 + } + }, + { + "kind": "instructionArgumentNode", + "name": "newDecryptableSupply", + "docs": ["The new decryptable supply encrypted with the supply aes key"], + "type": { + "kind": "definedTypeLinkNode", + "name": "decryptableSupply" + } + } + ], + "remainingAccounts": [ + { + "kind": "instructionRemainingAccountsNode", + "isOptional": true, + "isSigner": true, + "docs": [], + "value": { + "kind": "argumentValueNode", + "name": "multiSigners" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + }, + { + "kind": "fieldDiscriminatorNode", + "name": "confidentialMintBurnDiscriminator", + "offset": 1 + } + ] + }, + { + "kind": "instructionNode", + "name": "mintToConfidentialBalance", + "docs": [ + "Mints tokens to confidential balance", + "", + "Fails if the destination account is frozen." + ], + "optionalAccountStrategy": "programId", + "accounts": [ + { + "kind": "instructionAccountNode", + "name": "token", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The SPL Token account."] + }, + { + "kind": "instructionAccountNode", + "name": "mint", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The SPL Token mint."] + }, + { + "kind": "instructionAccountNode", + "name": "authority", + "isWritable": false, + "isSigner": "either", + "isOptional": false, + "docs": ["The mint's minting authority or its multisignature account."] + }, + { + "kind": "instructionAccountNode", + "name": "equalityProofRecord", + "isWritable": false, + "isSigner": false, + "isOptional": false, + "docs": [ + "(Optional) Equality proof record account or context state account." + ] + }, + { + "kind": "instructionAccountNode", + "name": "ciphertextValidityProofRecord", + "isWritable": false, + "isSigner": false, + "isOptional": false, + "docs": [ + "(Optional) Ciphertext validity proof record account or context state account." + ] + }, + { + "kind": "instructionAccountNode", + "name": "rangeProofRecord", + "isWritable": false, + "isSigner": false, + "isOptional": false, + "docs": [ + "(Optional) Range proof record account or context state account." + ] + } + ], + "arguments": [ + { + "kind": "instructionArgumentNode", + "name": "discriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 42 + } + }, + { + "kind": "instructionArgumentNode", + "name": "confidentialMintBurnDiscriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 3 + } + }, + { + "kind": "instructionArgumentNode", + "name": "mintAmountAuditorCiphertextLo", + "docs": ["The low part of the mint amount encrypted with the auditor aes key"], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + } + }, + { + "kind": "instructionArgumentNode", + "name": "mintAmountAuditorCiphertextHi", + "docs": ["The high part of the mint amount encrypted with the auditor aes key"], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + } + }, + { + "kind": "instructionArgumentNode", + "name": "equalityProofInstructionOffset", + "docs": [ + "Relative location of the", + "`ProofInstruction::VerifyCiphertextCommitmentEquality` instruction", + "to the `MintToConfidentialBalance` instruction in the transaction. If the offset", + "is `0`, then use a context state account for the proof." + ], + "type": { + "kind": "numberTypeNode", + "format": "i8", + "endian": "le" + } + }, + { + "kind": "instructionArgumentNode", + "name": "ciphertextValidityProofInstructionOffset", + "docs": [ + "Relative location of the", + "`ProofInstruction::VerifyBatchedGroupedCiphertext3HandlesValidity` instruction", + "to the `MintToConfidentialBalance` instruction in the transaction. If the offset", + "is `0`, then use a context state account for the proof." + ], + "type": { + "kind": "numberTypeNode", + "format": "i8", + "endian": "le" + } + }, + { + "kind": "instructionArgumentNode", + "name": "rangeProofInstructionOffset", + "docs": [ + "Relative location of the", + "`ProofInstruction::VerifyBatchedRangeProofU128` instruction", + "to the `MintToConfidentialBalance` instruction in the transaction. If the offset", + "is `0`, then use a context state account for the proof." + ], + "type": { + "kind": "numberTypeNode", + "format": "i8", + "endian": "le" + } + }, + { + "kind": "instructionArgumentNode", + "name": "newDecryptableSupply", + "docs": ["The new decryptable supply encrypted with the supply aes key"], + "type": { + "kind": "definedTypeLinkNode", + "name": "decryptableSupply" + } + } + ], + "remainingAccounts": [ + { + "kind": "instructionRemainingAccountsNode", + "isOptional": true, + "isSigner": true, + "docs": [], + "value": { + "kind": "argumentValueNode", + "name": "multiSigners" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + }, + { + "kind": "fieldDiscriminatorNode", + "name": "confidentialMintBurnDiscriminator", + "offset": 1 + } + ] + }, + { + "kind": "instructionNode", + "name": "burnFromConfidentialBalance", + "docs": [ + "Burns tokens from confidential balance", + "", + "Fails if the destination account is frozen." + ], + "optionalAccountStrategy": "programId", + "accounts": [ + { + "kind": "instructionAccountNode", + "name": "token", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The SPL Token account."] + }, + { + "kind": "instructionAccountNode", + "name": "mint", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The SPL Token mint."] + }, + { + "kind": "instructionAccountNode", + "name": "authority", + "isWritable": false, + "isSigner": "either", + "isOptional": false, + "docs": ["The mint's minting authority or its multisignature account."] + }, + { + "kind": "instructionAccountNode", + "name": "equalityProofRecord", + "isWritable": false, + "isSigner": false, + "isOptional": true, + "docs": [ + "(Optional) Equality proof record account or context state account." + ] + }, + { + "kind": "instructionAccountNode", + "name": "ciphertextValidityProofRecord", + "isWritable": false, + "isSigner": false, + "isOptional": true, + "docs": [ + "(Optional) Ciphertext validity proof record account or context state account." + ] + }, + { + "kind": "instructionAccountNode", + "name": "rangeProofRecord", + "isWritable": false, + "isSigner": false, + "isOptional": true, + "docs": [ + "(Optional) Range proof record account or context state account." + ] + } + ], + "arguments": [ + { + "kind": "instructionArgumentNode", + "name": "discriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 42 + } + }, + { + "kind": "instructionArgumentNode", + "name": "confidentialMintBurnDiscriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 4 + } + }, + { + "kind": "instructionArgumentNode", + "name": "newDecryptableAvailableBalance", + "docs": ["The new decryptable available balance encrypted with the supply aes key"], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + } + }, + { + "kind": "instructionArgumentNode", + "name": "burnAmountAuditorCiphertextLo", + "docs": ["The low part of the burn amount encrypted with the auditor aes key"], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + } + }, + { + "kind": "instructionArgumentNode", + "name": "burnAmountAuditorCiphertextHi", + "docs": ["The high part of the burn amount encrypted with the auditor aes key"], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + } + }, + { + "kind": "instructionArgumentNode", + "name": "equalityProofInstructionOffset", + "docs": [ + "Relative location of the", + "`ProofInstruction::VerifyCiphertextCommitmentEquality` instruction", + "to the `BurnFromConfidentialBalance` instruction in the transaction. If the offset", + "is `0`, then use a context state account for the proof." + ], + "type": { + "kind": "numberTypeNode", + "format": "i8", + "endian": "le" + } + }, + { + "kind": "instructionArgumentNode", + "name": "ciphertextValidityProofInstructionOffset", + "docs": [ + "Relative location of the", + "`ProofInstruction::VerifyBatchedGroupedCiphertext3HandlesValidity` instruction", + "to the `BurnFromConfidentialBalance` instruction in the transaction. If the offset", + "is `0`, then use a context state account for the proof." + ], + "type": { + "kind": "numberTypeNode", + "format": "i8", + "endian": "le" + } + }, + { + "kind": "instructionArgumentNode", + "name": "rangeProofInstructionOffset", + "docs": [ + "Relative location of the", + "`ProofInstruction::VerifyBatchedRangeProofU128` instruction", + "to the `BurnFromConfidentialBalance` instruction in the transaction. If the offset", + "is `0`, then use a context state account for the proof." + ], + "type": { + "kind": "numberTypeNode", + "format": "i8", + "endian": "le" + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + }, + { + "kind": "fieldDiscriminatorNode", + "name": "confidentialMintBurnDiscriminator", + "offset": 1 + } + ], + "remainingAccounts": [ + { + "kind": "instructionRemainingAccountsNode", + "isOptional": true, + "isSigner": true, + "docs": [], + "value": { + "kind": "argumentValueNode", + "name": "multiSigners" + } + } + ] + }, + { + "kind": "instructionNode", + "name": "applyPendingBurn", + "docs": [ + "Applies the pending burn amount to the confidential supply" + ], + "optionalAccountStrategy": "programId", + "accounts": [ + { + "kind": "instructionAccountNode", + "name": "mint", + "isWritable": true, + "isSigner": false, + "isOptional": false, + "docs": ["The SPL Token mint."] + }, + { + "kind": "instructionAccountNode", + "name": "authority", + "isWritable": false, + "isSigner": "either", + "isOptional": false, + "docs": ["The mint's minting authority or its multisignature account."] + } + ], + "arguments": [ + { + "kind": "instructionArgumentNode", + "name": "discriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 42 + } + }, + { + "kind": "instructionArgumentNode", + "name": "confidentialMintBurnDiscriminator", + "defaultValueStrategy": "omitted", + "docs": [], + "type": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + }, + "defaultValue": { + "kind": "numberValueNode", + "number": 5 + } + } + ], + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + }, + { + "kind": "fieldDiscriminatorNode", + "name": "confidentialMintBurnDiscriminator", + "offset": 1 + } + ], + "remainingAccounts": [ + { + "kind": "instructionRemainingAccountsNode", + "isOptional": true, + "isSigner": true, + "docs": [], + "value": { + "kind": "argumentValueNode", + "name": "multiSigners" + } + } + ] + }, { "kind": "instructionNode", "name": "initializeDefaultAccountState", @@ -8640,6 +9392,30 @@ } } }, + { + "kind": "definedTypeNode", + "name": "encryptedSupply", + "docs": ["ElGamal ciphertext containing the confidential supply."], + "type": { + "kind": "fixedSizeTypeNode", + "size": 64, + "type": { + "kind": "bytesTypeNode" + } + } + }, + { + "kind": "definedTypeNode", + "name": "decryptableSupply", + "docs": ["Authenticated encryption containing the confidential supply."], + "type": { + "kind": "fixedSizeTypeNode", + "size": 36, + "type": { + "kind": "bytesTypeNode" + } + } + }, { "kind": "definedTypeNode", "name": "extension", @@ -9769,8 +10545,42 @@ } }, { - "kind": "enumEmptyVariantTypeNode", - "name": "confidentialMintBurn" + "kind": "enumStructVariantTypeNode", + "name": "confidentialMintBurnConfig", + "struct": { + "kind": "sizePrefixTypeNode", + "type": { + "kind": "structTypeNode", + "fields": [ + { + "kind": "structFieldTypeNode", + "name": "supplyElgamalPubkey", + "docs": [ + "The ElGamal pubkey used to encrypt the confidential supply." + ], + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "structFieldTypeNode", + "name": "decryptableSupply", + "docs": [ + "The decryptable confidential supply of the mint." + ], + "type": { + "kind": "definedTypeLinkNode", + "name": "encryptedSupply" + } + } + ] + }, + "prefix": { + "kind": "numberTypeNode", + "format": "u16", + "endian": "le" + } + } }, { "kind": "enumStructVariantTypeNode", @@ -10004,6 +10814,11 @@ "name": "confidentialTransferFeeAmount", "docs": ["Includes confidential withheld transfer fees"] }, + { + "kind": "enumEmptyVariantTypeNode", + "name": "confidentialMintBurn", + "docs": ["Includes confidential mint-burn configuration"] + }, { "kind": "enumEmptyVariantTypeNode", "name": "scaledUiAmountConfig",