UNPKG

@nemoprotocol/points-sdk

Version:

1. [Overview](#overview) 2. [Installation](#installation) 3. [Core Features](#core-features) 4. [API Reference](#api-reference) 5. [Type Definitions](#type-definitions)

1,775 lines (1,773 loc) 240 kB
import Ls, { Decimal as re } from "decimal.js"; import "@cetusprotocol/vaults-sdk"; /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ function Ds(r) { return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array"; } function cn(r, e) { return Array.isArray(e) ? e.length === 0 ? !0 : r ? e.every((t) => typeof t == "string") : e.every((t) => Number.isSafeInteger(t)) : !1; } function or(r, e) { if (typeof e != "string") throw new Error(`${r}: string expected`); return !0; } function un(r) { if (!Number.isSafeInteger(r)) throw new Error(`invalid integer: ${r}`); } function cr(r) { if (!Array.isArray(r)) throw new Error("array expected"); } function ln(r, e) { if (!cn(!0, e)) throw new Error(`${r}: array of strings expected`); } function zs(r, e) { if (!cn(!1, e)) throw new Error(`${r}: array of numbers expected`); } // @__NO_SIDE_EFFECTS__ function Fs(...r) { const e = (a) => a, t = (a, i) => (o) => a(i(o)), n = r.map((a) => a.encode).reduceRight(t, e), s = r.map((a) => a.decode).reduce(t, e); return { encode: n, decode: s }; } // @__NO_SIDE_EFFECTS__ function Ws(r) { const e = typeof r == "string" ? r.split("") : r, t = e.length; ln("alphabet", e); const n = new Map(e.map((s, a) => [s, a])); return { encode: (s) => (cr(s), s.map((a) => { if (!Number.isSafeInteger(a) || a < 0 || a >= t) throw new Error(`alphabet.encode: digit index outside alphabet "${a}". Allowed: ${r}`); return e[a]; })), decode: (s) => (cr(s), s.map((a) => { or("alphabet.decode", a); const i = n.get(a); if (i === void 0) throw new Error(`Unknown letter: "${a}". Allowed: ${r}`); return i; })) }; } // @__NO_SIDE_EFFECTS__ function Gs(r = "") { return or("join", r), { encode: (e) => (ln("join.decode", e), e.join(r)), decode: (e) => (or("join.decode", e), e.split(r)) }; } function Vr(r, e, t) { if (e < 2) throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`); if (t < 2) throw new Error(`convertRadix: invalid to=${t}, base cannot be less than 2`); if (cr(r), !r.length) return []; let n = 0; const s = [], a = Array.from(r, (o) => { if (un(o), o < 0 || o >= e) throw new Error(`invalid integer: ${o}`); return o; }), i = a.length; for (; ; ) { let o = 0, u = !0; for (let d = n; d < i; d++) { const l = a[d], f = e * o, p = f + l; if (!Number.isSafeInteger(p) || f / e !== o || p - l !== f) throw new Error("convertRadix: carry overflow"); const y = p / t; o = p % t; const g = Math.floor(y); if (a[d] = g, !Number.isSafeInteger(g) || g * t + o !== p) throw new Error("convertRadix: carry overflow"); if (u) g ? u = !1 : n = d; else continue; } if (s.push(o), u) break; } for (let o = 0; o < r.length - 1 && r[o] === 0; o++) s.push(0); return s.reverse(); } // @__NO_SIDE_EFFECTS__ function qs(r) { un(r); const e = 2 ** 8; return { encode: (t) => { if (!Ds(t)) throw new Error("radix.encode input should be Uint8Array"); return Vr(Array.from(t), e, r); }, decode: (t) => (zs("radix.decode", t), Uint8Array.from(Vr(t, r, e))) }; } const Ks = /* @__NO_SIDE_EFFECTS__ */ (r) => /* @__PURE__ */ Fs(/* @__PURE__ */ qs(58), /* @__PURE__ */ Ws(r), /* @__PURE__ */ Gs("")), dn = /* @__PURE__ */ Ks("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), Wt = (r) => dn.encode(r), mt = (r) => dn.decode(r); function Z(r) { return Uint8Array.from(atob(r), (e) => e.charCodeAt(0)); } const Yt = 8192; function W(r) { if (r.length < Yt) return btoa(String.fromCharCode(...r)); let e = ""; for (var t = 0; t < r.length; t += Yt) { const n = r.slice(t, t + Yt); e += String.fromCharCode(...n); } return btoa(e); } function fn(r) { const e = r.startsWith("0x") ? r.slice(2) : r, t = e.length % 2 === 0 ? e : `0${e}`, n = t.match(/[0-9a-fA-F]{2}/g)?.map((s) => parseInt(s, 16)) ?? []; if (n.length !== t.length / 2) throw new Error(`Invalid hex string ${r}`); return Uint8Array.from(n); } function et(r) { return r.reduce((e, t) => e + t.toString(16).padStart(2, "0"), ""); } function Gt(r, e) { return Array.from({ length: Math.ceil(r.length / e) }, (t, n) => r.slice(n * e, (n + 1) * e)); } class pn { constructor(e, t) { if (typeof e != "function") throw new TypeError( `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${e}.` ); this._batchLoadFn = e, this._maxBatchSize = Qs(t), this._batchScheduleFn = Xs(t), this._cacheKeyFn = Zs(t), this._cacheMap = ea(t), this._batch = null, this.name = ta(t); } /** * Loads a key, returning a `Promise` for the value represented by that key. */ load(e) { if (e == null) throw new TypeError( `The loader.load() function must be called with a value, but got: ${String(e)}.` ); const t = Js(this), n = this._cacheMap; let s; if (n) { s = this._cacheKeyFn(e); const i = n.get(s); if (i) { const o = t.cacheHits || (t.cacheHits = []); return new Promise((u) => { o.push(() => { u(i); }); }); } } t.keys.push(e); const a = new Promise((i, o) => { t.callbacks.push({ resolve: i, reject: o }); }); return n && n.set(s, a), a; } /** * Loads multiple keys, promising an array of values: * * var [ a, b ] = await myLoader.loadMany([ 'a', 'b' ]); * * This is similar to the more verbose: * * var [ a, b ] = await Promise.all([ * myLoader.load('a'), * myLoader.load('b') * ]); * * However it is different in the case where any load fails. Where * Promise.all() would reject, loadMany() always resolves, however each result * is either a value or an Error instance. * * var [ a, b, c ] = await myLoader.loadMany([ 'a', 'b', 'badkey' ]); * // c instanceof Error * */ loadMany(e) { if (!hn(e)) throw new TypeError( `The loader.loadMany() function must be called with Array<key>, but got: ${e}.` ); const t = []; for (let n = 0; n < e.length; n++) t.push(this.load(e[n]).catch((s) => s)); return Promise.all(t); } /** * Clears the value at `key` from the cache, if it exists. Returns itself for * method chaining. */ clear(e) { const t = this._cacheMap; if (t) { const n = this._cacheKeyFn(e); t.delete(n); } return this; } /** * Clears the entire cache. To be used when some event results in unknown * invalidations across this particular `DataLoader`. Returns itself for * method chaining. */ clearAll() { const e = this._cacheMap; return e && e.clear(), this; } /** * Adds the provided key and value to the cache. If the key already * exists, no change is made. Returns itself for method chaining. * * To prime the cache with an error at a key, provide an Error instance. */ prime(e, t) { const n = this._cacheMap; if (n) { const s = this._cacheKeyFn(e); if (n.get(s) === void 0) { let a; t instanceof Error ? (a = Promise.reject(t), a.catch(() => { })) : a = Promise.resolve(t), n.set(s, a); } } return this; } } const Hs = ( /** @ts-ignore */ typeof process == "object" && typeof process.nextTick == "function" ? function(r) { Qt || (Qt = Promise.resolve()), Qt.then(() => { process.nextTick(r); }); } : ( // @ts-ignore typeof setImmediate == "function" ? function(r) { setImmediate(r); } : function(r) { setTimeout(r); } ) ); let Qt; function Js(r) { const e = r._batch; if (e !== null && !e.hasDispatched && e.keys.length < r._maxBatchSize) return e; const t = { hasDispatched: !1, keys: [], callbacks: [] }; return r._batch = t, r._batchScheduleFn(() => { Ys(r, t); }), t; } function Ys(r, e) { if (e.hasDispatched = !0, e.keys.length === 0) { ur(e); return; } let t; try { t = r._batchLoadFn(e.keys); } catch (n) { return Xt( r, e, new TypeError( `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(n)}.` ) ); } if (!t || typeof t.then != "function") return Xt( r, e, new TypeError( `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(t)}.` ) ); Promise.resolve(t).then((n) => { if (!hn(n)) throw new TypeError( `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: ${String(n)}.` ); if (n.length !== e.keys.length) throw new TypeError( `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys. Keys: ${String(e.keys)} Values: ${String(n)}` ); ur(e); for (let s = 0; s < e.callbacks.length; s++) { const a = n[s]; a instanceof Error ? e.callbacks[s].reject(a) : e.callbacks[s].resolve(a); } }).catch((n) => { Xt(r, e, n); }); } function Xt(r, e, t) { ur(e); for (let n = 0; n < e.keys.length; n++) r.clear(e.keys[n]), e.callbacks[n].reject(t); } function ur(r) { if (r.cacheHits) for (let e = 0; e < r.cacheHits.length; e++) r.cacheHits[e](); } function Qs(r) { if (!(!r || r.batch !== !1)) return 1; const t = r && r.maxBatchSize; if (t === void 0) return 1 / 0; if (typeof t != "number" || t < 1) throw new TypeError(`maxBatchSize must be a positive number: ${t}`); return t; } function Xs(r) { const e = r && r.batchScheduleFn; if (e === void 0) return Hs; if (typeof e != "function") throw new TypeError(`batchScheduleFn must be a function: ${e}`); return e; } function Zs(r) { const e = r && r.cacheKeyFn; if (e === void 0) return (t) => t; if (typeof e != "function") throw new TypeError(`cacheKeyFn must be a function: ${e}`); return e; } function ea(r) { if (!(!r || r.cache !== !1)) return null; const t = r && r.cacheMap; if (t === void 0) return /* @__PURE__ */ new Map(); if (t !== null) { const s = ["get", "set", "delete", "clear"].filter( (a) => t && typeof t[a] != "function" ); if (s.length !== 0) throw new TypeError("Custom cacheMap missing methods: " + s.join(", ")); } return t; } function ta(r) { return r && r.name ? r.name : null; } function hn(r) { return typeof r == "object" && r !== null && "length" in r && typeof r.length == "number" && (r.length === 0 || r.length > 0 && Object.prototype.hasOwnProperty.call(r, r.length - 1)); } function Ut(r) { const e = []; let t = 0; if (r === 0) return [0]; for (; r > 0; ) e[t] = r & 127, (r >>= 7) && (e[t] |= 128), t += 1; return e; } function ra(r) { let e = 0, t = 0, n = 0; for (; ; ) { const s = r[n]; if (n += 1, e |= (s & 127) << t, (s & 128) === 0) break; t += 7; } return { value: e, length: n }; } class na { /** * @param {Uint8Array} data Data to use as a buffer. */ constructor(e) { this.bytePosition = 0, this.dataView = new DataView(e.buffer, e.byteOffset, e.byteLength); } /** * Shift current cursor position by `bytes`. * * @param {Number} bytes Number of bytes to * @returns {this} Self for possible chaining. */ shift(e) { return this.bytePosition += e, this; } /** * Read U8 value from the buffer and shift cursor by 1. * @returns */ read8() { const e = this.dataView.getUint8(this.bytePosition); return this.shift(1), e; } /** * Read U16 value from the buffer and shift cursor by 2. * @returns */ read16() { const e = this.dataView.getUint16(this.bytePosition, !0); return this.shift(2), e; } /** * Read U32 value from the buffer and shift cursor by 4. * @returns */ read32() { const e = this.dataView.getUint32(this.bytePosition, !0); return this.shift(4), e; } /** * Read U64 value from the buffer and shift cursor by 8. * @returns */ read64() { const e = this.read32(), n = this.read32().toString(16) + e.toString(16).padStart(8, "0"); return BigInt("0x" + n).toString(10); } /** * Read U128 value from the buffer and shift cursor by 16. */ read128() { const e = BigInt(this.read64()), n = BigInt(this.read64()).toString(16) + e.toString(16).padStart(16, "0"); return BigInt("0x" + n).toString(10); } /** * Read U128 value from the buffer and shift cursor by 32. * @returns */ read256() { const e = BigInt(this.read128()), n = BigInt(this.read128()).toString(16) + e.toString(16).padStart(32, "0"); return BigInt("0x" + n).toString(10); } /** * Read `num` number of bytes from the buffer and shift cursor by `num`. * @param num Number of bytes to read. */ readBytes(e) { const t = this.bytePosition + this.dataView.byteOffset, n = new Uint8Array(this.dataView.buffer, t, e); return this.shift(e), n; } /** * Read ULEB value - an integer of varying size. Used for enum indexes and * vector lengths. * @returns {Number} The ULEB value. */ readULEB() { const e = this.bytePosition + this.dataView.byteOffset, t = new Uint8Array(this.dataView.buffer, e), { value: n, length: s } = ra(t); return this.shift(s), n; } /** * Read a BCS vector: read a length and then apply function `cb` X times * where X is the length of the vector, defined as ULEB in BCS bytes. * @param cb Callback to process elements of vector. * @returns {Array<Any>} Array of the resulting values, returned by callback. */ readVec(e) { const t = this.readULEB(), n = []; for (let s = 0; s < t; s++) n.push(e(this, s, t)); return n; } } function sa(r, e) { switch (e) { case "base58": return Wt(r); case "base64": return W(r); case "hex": return et(r); default: throw new Error("Unsupported encoding, supported values are: base64, hex"); } } function bn(r, e = ["<", ">"]) { const [t, n] = e, s = []; let a = "", i = 0; for (let o = 0; o < r.length; o++) { const u = r[o]; if (u === t && i++, u === n && i--, i === 0 && u === ",") { s.push(a.trim()), a = ""; continue; } a += u; } return s.push(a.trim()), s; } class aa { constructor({ initialSize: e = 1024, maxSize: t = 1 / 0, allocateSize: n = 1024 } = {}) { this.bytePosition = 0, this.size = e, this.maxSize = t, this.allocateSize = n, this.dataView = new DataView(new ArrayBuffer(e)); } ensureSizeOrGrow(e) { const t = this.bytePosition + e; if (t > this.size) { const n = Math.min(this.maxSize, this.size + this.allocateSize); if (t > n) throw new Error( `Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}` ); this.size = n; const s = new ArrayBuffer(this.size); new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)), this.dataView = new DataView(s); } } /** * Shift current cursor position by `bytes`. * * @param {Number} bytes Number of bytes to * @returns {this} Self for possible chaining. */ shift(e) { return this.bytePosition += e, this; } /** * Write a U8 value into a buffer and shift cursor position by 1. * @param {Number} value Value to write. * @returns {this} */ write8(e) { return this.ensureSizeOrGrow(1), this.dataView.setUint8(this.bytePosition, Number(e)), this.shift(1); } /** * Write a U16 value into a buffer and shift cursor position by 2. * @param {Number} value Value to write. * @returns {this} */ write16(e) { return this.ensureSizeOrGrow(2), this.dataView.setUint16(this.bytePosition, Number(e), !0), this.shift(2); } /** * Write a U32 value into a buffer and shift cursor position by 4. * @param {Number} value Value to write. * @returns {this} */ write32(e) { return this.ensureSizeOrGrow(4), this.dataView.setUint32(this.bytePosition, Number(e), !0), this.shift(4); } /** * Write a U64 value into a buffer and shift cursor position by 8. * @param {bigint} value Value to write. * @returns {this} */ write64(e) { return Zt(BigInt(e), 8).forEach((t) => this.write8(t)), this; } /** * Write a U128 value into a buffer and shift cursor position by 16. * * @param {bigint} value Value to write. * @returns {this} */ write128(e) { return Zt(BigInt(e), 16).forEach((t) => this.write8(t)), this; } /** * Write a U256 value into a buffer and shift cursor position by 16. * * @param {bigint} value Value to write. * @returns {this} */ write256(e) { return Zt(BigInt(e), 32).forEach((t) => this.write8(t)), this; } /** * Write a ULEB value into a buffer and shift cursor position by number of bytes * written. * @param {Number} value Value to write. * @returns {this} */ writeULEB(e) { return Ut(e).forEach((t) => this.write8(t)), this; } /** * Write a vector into a buffer by first writing the vector length and then calling * a callback on each passed value. * * @param {Array<Any>} vector Array of elements to write. * @param {WriteVecCb} cb Callback to call on each element of the vector. * @returns {this} */ writeVec(e, t) { return this.writeULEB(e.length), Array.from(e).forEach((n, s) => t(this, n, s, e.length)), this; } /** * Adds support for iterations over the object. * @returns {Uint8Array} */ *[Symbol.iterator]() { for (let e = 0; e < this.bytePosition; e++) yield this.dataView.getUint8(e); return this.toBytes(); } /** * Get underlying buffer taking only value bytes (in case initial buffer size was bigger). * @returns {Uint8Array} Resulting bcs. */ toBytes() { return new Uint8Array(this.dataView.buffer.slice(0, this.bytePosition)); } /** * Represent data as 'hex' or 'base64' * @param encoding Encoding to use: 'base64' or 'hex' */ toString(e) { return sa(this.toBytes(), e); } } function Zt(r, e) { const t = new Uint8Array(e); let n = 0; for (; r > 0; ) t[n] = Number(r % BigInt(256)), r = r / BigInt(256), n += 1; return t; } var mn = (r) => { throw TypeError(r); }, gn = (r, e, t) => e.has(r) || mn("Cannot " + t), ce = (r, e, t) => (gn(r, e, "read from private field"), t ? t.call(r) : e.get(r)), Rt = (r, e, t) => e.has(r) ? mn("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), Nt = (r, e, t, n) => (gn(r, e, "write to private field"), e.set(r, t), t), Qe, it, Ct, je; const ia = class yn { constructor(e) { Rt(this, Qe), Rt(this, it), this.name = e.name, this.read = e.read, this.serializedSize = e.serializedSize ?? (() => null), Nt(this, Qe, e.write), Nt(this, it, e.serialize ?? ((t, n) => { const s = new aa({ initialSize: this.serializedSize(t) ?? void 0, ...n }); return ce(this, Qe).call(this, t, s), s.toBytes(); })), this.validate = e.validate ?? (() => { }); } write(e, t) { this.validate(e), ce(this, Qe).call(this, e, t); } serialize(e, t) { return this.validate(e), new oa(this, ce(this, it).call(this, e, t)); } parse(e) { const t = new na(e); return this.read(t); } fromHex(e) { return this.parse(fn(e)); } fromBase58(e) { return this.parse(mt(e)); } fromBase64(e) { return this.parse(Z(e)); } transform({ name: e, input: t, output: n, validate: s }) { return new yn({ name: e ?? this.name, read: (a) => n ? n(this.read(a)) : this.read(a), write: (a, i) => ce(this, Qe).call(this, t ? t(a) : a, i), serializedSize: (a) => this.serializedSize(t ? t(a) : a), serialize: (a, i) => ce(this, it).call(this, t ? t(a) : a, i), validate: (a) => { s?.(a), this.validate(t ? t(a) : a); } }); } }; Qe = /* @__PURE__ */ new WeakMap(); it = /* @__PURE__ */ new WeakMap(); let me = ia; const vn = Symbol.for("@mysten/serialized-bcs"); function kr(r) { return !!r && typeof r == "object" && r[vn] === !0; } class oa { constructor(e, t) { Rt(this, Ct), Rt(this, je), Nt(this, Ct, e), Nt(this, je, t); } // Used to brand SerializedBcs so that they can be identified, even between multiple copies // of the @mysten/bcs package are installed get [vn]() { return !0; } toBytes() { return ce(this, je); } toHex() { return et(ce(this, je)); } toBase64() { return W(ce(this, je)); } toBase58() { return Wt(ce(this, je)); } parse() { return ce(this, Ct).parse(ce(this, je)); } } Ct = /* @__PURE__ */ new WeakMap(); je = /* @__PURE__ */ new WeakMap(); function Bt({ size: r, ...e }) { return new me({ ...e, serializedSize: () => r }); } function er({ readMethod: r, writeMethod: e, ...t }) { return Bt({ ...t, read: (n) => n[r](), write: (n, s) => s[e](n), validate: (n) => { if (n < 0 || n > t.maxValue) throw new TypeError( `Invalid ${t.name} value: ${n}. Expected value in range 0-${t.maxValue}` ); t.validate?.(n); } }); } function tr({ readMethod: r, writeMethod: e, ...t }) { return Bt({ ...t, read: (n) => n[r](), write: (n, s) => s[e](BigInt(n)), validate: (n) => { const s = BigInt(n); if (s < 0 || s > t.maxValue) throw new TypeError( `Invalid ${t.name} value: ${s}. Expected value in range 0-${t.maxValue}` ); t.validate?.(s); } }); } function ca({ serialize: r, ...e }) { const t = new me({ ...e, serialize: r, write: (n, s) => { for (const a of t.serialize(n).toBytes()) s.write8(a); } }); return t; } function ua({ toBytes: r, fromBytes: e, ...t }) { return new me({ ...t, read: (n) => { const s = n.readULEB(), a = n.readBytes(s); return e(a); }, write: (n, s) => { const a = r(n); s.writeULEB(a.length); for (let i = 0; i < a.length; i++) s.write8(a[i]); }, serialize: (n) => { const s = r(n), a = Ut(s.length), i = new Uint8Array(a.length + s.length); return i.set(a, 0), i.set(s, a.length), i; }, validate: (n) => { if (typeof n != "string") throw new TypeError(`Invalid ${t.name} value: ${n}. Expected string`); t.validate?.(n); } }); } function la(r) { let e = null; function t() { return e || (e = r()), e; } return new me({ name: "lazy", read: (n) => t().read(n), serializedSize: (n) => t().serializedSize(n), write: (n, s) => t().write(n, s), serialize: (n, s) => t().serialize(n, s).toBytes() }); } const c = { /** * Creates a BcsType that can be used to read and write an 8-bit unsigned integer. * @example * bcs.u8().serialize(255).toBytes() // Uint8Array [ 255 ] */ u8(r) { return er({ name: "u8", readMethod: "read8", writeMethod: "write8", size: 1, maxValue: 2 ** 8 - 1, ...r }); }, /** * Creates a BcsType that can be used to read and write a 16-bit unsigned integer. * @example * bcs.u16().serialize(65535).toBytes() // Uint8Array [ 255, 255 ] */ u16(r) { return er({ name: "u16", readMethod: "read16", writeMethod: "write16", size: 2, maxValue: 2 ** 16 - 1, ...r }); }, /** * Creates a BcsType that can be used to read and write a 32-bit unsigned integer. * @example * bcs.u32().serialize(4294967295).toBytes() // Uint8Array [ 255, 255, 255, 255 ] */ u32(r) { return er({ name: "u32", readMethod: "read32", writeMethod: "write32", size: 4, maxValue: 2 ** 32 - 1, ...r }); }, /** * Creates a BcsType that can be used to read and write a 64-bit unsigned integer. * @example * bcs.u64().serialize(1).toBytes() // Uint8Array [ 1, 0, 0, 0, 0, 0, 0, 0 ] */ u64(r) { return tr({ name: "u64", readMethod: "read64", writeMethod: "write64", size: 8, maxValue: 2n ** 64n - 1n, ...r }); }, /** * Creates a BcsType that can be used to read and write a 128-bit unsigned integer. * @example * bcs.u128().serialize(1).toBytes() // Uint8Array [ 1, ..., 0 ] */ u128(r) { return tr({ name: "u128", readMethod: "read128", writeMethod: "write128", size: 16, maxValue: 2n ** 128n - 1n, ...r }); }, /** * Creates a BcsType that can be used to read and write a 256-bit unsigned integer. * @example * bcs.u256().serialize(1).toBytes() // Uint8Array [ 1, ..., 0 ] */ u256(r) { return tr({ name: "u256", readMethod: "read256", writeMethod: "write256", size: 32, maxValue: 2n ** 256n - 1n, ...r }); }, /** * Creates a BcsType that can be used to read and write boolean values. * @example * bcs.bool().serialize(true).toBytes() // Uint8Array [ 1 ] */ bool(r) { return Bt({ name: "bool", size: 1, read: (e) => e.read8() === 1, write: (e, t) => t.write8(e ? 1 : 0), ...r, validate: (e) => { if (r?.validate?.(e), typeof e != "boolean") throw new TypeError(`Expected boolean, found ${typeof e}`); } }); }, /** * Creates a BcsType that can be used to read and write unsigned LEB encoded integers * @example * */ uleb128(r) { return ca({ name: "uleb128", read: (e) => e.readULEB(), serialize: (e) => Uint8Array.from(Ut(e)), ...r }); }, /** * Creates a BcsType representing a fixed length byte array * @param size The number of bytes this types represents * @example * bcs.bytes(3).serialize(new Uint8Array([1, 2, 3])).toBytes() // Uint8Array [1, 2, 3] */ bytes(r, e) { return Bt({ name: `bytes[${r}]`, size: r, read: (t) => t.readBytes(r), write: (t, n) => { const s = new Uint8Array(t); for (let a = 0; a < r; a++) n.write8(s[a] ?? 0); }, ...e, validate: (t) => { if (e?.validate?.(t), !t || typeof t != "object" || !("length" in t)) throw new TypeError(`Expected array, found ${typeof t}`); if (t.length !== r) throw new TypeError(`Expected array of length ${r}, found ${t.length}`); } }); }, /** * Creates a BcsType representing a variable length byte array * * @example * bcs.byteVector().serialize([1, 2, 3]).toBytes() // Uint8Array [3, 1, 2, 3] */ byteVector(r) { return new me({ name: "bytesVector", read: (e) => { const t = e.readULEB(); return e.readBytes(t); }, write: (e, t) => { const n = new Uint8Array(e); t.writeULEB(n.length); for (let s = 0; s < n.length; s++) t.write8(n[s] ?? 0); }, ...r, serializedSize: (e) => { const t = "length" in e ? e.length : null; return t == null ? null : Ut(t).length + t; }, validate: (e) => { if (r?.validate?.(e), !e || typeof e != "object" || !("length" in e)) throw new TypeError(`Expected array, found ${typeof e}`); } }); }, /** * Creates a BcsType that can ser/de string values. Strings will be UTF-8 encoded * @example * bcs.string().serialize('a').toBytes() // Uint8Array [ 1, 97 ] */ string(r) { return ua({ name: "string", toBytes: (e) => new TextEncoder().encode(e), fromBytes: (e) => new TextDecoder().decode(e), ...r }); }, /** * Creates a BcsType that represents a fixed length array of a given type * @param size The number of elements in the array * @param type The BcsType of each element in the array * @example * bcs.fixedArray(3, bcs.u8()).serialize([1, 2, 3]).toBytes() // Uint8Array [ 1, 2, 3 ] */ fixedArray(r, e, t) { return new me({ name: `${e.name}[${r}]`, read: (n) => { const s = new Array(r); for (let a = 0; a < r; a++) s[a] = e.read(n); return s; }, write: (n, s) => { for (const a of n) e.write(a, s); }, ...t, validate: (n) => { if (t?.validate?.(n), !n || typeof n != "object" || !("length" in n)) throw new TypeError(`Expected array, found ${typeof n}`); if (n.length !== r) throw new TypeError(`Expected array of length ${r}, found ${n.length}`); } }); }, /** * Creates a BcsType representing an optional value * @param type The BcsType of the optional value * @example * bcs.option(bcs.u8()).serialize(null).toBytes() // Uint8Array [ 0 ] * bcs.option(bcs.u8()).serialize(1).toBytes() // Uint8Array [ 1, 1 ] */ option(r) { return c.enum(`Option<${r.name}>`, { None: null, Some: r }).transform({ input: (e) => e == null ? { None: !0 } : { Some: e }, output: (e) => e.$kind === "Some" ? e.Some : null }); }, /** * Creates a BcsType representing a variable length vector of a given type * @param type The BcsType of each element in the vector * * @example * bcs.vector(bcs.u8()).toBytes([1, 2, 3]) // Uint8Array [ 3, 1, 2, 3 ] */ vector(r, e) { return new me({ name: `vector<${r.name}>`, read: (t) => { const n = t.readULEB(), s = new Array(n); for (let a = 0; a < n; a++) s[a] = r.read(t); return s; }, write: (t, n) => { n.writeULEB(t.length); for (const s of t) r.write(s, n); }, ...e, validate: (t) => { if (e?.validate?.(t), !t || typeof t != "object" || !("length" in t)) throw new TypeError(`Expected array, found ${typeof t}`); } }); }, /** * Creates a BcsType representing a tuple of a given set of types * @param types The BcsTypes for each element in the tuple * * @example * const tuple = bcs.tuple([bcs.u8(), bcs.string(), bcs.bool()]) * tuple.serialize([1, 'a', true]).toBytes() // Uint8Array [ 1, 1, 97, 1 ] */ tuple(r, e) { return new me({ name: `(${r.map((t) => t.name).join(", ")})`, serializedSize: (t) => { let n = 0; for (let s = 0; s < r.length; s++) { const a = r[s].serializedSize(t[s]); if (a == null) return null; n += a; } return n; }, read: (t) => { const n = []; for (const s of r) n.push(s.read(t)); return n; }, write: (t, n) => { for (let s = 0; s < r.length; s++) r[s].write(t[s], n); }, ...e, validate: (t) => { if (e?.validate?.(t), !Array.isArray(t)) throw new TypeError(`Expected array, found ${typeof t}`); if (t.length !== r.length) throw new TypeError(`Expected array of length ${r.length}, found ${t.length}`); } }); }, /** * Creates a BcsType representing a struct of a given set of fields * @param name The name of the struct * @param fields The fields of the struct. The order of the fields affects how data is serialized and deserialized * * @example * const struct = bcs.struct('MyStruct', { * a: bcs.u8(), * b: bcs.string(), * }) * struct.serialize({ a: 1, b: 'a' }).toBytes() // Uint8Array [ 1, 1, 97 ] */ struct(r, e, t) { const n = Object.entries(e); return new me({ name: r, serializedSize: (s) => { let a = 0; for (const [i, o] of n) { const u = o.serializedSize(s[i]); if (u == null) return null; a += u; } return a; }, read: (s) => { const a = {}; for (const [i, o] of n) a[i] = o.read(s); return a; }, write: (s, a) => { for (const [i, o] of n) o.write(s[i], a); }, ...t, validate: (s) => { if (t?.validate?.(s), typeof s != "object" || s == null) throw new TypeError(`Expected object, found ${typeof s}`); } }); }, /** * Creates a BcsType representing an enum of a given set of options * @param name The name of the enum * @param values The values of the enum. The order of the values affects how data is serialized and deserialized. * null can be used to represent a variant with no data. * * @example * const enum = bcs.enum('MyEnum', { * A: bcs.u8(), * B: bcs.string(), * C: null, * }) * enum.serialize({ A: 1 }).toBytes() // Uint8Array [ 0, 1 ] * enum.serialize({ B: 'a' }).toBytes() // Uint8Array [ 1, 1, 97 ] * enum.serialize({ C: true }).toBytes() // Uint8Array [ 2 ] */ enum(r, e, t) { const n = Object.entries(e); return new me({ name: r, read: (s) => { const a = s.readULEB(), i = n[a]; if (!i) throw new TypeError(`Unknown value ${a} for enum ${r}`); const [o, u] = i; return { [o]: u?.read(s) ?? !0, $kind: o }; }, write: (s, a) => { const [i, o] = Object.entries(s).filter( ([u]) => Object.hasOwn(e, u) )[0]; for (let u = 0; u < n.length; u++) { const [d, l] = n[u]; if (d === i) { a.writeULEB(u), l?.write(o, a); return; } } }, ...t, validate: (s) => { if (t?.validate?.(s), typeof s != "object" || s == null) throw new TypeError(`Expected object, found ${typeof s}`); const a = Object.keys(s).filter( (o) => s[o] !== void 0 && Object.hasOwn(e, o) ); if (a.length !== 1) throw new TypeError( `Expected object with one key, but found ${a.length} for type ${r}}` ); const [i] = a; if (!Object.hasOwn(e, i)) throw new TypeError(`Invalid enum variant ${i}`); } }); }, /** * Creates a BcsType representing a map of a given key and value type * @param keyType The BcsType of the key * @param valueType The BcsType of the value * @example * const map = bcs.map(bcs.u8(), bcs.string()) * map.serialize(new Map([[2, 'a']])).toBytes() // Uint8Array [ 1, 2, 1, 97 ] */ map(r, e) { return c.vector(c.tuple([r, e])).transform({ name: `Map<${r.name}, ${e.name}>`, input: (t) => [...t.entries()], output: (t) => { const n = /* @__PURE__ */ new Map(); for (const [s, a] of t) n.set(s, a); return n; } }); }, /** * Creates a BcsType that wraps another BcsType which is lazily evaluated. This is useful for creating recursive types. * @param cb A callback that returns the BcsType */ lazy(r) { return la(r); } }, wn = /^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i, _n = /^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i, da = 235; function fa(r) { return r.length > da ? !1 : r.includes("@") ? wn.test(r) : _n.test(r); } function pa(r, e = "at") { const t = r.toLowerCase(); let n; if (t.includes("@")) { if (!wn.test(t)) throw new Error(`Invalid SuiNS name ${r}`); const [s, a] = t.split("@"); n = [...s ? s.split(".") : [], a]; } else { if (!_n.test(t)) throw new Error(`Invalid SuiNS name ${r}`); n = t.split(".").slice(0, -1); } return e === "dot" ? `${n.join(".")}.sui` : `${n.slice(0, -1).join(".")}@${n[n.length - 1]}`; } const ha = /^([a-z0-9]+(?:-[a-z0-9]+)*)$/, ba = /^\d+$/, ma = 64, Sn = "/", X = (r) => { const e = r.split(Sn); if (e.length < 2 || e.length > 3) return !1; const [t, n, s] = e; return s !== void 0 && !ba.test(s) || !fa(t) ? !1 : ha.test(n) && n.length < ma; }, ga = (r) => { const e = r.split(/::|<|>|,/); for (const t of e) if (t.includes(Sn) && !X(t)) return !1; return !0; }, ya = 32; function Lr(r) { try { return mt(r).length === ya; } catch { return !1; } } const qt = 32; function ue(r) { return wa(r) && _a(r) === qt; } function At(r) { return ue(r); } function va(r) { return r.includes("::") ? Ge(r) : r; } function Ge(r) { const [e, t] = r.split("::"), n = X(e), s = r.slice(e.length + t.length + 4), a = s.includes("<") ? s.slice(0, s.indexOf("<")) : s, i = s.includes("<") ? bn(s.slice(s.indexOf("<") + 1, s.lastIndexOf(">"))).map( (o) => va(o.trim()) ) : []; return { address: n ? e : I(e), module: t, name: a, typeParams: i }; } function Vt(r) { const { address: e, module: t, name: n, typeParams: s } = typeof r == "string" ? Ge(r) : r, a = s?.length > 0 ? `<${s.map( (i) => typeof i == "string" ? i : Vt(i) ).join(",")}>` : ""; return `${e}::${t}::${n}${a}`; } function I(r, e = !1) { let t = r.toLowerCase(); return !e && t.startsWith("0x") && (t = t.slice(2)), `0x${t.padStart(qt * 2, "0")}`; } function ke(r, e = !1) { return I(r, e); } function wa(r) { return /^(0x|0X)?[a-fA-F0-9]+$/.test(r) && r.length % 2 === 0; } function _a(r) { return /^(0x|0X)/.test(r) ? (r.length - 2) / 2 : r.length / 2; } const Sa = /^vector<(.+)>$/, Ta = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/; class de { static parseFromStr(e, t = !1) { if (e === "address") return { address: null }; if (e === "bool") return { bool: null }; if (e === "u8") return { u8: null }; if (e === "u16") return { u16: null }; if (e === "u32") return { u32: null }; if (e === "u64") return { u64: null }; if (e === "u128") return { u128: null }; if (e === "u256") return { u256: null }; if (e === "signer") return { signer: null }; const n = e.match(Sa); if (n) return { vector: de.parseFromStr(n[1], t) }; const s = e.match(Ta); if (s) return { struct: { address: t ? I(s[1]) : s[1], module: s[2], name: s[3], typeParams: s[5] === void 0 ? [] : de.parseStructTypeArgs(s[5], t) } }; throw new Error(`Encountered unexpected token when parsing type args for ${e}`); } static parseStructTypeArgs(e, t = !1) { return bn(e).map( (n) => de.parseFromStr(n, t) ); } static tagToString(e) { if ("bool" in e) return "bool"; if ("u8" in e) return "u8"; if ("u16" in e) return "u16"; if ("u32" in e) return "u32"; if ("u64" in e) return "u64"; if ("u128" in e) return "u128"; if ("u256" in e) return "u256"; if ("address" in e) return "address"; if ("signer" in e) return "signer"; if ("vector" in e) return `vector<${de.tagToString(e.vector)}>`; if ("struct" in e) { const t = e.struct, n = t.typeParams.map(de.tagToString).join(", "); return `${t.address}::${t.module}::${t.name}${n ? `<${n}>` : ""}`; } throw new Error("Invalid TypeTag"); } } function ka(r) { return c.u64({ name: "unsafe_u64", ...r }).transform({ input: (e) => e, output: (e) => Number(e) }); } function Aa(r) { return c.enum("Option", { None: null, Some: r }); } const C = c.bytes(qt).transform({ validate: (r) => { const e = typeof r == "string" ? r : et(r); if (!e || !ue(I(e))) throw new Error(`Invalid Sui address ${e}`); }, input: (r) => typeof r == "string" ? fn(I(r)) : r, output: (r) => I(et(r)) }), pe = c.vector(c.u8()).transform({ name: "ObjectDigest", input: (r) => mt(r), output: (r) => Wt(new Uint8Array(r)), validate: (r) => { if (mt(r).length !== 32) throw new Error("ObjectDigest must be 32 bytes"); } }), ne = c.struct("SuiObjectRef", { objectId: C, version: c.u64(), digest: pe }), Tn = c.struct("SharedObjectRef", { objectId: C, initialSharedVersion: c.u64(), mutable: c.bool() }), kn = c.enum("ObjectArg", { ImmOrOwnedObject: ne, SharedObject: Tn, Receiving: ne }), Le = c.enum("Owner", { AddressOwner: C, ObjectOwner: C, Shared: c.struct("Shared", { initialSharedVersion: c.u64() }), Immutable: null, ConsensusV2: c.struct("ConsensusV2", { authenticator: c.enum("Authenticator", { SingleOwner: C }), startVersion: c.u64() }) }), An = c.enum("CallArg", { Pure: c.struct("Pure", { bytes: c.vector(c.u8()).transform({ input: (r) => typeof r == "string" ? Z(r) : r, output: (r) => W(new Uint8Array(r)) }) }), Object: kn }), Ar = c.enum("TypeTag", { bool: null, u8: null, u64: null, u128: null, address: null, signer: null, vector: c.lazy(() => Ar), struct: c.lazy(() => xn), u16: null, u32: null, u256: null }), Ir = Ar.transform({ input: (r) => typeof r == "string" ? de.parseFromStr(r, !0) : r, output: (r) => de.tagToString(r) }), be = c.enum("Argument", { GasCoin: null, Input: c.u16(), Result: c.u16(), NestedResult: c.tuple([c.u16(), c.u16()]) }), In = c.struct("ProgrammableMoveCall", { package: C, module: c.string(), function: c.string(), typeArguments: c.vector(Ir), arguments: c.vector(be) }), En = c.enum("Command", { /** * A Move Call - any public Move function can be called via * this transaction. The results can be used that instant to pass * into the next transaction. */ MoveCall: In, /** * Transfer vector of objects to a receiver. */ TransferObjects: c.struct("TransferObjects", { objects: c.vector(be), address: be }), // /** // * Split `amount` from a `coin`. // */ SplitCoins: c.struct("SplitCoins", { coin: be, amounts: c.vector(be) }), // /** // * Merge Vector of Coins (`sources`) into a `destination`. // */ MergeCoins: c.struct("MergeCoins", { destination: be, sources: c.vector(be) }), // /** // * Publish a Move module. // */ Publish: c.struct("Publish", { modules: c.vector( c.vector(c.u8()).transform({ input: (r) => typeof r == "string" ? Z(r) : r, output: (r) => W(new Uint8Array(r)) }) ), dependencies: c.vector(C) }), // /** // * Build a vector of objects using the input arguments. // * It is impossible to export construct a `vector<T: key>` otherwise, // * so this call serves a utility function. // */ MakeMoveVec: c.struct("MakeMoveVec", { type: Aa(Ir).transform({ input: (r) => r === null ? { None: !0 } : { Some: r }, output: (r) => r.Some ?? null }), elements: c.vector(be) }), Upgrade: c.struct("Upgrade", { modules: c.vector( c.vector(c.u8()).transform({ input: (r) => typeof r == "string" ? Z(r) : r, output: (r) => W(new Uint8Array(r)) }) ), dependencies: c.vector(C), package: C, ticket: be }) }), On = c.struct("ProgrammableTransaction", { inputs: c.vector(An), commands: c.vector(En) }), Cn = c.enum("TransactionKind", { ProgrammableTransaction: On, ChangeEpoch: null, Genesis: null, ConsensusCommitPrologue: null }), jn = c.enum("TransactionExpiration", { None: null, Epoch: ka() }), xn = c.struct("StructTag", { address: C, module: c.string(), name: c.string(), typeParams: c.vector(Ar) }), Mn = c.struct("GasData", { payment: c.vector(ne), owner: C, price: c.u64(), budget: c.u64() }), $n = c.struct("TransactionDataV1", { kind: Cn, sender: C, gasData: Mn, expiration: jn }), Pn = c.enum("TransactionData", { V1: $n }), Un = c.enum("IntentScope", { TransactionData: null, TransactionEffects: null, CheckpointSummary: null, PersonalMessage: null }), Rn = c.enum("IntentVersion", { V0: null }), Nn = c.enum("AppId", { Sui: null }), Bn = c.struct("Intent", { scope: Un, version: Rn, appId: Nn }); function Vn(r) { return c.struct(`IntentMessage<${r.name}>`, { intent: Bn, value: r }); } const Ln = c.enum("CompressedSignature", { ED25519: c.fixedArray(64, c.u8()), Secp256k1: c.fixedArray(64, c.u8()), Secp256r1: c.fixedArray(64, c.u8()), ZkLogin: c.vector(c.u8()) }), Dn = c.enum("PublicKey", { ED25519: c.fixedArray(32, c.u8()), Secp256k1: c.fixedArray(33, c.u8()), Secp256r1: c.fixedArray(33, c.u8()), ZkLogin: c.vector(c.u8()) }), zn = c.struct("MultiSigPkMap", { pubKey: Dn, weight: c.u8() }), Fn = c.struct("MultiSigPublicKey", { pk_map: c.vector(zn), threshold: c.u16() }), Ia = c.struct("MultiSig", { sigs: c.vector(Ln), bitmap: c.u16(), multisig_pk: Fn }), Ea = c.vector(c.u8()).transform({ input: (r) => typeof r == "string" ? Z(r) : r, output: (r) => W(new Uint8Array(r)) }), Wn = c.struct("SenderSignedTransaction", { intentMessage: Vn(Pn), txSignatures: c.vector(Ea) }), Oa = c.vector(Wn, { name: "SenderSignedData" }), Ca = c.struct("PasskeyAuthenticator", { authenticatorData: c.vector(c.u8()), clientDataJson: c.string(), userSignature: c.vector(c.u8()) }), ja = c.enum("PackageUpgradeError", { UnableToFetchPackage: c.struct("UnableToFetchPackage", { packageId: C }), NotAPackage: c.struct("NotAPackage", { objectId: C }), IncompatibleUpgrade: null, DigestDoesNotMatch: c.struct("DigestDoesNotMatch", { digest: c.vector(c.u8()) }), UnknownUpgradePolicy: c.struct("UnknownUpgradePolicy", { policy: c.u8() }), PackageIDDoesNotMatch: c.struct("PackageIDDoesNotMatch", { packageId: C, ticketId: C }) }), xa = c.struct("ModuleId", { address: C, name: c.string() }), Dr = c.struct("MoveLocation", { module: xa, function: c.u16(), instruction: c.u16(), functionName: c.option(c.string()) }), Ma = c.enum("CommandArgumentError", { TypeMismatch: null, InvalidBCSBytes: null, InvalidUsageOfPureArg: null, InvalidArgumentToPrivateEntryFunction: null, IndexOutOfBounds: c.struct("IndexOutOfBounds", { idx: c.u16() }), SecondaryIndexOutOfBounds: c.struct("SecondaryIndexOutOfBounds", { resultIdx: c.u16(), secondaryIdx: c.u16() }), InvalidResultArity: c.struct("InvalidResultArity", { resultIdx: c.u16() }), InvalidGasCoinUsage: null, InvalidValueUsage: null, InvalidObjectByValue: null, InvalidObjectByMutRef: null, SharedObjectOperationNotAllowed: null }), $a = c.enum("TypeArgumentError", { TypeNotFound: null, ConstraintNotSatisfied: null }), Pa = c.enum("ExecutionFailureStatus", { InsufficientGas: null, InvalidGasObject: null, InvariantViolation: null, FeatureNotYetSupported: null, MoveObjectTooBig: c.struct("MoveObjectTooBig", { objectSize: c.u64(), maxObjectSize: c.u64() }), MovePackageTooBig: c.struct("MovePackageTooBig", { objectSize: c.u64(), maxObjectSize: c.u64() }), CircularObjectOwnership: c.struct("CircularObjectOwnership", { object: C }), InsufficientCoinBalance: null, CoinBalanceOverflow: null, PublishErrorNonZeroAddress: null, SuiMoveVerificationError: null, MovePrimitiveRuntimeError: c.option(Dr), MoveAbort: c.tuple([Dr, c.u64()]), VMVerificationOrDeserializationError: null, VMInvariantViolation: null, FunctionNotFound: null, ArityMismatch: null, TypeArityMismatch: null, NonEntryFunctionInvoked: null, CommandArgumentError: c.struct("CommandArgumentError", { argIdx: c.u16(), kind: Ma }), TypeArgumentError: c.struct("TypeArgumentError", { argumentIdx: c.u16(), kind: $a }), UnusedValueWithoutDrop: c.struct("UnusedValueWithoutDrop", { resultIdx: c.u16(), secondaryIdx: c.u16() }), InvalidPublicFunctionReturnType: c.struct("InvalidPublicFunctionReturnType", { idx: c.u16() }), InvalidTransferObject: null, EffectsTooLarge: c.struct("EffectsTooLarge", { currentSize: c.u64(), maxSize: c.u64() }), PublishUpgradeMissingDependency: null, PublishUpgradeDependencyDowngrade: null, PackageUpgradeError: c.struct("PackageUpgradeError", { upgradeError: ja }), WrittenObjectsTooLarge: c.struct("WrittenObjectsTooLarge", { currentSize: c.u64(), maxSize: c.u64() }), CertificateDenied: null, SuiMoveVerificationTimedout: null, SharedObjectOperationNotAllowed: null, InputObjectDeleted: null, ExecutionCancelledDueToSharedObjectCongestion: c.struct( "ExecutionCancelledDueToSharedObjectCongestion", { congestedObjects: c.vector(C) } ), AddressDeniedForCoin: c.struct("AddressDeniedForCoin", { address: C, coinType: c.string() }), CoinTypeGlobalPause: c.struct("CoinTypeGlobalPause", { coinType: c.string() }), ExecutionCancelledDueToRandomnessUnavailable: null }), Gn = c.enum("ExecutionStatus", { Success: null, Failed: c.struct("ExecutionFailed", { error: Pa, command: c.option(c.u64()) }) }), qn = c.struct("GasCostSummary", { computationCost: c.u64(), storageCost: c.u64(), storageRebate: c.u64(), nonRefundableStorageFee: c.u64() }), Ua = c.struct("TransactionEffectsV1", { status: Gn, executedEpoch: c.u64(), gasUsed: qn, modifiedAtVersions: c.vector(c.tuple([C, c.u64()])), sharedObjects: c.vector(ne), transactionDigest: pe, created: c.vector(c.tuple([ne, Le])), mutated: c.vector(c.tuple([ne, Le])), unwrapped: c.vector(c.tuple([ne, Le])), deleted: c.vector(ne), unwrappedThenDeleted: c.vector(ne), wrapp