UNPKG

@wuwei-labs/srsly

Version:
132 lines 7.36 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_CONFIG_DISCRIMINATOR = void 0; exports.getUpdateConfigDiscriminatorBytes = getUpdateConfigDiscriminatorBytes; exports.getUpdateConfigInstructionDataEncoder = getUpdateConfigInstructionDataEncoder; exports.getUpdateConfigInstructionDataDecoder = getUpdateConfigInstructionDataDecoder; exports.getUpdateConfigInstructionDataCodec = getUpdateConfigInstructionDataCodec; exports.getUpdateConfigInstructionAsync = getUpdateConfigInstructionAsync; exports.getUpdateConfigInstruction = getUpdateConfigInstruction; exports.parseUpdateConfigInstruction = parseUpdateConfigInstruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); exports.UPDATE_CONFIG_DISCRIMINATOR = new Uint8Array([29, 158, 252, 191, 10, 83, 219, 99]); function getUpdateConfigDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.UPDATE_CONFIG_DISCRIMINATOR); } function getUpdateConfigInstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([ ['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['admin', (0, kit_1.getOptionEncoder)((0, kit_1.getAddressEncoder)())], ['stardustToAtlas', (0, kit_1.getOptionEncoder)((0, kit_1.getU64Encoder)())], ['serviceFeeBps', (0, kit_1.getOptionEncoder)((0, kit_1.getU64Encoder)())], ['baseBps', (0, kit_1.getOptionEncoder)((0, kit_1.getU16Encoder)())], ['rentalDurationMinSeconds', (0, kit_1.getOptionEncoder)((0, kit_1.getI64Encoder)())], ['rentalDurationMaxSeconds', (0, kit_1.getOptionEncoder)((0, kit_1.getI64Encoder)())], ['atlasMint', (0, kit_1.getOptionEncoder)((0, kit_1.getAddressEncoder)())], ['reservationsEnabled', (0, kit_1.getOptionEncoder)((0, kit_1.getBooleanEncoder)())], ['pointsPerDay', (0, kit_1.getOptionEncoder)((0, kit_1.getU64Encoder)())], ['cancellationPenalty', (0, kit_1.getOptionEncoder)((0, kit_1.getU64Encoder)())], ['minCaptureThreshold', (0, kit_1.getOptionEncoder)((0, kit_1.getU64Encoder)())], ['weightBase', (0, kit_1.getOptionEncoder)((0, kit_1.getU32Encoder)())], ['weightMultiplier', (0, kit_1.getOptionEncoder)((0, kit_1.getF32Encoder)())], ['maxWeight', (0, kit_1.getOptionEncoder)((0, kit_1.getU8Encoder)())], ['captureRateBps', (0, kit_1.getOptionEncoder)((0, kit_1.getU64Encoder)())], ['atlasPerPoint', (0, kit_1.getOptionEncoder)((0, kit_1.getU64Encoder)())], ['contestedMultiplierMaxBps', (0, kit_1.getOptionEncoder)((0, kit_1.getU16Encoder)())], ]), value => ({ ...value, discriminator: exports.UPDATE_CONFIG_DISCRIMINATOR })); } function getUpdateConfigInstructionDataDecoder() { return (0, kit_1.getStructDecoder)([ ['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['admin', (0, kit_1.getOptionDecoder)((0, kit_1.getAddressDecoder)())], ['stardustToAtlas', (0, kit_1.getOptionDecoder)((0, kit_1.getU64Decoder)())], ['serviceFeeBps', (0, kit_1.getOptionDecoder)((0, kit_1.getU64Decoder)())], ['baseBps', (0, kit_1.getOptionDecoder)((0, kit_1.getU16Decoder)())], ['rentalDurationMinSeconds', (0, kit_1.getOptionDecoder)((0, kit_1.getI64Decoder)())], ['rentalDurationMaxSeconds', (0, kit_1.getOptionDecoder)((0, kit_1.getI64Decoder)())], ['atlasMint', (0, kit_1.getOptionDecoder)((0, kit_1.getAddressDecoder)())], ['reservationsEnabled', (0, kit_1.getOptionDecoder)((0, kit_1.getBooleanDecoder)())], ['pointsPerDay', (0, kit_1.getOptionDecoder)((0, kit_1.getU64Decoder)())], ['cancellationPenalty', (0, kit_1.getOptionDecoder)((0, kit_1.getU64Decoder)())], ['minCaptureThreshold', (0, kit_1.getOptionDecoder)((0, kit_1.getU64Decoder)())], ['weightBase', (0, kit_1.getOptionDecoder)((0, kit_1.getU32Decoder)())], ['weightMultiplier', (0, kit_1.getOptionDecoder)((0, kit_1.getF32Decoder)())], ['maxWeight', (0, kit_1.getOptionDecoder)((0, kit_1.getU8Decoder)())], ['captureRateBps', (0, kit_1.getOptionDecoder)((0, kit_1.getU64Decoder)())], ['atlasPerPoint', (0, kit_1.getOptionDecoder)((0, kit_1.getU64Decoder)())], ['contestedMultiplierMaxBps', (0, kit_1.getOptionDecoder)((0, kit_1.getU16Decoder)())], ]); } function getUpdateConfigInstructionDataCodec() { return (0, kit_1.combineCodec)(getUpdateConfigInstructionDataEncoder(), getUpdateConfigInstructionDataDecoder()); } async function getUpdateConfigInstructionAsync(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { admin: { value: input.admin ?? null, isWritable: false }, config: { value: input.config ?? null, isWritable: true }, }; const accounts = originalAccounts; // Original args. const args = { ...input, admin: input.adminArg }; // 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]))], }); } const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [getAccountMeta(accounts.admin), getAccountMeta(accounts.config)], data: getUpdateConfigInstructionDataEncoder().encode(args), programAddress, }); } function getUpdateConfigInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { admin: { value: input.admin ?? null, isWritable: false }, config: { value: input.config ?? null, isWritable: true }, }; const accounts = originalAccounts; // Original args. const args = { ...input, admin: input.adminArg }; const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [getAccountMeta(accounts.admin), getAccountMeta(accounts.config)], data: getUpdateConfigInstructionDataEncoder().encode(args), programAddress, }); } function parseUpdateConfigInstruction(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: { admin: getNextAccount(), config: getNextAccount() }, data: getUpdateConfigInstructionDataDecoder().decode(instruction.data), }; } //# sourceMappingURL=updateConfig.js.map