@lombard.finance/sdk-sui 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -3
- package/package.json +1 -1
- package/src/common/parameters.ts +3 -2
- package/src/const/getConfig.ts +2 -2
- package/src/services/SuiServiceImpl.ts +6 -3
- package/src/web3Sdk/prepareAmount/prepareCoinsTransaction.ts +3 -5
- package/src/web3Sdk/unstakeLBTC/unstakeLBTC.ts +15 -8
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Us=Object.create;var Nn=Object.defineProperty;var Ns=Object.getOwnPropertyDescriptor;var Ds=Object.getOwnPropertyNames;var Vs=Object.getPrototypeOf,zs=Object.prototype.hasOwnProperty;var Ls=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ds(e))!zs.call(t,s)&&s!==n&&Nn(t,s,{get:()=>e[s],enumerable:!(r=Ns(e,s))||r.enumerable});return t};var Fs=(t,e,n)=>(n=t!=null?Us(Vs(t)):{},Ls(e||!t||!t.__esModule?Nn(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Mt=require("bignumber.js"),Ws="Phantom",Gs="0x2::sui::SUI",wn=8,qs=new Error("Coin Metadata could not be found."),ar=new Error("Not enough balance."),ct={prod:"prod",testnet:"testnet"},vn=ct.prod;let St=null;const Ks=async()=>{try{const t=await import("bitcoinjs-lib"),e=await Promise.resolve().then(()=>require("./index2.cjs")).then(n=>n.index);try{t.initEccLib(e)}catch(n){if(!/already initialized/i.test(String(n)))throw n}return t}catch(t){throw St=null,new Error(`Failed to initialize bitcoinjs-lib: ${t instanceof Error?t.message:String(t)}. Ensure bitcoinjs-lib and @bitcoinerlab/secp256k1 peer dependencies are installed.`)}},Hs=async()=>(St||(St=Ks()),St);async function Js(t,e=ct.prod){const n=await Hs();return`0x${n.address.toOutputScript(t,e===ct.prod?n.networks.bitcoin:n.networks.testnet).toString("hex")}`}const Xs={mint:{target:"0x2721ad6e939baca77b36f415ab91edb1c91b256cbc8614f8f6c84bf06faf74af::treasury::mint_v2",denyList:"0x403"},redeem:{target:"0x2721ad6e939baca77b36f415ab91edb1c91b256cbc8614f8f6c84bf06faf74af::treasury::redeem"},LBTC:"0x2d66430a27565b912f21be970e5ae1e8c0359f0b518c3235b751c75976791ce0::lbtc::LBTC",treasuryAddress:"0xf9621182bf6af94142e81f5c268d1a959991df2766a5b0755c528b70e5b33531",consortiumAddress:"0xd8a7bff969c0f7069ccda1601516fc93013d8c06835646f718d7d345409340cc",bascule:"0x61cf6760a04f4af6938543e1e9c0b84f7b271cf9069f0cb6c8017093fd814c68"},Zs={mint:{target:"0xbe409fa89cd3eedbe426fdae9c53a231f2fff9dc66c3ca797163b5b5b2aba977::treasury::mint_v2",denyList:"0x403"},redeem:{target:"0xbe409fa89cd3eedbe426fdae9c53a231f2fff9dc66c3ca797163b5b5b2aba977::treasury::redeem"},LBTC:"0x50454d0b0fbad1288a6ab74f2e8ce0905a3317870673ab7787ebcf6f322b45fa::lbtc::LBTC",treasuryAddress:"0xc8f3d6d596ed86012a289166400d3650d9f888f612bf9c35b0cde7bc1b053408",consortiumAddress:"0x5d0922bfc25cd4babc76e7e320b0e9b4d4950408bae9632a5fedf2a1f8dc29dc",bascule:"0xd8b1c1f9b893330180fa1fc52a316461a5fabd258fa15633e9a5ba5da71af49e"},Ys={mint:{target:"0x818430a456ff977f7320f78650d19801f90758d200a01dd3c2c679472c521357::treasury::mint_v2",denyList:"0x403"},redeem:{target:"0x818430a456ff977f7320f78650d19801f90758d200a01dd3c2c679472c521357::treasury::redeem"},LBTC:"0x3e8e9423d80e1774a7ca128fccd8bf5f1f7753be658c5e645929037f7c819040::lbtc::LBTC",treasuryAddress:"0x1adadbca040f368abd554ac55e7c216ea6df2ff891fc647f037d66669661584a",consortiumAddress:"0x9f68fe752d0879d615415e39207f0363a6fc8e0b3b335e976f5f18b31f55faf3",bascule:"0x138938cb496cf0900be970dde1407d86497b8c69182cb5aa22dc4767c92bedcc"};function kn(t=vn){switch(t){case ct.prod:return Ys;case ct.testnet:return Zs;default:return Xs}}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Qs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function or(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(n=>typeof n=="string"):e.every(n=>Number.isSafeInteger(n)):!1}function tn(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function cr(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function nn(t){if(!Array.isArray(t))throw new Error("array expected")}function ur(t,e){if(!or(!0,e))throw new Error(`${t}: array of strings expected`)}function ei(t,e){if(!or(!1,e))throw new Error(`${t}: array of numbers expected`)}function ti(...t){const e=i=>i,n=(i,o)=>a=>i(o(a)),r=t.map(i=>i.encode).reduceRight(n,e),s=t.map(i=>i.decode).reduce(n,e);return{encode:r,decode:s}}function ni(t){const e=typeof t=="string"?t.split(""):t,n=e.length;ur("alphabet",e);const r=new Map(e.map((s,i)=>[s,i]));return{encode:s=>(nn(s),s.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${t}`);return e[i]})),decode:s=>(nn(s),s.map(i=>{tn("alphabet.decode",i);const o=r.get(i);if(o===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${t}`);return o}))}}function ri(t=""){return tn("join",t),{encode:e=>(ur("join.decode",e),e.join(t)),decode:e=>(tn("join.decode",e),e.split(t))}}function Dn(t,e,n){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(nn(t),!t.length)return[];let r=0;const s=[],i=Array.from(t,a=>{if(cr(a),a<0||a>=e)throw new Error(`invalid integer: ${a}`);return a}),o=i.length;for(;;){let a=0,u=!0;for(let d=r;d<o;d++){const l=i[d],h=e*a,m=h+l;if(!Number.isSafeInteger(m)||h/e!==a||m-l!==h)throw new Error("convertRadix: carry overflow");const b=m/n;a=m%n;const g=Math.floor(b);if(i[d]=g,!Number.isSafeInteger(g)||g*n+a!==m)throw new Error("convertRadix: carry overflow");if(u)g?u=!1:r=d;else continue}if(s.push(a),u)break}for(let a=0;a<t.length-1&&t[a]===0;a++)s.push(0);return s.reverse()}function si(t){cr(t);const e=2**8;return{encode:n=>{if(!Qs(n))throw new Error("radix.encode input should be Uint8Array");return Dn(Array.from(n),e,t)},decode:n=>(ei("radix.decode",n),Uint8Array.from(Dn(n,t,e)))}}const ii=t=>ti(si(58),ni(t),ri("")),lr=ii("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Nt=t=>lr.encode(t),ut=t=>lr.decode(t);function ee(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const Wt=8192;function V(t){if(t.length<Wt)return btoa(String.fromCharCode(...t));let e="";for(var n=0;n<t.length;n+=Wt){const r=t.slice(n,n+Wt);e+=String.fromCharCode(...r)}return btoa(e)}function dr(t){var s;const e=t.startsWith("0x")?t.slice(2):t,n=e.length%2===0?e:`0${e}`,r=((s=n.match(/[0-9a-fA-F]{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];if(r.length!==n.length/2)throw new Error(`Invalid hex string ${t}`);return Uint8Array.from(r)}function Je(t){return t.reduce((e,n)=>e+n.toString(16).padStart(2,"0"),"")}function Ct(t){let e=BigInt(t);const n=[];let r=0;if(e===0n)return[0];for(;e>0;)n[r]=Number(e&0x7fn),e>>=7n,e>0n&&(n[r]|=128),r+=1;return n}function ai(t){let e=0n,n=0n,r=0;for(;;){if(r>=t.length)throw new Error("ULEB decode error: buffer overflow");const s=t[r];if(r+=1,e+=BigInt(s&127)<<n,(s&128)===0)break;n+=7n}if(e>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("ULEB decode error: value exceeds MAX_SAFE_INTEGER");return{value:Number(e),length:r}}class oi{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength)}shift(e){return this.bytePosition+=e,this}read8(){const e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){const e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){const e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){const e=this.read32(),r=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+r).toString(10)}read128(){const e=BigInt(this.read64()),r=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+r).toString(10)}read256(){const e=BigInt(this.read128()),r=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+r).toString(10)}readBytes(e){const n=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,n,e);return this.shift(e),r}readULEB(){const e=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=ai(n);return this.shift(s),r}readVec(e){const n=this.readULEB(),r=[];for(let s=0;s<n;s++)r.push(e(this,s,n));return r}}function ci(t,e){switch(e){case"base58":return Nt(t);case"base64":return V(t);case"hex":return Je(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function hr(t,e=["<",">"]){const[n,r]=e,s=[];let i="",o=0;for(let a=0;a<t.length;a++){const u=t[a];if(u===n&&o++,u===r&&o--,o===0&&u===","){s.push(i.trim()),i="";continue}i+=u}return s.push(i.trim()),s}class ui{constructor({initialSize:e=1024,maxSize:n=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=n,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const n=this.bytePosition+e;if(n>this.size){const r=Math.min(this.maxSize,Math.max(this.size+n,this.size+this.allocateSize));if(n>r)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: ${n}`);this.size=r;const s=new ArrayBuffer(this.size);new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(s)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}writeBytes(e){this.ensureSizeOrGrow(e.length);for(let n=0;n<e.length;n++)this.dataView.setUint8(this.bytePosition+n,e[n]);return this.shift(e.length)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return Gt(BigInt(e),8).forEach(n=>this.write8(n)),this}write128(e){return Gt(BigInt(e),16).forEach(n=>this.write8(n)),this}write256(e){return Gt(BigInt(e),32).forEach(n=>this.write8(n)),this}writeULEB(e){return Ct(e).forEach(n=>this.write8(n)),this}writeVec(e,n){return this.writeULEB(e.length),Array.from(e).forEach((r,s)=>n(this,r,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return ci(this.toBytes(),e)}}function Gt(t,e){const n=new Uint8Array(e);let r=0;for(;t>0;)n[r]=Number(t%BigInt(256)),t=t/BigInt(256),r+=1;return n}var fr=t=>{throw TypeError(t)},pr=(t,e,n)=>e.has(t)||fr("Cannot "+n),ie=(t,e,n)=>(pr(t,e,"read from private field"),n?n.call(t):e.get(t)),At=(t,e,n)=>e.has(t)?fr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),_t=(t,e,n,r)=>(pr(t,e,"write to private field"),e.set(t,n),n),qe,et,Ot,Me;const li=class gr{constructor(e){At(this,qe),At(this,et),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),_t(this,qe,e.write),_t(this,et,e.serialize??((n,r)=>{const s=new ui({initialSize:this.serializedSize(n)??void 0,...r});return ie(this,qe).call(this,n,s),s.toBytes()})),this.validate=e.validate??(()=>{})}write(e,n){this.validate(e),ie(this,qe).call(this,e,n)}serialize(e,n){return this.validate(e),new di(this,ie(this,et).call(this,e,n))}parse(e){const n=new oi(e);return this.read(n)}fromHex(e){return this.parse(dr(e))}fromBase58(e){return this.parse(ut(e))}fromBase64(e){return this.parse(ee(e))}transform({name:e,input:n,output:r,validate:s}){return new gr({name:e??this.name,read:i=>r?r(this.read(i)):this.read(i),write:(i,o)=>ie(this,qe).call(this,n?n(i):i,o),serializedSize:i=>this.serializedSize(n?n(i):i),serialize:(i,o)=>ie(this,et).call(this,n?n(i):i,o),validate:i=>{s==null||s(i),this.validate(n?n(i):i)}})}};qe=new WeakMap;et=new WeakMap;let be=li;const mr=Symbol.for("@mysten/serialized-bcs");function Sn(t){return!!t&&typeof t=="object"&&t[mr]===!0}class di{constructor(e,n){At(this,Ot),At(this,Me),_t(this,Ot,e),_t(this,Me,n)}get[mr](){return!0}toBytes(){return ie(this,Me)}toHex(){return Je(ie(this,Me))}toBase64(){return V(ie(this,Me))}toBase58(){return Nt(ie(this,Me))}parse(){return ie(this,Ot).parse(ie(this,Me))}}Ot=new WeakMap;Me=new WeakMap;function xt({size:t,...e}){return new be({...e,serializedSize:()=>t})}function qt({readMethod:t,writeMethod:e,...n}){return xt({...n,read:r=>r[t](),write:(r,s)=>s[e](r),validate:r=>{var s;if(r<0||r>n.maxValue)throw new TypeError(`Invalid ${n.name} value: ${r}. Expected value in range 0-${n.maxValue}`);(s=n.validate)==null||s.call(n,r)}})}function Kt({readMethod:t,writeMethod:e,...n}){return xt({...n,read:r=>r[t](),write:(r,s)=>s[e](BigInt(r)),validate:r=>{var i;const s=BigInt(r);if(s<0||s>n.maxValue)throw new TypeError(`Invalid ${n.name} value: ${s}. Expected value in range 0-${n.maxValue}`);(i=n.validate)==null||i.call(n,s)}})}function hi({serialize:t,...e}){const n=new be({...e,serialize:t,write:(r,s)=>{for(const i of n.serialize(r).toBytes())s.write8(i)}});return n}function fi({toBytes:t,fromBytes:e,...n}){return new be({...n,read:r=>{const s=r.readULEB(),i=r.readBytes(s);return e(i)},write:(r,s)=>{const i=t(r);s.writeULEB(i.length);for(let o=0;o<i.length;o++)s.write8(i[o])},serialize:r=>{const s=t(r),i=Ct(s.length),o=new Uint8Array(i.length+s.length);return o.set(i,0),o.set(s,i.length),o},validate:r=>{var s;if(typeof r!="string")throw new TypeError(`Invalid ${n.name} value: ${r}. Expected string`);(s=n.validate)==null||s.call(n,r)}})}function pi(t){let e=null;function n(){return e||(e=t()),e}return new be({name:"lazy",read:r=>n().read(r),serializedSize:r=>n().serializedSize(r),write:(r,s)=>n().write(r,s),serialize:(r,s)=>n().serialize(r,s).toBytes()})}class gi extends be{constructor({name:e,fields:n,...r}){const s=Object.entries(n);super({name:e,serializedSize:i=>{let o=0;for(const[a,u]of s){const d=u.serializedSize(i[a]);if(d==null)return null;o+=d}return o},read:i=>{const o={};for(const[a,u]of s)o[a]=u.read(i);return o},write:(i,o)=>{for(const[a,u]of s)u.write(i[a],o)},...r,validate:i=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`)}})}}class mi extends be{constructor({fields:e,...n}){const r=Object.entries(e);super({read:s=>{const i=s.readULEB(),o=r[i];if(!o)throw new TypeError(`Unknown value ${i} for enum ${n.name}`);const[a,u]=o;return{[a]:(u==null?void 0:u.read(s))??!0,$kind:a}},write:(s,i)=>{const[o,a]=Object.entries(s).filter(([u])=>Object.hasOwn(e,u))[0];for(let u=0;u<r.length;u++){const[d,l]=r[u];if(d===o){i.writeULEB(u),l==null||l.write(a,i);return}}},...n,validate:s=>{var a;if((a=n==null?void 0:n.validate)==null||a.call(n,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`);const i=Object.keys(s).filter(u=>s[u]!==void 0&&Object.hasOwn(e,u));if(i.length!==1)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${n.name}}`);const[o]=i;if(!Object.hasOwn(e,o))throw new TypeError(`Invalid enum variant ${o}`)}})}}class bi extends be{constructor({fields:e,name:n,...r}){super({name:n??`(${e.map(s=>s.name).join(", ")})`,serializedSize:s=>{let i=0;for(let o=0;o<e.length;o++){const a=e[o].serializedSize(s[o]);if(a==null)return null;i+=a}return i},read:s=>{const i=[];for(const o of e)i.push(o.read(s));return i},write:(s,i)=>{for(let o=0;o<e.length;o++)e[o].write(s[o],i)},...r,validate:s=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,s),!Array.isArray(s))throw new TypeError(`Expected array, found ${typeof s}`);if(s.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${s.length}`)}})}}function yi(t,e,n){return new be({read:r=>{const s=new Array(t);for(let i=0;i<t;i++)s[i]=e.read(r);return s},write:(r,s)=>{for(const i of r)e.write(i,s)},...n,name:(n==null?void 0:n.name)??`${e.name}[${t}]`,validate:r=>{var s;if((s=n==null?void 0:n.validate)==null||s.call(n,r),!r||typeof r!="object"||!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t)throw new TypeError(`Expected array of length ${t}, found ${r.length}`)}})}function wi(t){return c.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>e.$kind==="Some"?e.Some:null})}function vi(t,e){return new be({read:n=>{const r=n.readULEB(),s=new Array(r);for(let i=0;i<r;i++)s[i]=t.read(n);return s},write:(n,r)=>{r.writeULEB(n.length);for(const s of n)t.write(s,r)},...e,name:(e==null?void 0:e.name)??`vector<${t.name}>`,validate:n=>{var r;if((r=e==null?void 0:e.validate)==null||r.call(e,n),!n||typeof n!="object"||!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`)}})}function ki(t,e){return c.vector(c.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:n=>[...n.entries()],output:n=>{const r=new Map;for(const[s,i]of n)r.set(s,i);return r}})}const c={u8(t){return qt({readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t,name:(t==null?void 0:t.name)??"u8"})},u16(t){return qt({readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t,name:(t==null?void 0:t.name)??"u16"})},u32(t){return qt({readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t,name:(t==null?void 0:t.name)??"u32"})},u64(t){return Kt({readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t,name:(t==null?void 0:t.name)??"u64"})},u128(t){return Kt({readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t,name:(t==null?void 0:t.name)??"u128"})},u256(t){return Kt({readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t,name:(t==null?void 0:t.name)??"u256"})},bool(t){return xt({size:1,read:e=>e.read8()===1,write:(e,n)=>n.write8(e?1:0),...t,name:(t==null?void 0:t.name)??"bool",validate:e=>{var n;if((n=t==null?void 0:t.validate)==null||n.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return hi({read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Ct(e)),...t,name:(t==null?void 0:t.name)??"uleb128"})},bytes(t,e){return xt({size:t,read:n=>n.readBytes(t),write:(n,r)=>{r.writeBytes(new Uint8Array(n))},...e,name:(e==null?void 0:e.name)??`bytes[${t}]`,validate:n=>{var r;if((r=e==null?void 0:e.validate)==null||r.call(e,n),!n||typeof n!="object"||!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==t)throw new TypeError(`Expected array of length ${t}, found ${n.length}`)}})},byteVector(t){return new be({read:e=>{const n=e.readULEB();return e.readBytes(n)},write:(e,n)=>{const r=new Uint8Array(e);n.writeULEB(r.length),n.writeBytes(r)},...t,name:(t==null?void 0:t.name)??"vector<u8>",serializedSize:e=>{const n="length"in e?e.length:null;return n==null?null:Ct(n).length+n},validate:e=>{var n;if((n=t==null?void 0:t.validate)==null||n.call(t,e),!e||typeof e!="object"||!("length"in e))throw new TypeError(`Expected array, found ${typeof e}`)}})},string(t){return fi({toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t,name:(t==null?void 0:t.name)??"string"})},fixedArray:yi,option:wi,vector:vi,tuple(t,e){return new bi({fields:t,...e})},struct(t,e,n){return new gi({name:t,fields:e,...n})},enum(t,e,n){return new mi({name:t,fields:e,...n})},map:ki,lazy(t){return pi(t)}},br=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,yr=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i,Si=235;function Oi(t){return t.length>Si?!1:t.includes("@")?br.test(t):yr.test(t)}function Ei(t,e="at"){const n=t.toLowerCase();let r;if(n.includes("@")){if(!br.test(n))throw new Error(`Invalid SuiNS name ${t}`);const[s,i]=n.split("@");r=[...s?s.split("."):[],i]}else{if(!yr.test(n))throw new Error(`Invalid SuiNS name ${t}`);r=n.split(".").slice(0,-1)}return e==="dot"?`${r.join(".")}.sui`:`${r.slice(0,-1).join(".")}@${r[r.length-1]}`}const Ti=/^([a-z0-9]+(?:-[a-z0-9]+)*)$/,Ii=/^\d+$/,ji=64,wr="/",X=t=>{const e=t.split(wr);if(e.length<2||e.length>3)return!1;const[n,r,s]=e;return s!==void 0&&!Ii.test(s)||!Oi(n)?!1:Ti.test(r)&&r.length<ji},Mi=t=>{const e=t.split(/::|<|>|,/);for(const n of e)if(n.includes(wr)&&!X(n))return!1;return!0},Ci=32;function Vn(t){try{return ut(t).length===Ci}catch{return!1}}const Dt=32;function ae(t){return _i(t)&&xi(t)===Dt}function yt(t){return ae(t)}function Ai(t){return t.includes("::")?Le(t):t}function Le(t){const[e,n]=t.split("::"),r=X(e),s=t.slice(e.length+n.length+4),i=s.includes("<")?s.slice(0,s.indexOf("<")):s,o=s.includes("<")?hr(s.slice(s.indexOf("<")+1,s.lastIndexOf(">"))).map(a=>Ai(a.trim())):[];return{address:r?e:S(e),module:n,name:i,typeParams:o}}function $t(t){const{address:e,module:n,name:r,typeParams:s}=typeof t=="string"?Le(t):t,i=(s==null?void 0:s.length)>0?`<${s.map(o=>typeof o=="string"?o:$t(o)).join(",")}>`:"";return`${e}::${n}::${r}${i}`}function S(t,e=!1){let n=t.toLowerCase();return!e&&n.startsWith("0x")&&(n=n.slice(2)),`0x${n.padStart(Dt*2,"0")}`}function ge(t,e=!1){return S(t,e)}function _i(t){return/^(0x|0X)?[a-fA-F0-9]+$/.test(t)&&t.length%2===0}function xi(t){return/^(0x|0X)/.test(t)?(t.length-2)/2:t.length/2}const $i=/^vector<(.+)>$/,Pi=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class ce{static parseFromStr(e,n=!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 r=e.match($i);if(r)return{vector:ce.parseFromStr(r[1],n)};const s=e.match(Pi);if(s)return{struct:{address:n?S(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:ce.parseStructTypeArgs(s[5],n)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,n=!1){return hr(e).map(r=>ce.parseFromStr(r,n))}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<${ce.tagToString(e.vector)}>`;if("struct"in e){const n=e.struct,r=n.typeParams.map(ce.tagToString).join(", ");return`${n.address}::${n.module}::${n.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}function Ri(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function Bi(t){return c.enum("Option",{None:null,Some:t})}const j=c.bytes(Dt).transform({validate:t=>{const e=typeof t=="string"?t:Je(t);if(!e||!ae(S(e)))throw new Error(`Invalid Sui address ${e}`)},input:t=>typeof t=="string"?dr(S(t)):t,output:t=>S(Je(t))}),le=c.byteVector().transform({name:"ObjectDigest",input:t=>ut(t),output:t=>Nt(new Uint8Array(t)),validate:t=>{if(ut(t).length!==32)throw new Error("ObjectDigest must be 32 bytes")}}),ne=c.struct("SuiObjectRef",{objectId:j,version:c.u64(),digest:le}),vr=c.struct("SharedObjectRef",{objectId:j,initialSharedVersion:c.u64(),mutable:c.bool()}),kr=c.enum("ObjectArg",{ImmOrOwnedObject:ne,SharedObject:vr,Receiving:ne}),Ue=c.enum("Owner",{AddressOwner:j,ObjectOwner:j,Shared:c.struct("Shared",{initialSharedVersion:c.u64()}),Immutable:null,ConsensusAddressOwner:c.struct("ConsensusAddressOwner",{owner:j,startVersion:c.u64()})}),Sr=c.enum("CallArg",{Pure:c.struct("Pure",{bytes:c.byteVector().transform({input:t=>typeof t=="string"?ee(t):t,output:t=>V(new Uint8Array(t))})}),Object:kr}),On=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>On),struct:c.lazy(()=>Mr),u16:null,u32:null,u256:null}),En=On.transform({input:t=>typeof t=="string"?ce.parseFromStr(t,!0):t,output:t=>ce.tagToString(t)}),fe=c.enum("Argument",{GasCoin:null,Input:c.u16(),Result:c.u16(),NestedResult:c.tuple([c.u16(),c.u16()])}),Or=c.struct("ProgrammableMoveCall",{package:j,module:c.string(),function:c.string(),typeArguments:c.vector(En),arguments:c.vector(fe)}),Er=c.enum("Command",{MoveCall:Or,TransferObjects:c.struct("TransferObjects",{objects:c.vector(fe),address:fe}),SplitCoins:c.struct("SplitCoins",{coin:fe,amounts:c.vector(fe)}),MergeCoins:c.struct("MergeCoins",{destination:fe,sources:c.vector(fe)}),Publish:c.struct("Publish",{modules:c.vector(c.byteVector().transform({input:t=>typeof t=="string"?ee(t):t,output:t=>V(new Uint8Array(t))})),dependencies:c.vector(j)}),MakeMoveVec:c.struct("MakeMoveVec",{type:Bi(En).transform({input:t=>t===null?{None:!0}:{Some:t},output:t=>t.Some??null}),elements:c.vector(fe)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.byteVector().transform({input:t=>typeof t=="string"?ee(t):t,output:t=>V(new Uint8Array(t))})),dependencies:c.vector(j),package:j,ticket:fe})}),Tr=c.struct("ProgrammableTransaction",{inputs:c.vector(Sr),commands:c.vector(Er)}),Ir=c.enum("TransactionKind",{ProgrammableTransaction:Tr,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),jr=c.enum("TransactionExpiration",{None:null,Epoch:Ri()}),Mr=c.struct("StructTag",{address:j,module:c.string(),name:c.string(),typeParams:c.vector(On)}),Cr=c.struct("GasData",{payment:c.vector(ne),owner:j,price:c.u64(),budget:c.u64()}),Ar=c.struct("TransactionDataV1",{kind:Ir,sender:j,gasData:Cr,expiration:jr}),_r=c.enum("TransactionData",{V1:Ar}),xr=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),$r=c.enum("IntentVersion",{V0:null}),Pr=c.enum("AppId",{Sui:null}),Rr=c.struct("Intent",{scope:xr,version:$r,appId:Pr});function Br(t){return c.struct(`IntentMessage<${t.name}>`,{intent:Rr,value:t})}const Ur=c.enum("CompressedSignature",{ED25519:c.bytes(64),Secp256k1:c.bytes(64),Secp256r1:c.bytes(64),ZkLogin:c.byteVector(),Passkey:c.byteVector()}),Nr=c.enum("PublicKey",{ED25519:c.bytes(32),Secp256k1:c.bytes(33),Secp256r1:c.bytes(33),ZkLogin:c.byteVector(),Passkey:c.bytes(33)}),Dr=c.struct("MultiSigPkMap",{pubKey:Nr,weight:c.u8()}),Vr=c.struct("MultiSigPublicKey",{pk_map:c.vector(Dr),threshold:c.u16()}),Ui=c.struct("MultiSig",{sigs:c.vector(Ur),bitmap:c.u16(),multisig_pk:Vr}),Ni=c.byteVector().transform({input:t=>typeof t=="string"?ee(t):t,output:t=>V(new Uint8Array(t))}),zr=c.struct("SenderSignedTransaction",{intentMessage:Br(_r),txSignatures:c.vector(Ni)}),Di=c.vector(zr,{name:"SenderSignedData"}),Vi=c.struct("PasskeyAuthenticator",{authenticatorData:c.byteVector(),clientDataJson:c.string(),userSignature:c.byteVector()}),zi=c.enum("PackageUpgradeError",{UnableToFetchPackage:c.struct("UnableToFetchPackage",{packageId:j}),NotAPackage:c.struct("NotAPackage",{objectId:j}),IncompatibleUpgrade:null,DigestDoesNotMatch:c.struct("DigestDoesNotMatch",{digest:c.byteVector()}),UnknownUpgradePolicy:c.struct("UnknownUpgradePolicy",{policy:c.u8()}),PackageIDDoesNotMatch:c.struct("PackageIDDoesNotMatch",{packageId:j,ticketId:j})}),Li=c.struct("ModuleId",{address:j,name:c.string()}),zn=c.struct("MoveLocation",{module:Li,function:c.u16(),instruction:c.u16(),functionName:c.option(c.string())}),Fi=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}),Wi=c.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),Gi=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:j}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:c.option(zn),MoveAbort:c.tuple([zn,c.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:c.struct("CommandArgumentError",{argIdx:c.u16(),kind:Fi}),TypeArgumentError:c.struct("TypeArgumentError",{argumentIdx:c.u16(),kind:Wi}),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:zi}),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(j)}),AddressDeniedForCoin:c.struct("AddressDeniedForCoin",{address:j,coinType:c.string()}),CoinTypeGlobalPause:c.struct("CoinTypeGlobalPause",{coinType:c.string()}),ExecutionCancelledDueToRandomnessUnavailable:null}),Lr=c.enum("ExecutionStatus",{Success:null,Failed:c.struct("ExecutionFailed",{error:Gi,command:c.option(c.u64())})}),Fr=c.struct("GasCostSummary",{computationCost:c.u64(),storageCost:c.u64(),storageRebate:c.u64(),nonRefundableStorageFee:c.u64()}),qi=c.struct("TransactionEffectsV1",{status:Lr,executedEpoch:c.u64(),gasUsed:Fr,modifiedAtVersions:c.vector(c.tuple([j,c.u64()])),sharedObjects:c.vector(ne),transactionDigest:le,created:c.vector(c.tuple([ne,Ue])),mutated:c.vector(c.tuple([ne,Ue])),unwrapped:c.vector(c.tuple([ne,Ue])),deleted:c.vector(ne),unwrappedThenDeleted:c.vector(ne),wrapped:c.vector(ne),gasObject:c.tuple([ne,Ue]),eventsDigest:c.option(le),dependencies:c.vector(le)}),Tn=c.tuple([c.u64(),le]),Ki=c.enum("ObjectIn",{NotExist:null,Exist:c.tuple([Tn,Ue])}),Hi=c.enum("ObjectOut",{NotExist:null,ObjectWrite:c.tuple([le,Ue]),PackageWrite:Tn}),Ji=c.enum("IDOperation",{None:null,Created:null,Deleted:null}),Xi=c.struct("EffectsObjectChange",{inputState:Ki,outputState:Hi,idOperation:Ji}),Zi=c.enum("UnchangedSharedKind",{ReadOnlyRoot:Tn,MutateDeleted:c.u64(),ReadDeleted:c.u64(),Cancelled:c.u64(),PerEpochConfig:null}),Yi=c.struct("TransactionEffectsV2",{status:Lr,executedEpoch:c.u64(),gasUsed:Fr,transactionDigest:le,gasObjectIndex:c.option(c.u32()),eventsDigest:c.option(le),dependencies:c.vector(le),lamportVersion:c.u64(),changedObjects:c.vector(c.tuple([j,Xi])),unchangedSharedObjects:c.vector(c.tuple([j,Zi])),auxDataDigest:c.option(le)}),Qi=c.enum("TransactionEffects",{V1:qi,V2:Yi});function nt(t){switch(t){case"u8":return c.u8();case"u16":return c.u16();case"u32":return c.u32();case"u64":return c.u64();case"u128":return c.u128();case"u256":return c.u256();case"bool":return c.bool();case"string":return c.string();case"id":case"address":return j}const e=t.match(/^(vector|option)<(.+)>$/);if(e){const[n,r]=e.slice(1);return n==="vector"?c.vector(nt(r)):c.option(nt(r))}throw new Error(`Invalid Pure type name: ${t}`)}const k={...c,U8:c.u8(),U16:c.u16(),U32:c.u32(),U64:c.u64(),U128:c.u128(),U256:c.u256(),ULEB128:c.uleb128(),Bool:c.bool(),String:c.string(),Address:j,AppId:Pr,Argument:fe,CallArg:Sr,Command:Er,CompressedSignature:Ur,GasData:Cr,Intent:Rr,IntentMessage:Br,IntentScope:xr,IntentVersion:$r,MultiSig:Ui,MultiSigPkMap:Dr,MultiSigPublicKey:Vr,ObjectArg:kr,ObjectDigest:le,Owner:Ue,PasskeyAuthenticator:Vi,ProgrammableMoveCall:Or,ProgrammableTransaction:Tr,PublicKey:Nr,SenderSignedData:Di,SenderSignedTransaction:zr,SharedObjectRef:vr,StructTag:Mr,SuiObjectRef:ne,TransactionData:_r,TransactionDataV1:Ar,TransactionEffects:Qi,TransactionExpiration:jr,TransactionKind:Ir,TypeTag:En};BigInt(1e9);const ea="0x1",Wr="0x2";ge("0x6");const ta=`${Wr}::sui::SUI`;ge("0x5");ge("0x8");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function na(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function rn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function In(t,...e){if(!na(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ln(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ra(t,e){In(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Pt(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function sn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Gr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function qr(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const Se=Gr?t=>t:t=>qr(t);function sa(t){for(let e=0;e<t.length;e++)t[e]=qr(t[e]);return t}const Ge=Gr?t=>t:sa;function ia(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function rt(t){return typeof t=="string"&&(t=ia(t)),In(t),t}class aa{}function oa(t){const e=(r,s)=>t(s).update(rt(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}const ca=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),wt=BigInt(2**32-1),Fn=BigInt(32);function ua(t,e=!1){return e?{h:Number(t&wt),l:Number(t>>Fn&wt)}:{h:Number(t>>Fn&wt)|0,l:Number(t&wt)|0}}const Kr=(t,e,n)=>t>>>n|e<<32-n,Hr=(t,e,n)=>t<<32-n|e>>>n,la=(t,e,n)=>t<<64-n|e>>>n-32,da=(t,e,n)=>t>>>n-32|e<<64-n,ha=(t,e)=>e,fa=(t,e)=>t;function Jr(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const Xr=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Zr=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,x=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),p=new Uint32Array(32);function Ie(t,e,n,r,s,i){const o=s[i],a=s[i+1];let u=p[2*t],d=p[2*t+1],l=p[2*e],h=p[2*e+1],m=p[2*n],b=p[2*n+1],g=p[2*r],v=p[2*r+1],L=Xr(u,l,o);d=Zr(L,d,h,a),u=L|0,{Dh:v,Dl:g}={Dh:v^d,Dl:g^u},{Dh:v,Dl:g}={Dh:ha(v,g),Dl:fa(v)},{h:b,l:m}=Jr(b,m,v,g),{Bh:h,Bl:l}={Bh:h^b,Bl:l^m},{Bh:h,Bl:l}={Bh:Kr(h,l,24),Bl:Hr(h,l,24)},p[2*t]=u,p[2*t+1]=d,p[2*e]=l,p[2*e+1]=h,p[2*n]=m,p[2*n+1]=b,p[2*r]=g,p[2*r+1]=v}function je(t,e,n,r,s,i){const o=s[i],a=s[i+1];let u=p[2*t],d=p[2*t+1],l=p[2*e],h=p[2*e+1],m=p[2*n],b=p[2*n+1],g=p[2*r],v=p[2*r+1],L=Xr(u,l,o);d=Zr(L,d,h,a),u=L|0,{Dh:v,Dl:g}={Dh:v^d,Dl:g^u},{Dh:v,Dl:g}={Dh:Kr(v,g,16),Dl:Hr(v,g,16)},{h:b,l:m}=Jr(b,m,v,g),{Bh:h,Bl:l}={Bh:h^b,Bl:l^m},{Bh:h,Bl:l}={Bh:la(h,l,63),Bl:da(h,l,63)},p[2*t]=u,p[2*t+1]=d,p[2*e]=l,p[2*e+1]=h,p[2*n]=m,p[2*n+1]=b,p[2*r]=g,p[2*r+1]=v}function pa(t,e={},n,r,s){if(rn(n),t<0||t>n)throw new Error("outputLen bigger than keyLen");const{key:i,salt:o,personalization:a}=e;if(i!==void 0&&(i.length<1||i.length>n))throw new Error("key length must be undefined or 1.."+n);if(o!==void 0&&o.length!==r)throw new Error("salt must be undefined or "+r);if(a!==void 0&&a.length!==s)throw new Error("personalization must be undefined or "+s)}class ga extends aa{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,rn(e),rn(n),this.blockLen=e,this.outputLen=n,this.buffer=new Uint8Array(e),this.buffer32=Pt(this.buffer)}update(e){Ln(this),e=rt(e),In(e);const{blockLen:n,buffer:r,buffer32:s}=this,i=e.length,o=e.byteOffset,a=e.buffer;for(let u=0;u<i;){this.pos===n&&(Ge(s),this.compress(s,0,!1),Ge(s),this.pos=0);const d=Math.min(n-this.pos,i-u),l=o+u;if(d===n&&!(l%4)&&u+d<i){const h=new Uint32Array(a,l,Math.floor((i-u)/4));Ge(h);for(let m=0;u+n<i;m+=s.length,u+=n)this.length+=n,this.compress(h,m,!1);Ge(h);continue}r.set(e.subarray(u,u+d),this.pos),this.pos+=d,this.length+=d,u+=d}return this}digestInto(e){Ln(this),ra(e,this);const{pos:n,buffer32:r}=this;this.finished=!0,sn(this.buffer.subarray(n)),Ge(r),this.compress(r,0,!0),Ge(r);const s=Pt(e);this.get().forEach((i,o)=>s[o]=Se(i))}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){const{buffer:n,length:r,finished:s,destroyed:i,outputLen:o,pos:a}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(n),e.destroyed=i,e.finished=s,e.length=r,e.pos=a,e.outputLen=o,e}clone(){return this._cloneInto()}}class ma extends ga{constructor(e={}){const n=e.dkLen===void 0?64:e.dkLen;super(128,n),this.v0l=x[0]|0,this.v0h=x[1]|0,this.v1l=x[2]|0,this.v1h=x[3]|0,this.v2l=x[4]|0,this.v2h=x[5]|0,this.v3l=x[6]|0,this.v3h=x[7]|0,this.v4l=x[8]|0,this.v4h=x[9]|0,this.v5l=x[10]|0,this.v5h=x[11]|0,this.v6l=x[12]|0,this.v6h=x[13]|0,this.v7l=x[14]|0,this.v7h=x[15]|0,pa(n,e,64,16,16);let{key:r,personalization:s,salt:i}=e,o=0;if(r!==void 0&&(r=rt(r),o=r.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,i!==void 0){i=rt(i);const a=Pt(i);this.v4l^=Se(a[0]),this.v4h^=Se(a[1]),this.v5l^=Se(a[2]),this.v5h^=Se(a[3])}if(s!==void 0){s=rt(s);const a=Pt(s);this.v6l^=Se(a[0]),this.v6h^=Se(a[1]),this.v7l^=Se(a[2]),this.v7h^=Se(a[3])}if(r!==void 0){const a=new Uint8Array(this.blockLen);a.set(r),this.update(a)}}get(){let{v0l:e,v0h:n,v1l:r,v1h:s,v2l:i,v2h:o,v3l:a,v3h:u,v4l:d,v4h:l,v5l:h,v5h:m,v6l:b,v6h:g,v7l:v,v7h:L}=this;return[e,n,r,s,i,o,a,u,d,l,h,m,b,g,v,L]}set(e,n,r,s,i,o,a,u,d,l,h,m,b,g,v,L){this.v0l=e|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=i|0,this.v2h=o|0,this.v3l=a|0,this.v3h=u|0,this.v4l=d|0,this.v4h=l|0,this.v5l=h|0,this.v5h=m|0,this.v6l=b|0,this.v6h=g|0,this.v7l=v|0,this.v7h=L|0}compress(e,n,r){this.get().forEach((u,d)=>p[d]=u),p.set(x,16);let{h:s,l:i}=ua(BigInt(this.length));p[24]=x[8]^i,p[25]=x[9]^s,r&&(p[28]=~p[28],p[29]=~p[29]);let o=0;const a=ca;for(let u=0;u<12;u++)Ie(0,4,8,12,e,n+2*a[o++]),je(0,4,8,12,e,n+2*a[o++]),Ie(1,5,9,13,e,n+2*a[o++]),je(1,5,9,13,e,n+2*a[o++]),Ie(2,6,10,14,e,n+2*a[o++]),je(2,6,10,14,e,n+2*a[o++]),Ie(3,7,11,15,e,n+2*a[o++]),je(3,7,11,15,e,n+2*a[o++]),Ie(0,5,10,15,e,n+2*a[o++]),je(0,5,10,15,e,n+2*a[o++]),Ie(1,6,11,12,e,n+2*a[o++]),je(1,6,11,12,e,n+2*a[o++]),Ie(2,7,8,13,e,n+2*a[o++]),je(2,7,8,13,e,n+2*a[o++]),Ie(3,4,9,14,e,n+2*a[o++]),je(3,4,9,14,e,n+2*a[o++]);this.v0l^=p[0]^p[16],this.v0h^=p[1]^p[17],this.v1l^=p[2]^p[18],this.v1h^=p[3]^p[19],this.v2l^=p[4]^p[20],this.v2h^=p[5]^p[21],this.v3l^=p[6]^p[22],this.v3h^=p[7]^p[23],this.v4l^=p[8]^p[24],this.v4h^=p[9]^p[25],this.v5l^=p[10]^p[26],this.v5h^=p[11]^p[27],this.v6l^=p[12]^p[28],this.v6h^=p[13]^p[29],this.v7l^=p[14]^p[30],this.v7h^=p[15]^p[31],sn(p)}destroy(){this.destroyed=!0,sn(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ba=oa(t=>new ma(t)),Yr=ba;function ya(t,e,n){const r=k.Address.serialize(t).toBytes(),s=k.TypeTag.serialize(e).toBytes(),i=k.u64().serialize(n.length).toBytes(),o=Yr.create({dkLen:32});return o.update(new Uint8Array([240])),o.update(r),o.update(i),o.update(n),o.update(s),`0x${Je(o.digest().slice(0,32))}`}const wa="object",va="ID",ka="ascii",Sa="String",Oa="string",Ea="String",Ta="option",Ia="Option";function ja(t){const e=typeof t.body=="object"&&"datatype"in t.body?t.body.datatype:null;return!!e&&S(e.package)===S("0x2")&&e.module==="tx_context"&&e.type==="TxContext"}function an(t){if(typeof t=="string")switch(t){case"address":return k.Address;case"bool":return k.Bool;case"u8":return k.U8;case"u16":return k.U16;case"u32":return k.U32;case"u64":return k.U64;case"u128":return k.U128;case"u256":return k.U256;default:throw new Error(`Unknown type signature ${t}`)}if("vector"in t){if(t.vector==="u8")return k.byteVector().transform({input:n=>typeof n=="string"?new TextEncoder().encode(n):n,output:n=>n});const e=an(t.vector);return e?k.vector(e):null}if("datatype"in t){const e=S(t.datatype.package);if(e===S(ea)){if(t.datatype.module===ka&&t.datatype.type===Sa||t.datatype.module===Oa&&t.datatype.type===Ea)return k.String;if(t.datatype.module===Ta&&t.datatype.type===Ia){const n=an(t.datatype.typeParameters[0]);return n?k.vector(n):null}}if(e===S(Wr)&&t.datatype.module===wa&&t.datatype.type===va)return k.Address}return null}function Ma(t){return typeof t=="object"&&"Reference"in t?{ref:"&",body:st(t.Reference)}:typeof t=="object"&&"MutableReference"in t?{ref:"&mut",body:st(t.MutableReference)}:{ref:null,body:st(t)}}function st(t){if(typeof t=="string")switch(t){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${t}`)}if("Vector"in t)return{vector:st(t.Vector)};if("Struct"in t)return{datatype:{package:t.Struct.address,module:t.Struct.module,type:t.Struct.name,typeParameters:t.Struct.typeArguments.map(st)}};if("TypeParameter"in t)return{typeParameter:t.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(t)}`)}function Ca(t){return{$kind:"Pure",Pure:{bytes:t instanceof Uint8Array?V(t):t.toBase64()}}}const de={Pure:Ca,ObjectRef({objectId:t,digest:e,version:n}){return{$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:e,version:n,objectId:S(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:n}){return{$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:e,initialSharedVersion:n,objectId:S(t)}}}},ReceivingRef({objectId:t,digest:e,version:n}){return{$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:e,version:n,objectId:S(t)}}}}};let we;function Qr(t){return{lang:(t==null?void 0:t.lang)??(we==null?void 0:we.lang),message:t==null?void 0:t.message,abortEarly:(t==null?void 0:t.abortEarly)??(we==null?void 0:we.abortEarly),abortPipeEarly:(t==null?void 0:t.abortPipeEarly)??(we==null?void 0:we.abortPipeEarly)}}let Ht;function Aa(t){return Ht==null?void 0:Ht.get(t)}let Jt;function _a(t){return Jt==null?void 0:Jt.get(t)}let Xt;function xa(t,e){var n;return(n=Xt==null?void 0:Xt.get(t))==null?void 0:n.get(e)}function es(t){var n,r;const e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&((r=(n=Object.getPrototypeOf(t))==null?void 0:n.constructor)==null?void 0:r.name))??"null":e}function H(t,e,n,r,s){const i=s&&"input"in s?s.input:n.value,o=(s==null?void 0:s.expected)??t.expects??null,a=(s==null?void 0:s.received)??es(i),u={kind:t.kind,type:t.type,input:i,expected:o,received:a,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${a}`,requirement:t.requirement,path:s==null?void 0:s.path,issues:s==null?void 0:s.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},d=t.kind==="schema",l=(s==null?void 0:s.message)??t.message??xa(t.reference,u.lang)??(d?_a(u.lang):null)??r.message??Aa(u.lang);l!==void 0&&(u.message=typeof l=="function"?l(u):l),d&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function z(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},Qr())}}}function $a(t,e){return Object.hasOwn(t,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function Pa(t,e){const n=[...new Set(t)];return n.length>1?`(${n.join(` ${e} `)})`:n[0]??"never"}var Ra=class extends Error{constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function jn(t,e){return{kind:"validation",type:"check",reference:jn,async:!1,expects:null,requirement:t,message:e,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&H(this,"input",n,r),n}}}function q(t){return{kind:"validation",type:"integer",reference:q,async:!1,expects:null,requirement:Number.isInteger,message:t,"~run"(e,n){return e.typed&&!this.requirement(e.value)&&H(this,"integer",e,n),e}}}function Vt(t){return{kind:"transformation",type:"transform",reference:Vt,async:!1,operation:t,"~run"(e){return e.value=this.operation(e.value),e}}}function Ba(t,e,n){return typeof t.fallback=="function"?t.fallback(e,n):t.fallback}function zt(t,e,n){return typeof t.default=="function"?t.default(e,n):t.default}function on(t,e){return!t["~run"]({value:e},{abortEarly:!0}).issues}function O(t,e){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return z(this)},"~run"(n,r){var i;const s=n.value;if(Array.isArray(s)){n.typed=!0,n.value=[];for(let o=0;o<s.length;o++){const a=s[o],u=this.item["~run"]({value:a},r);if(u.issues){const d={type:"array",origin:"value",input:s,key:o,value:a};for(const l of u.issues)l.path?l.path.unshift(d):l.path=[d],(i=n.issues)==null||i.push(l);if(n.issues||(n.issues=u.issues),r.abortEarly){n.typed=!1;break}}u.typed||(n.typed=!1),n.value.push(u.value)}}else H(this,"type",n,r);return n}}}function ts(t){return{kind:"schema",type:"bigint",reference:ts,expects:"bigint",async:!1,message:t,get"~standard"(){return z(this)},"~run"(e,n){return typeof e.value=="bigint"?e.typed=!0:H(this,"type",e,n),e}}}function Xe(t){return{kind:"schema",type:"boolean",reference:Xe,expects:"boolean",async:!1,message:t,get"~standard"(){return z(this)},"~run"(e,n){return typeof e.value=="boolean"?e.typed=!0:H(this,"type",e,n),e}}}function cn(t){return{kind:"schema",type:"lazy",reference:cn,expects:"unknown",async:!1,getter:t,get"~standard"(){return z(this)},"~run"(e,n){return this.getter(e.value)["~run"](e,n)}}}function P(t,e){return{kind:"schema",type:"literal",reference:P,expects:es(t),async:!1,literal:t,message:e,get"~standard"(){return z(this)},"~run"(n,r){return n.value===this.literal?n.typed=!0:H(this,"type",n,r),n}}}function A(t,e){return{kind:"schema",type:"nullable",reference:A,expects:`(${t.expects} | null)`,async:!1,wrapped:t,default:e,get"~standard"(){return z(this)},"~run"(n,r){return n.value===null&&(this.default!==void 0&&(n.value=zt(this,n,r)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function lt(t,e){return{kind:"schema",type:"nullish",reference:lt,expects:`(${t.expects} | null | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return z(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=zt(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function K(t){return{kind:"schema",type:"number",reference:K,expects:"number",async:!1,message:t,get"~standard"(){return z(this)},"~run"(e,n){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:H(this,"type",e,n),e}}}function w(t,e){return{kind:"schema",type:"object",reference:w,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return z(this)},"~run"(n,r){var i;const s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(const o in this.entries){const a=this.entries[o];if(o in s||(a.type==="exact_optional"||a.type==="optional"||a.type==="nullish")&&a.default!==void 0){const u=o in s?s[o]:zt(a),d=a["~run"]({value:u},r);if(d.issues){const l={type:"object",origin:"value",input:s,key:o,value:u};for(const h of d.issues)h.path?h.path.unshift(l):h.path=[l],(i=n.issues)==null||i.push(h);if(n.issues||(n.issues=d.issues),r.abortEarly){n.typed=!1;break}}d.typed||(n.typed=!1),n.value[o]=d.value}else if(a.fallback!==void 0)n.value[o]=Ba(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(H(this,"key",n,r,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),r.abortEarly))break}}else H(this,"type",n,r);return n}}}function Q(t,e){return{kind:"schema",type:"optional",reference:Q,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return z(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=zt(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function dt(t,e,n){return{kind:"schema",type:"record",reference:dt,expects:"Object",async:!1,key:t,value:e,message:n,get"~standard"(){return z(this)},"~run"(r,s){var o,a;const i=r.value;if(i&&typeof i=="object"){r.typed=!0,r.value={};for(const u in i)if($a(i,u)){const d=i[u],l=this.key["~run"]({value:u},s);if(l.issues){const m={type:"object",origin:"key",input:i,key:u,value:d};for(const b of l.issues)b.path=[m],(o=r.issues)==null||o.push(b);if(r.issues||(r.issues=l.issues),s.abortEarly){r.typed=!1;break}}const h=this.value["~run"]({value:d},s);if(h.issues){const m={type:"object",origin:"value",input:i,key:u,value:d};for(const b of h.issues)b.path?b.path.unshift(m):b.path=[m],(a=r.issues)==null||a.push(b);if(r.issues||(r.issues=h.issues),s.abortEarly){r.typed=!1;break}}(!l.typed||!h.typed)&&(r.typed=!1),l.typed&&(r.value[l.value]=h.value)}}else H(this,"type",r,s);return r}}}function E(t){return{kind:"schema",type:"string",reference:E,expects:"string",async:!1,message:t,get"~standard"(){return z(this)},"~run"(e,n){return typeof e.value=="string"?e.typed=!0:H(this,"type",e,n),e}}}function Mn(t,e){return{kind:"schema",type:"tuple",reference:Mn,expects:"Array",async:!1,items:t,message:e,get"~standard"(){return z(this)},"~run"(n,r){var i;const s=n.value;if(Array.isArray(s)){n.typed=!0,n.value=[];for(let o=0;o<this.items.length;o++){const a=s[o],u=this.items[o]["~run"]({value:a},r);if(u.issues){const d={type:"array",origin:"value",input:s,key:o,value:a};for(const l of u.issues)l.path?l.path.unshift(d):l.path=[d],(i=n.issues)==null||i.push(l);if(n.issues||(n.issues=u.issues),r.abortEarly){n.typed=!1;break}}u.typed||(n.typed=!1),n.value.push(u.value)}}else H(this,"type",n,r);return n}}}function Wn(t){let e;if(t)for(const n of t)e?e.push(...n.issues):e=n.issues;return e}function ye(t,e){return{kind:"schema",type:"union",reference:ye,expects:Pa(t.map(n=>n.expects),"|"),async:!1,options:t,message:e,get"~standard"(){return z(this)},"~run"(n,r){let s,i,o;for(const a of this.options){const u=a["~run"]({value:n.value},r);if(u.typed)if(u.issues)i?i.push(u):i=[u];else{s=u;break}else o?o.push(u):o=[u]}if(s)return s;if(i){if(i.length===1)return i[0];H(this,"type",n,r,{issues:Wn(i)}),n.typed=!0}else{if((o==null?void 0:o.length)===1)return o[0];H(this,"type",n,r,{issues:Wn(o)})}return n}}}function gt(){return{kind:"schema",type:"unknown",reference:gt,expects:"unknown",async:!1,get"~standard"(){return z(this)},"~run"(t){return t.typed=!0,t}}}function C(t,e,n){const r=t["~run"]({value:e},Qr(n));if(r.issues)throw new Ra(r.issues);return r.value}function U(...t){return{...t[0],pipe:t,get"~standard"(){return z(this)},"~run"(e,n){for(const r of t)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!n.abortEarly&&!n.abortPipeEarly)&&(e=r["~run"](e,n))}return e}}}function We(t){const e=Object.entries(t).map(([n,r])=>w({[n]:r}));return U(ye(e),Vt(n=>({...n,$kind:Object.keys(n)[0]})))}const Ze=U(E(),Vt(t=>S(t)),jn(ae)),te=Ze,Fe=E(),J=U(ye([E(),U(K(),q())]),jn(t=>{try{return BigInt(t),BigInt(t)>=0&&BigInt(t)<=18446744073709551615n}catch{return!1}},"Invalid u64")),$e=w({objectId:Ze,version:J,digest:E()}),I=U(ye([w({GasCoin:P(!0)}),w({Input:U(K(),q()),type:Q(P("pure"))}),w({Input:U(K(),q()),type:Q(P("object"))}),w({Result:U(K(),q())}),w({NestedResult:Mn([U(K(),q()),U(K(),q())])})]),Vt(t=>({...t,$kind:Object.keys(t)[0]}))),Ua=w({budget:A(J),price:A(J),owner:A(Ze),payment:A(O($e))}),un=ye([P("address"),P("bool"),P("u8"),P("u16"),P("u32"),P("u64"),P("u128"),P("u256"),w({vector:cn(()=>un)}),w({datatype:w({package:E(),module:E(),type:E(),typeParameters:O(cn(()=>un))})}),w({typeParameter:U(K(),q())})]),Na=w({ref:A(ye([P("&"),P("&mut")])),body:un}),Da=w({package:te,module:E(),function:E(),typeArguments:O(E()),arguments:O(I),_argumentTypes:Q(A(O(Na)))}),Va=w({name:E(),inputs:dt(E(),ye([I,O(I)])),data:dt(E(),gt())}),za=We({MoveCall:Da,TransferObjects:w({objects:O(I),address:I}),SplitCoins:w({coin:I,amounts:O(I)}),MergeCoins:w({destination:I,sources:O(I)}),Publish:w({modules:O(Fe),dependencies:O(te)}),MakeMoveVec:w({type:A(E()),elements:O(I)}),Upgrade:w({modules:O(Fe),dependencies:O(te),package:te,ticket:I}),$Intent:Va}),ns=We({ImmOrOwnedObject:$e,SharedObject:w({objectId:te,initialSharedVersion:J,mutable:Xe()}),Receiving:$e}),La=We({Object:ns,Pure:w({bytes:Fe}),UnresolvedPure:w({value:gt()}),UnresolvedObject:w({objectId:te,version:Q(A(J)),digest:Q(A(E())),initialSharedVersion:Q(A(J)),mutable:Q(A(Xe()))})}),Gn=We({Object:ns,Pure:w({bytes:Fe})}),rs=We({None:P(!0),Epoch:J}),Et=w({version:P(2),sender:lt(Ze),expiration:lt(rs),gasData:Ua,inputs:O(La),commands:O(za)}),Pe={MoveCall(t){const[e,n="",r=""]="target"in t?t.target.split("::"):[t.package,t.module,t.function];return{$kind:"MoveCall",MoveCall:{package:e,module:n,function:r,typeArguments:t.typeArguments??[],arguments:t.arguments??[]}}},TransferObjects(t,e){return{$kind:"TransferObjects",TransferObjects:{objects:t.map(n=>C(I,n)),address:C(I,e)}}},SplitCoins(t,e){return{$kind:"SplitCoins",SplitCoins:{coin:C(I,t),amounts:e.map(n=>C(I,n))}}},MergeCoins(t,e){return{$kind:"MergeCoins",MergeCoins:{destination:C(I,t),sources:e.map(n=>C(I,n))}}},Publish({modules:t,dependencies:e}){return{$kind:"Publish",Publish:{modules:t.map(n=>typeof n=="string"?n:V(new Uint8Array(n))),dependencies:e.map(n=>ge(n))}}},Upgrade({modules:t,dependencies:e,package:n,ticket:r}){return{$kind:"Upgrade",Upgrade:{modules:t.map(s=>typeof s=="string"?s:V(new Uint8Array(s))),dependencies:e.map(s=>ge(s)),package:n,ticket:C(I,r)}}},MakeMoveVec({type:t,elements:e}){return{$kind:"MakeMoveVec",MakeMoveVec:{type:t??null,elements:e.map(n=>C(I,n))}}},Intent({name:t,inputs:e={},data:n={}}){return{$kind:"$Intent",$Intent:{name:t,inputs:Object.fromEntries(Object.entries(e).map(([r,s])=>[r,Array.isArray(s)?s.map(i=>C(I,i)):C(I,s)])),data:n}}}},qn=w({digest:E(),objectId:E(),version:ye([U(K(),q()),E(),ts()])}),Fa=We({ImmOrOwned:qn,Shared:w({objectId:te,initialSharedVersion:J,mutable:Xe()}),Receiving:qn}),Kn=We({Object:Fa,Pure:O(U(K(),q()))});function Hn(t){var n;const e=t.inputs.map((r,s)=>{if(r.Object)return{kind:"Input",index:s,value:{Object:r.Object.ImmOrOwnedObject?{ImmOrOwned:r.Object.ImmOrOwnedObject}:r.Object.Receiving?{Receiving:{digest:r.Object.Receiving.digest,version:r.Object.Receiving.version,objectId:r.Object.Receiving.objectId}}:{Shared:{mutable:r.Object.SharedObject.mutable,initialSharedVersion:r.Object.SharedObject.initialSharedVersion,objectId:r.Object.SharedObject.objectId}}},type:"object"};if(r.Pure)return{kind:"Input",index:s,value:{Pure:Array.from(ee(r.Pure.bytes))},type:"pure"};if(r.UnresolvedPure)return{kind:"Input",type:"pure",index:s,value:r.UnresolvedPure.value};if(r.UnresolvedObject)return{kind:"Input",type:"object",index:s,value:r.UnresolvedObject.objectId};throw new Error("Invalid input")});return{version:1,sender:t.sender??void 0,expiration:((n=t.expiration)==null?void 0:n.$kind)==="Epoch"?{Epoch:Number(t.expiration.Epoch)}:t.expiration?{None:!0}:null,gasConfig:{owner:t.gasData.owner??void 0,budget:t.gasData.budget??void 0,price:t.gasData.price??void 0,payment:t.gasData.payment??void 0},inputs:e,transactions:t.commands.map(r=>{if(r.MakeMoveVec)return{kind:"MakeMoveVec",type:r.MakeMoveVec.type===null?{None:!0}:{Some:ce.parseFromStr(r.MakeMoveVec.type)},objects:r.MakeMoveVec.elements.map(s=>ve(s,e))};if(r.MergeCoins)return{kind:"MergeCoins",destination:ve(r.MergeCoins.destination,e),sources:r.MergeCoins.sources.map(s=>ve(s,e))};if(r.MoveCall)return{kind:"MoveCall",target:`${r.MoveCall.package}::${r.MoveCall.module}::${r.MoveCall.function}`,typeArguments:r.MoveCall.typeArguments,arguments:r.MoveCall.arguments.map(s=>ve(s,e))};if(r.Publish)return{kind:"Publish",modules:r.Publish.modules.map(s=>Array.from(ee(s))),dependencies:r.Publish.dependencies};if(r.SplitCoins)return{kind:"SplitCoins",coin:ve(r.SplitCoins.coin,e),amounts:r.SplitCoins.amounts.map(s=>ve(s,e))};if(r.TransferObjects)return{kind:"TransferObjects",objects:r.TransferObjects.objects.map(s=>ve(s,e)),address:ve(r.TransferObjects.address,e)};if(r.Upgrade)return{kind:"Upgrade",modules:r.Upgrade.modules.map(s=>Array.from(ee(s))),dependencies:r.Upgrade.dependencies,packageId:r.Upgrade.package,ticket:ve(r.Upgrade.ticket,e)};throw new Error(`Unknown transaction ${Object.keys(r)}`)})}}function ve(t,e){if(t.$kind==="GasCoin")return{kind:"GasCoin"};if(t.$kind==="Result")return{kind:"Result",index:t.Result};if(t.$kind==="NestedResult")return{kind:"NestedResult",index:t.NestedResult[0],resultIndex:t.NestedResult[1]};if(t.$kind==="Input")return e[t.Input];throw new Error(`Invalid argument ${Object.keys(t)}`)}function Wa(t){var e,n,r;return C(Et,{version:2,sender:t.sender??null,expiration:t.expiration?"Epoch"in t.expiration?{Epoch:t.expiration.Epoch}:{None:!0}:null,gasData:{owner:t.gasConfig.owner??null,budget:((e=t.gasConfig.budget)==null?void 0:e.toString())??null,price:((n=t.gasConfig.price)==null?void 0:n.toString())??null,payment:((r=t.gasConfig.payment)==null?void 0:r.map(s=>({digest:s.digest,objectId:s.objectId,version:s.version.toString()})))??null},inputs:t.inputs.map(s=>{if(s.kind==="Input"){if(on(Kn,s.value)){const i=C(Kn,s.value);if(i.Object){if(i.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:i.Object.ImmOrOwned.objectId,version:String(i.Object.ImmOrOwned.version),digest:i.Object.ImmOrOwned.digest}}};if(i.Object.Shared)return{Object:{SharedObject:{mutable:i.Object.Shared.mutable??null,initialSharedVersion:i.Object.Shared.initialSharedVersion,objectId:i.Object.Shared.objectId}}};if(i.Object.Receiving)return{Object:{Receiving:{digest:i.Object.Receiving.digest,version:String(i.Object.Receiving.version),objectId:i.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:V(new Uint8Array(i.Pure))}}}return s.type==="object"?{UnresolvedObject:{objectId:s.value}}:{UnresolvedPure:{value:s.value}}}throw new Error("Invalid input")}),commands:t.transactions.map(s=>{switch(s.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in s.type?ce.tagToString(s.type.Some):null,elements:s.objects.map(i=>ke(i))}};case"MergeCoins":return{MergeCoins:{destination:ke(s.destination),sources:s.sources.map(i=>ke(i))}};case"MoveCall":{const[i,o,a]=s.target.split("::");return{MoveCall:{package:i,module:o,function:a,typeArguments:s.typeArguments,arguments:s.arguments.map(u=>ke(u))}}}case"Publish":return{Publish:{modules:s.modules.map(i=>V(Uint8Array.from(i))),dependencies:s.dependencies}};case"SplitCoins":return{SplitCoins:{coin:ke(s.coin),amounts:s.amounts.map(i=>ke(i))}};case"TransferObjects":return{TransferObjects:{objects:s.objects.map(i=>ke(i)),address:ke(s.address)}};case"Upgrade":return{Upgrade:{modules:s.modules.map(i=>V(Uint8Array.from(i))),dependencies:s.dependencies,package:s.packageId,ticket:ke(s.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(s)}`)})})}function ke(t){switch(t.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:t.index};case"NestedResult":return{NestedResult:[t.index,t.resultIndex]};case"Input":return{Input:t.index}}}function mt(t){return ye(Object.entries(t).map(([e,n])=>w({[e]:n})))}const se=mt({GasCoin:P(!0),Input:U(K(),q()),Result:U(K(),q()),NestedResult:Mn([U(K(),q()),U(K(),q())])}),Ga=w({budget:A(J),price:A(J),owner:A(Ze),payment:A(O($e))}),qa=w({package:te,module:E(),function:E(),typeArguments:O(E()),arguments:O(se)}),Ka=w({name:E(),inputs:dt(E(),ye([se,O(se)])),data:dt(E(),gt())}),Ha=mt({MoveCall:qa,TransferObjects:w({objects:O(se),address:se}),SplitCoins:w({coin:se,amounts:O(se)}),MergeCoins:w({destination:se,sources:O(se)}),Publish:w({modules:O(Fe),dependencies:O(te)}),MakeMoveVec:w({type:A(E()),elements:O(se)}),Upgrade:w({modules:O(Fe),dependencies:O(te),package:te,ticket:se}),$Intent:Ka}),Ja=mt({ImmOrOwnedObject:$e,SharedObject:w({objectId:te,initialSharedVersion:J,mutable:Xe()}),Receiving:$e}),Xa=mt({Object:Ja,Pure:w({bytes:Fe}),UnresolvedPure:w({value:gt()}),UnresolvedObject:w({objectId:te,version:Q(A(J)),digest:Q(A(E())),initialSharedVersion:Q(A(J)),mutable:Q(A(Xe()))})}),Za=mt({None:P(!0),Epoch:J}),Ya=w({version:P(2),sender:lt(Ze),expiration:lt(Za),gasData:Ga,inputs:O(Xa),commands:O(Ha),digest:Q(A(E()))});function Lt(t,e){return Array.from({length:Math.ceil(t.length/e)},(n,r)=>t.slice(r*e,(r+1)*e))}class ss{constructor(e,n){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=no(n),this._batchScheduleFn=ro(n),this._cacheKeyFn=so(n),this._cacheMap=io(n),this._batch=null,this.name=ao(n)}load(e){if(e==null)throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(e)}.`);const n=eo(this),r=this._cacheMap;let s;if(r){s=this._cacheKeyFn(e);const o=r.get(s);if(o){const a=n.cacheHits||(n.cacheHits=[]);return new Promise(u=>{a.push(()=>{u(o)})})}}n.keys.push(e);const i=new Promise((o,a)=>{n.callbacks.push({resolve:o,reject:a})});return r&&r.set(s,i),i}loadMany(e){if(!is(e))throw new TypeError(`The loader.loadMany() function must be called with Array<key>, but got: ${e}.`);const n=[];for(let r=0;r<e.length;r++)n.push(this.load(e[r]).catch(s=>s));return Promise.all(n)}clear(e){const n=this._cacheMap;if(n){const r=this._cacheKeyFn(e);n.delete(r)}return this}clearAll(){const e=this._cacheMap;return e&&e.clear(),this}prime(e,n){const r=this._cacheMap;if(r){const s=this._cacheKeyFn(e);if(r.get(s)===void 0){let i;n instanceof Error?(i=Promise.reject(n),i.catch(()=>{})):i=Promise.resolve(n),r.set(s,i)}}return this}}const Qa=typeof process=="object"&&typeof process.nextTick=="function"?function(t){Zt||(Zt=Promise.resolve()),Zt.then(()=>{process.nextTick(t)})}:typeof setImmediate=="function"?function(t){setImmediate(t)}:function(t){setTimeout(t)};let Zt;function eo(t){const e=t._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<t._maxBatchSize)return e;const n={hasDispatched:!1,keys:[],callbacks:[]};return t._batch=n,t._batchScheduleFn(()=>{to(t,n)}),n}function to(t,e){if(e.hasDispatched=!0,e.keys.length===0){ln(e);return}let n;try{n=t._batchLoadFn(e.keys)}catch(r){return Yt(t,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(r)}.`))}if(!n||typeof n.then!="function")return Yt(t,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(n)}.`));Promise.resolve(n).then(r=>{if(!is(r))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(r)}.`);if(r.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.
|
|
1
|
+
"use strict";var Us=Object.create;var Nn=Object.defineProperty;var Ns=Object.getOwnPropertyDescriptor;var Ds=Object.getOwnPropertyNames;var Vs=Object.getPrototypeOf,zs=Object.prototype.hasOwnProperty;var Ls=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ds(e))!zs.call(t,s)&&s!==n&&Nn(t,s,{get:()=>e[s],enumerable:!(r=Ns(e,s))||r.enumerable});return t};var Fs=(t,e,n)=>(n=t!=null?Us(Vs(t)):{},Ls(e||!t||!t.__esModule?Nn(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Mt=require("bignumber.js"),Ws="Phantom",Gs="0x2::sui::SUI",wn=8,qs=new Error("Coin Metadata could not be found."),ar=new Error("Not enough balance."),ct={prod:"prod",testnet:"testnet"},vn=ct.prod;let St=null;const Ks=async()=>{try{const t=await import("bitcoinjs-lib"),e=await Promise.resolve().then(()=>require("./index2.cjs")).then(n=>n.index);try{t.initEccLib(e)}catch(n){if(!/already initialized/i.test(String(n)))throw n}return t}catch(t){throw St=null,new Error(`Failed to initialize bitcoinjs-lib: ${t instanceof Error?t.message:String(t)}. Ensure bitcoinjs-lib and @bitcoinerlab/secp256k1 peer dependencies are installed.`)}},Hs=async()=>(St||(St=Ks()),St);async function Js(t,e=ct.prod){const n=await Hs();return`0x${n.address.toOutputScript(t,e===ct.prod?n.networks.bitcoin:n.networks.testnet).toString("hex")}`}const Xs={mint:{target:"0x1269ce3b46b5647d0e46024185dd24bdb7492ec7840ebc40fdd209150b89a33d::treasury::mint_v2",denyList:"0x403"},redeem:{target:"0x1269ce3b46b5647d0e46024185dd24bdb7492ec7840ebc40fdd209150b89a33d::treasury::redeem"},LBTC:"0x2d66430a27565b912f21be970e5ae1e8c0359f0b518c3235b751c75976791ce0::lbtc::LBTC",treasuryAddress:"0xf9621182bf6af94142e81f5c268d1a959991df2766a5b0755c528b70e5b33531",consortiumAddress:"0xd8a7bff969c0f7069ccda1601516fc93013d8c06835646f718d7d345409340cc",bascule:"0x61cf6760a04f4af6938543e1e9c0b84f7b271cf9069f0cb6c8017093fd814c68"},Zs={mint:{target:"0xbe409fa89cd3eedbe426fdae9c53a231f2fff9dc66c3ca797163b5b5b2aba977::treasury::mint_v2",denyList:"0x403"},redeem:{target:"0xbe409fa89cd3eedbe426fdae9c53a231f2fff9dc66c3ca797163b5b5b2aba977::treasury::redeem"},LBTC:"0x50454d0b0fbad1288a6ab74f2e8ce0905a3317870673ab7787ebcf6f322b45fa::lbtc::LBTC",treasuryAddress:"0xc8f3d6d596ed86012a289166400d3650d9f888f612bf9c35b0cde7bc1b053408",consortiumAddress:"0x5d0922bfc25cd4babc76e7e320b0e9b4d4950408bae9632a5fedf2a1f8dc29dc",bascule:"0xd8b1c1f9b893330180fa1fc52a316461a5fabd258fa15633e9a5ba5da71af49e"},Ys={mint:{target:"0x818430a456ff977f7320f78650d19801f90758d200a01dd3c2c679472c521357::treasury::mint_v2",denyList:"0x403"},redeem:{target:"0x818430a456ff977f7320f78650d19801f90758d200a01dd3c2c679472c521357::treasury::redeem"},LBTC:"0x3e8e9423d80e1774a7ca128fccd8bf5f1f7753be658c5e645929037f7c819040::lbtc::LBTC",treasuryAddress:"0x1adadbca040f368abd554ac55e7c216ea6df2ff891fc647f037d66669661584a",consortiumAddress:"0x9f68fe752d0879d615415e39207f0363a6fc8e0b3b335e976f5f18b31f55faf3",bascule:"0x138938cb496cf0900be970dde1407d86497b8c69182cb5aa22dc4767c92bedcc"};function kn(t=vn){switch(t){case ct.prod:return Ys;case ct.testnet:return Zs;default:return Xs}}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Qs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function or(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(n=>typeof n=="string"):e.every(n=>Number.isSafeInteger(n)):!1}function tn(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function cr(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function nn(t){if(!Array.isArray(t))throw new Error("array expected")}function ur(t,e){if(!or(!0,e))throw new Error(`${t}: array of strings expected`)}function ei(t,e){if(!or(!1,e))throw new Error(`${t}: array of numbers expected`)}function ti(...t){const e=i=>i,n=(i,o)=>a=>i(o(a)),r=t.map(i=>i.encode).reduceRight(n,e),s=t.map(i=>i.decode).reduce(n,e);return{encode:r,decode:s}}function ni(t){const e=typeof t=="string"?t.split(""):t,n=e.length;ur("alphabet",e);const r=new Map(e.map((s,i)=>[s,i]));return{encode:s=>(nn(s),s.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${t}`);return e[i]})),decode:s=>(nn(s),s.map(i=>{tn("alphabet.decode",i);const o=r.get(i);if(o===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${t}`);return o}))}}function ri(t=""){return tn("join",t),{encode:e=>(ur("join.decode",e),e.join(t)),decode:e=>(tn("join.decode",e),e.split(t))}}function Dn(t,e,n){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(nn(t),!t.length)return[];let r=0;const s=[],i=Array.from(t,a=>{if(cr(a),a<0||a>=e)throw new Error(`invalid integer: ${a}`);return a}),o=i.length;for(;;){let a=0,u=!0;for(let d=r;d<o;d++){const l=i[d],h=e*a,m=h+l;if(!Number.isSafeInteger(m)||h/e!==a||m-l!==h)throw new Error("convertRadix: carry overflow");const b=m/n;a=m%n;const g=Math.floor(b);if(i[d]=g,!Number.isSafeInteger(g)||g*n+a!==m)throw new Error("convertRadix: carry overflow");if(u)g?u=!1:r=d;else continue}if(s.push(a),u)break}for(let a=0;a<t.length-1&&t[a]===0;a++)s.push(0);return s.reverse()}function si(t){cr(t);const e=2**8;return{encode:n=>{if(!Qs(n))throw new Error("radix.encode input should be Uint8Array");return Dn(Array.from(n),e,t)},decode:n=>(ei("radix.decode",n),Uint8Array.from(Dn(n,t,e)))}}const ii=t=>ti(si(58),ni(t),ri("")),lr=ii("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Nt=t=>lr.encode(t),ut=t=>lr.decode(t);function ee(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const Wt=8192;function V(t){if(t.length<Wt)return btoa(String.fromCharCode(...t));let e="";for(var n=0;n<t.length;n+=Wt){const r=t.slice(n,n+Wt);e+=String.fromCharCode(...r)}return btoa(e)}function dr(t){var s;const e=t.startsWith("0x")?t.slice(2):t,n=e.length%2===0?e:`0${e}`,r=((s=n.match(/[0-9a-fA-F]{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];if(r.length!==n.length/2)throw new Error(`Invalid hex string ${t}`);return Uint8Array.from(r)}function Je(t){return t.reduce((e,n)=>e+n.toString(16).padStart(2,"0"),"")}function Ct(t){let e=BigInt(t);const n=[];let r=0;if(e===0n)return[0];for(;e>0;)n[r]=Number(e&0x7fn),e>>=7n,e>0n&&(n[r]|=128),r+=1;return n}function ai(t){let e=0n,n=0n,r=0;for(;;){if(r>=t.length)throw new Error("ULEB decode error: buffer overflow");const s=t[r];if(r+=1,e+=BigInt(s&127)<<n,(s&128)===0)break;n+=7n}if(e>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("ULEB decode error: value exceeds MAX_SAFE_INTEGER");return{value:Number(e),length:r}}class oi{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength)}shift(e){return this.bytePosition+=e,this}read8(){const e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){const e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){const e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){const e=this.read32(),r=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+r).toString(10)}read128(){const e=BigInt(this.read64()),r=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+r).toString(10)}read256(){const e=BigInt(this.read128()),r=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+r).toString(10)}readBytes(e){const n=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,n,e);return this.shift(e),r}readULEB(){const e=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=ai(n);return this.shift(s),r}readVec(e){const n=this.readULEB(),r=[];for(let s=0;s<n;s++)r.push(e(this,s,n));return r}}function ci(t,e){switch(e){case"base58":return Nt(t);case"base64":return V(t);case"hex":return Je(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function hr(t,e=["<",">"]){const[n,r]=e,s=[];let i="",o=0;for(let a=0;a<t.length;a++){const u=t[a];if(u===n&&o++,u===r&&o--,o===0&&u===","){s.push(i.trim()),i="";continue}i+=u}return s.push(i.trim()),s}class ui{constructor({initialSize:e=1024,maxSize:n=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=n,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const n=this.bytePosition+e;if(n>this.size){const r=Math.min(this.maxSize,Math.max(this.size+n,this.size+this.allocateSize));if(n>r)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: ${n}`);this.size=r;const s=new ArrayBuffer(this.size);new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(s)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}writeBytes(e){this.ensureSizeOrGrow(e.length);for(let n=0;n<e.length;n++)this.dataView.setUint8(this.bytePosition+n,e[n]);return this.shift(e.length)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return Gt(BigInt(e),8).forEach(n=>this.write8(n)),this}write128(e){return Gt(BigInt(e),16).forEach(n=>this.write8(n)),this}write256(e){return Gt(BigInt(e),32).forEach(n=>this.write8(n)),this}writeULEB(e){return Ct(e).forEach(n=>this.write8(n)),this}writeVec(e,n){return this.writeULEB(e.length),Array.from(e).forEach((r,s)=>n(this,r,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return ci(this.toBytes(),e)}}function Gt(t,e){const n=new Uint8Array(e);let r=0;for(;t>0;)n[r]=Number(t%BigInt(256)),t=t/BigInt(256),r+=1;return n}var fr=t=>{throw TypeError(t)},pr=(t,e,n)=>e.has(t)||fr("Cannot "+n),ie=(t,e,n)=>(pr(t,e,"read from private field"),n?n.call(t):e.get(t)),At=(t,e,n)=>e.has(t)?fr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),_t=(t,e,n,r)=>(pr(t,e,"write to private field"),e.set(t,n),n),qe,et,Ot,Me;const li=class gr{constructor(e){At(this,qe),At(this,et),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),_t(this,qe,e.write),_t(this,et,e.serialize??((n,r)=>{const s=new ui({initialSize:this.serializedSize(n)??void 0,...r});return ie(this,qe).call(this,n,s),s.toBytes()})),this.validate=e.validate??(()=>{})}write(e,n){this.validate(e),ie(this,qe).call(this,e,n)}serialize(e,n){return this.validate(e),new di(this,ie(this,et).call(this,e,n))}parse(e){const n=new oi(e);return this.read(n)}fromHex(e){return this.parse(dr(e))}fromBase58(e){return this.parse(ut(e))}fromBase64(e){return this.parse(ee(e))}transform({name:e,input:n,output:r,validate:s}){return new gr({name:e??this.name,read:i=>r?r(this.read(i)):this.read(i),write:(i,o)=>ie(this,qe).call(this,n?n(i):i,o),serializedSize:i=>this.serializedSize(n?n(i):i),serialize:(i,o)=>ie(this,et).call(this,n?n(i):i,o),validate:i=>{s==null||s(i),this.validate(n?n(i):i)}})}};qe=new WeakMap;et=new WeakMap;let be=li;const mr=Symbol.for("@mysten/serialized-bcs");function Sn(t){return!!t&&typeof t=="object"&&t[mr]===!0}class di{constructor(e,n){At(this,Ot),At(this,Me),_t(this,Ot,e),_t(this,Me,n)}get[mr](){return!0}toBytes(){return ie(this,Me)}toHex(){return Je(ie(this,Me))}toBase64(){return V(ie(this,Me))}toBase58(){return Nt(ie(this,Me))}parse(){return ie(this,Ot).parse(ie(this,Me))}}Ot=new WeakMap;Me=new WeakMap;function xt({size:t,...e}){return new be({...e,serializedSize:()=>t})}function qt({readMethod:t,writeMethod:e,...n}){return xt({...n,read:r=>r[t](),write:(r,s)=>s[e](r),validate:r=>{var s;if(r<0||r>n.maxValue)throw new TypeError(`Invalid ${n.name} value: ${r}. Expected value in range 0-${n.maxValue}`);(s=n.validate)==null||s.call(n,r)}})}function Kt({readMethod:t,writeMethod:e,...n}){return xt({...n,read:r=>r[t](),write:(r,s)=>s[e](BigInt(r)),validate:r=>{var i;const s=BigInt(r);if(s<0||s>n.maxValue)throw new TypeError(`Invalid ${n.name} value: ${s}. Expected value in range 0-${n.maxValue}`);(i=n.validate)==null||i.call(n,s)}})}function hi({serialize:t,...e}){const n=new be({...e,serialize:t,write:(r,s)=>{for(const i of n.serialize(r).toBytes())s.write8(i)}});return n}function fi({toBytes:t,fromBytes:e,...n}){return new be({...n,read:r=>{const s=r.readULEB(),i=r.readBytes(s);return e(i)},write:(r,s)=>{const i=t(r);s.writeULEB(i.length);for(let o=0;o<i.length;o++)s.write8(i[o])},serialize:r=>{const s=t(r),i=Ct(s.length),o=new Uint8Array(i.length+s.length);return o.set(i,0),o.set(s,i.length),o},validate:r=>{var s;if(typeof r!="string")throw new TypeError(`Invalid ${n.name} value: ${r}. Expected string`);(s=n.validate)==null||s.call(n,r)}})}function pi(t){let e=null;function n(){return e||(e=t()),e}return new be({name:"lazy",read:r=>n().read(r),serializedSize:r=>n().serializedSize(r),write:(r,s)=>n().write(r,s),serialize:(r,s)=>n().serialize(r,s).toBytes()})}class gi extends be{constructor({name:e,fields:n,...r}){const s=Object.entries(n);super({name:e,serializedSize:i=>{let o=0;for(const[a,u]of s){const d=u.serializedSize(i[a]);if(d==null)return null;o+=d}return o},read:i=>{const o={};for(const[a,u]of s)o[a]=u.read(i);return o},write:(i,o)=>{for(const[a,u]of s)u.write(i[a],o)},...r,validate:i=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`)}})}}class mi extends be{constructor({fields:e,...n}){const r=Object.entries(e);super({read:s=>{const i=s.readULEB(),o=r[i];if(!o)throw new TypeError(`Unknown value ${i} for enum ${n.name}`);const[a,u]=o;return{[a]:(u==null?void 0:u.read(s))??!0,$kind:a}},write:(s,i)=>{const[o,a]=Object.entries(s).filter(([u])=>Object.hasOwn(e,u))[0];for(let u=0;u<r.length;u++){const[d,l]=r[u];if(d===o){i.writeULEB(u),l==null||l.write(a,i);return}}},...n,validate:s=>{var a;if((a=n==null?void 0:n.validate)==null||a.call(n,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`);const i=Object.keys(s).filter(u=>s[u]!==void 0&&Object.hasOwn(e,u));if(i.length!==1)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${n.name}}`);const[o]=i;if(!Object.hasOwn(e,o))throw new TypeError(`Invalid enum variant ${o}`)}})}}class bi extends be{constructor({fields:e,name:n,...r}){super({name:n??`(${e.map(s=>s.name).join(", ")})`,serializedSize:s=>{let i=0;for(let o=0;o<e.length;o++){const a=e[o].serializedSize(s[o]);if(a==null)return null;i+=a}return i},read:s=>{const i=[];for(const o of e)i.push(o.read(s));return i},write:(s,i)=>{for(let o=0;o<e.length;o++)e[o].write(s[o],i)},...r,validate:s=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,s),!Array.isArray(s))throw new TypeError(`Expected array, found ${typeof s}`);if(s.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${s.length}`)}})}}function yi(t,e,n){return new be({read:r=>{const s=new Array(t);for(let i=0;i<t;i++)s[i]=e.read(r);return s},write:(r,s)=>{for(const i of r)e.write(i,s)},...n,name:(n==null?void 0:n.name)??`${e.name}[${t}]`,validate:r=>{var s;if((s=n==null?void 0:n.validate)==null||s.call(n,r),!r||typeof r!="object"||!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t)throw new TypeError(`Expected array of length ${t}, found ${r.length}`)}})}function wi(t){return c.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>e.$kind==="Some"?e.Some:null})}function vi(t,e){return new be({read:n=>{const r=n.readULEB(),s=new Array(r);for(let i=0;i<r;i++)s[i]=t.read(n);return s},write:(n,r)=>{r.writeULEB(n.length);for(const s of n)t.write(s,r)},...e,name:(e==null?void 0:e.name)??`vector<${t.name}>`,validate:n=>{var r;if((r=e==null?void 0:e.validate)==null||r.call(e,n),!n||typeof n!="object"||!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`)}})}function ki(t,e){return c.vector(c.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:n=>[...n.entries()],output:n=>{const r=new Map;for(const[s,i]of n)r.set(s,i);return r}})}const c={u8(t){return qt({readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t,name:(t==null?void 0:t.name)??"u8"})},u16(t){return qt({readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t,name:(t==null?void 0:t.name)??"u16"})},u32(t){return qt({readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t,name:(t==null?void 0:t.name)??"u32"})},u64(t){return Kt({readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t,name:(t==null?void 0:t.name)??"u64"})},u128(t){return Kt({readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t,name:(t==null?void 0:t.name)??"u128"})},u256(t){return Kt({readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t,name:(t==null?void 0:t.name)??"u256"})},bool(t){return xt({size:1,read:e=>e.read8()===1,write:(e,n)=>n.write8(e?1:0),...t,name:(t==null?void 0:t.name)??"bool",validate:e=>{var n;if((n=t==null?void 0:t.validate)==null||n.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return hi({read:e=>e.readULEB(),serialize:e=>Uint8Array.from(Ct(e)),...t,name:(t==null?void 0:t.name)??"uleb128"})},bytes(t,e){return xt({size:t,read:n=>n.readBytes(t),write:(n,r)=>{r.writeBytes(new Uint8Array(n))},...e,name:(e==null?void 0:e.name)??`bytes[${t}]`,validate:n=>{var r;if((r=e==null?void 0:e.validate)==null||r.call(e,n),!n||typeof n!="object"||!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==t)throw new TypeError(`Expected array of length ${t}, found ${n.length}`)}})},byteVector(t){return new be({read:e=>{const n=e.readULEB();return e.readBytes(n)},write:(e,n)=>{const r=new Uint8Array(e);n.writeULEB(r.length),n.writeBytes(r)},...t,name:(t==null?void 0:t.name)??"vector<u8>",serializedSize:e=>{const n="length"in e?e.length:null;return n==null?null:Ct(n).length+n},validate:e=>{var n;if((n=t==null?void 0:t.validate)==null||n.call(t,e),!e||typeof e!="object"||!("length"in e))throw new TypeError(`Expected array, found ${typeof e}`)}})},string(t){return fi({toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t,name:(t==null?void 0:t.name)??"string"})},fixedArray:yi,option:wi,vector:vi,tuple(t,e){return new bi({fields:t,...e})},struct(t,e,n){return new gi({name:t,fields:e,...n})},enum(t,e,n){return new mi({name:t,fields:e,...n})},map:ki,lazy(t){return pi(t)}},br=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,yr=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i,Si=235;function Oi(t){return t.length>Si?!1:t.includes("@")?br.test(t):yr.test(t)}function Ei(t,e="at"){const n=t.toLowerCase();let r;if(n.includes("@")){if(!br.test(n))throw new Error(`Invalid SuiNS name ${t}`);const[s,i]=n.split("@");r=[...s?s.split("."):[],i]}else{if(!yr.test(n))throw new Error(`Invalid SuiNS name ${t}`);r=n.split(".").slice(0,-1)}return e==="dot"?`${r.join(".")}.sui`:`${r.slice(0,-1).join(".")}@${r[r.length-1]}`}const Ti=/^([a-z0-9]+(?:-[a-z0-9]+)*)$/,Ii=/^\d+$/,ji=64,wr="/",X=t=>{const e=t.split(wr);if(e.length<2||e.length>3)return!1;const[n,r,s]=e;return s!==void 0&&!Ii.test(s)||!Oi(n)?!1:Ti.test(r)&&r.length<ji},Mi=t=>{const e=t.split(/::|<|>|,/);for(const n of e)if(n.includes(wr)&&!X(n))return!1;return!0},Ci=32;function Vn(t){try{return ut(t).length===Ci}catch{return!1}}const Dt=32;function ae(t){return _i(t)&&xi(t)===Dt}function yt(t){return ae(t)}function Ai(t){return t.includes("::")?Le(t):t}function Le(t){const[e,n]=t.split("::"),r=X(e),s=t.slice(e.length+n.length+4),i=s.includes("<")?s.slice(0,s.indexOf("<")):s,o=s.includes("<")?hr(s.slice(s.indexOf("<")+1,s.lastIndexOf(">"))).map(a=>Ai(a.trim())):[];return{address:r?e:S(e),module:n,name:i,typeParams:o}}function $t(t){const{address:e,module:n,name:r,typeParams:s}=typeof t=="string"?Le(t):t,i=(s==null?void 0:s.length)>0?`<${s.map(o=>typeof o=="string"?o:$t(o)).join(",")}>`:"";return`${e}::${n}::${r}${i}`}function S(t,e=!1){let n=t.toLowerCase();return!e&&n.startsWith("0x")&&(n=n.slice(2)),`0x${n.padStart(Dt*2,"0")}`}function ge(t,e=!1){return S(t,e)}function _i(t){return/^(0x|0X)?[a-fA-F0-9]+$/.test(t)&&t.length%2===0}function xi(t){return/^(0x|0X)/.test(t)?(t.length-2)/2:t.length/2}const $i=/^vector<(.+)>$/,Pi=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class ce{static parseFromStr(e,n=!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 r=e.match($i);if(r)return{vector:ce.parseFromStr(r[1],n)};const s=e.match(Pi);if(s)return{struct:{address:n?S(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:ce.parseStructTypeArgs(s[5],n)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,n=!1){return hr(e).map(r=>ce.parseFromStr(r,n))}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<${ce.tagToString(e.vector)}>`;if("struct"in e){const n=e.struct,r=n.typeParams.map(ce.tagToString).join(", ");return`${n.address}::${n.module}::${n.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}function Ri(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function Bi(t){return c.enum("Option",{None:null,Some:t})}const j=c.bytes(Dt).transform({validate:t=>{const e=typeof t=="string"?t:Je(t);if(!e||!ae(S(e)))throw new Error(`Invalid Sui address ${e}`)},input:t=>typeof t=="string"?dr(S(t)):t,output:t=>S(Je(t))}),le=c.byteVector().transform({name:"ObjectDigest",input:t=>ut(t),output:t=>Nt(new Uint8Array(t)),validate:t=>{if(ut(t).length!==32)throw new Error("ObjectDigest must be 32 bytes")}}),ne=c.struct("SuiObjectRef",{objectId:j,version:c.u64(),digest:le}),vr=c.struct("SharedObjectRef",{objectId:j,initialSharedVersion:c.u64(),mutable:c.bool()}),kr=c.enum("ObjectArg",{ImmOrOwnedObject:ne,SharedObject:vr,Receiving:ne}),Ue=c.enum("Owner",{AddressOwner:j,ObjectOwner:j,Shared:c.struct("Shared",{initialSharedVersion:c.u64()}),Immutable:null,ConsensusAddressOwner:c.struct("ConsensusAddressOwner",{owner:j,startVersion:c.u64()})}),Sr=c.enum("CallArg",{Pure:c.struct("Pure",{bytes:c.byteVector().transform({input:t=>typeof t=="string"?ee(t):t,output:t=>V(new Uint8Array(t))})}),Object:kr}),On=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>On),struct:c.lazy(()=>Mr),u16:null,u32:null,u256:null}),En=On.transform({input:t=>typeof t=="string"?ce.parseFromStr(t,!0):t,output:t=>ce.tagToString(t)}),fe=c.enum("Argument",{GasCoin:null,Input:c.u16(),Result:c.u16(),NestedResult:c.tuple([c.u16(),c.u16()])}),Or=c.struct("ProgrammableMoveCall",{package:j,module:c.string(),function:c.string(),typeArguments:c.vector(En),arguments:c.vector(fe)}),Er=c.enum("Command",{MoveCall:Or,TransferObjects:c.struct("TransferObjects",{objects:c.vector(fe),address:fe}),SplitCoins:c.struct("SplitCoins",{coin:fe,amounts:c.vector(fe)}),MergeCoins:c.struct("MergeCoins",{destination:fe,sources:c.vector(fe)}),Publish:c.struct("Publish",{modules:c.vector(c.byteVector().transform({input:t=>typeof t=="string"?ee(t):t,output:t=>V(new Uint8Array(t))})),dependencies:c.vector(j)}),MakeMoveVec:c.struct("MakeMoveVec",{type:Bi(En).transform({input:t=>t===null?{None:!0}:{Some:t},output:t=>t.Some??null}),elements:c.vector(fe)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.byteVector().transform({input:t=>typeof t=="string"?ee(t):t,output:t=>V(new Uint8Array(t))})),dependencies:c.vector(j),package:j,ticket:fe})}),Tr=c.struct("ProgrammableTransaction",{inputs:c.vector(Sr),commands:c.vector(Er)}),Ir=c.enum("TransactionKind",{ProgrammableTransaction:Tr,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),jr=c.enum("TransactionExpiration",{None:null,Epoch:Ri()}),Mr=c.struct("StructTag",{address:j,module:c.string(),name:c.string(),typeParams:c.vector(On)}),Cr=c.struct("GasData",{payment:c.vector(ne),owner:j,price:c.u64(),budget:c.u64()}),Ar=c.struct("TransactionDataV1",{kind:Ir,sender:j,gasData:Cr,expiration:jr}),_r=c.enum("TransactionData",{V1:Ar}),xr=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),$r=c.enum("IntentVersion",{V0:null}),Pr=c.enum("AppId",{Sui:null}),Rr=c.struct("Intent",{scope:xr,version:$r,appId:Pr});function Br(t){return c.struct(`IntentMessage<${t.name}>`,{intent:Rr,value:t})}const Ur=c.enum("CompressedSignature",{ED25519:c.bytes(64),Secp256k1:c.bytes(64),Secp256r1:c.bytes(64),ZkLogin:c.byteVector(),Passkey:c.byteVector()}),Nr=c.enum("PublicKey",{ED25519:c.bytes(32),Secp256k1:c.bytes(33),Secp256r1:c.bytes(33),ZkLogin:c.byteVector(),Passkey:c.bytes(33)}),Dr=c.struct("MultiSigPkMap",{pubKey:Nr,weight:c.u8()}),Vr=c.struct("MultiSigPublicKey",{pk_map:c.vector(Dr),threshold:c.u16()}),Ui=c.struct("MultiSig",{sigs:c.vector(Ur),bitmap:c.u16(),multisig_pk:Vr}),Ni=c.byteVector().transform({input:t=>typeof t=="string"?ee(t):t,output:t=>V(new Uint8Array(t))}),zr=c.struct("SenderSignedTransaction",{intentMessage:Br(_r),txSignatures:c.vector(Ni)}),Di=c.vector(zr,{name:"SenderSignedData"}),Vi=c.struct("PasskeyAuthenticator",{authenticatorData:c.byteVector(),clientDataJson:c.string(),userSignature:c.byteVector()}),zi=c.enum("PackageUpgradeError",{UnableToFetchPackage:c.struct("UnableToFetchPackage",{packageId:j}),NotAPackage:c.struct("NotAPackage",{objectId:j}),IncompatibleUpgrade:null,DigestDoesNotMatch:c.struct("DigestDoesNotMatch",{digest:c.byteVector()}),UnknownUpgradePolicy:c.struct("UnknownUpgradePolicy",{policy:c.u8()}),PackageIDDoesNotMatch:c.struct("PackageIDDoesNotMatch",{packageId:j,ticketId:j})}),Li=c.struct("ModuleId",{address:j,name:c.string()}),zn=c.struct("MoveLocation",{module:Li,function:c.u16(),instruction:c.u16(),functionName:c.option(c.string())}),Fi=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}),Wi=c.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),Gi=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:j}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:c.option(zn),MoveAbort:c.tuple([zn,c.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:c.struct("CommandArgumentError",{argIdx:c.u16(),kind:Fi}),TypeArgumentError:c.struct("TypeArgumentError",{argumentIdx:c.u16(),kind:Wi}),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:zi}),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(j)}),AddressDeniedForCoin:c.struct("AddressDeniedForCoin",{address:j,coinType:c.string()}),CoinTypeGlobalPause:c.struct("CoinTypeGlobalPause",{coinType:c.string()}),ExecutionCancelledDueToRandomnessUnavailable:null}),Lr=c.enum("ExecutionStatus",{Success:null,Failed:c.struct("ExecutionFailed",{error:Gi,command:c.option(c.u64())})}),Fr=c.struct("GasCostSummary",{computationCost:c.u64(),storageCost:c.u64(),storageRebate:c.u64(),nonRefundableStorageFee:c.u64()}),qi=c.struct("TransactionEffectsV1",{status:Lr,executedEpoch:c.u64(),gasUsed:Fr,modifiedAtVersions:c.vector(c.tuple([j,c.u64()])),sharedObjects:c.vector(ne),transactionDigest:le,created:c.vector(c.tuple([ne,Ue])),mutated:c.vector(c.tuple([ne,Ue])),unwrapped:c.vector(c.tuple([ne,Ue])),deleted:c.vector(ne),unwrappedThenDeleted:c.vector(ne),wrapped:c.vector(ne),gasObject:c.tuple([ne,Ue]),eventsDigest:c.option(le),dependencies:c.vector(le)}),Tn=c.tuple([c.u64(),le]),Ki=c.enum("ObjectIn",{NotExist:null,Exist:c.tuple([Tn,Ue])}),Hi=c.enum("ObjectOut",{NotExist:null,ObjectWrite:c.tuple([le,Ue]),PackageWrite:Tn}),Ji=c.enum("IDOperation",{None:null,Created:null,Deleted:null}),Xi=c.struct("EffectsObjectChange",{inputState:Ki,outputState:Hi,idOperation:Ji}),Zi=c.enum("UnchangedSharedKind",{ReadOnlyRoot:Tn,MutateDeleted:c.u64(),ReadDeleted:c.u64(),Cancelled:c.u64(),PerEpochConfig:null}),Yi=c.struct("TransactionEffectsV2",{status:Lr,executedEpoch:c.u64(),gasUsed:Fr,transactionDigest:le,gasObjectIndex:c.option(c.u32()),eventsDigest:c.option(le),dependencies:c.vector(le),lamportVersion:c.u64(),changedObjects:c.vector(c.tuple([j,Xi])),unchangedSharedObjects:c.vector(c.tuple([j,Zi])),auxDataDigest:c.option(le)}),Qi=c.enum("TransactionEffects",{V1:qi,V2:Yi});function nt(t){switch(t){case"u8":return c.u8();case"u16":return c.u16();case"u32":return c.u32();case"u64":return c.u64();case"u128":return c.u128();case"u256":return c.u256();case"bool":return c.bool();case"string":return c.string();case"id":case"address":return j}const e=t.match(/^(vector|option)<(.+)>$/);if(e){const[n,r]=e.slice(1);return n==="vector"?c.vector(nt(r)):c.option(nt(r))}throw new Error(`Invalid Pure type name: ${t}`)}const k={...c,U8:c.u8(),U16:c.u16(),U32:c.u32(),U64:c.u64(),U128:c.u128(),U256:c.u256(),ULEB128:c.uleb128(),Bool:c.bool(),String:c.string(),Address:j,AppId:Pr,Argument:fe,CallArg:Sr,Command:Er,CompressedSignature:Ur,GasData:Cr,Intent:Rr,IntentMessage:Br,IntentScope:xr,IntentVersion:$r,MultiSig:Ui,MultiSigPkMap:Dr,MultiSigPublicKey:Vr,ObjectArg:kr,ObjectDigest:le,Owner:Ue,PasskeyAuthenticator:Vi,ProgrammableMoveCall:Or,ProgrammableTransaction:Tr,PublicKey:Nr,SenderSignedData:Di,SenderSignedTransaction:zr,SharedObjectRef:vr,StructTag:Mr,SuiObjectRef:ne,TransactionData:_r,TransactionDataV1:Ar,TransactionEffects:Qi,TransactionExpiration:jr,TransactionKind:Ir,TypeTag:En};BigInt(1e9);const ea="0x1",Wr="0x2";ge("0x6");const ta=`${Wr}::sui::SUI`;ge("0x5");ge("0x8");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function na(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function rn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function In(t,...e){if(!na(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ln(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ra(t,e){In(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Pt(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function sn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Gr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function qr(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const Se=Gr?t=>t:t=>qr(t);function sa(t){for(let e=0;e<t.length;e++)t[e]=qr(t[e]);return t}const Ge=Gr?t=>t:sa;function ia(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function rt(t){return typeof t=="string"&&(t=ia(t)),In(t),t}class aa{}function oa(t){const e=(r,s)=>t(s).update(rt(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}const ca=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),wt=BigInt(2**32-1),Fn=BigInt(32);function ua(t,e=!1){return e?{h:Number(t&wt),l:Number(t>>Fn&wt)}:{h:Number(t>>Fn&wt)|0,l:Number(t&wt)|0}}const Kr=(t,e,n)=>t>>>n|e<<32-n,Hr=(t,e,n)=>t<<32-n|e>>>n,la=(t,e,n)=>t<<64-n|e>>>n-32,da=(t,e,n)=>t>>>n-32|e<<64-n,ha=(t,e)=>e,fa=(t,e)=>t;function Jr(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const Xr=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Zr=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,x=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),p=new Uint32Array(32);function Ie(t,e,n,r,s,i){const o=s[i],a=s[i+1];let u=p[2*t],d=p[2*t+1],l=p[2*e],h=p[2*e+1],m=p[2*n],b=p[2*n+1],g=p[2*r],v=p[2*r+1],L=Xr(u,l,o);d=Zr(L,d,h,a),u=L|0,{Dh:v,Dl:g}={Dh:v^d,Dl:g^u},{Dh:v,Dl:g}={Dh:ha(v,g),Dl:fa(v)},{h:b,l:m}=Jr(b,m,v,g),{Bh:h,Bl:l}={Bh:h^b,Bl:l^m},{Bh:h,Bl:l}={Bh:Kr(h,l,24),Bl:Hr(h,l,24)},p[2*t]=u,p[2*t+1]=d,p[2*e]=l,p[2*e+1]=h,p[2*n]=m,p[2*n+1]=b,p[2*r]=g,p[2*r+1]=v}function je(t,e,n,r,s,i){const o=s[i],a=s[i+1];let u=p[2*t],d=p[2*t+1],l=p[2*e],h=p[2*e+1],m=p[2*n],b=p[2*n+1],g=p[2*r],v=p[2*r+1],L=Xr(u,l,o);d=Zr(L,d,h,a),u=L|0,{Dh:v,Dl:g}={Dh:v^d,Dl:g^u},{Dh:v,Dl:g}={Dh:Kr(v,g,16),Dl:Hr(v,g,16)},{h:b,l:m}=Jr(b,m,v,g),{Bh:h,Bl:l}={Bh:h^b,Bl:l^m},{Bh:h,Bl:l}={Bh:la(h,l,63),Bl:da(h,l,63)},p[2*t]=u,p[2*t+1]=d,p[2*e]=l,p[2*e+1]=h,p[2*n]=m,p[2*n+1]=b,p[2*r]=g,p[2*r+1]=v}function pa(t,e={},n,r,s){if(rn(n),t<0||t>n)throw new Error("outputLen bigger than keyLen");const{key:i,salt:o,personalization:a}=e;if(i!==void 0&&(i.length<1||i.length>n))throw new Error("key length must be undefined or 1.."+n);if(o!==void 0&&o.length!==r)throw new Error("salt must be undefined or "+r);if(a!==void 0&&a.length!==s)throw new Error("personalization must be undefined or "+s)}class ga extends aa{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,rn(e),rn(n),this.blockLen=e,this.outputLen=n,this.buffer=new Uint8Array(e),this.buffer32=Pt(this.buffer)}update(e){Ln(this),e=rt(e),In(e);const{blockLen:n,buffer:r,buffer32:s}=this,i=e.length,o=e.byteOffset,a=e.buffer;for(let u=0;u<i;){this.pos===n&&(Ge(s),this.compress(s,0,!1),Ge(s),this.pos=0);const d=Math.min(n-this.pos,i-u),l=o+u;if(d===n&&!(l%4)&&u+d<i){const h=new Uint32Array(a,l,Math.floor((i-u)/4));Ge(h);for(let m=0;u+n<i;m+=s.length,u+=n)this.length+=n,this.compress(h,m,!1);Ge(h);continue}r.set(e.subarray(u,u+d),this.pos),this.pos+=d,this.length+=d,u+=d}return this}digestInto(e){Ln(this),ra(e,this);const{pos:n,buffer32:r}=this;this.finished=!0,sn(this.buffer.subarray(n)),Ge(r),this.compress(r,0,!0),Ge(r);const s=Pt(e);this.get().forEach((i,o)=>s[o]=Se(i))}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){const{buffer:n,length:r,finished:s,destroyed:i,outputLen:o,pos:a}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(n),e.destroyed=i,e.finished=s,e.length=r,e.pos=a,e.outputLen=o,e}clone(){return this._cloneInto()}}class ma extends ga{constructor(e={}){const n=e.dkLen===void 0?64:e.dkLen;super(128,n),this.v0l=x[0]|0,this.v0h=x[1]|0,this.v1l=x[2]|0,this.v1h=x[3]|0,this.v2l=x[4]|0,this.v2h=x[5]|0,this.v3l=x[6]|0,this.v3h=x[7]|0,this.v4l=x[8]|0,this.v4h=x[9]|0,this.v5l=x[10]|0,this.v5h=x[11]|0,this.v6l=x[12]|0,this.v6h=x[13]|0,this.v7l=x[14]|0,this.v7h=x[15]|0,pa(n,e,64,16,16);let{key:r,personalization:s,salt:i}=e,o=0;if(r!==void 0&&(r=rt(r),o=r.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,i!==void 0){i=rt(i);const a=Pt(i);this.v4l^=Se(a[0]),this.v4h^=Se(a[1]),this.v5l^=Se(a[2]),this.v5h^=Se(a[3])}if(s!==void 0){s=rt(s);const a=Pt(s);this.v6l^=Se(a[0]),this.v6h^=Se(a[1]),this.v7l^=Se(a[2]),this.v7h^=Se(a[3])}if(r!==void 0){const a=new Uint8Array(this.blockLen);a.set(r),this.update(a)}}get(){let{v0l:e,v0h:n,v1l:r,v1h:s,v2l:i,v2h:o,v3l:a,v3h:u,v4l:d,v4h:l,v5l:h,v5h:m,v6l:b,v6h:g,v7l:v,v7h:L}=this;return[e,n,r,s,i,o,a,u,d,l,h,m,b,g,v,L]}set(e,n,r,s,i,o,a,u,d,l,h,m,b,g,v,L){this.v0l=e|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=i|0,this.v2h=o|0,this.v3l=a|0,this.v3h=u|0,this.v4l=d|0,this.v4h=l|0,this.v5l=h|0,this.v5h=m|0,this.v6l=b|0,this.v6h=g|0,this.v7l=v|0,this.v7h=L|0}compress(e,n,r){this.get().forEach((u,d)=>p[d]=u),p.set(x,16);let{h:s,l:i}=ua(BigInt(this.length));p[24]=x[8]^i,p[25]=x[9]^s,r&&(p[28]=~p[28],p[29]=~p[29]);let o=0;const a=ca;for(let u=0;u<12;u++)Ie(0,4,8,12,e,n+2*a[o++]),je(0,4,8,12,e,n+2*a[o++]),Ie(1,5,9,13,e,n+2*a[o++]),je(1,5,9,13,e,n+2*a[o++]),Ie(2,6,10,14,e,n+2*a[o++]),je(2,6,10,14,e,n+2*a[o++]),Ie(3,7,11,15,e,n+2*a[o++]),je(3,7,11,15,e,n+2*a[o++]),Ie(0,5,10,15,e,n+2*a[o++]),je(0,5,10,15,e,n+2*a[o++]),Ie(1,6,11,12,e,n+2*a[o++]),je(1,6,11,12,e,n+2*a[o++]),Ie(2,7,8,13,e,n+2*a[o++]),je(2,7,8,13,e,n+2*a[o++]),Ie(3,4,9,14,e,n+2*a[o++]),je(3,4,9,14,e,n+2*a[o++]);this.v0l^=p[0]^p[16],this.v0h^=p[1]^p[17],this.v1l^=p[2]^p[18],this.v1h^=p[3]^p[19],this.v2l^=p[4]^p[20],this.v2h^=p[5]^p[21],this.v3l^=p[6]^p[22],this.v3h^=p[7]^p[23],this.v4l^=p[8]^p[24],this.v4h^=p[9]^p[25],this.v5l^=p[10]^p[26],this.v5h^=p[11]^p[27],this.v6l^=p[12]^p[28],this.v6h^=p[13]^p[29],this.v7l^=p[14]^p[30],this.v7h^=p[15]^p[31],sn(p)}destroy(){this.destroyed=!0,sn(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ba=oa(t=>new ma(t)),Yr=ba;function ya(t,e,n){const r=k.Address.serialize(t).toBytes(),s=k.TypeTag.serialize(e).toBytes(),i=k.u64().serialize(n.length).toBytes(),o=Yr.create({dkLen:32});return o.update(new Uint8Array([240])),o.update(r),o.update(i),o.update(n),o.update(s),`0x${Je(o.digest().slice(0,32))}`}const wa="object",va="ID",ka="ascii",Sa="String",Oa="string",Ea="String",Ta="option",Ia="Option";function ja(t){const e=typeof t.body=="object"&&"datatype"in t.body?t.body.datatype:null;return!!e&&S(e.package)===S("0x2")&&e.module==="tx_context"&&e.type==="TxContext"}function an(t){if(typeof t=="string")switch(t){case"address":return k.Address;case"bool":return k.Bool;case"u8":return k.U8;case"u16":return k.U16;case"u32":return k.U32;case"u64":return k.U64;case"u128":return k.U128;case"u256":return k.U256;default:throw new Error(`Unknown type signature ${t}`)}if("vector"in t){if(t.vector==="u8")return k.byteVector().transform({input:n=>typeof n=="string"?new TextEncoder().encode(n):n,output:n=>n});const e=an(t.vector);return e?k.vector(e):null}if("datatype"in t){const e=S(t.datatype.package);if(e===S(ea)){if(t.datatype.module===ka&&t.datatype.type===Sa||t.datatype.module===Oa&&t.datatype.type===Ea)return k.String;if(t.datatype.module===Ta&&t.datatype.type===Ia){const n=an(t.datatype.typeParameters[0]);return n?k.vector(n):null}}if(e===S(Wr)&&t.datatype.module===wa&&t.datatype.type===va)return k.Address}return null}function Ma(t){return typeof t=="object"&&"Reference"in t?{ref:"&",body:st(t.Reference)}:typeof t=="object"&&"MutableReference"in t?{ref:"&mut",body:st(t.MutableReference)}:{ref:null,body:st(t)}}function st(t){if(typeof t=="string")switch(t){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${t}`)}if("Vector"in t)return{vector:st(t.Vector)};if("Struct"in t)return{datatype:{package:t.Struct.address,module:t.Struct.module,type:t.Struct.name,typeParameters:t.Struct.typeArguments.map(st)}};if("TypeParameter"in t)return{typeParameter:t.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(t)}`)}function Ca(t){return{$kind:"Pure",Pure:{bytes:t instanceof Uint8Array?V(t):t.toBase64()}}}const de={Pure:Ca,ObjectRef({objectId:t,digest:e,version:n}){return{$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:e,version:n,objectId:S(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:n}){return{$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:e,initialSharedVersion:n,objectId:S(t)}}}},ReceivingRef({objectId:t,digest:e,version:n}){return{$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:e,version:n,objectId:S(t)}}}}};let we;function Qr(t){return{lang:(t==null?void 0:t.lang)??(we==null?void 0:we.lang),message:t==null?void 0:t.message,abortEarly:(t==null?void 0:t.abortEarly)??(we==null?void 0:we.abortEarly),abortPipeEarly:(t==null?void 0:t.abortPipeEarly)??(we==null?void 0:we.abortPipeEarly)}}let Ht;function Aa(t){return Ht==null?void 0:Ht.get(t)}let Jt;function _a(t){return Jt==null?void 0:Jt.get(t)}let Xt;function xa(t,e){var n;return(n=Xt==null?void 0:Xt.get(t))==null?void 0:n.get(e)}function es(t){var n,r;const e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&((r=(n=Object.getPrototypeOf(t))==null?void 0:n.constructor)==null?void 0:r.name))??"null":e}function H(t,e,n,r,s){const i=s&&"input"in s?s.input:n.value,o=(s==null?void 0:s.expected)??t.expects??null,a=(s==null?void 0:s.received)??es(i),u={kind:t.kind,type:t.type,input:i,expected:o,received:a,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${a}`,requirement:t.requirement,path:s==null?void 0:s.path,issues:s==null?void 0:s.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},d=t.kind==="schema",l=(s==null?void 0:s.message)??t.message??xa(t.reference,u.lang)??(d?_a(u.lang):null)??r.message??Aa(u.lang);l!==void 0&&(u.message=typeof l=="function"?l(u):l),d&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function z(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},Qr())}}}function $a(t,e){return Object.hasOwn(t,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function Pa(t,e){const n=[...new Set(t)];return n.length>1?`(${n.join(` ${e} `)})`:n[0]??"never"}var Ra=class extends Error{constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function jn(t,e){return{kind:"validation",type:"check",reference:jn,async:!1,expects:null,requirement:t,message:e,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&H(this,"input",n,r),n}}}function q(t){return{kind:"validation",type:"integer",reference:q,async:!1,expects:null,requirement:Number.isInteger,message:t,"~run"(e,n){return e.typed&&!this.requirement(e.value)&&H(this,"integer",e,n),e}}}function Vt(t){return{kind:"transformation",type:"transform",reference:Vt,async:!1,operation:t,"~run"(e){return e.value=this.operation(e.value),e}}}function Ba(t,e,n){return typeof t.fallback=="function"?t.fallback(e,n):t.fallback}function zt(t,e,n){return typeof t.default=="function"?t.default(e,n):t.default}function on(t,e){return!t["~run"]({value:e},{abortEarly:!0}).issues}function O(t,e){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return z(this)},"~run"(n,r){var i;const s=n.value;if(Array.isArray(s)){n.typed=!0,n.value=[];for(let o=0;o<s.length;o++){const a=s[o],u=this.item["~run"]({value:a},r);if(u.issues){const d={type:"array",origin:"value",input:s,key:o,value:a};for(const l of u.issues)l.path?l.path.unshift(d):l.path=[d],(i=n.issues)==null||i.push(l);if(n.issues||(n.issues=u.issues),r.abortEarly){n.typed=!1;break}}u.typed||(n.typed=!1),n.value.push(u.value)}}else H(this,"type",n,r);return n}}}function ts(t){return{kind:"schema",type:"bigint",reference:ts,expects:"bigint",async:!1,message:t,get"~standard"(){return z(this)},"~run"(e,n){return typeof e.value=="bigint"?e.typed=!0:H(this,"type",e,n),e}}}function Xe(t){return{kind:"schema",type:"boolean",reference:Xe,expects:"boolean",async:!1,message:t,get"~standard"(){return z(this)},"~run"(e,n){return typeof e.value=="boolean"?e.typed=!0:H(this,"type",e,n),e}}}function cn(t){return{kind:"schema",type:"lazy",reference:cn,expects:"unknown",async:!1,getter:t,get"~standard"(){return z(this)},"~run"(e,n){return this.getter(e.value)["~run"](e,n)}}}function P(t,e){return{kind:"schema",type:"literal",reference:P,expects:es(t),async:!1,literal:t,message:e,get"~standard"(){return z(this)},"~run"(n,r){return n.value===this.literal?n.typed=!0:H(this,"type",n,r),n}}}function A(t,e){return{kind:"schema",type:"nullable",reference:A,expects:`(${t.expects} | null)`,async:!1,wrapped:t,default:e,get"~standard"(){return z(this)},"~run"(n,r){return n.value===null&&(this.default!==void 0&&(n.value=zt(this,n,r)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function lt(t,e){return{kind:"schema",type:"nullish",reference:lt,expects:`(${t.expects} | null | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return z(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=zt(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function K(t){return{kind:"schema",type:"number",reference:K,expects:"number",async:!1,message:t,get"~standard"(){return z(this)},"~run"(e,n){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:H(this,"type",e,n),e}}}function w(t,e){return{kind:"schema",type:"object",reference:w,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return z(this)},"~run"(n,r){var i;const s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(const o in this.entries){const a=this.entries[o];if(o in s||(a.type==="exact_optional"||a.type==="optional"||a.type==="nullish")&&a.default!==void 0){const u=o in s?s[o]:zt(a),d=a["~run"]({value:u},r);if(d.issues){const l={type:"object",origin:"value",input:s,key:o,value:u};for(const h of d.issues)h.path?h.path.unshift(l):h.path=[l],(i=n.issues)==null||i.push(h);if(n.issues||(n.issues=d.issues),r.abortEarly){n.typed=!1;break}}d.typed||(n.typed=!1),n.value[o]=d.value}else if(a.fallback!==void 0)n.value[o]=Ba(a);else if(a.type!=="exact_optional"&&a.type!=="optional"&&a.type!=="nullish"&&(H(this,"key",n,r,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),r.abortEarly))break}}else H(this,"type",n,r);return n}}}function Q(t,e){return{kind:"schema",type:"optional",reference:Q,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return z(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=zt(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function dt(t,e,n){return{kind:"schema",type:"record",reference:dt,expects:"Object",async:!1,key:t,value:e,message:n,get"~standard"(){return z(this)},"~run"(r,s){var o,a;const i=r.value;if(i&&typeof i=="object"){r.typed=!0,r.value={};for(const u in i)if($a(i,u)){const d=i[u],l=this.key["~run"]({value:u},s);if(l.issues){const m={type:"object",origin:"key",input:i,key:u,value:d};for(const b of l.issues)b.path=[m],(o=r.issues)==null||o.push(b);if(r.issues||(r.issues=l.issues),s.abortEarly){r.typed=!1;break}}const h=this.value["~run"]({value:d},s);if(h.issues){const m={type:"object",origin:"value",input:i,key:u,value:d};for(const b of h.issues)b.path?b.path.unshift(m):b.path=[m],(a=r.issues)==null||a.push(b);if(r.issues||(r.issues=h.issues),s.abortEarly){r.typed=!1;break}}(!l.typed||!h.typed)&&(r.typed=!1),l.typed&&(r.value[l.value]=h.value)}}else H(this,"type",r,s);return r}}}function E(t){return{kind:"schema",type:"string",reference:E,expects:"string",async:!1,message:t,get"~standard"(){return z(this)},"~run"(e,n){return typeof e.value=="string"?e.typed=!0:H(this,"type",e,n),e}}}function Mn(t,e){return{kind:"schema",type:"tuple",reference:Mn,expects:"Array",async:!1,items:t,message:e,get"~standard"(){return z(this)},"~run"(n,r){var i;const s=n.value;if(Array.isArray(s)){n.typed=!0,n.value=[];for(let o=0;o<this.items.length;o++){const a=s[o],u=this.items[o]["~run"]({value:a},r);if(u.issues){const d={type:"array",origin:"value",input:s,key:o,value:a};for(const l of u.issues)l.path?l.path.unshift(d):l.path=[d],(i=n.issues)==null||i.push(l);if(n.issues||(n.issues=u.issues),r.abortEarly){n.typed=!1;break}}u.typed||(n.typed=!1),n.value.push(u.value)}}else H(this,"type",n,r);return n}}}function Wn(t){let e;if(t)for(const n of t)e?e.push(...n.issues):e=n.issues;return e}function ye(t,e){return{kind:"schema",type:"union",reference:ye,expects:Pa(t.map(n=>n.expects),"|"),async:!1,options:t,message:e,get"~standard"(){return z(this)},"~run"(n,r){let s,i,o;for(const a of this.options){const u=a["~run"]({value:n.value},r);if(u.typed)if(u.issues)i?i.push(u):i=[u];else{s=u;break}else o?o.push(u):o=[u]}if(s)return s;if(i){if(i.length===1)return i[0];H(this,"type",n,r,{issues:Wn(i)}),n.typed=!0}else{if((o==null?void 0:o.length)===1)return o[0];H(this,"type",n,r,{issues:Wn(o)})}return n}}}function gt(){return{kind:"schema",type:"unknown",reference:gt,expects:"unknown",async:!1,get"~standard"(){return z(this)},"~run"(t){return t.typed=!0,t}}}function C(t,e,n){const r=t["~run"]({value:e},Qr(n));if(r.issues)throw new Ra(r.issues);return r.value}function U(...t){return{...t[0],pipe:t,get"~standard"(){return z(this)},"~run"(e,n){for(const r of t)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!n.abortEarly&&!n.abortPipeEarly)&&(e=r["~run"](e,n))}return e}}}function We(t){const e=Object.entries(t).map(([n,r])=>w({[n]:r}));return U(ye(e),Vt(n=>({...n,$kind:Object.keys(n)[0]})))}const Ze=U(E(),Vt(t=>S(t)),jn(ae)),te=Ze,Fe=E(),J=U(ye([E(),U(K(),q())]),jn(t=>{try{return BigInt(t),BigInt(t)>=0&&BigInt(t)<=18446744073709551615n}catch{return!1}},"Invalid u64")),$e=w({objectId:Ze,version:J,digest:E()}),I=U(ye([w({GasCoin:P(!0)}),w({Input:U(K(),q()),type:Q(P("pure"))}),w({Input:U(K(),q()),type:Q(P("object"))}),w({Result:U(K(),q())}),w({NestedResult:Mn([U(K(),q()),U(K(),q())])})]),Vt(t=>({...t,$kind:Object.keys(t)[0]}))),Ua=w({budget:A(J),price:A(J),owner:A(Ze),payment:A(O($e))}),un=ye([P("address"),P("bool"),P("u8"),P("u16"),P("u32"),P("u64"),P("u128"),P("u256"),w({vector:cn(()=>un)}),w({datatype:w({package:E(),module:E(),type:E(),typeParameters:O(cn(()=>un))})}),w({typeParameter:U(K(),q())})]),Na=w({ref:A(ye([P("&"),P("&mut")])),body:un}),Da=w({package:te,module:E(),function:E(),typeArguments:O(E()),arguments:O(I),_argumentTypes:Q(A(O(Na)))}),Va=w({name:E(),inputs:dt(E(),ye([I,O(I)])),data:dt(E(),gt())}),za=We({MoveCall:Da,TransferObjects:w({objects:O(I),address:I}),SplitCoins:w({coin:I,amounts:O(I)}),MergeCoins:w({destination:I,sources:O(I)}),Publish:w({modules:O(Fe),dependencies:O(te)}),MakeMoveVec:w({type:A(E()),elements:O(I)}),Upgrade:w({modules:O(Fe),dependencies:O(te),package:te,ticket:I}),$Intent:Va}),ns=We({ImmOrOwnedObject:$e,SharedObject:w({objectId:te,initialSharedVersion:J,mutable:Xe()}),Receiving:$e}),La=We({Object:ns,Pure:w({bytes:Fe}),UnresolvedPure:w({value:gt()}),UnresolvedObject:w({objectId:te,version:Q(A(J)),digest:Q(A(E())),initialSharedVersion:Q(A(J)),mutable:Q(A(Xe()))})}),Gn=We({Object:ns,Pure:w({bytes:Fe})}),rs=We({None:P(!0),Epoch:J}),Et=w({version:P(2),sender:lt(Ze),expiration:lt(rs),gasData:Ua,inputs:O(La),commands:O(za)}),Pe={MoveCall(t){const[e,n="",r=""]="target"in t?t.target.split("::"):[t.package,t.module,t.function];return{$kind:"MoveCall",MoveCall:{package:e,module:n,function:r,typeArguments:t.typeArguments??[],arguments:t.arguments??[]}}},TransferObjects(t,e){return{$kind:"TransferObjects",TransferObjects:{objects:t.map(n=>C(I,n)),address:C(I,e)}}},SplitCoins(t,e){return{$kind:"SplitCoins",SplitCoins:{coin:C(I,t),amounts:e.map(n=>C(I,n))}}},MergeCoins(t,e){return{$kind:"MergeCoins",MergeCoins:{destination:C(I,t),sources:e.map(n=>C(I,n))}}},Publish({modules:t,dependencies:e}){return{$kind:"Publish",Publish:{modules:t.map(n=>typeof n=="string"?n:V(new Uint8Array(n))),dependencies:e.map(n=>ge(n))}}},Upgrade({modules:t,dependencies:e,package:n,ticket:r}){return{$kind:"Upgrade",Upgrade:{modules:t.map(s=>typeof s=="string"?s:V(new Uint8Array(s))),dependencies:e.map(s=>ge(s)),package:n,ticket:C(I,r)}}},MakeMoveVec({type:t,elements:e}){return{$kind:"MakeMoveVec",MakeMoveVec:{type:t??null,elements:e.map(n=>C(I,n))}}},Intent({name:t,inputs:e={},data:n={}}){return{$kind:"$Intent",$Intent:{name:t,inputs:Object.fromEntries(Object.entries(e).map(([r,s])=>[r,Array.isArray(s)?s.map(i=>C(I,i)):C(I,s)])),data:n}}}},qn=w({digest:E(),objectId:E(),version:ye([U(K(),q()),E(),ts()])}),Fa=We({ImmOrOwned:qn,Shared:w({objectId:te,initialSharedVersion:J,mutable:Xe()}),Receiving:qn}),Kn=We({Object:Fa,Pure:O(U(K(),q()))});function Hn(t){var n;const e=t.inputs.map((r,s)=>{if(r.Object)return{kind:"Input",index:s,value:{Object:r.Object.ImmOrOwnedObject?{ImmOrOwned:r.Object.ImmOrOwnedObject}:r.Object.Receiving?{Receiving:{digest:r.Object.Receiving.digest,version:r.Object.Receiving.version,objectId:r.Object.Receiving.objectId}}:{Shared:{mutable:r.Object.SharedObject.mutable,initialSharedVersion:r.Object.SharedObject.initialSharedVersion,objectId:r.Object.SharedObject.objectId}}},type:"object"};if(r.Pure)return{kind:"Input",index:s,value:{Pure:Array.from(ee(r.Pure.bytes))},type:"pure"};if(r.UnresolvedPure)return{kind:"Input",type:"pure",index:s,value:r.UnresolvedPure.value};if(r.UnresolvedObject)return{kind:"Input",type:"object",index:s,value:r.UnresolvedObject.objectId};throw new Error("Invalid input")});return{version:1,sender:t.sender??void 0,expiration:((n=t.expiration)==null?void 0:n.$kind)==="Epoch"?{Epoch:Number(t.expiration.Epoch)}:t.expiration?{None:!0}:null,gasConfig:{owner:t.gasData.owner??void 0,budget:t.gasData.budget??void 0,price:t.gasData.price??void 0,payment:t.gasData.payment??void 0},inputs:e,transactions:t.commands.map(r=>{if(r.MakeMoveVec)return{kind:"MakeMoveVec",type:r.MakeMoveVec.type===null?{None:!0}:{Some:ce.parseFromStr(r.MakeMoveVec.type)},objects:r.MakeMoveVec.elements.map(s=>ve(s,e))};if(r.MergeCoins)return{kind:"MergeCoins",destination:ve(r.MergeCoins.destination,e),sources:r.MergeCoins.sources.map(s=>ve(s,e))};if(r.MoveCall)return{kind:"MoveCall",target:`${r.MoveCall.package}::${r.MoveCall.module}::${r.MoveCall.function}`,typeArguments:r.MoveCall.typeArguments,arguments:r.MoveCall.arguments.map(s=>ve(s,e))};if(r.Publish)return{kind:"Publish",modules:r.Publish.modules.map(s=>Array.from(ee(s))),dependencies:r.Publish.dependencies};if(r.SplitCoins)return{kind:"SplitCoins",coin:ve(r.SplitCoins.coin,e),amounts:r.SplitCoins.amounts.map(s=>ve(s,e))};if(r.TransferObjects)return{kind:"TransferObjects",objects:r.TransferObjects.objects.map(s=>ve(s,e)),address:ve(r.TransferObjects.address,e)};if(r.Upgrade)return{kind:"Upgrade",modules:r.Upgrade.modules.map(s=>Array.from(ee(s))),dependencies:r.Upgrade.dependencies,packageId:r.Upgrade.package,ticket:ve(r.Upgrade.ticket,e)};throw new Error(`Unknown transaction ${Object.keys(r)}`)})}}function ve(t,e){if(t.$kind==="GasCoin")return{kind:"GasCoin"};if(t.$kind==="Result")return{kind:"Result",index:t.Result};if(t.$kind==="NestedResult")return{kind:"NestedResult",index:t.NestedResult[0],resultIndex:t.NestedResult[1]};if(t.$kind==="Input")return e[t.Input];throw new Error(`Invalid argument ${Object.keys(t)}`)}function Wa(t){var e,n,r;return C(Et,{version:2,sender:t.sender??null,expiration:t.expiration?"Epoch"in t.expiration?{Epoch:t.expiration.Epoch}:{None:!0}:null,gasData:{owner:t.gasConfig.owner??null,budget:((e=t.gasConfig.budget)==null?void 0:e.toString())??null,price:((n=t.gasConfig.price)==null?void 0:n.toString())??null,payment:((r=t.gasConfig.payment)==null?void 0:r.map(s=>({digest:s.digest,objectId:s.objectId,version:s.version.toString()})))??null},inputs:t.inputs.map(s=>{if(s.kind==="Input"){if(on(Kn,s.value)){const i=C(Kn,s.value);if(i.Object){if(i.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:i.Object.ImmOrOwned.objectId,version:String(i.Object.ImmOrOwned.version),digest:i.Object.ImmOrOwned.digest}}};if(i.Object.Shared)return{Object:{SharedObject:{mutable:i.Object.Shared.mutable??null,initialSharedVersion:i.Object.Shared.initialSharedVersion,objectId:i.Object.Shared.objectId}}};if(i.Object.Receiving)return{Object:{Receiving:{digest:i.Object.Receiving.digest,version:String(i.Object.Receiving.version),objectId:i.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:V(new Uint8Array(i.Pure))}}}return s.type==="object"?{UnresolvedObject:{objectId:s.value}}:{UnresolvedPure:{value:s.value}}}throw new Error("Invalid input")}),commands:t.transactions.map(s=>{switch(s.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in s.type?ce.tagToString(s.type.Some):null,elements:s.objects.map(i=>ke(i))}};case"MergeCoins":return{MergeCoins:{destination:ke(s.destination),sources:s.sources.map(i=>ke(i))}};case"MoveCall":{const[i,o,a]=s.target.split("::");return{MoveCall:{package:i,module:o,function:a,typeArguments:s.typeArguments,arguments:s.arguments.map(u=>ke(u))}}}case"Publish":return{Publish:{modules:s.modules.map(i=>V(Uint8Array.from(i))),dependencies:s.dependencies}};case"SplitCoins":return{SplitCoins:{coin:ke(s.coin),amounts:s.amounts.map(i=>ke(i))}};case"TransferObjects":return{TransferObjects:{objects:s.objects.map(i=>ke(i)),address:ke(s.address)}};case"Upgrade":return{Upgrade:{modules:s.modules.map(i=>V(Uint8Array.from(i))),dependencies:s.dependencies,package:s.packageId,ticket:ke(s.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(s)}`)})})}function ke(t){switch(t.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:t.index};case"NestedResult":return{NestedResult:[t.index,t.resultIndex]};case"Input":return{Input:t.index}}}function mt(t){return ye(Object.entries(t).map(([e,n])=>w({[e]:n})))}const se=mt({GasCoin:P(!0),Input:U(K(),q()),Result:U(K(),q()),NestedResult:Mn([U(K(),q()),U(K(),q())])}),Ga=w({budget:A(J),price:A(J),owner:A(Ze),payment:A(O($e))}),qa=w({package:te,module:E(),function:E(),typeArguments:O(E()),arguments:O(se)}),Ka=w({name:E(),inputs:dt(E(),ye([se,O(se)])),data:dt(E(),gt())}),Ha=mt({MoveCall:qa,TransferObjects:w({objects:O(se),address:se}),SplitCoins:w({coin:se,amounts:O(se)}),MergeCoins:w({destination:se,sources:O(se)}),Publish:w({modules:O(Fe),dependencies:O(te)}),MakeMoveVec:w({type:A(E()),elements:O(se)}),Upgrade:w({modules:O(Fe),dependencies:O(te),package:te,ticket:se}),$Intent:Ka}),Ja=mt({ImmOrOwnedObject:$e,SharedObject:w({objectId:te,initialSharedVersion:J,mutable:Xe()}),Receiving:$e}),Xa=mt({Object:Ja,Pure:w({bytes:Fe}),UnresolvedPure:w({value:gt()}),UnresolvedObject:w({objectId:te,version:Q(A(J)),digest:Q(A(E())),initialSharedVersion:Q(A(J)),mutable:Q(A(Xe()))})}),Za=mt({None:P(!0),Epoch:J}),Ya=w({version:P(2),sender:lt(Ze),expiration:lt(Za),gasData:Ga,inputs:O(Xa),commands:O(Ha),digest:Q(A(E()))});function Lt(t,e){return Array.from({length:Math.ceil(t.length/e)},(n,r)=>t.slice(r*e,(r+1)*e))}class ss{constructor(e,n){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=no(n),this._batchScheduleFn=ro(n),this._cacheKeyFn=so(n),this._cacheMap=io(n),this._batch=null,this.name=ao(n)}load(e){if(e==null)throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(e)}.`);const n=eo(this),r=this._cacheMap;let s;if(r){s=this._cacheKeyFn(e);const o=r.get(s);if(o){const a=n.cacheHits||(n.cacheHits=[]);return new Promise(u=>{a.push(()=>{u(o)})})}}n.keys.push(e);const i=new Promise((o,a)=>{n.callbacks.push({resolve:o,reject:a})});return r&&r.set(s,i),i}loadMany(e){if(!is(e))throw new TypeError(`The loader.loadMany() function must be called with Array<key>, but got: ${e}.`);const n=[];for(let r=0;r<e.length;r++)n.push(this.load(e[r]).catch(s=>s));return Promise.all(n)}clear(e){const n=this._cacheMap;if(n){const r=this._cacheKeyFn(e);n.delete(r)}return this}clearAll(){const e=this._cacheMap;return e&&e.clear(),this}prime(e,n){const r=this._cacheMap;if(r){const s=this._cacheKeyFn(e);if(r.get(s)===void 0){let i;n instanceof Error?(i=Promise.reject(n),i.catch(()=>{})):i=Promise.resolve(n),r.set(s,i)}}return this}}const Qa=typeof process=="object"&&typeof process.nextTick=="function"?function(t){Zt||(Zt=Promise.resolve()),Zt.then(()=>{process.nextTick(t)})}:typeof setImmediate=="function"?function(t){setImmediate(t)}:function(t){setTimeout(t)};let Zt;function eo(t){const e=t._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<t._maxBatchSize)return e;const n={hasDispatched:!1,keys:[],callbacks:[]};return t._batch=n,t._batchScheduleFn(()=>{to(t,n)}),n}function to(t,e){if(e.hasDispatched=!0,e.keys.length===0){ln(e);return}let n;try{n=t._batchLoadFn(e.keys)}catch(r){return Yt(t,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(r)}.`))}if(!n||typeof n.then!="function")return Yt(t,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(n)}.`));Promise.resolve(n).then(r=>{if(!is(r))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(r)}.`);if(r.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.
|
|
2
2
|
|
|
3
3
|
Keys:
|
|
4
4
|
${String(e.keys)}
|
package/dist/index.js
CHANGED
|
@@ -33,13 +33,13 @@ const Us = {
|
|
|
33
33
|
mint: {
|
|
34
34
|
target: (
|
|
35
35
|
// lbtc_v2_current
|
|
36
|
-
"
|
|
36
|
+
"0x1269ce3b46b5647d0e46024185dd24bdb7492ec7840ebc40fdd209150b89a33d::treasury::mint_v2"
|
|
37
37
|
),
|
|
38
38
|
denyList: "0x403"
|
|
39
39
|
},
|
|
40
40
|
redeem: {
|
|
41
41
|
// lbtc_v2_current
|
|
42
|
-
target: "
|
|
42
|
+
target: "0x1269ce3b46b5647d0e46024185dd24bdb7492ec7840ebc40fdd209150b89a33d::treasury::redeem"
|
|
43
43
|
},
|
|
44
44
|
// lbtc_v1_deprecated - This is intentional
|
|
45
45
|
LBTC: "0x2d66430a27565b912f21be970e5ae1e8c0359f0b518c3235b751c75976791ce0::lbtc::LBTC",
|
|
@@ -5567,7 +5567,10 @@ async function Uo({
|
|
|
5567
5567
|
amount: i,
|
|
5568
5568
|
coinType: a.LBTC
|
|
5569
5569
|
}), v = Array.from(
|
|
5570
|
-
Buffer.from(
|
|
5570
|
+
Buffer.from(
|
|
5571
|
+
(await Bs(s, o)).replace(/^0x/, ""),
|
|
5572
|
+
"hex"
|
|
5573
|
+
)
|
|
5571
5574
|
);
|
|
5572
5575
|
if (b.moveCall({
|
|
5573
5576
|
target: a.redeem.target,
|
package/package.json
CHANGED
package/src/common/parameters.ts
CHANGED
|
@@ -9,8 +9,9 @@ type EnvParameter = {
|
|
|
9
9
|
env?: Env;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export interface CommonWriteParameters<
|
|
13
|
-
extends
|
|
12
|
+
export interface CommonWriteParameters<
|
|
13
|
+
WF extends Wallet['features'],
|
|
14
|
+
> extends EnvParameter {
|
|
14
15
|
walletClient: WalletWithFeatures<WF>;
|
|
15
16
|
account: WalletAccount;
|
|
16
17
|
}
|
package/src/const/getConfig.ts
CHANGED
|
@@ -19,13 +19,13 @@ const stageConfig: IConfig = {
|
|
|
19
19
|
mint: {
|
|
20
20
|
target:
|
|
21
21
|
// lbtc_v2_current
|
|
22
|
-
'
|
|
22
|
+
'0x1269ce3b46b5647d0e46024185dd24bdb7492ec7840ebc40fdd209150b89a33d::treasury::mint_v2',
|
|
23
23
|
denyList: '0x403',
|
|
24
24
|
},
|
|
25
25
|
redeem: {
|
|
26
26
|
// lbtc_v2_current
|
|
27
27
|
target:
|
|
28
|
-
'
|
|
28
|
+
'0x1269ce3b46b5647d0e46024185dd24bdb7492ec7840ebc40fdd209150b89a33d::treasury::redeem',
|
|
29
29
|
},
|
|
30
30
|
// lbtc_v1_deprecated - This is intentional
|
|
31
31
|
LBTC: '0x2d66430a27565b912f21be970e5ae1e8c0359f0b518c3235b751c75976791ce0::lbtc::LBTC',
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { Env, SuiService } from '@lombard.finance/sdk-common';
|
|
10
|
-
import { getFullnodeUrl,SuiClient } from '@mysten/sui/client';
|
|
10
|
+
import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
|
|
11
11
|
import type {
|
|
12
12
|
SuiChain,
|
|
13
13
|
SuiSignPersonalMessageFeature,
|
|
@@ -28,7 +28,8 @@ type ProviderResolver = () => Promise<unknown>;
|
|
|
28
28
|
/**
|
|
29
29
|
* Sui wallet features required for signing and transactions
|
|
30
30
|
*/
|
|
31
|
-
type SuiWalletFeatures = SuiSignPersonalMessageFeature &
|
|
31
|
+
type SuiWalletFeatures = SuiSignPersonalMessageFeature &
|
|
32
|
+
SuiSignTransactionFeature;
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Sui wallet provider interface
|
|
@@ -41,7 +42,9 @@ interface SuiWalletProvider {
|
|
|
41
42
|
/**
|
|
42
43
|
* Get Sui network from chain ID
|
|
43
44
|
*/
|
|
44
|
-
function getSuiNetworkFromChainId(
|
|
45
|
+
function getSuiNetworkFromChainId(
|
|
46
|
+
chainId: string,
|
|
47
|
+
): 'mainnet' | 'testnet' | 'devnet' {
|
|
45
48
|
if (chainId.includes('mainnet')) return 'mainnet';
|
|
46
49
|
if (chainId.includes('testnet')) return 'testnet';
|
|
47
50
|
return 'devnet';
|
|
@@ -34,9 +34,7 @@ export async function prepareCoinsTransaction({
|
|
|
34
34
|
const decimals = coinMetadata?.decimals ?? LBTC_DECIMALS;
|
|
35
35
|
|
|
36
36
|
const unstakeAmount = BigInt(
|
|
37
|
-
amount
|
|
38
|
-
.multipliedBy(new BigNumber(10).pow(decimals))
|
|
39
|
-
.toString(10),
|
|
37
|
+
amount.multipliedBy(new BigNumber(10).pow(decimals)).toString(10),
|
|
40
38
|
);
|
|
41
39
|
|
|
42
40
|
const selectedCoins = [] as CoinStruct[];
|
|
@@ -49,7 +47,7 @@ export async function prepareCoinsTransaction({
|
|
|
49
47
|
} else if (selectedAmount + BigInt(coin.balance) === unstakeAmount) {
|
|
50
48
|
selectedCoins.push(coin);
|
|
51
49
|
|
|
52
|
-
const coinObjects = selectedCoins.map(coin =>
|
|
50
|
+
const coinObjects = selectedCoins.map((coin) =>
|
|
53
51
|
transaction.object(coin.coinObjectId),
|
|
54
52
|
);
|
|
55
53
|
|
|
@@ -73,7 +71,7 @@ export async function prepareCoinsTransaction({
|
|
|
73
71
|
|
|
74
72
|
transaction.mergeCoins(
|
|
75
73
|
splitCoin,
|
|
76
|
-
selectedCoins.map(coin => transaction.object(coin.coinObjectId)),
|
|
74
|
+
selectedCoins.map((coin) => transaction.object(coin.coinObjectId)),
|
|
77
75
|
);
|
|
78
76
|
|
|
79
77
|
return transaction.object(splitCoin);
|
|
@@ -30,16 +30,18 @@ const WALLETS_FORCE_V1 = ['OKX Wallet', 'OKX'];
|
|
|
30
30
|
* Check if we should force V1 for this wallet.
|
|
31
31
|
* Some wallets advertise V2 support but don't properly handle the new Transaction class.
|
|
32
32
|
*/
|
|
33
|
-
function shouldForceV1(
|
|
33
|
+
function shouldForceV1(
|
|
34
|
+
wallet: WalletWithFeatures<SuiSignTransactionFeature>,
|
|
35
|
+
): boolean {
|
|
34
36
|
const walletName = wallet.name || '';
|
|
35
|
-
return WALLETS_FORCE_V1.some(name =>
|
|
36
|
-
walletName.toLowerCase().includes(name.toLowerCase())
|
|
37
|
+
return WALLETS_FORCE_V1.some((name) =>
|
|
38
|
+
walletName.toLowerCase().includes(name.toLowerCase()),
|
|
37
39
|
);
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* Unstake LBTC.
|
|
42
|
-
*
|
|
44
|
+
*
|
|
43
45
|
* Supports both new (sui:signTransaction) and old (sui:signTransactionBlock) wallet interfaces.
|
|
44
46
|
* Some wallets (like OKX) advertise V2 support but fail with the new Transaction class,
|
|
45
47
|
* so we force V1 for known problematic wallets.
|
|
@@ -58,11 +60,11 @@ export async function unstakeLBTC({
|
|
|
58
60
|
// Cast to any to access both V1 and V2 features
|
|
59
61
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
62
|
const walletFeatures = (wallet as any).features || {};
|
|
61
|
-
|
|
63
|
+
|
|
62
64
|
const walletHasV2 = !!walletFeatures[SIGN_TRANSACTION_V2_FEATURE];
|
|
63
65
|
const walletHasV1 = !!walletFeatures[SIGN_TRANSACTION_V1_FEATURE];
|
|
64
66
|
const forceV1 = shouldForceV1(wallet);
|
|
65
|
-
|
|
67
|
+
|
|
66
68
|
// Use V2 only if available AND wallet is not in the force-V1 list
|
|
67
69
|
const useV2 = walletHasV2 && !forceV1;
|
|
68
70
|
|
|
@@ -75,7 +77,10 @@ export async function unstakeLBTC({
|
|
|
75
77
|
});
|
|
76
78
|
|
|
77
79
|
const scriptPubKey = Array.from(
|
|
78
|
-
Buffer.from(
|
|
80
|
+
Buffer.from(
|
|
81
|
+
(await getOutputScript(btcAddress, env)).replace(/^0x/, ''),
|
|
82
|
+
'hex',
|
|
83
|
+
),
|
|
79
84
|
);
|
|
80
85
|
|
|
81
86
|
transaction.moveCall({
|
|
@@ -114,7 +119,9 @@ export async function unstakeLBTC({
|
|
|
114
119
|
// Use V1 signTransactionBlock (OKX, and other wallets with V2 issues)
|
|
115
120
|
transaction.setSender(walletAccount.address);
|
|
116
121
|
|
|
117
|
-
const signedTransaction = await walletFeatures[
|
|
122
|
+
const signedTransaction = await walletFeatures[
|
|
123
|
+
SIGN_TRANSACTION_V1_FEATURE
|
|
124
|
+
].signTransactionBlock({
|
|
118
125
|
chain: chainId,
|
|
119
126
|
transactionBlock: transaction,
|
|
120
127
|
account: walletAccount,
|