@wormhole-foundation/wormhole-connect 1.1.8-beta.2-development → 1.1.8

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.
Files changed (94) hide show
  1. package/dist/assets/{ccip-B5VfDKOr.js → ccip-atE20ZEL.js} +1 -1
  2. package/dist/assets/{evm-CkbZddI4.js → evm-DiRlPnyB.js} +4 -4
  3. package/dist/assets/{index-BVl4T3LK.js → index-C6qclzFA.js} +1 -1
  4. package/dist/assets/index-CKe5Sopa.js +2 -0
  5. package/dist/assets/{index-CPZCe6ys.js → index-DOuohql9.js} +1 -1
  6. package/dist/assets/{index.es-D_CMbICm.js → index.es-BxGbRBbk.js} +2 -2
  7. package/dist/main.js +3 -3
  8. package/lib/{algorand-tXcNTbqw.js → algorand-BvtlkYvW.js} +1 -1
  9. package/lib/{algorand-DgpF_mXd.mjs → algorand-DUcbNcTT.mjs} +5 -5
  10. package/lib/{aptos-CTr4u3up.mjs → aptos-B4rlOyU6.mjs} +3 -3
  11. package/lib/{aptos-Cbmld6H3.js → aptos-BhgRAjHC.js} +2 -2
  12. package/lib/{aptos-CR0OcDBV.js → aptos-DhzeFi4o.js} +1 -1
  13. package/lib/{aptos-M_shWERr.mjs → aptos-nQowjIcb.mjs} +1 -1
  14. package/lib/{ccip-DaRd1xyq.js → ccip-BGUsNrsA.js} +1 -1
  15. package/lib/{ccip-C0KpO3UY.mjs → ccip-jzRXPLFO.mjs} +1 -1
  16. package/lib/{cosmwasm-u__X419O.js → cosmwasm-CGeqw6cI.js} +4 -4
  17. package/lib/{cosmwasm-BrumI-4g.mjs → cosmwasm-DrywDSkp.mjs} +10 -10
  18. package/lib/{events-B3M_mwnv.js → events-COjha8bx.js} +1 -1
  19. package/lib/{events-CpI6THlG.mjs → events-DuoZYNKO.mjs} +1 -1
  20. package/lib/{evm-Blf-_XHQ.js → evm-BBDClE2g.js} +4 -4
  21. package/lib/{evm-DTv3ll5g.mjs → evm-BuIItcEA.mjs} +12 -12
  22. package/lib/{evm-CcAiiNiN.mjs → evm-CEj34i-Y.mjs} +7 -7
  23. package/lib/{evm-B8QV0WMy.js → evm-CYnUn08H.js} +1 -1
  24. package/lib/{index-BWadlVxP.js → index-8IabBseN.js} +1 -1
  25. package/lib/{index-C24awnH1.mjs → index-A72nDBhY.mjs} +11 -11
  26. package/lib/{index-BLT1iLJO.js → index-B-LwhonE.js} +1 -1
  27. package/lib/{index-D_WLQWCk.js → index-B2JFHCjY.js} +1 -1
  28. package/lib/{index-CrvMtWJk.js → index-B6AFQ_fB.js} +1 -1
  29. package/lib/{index-lNjLQ3Ln.mjs → index-BISC0EuN.mjs} +9 -9
  30. package/lib/{index-NVVfqKqy.js → index-BIVNmWjC.js} +1 -1
  31. package/lib/{index-nvF_Vnsk.mjs → index-BJuAlURA.mjs} +3 -3
  32. package/lib/{index-Hj_44yP6.js → index-BJvQdk3o.js} +92 -92
  33. package/lib/{index-sqvrX5as.js → index-BTncL8og.js} +1 -1
  34. package/lib/{index-Br2oG_eT.mjs → index-BXkKxPSN.mjs} +2 -2
  35. package/lib/{index-BeR2pFP_.mjs → index-Bbhbkgfa.mjs} +2 -2
  36. package/lib/{index-DGUuTzq5.mjs → index-BeJsTgpu.mjs} +10 -10
  37. package/lib/{index-CH4v9fdl.mjs → index-Bh9u5bZu.mjs} +15 -15
  38. package/lib/{index-MAW-S7qJ.js → index-Bi4OJr6O.js} +1 -1
  39. package/lib/index-BsHKXTKU.js +1 -0
  40. package/lib/{index-CwrUNk7R.js → index-BuGRcK_Q.js} +1 -1
  41. package/lib/{index-CuqXZa2Q.mjs → index-CJEjOaWr.mjs} +1 -1
  42. package/lib/{index-BVEhvlmw.mjs → index-CRv6XxH6.mjs} +16 -16
  43. package/lib/{index-Dsp18Ki0.js → index-CTHiXye2.js} +1 -1
  44. package/lib/{index-iMGGdz1P.js → index-CWM3H2LC.js} +1 -1
  45. package/lib/{index-B9I8wNfR.js → index-CXIAreWV.js} +1 -1
  46. package/lib/{index-BVvayeum.mjs → index-CdExxm-8.mjs} +2 -2
  47. package/lib/{index-5iQ5GTSu.mjs → index-Cdpg2Kj3.mjs} +2 -2
  48. package/lib/{index-EFO4LCUD.mjs → index-CjexIr7B.mjs} +12 -12
  49. package/lib/{index-BPyIEVyq.js → index-Cyjyg63s.js} +1 -1
  50. package/lib/{index-DIeGmRzd.js → index-D5tJ7kz1.js} +1 -1
  51. package/lib/{index-DhvaqGhk.mjs → index-D7uCV0-2.mjs} +55 -55
  52. package/lib/{index-DSQmXjdq.mjs → index-D9fbH3oE.mjs} +35 -35
  53. package/lib/{index-B0-xPGuQ.mjs → index-D9h0sJ3x.mjs} +76 -76
  54. package/lib/{index-CaA38viB.js → index-DEi8dfu-.js} +1 -1
  55. package/lib/{index-BRV3iD_7.mjs → index-DKptU_Hc.mjs} +4 -4
  56. package/lib/{index-aB_fp0rM.mjs → index-Dc5wV51P.mjs} +20462 -20465
  57. package/lib/{index-CPe7WKSz.mjs → index-DcurocLc.mjs} +2 -2
  58. package/lib/{index-DZohPEoL.mjs → index-DdeuHj0J.mjs} +7 -7
  59. package/lib/{index-DcH-LW3u.js → index-DgbQ-dwi.js} +1 -1
  60. package/lib/{index-CU3bs1UO.js → index-DlnKgVH2.js} +1 -1
  61. package/lib/{index-CX4xrmvB.js → index-Ds_oSleh.js} +1 -1
  62. package/lib/{index-Dj9uX8Yq.mjs → index-HLOU4jOA.mjs} +2 -2
  63. package/lib/{index-QVDg02xQ.js → index-NNKFqYq6.js} +1 -1
  64. package/lib/{index-DXxIHcif.js → index-a5wU3oUB.js} +1 -1
  65. package/lib/{index-5Nsx5Sww.mjs → index-qoWS15WJ.mjs} +4 -4
  66. package/lib/{index-DaqgMXh5.mjs → index-uAstvLd8.mjs} +2 -2
  67. package/lib/{index-w19NhRI8.js → index-vjvft509.js} +1 -1
  68. package/lib/{index.es-8dGbttwj.js → index.es-ex5QzFoQ.js} +2 -2
  69. package/lib/{index.es-4k95rbkL.mjs → index.es-tj48a6VI.mjs} +5 -5
  70. package/lib/index.js +1 -1
  71. package/lib/index.mjs +2 -2
  72. package/lib/{keccak-BVl93H2h.mjs → keccak-CVFfUSfU.mjs} +1 -1
  73. package/lib/{keccak-DxPHQOs9.js → keccak-CzODwJ6V.js} +1 -1
  74. package/lib/{pbkdf2-C4tGHSl-.js → pbkdf2-DLmVRSHA.js} +1 -1
  75. package/lib/{pbkdf2-CrsCYTQU.mjs → pbkdf2-GUTNazYD.mjs} +1 -1
  76. package/lib/{signer-Du2DF25K.mjs → signer-Cqs1I7RB.mjs} +1 -1
  77. package/lib/{signer-BcAkKtkv.js → signer-rbcgQjZj.js} +1 -1
  78. package/lib/{solana-DS0mdgC1.mjs → solana-7ZFkKRtX.mjs} +4 -4
  79. package/lib/solana-BYPpXpJs.js +1 -0
  80. package/lib/solana-CcjhlsWI.mjs +16 -0
  81. package/lib/{solana-B2noqxW_.js → solana-DoqT3pca.js} +1 -1
  82. package/lib/{solanaEmbed.esm-Cr2BGkxp.js → solanaEmbed.esm-Bkti_f5v.js} +1 -1
  83. package/lib/{solanaEmbed.esm-B9HRNUtr.mjs → solanaEmbed.esm-LdO_IpPZ.mjs} +3 -3
  84. package/lib/{sui-CnGk4aWJ.mjs → sui-BffnXOND.mjs} +10 -10
  85. package/lib/{sui-CsizbSts.mjs → sui-Ch7mNd_P.mjs} +4 -4
  86. package/lib/{sui-Q9BM2cCK.js → sui-Df7REI6I.js} +2 -2
  87. package/lib/{sui-C7SxJ54B.js → sui-DfRirJoo.js} +1 -1
  88. package/lib/{unsignedTransaction-Cd7qXgBL.mjs → unsignedTransaction-CsCwFMvo.mjs} +4 -4
  89. package/lib/{unsignedTransaction-DDxT_548.js → unsignedTransaction-CvjJdjtG.js} +1 -1
  90. package/package.json +1 -1
  91. package/dist/assets/index-C_hywdem.js +0 -2
  92. package/lib/index-YmHc4VtK.js +0 -1
  93. package/lib/solana-CFMBUeJY.js +0 -1
  94. package/lib/solana-lSSqSdUq.mjs +0 -16
@@ -1 +1 @@
1
- "use strict";var T=Object.defineProperty;var C=(m,e,t)=>e in m?T(m,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):m[e]=t;var d=(m,e,t)=>C(m,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-sqvrX5as.js");const c=require("./cosmwasm-u__X419O.js"),i=require("./unsignedTransaction-DDxT_548.js"),s=require("./index-Hj_44yP6.js");class l{constructor(e,t,r,n){d(this,"network");d(this,"chain");d(this,"rpc");d(this,"contracts");d(this,"tokenBridge");d(this,"translator");this.network=e,this.chain=t,this.rpc=r,this.contracts=n;const a=this.contracts.tokenBridge;if(!a)throw new Error(`Wormhole Token Bridge contract for domain ${t} not found`);if(this.tokenBridge=a,this.translator=this.contracts.translator,this.translator!==void 0&&this.translator==="")throw new Error("Translator address may be undefined but not empty string")}static async fromRpc(e,t){const[r,n]=await c.CosmwasmPlatform.chainFromRpc(e),a=t[n];if(a.network!==r)throw new Error(`Network mismatch: ${a.network} != ${r}`);return new l(r,n,e,t[n].contracts)}async isWrappedAsset(e){try{return await this.getOriginalAsset(e),!0}catch{}return!1}async hasWrappedAsset(e){try{return await this.getWrappedAsset(e),!0}catch{}return!1}async getWrappedAsset(e){if(e.chain===this.chain)throw new Error(`Expected foreign chain, got ${e.chain}`);if(s.isNative(e.address))throw new Error("Native asset cannot be a wrapped asset");const t=s.b64.encode(e.address.toUniversalAddress().toUint8Array()),{address:r}=await this.rpc.queryContractSmart(this.tokenBridge,{wrapped_registry:{chain:s.toChainId(e.chain),address:t}});return s.toNative(this.chain,r)}async getOriginalAsset(e){let t=new s.CosmwasmAddress(e);t.denomType==="factory"&&(t=c.Gateway.factoryToCw20(t));const r=await this.rpc.queryContractSmart(t.toString(),{wrapped_asset_info:{}}),n=s.toChain(r.asset_chain),a=s.b64.decode(r.asset_address);return{chain:n,address:new s.UniversalAddress(new Uint8Array(a))}}async getTokenUniversalAddress(e){return new s.CosmwasmAddress(e).toUniversalAddress()}async getTokenNativeAddress(e,t){return new s.CosmwasmAddress(t).toNative()}async isTransferCompleted(e){const t=s.b64.encode(s.serialize(e));return(await this.rpc.queryContractSmart(this.tokenBridge,{is_vaa_redeemed:{vaa:t}})).is_redeemed}async*createAttestation(e,t){if(!t)throw new Error("Payer required to create attestation");const r=new s.CosmwasmAddress(e).toString(),n=new s.CosmwasmAddress(t).toString(),a=0,w=s.isNative(e)?{native_token:{denom:c.CosmwasmPlatform.getNativeDenom(this.network,this.chain)}}:{token:{contract_addr:r}};yield this.createUnsignedTx({msgs:[i.buildExecuteMsg(n,this.tokenBridge,{create_asset_meta:{asset_info:w,nonce:a}})],fee:i.computeFee(this.network,this.chain),memo:"Wormhole - Create Attestation"},"TokenBridge.createAttestation")}async*submitAttestation(e,t){if(!t)throw new Error("Payer required to submit attestation");const r=new s.CosmwasmAddress(t).toString();yield this.createUnsignedTx({msgs:[i.buildExecuteMsg(r,this.tokenBridge,{submit_vaa:{data:s.serialize(e)}})],fee:i.computeFee(this.network,this.chain),memo:"Wormhole - Submit Attestation"},"TokenBridge.submitAttestation")}async*transfer(e,t,r,n,a){const w=Math.round(Math.random()*1e5),u="0",k=s.toChainId(t.chain),A=s.b64.encode(t.address.toUniversalAddress().toUint8Array()),v=c.CosmwasmPlatform.getNativeDenom(this.network,this.chain),f=s.isNative(r);let o=f?v:r.toString();o.startsWith("factory")&&(o=c.Gateway.factoryToCw20(new s.CosmwasmAddress(o)).toString());const g=new s.CosmwasmAddress(e).toString(),p=h=>{const y={asset:{amount:n.toString(),info:h},recipient_chain:k,recipient:A,fee:u,nonce:w};return a?{initiate_transfer_with_payload:{...y,payload:s.b64.encode(a)}}:{initiate_transfer:y}};if(f){const h=[i.buildExecuteMsg(g,this.tokenBridge,{deposit_tokens:{}},[{amount:n.toString(),denom:o}]),i.buildExecuteMsg(g,this.tokenBridge,p({native_token:{denom:o}}))];yield this.createUnsignedTx({msgs:h,fee:i.computeFee(this.network,this.chain),memo:"Wormhole - Initiate Native Transfer"},"TokenBridge.transferNative")}else{const h=[i.buildExecuteMsg(g,o,{increase_allowance:{spender:this.tokenBridge,amount:n.toString(),expires:{never:{}}}}),i.buildExecuteMsg(g,this.tokenBridge,p({token:{contract_addr:o}}),[{amount:n.toString(),denom:o}])];yield this.createUnsignedTx({msgs:h,fee:i.computeFee(this.network,this.chain),memo:"Wormhole - Initiate Transfer"},"TokenBridge.transfer")}}async*redeem(e,t,r=!0){const n=s.b64.encode(s.serialize(t)),a=new s.CosmwasmAddress(e).toString(),u=this.translator&&new s.CosmwasmAddress(this.translator).toUniversalAddress().equals(t.payload.to.address)?i.buildExecuteMsg(a,this.translator,{complete_transfer_and_convert:{vaa:n}}):i.buildExecuteMsg(a,this.tokenBridge,{submit_vaa:{data:n}});yield this.createUnsignedTx({msgs:[u],fee:i.computeFee(this.network,this.chain),memo:"Wormhole - Complete Transfer"},"TokenBridge.redeem")}async parseTransactionDetails(e){throw new Error("Not implemented")}async getWrappedNative(){return s.toNative(this.chain,c.CosmwasmPlatform.getNativeDenom(this.network,this.chain))}createUnsignedTx(e,t,r=!1){return new i.CosmwasmUnsignedTransaction(e,this.network,this.chain,t,r)}}s.registerProtocol(s._platform$3,"TokenBridge",l);exports.CosmwasmTokenBridge=l;
1
+ "use strict";var T=Object.defineProperty;var C=(m,e,t)=>e in m?T(m,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):m[e]=t;var d=(m,e,t)=>C(m,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-BTncL8og.js");const c=require("./cosmwasm-CGeqw6cI.js"),i=require("./unsignedTransaction-CvjJdjtG.js"),s=require("./index-BJvQdk3o.js");class l{constructor(e,t,r,n){d(this,"network");d(this,"chain");d(this,"rpc");d(this,"contracts");d(this,"tokenBridge");d(this,"translator");this.network=e,this.chain=t,this.rpc=r,this.contracts=n;const a=this.contracts.tokenBridge;if(!a)throw new Error(`Wormhole Token Bridge contract for domain ${t} not found`);if(this.tokenBridge=a,this.translator=this.contracts.translator,this.translator!==void 0&&this.translator==="")throw new Error("Translator address may be undefined but not empty string")}static async fromRpc(e,t){const[r,n]=await c.CosmwasmPlatform.chainFromRpc(e),a=t[n];if(a.network!==r)throw new Error(`Network mismatch: ${a.network} != ${r}`);return new l(r,n,e,t[n].contracts)}async isWrappedAsset(e){try{return await this.getOriginalAsset(e),!0}catch{}return!1}async hasWrappedAsset(e){try{return await this.getWrappedAsset(e),!0}catch{}return!1}async getWrappedAsset(e){if(e.chain===this.chain)throw new Error(`Expected foreign chain, got ${e.chain}`);if(s.isNative(e.address))throw new Error("Native asset cannot be a wrapped asset");const t=s.b64.encode(e.address.toUniversalAddress().toUint8Array()),{address:r}=await this.rpc.queryContractSmart(this.tokenBridge,{wrapped_registry:{chain:s.toChainId(e.chain),address:t}});return s.toNative(this.chain,r)}async getOriginalAsset(e){let t=new s.CosmwasmAddress(e);t.denomType==="factory"&&(t=c.Gateway.factoryToCw20(t));const r=await this.rpc.queryContractSmart(t.toString(),{wrapped_asset_info:{}}),n=s.toChain(r.asset_chain),a=s.b64.decode(r.asset_address);return{chain:n,address:new s.UniversalAddress(new Uint8Array(a))}}async getTokenUniversalAddress(e){return new s.CosmwasmAddress(e).toUniversalAddress()}async getTokenNativeAddress(e,t){return new s.CosmwasmAddress(t).toNative()}async isTransferCompleted(e){const t=s.b64.encode(s.serialize(e));return(await this.rpc.queryContractSmart(this.tokenBridge,{is_vaa_redeemed:{vaa:t}})).is_redeemed}async*createAttestation(e,t){if(!t)throw new Error("Payer required to create attestation");const r=new s.CosmwasmAddress(e).toString(),n=new s.CosmwasmAddress(t).toString(),a=0,w=s.isNative(e)?{native_token:{denom:c.CosmwasmPlatform.getNativeDenom(this.network,this.chain)}}:{token:{contract_addr:r}};yield this.createUnsignedTx({msgs:[i.buildExecuteMsg(n,this.tokenBridge,{create_asset_meta:{asset_info:w,nonce:a}})],fee:i.computeFee(this.network,this.chain),memo:"Wormhole - Create Attestation"},"TokenBridge.createAttestation")}async*submitAttestation(e,t){if(!t)throw new Error("Payer required to submit attestation");const r=new s.CosmwasmAddress(t).toString();yield this.createUnsignedTx({msgs:[i.buildExecuteMsg(r,this.tokenBridge,{submit_vaa:{data:s.serialize(e)}})],fee:i.computeFee(this.network,this.chain),memo:"Wormhole - Submit Attestation"},"TokenBridge.submitAttestation")}async*transfer(e,t,r,n,a){const w=Math.round(Math.random()*1e5),u="0",k=s.toChainId(t.chain),A=s.b64.encode(t.address.toUniversalAddress().toUint8Array()),v=c.CosmwasmPlatform.getNativeDenom(this.network,this.chain),f=s.isNative(r);let o=f?v:r.toString();o.startsWith("factory")&&(o=c.Gateway.factoryToCw20(new s.CosmwasmAddress(o)).toString());const g=new s.CosmwasmAddress(e).toString(),p=h=>{const y={asset:{amount:n.toString(),info:h},recipient_chain:k,recipient:A,fee:u,nonce:w};return a?{initiate_transfer_with_payload:{...y,payload:s.b64.encode(a)}}:{initiate_transfer:y}};if(f){const h=[i.buildExecuteMsg(g,this.tokenBridge,{deposit_tokens:{}},[{amount:n.toString(),denom:o}]),i.buildExecuteMsg(g,this.tokenBridge,p({native_token:{denom:o}}))];yield this.createUnsignedTx({msgs:h,fee:i.computeFee(this.network,this.chain),memo:"Wormhole - Initiate Native Transfer"},"TokenBridge.transferNative")}else{const h=[i.buildExecuteMsg(g,o,{increase_allowance:{spender:this.tokenBridge,amount:n.toString(),expires:{never:{}}}}),i.buildExecuteMsg(g,this.tokenBridge,p({token:{contract_addr:o}}),[{amount:n.toString(),denom:o}])];yield this.createUnsignedTx({msgs:h,fee:i.computeFee(this.network,this.chain),memo:"Wormhole - Initiate Transfer"},"TokenBridge.transfer")}}async*redeem(e,t,r=!0){const n=s.b64.encode(s.serialize(t)),a=new s.CosmwasmAddress(e).toString(),u=this.translator&&new s.CosmwasmAddress(this.translator).toUniversalAddress().equals(t.payload.to.address)?i.buildExecuteMsg(a,this.translator,{complete_transfer_and_convert:{vaa:n}}):i.buildExecuteMsg(a,this.tokenBridge,{submit_vaa:{data:n}});yield this.createUnsignedTx({msgs:[u],fee:i.computeFee(this.network,this.chain),memo:"Wormhole - Complete Transfer"},"TokenBridge.redeem")}async parseTransactionDetails(e){throw new Error("Not implemented")}async getWrappedNative(){return s.toNative(this.chain,c.CosmwasmPlatform.getNativeDenom(this.network,this.chain))}createUnsignedTx(e,t,r=!1){return new i.CosmwasmUnsignedTransaction(e,this.network,this.chain,t,r)}}s.registerProtocol(s._platform$3,"TokenBridge",l);exports.CosmwasmTokenBridge=l;
@@ -1 +1 @@
1
- "use strict";var S=Object.defineProperty;var P=(l,o,t)=>o in l?S(l,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[o]=t;var h=(l,o,t)=>P(l,typeof o!="symbol"?o+"":o,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-Hj_44yP6.js"),U=require("./index-BLT1iLJO.js"),A=new e.Interface(["function start((bytes32,address,address,address,address,address,uint256,uint256,uint256,uint256)) returns (address,uint16,uint64)","function receiveMessageAndSwap(bytes)"]),q=new e.Interface(["function quoteExactInputSingle((address,address,uint256,uint24,uint160)) public view returns (uint256,uint160,uint32,uint256)"]),N="https://gfx.relayers.xlabs.xyz/api/v1/swap/quote";class R{static async quoteRelayer(o,t,r){var a;if(e.isNative(t)||e.isNative(r))throw new Error("how did you get here tho?");const n=e.hex.encode(t.toUniversalAddress().toUint8Array(),!1),s=e.hex.encode(r.toUniversalAddress().toUint8Array(),!1),i={targetChain:e.toChainId(o),sourceToken:n,targetToken:s};try{const c=await e.axios.post(N,i);return BigInt(c.data.fee)}catch(c){throw e.axios.isAxiosError(c)?new Error(`Error getting relayer fee: ${(a=c.response)==null?void 0:a.statusText}`):c}}}const m=100,E={ETH:[e.Wormhole.tokenId("Arbitrum","native"),e.Wormhole.tokenId("Base","native"),e.Wormhole.tokenId("Ethereum","native"),e.Wormhole.tokenId("Optimism","native")],WETH:[e.Wormhole.tokenId("Arbitrum","0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),e.Wormhole.tokenId("Avalanche","0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB"),e.Wormhole.tokenId("Base","0x4200000000000000000000000000000000000006"),e.Wormhole.tokenId("Bsc","0x2170Ed0880ac9A755fd29B2688956BD959F933F8"),e.Wormhole.tokenId("Ethereum","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),e.Wormhole.tokenId("Optimism","0x4200000000000000000000000000000000000006"),e.Wormhole.tokenId("Polygon","0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619")],wstETH:[e.Wormhole.tokenId("Arbitrum","0x5979D7b546E38E414F7E9822514be443A4800529"),e.Wormhole.tokenId("Base","0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452"),e.Wormhole.tokenId("Ethereum","0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"),e.Wormhole.tokenId("Optimism","0x1F32b1c2345538c0c6f582fCB022739c4A194Ebb"),e.Wormhole.tokenId("Polygon","0x03b54A6e9a984069379fae1a4fC4dBAE93B3bCCD")],USDT:[e.Wormhole.tokenId("Arbitrum","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),e.Wormhole.tokenId("Avalanche","0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7"),e.Wormhole.tokenId("Base","0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2"),e.Wormhole.tokenId("Bsc","0x55d398326f99059fF775485246999027B3197955"),e.Wormhole.tokenId("Ethereum","0xdAC17F958D2ee523a2206206994597C13D831ec7"),e.Wormhole.tokenId("Optimism","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"),e.Wormhole.tokenId("Polygon","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"),e.Wormhole.tokenId("Celo","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e")]};class p{constructor(o,t,r,n){h(this,"network");h(this,"chain");h(this,"provider");h(this,"contracts");h(this,"chainId");h(this,"core");h(this,"tokenBridge");if(this.network=o,this.chain=t,this.provider=r,this.contracts=n,!n.portico)throw new Error("Unsupported chain, no contract addresses for: "+t);this.core=new e.EvmWormholeCore(o,t,r,n),this.tokenBridge=new U.EvmTokenBridge(o,t,r,n),this.chainId=e.networkChainToNativeChainId.get(o,t)}static async fromRpc(o,t){const[r,n]=await e.EvmPlatform.chainFromRpc(o),s=t[n];if(s.network!==r)throw new Error(`Network mismatch: ${s.network} != ${r}`);return new p(r,n,o,s.contracts)}async*transfer(o,t,r,n,s,d,i){const{minAmountStart:a,minAmountFinish:c}=i.swapAmounts;if(a===0n)throw new Error("Invalid min swap amount");if(c===0n)throw new Error("Invalid min swap amount");const f=new e.EvmAddress(o).toString(),[u,g]=e.resolveWrappedToken(this.network,this.chain,r),[T,C]=e.resolveWrappedToken(this.network,t.chain,s),k=e.canonicalAddress(g),I=e.canonicalAddress(await this.getTransferrableToken(k)),b=e.canonicalAddress(t),v=e.canonicalAddress(C),F=new Date().valueOf()%2**4,B=e.PorticoBridge.serializeFlagSet({flags:{shouldWrapNative:u,shouldUnwrapNative:T},recipientChain:e.toChainId(t.chain),bridgeNonce:F,feeTierStart:m,feeTierFinish:m,padding:new Uint8Array(19)}),y=A.encodeFunctionData("start",[[B,k.toLowerCase(),I,v.toLowerCase(),b,d,n.toString(),a.toString(),c.toString(),i.relayerFee.toString()]]),x=this.getTokenGroup(g.address.toString()),w=this.getPorticoAddress(x);u||(yield*this.approve(k,f,n,w));const W=await this.core.getMessageFee(),D={to:w,data:y,value:W+(u?n:0n)};yield this.createUnsignedTransaction(e.addFrom(D,f),"PorticoBridge.Transfer")}async*redeem(o,t){const r=e.toChain(t.payload.payload.flagSet.recipientChain),n=t.payload.payload.finalTokenAddress.toNative(r).toString(),s=this.getTokenGroup(n),d=this.getPorticoAddress(s),a=await new e.Contract(d,A.fragments,this.provider).getFunction("receiveMessageAndSwap").populateTransaction(e.serialize(t)),c=new e.EvmAddress(o).toString();yield this.createUnsignedTransaction(e.addFrom(a,c),"PorticoBridge.Redeem")}async isTransferCompleted(o){return await this.tokenBridge.tokenBridge.isTransferCompleted(e.keccak256(o.hash))}async quoteSwap(o,t,r,n){const[,s]=e.resolveWrappedToken(this.network,this.chain,o),[,d]=e.resolveWrappedToken(this.network,this.chain,t),i=e.canonicalAddress(s),a=e.canonicalAddress(d);if(e.isEqualCaseInsensitive(i,a))return n;const c=this.getQuoterAddress(r);return(await new e.Contract(c,q.fragments,this.provider).getFunction("quoteExactInputSingle").staticCall([i,a,n,m,0]))[0]}async quoteRelay(o,t){return await R.quoteRelayer(this.chain,o,t)}async getTransferrableToken(o){const t=e.Wormhole.tokenId(this.chain,o),[,r]=e.resolveWrappedToken(this.network,this.chain,t);if(this.chain==="Ethereum")return r;const n=Object.values(E).find(i=>i.find(a=>a.chain===this.chain&&e.canonicalAddress(a)===e.canonicalAddress(r)));if(!n)throw new Error(`No token group found for ${o} on ${this.chain}`);const s=n.find(i=>i.chain==="Ethereum");if(!s)throw new Error(`No Ethereum origin token found for ${o} on ${this.chain}`);const d=await this.tokenBridge.getWrappedAsset(s);return e.Wormhole.tokenId(this.chain,d.toString())}supportedTokens(){const o=[];for(const[t,r]of Object.entries(E))for(const n of r)n.chain===this.chain&&o.push({group:t,token:n});return o}getTokenGroup(o){const r=this.supportedTokens().find(n=>e.canonicalAddress(n.token)===o);if(!r)throw new Error("Token not found");return r.group}async*approve(o,t,r,n){const s=e.EvmPlatform.getTokenImplementation(this.provider,o);if(await s.allowance(t,n)<r){const i=await s.approve.populateTransaction(n,r);yield this.createUnsignedTransaction(e.addFrom(i,t),"PorticoBridge.Approve")}}createUnsignedTransaction(o,t){return new e.EvmUnsignedTransaction(e.addChainId(o,this.chainId),this.network,this.chain,t,!1)}getPorticoAddress(o){const t=this.contracts.portico;return o==="USDT"&&t.porticoPancakeSwap||t.porticoUniswap}getQuoterAddress(o){const t=this.contracts.portico;return o==="USDT"&&t.pancakeSwapQuoterV2||t.uniswapQuoterV2}}e.registerProtocol(e._platform,"PorticoBridge",p);exports.EvmPorticoBridge=p;
1
+ "use strict";var S=Object.defineProperty;var P=(l,o,t)=>o in l?S(l,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[o]=t;var h=(l,o,t)=>P(l,typeof o!="symbol"?o+"":o,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BJvQdk3o.js"),U=require("./index-B-LwhonE.js"),A=new e.Interface(["function start((bytes32,address,address,address,address,address,uint256,uint256,uint256,uint256)) returns (address,uint16,uint64)","function receiveMessageAndSwap(bytes)"]),q=new e.Interface(["function quoteExactInputSingle((address,address,uint256,uint24,uint160)) public view returns (uint256,uint160,uint32,uint256)"]),N="https://gfx.relayers.xlabs.xyz/api/v1/swap/quote";class R{static async quoteRelayer(o,t,r){var a;if(e.isNative(t)||e.isNative(r))throw new Error("how did you get here tho?");const n=e.hex.encode(t.toUniversalAddress().toUint8Array(),!1),s=e.hex.encode(r.toUniversalAddress().toUint8Array(),!1),i={targetChain:e.toChainId(o),sourceToken:n,targetToken:s};try{const c=await e.axios.post(N,i);return BigInt(c.data.fee)}catch(c){throw e.axios.isAxiosError(c)?new Error(`Error getting relayer fee: ${(a=c.response)==null?void 0:a.statusText}`):c}}}const m=100,E={ETH:[e.Wormhole.tokenId("Arbitrum","native"),e.Wormhole.tokenId("Base","native"),e.Wormhole.tokenId("Ethereum","native"),e.Wormhole.tokenId("Optimism","native")],WETH:[e.Wormhole.tokenId("Arbitrum","0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),e.Wormhole.tokenId("Avalanche","0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB"),e.Wormhole.tokenId("Base","0x4200000000000000000000000000000000000006"),e.Wormhole.tokenId("Bsc","0x2170Ed0880ac9A755fd29B2688956BD959F933F8"),e.Wormhole.tokenId("Ethereum","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),e.Wormhole.tokenId("Optimism","0x4200000000000000000000000000000000000006"),e.Wormhole.tokenId("Polygon","0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619")],wstETH:[e.Wormhole.tokenId("Arbitrum","0x5979D7b546E38E414F7E9822514be443A4800529"),e.Wormhole.tokenId("Base","0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452"),e.Wormhole.tokenId("Ethereum","0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"),e.Wormhole.tokenId("Optimism","0x1F32b1c2345538c0c6f582fCB022739c4A194Ebb"),e.Wormhole.tokenId("Polygon","0x03b54A6e9a984069379fae1a4fC4dBAE93B3bCCD")],USDT:[e.Wormhole.tokenId("Arbitrum","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),e.Wormhole.tokenId("Avalanche","0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7"),e.Wormhole.tokenId("Base","0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2"),e.Wormhole.tokenId("Bsc","0x55d398326f99059fF775485246999027B3197955"),e.Wormhole.tokenId("Ethereum","0xdAC17F958D2ee523a2206206994597C13D831ec7"),e.Wormhole.tokenId("Optimism","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"),e.Wormhole.tokenId("Polygon","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"),e.Wormhole.tokenId("Celo","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e")]};class p{constructor(o,t,r,n){h(this,"network");h(this,"chain");h(this,"provider");h(this,"contracts");h(this,"chainId");h(this,"core");h(this,"tokenBridge");if(this.network=o,this.chain=t,this.provider=r,this.contracts=n,!n.portico)throw new Error("Unsupported chain, no contract addresses for: "+t);this.core=new e.EvmWormholeCore(o,t,r,n),this.tokenBridge=new U.EvmTokenBridge(o,t,r,n),this.chainId=e.networkChainToNativeChainId.get(o,t)}static async fromRpc(o,t){const[r,n]=await e.EvmPlatform.chainFromRpc(o),s=t[n];if(s.network!==r)throw new Error(`Network mismatch: ${s.network} != ${r}`);return new p(r,n,o,s.contracts)}async*transfer(o,t,r,n,s,d,i){const{minAmountStart:a,minAmountFinish:c}=i.swapAmounts;if(a===0n)throw new Error("Invalid min swap amount");if(c===0n)throw new Error("Invalid min swap amount");const f=new e.EvmAddress(o).toString(),[u,g]=e.resolveWrappedToken(this.network,this.chain,r),[T,C]=e.resolveWrappedToken(this.network,t.chain,s),k=e.canonicalAddress(g),I=e.canonicalAddress(await this.getTransferrableToken(k)),b=e.canonicalAddress(t),v=e.canonicalAddress(C),F=new Date().valueOf()%2**4,B=e.PorticoBridge.serializeFlagSet({flags:{shouldWrapNative:u,shouldUnwrapNative:T},recipientChain:e.toChainId(t.chain),bridgeNonce:F,feeTierStart:m,feeTierFinish:m,padding:new Uint8Array(19)}),y=A.encodeFunctionData("start",[[B,k.toLowerCase(),I,v.toLowerCase(),b,d,n.toString(),a.toString(),c.toString(),i.relayerFee.toString()]]),x=this.getTokenGroup(g.address.toString()),w=this.getPorticoAddress(x);u||(yield*this.approve(k,f,n,w));const W=await this.core.getMessageFee(),D={to:w,data:y,value:W+(u?n:0n)};yield this.createUnsignedTransaction(e.addFrom(D,f),"PorticoBridge.Transfer")}async*redeem(o,t){const r=e.toChain(t.payload.payload.flagSet.recipientChain),n=t.payload.payload.finalTokenAddress.toNative(r).toString(),s=this.getTokenGroup(n),d=this.getPorticoAddress(s),a=await new e.Contract(d,A.fragments,this.provider).getFunction("receiveMessageAndSwap").populateTransaction(e.serialize(t)),c=new e.EvmAddress(o).toString();yield this.createUnsignedTransaction(e.addFrom(a,c),"PorticoBridge.Redeem")}async isTransferCompleted(o){return await this.tokenBridge.tokenBridge.isTransferCompleted(e.keccak256(o.hash))}async quoteSwap(o,t,r,n){const[,s]=e.resolveWrappedToken(this.network,this.chain,o),[,d]=e.resolveWrappedToken(this.network,this.chain,t),i=e.canonicalAddress(s),a=e.canonicalAddress(d);if(e.isEqualCaseInsensitive(i,a))return n;const c=this.getQuoterAddress(r);return(await new e.Contract(c,q.fragments,this.provider).getFunction("quoteExactInputSingle").staticCall([i,a,n,m,0]))[0]}async quoteRelay(o,t){return await R.quoteRelayer(this.chain,o,t)}async getTransferrableToken(o){const t=e.Wormhole.tokenId(this.chain,o),[,r]=e.resolveWrappedToken(this.network,this.chain,t);if(this.chain==="Ethereum")return r;const n=Object.values(E).find(i=>i.find(a=>a.chain===this.chain&&e.canonicalAddress(a)===e.canonicalAddress(r)));if(!n)throw new Error(`No token group found for ${o} on ${this.chain}`);const s=n.find(i=>i.chain==="Ethereum");if(!s)throw new Error(`No Ethereum origin token found for ${o} on ${this.chain}`);const d=await this.tokenBridge.getWrappedAsset(s);return e.Wormhole.tokenId(this.chain,d.toString())}supportedTokens(){const o=[];for(const[t,r]of Object.entries(E))for(const n of r)n.chain===this.chain&&o.push({group:t,token:n});return o}getTokenGroup(o){const r=this.supportedTokens().find(n=>e.canonicalAddress(n.token)===o);if(!r)throw new Error("Token not found");return r.group}async*approve(o,t,r,n){const s=e.EvmPlatform.getTokenImplementation(this.provider,o);if(await s.allowance(t,n)<r){const i=await s.approve.populateTransaction(n,r);yield this.createUnsignedTransaction(e.addFrom(i,t),"PorticoBridge.Approve")}}createUnsignedTransaction(o,t){return new e.EvmUnsignedTransaction(e.addChainId(o,this.chainId),this.network,this.chain,t,!1)}getPorticoAddress(o){const t=this.contracts.portico;return o==="USDT"&&t.porticoPancakeSwap||t.porticoUniswap}getQuoterAddress(o){const t=this.contracts.portico;return o==="USDT"&&t.pancakeSwapQuoterV2||t.uniswapQuoterV2}}e.registerProtocol(e._platform,"PorticoBridge",p);exports.EvmPorticoBridge=p;
@@ -1,8 +1,8 @@
1
1
  var v = Object.defineProperty;
2
- var S = (i, e, t) => e in i ? v(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var a = (i, e, t) => S(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { cC as f, cD as b, ad as I, r as p, cE as x, ag as w, b_ as E, bD as $, b$ as m, u as o, cF as k, s as c, p as h, cG as F, c4 as _, h as U, c1 as C, m as T, bE as l, cH as W, bJ as N } from "./index-aB_fp0rM.mjs";
5
- import { A as O } from "./aptos-CTr4u3up.mjs";
2
+ var I = (i, e, t) => e in i ? v(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var a = (i, e, t) => I(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { cB as f, cC as S, ad as b, r as p, cD as x, ag as w, bZ as C, bC as E, b_ as m, u as o, cE as k, s as c, p as h, cF as F, c3 as _, h as U, c0 as $, m as T, bD as l, cG as W, bI as N } from "./index-Dc5wV51P.mjs";
5
+ import { A as O } from "./aptos-B4rlOyU6.mjs";
6
6
  class Q {
7
7
  constructor(e, t, s, r, n = !1) {
8
8
  a(this, "transaction");
@@ -15,11 +15,11 @@ class Q {
15
15
  }
16
16
  const R = [
17
17
  { name: "tokenBridgeAddress", ...f },
18
- { name: "chain", ...b() },
18
+ { name: "chain", ...S() },
19
19
  {
20
20
  name: "domainSeparator",
21
21
  binary: "bytes",
22
- custom: I.encode(p),
22
+ custom: b.encode(p),
23
23
  omit: !0
24
24
  },
25
25
  { name: "tokenId", ...f },
@@ -57,8 +57,8 @@ class d {
57
57
  const t = e.toString().split(p);
58
58
  let s;
59
59
  if (s = (await this.connection.getAccountResource(t[0], `${this.tokenBridgeAddress}::state::OriginInfo`)).data, !s)
60
- throw E;
61
- const r = $(parseInt(s.token_chain.number)), n = new m(s.token_address.external_address);
60
+ throw C;
61
+ const r = E(parseInt(s.token_chain.number)), n = new m(s.token_address.external_address);
62
62
  return { chain: r, address: n };
63
63
  }
64
64
  async getTokenUniversalAddress(e) {
@@ -91,7 +91,7 @@ class d {
91
91
  return await this.connection.getTableItem(s, {
92
92
  key_type: "vector<u8>",
93
93
  value_type: "u8",
94
- key: `0x${U.Buffer.from(C(e.hash)).toString("hex")}`
94
+ key: `0x${U.Buffer.from($(e.hash)).toString("hex")}`
95
95
  }), !0;
96
96
  } catch {
97
97
  return !1;