@wormhole-foundation/wormhole-connect 1.1.4-beta.2-development → 1.1.4
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/assets/{ccip-BNTHR_fq.js → ccip-DBKRHOzw.js} +1 -1
- package/dist/assets/{evm-BxXdWj24.js → evm-Ch2OAEjY.js} +4 -4
- package/dist/assets/{index-C2FPBPlV.js → index-6KD-Rsq-.js} +1 -1
- package/dist/assets/{index-nosdUF9i.js → index-CBRIB26U.js} +1 -1
- package/dist/assets/index-CqrwXT8q.js +2 -0
- package/dist/assets/{index.es--WISYjTj.js → index.es-BslALnP8.js} +2 -2
- package/dist/main.js +3 -3
- package/lib/{algorand-BfdC8LMm.mjs → algorand-DGFW1DOS.mjs} +7 -7
- package/lib/{algorand-B9Pcx34H.js → algorand-HCN4Bwfj.js} +1 -1
- package/lib/{aptos-DISEuAM4.mjs → aptos-Bbj6gw3L.mjs} +3 -3
- package/lib/{aptos-CuQYjxz4.mjs → aptos-CxTUUDke.mjs} +1 -1
- package/lib/{aptos-DlboPucS.js → aptos-DdgS7gP0.js} +2 -2
- package/lib/{aptos-D8msRZYc.js → aptos-rub8tun1.js} +1 -1
- package/lib/{ccip-BqkngZ6V.js → ccip-CSnIIYMU.js} +1 -1
- package/lib/{ccip-DV1T5CQz.mjs → ccip-DSfOJChg.mjs} +1 -1
- package/lib/{cosmwasm-D3ZKcsjq.js → cosmwasm-DEP08WU-.js} +4 -4
- package/lib/{cosmwasm-BFPK6deV.mjs → cosmwasm-DY1PMAJO.mjs} +10 -10
- package/lib/{events-CaIL5tL1.mjs → events-BZxm5jrM.mjs} +1 -1
- package/lib/{events-Cxw8aBUy.js → events-BozeIuDx.js} +1 -1
- package/lib/{evm-7idwo4la.mjs → evm-4DQ--w0X.mjs} +14 -14
- package/lib/{evm-UrRoO3lT.js → evm-5GsdcG4A.js} +1 -1
- package/lib/{evm-D12EHZXD.js → evm-BdikZZsP.js} +4 -4
- package/lib/{evm-D11YbeC_.mjs → evm-mqOA6aXy.mjs} +7 -7
- package/lib/{index-Cs8OaRdq.mjs → index-1U60lnae.mjs} +2 -2
- package/lib/{index-BkUc_QzZ.mjs → index-B-TRMIWs.mjs} +2 -2
- package/lib/{index-IwSEAKjs.mjs → index-B4RQFL8S.mjs} +3 -3
- package/lib/{index-Dh6mkRtz.js → index-B5r3vRTo.js} +92 -92
- package/lib/{index-Cg6LDJti.js → index-B7VunQ0V.js} +1 -1
- package/lib/{index-ClI_55nW.mjs → index-BBMlYvye.mjs} +8 -8
- package/lib/{index-Cfupv0rQ.mjs → index-BDvIwkuQ.mjs} +4 -4
- package/lib/{index-DjZ438HP.js → index-BDvsOJDF.js} +1 -1
- package/lib/{index-Cg19mcso.mjs → index-BMH6cJU8.mjs} +21 -21
- package/lib/{index-D4FfgE9k.mjs → index-BO-4Mtu6.mjs} +8 -8
- package/lib/{index-DgKyQSTc.js → index-BUmDz7gJ.js} +1 -1
- package/lib/{index-C6ww0FoG.js → index-BUsKmixx.js} +1 -1
- package/lib/{index-f6MztC_k.mjs → index-BaZ9ZXQ8.mjs} +11 -11
- package/lib/{index-xTifobUX.js → index-Bb4id6Q5.js} +1 -1
- package/lib/{index-Vouac_sN.js → index-Bdh7euLM.js} +1 -1
- package/lib/{index-yYbCizsj.js → index-BkwLjtPG.js} +1 -1
- package/lib/{index-DlXF_HRr.mjs → index-BxyQAGp1.mjs} +8 -8
- package/lib/{index-B-m7_r9W.js → index-CCrop6yd.js} +1 -1
- package/lib/{index-BKeG3u48.mjs → index-CFG8Auhr.mjs} +2 -2
- package/lib/{index-COW9BRyV.js → index-CJ4fqgIk.js} +1 -1
- package/lib/{index-s_6sncui.js → index-CLt3mTc2.js} +1 -1
- package/lib/{index-CBnSdTOm.mjs → index-CNq6iUaG.mjs} +5 -5
- package/lib/{index-DsMw6BFg.js → index-CNuaRHT9.js} +1 -1
- package/lib/{index-CJ8hOjdz.js → index-CSPGgVcz.js} +1 -1
- package/lib/{index-BQI2oZiv.js → index-Cgo4GYxn.js} +1 -1
- package/lib/{index-CDGkVXf1.mjs → index-CmUgRfB1.mjs} +2 -2
- package/lib/{index-Br_1eyUd.js → index-CpWbXdKl.js} +1 -1
- package/lib/{index-C1KUJpQh.mjs → index-CscLQMzV.mjs} +25 -25
- package/lib/{index-BEfsEC8g.mjs → index-D1fzB2pJ.mjs} +3 -3
- package/lib/{index-ClbyJuae.mjs → index-D3zV2OEX.mjs} +2 -2
- package/lib/index-DHSWeh-m.js +1 -0
- package/lib/{index-CeK6G0Jr.mjs → index-DIbdsPe6.mjs} +14 -14
- package/lib/{index-BUGIe9Q0.mjs → index-DN-MKi_Z.mjs} +4 -4
- package/lib/{index-CHGr1Xo0.js → index-DQPvaPS5.js} +1 -1
- package/lib/{index-BMsGsrRe.js → index-DRWMrzIU.js} +1 -1
- package/lib/{index-BMLK3kVY.js → index-DZ9CJGGU.js} +1 -1
- package/lib/{index-BPD6tZ5I.mjs → index-DgePBEwv.mjs} +19149 -19146
- package/lib/{index-vmVyLCAM.mjs → index-Dlnoph5j.mjs} +33 -33
- package/lib/{index-CGqBKzB5.js → index-Dly2vaRA.js} +1 -1
- package/lib/{index-D9Ezmk4f.js → index-DpzMnf-Z.js} +1 -1
- package/lib/{index-GKdJmpc9.mjs → index-KAe7y0WA.mjs} +2 -2
- package/lib/{index-VO5jvtPN.mjs → index-q3BebMyx.mjs} +1 -1
- package/lib/{index-CG2dc9k1.mjs → index-rJ51Opss.mjs} +5 -5
- package/lib/{index-CkHXWtPG.js → index-tzOxV6Ga.js} +1 -1
- package/lib/{index.es-Bld6bvmZ.mjs → index.es-B0vZ9CZN.mjs} +5 -5
- package/lib/{index.es-DWCjm6mS.js → index.es-CIkbIjAw.js} +2 -2
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{keccak-C8mX3bFz.js → keccak-Bbj2Yl-x.js} +1 -1
- package/lib/{keccak-BwFcIiaM.mjs → keccak-OTA2ssQD.mjs} +1 -1
- package/lib/{pbkdf2-CeHVjwwG.mjs → pbkdf2-BTEK0Lcd.mjs} +3 -3
- package/lib/{pbkdf2-Bk-3RPXm.js → pbkdf2-DWsBOC-R.js} +1 -1
- package/lib/{signer-DXNU3KLz.mjs → signer-CSn2uQ3I.mjs} +1 -1
- package/lib/{signer-LadskxdY.js → signer-JVKCqiEl.js} +1 -1
- package/lib/{solana-C9iEiCkx.js → solana-B25QaZay.js} +1 -1
- package/lib/solana-C5D4LdxL.mjs +16 -0
- package/lib/{solana-BasjNE9K.mjs → solana-CZiRQleS.mjs} +4 -4
- package/lib/solana-JSgP_iZe.js +1 -0
- package/lib/{solanaEmbed.esm-CJdWWBYT.js → solanaEmbed.esm-BU0rHfVX.js} +1 -1
- package/lib/{solanaEmbed.esm-pwzJ8Zc0.mjs → solanaEmbed.esm-D5MQek-2.mjs} +3 -3
- package/lib/{sui-B9B-EQyp.mjs → sui-BZ3grhrf.mjs} +4 -4
- package/lib/{sui-iJeaGeqF.js → sui-Bc5tJ6m9.js} +1 -1
- package/lib/{sui-BJBxQjSI.js → sui-CuJDivKm.js} +2 -2
- package/lib/{sui-HC466JTC.mjs → sui-Dv8Drra7.mjs} +10 -10
- package/lib/{unsignedTransaction-CmgkSLIX.js → unsignedTransaction-BnVGUXbX.js} +1 -1
- package/lib/{unsignedTransaction-Di5zQIK0.mjs → unsignedTransaction-CzttHBqx.mjs} +2 -2
- package/package.json +1 -1
- package/dist/assets/index-D2LZykJf.js +0 -2
- package/lib/index-hb33T1qT.js +0 -1
- package/lib/solana-B15fGx9S.js +0 -1
- package/lib/solana-CfCGAR-_.mjs +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var D=Object.defineProperty;var q=(o,e,n)=>e in o?D(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n;var p=(o,e,n)=>q(o,typeof e!="symbol"?e+"":e,n);const t=require("./index-Dh6mkRtz.js"),H=require("./algorand-B9Pcx34H.js");class j{constructor(e,n,r,s,i=!1){p(this,"transaction");p(this,"network");p(this,"chain");p(this,"description");p(this,"parallelizable");this.transaction=e,this.network=n,this.chain=r,this.description=s,this.parallelizable=i}}const K=1002e3,O=15,U=127,L=8,R=U*L,V=U*O,N=L*V,m={_limit:127,encodingLength:o=>{let e=0;for(;o>=128;e++)o>>=7;return e+1},encode:(o,e,n)=>{if(typeof o=="bigint"&&(o=t.safeBigIntToNumber(o)),o<0)throw new RangeError("value must be unsigned");const r=m.encodingLength(o);if(e=e||new ArrayBuffer(r),n=n||0,e.byteLength<n+r)throw new RangeError("the buffer is too small to encode the number at the offset");const s=new Uint8Array(e,n);let i=0;for(;m._limit<o;)s[i++]=o&m._limit|128,o>>=7;return s[i]=Number(o),s},decode:(o,e=0)=>{let n=0,r=0,s;do{if(s=o[e+r],s===void 0)throw new RangeError("offset out of range");n+=(s&m._limit)<<r*7,r++}while(128<=s);return n}},u={forMessageId:(o,e)=>{const n=t.decodeAddress(t.getApplicationAddress(o)).publicKey,r=e.emitter.toUniversalAddress().toUint8Array(),s=t.bignum.toBytes(BigInt(t.toChainId(e.chain)),2),i=t.bytes.concat(s,r);return u.fromData({appId:o,appAddress:n,idx:e.sequence/BigInt(N),address:i})},forWrappedAsset:(o,e)=>{if(t.isNative(e.address))throw new Error("native asset cannot be a wrapped asset");const n=t.decodeAddress(t.getApplicationAddress(o)).publicKey;return u.fromData({appId:o,appAddress:n,idx:BigInt(t.toChainId(e.chain)),address:e.address.toUniversalAddress().toUint8Array()})},forNativeAsset:(o,e)=>{const n=t.decodeAddress(t.getApplicationAddress(o)).publicKey;return u.fromData({appId:o,appAddress:n,idx:e,address:t.bytes.encode("native")})},forGuardianSet:(o,e)=>{const n=t.decodeAddress(t.getApplicationAddress(o)).publicKey;return u.fromData({appId:o,appAddress:n,idx:BigInt(e),address:t.bytes.encode("guardian")})},forEmitter:(o,e)=>{const n=t.decodeAddress(t.getApplicationAddress(o)).publicKey;return u.fromData({appId:o,appAddress:n,idx:0n,address:e})},_encode:o=>typeof o=="bigint"?[t.hex.encode(m.encode(o))]:[t.hex.encode(m.encode(o.length)),t.hex.encode(o)],fromData:o=>{const e=["0620010181",...u._encode(o.idx),"4880",...u._encode(o.address),"483110810612443119221244311881",...u._encode(o.appId),"1244312080",...u._encode(o.appAddress),"124431018100124431093203124431153203124422"],n=t.hex.decode(e.join(""));return new t.LogicSigAccount(n)},decodeLocalState:async(o,e,n)=>{let r;try{const a=await o.accountApplicationInformation(n,t.safeBigIntToNumber(e)).do();r=t.AccountApplicationResponse.from_obj_for_encoding(a).appLocalState}catch{return new Uint8Array}const s=t.b64.encode("meta");let i=new Map;for(const a of r.keyValue){if(a.key===s)continue;const g=t.b64.decode(a.key)[0],l=t.b64.decode(a.value.bytes);i.set(g,l)}const d=[];for(let a=0;a<O;a++)i.has(a)&&d.push(i.get(a));return t.bytes.concat(...d)},checkBitsSet:async(o,e,n,r)=>{let s=!1,i;const d=await o.accountInformation(n).do(),g=t.Account.from_obj_for_encoding(d).appsLocalState;if(g&&g.forEach(h=>{BigInt(h.id)===e&&(i=h.keyValue)}),(i==null?void 0:i.length)===0)return s;const l=BigInt(N),f=BigInt(8),y=r/l*l,b=t.safeBigIntToNumber(r-y),T=Math.floor(b/R),x=Math.floor((b-T*R)/8),B=t.b64.encode(t.bignum.toBytes(T,1));return i==null||i.forEach(h=>{if(h.key===B){const _=t.dist.Buffer.from(h.value.bytes,"base64"),w=1<<t.safeBigIntToNumber(r%f);s=(_[x]&w)!=0;return}}),s},storageAccountExists:async(o,e,n)=>{try{const r=await o.accountApplicationInformation(e,t.safeBigIntToNumber(n)).do();return Object.keys(r).length>0}catch{}return!1}},c=class c{constructor(e,n,r,s){p(this,"network");p(this,"chain");p(this,"connection");p(this,"contracts");p(this,"chainId");p(this,"coreAppId");p(this,"coreAppAddress");p(this,"tokenBridgeAppId");p(this,"tokenBridgeAppAddress");if(this.network=e,this.chain=n,this.connection=r,this.contracts=s,this.chainId=t.toChainId(n),!s.coreBridge)throw new Error(`Core contract address for chain ${n} not found`);const i=BigInt(s.coreBridge);if(this.coreAppId=i,this.coreAppAddress=t.getApplicationAddress(i),!s.tokenBridge)throw new Error(`TokenBridge contract address for chain ${n} not found`);const d=BigInt(s.tokenBridge);this.tokenBridgeAppId=d,this.tokenBridgeAppAddress=t.getApplicationAddress(d)}getGuardianSet(e){throw new Error("Method not implemented.")}async*verifyMessage(e,n,r){const s=new t.AlgorandAddress(e).toString(),i=await c.submitVAAHeader(this.connection,this.coreAppId,r??this.coreAppId,n,s);for(const d of i.txs)yield this.createUnsignedTx(d,"Core.verifyMessage")}static async fromRpc(e,n){const[r,s]=await H.AlgorandPlatform.chainFromRpc(e),i=n[s];if(i.network!==r)throw new Error(`Network mismatch: ${i.network} !== ${r}`);return new c(r,s,e,i.contracts)}async*publishMessage(e,n){const r=new t.AlgorandAddress(e),s=r.toString(),i=await this.connection.getTransactionParams().do(),d=u.forEmitter(this.coreAppId,r.toUint8Array()),{accounts:a,txs:g}=await c.maybeCreateStorageTx(this.connection,s,this.coreAppId,d,i);for(const f of g)yield this.createUnsignedTx(f,"Core.publishMessage",!0);const l=t.makeApplicationCallTxnFromObject({from:s,appIndex:t.safeBigIntToNumber(this.coreAppId),appArgs:[c.publishMessage,n,t.bignum.toBytes(0n,8)],accounts:a,onComplete:t.OnApplicationComplete.NoOpOC,suggestedParams:i});yield this.createUnsignedTx({tx:l},"Core.publishMessage",!0)}async getMessageFee(){var s;const e=await this.connection.getApplicationByID(t.safeBigIntToNumber(this.coreAppId)).do(),r=(s=t.Application.from_obj_for_encoding(e).params.globalState)==null?void 0:s.find(i=>i.key===c.feeKey);return r?BigInt(r.value.uint):0n}async getGuardianSetIndex(){throw new Error("Not implemented")}async parseTransaction(e){const n=await this.connection.pendingTransactionInformation(e).do(),r=t.PendingTransactionResponse.from_obj_for_encoding(n);return this.parseTx(r).map(s=>({chain:s.emitterChain,emitter:s.emitterAddress,sequence:s.sequence}))}async parseMessages(e){const n=await this.connection.pendingTransactionInformation(e).do(),r=t.PendingTransactionResponse.from_obj_for_encoding(n);return this.parseTx(r)}parseTx(e){const n=[];if(e.innerTxns&&e.innerTxns.length>0&&n.push(...e.innerTxns.flatMap(g=>this.parseTx(g))),BigInt(e.txn.txn.apid??0)!==this.coreAppId||!e.logs||e.logs.length===0)return n;const r=e.txn.txn.apaa??[];if(r.length!==3||!t.bytes.equals(new Uint8Array(r[0]),c.publishMessage))return n;const s=t.bignum.decode(e.logs[0]),i=new t.AlgorandAddress(e.txn.txn.snd).toUniversalAddress(),d=new Uint8Array(r[1]),a=t.bignum.decode(r[2]);return n.push(t.createVAA("Uint8Array",{emitterChain:this.chain,emitterAddress:i,sequence:s,guardianSet:0,timestamp:0,consistencyLevel:0,nonce:Number(a),payload:d,signatures:[]})),n}static async maybeCreateStorageTx(e,n,r,s,i){const d=t.getApplicationAddress(r),a=s.address(),g=[];if(await u.storageAccountExists(e,a,r))return{accounts:[a],txs:g};i=i??await e.getTransactionParams().do();const l=t.makePaymentTxnWithSuggestedParamsFromObject({from:n,to:a,amount:K,suggestedParams:i});l.fee=l.fee*2,g.push({tx:l});const f=t.makeApplicationOptInTxnFromObject({from:a,appIndex:t.safeBigIntToNumber(r),rekeyTo:d,suggestedParams:i});return f.fee=0,g.push({tx:f,signer:{address:s.address(),signTxn:y=>Promise.resolve(t.signLogicSigTransaction(y,s).blob)}}),{accounts:[a],txs:g}}static async submitVAAHeader(e,n,r,s,i,d){d=d??await e.getTransactionParams().do();let a=[];const g=u.forMessageId(r,{chain:s.emitterChain,sequence:s.sequence,emitter:s.emitterAddress}),{accounts:l,txs:f}=await c.maybeCreateStorageTx(e,i,r,g,d);a.push(...f);const y=u.forGuardianSet(n,s.guardianSet),{accounts:[b],txs:T}=await c.maybeCreateStorageTx(e,i,n,y,d);a.push(...T);let x=[...l,b];const B=await u.decodeLocalState(e,n,b),h=t.keccak_256(s.hash),_=s.signatures.length,w=Math.ceil(_/c.MAX_SIGS_PER_TXN),k=20,C=new t.LogicSigAccount(c.ALGO_VERIFY);for(let M=0;M<w;M++){const v=M*c.MAX_SIGS_PER_TXN,S=s.signatures.slice(v,v+c.MAX_SIGS_PER_TXN),F=S.length*k,G=new Uint8Array(F);for(let A=0;A<S.length;A++){const P=S[A],Y=B.slice(P.guardianIndex*k+1,(P.guardianIndex+1)*k+1);G.set(Y,A*20)}const X=t.makeApplicationCallTxnFromObject({appArgs:[c.verifySigs,t.bytes.concat(...S.map(A=>t.bytes.concat(new Uint8Array([A.guardianIndex]),A.signature.encode()))),G,h],accounts:x,appIndex:t.safeBigIntToNumber(n),from:c.ALGO_VERIFY_HASH,onComplete:t.OnApplicationComplete.NoOpOC,suggestedParams:d});X.fee=0,a.push({tx:X,signer:{address:C.address(),signTxn:A=>Promise.resolve(t.signLogicSigTransaction(A,C).blob)}})}const E=t.makeApplicationCallTxnFromObject({appArgs:[c.verifyVaa,t.serialize(s)],accounts:x,appIndex:t.safeBigIntToNumber(n),from:i,onComplete:t.OnApplicationComplete.NoOpOC,suggestedParams:d});return E.fee=E.fee*(2+w),a.push({tx:E}),{accounts:x,txs:a}}createUnsignedTx(e,n,r=!0){return new j(e,this.network,this.chain,n,r)}};p(c,"MAX_SIGS_PER_TXN",6),p(c,"ALGO_VERIFY_HASH","EZATROXX2HISIRZDRGXW4LRQ46Z6IUJYYIHU3PJGP7P5IQDPKVX42N767A"),p(c,"ALGO_VERIFY",new Uint8Array([6,32,4,1,0,32,20,38,1,0,49,32,50,3,18,68,49,1,35,18,68,49,16,129,6,18,68,54,26,1,54,26,3,54,26,2,136,0,3,68,34,67,53,2,53,1,53,0,40,53,240,40,53,241,52,0,21,53,5,35,53,3,35,53,4,52,3,52,5,12,65,0,68,52,1,52,0,52,3,129,65,8,34,88,23,52,0,52,3,34,8,36,88,52,0,52,3,129,33,8,36,88,7,0,53,241,53,240,52,2,52,4,37,88,52,240,52,241,80,2,87,12,20,18,68,52,3,129,66,8,53,3,52,4,37,8,53,4,66,255,180,34,137])),p(c,"feeKey",t.b64.encode("MessageFee")),p(c,"verifyVaa",t.bytes.encode("verifyVAA")),p(c,"verifySigs",t.bytes.encode("verifySigs")),p(c,"publishMessage",t.bytes.encode("publishMessage"));let I=c;t.registerProtocol("Algorand","WormholeCore",I);const z=Object.freeze(Object.defineProperty({__proto__:null,AlgorandWormholeCore:I,BITS_PER_BYTE:L,BITS_PER_KEY:R,MAX_BITS:N,MAX_BYTES:V,MAX_BYTES_PER_KEY:U,MAX_KEYS:O,SEED_AMT:K,StorageLogicSig:u,varint:m},Symbol.toStringTag,{value:"Module"}));exports.AlgorandUnsignedTransaction=j;exports.AlgorandWormholeCore=I;exports.StorageLogicSig=u;exports.index=z;
|
|
1
|
+
"use strict";var D=Object.defineProperty;var q=(o,e,n)=>e in o?D(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n;var p=(o,e,n)=>q(o,typeof e!="symbol"?e+"":e,n);const t=require("./index-B5r3vRTo.js"),H=require("./algorand-HCN4Bwfj.js");class j{constructor(e,n,r,s,i=!1){p(this,"transaction");p(this,"network");p(this,"chain");p(this,"description");p(this,"parallelizable");this.transaction=e,this.network=n,this.chain=r,this.description=s,this.parallelizable=i}}const K=1002e3,O=15,U=127,L=8,R=U*L,V=U*O,N=L*V,m={_limit:127,encodingLength:o=>{let e=0;for(;o>=128;e++)o>>=7;return e+1},encode:(o,e,n)=>{if(typeof o=="bigint"&&(o=t.safeBigIntToNumber(o)),o<0)throw new RangeError("value must be unsigned");const r=m.encodingLength(o);if(e=e||new ArrayBuffer(r),n=n||0,e.byteLength<n+r)throw new RangeError("the buffer is too small to encode the number at the offset");const s=new Uint8Array(e,n);let i=0;for(;m._limit<o;)s[i++]=o&m._limit|128,o>>=7;return s[i]=Number(o),s},decode:(o,e=0)=>{let n=0,r=0,s;do{if(s=o[e+r],s===void 0)throw new RangeError("offset out of range");n+=(s&m._limit)<<r*7,r++}while(128<=s);return n}},u={forMessageId:(o,e)=>{const n=t.decodeAddress(t.getApplicationAddress(o)).publicKey,r=e.emitter.toUniversalAddress().toUint8Array(),s=t.bignum.toBytes(BigInt(t.toChainId(e.chain)),2),i=t.bytes.concat(s,r);return u.fromData({appId:o,appAddress:n,idx:e.sequence/BigInt(N),address:i})},forWrappedAsset:(o,e)=>{if(t.isNative(e.address))throw new Error("native asset cannot be a wrapped asset");const n=t.decodeAddress(t.getApplicationAddress(o)).publicKey;return u.fromData({appId:o,appAddress:n,idx:BigInt(t.toChainId(e.chain)),address:e.address.toUniversalAddress().toUint8Array()})},forNativeAsset:(o,e)=>{const n=t.decodeAddress(t.getApplicationAddress(o)).publicKey;return u.fromData({appId:o,appAddress:n,idx:e,address:t.bytes.encode("native")})},forGuardianSet:(o,e)=>{const n=t.decodeAddress(t.getApplicationAddress(o)).publicKey;return u.fromData({appId:o,appAddress:n,idx:BigInt(e),address:t.bytes.encode("guardian")})},forEmitter:(o,e)=>{const n=t.decodeAddress(t.getApplicationAddress(o)).publicKey;return u.fromData({appId:o,appAddress:n,idx:0n,address:e})},_encode:o=>typeof o=="bigint"?[t.hex.encode(m.encode(o))]:[t.hex.encode(m.encode(o.length)),t.hex.encode(o)],fromData:o=>{const e=["0620010181",...u._encode(o.idx),"4880",...u._encode(o.address),"483110810612443119221244311881",...u._encode(o.appId),"1244312080",...u._encode(o.appAddress),"124431018100124431093203124431153203124422"],n=t.hex.decode(e.join(""));return new t.LogicSigAccount(n)},decodeLocalState:async(o,e,n)=>{let r;try{const a=await o.accountApplicationInformation(n,t.safeBigIntToNumber(e)).do();r=t.AccountApplicationResponse.from_obj_for_encoding(a).appLocalState}catch{return new Uint8Array}const s=t.b64.encode("meta");let i=new Map;for(const a of r.keyValue){if(a.key===s)continue;const g=t.b64.decode(a.key)[0],l=t.b64.decode(a.value.bytes);i.set(g,l)}const d=[];for(let a=0;a<O;a++)i.has(a)&&d.push(i.get(a));return t.bytes.concat(...d)},checkBitsSet:async(o,e,n,r)=>{let s=!1,i;const d=await o.accountInformation(n).do(),g=t.Account.from_obj_for_encoding(d).appsLocalState;if(g&&g.forEach(h=>{BigInt(h.id)===e&&(i=h.keyValue)}),(i==null?void 0:i.length)===0)return s;const l=BigInt(N),f=BigInt(8),y=r/l*l,b=t.safeBigIntToNumber(r-y),T=Math.floor(b/R),x=Math.floor((b-T*R)/8),B=t.b64.encode(t.bignum.toBytes(T,1));return i==null||i.forEach(h=>{if(h.key===B){const _=t.dist.Buffer.from(h.value.bytes,"base64"),w=1<<t.safeBigIntToNumber(r%f);s=(_[x]&w)!=0;return}}),s},storageAccountExists:async(o,e,n)=>{try{const r=await o.accountApplicationInformation(e,t.safeBigIntToNumber(n)).do();return Object.keys(r).length>0}catch{}return!1}},c=class c{constructor(e,n,r,s){p(this,"network");p(this,"chain");p(this,"connection");p(this,"contracts");p(this,"chainId");p(this,"coreAppId");p(this,"coreAppAddress");p(this,"tokenBridgeAppId");p(this,"tokenBridgeAppAddress");if(this.network=e,this.chain=n,this.connection=r,this.contracts=s,this.chainId=t.toChainId(n),!s.coreBridge)throw new Error(`Core contract address for chain ${n} not found`);const i=BigInt(s.coreBridge);if(this.coreAppId=i,this.coreAppAddress=t.getApplicationAddress(i),!s.tokenBridge)throw new Error(`TokenBridge contract address for chain ${n} not found`);const d=BigInt(s.tokenBridge);this.tokenBridgeAppId=d,this.tokenBridgeAppAddress=t.getApplicationAddress(d)}getGuardianSet(e){throw new Error("Method not implemented.")}async*verifyMessage(e,n,r){const s=new t.AlgorandAddress(e).toString(),i=await c.submitVAAHeader(this.connection,this.coreAppId,r??this.coreAppId,n,s);for(const d of i.txs)yield this.createUnsignedTx(d,"Core.verifyMessage")}static async fromRpc(e,n){const[r,s]=await H.AlgorandPlatform.chainFromRpc(e),i=n[s];if(i.network!==r)throw new Error(`Network mismatch: ${i.network} !== ${r}`);return new c(r,s,e,i.contracts)}async*publishMessage(e,n){const r=new t.AlgorandAddress(e),s=r.toString(),i=await this.connection.getTransactionParams().do(),d=u.forEmitter(this.coreAppId,r.toUint8Array()),{accounts:a,txs:g}=await c.maybeCreateStorageTx(this.connection,s,this.coreAppId,d,i);for(const f of g)yield this.createUnsignedTx(f,"Core.publishMessage",!0);const l=t.makeApplicationCallTxnFromObject({from:s,appIndex:t.safeBigIntToNumber(this.coreAppId),appArgs:[c.publishMessage,n,t.bignum.toBytes(0n,8)],accounts:a,onComplete:t.OnApplicationComplete.NoOpOC,suggestedParams:i});yield this.createUnsignedTx({tx:l},"Core.publishMessage",!0)}async getMessageFee(){var s;const e=await this.connection.getApplicationByID(t.safeBigIntToNumber(this.coreAppId)).do(),r=(s=t.Application.from_obj_for_encoding(e).params.globalState)==null?void 0:s.find(i=>i.key===c.feeKey);return r?BigInt(r.value.uint):0n}async getGuardianSetIndex(){throw new Error("Not implemented")}async parseTransaction(e){const n=await this.connection.pendingTransactionInformation(e).do(),r=t.PendingTransactionResponse.from_obj_for_encoding(n);return this.parseTx(r).map(s=>({chain:s.emitterChain,emitter:s.emitterAddress,sequence:s.sequence}))}async parseMessages(e){const n=await this.connection.pendingTransactionInformation(e).do(),r=t.PendingTransactionResponse.from_obj_for_encoding(n);return this.parseTx(r)}parseTx(e){const n=[];if(e.innerTxns&&e.innerTxns.length>0&&n.push(...e.innerTxns.flatMap(g=>this.parseTx(g))),BigInt(e.txn.txn.apid??0)!==this.coreAppId||!e.logs||e.logs.length===0)return n;const r=e.txn.txn.apaa??[];if(r.length!==3||!t.bytes.equals(new Uint8Array(r[0]),c.publishMessage))return n;const s=t.bignum.decode(e.logs[0]),i=new t.AlgorandAddress(e.txn.txn.snd).toUniversalAddress(),d=new Uint8Array(r[1]),a=t.bignum.decode(r[2]);return n.push(t.createVAA("Uint8Array",{emitterChain:this.chain,emitterAddress:i,sequence:s,guardianSet:0,timestamp:0,consistencyLevel:0,nonce:Number(a),payload:d,signatures:[]})),n}static async maybeCreateStorageTx(e,n,r,s,i){const d=t.getApplicationAddress(r),a=s.address(),g=[];if(await u.storageAccountExists(e,a,r))return{accounts:[a],txs:g};i=i??await e.getTransactionParams().do();const l=t.makePaymentTxnWithSuggestedParamsFromObject({from:n,to:a,amount:K,suggestedParams:i});l.fee=l.fee*2,g.push({tx:l});const f=t.makeApplicationOptInTxnFromObject({from:a,appIndex:t.safeBigIntToNumber(r),rekeyTo:d,suggestedParams:i});return f.fee=0,g.push({tx:f,signer:{address:s.address(),signTxn:y=>Promise.resolve(t.signLogicSigTransaction(y,s).blob)}}),{accounts:[a],txs:g}}static async submitVAAHeader(e,n,r,s,i,d){d=d??await e.getTransactionParams().do();let a=[];const g=u.forMessageId(r,{chain:s.emitterChain,sequence:s.sequence,emitter:s.emitterAddress}),{accounts:l,txs:f}=await c.maybeCreateStorageTx(e,i,r,g,d);a.push(...f);const y=u.forGuardianSet(n,s.guardianSet),{accounts:[b],txs:T}=await c.maybeCreateStorageTx(e,i,n,y,d);a.push(...T);let x=[...l,b];const B=await u.decodeLocalState(e,n,b),h=t.keccak_256(s.hash),_=s.signatures.length,w=Math.ceil(_/c.MAX_SIGS_PER_TXN),k=20,C=new t.LogicSigAccount(c.ALGO_VERIFY);for(let M=0;M<w;M++){const v=M*c.MAX_SIGS_PER_TXN,S=s.signatures.slice(v,v+c.MAX_SIGS_PER_TXN),F=S.length*k,G=new Uint8Array(F);for(let A=0;A<S.length;A++){const P=S[A],Y=B.slice(P.guardianIndex*k+1,(P.guardianIndex+1)*k+1);G.set(Y,A*20)}const X=t.makeApplicationCallTxnFromObject({appArgs:[c.verifySigs,t.bytes.concat(...S.map(A=>t.bytes.concat(new Uint8Array([A.guardianIndex]),A.signature.encode()))),G,h],accounts:x,appIndex:t.safeBigIntToNumber(n),from:c.ALGO_VERIFY_HASH,onComplete:t.OnApplicationComplete.NoOpOC,suggestedParams:d});X.fee=0,a.push({tx:X,signer:{address:C.address(),signTxn:A=>Promise.resolve(t.signLogicSigTransaction(A,C).blob)}})}const E=t.makeApplicationCallTxnFromObject({appArgs:[c.verifyVaa,t.serialize(s)],accounts:x,appIndex:t.safeBigIntToNumber(n),from:i,onComplete:t.OnApplicationComplete.NoOpOC,suggestedParams:d});return E.fee=E.fee*(2+w),a.push({tx:E}),{accounts:x,txs:a}}createUnsignedTx(e,n,r=!0){return new j(e,this.network,this.chain,n,r)}};p(c,"MAX_SIGS_PER_TXN",6),p(c,"ALGO_VERIFY_HASH","EZATROXX2HISIRZDRGXW4LRQ46Z6IUJYYIHU3PJGP7P5IQDPKVX42N767A"),p(c,"ALGO_VERIFY",new Uint8Array([6,32,4,1,0,32,20,38,1,0,49,32,50,3,18,68,49,1,35,18,68,49,16,129,6,18,68,54,26,1,54,26,3,54,26,2,136,0,3,68,34,67,53,2,53,1,53,0,40,53,240,40,53,241,52,0,21,53,5,35,53,3,35,53,4,52,3,52,5,12,65,0,68,52,1,52,0,52,3,129,65,8,34,88,23,52,0,52,3,34,8,36,88,52,0,52,3,129,33,8,36,88,7,0,53,241,53,240,52,2,52,4,37,88,52,240,52,241,80,2,87,12,20,18,68,52,3,129,66,8,53,3,52,4,37,8,53,4,66,255,180,34,137])),p(c,"feeKey",t.b64.encode("MessageFee")),p(c,"verifyVaa",t.bytes.encode("verifyVAA")),p(c,"verifySigs",t.bytes.encode("verifySigs")),p(c,"publishMessage",t.bytes.encode("publishMessage"));let I=c;t.registerProtocol("Algorand","WormholeCore",I);const z=Object.freeze(Object.defineProperty({__proto__:null,AlgorandWormholeCore:I,BITS_PER_BYTE:L,BITS_PER_KEY:R,MAX_BITS:N,MAX_BYTES:V,MAX_BYTES_PER_KEY:U,MAX_KEYS:O,SEED_AMT:K,StorageLogicSig:u,varint:m},Symbol.toStringTag,{value:"Module"}));exports.AlgorandUnsignedTransaction=j;exports.AlgorandWormholeCore=I;exports.StorageLogicSig=u;exports.index=z;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var U=(k,o,t)=>o in k?P(k,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):k[o]=t;var g=(k,o,t)=>U(k,typeof o!="symbol"?o+"":o,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index-DsMw6BFg.js"),e=require("./index-Dh6mkRtz.js"),v=require("./algorand-B9Pcx34H.js"),j=e.ABIMethod.fromSignature("portal_transfer(byte[])byte[]"),p=class p{constructor(o,t,r,s){g(this,"network");g(this,"chain");g(this,"connection");g(this,"contracts");g(this,"chainId");g(this,"coreBridge");g(this,"coreAppId");g(this,"coreAppAddress");g(this,"tokenBridgeAppId");g(this,"tokenBridgeAddress");if(this.network=o,this.chain=t,this.connection=r,this.contracts=s,this.chainId=e.toChainId(t),!s.coreBridge)throw new Error(`Core contract address for chain ${t} not found`);const i=BigInt(s.coreBridge);if(this.coreAppId=i,this.coreAppAddress=e.getApplicationAddress(i),this.coreBridge=new d.AlgorandWormholeCore(o,t,r,s),!s.tokenBridge)throw new Error(`TokenBridge contract address for chain ${t} not found`);const a=BigInt(s.tokenBridge);this.tokenBridgeAppId=a,this.tokenBridgeAddress=e.getApplicationAddress(a)}static async fromRpc(o,t){const[r,s]=await v.AlgorandPlatform.chainFromRpc(o),i=t[s];if(i.network!==r)throw new Error(`Network mismatch: ${i.network} != ${r}`);return new p(r,s,o,i.contracts)}async isWrappedAsset(o){const t=new e.AlgorandAddress(o).toInt();if(t===0)return!1;const r=await this.connection.getAssetByID(t).do(),i=e.Asset.from_obj_for_encoding(r).params.creator,a=await this.connection.accountInformation(i).exclude("all").do(),n=e.Account.from_obj_for_encoding(a);return(n==null?void 0:n.authAddr)===this.tokenBridgeAddress}async getOriginalAsset(o){const t=new e.AlgorandAddress(o).toInt(),r=await this.connection.getAssetByID(t).do(),s=e.Asset.from_obj_for_encoding(r),i=await d.StorageLogicSig.decodeLocalState(this.connection,this.tokenBridgeAppId,s.params.creator);if(i.length<94)throw new Error("Invalid local state data");const a=i.slice(92,94),n=e.toChain(e.bignum.decode(a)),A=new e.UniversalAddress(i.slice(60,92));return{chain:n,address:A}}async getTokenUniversalAddress(o){return new e.AlgorandAddress(o).toUniversalAddress()}async getTokenNativeAddress(o,t){return new e.AlgorandAddress(t).toNative()}async getWrappedAsset(o){if(e.isNative(o.address))throw new Error("native asset cannot be a wrapped asset");const t=d.StorageLogicSig.forWrappedAsset(this.tokenBridgeAppId,o),r=await d.StorageLogicSig.decodeLocalState(this.connection,this.tokenBridgeAppId,t.address());if(r.length<8)throw new Error("Invalid wrapped asset data");return e.toNative(this.chain,e.bignum.decode(r.slice(0,8)).toString())}async hasWrappedAsset(o){try{return await this.getWrappedAsset(o),!0}catch{}return!1}async getWrappedNative(){return e.toNative(this.chain,"0")}async isTransferCompleted(o){const t=d.StorageLogicSig.forMessageId(this.tokenBridgeAppId,{sequence:o.sequence,chain:o.emitterChain,emitter:o.emitterAddress});try{return await d.StorageLogicSig.checkBitsSet(this.connection,this.tokenBridgeAppId,t.address(),o.sequence)}catch{}return!1}async*createAttestation(o,t){if(!t)throw new Error("Payer required to create attestation");const r=new e.AlgorandAddress(t).toString(),s=new e.AlgorandAddress(o).toInt(),i=[],a=await this.connection.getTransactionParams().do(),n=d.StorageLogicSig.forEmitter(this.coreAppId,new e.AlgorandAddress(this.tokenBridgeAddress).toUint8Array()),{accounts:[A],txs:I}=await d.AlgorandWormholeCore.maybeCreateStorageTx(this.connection,r,this.coreAppId,n,a);i.push(...I);let h="",c;if(s!==0){const u=await this.connection.getAssetByID(s).do(),b=e.Asset.from_obj_for_encoding(u),S=await this.connection.accountInformation(b.params.creator).do();if(c=e.Account.from_obj_for_encoding(S),c.authAddr===this.tokenBridgeAddress.toString())throw new Error("Cannot re-attest wormhole assets")}const B=d.StorageLogicSig.forNativeAsset(this.tokenBridgeAppId,BigInt(s)),w=await d.AlgorandWormholeCore.maybeCreateStorageTx(this.connection,r,this.tokenBridgeAppId,B);h=w.accounts[0],i.push(...w.txs);const m=e.makeApplicationCallTxnFromObject({from:r,appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),onComplete:e.OnApplicationComplete.NoOpOC,appArgs:[p.noop],suggestedParams:a});i.push({tx:m});const f=await this.coreBridge.getMessageFee();if(f>BigInt(0)){const u=e.makePaymentTxnWithSuggestedParamsFromObject({from:r,suggestedParams:a,to:this.tokenBridgeAddress,amount:f});i.push({tx:u})}let y=[A,h,this.coreAppAddress];c&&y.push(c.address);let l=e.makeApplicationCallTxnFromObject({appArgs:[p.attestToken,e.bignum.toBytes(s,8)],accounts:y,appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),foreignApps:[e.safeBigIntToNumber(this.coreAppId)],foreignAssets:[s],from:r,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:a});f>BigInt(0)?l.fee*=3:l.fee*=2,i.push({tx:l});for(const u of i)yield this.createUnsignedTx(u,"TokenBridge.createAttestation",!0)}async*submitAttestation(o,t,r){if(!t)throw new Error("Sender required to submit attestation");r||(r=await this.connection.getTransactionParams().do());const s=t.toString(),a=d.StorageLogicSig.forWrappedAsset(this.tokenBridgeAppId,o.payload.token).address(),n=[],A=[],I=await d.StorageLogicSig.decodeLocalState(this.connection,this.tokenBridgeAppId,a);I.length>8&&A.push(new e.AlgorandAddress(I.slice(0,8)).toInt()),n.push({tx:e.makePaymentTxnWithSuggestedParamsFromObject({from:s,to:a,amount:1e5,suggestedParams:r})});let h=new Uint8Array(1);h[0]=1,n.push({tx:e.makeApplicationCallTxnFromObject({appArgs:[p.noop,h],appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),from:s,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:r})}),h=new Uint8Array(1),h[0]=2,n.push({tx:e.makeApplicationCallTxnFromObject({appArgs:[p.noop,h],appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),from:s,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:r})}),n.push({tx:e.makeApplicationCallTxnFromObject({accounts:[],appArgs:[p.receiveAttest,e.serialize(o)],appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),foreignAssets:A,from:s,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:r})}),n[n.length-1].tx.fee=n[n.length-1].tx.fee*2;for(const c of n)yield this.createUnsignedTx(c,"TokenBridge.submitAttestation",!0)}async*transfer(o,t,r,s,i){const a=o.toString(),n=e.isNative(r)?0:new e.AlgorandAddress(r).toInt(),A=s,I=e.toChainId(t.chain),h=t.address.toUniversalAddress().toUint8Array(),c=await this.connection.getTransactionParams().do(),B=BigInt(0),w=d.StorageLogicSig.fromData({appId:this.coreAppId,appAddress:e.decodeAddress(this.coreAppAddress).publicKey,idx:BigInt(0),address:e.decodeAddress(this.tokenBridgeAddress).publicKey}),m=[],{accounts:[f],txs:y}=await d.AlgorandWormholeCore.maybeCreateStorageTx(this.connection,a,this.coreAppId,w,c);m.push(...y);let l="",u,b=!1;if(n!==0){const x=await this.connection.getAssetByID(n).do();l=e.Asset.from_obj_for_encoding(x).params.creator;const C=await this.connection.accountInformation(l).do();u=e.Account.from_obj_for_encoding(C),b=u.authAddr===this.tokenBridgeAddress.toString()}const S=await this.coreBridge.getMessageFee();if(S>0&&m.push({tx:e.makePaymentTxnWithSuggestedParamsFromObject({from:a,to:this.tokenBridgeAddress,amount:S,suggestedParams:c})}),!b){const x=d.StorageLogicSig.forNativeAsset(this.tokenBridgeAppId,BigInt(n)),{accounts:[T],txs:C}=await d.AlgorandWormholeCore.maybeCreateStorageTx(this.connection,a,this.tokenBridgeAppId,x,c);l=T,C.push(...C)}if(n!==0&&!await p.isOptedInToAsset(this.connection,l,n)){const x=e.makePaymentTxnWithSuggestedParamsFromObject({from:a,to:l,amount:1e5,suggestedParams:c});let T=e.makeApplicationCallTxnFromObject({from:a,appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),onComplete:e.OnApplicationComplete.NoOpOC,appArgs:[p.optIn,e.bigIntToBytes(n,8)],foreignAssets:[n],accounts:[l],suggestedParams:c});T.fee*=2,m.unshift({tx:x},{tx:T})}const L=e.makeApplicationCallTxnFromObject({from:a,appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),onComplete:e.OnApplicationComplete.NoOpOC,appArgs:[p.noop],suggestedParams:c});m.push({tx:L});let N=[];if(n===0){const x=e.makePaymentTxnWithSuggestedParamsFromObject({from:a,to:l,amount:A,suggestedParams:c});m.push({tx:x}),N=[f,l,l]}else{const x=e.makeAssetTransferTxnWithSuggestedParamsFromObject({from:a,to:l,amount:A,assetIndex:n,suggestedParams:c});m.push({tx:x}),N=u!=null&&u.address?[f,l,u.address]:[f,l]}const W=[p.sendTransfer,e.bignum.toBytes(n,8),e.bignum.toBytes(A,8),h,e.bignum.toBytes(I,8),e.bignum.toBytes(B,8)];i&&W.push(i);const F=e.makeApplicationCallTxnFromObject({from:a,appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),onComplete:e.OnApplicationComplete.NoOpOC,appArgs:W,foreignApps:[e.safeBigIntToNumber(this.coreAppId)],foreignAssets:[n],accounts:N,suggestedParams:c});F.fee*=2,m.push({tx:F});for(const x of m)yield this.createUnsignedTx(x,"TokenBridge.transfer",!0)}async*redeem(o,t,r=!0,s){s||(s=await this.connection.getTransactionParams().do());const i=new e.AlgorandAddress(o).toString(),{accounts:a,txs:n}=await d.AlgorandWormholeCore.submitVAAHeader(this.connection,this.coreAppId,this.tokenBridgeAppId,t,i);let A,I="",h=[],c=0;if(t.payload.token.chain!==this.chain){A=d.StorageLogicSig.forWrappedAsset(this.tokenBridgeAppId,t.payload.token),I=A.address();const f=await d.StorageLogicSig.decodeLocalState(this.connection,this.tokenBridgeAppId,I);c=new e.AlgorandAddress(f.slice(0,8)).toInt()}else{const f=new e.AlgorandAddress(t.payload.token.address).toBigInt();A=d.StorageLogicSig.forNativeAsset(this.tokenBridgeAppId,f),I=A.address(),c=e.safeBigIntToNumber(f)}a.push(I);let B=0,w="";if(t.payloadName==="TransferWithPayload"?(B=new e.AlgorandAddress(t.payload.to.address).toInt(),w=e.getApplicationAddress(B)):w=new e.AlgorandAddress(t.payload.to.address.toUint8Array()).toString(),a.push(w),c!==0&&(h.push(c),!await p.isOptedInToAsset(this.connection,w,c))){if(i!=w)throw new Error("Cannot ASA optin for somebody else (asset "+c.toString()+")");n.unshift({tx:e.makeAssetTransferTxnWithSuggestedParamsFromObject({amount:0,assetIndex:c,from:i,suggestedParams:s,to:i})})}const m={accounts:a,appArgs:[p.completeTransfer,e.serialize(t)],appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),foreignAssets:h,from:i,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:s};n.push({tx:e.makeApplicationCallTxnFromObject(m)}),n[n.length-1].tx.fee=n[n.length-1].tx.fee*(t.payloadName==="Transfer"&&t.payload.fee!==void 0&&t.payload.fee===0n?2:3),t.payloadName==="TransferWithPayload"&&(n[n.length-1].tx.appForeignApps=[B],n.push({tx:e.makeApplicationCallTxnFromObject({appArgs:[j.getSelector(),j.args[0].type.encode(e.serialize(t))],appIndex:B,foreignAssets:h,from:i,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:s})}));for(const f of n)yield this.createUnsignedTx(f,"TokenBridge.redeem",!0)}static async isOptedInToAsset(o,t,r){var s;try{const i=await o.accountAssetInformation(t,r).do();return(((s=e.AccountAssetResponse.from_obj_for_encoding(i).assetHolding)==null?void 0:s.amount)??0)>0}catch{}return!1}createUnsignedTx(o,t,r=!0){return new d.AlgorandUnsignedTransaction(o,this.network,this.chain,t,r)}};g(p,"sendTransfer",e.bytes.encode("sendTransfer")),g(p,"attestToken",e.bytes.encode("attestToken")),g(p,"noop",e.bytes.encode("nop")),g(p,"optIn",e.bytes.encode("optin")),g(p,"completeTransfer",e.bytes.encode("completeTransfer")),g(p,"receiveAttest",e.bytes.encode("receiveAttest"));let O=p;e.registerProtocol(e._platform$4,"TokenBridge",O);exports.AlgorandTokenBridge=O;exports.TransferMethodSelector=j;
|
|
1
|
+
"use strict";var P=Object.defineProperty;var U=(k,o,t)=>o in k?P(k,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):k[o]=t;var g=(k,o,t)=>U(k,typeof o!="symbol"?o+"":o,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index-CNuaRHT9.js"),e=require("./index-B5r3vRTo.js"),v=require("./algorand-HCN4Bwfj.js"),j=e.ABIMethod.fromSignature("portal_transfer(byte[])byte[]"),p=class p{constructor(o,t,r,s){g(this,"network");g(this,"chain");g(this,"connection");g(this,"contracts");g(this,"chainId");g(this,"coreBridge");g(this,"coreAppId");g(this,"coreAppAddress");g(this,"tokenBridgeAppId");g(this,"tokenBridgeAddress");if(this.network=o,this.chain=t,this.connection=r,this.contracts=s,this.chainId=e.toChainId(t),!s.coreBridge)throw new Error(`Core contract address for chain ${t} not found`);const i=BigInt(s.coreBridge);if(this.coreAppId=i,this.coreAppAddress=e.getApplicationAddress(i),this.coreBridge=new d.AlgorandWormholeCore(o,t,r,s),!s.tokenBridge)throw new Error(`TokenBridge contract address for chain ${t} not found`);const a=BigInt(s.tokenBridge);this.tokenBridgeAppId=a,this.tokenBridgeAddress=e.getApplicationAddress(a)}static async fromRpc(o,t){const[r,s]=await v.AlgorandPlatform.chainFromRpc(o),i=t[s];if(i.network!==r)throw new Error(`Network mismatch: ${i.network} != ${r}`);return new p(r,s,o,i.contracts)}async isWrappedAsset(o){const t=new e.AlgorandAddress(o).toInt();if(t===0)return!1;const r=await this.connection.getAssetByID(t).do(),i=e.Asset.from_obj_for_encoding(r).params.creator,a=await this.connection.accountInformation(i).exclude("all").do(),n=e.Account.from_obj_for_encoding(a);return(n==null?void 0:n.authAddr)===this.tokenBridgeAddress}async getOriginalAsset(o){const t=new e.AlgorandAddress(o).toInt(),r=await this.connection.getAssetByID(t).do(),s=e.Asset.from_obj_for_encoding(r),i=await d.StorageLogicSig.decodeLocalState(this.connection,this.tokenBridgeAppId,s.params.creator);if(i.length<94)throw new Error("Invalid local state data");const a=i.slice(92,94),n=e.toChain(e.bignum.decode(a)),A=new e.UniversalAddress(i.slice(60,92));return{chain:n,address:A}}async getTokenUniversalAddress(o){return new e.AlgorandAddress(o).toUniversalAddress()}async getTokenNativeAddress(o,t){return new e.AlgorandAddress(t).toNative()}async getWrappedAsset(o){if(e.isNative(o.address))throw new Error("native asset cannot be a wrapped asset");const t=d.StorageLogicSig.forWrappedAsset(this.tokenBridgeAppId,o),r=await d.StorageLogicSig.decodeLocalState(this.connection,this.tokenBridgeAppId,t.address());if(r.length<8)throw new Error("Invalid wrapped asset data");return e.toNative(this.chain,e.bignum.decode(r.slice(0,8)).toString())}async hasWrappedAsset(o){try{return await this.getWrappedAsset(o),!0}catch{}return!1}async getWrappedNative(){return e.toNative(this.chain,"0")}async isTransferCompleted(o){const t=d.StorageLogicSig.forMessageId(this.tokenBridgeAppId,{sequence:o.sequence,chain:o.emitterChain,emitter:o.emitterAddress});try{return await d.StorageLogicSig.checkBitsSet(this.connection,this.tokenBridgeAppId,t.address(),o.sequence)}catch{}return!1}async*createAttestation(o,t){if(!t)throw new Error("Payer required to create attestation");const r=new e.AlgorandAddress(t).toString(),s=new e.AlgorandAddress(o).toInt(),i=[],a=await this.connection.getTransactionParams().do(),n=d.StorageLogicSig.forEmitter(this.coreAppId,new e.AlgorandAddress(this.tokenBridgeAddress).toUint8Array()),{accounts:[A],txs:I}=await d.AlgorandWormholeCore.maybeCreateStorageTx(this.connection,r,this.coreAppId,n,a);i.push(...I);let h="",c;if(s!==0){const u=await this.connection.getAssetByID(s).do(),b=e.Asset.from_obj_for_encoding(u),S=await this.connection.accountInformation(b.params.creator).do();if(c=e.Account.from_obj_for_encoding(S),c.authAddr===this.tokenBridgeAddress.toString())throw new Error("Cannot re-attest wormhole assets")}const B=d.StorageLogicSig.forNativeAsset(this.tokenBridgeAppId,BigInt(s)),w=await d.AlgorandWormholeCore.maybeCreateStorageTx(this.connection,r,this.tokenBridgeAppId,B);h=w.accounts[0],i.push(...w.txs);const m=e.makeApplicationCallTxnFromObject({from:r,appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),onComplete:e.OnApplicationComplete.NoOpOC,appArgs:[p.noop],suggestedParams:a});i.push({tx:m});const f=await this.coreBridge.getMessageFee();if(f>BigInt(0)){const u=e.makePaymentTxnWithSuggestedParamsFromObject({from:r,suggestedParams:a,to:this.tokenBridgeAddress,amount:f});i.push({tx:u})}let y=[A,h,this.coreAppAddress];c&&y.push(c.address);let l=e.makeApplicationCallTxnFromObject({appArgs:[p.attestToken,e.bignum.toBytes(s,8)],accounts:y,appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),foreignApps:[e.safeBigIntToNumber(this.coreAppId)],foreignAssets:[s],from:r,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:a});f>BigInt(0)?l.fee*=3:l.fee*=2,i.push({tx:l});for(const u of i)yield this.createUnsignedTx(u,"TokenBridge.createAttestation",!0)}async*submitAttestation(o,t,r){if(!t)throw new Error("Sender required to submit attestation");r||(r=await this.connection.getTransactionParams().do());const s=t.toString(),a=d.StorageLogicSig.forWrappedAsset(this.tokenBridgeAppId,o.payload.token).address(),n=[],A=[],I=await d.StorageLogicSig.decodeLocalState(this.connection,this.tokenBridgeAppId,a);I.length>8&&A.push(new e.AlgorandAddress(I.slice(0,8)).toInt()),n.push({tx:e.makePaymentTxnWithSuggestedParamsFromObject({from:s,to:a,amount:1e5,suggestedParams:r})});let h=new Uint8Array(1);h[0]=1,n.push({tx:e.makeApplicationCallTxnFromObject({appArgs:[p.noop,h],appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),from:s,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:r})}),h=new Uint8Array(1),h[0]=2,n.push({tx:e.makeApplicationCallTxnFromObject({appArgs:[p.noop,h],appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),from:s,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:r})}),n.push({tx:e.makeApplicationCallTxnFromObject({accounts:[],appArgs:[p.receiveAttest,e.serialize(o)],appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),foreignAssets:A,from:s,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:r})}),n[n.length-1].tx.fee=n[n.length-1].tx.fee*2;for(const c of n)yield this.createUnsignedTx(c,"TokenBridge.submitAttestation",!0)}async*transfer(o,t,r,s,i){const a=o.toString(),n=e.isNative(r)?0:new e.AlgorandAddress(r).toInt(),A=s,I=e.toChainId(t.chain),h=t.address.toUniversalAddress().toUint8Array(),c=await this.connection.getTransactionParams().do(),B=BigInt(0),w=d.StorageLogicSig.fromData({appId:this.coreAppId,appAddress:e.decodeAddress(this.coreAppAddress).publicKey,idx:BigInt(0),address:e.decodeAddress(this.tokenBridgeAddress).publicKey}),m=[],{accounts:[f],txs:y}=await d.AlgorandWormholeCore.maybeCreateStorageTx(this.connection,a,this.coreAppId,w,c);m.push(...y);let l="",u,b=!1;if(n!==0){const x=await this.connection.getAssetByID(n).do();l=e.Asset.from_obj_for_encoding(x).params.creator;const C=await this.connection.accountInformation(l).do();u=e.Account.from_obj_for_encoding(C),b=u.authAddr===this.tokenBridgeAddress.toString()}const S=await this.coreBridge.getMessageFee();if(S>0&&m.push({tx:e.makePaymentTxnWithSuggestedParamsFromObject({from:a,to:this.tokenBridgeAddress,amount:S,suggestedParams:c})}),!b){const x=d.StorageLogicSig.forNativeAsset(this.tokenBridgeAppId,BigInt(n)),{accounts:[T],txs:C}=await d.AlgorandWormholeCore.maybeCreateStorageTx(this.connection,a,this.tokenBridgeAppId,x,c);l=T,C.push(...C)}if(n!==0&&!await p.isOptedInToAsset(this.connection,l,n)){const x=e.makePaymentTxnWithSuggestedParamsFromObject({from:a,to:l,amount:1e5,suggestedParams:c});let T=e.makeApplicationCallTxnFromObject({from:a,appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),onComplete:e.OnApplicationComplete.NoOpOC,appArgs:[p.optIn,e.bigIntToBytes(n,8)],foreignAssets:[n],accounts:[l],suggestedParams:c});T.fee*=2,m.unshift({tx:x},{tx:T})}const L=e.makeApplicationCallTxnFromObject({from:a,appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),onComplete:e.OnApplicationComplete.NoOpOC,appArgs:[p.noop],suggestedParams:c});m.push({tx:L});let N=[];if(n===0){const x=e.makePaymentTxnWithSuggestedParamsFromObject({from:a,to:l,amount:A,suggestedParams:c});m.push({tx:x}),N=[f,l,l]}else{const x=e.makeAssetTransferTxnWithSuggestedParamsFromObject({from:a,to:l,amount:A,assetIndex:n,suggestedParams:c});m.push({tx:x}),N=u!=null&&u.address?[f,l,u.address]:[f,l]}const W=[p.sendTransfer,e.bignum.toBytes(n,8),e.bignum.toBytes(A,8),h,e.bignum.toBytes(I,8),e.bignum.toBytes(B,8)];i&&W.push(i);const F=e.makeApplicationCallTxnFromObject({from:a,appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),onComplete:e.OnApplicationComplete.NoOpOC,appArgs:W,foreignApps:[e.safeBigIntToNumber(this.coreAppId)],foreignAssets:[n],accounts:N,suggestedParams:c});F.fee*=2,m.push({tx:F});for(const x of m)yield this.createUnsignedTx(x,"TokenBridge.transfer",!0)}async*redeem(o,t,r=!0,s){s||(s=await this.connection.getTransactionParams().do());const i=new e.AlgorandAddress(o).toString(),{accounts:a,txs:n}=await d.AlgorandWormholeCore.submitVAAHeader(this.connection,this.coreAppId,this.tokenBridgeAppId,t,i);let A,I="",h=[],c=0;if(t.payload.token.chain!==this.chain){A=d.StorageLogicSig.forWrappedAsset(this.tokenBridgeAppId,t.payload.token),I=A.address();const f=await d.StorageLogicSig.decodeLocalState(this.connection,this.tokenBridgeAppId,I);c=new e.AlgorandAddress(f.slice(0,8)).toInt()}else{const f=new e.AlgorandAddress(t.payload.token.address).toBigInt();A=d.StorageLogicSig.forNativeAsset(this.tokenBridgeAppId,f),I=A.address(),c=e.safeBigIntToNumber(f)}a.push(I);let B=0,w="";if(t.payloadName==="TransferWithPayload"?(B=new e.AlgorandAddress(t.payload.to.address).toInt(),w=e.getApplicationAddress(B)):w=new e.AlgorandAddress(t.payload.to.address.toUint8Array()).toString(),a.push(w),c!==0&&(h.push(c),!await p.isOptedInToAsset(this.connection,w,c))){if(i!=w)throw new Error("Cannot ASA optin for somebody else (asset "+c.toString()+")");n.unshift({tx:e.makeAssetTransferTxnWithSuggestedParamsFromObject({amount:0,assetIndex:c,from:i,suggestedParams:s,to:i})})}const m={accounts:a,appArgs:[p.completeTransfer,e.serialize(t)],appIndex:e.safeBigIntToNumber(this.tokenBridgeAppId),foreignAssets:h,from:i,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:s};n.push({tx:e.makeApplicationCallTxnFromObject(m)}),n[n.length-1].tx.fee=n[n.length-1].tx.fee*(t.payloadName==="Transfer"&&t.payload.fee!==void 0&&t.payload.fee===0n?2:3),t.payloadName==="TransferWithPayload"&&(n[n.length-1].tx.appForeignApps=[B],n.push({tx:e.makeApplicationCallTxnFromObject({appArgs:[j.getSelector(),j.args[0].type.encode(e.serialize(t))],appIndex:B,foreignAssets:h,from:i,onComplete:e.OnApplicationComplete.NoOpOC,suggestedParams:s})}));for(const f of n)yield this.createUnsignedTx(f,"TokenBridge.redeem",!0)}static async isOptedInToAsset(o,t,r){var s;try{const i=await o.accountAssetInformation(t,r).do();return(((s=e.AccountAssetResponse.from_obj_for_encoding(i).assetHolding)==null?void 0:s.amount)??0)>0}catch{}return!1}createUnsignedTx(o,t,r=!0){return new d.AlgorandUnsignedTransaction(o,this.network,this.chain,t,r)}};g(p,"sendTransfer",e.bytes.encode("sendTransfer")),g(p,"attestToken",e.bytes.encode("attestToken")),g(p,"noop",e.bytes.encode("nop")),g(p,"optIn",e.bytes.encode("optin")),g(p,"completeTransfer",e.bytes.encode("completeTransfer")),g(p,"receiveAttest",e.bytes.encode("receiveAttest"));let O=p;e.registerProtocol(e._platform$4,"TokenBridge",O);exports.AlgorandTokenBridge=O;exports.TransferMethodSelector=j;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var xr=Object.defineProperty;var Br=(t,e,r)=>e in t?xr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var U=(t,e,r)=>Br(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./index-Dh6mkRtz.js"),b=require("./sui-BJBxQjSI.js");require("./index-Cg6LDJti.js");class qt{constructor(e,r,n,i,s=!1){U(this,"transaction");U(this,"network");U(this,"chain");U(this,"description");U(this,"parallelizable");this.transaction=e,this.network=r,this.chain=n,this.description=i,this.parallelizable=s}}class Cr extends TypeError{constructor(e,r){let n;const{message:i,explanation:s,...c}=e,{path:a}=e,o=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??o),s!=null&&(this.cause=o),Object.assign(this,c),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function $r(t){return K(t)&&typeof t[Symbol.iterator]=="function"}function K(t){return typeof t=="object"&&t!=null}function J(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function Ur(t){const{done:e,value:r}=t.next();return e?void 0:r}function Pr(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:s}=e,{type:c}=r,{refinement:a,message:o=`Expected a value of type \`${c}\`${a?` with refinement \`${a}\``:""}, but received: \`${J(n)}\``}=t;return{value:n,type:c,refinement:a,key:i[i.length-1],path:i,branch:s,...t,message:o}}function*Lt(t,e,r,n){$r(t)||(t=[t]);for(const i of t){const s=Pr(i,e,r,n);s&&(yield s)}}function*lt(t,e,r={}){const{path:n=[],branch:i=[t],coerce:s=!1,mask:c=!1}=r,a={path:n,branch:i};if(s&&(t=e.coercer(t,a),c&&e.type!=="type"&&K(e.schema)&&K(t)&&!Array.isArray(t)))for(const d in t)e.schema[d]===void 0&&delete t[d];let o="valid";for(const d of e.validator(t,a))d.explanation=r.message,o="not_valid",yield[d,void 0];for(let[d,u,g]of e.entries(t,a)){const m=lt(u,g,{path:d===void 0?n:[...n,d],branch:d===void 0?i:[...i,u],coerce:s,mask:c,message:r.message});for(const y of m)y[0]?(o=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):s&&(u=y[1],d===void 0?t=u:t instanceof Map?t.set(d,u):t instanceof Set?t.add(u):K(t)&&(u!==void 0||d in t)&&(t[d]=u))}if(o!=="not_valid")for(const d of e.refiner(t,a))d.explanation=r.message,o="not_refined",yield[d,void 0];o==="valid"&&(yield[void 0,t])}class te{constructor(e){const{type:r,schema:n,validator:i,refiner:s,coercer:c=o=>o,entries:a=function*(){}}=e;this.type=r,this.schema=n,this.entries=a,this.coercer=c,i?this.validator=(o,d)=>{const u=i(o,d);return Lt(u,d,this,o)}:this.validator=()=>[],s?this.refiner=(o,d)=>{const u=s(o,d);return Lt(u,d,this,o)}:this.refiner=()=>[]}assert(e,r){return nt(e,this,r)}create(e,r){return Xt(e,this,r)}is(e){return L(e,this)}mask(e,r){return Zt(e,this,r)}validate(e,r={}){return _e(e,this,r)}}function nt(t,e,r){const n=_e(t,e,{message:r});if(n[0])throw n[0]}function Xt(t,e,r){const n=_e(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Zt(t,e,r){const n=_e(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function L(t,e){return!_e(t,e)[0]}function _e(t,e,r={}){const n=lt(t,e,r),i=Ur(n);return i[0]?[new Cr(i[0],function*(){for(const c of n)c[0]&&(yield c[0])}),void 0]:[void 0,i[1]]}function je(...t){const e=t[0].type==="type",r=t.map(i=>i.schema),n=Object.assign({},...r);return e?Rr(n):p(n)}function W(t,e){return new te({type:t,schema:null,validator:e})}function it(){return W("any",()=>!0)}function E(t){return new te({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${J(e)}`}})}function Mr(){return W("bigint",t=>typeof t=="bigint")}function z(){return W("boolean",t=>typeof t=="boolean")}function ee(){return W("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${J(t)}`)}function k(t){const e=J(t),r=typeof t;return new te({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${J(n)}`}})}function Yt(){return W("never",()=>!1)}function $(t){return new te({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function he(){return W("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${J(t)}`)}function p(t){const e=t?Object.keys(t):[],r=Yt();return new te({type:"object",schema:t||null,*entries(n){if(t&&K(n)){const i=new Set(Object.keys(n));for(const s of e)i.delete(s),yield[s,n[s],t[s]];for(const s of i)yield[s,n[s],r]}},validator(n){return K(n)||`Expected an object, but received: ${J(n)}`},coercer(n){return K(n)?{...n}:n}})}function v(t){return new te({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Q(t,e){return new te({type:"record",schema:null,*entries(r){if(K(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator(r){return K(r)||`Expected an object, but received: ${J(r)}`}})}function h(){return W("string",t=>typeof t=="string"||`Expected a string, but received: ${J(t)}`)}function Qt(t){const e=Yt();return new te({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;i<n;i++)yield[i,r[i],t[i]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${J(r)}`}})}function Rr(t){const e=Object.keys(t);return new te({type:"type",schema:t,*entries(r){if(K(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return K(r)||`Expected an object, but received: ${J(r)}`},coercer(r){return K(r)?{...r}:r}})}function P(t){const e=t.map(r=>r.type).join(" | ");return new te({type:"union",schema:null,coercer(r){for(const n of t){const[i,s]=n.validate(r,{coerce:!0});if(!i)return s}return r},validator(r,n){const i=[];for(const s of t){const[...c]=lt(r,s,n),[a]=c;if(a[0])for(const[o]of c)o&&i.push(o);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${J(r)}`,...i]}})}function er(){return W("unknown",()=>!0)}const ft=P([p({AddressOwner:h()}),p({ObjectOwner:h()}),p({Shared:p({initial_shared_version:$(h())})}),k("Immutable")]);W("SuiJsonValue",()=>!0);const Nr=P([p({u32:h()}),p({u64:h()}),p({f64:h()})]);p({attributes:Q(h(),$(Nr)),featureFlags:Q(h(),z()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});P([h(),k("package")]);const ce=p({digest:h(),objectId:h(),version:P([he(),h(),Mr()])});p({owner:ft,reference:ce});p({objectId:h(),sequenceNumber:h()});p({payment:E(ce),owner:h(),price:h(),budget:h()});const Dr=je(ce,p({type:h(),owner:ft,previousTransaction:h()})),Vr=Q(h(),it()),zr=Q(h(),er()),Fr=p({type:h(),fields:Vr,hasPublicTransfer:z()}),Gr=p({disassembled:zr}),Lr=P([je(Fr,p({dataType:k("moveObject")})),je(Gr,p({dataType:k("package")}))]),Wr=p({type:h(),hasPublicTransfer:z(),version:h(),bcsBytes:h()}),Kr=p({id:h(),moduleMap:Q(h(),h())}),Jr=P([je(Wr,p({dataType:k("moveObject")})),je(Kr,p({dataType:k("package")}))]);BigInt(1e9);const tr=p({code:h(),error:v(h()),object_id:v(h()),parent_object_id:v(h()),version:v(h()),digest:v(h())}),Hr=p({data:$(v(Q(h(),h()))),error:$(v(tr))}),qr=P([Hr,v(Q(h(),h()))]),rr=p({objectId:h(),version:h(),digest:h(),type:$(v(h())),content:$(v(Lr)),bcs:$(v(Jr)),owner:$(v(ft)),previousTransaction:$(v(h())),storageRebate:$(v(h())),display:$(v(qr))});p({showType:$(v(z())),showContent:$(v(z())),showBcs:$(v(z())),showOwner:$(v(z())),showPreviousTransaction:$(v(z())),showStorageRebate:$(v(z())),showDisplay:$(v(z()))});P([k("Exists"),k("notExists"),k("Deleted")]);E(Dr);const Xr=p({data:$(v(rr)),error:$(v(tr))});function Zr(t){return t.data}function Yr(t){if(t.error&&"object_id"in t.error&&"version"in t.error&&"digest"in t.error){const e=t.error;return{objectId:e.object_id,version:e.version,digest:e.digest}}}function Wt(t){if("reference"in t)return t.reference;const e=Zr(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:Yr(t)}p({objectId:h(),atCheckpoint:v(he())});p({data:E(Xr),nextCursor:v($(h())),hasNextPage:z()});P([p({details:rr,status:k("VersionFound")}),p({details:h(),status:k("ObjectNotExists")}),p({details:ce,status:k("ObjectDeleted")}),p({details:Qt([h(),he()]),status:k("VersionNotFound")}),p({details:p({asked_version:he(),latest_version:he(),object_id:h()}),status:k("VersionTooHigh")})]);const Qr=P([h(),p({Object:h()})]);E(Qr);const en=p({address:h(),name:h()}),tn=P([k("Private"),k("Public"),k("Friend")]),ht=p({abilities:E(h())}),rn=p({constraints:ht,isPhantom:z()}),nn=p({TypeParameter:he()}),Xe=Qt([p({module:h(),package:h(),function:h()}),h()]);p({rank3Days:E(Xe),rank7Days:E(Xe),rank30Days:E(Xe)});function nr(t){if(!t)return!1;if(typeof t=="string"||L(t,nn)||ir(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(L(e.Reference,me)||L(e.MutableReference,me)||L(e.Vector,me))}const me=W("SuiMoveNormalizedType",nr);function ir(t){if(!t||typeof t!="object")return!1;const e=t;if(!e.Struct||typeof e.Struct!="object")return!1;const r=e.Struct;return!(typeof r.address!="string"||typeof r.module!="string"||typeof r.name!="string"||!Array.isArray(r.typeArguments)||!r.typeArguments.every(n=>nr(n)))}W("SuiMoveNormalizedStructType",ir);const sn=p({visibility:tn,isEntry:z(),typeParameters:E(ht),parameters:E(me),return:E(me)}),an=p({name:h(),type:me}),on=p({abilities:ht,typeParameters:E(rn),fields:E(an)}),cn=p({fileFormatVersion:he(),address:h(),name:h(),friends:E(en),structs:Q(h(),on),exposedFunctions:Q(h(),sn)});Q(h(),cn);function st(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function sr(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function gt(t){if(typeof t=="object"&&"Struct"in t)return t;const e=sr(t),r=st(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}function un(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=n}var c=t.length,a=t.charAt(0),o=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function u(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var S=0,T=0,f=0,O=y.length;f!==O&&y[f]===0;)f++,S++;for(var B=(O-f)*d+1>>>0,M=new Uint8Array(B);f!==O;){for(var A=y[f],j=0,R=B-1;(A!==0||j<T)&&R!==-1;R--,j++)A+=256*M[R]>>>0,M[R]=A%c>>>0,A=A/c>>>0;if(A!==0)throw new Error("Non-zero carry");T=j,f++}for(var H=B-T;H!==B&&M[H]===0;)H++;for(var pe=a.repeat(S);H<B;++H)pe+=t.charAt(M[H]);return pe}function g(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;for(var S=0,T=0,f=0;y[S]===a;)T++,S++;for(var O=(y.length-S)*o+1>>>0,B=new Uint8Array(O);y[S];){var M=e[y.charCodeAt(S)];if(M===255)return;for(var A=0,j=O-1;(M!==0||A<f)&&j!==-1;j--,A++)M+=c*B[j]>>>0,B[j]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");f=A,S++}for(var R=O-f;R!==O&&B[R]===0;)R++;for(var H=new Uint8Array(T+(O-R)),pe=T;R!==O;)H[pe++]=B[R++];return H}function m(y){var S=g(y);if(S)return S;throw new Error("Non-base"+c+" character")}return{encode:u,decodeUnsafe:g,decode:m}}var dn=un;const ln=dn,fn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var hn=ln(fn);const ar=w.getDefaultExportFromCjs(hn),xe=t=>ar.encode(t),pt=t=>ar.decode(t);function ue(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const Ze=8192;function Be(t){if(t.length<Ze)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=Ze){const n=t.slice(r,r+Ze);e+=String.fromCharCode(...n)}return btoa(e)}function Je(t){var i;const e=t.startsWith("0x")?t.slice(2):t,n=((i=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:i.map(s=>parseInt(s,16)))??[];return Uint8Array.from(n)}function Ce(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function yt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function gn(t){let e=0,r=0,n=0;for(;;){let i=t[n];if(n+=1,e|=(i&127)<<r,!(i&128))break;r+=7}return{value:e,length:n}}class or{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:i}=gn(r);return this.shift(i),n}readVec(e){let r=this.readULEB(),n=[];for(let i=0;i<r;i++)n.push(e(this,i,r));return n}}function pn(t,e){switch(e){case"base58":return xe(t);case"base64":return Be(t);case"hex":return Ce(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function yn(t,e){switch(e){case"base58":return pt(t);case"base64":return ue(t);case"hex":return Je(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function mt(t,e=["<",">"]){const[r,n]=e,i=[];let s="",c=0;for(let a=0;a<t.length;a++){const o=t[a];if(o===r&&c++,o===n&&c--,c===0&&o===","){i.push(s.trim()),s="";continue}s+=o}return i.push(s.trim()),i}class cr{constructor({size:e=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=r||e,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const r=this.bytePosition+e;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const i=new ArrayBuffer(this.size);new Uint8Array(i).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(i)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}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 Ye(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return Ye(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return Ye(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return yt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,i)=>r(this,n,i,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 pn(this.toBytes(),e)}}function Ye(t,e){let r=new Uint8Array(e),n=0;for(;t>0;)r[n]=Number(t%BigInt(256)),t=t/BigInt(256),n+=1;return r}var ur=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},X=(t,e,r)=>(ur(t,e,"read from private field"),r?r.call(t):e.get(t)),ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Fe=(t,e,r,n)=>(ur(t,e,"write to private field"),e.set(t,r),r),ye,Se,Me,ae;const dr=class{constructor(t){ze(this,ye,void 0),ze(this,Se,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),Fe(this,ye,t.write),Fe(this,Se,t.serialize??((e,r)=>{const n=new cr({size:this.serializedSize(e)??void 0,...r});return X(this,ye).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),X(this,ye).call(this,t,e)}serialize(t,e){return this.validate(t),new mn(this,X(this,Se).call(this,t,e))}parse(t){const e=new or(t);return this.read(e)}transform({name:t,input:e,output:r}){return new dr({name:t??this.name,read:n=>r(this.read(n)),write:(n,i)=>X(this,ye).call(this,e(n),i),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,i)=>X(this,Se).call(this,e(n),i),validate:n=>this.validate(e(n))})}};let Z=dr;ye=new WeakMap;Se=new WeakMap;const lr=Symbol.for("@mysten/serialized-bcs");function wt(t){return!!t&&typeof t=="object"&&t[lr]===!0}class mn{constructor(e,r){ze(this,Me,void 0),ze(this,ae,void 0),Fe(this,Me,e),Fe(this,ae,r)}get[lr](){return!0}toBytes(){return X(this,ae)}toHex(){return Ce(X(this,ae))}toBase64(){return Be(X(this,ae))}toBase58(){return xe(X(this,ae))}parse(){return X(this,Me).parse(X(this,ae))}}Me=new WeakMap;ae=new WeakMap;function Ge({size:t,...e}){return new Z({...e,serializedSize:()=>t})}function Qe({readMethod:t,writeMethod:e,...r}){return Ge({...r,read:n=>n[t](),write:(n,i)=>i[e](n),validate:n=>{var i;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,n)}})}function et({readMethod:t,writeMethod:e,...r}){return Ge({...r,read:n=>n[t](),write:(n,i)=>i[e](BigInt(n)),validate:n=>{var s;const i=BigInt(n);if(i<0||i>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${i}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,i)}})}function wn({serialize:t,...e}){const r=new Z({...e,serialize:t,write:(n,i)=>{for(const s of r.serialize(n).toBytes())i.write8(s)}});return r}function bn({toBytes:t,fromBytes:e,...r}){return new Z({...r,read:n=>{const i=n.readULEB(),s=n.readBytes(i);return e(s)},write:(n,i)=>{const s=t(n);i.writeULEB(s.length);for(let c=0;c<s.length;c++)i.write8(s[c])},serialize:n=>{const i=t(n),s=yt(i.length),c=new Uint8Array(s.length+i.length);return c.set(s,0),c.set(i,s.length),c},validate:n=>{var i;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(i=r.validate)==null||i.call(r,n)}})}function Sn(t){let e=null;function r(){return e||(e=t()),e}return new Z({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,i)=>r().write(n,i),serialize:(n,i)=>r().serialize(n,i).toBytes()})}const l={u8(t){return Qe({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return Qe({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return Qe({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return et({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return et({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return et({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Ge({name:"bool",size:1,read:e=>e.read8()===1,write:(e,r)=>r.write8(e?1:0),...t,validate:e=>{var r;if((r=t==null?void 0:t.validate)==null||r.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return wn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(yt(e)),...t})},bytes(t,e){return Ge({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let i=0;i<t;i++)n.write8(r[i]??0)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("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}`)}})},string(t){return bn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new Z({name:`${e.name}[${t}]`,read:n=>{const i=new Array(t);for(let s=0;s<t;s++)i[s]=e.read(n);return i},write:(n,i)=>{for(const s of n)e.write(s,i)},...r,validate:n=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,n),!("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}`)}})},option(t){return l.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>"Some"in e?e.Some:null})},vector(t,e){return new Z({name:`vector<${t.name}>`,read:r=>{const n=r.readULEB(),i=new Array(n);for(let s=0;s<n;s++)i[s]=t.read(r);return i},write:(r,n)=>{n.writeULEB(r.length);for(const i of r)t.write(i,n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`)}})},tuple(t,e){return new Z({name:`(${t.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let i=0;i<t.length;i++){const s=t[i].serializedSize(r[i]);if(s==null)return null;n+=s}return n},read:r=>{const n=[];for(const i of t)n.push(i.read(r));return n},write:(r,n)=>{for(let i=0;i<t.length;i++)t[i].write(r[i],n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!Array.isArray(r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t.length)throw new TypeError(`Expected array of length ${t.length}, found ${r.length}`)}})},struct(t,e,r){const n=Object.entries(e);return new Z({name:t,serializedSize:i=>{let s=0;for(const[c,a]of n){const o=a.serializedSize(i[c]);if(o==null)return null;s+=o}return s},read:i=>{const s={};for(const[c,a]of n)s[c]=a.read(i);return s},write:(i,s)=>{for(const[c,a]of n)a.write(i[c],s)},...r,validate:i=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`)}})},enum(t,e,r){const n=Object.entries(e);return new Z({name:t,read:i=>{const s=i.readULEB(),[c,a]=n[s];return{[c]:(a==null?void 0:a.read(i))??!0}},write:(i,s)=>{const[c,a]=Object.entries(i)[0];for(let o=0;o<n.length;o++){const[d,u]=n[o];if(d===c){s.writeULEB(o),u==null||u.write(a,s);return}}},...r,validate:i=>{var a;if((a=r==null?void 0:r.validate)==null||a.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`);const s=Object.keys(i);if(s.length!==1)throw new TypeError(`Expected object with one key, found ${s.length}`);const[c]=s;if(!Object.hasOwn(e,c))throw new TypeError(`Invalid enum variant ${c}`)}})},map(t,e){return l.vector(l.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[i,s]of r)n.set(i,s);return n}})},generic(t,e){return(...r)=>e(...r).transform({name:`${e.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(t){return Sn(t)}},Tn=32,Te=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof Te){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(Te.ADDRESS,t.addressLength,t.addressEncoding),this.registerVectorType(t.vectorType),t.types&&t.types.structs)for(let e of Object.keys(t.types.structs))this.registerStructType(e,t.types.structs[e]);if(t.types&&t.types.enums)for(let e of Object.keys(t.types.enums))this.registerEnumType(e,t.types.enums[e]);if(t.types&&t.types.aliases)for(let e of Object.keys(t.types.aliases))this.registerAlias(e,t.types.aliases[e]);t.withPrimitives!==!1&&vn(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:i}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,i)}if(typeof t=="object"){const n=this.tempKey();return new Te(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
1
|
+
"use strict";var xr=Object.defineProperty;var Br=(t,e,r)=>e in t?xr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var U=(t,e,r)=>Br(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./index-B5r3vRTo.js"),b=require("./sui-CuJDivKm.js");require("./index-B7VunQ0V.js");class qt{constructor(e,r,n,i,s=!1){U(this,"transaction");U(this,"network");U(this,"chain");U(this,"description");U(this,"parallelizable");this.transaction=e,this.network=r,this.chain=n,this.description=i,this.parallelizable=s}}class Cr extends TypeError{constructor(e,r){let n;const{message:i,explanation:s,...c}=e,{path:a}=e,o=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??o),s!=null&&(this.cause=o),Object.assign(this,c),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function $r(t){return K(t)&&typeof t[Symbol.iterator]=="function"}function K(t){return typeof t=="object"&&t!=null}function J(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function Ur(t){const{done:e,value:r}=t.next();return e?void 0:r}function Pr(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:s}=e,{type:c}=r,{refinement:a,message:o=`Expected a value of type \`${c}\`${a?` with refinement \`${a}\``:""}, but received: \`${J(n)}\``}=t;return{value:n,type:c,refinement:a,key:i[i.length-1],path:i,branch:s,...t,message:o}}function*Lt(t,e,r,n){$r(t)||(t=[t]);for(const i of t){const s=Pr(i,e,r,n);s&&(yield s)}}function*lt(t,e,r={}){const{path:n=[],branch:i=[t],coerce:s=!1,mask:c=!1}=r,a={path:n,branch:i};if(s&&(t=e.coercer(t,a),c&&e.type!=="type"&&K(e.schema)&&K(t)&&!Array.isArray(t)))for(const d in t)e.schema[d]===void 0&&delete t[d];let o="valid";for(const d of e.validator(t,a))d.explanation=r.message,o="not_valid",yield[d,void 0];for(let[d,u,g]of e.entries(t,a)){const m=lt(u,g,{path:d===void 0?n:[...n,d],branch:d===void 0?i:[...i,u],coerce:s,mask:c,message:r.message});for(const y of m)y[0]?(o=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):s&&(u=y[1],d===void 0?t=u:t instanceof Map?t.set(d,u):t instanceof Set?t.add(u):K(t)&&(u!==void 0||d in t)&&(t[d]=u))}if(o!=="not_valid")for(const d of e.refiner(t,a))d.explanation=r.message,o="not_refined",yield[d,void 0];o==="valid"&&(yield[void 0,t])}class te{constructor(e){const{type:r,schema:n,validator:i,refiner:s,coercer:c=o=>o,entries:a=function*(){}}=e;this.type=r,this.schema=n,this.entries=a,this.coercer=c,i?this.validator=(o,d)=>{const u=i(o,d);return Lt(u,d,this,o)}:this.validator=()=>[],s?this.refiner=(o,d)=>{const u=s(o,d);return Lt(u,d,this,o)}:this.refiner=()=>[]}assert(e,r){return nt(e,this,r)}create(e,r){return Xt(e,this,r)}is(e){return L(e,this)}mask(e,r){return Zt(e,this,r)}validate(e,r={}){return _e(e,this,r)}}function nt(t,e,r){const n=_e(t,e,{message:r});if(n[0])throw n[0]}function Xt(t,e,r){const n=_e(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Zt(t,e,r){const n=_e(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function L(t,e){return!_e(t,e)[0]}function _e(t,e,r={}){const n=lt(t,e,r),i=Ur(n);return i[0]?[new Cr(i[0],function*(){for(const c of n)c[0]&&(yield c[0])}),void 0]:[void 0,i[1]]}function je(...t){const e=t[0].type==="type",r=t.map(i=>i.schema),n=Object.assign({},...r);return e?Rr(n):p(n)}function W(t,e){return new te({type:t,schema:null,validator:e})}function it(){return W("any",()=>!0)}function E(t){return new te({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${J(e)}`}})}function Mr(){return W("bigint",t=>typeof t=="bigint")}function z(){return W("boolean",t=>typeof t=="boolean")}function ee(){return W("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${J(t)}`)}function k(t){const e=J(t),r=typeof t;return new te({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${J(n)}`}})}function Yt(){return W("never",()=>!1)}function $(t){return new te({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function he(){return W("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${J(t)}`)}function p(t){const e=t?Object.keys(t):[],r=Yt();return new te({type:"object",schema:t||null,*entries(n){if(t&&K(n)){const i=new Set(Object.keys(n));for(const s of e)i.delete(s),yield[s,n[s],t[s]];for(const s of i)yield[s,n[s],r]}},validator(n){return K(n)||`Expected an object, but received: ${J(n)}`},coercer(n){return K(n)?{...n}:n}})}function v(t){return new te({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Q(t,e){return new te({type:"record",schema:null,*entries(r){if(K(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator(r){return K(r)||`Expected an object, but received: ${J(r)}`}})}function h(){return W("string",t=>typeof t=="string"||`Expected a string, but received: ${J(t)}`)}function Qt(t){const e=Yt();return new te({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;i<n;i++)yield[i,r[i],t[i]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${J(r)}`}})}function Rr(t){const e=Object.keys(t);return new te({type:"type",schema:t,*entries(r){if(K(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return K(r)||`Expected an object, but received: ${J(r)}`},coercer(r){return K(r)?{...r}:r}})}function P(t){const e=t.map(r=>r.type).join(" | ");return new te({type:"union",schema:null,coercer(r){for(const n of t){const[i,s]=n.validate(r,{coerce:!0});if(!i)return s}return r},validator(r,n){const i=[];for(const s of t){const[...c]=lt(r,s,n),[a]=c;if(a[0])for(const[o]of c)o&&i.push(o);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${J(r)}`,...i]}})}function er(){return W("unknown",()=>!0)}const ft=P([p({AddressOwner:h()}),p({ObjectOwner:h()}),p({Shared:p({initial_shared_version:$(h())})}),k("Immutable")]);W("SuiJsonValue",()=>!0);const Nr=P([p({u32:h()}),p({u64:h()}),p({f64:h()})]);p({attributes:Q(h(),$(Nr)),featureFlags:Q(h(),z()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});P([h(),k("package")]);const ce=p({digest:h(),objectId:h(),version:P([he(),h(),Mr()])});p({owner:ft,reference:ce});p({objectId:h(),sequenceNumber:h()});p({payment:E(ce),owner:h(),price:h(),budget:h()});const Dr=je(ce,p({type:h(),owner:ft,previousTransaction:h()})),Vr=Q(h(),it()),zr=Q(h(),er()),Fr=p({type:h(),fields:Vr,hasPublicTransfer:z()}),Gr=p({disassembled:zr}),Lr=P([je(Fr,p({dataType:k("moveObject")})),je(Gr,p({dataType:k("package")}))]),Wr=p({type:h(),hasPublicTransfer:z(),version:h(),bcsBytes:h()}),Kr=p({id:h(),moduleMap:Q(h(),h())}),Jr=P([je(Wr,p({dataType:k("moveObject")})),je(Kr,p({dataType:k("package")}))]);BigInt(1e9);const tr=p({code:h(),error:v(h()),object_id:v(h()),parent_object_id:v(h()),version:v(h()),digest:v(h())}),Hr=p({data:$(v(Q(h(),h()))),error:$(v(tr))}),qr=P([Hr,v(Q(h(),h()))]),rr=p({objectId:h(),version:h(),digest:h(),type:$(v(h())),content:$(v(Lr)),bcs:$(v(Jr)),owner:$(v(ft)),previousTransaction:$(v(h())),storageRebate:$(v(h())),display:$(v(qr))});p({showType:$(v(z())),showContent:$(v(z())),showBcs:$(v(z())),showOwner:$(v(z())),showPreviousTransaction:$(v(z())),showStorageRebate:$(v(z())),showDisplay:$(v(z()))});P([k("Exists"),k("notExists"),k("Deleted")]);E(Dr);const Xr=p({data:$(v(rr)),error:$(v(tr))});function Zr(t){return t.data}function Yr(t){if(t.error&&"object_id"in t.error&&"version"in t.error&&"digest"in t.error){const e=t.error;return{objectId:e.object_id,version:e.version,digest:e.digest}}}function Wt(t){if("reference"in t)return t.reference;const e=Zr(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:Yr(t)}p({objectId:h(),atCheckpoint:v(he())});p({data:E(Xr),nextCursor:v($(h())),hasNextPage:z()});P([p({details:rr,status:k("VersionFound")}),p({details:h(),status:k("ObjectNotExists")}),p({details:ce,status:k("ObjectDeleted")}),p({details:Qt([h(),he()]),status:k("VersionNotFound")}),p({details:p({asked_version:he(),latest_version:he(),object_id:h()}),status:k("VersionTooHigh")})]);const Qr=P([h(),p({Object:h()})]);E(Qr);const en=p({address:h(),name:h()}),tn=P([k("Private"),k("Public"),k("Friend")]),ht=p({abilities:E(h())}),rn=p({constraints:ht,isPhantom:z()}),nn=p({TypeParameter:he()}),Xe=Qt([p({module:h(),package:h(),function:h()}),h()]);p({rank3Days:E(Xe),rank7Days:E(Xe),rank30Days:E(Xe)});function nr(t){if(!t)return!1;if(typeof t=="string"||L(t,nn)||ir(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(L(e.Reference,me)||L(e.MutableReference,me)||L(e.Vector,me))}const me=W("SuiMoveNormalizedType",nr);function ir(t){if(!t||typeof t!="object")return!1;const e=t;if(!e.Struct||typeof e.Struct!="object")return!1;const r=e.Struct;return!(typeof r.address!="string"||typeof r.module!="string"||typeof r.name!="string"||!Array.isArray(r.typeArguments)||!r.typeArguments.every(n=>nr(n)))}W("SuiMoveNormalizedStructType",ir);const sn=p({visibility:tn,isEntry:z(),typeParameters:E(ht),parameters:E(me),return:E(me)}),an=p({name:h(),type:me}),on=p({abilities:ht,typeParameters:E(rn),fields:E(an)}),cn=p({fileFormatVersion:he(),address:h(),name:h(),friends:E(en),structs:Q(h(),on),exposedFunctions:Q(h(),sn)});Q(h(),cn);function st(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function sr(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function gt(t){if(typeof t=="object"&&"Struct"in t)return t;const e=sr(t),r=st(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}function un(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=n}var c=t.length,a=t.charAt(0),o=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function u(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var S=0,T=0,f=0,O=y.length;f!==O&&y[f]===0;)f++,S++;for(var B=(O-f)*d+1>>>0,M=new Uint8Array(B);f!==O;){for(var A=y[f],j=0,R=B-1;(A!==0||j<T)&&R!==-1;R--,j++)A+=256*M[R]>>>0,M[R]=A%c>>>0,A=A/c>>>0;if(A!==0)throw new Error("Non-zero carry");T=j,f++}for(var H=B-T;H!==B&&M[H]===0;)H++;for(var pe=a.repeat(S);H<B;++H)pe+=t.charAt(M[H]);return pe}function g(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;for(var S=0,T=0,f=0;y[S]===a;)T++,S++;for(var O=(y.length-S)*o+1>>>0,B=new Uint8Array(O);y[S];){var M=e[y.charCodeAt(S)];if(M===255)return;for(var A=0,j=O-1;(M!==0||A<f)&&j!==-1;j--,A++)M+=c*B[j]>>>0,B[j]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");f=A,S++}for(var R=O-f;R!==O&&B[R]===0;)R++;for(var H=new Uint8Array(T+(O-R)),pe=T;R!==O;)H[pe++]=B[R++];return H}function m(y){var S=g(y);if(S)return S;throw new Error("Non-base"+c+" character")}return{encode:u,decodeUnsafe:g,decode:m}}var dn=un;const ln=dn,fn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var hn=ln(fn);const ar=w.getDefaultExportFromCjs(hn),xe=t=>ar.encode(t),pt=t=>ar.decode(t);function ue(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const Ze=8192;function Be(t){if(t.length<Ze)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=Ze){const n=t.slice(r,r+Ze);e+=String.fromCharCode(...n)}return btoa(e)}function Je(t){var i;const e=t.startsWith("0x")?t.slice(2):t,n=((i=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:i.map(s=>parseInt(s,16)))??[];return Uint8Array.from(n)}function Ce(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function yt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function gn(t){let e=0,r=0,n=0;for(;;){let i=t[n];if(n+=1,e|=(i&127)<<r,!(i&128))break;r+=7}return{value:e,length:n}}class or{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:i}=gn(r);return this.shift(i),n}readVec(e){let r=this.readULEB(),n=[];for(let i=0;i<r;i++)n.push(e(this,i,r));return n}}function pn(t,e){switch(e){case"base58":return xe(t);case"base64":return Be(t);case"hex":return Ce(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function yn(t,e){switch(e){case"base58":return pt(t);case"base64":return ue(t);case"hex":return Je(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function mt(t,e=["<",">"]){const[r,n]=e,i=[];let s="",c=0;for(let a=0;a<t.length;a++){const o=t[a];if(o===r&&c++,o===n&&c--,c===0&&o===","){i.push(s.trim()),s="";continue}s+=o}return i.push(s.trim()),i}class cr{constructor({size:e=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=r||e,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const r=this.bytePosition+e;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const i=new ArrayBuffer(this.size);new Uint8Array(i).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(i)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}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 Ye(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return Ye(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return Ye(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return yt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,i)=>r(this,n,i,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 pn(this.toBytes(),e)}}function Ye(t,e){let r=new Uint8Array(e),n=0;for(;t>0;)r[n]=Number(t%BigInt(256)),t=t/BigInt(256),n+=1;return r}var ur=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},X=(t,e,r)=>(ur(t,e,"read from private field"),r?r.call(t):e.get(t)),ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Fe=(t,e,r,n)=>(ur(t,e,"write to private field"),e.set(t,r),r),ye,Se,Me,ae;const dr=class{constructor(t){ze(this,ye,void 0),ze(this,Se,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),Fe(this,ye,t.write),Fe(this,Se,t.serialize??((e,r)=>{const n=new cr({size:this.serializedSize(e)??void 0,...r});return X(this,ye).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),X(this,ye).call(this,t,e)}serialize(t,e){return this.validate(t),new mn(this,X(this,Se).call(this,t,e))}parse(t){const e=new or(t);return this.read(e)}transform({name:t,input:e,output:r}){return new dr({name:t??this.name,read:n=>r(this.read(n)),write:(n,i)=>X(this,ye).call(this,e(n),i),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,i)=>X(this,Se).call(this,e(n),i),validate:n=>this.validate(e(n))})}};let Z=dr;ye=new WeakMap;Se=new WeakMap;const lr=Symbol.for("@mysten/serialized-bcs");function wt(t){return!!t&&typeof t=="object"&&t[lr]===!0}class mn{constructor(e,r){ze(this,Me,void 0),ze(this,ae,void 0),Fe(this,Me,e),Fe(this,ae,r)}get[lr](){return!0}toBytes(){return X(this,ae)}toHex(){return Ce(X(this,ae))}toBase64(){return Be(X(this,ae))}toBase58(){return xe(X(this,ae))}parse(){return X(this,Me).parse(X(this,ae))}}Me=new WeakMap;ae=new WeakMap;function Ge({size:t,...e}){return new Z({...e,serializedSize:()=>t})}function Qe({readMethod:t,writeMethod:e,...r}){return Ge({...r,read:n=>n[t](),write:(n,i)=>i[e](n),validate:n=>{var i;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,n)}})}function et({readMethod:t,writeMethod:e,...r}){return Ge({...r,read:n=>n[t](),write:(n,i)=>i[e](BigInt(n)),validate:n=>{var s;const i=BigInt(n);if(i<0||i>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${i}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,i)}})}function wn({serialize:t,...e}){const r=new Z({...e,serialize:t,write:(n,i)=>{for(const s of r.serialize(n).toBytes())i.write8(s)}});return r}function bn({toBytes:t,fromBytes:e,...r}){return new Z({...r,read:n=>{const i=n.readULEB(),s=n.readBytes(i);return e(s)},write:(n,i)=>{const s=t(n);i.writeULEB(s.length);for(let c=0;c<s.length;c++)i.write8(s[c])},serialize:n=>{const i=t(n),s=yt(i.length),c=new Uint8Array(s.length+i.length);return c.set(s,0),c.set(i,s.length),c},validate:n=>{var i;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(i=r.validate)==null||i.call(r,n)}})}function Sn(t){let e=null;function r(){return e||(e=t()),e}return new Z({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,i)=>r().write(n,i),serialize:(n,i)=>r().serialize(n,i).toBytes()})}const l={u8(t){return Qe({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return Qe({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return Qe({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return et({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return et({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return et({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Ge({name:"bool",size:1,read:e=>e.read8()===1,write:(e,r)=>r.write8(e?1:0),...t,validate:e=>{var r;if((r=t==null?void 0:t.validate)==null||r.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return wn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(yt(e)),...t})},bytes(t,e){return Ge({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let i=0;i<t;i++)n.write8(r[i]??0)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("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}`)}})},string(t){return bn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new Z({name:`${e.name}[${t}]`,read:n=>{const i=new Array(t);for(let s=0;s<t;s++)i[s]=e.read(n);return i},write:(n,i)=>{for(const s of n)e.write(s,i)},...r,validate:n=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,n),!("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}`)}})},option(t){return l.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>"Some"in e?e.Some:null})},vector(t,e){return new Z({name:`vector<${t.name}>`,read:r=>{const n=r.readULEB(),i=new Array(n);for(let s=0;s<n;s++)i[s]=t.read(r);return i},write:(r,n)=>{n.writeULEB(r.length);for(const i of r)t.write(i,n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`)}})},tuple(t,e){return new Z({name:`(${t.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let i=0;i<t.length;i++){const s=t[i].serializedSize(r[i]);if(s==null)return null;n+=s}return n},read:r=>{const n=[];for(const i of t)n.push(i.read(r));return n},write:(r,n)=>{for(let i=0;i<t.length;i++)t[i].write(r[i],n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!Array.isArray(r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t.length)throw new TypeError(`Expected array of length ${t.length}, found ${r.length}`)}})},struct(t,e,r){const n=Object.entries(e);return new Z({name:t,serializedSize:i=>{let s=0;for(const[c,a]of n){const o=a.serializedSize(i[c]);if(o==null)return null;s+=o}return s},read:i=>{const s={};for(const[c,a]of n)s[c]=a.read(i);return s},write:(i,s)=>{for(const[c,a]of n)a.write(i[c],s)},...r,validate:i=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`)}})},enum(t,e,r){const n=Object.entries(e);return new Z({name:t,read:i=>{const s=i.readULEB(),[c,a]=n[s];return{[c]:(a==null?void 0:a.read(i))??!0}},write:(i,s)=>{const[c,a]=Object.entries(i)[0];for(let o=0;o<n.length;o++){const[d,u]=n[o];if(d===c){s.writeULEB(o),u==null||u.write(a,s);return}}},...r,validate:i=>{var a;if((a=r==null?void 0:r.validate)==null||a.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`);const s=Object.keys(i);if(s.length!==1)throw new TypeError(`Expected object with one key, found ${s.length}`);const[c]=s;if(!Object.hasOwn(e,c))throw new TypeError(`Invalid enum variant ${c}`)}})},map(t,e){return l.vector(l.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[i,s]of r)n.set(i,s);return n}})},generic(t,e){return(...r)=>e(...r).transform({name:`${e.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(t){return Sn(t)}},Tn=32,Te=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof Te){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(Te.ADDRESS,t.addressLength,t.addressEncoding),this.registerVectorType(t.vectorType),t.types&&t.types.structs)for(let e of Object.keys(t.types.structs))this.registerStructType(e,t.types.structs[e]);if(t.types&&t.types.enums)for(let e of Object.keys(t.types.enums))this.registerEnumType(e,t.types.enums[e]);if(t.types&&t.types.aliases)for(let e of Object.keys(t.types.aliases))this.registerAlias(e,t.types.aliases[e]);t.withPrimitives!==!1&&vn(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:i}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,i)}if(typeof t=="object"){const n=this.tempKey();return new Te(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
2
2
|
${JSON.stringify(t)}`)}de(t,e,r){if(typeof e=="string")if(r)e=yn(e,r);else throw new Error("To pass a string to `bcs.de`, specify encoding");if(typeof t=="string"||Array.isArray(t)){const{name:n,params:i}=this.parseTypeName(t);return this.getTypeInterface(n).decode(this,e,i)}if(typeof t=="object"){const n=new Te(this),i=this.tempKey();return n.registerStructType(i,t).de(i,e,r)}throw new Error(`Incorrect type passed into the '.de()' function.
|
|
3
3
|
${JSON.stringify(t)}`)}hasType(t){return this.types.has(t)}registerAlias(t,e){return this.types.set(t,e),this}registerType(t,e,r,n=()=>!0){const{name:i,params:s}=this.parseTypeName(t);return this.types.set(i,{encode(c,a,o,d){const u=s.reduce((g,m,y)=>Object.assign(g,{[m]:d[y]}),{});return this._encodeRaw.call(c,new cr(o),a,d,u)},decode(c,a,o){const d=s.reduce((u,g,m)=>Object.assign(u,{[g]:o[m]}),{});return this._decodeRaw.call(c,new or(a),o,d)},_encodeRaw(c,a,o,d){if(n(a))return e.call(this,c,a,o,d);throw new Error(`Validation failed for type ${i}, data: ${a}`)},_decodeRaw(c,a,o){return r.call(this,c,a,o)}}),this}registerBcsType(t,e){return this.registerType(t,(r,n,i)=>{const s=i.map(c=>new Z({name:String(c),write:(a,o)=>{const{name:d,params:u}=this.parseTypeName(c),g=this.getTypeInterface(d),m=u.reduce((y,S,T)=>Object.assign(y,{[S]:i[T]}),{});return g._encodeRaw.call(this,o,a,u,m)},read:()=>{throw new Error("Not implemented")}}));return e(...s).write(n,r),r},(r,n)=>{const i=n.map(s=>new Z({name:String(s),write:(c,a)=>{throw new Error("Not implemented")},read:c=>{const{name:a,params:o}=this.parseTypeName(s),d=this.getTypeInterface(a),u=o.reduce((g,m,y)=>Object.assign(g,{[m]:n[y]}),{});return d._decodeRaw.call(this,c,o,u)}}));return e(...i).read(r)}),this}registerAddressType(t,e,r="hex"){switch(r){case"base64":return this.registerType(t,function(i,s){return ue(s).reduce((c,a)=>c.write8(a),i)},function(i){return Be(i.readBytes(e))});case"hex":return this.registerType(t,function(i,s){return Je(s).reduce((c,a)=>c.write8(a),i)},function(i){return Ce(i.readBytes(e))});default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(t){let{name:e,params:r}=this.parseTypeName(t);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+e);return this.registerType(t,function(i,s,c,a){return i.writeVec(s,(o,d)=>{let u=c[0];if(!u)throw new Error(`Incorrect number of type parameters passed a to vector '${t}'`);let{name:g,params:m}=this.parseTypeName(u);if(this.hasType(g))return this.getTypeInterface(g)._encodeRaw.call(this,o,d,m,a);if(!(g in a))throw new Error(`Unable to find a matching type definition for ${g} in vector; make sure you passed a generic`);let{name:y,params:S}=this.parseTypeName(a[g]);return this.getTypeInterface(y)._encodeRaw.call(this,o,d,S,a)})},function(i,s,c){return i.readVec(a=>{let o=s[0];if(!o)throw new Error(`Incorrect number of type parameters passed to a vector '${t}'`);let{name:d,params:u}=this.parseTypeName(o);if(this.hasType(d))return this.getTypeInterface(d)._decodeRaw.call(this,a,u,c);if(!(d in c))throw new Error(`Unable to find a matching type definition for ${d} in vector; make sure you passed a generic`);let{name:g,params:m}=this.parseTypeName(c[d]);return this.getTypeInterface(g)._decodeRaw.call(this,a,m,c)})})}registerStructType(t,e){for(let c in e){let a=this.tempKey(),o=e[c];!Array.isArray(o)&&typeof o!="string"&&(e[c]=a,this.registerStructType(a,o))}let r=Object.freeze(e),n=Object.keys(r),{name:i,params:s}=this.parseTypeName(t);return this.registerType(t,function(a,o,d,u){if(!o||o.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${o}`);if(d.length!==s.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${s.length}, got: ${d.length}`);for(let g of n){if(!(g in o))throw new Error(`Struct ${i} requires field ${g}:${r[g]}`);const{name:m,params:y}=this.parseTypeName(r[g]);if(!s.includes(m))this.getTypeInterface(m)._encodeRaw.call(this,a,o[g],y,u);else{const S=s.indexOf(m);let{name:T,params:f}=this.parseTypeName(d[S]);if(this.hasType(T)){this.getTypeInterface(T)._encodeRaw.call(this,a,o[g],f,u);continue}if(!(T in u))throw new Error(`Unable to find a matching type definition for ${T} in ${i}; make sure you passed a generic`);let{name:O,params:B}=this.parseTypeName(u[T]);this.getTypeInterface(O)._encodeRaw.call(this,a,o[g],B,u)}}return a},function(a,o,d){if(o.length!==s.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${s.length}, got: ${o.length}`);let u={};for(let g of n){const{name:m,params:y}=this.parseTypeName(r[g]);if(!s.includes(m))u[g]=this.getTypeInterface(m)._decodeRaw.call(this,a,y,d);else{const S=s.indexOf(m);let{name:T,params:f}=this.parseTypeName(o[S]);if(this.hasType(T)){u[g]=this.getTypeInterface(T)._decodeRaw.call(this,a,f,d);continue}if(!(T in d))throw new Error(`Unable to find a matching type definition for ${T} in ${i}; make sure you passed a generic`);let{name:O,params:B}=this.parseTypeName(d[T]);u[g]=this.getTypeInterface(O)._decodeRaw.call(this,a,B,d)}}return u})}registerEnumType(t,e){for(let c in e){let a=this.tempKey(),o=e[c];o!==null&&!Array.isArray(o)&&typeof o!="string"&&(e[c]=a,this.registerStructType(a,o))}let r=Object.freeze(e),n=Object.keys(r),{name:i,params:s}=this.parseTypeName(t);return this.registerType(t,function(a,o,d,u){if(!o)throw new Error(`Unable to write enum "${i}", missing data.
|
|
4
4
|
Received: "${o}"`);if(typeof o!="object")throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${n.join(" | ")}".
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as _t, s as ce, T as N, o as ot, R as Do, a as C, t as H, p as K, y as gt } from "./index-
|
|
1
|
+
import { n as _t, s as ce, T as N, o as ot, R as Do, a as C, t as H, p as K, y as gt } from "./index-B-TRMIWs.mjs";
|
|
2
2
|
import { d as Uo } from "./dijkstra-BZM-8g-B.mjs";
|
|
3
|
-
import { h as Wo } from "./index-
|
|
3
|
+
import { h as Wo } from "./index-DgePBEwv.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2019 Google LLC
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index-DHSWeh-m.js"),kr=require("./dijkstra-CtFxn7S9.js"),Mr=require("./index-B5r3vRTo.js");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Pt = Object.defineProperty;
|
|
2
2
|
var _t = (e, t, r) => t in e ? Pt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var f = (e, t, r) => _t(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import {
|
|
4
|
+
import { b1 as c, bm as A, bq as z, bp as U, h as l, c3 as le, br as Z, bo as S, bn as V, c4 as Ze, c5 as Ge, c6 as Wt, c7 as It, c8 as Ut, c9 as Nt, ca as O, cb as E, ah as y, cc as T, cd as Ft, ce as ye, bZ as dt, cf as xt, cg as lt, ch as zt, ci as Ot, cj as Q, ck as Lt, cl as G, cm as H, cn as qt, co as Dt, cp as Kt, cq as Vt, cr as Se, cs as Zt, ct as v, cu as Gt, e as oe, S as k, bY as Ce, bB as Ht, p as j, c2 as Be, cv as Yt, cw as Qt, bc as se, b5 as L, ae as Xt, cx as ft, bH as mt, g as gt } from "./index-DgePBEwv.mjs";
|
|
5
5
|
const M = new c("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
6
6
|
new c("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
|
|
7
7
|
const Ae = new c("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), q = new c("So11111111111111111111111111111111111111112");
|
|
@@ -84,7 +84,7 @@ var ge;
|
|
|
84
84
|
const Pe = 1, en = A([
|
|
85
85
|
z("m"),
|
|
86
86
|
z("n"),
|
|
87
|
-
|
|
87
|
+
Z("isInitialized"),
|
|
88
88
|
S("signer1"),
|
|
89
89
|
S("signer2"),
|
|
90
90
|
S("signer3"),
|
|
@@ -161,7 +161,7 @@ const yt = A([
|
|
|
161
161
|
S("mintAuthority"),
|
|
162
162
|
U("supply"),
|
|
163
163
|
z("decimals"),
|
|
164
|
-
|
|
164
|
+
Z("isInitialized"),
|
|
165
165
|
V("freezeAuthorityOption"),
|
|
166
166
|
S("freezeAuthority")
|
|
167
167
|
]), ve = yt.span;
|
|
@@ -209,13 +209,13 @@ function We(e, t, r = !1, n = M, i = Ae) {
|
|
|
209
209
|
const [s] = c.findProgramAddressSync([t.toBuffer(), n.toBuffer(), e.toBuffer()], i);
|
|
210
210
|
return s;
|
|
211
211
|
}
|
|
212
|
-
const on = A([
|
|
212
|
+
const on = A([Z("lockCpi")]), cn = on.span, un = A([z("state")]), dn = un.span, ln = A([]), fn = ln.span, mn = A([
|
|
213
213
|
S("rateAuthority"),
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
]), gn = mn.span, hn = A([
|
|
214
|
+
Ze("initializationTimestamp"),
|
|
215
|
+
Ge("preUpdateAverageRate"),
|
|
216
|
+
Ze("lastUpdateTimestamp"),
|
|
217
|
+
Ge("currentRate")
|
|
218
|
+
]), gn = mn.span, hn = A([Z("requireIncomingTransferMemos")]), pn = hn.span, wn = A([
|
|
219
219
|
S("authority"),
|
|
220
220
|
S("metadataAddress")
|
|
221
221
|
]), yn = wn.span, Sn = A([S("closeAuthority")]), An = Sn.span, St = A([]), Mn = St.span, kn = St.span, bn = A([S("delegate")]), Tn = bn.span, Cn = 1e4;
|
|
@@ -229,11 +229,11 @@ const vn = A([
|
|
|
229
229
|
U("withheldAmount"),
|
|
230
230
|
je("olderTransferFee"),
|
|
231
231
|
je("newerTransferFee")
|
|
232
|
-
]), Bn = vn.span, Rn = A([U("withheldAmount")]), En = Rn.span, Pn = A([S("authority"), S("programId")]), _n = Pn.span, Wn = A([
|
|
232
|
+
]), Bn = vn.span, Rn = A([U("withheldAmount")]), En = Rn.span, Pn = A([S("authority"), S("programId")]), _n = Pn.span, Wn = A([Z("transferring")]), In = Wn.span, $e = A([
|
|
233
233
|
z("discriminator"),
|
|
234
234
|
It(32, "addressConfig"),
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
Z("isSigner"),
|
|
236
|
+
Z("isWritable")
|
|
237
237
|
]), Un = A([
|
|
238
238
|
V("count"),
|
|
239
239
|
Ut($e, Nt($e.span), "extraAccounts")
|
|
@@ -504,9 +504,9 @@ class Vn {
|
|
|
504
504
|
encode(t, r) {
|
|
505
505
|
switch (t) {
|
|
506
506
|
case "initialize":
|
|
507
|
-
return Gn(r);
|
|
508
|
-
case "attestToken":
|
|
509
507
|
return Zn(r);
|
|
508
|
+
case "attestToken":
|
|
509
|
+
return Gn(r);
|
|
510
510
|
case "completeNative":
|
|
511
511
|
return Hn(r);
|
|
512
512
|
case "completeWrapped":
|
|
@@ -541,11 +541,11 @@ function N(e, t) {
|
|
|
541
541
|
const r = t === void 0 ? 0 : t.length, n = l.Buffer.alloc(1 + r);
|
|
542
542
|
return n.writeUInt8(e, 0), r > 0 && n.write(t.toString("hex"), 1, "hex"), n;
|
|
543
543
|
}
|
|
544
|
-
function
|
|
544
|
+
function Zn({ wormhole: e }) {
|
|
545
545
|
const t = l.Buffer.alloc(32);
|
|
546
546
|
return t.write(new c(e).toBuffer().toString("hex"), 0, "hex"), N(P.Initialize, t);
|
|
547
547
|
}
|
|
548
|
-
function
|
|
548
|
+
function Gn({ nonce: e }) {
|
|
549
549
|
const t = l.Buffer.alloc(4);
|
|
550
550
|
return t.writeUInt32LE(e, 0), N(P.AttestToken, t);
|
|
551
551
|
}
|
|
@@ -1767,7 +1767,7 @@ function cr(e, t, r, n, i) {
|
|
|
1767
1767
|
return {
|
|
1768
1768
|
payer: new c(r),
|
|
1769
1769
|
config: B(e),
|
|
1770
|
-
vaa:
|
|
1770
|
+
vaa: G(t, l.Buffer.from(n.hash)),
|
|
1771
1771
|
claim: H(e, n.emitterAddress.toUint8Array(), y(n.emitterChain), n.sequence),
|
|
1772
1772
|
endpoint: te(e, y(n.emitterChain), n.emitterAddress.toUint8Array()),
|
|
1773
1773
|
to: new c(n.payload.to.address.toUint8Array()),
|
|
@@ -1796,7 +1796,7 @@ function dr(e, t, r, n, i) {
|
|
|
1796
1796
|
return {
|
|
1797
1797
|
payer: new c(r),
|
|
1798
1798
|
config: B(e),
|
|
1799
|
-
vaa:
|
|
1799
|
+
vaa: G(t, l.Buffer.from(n.hash)),
|
|
1800
1800
|
claim: H(e, n.emitterAddress.toUint8Array(), y(n.emitterChain), n.sequence),
|
|
1801
1801
|
endpoint: te(e, y(n.emitterChain), n.emitterAddress.toUint8Array()),
|
|
1802
1802
|
to: new c(n.payload.to.address.toUint8Array()),
|
|
@@ -1826,7 +1826,7 @@ function fr(e, t, r, n) {
|
|
|
1826
1826
|
payer: new c(r),
|
|
1827
1827
|
config: B(e),
|
|
1828
1828
|
endpoint: te(e, y(n.emitterChain), n.emitterAddress.toUint8Array()),
|
|
1829
|
-
vaa:
|
|
1829
|
+
vaa: G(t, l.Buffer.from(n.hash)),
|
|
1830
1830
|
claim: H(e, n.emitterAddress.toUint8Array(), y(n.emitterChain), n.sequence),
|
|
1831
1831
|
mint: i,
|
|
1832
1832
|
wrappedMeta: Y(e, i),
|
|
@@ -1872,7 +1872,7 @@ function gr(e, t, r, n) {
|
|
|
1872
1872
|
payer: new c(r),
|
|
1873
1873
|
config: B(e),
|
|
1874
1874
|
endpoint: te(e, y(n.payload.actionArgs.foreignChain), n.payload.actionArgs.foreignAddress.toUint8Array()),
|
|
1875
|
-
vaa:
|
|
1875
|
+
vaa: G(t, l.Buffer.from(n.hash)),
|
|
1876
1876
|
claim: H(e, n.emitterAddress.toUint8Array(), y(n.emitterChain), n.sequence),
|
|
1877
1877
|
rent: O,
|
|
1878
1878
|
systemProgram: E.programId,
|
|
@@ -1892,7 +1892,7 @@ function Ir(e, t, r, n, i) {
|
|
|
1892
1892
|
function hr(e, t, r, n, i) {
|
|
1893
1893
|
return {
|
|
1894
1894
|
payer: new c(r),
|
|
1895
|
-
vaa:
|
|
1895
|
+
vaa: G(t, l.Buffer.from(n.hash)),
|
|
1896
1896
|
claim: H(e, n.emitterAddress.toUint8Array(), y(n.emitterChain), n.sequence),
|
|
1897
1897
|
upgradeAuthority: qt(e),
|
|
1898
1898
|
spill: new c(i === void 0 ? r : i),
|
|
@@ -2036,7 +2036,7 @@ function Rt(e, t, r, n, i, s, o, a, d) {
|
|
|
2036
2036
|
};
|
|
2037
2037
|
}
|
|
2038
2038
|
function Ur(e, t, r) {
|
|
2039
|
-
const { wormholeEmitter: n, wormholeBridge: i, wormholeFeeCollector: s, wormholeSequence: o } =
|
|
2039
|
+
const { wormholeEmitter: n, wormholeBridge: i, wormholeFeeCollector: s, wormholeSequence: o } = Zt(t, r);
|
|
2040
2040
|
return {
|
|
2041
2041
|
tokenBridgeConfig: B(t),
|
|
2042
2042
|
tokenBridgeAuthoritySigner: ne(t),
|
|
@@ -2101,7 +2101,7 @@ function Nr(e, t, r, n, i) {
|
|
|
2101
2101
|
return {
|
|
2102
2102
|
payer: new c(r),
|
|
2103
2103
|
tokenBridgeConfig: B(e),
|
|
2104
|
-
vaa:
|
|
2104
|
+
vaa: G(t, l.Buffer.from(n.hash)),
|
|
2105
2105
|
tokenBridgeClaim: H(e, n.emitterAddress.toUint8Array(), y(n.emitterChain), n.sequence),
|
|
2106
2106
|
tokenBridgeForeignEndpoint: te(e, y(n.emitterChain), n.emitterAddress.toUint8Array()),
|
|
2107
2107
|
toTokenAccount: new c(i),
|
|
@@ -2121,7 +2121,7 @@ function Fr(e, t, r, n, i) {
|
|
|
2121
2121
|
return {
|
|
2122
2122
|
payer: new c(r),
|
|
2123
2123
|
tokenBridgeConfig: B(e),
|
|
2124
|
-
vaa:
|
|
2124
|
+
vaa: G(t, l.Buffer.from(n.hash)),
|
|
2125
2125
|
tokenBridgeClaim: H(e, n.emitterAddress.toUint8Array(), y(n.emitterChain), n.sequence),
|
|
2126
2126
|
tokenBridgeForeignEndpoint: te(e, y(n.emitterChain), n.emitterAddress.toUint8Array()),
|
|
2127
2127
|
toTokenAccount: new c(i),
|
|
@@ -4171,7 +4171,7 @@ class De {
|
|
|
4171
4171
|
const s = i.tokenBridge;
|
|
4172
4172
|
if (!s)
|
|
4173
4173
|
throw new Error(`TokenBridge contract Address for chain ${r} not found`);
|
|
4174
|
-
this.tokenBridge = W(s, n), this.coreBridge = new
|
|
4174
|
+
this.tokenBridge = W(s, n), this.coreBridge = new Gt(t, r, n, i);
|
|
4175
4175
|
}
|
|
4176
4176
|
static async fromRpc(t, r) {
|
|
4177
4177
|
const [n, i] = await oe.chainFromRpc(t), s = r[i];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var Zr = Object.defineProperty;
|
|
2
2
|
var Yr = (t, e, r) => e in t ? Zr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
3
|
var C = (t, e, r) => Yr(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { al as Qr, F as en,
|
|
5
|
-
import { g as tt, a as gt, i as Ve, S as Q, b as H, p as ln, c as fn, d as it, u as ze, e as pr, f as hn, h as He, j as gn, k as pn } from "./sui-
|
|
6
|
-
import "./index-
|
|
4
|
+
import { al as Qr, F as en, cG as ft, L as tn, cH as hr, cI as ke, ax as rn, bY as nt, bB as nn, bZ as nr, ah as ce, Q as ge, p as oe, by as sn, c2 as ir, b$ as an, cJ as on, bC as ht, N as cn, u as De, ae as un, cd as sr, cK as dn, O as ar, bH as gr } from "./index-DgePBEwv.mjs";
|
|
5
|
+
import { g as tt, a as gt, i as Ve, S as Q, b as H, p as ln, c as fn, d as it, u as ze, e as pr, f as hn, h as He, j as gn, k as pn } from "./sui-BZ3grhrf.mjs";
|
|
6
|
+
import "./index-CFG8Auhr.mjs";
|
|
7
7
|
class yr {
|
|
8
8
|
constructor(e, r, n, i, s = !1) {
|
|
9
9
|
C(this, "transaction");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as $, al as V1,
|
|
2
|
-
import { h as e7, e as t7 } from "./evm-
|
|
1
|
+
import { h as $, al as V1, df as K4, ct as J5, dg as Y5, X as X5 } from "./index-DgePBEwv.mjs";
|
|
2
|
+
import { h as e7, e as t7 } from "./evm-mqOA6aXy.mjs";
|
|
3
3
|
import * as C3 from "react";
|
|
4
4
|
import w, { createContext as n7, useState as o3, useEffect as j0, useCallback as r7, useContext as i7 } from "react";
|
|
5
5
|
import o7 from "react-dom";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const me=Symbol(),se=Object.getPrototypeOf,G=new WeakMap,he=e=>e&&(G.has(e)?G.get(e):se(e)===Object.prototype||se(e)===Array.prototype),ge=e=>he(e)&&e[me]||null,ne=(e,t=!0)=>{G.set(e,t)},H={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,REACT_APP_CONNECT_GIT_HASH:"5534a95209cc64101f6b34f3fa3e7486d56a9233",REACT_APP_CONNECT_VERSION:"1.1.4",SSR:!1},F=e=>typeof e=="object"&&e!==null,A=new WeakMap,x=new WeakSet,be=(e=Object.is,t=(n,g)=>new Proxy(n,g),s=n=>F(n)&&!x.has(n)&&(Array.isArray(n)||!(Symbol.iterator in n))&&!(n instanceof WeakMap)&&!(n instanceof WeakSet)&&!(n instanceof Error)&&!(n instanceof Number)&&!(n instanceof Date)&&!(n instanceof String)&&!(n instanceof RegExp)&&!(n instanceof ArrayBuffer),r=n=>{switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:throw n}},l=new WeakMap,c=(n,g,I=r)=>{const v=l.get(n);if((v==null?void 0:v[0])===g)return v[1];const w=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n));return ne(w,!0),l.set(n,[g,w]),Reflect.ownKeys(n).forEach(_=>{if(Object.getOwnPropertyDescriptor(w,_))return;const L=Reflect.get(n,_),M={value:L,enumerable:!0,configurable:!0};if(x.has(L))ne(L,!1);else if(L instanceof Promise)delete M.value,M.get=()=>I(L);else if(A.has(L)){const[b,q]=A.get(L);M.value=c(b,q(),I)}Object.defineProperty(w,_,M)}),Object.preventExtensions(w)},m=new WeakMap,f=[1,1],W=n=>{if(!F(n))throw new Error("object required");const g=m.get(n);if(g)return g;let I=f[0];const v=new Set,w=(a,i=++f[0])=>{I!==i&&(I=i,v.forEach(o=>o(a,i)))};let _=f[1];const L=(a=++f[1])=>(_!==a&&!v.size&&(_=a,b.forEach(([i])=>{const o=i[1](a);o>I&&(I=o)})),I),M=a=>(i,o)=>{const h=[...i];h[1]=[a,...h[1]],w(h,o)},b=new Map,q=(a,i)=>{if((H?"production":void 0)!=="production"&&b.has(a))throw new Error("prop listener already exists");if(v.size){const o=i[3](M(a));b.set(a,[i,o])}else b.set(a,[i])},te=a=>{var i;const o=b.get(a);o&&(b.delete(a),(i=o[1])==null||i.call(o))},pe=a=>(v.add(a),v.size===1&&b.forEach(([o,h],k)=>{if((H?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const T=o[3](M(k));b.set(k,[o,T])}),()=>{v.delete(a),v.size===0&&b.forEach(([o,h],k)=>{h&&(h(),b.set(k,[o]))})}),J=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),$=t(J,{deleteProperty(a,i){const o=Reflect.get(a,i);te(i);const h=Reflect.deleteProperty(a,i);return h&&w(["delete",[i],o]),h},set(a,i,o,h){const k=Reflect.has(a,i),T=Reflect.get(a,i,h);if(k&&(e(T,o)||m.has(o)&&e(T,m.get(o))))return!0;te(i),F(o)&&(o=ge(o)||o);let V=o;if(o instanceof Promise)o.then(C=>{o.status="fulfilled",o.value=C,w(["resolve",[i],C])}).catch(C=>{o.status="rejected",o.reason=C,w(["reject",[i],C])});else{!A.has(o)&&s(o)&&(V=W(o));const C=!x.has(V)&&A.get(V);C&&q(i,C)}return Reflect.set(a,i,V,h),w(["set",[i],o,T]),!0}});m.set(n,$);const fe=[J,L,c,pe];return A.set($,fe),Reflect.ownKeys(n).forEach(a=>{const i=Object.getOwnPropertyDescriptor(n,a);"value"in i&&($[a]=n[a],delete i.value,delete i.writable),Object.defineProperty(J,a,i)}),$})=>[W,A,x,e,t,s,r,l,c,m,f],[ye]=be();function j(e={}){return ye(e)}function D(e,t,s){const r=A.get(e);(H?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let l;const c=[],m=r[3];let f=!1;const n=m(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,n()}}function ve(e,t){const s=A.get(e);(H?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,l,c]=s;return c(r,l(),t)}const d=j({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),ee={state:d,subscribe(e){return D(d,()=>e(d))},push(e,t){e!==d.view&&(d.view=e,t&&(d.data=t),d.history.push(e))},reset(e){d.view=e,d.history=[e]},replace(e){d.history.length>1&&(d.history[d.history.length-1]=e,d.view=e)},goBack(){if(d.history.length>1){d.history.pop();const[e]=d.history.slice(-1);d.view=e}},setData(e){d.data=e}},u={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return u.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return u.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},formatNativeUrl(e,t,s){if(u.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!u.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let r=e;r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(u.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(u.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(u.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(u.WCM_VERSION,"2.6.2")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=ee.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},we=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=j({enabled:we,userSessionId:"",events:[],connectedWalletId:void 0}),ue={state:p,subscribe(e){return D(p.events,()=>e(ve(p.events[p.events.length-1])))},initialize(){p.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(p.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){p.connectedWalletId=e},click(e){if(p.enabled){const t={type:"CLICK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},track(e){if(p.enabled){const t={type:"TRACK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},view(e){if(p.enabled){const t={type:"VIEW",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}}},E=j({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),y={state:E,subscribe(e){return D(E,()=>e(E))},setChains(e){E.chains=e},setWalletConnectUri(e){E.walletConnectUri=e},setIsCustomDesktop(e){E.isCustomDesktop=e},setIsCustomMobile(e){E.isCustomMobile=e},setIsDataLoaded(e){E.isDataLoaded=e},setIsUiLoaded(e){E.isUiLoaded=e},setIsAuth(e){E.isAuth=e}},B=j({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),U={state:B,subscribe(e){return D(B,()=>e(B))},setConfig(e){var t,s;ue.initialize(),y.setChains(e.chains),y.setIsAuth(!!e.enableAuthMode),y.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),y.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),u.setModalVersionInStorage(),Object.assign(B,e)}};var Ie=Object.defineProperty,oe=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Le=(e,t)=>{for(var s in t||(t={}))Ee.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))Oe.call(t,s)&&re(e,s,t[s]);return e};const Q="https://explorer-api.walletconnect.com",X="wcm",Y="js-2.6.2";async function K(e,t){const s=Le({sdkType:X,sdkVersion:Y},t),r=new URL(e,Q);return r.searchParams.append("projectId",U.state.projectId),Object.entries(s).forEach(([l,c])=>{c&&r.searchParams.append(l,String(c))}),(await fetch(r)).json()}const P={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${Q}/w3m/v1/getWalletImage/${e}?projectId=${U.state.projectId}&sdkType=${X}&sdkVersion=${Y}`},getAssetImageUrl(e){return`${Q}/w3m/v1/getAssetImage/${e}?projectId=${U.state.projectId}&sdkType=${X}&sdkVersion=${Y}`}};var We=Object.defineProperty,ie=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,ae=(e,t,s)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,je=(e,t)=>{for(var s in t||(t={}))Ce.call(t,s)&&ae(e,s,t[s]);if(ie)for(var s of ie(t))Ae.call(t,s)&&ae(e,s,t[s]);return e};const le=u.isMobile(),O=j({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Me={state:O,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=U.state;if(e==="NONE"||t==="ALL"&&!e)return O.recomendedWallets;if(u.isArray(e)){const s={recommendedIds:e.join(",")},{listings:r}=await P.getAllListings(s),l=Object.values(r);l.sort((c,m)=>{const f=e.indexOf(c.id),W=e.indexOf(m.id);return f-W}),O.recomendedWallets=l}else{const{chains:s,isAuth:r}=y.state,l=s==null?void 0:s.join(","),c=u.isArray(t),m={page:1,sdks:r?"auth_v1":void 0,entries:u.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=le?await P.getMobileListings(m):await P.getDesktopListings(m);O.recomendedWallets=Object.values(f)}return O.recomendedWallets},async getWallets(e){const t=je({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:r}=U.state,{recomendedWallets:l}=O;if(r==="ALL")return O.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):u.isArray(s)&&(t.excludedIds=s.join(",")),u.isArray(r)&&(t.excludedIds=[t.excludedIds,r].filter(Boolean).join(",")),y.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:m}=e,{listings:f,total:W}=le?await P.getMobileListings(t):await P.getDesktopListings(t),n=Object.values(f),g=m?"search":"wallets";return O[g]={listings:[...O[g].listings,...n],total:W,page:c??1},{listings:n,total:W}},getWalletImageUrl(e){return P.getWalletImageUrl(e)},getAssetImageUrl(e){return P.getAssetImageUrl(e)},resetSearch(){O.search={listings:[],total:0,page:1}}},N=j({open:!1}),z={state:N,subscribe(e){return D(N,()=>e(N))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:r}=y.state;if(u.removeWalletConnectDeepLink(),y.setWalletConnectUri(e==null?void 0:e.uri),y.setChains(e==null?void 0:e.chains),ee.reset("ConnectWallet"),s&&r)N.open=!0,t();else{const l=setInterval(()=>{const c=y.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),N.open=!0,t())},200)}})},close(){N.open=!1}};var Pe=Object.defineProperty,ce=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,de=(e,t,s)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,De=(e,t)=>{for(var s in t||(t={}))Se.call(t,s)&&de(e,s,t[s]);if(ce)for(var s of ce(t))Ue.call(t,s)&&de(e,s,t[s]);return e};function _e(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const R=j({themeMode:_e()?"dark":"light"}),Z={state:R,subscribe(e){return D(R,()=>e(R))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(R.themeMode=t),s&&(R.themeVariables=De({},s))}},S=j({open:!1,message:"",variant:"success"}),ke={state:S,subscribe(e){return D(S,()=>e(S))},openToast(e,t){S.open=!0,S.message=e,S.variant=t},closeToast(){S.open=!1}};class Ne{constructor(t){this.openModal=z.open,this.closeModal=z.close,this.subscribeModal=z.subscribe,this.setTheme=Z.setThemeConfig,Z.setThemeConfig(t),U.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await Promise.resolve().then(()=>require("./index-CpWbXdKl.js"));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),y.setIsUiLoaded(!0)}}}const Te=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Ne},Symbol.toStringTag,{value:"Module"}));exports.R=ue;exports.T=ee;exports.a=u;exports.index=Te;exports.ne=Z;exports.oe=ke;exports.p=y;exports.se=z;exports.te=Me;exports.y=U;
|