UNPKG

@wuwei-labs/srsly

Version:

[![npm version](https://img.shields.io/npm/v/ts-sdk-example.svg)](https://www.npmjs.com/package/ts-sdk-example)

92 lines 4.37 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.CONTRACT_STATE_DISCRIMINATOR = void 0; exports.getContractStateDiscriminatorBytes = getContractStateDiscriminatorBytes; exports.getContractStateEncoder = getContractStateEncoder; exports.getContractStateDecoder = getContractStateDecoder; exports.getContractStateCodec = getContractStateCodec; exports.decodeContractState = decodeContractState; exports.fetchContractState = fetchContractState; exports.fetchMaybeContractState = fetchMaybeContractState; exports.fetchAllContractState = fetchAllContractState; exports.fetchAllMaybeContractState = fetchAllMaybeContractState; exports.getContractStateSize = getContractStateSize; const kit_1 = require("@solana/kit"); const types_1 = require("../types"); exports.CONTRACT_STATE_DISCRIMINATOR = new Uint8Array([ 190, 138, 10, 223, 189, 116, 222, 115, ]); function getContractStateDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.CONTRACT_STATE_DISCRIMINATOR); } function getContractStateEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([ ['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)], ['version', (0, kit_1.getU8Encoder)()], ['toClose', (0, kit_1.getBooleanEncoder)()], ['rate', (0, kit_1.getU64Encoder)()], ['durationMin', (0, kit_1.getU64Encoder)()], ['durationMax', (0, kit_1.getU64Encoder)()], ['paymentsFeq', (0, types_1.getPaymentFrequencyEncoder)()], ['fleet', (0, kit_1.getAddressEncoder)()], ['gameId', (0, kit_1.getAddressEncoder)()], ['currentRentalState', (0, kit_1.getAddressEncoder)()], ['owner', (0, kit_1.getAddressEncoder)()], ['ownerTokenAccount', (0, kit_1.getAddressEncoder)()], ['ownerProfile', (0, kit_1.getAddressEncoder)()], ['bump', (0, kit_1.getU8Encoder)()], ]), (value) => ({ ...value, discriminator: exports.CONTRACT_STATE_DISCRIMINATOR })); } function getContractStateDecoder() { return (0, kit_1.getStructDecoder)([ ['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)], ['version', (0, kit_1.getU8Decoder)()], ['toClose', (0, kit_1.getBooleanDecoder)()], ['rate', (0, kit_1.getU64Decoder)()], ['durationMin', (0, kit_1.getU64Decoder)()], ['durationMax', (0, kit_1.getU64Decoder)()], ['paymentsFeq', (0, types_1.getPaymentFrequencyDecoder)()], ['fleet', (0, kit_1.getAddressDecoder)()], ['gameId', (0, kit_1.getAddressDecoder)()], ['currentRentalState', (0, kit_1.getAddressDecoder)()], ['owner', (0, kit_1.getAddressDecoder)()], ['ownerTokenAccount', (0, kit_1.getAddressDecoder)()], ['ownerProfile', (0, kit_1.getAddressDecoder)()], ['bump', (0, kit_1.getU8Decoder)()], ]); } function getContractStateCodec() { return (0, kit_1.combineCodec)(getContractStateEncoder(), getContractStateDecoder()); } function decodeContractState(encodedAccount) { return (0, kit_1.decodeAccount)(encodedAccount, getContractStateDecoder()); } async function fetchContractState(rpc, address, config) { const maybeAccount = await fetchMaybeContractState(rpc, address, config); (0, kit_1.assertAccountExists)(maybeAccount); return maybeAccount; } async function fetchMaybeContractState(rpc, address, config) { const maybeAccount = await (0, kit_1.fetchEncodedAccount)(rpc, address, config); return decodeContractState(maybeAccount); } async function fetchAllContractState(rpc, addresses, config) { const maybeAccounts = await fetchAllMaybeContractState(rpc, addresses, config); (0, kit_1.assertAccountsExist)(maybeAccounts); return maybeAccounts; } async function fetchAllMaybeContractState(rpc, addresses, config) { const maybeAccounts = await (0, kit_1.fetchEncodedAccounts)(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeContractState(maybeAccount)); } function getContractStateSize() { return 228; } //# sourceMappingURL=contractState.js.map