@swapkit/toolboxes 5.1.2 → 5.2.1
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/CHANGELOG.md +13 -0
- package/dist/chunk-ye1j5pz2.js +2 -0
- package/dist/{chunk-v9dcj9m7.js → chunk-zhn86hw6.js} +1 -1
- package/dist/src/cardano/index.js +1 -1
- package/dist/src/cosmos/index.js +1 -1
- package/dist/src/evm/index.js +1 -1
- package/dist/src/hypercore/index.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/near/index.js +1 -1
- package/dist/src/ripple/index.js +1 -1
- package/dist/src/stellar/index.js +1 -1
- package/dist/src/sui/index.js +1 -1
- package/dist/src/ton/index.js +1 -1
- package/dist/src/utxo/index.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/ripple/index.d.ts +4 -2
- package/dist/types/stellar/types.d.ts +1 -0
- package/dist/types/sui/types.d.ts +3 -1
- package/dist/types/utxo/hdWallet.d.ts +1 -1
- package/package.json +2 -2
- package/dist/chunk-55jkfkar.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @swapkit/toolboxes
|
|
2
2
|
|
|
3
|
+
## 5.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Update generated token lists. (via @swapkit/helpers@5.2.1)
|
|
8
|
+
|
|
9
|
+
## 5.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`1c3d941`](https://github.com/swapkit/sdk/commit/1c3d941eecfe123aa29fd34cd710f848fcb1122f) Thanks [@ice-chillios](https://github.com/ice-chillios)! - **Derived addresses change for a non-zero index or an explicit derivation path.** Index 0 without a path is unchanged everywhere, which is why this ships as a minor rather than a major. EVM (every chain, including the OP-stack ones) declared `derivationPath` and `index` and read neither, so every phrase collapsed onto `m/44'/60'/0'/0/0`. Sui and Ripple had no path or index parameter at all and always used their library's default path. Cardano applied `index` to the address index but never read `derivationPath` and hardcoded the account to 0. Zcash overwrote the last slot of an explicit path with `index`. All of these now honour supported values, so the address returned for a non-zero index — or for an explicit path — differs from earlier versions. Nothing is lost: the funds stay at the previous address, which is unchanged and still reachable by requesting index 0 with no path. Cached addresses, saved address books, deposit instructions and in-flight quotes built against the old behaviour will no longer match, so audit anything that persisted an address before upgrading.
|
|
14
|
+
- Update generated token lists. (via @swapkit/helpers@5.2.0)
|
|
15
|
+
|
|
3
16
|
## 5.1.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{fa as Ny}from"./chunk-nvfkjbyq.js";import{ga as Uy}from"./chunk-xbdjxeqd.js";import{Chain as H}from"@swapkit/helpers";import{match as Q5}from"ts-pattern";import{Chain as J,getChainConfig as p,getRPCUrl as Wu,SKConfig as Qu,SwapKitError as h}from"@swapkit/helpers";import{FallbackProvider as Xu,getAddress as Hy,Interface as Yu,JsonRpcProvider as ty,Network as Zu}from"ethers";import{match as Ry}from"ts-pattern";function $u(y){return new ty(y)}async function B5(y,u){return $u(u||await Wu(y))}function Dy(y){let u=Qu.get("rpcUrls")[y]?.filter(Boolean)??[];if(u.length===0)throw new h("helpers_chain_no_public_or_set_rpc_url",{chain:y});let{chainId:n}=p(y),t=Zu.from(Number(n)),[T]=u;if(u.length===1)return new ty(T,t,{staticNetwork:t});return new Xu(u.map((M,b)=>({priority:b+1,provider:new ty(M,t,{staticNetwork:t}),stallTimeout:2000})),t,{quorum:1})}function l(y){return y>0n?`0x${y.toString(16)}`:"0x0"}function ky(y){let{explorerUrl:u,chainIdHex:n,rpcUrls:t}=p(y);return function(){return y!==J.Ethereum?{...Bu({chain:y}),blockExplorerUrls:[u],chainId:n,rpcUrls:t}:void 0}}function Ly(y){return![J.Adi,J.Arbitrum,J.BinanceSmartChain,J.Robinhood].includes(y)}function Bu({chain:y}){let{name:u,nativeCurrency:n,baseDecimal:t}=p(y);return Ry(y).with(J.Arbitrum,()=>({chainName:"Arbitrum One",nativeCurrency:{decimals:t,name:"Ethereum",symbol:J.Ethereum}})).with(J.Aurora,()=>({chainName:"Aurora Mainnet",nativeCurrency:{decimals:t,name:"Ethereum",symbol:J.Ethereum}})).with(J.Avalanche,()=>({chainName:"Avalanche Network",nativeCurrency:{decimals:t,name:"Avalanche",symbol:y}})).with(J.Base,()=>({chainName:"Base Mainnet",nativeCurrency:{decimals:t,name:"Ethereum",symbol:J.Ethereum}})).with(J.Berachain,()=>({chainName:"Berachain",nativeCurrency:{decimals:t,name:"Berachain",symbol:"BERA"}})).with(J.XLayer,()=>({chainName:"X Layer",nativeCurrency:{decimals:t,name:"OKB",symbol:"OKB"}})).with(J.BinanceSmartChain,()=>({chainName:"BNB Smart Chain Mainnet",nativeCurrency:{decimals:t,name:"Binance Coin",symbol:"BNB"}})).with(J.Gnosis,()=>({chainName:"Gnosis",nativeCurrency:{decimals:t,name:"xDAI",symbol:"XDAI"}})).with(J.Optimism,()=>({chainName:"OP Mainnet",nativeCurrency:{decimals:t,name:"Ethereum",symbol:J.Ethereum}})).with(J.Polygon,()=>({chainName:"Polygon Mainnet",nativeCurrency:{decimals:t,name:"Polygon",symbol:J.Polygon}})).with(J.Robinhood,()=>({chainName:"Robinhood Chain",nativeCurrency:{decimals:t,name:"Ethereum",symbol:J.Ethereum}})).otherwise(()=>({chainName:u,nativeCurrency:{decimals:t,name:n,symbol:n}}))}async function zy(y,u){if(!("authorize"in y))throw Error("Signer does not support EIP-7702 authorization. Requires ethers.js v6.14+");let n={...u,nonce:u.nonce!==void 0?BigInt(u.nonce):void 0};return await y.authorize(n)}var Jy=(y)=>typeof y==="string"&&/^0x[a-fA-F0-9]{64}$/.test(y),Ju=(y)=>{try{return typeof y==="string"&&!!Hy(y)}catch{return!1}};function Hu(y,u){let n=u!==void 0?`index ${u}: `:"",t=(T,M)=>{throw new h({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{field:T,message:`${n}${M}`}})};Ry(y).when(({chainId:T})=>typeof T!=="bigint",()=>t("chainId","chainId must be a bigint")).when(({address:T})=>!Ju(T),()=>t("address","address must be a valid checksummed address")).when(({nonce:T})=>typeof T!=="bigint"||T<0n,()=>t("nonce","nonce must be a non-negative bigint")).when(({signature:T})=>!T,()=>t("signature","signature is required")).when(({signature:T})=>typeof T?.yParity!=="number"||![0,1].includes(T.yParity),()=>t("signature.yParity","yParity must be 0 or 1")).when(({signature:T})=>!Jy(T?.r),()=>t("signature.r","r must be a 32-byte hex string")).when(({signature:T})=>!Jy(T?.s),()=>t("signature.s","s must be a 32-byte hex string")).otherwise(()=>{})}function Ru(y){return[{key:"name",type:"string"},{key:"version",type:"string"},{key:"chainId",type:"uint256"},{key:"verifyingContract",type:"address"},{key:"salt",type:"bytes32"}].filter(({key:u})=>y[u]!=null).map(({key:u,type:n})=>({name:u,type:n}))}function Ty(y){return y.charAt(0).toUpperCase()+y.slice(1)}function My(y,u){if(y.isTuple()&&y.components){let n=Ty(y.name);return u[n]=y.components.map((t)=>({name:t.name,type:My(t,u)})),n}if(y.isArray()){let n=y.arrayChildren;if(n?.isTuple()&&n.components){let t=Ty(y.name.replace(/s$/,""));return u[t]=n.components.map((T)=>({name:T.name,type:My(T,u)})),`${t}[]`}return`${n?.type??"bytes"}[]`}return y.type}function by(y,u){if(typeof y==="bigint")return y;if(u?.isTuple()&&typeof y?.toObject==="function"){let n=y.toObject(),t={};for(let[T,M]of(u.components??[]).entries())t[M.name]=by(n[M.name]??y[T],M);return t}if(Array.isArray(y)){let n=u?.arrayChildren;return y.map((t)=>by(t,n??void 0))}return y}function J5({chain:y,abi:u,data:n,to:t}){let M=new Yu(u).parseTransaction({data:n});if(!M)throw new h({errorKey:"toolbox_evm_invalid_params",info:{error:"Could not decode calldata"}});let b={},q=Ty(M.name);b[q]=M.fragment.inputs.map((X)=>({name:X.name,type:My(X,b)}));let W={};for(let[X,$]of M.fragment.inputs.entries())W[$.name]=by(M.args[X],$);let{chainId:Q}=p(y),U={chainId:Number(Q),verifyingContract:Hy(t)},D=Ru(U);return{domain:U,message:W,primaryType:q,types:{EIP712Domain:D,...b}}}function jy(y,u){if(!Array.isArray(y)||y.length===0)throw new h({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{message:"EIP-7702 transactions require at least one authorization"}});for(let[n,t]of y.entries())if(Hu(t,n),u!==void 0&&t.chainId!==u)throw new h({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{field:"chainId",message:`index ${n}: authorization chainId (${t.chainId}) does not match transaction chainId (${u})`}})}import{Chain as R,derivationPathToString as T5,FeeOption as M5,resolveDerivationPath as b5}from"@swapkit/helpers";import{HDNodeWallet as q5}from"ethers";import{match as U5,P as Cy}from"ts-pattern";var Gy=[{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"aggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes[]",name:"returnData",type:"bytes[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"blockAndAggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes32",name:"blockHash",type:"bytes32"},{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBlockNumber",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockCoinbase",outputs:[{internalType:"address",name:"coinbase",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockDifficulty",outputs:[{internalType:"uint256",name:"difficulty",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockGasLimit",outputs:[{internalType:"uint256",name:"gaslimit",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"addr",type:"address"}],name:"getEthBalance",outputs:[{internalType:"uint256",name:"balance",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"requireSuccess",type:"bool"},{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"tryAggregate",outputs:[{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"requireSuccess",type:"bool"},{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"tryBlockAndAggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes32",name:"blockHash",type:"bytes32"},{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"}];import{AssetValue as Du,applyFeeMultiplierToBigInt as j,Chain as K,EVMChains as ku,FeeOption as Y,isGasAsset as Lu,SwapKitError as Z,SwapKitNumber as s}from"@swapkit/helpers";import{erc20ABI as o}from"@swapkit/helpers/contracts";import{BrowserProvider as zu,Contract as _y,getAddress as i,getBytes as ju,Interface as Vy}from"ethers";import{match as wy}from"ts-pattern";function d(y){return{getBalance:Ny(y)}}function k5(y){return y}var Wy=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function a({chain:y=K.Ethereum,provider:u,signer:n,isEIP1559Compatible:t=!0,estimateGasPrices:T,estimateAdditionalFee:M}){let b=T??m({chain:y,isEIP1559Compatible:t,provider:u}),q=fy({chain:y,estimateAdditionalFee:M,estimateGasPrices:b,isEIP1559Compatible:t,provider:u,signer:n});return{approve:Ou({chain:y,isEIP1559Compatible:t,provider:u,signer:n}),approvedAmount:ly({chain:y,provider:u}),broadcastTransaction:u.broadcastTransaction,call:yy({chain:y,isEIP1559Compatible:t,provider:u,signer:n}),createApprovalTx:cu({chain:y,provider:u,signer:n}),createContract:Nu({chain:y,provider:u}),createContractTxObject:c({chain:y,provider:u}),createTransaction:q,createTransferTx:q,EIP1193SendTransaction:r(u),estimateCall:Sy({provider:u,signer:n}),estimateGasLimit:xu({chain:y,provider:u,signer:n}),estimateGasPrices:b,estimateTransactionFee:mu({chain:y,isEIP1559Compatible:t,provider:u}),getAddress:()=>{return n?n.getAddress():void 0},getBalance:d(y).getBalance,getNetworkParams:ky(y),isApproved:Ku({chain:y,provider:u}),sendTransaction:Oy({chain:y,estimateGasPrices:b,isEIP1559Compatible:t,provider:u,signer:n}),signAuthorization:Fu({signer:n}),signMessage:n?(W)=>n.signMessage(W):void 0,signTypedData:n?({domain:W,types:Q,value:U})=>n.signTypedData(W,Q,U):void 0,transfer:fu({chain:y,estimateAdditionalFee:M,estimateGasPrices:b,isEIP1559Compatible:t,provider:u,signer:n}),validateAddress:Gu}}function Gu(y){try{return i(y),!0}catch{return!1}}function e(y){return y instanceof zu}function Qy(y,u,n){return new _y(y,Vy.from(u),n)}function Nu({provider:y}){return function(n,t){return new _y(n,Vy.from(t),y)}}var _u=["payable","nonpayable"];function Vu({abi:y,funcName:u}){let n=y.find((t)=>t.name===u);if(!n)throw new Z("toolbox_evm_no_abi_fragment",{funcName:u});return n.stateMutability&&_u.includes(n.stateMutability)}function w5(y){return i(y)}function r(y,u=!1){return function({value:t,...T}){if(!e(y))throw new Z("toolbox_evm_provider_not_eip1193_compatible");let M={...T,gasPrice:"gasPrice"in T?T.gasPrice:void 0,maxFeePerGas:"maxFeePerGas"in T?T.maxFeePerGas:void 0,maxPriorityFeePerGas:"maxPriorityFeePerGas"in T?T.maxPriorityFeePerGas:void 0},{gasLimit:b,gasPrice:q,maxFeePerGas:W,maxPriorityFeePerGas:Q,...U}=M,D={...U,...u&&b!==void 0&&{gas:l(BigInt(b))},...u&&q!==void 0&&{gasPrice:l(BigInt(q))},...u&&W!==void 0&&{maxFeePerGas:l(BigInt(W))},...u&&Q!==void 0&&{maxPriorityFeePerGas:l(BigInt(Q))},value:l(BigInt(t||0))};return y.send("eth_sendTransaction",[D])}}function l5(y,u){let n=Xy(y,u);if(n)return i(n.toLowerCase());throw new Z("toolbox_evm_invalid_gas_asset_address")}var wu=ku.reduce((y,u)=>{return y[u]="0x0000000000000000000000000000000000000000",y},{}),lu={...wu,[K.Optimism]:"0x4200000000000000000000000000000000000042",[K.Polygon]:"0x0000000000000000000000000000000000001010"},Su=[K.Arbitrum,K.Aurora,K.Base,K.Optimism,K.Robinhood];function Xy({chain:y,symbol:u,ticker:n},t){try{let T=y===K.BinanceSmartChain&&u==="BNB"&&n==="BNB",M=y===K.Hyperevm&&u==="HYPE"&&n==="HYPE",b=y===t&&u===t&&n===t,q=Su.includes(y)&&u==="ETH"&&n==="ETH";if(b||T||M||q)return lu[t];return i(u.slice(n.length+1).replace(/^0X/,""))}catch{return null}}function c({provider:y}){return async({contractAddress:u,abi:n,funcName:t,funcParams:T=[],txOverrides:M})=>{let b=await Qy(u,n,y).getFunction(t).populateTransaction(...T.concat(M).filter((q)=>typeof q<"u"));return{...b,value:l(BigInt(b.value||0))}}}function m({chain:y,provider:u,isEIP1559Compatible:n=!0}){return wy(y).with(K.Gnosis,()=>{return async function(){try{let{gasPrice:T,maxPriorityFeePerGas:M}=await u.getFeeData();if(!T||M===null)throw new Z("toolbox_evm_no_fee_data");return{[Y.Average]:{maxFeePerGas:j(T,Y.Average),maxPriorityFeePerGas:j(M,Y.Average)},[Y.Fast]:{maxFeePerGas:j(T,Y.Fast),maxPriorityFeePerGas:j(M,Y.Fast)},[Y.Fastest]:{maxFeePerGas:j(T,Y.Fastest),maxPriorityFeePerGas:j(M,Y.Fastest)}}}catch(T){throw new Z("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}}).with(K.Arbitrum,()=>{return async function(){try{let{gasPrice:T}=await u.getFeeData();if(!T)throw new Z("toolbox_evm_no_fee_data");let M=T*12n/10n;return{[Y.Average]:{gasPrice:M},[Y.Fast]:{gasPrice:j(M,Y.Fast)},[Y.Fastest]:{gasPrice:j(M,Y.Fastest)}}}catch(T){throw new Z("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}}).otherwise(()=>{return async function(){try{let{maxFeePerGas:T,maxPriorityFeePerGas:M,gasPrice:b}=await u.getFeeData();if(n){if(T===null||M===null)throw new Z("toolbox_evm_no_fee_data");return{[Y.Average]:{maxFeePerGas:T,maxPriorityFeePerGas:M},[Y.Fast]:{maxFeePerGas:j(T,Y.Fast),maxPriorityFeePerGas:j(M,Y.Fast)},[Y.Fastest]:{maxFeePerGas:j(T,Y.Fastest),maxPriorityFeePerGas:j(M,Y.Fastest)}}}if(!b)throw new Z("toolbox_evm_no_gas_price");return{[Y.Average]:{gasPrice:b},[Y.Fast]:{gasPrice:j(b,Y.Fast)},[Y.Fastest]:{gasPrice:j(b,Y.Fastest)}}}catch(T){throw new Z("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}})}function yy({provider:y,isEIP1559Compatible:u,signer:n,chain:t}){return async function({callProvider:M,contractAddress:b,abi:q,funcName:W,funcParams:Q=[],txOverrides:U={},feeOption:D=Y.Fast}){let X=M||y;if(!b)throw new Z("toolbox_evm_invalid_params",{error:"contractAddress must be provided"});let $=Vu({abi:q,funcName:W});if($&&e(X)&&n){let z=c({chain:t,provider:X}),O=U?.from||await n?.getAddress(),G=await z({abi:q,contractAddress:b,funcName:W,funcParams:Q,txOverrides:{...U,from:O}});return r(X)(G)}let B=Qy(b,q,X);if($){if(!n)throw new Z("toolbox_evm_no_signer");let z=U?.from||await n.getAddress();if(!z)throw new Z("toolbox_evm_no_signer_address");let O=B.connect(n),G=m({chain:t,isEIP1559Compatible:u,provider:y}),[{maxFeePerGas:N,maxPriorityFeePerGas:I,gasPrice:x},_,F]=await Promise.all([G().then((V)=>V[D]),B.getFunction(W).estimateGas(...Q,U),U?.nonce!==void 0?Promise.resolve(U.nonce):X.getTransactionCount(z)]),S=await O[W](...Q,{...U,gasLimit:_,gasPrice:x,maxFeePerGas:N,maxPriorityFeePerGas:I,nonce:F});return typeof S?.hash==="string"?S?.hash:S}let k=await B[W]?.(...Q);return typeof k?.hash==="string"?k?.hash:k}}function ly({provider:y,chain:u}){return function({assetAddress:t,spenderAddress:T,from:M}){return yy({chain:u,isEIP1559Compatible:!0,provider:y})({abi:o,contractAddress:t,funcName:"allowance",funcParams:[M,T]})}}function Ku({provider:y,chain:u}){return async function({assetAddress:t,spenderAddress:T,from:M,amount:b=Wy}){let q=await ly({chain:u,provider:y})({assetAddress:t,from:M,spenderAddress:T});return s.fromBigInt(q).gte(s.fromBigInt(BigInt(b)))}}function Ou({signer:y,isEIP1559Compatible:u=!0,provider:n,chain:t}){return async function({assetAddress:M,spenderAddress:b,feeOptionKey:q=Y.Fast,amount:W,gasLimitFallback:Q,from:U,nonce:D}){let X=[b,BigInt(W||Wy)],$=await y?.getAddress()||U,B={abi:o,contractAddress:M,funcName:"approve",funcParams:X,signer:y,txOverrides:{from:$}};if(e(n)){let z=c({chain:t,provider:n}),O=r(n),G=await z(B);return O(G)}return yy({chain:t,isEIP1559Compatible:u,provider:n,signer:y})({...B,feeOption:q,funcParams:X,txOverrides:{from:$,gasLimit:Q?BigInt(Q.toString()):void 0,nonce:D}})}}function fu({chain:y,estimateGasPrices:u,estimateAdditionalFee:n,signer:t,isEIP1559Compatible:T=!0,provider:M}){return async function({assetValue:q,memo:W,recipient:Q,feeOptionKey:U=Y.Fast,sender:D,sweep:X,...$}){let B=D||await t?.getAddress(),k=Oy({chain:y,estimateGasPrices:u,isEIP1559Compatible:T,provider:M,signer:t});if(!B)throw new Z("toolbox_evm_no_from_address");let z=await fy({chain:y,estimateAdditionalFee:n,estimateGasPrices:u,isEIP1559Compatible:T,provider:M,signer:t})({assetValue:q,feeOptionKey:U,memo:W,recipient:Q,sender:B,sweep:X,...$});return k({...z,feeOptionKey:U,sweep:X})}}function Sy({provider:y,signer:u}){return function({contractAddress:t,abi:T,funcName:M,funcParams:b=[],txOverrides:q}){if(!t)throw new Z("toolbox_evm_no_contract_address");let W=Qy(t,T,y);return u?W.connect(u).getFunction(M).estimateGas(...b,q):W.getFunction(M).estimateGas(...b,q)}}function xu({provider:y,signer:u}){return async function({assetValue:t,recipient:T,memo:M,data:b,sender:q,funcName:W,funcParams:Q,txOverrides:U}){let D=t.bigIntValue,X=t.isGasAsset?null:Xy(t,t.chain);if(X&&W)return Sy({provider:y,signer:u})({abi:o,contractAddress:X,funcName:W,funcParams:Q,txOverrides:U});let{hexlify:$,toUtf8Bytes:B}=await import("ethers");return y.estimateGas({data:b?b:M?$(B(M)):void 0,from:q,to:T,value:D})}}function Fu({signer:y}){if(!y)return;return(u)=>zy(y,u)}var Ky=(y)=>y.type===4||(y.authorizations?.length??0)>0,Iu=(y)=>!Ky(y)&&(y.type===2||!!y.maxFeePerGas||!!y.maxPriorityFeePerGas),Eu=(y,u=!0)=>{if(Ky(y))return"eip7702";if(Iu(y)||u)return"eip1559";return"legacy"};function Au(y,u){if(y==="legacy"){if(u.gasPrice===void 0)throw new Z("toolbox_evm_no_fee_data");return{gasPrice:l(u.gasPrice)}}if(u.maxFeePerGas===void 0||u.maxPriorityFeePerGas===void 0)throw new Z("toolbox_evm_no_fee_data");return{maxFeePerGas:l(u.maxFeePerGas),maxPriorityFeePerGas:l(u.maxPriorityFeePerGas)}}function Oy({chain:y,estimateGasPrices:u,provider:n,signer:t,isEIP1559Compatible:T=!0}){return async function({feeOptionKey:b=Y.Fast,sweep:q,...W}){let{from:Q,to:U,data:D,value:X,...$}=W;if(!t)throw new Z("toolbox_evm_no_signer");if(!U)throw new Z("toolbox_evm_no_to_address");let B={...$,data:D||"0x",from:Q,to:U,value:BigInt(X||0)};if(e(n))return r(n,q)(B);let k=Q||await t.getAddress(),[z,O]=await Promise.all([W.nonce!==void 0?Promise.resolve(W.nonce):n.getTransactionCount(k),n.getNetwork()]),G=O.chainId,N=Eu(B,T);if(N==="eip7702")jy(B.authorizations||[],G);let I=wy(N).with("eip7702",()=>4).with("eip1559",()=>2).otherwise(()=>0),x={...B,chainId:G,nonce:z,type:I,...N==="eip7702"&&{authorizationList:B.authorizations}},_=u??m({chain:y,isEIP1559Compatible:T,provider:n}),S=(N==="legacy"?B.gasPrice!==void 0:B.maxFeePerGas!==void 0&&B.maxPriorityFeePerGas!==void 0)?{}:Au(N,(await _())[b]),V;try{V=l(B.gasLimit?BigInt(B.gasLimit):await n.estimateGas(x)*11n/10n)}catch(w){throw new Z("toolbox_evm_error_estimating_gas_limit",{error:w})}try{let w={...x,gasLimit:V,...S};try{return(await t.sendTransaction(w)).hash}catch{let E=await t.signTransaction({...w,from:k});return(await n.broadcastTransaction(E)).hash}}catch(w){throw new Z("toolbox_evm_error_sending_transaction",{error:w})}}}function A(y,u){throw new Z({errorKey:"toolbox_sweep_amount_too_low",info:{balance:y.toString(),fee:u.toString()}})}function Pu(y,u){if(u){if(y.maxFeePerGas===void 0||y.maxPriorityFeePerGas===void 0)throw new Z("toolbox_evm_no_fee_data");return{feeFields:{maxFeePerGas:y.maxFeePerGas,maxPriorityFeePerGas:y.maxPriorityFeePerGas},feePerGas:y.maxFeePerGas}}if(y.gasPrice===void 0)throw new Z("toolbox_evm_no_fee_data");return{feeFields:{gasPrice:y.gasPrice},feePerGas:y.gasPrice}}function ou(y,u){if(y>u)return y;return u}function Cu(y){return ju(y).reduce((u,n)=>u+(n===0?4n:16n),21000n)}function qy(y){let n=(y instanceof Error?y.message:String(y)).toLowerCase();return n.includes("insufficient funds")||n.includes("insufficient balance")||n.includes("gas required exceeds allowance")}async function gu({balance:y,estimateAdditionalFee:u,feeOptionKey:n,l2Reserve:t,sweepTx:T,valueBeforeL1Fee:M}){if(!u)return 0n;let b=await u({...T,value:M})??0n,q=j(b,n),W=M-q;if(W<=0n)A(y,t+q);let Q=await u({...T,value:W})??b;return j(ou(b,Q),n)}async function vu({chain:y,data:u,estimateGasPrices:n,estimateAdditionalFee:t,feeOptionKey:T,from:M,isEIP1559Compatible:b,provider:q,recipient:W,transaction:Q}){let U=await q.getBalance(M),D=n??m({chain:y,isEIP1559Compatible:b,provider:q}),{feeFields:X,feePerGas:$}=Pu((await D())[T],b),k={...t&&Q.nonce===void 0?{...Q,nonce:await q.getTransactionCount(M)}:Q,...X,data:u,from:M,to:W},z=Cu(u)*$;if(U-z<=0n)A(U,z);let O=(U-z)/2n,G;try{G=await q.estimateGas({...k,value:O})}catch(v){if(!qy(v))throw v;try{G=await q.estimateGas({...k,value:0n})}catch(By){if(qy(By))A(U,z);throw By}}let N=G*$;if(U-N<=0n)A(U,N);let _=G*11n/10n*$,F=U>_?U-_:0n,S;try{S=await q.estimateGas({...k,value:F})}catch(v){if(!qy(v))throw v;A(U,_)}let V=S*$,w=U-V;if(w<=0n)A(U,V);let E=await gu({balance:U,estimateAdditionalFee:t,feeOptionKey:T,l2Reserve:V,sweepTx:{...k,gasLimit:S},valueBeforeL1Fee:w}),P=w-E;if(P<=0n)A(U,V+E);return{...k,gasLimit:S,value:l(P)}}async function hu({chain:y,contractAddress:u,from:n,provider:t}){let T=await yy({chain:y,provider:t})({abi:o,contractAddress:u,funcName:"balanceOf",funcParams:[n]});if(typeof T!=="bigint")throw new Z({errorKey:"toolbox_evm_invalid_transaction",info:{error:"Invalid ERC20 balance"}});return T}function fy({chain:y,estimateAdditionalFee:u,estimateGasPrices:n,isEIP1559Compatible:t=!0,provider:T,signer:M}){return async function({assetValue:q,authorizations:W,memo:Q,recipient:U,data:D,feeOptionKey:X=Y.Fast,gasLimit:$,sender:B,sweep:k,type:z,maxFeePerGas:O,maxPriorityFeePerGas:G,gasPrice:N,...I}){let x=q.getBaseValue("bigint"),_=B||await M?.getAddress();if(!_)throw new Z("toolbox_evm_no_from_address");if(k&&(z===4||(W?.length??0)>0))throw new Z({errorKey:"toolbox_not_supported",info:{chain:y,reason:"EIP-7702 sweep transactions are not supported"}});if(Lu(q)){let{hexlify:w,toUtf8Bytes:E}=await import("ethers"),P=D||w(E(Q||""));if(!k)return{...I,...W!==void 0&&{authorizations:W},data:P,from:_,...$!==void 0&&{gasLimit:$},to:U,...z!==void 0&&{type:z},value:l(x)};return vu({chain:y,data:P,estimateAdditionalFee:u,estimateGasPrices:n,feeOptionKey:X,from:_,isEIP1559Compatible:t,provider:T,recipient:U,transaction:{nonce:I.nonce,type:z}})}let F=Xy(q,y);if(!F)throw new Z("toolbox_evm_no_contract_address");let S=c({chain:y,provider:T}),V=k?await hu({chain:y,contractAddress:F,from:_,provider:T}):x;if(k&&V<=0n)throw new Z({errorKey:"toolbox_sweep_amount_too_low",info:{asset:q.toString(),balance:V.toString()}});return S({abi:o,contractAddress:F,funcName:"transfer",funcParams:[U,V],txOverrides:{from:_,gasLimit:$,gasPrice:N,maxFeePerGas:O,maxPriorityFeePerGas:G}})}}function cu({provider:y,signer:u,chain:n}){return async function({assetAddress:T,spenderAddress:M,amount:b,from:q}){let W=await u?.getAddress()||q,Q=c({chain:n,provider:y}),U=["bigint","number"].includes(typeof b)?b:b||Wy;return await Q({abi:o,contractAddress:T,funcName:"approve",funcParams:[M,BigInt(U)],txOverrides:{from:W}})}}function mu({provider:y,isEIP1559Compatible:u=!0,chain:n}){return async function({feeOption:T=Y.Fast,...M}){let q=await m({chain:n,isEIP1559Compatible:u,provider:y})(),W=await y.estimateGas(M),Q=Du.from({chain:n}),{gasPrice:U,maxFeePerGas:D,maxPriorityFeePerGas:X}=q[T];if(!u&&U)return Q.set(s.fromBigInt(U*W,Q.decimal));if(D&&X){let $=(D+X)*W;return Q.set(s.fromBigInt($,Q.decimal))}throw new Z("toolbox_evm_no_gas_price")}}import{applyFeeMultiplierToBigInt as C,Chain as Iy,derivationPathToString as pu,FeeOption as f,getChainConfig as du,resolveDerivationPath as su,SwapKitError as g}from"@swapkit/helpers";import{Contract as iu,HDNodeWallet as au}from"ethers";import{match as eu,P as Fy}from"ts-pattern";var xy=[{inputs:[{internalType:"address",name:"_owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"DecimalsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"GasPriceUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"L1BaseFeeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"OverheadUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"ScalarUpdated",type:"event"},{inputs:[],name:"decimals",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"gasPrice",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"_data",type:"bytes"}],name:"getL1Fee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"_data",type:"bytes"}],name:"getL1GasUsed",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_gasUsed",type:"uint256"}],name:"getOperatorFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"l1BaseFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"overhead",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"scalar",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_decimals",type:"uint256"}],name:"setDecimals",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_gasPrice",type:"uint256"}],name:"setGasPrice",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_baseFee",type:"uint256"}],name:"setL1BaseFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_overhead",type:"uint256"}],name:"setOverhead",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_scalar",type:"uint256"}],name:"setScalar",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];var ru="0x420000000000000000000000000000000000000f";function uy(y){return new iu(ru,xy,y)}function Ey(y){return async function(){let n=uy(y);if(n&&"l1BaseFee"in n)return await n?.l1BaseFee();return}}function Ay(y){return async function({from:n,to:t,nonce:T,...M}){let{Transaction:b}=await import("ethers");if(!t)throw new g("toolbox_evm_invalid_transaction",{error:"Missing to address"});return b.from({...M,authorizationList:M.authorizationList,nonce:T??(n?await y.getTransactionCount(n):0),to:t}).unsignedSerialized}}function Yy(y,u){return async function(t){let T=uy(y),M=t.chainId??u??(await y.getNetwork()).chainId,b=await Ay(y)({...t,chainId:M});if(T&&"getL1Fee"in T){let q=await T.getL1Fee(b);if(typeof q!=="bigint")throw new g({errorKey:"toolbox_evm_invalid_transaction",info:{error:"Invalid OP-stack L1 fee"}});return q}return}}function Zy(y){return async function(n){let t=uy(y);if(t&&"getOperatorFee"in t){let T=await t.getOperatorFee(n);if(typeof T!=="bigint")throw new g({errorKey:"toolbox_evm_invalid_transaction",info:{error:"Invalid OP-stack operator fee"}});return T}return 0n}}function y5(y,u){let n=Yy(y,u),t=Zy(y);return async function(M){if(M.gasLimit===void 0||M.gasLimit===null)throw new g({errorKey:"toolbox_evm_invalid_transaction",info:{error:"Missing gas limit for OP-stack fee estimation"}});let[b,q]=await Promise.all([n(M),t(BigInt(M.gasLimit.toString()))]);return(b??0n)+q}}function Py(y){return async function(n){let T=(await y.getFeeData()).gasPrice??0n,M=await y.estimateGas(n);return T*M}}function u5(y){return async function(n){let t=await Yy(y)(n)??0n,T=await Py(y)(n),M=n.gasLimit??await y.estimateGas(n),b=await Zy(y)(BigInt(M.toString()));return t+T+b}}function n5(y){return async function(n){let t=uy(y),T=await Ay(y)(n);if(t&&"getL1GasUsed"in t)return t.getL1GasUsed(T)}}function t5(y){return async function(){try{let{maxFeePerGas:n,maxPriorityFeePerGas:t,gasPrice:T}=await y.getFeeData(),M=await Ey(y)(),b=T;if(!(n&&t))throw new g("toolbox_evm_no_fee_data");return{[f.Average]:{gasPrice:b,l1GasPrice:M,maxFeePerGas:n,maxPriorityFeePerGas:t},[f.Fast]:{gasPrice:C(b,f.Fast),l1GasPrice:C(M||0n,f.Fast),maxFeePerGas:n,maxPriorityFeePerGas:C(t,f.Fast)},[f.Fastest]:{gasPrice:C(b,f.Fastest),l1GasPrice:C(M||0n,f.Fastest),maxFeePerGas:n,maxPriorityFeePerGas:C(t,f.Fastest)}}}catch(n){throw new g("toolbox_evm_gas_estimation_error",{error:n.msg??n.toString()})}}}function ny(y){return function({provider:n,...t}){let T=eu(t).with({phrase:Fy.string},({phrase:X,derivationPath:$,index:B=0})=>au.fromPhrase(X,void 0,pu(su({chain:y,derivationPath:$,index:B}))).connect(n)).with({signer:Fy.any},({signer:X})=>X).otherwise(()=>{return}),M=Ey(n),b=BigInt(du(y).chainId),q=Yy(n,b),W=y5(n,b),Q=Zy(n),U=y===Iy.Optimism?t5(n):void 0;return{...a({chain:y,estimateAdditionalFee:W,estimateGasPrices:U,provider:n,signer:T}),estimateL1Gas:n5(n),estimateL1GasCost:q,estimateL2GasCost:Py(n),estimateOperatorFee:Q,estimateTotalGasCost:u5(n),getBalance:d(y).getBalance,getL1GasPrice:M}}}var oy=ny(Iy.Optimism);function gy(y){let u=L(R.Ethereum)(y);async function n(t,T="0x5ba1e12693dc8f9c48aad8770482f4739beed696",M="aggregate",b=M5.Fast){let q=await u.createContractTxObject({abi:Gy,contractAddress:T,funcName:M,funcParams:[t]});return u.sendTransaction({...q,feeOptionKey:b})}return{...u,multicall:n}}var vy=L(R.Adi),hy=L(R.Arbitrum),cy=L(R.Aurora),my=L(R.Avalanche),py=ny(R.Base),dy=L(R.Berachain),sy=L(R.BinanceSmartChain),m5=L(R.Botanix),iy=L(R.Core),ay=L(R.Corn),ey=L(R.Cronos),ry=L(R.Gnosis),yu=L(R.Robinhood),uu=L(R.Hyperevm),nu=L(R.Linea),tu=L(R.Polygon),Tu=L(R.MegaETH),Mu=L(R.Monad),bu=L(R.Plasma),$y=L(R.Sonic),qu=ny(R.Unichain),Uu=L(R.XLayer);function L(y){return function({provider:n,...t}){let T=Ly(y),M=U5(t).with({phrase:Cy.string},({phrase:q,derivationPath:W,index:Q=0})=>q5.fromPhrase(q,void 0,T5(b5({chain:y,derivationPath:W,index:Q}))).connect(n)).with({signer:Cy.any},({signer:q})=>q).otherwise(()=>{return});return a({chain:y,isEIP1559Compatible:T,provider:n,signer:M})}}function X5(y,u){return Q5(y).with(H.Adi,()=>vy(u)).with(H.Arbitrum,()=>hy(u)).with(H.Aurora,()=>cy(u)).with(H.Avalanche,()=>my(u)).with(H.Base,()=>py(u)).with(H.Berachain,()=>dy(u)).with(H.BinanceSmartChain,()=>sy(u)).with(H.Botanix,()=>$y(u)).with(H.Core,()=>iy(u)).with(H.Corn,()=>ay(u)).with(H.Cronos,()=>ey(u)).with(H.Ethereum,()=>gy(u)).with(H.Gnosis,()=>ry(u)).with(H.Hyperevm,()=>uu(u)).with(H.Linea,()=>nu(u)).with(H.MegaETH,()=>Tu(u)).with(H.Monad,()=>Mu(u)).with(H.Optimism,()=>oy(u)).with(H.Plasma,()=>bu(u)).with(H.Polygon,()=>tu(u)).with(H.Robinhood,()=>yu(u)).with(H.Sonic,()=>$y(u)).with(H.Unichain,()=>qu(u)).with(H.XLayer,()=>Uu(u)).exhaustive()}async function a5(y,u){let n={...u,provider:u?.provider||Dy(y)};return X5(y,n)}
|
|
2
|
+
export{d as b,k5 as c,$u as d,B5 as e,Dy as f,l as g,ky as h,Ly as i,zy as j,Hu as k,Ru as l,J5 as m,jy as n,Wy as o,a as p,Gu as q,e as r,Qy as s,Nu as t,Vu as u,w5 as v,r as w,l5 as x,lu as y,Xy as z,c as A,m as B,Ky as C,Iu as D,Eu as E,ny as F,oy as G,gy as H,vy as I,hy as J,cy as K,my as L,py as M,dy as N,sy as O,m5 as P,iy as Q,ay as R,ey as S,ry as T,yu as U,uu as V,nu as W,tu as X,Tu as Y,Mu as Z,bu as _,$y as $,qu as aa,Uu as ba,X5 as ca,a5 as da};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as N,A as m,B as n,C as o,D as p,E as q,F as r,G as s,H as t,I as u,J as v,K as w,L as x,M as y,N as z,O as A,P as B,Q as C,R as D,S as E,T as F,U as G,V as H,W as I,X as J,Y as K,Z as L,_ as M,aa as O,ba as P,ca as Q,da as R,o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i,x as j,y as k,z as l}from"./chunk-
|
|
1
|
+
import{$ as N,A as m,B as n,C as o,D as p,E as q,F as r,G as s,H as t,I as u,J as v,K as w,L as x,M as y,N as z,O as A,P as B,Q as C,R as D,S as E,T as F,U as G,V as H,W as I,X as J,Y as K,Z as L,_ as M,aa as O,ba as P,ca as Q,da as R,o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i,x as j,y as k,z as l}from"./chunk-ye1j5pz2.js";import"./chunk-nvfkjbyq.js";import"./chunk-xbdjxeqd.js";export{c as validateEVMAddress,h as toChecksumAddress,g as isStateChangingCall,o as isEIP7702Transaction,p as isEIP1559Transaction,d as isBrowserProvider,l as getTokenAddress,R as getEvmToolboxAsync,Q as getEvmToolbox,n as getEstimateGasPrices,q as getEVMTxType,i as getEIP1193SendTransaction,m as getCreateContractTxObject,f as getCreateContract,j as getChecksumAddressFromAsset,r as createOPStackToolbox,e as createContract,P as XLayerToolbox,O as UNIToolbox,N as SONICToolbox,M as PLASMAToolbox,s as OPToolbox,L as MONADToolbox,K as MEGAETHToolbox,a as MAX_APPROVAL,J as MATICToolbox,I as LINEAToolbox,H as HYPEREVMToolbox,G as HOODToolbox,F as GNOToolbox,t as ETHToolbox,k as ContractAddress,E as CROToolbox,D as CORNToolbox,C as COREToolbox,B as BotanixToolbox,b as BaseEVMToolbox,A as BSCToolbox,z as BERAToolbox,y as BASEToolbox,x as AVAXToolbox,w as AURORAToolbox,v as ARBToolbox,u as ADIToolbox};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ga as
|
|
1
|
+
import{ga as x}from"../../chunk-xbdjxeqd.js";import{bech32 as JG}from"@scure/base";import{mnemonicToEntropy as QG}from"@scure/bip39";import{wordlist as ZG}from"@scure/bip39/wordlists/english.js";import{AssetValue as B,Chain as k,getChainConfig as $G,SwapKitError as I}from"@swapkit/helpers";import Y from"bignumber.js";var r="mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS",t="https://cardano-mainnet.blockfrost.io/api/v0",p=2147483648,n=0;async function c(G,J){let $=await fetch(`${t}${G}`,{...J,headers:{project_id:r,...J?.headers}});if(!$.ok)throw Error(`Blockfrost API error: ${$.status} ${$.statusText}`);return $.json()}async function s(G){try{return await c(`/addresses/${G}/utxos`)}catch{return[]}}async function zG(){return(await c("/blocks/latest")).slot}async function XG(){let G=await c("/epochs/latest/parameters"),J={PlutusScriptV1:G.cost_models.PlutusV1?Object.values(G.cost_models.PlutusV1):[],PlutusScriptV2:G.cost_models.PlutusV2?Object.values(G.cost_models.PlutusV2):[],PlutusScriptV3:G.cost_models.PlutusV3?Object.values(G.cost_models.PlutusV3):[]};return{collateralPercent:new Y(G.collateral_percent),languageView:J,maxValueSize:Number.parseInt(G.max_val_size,10),minFeeA:new Y(G.min_fee_a),minFeeB:new Y(G.min_fee_b),minFeeRefScriptCostPerByte:new Y(15),priceMem:new Y(G.price_mem),priceSteps:new Y(G.price_step),stakeKeyDeposit:new Y(2000000),utxoCostPerByte:new Y(G.coins_per_utxo_size)}}async function o(G){let J=await fetch(`${t}/tx/submit`,{body:Buffer.from(G,"hex"),headers:{"Content-Type":"application/cbor",project_id:r},method:"POST"});if(!J.ok){let $=await J.text();throw Error(`Transaction submission failed: ${$}`)}return J.json()}function jG(G,J){return G.map(($)=>{let W=$.amount.find((Z)=>Z.unit==="lovelace"),X=W?new Y(W.quantity):new Y(0),q=$.amount.filter((Z)=>Z.unit!=="lovelace").map((Z)=>({amount:new Y(Z.quantity),assetName:Z.unit.slice(56),policyId:Z.unit.slice(0,56)}));return{address:J,amount:X,index:$.output_index,tokens:q,txId:$.tx_hash}})}function WG({TransactionConstructor:G,auxiliaryData:J,bufferedParams:$,currentSlot:W,inputs:X,recipientAddress:q}){let Z=X.reduce((Q,z)=>Q.plus(z.amount),new Y(0));if(!Z.isPositive())throw new I({errorKey:"toolbox_sweep_amount_too_low",info:{available:Z.toString()}});let j=new G({protocolParams:$});for(let Q of X)j.addInput(Q);if(j.addOutput({address:q,amount:Z,tokens:[]}),j.setTTL(W+3600),J)j.setAuxiliaryData(J);j.setFee(j.calculateFee());let H=j.getFee(),F=Z.minus(H),M={address:q,amount:F,tokens:[]},O=j.calculateMinUtxoAmountBabbage(M);if(!F.isPositive()||F.lt(O))throw new I({errorKey:"toolbox_sweep_amount_too_low",info:{available:Z.toString(),fee:H.toString(),minimumOutput:O.toString()}});return new G({protocolParams:$}).paymentTransaction({auxiliaryData:J,changeAddress:q,inputs:X,outputs:[M],ttl:W+3600})}async function qG(G){try{let J=await s(G),$=0n,W=new Map;for(let Z of J){if(!Z.amount||!Array.isArray(Z.amount))continue;for(let j of Z.amount){let{unit:H,quantity:F}=j;if(H==="lovelace")$+=BigInt(F);else{let M=W.get(H)||0n;W.set(H,M+BigInt(F))}}}let X=[],{baseDecimal:q}=$G(k.Cardano);if($>0n)X.push(B.from({chain:k.Cardano,fromBaseDecimal:q,value:$.toString()}));for(let[Z,j]of W)X.push(B.from({asset:`${k.Cardano}.${Z}`,value:j.toString()}));if(X.length===0)return[B.from({chain:k.Cardano})];return X}catch(J){let $=J instanceof Error?J.message:String(J);return console.error(`Cardano balance fetch error: ${$}`),[B.from({chain:k.Cardano})]}}function FG(G){if(!G||typeof G!=="string")return!1;try{let J=JG.decode(G,120);return J.prefix==="addr"||J.prefix==="addr_test"}catch{return!1}}async function UG(G,J=0,$=0){let{Bip32PrivateKey:W}=await import("@stricahq/bip32ed25519"),{types:X,address:q,crypto:Z}=await import("@stricahq/typhonjs"),j=QG(G,ZG),F=(await W.fromEntropy(Buffer.from(Array.from(j)))).derive(p+1852).derive(p+1815).derive(p+J),M=F.derive(0).derive($),O=M.toBip32PublicKey().toPublicKey().toBytes(),C=Z.hash28(O),z=F.derive(2).derive(0).toBip32PublicKey().toPublicKey().toBytes(),U=Z.hash28(z),D={hash:C,type:X.HashType.ADDRESS},N={hash:U,type:X.HashType.ADDRESS},v=new q.BaseAddress(X.NetworkId.MAINNET,D,N).getBech32(),K=M.toPrivateKey();return{getAddress:()=>v,publicKey:O,publicKeyHash:C,signTransaction:async(f)=>{try{let V=await import("@stricahq/cbors"),T=Buffer.from(f,"hex"),w=V.Decoder.decode(T),[S,h,m,g]=w.value,P=V.Encoder.encode(S),y=Z.hash32(P),A=K.sign(y),E=h instanceof Map?h:new Map,b=E.get(n)||[];b.push([O,A]),E.set(n,b);let l=[S,E,m,g];return V.Encoder.encode(l).toString("hex")}catch(V){throw new I("toolbox_cardano_sign_transaction_failed",{message:String(V)})}}}}function IG(G){let J,$,W;async function X(){if(!W)W=await XG();return W}async function q(){if(J!==void 0)return J;if(G&&"phrase"in G&&G.phrase){let{derivationPath:Q}=G;if(Q&&(Q.length!==5||Q[3]!==0||Q[4]===void 0))throw new I("toolbox_derivation_slot_unsupported",{chain:k.Cardano,derivationPath:Q});let z=Q?.[2]??0,U=Q?.[4]??G.index??0;return J=await UG(G.phrase,z,U),J}if(G&&"signer"in G&&G.signer)return J=G.signer,J;return}async function Z(){if($)return $;let Q=await q();if(!Q)return"";if("getAddress"in Q)return $=await Q.getAddress(),$;return""}async function j(Q){let z=Q||await Z();if(!z)throw new I("core_wallet_connection_not_found");return qG(z)}async function H(Q){if(Q)try{let{tx:N}=await F(Q),L=N.getFee();return B.from({chain:k.Cardano,fromBaseDecimal:6,value:L.toString()})}catch{}let z=await X(),U=400,D=z.minFeeB.plus(z.minFeeA.times(U));return B.from({chain:k.Cardano,fromBaseDecimal:6,value:D.toString()})}async function F({sender:Q="",recipient:z,assetValue:U,memo:D,pureLovelaceOnly:N=!1,sweep:L=!1}){let{Transaction:v,utils:K}=await import("@stricahq/typhonjs"),f=Q||await Z();if(!f)throw new I("core_wallet_connection_not_found");let[V,T,w]=await Promise.all([s(f),zG(),X()]);if(L&&!U.isGasAsset)throw new I({errorKey:"toolbox_not_supported",info:{asset:U.toString(),chain:k.Cardano,feature:"token_sweep"}});let S=L&&U.isGasAsset,h=N||S,m=V.filter((R)=>h?R.amount.some((_)=>_.unit==="lovelace")&&R.amount.every((_)=>_.unit==="lovelace"):R.amount.some((_)=>_.unit==="lovelace")).sort((R,_)=>{let i=R.amount.some((u)=>u.unit!=="lovelace"),GG=_.amount.some((u)=>u.unit!=="lovelace");if(i===GG)return 0;return i?1:-1}),g=K.getAddressFromString(f),P=K.getAddressFromString(z),y=jG(m,g),A;if(D){let R=new Map;R.set("msg",[D]),A={metadata:[{data:R,label:674}]}}let E={...w,minFeeB:w.minFeeB.plus(w.minFeeA.times(4))};if(S){let R=WG({auxiliaryData:A,bufferedParams:E,currentSlot:T,inputs:y,recipientAddress:P,TransactionConstructor:v}),{payload:_}=R.buildTransaction();return{tx:R,unsignedTx:_}}let b=new Y(U.getBaseValue("string")),l=[{address:P,amount:b,tokens:[]}],d=new v({protocolParams:E}).paymentTransaction({auxiliaryData:A,changeAddress:g,inputs:y,outputs:l,ttl:T+3600}),{payload:e}=d.buildTransaction();return{tx:d,unsignedTx:e}}async function M(Q){let z=await q();if(!z||!("signTransaction"in z))throw new I("core_wallet_connection_not_found");return z.signTransaction(Q)}async function O({recipient:Q,assetValue:z,memo:U,sweep:D}){let N=await q();if(!N||!("signTransaction"in N))throw new I("core_wallet_connection_not_found");let{unsignedTx:L}=await F({assetValue:z,memo:U,recipient:Q,sender:await Z(),sweep:D}),v=await M(L);return await o(v)}async function C(Q){let z=await M(Q);return await o(z)}return{createTransaction:F,estimateTransactionFee:H,getAddress:Z,getBalance:j,signAndBroadcastTransaction:C,signTransaction:M,transfer:O,validateAddress:FG}}export{FG as validateCardanoAddress,IG as getCardanoToolbox};
|
package/dist/src/cosmos/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../../chunk-xbdjxeqd.js";import{base64 as o,bech32 as i}from"@scure/base";import{SwapKitError as L0}from"@swapkit/helpers";function t(Y){return o.encode(Uint8Array.from(i.fromWords(i.decode(Y).words)))}function r(Y,z="thor"){return i.encode(z,i.toWords(o.decode(Y)))}function P8(Y){return o.encode(Y)}function A8(Y){if(!Y.match(/^[a-zA-Z0-9+/]*={0,2}$/))throw new L0("toolbox_cosmos_invalid_params",{error:"Invalid base64 string format"});return o.decode(Y)}import{encodeMessage as f0,encodeTxBody as w0}from"@swapkit/cosmos-signer";import{AssetValue as j0,Chain as Z6,getChainConfig as h6,getRPCUrl as N6,SwapKitError as B6}from"@swapkit/helpers";import{base64 as G6}from"@scure/base";import{broadcastTx as a,getAccount as P6,getBalances as J0,createTendermintRpc as G0,defaultEncoders as q0,encodeAuthInfo as F6,encodeMessage as _0,encodePubkey as W0,encodeTxBody as O0,encodeTxRaw as v6,makeStdSignDoc as N0}from"@swapkit/cosmos-signer";import{AssetValue as q6,Chain as K,getChainConfig as S,getRPCUrl as B0,RequestClient as I0,SKConfig as D6,SwapKitError as D,SwapKitNumber as _6}from"@swapkit/helpers";var A6="FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK",E0="FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM",U0={amount:[{amount:"500",denom:"uatom"}],gas:"200000"},K0={amount:[{amount:"1000",denom:"ukuji"}],gas:"200000"},R0={amount:[{amount:"1000",denom:"uusdc"}],gas:"200000"};function C(Y){switch(Y){case K.Maya:return{amount:[],gas:"10000000000"};case K.THORChain:return{amount:[],gas:"500000000"};case K.Kujira:return K0;case K.Noble:return R0;default:return U0}}async function s(Y){let{isStagenet:z}=D6.get("envs"),H=D6.get("thornodeUrls"),Z=Y===K.Maya,X=`${Z?z?H.MAYA_STAGENET:H.MAYA:z?H.THOR_STAGENET:H.THOR}/${Z?"mayachain":"thorchain"}/constants`,L=S(Y).baseDecimal;try{let{int_64_values:{NativeTransactionFee:J}}=await I0.get(X);if(!Number.isInteger(J)||J<=0)throw new D("toolbox_cosmos_invalid_fee",{nativeFee:J.toString()});return _6.fromBigInt(BigInt(J),L)}catch{let J=Z?10000000000n:2000000n;return _6.fromBigInt(J,L)}}var y=(Y,z=!1)=>{if(z)return Y.toLowerCase();switch(Y){case"uUSK":case"USK":return A6;case"uYUM":case"YUM":return E0;case"uKUJI":case"KUJI":return"ukuji";case"ATOM":case"uATOM":return"uatom";case"uUSDC":case"USDC":case"NOBLE":return"uusdc";default:return Y}},e=({symbol:Y,chain:z})=>{if(z===K.Maya)return(Y.toUpperCase()!=="CACAO"?Y:`${K.Maya}.${Y}`).toUpperCase();if(z===K.THORChain)return(["RUNE","TCY","RUJI"].includes(Y.toUpperCase())?`${K.THORChain}.${Y}`:Y).toUpperCase();return y(Y,!1)},V0=()=>typeof window<"u"?{}:{referer:"https://sdk.swapkit.dev",referrer:"https://sdk.swapkit.dev"};function S6(Y){return G0(Y,{headers:V0()})}function C6(Y){return{amount:Y.amount,denom:Y.denom}}function M0(Y,z){if(!Y)return null;if("toAmino"in Y&&typeof Y.toAmino==="function")return null;let Z=Y[z];return Z?{aminoType:Z.aminoType,toAmino:Z.toAmino}:null}async function $(Y){let z=S6(Y);return{async broadcastTx(H){let Z=await a(z,H,"sync");if(Z.code!==0)throw new D("core_swap_transaction_error",{code:Z.code,message:Z.log});return{code:Z.code,rawLog:Z.log,transactionHash:Z.hash}},async getAccount(H){let Z=await P6(z,H);if(!Z)return null;return{accountNumber:Number(Z.accountNumber),address:Z.address,pubkey:Z.pubKey?{type:Z.pubKey.typeUrl,value:Z.pubKey.key}:null,sequence:Number(Z.sequence)}},async getAllBalances(H){return(await J0(z,H)).map((Q)=>({amount:Q.amount,denom:Q.denom}))}}}function $6(Y,z={}){let H=T0(Y);async function Z(Q,X,L,J,G){let U=(await Y.getAccounts()).find((E)=>E.address===Q);if(!U)throw new D("toolbox_cosmos_signer_not_defined");let V=D0({memo:J,messages:X,registry:z.registry}),T=W0({type:"tendermint/PubKeySecp256k1",value:G6.encode(U.pubkey)});if(H){let E=X.map((v)=>v0(v,z.aminoTypes)),R=N0({accountNumber:G.accountNumber,chainId:G.chainId,fee:x0(L),memo:J,msgs:E,sequence:G.sequence}),M=await Y.signAmino(Q,R),x=F6({fee:F0(M.signed.fee,L),signerInfos:[{mode:"amino",pubkey:T,sequence:BigInt(M.signed.sequence)}]}),A=G6.decode(M.signature.signature);return{authInfoBytes:x,bodyBytes:V,signatures:[A]}}let N=F6({fee:k0(L),signerInfos:[{mode:"direct",pubkey:T,sequence:BigInt(G.sequence)}]}),I=await Y.signDirect(Q,{accountNumber:G.accountNumber,authInfoBytes:N,bodyBytes:V,chainId:G.chainId}),W=G6.decode(I.signature.signature);return{authInfoBytes:N,bodyBytes:V,signatures:[W]}}return{signWithRegistry:Z}}function T0(Y){return typeof Y.signAmino==="function"}function x0(Y){return{amount:Y.amount.map((z)=>({amount:z.amount,denom:z.denom})),gas:Y.gas,...Y.granter?{granter:Y.granter}:{},...Y.payer?{payer:Y.payer}:{}}}function k0(Y){return{amount:Y.amount.map(C6),gasLimit:BigInt(Y.gas),...Y.granter?{granter:Y.granter}:{},...Y.payer?{payer:Y.payer}:{}}}function F0(Y,z){return{amount:Y.amount.map(C6),gasLimit:BigInt(Y.gas),...Y.granter??z.granter?{granter:Y.granter??z.granter}:{},...Y.payer??z.payer?{payer:Y.payer??z.payer}:{}}}function v0(Y,z){if(z&&"toAmino"in z&&typeof z.toAmino==="function")return z.toAmino(Y);let H=M0(z,Y.typeUrl);if(!H){if(Y.typeUrl==="/cosmos.bank.v1beta1.MsgSend"){let Z=Y.value;return{type:"cosmos-sdk/MsgSend",value:{amount:Z.amount,from_address:Z.fromAddress,to_address:Z.toAddress}}}throw new D("toolbox_cosmos_invalid_params",{error:`No amino converter for ${Y.typeUrl}`})}return{type:H.aminoType,value:H.toAmino(Y.value)}}function D0(Y){let{memo:z,messages:H,registry:Z}=Y;if(Z&&"encode"in Z&&typeof Z.encode==="function")return Z.encode({typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:z,messages:H}});let Q={...q0,...Z??{}},X=H.map((L)=>_0(L,Q));return O0({memo:z,messages:X})}async function p(Y,z,H={}){let Z=typeof H==="string"?{}:H,Q=S6(Y),X=$6(z,Z);async function L(J,G){let B=await P6(Q,J);if(!B)throw new D("toolbox_cosmos_account_not_found",{sender:J});let U=G?.chainId??(await Q.status()).chainId;return{accountNumber:G?.accountNumber??B.accountNumber,chainId:U,sequence:G?.sequence??B.sequence}}return{async broadcastTx(J){let G=await a(Q,J,"sync");if(G.code!==0)throw new D("core_swap_transaction_error",{code:G.code,message:G.log});return{code:G.code,rawLog:G.log,transactionHash:G.hash}},async sendTokens(J,G,B,U,V=""){let T=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:{amount:B.map((R)=>({amount:R.amount,denom:R.denom})),fromAddress:J,toAddress:G}}],N=await L(J),I=await X.signWithRegistry(J,T,U,V,N),W=v6({authInfoBytes:I.authInfoBytes,bodyBytes:I.bodyBytes,signatures:I.signatures}),E=await a(Q,W,"sync");if(E.code!==0)throw new D("core_swap_transaction_error",{code:E.code,message:E.log});return{code:E.code,rawLog:E.log,transactionHash:E.hash}},async sign(J,G,B,U,V){let T=V??await L(J);return X.signWithRegistry(J,G,B,U,T)},async signAndBroadcast(J,G,B,U=""){let V=await L(J),T=await X.signWithRegistry(J,G,B,U,V),N=v6({authInfoBytes:T.authInfoBytes,bodyBytes:T.bodyBytes,signatures:T.signatures}),I=await a(Q,N,"sync");return{code:I.code,rawLog:I.log,transactionHash:I.hash}}}}async function y6(Y,z){let H=$6(Y,z??{});return{sign(Z,Q,X,L,J){if(!J)throw new D("toolbox_cosmos_invalid_params",{error:"createOfflineStargateClient.sign requires signerData"});return H.signWithRegistry(Z,Q,X,L,J)}}}var P0=(Y)=>{switch(Y){case K.Maya:case K.THORChain:return"/types.MsgSend";case K.Cosmos:case K.Kujira:case K.Noble:return"/cosmos.bank.v1beta1.MsgSend";default:throw new D("toolbox_cosmos_not_supported",{chain:Y})}};async function A0({client:Y,sender:z}){let H=await Y.getAccount(z);if(!H)throw new D("toolbox_cosmos_account_not_found",{sender:z});return H}async function f6({sender:Y,recipient:z,assetValue:H,memo:Z="",feeRate:Q,sequence:X,accountNumber:L,sweep:J}){let{chain:G,chainId:B}=H,U=L===void 0||X===void 0,V=J||U?await $(await B0(G)):void 0,T=U&&V?await A0({client:V,sender:Y}):void 0,N=q6.from({chain:G}),I=y(N.symbol),W=C(G),E=I&&Q?{amount:[{amount:Q.toString(),denom:I}],gas:W.gas}:W,R=y(H.symbol),M=H;if(J){if(!V)throw new D("toolbox_cosmos_account_not_found",{sender:Y});M=m({assetValue:H,balances:await V.getAllBalances(Y),denom:R,feeAmount:W6(E.amount,R)})}let x={amount:[{amount:M.getBaseValue("string"),denom:R}],fromAddress:Y,toAddress:z};return{accountNumber:L??Number(T?.accountNumber),chainId:B,fee:E,memo:Z,msgs:[{typeUrl:P0(G),value:x}],sequence:X??Number(T?.sequence)}}function W6(Y,z){let H=z.toLowerCase();return Y.reduce((Z,Q)=>Q.denom.toLowerCase()===H?Z+BigInt(Q.amount):Z,0n)}function m({assetValue:Y,balances:z,denom:H,feeAmount:Z=0n}){let Q=H.toLowerCase(),X=z.find(({denom:G})=>G.toLowerCase()===Q),L=BigInt(X?.amount??"0"),J=L-Z;if(J<=0n)throw new D("toolbox_sweep_amount_too_low",{asset:Y.toString(),balance:L.toString(),fee:Z.toString()});return Y.set(_6.fromBigInt(J,Y.decimal))}var S0={atom:{chain:K.Cosmos,decimals:S(K.Cosmos).baseDecimal},cacao:{chain:K.Maya,decimals:10},kuji:{chain:K.Kujira,decimals:S(K.Kujira).baseDecimal},maya:{asset:`${K.Maya}.${K.Maya}`,decimals:4},rune:{chain:K.THORChain,decimals:S(K.THORChain).baseDecimal},tcy:{asset:"THOR.TCY",decimals:S(K.THORChain).baseDecimal},uatom:{chain:K.Cosmos,decimals:S(K.Cosmos).baseDecimal},ukuji:{chain:K.Kujira,decimals:S(K.Kujira).baseDecimal},usdc:{chain:K.Noble,decimals:S(K.Noble).baseDecimal},uusdc:{chain:K.Noble,decimals:S(K.Noble).baseDecimal},"x/kuji":{asset:"THOR.KUJI",decimals:S(K.THORChain).baseDecimal},[A6.toLowerCase()]:{asset:`${K.Kujira}.USK`,decimals:S(K.Kujira).baseDecimal}},w6=(Y,z)=>{let H=S0[Y.toLowerCase()];if(!H)return q6.from({asset:Y,fromBaseDecimal:8,value:z});let{chain:Z,asset:Q,decimals:X}=H,L=Z?{chain:Z}:{asset:Q};return q6.from({...L,fromBaseDecimal:X,value:z})};import{defaultEncoders as C0}from"@swapkit/cosmos-signer";import{Chain as j6}from"@swapkit/helpers";import k from"protobufjs/minimal.js";var O=k.Reader,P=k.Writer,_=k.util,q=k.roots.default||(k.roots.default={});q.common=(()=>{let Y={};return Y.Asset=(()=>{function z(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 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,Q){if(!Q)Q=P.create();if(Z.chain!=null&&Object.hasOwnProperty.call(Z,"chain"))Q.uint32(10).string(Z.chain);if(Z.symbol!=null&&Object.hasOwnProperty.call(Z,"symbol"))Q.uint32(18).string(Z.symbol);if(Z.ticker!=null&&Object.hasOwnProperty.call(Z,"ticker"))Q.uint32(26).string(Z.ticker);if(Z.synth!=null&&Object.hasOwnProperty.call(Z,"synth"))Q.uint32(32).bool(Z.synth);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.Asset;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.chain=Z.string();break;case 2:L.symbol=Z.string();break;case 3:L.ticker=Z.string();break;case 4:L.synth=Z.bool();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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(!_.isString(Z.chain))return"chain: string expected"}if(Z.symbol!=null&&Z.hasOwnProperty("symbol")){if(!_.isString(Z.symbol))return"symbol: string expected"}if(Z.ticker!=null&&Z.hasOwnProperty("ticker")){if(!_.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 Q=new q.common.Asset;if(Z.chain!=null)Q.chain=String(Z.chain);if(Z.symbol!=null)Q.symbol=String(Z.symbol);if(Z.ticker!=null)Q.ticker=String(Z.ticker);if(Z.synth!=null)Q.synth=Boolean(Z.synth);return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.defaults)X.chain="",X.symbol="",X.ticker="",X.synth=!1;if(Z.chain!=null&&Z.hasOwnProperty("chain"))X.chain=Z.chain;if(Z.symbol!=null&&Z.hasOwnProperty("symbol"))X.symbol=Z.symbol;if(Z.ticker!=null&&Z.hasOwnProperty("ticker"))X.ticker=Z.ticker;if(Z.synth!=null&&Z.hasOwnProperty("synth"))X.synth=Z.synth;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.Coin=(()=>{function z(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 z.prototype.asset=null,z.prototype.amount="",z.prototype.decimals=_.Long?_.Long.fromBits(0,0,!1):0,z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.asset!=null&&Object.hasOwnProperty.call(Z,"asset"))q.common.Asset.encode(Z.asset,Q.uint32(10).fork()).ldelim();if(Z.amount!=null&&Object.hasOwnProperty.call(Z,"amount"))Q.uint32(18).string(Z.amount);if(Z.decimals!=null&&Object.hasOwnProperty.call(Z,"decimals"))Q.uint32(24).int64(Z.decimals);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.Coin;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.asset=q.common.Asset.decode(Z,Z.uint32());break;case 2:L.amount=Z.string();break;case 3:L.decimals=Z.int64();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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 Q=q.common.Asset.verify(Z.asset);if(Q)return"asset."+Q}if(Z.amount!=null&&Z.hasOwnProperty("amount")){if(!_.isString(Z.amount))return"amount: string expected"}if(Z.decimals!=null&&Z.hasOwnProperty("decimals")){if(!_.isInteger(Z.decimals)&&!(Z.decimals&&_.isInteger(Z.decimals.low)&&_.isInteger(Z.decimals.high)))return"decimals: integer|Long expected"}return null},z.fromObject=function(Z){if(Z instanceof q.common.Coin)return Z;let Q=new q.common.Coin;if(Z.asset!=null){if(typeof Z.asset!=="object")throw TypeError(".common.Coin.asset: object expected");Q.asset=q.common.Asset.fromObject(Z.asset)}if(Z.amount!=null)Q.amount=String(Z.amount);if(Z.decimals!=null){if(_.Long)(Q.decimals=_.Long.fromValue(Z.decimals)).unsigned=!1;else if(typeof Z.decimals==="string")Q.decimals=Number.parseInt(Z.decimals,10);else if(typeof Z.decimals==="number")Q.decimals=Z.decimals;else if(typeof Z.decimals==="object")Q.decimals=new _.LongBits(Z.decimals.low>>>0,Z.decimals.high>>>0).toNumber()}return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.defaults)if(X.asset=null,X.amount="",_.Long){let L=new _.Long(0,0,!1);X.decimals=Q.longs===String?L.toString():Q.longs===Number?L.toNumber():L}else X.decimals=Q.longs===String?"0":0;if(Z.asset!=null&&Z.hasOwnProperty("asset"))X.asset=q.common.Asset.toObject(Z.asset,Q);if(Z.amount!=null&&Z.hasOwnProperty("amount"))X.amount=Z.amount;if(Z.decimals!=null&&Z.hasOwnProperty("decimals"))if(typeof Z.decimals==="number")X.decimals=Q.longs===String?String(Z.decimals):Z.decimals;else X.decimals=Q.longs===String?_.Long.prototype.toString.call(Z.decimals):Q.longs===Number?new _.LongBits(Z.decimals.low>>>0,Z.decimals.high>>>0).toNumber():Z.decimals;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.PubKeySet=(()=>{function z(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 z.prototype.secp256k1="",z.prototype.ed25519="",z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.secp256k1!=null&&Object.hasOwnProperty.call(Z,"secp256k1"))Q.uint32(10).string(Z.secp256k1);if(Z.ed25519!=null&&Object.hasOwnProperty.call(Z,"ed25519"))Q.uint32(18).string(Z.ed25519);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.PubKeySet;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.secp256k1=Z.string();break;case 2:L.ed25519=Z.string();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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(!_.isString(Z.secp256k1))return"secp256k1: string expected"}if(Z.ed25519!=null&&Z.hasOwnProperty("ed25519")){if(!_.isString(Z.ed25519))return"ed25519: string expected"}return null},z.fromObject=function(Z){if(Z instanceof q.common.PubKeySet)return Z;let Q=new q.common.PubKeySet;if(Z.secp256k1!=null)Q.secp256k1=String(Z.secp256k1);if(Z.ed25519!=null)Q.ed25519=String(Z.ed25519);return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.defaults)X.secp256k1="",X.ed25519="";if(Z.secp256k1!=null&&Z.hasOwnProperty("secp256k1"))X.secp256k1=Z.secp256k1;if(Z.ed25519!=null&&Z.hasOwnProperty("ed25519"))X.ed25519=Z.ed25519;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.Tx=(()=>{function z(H){if(this.coins=[],this.gas=[],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 z.prototype.id="",z.prototype.chain="",z.prototype.fromAddress="",z.prototype.toAddress="",z.prototype.coins=_.emptyArray,z.prototype.gas=_.emptyArray,z.prototype.memo="",z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.id!=null&&Object.hasOwnProperty.call(Z,"id"))Q.uint32(10).string(Z.id);if(Z.chain!=null&&Object.hasOwnProperty.call(Z,"chain"))Q.uint32(18).string(Z.chain);if(Z.fromAddress!=null&&Object.hasOwnProperty.call(Z,"fromAddress"))Q.uint32(26).string(Z.fromAddress);if(Z.toAddress!=null&&Object.hasOwnProperty.call(Z,"toAddress"))Q.uint32(34).string(Z.toAddress);if(Z.coins?.length)for(let X=0;X<Z.coins.length;++X)q.common.Coin.encode(Z.coins[X],Q.uint32(42).fork()).ldelim();if(Z.gas?.length)for(let X=0;X<Z.gas.length;++X)q.common.Coin.encode(Z.gas[X],Q.uint32(50).fork()).ldelim();if(Z.memo!=null&&Object.hasOwnProperty.call(Z,"memo"))Q.uint32(58).string(Z.memo);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.Tx;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.id=Z.string();break;case 2:L.chain=Z.string();break;case 3:L.fromAddress=Z.string();break;case 4:L.toAddress=Z.string();break;case 5:if(!L.coins?.length)L.coins=[];L.coins.push(q.common.Coin.decode(Z,Z.uint32()));break;case 6:if(!L.gas?.length)L.gas=[];L.gas.push(q.common.Coin.decode(Z,Z.uint32()));break;case 7:L.memo=Z.string();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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(!_.isString(Z.id))return"id: string expected"}if(Z.chain!=null&&Z.hasOwnProperty("chain")){if(!_.isString(Z.chain))return"chain: string expected"}if(Z.fromAddress!=null&&Z.hasOwnProperty("fromAddress")){if(!_.isString(Z.fromAddress))return"fromAddress: string expected"}if(Z.toAddress!=null&&Z.hasOwnProperty("toAddress")){if(!_.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 Q=0;Q<Z.coins.length;++Q){let X=q.common.Coin.verify(Z.coins[Q]);if(X)return"coins."+X}}if(Z.gas!=null&&Z.hasOwnProperty("gas")){if(!Array.isArray(Z.gas))return"gas: array expected";for(let Q=0;Q<Z.gas.length;++Q){let X=q.common.Coin.verify(Z.gas[Q]);if(X)return"gas."+X}}if(Z.memo!=null&&Z.hasOwnProperty("memo")){if(!_.isString(Z.memo))return"memo: string expected"}return null},z.fromObject=function(Z){if(Z instanceof q.common.Tx)return Z;let Q=new q.common.Tx;if(Z.id!=null)Q.id=String(Z.id);if(Z.chain!=null)Q.chain=String(Z.chain);if(Z.fromAddress!=null)Q.fromAddress=String(Z.fromAddress);if(Z.toAddress!=null)Q.toAddress=String(Z.toAddress);if(Z.coins){if(!Array.isArray(Z.coins))throw TypeError(".common.Tx.coins: array expected");Q.coins=[];for(let X=0;X<Z.coins.length;++X){if(typeof Z.coins[X]!=="object")throw TypeError(".common.Tx.coins: object expected");Q.coins[X]=q.common.Coin.fromObject(Z.coins[X])}}if(Z.gas){if(!Array.isArray(Z.gas))throw TypeError(".common.Tx.gas: array expected");Q.gas=[];for(let X=0;X<Z.gas.length;++X){if(typeof Z.gas[X]!=="object")throw TypeError(".common.Tx.gas: object expected");Q.gas[X]=q.common.Coin.fromObject(Z.gas[X])}}if(Z.memo!=null)Q.memo=String(Z.memo);return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.arrays||Q.defaults)X.coins=[],X.gas=[];if(Q.defaults)X.id="",X.chain="",X.fromAddress="",X.toAddress="",X.memo="";if(Z.id!=null&&Z.hasOwnProperty("id"))X.id=Z.id;if(Z.chain!=null&&Z.hasOwnProperty("chain"))X.chain=Z.chain;if(Z.fromAddress!=null&&Z.hasOwnProperty("fromAddress"))X.fromAddress=Z.fromAddress;if(Z.toAddress!=null&&Z.hasOwnProperty("toAddress"))X.toAddress=Z.toAddress;if(Z.coins?.length){X.coins=[];for(let L=0;L<Z.coins.length;++L)X.coins[L]=q.common.Coin.toObject(Z.coins[L],Q)}if(Z.gas?.length){X.gas=[];for(let L=0;L<Z.gas.length;++L)X.gas[L]=q.common.Coin.toObject(Z.gas[L],Q)}if(Z.memo!=null&&Z.hasOwnProperty("memo"))X.memo=Z.memo;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.Fee=(()=>{function z(H){if(this.coins=[],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 z.prototype.coins=_.emptyArray,z.prototype.poolDeduct="",z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.coins?.length)for(let X=0;X<Z.coins.length;++X)q.common.Coin.encode(Z.coins[X],Q.uint32(10).fork()).ldelim();if(Z.poolDeduct!=null&&Object.hasOwnProperty.call(Z,"poolDeduct"))Q.uint32(18).string(Z.poolDeduct);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.Fee;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:if(!L.coins?.length)L.coins=[];L.coins.push(q.common.Coin.decode(Z,Z.uint32()));break;case 2:L.poolDeduct=Z.string();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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 Q=0;Q<Z.coins.length;++Q){let X=q.common.Coin.verify(Z.coins[Q]);if(X)return"coins."+X}}if(Z.poolDeduct!=null&&Z.hasOwnProperty("poolDeduct")){if(!_.isString(Z.poolDeduct))return"poolDeduct: string expected"}return null},z.fromObject=function(Z){if(Z instanceof q.common.Fee)return Z;let Q=new q.common.Fee;if(Z.coins){if(!Array.isArray(Z.coins))throw TypeError(".common.Fee.coins: array expected");Q.coins=[];for(let X=0;X<Z.coins.length;++X){if(typeof Z.coins[X]!=="object")throw TypeError(".common.Fee.coins: object expected");Q.coins[X]=q.common.Coin.fromObject(Z.coins[X])}}if(Z.poolDeduct!=null)Q.poolDeduct=String(Z.poolDeduct);return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.arrays||Q.defaults)X.coins=[];if(Q.defaults)X.poolDeduct="";if(Z.coins?.length){X.coins=[];for(let L=0;L<Z.coins.length;++L)X.coins[L]=q.common.Coin.toObject(Z.coins[L],Q)}if(Z.poolDeduct!=null&&Z.hasOwnProperty("poolDeduct"))X.poolDeduct=Z.poolDeduct;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.ProtoUint=(()=>{function z(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 z.prototype.value="",z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.value!=null&&Object.hasOwnProperty.call(Z,"value"))Q.uint32(10).string(Z.value);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.ProtoUint;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.value=Z.string();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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(!_.isString(Z.value))return"value: string expected"}return null},z.fromObject=function(Z){if(Z instanceof q.common.ProtoUint)return Z;let Q=new q.common.ProtoUint;if(Z.value!=null)Q.value=String(Z.value);return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.defaults)X.value="";if(Z.value!=null&&Z.hasOwnProperty("value"))X.value=Z.value;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y})();q.types=(()=>{let Y={};return Y.MsgDeposit=(()=>{function z(H){if(this.coins=[],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 z.prototype.coins=_.emptyArray,z.prototype.memo="",z.prototype.signer=_.newBuffer([]),z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.coins?.length)for(let X=0;X<Z.coins.length;++X)q.common.Coin.encode(Z.coins[X],Q.uint32(10).fork()).ldelim();if(Z.memo!=null&&Object.hasOwnProperty.call(Z,"memo"))Q.uint32(18).string(Z.memo);if(Z.signer!=null&&Object.hasOwnProperty.call(Z,"signer"))Q.uint32(26).bytes(Z.signer);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.types.MsgDeposit;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:if(!L.coins?.length)L.coins=[];L.coins.push(q.common.Coin.decode(Z,Z.uint32()));break;case 2:L.memo=Z.string();break;case 3:L.signer=Z.bytes();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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 Q=0;Q<Z.coins.length;++Q){let X=q.common.Coin.verify(Z.coins[Q]);if(X)return"coins."+X}}if(Z.memo!=null&&Z.hasOwnProperty("memo")){if(!_.isString(Z.memo))return"memo: string expected"}if(Z.signer!=null&&Z.hasOwnProperty("signer")){if(!(Z.signer&&typeof Z.signer.length==="number"||_.isString(Z.signer)))return"signer: buffer expected"}return null},z.fromObject=function(Z){if(Z instanceof q.types.MsgDeposit)return Z;let Q=new q.types.MsgDeposit;if(Z.coins){if(!Array.isArray(Z.coins))throw TypeError(".types.MsgDeposit.coins: array expected");Q.coins=[];for(let X=0;X<Z.coins.length;++X){if(typeof Z.coins[X]!=="object")throw TypeError(".types.MsgDeposit.coins: object expected");Q.coins[X]=q.common.Coin.fromObject(Z.coins[X])}}if(Z.memo!=null)Q.memo=String(Z.memo);if(Z.signer!=null){if(typeof Z.signer==="string")_.base64.decode(Z.signer,Q.signer=_.newBuffer(_.base64.length(Z.signer)),0);else if(Z.signer.length)Q.signer=Z.signer}return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.arrays||Q.defaults)X.coins=[];if(Q.defaults){if(X.memo="",Q.bytes===String)X.signer="";else if(X.signer=[],Q.bytes!==Array)X.signer=_.newBuffer(X.signer)}if(Z.coins?.length){X.coins=[];for(let L=0;L<Z.coins.length;++L)X.coins[L]=q.common.Coin.toObject(Z.coins[L],Q)}if(Z.memo!=null&&Z.hasOwnProperty("memo"))X.memo=Z.memo;if(Z.signer!=null&&Z.hasOwnProperty("signer"))X.signer=Q.bytes===String?_.base64.encode(Z.signer,0,Z.signer.length):Q.bytes===Array?Array.prototype.slice.call(Z.signer):Z.signer;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.MsgSend=(()=>{function z(H){if(this.amount=[],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 z.prototype.fromAddress=_.newBuffer([]),z.prototype.toAddress=_.newBuffer([]),z.prototype.amount=_.emptyArray,z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.fromAddress!=null&&Object.hasOwnProperty.call(Z,"fromAddress"))Q.uint32(10).bytes(Z.fromAddress);if(Z.toAddress!=null&&Object.hasOwnProperty.call(Z,"toAddress"))Q.uint32(18).bytes(Z.toAddress);if(Z.amount?.length)for(let X=0;X<Z.amount.length;++X)q.cosmos.base.v1beta1.Coin.encode(Z.amount[X],Q.uint32(26).fork()).ldelim();return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.types.MsgSend;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.fromAddress=Z.bytes();break;case 2:L.toAddress=Z.bytes();break;case 3:if(!L.amount?.length)L.amount=[];L.amount.push(q.cosmos.base.v1beta1.Coin.decode(Z,Z.uint32()));break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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"||_.isString(Z.fromAddress)))return"fromAddress: buffer expected"}if(Z.toAddress!=null&&Z.hasOwnProperty("toAddress")){if(!(Z.toAddress&&typeof Z.toAddress.length==="number"||_.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 Q=0;Q<Z.amount.length;++Q){let X=q.cosmos.base.v1beta1.Coin.verify(Z.amount[Q]);if(X)return"amount."+X}}return null},z.fromObject=function(Z){if(Z instanceof q.types.MsgSend)return Z;let Q=new q.types.MsgSend;if(Z.fromAddress!=null){if(typeof Z.fromAddress==="string")_.base64.decode(Z.fromAddress,Q.fromAddress=_.newBuffer(_.base64.length(Z.fromAddress)),0);else if(Z.fromAddress.length)Q.fromAddress=Z.fromAddress}if(Z.toAddress!=null){if(typeof Z.toAddress==="string")_.base64.decode(Z.toAddress,Q.toAddress=_.newBuffer(_.base64.length(Z.toAddress)),0);else if(Z.toAddress.length)Q.toAddress=Z.toAddress}if(Z.amount){if(!Array.isArray(Z.amount))throw TypeError(".types.MsgSend.amount: array expected");Q.amount=[];for(let X=0;X<Z.amount.length;++X){if(typeof Z.amount[X]!=="object")throw TypeError(".types.MsgSend.amount: object expected");Q.amount[X]=q.cosmos.base.v1beta1.Coin.fromObject(Z.amount[X])}}return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.arrays||Q.defaults)X.amount=[];if(Q.defaults){if(Q.bytes===String)X.fromAddress="";else if(X.fromAddress=[],Q.bytes!==Array)X.fromAddress=_.newBuffer(X.fromAddress);if(Q.bytes===String)X.toAddress="";else if(X.toAddress=[],Q.bytes!==Array)X.toAddress=_.newBuffer(X.toAddress)}if(Z.fromAddress!=null&&Z.hasOwnProperty("fromAddress"))X.fromAddress=Q.bytes===String?_.base64.encode(Z.fromAddress,0,Z.fromAddress.length):Q.bytes===Array?Array.prototype.slice.call(Z.fromAddress):Z.fromAddress;if(Z.toAddress!=null&&Z.hasOwnProperty("toAddress"))X.toAddress=Q.bytes===String?_.base64.encode(Z.toAddress,0,Z.toAddress.length):Q.bytes===Array?Array.prototype.slice.call(Z.toAddress):Z.toAddress;if(Z.amount?.length){X.amount=[];for(let L=0;L<Z.amount.length;++L)X.amount[L]=q.cosmos.base.v1beta1.Coin.toObject(Z.amount[L],Q)}return X},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 H={};return H.Coin=(()=>{function Z(Q){if(Q){for(let X=Object.keys(Q),L=0;L<X.length;++L)if(Q[X[L]]!=null)this[X[L]]=Q[X[L]]}}return Z.prototype.denom="",Z.prototype.amount="",Z.create=function(X){return new Z(X)},Z.encode=function(X,L){if(!L)L=P.create();if(X.denom!=null&&Object.hasOwnProperty.call(X,"denom"))L.uint32(10).string(X.denom);if(X.amount!=null&&Object.hasOwnProperty.call(X,"amount"))L.uint32(18).string(X.amount);return L},Z.encodeDelimited=function(X,L){return this.encode(X,L).ldelim()},Z.decode=function(X,L){if(!(X instanceof O))X=O.create(X);let J=L===void 0?X.len:X.pos+L,G=new q.cosmos.base.v1beta1.Coin;while(X.pos<J){let B=X.uint32();switch(B>>>3){case 1:G.denom=X.string();break;case 2:G.amount=X.string();break;default:X.skipType(B&7);break}}return G},Z.decodeDelimited=function(X){if(!(X instanceof O))X=new O(X);return this.decode(X,X.uint32())},Z.verify=function(X){if(typeof X!=="object"||X===null)return"object expected";if(X.denom!=null&&X.hasOwnProperty("denom")){if(!_.isString(X.denom))return"denom: string expected"}if(X.amount!=null&&X.hasOwnProperty("amount")){if(!_.isString(X.amount))return"amount: string expected"}return null},Z.fromObject=function(X){if(X instanceof q.cosmos.base.v1beta1.Coin)return X;let L=new q.cosmos.base.v1beta1.Coin;if(X.denom!=null)L.denom=String(X.denom);if(X.amount!=null)L.amount=String(X.amount);return L},Z.toObject=function(X,L){if(!L)L={};let J={};if(L.defaults)J.denom="",J.amount="";if(X.denom!=null&&X.hasOwnProperty("denom"))J.denom=X.denom;if(X.amount!=null&&X.hasOwnProperty("amount"))J.amount=X.amount;return J},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),H.DecCoin=(()=>{function Z(Q){if(Q){for(let X=Object.keys(Q),L=0;L<X.length;++L)if(Q[X[L]]!=null)this[X[L]]=Q[X[L]]}}return Z.prototype.denom="",Z.prototype.amount="",Z.create=function(X){return new Z(X)},Z.encode=function(X,L){if(!L)L=P.create();if(X.denom!=null&&Object.hasOwnProperty.call(X,"denom"))L.uint32(10).string(X.denom);if(X.amount!=null&&Object.hasOwnProperty.call(X,"amount"))L.uint32(18).string(X.amount);return L},Z.encodeDelimited=function(X,L){return this.encode(X,L).ldelim()},Z.decode=function(X,L){if(!(X instanceof O))X=O.create(X);let J=L===void 0?X.len:X.pos+L,G=new q.cosmos.base.v1beta1.DecCoin;while(X.pos<J){let B=X.uint32();switch(B>>>3){case 1:G.denom=X.string();break;case 2:G.amount=X.string();break;default:X.skipType(B&7);break}}return G},Z.decodeDelimited=function(X){if(!(X instanceof O))X=new O(X);return this.decode(X,X.uint32())},Z.verify=function(X){if(typeof X!=="object"||X===null)return"object expected";if(X.denom!=null&&X.hasOwnProperty("denom")){if(!_.isString(X.denom))return"denom: string expected"}if(X.amount!=null&&X.hasOwnProperty("amount")){if(!_.isString(X.amount))return"amount: string expected"}return null},Z.fromObject=function(X){if(X instanceof q.cosmos.base.v1beta1.DecCoin)return X;let L=new q.cosmos.base.v1beta1.DecCoin;if(X.denom!=null)L.denom=String(X.denom);if(X.amount!=null)L.amount=String(X.amount);return L},Z.toObject=function(X,L){if(!L)L={};let J={};if(L.defaults)J.denom="",J.amount="";if(X.denom!=null&&X.hasOwnProperty("denom"))J.denom=X.denom;if(X.amount!=null&&X.hasOwnProperty("amount"))J.amount=X.amount;return J},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),H.IntProto=(()=>{function Z(Q){if(Q){for(let X=Object.keys(Q),L=0;L<X.length;++L)if(Q[X[L]]!=null)this[X[L]]=Q[X[L]]}}return Z.prototype.int="",Z.create=function(X){return new Z(X)},Z.encode=function(X,L){if(!L)L=P.create();if(X.int!=null&&Object.hasOwnProperty.call(X,"int"))L.uint32(10).string(X.int);return L},Z.encodeDelimited=function(X,L){return this.encode(X,L).ldelim()},Z.decode=function(X,L){if(!(X instanceof O))X=O.create(X);let J=L===void 0?X.len:X.pos+L,G=new q.cosmos.base.v1beta1.IntProto;while(X.pos<J){let B=X.uint32();switch(B>>>3){case 1:G.int=X.string();break;default:X.skipType(B&7);break}}return G},Z.decodeDelimited=function(X){if(!(X instanceof O))X=new O(X);return this.decode(X,X.uint32())},Z.verify=function(X){if(typeof X!=="object"||X===null)return"object expected";if(X.int!=null&&X.hasOwnProperty("int")){if(!_.isString(X.int))return"int: string expected"}return null},Z.fromObject=function(X){if(X instanceof q.cosmos.base.v1beta1.IntProto)return X;let L=new q.cosmos.base.v1beta1.IntProto;if(X.int!=null)L.int=String(X.int);return L},Z.toObject=function(X,L){if(!L)L={};let J={};if(L.defaults)J.int="";if(X.int!=null&&X.hasOwnProperty("int"))J.int=X.int;return J},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),H.DecProto=(()=>{function Z(Q){if(Q){for(let X=Object.keys(Q),L=0;L<X.length;++L)if(Q[X[L]]!=null)this[X[L]]=Q[X[L]]}}return Z.prototype.dec="",Z.create=function(X){return new Z(X)},Z.encode=function(X,L){if(!L)L=P.create();if(X.dec!=null&&Object.hasOwnProperty.call(X,"dec"))L.uint32(10).string(X.dec);return L},Z.encodeDelimited=function(X,L){return this.encode(X,L).ldelim()},Z.decode=function(X,L){if(!(X instanceof O))X=O.create(X);let J=L===void 0?X.len:X.pos+L,G=new q.cosmos.base.v1beta1.DecProto;while(X.pos<J){let B=X.uint32();switch(B>>>3){case 1:G.dec=X.string();break;default:X.skipType(B&7);break}}return G},Z.decodeDelimited=function(X){if(!(X instanceof O))X=new O(X);return this.decode(X,X.uint32())},Z.verify=function(X){if(typeof X!=="object"||X===null)return"object expected";if(X.dec!=null&&X.hasOwnProperty("dec")){if(!_.isString(X.dec))return"dec: string expected"}return null},Z.fromObject=function(X){if(X instanceof q.cosmos.base.v1beta1.DecProto)return X;let L=new q.cosmos.base.v1beta1.DecProto;if(X.dec!=null)L.dec=String(X.dec);return L},Z.toObject=function(X,L){if(!L)L={};let J={};if(L.defaults)J.dec="";if(X.dec!=null&&X.hasOwnProperty("dec"))J.dec=X.dec;return J},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),H})(),z})(),Y})();function O6(Y){if(Y instanceof Uint8Array)return Y;if(typeof Y==="string")return Uint8Array.from(globalThis.atob(Y),(H)=>H.charCodeAt(0));throw TypeError("address must be Uint8Array or base64 string")}var $0=(Y)=>{let z=Y;return q.types.MsgSend.encode({amount:z.amount,fromAddress:O6(z.fromAddress),toAddress:O6(z.toAddress)}).finish()},y0=(Y)=>{let z=Y;return q.types.MsgDeposit.encode({coins:z.coins.map((H)=>({amount:H.amount,asset:H.asset})),memo:z.memo,signer:O6(z.signer)}).finish()};function d(){return{...C0,"/types.MsgDeposit":y0,"/types.MsgSend":$0}}function j(Y,z=Y===j6.THORChain?"thor":"maya"){let H=Y===j6.THORChain?"thorchain":"mayachain",Z={"/types.MsgDeposit":{aminoType:`${H}/MsgDeposit`,fromAmino:({signer:Q,...X})=>({...X,signer:t(Q)}),toAmino:({signer:Q,...X})=>({...X,signer:typeof Q==="string"?r(Q,z):Q})},"/types.MsgSend":{aminoType:`${H}/MsgSend`,fromAmino:({from_address:Q,to_address:X,...L})=>({...L,fromAddress:t(Q),toAddress:t(X)}),toAmino:({fromAddress:Q,toAddress:X,...L})=>({...L,from_address:typeof Q==="string"?r(Q,z):Q,to_address:typeof X==="string"?r(X,z):X})}};return Object.assign(Z,{fromAmino(Q){let X=Object.entries(Z).find(([,G])=>G.aminoType===Q.type);if(!X)throw TypeError(`No converter for amino type ${Q.type}`);let[L,J]=X;return{typeUrl:L,value:J.fromAmino(Q.value)}},toAmino(Q){let X=Z[Q.typeUrl];if(!X)throw TypeError(`No converter for type URL ${Q.typeUrl}`);return{type:X.aminoType,value:X.toAmino(Q.value)}}})}var g8=C(Z6.THORChain).gas,i8=C(Z6.Maya).gas,u6=({sender:Y,recipient:z,assetValue:H})=>{return{type:`${H.chain===Z6.Maya?"mayachain":"thorchain"}/MsgSend`,value:{amount:[{amount:H.getBaseValue("string"),denom:y(H.symbol,!0)}],from_address:Y,to_address:z}}},l6=({sender:Y,assetValue:z,memo:H=""})=>{return{type:`${z.chain===Z6.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:z.getBaseValue("string"),asset:e(z)}],memo:H,signer:Y}}},I6=({sender:Y,recipient:z,assetValue:H,memo:Z})=>{return!z?l6({assetValue:H,memo:Z,sender:Y}):u6({assetValue:H,recipient:z,sender:Y})};function b6(Y,z){for(let H of["/types.MsgDeposit","/types.MsgSend"]){let Z=Y[H];if(Z.aminoType===z)return{fromAmino:Z.fromAmino,typeUrl:H}}return null}var h=(Y,z)=>{let H=j(z),Z=b6(H,Y.type);if(!Z)throw new B6("toolbox_cosmos_invalid_params",{error:`No converter for amino type ${Y.type}`});return{typeUrl:Z.typeUrl,value:Z.fromAmino(Y.value)}},p6=async({rpcUrl:Y,sender:z})=>{let Z=await(await $(Y)).getAccount(z);if(!Z)throw new B6("toolbox_cosmos_account_not_found",{sender:z});return Z};async function d6(Y){let{assetValue:z,recipient:H,memo:Z,sender:Q,asSignable:X,asAminoMessage:L,sequence:J,accountNumber:G}=Y,B=Y.sweep?await E6({assetValue:z,sender:Q}):z;if(H)return h0({accountNumber:G,asAminoMessage:L,asSignable:X,assetValue:B,memo:Z,recipient:H,sender:Q,sequence:J});return u0({accountNumber:G,asAminoMessage:L,asSignable:X,assetValue:B,memo:Z,sender:Q,sequence:J})}async function E6({assetValue:Y,sender:z}){let H=Y.chain,Z=await N6(H),X=await(await $(Z)).getAllBalances(z),L=Y.isGasAsset?(await s(H)).getBaseValue("bigint"):0n;return m({assetValue:Y,balances:X,denom:y(Y.symbol,!0),feeAmount:L})}async function h0({sender:Y,recipient:z,assetValue:H,memo:Z="",asSignable:Q=!0,asAminoMessage:X=!1,sequence:L,accountNumber:J}){let G=H.chain,B=J!==void 0&&L!==void 0?void 0:await p6({rpcUrl:await N6(G),sender:Y}),{chainId:U}=h6(G),V=u6({assetValue:H,recipient:z,sender:Y}),T=Q?h(X?V:u(V),G):V;return{accountNumber:J??Number(B?.accountNumber),chainId:U,fee:C(G),memo:Z,msgs:[T],sequence:L??Number(B?.sequence)}}async function u0({sender:Y,assetValue:z,memo:H="",asSignable:Z=!0,asAminoMessage:Q=!1,sequence:X,accountNumber:L}){let J=z.chain,G=L!==void 0&&X!==void 0?void 0:await p6({rpcUrl:await N6(J),sender:Y}),{chainId:B}=h6(J),U=l6({assetValue:z,memo:H,sender:Y}),V=Z?h(Q?U:u(U),J):U;return{accountNumber:L??Number(G?.accountNumber),chainId:B,fee:C(J),memo:H,msgs:[V],sequence:X??Number(G?.sequence)}}function u(Y){if(Y.type==="thorchain/MsgSend"||Y.type==="mayachain/MsgSend")return Y;return{...Y,value:{...Y.value,coins:Y.value.coins.map((z)=>{let H=j0.from({asset:z.asset}),Z=(H.isSynthetic?H.symbol.split("/")?.[1]:H.symbol)?.toUpperCase(),Q=(H.isSynthetic?H.symbol.split("/")?.[0]:H.chain)?.toUpperCase();return{...z,asset:{chain:Q,symbol:Z,synth:H.isSynthetic,ticker:H.ticker}}})}}}function Q6({chain:Y,memo:z,msgs:H}){let Z=d(),Q=j(Y),L=H.map((J)=>{let G=b6(Q,J.type);if(!G)throw new B6("toolbox_cosmos_invalid_params",{error:`No converter for amino type ${J.type}`});return{typeUrl:G.typeUrl,value:G.fromAmino(J.value)}}).map((J)=>f0(J,Z));return w0({memo:z,messages:L})}import{Chain as g,SwapKitError as k8}from"@swapkit/helpers";import{secp256k1 as l0}from"@noble/curves/secp256k1.js";import{base64 as V6,bech32 as U6}from"@scure/base";import{HDKey as b0}from"@scure/bip32";import{verifySignature as p0,createWalletFromMnemonic as d0,createWalletFromPrivateKey as c0,mnemonicToSeed as m0,signDirect as n0}from"@swapkit/cosmos-signer";import{AssetValue as M6,applyFeeMultiplier as c6,Chain as F,CosmosChainPrefixes as t6,DerivationPath as g0,derivationPathToString as m6,FeeOption as T6,getChainConfig as i0,getRPCUrl as n,NetworkDerivationPath as o0,SwapKitError as f,SwapKitNumber as K6,updateDerivationPath as t0}from"@swapkit/helpers";import{SwapKitApi as r6}from"@swapkit/helpers/api";import{PubKey as r0}from"cosmjs-types/cosmos/crypto/secp256k1/keys";import{match as a0,P as n6}from"ts-pattern";async function a6(Y,z){try{let Z=(await r6.getGasRate()).find((Q)=>Q.chainId===Y)?.value;return Z?Number.parseFloat(Z):z}catch{return z}}function s6(Y){let z=[{address:Y.address,algo:"secp256k1",pubkey:Y.publicKey}];return{getAccounts:()=>Promise.resolve(z),async signDirect(H,Z){if(H!==Y.address)throw new f("toolbox_cosmos_signer_not_defined");let Q=await n0(Y.privateKey,Y.publicKey,{accountNumber:Z.accountNumber,authInfoBytes:Z.authInfoBytes,bodyBytes:Z.bodyBytes,chainId:Z.chainId});return{signature:Q.signature,signed:{accountNumber:Q.signed.accountNumber,authInfoBytes:Q.signed.authInfoBytes,bodyBytes:Q.signed.bodyBytes,chainId:Q.signed.chainId}}}}}async function g6({phrase:Y,prefix:z,...H}){let Z="derivationPath"in H?H.derivationPath:`${g0[H.chain]}/${H.index}`,Q=await d0({hdPath:Z,mnemonic:Y,prefix:z??""});return s6(Q)}async function s0({privateKey:Y,prefix:z}){let H=c0({prefix:z,privateKey:Y});return s6(H)}var i6={[F.Cosmos]:1000,[F.Kujira]:1000,[F.Noble]:1000,[F.THORChain]:5000000,[F.Maya]:5000000,[F.Harbor]:5000000};function e0(Y){return async function({signature:H,message:Z,address:Q}){let X=await Y(Q);if(!X?.pubkey)throw new f("toolbox_cosmos_verify_signature_no_pubkey");let L=X.pubkey.type==="/cosmos.crypto.secp256k1.PubKey"?r0.decode(X.pubkey.value).key:X.pubkey.value;return p0(V6.decode(Z),V6.decode(H),L)}}function X6({chain:Y,...z}){let H=t6[Y],Z="index"in z?z.index||0:0,Q=m6("derivationPath"in z&&z.derivationPath?z.derivationPath:t0(o0[Y],{index:Z})),X;async function L(){if(X)return X;return X=await a0(z).with({phrase:n6.string},({phrase:N})=>g6({derivationPath:Q,phrase:N,prefix:H})).with({signer:n6.any},({signer:N})=>N).otherwise(()=>{return}),X}async function J(N){let I=await n(Y);return(await $(I)).getAccount(N)}async function G(){let N=await L(),[I]=await N?.getAccounts()||[];return I?.address}async function B(){let N=await L(),[I]=await N?.getAccounts()||[];if(!I?.pubkey)throw new f("toolbox_cosmos_signer_not_defined");return V6.encode(I?.pubkey)}async function U(N){let I=await L(),W=await G(),E=await n(Y);if(!(I&&W))throw new f("toolbox_cosmos_signer_not_defined");return(await p(E,I)).sign(W,N.msgs,N.fee,N.memo,{accountNumber:BigInt(N.accountNumber),chainId:N.chainId,sequence:N.sequence})}async function V(N){let I=await L(),W=await G(),E=await n(Y);if(!(I&&W))throw new f("toolbox_cosmos_signer_not_defined");let M=await(await p(E,I)).signAndBroadcast(W,N.msgs,N.fee,N.memo);if(M.code!==0)throw new f("core_swap_transaction_error",{code:M.code,message:M.rawLog});return M.transactionHash}async function T({recipient:N,assetValue:I,memo:W="",feeRate:E,feeOptionKey:R=T6.Fast,sweep:M}){let x=await L(),A=await G();if(!(x&&A))throw new f("toolbox_cosmos_signer_not_defined");let v=await n(Y),z6=M6.from({chain:Y}),Y6=e(z6),b=Z8(E||(await o6(Y,i6[Y]))[R],Y6,Y),H6=await p(v,x),c=y(I.symbol),L6=[{amount:(M?m({assetValue:I,balances:await R6(Y)(A),denom:c,feeAmount:W6(b.amount,c)}):I).getBaseValue("string"),denom:c}],{transactionHash:J6}=await H6.sendTokens(A,N,L6,b,W);return J6}return{createPrivateKeyFromPhrase:z8(Q),createTransaction:f6,fetchFeeRateFromSwapKit:a6,getAccount:J,getAddress:G,getBalance:async(N,I)=>{let W=await R6(Y)(N),E=await Promise.all(W.filter(({denom:R})=>R&&!R.includes("IBC/")&&!([F.THORChain,F.Maya].includes(Y)&&R.split("-").length>2)).map(({denom:R,amount:M})=>{let x=[F.THORChain,F.Maya].includes(Y)&&(R.includes("/")||R.includes("˜"))?`${Y}.${R}`:R;return w6(x,M)}));if(E.length===0)return[M6.from({chain:Y})];return E},getBalanceAsDenoms:R6(Y),getFees:()=>o6(Y,i6[Y]),getPubKey:B,getSignerFromPhrase:({phrase:N,derivationPath:I})=>g6({derivationPath:m6(I),index:Z,phrase:N,prefix:H}),getSignerFromPrivateKey:(N)=>s0({prefix:H,privateKey:N}),signAndBroadcastTransaction:V,signTransaction:U,transfer:T,validateAddress:X8(Y),verifySignature:e0(J)}}async function _Z(Y,z){try{let Z=(await r6.getGasRate()).find((Q)=>Q.chainId===Y)?.value;return Z?Number.parseFloat(Z):z}catch{return z}}function WZ({assetValue:{chain:Y}}){return M6.from({chain:Y,value:Q8(Y)})}async function o6(Y,z){let{chainId:H,baseDecimal:Z}=i0(Y),Q=await a6(H,z);return{average:K6.fromBigInt(BigInt(Q),Z),fast:K6.fromBigInt(BigInt(c6(Q,T6.Fast,!0)),Z),fastest:K6.fromBigInt(BigInt(c6(Q,T6.Fastest,!0)),Z)}}function Z8(Y,z,H){return{amount:[{amount:typeof Y==="number"?Y.toString():Y.getBaseValue("string"),denom:z}],gas:C(H).gas}}function Q8(Y){return{[F.Cosmos]:0.007,[F.Kujira]:0.02,[F.Noble]:0.01,[F.THORChain]:0.02,[F.Maya]:0.02,[F.Harbor]:0.02}[Y]||0}function X8(Y){let z=t6[Y];return function(Z){if(!Z.startsWith(z))return!1;try{let{prefix:Q,words:X}=U6.decode(Z);return U6.encode(Q,X)===Z.toLocaleLowerCase()}catch{return!1}}}function R6(Y){return async function(H){let Z=await n(Y);return(await(await $(Z)).getAllBalances(H)).map((J)=>({...J,denom:J.denom.includes("/")?J.denom.toUpperCase():J.denom}))}}function z8(Y){return async function(H){let Z=await m0(H),X=b0.fromMasterSeed(Z).derive(Y);if(!X.privateKey)throw new f("toolbox_cosmos_invalid_params",{error:"HDKey derivation produced no private key"});return l0.getPublicKey(X.privateKey,!0),Uint8Array.from(X.privateKey)}}import{secp256k1 as Y8}from"@noble/curves/secp256k1.js";import{base64 as w}from"@scure/base";import{buildMultisignedTx as H8,createMultisigThresholdPubkey as L8,signAmino as J8,createWalletFromMnemonic as G8,encodeTxRaw as q8,multisigPubkeyToAddress as _8,singlePubkeyToAddress as Z0}from"@swapkit/cosmos-signer";import{CosmosChainPrefixes as W8,derivationPathToString as O8,FeeOption as x6,getRPCUrl as Q0,NetworkDerivationPath as N8,SKConfig as B8,SwapKitError as l,updateDerivationPath as I8}from"@swapkit/helpers";import{match as E8,P as e6}from"ts-pattern";function U8(Y){let z=[{address:Y.address,algo:"secp256k1",pubkey:Y.publicKey}];return{accounts:z,getAccounts:()=>Promise.resolve(z),async signAmino(H,Z){if(H!==Y.address)throw new l("toolbox_cosmos_signer_not_defined");let Q=await J8(Y.privateKey,Y.publicKey,{signDoc:Z});return{signature:Q.signature,signed:Q.signed}}}}function K8({prefix:Y,derivationPath:z}){return async function(Z,Q=0){let X=await G8({hdPath:`${z}/${Q}`,mnemonic:Z,prefix:Y});return U8(X)}}function R8(Y){return w.encode(Y)}function V8(Y,z){return async function({wallet:Z,tx:Q}){let{msgs:X,accountNumber:L,sequence:J,chainId:G,fee:B,memo:U}=typeof Q==="string"?JSON.parse(Q):Q,V=(await Z.getAccounts())?.[0]?.address||"",T=j(Y,z),N=d(),I=await y6(Z,{aminoTypes:T,registry:N}),W=[];for(let M of X){let x=h(M,Y);W.push(x)}let{signatures:[E]}=await I.sign(V,W,B,U,{accountNumber:BigInt(L),chainId:G,sequence:J});return{bodyBytes:Q6({chain:Y,memo:U,msgs:X.map(u)}),signature:R8(E)}}}function X0(Y){if(Y.length!==33||Y[0]!==2&&Y[0]!==3)throw new l("toolbox_cosmos_invalid_params",{error:"Invalid compressed secp256k1 pubkey (must be 33 bytes starting with 0x02 or 0x03)"});return{type:"tendermint/PubKeySecp256k1",value:w.encode(Y)}}function M8({prefix:Y,chain:z}){return async function(Z,Q,X,L,J){let G=await Q0(z),{sequence:B,fee:U}=JSON.parse(Z),V=z0(X,L),T=Q.map((W)=>[Z0(X0(w.decode(W.pubKey)),Y),w.decode(W.signature)]),N=await $(G),{transactionHash:I}=await N.broadcastTx(H8({bodyBytes:J,fee:{amount:U.amount,gasLimit:BigInt(U.gas),...U.payer?{payer:U.payer}:{},...U.granter?{granter:U.granter}:{}},multisigPubkey:V,prefix:Y,sequence:B,signatures:new Map(T)}));return I}}function z0(Y,z,H=!0){return L8(Y.map((Z)=>X0(w.decode(Z))),z,H)}function T8(Y){return w.decode(Y)}function x8({privateKey:Y,message:z}){let H=Y8.sign(w.decode(z),Y,{lowS:!0,prehash:!1});return Promise.resolve(w.encode(H))}function Y0({chain:Y,...z}){let{isStagenet:H}=B8.get("envs"),Z=`${H?"s":""}${W8[Y]}`,Q="index"in z?z.index||0:0,X="derivationPath"in z&&z.derivationPath?z.derivationPath:I8(N8[Y],{index:Q}),L=X6({chain:Y,...z}),J=C(Y),G;function B(){return G??=E8(z).with({phrase:e6.string},({phrase:W})=>L.getSignerFromPhrase({derivationPath:X,phrase:W})).with({signer:e6.any},({signer:W})=>Promise.resolve(W)).otherwise(()=>Promise.resolve(void 0)),G}async function U(){let W=await Q0(Y),E=await B();if(!E)throw new l("toolbox_cosmos_no_signer");let R=d(),M=j(Y,Z),x=await p(W,E,{aminoTypes:M,registry:R});return{signer:E,signingClient:x}}async function V({fee:W,memo:E,msgs:R}){let{signer:M,signingClient:x}=await U(),A=(await M.getAccounts())?.[0]?.address;if(!A)throw new l("toolbox_cosmos_signer_not_defined");let v=await x.signAndBroadcast(A,R,W,E);if(v.code!==0)throw new l("core_swap_transaction_error",{code:v.code,message:v.rawLog});return v.transactionHash}async function T(){let W=await s(Y);return{[x6.Average]:W,[x6.Fast]:W,[x6.Fastest]:W}}async function N({assetValue:W,memo:E="",recipient:R,sweep:M}){let{signer:x,signingClient:A}=await U(),v=(await x.getAccounts())?.[0]?.address;if(!v)throw new l("toolbox_cosmos_no_signer");let z6="signAmino"in x,Y6=M?await E6({assetValue:W,sender:v}):W,b=I6({assetValue:Y6,memo:E,recipient:R,sender:v});if(z6){let k6=h(b,Y),{signatures:L6,authInfoBytes:J6}=await A.sign(v,[k6],J,E),H0=q8({authInfoBytes:J6,bodyBytes:Q6({chain:Y,memo:E,msgs:[b].map(u)}),signatures:L6});return(await A.broadcastTx(H0)).transactionHash}let H6=u(b),c=h(H6,Y);return V({fee:J,memo:E,msgs:[c]})}async function I(W){let{signer:E,signingClient:R}=await U(),M=(await E.getAccounts())?.[0]?.address;if(!M)throw new l("toolbox_cosmos_signer_not_defined");return R.sign(M,W.msgs,W.fee,W.memo,{accountNumber:BigInt(W.accountNumber),chainId:W.chainId,sequence:W.sequence})}return{...L,broadcastMultisigTx:M8({chain:Y,prefix:Z}),buildAminoMsg:I6,buildEncodedTxBody:Q6,convertToSignable:h,createDefaultAminoTypes:()=>j(Y,Z),createDefaultRegistry:d,createMultisig:z0,createTransaction:d6,deposit:N,getFees:T,importSignature:T8,parseAminoMessageForDirectSigning:u,pubkeyToAddress:(W)=>{if(W.type==="tendermint/PubKeyMultisigThreshold")return _8(W,Z);return Z0(W,Z)},secp256k1HdWalletFromMnemonic:K8({derivationPath:O8(X),prefix:Z}),signAndBroadcastTransaction:V,signMultisigTx:V8(Y,Z),signTransaction:I,signWithPrivateKey:x8,transfer:N}}var FZ=(Y,z)=>{switch(Y){case g.Cosmos:case g.Kujira:case g.Noble:return X6({chain:Y,...z});case g.Maya:case g.THORChain:return Y0({chain:Y,...z});default:throw new k8("toolbox_cosmos_not_supported",{chain:Y})}};export{e0 as verifySignature,u6 as transferMsgAmino,P8 as toBase64,E6 as resolveThorchainSweepAssetValue,u as parseAminoMessageForDirectSigning,s as getThorchainNativeFee,m as getSweepAssetValue,s0 as getSignerFromPrivateKey,g6 as getSignerFromPhrase,y as getMsgSendDenom,_Z as getFeeRateFromSwapKit,W6 as getFeeAmountForDenom,e as getDenomWithChain,C as getDefaultChainFee,FZ as getCosmosToolbox,X8 as getCosmosAddressValidator,w6 as getAssetFromDenom,A8 as fromBase64,a6 as fetchFeeRateFromSwapKit,WZ as estimateTransactionFee,l6 as depositMsgAmino,d6 as createTransaction,Y0 as createThorchainToolbox,$ as createStargateClient,p as createSigningStargateClient,y6 as createOfflineStargateClient,d as createDefaultRegistry,j as createDefaultAminoTypes,X6 as createCosmosToolbox,f6 as cosmosCreateTransaction,h as convertToSignable,h0 as buildTransferTx,Q6 as buildEncodedTxBody,u0 as buildDepositTx,I6 as buildAminoMsg,t as bech32ToBase64,r as base64ToBech32,E0 as YUM_KUJIRA_FACTORY_DENOM,A6 as USK_KUJIRA_FACTORY_DENOM,g8 as THORCHAIN_GAS_VALUE,i8 as MAYA_GAS_VALUE,R0 as DEFAULT_NOBLE_FEE_MAINNET,K0 as DEFAULT_KUJI_FEE_MAINNET,U0 as DEFAULT_COSMOS_FEE_MAINNET};
|
|
1
|
+
import"../../chunk-xbdjxeqd.js";import{base64 as o,bech32 as i}from"@scure/base";import{SwapKitError as L0}from"@swapkit/helpers";function t(Y){return o.encode(Uint8Array.from(i.fromWords(i.decode(Y).words)))}function r(Y,z="thor"){return i.encode(z,i.toWords(o.decode(Y)))}function P8(Y){return o.encode(Y)}function A8(Y){if(!Y.match(/^[a-zA-Z0-9+/]*={0,2}$/))throw new L0("toolbox_cosmos_invalid_params",{error:"Invalid base64 string format"});return o.decode(Y)}import{encodeMessage as f0,encodeTxBody as w0}from"@swapkit/cosmos-signer";import{AssetValue as j0,Chain as Z6,getChainConfig as h6,getRPCUrl as N6,SwapKitError as B6}from"@swapkit/helpers";import{base64 as G6}from"@scure/base";import{broadcastTx as a,getAccount as P6,getBalances as J0,createTendermintRpc as G0,defaultEncoders as q0,encodeAuthInfo as F6,encodeMessage as _0,encodePubkey as W0,encodeTxBody as O0,encodeTxRaw as v6,makeStdSignDoc as N0}from"@swapkit/cosmos-signer";import{AssetValue as q6,Chain as K,getChainConfig as S,getRPCUrl as B0,RequestClient as I0,SKConfig as D6,SwapKitError as D,SwapKitNumber as _6}from"@swapkit/helpers";var A6="FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK",E0="FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM",U0={amount:[{amount:"500",denom:"uatom"}],gas:"200000"},K0={amount:[{amount:"1000",denom:"ukuji"}],gas:"200000"},R0={amount:[{amount:"1000",denom:"uusdc"}],gas:"200000"};function C(Y){switch(Y){case K.Maya:return{amount:[],gas:"10000000000"};case K.THORChain:return{amount:[],gas:"500000000"};case K.Kujira:return K0;case K.Noble:return R0;default:return U0}}async function s(Y){let{isStagenet:z}=D6.get("envs"),H=D6.get("thornodeUrls"),Z=Y===K.Maya,X=`${Z?z?H.MAYA_STAGENET:H.MAYA:z?H.THOR_STAGENET:H.THOR}/${Z?"mayachain":"thorchain"}/constants`,L=S(Y).baseDecimal;try{let{int_64_values:{NativeTransactionFee:J}}=await I0.get(X);if(!Number.isInteger(J)||J<=0)throw new D("toolbox_cosmos_invalid_fee",{nativeFee:J.toString()});return _6.fromBigInt(BigInt(J),L)}catch{let J=Z?10000000000n:2000000n;return _6.fromBigInt(J,L)}}var y=(Y,z=!1)=>{if(z)return Y.toLowerCase();switch(Y){case"uUSK":case"USK":return A6;case"uYUM":case"YUM":return E0;case"uKUJI":case"KUJI":return"ukuji";case"ATOM":case"uATOM":return"uatom";case"uUSDC":case"USDC":case"NOBLE":return"uusdc";default:return Y}},e=({symbol:Y,chain:z})=>{if(z===K.Maya)return(Y.toUpperCase()!=="CACAO"?Y:`${K.Maya}.${Y}`).toUpperCase();if(z===K.THORChain)return(["RUNE","TCY","RUJI"].includes(Y.toUpperCase())?`${K.THORChain}.${Y}`:Y).toUpperCase();return y(Y,!1)},V0=()=>typeof window<"u"?{}:{referer:"https://sdk.swapkit.dev",referrer:"https://sdk.swapkit.dev"};function S6(Y){return G0(Y,{headers:V0()})}function C6(Y){return{amount:Y.amount,denom:Y.denom}}function M0(Y,z){if(!Y)return null;if("toAmino"in Y&&typeof Y.toAmino==="function")return null;let Z=Y[z];return Z?{aminoType:Z.aminoType,toAmino:Z.toAmino}:null}async function $(Y){let z=S6(Y);return{async broadcastTx(H){let Z=await a(z,H,"sync");if(Z.code!==0)throw new D("core_swap_transaction_error",{code:Z.code,message:Z.log});return{code:Z.code,rawLog:Z.log,transactionHash:Z.hash}},async getAccount(H){let Z=await P6(z,H);if(!Z)return null;return{accountNumber:Number(Z.accountNumber),address:Z.address,pubkey:Z.pubKey?{type:Z.pubKey.typeUrl,value:Z.pubKey.key}:null,sequence:Number(Z.sequence)}},async getAllBalances(H){return(await J0(z,H)).map((Q)=>({amount:Q.amount,denom:Q.denom}))}}}function $6(Y,z={}){let H=T0(Y);async function Z(Q,X,L,J,G){let U=(await Y.getAccounts()).find((E)=>E.address===Q);if(!U)throw new D("toolbox_cosmos_signer_not_defined");let V=D0({memo:J,messages:X,registry:z.registry}),T=W0({type:"tendermint/PubKeySecp256k1",value:G6.encode(U.pubkey)});if(H){let E=X.map((v)=>v0(v,z.aminoTypes)),R=N0({accountNumber:G.accountNumber,chainId:G.chainId,fee:x0(L),memo:J,msgs:E,sequence:G.sequence}),M=await Y.signAmino(Q,R),x=F6({fee:F0(M.signed.fee,L),signerInfos:[{mode:"amino",pubkey:T,sequence:BigInt(M.signed.sequence)}]}),A=G6.decode(M.signature.signature);return{authInfoBytes:x,bodyBytes:V,signatures:[A]}}let N=F6({fee:k0(L),signerInfos:[{mode:"direct",pubkey:T,sequence:BigInt(G.sequence)}]}),I=await Y.signDirect(Q,{accountNumber:G.accountNumber,authInfoBytes:N,bodyBytes:V,chainId:G.chainId}),W=G6.decode(I.signature.signature);return{authInfoBytes:N,bodyBytes:V,signatures:[W]}}return{signWithRegistry:Z}}function T0(Y){return typeof Y.signAmino==="function"}function x0(Y){return{amount:Y.amount.map((z)=>({amount:z.amount,denom:z.denom})),gas:Y.gas,...Y.granter?{granter:Y.granter}:{},...Y.payer?{payer:Y.payer}:{}}}function k0(Y){return{amount:Y.amount.map(C6),gasLimit:BigInt(Y.gas),...Y.granter?{granter:Y.granter}:{},...Y.payer?{payer:Y.payer}:{}}}function F0(Y,z){return{amount:Y.amount.map(C6),gasLimit:BigInt(Y.gas),...Y.granter??z.granter?{granter:Y.granter??z.granter}:{},...Y.payer??z.payer?{payer:Y.payer??z.payer}:{}}}function v0(Y,z){if(z&&"toAmino"in z&&typeof z.toAmino==="function")return z.toAmino(Y);let H=M0(z,Y.typeUrl);if(!H){if(Y.typeUrl==="/cosmos.bank.v1beta1.MsgSend"){let Z=Y.value;return{type:"cosmos-sdk/MsgSend",value:{amount:Z.amount,from_address:Z.fromAddress,to_address:Z.toAddress}}}throw new D("toolbox_cosmos_invalid_params",{error:`No amino converter for ${Y.typeUrl}`})}return{type:H.aminoType,value:H.toAmino(Y.value)}}function D0(Y){let{memo:z,messages:H,registry:Z}=Y;if(Z&&"encode"in Z&&typeof Z.encode==="function")return Z.encode({typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:z,messages:H}});let Q={...q0,...Z??{}},X=H.map((L)=>_0(L,Q));return O0({memo:z,messages:X})}async function p(Y,z,H={}){let Z=typeof H==="string"?{}:H,Q=S6(Y),X=$6(z,Z);async function L(J,G){let B=await P6(Q,J);if(!B)throw new D("toolbox_cosmos_account_not_found",{sender:J});let U=G?.chainId??(await Q.status()).chainId;return{accountNumber:G?.accountNumber??B.accountNumber,chainId:U,sequence:G?.sequence??B.sequence}}return{async broadcastTx(J){let G=await a(Q,J,"sync");if(G.code!==0)throw new D("core_swap_transaction_error",{code:G.code,message:G.log});return{code:G.code,rawLog:G.log,transactionHash:G.hash}},async sendTokens(J,G,B,U,V=""){let T=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:{amount:B.map((R)=>({amount:R.amount,denom:R.denom})),fromAddress:J,toAddress:G}}],N=await L(J),I=await X.signWithRegistry(J,T,U,V,N),W=v6({authInfoBytes:I.authInfoBytes,bodyBytes:I.bodyBytes,signatures:I.signatures}),E=await a(Q,W,"sync");if(E.code!==0)throw new D("core_swap_transaction_error",{code:E.code,message:E.log});return{code:E.code,rawLog:E.log,transactionHash:E.hash}},async sign(J,G,B,U,V){let T=V??await L(J);return X.signWithRegistry(J,G,B,U,T)},async signAndBroadcast(J,G,B,U=""){let V=await L(J),T=await X.signWithRegistry(J,G,B,U,V),N=v6({authInfoBytes:T.authInfoBytes,bodyBytes:T.bodyBytes,signatures:T.signatures}),I=await a(Q,N,"sync");return{code:I.code,rawLog:I.log,transactionHash:I.hash}}}}async function y6(Y,z){let H=$6(Y,z??{});return{sign(Z,Q,X,L,J){if(!J)throw new D("toolbox_cosmos_invalid_params",{error:"createOfflineStargateClient.sign requires signerData"});return H.signWithRegistry(Z,Q,X,L,J)}}}var P0=(Y)=>{switch(Y){case K.Maya:case K.THORChain:return"/types.MsgSend";case K.Cosmos:case K.Kujira:case K.Noble:return"/cosmos.bank.v1beta1.MsgSend";default:throw new D("toolbox_cosmos_not_supported",{chain:Y})}};async function A0({client:Y,sender:z}){let H=await Y.getAccount(z);if(!H)throw new D("toolbox_cosmos_account_not_found",{sender:z});return H}async function f6({sender:Y,recipient:z,assetValue:H,memo:Z="",feeRate:Q,sequence:X,accountNumber:L,sweep:J}){let{chain:G,chainId:B}=H,U=L===void 0||X===void 0,V=J||U?await $(await B0(G)):void 0,T=U&&V?await A0({client:V,sender:Y}):void 0,N=q6.from({chain:G}),I=y(N.symbol),W=C(G),E=I&&Q?{amount:[{amount:Q.toString(),denom:I}],gas:W.gas}:W,R=y(H.symbol),M=H;if(J){if(!V)throw new D("toolbox_cosmos_account_not_found",{sender:Y});M=m({assetValue:H,balances:await V.getAllBalances(Y),denom:R,feeAmount:W6(E.amount,R)})}let x={amount:[{amount:M.getBaseValue("string"),denom:R}],fromAddress:Y,toAddress:z};return{accountNumber:L??Number(T?.accountNumber),chainId:B,fee:E,memo:Z,msgs:[{typeUrl:P0(G),value:x}],sequence:X??Number(T?.sequence)}}function W6(Y,z){let H=z.toLowerCase();return Y.reduce((Z,Q)=>Q.denom.toLowerCase()===H?Z+BigInt(Q.amount):Z,0n)}function m({assetValue:Y,balances:z,denom:H,feeAmount:Z=0n}){let Q=H.toLowerCase(),X=z.find(({denom:G})=>G.toLowerCase()===Q),L=BigInt(X?.amount??"0"),J=L-Z;if(J<=0n)throw new D("toolbox_sweep_amount_too_low",{asset:Y.toString(),balance:L.toString(),fee:Z.toString()});return Y.set(_6.fromBigInt(J,Y.decimal))}var S0={atom:{chain:K.Cosmos,decimals:S(K.Cosmos).baseDecimal},cacao:{chain:K.Maya,decimals:10},kuji:{chain:K.Kujira,decimals:S(K.Kujira).baseDecimal},maya:{asset:`${K.Maya}.${K.Maya}`,decimals:4},rune:{chain:K.THORChain,decimals:S(K.THORChain).baseDecimal},tcy:{asset:"THOR.TCY",decimals:S(K.THORChain).baseDecimal},uatom:{chain:K.Cosmos,decimals:S(K.Cosmos).baseDecimal},ukuji:{chain:K.Kujira,decimals:S(K.Kujira).baseDecimal},usdc:{chain:K.Noble,decimals:S(K.Noble).baseDecimal},uusdc:{chain:K.Noble,decimals:S(K.Noble).baseDecimal},"x/kuji":{asset:"THOR.KUJI",decimals:S(K.THORChain).baseDecimal},[A6.toLowerCase()]:{asset:`${K.Kujira}.USK`,decimals:S(K.Kujira).baseDecimal}},w6=(Y,z)=>{let H=S0[Y.toLowerCase()];if(!H)return q6.from({asset:Y,fromBaseDecimal:8,value:z});let{chain:Z,asset:Q,decimals:X}=H,L=Z?{chain:Z}:{asset:Q};return q6.from({...L,fromBaseDecimal:X,value:z})};import{defaultEncoders as C0}from"@swapkit/cosmos-signer";import{Chain as j6}from"@swapkit/helpers";import k from"protobufjs/minimal.js";var O=k.Reader,P=k.Writer,_=k.util,q=k.roots.default||(k.roots.default={});q.common=(()=>{let Y={};return Y.Asset=(()=>{function z(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 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,Q){if(!Q)Q=P.create();if(Z.chain!=null&&Object.hasOwnProperty.call(Z,"chain"))Q.uint32(10).string(Z.chain);if(Z.symbol!=null&&Object.hasOwnProperty.call(Z,"symbol"))Q.uint32(18).string(Z.symbol);if(Z.ticker!=null&&Object.hasOwnProperty.call(Z,"ticker"))Q.uint32(26).string(Z.ticker);if(Z.synth!=null&&Object.hasOwnProperty.call(Z,"synth"))Q.uint32(32).bool(Z.synth);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.Asset;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.chain=Z.string();break;case 2:L.symbol=Z.string();break;case 3:L.ticker=Z.string();break;case 4:L.synth=Z.bool();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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(!_.isString(Z.chain))return"chain: string expected"}if(Z.symbol!=null&&Z.hasOwnProperty("symbol")){if(!_.isString(Z.symbol))return"symbol: string expected"}if(Z.ticker!=null&&Z.hasOwnProperty("ticker")){if(!_.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 Q=new q.common.Asset;if(Z.chain!=null)Q.chain=String(Z.chain);if(Z.symbol!=null)Q.symbol=String(Z.symbol);if(Z.ticker!=null)Q.ticker=String(Z.ticker);if(Z.synth!=null)Q.synth=Boolean(Z.synth);return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.defaults)X.chain="",X.symbol="",X.ticker="",X.synth=!1;if(Z.chain!=null&&Z.hasOwnProperty("chain"))X.chain=Z.chain;if(Z.symbol!=null&&Z.hasOwnProperty("symbol"))X.symbol=Z.symbol;if(Z.ticker!=null&&Z.hasOwnProperty("ticker"))X.ticker=Z.ticker;if(Z.synth!=null&&Z.hasOwnProperty("synth"))X.synth=Z.synth;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.Coin=(()=>{function z(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 z.prototype.asset=null,z.prototype.amount="",z.prototype.decimals=_.Long?_.Long.fromBits(0,0,!1):0,z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.asset!=null&&Object.hasOwnProperty.call(Z,"asset"))q.common.Asset.encode(Z.asset,Q.uint32(10).fork()).ldelim();if(Z.amount!=null&&Object.hasOwnProperty.call(Z,"amount"))Q.uint32(18).string(Z.amount);if(Z.decimals!=null&&Object.hasOwnProperty.call(Z,"decimals"))Q.uint32(24).int64(Z.decimals);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.Coin;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.asset=q.common.Asset.decode(Z,Z.uint32());break;case 2:L.amount=Z.string();break;case 3:L.decimals=Z.int64();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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 Q=q.common.Asset.verify(Z.asset);if(Q)return"asset."+Q}if(Z.amount!=null&&Z.hasOwnProperty("amount")){if(!_.isString(Z.amount))return"amount: string expected"}if(Z.decimals!=null&&Z.hasOwnProperty("decimals")){if(!_.isInteger(Z.decimals)&&!(Z.decimals&&_.isInteger(Z.decimals.low)&&_.isInteger(Z.decimals.high)))return"decimals: integer|Long expected"}return null},z.fromObject=function(Z){if(Z instanceof q.common.Coin)return Z;let Q=new q.common.Coin;if(Z.asset!=null){if(typeof Z.asset!=="object")throw TypeError(".common.Coin.asset: object expected");Q.asset=q.common.Asset.fromObject(Z.asset)}if(Z.amount!=null)Q.amount=String(Z.amount);if(Z.decimals!=null){if(_.Long)(Q.decimals=_.Long.fromValue(Z.decimals)).unsigned=!1;else if(typeof Z.decimals==="string")Q.decimals=Number.parseInt(Z.decimals,10);else if(typeof Z.decimals==="number")Q.decimals=Z.decimals;else if(typeof Z.decimals==="object")Q.decimals=new _.LongBits(Z.decimals.low>>>0,Z.decimals.high>>>0).toNumber()}return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.defaults)if(X.asset=null,X.amount="",_.Long){let L=new _.Long(0,0,!1);X.decimals=Q.longs===String?L.toString():Q.longs===Number?L.toNumber():L}else X.decimals=Q.longs===String?"0":0;if(Z.asset!=null&&Z.hasOwnProperty("asset"))X.asset=q.common.Asset.toObject(Z.asset,Q);if(Z.amount!=null&&Z.hasOwnProperty("amount"))X.amount=Z.amount;if(Z.decimals!=null&&Z.hasOwnProperty("decimals"))if(typeof Z.decimals==="number")X.decimals=Q.longs===String?String(Z.decimals):Z.decimals;else X.decimals=Q.longs===String?_.Long.prototype.toString.call(Z.decimals):Q.longs===Number?new _.LongBits(Z.decimals.low>>>0,Z.decimals.high>>>0).toNumber():Z.decimals;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.PubKeySet=(()=>{function z(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 z.prototype.secp256k1="",z.prototype.ed25519="",z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.secp256k1!=null&&Object.hasOwnProperty.call(Z,"secp256k1"))Q.uint32(10).string(Z.secp256k1);if(Z.ed25519!=null&&Object.hasOwnProperty.call(Z,"ed25519"))Q.uint32(18).string(Z.ed25519);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.PubKeySet;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.secp256k1=Z.string();break;case 2:L.ed25519=Z.string();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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(!_.isString(Z.secp256k1))return"secp256k1: string expected"}if(Z.ed25519!=null&&Z.hasOwnProperty("ed25519")){if(!_.isString(Z.ed25519))return"ed25519: string expected"}return null},z.fromObject=function(Z){if(Z instanceof q.common.PubKeySet)return Z;let Q=new q.common.PubKeySet;if(Z.secp256k1!=null)Q.secp256k1=String(Z.secp256k1);if(Z.ed25519!=null)Q.ed25519=String(Z.ed25519);return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.defaults)X.secp256k1="",X.ed25519="";if(Z.secp256k1!=null&&Z.hasOwnProperty("secp256k1"))X.secp256k1=Z.secp256k1;if(Z.ed25519!=null&&Z.hasOwnProperty("ed25519"))X.ed25519=Z.ed25519;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.Tx=(()=>{function z(H){if(this.coins=[],this.gas=[],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 z.prototype.id="",z.prototype.chain="",z.prototype.fromAddress="",z.prototype.toAddress="",z.prototype.coins=_.emptyArray,z.prototype.gas=_.emptyArray,z.prototype.memo="",z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.id!=null&&Object.hasOwnProperty.call(Z,"id"))Q.uint32(10).string(Z.id);if(Z.chain!=null&&Object.hasOwnProperty.call(Z,"chain"))Q.uint32(18).string(Z.chain);if(Z.fromAddress!=null&&Object.hasOwnProperty.call(Z,"fromAddress"))Q.uint32(26).string(Z.fromAddress);if(Z.toAddress!=null&&Object.hasOwnProperty.call(Z,"toAddress"))Q.uint32(34).string(Z.toAddress);if(Z.coins?.length)for(let X=0;X<Z.coins.length;++X)q.common.Coin.encode(Z.coins[X],Q.uint32(42).fork()).ldelim();if(Z.gas?.length)for(let X=0;X<Z.gas.length;++X)q.common.Coin.encode(Z.gas[X],Q.uint32(50).fork()).ldelim();if(Z.memo!=null&&Object.hasOwnProperty.call(Z,"memo"))Q.uint32(58).string(Z.memo);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.Tx;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.id=Z.string();break;case 2:L.chain=Z.string();break;case 3:L.fromAddress=Z.string();break;case 4:L.toAddress=Z.string();break;case 5:if(!L.coins?.length)L.coins=[];L.coins.push(q.common.Coin.decode(Z,Z.uint32()));break;case 6:if(!L.gas?.length)L.gas=[];L.gas.push(q.common.Coin.decode(Z,Z.uint32()));break;case 7:L.memo=Z.string();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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(!_.isString(Z.id))return"id: string expected"}if(Z.chain!=null&&Z.hasOwnProperty("chain")){if(!_.isString(Z.chain))return"chain: string expected"}if(Z.fromAddress!=null&&Z.hasOwnProperty("fromAddress")){if(!_.isString(Z.fromAddress))return"fromAddress: string expected"}if(Z.toAddress!=null&&Z.hasOwnProperty("toAddress")){if(!_.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 Q=0;Q<Z.coins.length;++Q){let X=q.common.Coin.verify(Z.coins[Q]);if(X)return"coins."+X}}if(Z.gas!=null&&Z.hasOwnProperty("gas")){if(!Array.isArray(Z.gas))return"gas: array expected";for(let Q=0;Q<Z.gas.length;++Q){let X=q.common.Coin.verify(Z.gas[Q]);if(X)return"gas."+X}}if(Z.memo!=null&&Z.hasOwnProperty("memo")){if(!_.isString(Z.memo))return"memo: string expected"}return null},z.fromObject=function(Z){if(Z instanceof q.common.Tx)return Z;let Q=new q.common.Tx;if(Z.id!=null)Q.id=String(Z.id);if(Z.chain!=null)Q.chain=String(Z.chain);if(Z.fromAddress!=null)Q.fromAddress=String(Z.fromAddress);if(Z.toAddress!=null)Q.toAddress=String(Z.toAddress);if(Z.coins){if(!Array.isArray(Z.coins))throw TypeError(".common.Tx.coins: array expected");Q.coins=[];for(let X=0;X<Z.coins.length;++X){if(typeof Z.coins[X]!=="object")throw TypeError(".common.Tx.coins: object expected");Q.coins[X]=q.common.Coin.fromObject(Z.coins[X])}}if(Z.gas){if(!Array.isArray(Z.gas))throw TypeError(".common.Tx.gas: array expected");Q.gas=[];for(let X=0;X<Z.gas.length;++X){if(typeof Z.gas[X]!=="object")throw TypeError(".common.Tx.gas: object expected");Q.gas[X]=q.common.Coin.fromObject(Z.gas[X])}}if(Z.memo!=null)Q.memo=String(Z.memo);return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.arrays||Q.defaults)X.coins=[],X.gas=[];if(Q.defaults)X.id="",X.chain="",X.fromAddress="",X.toAddress="",X.memo="";if(Z.id!=null&&Z.hasOwnProperty("id"))X.id=Z.id;if(Z.chain!=null&&Z.hasOwnProperty("chain"))X.chain=Z.chain;if(Z.fromAddress!=null&&Z.hasOwnProperty("fromAddress"))X.fromAddress=Z.fromAddress;if(Z.toAddress!=null&&Z.hasOwnProperty("toAddress"))X.toAddress=Z.toAddress;if(Z.coins?.length){X.coins=[];for(let L=0;L<Z.coins.length;++L)X.coins[L]=q.common.Coin.toObject(Z.coins[L],Q)}if(Z.gas?.length){X.gas=[];for(let L=0;L<Z.gas.length;++L)X.gas[L]=q.common.Coin.toObject(Z.gas[L],Q)}if(Z.memo!=null&&Z.hasOwnProperty("memo"))X.memo=Z.memo;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.Fee=(()=>{function z(H){if(this.coins=[],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 z.prototype.coins=_.emptyArray,z.prototype.poolDeduct="",z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.coins?.length)for(let X=0;X<Z.coins.length;++X)q.common.Coin.encode(Z.coins[X],Q.uint32(10).fork()).ldelim();if(Z.poolDeduct!=null&&Object.hasOwnProperty.call(Z,"poolDeduct"))Q.uint32(18).string(Z.poolDeduct);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.Fee;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:if(!L.coins?.length)L.coins=[];L.coins.push(q.common.Coin.decode(Z,Z.uint32()));break;case 2:L.poolDeduct=Z.string();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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 Q=0;Q<Z.coins.length;++Q){let X=q.common.Coin.verify(Z.coins[Q]);if(X)return"coins."+X}}if(Z.poolDeduct!=null&&Z.hasOwnProperty("poolDeduct")){if(!_.isString(Z.poolDeduct))return"poolDeduct: string expected"}return null},z.fromObject=function(Z){if(Z instanceof q.common.Fee)return Z;let Q=new q.common.Fee;if(Z.coins){if(!Array.isArray(Z.coins))throw TypeError(".common.Fee.coins: array expected");Q.coins=[];for(let X=0;X<Z.coins.length;++X){if(typeof Z.coins[X]!=="object")throw TypeError(".common.Fee.coins: object expected");Q.coins[X]=q.common.Coin.fromObject(Z.coins[X])}}if(Z.poolDeduct!=null)Q.poolDeduct=String(Z.poolDeduct);return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.arrays||Q.defaults)X.coins=[];if(Q.defaults)X.poolDeduct="";if(Z.coins?.length){X.coins=[];for(let L=0;L<Z.coins.length;++L)X.coins[L]=q.common.Coin.toObject(Z.coins[L],Q)}if(Z.poolDeduct!=null&&Z.hasOwnProperty("poolDeduct"))X.poolDeduct=Z.poolDeduct;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.ProtoUint=(()=>{function z(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 z.prototype.value="",z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.value!=null&&Object.hasOwnProperty.call(Z,"value"))Q.uint32(10).string(Z.value);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.common.ProtoUint;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.value=Z.string();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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(!_.isString(Z.value))return"value: string expected"}return null},z.fromObject=function(Z){if(Z instanceof q.common.ProtoUint)return Z;let Q=new q.common.ProtoUint;if(Z.value!=null)Q.value=String(Z.value);return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.defaults)X.value="";if(Z.value!=null&&Z.hasOwnProperty("value"))X.value=Z.value;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y})();q.types=(()=>{let Y={};return Y.MsgDeposit=(()=>{function z(H){if(this.coins=[],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 z.prototype.coins=_.emptyArray,z.prototype.memo="",z.prototype.signer=_.newBuffer([]),z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.coins?.length)for(let X=0;X<Z.coins.length;++X)q.common.Coin.encode(Z.coins[X],Q.uint32(10).fork()).ldelim();if(Z.memo!=null&&Object.hasOwnProperty.call(Z,"memo"))Q.uint32(18).string(Z.memo);if(Z.signer!=null&&Object.hasOwnProperty.call(Z,"signer"))Q.uint32(26).bytes(Z.signer);return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.types.MsgDeposit;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:if(!L.coins?.length)L.coins=[];L.coins.push(q.common.Coin.decode(Z,Z.uint32()));break;case 2:L.memo=Z.string();break;case 3:L.signer=Z.bytes();break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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 Q=0;Q<Z.coins.length;++Q){let X=q.common.Coin.verify(Z.coins[Q]);if(X)return"coins."+X}}if(Z.memo!=null&&Z.hasOwnProperty("memo")){if(!_.isString(Z.memo))return"memo: string expected"}if(Z.signer!=null&&Z.hasOwnProperty("signer")){if(!(Z.signer&&typeof Z.signer.length==="number"||_.isString(Z.signer)))return"signer: buffer expected"}return null},z.fromObject=function(Z){if(Z instanceof q.types.MsgDeposit)return Z;let Q=new q.types.MsgDeposit;if(Z.coins){if(!Array.isArray(Z.coins))throw TypeError(".types.MsgDeposit.coins: array expected");Q.coins=[];for(let X=0;X<Z.coins.length;++X){if(typeof Z.coins[X]!=="object")throw TypeError(".types.MsgDeposit.coins: object expected");Q.coins[X]=q.common.Coin.fromObject(Z.coins[X])}}if(Z.memo!=null)Q.memo=String(Z.memo);if(Z.signer!=null){if(typeof Z.signer==="string")_.base64.decode(Z.signer,Q.signer=_.newBuffer(_.base64.length(Z.signer)),0);else if(Z.signer.length)Q.signer=Z.signer}return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.arrays||Q.defaults)X.coins=[];if(Q.defaults){if(X.memo="",Q.bytes===String)X.signer="";else if(X.signer=[],Q.bytes!==Array)X.signer=_.newBuffer(X.signer)}if(Z.coins?.length){X.coins=[];for(let L=0;L<Z.coins.length;++L)X.coins[L]=q.common.Coin.toObject(Z.coins[L],Q)}if(Z.memo!=null&&Z.hasOwnProperty("memo"))X.memo=Z.memo;if(Z.signer!=null&&Z.hasOwnProperty("signer"))X.signer=Q.bytes===String?_.base64.encode(Z.signer,0,Z.signer.length):Q.bytes===Array?Array.prototype.slice.call(Z.signer):Z.signer;return X},z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},z})(),Y.MsgSend=(()=>{function z(H){if(this.amount=[],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 z.prototype.fromAddress=_.newBuffer([]),z.prototype.toAddress=_.newBuffer([]),z.prototype.amount=_.emptyArray,z.create=function(Z){return new z(Z)},z.encode=function(Z,Q){if(!Q)Q=P.create();if(Z.fromAddress!=null&&Object.hasOwnProperty.call(Z,"fromAddress"))Q.uint32(10).bytes(Z.fromAddress);if(Z.toAddress!=null&&Object.hasOwnProperty.call(Z,"toAddress"))Q.uint32(18).bytes(Z.toAddress);if(Z.amount?.length)for(let X=0;X<Z.amount.length;++X)q.cosmos.base.v1beta1.Coin.encode(Z.amount[X],Q.uint32(26).fork()).ldelim();return Q},z.encodeDelimited=function(Z,Q){return this.encode(Z,Q).ldelim()},z.decode=function(Z,Q){if(!(Z instanceof O))Z=O.create(Z);let X=Q===void 0?Z.len:Z.pos+Q,L=new q.types.MsgSend;while(Z.pos<X){let J=Z.uint32();switch(J>>>3){case 1:L.fromAddress=Z.bytes();break;case 2:L.toAddress=Z.bytes();break;case 3:if(!L.amount?.length)L.amount=[];L.amount.push(q.cosmos.base.v1beta1.Coin.decode(Z,Z.uint32()));break;default:Z.skipType(J&7);break}}return L},z.decodeDelimited=function(Z){if(!(Z instanceof O))Z=new O(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"||_.isString(Z.fromAddress)))return"fromAddress: buffer expected"}if(Z.toAddress!=null&&Z.hasOwnProperty("toAddress")){if(!(Z.toAddress&&typeof Z.toAddress.length==="number"||_.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 Q=0;Q<Z.amount.length;++Q){let X=q.cosmos.base.v1beta1.Coin.verify(Z.amount[Q]);if(X)return"amount."+X}}return null},z.fromObject=function(Z){if(Z instanceof q.types.MsgSend)return Z;let Q=new q.types.MsgSend;if(Z.fromAddress!=null){if(typeof Z.fromAddress==="string")_.base64.decode(Z.fromAddress,Q.fromAddress=_.newBuffer(_.base64.length(Z.fromAddress)),0);else if(Z.fromAddress.length)Q.fromAddress=Z.fromAddress}if(Z.toAddress!=null){if(typeof Z.toAddress==="string")_.base64.decode(Z.toAddress,Q.toAddress=_.newBuffer(_.base64.length(Z.toAddress)),0);else if(Z.toAddress.length)Q.toAddress=Z.toAddress}if(Z.amount){if(!Array.isArray(Z.amount))throw TypeError(".types.MsgSend.amount: array expected");Q.amount=[];for(let X=0;X<Z.amount.length;++X){if(typeof Z.amount[X]!=="object")throw TypeError(".types.MsgSend.amount: object expected");Q.amount[X]=q.cosmos.base.v1beta1.Coin.fromObject(Z.amount[X])}}return Q},z.toObject=function(Z,Q){if(!Q)Q={};let X={};if(Q.arrays||Q.defaults)X.amount=[];if(Q.defaults){if(Q.bytes===String)X.fromAddress="";else if(X.fromAddress=[],Q.bytes!==Array)X.fromAddress=_.newBuffer(X.fromAddress);if(Q.bytes===String)X.toAddress="";else if(X.toAddress=[],Q.bytes!==Array)X.toAddress=_.newBuffer(X.toAddress)}if(Z.fromAddress!=null&&Z.hasOwnProperty("fromAddress"))X.fromAddress=Q.bytes===String?_.base64.encode(Z.fromAddress,0,Z.fromAddress.length):Q.bytes===Array?Array.prototype.slice.call(Z.fromAddress):Z.fromAddress;if(Z.toAddress!=null&&Z.hasOwnProperty("toAddress"))X.toAddress=Q.bytes===String?_.base64.encode(Z.toAddress,0,Z.toAddress.length):Q.bytes===Array?Array.prototype.slice.call(Z.toAddress):Z.toAddress;if(Z.amount?.length){X.amount=[];for(let L=0;L<Z.amount.length;++L)X.amount[L]=q.cosmos.base.v1beta1.Coin.toObject(Z.amount[L],Q)}return X},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 H={};return H.Coin=(()=>{function Z(Q){if(Q){for(let X=Object.keys(Q),L=0;L<X.length;++L)if(Q[X[L]]!=null)this[X[L]]=Q[X[L]]}}return Z.prototype.denom="",Z.prototype.amount="",Z.create=function(X){return new Z(X)},Z.encode=function(X,L){if(!L)L=P.create();if(X.denom!=null&&Object.hasOwnProperty.call(X,"denom"))L.uint32(10).string(X.denom);if(X.amount!=null&&Object.hasOwnProperty.call(X,"amount"))L.uint32(18).string(X.amount);return L},Z.encodeDelimited=function(X,L){return this.encode(X,L).ldelim()},Z.decode=function(X,L){if(!(X instanceof O))X=O.create(X);let J=L===void 0?X.len:X.pos+L,G=new q.cosmos.base.v1beta1.Coin;while(X.pos<J){let B=X.uint32();switch(B>>>3){case 1:G.denom=X.string();break;case 2:G.amount=X.string();break;default:X.skipType(B&7);break}}return G},Z.decodeDelimited=function(X){if(!(X instanceof O))X=new O(X);return this.decode(X,X.uint32())},Z.verify=function(X){if(typeof X!=="object"||X===null)return"object expected";if(X.denom!=null&&X.hasOwnProperty("denom")){if(!_.isString(X.denom))return"denom: string expected"}if(X.amount!=null&&X.hasOwnProperty("amount")){if(!_.isString(X.amount))return"amount: string expected"}return null},Z.fromObject=function(X){if(X instanceof q.cosmos.base.v1beta1.Coin)return X;let L=new q.cosmos.base.v1beta1.Coin;if(X.denom!=null)L.denom=String(X.denom);if(X.amount!=null)L.amount=String(X.amount);return L},Z.toObject=function(X,L){if(!L)L={};let J={};if(L.defaults)J.denom="",J.amount="";if(X.denom!=null&&X.hasOwnProperty("denom"))J.denom=X.denom;if(X.amount!=null&&X.hasOwnProperty("amount"))J.amount=X.amount;return J},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),H.DecCoin=(()=>{function Z(Q){if(Q){for(let X=Object.keys(Q),L=0;L<X.length;++L)if(Q[X[L]]!=null)this[X[L]]=Q[X[L]]}}return Z.prototype.denom="",Z.prototype.amount="",Z.create=function(X){return new Z(X)},Z.encode=function(X,L){if(!L)L=P.create();if(X.denom!=null&&Object.hasOwnProperty.call(X,"denom"))L.uint32(10).string(X.denom);if(X.amount!=null&&Object.hasOwnProperty.call(X,"amount"))L.uint32(18).string(X.amount);return L},Z.encodeDelimited=function(X,L){return this.encode(X,L).ldelim()},Z.decode=function(X,L){if(!(X instanceof O))X=O.create(X);let J=L===void 0?X.len:X.pos+L,G=new q.cosmos.base.v1beta1.DecCoin;while(X.pos<J){let B=X.uint32();switch(B>>>3){case 1:G.denom=X.string();break;case 2:G.amount=X.string();break;default:X.skipType(B&7);break}}return G},Z.decodeDelimited=function(X){if(!(X instanceof O))X=new O(X);return this.decode(X,X.uint32())},Z.verify=function(X){if(typeof X!=="object"||X===null)return"object expected";if(X.denom!=null&&X.hasOwnProperty("denom")){if(!_.isString(X.denom))return"denom: string expected"}if(X.amount!=null&&X.hasOwnProperty("amount")){if(!_.isString(X.amount))return"amount: string expected"}return null},Z.fromObject=function(X){if(X instanceof q.cosmos.base.v1beta1.DecCoin)return X;let L=new q.cosmos.base.v1beta1.DecCoin;if(X.denom!=null)L.denom=String(X.denom);if(X.amount!=null)L.amount=String(X.amount);return L},Z.toObject=function(X,L){if(!L)L={};let J={};if(L.defaults)J.denom="",J.amount="";if(X.denom!=null&&X.hasOwnProperty("denom"))J.denom=X.denom;if(X.amount!=null&&X.hasOwnProperty("amount"))J.amount=X.amount;return J},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),H.IntProto=(()=>{function Z(Q){if(Q){for(let X=Object.keys(Q),L=0;L<X.length;++L)if(Q[X[L]]!=null)this[X[L]]=Q[X[L]]}}return Z.prototype.int="",Z.create=function(X){return new Z(X)},Z.encode=function(X,L){if(!L)L=P.create();if(X.int!=null&&Object.hasOwnProperty.call(X,"int"))L.uint32(10).string(X.int);return L},Z.encodeDelimited=function(X,L){return this.encode(X,L).ldelim()},Z.decode=function(X,L){if(!(X instanceof O))X=O.create(X);let J=L===void 0?X.len:X.pos+L,G=new q.cosmos.base.v1beta1.IntProto;while(X.pos<J){let B=X.uint32();switch(B>>>3){case 1:G.int=X.string();break;default:X.skipType(B&7);break}}return G},Z.decodeDelimited=function(X){if(!(X instanceof O))X=new O(X);return this.decode(X,X.uint32())},Z.verify=function(X){if(typeof X!=="object"||X===null)return"object expected";if(X.int!=null&&X.hasOwnProperty("int")){if(!_.isString(X.int))return"int: string expected"}return null},Z.fromObject=function(X){if(X instanceof q.cosmos.base.v1beta1.IntProto)return X;let L=new q.cosmos.base.v1beta1.IntProto;if(X.int!=null)L.int=String(X.int);return L},Z.toObject=function(X,L){if(!L)L={};let J={};if(L.defaults)J.int="";if(X.int!=null&&X.hasOwnProperty("int"))J.int=X.int;return J},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),H.DecProto=(()=>{function Z(Q){if(Q){for(let X=Object.keys(Q),L=0;L<X.length;++L)if(Q[X[L]]!=null)this[X[L]]=Q[X[L]]}}return Z.prototype.dec="",Z.create=function(X){return new Z(X)},Z.encode=function(X,L){if(!L)L=P.create();if(X.dec!=null&&Object.hasOwnProperty.call(X,"dec"))L.uint32(10).string(X.dec);return L},Z.encodeDelimited=function(X,L){return this.encode(X,L).ldelim()},Z.decode=function(X,L){if(!(X instanceof O))X=O.create(X);let J=L===void 0?X.len:X.pos+L,G=new q.cosmos.base.v1beta1.DecProto;while(X.pos<J){let B=X.uint32();switch(B>>>3){case 1:G.dec=X.string();break;default:X.skipType(B&7);break}}return G},Z.decodeDelimited=function(X){if(!(X instanceof O))X=new O(X);return this.decode(X,X.uint32())},Z.verify=function(X){if(typeof X!=="object"||X===null)return"object expected";if(X.dec!=null&&X.hasOwnProperty("dec")){if(!_.isString(X.dec))return"dec: string expected"}return null},Z.fromObject=function(X){if(X instanceof q.cosmos.base.v1beta1.DecProto)return X;let L=new q.cosmos.base.v1beta1.DecProto;if(X.dec!=null)L.dec=String(X.dec);return L},Z.toObject=function(X,L){if(!L)L={};let J={};if(L.defaults)J.dec="";if(X.dec!=null&&X.hasOwnProperty("dec"))J.dec=X.dec;return J},Z.prototype.toJSON=function(){return this.constructor.toObject(this,k.util.toJSONOptions)},Z})(),H})(),z})(),Y})();function O6(Y){if(Y instanceof Uint8Array)return Y;if(typeof Y==="string")return Uint8Array.from(globalThis.atob(Y),(H)=>H.charCodeAt(0));throw TypeError("address must be Uint8Array or base64 string")}var $0=(Y)=>{let z=Y;return q.types.MsgSend.encode({amount:z.amount,fromAddress:O6(z.fromAddress),toAddress:O6(z.toAddress)}).finish()},y0=(Y)=>{let z=Y;return q.types.MsgDeposit.encode({coins:z.coins.map((H)=>({amount:H.amount,asset:H.asset})),memo:z.memo,signer:O6(z.signer)}).finish()};function d(){return{...C0,"/types.MsgDeposit":y0,"/types.MsgSend":$0}}function j(Y,z=Y===j6.THORChain?"thor":"maya"){let H=Y===j6.THORChain?"thorchain":"mayachain",Z={"/types.MsgDeposit":{aminoType:`${H}/MsgDeposit`,fromAmino:({signer:Q,...X})=>({...X,signer:t(Q)}),toAmino:({signer:Q,...X})=>({...X,signer:typeof Q==="string"?r(Q,z):Q})},"/types.MsgSend":{aminoType:`${H}/MsgSend`,fromAmino:({from_address:Q,to_address:X,...L})=>({...L,fromAddress:t(Q),toAddress:t(X)}),toAmino:({fromAddress:Q,toAddress:X,...L})=>({...L,from_address:typeof Q==="string"?r(Q,z):Q,to_address:typeof X==="string"?r(X,z):X})}};return Object.assign(Z,{fromAmino(Q){let X=Object.entries(Z).find(([,G])=>G.aminoType===Q.type);if(!X)throw TypeError(`No converter for amino type ${Q.type}`);let[L,J]=X;return{typeUrl:L,value:J.fromAmino(Q.value)}},toAmino(Q){let X=Z[Q.typeUrl];if(!X)throw TypeError(`No converter for type URL ${Q.typeUrl}`);return{type:X.aminoType,value:X.toAmino(Q.value)}}})}var g8=C(Z6.THORChain).gas,i8=C(Z6.Maya).gas,u6=({sender:Y,recipient:z,assetValue:H})=>{return{type:`${H.chain===Z6.Maya?"mayachain":"thorchain"}/MsgSend`,value:{amount:[{amount:H.getBaseValue("string"),denom:y(H.symbol,!0)}],from_address:Y,to_address:z}}},l6=({sender:Y,assetValue:z,memo:H=""})=>{return{type:`${z.chain===Z6.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:z.getBaseValue("string"),asset:e(z)}],memo:H,signer:Y}}},I6=({sender:Y,recipient:z,assetValue:H,memo:Z})=>{return!z?l6({assetValue:H,memo:Z,sender:Y}):u6({assetValue:H,recipient:z,sender:Y})};function b6(Y,z){for(let H of["/types.MsgDeposit","/types.MsgSend"]){let Z=Y[H];if(Z.aminoType===z)return{fromAmino:Z.fromAmino,typeUrl:H}}return null}var h=(Y,z)=>{let H=j(z),Z=b6(H,Y.type);if(!Z)throw new B6("toolbox_cosmos_invalid_params",{error:`No converter for amino type ${Y.type}`});return{typeUrl:Z.typeUrl,value:Z.fromAmino(Y.value)}},p6=async({rpcUrl:Y,sender:z})=>{let Z=await(await $(Y)).getAccount(z);if(!Z)throw new B6("toolbox_cosmos_account_not_found",{sender:z});return Z};async function d6(Y){let{assetValue:z,recipient:H,memo:Z,sender:Q,asSignable:X,asAminoMessage:L,sequence:J,accountNumber:G}=Y,B=Y.sweep?await E6({assetValue:z,sender:Q}):z;if(H)return h0({accountNumber:G,asAminoMessage:L,asSignable:X,assetValue:B,memo:Z,recipient:H,sender:Q,sequence:J});return u0({accountNumber:G,asAminoMessage:L,asSignable:X,assetValue:B,memo:Z,sender:Q,sequence:J})}async function E6({assetValue:Y,sender:z}){let H=Y.chain,Z=await N6(H),X=await(await $(Z)).getAllBalances(z),L=Y.isGasAsset?(await s(H)).getBaseValue("bigint"):0n;return m({assetValue:Y,balances:X,denom:y(Y.symbol,!0),feeAmount:L})}async function h0({sender:Y,recipient:z,assetValue:H,memo:Z="",asSignable:Q=!0,asAminoMessage:X=!1,sequence:L,accountNumber:J}){let G=H.chain,B=J!==void 0&&L!==void 0?void 0:await p6({rpcUrl:await N6(G),sender:Y}),{chainId:U}=h6(G),V=u6({assetValue:H,recipient:z,sender:Y}),T=Q?h(X?V:u(V),G):V;return{accountNumber:J??Number(B?.accountNumber),chainId:U,fee:C(G),memo:Z,msgs:[T],sequence:L??Number(B?.sequence)}}async function u0({sender:Y,assetValue:z,memo:H="",asSignable:Z=!0,asAminoMessage:Q=!1,sequence:X,accountNumber:L}){let J=z.chain,G=L!==void 0&&X!==void 0?void 0:await p6({rpcUrl:await N6(J),sender:Y}),{chainId:B}=h6(J),U=l6({assetValue:z,memo:H,sender:Y}),V=Z?h(Q?U:u(U),J):U;return{accountNumber:L??Number(G?.accountNumber),chainId:B,fee:C(J),memo:H,msgs:[V],sequence:X??Number(G?.sequence)}}function u(Y){if(Y.type==="thorchain/MsgSend"||Y.type==="mayachain/MsgSend")return Y;return{...Y,value:{...Y.value,coins:Y.value.coins.map((z)=>{let H=j0.from({asset:z.asset}),Z=(H.isSynthetic?H.symbol.split("/")?.[1]:H.symbol)?.toUpperCase(),Q=(H.isSynthetic?H.symbol.split("/")?.[0]:H.chain)?.toUpperCase();return{...z,asset:{chain:Q,symbol:Z,synth:H.isSynthetic,ticker:H.ticker}}})}}}function Q6({chain:Y,memo:z,msgs:H}){let Z=d(),Q=j(Y),L=H.map((J)=>{let G=b6(Q,J.type);if(!G)throw new B6("toolbox_cosmos_invalid_params",{error:`No converter for amino type ${J.type}`});return{typeUrl:G.typeUrl,value:G.fromAmino(J.value)}}).map((J)=>f0(J,Z));return w0({memo:z,messages:L})}import{Chain as g,SwapKitError as k8}from"@swapkit/helpers";import{secp256k1 as l0}from"@noble/curves/secp256k1.js";import{base64 as V6,bech32 as U6}from"@scure/base";import{HDKey as b0}from"@scure/bip32";import{verifySignature as p0,createWalletFromMnemonic as d0,createWalletFromPrivateKey as c0,mnemonicToSeed as m0,signDirect as n0}from"@swapkit/cosmos-signer";import{AssetValue as M6,applyFeeMultiplier as c6,Chain as F,CosmosChainPrefixes as t6,DerivationPath as g0,derivationPathToString as m6,FeeOption as T6,getChainConfig as i0,getRPCUrl as n,NetworkDerivationPath as o0,SwapKitError as f,SwapKitNumber as K6,updateDerivationPath as t0}from"@swapkit/helpers";import{SwapKitApi as r6}from"@swapkit/helpers/api";import{PubKey as r0}from"cosmjs-types/cosmos/crypto/secp256k1/keys";import{match as a0,P as n6}from"ts-pattern";async function a6(Y,z){try{let Z=(await r6.getGasRate()).find((Q)=>Q.chainId===Y)?.value;return Z?Number.parseFloat(Z):z}catch{return z}}function s6(Y){let z=[{address:Y.address,algo:"secp256k1",pubkey:Y.publicKey}];return{getAccounts:()=>Promise.resolve(z),async signDirect(H,Z){if(H!==Y.address)throw new f("toolbox_cosmos_signer_not_defined");let Q=await n0(Y.privateKey,Y.publicKey,{accountNumber:Z.accountNumber,authInfoBytes:Z.authInfoBytes,bodyBytes:Z.bodyBytes,chainId:Z.chainId});return{signature:Q.signature,signed:{accountNumber:Q.signed.accountNumber,authInfoBytes:Q.signed.authInfoBytes,bodyBytes:Q.signed.bodyBytes,chainId:Q.signed.chainId}}}}}async function g6({phrase:Y,prefix:z,...H}){let Z="derivationPath"in H?H.derivationPath:`${g0[H.chain]}/${H.index??0}`,Q=await d0({hdPath:Z,mnemonic:Y,prefix:z??""});return s6(Q)}async function s0({privateKey:Y,prefix:z}){let H=c0({prefix:z,privateKey:Y});return s6(H)}var i6={[F.Cosmos]:1000,[F.Kujira]:1000,[F.Noble]:1000,[F.THORChain]:5000000,[F.Maya]:5000000,[F.Harbor]:5000000};function e0(Y){return async function({signature:H,message:Z,address:Q}){let X=await Y(Q);if(!X?.pubkey)throw new f("toolbox_cosmos_verify_signature_no_pubkey");let L=X.pubkey.type==="/cosmos.crypto.secp256k1.PubKey"?r0.decode(X.pubkey.value).key:X.pubkey.value;return p0(V6.decode(Z),V6.decode(H),L)}}function X6({chain:Y,...z}){let H=t6[Y],Z="index"in z?z.index||0:0,Q=m6("derivationPath"in z&&z.derivationPath?z.derivationPath:t0(o0[Y],{index:Z})),X;async function L(){if(X)return X;return X=await a0(z).with({phrase:n6.string},({phrase:N})=>g6({derivationPath:Q,phrase:N,prefix:H})).with({signer:n6.any},({signer:N})=>N).otherwise(()=>{return}),X}async function J(N){let I=await n(Y);return(await $(I)).getAccount(N)}async function G(){let N=await L(),[I]=await N?.getAccounts()||[];return I?.address}async function B(){let N=await L(),[I]=await N?.getAccounts()||[];if(!I?.pubkey)throw new f("toolbox_cosmos_signer_not_defined");return V6.encode(I?.pubkey)}async function U(N){let I=await L(),W=await G(),E=await n(Y);if(!(I&&W))throw new f("toolbox_cosmos_signer_not_defined");return(await p(E,I)).sign(W,N.msgs,N.fee,N.memo,{accountNumber:BigInt(N.accountNumber),chainId:N.chainId,sequence:N.sequence})}async function V(N){let I=await L(),W=await G(),E=await n(Y);if(!(I&&W))throw new f("toolbox_cosmos_signer_not_defined");let M=await(await p(E,I)).signAndBroadcast(W,N.msgs,N.fee,N.memo);if(M.code!==0)throw new f("core_swap_transaction_error",{code:M.code,message:M.rawLog});return M.transactionHash}async function T({recipient:N,assetValue:I,memo:W="",feeRate:E,feeOptionKey:R=T6.Fast,sweep:M}){let x=await L(),A=await G();if(!(x&&A))throw new f("toolbox_cosmos_signer_not_defined");let v=await n(Y),z6=M6.from({chain:Y}),Y6=e(z6),b=Z8(E||(await o6(Y,i6[Y]))[R],Y6,Y),H6=await p(v,x),c=y(I.symbol),L6=[{amount:(M?m({assetValue:I,balances:await R6(Y)(A),denom:c,feeAmount:W6(b.amount,c)}):I).getBaseValue("string"),denom:c}],{transactionHash:J6}=await H6.sendTokens(A,N,L6,b,W);return J6}return{createPrivateKeyFromPhrase:z8(Q),createTransaction:f6,fetchFeeRateFromSwapKit:a6,getAccount:J,getAddress:G,getBalance:async(N,I)=>{let W=await R6(Y)(N),E=await Promise.all(W.filter(({denom:R})=>R&&!R.includes("IBC/")&&!([F.THORChain,F.Maya].includes(Y)&&R.split("-").length>2)).map(({denom:R,amount:M})=>{let x=[F.THORChain,F.Maya].includes(Y)&&(R.includes("/")||R.includes("˜"))?`${Y}.${R}`:R;return w6(x,M)}));if(E.length===0)return[M6.from({chain:Y})];return E},getBalanceAsDenoms:R6(Y),getFees:()=>o6(Y,i6[Y]),getPubKey:B,getSignerFromPhrase:({phrase:N,derivationPath:I})=>g6({derivationPath:m6(I),index:Z,phrase:N,prefix:H}),getSignerFromPrivateKey:(N)=>s0({prefix:H,privateKey:N}),signAndBroadcastTransaction:V,signTransaction:U,transfer:T,validateAddress:X8(Y),verifySignature:e0(J)}}async function _Z(Y,z){try{let Z=(await r6.getGasRate()).find((Q)=>Q.chainId===Y)?.value;return Z?Number.parseFloat(Z):z}catch{return z}}function WZ({assetValue:{chain:Y}}){return M6.from({chain:Y,value:Q8(Y)})}async function o6(Y,z){let{chainId:H,baseDecimal:Z}=i0(Y),Q=await a6(H,z);return{average:K6.fromBigInt(BigInt(Q),Z),fast:K6.fromBigInt(BigInt(c6(Q,T6.Fast,!0)),Z),fastest:K6.fromBigInt(BigInt(c6(Q,T6.Fastest,!0)),Z)}}function Z8(Y,z,H){return{amount:[{amount:typeof Y==="number"?Y.toString():Y.getBaseValue("string"),denom:z}],gas:C(H).gas}}function Q8(Y){return{[F.Cosmos]:0.007,[F.Kujira]:0.02,[F.Noble]:0.01,[F.THORChain]:0.02,[F.Maya]:0.02,[F.Harbor]:0.02}[Y]||0}function X8(Y){let z=t6[Y];return function(Z){if(!Z.startsWith(z))return!1;try{let{prefix:Q,words:X}=U6.decode(Z);return U6.encode(Q,X)===Z.toLocaleLowerCase()}catch{return!1}}}function R6(Y){return async function(H){let Z=await n(Y);return(await(await $(Z)).getAllBalances(H)).map((J)=>({...J,denom:J.denom.includes("/")?J.denom.toUpperCase():J.denom}))}}function z8(Y){return async function(H){let Z=await m0(H),X=b0.fromMasterSeed(Z).derive(Y);if(!X.privateKey)throw new f("toolbox_cosmos_invalid_params",{error:"HDKey derivation produced no private key"});return l0.getPublicKey(X.privateKey,!0),Uint8Array.from(X.privateKey)}}import{secp256k1 as Y8}from"@noble/curves/secp256k1.js";import{base64 as w}from"@scure/base";import{buildMultisignedTx as H8,createMultisigThresholdPubkey as L8,signAmino as J8,createWalletFromMnemonic as G8,encodeTxRaw as q8,multisigPubkeyToAddress as _8,singlePubkeyToAddress as Z0}from"@swapkit/cosmos-signer";import{CosmosChainPrefixes as W8,derivationPathToString as O8,FeeOption as x6,getRPCUrl as Q0,NetworkDerivationPath as N8,SKConfig as B8,SwapKitError as l,updateDerivationPath as I8}from"@swapkit/helpers";import{match as E8,P as e6}from"ts-pattern";function U8(Y){let z=[{address:Y.address,algo:"secp256k1",pubkey:Y.publicKey}];return{accounts:z,getAccounts:()=>Promise.resolve(z),async signAmino(H,Z){if(H!==Y.address)throw new l("toolbox_cosmos_signer_not_defined");let Q=await J8(Y.privateKey,Y.publicKey,{signDoc:Z});return{signature:Q.signature,signed:Q.signed}}}}function K8({prefix:Y,derivationPath:z}){return async function(Z,Q=0){let X=await G8({hdPath:`${z}/${Q}`,mnemonic:Z,prefix:Y});return U8(X)}}function R8(Y){return w.encode(Y)}function V8(Y,z){return async function({wallet:Z,tx:Q}){let{msgs:X,accountNumber:L,sequence:J,chainId:G,fee:B,memo:U}=typeof Q==="string"?JSON.parse(Q):Q,V=(await Z.getAccounts())?.[0]?.address||"",T=j(Y,z),N=d(),I=await y6(Z,{aminoTypes:T,registry:N}),W=[];for(let M of X){let x=h(M,Y);W.push(x)}let{signatures:[E]}=await I.sign(V,W,B,U,{accountNumber:BigInt(L),chainId:G,sequence:J});return{bodyBytes:Q6({chain:Y,memo:U,msgs:X.map(u)}),signature:R8(E)}}}function X0(Y){if(Y.length!==33||Y[0]!==2&&Y[0]!==3)throw new l("toolbox_cosmos_invalid_params",{error:"Invalid compressed secp256k1 pubkey (must be 33 bytes starting with 0x02 or 0x03)"});return{type:"tendermint/PubKeySecp256k1",value:w.encode(Y)}}function M8({prefix:Y,chain:z}){return async function(Z,Q,X,L,J){let G=await Q0(z),{sequence:B,fee:U}=JSON.parse(Z),V=z0(X,L),T=Q.map((W)=>[Z0(X0(w.decode(W.pubKey)),Y),w.decode(W.signature)]),N=await $(G),{transactionHash:I}=await N.broadcastTx(H8({bodyBytes:J,fee:{amount:U.amount,gasLimit:BigInt(U.gas),...U.payer?{payer:U.payer}:{},...U.granter?{granter:U.granter}:{}},multisigPubkey:V,prefix:Y,sequence:B,signatures:new Map(T)}));return I}}function z0(Y,z,H=!0){return L8(Y.map((Z)=>X0(w.decode(Z))),z,H)}function T8(Y){return w.decode(Y)}function x8({privateKey:Y,message:z}){let H=Y8.sign(w.decode(z),Y,{lowS:!0,prehash:!1});return Promise.resolve(w.encode(H))}function Y0({chain:Y,...z}){let{isStagenet:H}=B8.get("envs"),Z=`${H?"s":""}${W8[Y]}`,Q="index"in z?z.index||0:0,X="derivationPath"in z&&z.derivationPath?z.derivationPath:I8(N8[Y],{index:Q}),L=X6({chain:Y,...z}),J=C(Y),G;function B(){return G??=E8(z).with({phrase:e6.string},({phrase:W})=>L.getSignerFromPhrase({derivationPath:X,phrase:W})).with({signer:e6.any},({signer:W})=>Promise.resolve(W)).otherwise(()=>Promise.resolve(void 0)),G}async function U(){let W=await Q0(Y),E=await B();if(!E)throw new l("toolbox_cosmos_no_signer");let R=d(),M=j(Y,Z),x=await p(W,E,{aminoTypes:M,registry:R});return{signer:E,signingClient:x}}async function V({fee:W,memo:E,msgs:R}){let{signer:M,signingClient:x}=await U(),A=(await M.getAccounts())?.[0]?.address;if(!A)throw new l("toolbox_cosmos_signer_not_defined");let v=await x.signAndBroadcast(A,R,W,E);if(v.code!==0)throw new l("core_swap_transaction_error",{code:v.code,message:v.rawLog});return v.transactionHash}async function T(){let W=await s(Y);return{[x6.Average]:W,[x6.Fast]:W,[x6.Fastest]:W}}async function N({assetValue:W,memo:E="",recipient:R,sweep:M}){let{signer:x,signingClient:A}=await U(),v=(await x.getAccounts())?.[0]?.address;if(!v)throw new l("toolbox_cosmos_no_signer");let z6="signAmino"in x,Y6=M?await E6({assetValue:W,sender:v}):W,b=I6({assetValue:Y6,memo:E,recipient:R,sender:v});if(z6){let k6=h(b,Y),{signatures:L6,authInfoBytes:J6}=await A.sign(v,[k6],J,E),H0=q8({authInfoBytes:J6,bodyBytes:Q6({chain:Y,memo:E,msgs:[b].map(u)}),signatures:L6});return(await A.broadcastTx(H0)).transactionHash}let H6=u(b),c=h(H6,Y);return V({fee:J,memo:E,msgs:[c]})}async function I(W){let{signer:E,signingClient:R}=await U(),M=(await E.getAccounts())?.[0]?.address;if(!M)throw new l("toolbox_cosmos_signer_not_defined");return R.sign(M,W.msgs,W.fee,W.memo,{accountNumber:BigInt(W.accountNumber),chainId:W.chainId,sequence:W.sequence})}return{...L,broadcastMultisigTx:M8({chain:Y,prefix:Z}),buildAminoMsg:I6,buildEncodedTxBody:Q6,convertToSignable:h,createDefaultAminoTypes:()=>j(Y,Z),createDefaultRegistry:d,createMultisig:z0,createTransaction:d6,deposit:N,getFees:T,importSignature:T8,parseAminoMessageForDirectSigning:u,pubkeyToAddress:(W)=>{if(W.type==="tendermint/PubKeyMultisigThreshold")return _8(W,Z);return Z0(W,Z)},secp256k1HdWalletFromMnemonic:K8({derivationPath:O8(X),prefix:Z}),signAndBroadcastTransaction:V,signMultisigTx:V8(Y,Z),signTransaction:I,signWithPrivateKey:x8,transfer:N}}var FZ=(Y,z)=>{switch(Y){case g.Cosmos:case g.Kujira:case g.Noble:return X6({chain:Y,...z});case g.Maya:case g.THORChain:return Y0({chain:Y,...z});default:throw new k8("toolbox_cosmos_not_supported",{chain:Y})}};export{e0 as verifySignature,u6 as transferMsgAmino,P8 as toBase64,E6 as resolveThorchainSweepAssetValue,u as parseAminoMessageForDirectSigning,s as getThorchainNativeFee,m as getSweepAssetValue,s0 as getSignerFromPrivateKey,g6 as getSignerFromPhrase,y as getMsgSendDenom,_Z as getFeeRateFromSwapKit,W6 as getFeeAmountForDenom,e as getDenomWithChain,C as getDefaultChainFee,FZ as getCosmosToolbox,X8 as getCosmosAddressValidator,w6 as getAssetFromDenom,A8 as fromBase64,a6 as fetchFeeRateFromSwapKit,WZ as estimateTransactionFee,l6 as depositMsgAmino,d6 as createTransaction,Y0 as createThorchainToolbox,$ as createStargateClient,p as createSigningStargateClient,y6 as createOfflineStargateClient,d as createDefaultRegistry,j as createDefaultAminoTypes,X6 as createCosmosToolbox,f6 as cosmosCreateTransaction,h as convertToSignable,h0 as buildTransferTx,Q6 as buildEncodedTxBody,u0 as buildDepositTx,I6 as buildAminoMsg,t as bech32ToBase64,r as base64ToBech32,E0 as YUM_KUJIRA_FACTORY_DENOM,A6 as USK_KUJIRA_FACTORY_DENOM,g8 as THORCHAIN_GAS_VALUE,i8 as MAYA_GAS_VALUE,R0 as DEFAULT_NOBLE_FEE_MAINNET,K0 as DEFAULT_KUJI_FEE_MAINNET,U0 as DEFAULT_COSMOS_FEE_MAINNET};
|
package/dist/src/evm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as da}from"../../chunk-44m22jy1.js";import{$ as _,A as z,B as A,C as B,D as C,E as D,F as E,G as F,H as G,I as H,J as I,K as J,L as K,M as L,N as M,O as N,P as O,Q as P,R as Q,S as R,T as S,U as T,V as U,W as V,X as W,Y as X,Z as Y,_ as Z,aa as $,b as a,ba as aa,c as b,ca as ba,d as c,da as ca,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t,v as u,w as v,x as w,y as x,z as y}from"../../chunk-
|
|
1
|
+
import{a as da}from"../../chunk-44m22jy1.js";import{$ as _,A as z,B as A,C as B,D as C,E as D,F as E,G as F,H as G,I as H,J as I,K as J,L as K,M as L,N as M,O as N,P as O,Q as P,R as Q,S as R,T as S,U as T,V as U,W as V,X as W,Y as X,Z as Y,_ as Z,aa as $,b as a,ba as aa,c as b,ca as ba,d as c,da as ca,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t,v as u,w as v,x as w,y as x,z as y}from"../../chunk-ye1j5pz2.js";import"../../chunk-nvfkjbyq.js";import"../../chunk-xbdjxeqd.js";export{p as validateEVMAddress,m as validateAuthorizations,j as validateAuthorization,f as toHexString,u as toChecksumAddress,i as signAuthorization,l as parseEIP712FromEVMTx,t as isStateChangingCall,B as isEIP7702Transaction,C as isEIP1559Transaction,q as isBrowserProvider,y as getTokenAddress,c as getProviderSync,d as getProvider,g as getNetworkParams,h as getIsEIP1559Compatible,e as getFallbackProvider,ca as getEvmToolboxAsync,ba as getEvmToolbox,a as getEvmApi,A as getEstimateGasPrices,D as getEVMTxType,v as getEIP1193SendTransaction,z as getCreateContractTxObject,s as getCreateContract,w as getChecksumAddressFromAsset,E as createOPStackToolbox,b as createCustomEvmApi,r as createContract,k as buildEIP712DomainType,aa as XLayerToolbox,$ as UNIToolbox,_ as SONICToolbox,Z as PLASMAToolbox,F as OPToolbox,Y as MONADToolbox,X as MEGAETHToolbox,n as MAX_APPROVAL,W as MATICToolbox,V as LINEAToolbox,U as HYPEREVMToolbox,T as HOODToolbox,S as GNOToolbox,da as EthNetwork,G as ETHToolbox,x as ContractAddress,R as CROToolbox,Q as CORNToolbox,P as COREToolbox,O as BotanixToolbox,o as BaseEVMToolbox,N as BSCToolbox,M as BERAToolbox,L as BASEToolbox,K as AVAXToolbox,J as AURORAToolbox,I as ARBToolbox,H as ADIToolbox};
|