@pod-protocol/sdk
Version:
TypeScript SDK for PoD Protocol - AI agent communication on Solana
1,356 lines (1,327 loc) • 178 kB
JavaScript
'use strict';
var client = require('./client.js');
var types = require('./types-OQd1rGtn.js');
var index_node = require('./index.node-aPHhG-NK.js');
var services_agent = require('./services/agent.js');
var services_message = require('./services/message.js');
var services_channel = require('./services/channel.js');
var services_escrow = require('./services/escrow.js');
var services_analytics = require('./services/analytics.js');
var services_discovery = require('./services/discovery.js');
var services_ipfs = require('./services/ipfs.js');
var services_zkCompression = require('./zk-compression-BLNcVyJy.js');
var utils = require('./utils.js');
require('@coral-xyz/anchor');
require('./session-keys-AhkZ00W7.js');
require('./base-4VR-G3Dc.js');
require('node:events');
require('ws');
require('./services/jito-bundles.js');
require('@solana-program/compute-budget');
require('@solana-program/system');
require('keccak');
require('@lightprotocol/stateless.js');
function decodeAccount(encodedAccount, decoder) {
try {
if ("exists" in encodedAccount && !encodedAccount.exists) {
return encodedAccount;
}
return Object.freeze({ ...encodedAccount, data: decoder.decode(encodedAccount.data) });
} catch {
throw new types.SolanaError(types.SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT, {
address: encodedAccount.address
});
}
}
function parseBase64RpcAccount(address, rpcAccount) {
if (!rpcAccount) return Object.freeze({ address, exists: false });
const data = types.getBase64Encoder().encode(rpcAccount.data[0]);
return Object.freeze({ ...parseBaseAccount(rpcAccount), address, data, exists: true });
}
function parseBaseAccount(rpcAccount) {
return Object.freeze({
executable: rpcAccount.executable,
lamports: rpcAccount.lamports,
programAddress: rpcAccount.owner,
space: rpcAccount.space
});
}
// src/fetch-account.ts
async function fetchEncodedAccount(rpc, address, config = {}) {
const { abortSignal, ...rpcConfig } = config;
const response = await rpc.getAccountInfo(address, { ...rpcConfig, encoding: "base64" }).send({ abortSignal });
return parseBase64RpcAccount(address, response.value);
}
async function fetchEncodedAccounts(rpc, addresses, config = {}) {
const { abortSignal, ...rpcConfig } = config;
const response = await rpc.getMultipleAccounts(addresses, { ...rpcConfig, encoding: "base64" }).send({ abortSignal });
return response.value.map((account, index) => parseBase64RpcAccount(addresses[index], account));
}
function assertAccountExists(account) {
if (!account.exists) {
throw new types.SolanaError(types.SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND, { address: account.address });
}
}
function assertAccountsExist(accounts) {
const missingAccounts = accounts.filter((a) => !a.exists);
if (missingAccounts.length > 0) {
const missingAddresses = missingAccounts.map((a) => a.address);
throw new types.SolanaError(types.SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND, { addresses: missingAddresses });
}
}
// src/assertions.ts
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
if (value < min || value > max) {
throw new types.SolanaError(types.SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE, {
codecDescription,
max,
min,
value
});
}
}
function isLittleEndian(config) {
return config?.endian === 1 /* Big */ ? false : true;
}
function numberEncoderFactory(input) {
return types.createEncoder({
fixedSize: input.size,
write(value, bytes, offset) {
if (input.range) {
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
}
const arrayBuffer = new ArrayBuffer(input.size);
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
bytes.set(new Uint8Array(arrayBuffer), offset);
return offset + input.size;
}
});
}
function numberDecoderFactory(input) {
return types.createDecoder({
fixedSize: input.size,
read(bytes, offset = 0) {
types.assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
types.assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
return [input.get(view, isLittleEndian(input.config)), offset + input.size];
}
});
}
function toArrayBuffer(bytes, offset, length) {
const bytesOffset = bytes.byteOffset + (offset ?? 0);
const bytesLength = length ?? bytes.byteLength;
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
}
var getI64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "i64",
range: [-BigInt("0x7fffffffffffffff") - 1n, BigInt("0x7fffffffffffffff")],
set: (view, value, le) => view.setBigInt64(0, BigInt(value), le),
size: 8
});
var getI64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getBigInt64(0, le),
name: "i64",
size: 8
});
var getU16Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u16",
range: [0, Number("0xffff")],
set: (view, value, le) => view.setUint16(0, Number(value), le),
size: 2
});
var getU16Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getUint16(0, le),
name: "u16",
size: 2
});
var getU32Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u32",
range: [0, Number("0xffffffff")],
set: (view, value, le) => view.setUint32(0, Number(value), le),
size: 4
});
var getU32Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getUint32(0, le),
name: "u32",
size: 4
});
var getU64Encoder = (config = {}) => numberEncoderFactory({
config,
name: "u64",
range: [0n, BigInt("0xffffffffffffffff")],
set: (view, value, le) => view.setBigUint64(0, BigInt(value), le),
size: 8
});
var getU64Decoder = (config = {}) => numberDecoderFactory({
config,
get: (view, le) => view.getBigUint64(0, le),
name: "u64",
size: 8
});
var getU8Encoder = () => numberEncoderFactory({
name: "u8",
range: [0, Number("0xff")],
set: (view, value) => view.setUint8(0, Number(value)),
size: 1
});
var getU8Decoder = () => numberDecoderFactory({
get: (view) => view.getUint8(0),
name: "u8",
size: 1
});
// src/array.ts
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
if (expected !== actual) {
throw new types.SolanaError(types.SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS, {
actual,
codecDescription,
expected
});
}
}
function maxCodecSizes(sizes) {
return sizes.reduce(
(all, size) => all === null || size === null ? null : Math.max(all, size),
0
);
}
function sumCodecSizes(sizes) {
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
}
function getFixedSize(codec) {
return types.isFixedSize(codec) ? codec.fixedSize : null;
}
function getMaxSize(codec) {
return types.isFixedSize(codec) ? codec.fixedSize : codec.maxSize ?? null;
}
// src/array.ts
function getArrayEncoder(item, config = {}) {
const size = config.size ?? getU32Encoder();
const fixedSize = computeArrayLikeCodecSize(size, getFixedSize(item));
const maxSize = computeArrayLikeCodecSize(size, getMaxSize(item)) ?? void 0;
return types.createEncoder({
...fixedSize !== null ? { fixedSize } : {
getSizeFromValue: (array) => {
const prefixSize = typeof size === "object" ? types.getEncodedSize(array.length, size) : 0;
return prefixSize + [...array].reduce((all, value) => all + types.getEncodedSize(value, item), 0);
},
maxSize
},
write: (array, bytes, offset) => {
if (typeof size === "number") {
assertValidNumberOfItemsForCodec("array", size, array.length);
}
if (typeof size === "object") {
offset = size.write(array.length, bytes, offset);
}
array.forEach((value) => {
offset = item.write(value, bytes, offset);
});
return offset;
}
});
}
function getArrayDecoder(item, config = {}) {
const size = config.size ?? getU32Decoder();
const itemSize = getFixedSize(item);
const fixedSize = computeArrayLikeCodecSize(size, itemSize);
const maxSize = computeArrayLikeCodecSize(size, getMaxSize(item)) ?? void 0;
return types.createDecoder({
...fixedSize !== null ? { fixedSize } : { maxSize },
read: (bytes, offset) => {
const array = [];
if (typeof size === "object" && bytes.slice(offset).length === 0) {
return [array, offset];
}
if (size === "remainder") {
while (offset < bytes.length) {
const [value, newOffset2] = item.read(bytes, offset);
offset = newOffset2;
array.push(value);
}
return [array, offset];
}
const [resolvedSize, newOffset] = typeof size === "number" ? [size, offset] : size.read(bytes, offset);
offset = newOffset;
for (let i = 0; i < resolvedSize; i += 1) {
const [value, newOffset2] = item.read(bytes, offset);
offset = newOffset2;
array.push(value);
}
return [array, offset];
}
});
}
function computeArrayLikeCodecSize(size, itemSize) {
if (typeof size !== "number") return null;
if (size === 0) return 0;
return itemSize === null ? null : itemSize * size;
}
function getBooleanEncoder(config = {}) {
return types.transformEncoder(config.size ?? getU8Encoder(), (value) => value ? 1 : 0);
}
function getBooleanDecoder(config = {}) {
return types.transformDecoder(config.size ?? getU8Decoder(), (value) => Number(value) === 1);
}
function getBytesEncoder() {
return types.createEncoder({
getSizeFromValue: (value) => value.length,
write: (value, bytes, offset) => {
bytes.set(value, offset);
return offset + value.length;
}
});
}
function getBytesDecoder() {
return types.createDecoder({
read: (bytes, offset) => {
const slice = bytes.slice(offset);
return [slice, offset + slice.length];
}
});
}
var getBase16Decoder = () => types.createDecoder({
read(bytes, offset) {
const value = bytes.slice(offset).reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
return [value, bytes.length];
}
});
function getConstantEncoder(constant) {
return types.createEncoder({
fixedSize: constant.length,
write: (_, bytes, offset) => {
bytes.set(constant, offset);
return offset + constant.length;
}
});
}
function getConstantDecoder(constant) {
return types.createDecoder({
fixedSize: constant.length,
read: (bytes, offset) => {
const base16 = getBase16Decoder();
if (!types.containsBytes(bytes, constant, offset)) {
throw new types.SolanaError(types.SOLANA_ERROR__CODECS__INVALID_CONSTANT, {
constant,
data: bytes,
hexConstant: base16.decode(constant),
hexData: base16.decode(bytes),
offset
});
}
return [void 0, offset + constant.length];
}
});
}
function getTupleEncoder(items) {
const fixedSize = sumCodecSizes(items.map(getFixedSize));
const maxSize = sumCodecSizes(items.map(getMaxSize)) ?? void 0;
return types.createEncoder({
...fixedSize === null ? {
getSizeFromValue: (value) => items.map((item, index) => types.getEncodedSize(value[index], item)).reduce((all, one) => all + one, 0),
maxSize
} : { fixedSize },
write: (value, bytes, offset) => {
assertValidNumberOfItemsForCodec("tuple", items.length, value.length);
items.forEach((item, index) => {
offset = item.write(value[index], bytes, offset);
});
return offset;
}
});
}
function getTupleDecoder(items) {
const fixedSize = sumCodecSizes(items.map(getFixedSize));
const maxSize = sumCodecSizes(items.map(getMaxSize)) ?? void 0;
return types.createDecoder({
...fixedSize === null ? { maxSize } : { fixedSize },
read: (bytes, offset) => {
const values = [];
items.forEach((item) => {
const [newValue, newOffset] = item.read(bytes, offset);
values.push(newValue);
offset = newOffset;
});
return [values, offset];
}
});
}
function getUnionEncoder(variants, getIndexFromValue) {
const fixedSize = getUnionFixedSize(variants);
const write = (variant, bytes, offset) => {
const index = getIndexFromValue(variant);
assertValidVariantIndex(variants, index);
return variants[index].write(variant, bytes, offset);
};
if (fixedSize !== null) {
return types.createEncoder({ fixedSize, write });
}
const maxSize = getUnionMaxSize(variants);
return types.createEncoder({
...maxSize !== null ? { maxSize } : {},
getSizeFromValue: (variant) => {
const index = getIndexFromValue(variant);
assertValidVariantIndex(variants, index);
return types.getEncodedSize(variant, variants[index]);
},
write
});
}
function getUnionDecoder(variants, getIndexFromBytes) {
const fixedSize = getUnionFixedSize(variants);
const read = (bytes, offset) => {
const index = getIndexFromBytes(bytes, offset);
assertValidVariantIndex(variants, index);
return variants[index].read(bytes, offset);
};
if (fixedSize !== null) {
return types.createDecoder({ fixedSize, read });
}
const maxSize = getUnionMaxSize(variants);
return types.createDecoder({ ...maxSize !== null ? { maxSize } : {}, read });
}
function assertValidVariantIndex(variants, index) {
if (typeof variants[index] === "undefined") {
throw new types.SolanaError(types.SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE, {
maxRange: variants.length - 1,
minRange: 0,
variant: index
});
}
}
function getUnionFixedSize(variants) {
if (variants.length === 0) return 0;
if (!types.isFixedSize(variants[0])) return null;
const variantSize = variants[0].fixedSize;
const sameSizedVariants = variants.every((variant) => types.isFixedSize(variant) && variant.fixedSize === variantSize);
return sameSizedVariants ? variantSize : null;
}
function getUnionMaxSize(variants) {
return maxCodecSizes(variants.map((variant) => getMaxSize(variant)));
}
// src/discriminated-union.ts
function getDiscriminatedUnionEncoder(variants, config = {}) {
const discriminatorProperty = config.discriminator ?? "__kind";
const prefix = config.size ?? getU8Encoder();
return getUnionEncoder(
variants.map(
([, variant], index) => types.transformEncoder(getTupleEncoder([prefix, variant]), (value) => [index, value])
),
(value) => getVariantDiscriminator(variants, value[discriminatorProperty])
);
}
function getDiscriminatedUnionDecoder(variants, config = {}) {
const discriminatorProperty = config.discriminator ?? "__kind";
const prefix = config.size ?? getU8Decoder();
return getUnionDecoder(
variants.map(
([discriminator, variant]) => types.transformDecoder(getTupleDecoder([prefix, variant]), ([, value]) => ({
[discriminatorProperty]: discriminator,
...value
}))
),
(bytes, offset) => Number(prefix.read(bytes, offset)[0])
);
}
function getVariantDiscriminator(variants, discriminatorValue) {
const discriminator = variants.findIndex(([key]) => discriminatorValue === key);
if (discriminator < 0) {
throw new types.SolanaError(types.SOLANA_ERROR__CODECS__INVALID_DISCRIMINATED_UNION_VARIANT, {
value: discriminatorValue,
variants: variants.map(([key]) => key)
});
}
return discriminator;
}
// src/enum-helpers.ts
function getEnumStats(constructor) {
const numericalValues = [...new Set(Object.values(constructor).filter((v) => typeof v === "number"))].sort();
const enumRecord = Object.fromEntries(Object.entries(constructor).slice(numericalValues.length));
const enumKeys = Object.keys(enumRecord);
const enumValues = Object.values(enumRecord);
const stringValues = [
.../* @__PURE__ */ new Set([...enumKeys, ...enumValues.filter((v) => typeof v === "string")])
];
return { enumKeys, enumRecord, enumValues, numericalValues, stringValues };
}
function getEnumIndexFromVariant({
enumKeys,
enumValues,
variant
}) {
const valueIndex = findLastIndex(enumValues, (value) => value === variant);
if (valueIndex >= 0) return valueIndex;
return enumKeys.findIndex((key) => key === variant);
}
function getEnumIndexFromDiscriminator({
discriminator,
enumKeys,
enumValues,
useValuesAsDiscriminators
}) {
if (!useValuesAsDiscriminators) {
return discriminator >= 0 && discriminator < enumKeys.length ? discriminator : -1;
}
return findLastIndex(enumValues, (value) => value === discriminator);
}
function findLastIndex(array, predicate) {
let l = array.length;
while (l--) {
if (predicate(array[l], l, array)) return l;
}
return -1;
}
function formatNumericalValues(values) {
if (values.length === 0) return "";
let range = [values[0], values[0]];
const ranges = [];
for (let index = 1; index < values.length; index++) {
const value = values[index];
if (range[1] + 1 === value) {
range[1] = value;
} else {
ranges.push(range[0] === range[1] ? `${range[0]}` : `${range[0]}-${range[1]}`);
range = [value, value];
}
}
ranges.push(range[0] === range[1] ? `${range[0]}` : `${range[0]}-${range[1]}`);
return ranges.join(", ");
}
// src/enum.ts
function getEnumEncoder(constructor, config = {}) {
const prefix = config.size ?? getU8Encoder();
const useValuesAsDiscriminators = config.useValuesAsDiscriminators ?? false;
const { enumKeys, enumValues, numericalValues, stringValues } = getEnumStats(constructor);
if (useValuesAsDiscriminators && enumValues.some((value) => typeof value === "string")) {
throw new types.SolanaError(types.SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS, {
stringValues: enumValues.filter((v) => typeof v === "string")
});
}
return types.transformEncoder(prefix, (variant) => {
const index = getEnumIndexFromVariant({ enumKeys, enumValues, variant });
if (index < 0) {
throw new types.SolanaError(types.SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT, {
formattedNumericalValues: formatNumericalValues(numericalValues),
numericalValues,
stringValues,
variant
});
}
return useValuesAsDiscriminators ? enumValues[index] : index;
});
}
function getEnumDecoder(constructor, config = {}) {
const prefix = config.size ?? getU8Decoder();
const useValuesAsDiscriminators = config.useValuesAsDiscriminators ?? false;
const { enumKeys, enumValues, numericalValues } = getEnumStats(constructor);
if (useValuesAsDiscriminators && enumValues.some((value) => typeof value === "string")) {
throw new types.SolanaError(types.SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS, {
stringValues: enumValues.filter((v) => typeof v === "string")
});
}
return types.transformDecoder(prefix, (value) => {
const discriminator = Number(value);
const index = getEnumIndexFromDiscriminator({
discriminator,
enumKeys,
enumValues,
useValuesAsDiscriminators
});
if (index < 0) {
const validDiscriminators = useValuesAsDiscriminators ? numericalValues : [...Array(enumKeys.length).keys()];
throw new types.SolanaError(types.SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE, {
discriminator,
formattedValidDiscriminators: formatNumericalValues(validDiscriminators),
validDiscriminators
});
}
return enumValues[index];
});
}
function getUnitEncoder() {
return types.createEncoder({
fixedSize: 0,
write: (_value, _bytes, offset) => offset
});
}
function getUnitDecoder() {
return types.createDecoder({
fixedSize: 0,
read: (_bytes, offset) => [void 0, offset]
});
}
function getStructEncoder(fields) {
const fieldCodecs = fields.map(([, codec]) => codec);
const fixedSize = sumCodecSizes(fieldCodecs.map(getFixedSize));
const maxSize = sumCodecSizes(fieldCodecs.map(getMaxSize)) ?? void 0;
return types.createEncoder({
...fixedSize === null ? {
getSizeFromValue: (value) => fields.map(([key, codec]) => types.getEncodedSize(value[key], codec)).reduce((all, one) => all + one, 0),
maxSize
} : { fixedSize },
write: (struct, bytes, offset) => {
fields.forEach(([key, codec]) => {
offset = codec.write(struct[key], bytes, offset);
});
return offset;
}
});
}
function getStructDecoder(fields) {
const fieldCodecs = fields.map(([, codec]) => codec);
const fixedSize = sumCodecSizes(fieldCodecs.map(getFixedSize));
const maxSize = sumCodecSizes(fieldCodecs.map(getMaxSize)) ?? void 0;
return types.createDecoder({
...fixedSize === null ? { maxSize } : { fixedSize },
read: (bytes, offset) => {
const struct = {};
fields.forEach(([key, codec]) => {
const [value, newOffset] = codec.read(bytes, offset);
offset = newOffset;
struct[key] = value;
});
return [struct, offset];
}
});
}
// src/option.ts
var some = (value) => ({ __option: "Some", value });
var none = () => ({ __option: "None" });
var isOption = (input) => !!(input && typeof input === "object" && "__option" in input && (input.__option === "Some" && "value" in input || input.__option === "None"));
var isSome = (option) => option.__option === "Some";
var wrapNullable = (nullable) => nullable !== null ? some(nullable) : none();
// src/option-codec.ts
function getOptionEncoder(item, config = {}) {
const prefix = (() => {
if (config.prefix === null) {
return types.transformEncoder(getUnitEncoder(), (_boolean) => void 0);
}
return getBooleanEncoder({ size: config.prefix ?? getU8Encoder() });
})();
const noneValue = (() => {
if (config.noneValue === "zeroes") {
types.assertIsFixedSize(item);
return types.fixEncoderSize(getUnitEncoder(), item.fixedSize);
}
if (!config.noneValue) {
return getUnitEncoder();
}
return getConstantEncoder(config.noneValue);
})();
return getUnionEncoder(
[
types.transformEncoder(getTupleEncoder([prefix, noneValue]), (_value) => [
false,
void 0
]),
types.transformEncoder(getTupleEncoder([prefix, item]), (value) => [
true,
isOption(value) && isSome(value) ? value.value : value
])
],
(variant) => {
const option = isOption(variant) ? variant : wrapNullable(variant);
return Number(isSome(option));
}
);
}
function getOptionDecoder(item, config = {}) {
const prefix = (() => {
if (config.prefix === null) {
return types.transformDecoder(getUnitDecoder(), () => false);
}
return getBooleanDecoder({ size: config.prefix ?? getU8Decoder() });
})();
const noneValue = (() => {
if (config.noneValue === "zeroes") {
types.assertIsFixedSize(item);
return types.fixDecoderSize(getUnitDecoder(), item.fixedSize);
}
if (!config.noneValue) {
return getUnitDecoder();
}
return getConstantDecoder(config.noneValue);
})();
return getUnionDecoder(
[
types.transformDecoder(getTupleDecoder([prefix, noneValue]), () => none()),
types.transformDecoder(getTupleDecoder([prefix, item]), ([, value]) => some(value))
],
(bytes, offset) => {
if (config.prefix === null && !config.noneValue) {
return Number(offset < bytes.length);
}
if (config.prefix === null && config.noneValue != null) {
const zeroValue = config.noneValue === "zeroes" ? new Uint8Array(noneValue.fixedSize).fill(0) : config.noneValue;
return types.containsBytes(bytes, zeroValue, offset) ? 0 : 1;
}
return Number(prefix.read(bytes, offset)[0]);
}
);
}
// src/roles.ts
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
3] = "WRITABLE_SIGNER";
AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
2] = "READONLY_SIGNER";
AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
1] = "WRITABLE";
AccountRole2[AccountRole2["READONLY"] = /* 0 */
0] = "READONLY";
return AccountRole2;
})(AccountRole || {});
var IS_SIGNER_BITMASK = 2;
function upgradeRoleToSigner(role) {
return role | IS_SIGNER_BITMASK;
}
// src/program-error.ts
function isProgramError(error, transactionMessage, programAddress, code) {
if (!types.isSolanaError(error, types.SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM)) {
return false;
}
const instructionProgramAddress = transactionMessage.instructions[error.context.index]?.programAddress;
if (!instructionProgramAddress || instructionProgramAddress !== programAddress) {
return false;
}
return typeof code === "undefined" || error.context.code === code;
}
/**
* 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
*/
const AGENT_ACCOUNT_DISCRIMINATOR = new Uint8Array([
241, 119, 69, 140, 233, 9, 112, 50,
]);
function getAgentAccountDiscriminatorBytes() {
return types.fixEncoderSize(getBytesEncoder(), 8).encode(AGENT_ACCOUNT_DISCRIMINATOR);
}
function getAgentAccountEncoder() {
return types.transformEncoder(getStructEncoder([
['discriminator', types.fixEncoderSize(getBytesEncoder(), 8)],
['pubkey', types.getAddressEncoder()],
['capabilities', getU64Encoder()],
['reputation', getU64Encoder()],
['lastUpdated', getI64Encoder()],
['metadataUri', types.addEncoderSizePrefix(types.getUtf8Encoder(), getU32Encoder())],
['invitesSent', getU16Encoder()],
['lastInviteAt', getI64Encoder()],
['bump', getU8Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 7 })],
]), (value) => ({ ...value, discriminator: AGENT_ACCOUNT_DISCRIMINATOR }));
}
function getAgentAccountDecoder() {
return getStructDecoder([
['discriminator', types.fixDecoderSize(getBytesDecoder(), 8)],
['pubkey', types.getAddressDecoder()],
['capabilities', getU64Decoder()],
['reputation', getU64Decoder()],
['lastUpdated', getI64Decoder()],
['metadataUri', types.addDecoderSizePrefix(types.getUtf8Decoder(), getU32Decoder())],
['invitesSent', getU16Decoder()],
['lastInviteAt', getI64Decoder()],
['bump', getU8Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 7 })],
]);
}
function getAgentAccountCodec() {
return types.combineCodec(getAgentAccountEncoder(), getAgentAccountDecoder());
}
function decodeAgentAccount(encodedAccount) {
return decodeAccount(encodedAccount, getAgentAccountDecoder());
}
async function fetchAgentAccount(rpc, address, config) {
const maybeAccount = await fetchMaybeAgentAccount(rpc, address, config);
assertAccountExists(maybeAccount);
return maybeAccount;
}
async function fetchMaybeAgentAccount(rpc, address, config) {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return decodeAgentAccount(maybeAccount);
}
async function fetchAllAgentAccount(rpc, addresses, config) {
const maybeAccounts = await fetchAllMaybeAgentAccount(rpc, addresses, config);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}
async function fetchAllMaybeAgentAccount(rpc, addresses, config) {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) => decodeAgentAccount(maybeAccount));
}
/**
* 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
*/
function getAgentRegisteredEncoder() {
return getStructEncoder([
['agent', types.getAddressEncoder()],
['capabilities', getU64Encoder()],
['metadataUri', types.addEncoderSizePrefix(types.getUtf8Encoder(), getU32Encoder())],
['timestamp', getI64Encoder()],
]);
}
function getAgentRegisteredDecoder() {
return getStructDecoder([
['agent', types.getAddressDecoder()],
['capabilities', getU64Decoder()],
['metadataUri', types.addDecoderSizePrefix(types.getUtf8Decoder(), getU32Decoder())],
['timestamp', getI64Decoder()],
]);
}
function getAgentRegisteredCodec() {
return types.combineCodec(getAgentRegisteredEncoder(), getAgentRegisteredDecoder());
}
/**
* 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
*/
var ChannelVisibility;
(function (ChannelVisibility) {
ChannelVisibility[ChannelVisibility["Public"] = 0] = "Public";
ChannelVisibility[ChannelVisibility["Private"] = 1] = "Private";
})(ChannelVisibility || (ChannelVisibility = {}));
function getChannelVisibilityEncoder() {
return getEnumEncoder(ChannelVisibility);
}
function getChannelVisibilityDecoder() {
return getEnumDecoder(ChannelVisibility);
}
function getChannelVisibilityCodec() {
return types.combineCodec(getChannelVisibilityEncoder(), getChannelVisibilityDecoder());
}
/**
* 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
*/
function getChannelCreatedEncoder() {
return getStructEncoder([
['channel', types.getAddressEncoder()],
['creator', types.getAddressEncoder()],
['name', types.addEncoderSizePrefix(types.getUtf8Encoder(), getU32Encoder())],
['visibility', getChannelVisibilityEncoder()],
['timestamp', getI64Encoder()],
]);
}
function getChannelCreatedDecoder() {
return getStructDecoder([
['channel', types.getAddressDecoder()],
['creator', types.getAddressDecoder()],
['name', types.addDecoderSizePrefix(types.getUtf8Decoder(), getU32Decoder())],
['visibility', getChannelVisibilityDecoder()],
['timestamp', getI64Decoder()],
]);
}
function getChannelCreatedCodec() {
return types.combineCodec(getChannelCreatedEncoder(), getChannelCreatedDecoder());
}
/**
* 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
*/
function getChannelJoinedEncoder() {
return getStructEncoder([
['channel', types.getAddressEncoder()],
['participant', types.getAddressEncoder()],
['timestamp', getI64Encoder()],
]);
}
function getChannelJoinedDecoder() {
return getStructDecoder([
['channel', types.getAddressDecoder()],
['participant', types.getAddressDecoder()],
['timestamp', getI64Decoder()],
]);
}
function getChannelJoinedCodec() {
return types.combineCodec(getChannelJoinedEncoder(), getChannelJoinedDecoder());
}
/**
* 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
*/
function getCompressedMessageSyncedEncoder() {
return getStructEncoder([
['channelId', types.getAddressEncoder()],
['messageHash', getArrayEncoder(getU8Encoder(), { size: 32 })],
['compressedHash', getArrayEncoder(getU8Encoder(), { size: 32 })],
['batchIndex', getU32Encoder()],
['syncTimestamp', getI64Encoder()],
]);
}
function getCompressedMessageSyncedDecoder() {
return getStructDecoder([
['channelId', types.getAddressDecoder()],
['messageHash', getArrayDecoder(getU8Decoder(), { size: 32 })],
['compressedHash', getArrayDecoder(getU8Decoder(), { size: 32 })],
['batchIndex', getU32Decoder()],
['syncTimestamp', getI64Decoder()],
]);
}
function getCompressedMessageSyncedCodec() {
return types.combineCodec(getCompressedMessageSyncedEncoder(), getCompressedMessageSyncedDecoder());
}
/**
* 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
*/
function getEscrowDepositEncoder() {
return getStructEncoder([
['channel', types.getAddressEncoder()],
['depositor', types.getAddressEncoder()],
['amount', getU64Encoder()],
['timestamp', getI64Encoder()],
]);
}
function getEscrowDepositDecoder() {
return getStructDecoder([
['channel', types.getAddressDecoder()],
['depositor', types.getAddressDecoder()],
['amount', getU64Decoder()],
['timestamp', getI64Decoder()],
]);
}
function getEscrowDepositCodec() {
return types.combineCodec(getEscrowDepositEncoder(), getEscrowDepositDecoder());
}
/**
* 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
*/
function getEscrowWithdrawalEncoder() {
return getStructEncoder([
['channel', types.getAddressEncoder()],
['depositor', types.getAddressEncoder()],
['amount', getU64Encoder()],
['timestamp', getI64Encoder()],
]);
}
function getEscrowWithdrawalDecoder() {
return getStructDecoder([
['channel', types.getAddressDecoder()],
['depositor', types.getAddressDecoder()],
['amount', getU64Decoder()],
['timestamp', getI64Decoder()],
]);
}
function getEscrowWithdrawalCodec() {
return types.combineCodec(getEscrowWithdrawalEncoder(), getEscrowWithdrawalDecoder());
}
/**
* 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
*/
function getMessageTypeEncoder() {
return getDiscriminatedUnionEncoder([
['Text', getUnitEncoder()],
['Data', getUnitEncoder()],
['Command', getUnitEncoder()],
['Response', getUnitEncoder()],
[
'Custom',
getStructEncoder([['fields', getTupleEncoder([getU8Encoder()])]]),
],
]);
}
function getMessageTypeDecoder() {
return getDiscriminatedUnionDecoder([
['Text', getUnitDecoder()],
['Data', getUnitDecoder()],
['Command', getUnitDecoder()],
['Response', getUnitDecoder()],
[
'Custom',
getStructDecoder([['fields', getTupleDecoder([getU8Decoder()])]]),
],
]);
}
function getMessageTypeCodec() {
return types.combineCodec(getMessageTypeEncoder(), getMessageTypeDecoder());
}
function messageType(kind, data) {
return Array.isArray(data)
? { __kind: kind, fields: data }
: { __kind: kind, ...(data ?? {}) };
}
function isMessageType(kind, value) {
return value.__kind === kind;
}
/**
* 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
*/
function getMessageBroadcastEncoder() {
return getStructEncoder([
['channel', types.getAddressEncoder()],
['sender', types.getAddressEncoder()],
['messageType', getMessageTypeEncoder()],
['timestamp', getI64Encoder()],
]);
}
function getMessageBroadcastDecoder() {
return getStructDecoder([
['channel', types.getAddressDecoder()],
['sender', types.getAddressDecoder()],
['messageType', getMessageTypeDecoder()],
['timestamp', getI64Decoder()],
]);
}
function getMessageBroadcastCodec() {
return types.combineCodec(getMessageBroadcastEncoder(), getMessageBroadcastDecoder());
}
/**
* 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
*/
function getMessageSentEncoder() {
return getStructEncoder([
['sender', types.getAddressEncoder()],
['recipient', types.getAddressEncoder()],
['messageType', getMessageTypeEncoder()],
['timestamp', getI64Encoder()],
]);
}
function getMessageSentDecoder() {
return getStructDecoder([
['sender', types.getAddressDecoder()],
['recipient', types.getAddressDecoder()],
['messageType', getMessageTypeDecoder()],
['timestamp', getI64Decoder()],
]);
}
function getMessageSentCodec() {
return types.combineCodec(getMessageSentEncoder(), getMessageSentDecoder());
}
/**
* 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
*/
var MessageStatus;
(function (MessageStatus) {
MessageStatus[MessageStatus["Pending"] = 0] = "Pending";
MessageStatus[MessageStatus["Delivered"] = 1] = "Delivered";
MessageStatus[MessageStatus["Read"] = 2] = "Read";
MessageStatus[MessageStatus["Failed"] = 3] = "Failed";
})(MessageStatus || (MessageStatus = {}));
function getMessageStatusEncoder() {
return getEnumEncoder(MessageStatus);
}
function getMessageStatusDecoder() {
return getEnumDecoder(MessageStatus);
}
function getMessageStatusCodec() {
return types.combineCodec(getMessageStatusEncoder(), getMessageStatusDecoder());
}
/**
* 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
*/
const CHANNEL_ACCOUNT_DISCRIMINATOR = new Uint8Array([
140, 232, 26, 78, 89, 26, 17, 244,
]);
function getChannelAccountDiscriminatorBytes() {
return types.fixEncoderSize(getBytesEncoder(), 8).encode(CHANNEL_ACCOUNT_DISCRIMINATOR);
}
function getChannelAccountEncoder() {
return types.transformEncoder(getStructEncoder([
['discriminator', types.fixEncoderSize(getBytesEncoder(), 8)],
['creator', types.getAddressEncoder()],
['feePerMessage', getU64Encoder()],
['escrowBalance', getU64Encoder()],
['createdAt', getI64Encoder()],
['maxParticipants', getU32Encoder()],
['currentParticipants', getU32Encoder()],
['name', types.addEncoderSizePrefix(types.getUtf8Encoder(), getU32Encoder())],
['description', types.addEncoderSizePrefix(types.getUtf8Encoder(), getU32Encoder())],
['visibility', getChannelVisibilityEncoder()],
['isActive', getBooleanEncoder()],
['lastSyncTimestamp', getI64Encoder()],
['totalCompressedMessages', getU64Encoder()],
['compressedDataSize', getU64Encoder()],
['bump', getU8Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 5 })],
]), (value) => ({ ...value, discriminator: CHANNEL_ACCOUNT_DISCRIMINATOR }));
}
function getChannelAccountDecoder() {
return getStructDecoder([
['discriminator', types.fixDecoderSize(getBytesDecoder(), 8)],
['creator', types.getAddressDecoder()],
['feePerMessage', getU64Decoder()],
['escrowBalance', getU64Decoder()],
['createdAt', getI64Decoder()],
['maxParticipants', getU32Decoder()],
['currentParticipants', getU32Decoder()],
['name', types.addDecoderSizePrefix(types.getUtf8Decoder(), getU32Decoder())],
['description', types.addDecoderSizePrefix(types.getUtf8Decoder(), getU32Decoder())],
['visibility', getChannelVisibilityDecoder()],
['isActive', getBooleanDecoder()],
['lastSyncTimestamp', getI64Decoder()],
['totalCompressedMessages', getU64Decoder()],
['compressedDataSize', getU64Decoder()],
['bump', getU8Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 5 })],
]);
}
function getChannelAccountCodec() {
return types.combineCodec(getChannelAccountEncoder(), getChannelAccountDecoder());
}
function decodeChannelAccount(encodedAccount) {
return decodeAccount(encodedAccount, getChannelAccountDecoder());
}
async function fetchChannelAccount(rpc, address, config) {
const maybeAccount = await fetchMaybeChannelAccount(rpc, address, config);
assertAccountExists(maybeAccount);
return maybeAccount;
}
async function fetchMaybeChannelAccount(rpc, address, config) {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return decodeChannelAccount(maybeAccount);
}
async function fetchAllChannelAccount(rpc, addresses, config) {
const maybeAccounts = await fetchAllMaybeChannelAccount(rpc, addresses, config);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}
async function fetchAllMaybeChannelAccount(rpc, addresses, config) {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) => decodeChannelAccount(maybeAccount));
}
/**
* 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
*/
const CHANNEL_INVITATION_DISCRIMINATOR = new Uint8Array([
103, 36, 72, 198, 173, 128, 0, 255,
]);
function getChannelInvitationDiscriminatorBytes() {
return types.fixEncoderSize(getBytesEncoder(), 8).encode(CHANNEL_INVITATION_DISCRIMINATOR);
}
function getChannelInvitationEncoder() {
return types.transformEncoder(getStructEncoder([
['discriminator', types.fixEncoderSize(getBytesEncoder(), 8)],
['channel', types.getAddressEncoder()],
['inviter', types.getAddressEncoder()],
['invitee', types.getAddressEncoder()],
['invitationHash', getArrayEncoder(getU8Encoder(), { size: 32 })],
['createdAt', getI64Encoder()],
['expiresAt', getI64Encoder()],
['nonce', getU64Encoder()],
['isAccepted', getBooleanEncoder()],
['isUsed', getBooleanEncoder()],
['bump', getU8Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 5 })],
]), (value) => ({ ...value, discriminator: CHANNEL_INVITATION_DISCRIMINATOR }));
}
function getChannelInvitationDecoder() {
return getStructDecoder([
['discriminator', types.fixDecoderSize(getBytesDecoder(), 8)],
['channel', types.getAddressDecoder()],
['inviter', types.getAddressDecoder()],
['invitee', types.getAddressDecoder()],
['invitationHash', getArrayDecoder(getU8Decoder(), { size: 32 })],
['createdAt', getI64Decoder()],
['expiresAt', getI64Decoder()],
['nonce', getU64Decoder()],
['isAccepted', getBooleanDecoder()],
['isUsed', getBooleanDecoder()],
['bump', getU8Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 5 })],
]);
}
function getChannelInvitationCodec() {
return types.combineCodec(getChannelInvitationEncoder(), getChannelInvitationDecoder());
}
function decodeChannelInvitation(encodedAccount) {
return decodeAccount(encodedAccount, getChannelInvitationDecoder());
}
async function fetchChannelInvitation(rpc, address, config) {
const maybeAccount = await fetchMaybeChannelInvitation(rpc, address, config);
assertAccountExists(maybeAccount);
return maybeAccount;
}
async function fetchMaybeChannelInvitation(rpc, address, config) {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return decodeChannelInvitation(maybeAccount);
}
async function fetchAllChannelInvitation(rpc, addresses, config) {
const maybeAccounts = await fetchAllMaybeChannelInvitation(rpc, addresses, config);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}
async function fetchAllMaybeChannelInvitation(rpc, addresses, config) {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) => decodeChannelInvitation(maybeAccount));
}
/**
* 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
*/
const CHANNEL_MESSAGE_DISCRIMINATOR = new Uint8Array([
172, 149, 77, 27, 88, 227, 80, 87,
]);
function getChannelMessageDiscriminatorBytes() {
return types.fixEncoderSize(getBytesEncoder(), 8).encode(CHANNEL_MESSAGE_DISCRIMINATOR);
}
function getChannelMessageEncoder() {
return types.transformEncoder(getStructEncoder([
['discriminator', types.fixEncoderSize(getBytesEncoder(), 8)],
['channel', types.getAddressEncoder()],
['sender', types.getAddressEncoder()],
['replyTo', getOptionEncoder(types.getAddressEncoder())],
['createdAt', getI64Encoder()],
['editedAt', getOptionEncoder(getI64Encoder())],
['content', types.addEncoderSizePrefix(types.getUtf8Encoder(), getU32Encoder())],
['messageType', getMessageTypeEncoder()],
['bump', getU8Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 6 })],
]), (value) => ({ ...value, discriminator: CHANNEL_MESSAGE_DISCRIMINATOR }));
}
function getChannelMessageDecoder() {
return getStructDecoder([
['discriminator', types.fixDecoderSize(getBytesDecoder(), 8)],
['channel', types.getAddressDecoder()],
['sender', types.getAddressDecoder()],
['replyTo', getOptionDecoder(types.getAddressDecoder())],
['createdAt', getI64Decoder()],
['editedAt', getOptionDecoder(getI64Decoder())],
['content', types.addDecoderSizePrefix(types.getUtf8Decoder(), getU32Decoder())],
['messageType', getMessageTypeDecoder()],
['bump', getU8Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 6 })],
]);
}
function getChannelMessageCodec() {
return types.combineCodec(getChannelMessageEncoder(), getChannelMessageDecoder());
}
function decodeChannelMessage(encodedAccount) {
return decodeAccount(encodedAccount, getChannelMessageDecoder());
}
async function fetchChannelMessage(rpc, address, config) {
const maybeAccount = await fetchMaybeChannelMessage(rpc, address, config);
assertAccountExists(maybeAccount);
return maybeAccount;
}
async function fetchMaybeChannelMessage(rpc, address, config) {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return decodeChannelMessage(maybeAccount);
}
async function fetchAllChannelMessage(rpc, addresses, config) {
const maybeAccounts = await fetchAllMaybeChannelMessage(rpc, addresses, config);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}
async function fetchAllMaybeChannelMessage(rpc, addresses, config) {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) => decodeChannelMessage(maybeAccount));
}
/**
* 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
*/
const CHANNEL_PARTICIPANT_DISCRIMINATOR = new Uint8Array([
147, 89, 184, 207, 10, 190, 78, 145,
]);
function getChannelParticipantDiscriminatorBytes() {
return types.fixEncoderSize(getBytesEncoder(), 8).encode(CHANNEL_PARTICIPANT_DISCRIMINATOR);
}
function getChannelParticipantEncoder() {
return types.transformEncoder(getStructEncoder([
['discriminator', types.fixEncoderSize(getBytesEncoder(), 8)],
['channel', types.getAddressEncoder()],
['participant', types.getAddressEncoder()],
['joinedAt', getI64Encoder()],
['messagesSent', getU64Encoder()],
['lastMessageAt', getI64Encoder()],
['isActive', getBooleanEncoder()],
['bump', getU8Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 6 })],
]), (value) => ({ ...value, discriminator: CHANNEL_PARTICIPANT_DISCRIMINATOR }));
}
function getChannelParticipantDecoder() {
return getStructDecoder([
['discriminator', types.fixDecoderSize(getBytesDecoder(), 8)],
['channel', types.getAddressDecoder()],
['participant', types.getAddressDecoder()],
['joinedAt', getI64Decoder()],
['messagesSent', getU64Decoder()],
['lastMessageAt', getI64Decoder()],
['isActive', getBooleanDecoder()],
['bump', getU8Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 6 })],
]);
}
function getChannelParticipantCodec() {
return types.combineCodec(getChannelParticipantEncoder(), getChannelParticipantDecoder());
}
function decodeChannelParticipant(encodedAccount) {
return decodeAccount(encodedAccount, getChannelParticipantDecoder());
}
async function fetchChannelParticipant(rpc, address, config) {
const maybeAccount = await fetchMaybeChannelParticipant(rpc, address, config);
assertAccountExists(maybeAccount);
return maybeAccount;
}
async function fetchMaybeChannelParticipant(rpc, address, config) {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return decodeChannelParticipant(maybeAccount);
}
async function fetchAllChannelParticipant(rpc, addresses, config) {
const maybeAccounts = await fetchAllMaybeChannelParticipant(rpc, addresses, config);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}
async function fetchAllMaybeChann