@uswap/toolboxes 4.3.10 → 4.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cardano/index.cjs.map +2 -2
- package/dist/src/cardano/index.js.map +2 -2
- package/dist/src/cosmos/index.cjs +2 -2
- package/dist/src/cosmos/index.cjs.map +8 -8
- package/dist/src/cosmos/index.js +2 -2
- package/dist/src/cosmos/index.js.map +8 -8
- package/dist/src/evm/index.cjs +2 -2
- package/dist/src/evm/index.cjs.map +5 -5
- package/dist/src/evm/index.js +2 -2
- package/dist/src/evm/index.js.map +5 -5
- package/dist/src/index.cjs +3 -3
- package/dist/src/index.cjs.map +32 -32
- package/dist/src/index.js +3 -3
- package/dist/src/index.js.map +32 -32
- package/dist/src/near/index.cjs +2 -2
- package/dist/src/near/index.cjs.map +5 -5
- package/dist/src/near/index.js +2 -2
- package/dist/src/near/index.js.map +5 -5
- package/dist/src/radix/index.cjs +2 -2
- package/dist/src/radix/index.cjs.map +3 -3
- package/dist/src/radix/index.js +2 -2
- package/dist/src/radix/index.js.map +3 -3
- package/dist/src/ripple/index.cjs +2 -2
- package/dist/src/ripple/index.cjs.map +3 -3
- package/dist/src/ripple/index.js +2 -2
- package/dist/src/ripple/index.js.map +3 -3
- package/dist/src/solana/index.cjs.map +2 -2
- package/dist/src/solana/index.js.map +2 -2
- package/dist/src/substrate/index.cjs +2 -2
- package/dist/src/substrate/index.cjs.map +4 -4
- package/dist/src/substrate/index.js +2 -2
- package/dist/src/substrate/index.js.map +4 -4
- package/dist/src/sui/index.cjs.map +2 -2
- package/dist/src/sui/index.js.map +2 -2
- package/dist/src/ton/index.cjs +2 -2
- package/dist/src/ton/index.cjs.map +3 -3
- package/dist/src/ton/index.js +2 -2
- package/dist/src/ton/index.js.map +3 -3
- package/dist/src/tron/index.cjs.map +3 -3
- package/dist/src/tron/index.js.map +3 -3
- package/dist/src/utxo/index.cjs +3 -3
- package/dist/src/utxo/index.cjs.map +11 -11
- package/dist/src/utxo/index.js +3 -3
- package/dist/src/utxo/index.js.map +11 -11
- package/dist/types/cardano/toolbox.d.ts +0 -2
- package/dist/types/cardano/toolbox.d.ts.map +1 -1
- package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts +0 -2
- package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts.map +1 -1
- package/dist/types/cosmos/thorchainUtils/messages.d.ts +0 -2
- package/dist/types/cosmos/thorchainUtils/messages.d.ts.map +1 -1
- package/dist/types/cosmos/toolbox/cosmos.d.ts +4 -6
- package/dist/types/cosmos/toolbox/cosmos.d.ts.map +1 -1
- package/dist/types/cosmos/toolbox/index.d.ts +0 -2
- package/dist/types/cosmos/toolbox/index.d.ts.map +1 -1
- package/dist/types/cosmos/toolbox/thorchain.d.ts +4 -6
- package/dist/types/cosmos/toolbox/thorchain.d.ts.map +1 -1
- package/dist/types/cosmos/util.d.ts +0 -2
- package/dist/types/cosmos/util.d.ts.map +1 -1
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +0 -2
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts.map +1 -1
- package/dist/types/evm/toolbox/evm.d.ts.map +1 -1
- package/dist/types/evm/toolbox/op.d.ts +0 -2
- package/dist/types/evm/toolbox/op.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/near/helpers/core.d.ts +0 -2
- package/dist/types/near/helpers/core.d.ts.map +1 -1
- package/dist/types/near/toolbox.d.ts +0 -2
- package/dist/types/near/toolbox.d.ts.map +1 -1
- package/dist/types/radix/index.d.ts +2 -4
- package/dist/types/radix/index.d.ts.map +1 -1
- package/dist/types/ripple/index.d.ts +0 -2
- package/dist/types/ripple/index.d.ts.map +1 -1
- package/dist/types/solana/toolbox.d.ts +0 -2
- package/dist/types/solana/toolbox.d.ts.map +1 -1
- package/dist/types/substrate/balance.d.ts +3 -0
- package/dist/types/substrate/balance.d.ts.map +1 -1
- package/dist/types/substrate/substrate.d.ts +0 -2
- package/dist/types/substrate/substrate.d.ts.map +1 -1
- package/dist/types/sui/toolbox.d.ts +0 -2
- package/dist/types/sui/toolbox.d.ts.map +1 -1
- package/dist/types/ton/toolbox.d.ts +0 -2
- package/dist/types/ton/toolbox.d.ts.map +1 -1
- package/dist/types/tron/helpers/trongrid.d.ts +0 -2
- package/dist/types/tron/helpers/trongrid.d.ts.map +1 -1
- package/dist/types/tron/toolbox.d.ts +0 -2
- package/dist/types/tron/toolbox.d.ts.map +1 -1
- package/dist/types/utils.d.ts +3 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/utxo/helpers/api.d.ts +0 -2
- package/dist/types/utxo/helpers/api.d.ts.map +1 -1
- package/dist/types/utxo/helpers/bchaddrjs.d.ts +0 -2
- package/dist/types/utxo/helpers/bchaddrjs.d.ts.map +1 -1
- package/dist/types/utxo/helpers/coinselect.d.ts +0 -2
- package/dist/types/utxo/helpers/coinselect.d.ts.map +1 -1
- package/dist/types/utxo/helpers/txSize.d.ts +0 -2
- package/dist/types/utxo/helpers/txSize.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/bitcoinCash.d.ts +0 -2
- package/dist/types/utxo/toolbox/bitcoinCash.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/index.d.ts +0 -2
- package/dist/types/utxo/toolbox/index.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/utxo.d.ts +0 -2
- package/dist/types/utxo/toolbox/utxo.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/zcash.d.ts +0 -2
- package/dist/types/utxo/toolbox/zcash.d.ts.map +1 -1
- package/package.json +5 -11
- package/src/cardano/toolbox.ts +0 -2
- package/src/cosmos/thorchainUtils/addressFormat.ts +0 -2
- package/src/cosmos/thorchainUtils/messages.ts +0 -2
- package/src/cosmos/toolbox/cosmos.ts +9 -11
- package/src/cosmos/toolbox/index.ts +0 -2
- package/src/cosmos/toolbox/thorchain.ts +6 -8
- package/src/cosmos/util.ts +1 -3
- package/src/evm/__tests__/ethereum.test.ts +6 -2
- package/src/evm/toolbox/baseEVMToolbox.ts +4 -6
- package/src/evm/toolbox/op.ts +0 -2
- package/src/index.ts +0 -2
- package/src/near/helpers/core.ts +0 -2
- package/src/near/toolbox.ts +0 -2
- package/src/radix/index.ts +3 -5
- package/src/ripple/index.ts +2 -4
- package/src/solana/toolbox.ts +0 -2
- package/src/substrate/balance.ts +9 -5
- package/src/substrate/substrate.ts +2 -4
- package/src/sui/toolbox.ts +0 -2
- package/src/ton/toolbox.ts +2 -4
- package/src/tron/__tests__/toolbox.test.ts +6 -2
- package/src/tron/helpers/trongrid.ts +0 -2
- package/src/tron/toolbox.ts +1 -3
- package/src/utils.ts +6 -2
- package/src/utxo/helpers/api.ts +2 -4
- package/src/utxo/helpers/bchaddrjs.ts +0 -2
- package/src/utxo/helpers/coinselect.ts +0 -2
- package/src/utxo/helpers/txSize.ts +0 -2
- package/src/utxo/toolbox/bitcoinCash.ts +0 -2
- package/src/utxo/toolbox/index.ts +0 -2
- package/src/utxo/toolbox/utxo.ts +2 -4
- package/src/utxo/toolbox/zcash.ts +2 -4
package/dist/src/cosmos/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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};
|
|
1
|
+
var B4=Object.create;var{getPrototypeOf:G4,defineProperty:J6,getOwnPropertyNames:T4}=Object;var _4=Object.prototype.hasOwnProperty;var K=(Y,Z,X)=>{X=Y!=null?B4(G4(Y)):{};let z=Z||!Y||!Y.__esModule?J6(X,"default",{value:Y,enumerable:!0}):X;for(let L of T4(Y))if(!_4.call(z,L))J6(z,L,{get:()=>Y[L],enumerable:!0});return z};var D6=(Y,Z)=>{for(var X in Z)J6(Y,X,{get:Z[X],enumerable:!0,configurable:!0,set:(z)=>Z[X]=()=>z})};var F=(Y,Z)=>()=>(Y&&(Z=Y(Y=0)),Z);var v=((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 W6,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,z=typeof window<"u"?{}:{referer:"https://sdk.uswap.dev",referrer:"https://sdk.uswap.dev"};return X.connect({headers:z,url:Y})}async function p(Y,Z,X={}){let z=await import("@cosmjs/stargate"),L=z.SigningStargateClient??z.default?.SigningStargateClient,H=z.GasPrice??z.default?.GasPrice,Q=typeof X==="string"?X:"0.0003uatom",J=typeof X==="string"?{}:X;return L.connectWithSigner(Y,Z,{gasPrice:H.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:z="",feeRate:L,sequence:H,accountNumber:Q}){let{chain:J,chainId:G}=X,_=await K4(J),U=await(await P(_)).getAccount(Y);if(!U)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&&L?{amount:[{amount:L.toString(),denom:N}],gas:E.gas}:E,O={amount:[{amount:X.getBaseValue("string"),denom:D(X.symbol)}],fromAddress:Y,toAddress:Z};return{accountNumber:Q??U.accountNumber,chainId:G,fee:x,memo:z,msgs:[{typeUrl:v4(J),value:O}],sequence:H??U.sequence}}var B6="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 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: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)},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})}},A4,_6=(Y,Z)=>{let X=A4[Y.toLowerCase()];if(!X)return W6.from({asset:Y,fromBaseDecimal:8,value:Z});let{chain:z,asset:L,decimals:H}=X,Q=z?{chain:z}:{asset:L};return W6.from({...Q,fromBaseDecimal:H,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"};A4={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 Z(X){if(X){for(let z=Object.keys(X),L=0;L<z.length;++L)if(X[z[L]]!=null)this[z[L]]=X[z[L]]}}return Z.prototype.chain="",Z.prototype.symbol="",Z.prototype.ticker="",Z.prototype.synth=!1,Z.create=function(z){return new Z(z)},Z.encode=function(z,L){if(!L)L=f.create();if(z.chain!=null&&Object.hasOwnProperty.call(z,"chain"))L.uint32(10).string(z.chain);if(z.symbol!=null&&Object.hasOwnProperty.call(z,"symbol"))L.uint32(18).string(z.symbol);if(z.ticker!=null&&Object.hasOwnProperty.call(z,"ticker"))L.uint32(26).string(z.ticker);if(z.synth!=null&&Object.hasOwnProperty.call(z,"synth"))L.uint32(32).bool(z.synth);return L},Z.encodeDelimited=function(z,L){return this.encode(z,L).ldelim()},Z.decode=function(z,L){if(!(z instanceof B))z=B.create(z);let H=L===void 0?z.len:z.pos+L,Q=new q.common.Asset;while(z.pos<H){let J=z.uint32();switch(J>>>3){case 1:Q.chain=z.string();break;case 2:Q.symbol=z.string();break;case 3:Q.ticker=z.string();break;case 4:Q.synth=z.bool();break;default:z.skipType(J&7);break}}return Q},Z.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},Z.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.chain!=null&&z.hasOwnProperty("chain")){if(!W.isString(z.chain))return"chain: string expected"}if(z.symbol!=null&&z.hasOwnProperty("symbol")){if(!W.isString(z.symbol))return"symbol: string expected"}if(z.ticker!=null&&z.hasOwnProperty("ticker")){if(!W.isString(z.ticker))return"ticker: string expected"}if(z.synth!=null&&z.hasOwnProperty("synth")){if(typeof z.synth!=="boolean")return"synth: boolean expected"}return null},Z.fromObject=function(z){if(z instanceof q.common.Asset)return z;let L=new q.common.Asset;if(z.chain!=null)L.chain=String(z.chain);if(z.symbol!=null)L.symbol=String(z.symbol);if(z.ticker!=null)L.ticker=String(z.ticker);if(z.synth!=null)L.synth=Boolean(z.synth);return L},Z.toObject=function(z,L){if(!L)L={};let H={};if(L.defaults)H.chain="",H.symbol="",H.ticker="",H.synth=!1;if(z.chain!=null&&z.hasOwnProperty("chain"))H.chain=z.chain;if(z.symbol!=null&&z.hasOwnProperty("symbol"))H.symbol=z.symbol;if(z.ticker!=null&&z.hasOwnProperty("ticker"))H.ticker=z.ticker;if(z.synth!=null&&z.hasOwnProperty("synth"))H.synth=z.synth;return H},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.Coin=(()=>{function Z(X){if(X){for(let z=Object.keys(X),L=0;L<z.length;++L)if(X[z[L]]!=null)this[z[L]]=X[z[L]]}}return Z.prototype.asset=null,Z.prototype.amount="",Z.prototype.decimals=W.Long?W.Long.fromBits(0,0,!1):0,Z.create=function(z){return new Z(z)},Z.encode=function(z,L){if(!L)L=f.create();if(z.asset!=null&&Object.hasOwnProperty.call(z,"asset"))q.common.Asset.encode(z.asset,L.uint32(10).fork()).ldelim();if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))L.uint32(18).string(z.amount);if(z.decimals!=null&&Object.hasOwnProperty.call(z,"decimals"))L.uint32(24).int64(z.decimals);return L},Z.encodeDelimited=function(z,L){return this.encode(z,L).ldelim()},Z.decode=function(z,L){if(!(z instanceof B))z=B.create(z);let H=L===void 0?z.len:z.pos+L,Q=new q.common.Coin;while(z.pos<H){let J=z.uint32();switch(J>>>3){case 1:Q.asset=q.common.Asset.decode(z,z.uint32());break;case 2:Q.amount=z.string();break;case 3:Q.decimals=z.int64();break;default:z.skipType(J&7);break}}return Q},Z.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},Z.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.asset!=null&&z.hasOwnProperty("asset")){let L=q.common.Asset.verify(z.asset);if(L)return"asset."+L}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!W.isString(z.amount))return"amount: string expected"}if(z.decimals!=null&&z.hasOwnProperty("decimals")){if(!W.isInteger(z.decimals)&&!(z.decimals&&W.isInteger(z.decimals.low)&&W.isInteger(z.decimals.high)))return"decimals: integer|Long expected"}return null},Z.fromObject=function(z){if(z instanceof q.common.Coin)return z;let L=new q.common.Coin;if(z.asset!=null){if(typeof z.asset!=="object")throw TypeError(".common.Coin.asset: object expected");L.asset=q.common.Asset.fromObject(z.asset)}if(z.amount!=null)L.amount=String(z.amount);if(z.decimals!=null){if(W.Long)(L.decimals=W.Long.fromValue(z.decimals)).unsigned=!1;else if(typeof z.decimals==="string")L.decimals=Number.parseInt(z.decimals,10);else if(typeof z.decimals==="number")L.decimals=z.decimals;else if(typeof z.decimals==="object")L.decimals=new W.LongBits(z.decimals.low>>>0,z.decimals.high>>>0).toNumber()}return L},Z.toObject=function(z,L){if(!L)L={};let H={};if(L.defaults)if(H.asset=null,H.amount="",W.Long){let Q=new W.Long(0,0,!1);H.decimals=L.longs===String?Q.toString():L.longs===Number?Q.toNumber():Q}else H.decimals=L.longs===String?"0":0;if(z.asset!=null&&z.hasOwnProperty("asset"))H.asset=q.common.Asset.toObject(z.asset,L);if(z.amount!=null&&z.hasOwnProperty("amount"))H.amount=z.amount;if(z.decimals!=null&&z.hasOwnProperty("decimals"))if(typeof z.decimals==="number")H.decimals=L.longs===String?String(z.decimals):z.decimals;else H.decimals=L.longs===String?W.Long.prototype.toString.call(z.decimals):L.longs===Number?new W.LongBits(z.decimals.low>>>0,z.decimals.high>>>0).toNumber():z.decimals;return H},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.PubKeySet=(()=>{function Z(X){if(X){for(let z=Object.keys(X),L=0;L<z.length;++L)if(X[z[L]]!=null)this[z[L]]=X[z[L]]}}return Z.prototype.secp256k1="",Z.prototype.ed25519="",Z.create=function(z){return new Z(z)},Z.encode=function(z,L){if(!L)L=f.create();if(z.secp256k1!=null&&Object.hasOwnProperty.call(z,"secp256k1"))L.uint32(10).string(z.secp256k1);if(z.ed25519!=null&&Object.hasOwnProperty.call(z,"ed25519"))L.uint32(18).string(z.ed25519);return L},Z.encodeDelimited=function(z,L){return this.encode(z,L).ldelim()},Z.decode=function(z,L){if(!(z instanceof B))z=B.create(z);let H=L===void 0?z.len:z.pos+L,Q=new q.common.PubKeySet;while(z.pos<H){let J=z.uint32();switch(J>>>3){case 1:Q.secp256k1=z.string();break;case 2:Q.ed25519=z.string();break;default:z.skipType(J&7);break}}return Q},Z.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},Z.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.secp256k1!=null&&z.hasOwnProperty("secp256k1")){if(!W.isString(z.secp256k1))return"secp256k1: string expected"}if(z.ed25519!=null&&z.hasOwnProperty("ed25519")){if(!W.isString(z.ed25519))return"ed25519: string expected"}return null},Z.fromObject=function(z){if(z instanceof q.common.PubKeySet)return z;let L=new q.common.PubKeySet;if(z.secp256k1!=null)L.secp256k1=String(z.secp256k1);if(z.ed25519!=null)L.ed25519=String(z.ed25519);return L},Z.toObject=function(z,L){if(!L)L={};let H={};if(L.defaults)H.secp256k1="",H.ed25519="";if(z.secp256k1!=null&&z.hasOwnProperty("secp256k1"))H.secp256k1=z.secp256k1;if(z.ed25519!=null&&z.hasOwnProperty("ed25519"))H.ed25519=z.ed25519;return H},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 z=Object.keys(X),L=0;L<z.length;++L)if(X[z[L]]!=null)this[z[L]]=X[z[L]]}}return Z.prototype.id="",Z.prototype.chain="",Z.prototype.fromAddress="",Z.prototype.toAddress="",Z.prototype.coins=W.emptyArray,Z.prototype.gas=W.emptyArray,Z.prototype.memo="",Z.create=function(z){return new Z(z)},Z.encode=function(z,L){if(!L)L=f.create();if(z.id!=null&&Object.hasOwnProperty.call(z,"id"))L.uint32(10).string(z.id);if(z.chain!=null&&Object.hasOwnProperty.call(z,"chain"))L.uint32(18).string(z.chain);if(z.fromAddress!=null&&Object.hasOwnProperty.call(z,"fromAddress"))L.uint32(26).string(z.fromAddress);if(z.toAddress!=null&&Object.hasOwnProperty.call(z,"toAddress"))L.uint32(34).string(z.toAddress);if(z.coins?.length)for(let H=0;H<z.coins.length;++H)q.common.Coin.encode(z.coins[H],L.uint32(42).fork()).ldelim();if(z.gas?.length)for(let H=0;H<z.gas.length;++H)q.common.Coin.encode(z.gas[H],L.uint32(50).fork()).ldelim();if(z.memo!=null&&Object.hasOwnProperty.call(z,"memo"))L.uint32(58).string(z.memo);return L},Z.encodeDelimited=function(z,L){return this.encode(z,L).ldelim()},Z.decode=function(z,L){if(!(z instanceof B))z=B.create(z);let H=L===void 0?z.len:z.pos+L,Q=new q.common.Tx;while(z.pos<H){let J=z.uint32();switch(J>>>3){case 1:Q.id=z.string();break;case 2:Q.chain=z.string();break;case 3:Q.fromAddress=z.string();break;case 4:Q.toAddress=z.string();break;case 5:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(z,z.uint32()));break;case 6:if(!Q.gas?.length)Q.gas=[];Q.gas.push(q.common.Coin.decode(z,z.uint32()));break;case 7:Q.memo=z.string();break;default:z.skipType(J&7);break}}return Q},Z.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},Z.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.id!=null&&z.hasOwnProperty("id")){if(!W.isString(z.id))return"id: string expected"}if(z.chain!=null&&z.hasOwnProperty("chain")){if(!W.isString(z.chain))return"chain: string expected"}if(z.fromAddress!=null&&z.hasOwnProperty("fromAddress")){if(!W.isString(z.fromAddress))return"fromAddress: string expected"}if(z.toAddress!=null&&z.hasOwnProperty("toAddress")){if(!W.isString(z.toAddress))return"toAddress: string expected"}if(z.coins!=null&&z.hasOwnProperty("coins")){if(!Array.isArray(z.coins))return"coins: array expected";for(let L=0;L<z.coins.length;++L){let H=q.common.Coin.verify(z.coins[L]);if(H)return"coins."+H}}if(z.gas!=null&&z.hasOwnProperty("gas")){if(!Array.isArray(z.gas))return"gas: array expected";for(let L=0;L<z.gas.length;++L){let H=q.common.Coin.verify(z.gas[L]);if(H)return"gas."+H}}if(z.memo!=null&&z.hasOwnProperty("memo")){if(!W.isString(z.memo))return"memo: string expected"}return null},Z.fromObject=function(z){if(z instanceof q.common.Tx)return z;let L=new q.common.Tx;if(z.id!=null)L.id=String(z.id);if(z.chain!=null)L.chain=String(z.chain);if(z.fromAddress!=null)L.fromAddress=String(z.fromAddress);if(z.toAddress!=null)L.toAddress=String(z.toAddress);if(z.coins){if(!Array.isArray(z.coins))throw TypeError(".common.Tx.coins: array expected");L.coins=[];for(let H=0;H<z.coins.length;++H){if(typeof z.coins[H]!=="object")throw TypeError(".common.Tx.coins: object expected");L.coins[H]=q.common.Coin.fromObject(z.coins[H])}}if(z.gas){if(!Array.isArray(z.gas))throw TypeError(".common.Tx.gas: array expected");L.gas=[];for(let H=0;H<z.gas.length;++H){if(typeof z.gas[H]!=="object")throw TypeError(".common.Tx.gas: object expected");L.gas[H]=q.common.Coin.fromObject(z.gas[H])}}if(z.memo!=null)L.memo=String(z.memo);return L},Z.toObject=function(z,L){if(!L)L={};let H={};if(L.arrays||L.defaults)H.coins=[],H.gas=[];if(L.defaults)H.id="",H.chain="",H.fromAddress="",H.toAddress="",H.memo="";if(z.id!=null&&z.hasOwnProperty("id"))H.id=z.id;if(z.chain!=null&&z.hasOwnProperty("chain"))H.chain=z.chain;if(z.fromAddress!=null&&z.hasOwnProperty("fromAddress"))H.fromAddress=z.fromAddress;if(z.toAddress!=null&&z.hasOwnProperty("toAddress"))H.toAddress=z.toAddress;if(z.coins?.length){H.coins=[];for(let Q=0;Q<z.coins.length;++Q)H.coins[Q]=q.common.Coin.toObject(z.coins[Q],L)}if(z.gas?.length){H.gas=[];for(let Q=0;Q<z.gas.length;++Q)H.gas[Q]=q.common.Coin.toObject(z.gas[Q],L)}if(z.memo!=null&&z.hasOwnProperty("memo"))H.memo=z.memo;return H},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.Fee=(()=>{function Z(X){if(this.coins=[],X){for(let z=Object.keys(X),L=0;L<z.length;++L)if(X[z[L]]!=null)this[z[L]]=X[z[L]]}}return Z.prototype.coins=W.emptyArray,Z.prototype.poolDeduct="",Z.create=function(z){return new Z(z)},Z.encode=function(z,L){if(!L)L=f.create();if(z.coins?.length)for(let H=0;H<z.coins.length;++H)q.common.Coin.encode(z.coins[H],L.uint32(10).fork()).ldelim();if(z.poolDeduct!=null&&Object.hasOwnProperty.call(z,"poolDeduct"))L.uint32(18).string(z.poolDeduct);return L},Z.encodeDelimited=function(z,L){return this.encode(z,L).ldelim()},Z.decode=function(z,L){if(!(z instanceof B))z=B.create(z);let H=L===void 0?z.len:z.pos+L,Q=new q.common.Fee;while(z.pos<H){let J=z.uint32();switch(J>>>3){case 1:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(z,z.uint32()));break;case 2:Q.poolDeduct=z.string();break;default:z.skipType(J&7);break}}return Q},Z.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},Z.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.coins!=null&&z.hasOwnProperty("coins")){if(!Array.isArray(z.coins))return"coins: array expected";for(let L=0;L<z.coins.length;++L){let H=q.common.Coin.verify(z.coins[L]);if(H)return"coins."+H}}if(z.poolDeduct!=null&&z.hasOwnProperty("poolDeduct")){if(!W.isString(z.poolDeduct))return"poolDeduct: string expected"}return null},Z.fromObject=function(z){if(z instanceof q.common.Fee)return z;let L=new q.common.Fee;if(z.coins){if(!Array.isArray(z.coins))throw TypeError(".common.Fee.coins: array expected");L.coins=[];for(let H=0;H<z.coins.length;++H){if(typeof z.coins[H]!=="object")throw TypeError(".common.Fee.coins: object expected");L.coins[H]=q.common.Coin.fromObject(z.coins[H])}}if(z.poolDeduct!=null)L.poolDeduct=String(z.poolDeduct);return L},Z.toObject=function(z,L){if(!L)L={};let H={};if(L.arrays||L.defaults)H.coins=[];if(L.defaults)H.poolDeduct="";if(z.coins?.length){H.coins=[];for(let Q=0;Q<z.coins.length;++Q)H.coins[Q]=q.common.Coin.toObject(z.coins[Q],L)}if(z.poolDeduct!=null&&z.hasOwnProperty("poolDeduct"))H.poolDeduct=z.poolDeduct;return H},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.ProtoUint=(()=>{function Z(X){if(X){for(let z=Object.keys(X),L=0;L<z.length;++L)if(X[z[L]]!=null)this[z[L]]=X[z[L]]}}return Z.prototype.value="",Z.create=function(z){return new Z(z)},Z.encode=function(z,L){if(!L)L=f.create();if(z.value!=null&&Object.hasOwnProperty.call(z,"value"))L.uint32(10).string(z.value);return L},Z.encodeDelimited=function(z,L){return this.encode(z,L).ldelim()},Z.decode=function(z,L){if(!(z instanceof B))z=B.create(z);let H=L===void 0?z.len:z.pos+L,Q=new q.common.ProtoUint;while(z.pos<H){let J=z.uint32();switch(J>>>3){case 1:Q.value=z.string();break;default:z.skipType(J&7);break}}return Q},Z.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},Z.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.value!=null&&z.hasOwnProperty("value")){if(!W.isString(z.value))return"value: string expected"}return null},Z.fromObject=function(z){if(z instanceof q.common.ProtoUint)return z;let L=new q.common.ProtoUint;if(z.value!=null)L.value=String(z.value);return L},Z.toObject=function(z,L){if(!L)L={};let H={};if(L.defaults)H.value="";if(z.value!=null&&z.hasOwnProperty("value"))H.value=z.value;return H},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 z=Object.keys(X),L=0;L<z.length;++L)if(X[z[L]]!=null)this[z[L]]=X[z[L]]}}return Z.prototype.coins=W.emptyArray,Z.prototype.memo="",Z.prototype.signer=W.newBuffer([]),Z.create=function(z){return new Z(z)},Z.encode=function(z,L){if(!L)L=f.create();if(z.coins?.length)for(let H=0;H<z.coins.length;++H)q.common.Coin.encode(z.coins[H],L.uint32(10).fork()).ldelim();if(z.memo!=null&&Object.hasOwnProperty.call(z,"memo"))L.uint32(18).string(z.memo);if(z.signer!=null&&Object.hasOwnProperty.call(z,"signer"))L.uint32(26).bytes(z.signer);return L},Z.encodeDelimited=function(z,L){return this.encode(z,L).ldelim()},Z.decode=function(z,L){if(!(z instanceof B))z=B.create(z);let H=L===void 0?z.len:z.pos+L,Q=new q.types.MsgDeposit;while(z.pos<H){let J=z.uint32();switch(J>>>3){case 1:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(z,z.uint32()));break;case 2:Q.memo=z.string();break;case 3:Q.signer=z.bytes();break;default:z.skipType(J&7);break}}return Q},Z.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},Z.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.coins!=null&&z.hasOwnProperty("coins")){if(!Array.isArray(z.coins))return"coins: array expected";for(let L=0;L<z.coins.length;++L){let H=q.common.Coin.verify(z.coins[L]);if(H)return"coins."+H}}if(z.memo!=null&&z.hasOwnProperty("memo")){if(!W.isString(z.memo))return"memo: string expected"}if(z.signer!=null&&z.hasOwnProperty("signer")){if(!(z.signer&&typeof z.signer.length==="number"||W.isString(z.signer)))return"signer: buffer expected"}return null},Z.fromObject=function(z){if(z instanceof q.types.MsgDeposit)return z;let L=new q.types.MsgDeposit;if(z.coins){if(!Array.isArray(z.coins))throw TypeError(".types.MsgDeposit.coins: array expected");L.coins=[];for(let H=0;H<z.coins.length;++H){if(typeof z.coins[H]!=="object")throw TypeError(".types.MsgDeposit.coins: object expected");L.coins[H]=q.common.Coin.fromObject(z.coins[H])}}if(z.memo!=null)L.memo=String(z.memo);if(z.signer!=null){if(typeof z.signer==="string")W.base64.decode(z.signer,L.signer=W.newBuffer(W.base64.length(z.signer)),0);else if(z.signer.length)L.signer=z.signer}return L},Z.toObject=function(z,L){if(!L)L={};let H={};if(L.arrays||L.defaults)H.coins=[];if(L.defaults){if(H.memo="",L.bytes===String)H.signer="";else if(H.signer=[],L.bytes!==Array)H.signer=W.newBuffer(H.signer)}if(z.coins?.length){H.coins=[];for(let Q=0;Q<z.coins.length;++Q)H.coins[Q]=q.common.Coin.toObject(z.coins[Q],L)}if(z.memo!=null&&z.hasOwnProperty("memo"))H.memo=z.memo;if(z.signer!=null&&z.hasOwnProperty("signer"))H.signer=L.bytes===String?W.base64.encode(z.signer,0,z.signer.length):L.bytes===Array?Array.prototype.slice.call(z.signer):z.signer;return H},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),Y.MsgSend=(()=>{function Z(X){if(this.amount=[],X){for(let z=Object.keys(X),L=0;L<z.length;++L)if(X[z[L]]!=null)this[z[L]]=X[z[L]]}}return Z.prototype.fromAddress=W.newBuffer([]),Z.prototype.toAddress=W.newBuffer([]),Z.prototype.amount=W.emptyArray,Z.create=function(z){return new Z(z)},Z.encode=function(z,L){if(!L)L=f.create();if(z.fromAddress!=null&&Object.hasOwnProperty.call(z,"fromAddress"))L.uint32(10).bytes(z.fromAddress);if(z.toAddress!=null&&Object.hasOwnProperty.call(z,"toAddress"))L.uint32(18).bytes(z.toAddress);if(z.amount?.length)for(let H=0;H<z.amount.length;++H)q.cosmos.base.v1beta1.Coin.encode(z.amount[H],L.uint32(26).fork()).ldelim();return L},Z.encodeDelimited=function(z,L){return this.encode(z,L).ldelim()},Z.decode=function(z,L){if(!(z instanceof B))z=B.create(z);let H=L===void 0?z.len:z.pos+L,Q=new q.types.MsgSend;while(z.pos<H){let J=z.uint32();switch(J>>>3){case 1:Q.fromAddress=z.bytes();break;case 2:Q.toAddress=z.bytes();break;case 3:if(!Q.amount?.length)Q.amount=[];Q.amount.push(q.cosmos.base.v1beta1.Coin.decode(z,z.uint32()));break;default:z.skipType(J&7);break}}return Q},Z.decodeDelimited=function(z){if(!(z instanceof B))z=new B(z);return this.decode(z,z.uint32())},Z.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.fromAddress!=null&&z.hasOwnProperty("fromAddress")){if(!(z.fromAddress&&typeof z.fromAddress.length==="number"||W.isString(z.fromAddress)))return"fromAddress: buffer expected"}if(z.toAddress!=null&&z.hasOwnProperty("toAddress")){if(!(z.toAddress&&typeof z.toAddress.length==="number"||W.isString(z.toAddress)))return"toAddress: buffer expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!Array.isArray(z.amount))return"amount: array expected";for(let L=0;L<z.amount.length;++L){let H=q.cosmos.base.v1beta1.Coin.verify(z.amount[L]);if(H)return"amount."+H}}return null},Z.fromObject=function(z){if(z instanceof q.types.MsgSend)return z;let L=new q.types.MsgSend;if(z.fromAddress!=null){if(typeof z.fromAddress==="string")W.base64.decode(z.fromAddress,L.fromAddress=W.newBuffer(W.base64.length(z.fromAddress)),0);else if(z.fromAddress.length)L.fromAddress=z.fromAddress}if(z.toAddress!=null){if(typeof z.toAddress==="string")W.base64.decode(z.toAddress,L.toAddress=W.newBuffer(W.base64.length(z.toAddress)),0);else if(z.toAddress.length)L.toAddress=z.toAddress}if(z.amount){if(!Array.isArray(z.amount))throw TypeError(".types.MsgSend.amount: array expected");L.amount=[];for(let H=0;H<z.amount.length;++H){if(typeof z.amount[H]!=="object")throw TypeError(".types.MsgSend.amount: object expected");L.amount[H]=q.cosmos.base.v1beta1.Coin.fromObject(z.amount[H])}}return L},Z.toObject=function(z,L){if(!L)L={};let H={};if(L.arrays||L.defaults)H.amount=[];if(L.defaults){if(L.bytes===String)H.fromAddress="";else if(H.fromAddress=[],L.bytes!==Array)H.fromAddress=W.newBuffer(H.fromAddress);if(L.bytes===String)H.toAddress="";else if(H.toAddress=[],L.bytes!==Array)H.toAddress=W.newBuffer(H.toAddress)}if(z.fromAddress!=null&&z.hasOwnProperty("fromAddress"))H.fromAddress=L.bytes===String?W.base64.encode(z.fromAddress,0,z.fromAddress.length):L.bytes===Array?Array.prototype.slice.call(z.fromAddress):z.fromAddress;if(z.toAddress!=null&&z.hasOwnProperty("toAddress"))H.toAddress=L.bytes===String?W.base64.encode(z.toAddress,0,z.toAddress.length):L.bytes===Array?Array.prototype.slice.call(z.toAddress):z.toAddress;if(z.amount?.length){H.amount=[];for(let Q=0;Q<z.amount.length;++Q)H.amount[Q]=q.cosmos.base.v1beta1.Coin.toObject(z.amount[Q],L)}return H},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 z(L){if(L){for(let H=Object.keys(L),Q=0;Q<H.length;++Q)if(L[H[Q]]!=null)this[H[Q]]=L[H[Q]]}}return z.prototype.denom="",z.prototype.amount="",z.create=function(H){return new z(H)},z.encode=function(H,Q){if(!Q)Q=f.create();if(H.denom!=null&&Object.hasOwnProperty.call(H,"denom"))Q.uint32(10).string(H.denom);if(H.amount!=null&&Object.hasOwnProperty.call(H,"amount"))Q.uint32(18).string(H.amount);return Q},z.encodeDelimited=function(H,Q){return this.encode(H,Q).ldelim()},z.decode=function(H,Q){if(!(H instanceof B))H=B.create(H);let J=Q===void 0?H.len:H.pos+Q,G=new q.cosmos.base.v1beta1.Coin;while(H.pos<J){let _=H.uint32();switch(_>>>3){case 1:G.denom=H.string();break;case 2:G.amount=H.string();break;default:H.skipType(_&7);break}}return G},z.decodeDelimited=function(H){if(!(H instanceof B))H=new B(H);return this.decode(H,H.uint32())},z.verify=function(H){if(typeof H!=="object"||H===null)return"object expected";if(H.denom!=null&&H.hasOwnProperty("denom")){if(!W.isString(H.denom))return"denom: string expected"}if(H.amount!=null&&H.hasOwnProperty("amount")){if(!W.isString(H.amount))return"amount: string expected"}return null},z.fromObject=function(H){if(H instanceof q.cosmos.base.v1beta1.Coin)return H;let Q=new q.cosmos.base.v1beta1.Coin;if(H.denom!=null)Q.denom=String(H.denom);if(H.amount!=null)Q.amount=String(H.amount);return Q},z.toObject=function(H,Q){if(!Q)Q={};let J={};if(Q.defaults)J.denom="",J.amount="";if(H.denom!=null&&H.hasOwnProperty("denom"))J.denom=H.denom;if(H.amount!=null&&H.hasOwnProperty("amount"))J.amount=H.amount;return J},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),X.DecCoin=(()=>{function z(L){if(L){for(let H=Object.keys(L),Q=0;Q<H.length;++Q)if(L[H[Q]]!=null)this[H[Q]]=L[H[Q]]}}return z.prototype.denom="",z.prototype.amount="",z.create=function(H){return new z(H)},z.encode=function(H,Q){if(!Q)Q=f.create();if(H.denom!=null&&Object.hasOwnProperty.call(H,"denom"))Q.uint32(10).string(H.denom);if(H.amount!=null&&Object.hasOwnProperty.call(H,"amount"))Q.uint32(18).string(H.amount);return Q},z.encodeDelimited=function(H,Q){return this.encode(H,Q).ldelim()},z.decode=function(H,Q){if(!(H instanceof B))H=B.create(H);let J=Q===void 0?H.len:H.pos+Q,G=new q.cosmos.base.v1beta1.DecCoin;while(H.pos<J){let _=H.uint32();switch(_>>>3){case 1:G.denom=H.string();break;case 2:G.amount=H.string();break;default:H.skipType(_&7);break}}return G},z.decodeDelimited=function(H){if(!(H instanceof B))H=new B(H);return this.decode(H,H.uint32())},z.verify=function(H){if(typeof H!=="object"||H===null)return"object expected";if(H.denom!=null&&H.hasOwnProperty("denom")){if(!W.isString(H.denom))return"denom: string expected"}if(H.amount!=null&&H.hasOwnProperty("amount")){if(!W.isString(H.amount))return"amount: string expected"}return null},z.fromObject=function(H){if(H instanceof q.cosmos.base.v1beta1.DecCoin)return H;let Q=new q.cosmos.base.v1beta1.DecCoin;if(H.denom!=null)Q.denom=String(H.denom);if(H.amount!=null)Q.amount=String(H.amount);return Q},z.toObject=function(H,Q){if(!Q)Q={};let J={};if(Q.defaults)J.denom="",J.amount="";if(H.denom!=null&&H.hasOwnProperty("denom"))J.denom=H.denom;if(H.amount!=null&&H.hasOwnProperty("amount"))J.amount=H.amount;return J},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),X.IntProto=(()=>{function z(L){if(L){for(let H=Object.keys(L),Q=0;Q<H.length;++Q)if(L[H[Q]]!=null)this[H[Q]]=L[H[Q]]}}return z.prototype.int="",z.create=function(H){return new z(H)},z.encode=function(H,Q){if(!Q)Q=f.create();if(H.int!=null&&Object.hasOwnProperty.call(H,"int"))Q.uint32(10).string(H.int);return Q},z.encodeDelimited=function(H,Q){return this.encode(H,Q).ldelim()},z.decode=function(H,Q){if(!(H instanceof B))H=B.create(H);let J=Q===void 0?H.len:H.pos+Q,G=new q.cosmos.base.v1beta1.IntProto;while(H.pos<J){let _=H.uint32();switch(_>>>3){case 1:G.int=H.string();break;default:H.skipType(_&7);break}}return G},z.decodeDelimited=function(H){if(!(H instanceof B))H=new B(H);return this.decode(H,H.uint32())},z.verify=function(H){if(typeof H!=="object"||H===null)return"object expected";if(H.int!=null&&H.hasOwnProperty("int")){if(!W.isString(H.int))return"int: string expected"}return null},z.fromObject=function(H){if(H instanceof q.cosmos.base.v1beta1.IntProto)return H;let Q=new q.cosmos.base.v1beta1.IntProto;if(H.int!=null)Q.int=String(H.int);return Q},z.toObject=function(H,Q){if(!Q)Q={};let J={};if(Q.defaults)J.int="";if(H.int!=null&&H.hasOwnProperty("int"))J.int=H.int;return J},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),X.DecProto=(()=>{function z(L){if(L){for(let H=Object.keys(L),Q=0;Q<H.length;++Q)if(L[H[Q]]!=null)this[H[Q]]=L[H[Q]]}}return z.prototype.dec="",z.create=function(H){return new z(H)},z.encode=function(H,Q){if(!Q)Q=f.create();if(H.dec!=null&&Object.hasOwnProperty.call(H,"dec"))Q.uint32(10).string(H.dec);return Q},z.encodeDelimited=function(H,Q){return this.encode(H,Q).ldelim()},z.decode=function(H,Q){if(!(H instanceof B))H=B.create(H);let J=Q===void 0?H.len:H.pos+Q,G=new q.cosmos.base.v1beta1.DecProto;while(H.pos<J){let _=H.uint32();switch(_>>>3){case 1:G.dec=H.string();break;default:H.skipType(_&7);break}}return G},z.decodeDelimited=function(H){if(!(H instanceof B))H=new B(H);return this.decode(H,H.uint32())},z.verify=function(H){if(typeof H!=="object"||H===null)return"object expected";if(H.dec!=null&&H.hasOwnProperty("dec")){if(!W.isString(H.dec))return"dec: string expected"}return null},z.fromObject=function(H){if(H instanceof q.cosmos.base.v1beta1.DecProto)return H;let Q=new q.cosmos.base.v1beta1.DecProto;if(H.dec!=null)Q.dec=String(H.dec);return Q},z.toObject=function(H,Q){if(!Q)Q={};let J={};if(Q.defaults)J.dec="";if(H.dec!=null&&H.hasOwnProperty("dec"))J.dec=H.dec;return J},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),X})(),Z})(),Y})()});import{Chain as U4}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,z=await import("@cosmjs/stargate"),L=z.defaultRegistryTypes??z.default?.defaultRegistryTypes;return new X([...L,["/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,z=Y===U4.THORChain?"thorchain":"mayachain";return new X({"/types.MsgDeposit":{aminoType:`${z}/MsgDeposit`,fromAmino:({signer:L,...H})=>({...H,signer:i(L)}),toAmino:({signer:L,...H})=>({...H,signer:o(L)})},"/types.MsgSend":{aminoType:`${z}/MsgSend`,fromAmino:({from_address:L,to_address:H,...Q})=>({...Q,fromAddress:i(L),toAddress:i(H)}),toAmino:({fromAddress:L,toAddress:H,...Q})=>({...Q,from_address:o(L),to_address:o(H)})}})}var I6=F(()=>{q6()});import{AssetValue as k4,Chain as z6,getChainConfig as j6,USwapError as R4}from"@uswap/helpers";function O6(Y){return function(X){let{assetValue:z,recipient:L,memo:H,sender:Q,asSignable:J,asAminoMessage:G}=X;if(L)return p6(Y)({asAminoMessage:G,asSignable:J,assetValue:z,memo:H,recipient:L,sender:Q});return c6(Y)({asAminoMessage:G,asSignable:J,assetValue:z,memo:H,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}),z=(X.isSynthetic?X.symbol.split("/")?.[1]:X.symbol)?.toUpperCase(),L=(X.isSynthetic?X.symbol.split("/")?.[0]:X.chain)?.toUpperCase();return{...Z,asset:{chain:L,symbol:z,synth:X.isSynthetic,ticker:X.ticker}}})}}}async function r({chain:Y,memo:Z,msgs:X}){let z=await l(),L=await C(Y),H={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:Z,messages:X.map((Q)=>L.fromAmino(Q))}};return z.encode(H)}var V4,M4,E6=({sender:Y,recipient:Z,assetValue:X})=>{return{type:`${X.chain===z6.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===z6.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:Z.getBaseValue("string"),asset:b(Z)}],memo:X,signer:Y}}},H6=({sender:Y,recipient:Z,assetValue:X,memo:z})=>{return!Z?N6({assetValue:X,memo:z,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 z=await(await P(Y)).getAccount(Z);if(!z)throw new R4("toolbox_cosmos_account_not_found",{sender:Z});return z},p6=(Y)=>async({sender:Z,recipient:X,assetValue:z,memo:L="",asSignable:H=!0,asAminoMessage:Q=!1,sequence:J,accountNumber:G})=>{let _=await b6({rpcUrl:Y,sender:Z}),A=z.chain,{chainId:U}=j6(A),T=E6({assetValue:z,recipient:X,sender:Z}),N=H?await w(Q?T:$(T),A):T;return{accountNumber:G||_.accountNumber,chainId:U,fee:S(A),memo:L,msgs:[N],sequence:J||_.sequence}},c6=(Y)=>async({sender:Z,assetValue:X,memo:z="",asSignable:L=!0,asAminoMessage:H=!1,sequence:Q,accountNumber:J})=>{let G=await b6({rpcUrl:Y,sender:Z}),_=X.chain,{chainId:A}=j6(_),U=N6({assetValue:X,memo:z,sender:Z}),T=L?await w(H?U:$(U),_):U;return{accountNumber:J||G.accountNumber,chainId:A,fee:S(_),memo:z,msgs:[T],sequence:Q||G.sequence}};var d6=F(()=>{t();I6();V4=S(z6.THORChain).gas,M4=S(z6.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 L6,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,USwapError as Z6,USwapNumber as v6,updateDerivationPath as S4}from"@uswap/helpers";import{USwapApi as s6}from"@uswap/helpers/api";import{match as P4,P as o6}from"ts-pattern";async function V6(Y,Z){try{let z=(await s6.getGasRate()).find((L)=>L.chainId===Y)?.value;return z?Number.parseFloat(z):Z}catch{return Z}}async function R6({phrase:Y,prefix:Z,...X}){let z=await import("@cosmjs/proto-signing"),L=z.DirectSecp256k1HdWallet??z.default?.DirectSecp256k1HdWallet,H=await import("@cosmjs/crypto"),Q=H.stringToPath??H.default?.stringToPath,J="derivationPath"in X?X.derivationPath:`${F4[X.chain]}/${X.index}`;return L.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:z,address:L}){let H=await Y(L);if(!H?.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(z),H.pubkey.value)}}async function a({chain:Y,...Z}){let X=await y4(Y),z=a6[Y],L="index"in Z?Z.index||0:0,H=i6("derivationPath"in Z&&Z.derivationPath?Z.derivationPath:S4(D4[Y],{index:L})),Q=await P4(Z).with({phrase:o6.string},({phrase:T})=>R6({derivationPath:H,phrase:T,prefix:z})).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 A({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=L6.from({chain:Y}),c=b(M),d=x||t6((await U6(Y,A6[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 U({recipient:T,assetValue:N,memo:E="",feeRate:x,feeOptionKey:O=Q6.Fast,dryRun:R=!1}){if(R)return A({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=L6.from({chain:Y}),d=b(c),n=x||t6((await U6(Y,A6[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(H),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[L6.from({chain:Y})];return x},getBalanceAsDenoms:r6(X),getFees:()=>U6(Y,A6[Y]),getPubKey:_,getSignerFromPhrase:async({phrase:T,derivationPath:N})=>R6({derivationPath:i6(N),index:L,phrase:T,prefix:z}),getSignerFromPrivateKey:async(T)=>{let N=await import("@cosmjs/proto-signing");return(N.DirectSecp256k1Wallet??N.default?.DirectSecp256k1Wallet).fromKey(T,z)},signTransaction:A,transfer:U,validateAddress:z4(Y),verifySignature:e6(J)}}async function w4(Y,Z){try{let z=(await s6.getGasRate()).find((L)=>L.chainId===Y)?.value;return z?Number.parseFloat(z):Z}catch{return Z}}function $4({assetValue:{chain:Y}}){return L6.from({chain:Y,value:u4(Y)})}async function U6(Y,Z){let{chainId:X,baseDecimal:z}=f4(Y),L=await V6(X,Z);return{average:v6.fromBigInt(BigInt(L),z),fast:v6.fromBigInt(BigInt(g6(L,Q6.Fast,!0)),z),fastest:v6.fromBigInt(BigInt(g6(L,Q6.Fastest,!0)),z)}}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 z4(Y){let Z=a6[Y];return function(z){if(!z.startsWith(Z))return!1;try{let{prefix:L,words:H}=K6.decode(z);return K6.encode(L,H)===z.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 z=await import("@cosmjs/crypto"),L=z.stringToPath??z.default?.stringToPath,H=z.Slip10Curve??z.default?.Slip10Curve,Q=z.Slip10??z.default?.Slip10,J=z.EnglishMnemonic??z.default?.EnglishMnemonic,G=z.Bip39??z.default?.Bip39,_=new J(X),A=await G.mnemonicToSeed(_),{privkey:U}=Q.derivePath(H.Secp256k1,A,L(Y));return U}}var A6;var X6=F(()=>{t();A6={[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 H4,getRPCUrl as p4,NetworkDerivationPath as c4,RequestClient as d4,USwapConfig as n4,USwapError as L4,USwapNumber 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(z,L=0){let H=await import("@cosmjs/amino"),Q=H.Secp256k1HdWallet??H.default?.Secp256k1HdWallet,J=await import("@cosmjs/crypto"),G=J.stringToPath??J.default?.stringToPath;return Q.fromMnemonic(z,{hdPaths:[G(`${Z}/${L}`)],prefix:Y})}}function o4(Y){return j.encode(Y)}function t4(Y){return async function({wallet:X,tx:z}){let{msgs:L,accountNumber:H,sequence:Q,chainId:J,fee:G,memo:_}=typeof z==="string"?JSON.parse(z):z,A=(await X.getAccounts())?.[0]?.address||"",U=await C(Y),T=await l(),N=await G6(X,{aminoTypes:U,registry:T}),E=[];for(let R of L){let M=await w(R,Y);E.push(M)}let{signatures:[x]}=await N.sign(A,E,G,_,{accountNumber:H,chainId:J,sequence:Q});return{bodyBytes:await r({chain:Y,memo:_,msgs:L.map($)}),signature:o4(x)}}}function r4({prefix:Y,rpcUrl:Z}){return async function(z,L,H,Q,J){let{encodeSecp256k1Pubkey:G,pubkeyToAddress:_}=(await import("@cosmjs/amino")).default,{makeMultisignedTxBytes:A}=(await import("@cosmjs/stargate")).default,{sequence:U,fee:T}=JSON.parse(z),N=await X4(H,Q),E=L.map((R)=>[_(G(j.decode(R.pubKey)),Y),j.decode(R.signature)]),x=await P(Z),{transactionHash:O}=await x.broadcastTx(A(N,U,T,J,new Map(E)));return O}}async function X4(Y,Z,X=!0){let{createMultisigThresholdPubkey:z,encodeSecp256k1Pubkey:L}=(await import("@cosmjs/amino")).default;return z(Y.map((H)=>L(j.decode(H))),Z,X)}function a4(Y){return j.decode(Y)}async function s4({privateKey:Y,message:Z}){let{Secp256k1:X}=(await import("@cosmjs/crypto")).default,z=await X.createSignature(j.decode(Z),Y);return j.encode(Buffer.concat([z.r(32),z.s(32)]))}async function F6({chain:Y,...Z}){let X=await p4(Y),{nodeUrl:z}=H4(Y),{isStagenet:L}=n4.get("envs"),H=Y===l4.THORChain,Q=`${L?"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}),A=await g4(Z).with({phrase:Q4.string},({phrase:E})=>_.getSignerFromPhrase({derivationPath:G,phrase:E})).with({signer:Q4.any},({signer:E})=>E).otherwise(()=>{return}),U=S(Y);async function T(){let E,x=`${z}/${H?"thorchain":"mayachain"}/constants`;try{let{int_64_values:{NativeTransactionFee:O}}=await d4.get(x);if(!O||Number.isNaN(O)||O<0)throw new L4("toolbox_cosmos_invalid_fee",{nativeFee:O.toString()});E=new Z4(O)}catch{E=new Z4({decimal:H4(Y).baseDecimal,value:H?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 A?.getAccounts())?.[0]?.address;if(!(M&&A))throw new L4("toolbox_cosmos_no_signer");let c="signAmino"in A,d=await l(),n=await C(Y),u=await p(X,A,{aminoTypes:n,registry:d}),h=H6({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],U,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],U,x)).transactionHash}return{..._,broadcastMultisigTx:r4({prefix:Q,rpcUrl:X}),buildAminoMsg:H6,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 z0=(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 L0={};D6(L0,{verifySignature:()=>e6,transferMsgAmino:()=>E6,toBase64:()=>O4,parseAminoMessageForDirectSigning:()=>$,getSignerFromPrivateKey:()=>C4,getSignerFromPhrase:()=>R6,getMsgSendDenom:()=>D,getFeeRateFromSwapKit:()=>w4,getDenomWithChain:()=>b,getDefaultChainFee:()=>S,getCreateTransaction:()=>O6,getCosmosValidateAddress:()=>z4,getCosmosToolbox:()=>z0,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:()=>H6,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 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,z4 as getCosmosValidateAddress,z0 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,H6 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};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=7622C2D192992B5564756E2164756E21
|
|
4
4
|
//# sourceMappingURL=index.js.map
|