UNPKG

@wuwei-labs/srsly

Version:
168 lines 7.69 kB
"use strict"; /** * 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 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.UPDATE_CONTRACT_THREAD_DISCRIMINATOR = void 0; exports.getUpdateContractThreadDiscriminatorBytes = getUpdateContractThreadDiscriminatorBytes; exports.getUpdateContractThreadInstructionDataEncoder = getUpdateContractThreadInstructionDataEncoder; exports.getUpdateContractThreadInstructionDataDecoder = getUpdateContractThreadInstructionDataDecoder; exports.getUpdateContractThreadInstructionDataCodec = getUpdateContractThreadInstructionDataCodec; exports.getUpdateContractThreadInstructionAsync = getUpdateContractThreadInstructionAsync; exports.getUpdateContractThreadInstruction = getUpdateContractThreadInstruction; exports.parseUpdateContractThreadInstruction = parseUpdateContractThreadInstruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); exports.UPDATE_CONTRACT_THREAD_DISCRIMINATOR = new Uint8Array([ 183, 75, 119, 98, 134, 24, 187, 91, ]); function getUpdateContractThreadDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.UPDATE_CONTRACT_THREAD_DISCRIMINATOR); } function getUpdateContractThreadInstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([ ['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['lamports', (0, kit_1.getU64Encoder)()], ['paymentsFreq', (0, kit_1.getOptionEncoder)((0, kit_1.addEncoderSizePrefix)((0, kit_1.getUtf8Encoder)(), (0, kit_1.getU32Encoder)()))], ]), value => ({ ...value, discriminator: exports.UPDATE_CONTRACT_THREAD_DISCRIMINATOR, })); } function getUpdateContractThreadInstructionDataDecoder() { return (0, kit_1.getStructDecoder)([ ['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['lamports', (0, kit_1.getU64Decoder)()], ['paymentsFreq', (0, kit_1.getOptionDecoder)((0, kit_1.addDecoderSizePrefix)((0, kit_1.getUtf8Decoder)(), (0, kit_1.getU32Decoder)()))], ]); } function getUpdateContractThreadInstructionDataCodec() { return (0, kit_1.combineCodec)(getUpdateContractThreadInstructionDataEncoder(), getUpdateContractThreadInstructionDataDecoder()); } async function getUpdateContractThreadInstructionAsync(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { payer: { value: input.payer ?? null, isWritable: true }, config: { value: input.config ?? null, isWritable: false }, contract: { value: input.contract ?? null, isWritable: true }, rentalAuthority: { value: input.rentalAuthority ?? null, isWritable: true }, contractThread: { value: input.contractThread ?? null, isWritable: true }, antegenProgram: { value: input.antegenProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, }; const accounts = originalAccounts; // Original args. const args = { ...input }; // Resolve default values. if (!accounts.config.value) { accounts.config.value = await (0, kit_1.getProgramDerivedAddress)({ programAddress, seeds: [(0, kit_1.getBytesEncoder)().encode(new Uint8Array([99, 111, 110, 102, 105, 103]))], }); } if (!accounts.rentalAuthority.value) { accounts.rentalAuthority.value = await (0, kit_1.getProgramDerivedAddress)({ programAddress, seeds: [ (0, kit_1.getBytesEncoder)().encode(new Uint8Array([ 114, 101, 110, 116, 97, 108, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121, ])), ], }); } if (!accounts.antegenProgram.value) { accounts.antegenProgram.value = 'AgTv5w1UvUb6zeqkThwMrztGu9hpepBu8YLghuR4dpSx'; } if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111'; } const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta(accounts.payer), getAccountMeta(accounts.config), getAccountMeta(accounts.contract), getAccountMeta(accounts.rentalAuthority), getAccountMeta(accounts.contractThread), getAccountMeta(accounts.antegenProgram), getAccountMeta(accounts.systemProgram), ], data: getUpdateContractThreadInstructionDataEncoder().encode(args), programAddress, }); } function getUpdateContractThreadInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { payer: { value: input.payer ?? null, isWritable: true }, config: { value: input.config ?? null, isWritable: false }, contract: { value: input.contract ?? null, isWritable: true }, rentalAuthority: { value: input.rentalAuthority ?? null, isWritable: true }, contractThread: { value: input.contractThread ?? null, isWritable: true }, antegenProgram: { value: input.antegenProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, }; const accounts = originalAccounts; // Original args. const args = { ...input }; // Resolve default values. if (!accounts.antegenProgram.value) { accounts.antegenProgram.value = 'AgTv5w1UvUb6zeqkThwMrztGu9hpepBu8YLghuR4dpSx'; } if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111'; } const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta(accounts.payer), getAccountMeta(accounts.config), getAccountMeta(accounts.contract), getAccountMeta(accounts.rentalAuthority), getAccountMeta(accounts.contractThread), getAccountMeta(accounts.antegenProgram), getAccountMeta(accounts.systemProgram), ], data: getUpdateContractThreadInstructionDataEncoder().encode(args), programAddress, }); } function parseUpdateContractThreadInstruction(instruction) { if (instruction.accounts.length < 7) { // TODO: Coded error. throw new Error('Not enough accounts'); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = instruction.accounts[accountIndex]; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { payer: getNextAccount(), config: getNextAccount(), contract: getNextAccount(), rentalAuthority: getNextAccount(), contractThread: getNextAccount(), antegenProgram: getNextAccount(), systemProgram: getNextAccount(), }, data: getUpdateContractThreadInstructionDataDecoder().decode(instruction.data), }; } //# sourceMappingURL=updateContractThread.js.map