UNPKG

@wuwei-labs/srsly

Version:
148 lines 6.77 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.RELEASE_RENTAL_DISCRIMINATOR = void 0; exports.getReleaseRentalDiscriminatorBytes = getReleaseRentalDiscriminatorBytes; exports.getReleaseRentalInstructionDataEncoder = getReleaseRentalInstructionDataEncoder; exports.getReleaseRentalInstructionDataDecoder = getReleaseRentalInstructionDataDecoder; exports.getReleaseRentalInstructionDataCodec = getReleaseRentalInstructionDataCodec; exports.getReleaseRentalInstructionAsync = getReleaseRentalInstructionAsync; exports.getReleaseRentalInstruction = getReleaseRentalInstruction; exports.parseReleaseRentalInstruction = parseReleaseRentalInstruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); exports.RELEASE_RENTAL_DISCRIMINATOR = new Uint8Array([99, 35, 221, 147, 185, 205, 23, 12]); function getReleaseRentalDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.RELEASE_RENTAL_DISCRIMINATOR); } function getReleaseRentalInstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)]]), value => ({ ...value, discriminator: exports.RELEASE_RENTAL_DISCRIMINATOR })); } function getReleaseRentalInstructionDataDecoder() { return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)]]); } function getReleaseRentalInstructionDataCodec() { return (0, kit_1.combineCodec)(getReleaseRentalInstructionDataEncoder(), getReleaseRentalInstructionDataDecoder()); } async function getReleaseRentalInstructionAsync(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { signer: { value: input.signer ?? null, isWritable: true }, fleet: { value: input.fleet ?? null, isWritable: true }, gameId: { value: input.gameId ?? null, isWritable: false }, starbase: { value: input.starbase ?? null, isWritable: false }, starbasePlayer: { value: input.starbasePlayer ?? null, isWritable: true }, contract: { value: input.contract ?? null, isWritable: false }, rentalAuthority: { value: input.rentalAuthority ?? null, isWritable: false, }, sageProgram: { value: input.sageProgram ?? null, isWritable: false }, }; const accounts = originalAccounts; // Resolve default values. if (!accounts.contract.value) { accounts.contract.value = await (0, kit_1.getProgramDerivedAddress)({ programAddress, seeds: [ (0, kit_1.getBytesEncoder)().encode(new Uint8Array([114, 101, 110, 116, 97, 108, 95, 99, 111, 110, 116, 114, 97, 99, 116])), (0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.fleet.value)), ], }); } 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, ])), ], }); } const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta(accounts.signer), getAccountMeta(accounts.fleet), getAccountMeta(accounts.gameId), getAccountMeta(accounts.starbase), getAccountMeta(accounts.starbasePlayer), getAccountMeta(accounts.contract), getAccountMeta(accounts.rentalAuthority), getAccountMeta(accounts.sageProgram), ], data: getReleaseRentalInstructionDataEncoder().encode({}), programAddress, }); } function getReleaseRentalInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { signer: { value: input.signer ?? null, isWritable: true }, fleet: { value: input.fleet ?? null, isWritable: true }, gameId: { value: input.gameId ?? null, isWritable: false }, starbase: { value: input.starbase ?? null, isWritable: false }, starbasePlayer: { value: input.starbasePlayer ?? null, isWritable: true }, contract: { value: input.contract ?? null, isWritable: false }, rentalAuthority: { value: input.rentalAuthority ?? null, isWritable: false, }, sageProgram: { value: input.sageProgram ?? null, isWritable: false }, }; const accounts = originalAccounts; const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta(accounts.signer), getAccountMeta(accounts.fleet), getAccountMeta(accounts.gameId), getAccountMeta(accounts.starbase), getAccountMeta(accounts.starbasePlayer), getAccountMeta(accounts.contract), getAccountMeta(accounts.rentalAuthority), getAccountMeta(accounts.sageProgram), ], data: getReleaseRentalInstructionDataEncoder().encode({}), programAddress, }); } function parseReleaseRentalInstruction(instruction) { if (instruction.accounts.length < 8) { // 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: { signer: getNextAccount(), fleet: getNextAccount(), gameId: getNextAccount(), starbase: getNextAccount(), starbasePlayer: getNextAccount(), contract: getNextAccount(), rentalAuthority: getNextAccount(), sageProgram: getNextAccount(), }, data: getReleaseRentalInstructionDataDecoder().decode(instruction.data), }; } //# sourceMappingURL=releaseRental.js.map