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)

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