@uswap/toolboxes 4.3.7 → 4.3.10

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 (149) hide show
  1. package/dist/src/cardano/index.cjs +2 -2
  2. package/dist/src/cardano/index.cjs.map +3 -3
  3. package/dist/src/cardano/index.js +2 -2
  4. package/dist/src/cardano/index.js.map +3 -3
  5. package/dist/src/cosmos/index.cjs +2 -2
  6. package/dist/src/cosmos/index.cjs.map +8 -8
  7. package/dist/src/cosmos/index.js +2 -2
  8. package/dist/src/cosmos/index.js.map +8 -8
  9. package/dist/src/evm/index.cjs +2 -2
  10. package/dist/src/evm/index.cjs.map +7 -7
  11. package/dist/src/evm/index.js +2 -2
  12. package/dist/src/evm/index.js.map +7 -7
  13. package/dist/src/index.cjs +3 -3
  14. package/dist/src/index.cjs.map +34 -34
  15. package/dist/src/index.js +3 -3
  16. package/dist/src/index.js.map +34 -34
  17. package/dist/src/near/index.cjs +2 -2
  18. package/dist/src/near/index.cjs.map +5 -5
  19. package/dist/src/near/index.js +2 -2
  20. package/dist/src/near/index.js.map +5 -5
  21. package/dist/src/radix/index.cjs +2 -2
  22. package/dist/src/radix/index.cjs.map +3 -3
  23. package/dist/src/radix/index.js +2 -2
  24. package/dist/src/radix/index.js.map +3 -3
  25. package/dist/src/ripple/index.cjs +2 -2
  26. package/dist/src/ripple/index.cjs.map +3 -3
  27. package/dist/src/ripple/index.js +2 -2
  28. package/dist/src/ripple/index.js.map +3 -3
  29. package/dist/src/solana/index.cjs +2 -2
  30. package/dist/src/solana/index.cjs.map +3 -3
  31. package/dist/src/solana/index.js +2 -2
  32. package/dist/src/solana/index.js.map +3 -3
  33. package/dist/src/substrate/index.cjs +2 -2
  34. package/dist/src/substrate/index.cjs.map +4 -4
  35. package/dist/src/substrate/index.js +2 -2
  36. package/dist/src/substrate/index.js.map +4 -4
  37. package/dist/src/sui/index.cjs +2 -2
  38. package/dist/src/sui/index.cjs.map +3 -3
  39. package/dist/src/sui/index.js +2 -2
  40. package/dist/src/sui/index.js.map +3 -3
  41. package/dist/src/ton/index.cjs +2 -2
  42. package/dist/src/ton/index.cjs.map +3 -3
  43. package/dist/src/ton/index.js +2 -2
  44. package/dist/src/ton/index.js.map +3 -3
  45. package/dist/src/tron/index.cjs +2 -2
  46. package/dist/src/tron/index.cjs.map +4 -4
  47. package/dist/src/tron/index.js +2 -2
  48. package/dist/src/tron/index.js.map +4 -4
  49. package/dist/src/utxo/index.cjs +3 -3
  50. package/dist/src/utxo/index.cjs.map +11 -11
  51. package/dist/src/utxo/index.js +3 -3
  52. package/dist/src/utxo/index.js.map +11 -11
  53. package/dist/types/cardano/toolbox.d.ts +5 -0
  54. package/dist/types/cardano/toolbox.d.ts.map +1 -1
  55. package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts +5 -0
  56. package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts.map +1 -1
  57. package/dist/types/cosmos/thorchainUtils/messages.d.ts +5 -0
  58. package/dist/types/cosmos/thorchainUtils/messages.d.ts.map +1 -1
  59. package/dist/types/cosmos/toolbox/cosmos.d.ts +5 -0
  60. package/dist/types/cosmos/toolbox/cosmos.d.ts.map +1 -1
  61. package/dist/types/cosmos/toolbox/index.d.ts +5 -0
  62. package/dist/types/cosmos/toolbox/index.d.ts.map +1 -1
  63. package/dist/types/cosmos/toolbox/thorchain.d.ts +5 -0
  64. package/dist/types/cosmos/toolbox/thorchain.d.ts.map +1 -1
  65. package/dist/types/cosmos/util.d.ts +5 -0
  66. package/dist/types/cosmos/util.d.ts.map +1 -1
  67. package/dist/types/evm/helpers.d.ts +1 -1
  68. package/dist/types/evm/helpers.d.ts.map +1 -1
  69. package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +7 -0
  70. package/dist/types/evm/toolbox/baseEVMToolbox.d.ts.map +1 -1
  71. package/dist/types/evm/toolbox/evm.d.ts +38 -38
  72. package/dist/types/evm/toolbox/evm.d.ts.map +1 -1
  73. package/dist/types/evm/toolbox/op.d.ts +7 -14
  74. package/dist/types/evm/toolbox/op.d.ts.map +1 -1
  75. package/dist/types/index.d.ts +5 -0
  76. package/dist/types/index.d.ts.map +1 -1
  77. package/dist/types/near/helpers/core.d.ts +5 -0
  78. package/dist/types/near/helpers/core.d.ts.map +1 -1
  79. package/dist/types/near/toolbox.d.ts +5 -0
  80. package/dist/types/near/toolbox.d.ts.map +1 -1
  81. package/dist/types/radix/index.d.ts +5 -0
  82. package/dist/types/radix/index.d.ts.map +1 -1
  83. package/dist/types/ripple/index.d.ts +5 -0
  84. package/dist/types/ripple/index.d.ts.map +1 -1
  85. package/dist/types/solana/toolbox.d.ts +5 -0
  86. package/dist/types/solana/toolbox.d.ts.map +1 -1
  87. package/dist/types/substrate/substrate.d.ts +5 -0
  88. package/dist/types/substrate/substrate.d.ts.map +1 -1
  89. package/dist/types/sui/toolbox.d.ts +5 -0
  90. package/dist/types/sui/toolbox.d.ts.map +1 -1
  91. package/dist/types/ton/toolbox.d.ts +5 -0
  92. package/dist/types/ton/toolbox.d.ts.map +1 -1
  93. package/dist/types/tron/helpers/trongrid.d.ts +5 -0
  94. package/dist/types/tron/helpers/trongrid.d.ts.map +1 -1
  95. package/dist/types/tron/toolbox.d.ts +5 -0
  96. package/dist/types/tron/toolbox.d.ts.map +1 -1
  97. package/dist/types/utils.d.ts.map +1 -1
  98. package/dist/types/utxo/helpers/api.d.ts +5 -0
  99. package/dist/types/utxo/helpers/api.d.ts.map +1 -1
  100. package/dist/types/utxo/helpers/bchaddrjs.d.ts +5 -0
  101. package/dist/types/utxo/helpers/bchaddrjs.d.ts.map +1 -1
  102. package/dist/types/utxo/helpers/coinselect.d.ts +5 -0
  103. package/dist/types/utxo/helpers/coinselect.d.ts.map +1 -1
  104. package/dist/types/utxo/helpers/txSize.d.ts +5 -0
  105. package/dist/types/utxo/helpers/txSize.d.ts.map +1 -1
  106. package/dist/types/utxo/toolbox/bitcoinCash.d.ts +5 -0
  107. package/dist/types/utxo/toolbox/bitcoinCash.d.ts.map +1 -1
  108. package/dist/types/utxo/toolbox/index.d.ts +5 -0
  109. package/dist/types/utxo/toolbox/index.d.ts.map +1 -1
  110. package/dist/types/utxo/toolbox/utxo.d.ts +5 -0
  111. package/dist/types/utxo/toolbox/utxo.d.ts.map +1 -1
  112. package/dist/types/utxo/toolbox/zcash.d.ts +6 -1
  113. package/dist/types/utxo/toolbox/zcash.d.ts.map +1 -1
  114. package/package.json +13 -7
  115. package/src/cardano/toolbox.ts +12 -6
  116. package/src/cosmos/__tests__/toolbox.test.ts +8 -4
  117. package/src/cosmos/thorchainUtils/addressFormat.ts +8 -2
  118. package/src/cosmos/thorchainUtils/messages.ts +8 -2
  119. package/src/cosmos/toolbox/cosmos.ts +11 -5
  120. package/src/cosmos/toolbox/index.ts +8 -2
  121. package/src/cosmos/toolbox/thorchain.ts +9 -3
  122. package/src/cosmos/util.ts +9 -3
  123. package/src/evm/helpers.ts +7 -9
  124. package/src/evm/toolbox/baseEVMToolbox.ts +34 -26
  125. package/src/evm/toolbox/evm.ts +2 -3
  126. package/src/evm/toolbox/op.ts +10 -17
  127. package/src/index.ts +8 -2
  128. package/src/near/helpers/core.ts +8 -2
  129. package/src/near/toolbox.ts +21 -15
  130. package/src/radix/index.ts +15 -3
  131. package/src/ripple/index.ts +15 -12
  132. package/src/solana/toolbox.ts +16 -16
  133. package/src/substrate/balance.ts +2 -2
  134. package/src/substrate/substrate.ts +17 -11
  135. package/src/sui/__tests__/toolbox.test.ts +9 -5
  136. package/src/sui/toolbox.ts +18 -11
  137. package/src/ton/__tests__/toolbox.test.ts +9 -5
  138. package/src/ton/toolbox.ts +14 -8
  139. package/src/tron/helpers/trongrid.ts +8 -2
  140. package/src/tron/toolbox.ts +21 -15
  141. package/src/utils.ts +8 -1
  142. package/src/utxo/helpers/api.ts +15 -9
  143. package/src/utxo/helpers/bchaddrjs.ts +9 -3
  144. package/src/utxo/helpers/coinselect.ts +8 -2
  145. package/src/utxo/helpers/txSize.ts +8 -2
  146. package/src/utxo/toolbox/bitcoinCash.ts +13 -7
  147. package/src/utxo/toolbox/index.ts +8 -2
  148. package/src/utxo/toolbox/utxo.ts +16 -10
  149. package/src/utxo/toolbox/zcash.ts +24 -21
@@ -1,4 +1,4 @@
1
- var B4=Object.create;var{getPrototypeOf:G4,defineProperty:J6,getOwnPropertyNames:T4}=Object;var _4=Object.prototype.hasOwnProperty;var U=(Y,H,X)=>{X=Y!=null?B4(G4(Y)):{};let L=H||!Y||!Y.__esModule?J6(X,"default",{value:Y,enumerable:!0}):X;for(let Z of T4(Y))if(!_4.call(L,Z))J6(L,Z,{get:()=>Y[Z],enumerable:!0});return L};var D6=(Y,H)=>{for(var X in H)J6(Y,X,{get:H[X],enumerable:!0,configurable:!0,set:(L)=>H[X]=()=>L})};var F=(Y,H)=>()=>(Y&&(H=Y(Y=0)),H);var v=((Y)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(Y,{get:(H,X)=>(typeof require<"u"?require:H)[X]}):Y)(function(Y){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+Y+'" is not supported')});import{base64 as S6,bech32 as e}from"@scure/base";import{SwapKitError as I4}from"@uswap/helpers";import{fromByteArray as E4,toByteArray as N4}from"base64-js";function i(Y){return S6.encode(Uint8Array.from(e.fromWords(e.decode(Y).words)))}function o(Y,H="thor"){return e.encode(H,e.toWords(S6.decode(Y)))}function O4(Y){return E4(Y)}function x4(Y){if(!Y.match(/^[a-zA-Z0-9+/]*={0,2}$/))throw new I4("toolbox_cosmos_invalid_params",{error:"Invalid base64 string format"});return N4(Y)}var q6=()=>{};import{AssetValue as W6,Chain as I,getChainConfig as y,getRPCUrl as U4,SwapKitError as P6}from"@uswap/helpers";function S(Y){switch(Y){case I.Maya:return{amount:[],gas:"10000000000"};case I.THORChain:return{amount:[],gas:"500000000"};case I.Kujira:return $6;case I.Noble:return u6;default:return w6}}async function P(Y){let H=await import("@cosmjs/stargate"),X=H.StargateClient??H.default?.StargateClient,L=typeof window<"u"?{}:{referer:"https://sdk.swapkit.dev",referrer:"https://sdk.swapkit.dev"};return X.connect({headers:L,url:Y})}async function p(Y,H,X={}){let L=await import("@cosmjs/stargate"),Z=L.SigningStargateClient??L.default?.SigningStargateClient,z=L.GasPrice??L.default?.GasPrice,Q=typeof X==="string"?X:"0.0003uatom",J=typeof X==="string"?{}:X;return Z.connectWithSigner(Y,H,{gasPrice:z.fromString(Q),...J})}async function G6(Y,H){let X=await import("@cosmjs/stargate");return(X.SigningStargateClient??X.default?.SigningStargateClient).offline(Y,H)}async function T6({sender:Y,recipient:H,assetValue:X,memo:L="",feeRate:Z,sequence:z,accountNumber:Q}){let{chain:J,chainId:G}=X,_=await U4(J),A=await(await P(_)).getAccount(Y);if(!A)throw new P6("toolbox_cosmos_account_not_found",{sender:Y});let T=W6.from({chain:J}),N=D(T.symbol),E=S(J),x=N&&Z?{amount:[{amount:Z.toString(),denom:N}],gas:E.gas}:E,O={amount:[{amount:X.getBaseValue("string"),denom:D(X.symbol)}],fromAddress:Y,toAddress:H};return{accountNumber:Q??A.accountNumber,chainId:G,fee:x,memo:L,msgs:[{typeUrl:v4(J),value:O}],sequence:z??A.sequence}}var B6="FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK",C6="FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM",w6,$6,u6,D=(Y,H=!1)=>{if(H)return Y.toLowerCase();switch(Y){case"uUSK":case"USK":return B6;case"uYUM":case"YUM":return C6;case"uKUJI":case"KUJI":return"ukuji";case"ATOM":case"uATOM":return"uatom";case"uUSDC":case"USDC":return"uusdc";default:return Y}},b=({symbol:Y,chain:H})=>{if(H===I.Maya)return(Y.toUpperCase()!=="CACAO"?Y:`${I.Maya}.${Y}`).toUpperCase();if(H===I.THORChain)return(["RUNE","TCY","RUJI"].includes(Y.toUpperCase())?`${I.THORChain}.${Y}`:Y).toUpperCase();return D(Y,!1)},v4=(Y)=>{switch(Y){case I.Maya:case I.THORChain:return"/types.MsgSend";case I.Cosmos:case I.Kujira:case I.Noble:return"/cosmos.bank.v1beta1.MsgSend";default:throw new P6("toolbox_cosmos_not_supported",{chain:Y})}},K4,_6=(Y,H)=>{let X=K4[Y.toLowerCase()];if(!X)return W6.from({asset:Y,fromBaseDecimal:8,value:H});let{chain:L,asset:Z,decimals:z}=X,Q=L?{chain:L}:{asset:Z};return W6.from({...Q,fromBaseDecimal:z,value:H})};var t=F(()=>{w6={amount:[{amount:"500",denom:"uatom"}],gas:"200000"},$6={amount:[{amount:"1000",denom:"ukuji"}],gas:"200000"},u6={amount:[{amount:"1000",denom:"uusdc"}],gas:"200000"};K4={atom:{chain:I.Cosmos,decimals:y(I.Cosmos).baseDecimal},cacao:{chain:I.Maya,decimals:10},kuji:{chain:I.Kujira,decimals:y(I.Kujira).baseDecimal},maya:{asset:`${I.Maya}.${I.Maya}`,decimals:4},rune:{chain:I.THORChain,decimals:y(I.THORChain).baseDecimal},tcy:{asset:"THOR.TCY",decimals:y(I.THORChain).baseDecimal},uatom:{chain:I.Cosmos,decimals:y(I.Cosmos).baseDecimal},ukuji:{chain:I.Kujira,decimals:y(I.Kujira).baseDecimal},usdc:{chain:I.Noble,decimals:y(I.Noble).baseDecimal},uusdc:{chain:I.Noble,decimals:y(I.Noble).baseDecimal},"x/kuji":{asset:"THOR.KUJI",decimals:y(I.THORChain).baseDecimal},[B6.toLowerCase()]:{asset:`${I.Kujira}.USK`,decimals:y(I.Kujira).baseDecimal}}});var h6={};D6(h6,{$root:()=>q});import k from"protobufjs/minimal.js";var B,f,W,q;var l6=F(()=>{B=k.Reader,f=k.Writer,W=k.util,q=k.roots.default||(k.roots.default={});q.common=(()=>{let Y={};return Y.Asset=(()=>{function H(X){if(X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.chain="",H.prototype.symbol="",H.prototype.ticker="",H.prototype.synth=!1,H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=f.create();if(L.chain!=null&&Object.hasOwnProperty.call(L,"chain"))Z.uint32(10).string(L.chain);if(L.symbol!=null&&Object.hasOwnProperty.call(L,"symbol"))Z.uint32(18).string(L.symbol);if(L.ticker!=null&&Object.hasOwnProperty.call(L,"ticker"))Z.uint32(26).string(L.ticker);if(L.synth!=null&&Object.hasOwnProperty.call(L,"synth"))Z.uint32(32).bool(L.synth);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof B))L=B.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.Asset;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.chain=L.string();break;case 2:Q.symbol=L.string();break;case 3:Q.ticker=L.string();break;case 4:Q.synth=L.bool();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof B))L=new B(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.chain!=null&&L.hasOwnProperty("chain")){if(!W.isString(L.chain))return"chain: string expected"}if(L.symbol!=null&&L.hasOwnProperty("symbol")){if(!W.isString(L.symbol))return"symbol: string expected"}if(L.ticker!=null&&L.hasOwnProperty("ticker")){if(!W.isString(L.ticker))return"ticker: string expected"}if(L.synth!=null&&L.hasOwnProperty("synth")){if(typeof L.synth!=="boolean")return"synth: boolean expected"}return null},H.fromObject=function(L){if(L instanceof q.common.Asset)return L;let Z=new q.common.Asset;if(L.chain!=null)Z.chain=String(L.chain);if(L.symbol!=null)Z.symbol=String(L.symbol);if(L.ticker!=null)Z.ticker=String(L.ticker);if(L.synth!=null)Z.synth=Boolean(L.synth);return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.defaults)z.chain="",z.symbol="",z.ticker="",z.synth=!1;if(L.chain!=null&&L.hasOwnProperty("chain"))z.chain=L.chain;if(L.symbol!=null&&L.hasOwnProperty("symbol"))z.symbol=L.symbol;if(L.ticker!=null&&L.hasOwnProperty("ticker"))z.ticker=L.ticker;if(L.synth!=null&&L.hasOwnProperty("synth"))z.synth=L.synth;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},H})(),Y.Coin=(()=>{function H(X){if(X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.asset=null,H.prototype.amount="",H.prototype.decimals=W.Long?W.Long.fromBits(0,0,!1):0,H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=f.create();if(L.asset!=null&&Object.hasOwnProperty.call(L,"asset"))q.common.Asset.encode(L.asset,Z.uint32(10).fork()).ldelim();if(L.amount!=null&&Object.hasOwnProperty.call(L,"amount"))Z.uint32(18).string(L.amount);if(L.decimals!=null&&Object.hasOwnProperty.call(L,"decimals"))Z.uint32(24).int64(L.decimals);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof B))L=B.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.Coin;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.asset=q.common.Asset.decode(L,L.uint32());break;case 2:Q.amount=L.string();break;case 3:Q.decimals=L.int64();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof B))L=new B(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.asset!=null&&L.hasOwnProperty("asset")){let Z=q.common.Asset.verify(L.asset);if(Z)return"asset."+Z}if(L.amount!=null&&L.hasOwnProperty("amount")){if(!W.isString(L.amount))return"amount: string expected"}if(L.decimals!=null&&L.hasOwnProperty("decimals")){if(!W.isInteger(L.decimals)&&!(L.decimals&&W.isInteger(L.decimals.low)&&W.isInteger(L.decimals.high)))return"decimals: integer|Long expected"}return null},H.fromObject=function(L){if(L instanceof q.common.Coin)return L;let Z=new q.common.Coin;if(L.asset!=null){if(typeof L.asset!=="object")throw TypeError(".common.Coin.asset: object expected");Z.asset=q.common.Asset.fromObject(L.asset)}if(L.amount!=null)Z.amount=String(L.amount);if(L.decimals!=null){if(W.Long)(Z.decimals=W.Long.fromValue(L.decimals)).unsigned=!1;else if(typeof L.decimals==="string")Z.decimals=Number.parseInt(L.decimals,10);else if(typeof L.decimals==="number")Z.decimals=L.decimals;else if(typeof L.decimals==="object")Z.decimals=new W.LongBits(L.decimals.low>>>0,L.decimals.high>>>0).toNumber()}return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.defaults)if(z.asset=null,z.amount="",W.Long){let Q=new W.Long(0,0,!1);z.decimals=Z.longs===String?Q.toString():Z.longs===Number?Q.toNumber():Q}else z.decimals=Z.longs===String?"0":0;if(L.asset!=null&&L.hasOwnProperty("asset"))z.asset=q.common.Asset.toObject(L.asset,Z);if(L.amount!=null&&L.hasOwnProperty("amount"))z.amount=L.amount;if(L.decimals!=null&&L.hasOwnProperty("decimals"))if(typeof L.decimals==="number")z.decimals=Z.longs===String?String(L.decimals):L.decimals;else z.decimals=Z.longs===String?W.Long.prototype.toString.call(L.decimals):Z.longs===Number?new W.LongBits(L.decimals.low>>>0,L.decimals.high>>>0).toNumber():L.decimals;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},H})(),Y.PubKeySet=(()=>{function H(X){if(X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.secp256k1="",H.prototype.ed25519="",H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=f.create();if(L.secp256k1!=null&&Object.hasOwnProperty.call(L,"secp256k1"))Z.uint32(10).string(L.secp256k1);if(L.ed25519!=null&&Object.hasOwnProperty.call(L,"ed25519"))Z.uint32(18).string(L.ed25519);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof B))L=B.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.PubKeySet;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.secp256k1=L.string();break;case 2:Q.ed25519=L.string();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof B))L=new B(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.secp256k1!=null&&L.hasOwnProperty("secp256k1")){if(!W.isString(L.secp256k1))return"secp256k1: string expected"}if(L.ed25519!=null&&L.hasOwnProperty("ed25519")){if(!W.isString(L.ed25519))return"ed25519: string expected"}return null},H.fromObject=function(L){if(L instanceof q.common.PubKeySet)return L;let Z=new q.common.PubKeySet;if(L.secp256k1!=null)Z.secp256k1=String(L.secp256k1);if(L.ed25519!=null)Z.ed25519=String(L.ed25519);return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.defaults)z.secp256k1="",z.ed25519="";if(L.secp256k1!=null&&L.hasOwnProperty("secp256k1"))z.secp256k1=L.secp256k1;if(L.ed25519!=null&&L.hasOwnProperty("ed25519"))z.ed25519=L.ed25519;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},H})(),Y.Tx=(()=>{function H(X){if(this.coins=[],this.gas=[],X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.id="",H.prototype.chain="",H.prototype.fromAddress="",H.prototype.toAddress="",H.prototype.coins=W.emptyArray,H.prototype.gas=W.emptyArray,H.prototype.memo="",H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=f.create();if(L.id!=null&&Object.hasOwnProperty.call(L,"id"))Z.uint32(10).string(L.id);if(L.chain!=null&&Object.hasOwnProperty.call(L,"chain"))Z.uint32(18).string(L.chain);if(L.fromAddress!=null&&Object.hasOwnProperty.call(L,"fromAddress"))Z.uint32(26).string(L.fromAddress);if(L.toAddress!=null&&Object.hasOwnProperty.call(L,"toAddress"))Z.uint32(34).string(L.toAddress);if(L.coins?.length)for(let z=0;z<L.coins.length;++z)q.common.Coin.encode(L.coins[z],Z.uint32(42).fork()).ldelim();if(L.gas?.length)for(let z=0;z<L.gas.length;++z)q.common.Coin.encode(L.gas[z],Z.uint32(50).fork()).ldelim();if(L.memo!=null&&Object.hasOwnProperty.call(L,"memo"))Z.uint32(58).string(L.memo);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof B))L=B.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.Tx;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.id=L.string();break;case 2:Q.chain=L.string();break;case 3:Q.fromAddress=L.string();break;case 4:Q.toAddress=L.string();break;case 5:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(L,L.uint32()));break;case 6:if(!Q.gas?.length)Q.gas=[];Q.gas.push(q.common.Coin.decode(L,L.uint32()));break;case 7:Q.memo=L.string();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof B))L=new B(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.id!=null&&L.hasOwnProperty("id")){if(!W.isString(L.id))return"id: string expected"}if(L.chain!=null&&L.hasOwnProperty("chain")){if(!W.isString(L.chain))return"chain: string expected"}if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress")){if(!W.isString(L.fromAddress))return"fromAddress: string expected"}if(L.toAddress!=null&&L.hasOwnProperty("toAddress")){if(!W.isString(L.toAddress))return"toAddress: string expected"}if(L.coins!=null&&L.hasOwnProperty("coins")){if(!Array.isArray(L.coins))return"coins: array expected";for(let Z=0;Z<L.coins.length;++Z){let z=q.common.Coin.verify(L.coins[Z]);if(z)return"coins."+z}}if(L.gas!=null&&L.hasOwnProperty("gas")){if(!Array.isArray(L.gas))return"gas: array expected";for(let Z=0;Z<L.gas.length;++Z){let z=q.common.Coin.verify(L.gas[Z]);if(z)return"gas."+z}}if(L.memo!=null&&L.hasOwnProperty("memo")){if(!W.isString(L.memo))return"memo: string expected"}return null},H.fromObject=function(L){if(L instanceof q.common.Tx)return L;let Z=new q.common.Tx;if(L.id!=null)Z.id=String(L.id);if(L.chain!=null)Z.chain=String(L.chain);if(L.fromAddress!=null)Z.fromAddress=String(L.fromAddress);if(L.toAddress!=null)Z.toAddress=String(L.toAddress);if(L.coins){if(!Array.isArray(L.coins))throw TypeError(".common.Tx.coins: array expected");Z.coins=[];for(let z=0;z<L.coins.length;++z){if(typeof L.coins[z]!=="object")throw TypeError(".common.Tx.coins: object expected");Z.coins[z]=q.common.Coin.fromObject(L.coins[z])}}if(L.gas){if(!Array.isArray(L.gas))throw TypeError(".common.Tx.gas: array expected");Z.gas=[];for(let z=0;z<L.gas.length;++z){if(typeof L.gas[z]!=="object")throw TypeError(".common.Tx.gas: object expected");Z.gas[z]=q.common.Coin.fromObject(L.gas[z])}}if(L.memo!=null)Z.memo=String(L.memo);return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.arrays||Z.defaults)z.coins=[],z.gas=[];if(Z.defaults)z.id="",z.chain="",z.fromAddress="",z.toAddress="",z.memo="";if(L.id!=null&&L.hasOwnProperty("id"))z.id=L.id;if(L.chain!=null&&L.hasOwnProperty("chain"))z.chain=L.chain;if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress"))z.fromAddress=L.fromAddress;if(L.toAddress!=null&&L.hasOwnProperty("toAddress"))z.toAddress=L.toAddress;if(L.coins?.length){z.coins=[];for(let Q=0;Q<L.coins.length;++Q)z.coins[Q]=q.common.Coin.toObject(L.coins[Q],Z)}if(L.gas?.length){z.gas=[];for(let Q=0;Q<L.gas.length;++Q)z.gas[Q]=q.common.Coin.toObject(L.gas[Q],Z)}if(L.memo!=null&&L.hasOwnProperty("memo"))z.memo=L.memo;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},H})(),Y.Fee=(()=>{function H(X){if(this.coins=[],X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.coins=W.emptyArray,H.prototype.poolDeduct="",H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=f.create();if(L.coins?.length)for(let z=0;z<L.coins.length;++z)q.common.Coin.encode(L.coins[z],Z.uint32(10).fork()).ldelim();if(L.poolDeduct!=null&&Object.hasOwnProperty.call(L,"poolDeduct"))Z.uint32(18).string(L.poolDeduct);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof B))L=B.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.Fee;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(L,L.uint32()));break;case 2:Q.poolDeduct=L.string();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof B))L=new B(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.coins!=null&&L.hasOwnProperty("coins")){if(!Array.isArray(L.coins))return"coins: array expected";for(let Z=0;Z<L.coins.length;++Z){let z=q.common.Coin.verify(L.coins[Z]);if(z)return"coins."+z}}if(L.poolDeduct!=null&&L.hasOwnProperty("poolDeduct")){if(!W.isString(L.poolDeduct))return"poolDeduct: string expected"}return null},H.fromObject=function(L){if(L instanceof q.common.Fee)return L;let Z=new q.common.Fee;if(L.coins){if(!Array.isArray(L.coins))throw TypeError(".common.Fee.coins: array expected");Z.coins=[];for(let z=0;z<L.coins.length;++z){if(typeof L.coins[z]!=="object")throw TypeError(".common.Fee.coins: object expected");Z.coins[z]=q.common.Coin.fromObject(L.coins[z])}}if(L.poolDeduct!=null)Z.poolDeduct=String(L.poolDeduct);return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.arrays||Z.defaults)z.coins=[];if(Z.defaults)z.poolDeduct="";if(L.coins?.length){z.coins=[];for(let Q=0;Q<L.coins.length;++Q)z.coins[Q]=q.common.Coin.toObject(L.coins[Q],Z)}if(L.poolDeduct!=null&&L.hasOwnProperty("poolDeduct"))z.poolDeduct=L.poolDeduct;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},H})(),Y.ProtoUint=(()=>{function H(X){if(X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.value="",H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=f.create();if(L.value!=null&&Object.hasOwnProperty.call(L,"value"))Z.uint32(10).string(L.value);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof B))L=B.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.ProtoUint;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.value=L.string();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof B))L=new B(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.value!=null&&L.hasOwnProperty("value")){if(!W.isString(L.value))return"value: string expected"}return null},H.fromObject=function(L){if(L instanceof q.common.ProtoUint)return L;let Z=new q.common.ProtoUint;if(L.value!=null)Z.value=String(L.value);return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.defaults)z.value="";if(L.value!=null&&L.hasOwnProperty("value"))z.value=L.value;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},H})(),Y})();q.types=(()=>{let Y={};return Y.MsgDeposit=(()=>{function H(X){if(this.coins=[],X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.coins=W.emptyArray,H.prototype.memo="",H.prototype.signer=W.newBuffer([]),H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=f.create();if(L.coins?.length)for(let z=0;z<L.coins.length;++z)q.common.Coin.encode(L.coins[z],Z.uint32(10).fork()).ldelim();if(L.memo!=null&&Object.hasOwnProperty.call(L,"memo"))Z.uint32(18).string(L.memo);if(L.signer!=null&&Object.hasOwnProperty.call(L,"signer"))Z.uint32(26).bytes(L.signer);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof B))L=B.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.types.MsgDeposit;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(L,L.uint32()));break;case 2:Q.memo=L.string();break;case 3:Q.signer=L.bytes();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof B))L=new B(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.coins!=null&&L.hasOwnProperty("coins")){if(!Array.isArray(L.coins))return"coins: array expected";for(let Z=0;Z<L.coins.length;++Z){let z=q.common.Coin.verify(L.coins[Z]);if(z)return"coins."+z}}if(L.memo!=null&&L.hasOwnProperty("memo")){if(!W.isString(L.memo))return"memo: string expected"}if(L.signer!=null&&L.hasOwnProperty("signer")){if(!(L.signer&&typeof L.signer.length==="number"||W.isString(L.signer)))return"signer: buffer expected"}return null},H.fromObject=function(L){if(L instanceof q.types.MsgDeposit)return L;let Z=new q.types.MsgDeposit;if(L.coins){if(!Array.isArray(L.coins))throw TypeError(".types.MsgDeposit.coins: array expected");Z.coins=[];for(let z=0;z<L.coins.length;++z){if(typeof L.coins[z]!=="object")throw TypeError(".types.MsgDeposit.coins: object expected");Z.coins[z]=q.common.Coin.fromObject(L.coins[z])}}if(L.memo!=null)Z.memo=String(L.memo);if(L.signer!=null){if(typeof L.signer==="string")W.base64.decode(L.signer,Z.signer=W.newBuffer(W.base64.length(L.signer)),0);else if(L.signer.length)Z.signer=L.signer}return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.arrays||Z.defaults)z.coins=[];if(Z.defaults){if(z.memo="",Z.bytes===String)z.signer="";else if(z.signer=[],Z.bytes!==Array)z.signer=W.newBuffer(z.signer)}if(L.coins?.length){z.coins=[];for(let Q=0;Q<L.coins.length;++Q)z.coins[Q]=q.common.Coin.toObject(L.coins[Q],Z)}if(L.memo!=null&&L.hasOwnProperty("memo"))z.memo=L.memo;if(L.signer!=null&&L.hasOwnProperty("signer"))z.signer=Z.bytes===String?W.base64.encode(L.signer,0,L.signer.length):Z.bytes===Array?Array.prototype.slice.call(L.signer):L.signer;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},H})(),Y.MsgSend=(()=>{function H(X){if(this.amount=[],X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.fromAddress=W.newBuffer([]),H.prototype.toAddress=W.newBuffer([]),H.prototype.amount=W.emptyArray,H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=f.create();if(L.fromAddress!=null&&Object.hasOwnProperty.call(L,"fromAddress"))Z.uint32(10).bytes(L.fromAddress);if(L.toAddress!=null&&Object.hasOwnProperty.call(L,"toAddress"))Z.uint32(18).bytes(L.toAddress);if(L.amount?.length)for(let z=0;z<L.amount.length;++z)q.cosmos.base.v1beta1.Coin.encode(L.amount[z],Z.uint32(26).fork()).ldelim();return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof B))L=B.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.types.MsgSend;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.fromAddress=L.bytes();break;case 2:Q.toAddress=L.bytes();break;case 3:if(!Q.amount?.length)Q.amount=[];Q.amount.push(q.cosmos.base.v1beta1.Coin.decode(L,L.uint32()));break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof B))L=new B(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress")){if(!(L.fromAddress&&typeof L.fromAddress.length==="number"||W.isString(L.fromAddress)))return"fromAddress: buffer expected"}if(L.toAddress!=null&&L.hasOwnProperty("toAddress")){if(!(L.toAddress&&typeof L.toAddress.length==="number"||W.isString(L.toAddress)))return"toAddress: buffer expected"}if(L.amount!=null&&L.hasOwnProperty("amount")){if(!Array.isArray(L.amount))return"amount: array expected";for(let Z=0;Z<L.amount.length;++Z){let z=q.cosmos.base.v1beta1.Coin.verify(L.amount[Z]);if(z)return"amount."+z}}return null},H.fromObject=function(L){if(L instanceof q.types.MsgSend)return L;let Z=new q.types.MsgSend;if(L.fromAddress!=null){if(typeof L.fromAddress==="string")W.base64.decode(L.fromAddress,Z.fromAddress=W.newBuffer(W.base64.length(L.fromAddress)),0);else if(L.fromAddress.length)Z.fromAddress=L.fromAddress}if(L.toAddress!=null){if(typeof L.toAddress==="string")W.base64.decode(L.toAddress,Z.toAddress=W.newBuffer(W.base64.length(L.toAddress)),0);else if(L.toAddress.length)Z.toAddress=L.toAddress}if(L.amount){if(!Array.isArray(L.amount))throw TypeError(".types.MsgSend.amount: array expected");Z.amount=[];for(let z=0;z<L.amount.length;++z){if(typeof L.amount[z]!=="object")throw TypeError(".types.MsgSend.amount: object expected");Z.amount[z]=q.cosmos.base.v1beta1.Coin.fromObject(L.amount[z])}}return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.arrays||Z.defaults)z.amount=[];if(Z.defaults){if(Z.bytes===String)z.fromAddress="";else if(z.fromAddress=[],Z.bytes!==Array)z.fromAddress=W.newBuffer(z.fromAddress);if(Z.bytes===String)z.toAddress="";else if(z.toAddress=[],Z.bytes!==Array)z.toAddress=W.newBuffer(z.toAddress)}if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress"))z.fromAddress=Z.bytes===String?W.base64.encode(L.fromAddress,0,L.fromAddress.length):Z.bytes===Array?Array.prototype.slice.call(L.fromAddress):L.fromAddress;if(L.toAddress!=null&&L.hasOwnProperty("toAddress"))z.toAddress=Z.bytes===String?W.base64.encode(L.toAddress,0,L.toAddress.length):Z.bytes===Array?Array.prototype.slice.call(L.toAddress):L.toAddress;if(L.amount?.length){z.amount=[];for(let Q=0;Q<L.amount.length;++Q)z.amount[Q]=q.cosmos.base.v1beta1.Coin.toObject(L.amount[Q],Z)}return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},H})(),Y})();q.cosmos=(()=>{let Y={};return Y.base=(()=>{let H={};return H.v1beta1=(()=>{let X={};return X.Coin=(()=>{function L(Z){if(Z){for(let z=Object.keys(Z),Q=0;Q<z.length;++Q)if(Z[z[Q]]!=null)this[z[Q]]=Z[z[Q]]}}return L.prototype.denom="",L.prototype.amount="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=f.create();if(z.denom!=null&&Object.hasOwnProperty.call(z,"denom"))Q.uint32(10).string(z.denom);if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))Q.uint32(18).string(z.amount);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof B))z=B.create(z);let J=Q===void 0?z.len:z.pos+Q,G=new q.cosmos.base.v1beta1.Coin;while(z.pos<J){let _=z.uint32();switch(_>>>3){case 1:G.denom=z.string();break;case 2:G.amount=z.string();break;default:z.skipType(_&7);break}}return G},L.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.denom!=null&&z.hasOwnProperty("denom")){if(!W.isString(z.denom))return"denom: string expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!W.isString(z.amount))return"amount: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.Coin)return z;let Q=new q.cosmos.base.v1beta1.Coin;if(z.denom!=null)Q.denom=String(z.denom);if(z.amount!=null)Q.amount=String(z.amount);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.denom="",J.amount="";if(z.denom!=null&&z.hasOwnProperty("denom"))J.denom=z.denom;if(z.amount!=null&&z.hasOwnProperty("amount"))J.amount=z.amount;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},L})(),X.DecCoin=(()=>{function L(Z){if(Z){for(let z=Object.keys(Z),Q=0;Q<z.length;++Q)if(Z[z[Q]]!=null)this[z[Q]]=Z[z[Q]]}}return L.prototype.denom="",L.prototype.amount="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=f.create();if(z.denom!=null&&Object.hasOwnProperty.call(z,"denom"))Q.uint32(10).string(z.denom);if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))Q.uint32(18).string(z.amount);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof B))z=B.create(z);let J=Q===void 0?z.len:z.pos+Q,G=new q.cosmos.base.v1beta1.DecCoin;while(z.pos<J){let _=z.uint32();switch(_>>>3){case 1:G.denom=z.string();break;case 2:G.amount=z.string();break;default:z.skipType(_&7);break}}return G},L.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.denom!=null&&z.hasOwnProperty("denom")){if(!W.isString(z.denom))return"denom: string expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!W.isString(z.amount))return"amount: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.DecCoin)return z;let Q=new q.cosmos.base.v1beta1.DecCoin;if(z.denom!=null)Q.denom=String(z.denom);if(z.amount!=null)Q.amount=String(z.amount);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.denom="",J.amount="";if(z.denom!=null&&z.hasOwnProperty("denom"))J.denom=z.denom;if(z.amount!=null&&z.hasOwnProperty("amount"))J.amount=z.amount;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},L})(),X.IntProto=(()=>{function L(Z){if(Z){for(let z=Object.keys(Z),Q=0;Q<z.length;++Q)if(Z[z[Q]]!=null)this[z[Q]]=Z[z[Q]]}}return L.prototype.int="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=f.create();if(z.int!=null&&Object.hasOwnProperty.call(z,"int"))Q.uint32(10).string(z.int);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof B))z=B.create(z);let J=Q===void 0?z.len:z.pos+Q,G=new q.cosmos.base.v1beta1.IntProto;while(z.pos<J){let _=z.uint32();switch(_>>>3){case 1:G.int=z.string();break;default:z.skipType(_&7);break}}return G},L.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.int!=null&&z.hasOwnProperty("int")){if(!W.isString(z.int))return"int: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.IntProto)return z;let Q=new q.cosmos.base.v1beta1.IntProto;if(z.int!=null)Q.int=String(z.int);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.int="";if(z.int!=null&&z.hasOwnProperty("int"))J.int=z.int;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},L})(),X.DecProto=(()=>{function L(Z){if(Z){for(let z=Object.keys(Z),Q=0;Q<z.length;++Q)if(Z[z[Q]]!=null)this[z[Q]]=Z[z[Q]]}}return L.prototype.dec="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=f.create();if(z.dec!=null&&Object.hasOwnProperty.call(z,"dec"))Q.uint32(10).string(z.dec);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof B))z=B.create(z);let J=Q===void 0?z.len:z.pos+Q,G=new q.cosmos.base.v1beta1.DecProto;while(z.pos<J){let _=z.uint32();switch(_>>>3){case 1:G.dec=z.string();break;default:z.skipType(_&7);break}}return G},L.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.dec!=null&&z.hasOwnProperty("dec")){if(!W.isString(z.dec))return"dec: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.DecProto)return z;let Q=new q.cosmos.base.v1beta1.DecProto;if(z.dec!=null)Q.dec=String(z.dec);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.dec="";if(z.dec!=null&&z.hasOwnProperty("dec"))J.dec=z.dec;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},L})(),X})(),H})(),Y})()});import{Chain as A4}from"@uswap/helpers";async function l(){let{$root:Y}=await Promise.resolve().then(() => (l6(),h6)),H=await import("@cosmjs/proto-signing"),X=H.Registry??H.default?.Registry,L=await import("@cosmjs/stargate"),Z=L.defaultRegistryTypes??L.default?.defaultRegistryTypes;return new X([...Z,["/types.MsgSend",Y.types.MsgSend],["/types.MsgDeposit",Y.types.MsgDeposit]])}async function C(Y){let H=await import("@cosmjs/stargate"),X=H.AminoTypes??H.default?.AminoTypes,L=Y===A4.THORChain?"thorchain":"mayachain";return new X({"/types.MsgDeposit":{aminoType:`${L}/MsgDeposit`,fromAmino:({signer:Z,...z})=>({...z,signer:i(Z)}),toAmino:({signer:Z,...z})=>({...z,signer:o(Z)})},"/types.MsgSend":{aminoType:`${L}/MsgSend`,fromAmino:({from_address:Z,to_address:z,...Q})=>({...Q,fromAddress:i(Z),toAddress:i(z)}),toAmino:({fromAddress:Z,toAddress:z,...Q})=>({...Q,from_address:o(Z),to_address:o(z)})}})}var I6=F(()=>{q6()});import{AssetValue as k4,Chain as L6,getChainConfig as j6,SwapKitError as R4}from"@uswap/helpers";function O6(Y){return function(X){let{assetValue:L,recipient:Z,memo:z,sender:Q,asSignable:J,asAminoMessage:G}=X;if(Z)return p6(Y)({asAminoMessage:G,asSignable:J,assetValue:L,memo:z,recipient:Z,sender:Q});return c6(Y)({asAminoMessage:G,asSignable:J,assetValue:L,memo:z,sender:Q})}}function $(Y){if(Y.type==="thorchain/MsgSend"||Y.type==="mayachain/MsgSend")return Y;return{...Y,value:{...Y.value,coins:Y.value.coins.map((H)=>{let X=k4.from({asset:H.asset}),L=(X.isSynthetic?X.symbol.split("/")?.[1]:X.symbol)?.toUpperCase(),Z=(X.isSynthetic?X.symbol.split("/")?.[0]:X.chain)?.toUpperCase();return{...H,asset:{chain:Z,symbol:L,synth:X.isSynthetic,ticker:X.ticker}}})}}}async function r({chain:Y,memo:H,msgs:X}){let L=await l(),Z=await C(Y),z={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:H,messages:X.map((Q)=>Z.fromAmino(Q))}};return L.encode(z)}var V4,M4,E6=({sender:Y,recipient:H,assetValue:X})=>{return{type:`${X.chain===L6.Maya?"mayachain":"thorchain"}/MsgSend`,value:{amount:[{amount:X.getBaseValue("string"),denom:D(X.symbol,!0)}],from_address:Y,to_address:H}}},N6=({sender:Y,assetValue:H,memo:X=""})=>{return{type:`${H.chain===L6.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:H.getBaseValue("string"),asset:b(H)}],memo:X,signer:Y}}},z6=({sender:Y,recipient:H,assetValue:X,memo:L})=>{return!H?N6({assetValue:X,memo:L,sender:Y}):E6({assetValue:X,recipient:H,sender:Y})},w=async(Y,H)=>{return(await C(H)).fromAmino(Y)},b6=async({rpcUrl:Y,sender:H})=>{let L=await(await P(Y)).getAccount(H);if(!L)throw new R4("toolbox_cosmos_account_not_found",{sender:H});return L},p6=(Y)=>async({sender:H,recipient:X,assetValue:L,memo:Z="",asSignable:z=!0,asAminoMessage:Q=!1,sequence:J,accountNumber:G})=>{let _=await b6({rpcUrl:Y,sender:H}),K=L.chain,{chainId:A}=j6(K),T=E6({assetValue:L,recipient:X,sender:H}),N=z?await w(Q?T:$(T),K):T;return{accountNumber:G||_.accountNumber,chainId:A,fee:S(K),memo:Z,msgs:[N],sequence:J||_.sequence}},c6=(Y)=>async({sender:H,assetValue:X,memo:L="",asSignable:Z=!0,asAminoMessage:z=!1,sequence:Q,accountNumber:J})=>{let G=await b6({rpcUrl:Y,sender:H}),_=X.chain,{chainId:K}=j6(_),A=N6({assetValue:X,memo:L,sender:H}),T=Z?await w(z?A:$(A),_):A;return{accountNumber:J||G.accountNumber,chainId:K,fee:S(_),memo:L,msgs:[T],sequence:Q||G.sequence}};var d6=F(()=>{t();I6();V4=S(L6.THORChain).gas,M4=S(L6.Maya).gas});var n6=()=>{};var m6=F(()=>{n6()});var x6=F(()=>{q6();d6();I6();m6()});import{base64 as k6,bech32 as U6}from"@scure/base";import{AssetValue as Z6,applyFeeMultiplier as g6,Chain as V,CosmosChainPrefixes as a6,DerivationPath as F4,derivationPathToString as i6,FeeOption as Q6,getChainConfig as f4,getRPCUrl as y4,NetworkDerivationPath as D4,SwapKitError as H6,SwapKitNumber as v6,updateDerivationPath as S4}from"@uswap/helpers";import{SwapKitApi as s6}from"@uswap/helpers/api";import{match as P4,P as o6}from"ts-pattern";async function V6(Y,H){try{let L=(await s6.getGasRate()).find((Z)=>Z.chainId===Y)?.value;return L?Number.parseFloat(L):H}catch{return H}}async function R6({phrase:Y,prefix:H,...X}){let L=await import("@cosmjs/proto-signing"),Z=L.DirectSecp256k1HdWallet??L.default?.DirectSecp256k1HdWallet,z=await import("@cosmjs/crypto"),Q=z.stringToPath??z.default?.stringToPath,J="derivationPath"in X?X.derivationPath:`${F4[X.chain]}/${X.index}`;return Z.fromMnemonic(Y,{hdPaths:[Q(J)],prefix:H})}async function C4({privateKey:Y,prefix:H}){let X=await import("@cosmjs/proto-signing");return(X.DirectSecp256k1Wallet??X.default?.DirectSecp256k1Wallet).fromKey(Y,H)}function e6(Y){return async function({signature:X,message:L,address:Z}){let z=await Y(Z);if(!z?.pubkey)throw new H6("toolbox_cosmos_verify_signature_no_pubkey");let Q=await import("@cosmjs/crypto"),J=Q.Secp256k1Signature??Q.default?.Secp256k1Signature,G=Q.Secp256k1??Q.default?.Secp256k1,_=J.fromFixedLength(k6.decode(X));return G.verifySignature(_,k6.decode(L),z.pubkey.value)}}async function a({chain:Y,...H}){let X=await y4(Y),L=a6[Y],Z="index"in H?H.index||0:0,z=i6("derivationPath"in H&&H.derivationPath?H.derivationPath:S4(D4[Y],{index:Z})),Q=await P4(H).with({phrase:o6.string},({phrase:T})=>R6({derivationPath:z,phrase:T,prefix:L})).with({signer:o6.any},({signer:T})=>T).otherwise(()=>{return});async function J(T){return(await P(X)).getAccount(T)}async function G(){let[T]=await Q?.getAccounts()||[];return T?.address}async function _(){let[T]=await Q?.getAccounts()||[];if(!T?.pubkey)throw new H6("toolbox_cosmos_signer_not_defined");return k6.encode(T?.pubkey)}async function K({recipient:T,assetValue:N,memo:E="",feeRate:x,feeOptionKey:O=Q6.Fast}){let R=await G();if(!(Q&&R))throw new H6("toolbox_cosmos_signer_not_defined");let M=Z6.from({chain:Y}),c=b(M),d=x||t6((await A6(Y,K6[Y]))[O],c),n=await p(X,Q),u=D(N.symbol),h=N.getBaseValue("string"),{TxRaw:m}=await import("cosmjs-types/cosmos/tx/v1beta1/tx"),g={amount:[{amount:h,denom:u}],fromAddress:R,toAddress:T},y6=await n.sign(R,[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:g}],d,E),Y6=m.encode(y6).finish();return Buffer.from(Y6).toString("hex")}async function A({recipient:T,assetValue:N,memo:E="",feeRate:x,feeOptionKey:O=Q6.Fast,dryRun:R=!1}){if(R)return K({assetValue:N,feeOptionKey:O,feeRate:x,memo:E,recipient:T});let M=await G();if(!(Q&&M))throw new H6("toolbox_cosmos_signer_not_defined");let c=Z6.from({chain:Y}),d=b(c),n=x||t6((await A6(Y,K6[Y]))[O],d),u=await p(X,Q),h=D(N.symbol),m=[{amount:N.getBaseValue("string"),denom:h}],{transactionHash:g}=await u.sendTokens(M,T,m,n,E);return g}return{createPrivateKeyFromPhrase:h4(z),createTransaction:T6,fetchFeeRateFromSwapKit:V6,getAccount:J,getAddress:G,getBalance:async(T,N)=>{let E=await r6(X)(T),x=await Promise.all(E.filter(({denom:O})=>O&&!O.includes("IBC/")).map(({denom:O,amount:R})=>{let M=[V.THORChain,V.Maya].includes(Y)&&(O.includes("/")||O.includes("˜"))?`${Y}.${O}`:O;return _6(M,R)}));if(x.length===0)return[Z6.from({chain:Y})];return x},getBalanceAsDenoms:r6(X),getFees:()=>A6(Y,K6[Y]),getPubKey:_,getSignerFromPhrase:async({phrase:T,derivationPath:N})=>R6({derivationPath:i6(N),index:Z,phrase:T,prefix:L}),getSignerFromPrivateKey:async(T)=>{let N=await import("@cosmjs/proto-signing");return(N.DirectSecp256k1Wallet??N.default?.DirectSecp256k1Wallet).fromKey(T,L)},signTransaction:K,transfer:A,validateAddress:L4(Y),verifySignature:e6(J)}}async function w4(Y,H){try{let L=(await s6.getGasRate()).find((Z)=>Z.chainId===Y)?.value;return L?Number.parseFloat(L):H}catch{return H}}function $4({assetValue:{chain:Y}}){return Z6.from({chain:Y,value:u4(Y)})}async function A6(Y,H){let{chainId:X,baseDecimal:L}=f4(Y),Z=await V6(X,H);return{average:v6.fromBigInt(BigInt(Z),L),fast:v6.fromBigInt(BigInt(g6(Z,Q6.Fast,!0)),L),fastest:v6.fromBigInt(BigInt(g6(Z,Q6.Fastest,!0)),L)}}function t6(Y,H){return{amount:[{amount:Y.getBaseValue("string"),denom:H}],gas:"200000"}}function u4(Y){return{[V.Cosmos]:0.007,[V.Kujira]:0.02,[V.Noble]:0.01,[V.THORChain]:0.02,[V.Maya]:0.02,[V.Harbor]:0.02}[Y]||0}function L4(Y){let H=a6[Y];return function(L){if(!L.startsWith(H))return!1;try{let{prefix:Z,words:z}=U6.decode(L);return U6.encode(Z,z)===L.toLocaleLowerCase()}catch{return!1}}}function r6(Y){return async function(X){return(await(await P(Y)).getAllBalances(X)).map((Q)=>({...Q,denom:Q.denom.includes("/")?Q.denom.toUpperCase():Q.denom}))}}function h4(Y){return async function(X){let L=await import("@cosmjs/crypto"),Z=L.stringToPath??L.default?.stringToPath,z=L.Slip10Curve??L.default?.Slip10Curve,Q=L.Slip10??L.default?.Slip10,J=L.EnglishMnemonic??L.default?.EnglishMnemonic,G=L.Bip39??L.default?.Bip39,_=new J(X),K=await G.mnemonicToSeed(_),{privkey:A}=Q.derivePath(z.Secp256k1,K,Z(Y));return A}}var K6;var X6=F(()=>{t();K6={[V.Cosmos]:1000,[V.Kujira]:1000,[V.Noble]:1000,[V.THORChain]:5000000,[V.Maya]:5000000,[V.Harbor]:5000000}});import{base64 as j}from"@scure/base";import{Chain as l4,CosmosChainPrefixes as j4,derivationPathToString as b4,FeeOption as M6,getChainConfig as z4,getRPCUrl as p4,NetworkDerivationPath as c4,RequestClient as d4,SKConfig as n4,SwapKitError as Z4,SwapKitNumber as H4,updateDerivationPath as m4}from"@uswap/helpers";import{match as g4,P as Q4}from"ts-pattern";function i4({prefix:Y,derivationPath:H}){return async function(L,Z=0){let z=await import("@cosmjs/amino"),Q=z.Secp256k1HdWallet??z.default?.Secp256k1HdWallet,J=await import("@cosmjs/crypto"),G=J.stringToPath??J.default?.stringToPath;return Q.fromMnemonic(L,{hdPaths:[G(`${H}/${Z}`)],prefix:Y})}}function o4(Y){return j.encode(Y)}function t4(Y){return async function({wallet:X,tx:L}){let{msgs:Z,accountNumber:z,sequence:Q,chainId:J,fee:G,memo:_}=typeof L==="string"?JSON.parse(L):L,K=(await X.getAccounts())?.[0]?.address||"",A=await C(Y),T=await l(),N=await G6(X,{aminoTypes:A,registry:T}),E=[];for(let R of Z){let M=await w(R,Y);E.push(M)}let{signatures:[x]}=await N.sign(K,E,G,_,{accountNumber:z,chainId:J,sequence:Q});return{bodyBytes:await r({chain:Y,memo:_,msgs:Z.map($)}),signature:o4(x)}}}function r4({prefix:Y,rpcUrl:H}){return async function(L,Z,z,Q,J){let{encodeSecp256k1Pubkey:G,pubkeyToAddress:_}=(await import("@cosmjs/amino")).default,{makeMultisignedTxBytes:K}=(await import("@cosmjs/stargate")).default,{sequence:A,fee:T}=JSON.parse(L),N=await X4(z,Q),E=Z.map((R)=>[_(G(j.decode(R.pubKey)),Y),j.decode(R.signature)]),x=await P(H),{transactionHash:O}=await x.broadcastTx(K(N,A,T,J,new Map(E)));return O}}async function X4(Y,H,X=!0){let{createMultisigThresholdPubkey:L,encodeSecp256k1Pubkey:Z}=(await import("@cosmjs/amino")).default;return L(Y.map((z)=>Z(j.decode(z))),H,X)}function a4(Y){return j.decode(Y)}async function s4({privateKey:Y,message:H}){let{Secp256k1:X}=(await import("@cosmjs/crypto")).default,L=await X.createSignature(j.decode(H),Y);return j.encode(Buffer.concat([L.r(32),L.s(32)]))}async function F6({chain:Y,...H}){let X=await p4(Y),{nodeUrl:L}=z4(Y),{isStagenet:Z}=n4.get("envs"),z=Y===l4.THORChain,Q=`${Z?"s":""}${j4[Y]}`,J="index"in H?H.index||0:0,G="derivationPath"in H&&H.derivationPath?H.derivationPath:m4(c4[Y],{index:J}),_=await a({chain:Y,...H}),K=await g4(H).with({phrase:Q4.string},({phrase:E})=>_.getSignerFromPhrase({derivationPath:G,phrase:E})).with({signer:Q4.any},({signer:E})=>E).otherwise(()=>{return}),A=S(Y);async function T(){let E,x=`${L}/${z?"thorchain":"mayachain"}/constants`;try{let{int_64_values:{NativeTransactionFee:O}}=await d4.get(x);if(!O||Number.isNaN(O)||O<0)throw new Z4("toolbox_cosmos_invalid_fee",{nativeFee:O.toString()});E=new H4(O)}catch{E=new H4({decimal:z4(Y).baseDecimal,value:z?0.02:1})}return{[M6.Average]:E,[M6.Fast]:E,[M6.Fastest]:E}}async function N({assetValue:E,memo:x="",recipient:O}){let{TxRaw:R}=await import("cosmjs-types/cosmos/tx/v1beta1/tx"),M=(await K?.getAccounts())?.[0]?.address;if(!(M&&K))throw new Z4("toolbox_cosmos_no_signer");let c="signAmino"in K,d=await l(),n=await C(Y),u=await p(X,K,{aminoTypes:n,registry:d}),h=z6({assetValue:E,memo:x,recipient:O,sender:M});if(c){let Y6=await w(h,Y),{signatures:J4,authInfoBytes:q4}=await u.sign(M,[Y6],A,x),W4=R.encode({authInfoBytes:q4,bodyBytes:await r({chain:Y,memo:x,msgs:[h].map($)}),signatures:J4}).finish();return(await u.broadcastTx(W4)).transactionHash}let m=$(h),g=await w(m,Y);return(await u.signAndBroadcast(M,[g],A,x)).transactionHash}return{..._,broadcastMultisigTx:r4({prefix:Q,rpcUrl:X}),buildAminoMsg:z6,buildEncodedTxBody:r,convertToSignable:w,createDefaultAminoTypes:()=>C(Y),createDefaultRegistry:l,createMultisig:X4,createTransaction:O6(X),deposit:N,getFees:T,importSignature:a4,parseAminoMessageForDirectSigning:$,pubkeyToAddress:async(E)=>{let{pubkeyToAddress:x}=(await import("@cosmjs/amino")).default;return x(E,Q)},secp256k1HdWalletFromMnemonic:i4({derivationPath:b4(G),prefix:Q}),signMultisigTx:t4(Y),signWithPrivateKey:s4,transfer:N}}var f6=F(()=>{x6();t();X6()});import{Chain as s,SwapKitError as e4}from"@uswap/helpers";var LL=(Y,H)=>{switch(Y){case s.Cosmos:case s.Kujira:case s.Noble:return a({chain:Y,...H});case s.Maya:case s.THORChain:return F6({chain:Y,...H});default:throw new e4("toolbox_cosmos_not_supported",{chain:Y})}};var Y4=F(()=>{X6();f6();X6();f6()});var ZL={};D6(ZL,{verifySignature:()=>e6,transferMsgAmino:()=>E6,toBase64:()=>O4,parseAminoMessageForDirectSigning:()=>$,getSignerFromPrivateKey:()=>C4,getSignerFromPhrase:()=>R6,getMsgSendDenom:()=>D,getFeeRateFromSwapKit:()=>w4,getDenomWithChain:()=>b,getDefaultChainFee:()=>S,getCreateTransaction:()=>O6,getCosmosValidateAddress:()=>L4,getCosmosToolbox:()=>LL,getAssetFromDenom:()=>_6,fromBase64:()=>x4,fetchFeeRateFromSwapKit:()=>V6,estimateTransactionFee:()=>$4,depositMsgAmino:()=>N6,createThorchainToolbox:()=>F6,createStargateClient:()=>P,createSigningStargateClient:()=>p,createOfflineStargateClient:()=>G6,createDefaultRegistry:()=>l,createDefaultAminoTypes:()=>C,createCosmosToolbox:()=>a,cosmosCreateTransaction:()=>T6,convertToSignable:()=>w,buildTransferTx:()=>p6,buildEncodedTxBody:()=>r,buildDepositTx:()=>c6,buildAminoMsg:()=>z6,bech32ToBase64:()=>i,base64ToBech32:()=>o,YUM_KUJIRA_FACTORY_DENOM:()=>C6,USK_KUJIRA_FACTORY_DENOM:()=>B6,THORCHAIN_GAS_VALUE:()=>V4,MAYA_GAS_VALUE:()=>M4,DEFAULT_NOBLE_FEE_MAINNET:()=>u6,DEFAULT_KUJI_FEE_MAINNET:()=>$6,DEFAULT_COSMOS_FEE_MAINNET:()=>w6});var HL=F(()=>{x6();Y4();t()});HL();export{e6 as verifySignature,E6 as transferMsgAmino,O4 as toBase64,$ as parseAminoMessageForDirectSigning,C4 as getSignerFromPrivateKey,R6 as getSignerFromPhrase,D as getMsgSendDenom,w4 as getFeeRateFromSwapKit,b as getDenomWithChain,S as getDefaultChainFee,O6 as getCreateTransaction,L4 as getCosmosValidateAddress,LL as getCosmosToolbox,_6 as getAssetFromDenom,x4 as fromBase64,V6 as fetchFeeRateFromSwapKit,$4 as estimateTransactionFee,N6 as depositMsgAmino,F6 as createThorchainToolbox,P as createStargateClient,p as createSigningStargateClient,G6 as createOfflineStargateClient,l as createDefaultRegistry,C as createDefaultAminoTypes,a as createCosmosToolbox,T6 as cosmosCreateTransaction,w as convertToSignable,p6 as buildTransferTx,r as buildEncodedTxBody,c6 as buildDepositTx,z6 as buildAminoMsg,i as bech32ToBase64,o as base64ToBech32,C6 as YUM_KUJIRA_FACTORY_DENOM,B6 as USK_KUJIRA_FACTORY_DENOM,V4 as THORCHAIN_GAS_VALUE,M4 as MAYA_GAS_VALUE,u6 as DEFAULT_NOBLE_FEE_MAINNET,$6 as DEFAULT_KUJI_FEE_MAINNET,w6 as DEFAULT_COSMOS_FEE_MAINNET};
1
+ var W4=Object.create;var{getPrototypeOf:G4,defineProperty:J6,getOwnPropertyNames:T4}=Object;var _4=Object.prototype.hasOwnProperty;var K=(Y,Z,X)=>{X=Y!=null?W4(G4(Y)):{};let L=Z||!Y||!Y.__esModule?J6(X,"default",{value:Y,enumerable:!0}):X;for(let H of T4(Y))if(!_4.call(L,H))J6(L,H,{get:()=>Y[H],enumerable:!0});return L};var D6=(Y,Z)=>{for(var X in Z)J6(Y,X,{get:Z[X],enumerable:!0,configurable:!0,set:(L)=>Z[X]=()=>L})};var F=(Y,Z)=>()=>(Y&&(Z=Y(Y=0)),Z);var U=((Y)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(Y,{get:(Z,X)=>(typeof require<"u"?require:Z)[X]}):Y)(function(Y){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+Y+'" is not supported')});import{base64 as S6,bech32 as e}from"@scure/base";import{USwapError as I4}from"@uswap/helpers";import{fromByteArray as E4,toByteArray as N4}from"base64-js";function i(Y){return S6.encode(Uint8Array.from(e.fromWords(e.decode(Y).words)))}function o(Y,Z="thor"){return e.encode(Z,e.toWords(S6.decode(Y)))}function O4(Y){return E4(Y)}function x4(Y){if(!Y.match(/^[a-zA-Z0-9+/]*={0,2}$/))throw new I4("toolbox_cosmos_invalid_params",{error:"Invalid base64 string format"});return N4(Y)}var q6=()=>{};import{AssetValue as B6,Chain as I,getChainConfig as y,getRPCUrl as K4,USwapError as P6}from"@uswap/helpers";function S(Y){switch(Y){case I.Maya:return{amount:[],gas:"10000000000"};case I.THORChain:return{amount:[],gas:"500000000"};case I.Kujira:return $6;case I.Noble:return u6;default:return w6}}async function P(Y){let Z=await import("@cosmjs/stargate"),X=Z.StargateClient??Z.default?.StargateClient,L=typeof window<"u"?{}:{referer:"https://sdk.swapkit.dev",referrer:"https://sdk.swapkit.dev"};return X.connect({headers:L,url:Y})}async function p(Y,Z,X={}){let L=await import("@cosmjs/stargate"),H=L.SigningStargateClient??L.default?.SigningStargateClient,z=L.GasPrice??L.default?.GasPrice,Q=typeof X==="string"?X:"0.0003uatom",J=typeof X==="string"?{}:X;return H.connectWithSigner(Y,Z,{gasPrice:z.fromString(Q),...J})}async function G6(Y,Z){let X=await import("@cosmjs/stargate");return(X.SigningStargateClient??X.default?.SigningStargateClient).offline(Y,Z)}async function T6({sender:Y,recipient:Z,assetValue:X,memo:L="",feeRate:H,sequence:z,accountNumber:Q}){let{chain:J,chainId:G}=X,_=await K4(J),A=await(await P(_)).getAccount(Y);if(!A)throw new P6("toolbox_cosmos_account_not_found",{sender:Y});let T=B6.from({chain:J}),N=D(T.symbol),E=S(J),x=N&&H?{amount:[{amount:H.toString(),denom:N}],gas:E.gas}:E,O={amount:[{amount:X.getBaseValue("string"),denom:D(X.symbol)}],fromAddress:Y,toAddress:Z};return{accountNumber:Q??A.accountNumber,chainId:G,fee:x,memo:L,msgs:[{typeUrl:U4(J),value:O}],sequence:z??A.sequence}}var W6="FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK",C6="FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM",w6,$6,u6,D=(Y,Z=!1)=>{if(Z)return Y.toLowerCase();switch(Y){case"uUSK":case"USK":return W6;case"uYUM":case"YUM":return C6;case"uKUJI":case"KUJI":return"ukuji";case"ATOM":case"uATOM":return"uatom";case"uUSDC":case"USDC":return"uusdc";default:return Y}},b=({symbol:Y,chain:Z})=>{if(Z===I.Maya)return(Y.toUpperCase()!=="CACAO"?Y:`${I.Maya}.${Y}`).toUpperCase();if(Z===I.THORChain)return(["RUNE","TCY","RUJI"].includes(Y.toUpperCase())?`${I.THORChain}.${Y}`:Y).toUpperCase();return D(Y,!1)},U4=(Y)=>{switch(Y){case I.Maya:case I.THORChain:return"/types.MsgSend";case I.Cosmos:case I.Kujira:case I.Noble:return"/cosmos.bank.v1beta1.MsgSend";default:throw new P6("toolbox_cosmos_not_supported",{chain:Y})}},v4,_6=(Y,Z)=>{let X=v4[Y.toLowerCase()];if(!X)return B6.from({asset:Y,fromBaseDecimal:8,value:Z});let{chain:L,asset:H,decimals:z}=X,Q=L?{chain:L}:{asset:H};return B6.from({...Q,fromBaseDecimal:z,value:Z})};var t=F(()=>{w6={amount:[{amount:"500",denom:"uatom"}],gas:"200000"},$6={amount:[{amount:"1000",denom:"ukuji"}],gas:"200000"},u6={amount:[{amount:"1000",denom:"uusdc"}],gas:"200000"};v4={atom:{chain:I.Cosmos,decimals:y(I.Cosmos).baseDecimal},cacao:{chain:I.Maya,decimals:10},kuji:{chain:I.Kujira,decimals:y(I.Kujira).baseDecimal},maya:{asset:`${I.Maya}.${I.Maya}`,decimals:4},rune:{chain:I.THORChain,decimals:y(I.THORChain).baseDecimal},tcy:{asset:"THOR.TCY",decimals:y(I.THORChain).baseDecimal},uatom:{chain:I.Cosmos,decimals:y(I.Cosmos).baseDecimal},ukuji:{chain:I.Kujira,decimals:y(I.Kujira).baseDecimal},usdc:{chain:I.Noble,decimals:y(I.Noble).baseDecimal},uusdc:{chain:I.Noble,decimals:y(I.Noble).baseDecimal},"x/kuji":{asset:"THOR.KUJI",decimals:y(I.THORChain).baseDecimal},[W6.toLowerCase()]:{asset:`${I.Kujira}.USK`,decimals:y(I.Kujira).baseDecimal}}});var h6={};D6(h6,{$root:()=>q});import k from"protobufjs/minimal.js";var W,f,B,q;var l6=F(()=>{W=k.Reader,f=k.Writer,B=k.util,q=k.roots.default||(k.roots.default={});q.common=(()=>{let Y={};return Y.Asset=(()=>{function Z(X){if(X){for(let L=Object.keys(X),H=0;H<L.length;++H)if(X[L[H]]!=null)this[L[H]]=X[L[H]]}}return Z.prototype.chain="",Z.prototype.symbol="",Z.prototype.ticker="",Z.prototype.synth=!1,Z.create=function(L){return new Z(L)},Z.encode=function(L,H){if(!H)H=f.create();if(L.chain!=null&&Object.hasOwnProperty.call(L,"chain"))H.uint32(10).string(L.chain);if(L.symbol!=null&&Object.hasOwnProperty.call(L,"symbol"))H.uint32(18).string(L.symbol);if(L.ticker!=null&&Object.hasOwnProperty.call(L,"ticker"))H.uint32(26).string(L.ticker);if(L.synth!=null&&Object.hasOwnProperty.call(L,"synth"))H.uint32(32).bool(L.synth);return H},Z.encodeDelimited=function(L,H){return this.encode(L,H).ldelim()},Z.decode=function(L,H){if(!(L instanceof W))L=W.create(L);let z=H===void 0?L.len:L.pos+H,Q=new q.common.Asset;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.chain=L.string();break;case 2:Q.symbol=L.string();break;case 3:Q.ticker=L.string();break;case 4:Q.synth=L.bool();break;default:L.skipType(J&7);break}}return Q},Z.decodeDelimited=function(L){if(!(L instanceof W))L=new W(L);return this.decode(L,L.uint32())},Z.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.chain!=null&&L.hasOwnProperty("chain")){if(!B.isString(L.chain))return"chain: string expected"}if(L.symbol!=null&&L.hasOwnProperty("symbol")){if(!B.isString(L.symbol))return"symbol: string expected"}if(L.ticker!=null&&L.hasOwnProperty("ticker")){if(!B.isString(L.ticker))return"ticker: string expected"}if(L.synth!=null&&L.hasOwnProperty("synth")){if(typeof L.synth!=="boolean")return"synth: boolean expected"}return null},Z.fromObject=function(L){if(L instanceof q.common.Asset)return L;let H=new q.common.Asset;if(L.chain!=null)H.chain=String(L.chain);if(L.symbol!=null)H.symbol=String(L.symbol);if(L.ticker!=null)H.ticker=String(L.ticker);if(L.synth!=null)H.synth=Boolean(L.synth);return H},Z.toObject=function(L,H){if(!H)H={};let z={};if(H.defaults)z.chain="",z.symbol="",z.ticker="",z.synth=!1;if(L.chain!=null&&L.hasOwnProperty("chain"))z.chain=L.chain;if(L.symbol!=null&&L.hasOwnProperty("symbol"))z.symbol=L.symbol;if(L.ticker!=null&&L.hasOwnProperty("ticker"))z.ticker=L.ticker;if(L.synth!=null&&L.hasOwnProperty("synth"))z.synth=L.synth;return z},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.Coin=(()=>{function Z(X){if(X){for(let L=Object.keys(X),H=0;H<L.length;++H)if(X[L[H]]!=null)this[L[H]]=X[L[H]]}}return Z.prototype.asset=null,Z.prototype.amount="",Z.prototype.decimals=B.Long?B.Long.fromBits(0,0,!1):0,Z.create=function(L){return new Z(L)},Z.encode=function(L,H){if(!H)H=f.create();if(L.asset!=null&&Object.hasOwnProperty.call(L,"asset"))q.common.Asset.encode(L.asset,H.uint32(10).fork()).ldelim();if(L.amount!=null&&Object.hasOwnProperty.call(L,"amount"))H.uint32(18).string(L.amount);if(L.decimals!=null&&Object.hasOwnProperty.call(L,"decimals"))H.uint32(24).int64(L.decimals);return H},Z.encodeDelimited=function(L,H){return this.encode(L,H).ldelim()},Z.decode=function(L,H){if(!(L instanceof W))L=W.create(L);let z=H===void 0?L.len:L.pos+H,Q=new q.common.Coin;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.asset=q.common.Asset.decode(L,L.uint32());break;case 2:Q.amount=L.string();break;case 3:Q.decimals=L.int64();break;default:L.skipType(J&7);break}}return Q},Z.decodeDelimited=function(L){if(!(L instanceof W))L=new W(L);return this.decode(L,L.uint32())},Z.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.asset!=null&&L.hasOwnProperty("asset")){let H=q.common.Asset.verify(L.asset);if(H)return"asset."+H}if(L.amount!=null&&L.hasOwnProperty("amount")){if(!B.isString(L.amount))return"amount: string expected"}if(L.decimals!=null&&L.hasOwnProperty("decimals")){if(!B.isInteger(L.decimals)&&!(L.decimals&&B.isInteger(L.decimals.low)&&B.isInteger(L.decimals.high)))return"decimals: integer|Long expected"}return null},Z.fromObject=function(L){if(L instanceof q.common.Coin)return L;let H=new q.common.Coin;if(L.asset!=null){if(typeof L.asset!=="object")throw TypeError(".common.Coin.asset: object expected");H.asset=q.common.Asset.fromObject(L.asset)}if(L.amount!=null)H.amount=String(L.amount);if(L.decimals!=null){if(B.Long)(H.decimals=B.Long.fromValue(L.decimals)).unsigned=!1;else if(typeof L.decimals==="string")H.decimals=Number.parseInt(L.decimals,10);else if(typeof L.decimals==="number")H.decimals=L.decimals;else if(typeof L.decimals==="object")H.decimals=new B.LongBits(L.decimals.low>>>0,L.decimals.high>>>0).toNumber()}return H},Z.toObject=function(L,H){if(!H)H={};let z={};if(H.defaults)if(z.asset=null,z.amount="",B.Long){let Q=new B.Long(0,0,!1);z.decimals=H.longs===String?Q.toString():H.longs===Number?Q.toNumber():Q}else z.decimals=H.longs===String?"0":0;if(L.asset!=null&&L.hasOwnProperty("asset"))z.asset=q.common.Asset.toObject(L.asset,H);if(L.amount!=null&&L.hasOwnProperty("amount"))z.amount=L.amount;if(L.decimals!=null&&L.hasOwnProperty("decimals"))if(typeof L.decimals==="number")z.decimals=H.longs===String?String(L.decimals):L.decimals;else z.decimals=H.longs===String?B.Long.prototype.toString.call(L.decimals):H.longs===Number?new B.LongBits(L.decimals.low>>>0,L.decimals.high>>>0).toNumber():L.decimals;return z},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.PubKeySet=(()=>{function Z(X){if(X){for(let L=Object.keys(X),H=0;H<L.length;++H)if(X[L[H]]!=null)this[L[H]]=X[L[H]]}}return Z.prototype.secp256k1="",Z.prototype.ed25519="",Z.create=function(L){return new Z(L)},Z.encode=function(L,H){if(!H)H=f.create();if(L.secp256k1!=null&&Object.hasOwnProperty.call(L,"secp256k1"))H.uint32(10).string(L.secp256k1);if(L.ed25519!=null&&Object.hasOwnProperty.call(L,"ed25519"))H.uint32(18).string(L.ed25519);return H},Z.encodeDelimited=function(L,H){return this.encode(L,H).ldelim()},Z.decode=function(L,H){if(!(L instanceof W))L=W.create(L);let z=H===void 0?L.len:L.pos+H,Q=new q.common.PubKeySet;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.secp256k1=L.string();break;case 2:Q.ed25519=L.string();break;default:L.skipType(J&7);break}}return Q},Z.decodeDelimited=function(L){if(!(L instanceof W))L=new W(L);return this.decode(L,L.uint32())},Z.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.secp256k1!=null&&L.hasOwnProperty("secp256k1")){if(!B.isString(L.secp256k1))return"secp256k1: string expected"}if(L.ed25519!=null&&L.hasOwnProperty("ed25519")){if(!B.isString(L.ed25519))return"ed25519: string expected"}return null},Z.fromObject=function(L){if(L instanceof q.common.PubKeySet)return L;let H=new q.common.PubKeySet;if(L.secp256k1!=null)H.secp256k1=String(L.secp256k1);if(L.ed25519!=null)H.ed25519=String(L.ed25519);return H},Z.toObject=function(L,H){if(!H)H={};let z={};if(H.defaults)z.secp256k1="",z.ed25519="";if(L.secp256k1!=null&&L.hasOwnProperty("secp256k1"))z.secp256k1=L.secp256k1;if(L.ed25519!=null&&L.hasOwnProperty("ed25519"))z.ed25519=L.ed25519;return z},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.Tx=(()=>{function Z(X){if(this.coins=[],this.gas=[],X){for(let L=Object.keys(X),H=0;H<L.length;++H)if(X[L[H]]!=null)this[L[H]]=X[L[H]]}}return Z.prototype.id="",Z.prototype.chain="",Z.prototype.fromAddress="",Z.prototype.toAddress="",Z.prototype.coins=B.emptyArray,Z.prototype.gas=B.emptyArray,Z.prototype.memo="",Z.create=function(L){return new Z(L)},Z.encode=function(L,H){if(!H)H=f.create();if(L.id!=null&&Object.hasOwnProperty.call(L,"id"))H.uint32(10).string(L.id);if(L.chain!=null&&Object.hasOwnProperty.call(L,"chain"))H.uint32(18).string(L.chain);if(L.fromAddress!=null&&Object.hasOwnProperty.call(L,"fromAddress"))H.uint32(26).string(L.fromAddress);if(L.toAddress!=null&&Object.hasOwnProperty.call(L,"toAddress"))H.uint32(34).string(L.toAddress);if(L.coins?.length)for(let z=0;z<L.coins.length;++z)q.common.Coin.encode(L.coins[z],H.uint32(42).fork()).ldelim();if(L.gas?.length)for(let z=0;z<L.gas.length;++z)q.common.Coin.encode(L.gas[z],H.uint32(50).fork()).ldelim();if(L.memo!=null&&Object.hasOwnProperty.call(L,"memo"))H.uint32(58).string(L.memo);return H},Z.encodeDelimited=function(L,H){return this.encode(L,H).ldelim()},Z.decode=function(L,H){if(!(L instanceof W))L=W.create(L);let z=H===void 0?L.len:L.pos+H,Q=new q.common.Tx;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.id=L.string();break;case 2:Q.chain=L.string();break;case 3:Q.fromAddress=L.string();break;case 4:Q.toAddress=L.string();break;case 5:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(L,L.uint32()));break;case 6:if(!Q.gas?.length)Q.gas=[];Q.gas.push(q.common.Coin.decode(L,L.uint32()));break;case 7:Q.memo=L.string();break;default:L.skipType(J&7);break}}return Q},Z.decodeDelimited=function(L){if(!(L instanceof W))L=new W(L);return this.decode(L,L.uint32())},Z.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.id!=null&&L.hasOwnProperty("id")){if(!B.isString(L.id))return"id: string expected"}if(L.chain!=null&&L.hasOwnProperty("chain")){if(!B.isString(L.chain))return"chain: string expected"}if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress")){if(!B.isString(L.fromAddress))return"fromAddress: string expected"}if(L.toAddress!=null&&L.hasOwnProperty("toAddress")){if(!B.isString(L.toAddress))return"toAddress: string expected"}if(L.coins!=null&&L.hasOwnProperty("coins")){if(!Array.isArray(L.coins))return"coins: array expected";for(let H=0;H<L.coins.length;++H){let z=q.common.Coin.verify(L.coins[H]);if(z)return"coins."+z}}if(L.gas!=null&&L.hasOwnProperty("gas")){if(!Array.isArray(L.gas))return"gas: array expected";for(let H=0;H<L.gas.length;++H){let z=q.common.Coin.verify(L.gas[H]);if(z)return"gas."+z}}if(L.memo!=null&&L.hasOwnProperty("memo")){if(!B.isString(L.memo))return"memo: string expected"}return null},Z.fromObject=function(L){if(L instanceof q.common.Tx)return L;let H=new q.common.Tx;if(L.id!=null)H.id=String(L.id);if(L.chain!=null)H.chain=String(L.chain);if(L.fromAddress!=null)H.fromAddress=String(L.fromAddress);if(L.toAddress!=null)H.toAddress=String(L.toAddress);if(L.coins){if(!Array.isArray(L.coins))throw TypeError(".common.Tx.coins: array expected");H.coins=[];for(let z=0;z<L.coins.length;++z){if(typeof L.coins[z]!=="object")throw TypeError(".common.Tx.coins: object expected");H.coins[z]=q.common.Coin.fromObject(L.coins[z])}}if(L.gas){if(!Array.isArray(L.gas))throw TypeError(".common.Tx.gas: array expected");H.gas=[];for(let z=0;z<L.gas.length;++z){if(typeof L.gas[z]!=="object")throw TypeError(".common.Tx.gas: object expected");H.gas[z]=q.common.Coin.fromObject(L.gas[z])}}if(L.memo!=null)H.memo=String(L.memo);return H},Z.toObject=function(L,H){if(!H)H={};let z={};if(H.arrays||H.defaults)z.coins=[],z.gas=[];if(H.defaults)z.id="",z.chain="",z.fromAddress="",z.toAddress="",z.memo="";if(L.id!=null&&L.hasOwnProperty("id"))z.id=L.id;if(L.chain!=null&&L.hasOwnProperty("chain"))z.chain=L.chain;if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress"))z.fromAddress=L.fromAddress;if(L.toAddress!=null&&L.hasOwnProperty("toAddress"))z.toAddress=L.toAddress;if(L.coins?.length){z.coins=[];for(let Q=0;Q<L.coins.length;++Q)z.coins[Q]=q.common.Coin.toObject(L.coins[Q],H)}if(L.gas?.length){z.gas=[];for(let Q=0;Q<L.gas.length;++Q)z.gas[Q]=q.common.Coin.toObject(L.gas[Q],H)}if(L.memo!=null&&L.hasOwnProperty("memo"))z.memo=L.memo;return z},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.Fee=(()=>{function Z(X){if(this.coins=[],X){for(let L=Object.keys(X),H=0;H<L.length;++H)if(X[L[H]]!=null)this[L[H]]=X[L[H]]}}return Z.prototype.coins=B.emptyArray,Z.prototype.poolDeduct="",Z.create=function(L){return new Z(L)},Z.encode=function(L,H){if(!H)H=f.create();if(L.coins?.length)for(let z=0;z<L.coins.length;++z)q.common.Coin.encode(L.coins[z],H.uint32(10).fork()).ldelim();if(L.poolDeduct!=null&&Object.hasOwnProperty.call(L,"poolDeduct"))H.uint32(18).string(L.poolDeduct);return H},Z.encodeDelimited=function(L,H){return this.encode(L,H).ldelim()},Z.decode=function(L,H){if(!(L instanceof W))L=W.create(L);let z=H===void 0?L.len:L.pos+H,Q=new q.common.Fee;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(L,L.uint32()));break;case 2:Q.poolDeduct=L.string();break;default:L.skipType(J&7);break}}return Q},Z.decodeDelimited=function(L){if(!(L instanceof W))L=new W(L);return this.decode(L,L.uint32())},Z.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.coins!=null&&L.hasOwnProperty("coins")){if(!Array.isArray(L.coins))return"coins: array expected";for(let H=0;H<L.coins.length;++H){let z=q.common.Coin.verify(L.coins[H]);if(z)return"coins."+z}}if(L.poolDeduct!=null&&L.hasOwnProperty("poolDeduct")){if(!B.isString(L.poolDeduct))return"poolDeduct: string expected"}return null},Z.fromObject=function(L){if(L instanceof q.common.Fee)return L;let H=new q.common.Fee;if(L.coins){if(!Array.isArray(L.coins))throw TypeError(".common.Fee.coins: array expected");H.coins=[];for(let z=0;z<L.coins.length;++z){if(typeof L.coins[z]!=="object")throw TypeError(".common.Fee.coins: object expected");H.coins[z]=q.common.Coin.fromObject(L.coins[z])}}if(L.poolDeduct!=null)H.poolDeduct=String(L.poolDeduct);return H},Z.toObject=function(L,H){if(!H)H={};let z={};if(H.arrays||H.defaults)z.coins=[];if(H.defaults)z.poolDeduct="";if(L.coins?.length){z.coins=[];for(let Q=0;Q<L.coins.length;++Q)z.coins[Q]=q.common.Coin.toObject(L.coins[Q],H)}if(L.poolDeduct!=null&&L.hasOwnProperty("poolDeduct"))z.poolDeduct=L.poolDeduct;return z},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.ProtoUint=(()=>{function Z(X){if(X){for(let L=Object.keys(X),H=0;H<L.length;++H)if(X[L[H]]!=null)this[L[H]]=X[L[H]]}}return Z.prototype.value="",Z.create=function(L){return new Z(L)},Z.encode=function(L,H){if(!H)H=f.create();if(L.value!=null&&Object.hasOwnProperty.call(L,"value"))H.uint32(10).string(L.value);return H},Z.encodeDelimited=function(L,H){return this.encode(L,H).ldelim()},Z.decode=function(L,H){if(!(L instanceof W))L=W.create(L);let z=H===void 0?L.len:L.pos+H,Q=new q.common.ProtoUint;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.value=L.string();break;default:L.skipType(J&7);break}}return Q},Z.decodeDelimited=function(L){if(!(L instanceof W))L=new W(L);return this.decode(L,L.uint32())},Z.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.value!=null&&L.hasOwnProperty("value")){if(!B.isString(L.value))return"value: string expected"}return null},Z.fromObject=function(L){if(L instanceof q.common.ProtoUint)return L;let H=new q.common.ProtoUint;if(L.value!=null)H.value=String(L.value);return H},Z.toObject=function(L,H){if(!H)H={};let z={};if(H.defaults)z.value="";if(L.value!=null&&L.hasOwnProperty("value"))z.value=L.value;return z},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y})();q.types=(()=>{let Y={};return Y.MsgDeposit=(()=>{function Z(X){if(this.coins=[],X){for(let L=Object.keys(X),H=0;H<L.length;++H)if(X[L[H]]!=null)this[L[H]]=X[L[H]]}}return Z.prototype.coins=B.emptyArray,Z.prototype.memo="",Z.prototype.signer=B.newBuffer([]),Z.create=function(L){return new Z(L)},Z.encode=function(L,H){if(!H)H=f.create();if(L.coins?.length)for(let z=0;z<L.coins.length;++z)q.common.Coin.encode(L.coins[z],H.uint32(10).fork()).ldelim();if(L.memo!=null&&Object.hasOwnProperty.call(L,"memo"))H.uint32(18).string(L.memo);if(L.signer!=null&&Object.hasOwnProperty.call(L,"signer"))H.uint32(26).bytes(L.signer);return H},Z.encodeDelimited=function(L,H){return this.encode(L,H).ldelim()},Z.decode=function(L,H){if(!(L instanceof W))L=W.create(L);let z=H===void 0?L.len:L.pos+H,Q=new q.types.MsgDeposit;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(L,L.uint32()));break;case 2:Q.memo=L.string();break;case 3:Q.signer=L.bytes();break;default:L.skipType(J&7);break}}return Q},Z.decodeDelimited=function(L){if(!(L instanceof W))L=new W(L);return this.decode(L,L.uint32())},Z.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.coins!=null&&L.hasOwnProperty("coins")){if(!Array.isArray(L.coins))return"coins: array expected";for(let H=0;H<L.coins.length;++H){let z=q.common.Coin.verify(L.coins[H]);if(z)return"coins."+z}}if(L.memo!=null&&L.hasOwnProperty("memo")){if(!B.isString(L.memo))return"memo: string expected"}if(L.signer!=null&&L.hasOwnProperty("signer")){if(!(L.signer&&typeof L.signer.length==="number"||B.isString(L.signer)))return"signer: buffer expected"}return null},Z.fromObject=function(L){if(L instanceof q.types.MsgDeposit)return L;let H=new q.types.MsgDeposit;if(L.coins){if(!Array.isArray(L.coins))throw TypeError(".types.MsgDeposit.coins: array expected");H.coins=[];for(let z=0;z<L.coins.length;++z){if(typeof L.coins[z]!=="object")throw TypeError(".types.MsgDeposit.coins: object expected");H.coins[z]=q.common.Coin.fromObject(L.coins[z])}}if(L.memo!=null)H.memo=String(L.memo);if(L.signer!=null){if(typeof L.signer==="string")B.base64.decode(L.signer,H.signer=B.newBuffer(B.base64.length(L.signer)),0);else if(L.signer.length)H.signer=L.signer}return H},Z.toObject=function(L,H){if(!H)H={};let z={};if(H.arrays||H.defaults)z.coins=[];if(H.defaults){if(z.memo="",H.bytes===String)z.signer="";else if(z.signer=[],H.bytes!==Array)z.signer=B.newBuffer(z.signer)}if(L.coins?.length){z.coins=[];for(let Q=0;Q<L.coins.length;++Q)z.coins[Q]=q.common.Coin.toObject(L.coins[Q],H)}if(L.memo!=null&&L.hasOwnProperty("memo"))z.memo=L.memo;if(L.signer!=null&&L.hasOwnProperty("signer"))z.signer=H.bytes===String?B.base64.encode(L.signer,0,L.signer.length):H.bytes===Array?Array.prototype.slice.call(L.signer):L.signer;return z},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.MsgSend=(()=>{function Z(X){if(this.amount=[],X){for(let L=Object.keys(X),H=0;H<L.length;++H)if(X[L[H]]!=null)this[L[H]]=X[L[H]]}}return Z.prototype.fromAddress=B.newBuffer([]),Z.prototype.toAddress=B.newBuffer([]),Z.prototype.amount=B.emptyArray,Z.create=function(L){return new Z(L)},Z.encode=function(L,H){if(!H)H=f.create();if(L.fromAddress!=null&&Object.hasOwnProperty.call(L,"fromAddress"))H.uint32(10).bytes(L.fromAddress);if(L.toAddress!=null&&Object.hasOwnProperty.call(L,"toAddress"))H.uint32(18).bytes(L.toAddress);if(L.amount?.length)for(let z=0;z<L.amount.length;++z)q.cosmos.base.v1beta1.Coin.encode(L.amount[z],H.uint32(26).fork()).ldelim();return H},Z.encodeDelimited=function(L,H){return this.encode(L,H).ldelim()},Z.decode=function(L,H){if(!(L instanceof W))L=W.create(L);let z=H===void 0?L.len:L.pos+H,Q=new q.types.MsgSend;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.fromAddress=L.bytes();break;case 2:Q.toAddress=L.bytes();break;case 3:if(!Q.amount?.length)Q.amount=[];Q.amount.push(q.cosmos.base.v1beta1.Coin.decode(L,L.uint32()));break;default:L.skipType(J&7);break}}return Q},Z.decodeDelimited=function(L){if(!(L instanceof W))L=new W(L);return this.decode(L,L.uint32())},Z.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress")){if(!(L.fromAddress&&typeof L.fromAddress.length==="number"||B.isString(L.fromAddress)))return"fromAddress: buffer expected"}if(L.toAddress!=null&&L.hasOwnProperty("toAddress")){if(!(L.toAddress&&typeof L.toAddress.length==="number"||B.isString(L.toAddress)))return"toAddress: buffer expected"}if(L.amount!=null&&L.hasOwnProperty("amount")){if(!Array.isArray(L.amount))return"amount: array expected";for(let H=0;H<L.amount.length;++H){let z=q.cosmos.base.v1beta1.Coin.verify(L.amount[H]);if(z)return"amount."+z}}return null},Z.fromObject=function(L){if(L instanceof q.types.MsgSend)return L;let H=new q.types.MsgSend;if(L.fromAddress!=null){if(typeof L.fromAddress==="string")B.base64.decode(L.fromAddress,H.fromAddress=B.newBuffer(B.base64.length(L.fromAddress)),0);else if(L.fromAddress.length)H.fromAddress=L.fromAddress}if(L.toAddress!=null){if(typeof L.toAddress==="string")B.base64.decode(L.toAddress,H.toAddress=B.newBuffer(B.base64.length(L.toAddress)),0);else if(L.toAddress.length)H.toAddress=L.toAddress}if(L.amount){if(!Array.isArray(L.amount))throw TypeError(".types.MsgSend.amount: array expected");H.amount=[];for(let z=0;z<L.amount.length;++z){if(typeof L.amount[z]!=="object")throw TypeError(".types.MsgSend.amount: object expected");H.amount[z]=q.cosmos.base.v1beta1.Coin.fromObject(L.amount[z])}}return H},Z.toObject=function(L,H){if(!H)H={};let z={};if(H.arrays||H.defaults)z.amount=[];if(H.defaults){if(H.bytes===String)z.fromAddress="";else if(z.fromAddress=[],H.bytes!==Array)z.fromAddress=B.newBuffer(z.fromAddress);if(H.bytes===String)z.toAddress="";else if(z.toAddress=[],H.bytes!==Array)z.toAddress=B.newBuffer(z.toAddress)}if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress"))z.fromAddress=H.bytes===String?B.base64.encode(L.fromAddress,0,L.fromAddress.length):H.bytes===Array?Array.prototype.slice.call(L.fromAddress):L.fromAddress;if(L.toAddress!=null&&L.hasOwnProperty("toAddress"))z.toAddress=H.bytes===String?B.base64.encode(L.toAddress,0,L.toAddress.length):H.bytes===Array?Array.prototype.slice.call(L.toAddress):L.toAddress;if(L.amount?.length){z.amount=[];for(let Q=0;Q<L.amount.length;++Q)z.amount[Q]=q.cosmos.base.v1beta1.Coin.toObject(L.amount[Q],H)}return z},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y})();q.cosmos=(()=>{let Y={};return Y.base=(()=>{let Z={};return Z.v1beta1=(()=>{let X={};return X.Coin=(()=>{function L(H){if(H){for(let z=Object.keys(H),Q=0;Q<z.length;++Q)if(H[z[Q]]!=null)this[z[Q]]=H[z[Q]]}}return L.prototype.denom="",L.prototype.amount="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=f.create();if(z.denom!=null&&Object.hasOwnProperty.call(z,"denom"))Q.uint32(10).string(z.denom);if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))Q.uint32(18).string(z.amount);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof W))z=W.create(z);let J=Q===void 0?z.len:z.pos+Q,G=new q.cosmos.base.v1beta1.Coin;while(z.pos<J){let _=z.uint32();switch(_>>>3){case 1:G.denom=z.string();break;case 2:G.amount=z.string();break;default:z.skipType(_&7);break}}return G},L.decodeDelimited=function(z){if(!(z instanceof W))z=new W(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.denom!=null&&z.hasOwnProperty("denom")){if(!B.isString(z.denom))return"denom: string expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!B.isString(z.amount))return"amount: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.Coin)return z;let Q=new q.cosmos.base.v1beta1.Coin;if(z.denom!=null)Q.denom=String(z.denom);if(z.amount!=null)Q.amount=String(z.amount);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.denom="",J.amount="";if(z.denom!=null&&z.hasOwnProperty("denom"))J.denom=z.denom;if(z.amount!=null&&z.hasOwnProperty("amount"))J.amount=z.amount;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},L})(),X.DecCoin=(()=>{function L(H){if(H){for(let z=Object.keys(H),Q=0;Q<z.length;++Q)if(H[z[Q]]!=null)this[z[Q]]=H[z[Q]]}}return L.prototype.denom="",L.prototype.amount="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=f.create();if(z.denom!=null&&Object.hasOwnProperty.call(z,"denom"))Q.uint32(10).string(z.denom);if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))Q.uint32(18).string(z.amount);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof W))z=W.create(z);let J=Q===void 0?z.len:z.pos+Q,G=new q.cosmos.base.v1beta1.DecCoin;while(z.pos<J){let _=z.uint32();switch(_>>>3){case 1:G.denom=z.string();break;case 2:G.amount=z.string();break;default:z.skipType(_&7);break}}return G},L.decodeDelimited=function(z){if(!(z instanceof W))z=new W(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.denom!=null&&z.hasOwnProperty("denom")){if(!B.isString(z.denom))return"denom: string expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!B.isString(z.amount))return"amount: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.DecCoin)return z;let Q=new q.cosmos.base.v1beta1.DecCoin;if(z.denom!=null)Q.denom=String(z.denom);if(z.amount!=null)Q.amount=String(z.amount);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.denom="",J.amount="";if(z.denom!=null&&z.hasOwnProperty("denom"))J.denom=z.denom;if(z.amount!=null&&z.hasOwnProperty("amount"))J.amount=z.amount;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},L})(),X.IntProto=(()=>{function L(H){if(H){for(let z=Object.keys(H),Q=0;Q<z.length;++Q)if(H[z[Q]]!=null)this[z[Q]]=H[z[Q]]}}return L.prototype.int="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=f.create();if(z.int!=null&&Object.hasOwnProperty.call(z,"int"))Q.uint32(10).string(z.int);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof W))z=W.create(z);let J=Q===void 0?z.len:z.pos+Q,G=new q.cosmos.base.v1beta1.IntProto;while(z.pos<J){let _=z.uint32();switch(_>>>3){case 1:G.int=z.string();break;default:z.skipType(_&7);break}}return G},L.decodeDelimited=function(z){if(!(z instanceof W))z=new W(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.int!=null&&z.hasOwnProperty("int")){if(!B.isString(z.int))return"int: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.IntProto)return z;let Q=new q.cosmos.base.v1beta1.IntProto;if(z.int!=null)Q.int=String(z.int);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.int="";if(z.int!=null&&z.hasOwnProperty("int"))J.int=z.int;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},L})(),X.DecProto=(()=>{function L(H){if(H){for(let z=Object.keys(H),Q=0;Q<z.length;++Q)if(H[z[Q]]!=null)this[z[Q]]=H[z[Q]]}}return L.prototype.dec="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=f.create();if(z.dec!=null&&Object.hasOwnProperty.call(z,"dec"))Q.uint32(10).string(z.dec);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof W))z=W.create(z);let J=Q===void 0?z.len:z.pos+Q,G=new q.cosmos.base.v1beta1.DecProto;while(z.pos<J){let _=z.uint32();switch(_>>>3){case 1:G.dec=z.string();break;default:z.skipType(_&7);break}}return G},L.decodeDelimited=function(z){if(!(z instanceof W))z=new W(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.dec!=null&&z.hasOwnProperty("dec")){if(!B.isString(z.dec))return"dec: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.DecProto)return z;let Q=new q.cosmos.base.v1beta1.DecProto;if(z.dec!=null)Q.dec=String(z.dec);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.dec="";if(z.dec!=null&&z.hasOwnProperty("dec"))J.dec=z.dec;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},L})(),X})(),Z})(),Y})()});import{Chain as A4}from"@uswap/helpers";async function l(){let{$root:Y}=await Promise.resolve().then(() => (l6(),h6)),Z=await import("@cosmjs/proto-signing"),X=Z.Registry??Z.default?.Registry,L=await import("@cosmjs/stargate"),H=L.defaultRegistryTypes??L.default?.defaultRegistryTypes;return new X([...H,["/types.MsgSend",Y.types.MsgSend],["/types.MsgDeposit",Y.types.MsgDeposit]])}async function C(Y){let Z=await import("@cosmjs/stargate"),X=Z.AminoTypes??Z.default?.AminoTypes,L=Y===A4.THORChain?"thorchain":"mayachain";return new X({"/types.MsgDeposit":{aminoType:`${L}/MsgDeposit`,fromAmino:({signer:H,...z})=>({...z,signer:i(H)}),toAmino:({signer:H,...z})=>({...z,signer:o(H)})},"/types.MsgSend":{aminoType:`${L}/MsgSend`,fromAmino:({from_address:H,to_address:z,...Q})=>({...Q,fromAddress:i(H),toAddress:i(z)}),toAmino:({fromAddress:H,toAddress:z,...Q})=>({...Q,from_address:o(H),to_address:o(z)})}})}var I6=F(()=>{q6()});import{AssetValue as k4,Chain as L6,getChainConfig as j6,USwapError as R4}from"@uswap/helpers";function O6(Y){return function(X){let{assetValue:L,recipient:H,memo:z,sender:Q,asSignable:J,asAminoMessage:G}=X;if(H)return p6(Y)({asAminoMessage:G,asSignable:J,assetValue:L,memo:z,recipient:H,sender:Q});return c6(Y)({asAminoMessage:G,asSignable:J,assetValue:L,memo:z,sender:Q})}}function $(Y){if(Y.type==="thorchain/MsgSend"||Y.type==="mayachain/MsgSend")return Y;return{...Y,value:{...Y.value,coins:Y.value.coins.map((Z)=>{let X=k4.from({asset:Z.asset}),L=(X.isSynthetic?X.symbol.split("/")?.[1]:X.symbol)?.toUpperCase(),H=(X.isSynthetic?X.symbol.split("/")?.[0]:X.chain)?.toUpperCase();return{...Z,asset:{chain:H,symbol:L,synth:X.isSynthetic,ticker:X.ticker}}})}}}async function r({chain:Y,memo:Z,msgs:X}){let L=await l(),H=await C(Y),z={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:Z,messages:X.map((Q)=>H.fromAmino(Q))}};return L.encode(z)}var V4,M4,E6=({sender:Y,recipient:Z,assetValue:X})=>{return{type:`${X.chain===L6.Maya?"mayachain":"thorchain"}/MsgSend`,value:{amount:[{amount:X.getBaseValue("string"),denom:D(X.symbol,!0)}],from_address:Y,to_address:Z}}},N6=({sender:Y,assetValue:Z,memo:X=""})=>{return{type:`${Z.chain===L6.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:Z.getBaseValue("string"),asset:b(Z)}],memo:X,signer:Y}}},z6=({sender:Y,recipient:Z,assetValue:X,memo:L})=>{return!Z?N6({assetValue:X,memo:L,sender:Y}):E6({assetValue:X,recipient:Z,sender:Y})},w=async(Y,Z)=>{return(await C(Z)).fromAmino(Y)},b6=async({rpcUrl:Y,sender:Z})=>{let L=await(await P(Y)).getAccount(Z);if(!L)throw new R4("toolbox_cosmos_account_not_found",{sender:Z});return L},p6=(Y)=>async({sender:Z,recipient:X,assetValue:L,memo:H="",asSignable:z=!0,asAminoMessage:Q=!1,sequence:J,accountNumber:G})=>{let _=await b6({rpcUrl:Y,sender:Z}),v=L.chain,{chainId:A}=j6(v),T=E6({assetValue:L,recipient:X,sender:Z}),N=z?await w(Q?T:$(T),v):T;return{accountNumber:G||_.accountNumber,chainId:A,fee:S(v),memo:H,msgs:[N],sequence:J||_.sequence}},c6=(Y)=>async({sender:Z,assetValue:X,memo:L="",asSignable:H=!0,asAminoMessage:z=!1,sequence:Q,accountNumber:J})=>{let G=await b6({rpcUrl:Y,sender:Z}),_=X.chain,{chainId:v}=j6(_),A=N6({assetValue:X,memo:L,sender:Z}),T=H?await w(z?A:$(A),_):A;return{accountNumber:J||G.accountNumber,chainId:v,fee:S(_),memo:L,msgs:[T],sequence:Q||G.sequence}};var d6=F(()=>{t();I6();V4=S(L6.THORChain).gas,M4=S(L6.Maya).gas});var n6=()=>{};var m6=F(()=>{n6()});var x6=F(()=>{q6();d6();I6();m6()});import{base64 as k6,bech32 as K6}from"@scure/base";import{AssetValue as H6,applyFeeMultiplier as g6,Chain as V,CosmosChainPrefixes as a6,DerivationPath as F4,derivationPathToString as i6,FeeOption as Q6,getChainConfig as f4,getRPCUrl as y4,NetworkDerivationPath as D4,SwapKitNumber as U6,USwapError as Z6,updateDerivationPath as S4}from"@uswap/helpers";import{SwapKitApi as s6}from"@uswap/helpers/api";import{match as P4,P as o6}from"ts-pattern";async function V6(Y,Z){try{let L=(await s6.getGasRate()).find((H)=>H.chainId===Y)?.value;return L?Number.parseFloat(L):Z}catch{return Z}}async function R6({phrase:Y,prefix:Z,...X}){let L=await import("@cosmjs/proto-signing"),H=L.DirectSecp256k1HdWallet??L.default?.DirectSecp256k1HdWallet,z=await import("@cosmjs/crypto"),Q=z.stringToPath??z.default?.stringToPath,J="derivationPath"in X?X.derivationPath:`${F4[X.chain]}/${X.index}`;return H.fromMnemonic(Y,{hdPaths:[Q(J)],prefix:Z})}async function C4({privateKey:Y,prefix:Z}){let X=await import("@cosmjs/proto-signing");return(X.DirectSecp256k1Wallet??X.default?.DirectSecp256k1Wallet).fromKey(Y,Z)}function e6(Y){return async function({signature:X,message:L,address:H}){let z=await Y(H);if(!z?.pubkey)throw new Z6("toolbox_cosmos_verify_signature_no_pubkey");let Q=await import("@cosmjs/crypto"),J=Q.Secp256k1Signature??Q.default?.Secp256k1Signature,G=Q.Secp256k1??Q.default?.Secp256k1,_=J.fromFixedLength(k6.decode(X));return G.verifySignature(_,k6.decode(L),z.pubkey.value)}}async function a({chain:Y,...Z}){let X=await y4(Y),L=a6[Y],H="index"in Z?Z.index||0:0,z=i6("derivationPath"in Z&&Z.derivationPath?Z.derivationPath:S4(D4[Y],{index:H})),Q=await P4(Z).with({phrase:o6.string},({phrase:T})=>R6({derivationPath:z,phrase:T,prefix:L})).with({signer:o6.any},({signer:T})=>T).otherwise(()=>{return});async function J(T){return(await P(X)).getAccount(T)}async function G(){let[T]=await Q?.getAccounts()||[];return T?.address}async function _(){let[T]=await Q?.getAccounts()||[];if(!T?.pubkey)throw new Z6("toolbox_cosmos_signer_not_defined");return k6.encode(T?.pubkey)}async function v({recipient:T,assetValue:N,memo:E="",feeRate:x,feeOptionKey:O=Q6.Fast}){let R=await G();if(!(Q&&R))throw new Z6("toolbox_cosmos_signer_not_defined");let M=H6.from({chain:Y}),c=b(M),d=x||t6((await A6(Y,v6[Y]))[O],c),n=await p(X,Q),u=D(N.symbol),h=N.getBaseValue("string"),{TxRaw:m}=await import("cosmjs-types/cosmos/tx/v1beta1/tx"),g={amount:[{amount:h,denom:u}],fromAddress:R,toAddress:T},y6=await n.sign(R,[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:g}],d,E),Y6=m.encode(y6).finish();return Buffer.from(Y6).toString("hex")}async function A({recipient:T,assetValue:N,memo:E="",feeRate:x,feeOptionKey:O=Q6.Fast,dryRun:R=!1}){if(R)return v({assetValue:N,feeOptionKey:O,feeRate:x,memo:E,recipient:T});let M=await G();if(!(Q&&M))throw new Z6("toolbox_cosmos_signer_not_defined");let c=H6.from({chain:Y}),d=b(c),n=x||t6((await A6(Y,v6[Y]))[O],d),u=await p(X,Q),h=D(N.symbol),m=[{amount:N.getBaseValue("string"),denom:h}],{transactionHash:g}=await u.sendTokens(M,T,m,n,E);return g}return{createPrivateKeyFromPhrase:h4(z),createTransaction:T6,fetchFeeRateFromSwapKit:V6,getAccount:J,getAddress:G,getBalance:async(T,N)=>{let E=await r6(X)(T),x=await Promise.all(E.filter(({denom:O})=>O&&!O.includes("IBC/")).map(({denom:O,amount:R})=>{let M=[V.THORChain,V.Maya].includes(Y)&&(O.includes("/")||O.includes("˜"))?`${Y}.${O}`:O;return _6(M,R)}));if(x.length===0)return[H6.from({chain:Y})];return x},getBalanceAsDenoms:r6(X),getFees:()=>A6(Y,v6[Y]),getPubKey:_,getSignerFromPhrase:async({phrase:T,derivationPath:N})=>R6({derivationPath:i6(N),index:H,phrase:T,prefix:L}),getSignerFromPrivateKey:async(T)=>{let N=await import("@cosmjs/proto-signing");return(N.DirectSecp256k1Wallet??N.default?.DirectSecp256k1Wallet).fromKey(T,L)},signTransaction:v,transfer:A,validateAddress:L4(Y),verifySignature:e6(J)}}async function w4(Y,Z){try{let L=(await s6.getGasRate()).find((H)=>H.chainId===Y)?.value;return L?Number.parseFloat(L):Z}catch{return Z}}function $4({assetValue:{chain:Y}}){return H6.from({chain:Y,value:u4(Y)})}async function A6(Y,Z){let{chainId:X,baseDecimal:L}=f4(Y),H=await V6(X,Z);return{average:U6.fromBigInt(BigInt(H),L),fast:U6.fromBigInt(BigInt(g6(H,Q6.Fast,!0)),L),fastest:U6.fromBigInt(BigInt(g6(H,Q6.Fastest,!0)),L)}}function t6(Y,Z){return{amount:[{amount:Y.getBaseValue("string"),denom:Z}],gas:"200000"}}function u4(Y){return{[V.Cosmos]:0.007,[V.Kujira]:0.02,[V.Noble]:0.01,[V.THORChain]:0.02,[V.Maya]:0.02,[V.Harbor]:0.02}[Y]||0}function L4(Y){let Z=a6[Y];return function(L){if(!L.startsWith(Z))return!1;try{let{prefix:H,words:z}=K6.decode(L);return K6.encode(H,z)===L.toLocaleLowerCase()}catch{return!1}}}function r6(Y){return async function(X){return(await(await P(Y)).getAllBalances(X)).map((Q)=>({...Q,denom:Q.denom.includes("/")?Q.denom.toUpperCase():Q.denom}))}}function h4(Y){return async function(X){let L=await import("@cosmjs/crypto"),H=L.stringToPath??L.default?.stringToPath,z=L.Slip10Curve??L.default?.Slip10Curve,Q=L.Slip10??L.default?.Slip10,J=L.EnglishMnemonic??L.default?.EnglishMnemonic,G=L.Bip39??L.default?.Bip39,_=new J(X),v=await G.mnemonicToSeed(_),{privkey:A}=Q.derivePath(z.Secp256k1,v,H(Y));return A}}var v6;var X6=F(()=>{t();v6={[V.Cosmos]:1000,[V.Kujira]:1000,[V.Noble]:1000,[V.THORChain]:5000000,[V.Maya]:5000000,[V.Harbor]:5000000}});import{base64 as j}from"@scure/base";import{Chain as l4,CosmosChainPrefixes as j4,derivationPathToString as b4,FeeOption as M6,getChainConfig as z4,getRPCUrl as p4,NetworkDerivationPath as c4,RequestClient as d4,SKConfig as n4,SwapKitNumber as H4,USwapError as Z4,updateDerivationPath as m4}from"@uswap/helpers";import{match as g4,P as Q4}from"ts-pattern";function i4({prefix:Y,derivationPath:Z}){return async function(L,H=0){let z=await import("@cosmjs/amino"),Q=z.Secp256k1HdWallet??z.default?.Secp256k1HdWallet,J=await import("@cosmjs/crypto"),G=J.stringToPath??J.default?.stringToPath;return Q.fromMnemonic(L,{hdPaths:[G(`${Z}/${H}`)],prefix:Y})}}function o4(Y){return j.encode(Y)}function t4(Y){return async function({wallet:X,tx:L}){let{msgs:H,accountNumber:z,sequence:Q,chainId:J,fee:G,memo:_}=typeof L==="string"?JSON.parse(L):L,v=(await X.getAccounts())?.[0]?.address||"",A=await C(Y),T=await l(),N=await G6(X,{aminoTypes:A,registry:T}),E=[];for(let R of H){let M=await w(R,Y);E.push(M)}let{signatures:[x]}=await N.sign(v,E,G,_,{accountNumber:z,chainId:J,sequence:Q});return{bodyBytes:await r({chain:Y,memo:_,msgs:H.map($)}),signature:o4(x)}}}function r4({prefix:Y,rpcUrl:Z}){return async function(L,H,z,Q,J){let{encodeSecp256k1Pubkey:G,pubkeyToAddress:_}=(await import("@cosmjs/amino")).default,{makeMultisignedTxBytes:v}=(await import("@cosmjs/stargate")).default,{sequence:A,fee:T}=JSON.parse(L),N=await X4(z,Q),E=H.map((R)=>[_(G(j.decode(R.pubKey)),Y),j.decode(R.signature)]),x=await P(Z),{transactionHash:O}=await x.broadcastTx(v(N,A,T,J,new Map(E)));return O}}async function X4(Y,Z,X=!0){let{createMultisigThresholdPubkey:L,encodeSecp256k1Pubkey:H}=(await import("@cosmjs/amino")).default;return L(Y.map((z)=>H(j.decode(z))),Z,X)}function a4(Y){return j.decode(Y)}async function s4({privateKey:Y,message:Z}){let{Secp256k1:X}=(await import("@cosmjs/crypto")).default,L=await X.createSignature(j.decode(Z),Y);return j.encode(Buffer.concat([L.r(32),L.s(32)]))}async function F6({chain:Y,...Z}){let X=await p4(Y),{nodeUrl:L}=z4(Y),{isStagenet:H}=n4.get("envs"),z=Y===l4.THORChain,Q=`${H?"s":""}${j4[Y]}`,J="index"in Z?Z.index||0:0,G="derivationPath"in Z&&Z.derivationPath?Z.derivationPath:m4(c4[Y],{index:J}),_=await a({chain:Y,...Z}),v=await g4(Z).with({phrase:Q4.string},({phrase:E})=>_.getSignerFromPhrase({derivationPath:G,phrase:E})).with({signer:Q4.any},({signer:E})=>E).otherwise(()=>{return}),A=S(Y);async function T(){let E,x=`${L}/${z?"thorchain":"mayachain"}/constants`;try{let{int_64_values:{NativeTransactionFee:O}}=await d4.get(x);if(!O||Number.isNaN(O)||O<0)throw new Z4("toolbox_cosmos_invalid_fee",{nativeFee:O.toString()});E=new H4(O)}catch{E=new H4({decimal:z4(Y).baseDecimal,value:z?0.02:1})}return{[M6.Average]:E,[M6.Fast]:E,[M6.Fastest]:E}}async function N({assetValue:E,memo:x="",recipient:O}){let{TxRaw:R}=await import("cosmjs-types/cosmos/tx/v1beta1/tx"),M=(await v?.getAccounts())?.[0]?.address;if(!(M&&v))throw new Z4("toolbox_cosmos_no_signer");let c="signAmino"in v,d=await l(),n=await C(Y),u=await p(X,v,{aminoTypes:n,registry:d}),h=z6({assetValue:E,memo:x,recipient:O,sender:M});if(c){let Y6=await w(h,Y),{signatures:J4,authInfoBytes:q4}=await u.sign(M,[Y6],A,x),B4=R.encode({authInfoBytes:q4,bodyBytes:await r({chain:Y,memo:x,msgs:[h].map($)}),signatures:J4}).finish();return(await u.broadcastTx(B4)).transactionHash}let m=$(h),g=await w(m,Y);return(await u.signAndBroadcast(M,[g],A,x)).transactionHash}return{..._,broadcastMultisigTx:r4({prefix:Q,rpcUrl:X}),buildAminoMsg:z6,buildEncodedTxBody:r,convertToSignable:w,createDefaultAminoTypes:()=>C(Y),createDefaultRegistry:l,createMultisig:X4,createTransaction:O6(X),deposit:N,getFees:T,importSignature:a4,parseAminoMessageForDirectSigning:$,pubkeyToAddress:async(E)=>{let{pubkeyToAddress:x}=(await import("@cosmjs/amino")).default;return x(E,Q)},secp256k1HdWalletFromMnemonic:i4({derivationPath:b4(G),prefix:Q}),signMultisigTx:t4(Y),signWithPrivateKey:s4,transfer:N}}var f6=F(()=>{x6();t();X6()});import{Chain as s,USwapError as e4}from"@uswap/helpers";var L0=(Y,Z)=>{switch(Y){case s.Cosmos:case s.Kujira:case s.Noble:return a({chain:Y,...Z});case s.Maya:case s.THORChain:return F6({chain:Y,...Z});default:throw new e4("toolbox_cosmos_not_supported",{chain:Y})}};var Y4=F(()=>{X6();f6();X6();f6()});var H0={};D6(H0,{verifySignature:()=>e6,transferMsgAmino:()=>E6,toBase64:()=>O4,parseAminoMessageForDirectSigning:()=>$,getSignerFromPrivateKey:()=>C4,getSignerFromPhrase:()=>R6,getMsgSendDenom:()=>D,getFeeRateFromSwapKit:()=>w4,getDenomWithChain:()=>b,getDefaultChainFee:()=>S,getCreateTransaction:()=>O6,getCosmosValidateAddress:()=>L4,getCosmosToolbox:()=>L0,getAssetFromDenom:()=>_6,fromBase64:()=>x4,fetchFeeRateFromSwapKit:()=>V6,estimateTransactionFee:()=>$4,depositMsgAmino:()=>N6,createThorchainToolbox:()=>F6,createStargateClient:()=>P,createSigningStargateClient:()=>p,createOfflineStargateClient:()=>G6,createDefaultRegistry:()=>l,createDefaultAminoTypes:()=>C,createCosmosToolbox:()=>a,cosmosCreateTransaction:()=>T6,convertToSignable:()=>w,buildTransferTx:()=>p6,buildEncodedTxBody:()=>r,buildDepositTx:()=>c6,buildAminoMsg:()=>z6,bech32ToBase64:()=>i,base64ToBech32:()=>o,YUM_KUJIRA_FACTORY_DENOM:()=>C6,USK_KUJIRA_FACTORY_DENOM:()=>W6,THORCHAIN_GAS_VALUE:()=>V4,MAYA_GAS_VALUE:()=>M4,DEFAULT_NOBLE_FEE_MAINNET:()=>u6,DEFAULT_KUJI_FEE_MAINNET:()=>$6,DEFAULT_COSMOS_FEE_MAINNET:()=>w6});var Z0=F(()=>{x6();Y4();t()});Z0();export{e6 as verifySignature,E6 as transferMsgAmino,O4 as toBase64,$ as parseAminoMessageForDirectSigning,C4 as getSignerFromPrivateKey,R6 as getSignerFromPhrase,D as getMsgSendDenom,w4 as getFeeRateFromSwapKit,b as getDenomWithChain,S as getDefaultChainFee,O6 as getCreateTransaction,L4 as getCosmosValidateAddress,L0 as getCosmosToolbox,_6 as getAssetFromDenom,x4 as fromBase64,V6 as fetchFeeRateFromSwapKit,$4 as estimateTransactionFee,N6 as depositMsgAmino,F6 as createThorchainToolbox,P as createStargateClient,p as createSigningStargateClient,G6 as createOfflineStargateClient,l as createDefaultRegistry,C as createDefaultAminoTypes,a as createCosmosToolbox,T6 as cosmosCreateTransaction,w as convertToSignable,p6 as buildTransferTx,r as buildEncodedTxBody,c6 as buildDepositTx,z6 as buildAminoMsg,i as bech32ToBase64,o as base64ToBech32,C6 as YUM_KUJIRA_FACTORY_DENOM,W6 as USK_KUJIRA_FACTORY_DENOM,V4 as THORCHAIN_GAS_VALUE,M4 as MAYA_GAS_VALUE,u6 as DEFAULT_NOBLE_FEE_MAINNET,$6 as DEFAULT_KUJI_FEE_MAINNET,w6 as DEFAULT_COSMOS_FEE_MAINNET};
2
2
 
3
- //# debugId=431A0C344BB8557164756E2164756E21
3
+ //# debugId=14FED4B7B991A48F64756E2164756E21
4
4
  //# sourceMappingURL=index.js.map