/** * 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, getU16Decoder, getU16Encoder, getU64Decoder, getU64Encoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, 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 { getAccountMetaFactory, type ResolvedInstructionAccount, } from '@solana/program-client-core'; import { SAGE_PROGRAM_ADDRESS } from '../programs'; export const RETIRE_DEMOCRACY_PTR_LEGACY_SOURCE_DISCRIMINATOR = new Uint8Array([ 79, 36, 179, 252, 210, 147, 92, 176, ]); export function getRetireDemocracyPtrLegacySourceDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( RETIRE_DEMOCRACY_PTR_LEGACY_SOURCE_DISCRIMINATOR, ); } export type RetireDemocracyPtrLegacySourceInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountCurrentSigner extends string | AccountMeta = string, TAccountCurrentProfile extends string | AccountMeta = string, TAccountCurrentCertificate extends string | AccountMeta = string, TAccountCurrentProgram extends string | AccountMeta = 'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u', TAccountGame extends string | AccountMeta = string, TAccountIdentity extends string | AccountMeta = string, TAccountMigration extends string | AccountMeta = string, TAccountProgress extends string | AccountMeta = string, TAccountRoute extends string | AccountMeta = string, TAccountFrozen extends string | AccountMeta = string, TAccountLock extends string | AccountMeta = string, TAccountVoter extends string | AccountMeta = string, TAccountGovernance extends string | AccountMeta = string, TAccountTreasury extends string | AccountMeta = string, TAccountOpening extends string | AccountMeta = string, TAccountDelegation extends string | AccountMeta = string, TAccountClaim extends string | AccountMeta = string, TAccountStarbasePlayer extends string | AccountMeta = string, TAccountReceipt extends string | AccountMeta = string, TAccountSystemProgram extends string | AccountMeta = '11111111111111111111111111111111', TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountCurrentSigner extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountCurrentSigner, TAccountCurrentProfile extends string ? WritableAccount : TAccountCurrentProfile, TAccountCurrentCertificate extends string ? ReadonlyAccount : TAccountCurrentCertificate, TAccountCurrentProgram extends string ? ReadonlyAccount : TAccountCurrentProgram, TAccountGame extends string ? ReadonlyAccount : TAccountGame, TAccountIdentity extends string ? ReadonlyAccount : TAccountIdentity, TAccountMigration extends string ? ReadonlyAccount : TAccountMigration, TAccountProgress extends string ? WritableAccount : TAccountProgress, TAccountRoute extends string ? ReadonlyAccount : TAccountRoute, TAccountFrozen extends string ? ReadonlyAccount : TAccountFrozen, TAccountLock extends string ? WritableAccount : TAccountLock, TAccountVoter extends string ? WritableAccount : TAccountVoter, TAccountGovernance extends string ? WritableAccount : TAccountGovernance, TAccountTreasury extends string ? WritableAccount : TAccountTreasury, TAccountOpening extends string ? WritableAccount : TAccountOpening, TAccountDelegation extends string ? WritableAccount : TAccountDelegation, TAccountClaim extends string ? WritableAccount : TAccountClaim, TAccountStarbasePlayer extends string ? WritableAccount : TAccountStarbasePlayer, TAccountReceipt extends string ? WritableAccount : TAccountReceipt, TAccountSystemProgram extends string ? ReadonlyAccount : TAccountSystemProgram, ...TRemainingAccounts, ] >; export type RetireDemocracyPtrLegacySourceInstructionData = { discriminator: ReadonlyUint8Array; keyIndex: number; expectedAuthorizationRevision: bigint; }; export type RetireDemocracyPtrLegacySourceInstructionDataArgs = { keyIndex: number; expectedAuthorizationRevision: number | bigint; }; export function getRetireDemocracyPtrLegacySourceInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['keyIndex', getU16Encoder()], ['expectedAuthorizationRevision', getU64Encoder()], ]), (value) => ({ ...value, discriminator: RETIRE_DEMOCRACY_PTR_LEGACY_SOURCE_DISCRIMINATOR, }), ); } export function getRetireDemocracyPtrLegacySourceInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['keyIndex', getU16Decoder()], ['expectedAuthorizationRevision', getU64Decoder()], ]); } export function getRetireDemocracyPtrLegacySourceInstructionDataCodec(): FixedSizeCodec< RetireDemocracyPtrLegacySourceInstructionDataArgs, RetireDemocracyPtrLegacySourceInstructionData > { return combineCodec( getRetireDemocracyPtrLegacySourceInstructionDataEncoder(), getRetireDemocracyPtrLegacySourceInstructionDataDecoder(), ); } export type RetireDemocracyPtrLegacySourceInput< TAccountCurrentSigner extends string = string, TAccountCurrentProfile extends string = string, TAccountCurrentCertificate extends string = string, TAccountCurrentProgram extends string = string, TAccountGame extends string = string, TAccountIdentity extends string = string, TAccountMigration extends string = string, TAccountProgress extends string = string, TAccountRoute extends string = string, TAccountFrozen extends string = string, TAccountLock extends string = string, TAccountVoter extends string = string, TAccountGovernance extends string = string, TAccountTreasury extends string = string, TAccountOpening extends string = string, TAccountDelegation extends string = string, TAccountClaim extends string = string, TAccountStarbasePlayer extends string = string, TAccountReceipt extends string = string, TAccountSystemProgram extends string = string, > = { currentSigner: TransactionSigner; currentProfile: Address; currentCertificate?: Address; currentProgram?: Address; game: Address; identity: Address; migration: Address; progress: Address; route: Address; frozen: Address; lock: Address; voter: Address; governance: Address; treasury: Address; opening: Address; delegation: Address; claim: Address; /** The original source remains the release destination after recovery or System deletion. */ starbasePlayer: Address; receipt: Address; systemProgram?: Address; keyIndex: RetireDemocracyPtrLegacySourceInstructionDataArgs['keyIndex']; expectedAuthorizationRevision: RetireDemocracyPtrLegacySourceInstructionDataArgs['expectedAuthorizationRevision']; }; export function getRetireDemocracyPtrLegacySourceInstruction< TAccountCurrentSigner extends string, TAccountCurrentProfile extends string, TAccountCurrentCertificate extends string, TAccountCurrentProgram extends string, TAccountGame extends string, TAccountIdentity extends string, TAccountMigration extends string, TAccountProgress extends string, TAccountRoute extends string, TAccountFrozen extends string, TAccountLock extends string, TAccountVoter extends string, TAccountGovernance extends string, TAccountTreasury extends string, TAccountOpening extends string, TAccountDelegation extends string, TAccountClaim extends string, TAccountStarbasePlayer extends string, TAccountReceipt extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: RetireDemocracyPtrLegacySourceInput< TAccountCurrentSigner, TAccountCurrentProfile, TAccountCurrentCertificate, TAccountCurrentProgram, TAccountGame, TAccountIdentity, TAccountMigration, TAccountProgress, TAccountRoute, TAccountFrozen, TAccountLock, TAccountVoter, TAccountGovernance, TAccountTreasury, TAccountOpening, TAccountDelegation, TAccountClaim, TAccountStarbasePlayer, TAccountReceipt, TAccountSystemProgram >, config?: { programAddress?: TProgramAddress }, ): RetireDemocracyPtrLegacySourceInstruction< TProgramAddress, TAccountCurrentSigner, TAccountCurrentProfile, TAccountCurrentCertificate, TAccountCurrentProgram, TAccountGame, TAccountIdentity, TAccountMigration, TAccountProgress, TAccountRoute, TAccountFrozen, TAccountLock, TAccountVoter, TAccountGovernance, TAccountTreasury, TAccountOpening, TAccountDelegation, TAccountClaim, TAccountStarbasePlayer, TAccountReceipt, TAccountSystemProgram > { // Program address. const programAddress = config?.programAddress ?? SAGE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { currentSigner: { value: input.currentSigner ?? null, isWritable: false }, currentProfile: { value: input.currentProfile ?? null, isWritable: true }, currentCertificate: { value: input.currentCertificate ?? null, isWritable: false, }, currentProgram: { value: input.currentProgram ?? null, isWritable: false }, game: { value: input.game ?? null, isWritable: false }, identity: { value: input.identity ?? null, isWritable: false }, migration: { value: input.migration ?? null, isWritable: false }, progress: { value: input.progress ?? null, isWritable: true }, route: { value: input.route ?? null, isWritable: false }, frozen: { value: input.frozen ?? null, isWritable: false }, lock: { value: input.lock ?? null, isWritable: true }, voter: { value: input.voter ?? null, isWritable: true }, governance: { value: input.governance ?? null, isWritable: true }, treasury: { value: input.treasury ?? null, isWritable: true }, opening: { value: input.opening ?? null, isWritable: true }, delegation: { value: input.delegation ?? null, isWritable: true }, claim: { value: input.claim ?? null, isWritable: true }, starbasePlayer: { value: input.starbasePlayer ?? null, isWritable: true }, receipt: { value: input.receipt ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Original args. const args = { ...input }; // Resolve default values. if (!accounts.currentProgram.value) { accounts.currentProgram.value = 'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u' as Address<'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u'>; } if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta('currentSigner', accounts.currentSigner), getAccountMeta('currentProfile', accounts.currentProfile), getAccountMeta('currentCertificate', accounts.currentCertificate), getAccountMeta('currentProgram', accounts.currentProgram), getAccountMeta('game', accounts.game), getAccountMeta('identity', accounts.identity), getAccountMeta('migration', accounts.migration), getAccountMeta('progress', accounts.progress), getAccountMeta('route', accounts.route), getAccountMeta('frozen', accounts.frozen), getAccountMeta('lock', accounts.lock), getAccountMeta('voter', accounts.voter), getAccountMeta('governance', accounts.governance), getAccountMeta('treasury', accounts.treasury), getAccountMeta('opening', accounts.opening), getAccountMeta('delegation', accounts.delegation), getAccountMeta('claim', accounts.claim), getAccountMeta('starbasePlayer', accounts.starbasePlayer), getAccountMeta('receipt', accounts.receipt), getAccountMeta('systemProgram', accounts.systemProgram), ], data: getRetireDemocracyPtrLegacySourceInstructionDataEncoder().encode( args as RetireDemocracyPtrLegacySourceInstructionDataArgs, ), programAddress, } as RetireDemocracyPtrLegacySourceInstruction< TProgramAddress, TAccountCurrentSigner, TAccountCurrentProfile, TAccountCurrentCertificate, TAccountCurrentProgram, TAccountGame, TAccountIdentity, TAccountMigration, TAccountProgress, TAccountRoute, TAccountFrozen, TAccountLock, TAccountVoter, TAccountGovernance, TAccountTreasury, TAccountOpening, TAccountDelegation, TAccountClaim, TAccountStarbasePlayer, TAccountReceipt, TAccountSystemProgram >); } export type ParsedRetireDemocracyPtrLegacySourceInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { currentSigner: TAccountMetas[0]; currentProfile: TAccountMetas[1]; currentCertificate?: TAccountMetas[2] | undefined; currentProgram: TAccountMetas[3]; game: TAccountMetas[4]; identity: TAccountMetas[5]; migration: TAccountMetas[6]; progress: TAccountMetas[7]; route: TAccountMetas[8]; frozen: TAccountMetas[9]; lock: TAccountMetas[10]; voter: TAccountMetas[11]; governance: TAccountMetas[12]; treasury: TAccountMetas[13]; opening: TAccountMetas[14]; delegation: TAccountMetas[15]; claim: TAccountMetas[16]; /** The original source remains the release destination after recovery or System deletion. */ starbasePlayer: TAccountMetas[17]; receipt: TAccountMetas[18]; systemProgram: TAccountMetas[19]; }; data: RetireDemocracyPtrLegacySourceInstructionData; }; export function parseRetireDemocracyPtrLegacySourceInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedRetireDemocracyPtrLegacySourceInstruction { if (instruction.accounts.length < 20) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 20, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; const getNextOptionalAccount = () => { const accountMeta = getNextAccount(); return accountMeta.address === SAGE_PROGRAM_ADDRESS ? undefined : accountMeta; }; return { programAddress: instruction.programAddress, accounts: { currentSigner: getNextAccount(), currentProfile: getNextAccount(), currentCertificate: getNextOptionalAccount(), currentProgram: getNextAccount(), game: getNextAccount(), identity: getNextAccount(), migration: getNextAccount(), progress: getNextAccount(), route: getNextAccount(), frozen: getNextAccount(), lock: getNextAccount(), voter: getNextAccount(), governance: getNextAccount(), treasury: getNextAccount(), opening: getNextAccount(), delegation: getNextAccount(), claim: getNextAccount(), starbasePlayer: getNextAccount(), receipt: getNextAccount(), systemProgram: getNextAccount(), }, data: getRetireDemocracyPtrLegacySourceInstructionDataDecoder().decode( instruction.data, ), }; }