/** * This code was AUTOGENERATED using the Codama library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ import { combineCodec, fixDecoderSize, fixEncoderSize, getArrayDecoder, getArrayEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU16Decoder, getU16Encoder, getU32Decoder, getU32Encoder, 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 DEPOSIT_DEMOCRACY_PTR_BACKING_DISCRIMINATOR = new Uint8Array([ 26, 194, 137, 110, 165, 90, 93, 98, ]); export function getDepositDemocracyPtrBackingDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( DEPOSIT_DEMOCRACY_PTR_BACKING_DISCRIMINATOR, ); } export type DepositDemocracyPtrBackingInstruction< 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', TAccountSourceSigner extends string | AccountMeta = string, TAccountSourceProfile extends string | AccountMeta = string, TAccountSourceCertificate extends string | AccountMeta = string, TAccountSourceProgram extends string | AccountMeta = 'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u', TAccountPositionAuthorityGame extends string | AccountMeta = string, TAccountPositionAuthorityIdentity extends string | AccountMeta = string, TAccountPositionAuthorityRoot extends string | AccountMeta = string, TAccountPositionAllocation extends string | AccountMeta = string, TAccountPositionClaimHistory extends string | AccountMeta = string, TAccountPositionGeneration extends string | AccountMeta = string, TAccountHistory extends string | AccountMeta = string, TAccountRoute extends string | AccountMeta = string, TAccountSystem extends string | AccountMeta = string, TAccountStarbasePlayer extends string | AccountMeta = string, TAccountBacking 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, TAccountSourceSigner extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountSourceSigner, TAccountSourceProfile extends string ? WritableAccount : TAccountSourceProfile, TAccountSourceCertificate extends string ? ReadonlyAccount : TAccountSourceCertificate, TAccountSourceProgram extends string ? ReadonlyAccount : TAccountSourceProgram, TAccountPositionAuthorityGame extends string ? ReadonlyAccount : TAccountPositionAuthorityGame, TAccountPositionAuthorityIdentity extends string ? ReadonlyAccount : TAccountPositionAuthorityIdentity, TAccountPositionAuthorityRoot extends string ? WritableAccount : TAccountPositionAuthorityRoot, TAccountPositionAllocation extends string ? WritableAccount : TAccountPositionAllocation, TAccountPositionClaimHistory extends string ? WritableAccount : TAccountPositionClaimHistory, TAccountPositionGeneration extends string ? WritableAccount : TAccountPositionGeneration, TAccountHistory extends string ? ReadonlyAccount : TAccountHistory, TAccountRoute extends string ? ReadonlyAccount : TAccountRoute, TAccountSystem extends string ? ReadonlyAccount : TAccountSystem, TAccountStarbasePlayer extends string ? WritableAccount : TAccountStarbasePlayer, TAccountBacking extends string ? WritableAccount : TAccountBacking, TAccountSystemProgram extends string ? ReadonlyAccount : TAccountSystemProgram, ...TRemainingAccounts, ] >; export type DepositDemocracyPtrBackingInstructionData = { discriminator: ReadonlyUint8Array; currentKeyIndex: number; sourceKeyIndex: number; expectedAuthorizationRevision: bigint; expectedRootRevision: bigint; expectedAllocationRevision: bigint; expectedBackingRevision: bigint; crew: number; housingQuantities: Array; }; export type DepositDemocracyPtrBackingInstructionDataArgs = { currentKeyIndex: number; sourceKeyIndex: number; expectedAuthorizationRevision: number | bigint; expectedRootRevision: number | bigint; expectedAllocationRevision: number | bigint; expectedBackingRevision: number | bigint; crew: number; housingQuantities: Array; }; export function getDepositDemocracyPtrBackingInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['currentKeyIndex', getU16Encoder()], ['sourceKeyIndex', getU16Encoder()], ['expectedAuthorizationRevision', getU64Encoder()], ['expectedRootRevision', getU64Encoder()], ['expectedAllocationRevision', getU64Encoder()], ['expectedBackingRevision', getU64Encoder()], ['crew', getU32Encoder()], ['housingQuantities', getArrayEncoder(getU64Encoder(), { size: 18 })], ]), (value) => ({ ...value, discriminator: DEPOSIT_DEMOCRACY_PTR_BACKING_DISCRIMINATOR, }), ); } export function getDepositDemocracyPtrBackingInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['currentKeyIndex', getU16Decoder()], ['sourceKeyIndex', getU16Decoder()], ['expectedAuthorizationRevision', getU64Decoder()], ['expectedRootRevision', getU64Decoder()], ['expectedAllocationRevision', getU64Decoder()], ['expectedBackingRevision', getU64Decoder()], ['crew', getU32Decoder()], ['housingQuantities', getArrayDecoder(getU64Decoder(), { size: 18 })], ]); } export function getDepositDemocracyPtrBackingInstructionDataCodec(): FixedSizeCodec< DepositDemocracyPtrBackingInstructionDataArgs, DepositDemocracyPtrBackingInstructionData > { return combineCodec( getDepositDemocracyPtrBackingInstructionDataEncoder(), getDepositDemocracyPtrBackingInstructionDataDecoder(), ); } export type DepositDemocracyPtrBackingInput< TAccountCurrentSigner extends string = string, TAccountCurrentProfile extends string = string, TAccountCurrentCertificate extends string = string, TAccountCurrentProgram extends string = string, TAccountSourceSigner extends string = string, TAccountSourceProfile extends string = string, TAccountSourceCertificate extends string = string, TAccountSourceProgram extends string = string, TAccountPositionAuthorityGame extends string = string, TAccountPositionAuthorityIdentity extends string = string, TAccountPositionAuthorityRoot extends string = string, TAccountPositionAllocation extends string = string, TAccountPositionClaimHistory extends string = string, TAccountPositionGeneration extends string = string, TAccountHistory extends string = string, TAccountRoute extends string = string, TAccountSystem extends string = string, TAccountStarbasePlayer extends string = string, TAccountBacking extends string = string, TAccountSystemProgram extends string = string, > = { currentSigner: TransactionSigner; currentProfile: Address; currentCertificate?: Address; currentProgram?: Address; sourceSigner: TransactionSigner; sourceProfile: Address; sourceCertificate?: Address; sourceProgram?: Address; positionAuthorityGame: Address; positionAuthorityIdentity: Address; positionAuthorityRoot: Address; positionAllocation: Address; positionClaimHistory: Address; positionGeneration: Address; history: Address; route: Address; system: Address; starbasePlayer: Address; backing: Address; systemProgram?: Address; currentKeyIndex: DepositDemocracyPtrBackingInstructionDataArgs['currentKeyIndex']; sourceKeyIndex: DepositDemocracyPtrBackingInstructionDataArgs['sourceKeyIndex']; expectedAuthorizationRevision: DepositDemocracyPtrBackingInstructionDataArgs['expectedAuthorizationRevision']; expectedRootRevision: DepositDemocracyPtrBackingInstructionDataArgs['expectedRootRevision']; expectedAllocationRevision: DepositDemocracyPtrBackingInstructionDataArgs['expectedAllocationRevision']; expectedBackingRevision: DepositDemocracyPtrBackingInstructionDataArgs['expectedBackingRevision']; crew: DepositDemocracyPtrBackingInstructionDataArgs['crew']; housingQuantities: DepositDemocracyPtrBackingInstructionDataArgs['housingQuantities']; }; export function getDepositDemocracyPtrBackingInstruction< TAccountCurrentSigner extends string, TAccountCurrentProfile extends string, TAccountCurrentCertificate extends string, TAccountCurrentProgram extends string, TAccountSourceSigner extends string, TAccountSourceProfile extends string, TAccountSourceCertificate extends string, TAccountSourceProgram extends string, TAccountPositionAuthorityGame extends string, TAccountPositionAuthorityIdentity extends string, TAccountPositionAuthorityRoot extends string, TAccountPositionAllocation extends string, TAccountPositionClaimHistory extends string, TAccountPositionGeneration extends string, TAccountHistory extends string, TAccountRoute extends string, TAccountSystem extends string, TAccountStarbasePlayer extends string, TAccountBacking extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: DepositDemocracyPtrBackingInput< TAccountCurrentSigner, TAccountCurrentProfile, TAccountCurrentCertificate, TAccountCurrentProgram, TAccountSourceSigner, TAccountSourceProfile, TAccountSourceCertificate, TAccountSourceProgram, TAccountPositionAuthorityGame, TAccountPositionAuthorityIdentity, TAccountPositionAuthorityRoot, TAccountPositionAllocation, TAccountPositionClaimHistory, TAccountPositionGeneration, TAccountHistory, TAccountRoute, TAccountSystem, TAccountStarbasePlayer, TAccountBacking, TAccountSystemProgram >, config?: { programAddress?: TProgramAddress }, ): DepositDemocracyPtrBackingInstruction< TProgramAddress, TAccountCurrentSigner, TAccountCurrentProfile, TAccountCurrentCertificate, TAccountCurrentProgram, TAccountSourceSigner, TAccountSourceProfile, TAccountSourceCertificate, TAccountSourceProgram, TAccountPositionAuthorityGame, TAccountPositionAuthorityIdentity, TAccountPositionAuthorityRoot, TAccountPositionAllocation, TAccountPositionClaimHistory, TAccountPositionGeneration, TAccountHistory, TAccountRoute, TAccountSystem, TAccountStarbasePlayer, TAccountBacking, 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 }, sourceSigner: { value: input.sourceSigner ?? null, isWritable: false }, sourceProfile: { value: input.sourceProfile ?? null, isWritable: true }, sourceCertificate: { value: input.sourceCertificate ?? null, isWritable: false, }, sourceProgram: { value: input.sourceProgram ?? null, isWritable: false }, positionAuthorityGame: { value: input.positionAuthorityGame ?? null, isWritable: false, }, positionAuthorityIdentity: { value: input.positionAuthorityIdentity ?? null, isWritable: false, }, positionAuthorityRoot: { value: input.positionAuthorityRoot ?? null, isWritable: true, }, positionAllocation: { value: input.positionAllocation ?? null, isWritable: true, }, positionClaimHistory: { value: input.positionClaimHistory ?? null, isWritable: true, }, positionGeneration: { value: input.positionGeneration ?? null, isWritable: true, }, history: { value: input.history ?? null, isWritable: false }, route: { value: input.route ?? null, isWritable: false }, system: { value: input.system ?? null, isWritable: false }, starbasePlayer: { value: input.starbasePlayer ?? null, isWritable: true }, backing: { value: input.backing ?? 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.sourceProgram.value) { accounts.sourceProgram.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('sourceSigner', accounts.sourceSigner), getAccountMeta('sourceProfile', accounts.sourceProfile), getAccountMeta('sourceCertificate', accounts.sourceCertificate), getAccountMeta('sourceProgram', accounts.sourceProgram), getAccountMeta('positionAuthorityGame', accounts.positionAuthorityGame), getAccountMeta( 'positionAuthorityIdentity', accounts.positionAuthorityIdentity, ), getAccountMeta('positionAuthorityRoot', accounts.positionAuthorityRoot), getAccountMeta('positionAllocation', accounts.positionAllocation), getAccountMeta('positionClaimHistory', accounts.positionClaimHistory), getAccountMeta('positionGeneration', accounts.positionGeneration), getAccountMeta('history', accounts.history), getAccountMeta('route', accounts.route), getAccountMeta('system', accounts.system), getAccountMeta('starbasePlayer', accounts.starbasePlayer), getAccountMeta('backing', accounts.backing), getAccountMeta('systemProgram', accounts.systemProgram), ], data: getDepositDemocracyPtrBackingInstructionDataEncoder().encode( args as DepositDemocracyPtrBackingInstructionDataArgs, ), programAddress, } as DepositDemocracyPtrBackingInstruction< TProgramAddress, TAccountCurrentSigner, TAccountCurrentProfile, TAccountCurrentCertificate, TAccountCurrentProgram, TAccountSourceSigner, TAccountSourceProfile, TAccountSourceCertificate, TAccountSourceProgram, TAccountPositionAuthorityGame, TAccountPositionAuthorityIdentity, TAccountPositionAuthorityRoot, TAccountPositionAllocation, TAccountPositionClaimHistory, TAccountPositionGeneration, TAccountHistory, TAccountRoute, TAccountSystem, TAccountStarbasePlayer, TAccountBacking, TAccountSystemProgram >); } export type ParsedDepositDemocracyPtrBackingInstruction< 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]; sourceSigner: TAccountMetas[4]; sourceProfile: TAccountMetas[5]; sourceCertificate?: TAccountMetas[6] | undefined; sourceProgram: TAccountMetas[7]; positionAuthorityGame: TAccountMetas[8]; positionAuthorityIdentity: TAccountMetas[9]; positionAuthorityRoot: TAccountMetas[10]; positionAllocation: TAccountMetas[11]; positionClaimHistory: TAccountMetas[12]; positionGeneration: TAccountMetas[13]; history: TAccountMetas[14]; route: TAccountMetas[15]; system: TAccountMetas[16]; starbasePlayer: TAccountMetas[17]; backing: TAccountMetas[18]; systemProgram: TAccountMetas[19]; }; data: DepositDemocracyPtrBackingInstructionData; }; export function parseDepositDemocracyPtrBackingInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedDepositDemocracyPtrBackingInstruction { 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(), sourceSigner: getNextAccount(), sourceProfile: getNextAccount(), sourceCertificate: getNextOptionalAccount(), sourceProgram: getNextAccount(), positionAuthorityGame: getNextAccount(), positionAuthorityIdentity: getNextAccount(), positionAuthorityRoot: getNextAccount(), positionAllocation: getNextAccount(), positionClaimHistory: getNextAccount(), positionGeneration: getNextAccount(), history: getNextAccount(), route: getNextAccount(), system: getNextAccount(), starbasePlayer: getNextAccount(), backing: getNextAccount(), systemProgram: getNextAccount(), }, data: getDepositDemocracyPtrBackingInstructionDataDecoder().decode( instruction.data, ), }; }