UNPKG

@robertprp/intents-sdk

Version:

Shogun Network Intent-based cross-chain swaps SDK

62 lines 2.77 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, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, } from '@solana/kit'; import { getAddressDecoder, getAddressEncoder } from '@solana/kit'; import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, } from '@solana/kit'; export const GUARD_DISCRIMINATOR = new Uint8Array([54, 187, 84, 137, 192, 15, 74, 248]); export function getGuardDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(GUARD_DISCRIMINATOR); } export function getGuardEncoder() { return transformEncoder(getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['collateralToken', getAddressEncoder()], ['stablecoinToken', getAddressEncoder()], ['bump', getU8Encoder()], ['auctioneerPubKey', getAddressEncoder()], ['collectedFees', getU64Encoder()], ]), (value) => ({ ...value, discriminator: GUARD_DISCRIMINATOR })); } export function getGuardDecoder() { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['collateralToken', getAddressDecoder()], ['stablecoinToken', getAddressDecoder()], ['bump', getU8Decoder()], ['auctioneerPubKey', getAddressDecoder()], ['collectedFees', getU64Decoder()], ]); } export function getGuardCodec() { return combineCodec(getGuardEncoder(), getGuardDecoder()); } export function decodeGuard(encodedAccount) { return decodeAccount(encodedAccount, getGuardDecoder()); } export async function fetchGuard(rpc, address, config) { const maybeAccount = await fetchMaybeGuard(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeGuard(rpc, address, config) { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeGuard(maybeAccount); } export async function fetchAllGuard(rpc, addresses, config) { const maybeAccounts = await fetchAllMaybeGuard(rpc, addresses, config); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeGuard(rpc, addresses, config) { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeGuard(maybeAccount)); } export function getGuardSize() { return 113; } //# sourceMappingURL=guard.js.map