UNPKG

@kamino-finance/farms-sdk

Version:
88 lines 4.13 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.IDL_MISSING_TYPES_DISCRIMINATOR = void 0; exports.getIdlMissingTypesDiscriminatorBytes = getIdlMissingTypesDiscriminatorBytes; exports.getIdlMissingTypesInstructionDataEncoder = getIdlMissingTypesInstructionDataEncoder; exports.getIdlMissingTypesInstructionDataDecoder = getIdlMissingTypesInstructionDataDecoder; exports.getIdlMissingTypesInstructionDataCodec = getIdlMissingTypesInstructionDataCodec; exports.getIdlMissingTypesInstruction = getIdlMissingTypesInstruction; exports.parseIdlMissingTypesInstruction = parseIdlMissingTypesInstruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); const types_1 = require("../types"); exports.IDL_MISSING_TYPES_DISCRIMINATOR = new Uint8Array([ 130, 80, 38, 153, 80, 212, 182, 253, ]); function getIdlMissingTypesDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.IDL_MISSING_TYPES_DISCRIMINATOR); } function getIdlMissingTypesInstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([ ["discriminator", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ["globalConfigOptionKind", (0, types_1.getGlobalConfigOptionEncoder)()], ["farmConfigOptionKind", (0, types_1.getFarmConfigOptionEncoder)()], ["timeUnit", (0, types_1.getTimeUnitEncoder)()], ["lockingMode", (0, types_1.getLockingModeEncoder)()], ["rewardType", (0, types_1.getRewardTypeEncoder)()], ]), (value) => ({ ...value, discriminator: exports.IDL_MISSING_TYPES_DISCRIMINATOR })); } function getIdlMissingTypesInstructionDataDecoder() { return (0, kit_1.getStructDecoder)([ ["discriminator", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ["globalConfigOptionKind", (0, types_1.getGlobalConfigOptionDecoder)()], ["farmConfigOptionKind", (0, types_1.getFarmConfigOptionDecoder)()], ["timeUnit", (0, types_1.getTimeUnitDecoder)()], ["lockingMode", (0, types_1.getLockingModeDecoder)()], ["rewardType", (0, types_1.getRewardTypeDecoder)()], ]); } function getIdlMissingTypesInstructionDataCodec() { return (0, kit_1.combineCodec)(getIdlMissingTypesInstructionDataEncoder(), getIdlMissingTypesInstructionDataDecoder()); } function getIdlMissingTypesInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.FARMS_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { globalAdmin: { value: input.globalAdmin ?? null, isWritable: false }, globalConfig: { value: input.globalConfig ?? null, isWritable: true }, }; const accounts = originalAccounts; // Original args. const args = { ...input }; const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, "programId"); return Object.freeze({ accounts: [ getAccountMeta(accounts.globalAdmin), getAccountMeta(accounts.globalConfig), ], data: getIdlMissingTypesInstructionDataEncoder().encode(args), programAddress, }); } function parseIdlMissingTypesInstruction(instruction) { if (instruction.accounts.length < 2) { // 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: { globalAdmin: getNextAccount(), globalConfig: getNextAccount() }, data: getIdlMissingTypesInstructionDataDecoder().decode(instruction.data), }; } //# sourceMappingURL=idlMissingTypes.js.map