@swapkit/toolboxes 4.0.27 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cardano/index.cjs +4 -0
- package/dist/src/cardano/index.cjs.map +11 -0
- package/dist/src/cardano/index.js +4 -0
- package/dist/src/cardano/index.js.map +11 -0
- package/dist/src/cosmos/index.cjs +2 -2
- package/dist/src/cosmos/index.cjs.map +5 -5
- package/dist/src/cosmos/index.js +2 -2
- package/dist/src/cosmos/index.js.map +5 -5
- package/dist/src/evm/index.cjs +2 -2
- package/dist/src/evm/index.cjs.map +6 -6
- package/dist/src/evm/index.js +2 -2
- package/dist/src/evm/index.js.map +6 -6
- package/dist/src/index.cjs +3 -3
- package/dist/src/index.cjs.map +40 -34
- package/dist/src/index.js +3 -3
- package/dist/src/index.js.map +40 -34
- package/dist/src/near/index.cjs +2 -2
- package/dist/src/near/index.cjs.map +4 -4
- package/dist/src/near/index.js +2 -2
- package/dist/src/near/index.js.map +4 -4
- package/dist/src/solana/index.cjs +2 -2
- package/dist/src/solana/index.cjs.map +3 -3
- package/dist/src/solana/index.js +2 -2
- package/dist/src/solana/index.js.map +3 -3
- package/dist/src/substrate/index.cjs +2 -2
- package/dist/src/substrate/index.cjs.map +3 -3
- package/dist/src/substrate/index.js +2 -2
- package/dist/src/substrate/index.js.map +3 -3
- package/dist/src/sui/index.cjs +4 -0
- package/dist/src/sui/index.cjs.map +11 -0
- package/dist/src/sui/index.js +4 -0
- package/dist/src/sui/index.js.map +11 -0
- package/dist/src/ton/index.cjs +4 -0
- package/dist/src/ton/index.cjs.map +11 -0
- package/dist/src/ton/index.js +4 -0
- package/dist/src/ton/index.js.map +11 -0
- package/dist/src/tron/index.cjs +2 -2
- package/dist/src/tron/index.cjs.map +3 -3
- package/dist/src/tron/index.js +2 -2
- package/dist/src/tron/index.js.map +3 -3
- package/dist/src/utxo/index.cjs +2 -2
- package/dist/src/utxo/index.cjs.map +5 -5
- package/dist/src/utxo/index.js +2 -2
- package/dist/src/utxo/index.js.map +5 -5
- package/dist/types/cardano/index.d.ts +3 -0
- package/dist/types/cardano/index.d.ts.map +1 -0
- package/dist/types/cardano/toolbox.d.ts +34 -0
- package/dist/types/cardano/toolbox.d.ts.map +1 -0
- package/dist/types/cardano/types.d.ts +11 -0
- package/dist/types/cardano/types.d.ts.map +1 -0
- package/dist/types/cosmos/toolbox/cosmos.d.ts +2 -14
- package/dist/types/cosmos/toolbox/cosmos.d.ts.map +1 -1
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +1 -0
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts.map +1 -1
- package/dist/types/evm/toolbox/evm.d.ts.map +1 -1
- package/dist/types/evm/toolbox/index.d.ts +2 -2
- package/dist/types/evm/toolbox/index.d.ts.map +1 -1
- package/dist/types/evm/toolbox/op.d.ts +2 -2
- package/dist/types/evm/toolbox/op.d.ts.map +1 -1
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/solana/toolbox.d.ts.map +1 -1
- package/dist/types/sui/index.d.ts +3 -0
- package/dist/types/sui/index.d.ts.map +1 -0
- package/dist/types/sui/toolbox.d.ts +19 -0
- package/dist/types/sui/toolbox.d.ts.map +1 -0
- package/dist/types/sui/types.d.ts +16 -0
- package/dist/types/sui/types.d.ts.map +1 -0
- package/dist/types/ton/index.d.ts +3 -0
- package/dist/types/ton/index.d.ts.map +1 -0
- package/dist/types/ton/toolbox.d.ts +14 -0
- package/dist/types/ton/toolbox.d.ts.map +1 -0
- package/dist/types/ton/types.d.ts +22 -0
- package/dist/types/ton/types.d.ts.map +1 -0
- package/dist/types/tron/toolbox.d.ts.map +1 -1
- package/dist/types/types.d.ts +10 -2
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/bitcoinCash.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/zcash.d.ts.map +1 -1
- package/package.json +31 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var C=Object.create;var{getPrototypeOf:K,defineProperty:Z,getOwnPropertyNames:x,getOwnPropertyDescriptor:S}=Object,B=Object.prototype.hasOwnProperty;var $=(y,f,R)=>{R=y!=null?C(K(y)):{};let q=f||!y||!y.__esModule?Z(R,"default",{value:y,enumerable:!0}):R;for(let J of x(y))if(!B.call(q,J))Z(q,J,{get:()=>y[J],enumerable:!0});return q},I=new WeakMap,k=(y)=>{var f=I.get(y),R;if(f)return f;if(f=Z({},"__esModule",{value:!0}),y&&typeof y==="object"||typeof y==="function")x(y).map((q)=>!B.call(f,q)&&Z(f,q,{get:()=>y[q],enumerable:!(R=S(y,q))||R.enumerable}));return I.set(y,f),f};var E=(y,f)=>{for(var R in f)Z(y,R,{get:f[R],enumerable:!0,configurable:!0,set:(q)=>f[R]=()=>q})};var O=(y,f)=>()=>(y&&(f=y(y=0)),f);async function Y(){let{BlockfrostProvider:y}=await import("@meshsdk/core"),f="mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS";return new y("mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS")}async function w(y){try{let{MeshWallet:f}=await import("@meshsdk/core"),R=await Y(),q=new f({fetcher:R,key:{address:y,type:"address"},networkId:1});await q.init();let J=await q.getBalance(),N=[];for(let Q of J)if(Q.unit===p){let{baseDecimal:F}=j.getChainConfig(j.Chain.Cardano);N.push(j.AssetValue.from({chain:j.Chain.Cardano,fromBaseDecimal:F,value:Q.quantity}))}else N.push(j.AssetValue.from({asset:`${j.Chain.Cardano}.${Q.unit}`,value:Q.quantity}));if(N.length===0)return[j.AssetValue.from({chain:j.Chain.Cardano})];return N}catch(f){return console.error("Cardano balance fetch error:",f),[j.AssetValue.from({chain:j.Chain.Cardano})]}}async function b(){let{deserializeAddress:y}=await import("@meshsdk/core");return(f)=>{try{return y(f),!0}catch{return!1}}}async function P(y){let f=await b(),R=await z.match(y).with({phrase:z.P.string},async({phrase:H})=>{let{MeshWallet:G}=await import("@meshsdk/core"),L=await Y(),U=new G({fetcher:L,key:{type:"mnemonic",words:H.split(" ")},networkId:1,submitter:L});return await U.init(),U}).with({signer:z.P.any},({signer:H})=>H).otherwise(()=>{return}),q=R&&"getChangeAddress"in R?await R.getChangeAddress():"";function J(){return q||""}function N(H){let G=H||J();if(!G)throw new j.SwapKitError("core_wallet_connection_not_found");return w(G)}function Q(){return Promise.resolve(j.AssetValue.from({chain:j.Chain.Cardano,value:"0.01"}))}async function F({recipient:H,assetValue:G,memo:L}){if(!R||!("getChangeAddress"in R))throw new j.SwapKitError("core_wallet_connection_not_found");let{Transaction:U}=await import("@meshsdk/core"),[,W]=G.symbol.split("-");if(!G.isGasAsset&&!W)throw new j.SwapKitError("core_wallet_connection_not_found");let X=new U({initiator:R});if(X.sendAssets({address:H},[{quantity:G.getBaseValue("string"),unit:G.isGasAsset?"lovelace":G.symbol}]),L)X.setMetadata(0,L);let M=await X.build();return{tx:X,unsignedTx:M}}function _(H){if(!R||!("getChangeAddress"in R))throw new j.SwapKitError("core_wallet_connection_not_found");return R.signTx(H)}async function v({recipient:H,assetValue:G,memo:L}){if(!R||!("getChangeAddress"in R))throw new j.SwapKitError("core_wallet_connection_not_found");let{unsignedTx:U}=await F({assetValue:G,memo:L,recipient:H}),W=await _(U);return await(await Y()).submitTx(W)}return{createTransaction:F,estimateTransactionFee:Q,getAddress:J,getBalance:N,signTransaction:_,transfer:v,validateAddress:f}}var j,z,p="lovelace";var D=O(()=>{j=require("@swapkit/helpers"),z=require("ts-pattern")});var A={};E(A,{getCardanoToolbox:()=>P,getCardanoAddressValidator:()=>b});module.exports=k(A);var o=O(()=>{D()});o();
|
|
2
|
+
|
|
3
|
+
//# debugId=8F93DCBA8767816564756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cardano/toolbox.ts", "../src/cardano/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { AssetValue, Chain, type DerivationPathArray, getChainConfig, SwapKitError } from \"@swapkit/helpers\";\nimport { match, P } from \"ts-pattern\";\nimport type { CardanoProvider } from \"./index\";\n\ntype CardanoSigner = CardanoProvider | { address: string };\n\n// TODO: this should done on BE side\nasync function getProvider() {\n const { BlockfrostProvider } = await import(\"@meshsdk/core\");\n const apiKey = \"mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS\"; // TODO: TEST API KEY\n return new BlockfrostProvider(apiKey);\n}\n\nconst ADA_ID = \"lovelace\";\n\nasync function getCardanoBalance(address: string) {\n try {\n const { MeshWallet } = await import(\"@meshsdk/core\");\n const provider = await getProvider();\n\n const wallet = new MeshWallet({ fetcher: provider, key: { address, type: \"address\" }, networkId: 1 });\n\n await wallet.init();\n const balance = await wallet.getBalance();\n\n const balances: AssetValue[] = [];\n\n for (const asset of balance) {\n if (asset.unit === ADA_ID) {\n const { baseDecimal } = getChainConfig(Chain.Cardano);\n balances.push(AssetValue.from({ chain: Chain.Cardano, fromBaseDecimal: baseDecimal, value: asset.quantity }));\n } else {\n balances.push(AssetValue.from({ asset: `${Chain.Cardano}.${asset.unit}`, value: asset.quantity }));\n }\n }\n\n if (balances.length === 0) {\n return [AssetValue.from({ chain: Chain.Cardano })];\n }\n\n return balances;\n } catch (error) {\n console.error(\"Cardano balance fetch error:\", error);\n return [AssetValue.from({ chain: Chain.Cardano })];\n }\n}\n\nexport async function getCardanoAddressValidator() {\n const { deserializeAddress } = await import(\"@meshsdk/core\");\n\n return (address: string) => {\n try {\n deserializeAddress(address);\n return true;\n } catch {\n return false;\n }\n };\n}\n\nexport async function getCardanoToolbox(\n toolboxParams?:\n | { signer?: CardanoSigner }\n | { phrase?: string; index?: number; derivationPath?: DerivationPathArray },\n) {\n const validateAddress = await getCardanoAddressValidator();\n const signer = await match(toolboxParams)\n .with({ phrase: P.string }, async ({ phrase }) => {\n const { MeshWallet } = await import(\"@meshsdk/core\");\n const provider = await getProvider();\n\n const wallet = new MeshWallet({\n fetcher: provider,\n key: { type: \"mnemonic\", words: phrase.split(\" \") },\n networkId: 1,\n submitter: provider,\n });\n\n await wallet.init();\n return wallet;\n })\n .with({ signer: P.any }, ({ signer }) => signer)\n .otherwise(() => undefined);\n\n const signerAddress = signer && \"getChangeAddress\" in signer ? await signer.getChangeAddress() : \"\";\n\n function getAddress() {\n return signerAddress || \"\";\n }\n\n function getBalance(addressParam?: string) {\n const address = addressParam || getAddress();\n if (!address) throw new SwapKitError(\"core_wallet_connection_not_found\");\n return getCardanoBalance(address);\n }\n\n function estimateTransactionFee() {\n return Promise.resolve(AssetValue.from({ chain: Chain.Cardano, value: \"0.01\" }));\n }\n\n async function createTransaction({\n recipient,\n assetValue,\n memo,\n }: {\n recipient: string;\n assetValue: AssetValue;\n memo?: string;\n }) {\n if (!signer || !(\"getChangeAddress\" in signer)) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n const { Transaction } = await import(\"@meshsdk/core\");\n\n const [, policyId] = assetValue.symbol.split(\"-\");\n if (!assetValue.isGasAsset && !policyId) throw new SwapKitError(\"core_wallet_connection_not_found\");\n\n const tx = new Transaction({ initiator: signer });\n tx.sendAssets({ address: recipient }, [\n { quantity: assetValue.getBaseValue(\"string\"), unit: assetValue.isGasAsset ? \"lovelace\" : assetValue.symbol },\n ]);\n\n if (memo) tx.setMetadata(0, memo);\n\n const unsignedTx = await tx.build();\n return { tx, unsignedTx };\n }\n\n function signTransaction(txParams: string) {\n if (!signer || !(\"getChangeAddress\" in signer)) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n return signer.signTx(txParams);\n }\n\n async function transfer({\n recipient,\n assetValue,\n memo,\n }: {\n recipient: string;\n assetValue: AssetValue;\n memo?: string;\n }) {\n if (!signer || !(\"getChangeAddress\" in signer)) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { unsignedTx } = await createTransaction({ assetValue, memo, recipient });\n const signedTx = await signTransaction(unsignedTx);\n const provider = await getProvider();\n const txHash = await provider.submitTx(signedTx);\n\n return txHash;\n }\n\n return {\n createTransaction,\n estimateTransactionFee,\n getAddress,\n getBalance,\n signTransaction,\n transfer,\n validateAddress,\n };\n}\n",
|
|
6
|
+
"export * from \"./toolbox\";\nexport * from \"./types\";\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": "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",
|
|
9
|
+
"debugId": "8F93DCBA8767816564756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var C=Object.create;var{getPrototypeOf:K,defineProperty:_,getOwnPropertyNames:S}=Object;var k=Object.prototype.hasOwnProperty;var Z=(y,R,f)=>{f=y!=null?C(K(y)):{};let G=R||!y||!y.__esModule?_(f,"default",{value:y,enumerable:!0}):f;for(let H of S(y))if(!k.call(G,H))_(G,H,{get:()=>y[H],enumerable:!0});return G};var E=(y,R)=>{for(var f in R)_(y,f,{get:R[f],enumerable:!0,configurable:!0,set:(G)=>R[f]=()=>G})};var B=(y,R)=>()=>(y&&(R=y(y=0)),R);var $=((y)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(y,{get:(R,f)=>(typeof require<"u"?require:R)[f]}):y)(function(y){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+y+'" is not supported')});import{AssetValue as F,Chain as U,getChainConfig as p,SwapKitError as z}from"@swapkit/helpers";import{match as w,P as O}from"ts-pattern";async function M(){let{BlockfrostProvider:y}=await import("@meshsdk/core"),R="mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS";return new y("mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS")}async function T(y){try{let{MeshWallet:R}=await import("@meshsdk/core"),f=await M(),G=new R({fetcher:f,key:{address:y,type:"address"},networkId:1});await G.init();let H=await G.getBalance(),L=[];for(let N of H)if(N.unit===P){let{baseDecimal:W}=p(U.Cardano);L.push(F.from({chain:U.Cardano,fromBaseDecimal:W,value:N.quantity}))}else L.push(F.from({asset:`${U.Cardano}.${N.unit}`,value:N.quantity}));if(L.length===0)return[F.from({chain:U.Cardano})];return L}catch(R){return console.error("Cardano balance fetch error:",R),[F.from({chain:U.Cardano})]}}async function b(){let{deserializeAddress:y}=await import("@meshsdk/core");return(R)=>{try{return y(R),!0}catch{return!1}}}async function A(y){let R=await b(),f=await w(y).with({phrase:O.string},async({phrase:q})=>{let{MeshWallet:j}=await import("@meshsdk/core"),J=await M(),Q=new j({fetcher:J,key:{type:"mnemonic",words:q.split(" ")},networkId:1,submitter:J});return await Q.init(),Q}).with({signer:O.any},({signer:q})=>q).otherwise(()=>{return}),G=f&&"getChangeAddress"in f?await f.getChangeAddress():"";function H(){return G||""}function L(q){let j=q||H();if(!j)throw new z("core_wallet_connection_not_found");return T(j)}function N(){return Promise.resolve(F.from({chain:U.Cardano,value:"0.01"}))}async function W({recipient:q,assetValue:j,memo:J}){if(!f||!("getChangeAddress"in f))throw new z("core_wallet_connection_not_found");let{Transaction:Q}=await import("@meshsdk/core"),[,Y]=j.symbol.split("-");if(!j.isGasAsset&&!Y)throw new z("core_wallet_connection_not_found");let X=new Q({initiator:f});if(X.sendAssets({address:q},[{quantity:j.getBaseValue("string"),unit:j.isGasAsset?"lovelace":j.symbol}]),J)X.setMetadata(0,J);let x=await X.build();return{tx:X,unsignedTx:x}}function I(q){if(!f||!("getChangeAddress"in f))throw new z("core_wallet_connection_not_found");return f.signTx(q)}async function v({recipient:q,assetValue:j,memo:J}){if(!f||!("getChangeAddress"in f))throw new z("core_wallet_connection_not_found");let{unsignedTx:Q}=await W({assetValue:j,memo:J,recipient:q}),Y=await I(Q);return await(await M()).submitTx(Y)}return{createTransaction:W,estimateTransactionFee:N,getAddress:H,getBalance:L,signTransaction:I,transfer:v,validateAddress:R}}var P="lovelace";var D=()=>{};var u={};E(u,{getCardanoToolbox:()=>A,getCardanoAddressValidator:()=>b});var V=B(()=>{D()});V();export{A as getCardanoToolbox,b as getCardanoAddressValidator};
|
|
2
|
+
|
|
3
|
+
//# debugId=0526352FCE5F2E8A64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cardano/toolbox.ts", "../src/cardano/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { AssetValue, Chain, type DerivationPathArray, getChainConfig, SwapKitError } from \"@swapkit/helpers\";\nimport { match, P } from \"ts-pattern\";\nimport type { CardanoProvider } from \"./index\";\n\ntype CardanoSigner = CardanoProvider | { address: string };\n\n// TODO: this should done on BE side\nasync function getProvider() {\n const { BlockfrostProvider } = await import(\"@meshsdk/core\");\n const apiKey = \"mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS\"; // TODO: TEST API KEY\n return new BlockfrostProvider(apiKey);\n}\n\nconst ADA_ID = \"lovelace\";\n\nasync function getCardanoBalance(address: string) {\n try {\n const { MeshWallet } = await import(\"@meshsdk/core\");\n const provider = await getProvider();\n\n const wallet = new MeshWallet({ fetcher: provider, key: { address, type: \"address\" }, networkId: 1 });\n\n await wallet.init();\n const balance = await wallet.getBalance();\n\n const balances: AssetValue[] = [];\n\n for (const asset of balance) {\n if (asset.unit === ADA_ID) {\n const { baseDecimal } = getChainConfig(Chain.Cardano);\n balances.push(AssetValue.from({ chain: Chain.Cardano, fromBaseDecimal: baseDecimal, value: asset.quantity }));\n } else {\n balances.push(AssetValue.from({ asset: `${Chain.Cardano}.${asset.unit}`, value: asset.quantity }));\n }\n }\n\n if (balances.length === 0) {\n return [AssetValue.from({ chain: Chain.Cardano })];\n }\n\n return balances;\n } catch (error) {\n console.error(\"Cardano balance fetch error:\", error);\n return [AssetValue.from({ chain: Chain.Cardano })];\n }\n}\n\nexport async function getCardanoAddressValidator() {\n const { deserializeAddress } = await import(\"@meshsdk/core\");\n\n return (address: string) => {\n try {\n deserializeAddress(address);\n return true;\n } catch {\n return false;\n }\n };\n}\n\nexport async function getCardanoToolbox(\n toolboxParams?:\n | { signer?: CardanoSigner }\n | { phrase?: string; index?: number; derivationPath?: DerivationPathArray },\n) {\n const validateAddress = await getCardanoAddressValidator();\n const signer = await match(toolboxParams)\n .with({ phrase: P.string }, async ({ phrase }) => {\n const { MeshWallet } = await import(\"@meshsdk/core\");\n const provider = await getProvider();\n\n const wallet = new MeshWallet({\n fetcher: provider,\n key: { type: \"mnemonic\", words: phrase.split(\" \") },\n networkId: 1,\n submitter: provider,\n });\n\n await wallet.init();\n return wallet;\n })\n .with({ signer: P.any }, ({ signer }) => signer)\n .otherwise(() => undefined);\n\n const signerAddress = signer && \"getChangeAddress\" in signer ? await signer.getChangeAddress() : \"\";\n\n function getAddress() {\n return signerAddress || \"\";\n }\n\n function getBalance(addressParam?: string) {\n const address = addressParam || getAddress();\n if (!address) throw new SwapKitError(\"core_wallet_connection_not_found\");\n return getCardanoBalance(address);\n }\n\n function estimateTransactionFee() {\n return Promise.resolve(AssetValue.from({ chain: Chain.Cardano, value: \"0.01\" }));\n }\n\n async function createTransaction({\n recipient,\n assetValue,\n memo,\n }: {\n recipient: string;\n assetValue: AssetValue;\n memo?: string;\n }) {\n if (!signer || !(\"getChangeAddress\" in signer)) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n const { Transaction } = await import(\"@meshsdk/core\");\n\n const [, policyId] = assetValue.symbol.split(\"-\");\n if (!assetValue.isGasAsset && !policyId) throw new SwapKitError(\"core_wallet_connection_not_found\");\n\n const tx = new Transaction({ initiator: signer });\n tx.sendAssets({ address: recipient }, [\n { quantity: assetValue.getBaseValue(\"string\"), unit: assetValue.isGasAsset ? \"lovelace\" : assetValue.symbol },\n ]);\n\n if (memo) tx.setMetadata(0, memo);\n\n const unsignedTx = await tx.build();\n return { tx, unsignedTx };\n }\n\n function signTransaction(txParams: string) {\n if (!signer || !(\"getChangeAddress\" in signer)) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n return signer.signTx(txParams);\n }\n\n async function transfer({\n recipient,\n assetValue,\n memo,\n }: {\n recipient: string;\n assetValue: AssetValue;\n memo?: string;\n }) {\n if (!signer || !(\"getChangeAddress\" in signer)) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { unsignedTx } = await createTransaction({ assetValue, memo, recipient });\n const signedTx = await signTransaction(unsignedTx);\n const provider = await getProvider();\n const txHash = await provider.submitTx(signedTx);\n\n return txHash;\n }\n\n return {\n createTransaction,\n estimateTransactionFee,\n getAddress,\n getBalance,\n signTransaction,\n transfer,\n validateAddress,\n };\n}\n",
|
|
6
|
+
"export * from \"./toolbox\";\nexport * from \"./types\";\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": "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",
|
|
9
|
+
"debugId": "0526352FCE5F2E8A64756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var s6=Object.create;var{getPrototypeOf:e6,defineProperty:c,getOwnPropertyNames:A6,getOwnPropertyDescriptor:L4}=Object,K6=Object.prototype.hasOwnProperty;var U=(Y,H,X)=>{X=Y!=null?s6(e6(Y)):{};let L=H||!Y||!Y.__esModule?c(X,"default",{value:Y,enumerable:!0}):X;for(let Z of A6(Y))if(!K6.call(L,Z))c(L,Z,{get:()=>Y[Z],enumerable:!0});return L},v6=new WeakMap,z4=(Y)=>{var H=v6.get(Y),X;if(H)return H;if(H=c({},"__esModule",{value:!0}),Y&&typeof Y==="object"||typeof Y==="function")A6(Y).map((L)=>!K6.call(H,L)&&c(H,L,{get:()=>Y[L],enumerable:!(X=L4(Y,L))||X.enumerable}));return v6.set(Y,H),H};var V6=(Y,H)=>{for(var X in H)c(Y,X,{get:H[X],enumerable:!0,configurable:!0,set:(L)=>H[X]=()=>L})};var k=(Y,H)=>()=>(Y&&(H=Y(Y=0)),H);function d(Y){return C.base64.encode(Uint8Array.from(C.bech32.fromWords(C.bech32.decode(Y).words)))}function n(Y,H="thor"){return C.bech32.encode(H,C.bech32.toWords(C.base64.decode(Y)))}function Z4(Y){return s.fromByteArray(Y)}function H4(Y){if(!Y.match(/^[a-zA-Z0-9+/]*={0,2}$/))throw new R6.SwapKitError("toolbox_cosmos_invalid_params",{error:"Invalid base64 string format"});return s.toByteArray(Y)}var C,R6,s;var X6=k(()=>{C=require("@scure/base"),R6=require("@swapkit/helpers"),s=require("base64-js")});function f(Y){switch(Y){case W.Chain.Maya:return{amount:[],gas:"10000000000"};case W.Chain.THORChain:return{amount:[],gas:"500000000"};case W.Chain.Kujira:return F6;case W.Chain.Noble:return f6;default:return M6}}async function y(Y){let H=await import("@cosmjs/stargate"),X=H.StargateClient??H.default?.StargateClient,L=typeof window<"u"?{}:{referer:"https://sdk.swapkit.dev",referrer:"https://sdk.swapkit.dev"};return X.connect({headers:L,url:Y})}async function g(Y,H,X={}){let L=await import("@cosmjs/stargate"),Z=L.SigningStargateClient??L.default?.SigningStargateClient,z=L.GasPrice??L.default?.GasPrice,Q=typeof X==="string"?X:"0.0003uatom",J=typeof X==="string"?{}:X;return Z.connectWithSigner(Y,H,{gasPrice:z.fromString(Q),...J})}async function J6(Y,H){let X=await import("@cosmjs/stargate");return(X.SigningStargateClient??X.default?.SigningStargateClient).offline(Y,H)}async function q6({sender:Y,recipient:H,assetValue:X,memo:L="",feeRate:Z,sequence:z,accountNumber:Q}){let{chain:J,chainId:_}=X,E=await W.getRPCUrl(J),I=await(await y(E)).getAccount(Y);if(!I)throw new W.SwapKitError("toolbox_cosmos_account_not_found",{sender:Y});let x=W.AssetValue.from({chain:J}),V=P(x.symbol),N=f(J),A=V&&Z?{amount:[{amount:Z.toString(),denom:V}],gas:N.gas}:N,R={amount:[{amount:X.getBaseValue("string"),denom:P(X.symbol)}],fromAddress:Y,toAddress:H};return{accountNumber:Q??I.accountNumber,chainId:_,fee:A,memo:L,msgs:[{typeUrl:Q4(J),value:R}],sequence:z??I.sequence}}var W,Y6="FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK",k6="FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM",M6,F6,f6,P=(Y,H=!1)=>{if(H)return Y.toLowerCase();switch(Y){case"uUSK":case"USK":return Y6;case"uYUM":case"YUM":return k6;case"uKUJI":case"KUJI":return"ukuji";case"ATOM":case"uATOM":return"uatom";case"uUSDC":case"USDC":return"uusdc";default:return Y}},m=({symbol:Y,chain:H})=>{if(H===W.Chain.Maya)return(Y.toUpperCase()!=="CACAO"?Y:`${W.Chain.Maya}.${Y}`).toUpperCase();if(H===W.Chain.THORChain)return(["RUNE","TCY","RUJI"].includes(Y.toUpperCase())?`${W.Chain.THORChain}.${Y}`:Y).toUpperCase();return P(Y,!1)},Q4=(Y)=>{switch(Y){case W.Chain.Maya:case W.Chain.THORChain:return"/types.MsgSend";case W.Chain.Cosmos:case W.Chain.Kujira:case W.Chain.Noble:return"/cosmos.bank.v1beta1.MsgSend";default:throw new W.SwapKitError("toolbox_cosmos_not_supported",{chain:Y})}},X4,T6=(Y,H)=>{let X=X4[Y.toLowerCase()];if(!X)return W.AssetValue.from({asset:Y,fromBaseDecimal:8,value:H});let{chain:L,asset:Z,decimals:z}=X,Q=L?{chain:L}:{asset:Z};return W.AssetValue.from({...Q,fromBaseDecimal:z,value:H})};var i=k(()=>{W=require("@swapkit/helpers"),M6={amount:[{amount:"500",denom:"uatom"}],gas:"200000"},F6={amount:[{amount:"1000",denom:"ukuji"}],gas:"200000"},f6={amount:[{amount:"1000",denom:"uusdc"}],gas:"200000"};X4={atom:{chain:W.Chain.Cosmos,decimals:W.getChainConfig(W.Chain.Cosmos).baseDecimal},cacao:{chain:W.Chain.Maya,decimals:10},kuji:{chain:W.Chain.Kujira,decimals:W.getChainConfig(W.Chain.Kujira).baseDecimal},maya:{asset:`${W.Chain.Maya}.${W.Chain.Maya}`,decimals:4},rune:{chain:W.Chain.THORChain,decimals:W.getChainConfig(W.Chain.THORChain).baseDecimal},tcy:{asset:"THOR.TCY",decimals:W.getChainConfig(W.Chain.THORChain).baseDecimal},uatom:{chain:W.Chain.Cosmos,decimals:W.getChainConfig(W.Chain.Cosmos).baseDecimal},ukuji:{chain:W.Chain.Kujira,decimals:W.getChainConfig(W.Chain.Kujira).baseDecimal},usdc:{chain:W.Chain.Noble,decimals:W.getChainConfig(W.Chain.Noble).baseDecimal},uusdc:{chain:W.Chain.Noble,decimals:W.getChainConfig(W.Chain.Noble).baseDecimal},"x/kuji":{asset:"THOR.KUJI",decimals:W.getChainConfig(W.Chain.THORChain).baseDecimal},[Y6.toLowerCase()]:{asset:`${W.Chain.Kujira}.USK`,decimals:W.getChainConfig(W.Chain.Kujira).baseDecimal}}});var y6={};V6(y6,{$root:()=>q});var K,G,M,T,q;var D6=k(()=>{K=U(require("protobufjs/minimal.js")),G=K.default.Reader,M=K.default.Writer,T=K.default.util,q=K.default.roots.default||(K.default.roots.default={});q.common=(()=>{let Y={};return Y.Asset=(()=>{function H(X){if(X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.chain="",H.prototype.symbol="",H.prototype.ticker="",H.prototype.synth=!1,H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=M.create();if(L.chain!=null&&Object.hasOwnProperty.call(L,"chain"))Z.uint32(10).string(L.chain);if(L.symbol!=null&&Object.hasOwnProperty.call(L,"symbol"))Z.uint32(18).string(L.symbol);if(L.ticker!=null&&Object.hasOwnProperty.call(L,"ticker"))Z.uint32(26).string(L.ticker);if(L.synth!=null&&Object.hasOwnProperty.call(L,"synth"))Z.uint32(32).bool(L.synth);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof G))L=G.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.Asset;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.chain=L.string();break;case 2:Q.symbol=L.string();break;case 3:Q.ticker=L.string();break;case 4:Q.synth=L.bool();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof G))L=new G(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.chain!=null&&L.hasOwnProperty("chain")){if(!T.isString(L.chain))return"chain: string expected"}if(L.symbol!=null&&L.hasOwnProperty("symbol")){if(!T.isString(L.symbol))return"symbol: string expected"}if(L.ticker!=null&&L.hasOwnProperty("ticker")){if(!T.isString(L.ticker))return"ticker: string expected"}if(L.synth!=null&&L.hasOwnProperty("synth")){if(typeof L.synth!=="boolean")return"synth: boolean expected"}return null},H.fromObject=function(L){if(L instanceof q.common.Asset)return L;let Z=new q.common.Asset;if(L.chain!=null)Z.chain=String(L.chain);if(L.symbol!=null)Z.symbol=String(L.symbol);if(L.ticker!=null)Z.ticker=String(L.ticker);if(L.synth!=null)Z.synth=Boolean(L.synth);return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.defaults)z.chain="",z.symbol="",z.ticker="",z.synth=!1;if(L.chain!=null&&L.hasOwnProperty("chain"))z.chain=L.chain;if(L.symbol!=null&&L.hasOwnProperty("symbol"))z.symbol=L.symbol;if(L.ticker!=null&&L.hasOwnProperty("ticker"))z.ticker=L.ticker;if(L.synth!=null&&L.hasOwnProperty("synth"))z.synth=L.synth;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},H})(),Y.Coin=(()=>{function H(X){if(X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.asset=null,H.prototype.amount="",H.prototype.decimals=T.Long?T.Long.fromBits(0,0,!1):0,H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=M.create();if(L.asset!=null&&Object.hasOwnProperty.call(L,"asset"))q.common.Asset.encode(L.asset,Z.uint32(10).fork()).ldelim();if(L.amount!=null&&Object.hasOwnProperty.call(L,"amount"))Z.uint32(18).string(L.amount);if(L.decimals!=null&&Object.hasOwnProperty.call(L,"decimals"))Z.uint32(24).int64(L.decimals);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof G))L=G.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.Coin;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.asset=q.common.Asset.decode(L,L.uint32());break;case 2:Q.amount=L.string();break;case 3:Q.decimals=L.int64();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof G))L=new G(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.asset!=null&&L.hasOwnProperty("asset")){let Z=q.common.Asset.verify(L.asset);if(Z)return"asset."+Z}if(L.amount!=null&&L.hasOwnProperty("amount")){if(!T.isString(L.amount))return"amount: string expected"}if(L.decimals!=null&&L.hasOwnProperty("decimals")){if(!T.isInteger(L.decimals)&&!(L.decimals&&T.isInteger(L.decimals.low)&&T.isInteger(L.decimals.high)))return"decimals: integer|Long expected"}return null},H.fromObject=function(L){if(L instanceof q.common.Coin)return L;let Z=new q.common.Coin;if(L.asset!=null){if(typeof L.asset!=="object")throw TypeError(".common.Coin.asset: object expected");Z.asset=q.common.Asset.fromObject(L.asset)}if(L.amount!=null)Z.amount=String(L.amount);if(L.decimals!=null){if(T.Long)(Z.decimals=T.Long.fromValue(L.decimals)).unsigned=!1;else if(typeof L.decimals==="string")Z.decimals=Number.parseInt(L.decimals,10);else if(typeof L.decimals==="number")Z.decimals=L.decimals;else if(typeof L.decimals==="object")Z.decimals=new T.LongBits(L.decimals.low>>>0,L.decimals.high>>>0).toNumber()}return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.defaults)if(z.asset=null,z.amount="",T.Long){let Q=new T.Long(0,0,!1);z.decimals=Z.longs===String?Q.toString():Z.longs===Number?Q.toNumber():Q}else z.decimals=Z.longs===String?"0":0;if(L.asset!=null&&L.hasOwnProperty("asset"))z.asset=q.common.Asset.toObject(L.asset,Z);if(L.amount!=null&&L.hasOwnProperty("amount"))z.amount=L.amount;if(L.decimals!=null&&L.hasOwnProperty("decimals"))if(typeof L.decimals==="number")z.decimals=Z.longs===String?String(L.decimals):L.decimals;else z.decimals=Z.longs===String?T.Long.prototype.toString.call(L.decimals):Z.longs===Number?new T.LongBits(L.decimals.low>>>0,L.decimals.high>>>0).toNumber():L.decimals;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},H})(),Y.PubKeySet=(()=>{function H(X){if(X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.secp256k1="",H.prototype.ed25519="",H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=M.create();if(L.secp256k1!=null&&Object.hasOwnProperty.call(L,"secp256k1"))Z.uint32(10).string(L.secp256k1);if(L.ed25519!=null&&Object.hasOwnProperty.call(L,"ed25519"))Z.uint32(18).string(L.ed25519);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof G))L=G.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.PubKeySet;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.secp256k1=L.string();break;case 2:Q.ed25519=L.string();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof G))L=new G(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.secp256k1!=null&&L.hasOwnProperty("secp256k1")){if(!T.isString(L.secp256k1))return"secp256k1: string expected"}if(L.ed25519!=null&&L.hasOwnProperty("ed25519")){if(!T.isString(L.ed25519))return"ed25519: string expected"}return null},H.fromObject=function(L){if(L instanceof q.common.PubKeySet)return L;let Z=new q.common.PubKeySet;if(L.secp256k1!=null)Z.secp256k1=String(L.secp256k1);if(L.ed25519!=null)Z.ed25519=String(L.ed25519);return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.defaults)z.secp256k1="",z.ed25519="";if(L.secp256k1!=null&&L.hasOwnProperty("secp256k1"))z.secp256k1=L.secp256k1;if(L.ed25519!=null&&L.hasOwnProperty("ed25519"))z.ed25519=L.ed25519;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},H})(),Y.Tx=(()=>{function H(X){if(this.coins=[],this.gas=[],X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.id="",H.prototype.chain="",H.prototype.fromAddress="",H.prototype.toAddress="",H.prototype.coins=T.emptyArray,H.prototype.gas=T.emptyArray,H.prototype.memo="",H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=M.create();if(L.id!=null&&Object.hasOwnProperty.call(L,"id"))Z.uint32(10).string(L.id);if(L.chain!=null&&Object.hasOwnProperty.call(L,"chain"))Z.uint32(18).string(L.chain);if(L.fromAddress!=null&&Object.hasOwnProperty.call(L,"fromAddress"))Z.uint32(26).string(L.fromAddress);if(L.toAddress!=null&&Object.hasOwnProperty.call(L,"toAddress"))Z.uint32(34).string(L.toAddress);if(L.coins?.length)for(let z=0;z<L.coins.length;++z)q.common.Coin.encode(L.coins[z],Z.uint32(42).fork()).ldelim();if(L.gas?.length)for(let z=0;z<L.gas.length;++z)q.common.Coin.encode(L.gas[z],Z.uint32(50).fork()).ldelim();if(L.memo!=null&&Object.hasOwnProperty.call(L,"memo"))Z.uint32(58).string(L.memo);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof G))L=G.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.Tx;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.id=L.string();break;case 2:Q.chain=L.string();break;case 3:Q.fromAddress=L.string();break;case 4:Q.toAddress=L.string();break;case 5:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(L,L.uint32()));break;case 6:if(!Q.gas?.length)Q.gas=[];Q.gas.push(q.common.Coin.decode(L,L.uint32()));break;case 7:Q.memo=L.string();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof G))L=new G(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.id!=null&&L.hasOwnProperty("id")){if(!T.isString(L.id))return"id: string expected"}if(L.chain!=null&&L.hasOwnProperty("chain")){if(!T.isString(L.chain))return"chain: string expected"}if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress")){if(!T.isString(L.fromAddress))return"fromAddress: string expected"}if(L.toAddress!=null&&L.hasOwnProperty("toAddress")){if(!T.isString(L.toAddress))return"toAddress: string expected"}if(L.coins!=null&&L.hasOwnProperty("coins")){if(!Array.isArray(L.coins))return"coins: array expected";for(let Z=0;Z<L.coins.length;++Z){let z=q.common.Coin.verify(L.coins[Z]);if(z)return"coins."+z}}if(L.gas!=null&&L.hasOwnProperty("gas")){if(!Array.isArray(L.gas))return"gas: array expected";for(let Z=0;Z<L.gas.length;++Z){let z=q.common.Coin.verify(L.gas[Z]);if(z)return"gas."+z}}if(L.memo!=null&&L.hasOwnProperty("memo")){if(!T.isString(L.memo))return"memo: string expected"}return null},H.fromObject=function(L){if(L instanceof q.common.Tx)return L;let Z=new q.common.Tx;if(L.id!=null)Z.id=String(L.id);if(L.chain!=null)Z.chain=String(L.chain);if(L.fromAddress!=null)Z.fromAddress=String(L.fromAddress);if(L.toAddress!=null)Z.toAddress=String(L.toAddress);if(L.coins){if(!Array.isArray(L.coins))throw TypeError(".common.Tx.coins: array expected");Z.coins=[];for(let z=0;z<L.coins.length;++z){if(typeof L.coins[z]!=="object")throw TypeError(".common.Tx.coins: object expected");Z.coins[z]=q.common.Coin.fromObject(L.coins[z])}}if(L.gas){if(!Array.isArray(L.gas))throw TypeError(".common.Tx.gas: array expected");Z.gas=[];for(let z=0;z<L.gas.length;++z){if(typeof L.gas[z]!=="object")throw TypeError(".common.Tx.gas: object expected");Z.gas[z]=q.common.Coin.fromObject(L.gas[z])}}if(L.memo!=null)Z.memo=String(L.memo);return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.arrays||Z.defaults)z.coins=[],z.gas=[];if(Z.defaults)z.id="",z.chain="",z.fromAddress="",z.toAddress="",z.memo="";if(L.id!=null&&L.hasOwnProperty("id"))z.id=L.id;if(L.chain!=null&&L.hasOwnProperty("chain"))z.chain=L.chain;if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress"))z.fromAddress=L.fromAddress;if(L.toAddress!=null&&L.hasOwnProperty("toAddress"))z.toAddress=L.toAddress;if(L.coins?.length){z.coins=[];for(let Q=0;Q<L.coins.length;++Q)z.coins[Q]=q.common.Coin.toObject(L.coins[Q],Z)}if(L.gas?.length){z.gas=[];for(let Q=0;Q<L.gas.length;++Q)z.gas[Q]=q.common.Coin.toObject(L.gas[Q],Z)}if(L.memo!=null&&L.hasOwnProperty("memo"))z.memo=L.memo;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},H})(),Y.Fee=(()=>{function H(X){if(this.coins=[],X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.coins=T.emptyArray,H.prototype.poolDeduct="",H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=M.create();if(L.coins?.length)for(let z=0;z<L.coins.length;++z)q.common.Coin.encode(L.coins[z],Z.uint32(10).fork()).ldelim();if(L.poolDeduct!=null&&Object.hasOwnProperty.call(L,"poolDeduct"))Z.uint32(18).string(L.poolDeduct);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof G))L=G.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.Fee;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(L,L.uint32()));break;case 2:Q.poolDeduct=L.string();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof G))L=new G(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.coins!=null&&L.hasOwnProperty("coins")){if(!Array.isArray(L.coins))return"coins: array expected";for(let Z=0;Z<L.coins.length;++Z){let z=q.common.Coin.verify(L.coins[Z]);if(z)return"coins."+z}}if(L.poolDeduct!=null&&L.hasOwnProperty("poolDeduct")){if(!T.isString(L.poolDeduct))return"poolDeduct: string expected"}return null},H.fromObject=function(L){if(L instanceof q.common.Fee)return L;let Z=new q.common.Fee;if(L.coins){if(!Array.isArray(L.coins))throw TypeError(".common.Fee.coins: array expected");Z.coins=[];for(let z=0;z<L.coins.length;++z){if(typeof L.coins[z]!=="object")throw TypeError(".common.Fee.coins: object expected");Z.coins[z]=q.common.Coin.fromObject(L.coins[z])}}if(L.poolDeduct!=null)Z.poolDeduct=String(L.poolDeduct);return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.arrays||Z.defaults)z.coins=[];if(Z.defaults)z.poolDeduct="";if(L.coins?.length){z.coins=[];for(let Q=0;Q<L.coins.length;++Q)z.coins[Q]=q.common.Coin.toObject(L.coins[Q],Z)}if(L.poolDeduct!=null&&L.hasOwnProperty("poolDeduct"))z.poolDeduct=L.poolDeduct;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},H})(),Y.ProtoUint=(()=>{function H(X){if(X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.value="",H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=M.create();if(L.value!=null&&Object.hasOwnProperty.call(L,"value"))Z.uint32(10).string(L.value);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof G))L=G.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.common.ProtoUint;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.value=L.string();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof G))L=new G(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.value!=null&&L.hasOwnProperty("value")){if(!T.isString(L.value))return"value: string expected"}return null},H.fromObject=function(L){if(L instanceof q.common.ProtoUint)return L;let Z=new q.common.ProtoUint;if(L.value!=null)Z.value=String(L.value);return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.defaults)z.value="";if(L.value!=null&&L.hasOwnProperty("value"))z.value=L.value;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},H})(),Y})();q.types=(()=>{let Y={};return Y.MsgDeposit=(()=>{function H(X){if(this.coins=[],X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.coins=T.emptyArray,H.prototype.memo="",H.prototype.signer=T.newBuffer([]),H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=M.create();if(L.coins?.length)for(let z=0;z<L.coins.length;++z)q.common.Coin.encode(L.coins[z],Z.uint32(10).fork()).ldelim();if(L.memo!=null&&Object.hasOwnProperty.call(L,"memo"))Z.uint32(18).string(L.memo);if(L.signer!=null&&Object.hasOwnProperty.call(L,"signer"))Z.uint32(26).bytes(L.signer);return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof G))L=G.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.types.MsgDeposit;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:if(!Q.coins?.length)Q.coins=[];Q.coins.push(q.common.Coin.decode(L,L.uint32()));break;case 2:Q.memo=L.string();break;case 3:Q.signer=L.bytes();break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof G))L=new G(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.coins!=null&&L.hasOwnProperty("coins")){if(!Array.isArray(L.coins))return"coins: array expected";for(let Z=0;Z<L.coins.length;++Z){let z=q.common.Coin.verify(L.coins[Z]);if(z)return"coins."+z}}if(L.memo!=null&&L.hasOwnProperty("memo")){if(!T.isString(L.memo))return"memo: string expected"}if(L.signer!=null&&L.hasOwnProperty("signer")){if(!(L.signer&&typeof L.signer.length==="number"||T.isString(L.signer)))return"signer: buffer expected"}return null},H.fromObject=function(L){if(L instanceof q.types.MsgDeposit)return L;let Z=new q.types.MsgDeposit;if(L.coins){if(!Array.isArray(L.coins))throw TypeError(".types.MsgDeposit.coins: array expected");Z.coins=[];for(let z=0;z<L.coins.length;++z){if(typeof L.coins[z]!=="object")throw TypeError(".types.MsgDeposit.coins: object expected");Z.coins[z]=q.common.Coin.fromObject(L.coins[z])}}if(L.memo!=null)Z.memo=String(L.memo);if(L.signer!=null){if(typeof L.signer==="string")T.base64.decode(L.signer,Z.signer=T.newBuffer(T.base64.length(L.signer)),0);else if(L.signer.length)Z.signer=L.signer}return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.arrays||Z.defaults)z.coins=[];if(Z.defaults){if(z.memo="",Z.bytes===String)z.signer="";else if(z.signer=[],Z.bytes!==Array)z.signer=T.newBuffer(z.signer)}if(L.coins?.length){z.coins=[];for(let Q=0;Q<L.coins.length;++Q)z.coins[Q]=q.common.Coin.toObject(L.coins[Q],Z)}if(L.memo!=null&&L.hasOwnProperty("memo"))z.memo=L.memo;if(L.signer!=null&&L.hasOwnProperty("signer"))z.signer=Z.bytes===String?T.base64.encode(L.signer,0,L.signer.length):Z.bytes===Array?Array.prototype.slice.call(L.signer):L.signer;return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},H})(),Y.MsgSend=(()=>{function H(X){if(this.amount=[],X){for(let L=Object.keys(X),Z=0;Z<L.length;++Z)if(X[L[Z]]!=null)this[L[Z]]=X[L[Z]]}}return H.prototype.fromAddress=T.newBuffer([]),H.prototype.toAddress=T.newBuffer([]),H.prototype.amount=T.emptyArray,H.create=function(L){return new H(L)},H.encode=function(L,Z){if(!Z)Z=M.create();if(L.fromAddress!=null&&Object.hasOwnProperty.call(L,"fromAddress"))Z.uint32(10).bytes(L.fromAddress);if(L.toAddress!=null&&Object.hasOwnProperty.call(L,"toAddress"))Z.uint32(18).bytes(L.toAddress);if(L.amount?.length)for(let z=0;z<L.amount.length;++z)q.cosmos.base.v1beta1.Coin.encode(L.amount[z],Z.uint32(26).fork()).ldelim();return Z},H.encodeDelimited=function(L,Z){return this.encode(L,Z).ldelim()},H.decode=function(L,Z){if(!(L instanceof G))L=G.create(L);let z=Z===void 0?L.len:L.pos+Z,Q=new q.types.MsgSend;while(L.pos<z){let J=L.uint32();switch(J>>>3){case 1:Q.fromAddress=L.bytes();break;case 2:Q.toAddress=L.bytes();break;case 3:if(!Q.amount?.length)Q.amount=[];Q.amount.push(q.cosmos.base.v1beta1.Coin.decode(L,L.uint32()));break;default:L.skipType(J&7);break}}return Q},H.decodeDelimited=function(L){if(!(L instanceof G))L=new G(L);return this.decode(L,L.uint32())},H.verify=function(L){if(typeof L!=="object"||L===null)return"object expected";if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress")){if(!(L.fromAddress&&typeof L.fromAddress.length==="number"||T.isString(L.fromAddress)))return"fromAddress: buffer expected"}if(L.toAddress!=null&&L.hasOwnProperty("toAddress")){if(!(L.toAddress&&typeof L.toAddress.length==="number"||T.isString(L.toAddress)))return"toAddress: buffer expected"}if(L.amount!=null&&L.hasOwnProperty("amount")){if(!Array.isArray(L.amount))return"amount: array expected";for(let Z=0;Z<L.amount.length;++Z){let z=q.cosmos.base.v1beta1.Coin.verify(L.amount[Z]);if(z)return"amount."+z}}return null},H.fromObject=function(L){if(L instanceof q.types.MsgSend)return L;let Z=new q.types.MsgSend;if(L.fromAddress!=null){if(typeof L.fromAddress==="string")T.base64.decode(L.fromAddress,Z.fromAddress=T.newBuffer(T.base64.length(L.fromAddress)),0);else if(L.fromAddress.length)Z.fromAddress=L.fromAddress}if(L.toAddress!=null){if(typeof L.toAddress==="string")T.base64.decode(L.toAddress,Z.toAddress=T.newBuffer(T.base64.length(L.toAddress)),0);else if(L.toAddress.length)Z.toAddress=L.toAddress}if(L.amount){if(!Array.isArray(L.amount))throw TypeError(".types.MsgSend.amount: array expected");Z.amount=[];for(let z=0;z<L.amount.length;++z){if(typeof L.amount[z]!=="object")throw TypeError(".types.MsgSend.amount: object expected");Z.amount[z]=q.cosmos.base.v1beta1.Coin.fromObject(L.amount[z])}}return Z},H.toObject=function(L,Z){if(!Z)Z={};let z={};if(Z.arrays||Z.defaults)z.amount=[];if(Z.defaults){if(Z.bytes===String)z.fromAddress="";else if(z.fromAddress=[],Z.bytes!==Array)z.fromAddress=T.newBuffer(z.fromAddress);if(Z.bytes===String)z.toAddress="";else if(z.toAddress=[],Z.bytes!==Array)z.toAddress=T.newBuffer(z.toAddress)}if(L.fromAddress!=null&&L.hasOwnProperty("fromAddress"))z.fromAddress=Z.bytes===String?T.base64.encode(L.fromAddress,0,L.fromAddress.length):Z.bytes===Array?Array.prototype.slice.call(L.fromAddress):L.fromAddress;if(L.toAddress!=null&&L.hasOwnProperty("toAddress"))z.toAddress=Z.bytes===String?T.base64.encode(L.toAddress,0,L.toAddress.length):Z.bytes===Array?Array.prototype.slice.call(L.toAddress):L.toAddress;if(L.amount?.length){z.amount=[];for(let Q=0;Q<L.amount.length;++Q)z.amount[Q]=q.cosmos.base.v1beta1.Coin.toObject(L.amount[Q],Z)}return z},H.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},H})(),Y})();q.cosmos=(()=>{let Y={};return Y.base=(()=>{let H={};return H.v1beta1=(()=>{let X={};return X.Coin=(()=>{function L(Z){if(Z){for(let z=Object.keys(Z),Q=0;Q<z.length;++Q)if(Z[z[Q]]!=null)this[z[Q]]=Z[z[Q]]}}return L.prototype.denom="",L.prototype.amount="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=M.create();if(z.denom!=null&&Object.hasOwnProperty.call(z,"denom"))Q.uint32(10).string(z.denom);if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))Q.uint32(18).string(z.amount);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof G))z=G.create(z);let J=Q===void 0?z.len:z.pos+Q,_=new q.cosmos.base.v1beta1.Coin;while(z.pos<J){let E=z.uint32();switch(E>>>3){case 1:_.denom=z.string();break;case 2:_.amount=z.string();break;default:z.skipType(E&7);break}}return _},L.decodeDelimited=function(z){if(!(z instanceof G))z=new G(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.denom!=null&&z.hasOwnProperty("denom")){if(!T.isString(z.denom))return"denom: string expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!T.isString(z.amount))return"amount: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.Coin)return z;let Q=new q.cosmos.base.v1beta1.Coin;if(z.denom!=null)Q.denom=String(z.denom);if(z.amount!=null)Q.amount=String(z.amount);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.denom="",J.amount="";if(z.denom!=null&&z.hasOwnProperty("denom"))J.denom=z.denom;if(z.amount!=null&&z.hasOwnProperty("amount"))J.amount=z.amount;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},L})(),X.DecCoin=(()=>{function L(Z){if(Z){for(let z=Object.keys(Z),Q=0;Q<z.length;++Q)if(Z[z[Q]]!=null)this[z[Q]]=Z[z[Q]]}}return L.prototype.denom="",L.prototype.amount="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=M.create();if(z.denom!=null&&Object.hasOwnProperty.call(z,"denom"))Q.uint32(10).string(z.denom);if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))Q.uint32(18).string(z.amount);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof G))z=G.create(z);let J=Q===void 0?z.len:z.pos+Q,_=new q.cosmos.base.v1beta1.DecCoin;while(z.pos<J){let E=z.uint32();switch(E>>>3){case 1:_.denom=z.string();break;case 2:_.amount=z.string();break;default:z.skipType(E&7);break}}return _},L.decodeDelimited=function(z){if(!(z instanceof G))z=new G(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.denom!=null&&z.hasOwnProperty("denom")){if(!T.isString(z.denom))return"denom: string expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!T.isString(z.amount))return"amount: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.DecCoin)return z;let Q=new q.cosmos.base.v1beta1.DecCoin;if(z.denom!=null)Q.denom=String(z.denom);if(z.amount!=null)Q.amount=String(z.amount);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.denom="",J.amount="";if(z.denom!=null&&z.hasOwnProperty("denom"))J.denom=z.denom;if(z.amount!=null&&z.hasOwnProperty("amount"))J.amount=z.amount;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},L})(),X.IntProto=(()=>{function L(Z){if(Z){for(let z=Object.keys(Z),Q=0;Q<z.length;++Q)if(Z[z[Q]]!=null)this[z[Q]]=Z[z[Q]]}}return L.prototype.int="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=M.create();if(z.int!=null&&Object.hasOwnProperty.call(z,"int"))Q.uint32(10).string(z.int);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof G))z=G.create(z);let J=Q===void 0?z.len:z.pos+Q,_=new q.cosmos.base.v1beta1.IntProto;while(z.pos<J){let E=z.uint32();switch(E>>>3){case 1:_.int=z.string();break;default:z.skipType(E&7);break}}return _},L.decodeDelimited=function(z){if(!(z instanceof G))z=new G(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.int!=null&&z.hasOwnProperty("int")){if(!T.isString(z.int))return"int: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.IntProto)return z;let Q=new q.cosmos.base.v1beta1.IntProto;if(z.int!=null)Q.int=String(z.int);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.int="";if(z.int!=null&&z.hasOwnProperty("int"))J.int=z.int;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},L})(),X.DecProto=(()=>{function L(Z){if(Z){for(let z=Object.keys(Z),Q=0;Q<z.length;++Q)if(Z[z[Q]]!=null)this[z[Q]]=Z[z[Q]]}}return L.prototype.dec="",L.create=function(z){return new L(z)},L.encode=function(z,Q){if(!Q)Q=M.create();if(z.dec!=null&&Object.hasOwnProperty.call(z,"dec"))Q.uint32(10).string(z.dec);return Q},L.encodeDelimited=function(z,Q){return this.encode(z,Q).ldelim()},L.decode=function(z,Q){if(!(z instanceof G))z=G.create(z);let J=Q===void 0?z.len:z.pos+Q,_=new q.cosmos.base.v1beta1.DecProto;while(z.pos<J){let E=z.uint32();switch(E>>>3){case 1:_.dec=z.string();break;default:z.skipType(E&7);break}}return _},L.decodeDelimited=function(z){if(!(z instanceof G))z=new G(z);return this.decode(z,z.uint32())},L.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.dec!=null&&z.hasOwnProperty("dec")){if(!T.isString(z.dec))return"dec: string expected"}return null},L.fromObject=function(z){if(z instanceof q.cosmos.base.v1beta1.DecProto)return z;let Q=new q.cosmos.base.v1beta1.DecProto;if(z.dec!=null)Q.dec=String(z.dec);return Q},L.toObject=function(z,Q){if(!Q)Q={};let J={};if(Q.defaults)J.dec="";if(z.dec!=null&&z.hasOwnProperty("dec"))J.dec=z.dec;return J},L.prototype.toJSON=function(){return this.constructor.toObject(this,K.default.util.toJSONOptions)},L})(),X})(),H})(),Y})()});async function b(){let{$root:Y}=await Promise.resolve().then(() => (D6(),y6)),H=await import("@cosmjs/proto-signing"),X=H.Registry??H.default?.Registry,L=await import("@cosmjs/stargate"),Z=L.defaultRegistryTypes??L.default?.defaultRegistryTypes;return new X([...Z,["/types.MsgSend",Y.types.MsgSend],["/types.MsgDeposit",Y.types.MsgDeposit]])}async function w(Y){let H=await import("@cosmjs/stargate"),X=H.AminoTypes??H.default?.AminoTypes,L=Y===S6.Chain.THORChain?"thorchain":"mayachain";return new X({"/types.MsgDeposit":{aminoType:`${L}/MsgDeposit`,fromAmino:({signer:Z,...z})=>({...z,signer:d(Z)}),toAmino:({signer:Z,...z})=>({...z,signer:n(Z)})},"/types.MsgSend":{aminoType:`${L}/MsgSend`,fromAmino:({from_address:Z,to_address:z,...Q})=>({...Q,fromAddress:d(Z),toAddress:d(z)}),toAmino:({fromAddress:Z,toAddress:z,...Q})=>({...Q,from_address:n(Z),to_address:n(z)})}})}var S6;var W6=k(()=>{X6();S6=require("@swapkit/helpers")});function _6(Y){return function(X){let{assetValue:L,recipient:Z,memo:z,sender:Q,asSignable:J,asAminoMessage:_}=X;if(Z)return P6(Y)({asAminoMessage:_,asSignable:J,assetValue:L,memo:z,recipient:Z,sender:Q});return w6(Y)({asAminoMessage:_,asSignable:J,assetValue:L,memo:z,sender:Q})}}function u(Y){if(Y.type==="thorchain/MsgSend"||Y.type==="mayachain/MsgSend")return Y;return{...Y,value:{...Y.value,coins:Y.value.coins.map((H)=>{let X=F.AssetValue.from({asset:H.asset}),L=(X.isSynthetic?X.symbol.split("/")?.[1]:X.symbol)?.toUpperCase(),Z=(X.isSynthetic?X.symbol.split("/")?.[0]:X.chain)?.toUpperCase();return{...H,asset:{chain:Z,symbol:L,synth:X.isSynthetic,ticker:X.ticker}}})}}}async function o({chain:Y,memo:H,msgs:X}){let L=await b(),Z=await w(Y),z={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:H,messages:X.map((Q)=>Z.fromAmino(Q))}};return L.encode(z)}var F,Y4,J4,B6=({sender:Y,recipient:H,assetValue:X})=>{return{type:`${X.chain===F.Chain.Maya?"mayachain":"thorchain"}/MsgSend`,value:{amount:[{amount:X.getBaseValue("string"),denom:P(X.symbol,!0)}],from_address:Y,to_address:H}}},G6=({sender:Y,assetValue:H,memo:X=""})=>{return{type:`${H.chain===F.Chain.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:H.getBaseValue("string"),asset:m(H)}],memo:X,signer:Y}}},e=({sender:Y,recipient:H,assetValue:X,memo:L})=>{return!H?G6({assetValue:X,memo:L,sender:Y}):B6({assetValue:X,recipient:H,sender:Y})},$=async(Y,H)=>{return(await w(H)).fromAmino(Y)},C6=async({rpcUrl:Y,sender:H})=>{let L=await(await y(Y)).getAccount(H);if(!L)throw new F.SwapKitError("toolbox_cosmos_account_not_found",{sender:H});return L},P6=(Y)=>async({sender:H,recipient:X,assetValue:L,memo:Z="",asSignable:z=!0,asAminoMessage:Q=!1,sequence:J,accountNumber:_})=>{let E=await C6({rpcUrl:Y,sender:H}),v=L.chain,{chainId:I}=F.getChainConfig(v),x=B6({assetValue:L,recipient:X,sender:H}),V=z?await $(Q?x:u(x),v):x;return{accountNumber:_||E.accountNumber,chainId:I,fee:f(v),memo:Z,msgs:[V],sequence:J||E.sequence}},w6=(Y)=>async({sender:H,assetValue:X,memo:L="",asSignable:Z=!0,asAminoMessage:z=!1,sequence:Q,accountNumber:J})=>{let _=await C6({rpcUrl:Y,sender:H}),E=X.chain,{chainId:v}=F.getChainConfig(E),I=G6({assetValue:X,memo:L,sender:H}),x=Z?await $(z?I:u(I),E):I;return{accountNumber:J||_.accountNumber,chainId:v,fee:f(E),memo:L,msgs:[x],sequence:Q||_.sequence}};var $6=k(()=>{i();W6();F=require("@swapkit/helpers"),Y4=f(F.Chain.THORChain).gas,J4=f(F.Chain.Maya).gas});var u6=()=>{};var h6=k(()=>{u6()});var I6=k(()=>{X6();$6();W6();h6()});async function O6(Y,H){try{let L=(await N6.SwapKitApi.getGasRate()).find((Z)=>Z.chainId===Y)?.value;return L?Number.parseFloat(L):H}catch(X){return H}}async function E6({phrase:Y,prefix:H,...X}){let L=await import("@cosmjs/proto-signing"),Z=L.DirectSecp256k1HdWallet??L.default?.DirectSecp256k1HdWallet,z=await import("@cosmjs/crypto"),Q=z.stringToPath??z.default?.stringToPath,J="derivationPath"in X?X.derivationPath:`${B.DerivationPath[X.chain]}/${X.index}`;return Z.fromMnemonic(Y,{hdPaths:[Q(J)],prefix:H})}async function q4({privateKey:Y,prefix:H}){let X=await import("@cosmjs/proto-signing");return(X.DirectSecp256k1Wallet??X.default?.DirectSecp256k1Wallet).fromKey(Y,H)}function p6(Y){return async function({signature:X,message:L,address:Z}){let z=await Y(Z);if(!z?.pubkey)throw new B.SwapKitError("toolbox_cosmos_verify_signature_no_pubkey");let Q=await import("@cosmjs/crypto"),J=Q.Secp256k1Signature??Q.default?.Secp256k1Signature,_=Q.Secp256k1??Q.default?.Secp256k1,E=J.fromFixedLength(h.base64.decode(X));return _.verifySignature(E,h.base64.decode(L),z.pubkey.value)}}async function r({chain:Y,...H}){let X=await B.getRPCUrl(Y),L=B.CosmosChainPrefixes[Y],Z="index"in H?H.index||0:0,z=B.derivationPathToString("derivationPath"in H&&H.derivationPath?H.derivationPath:B.updateDerivationPath(B.NetworkDerivationPath[Y],{index:Z})),Q=await t.match(H).with({phrase:t.P.string},({phrase:I})=>E6({derivationPath:z,phrase:I,prefix:L})).with({signer:t.P.any},({signer:I})=>I).otherwise(()=>{return});async function J(I){return(await y(X)).getAccount(I)}async function _(){let[I]=await Q?.getAccounts()||[];return I?.address}async function E(){let[I]=await Q?.getAccounts()||[];if(!I?.pubkey)throw new B.SwapKitError("toolbox_cosmos_signer_not_defined");return h.base64.encode(I?.pubkey)}async function v({recipient:I,assetValue:x,memo:V="",feeRate:N,feeOptionKey:A=B.FeeOption.Fast}){let R=await _();if(!(Q&&R))throw new B.SwapKitError("toolbox_cosmos_signer_not_defined");let D=B.AssetValue.from({chain:Y}),S=m(D),z6=N||_4((await j6(Y,l6[Y]))[A],S),Z6=await g(X,Q),H6=[{amount:x.getBaseValue("string"),denom:P(`u${x.symbol}`).toLowerCase()}],{transactionHash:p}=await Z6.sendTokens(R,I,H6,z6,V);return p}return{createPrivateKeyFromPhrase:E4(z),createTransaction:q6,fetchFeeRateFromSwapKit:O6,getAccount:J,getAddress:_,getBalance:async(I,x)=>{let V=await b6(X)(I);return await Promise.all(V.filter(({denom:N})=>N&&!N.includes("IBC/")).map(({denom:N,amount:A})=>{let R=[B.Chain.THORChain,B.Chain.Maya].includes(Y)&&(N.includes("/")||N.includes("˜"))?`${Y}.${N}`:N;return T6(R,A)}))},getBalanceAsDenoms:b6(X),getFees:()=>j6(Y,l6[Y]),getPubKey:E,getSignerFromPhrase:async({phrase:I,derivationPath:x})=>E6({derivationPath:B.derivationPathToString(x),index:Z,phrase:I,prefix:L}),getSignerFromPrivateKey:async(I)=>{let x=await import("@cosmjs/proto-signing");return(x.DirectSecp256k1Wallet??x.default?.DirectSecp256k1Wallet).fromKey(I,L)},transfer:v,validateAddress:d6(L),verifySignature:p6(J)}}async function c6(Y,H){try{let L=(await N6.SwapKitApi.getGasRate()).find((Z)=>Z.chainId===Y)?.value;return L?Number.parseFloat(L):H}catch(X){return H}}function W4({address:Y,chain:H,prefix:X}){let L=X||G4(H);if(!(L&&Y))throw new B.SwapKitError("toolbox_cosmos_validate_address_prefix_not_found");return d6(L)(Y)}function B4({assetValue:{chain:Y}}){return B.AssetValue.from({chain:Y,value:I4(Y)})}function G4(Y){let{isStagenet:H}=B.SKConfig.get("envs"),X=Y?[B.Chain.THORChain,B.Chain.Maya].includes(Y)&&H:!1,L=Y?B.CosmosChainPrefixes[Y]:void 0;return X?`s${L}`:L}async function j6(Y,H){let{chainId:X,baseDecimal:L}=B.getChainConfig(Y),Z=await O6(X,H);return{average:B.SwapKitNumber.fromBigInt(BigInt(Z),L),fast:B.SwapKitNumber.fromBigInt(BigInt(B.applyFeeMultiplier(Z,B.FeeOption.Fast,!0)),L),fastest:B.SwapKitNumber.fromBigInt(BigInt(B.applyFeeMultiplier(Z,B.FeeOption.Fastest,!0)),L)}}function _4(Y,H){return{amount:[{amount:Y.getBaseValue("string"),denom:H}],gas:"200000"}}function I4(Y){return{[B.Chain.Cosmos]:0.007,[B.Chain.Kujira]:0.02,[B.Chain.Noble]:0.01,[B.Chain.THORChain]:0.02,[B.Chain.Maya]:0.02,[B.Chain.Harbor]:0.02}[Y]||0}function d6(Y){return function(X){if(!X.startsWith(Y))return!1;try{let{prefix:L,words:Z}=h.bech32.decode(X);return h.bech32.encode(L,Z)===X.toLocaleLowerCase()}catch(L){return!1}}}function b6(Y){return async function(X){return(await(await y(Y)).getAllBalances(X)).map((Q)=>({...Q,denom:Q.denom.includes("/")?Q.denom.toUpperCase():Q.denom}))}}function E4(Y){return async function(X){let L=await import("@cosmjs/crypto"),Z=L.stringToPath??L.default?.stringToPath,z=L.Slip10Curve??L.default?.Slip10Curve,Q=L.Slip10??L.default?.Slip10,J=L.EnglishMnemonic??L.default?.EnglishMnemonic,_=L.Bip39??L.default?.Bip39,E=new J(X),v=await _.mnemonicToSeed(E),{privkey:I}=Q.derivePath(z.Secp256k1,v,Z(Y));return I}}var h,B,N6,t,l6,T4;var L6=k(()=>{i();h=require("@scure/base"),B=require("@swapkit/helpers"),N6=require("@swapkit/helpers/api"),t=require("ts-pattern");l6={[B.Chain.Cosmos]:500,[B.Chain.Kujira]:1000,[B.Chain.Noble]:1000,[B.Chain.THORChain]:5000000,[B.Chain.Maya]:5000000,[B.Chain.Harbor]:5000000};T4=c6});function N4({prefix:Y,derivationPath:H}){return async function(L,Z=0){let z=await import("@cosmjs/amino"),Q=z.Secp256k1HdWallet??z.default?.Secp256k1HdWallet,J=await import("@cosmjs/crypto"),_=J.stringToPath??J.default?.stringToPath;return Q.fromMnemonic(L,{hdPaths:[_(`${H}/${Z}`)],prefix:Y})}}function O4(Y){return l.base64.encode(Y)}function x4(Y){return async function({wallet:X,tx:L}){let{msgs:Z,accountNumber:z,sequence:Q,chainId:J,fee:_,memo:E}=typeof L==="string"?JSON.parse(L):L,v=(await X.getAccounts())?.[0]?.address||"",I=await w(Y),x=await b(),V=await J6(X,{aminoTypes:I,registry:x}),N=[];for(let D of Z){let S=await $(D,Y);N.push(S)}let{signatures:[A]}=await V.sign(v,N,_,E,{accountNumber:z,chainId:J,sequence:Q});return{bodyBytes:await o({chain:Y,memo:E,msgs:Z.map(u)}),signature:O4(A)}}}function U4({prefix:Y,rpcUrl:H}){return async function(L,Z,z,Q,J){let{encodeSecp256k1Pubkey:_,pubkeyToAddress:E}=(await import("@cosmjs/amino")).default,{makeMultisignedTxBytes:v}=(await import("@cosmjs/stargate")).default,{sequence:I,fee:x}=JSON.parse(L),V=await n6(z,Q),N=Z.map((D)=>[E(_(l.base64.decode(D.pubKey)),Y),l.base64.decode(D.signature)]),A=await y(H),{transactionHash:R}=await A.broadcastTx(v(V,I,x,J,new Map(N)));return R}}async function n6(Y,H,X=!0){let{createMultisigThresholdPubkey:L,encodeSecp256k1Pubkey:Z}=(await import("@cosmjs/amino")).default;return L(Y.map((z)=>Z(l.base64.decode(z))),H,X)}function v4(Y){return l.base64.decode(Y)}async function A4({privateKey:Y,message:H}){let{Secp256k1:X}=(await import("@cosmjs/crypto")).default,L=await X.createSignature(l.base64.decode(H),Y);return l.base64.encode(Buffer.concat([L.r(32),L.s(32)]))}async function x6({chain:Y,...H}){let X=O.SKConfig.get("nodeUrls")[Y],L=await O.getRPCUrl(Y),{isStagenet:Z}=O.SKConfig.get("envs"),z=Y===O.Chain.THORChain,Q=`${Z?"s":""}${O.CosmosChainPrefixes[Y]}`,J="index"in H?H.index||0:0,_="derivationPath"in H&&H.derivationPath?H.derivationPath:O.updateDerivationPath(O.NetworkDerivationPath[Y],{index:J}),E=await r({chain:Y,...H}),v=await a.match(H).with({phrase:a.P.string},({phrase:N})=>E.getSignerFromPhrase({derivationPath:_,phrase:N})).with({signer:a.P.any},({signer:N})=>N).otherwise(()=>{return}),I=f(Y);async function x(){let N,A=`${X}/${z?"thorchain":"mayachain"}/constants`;try{let{int_64_values:{NativeTransactionFee:R}}=await O.RequestClient.get(A);if(!R||Number.isNaN(R)||R<0)throw new O.SwapKitError("toolbox_cosmos_invalid_fee",{nativeFee:R.toString()});N=new O.SwapKitNumber(R)}catch{N=new O.SwapKitNumber({decimal:O.getChainConfig(Y).baseDecimal,value:z?0.02:1})}return{[O.FeeOption.Average]:N,[O.FeeOption.Fast]:N,[O.FeeOption.Fastest]:N}}async function V({assetValue:N,memo:A="",recipient:R}){let{TxRaw:D}=await import("cosmjs-types/cosmos/tx/v1beta1/tx"),S=(await v?.getAccounts())?.[0]?.address;if(!(S&&v))throw new O.SwapKitError("toolbox_cosmos_no_signer");let z6="signAmino"in v,Z6=await b(),H6=await w(Y),p=await g(L,v,{aminoTypes:H6,registry:Z6}),Q6=e({assetValue:N,memo:A,recipient:R,sender:S});if(z6){let o6=await $(Q6,Y),{signatures:t6,authInfoBytes:r6}=await p.sign(S,[o6],I,A),a6=D.encode({authInfoBytes:r6,bodyBytes:await o({chain:Y,memo:A,msgs:[Q6].map(u)}),signatures:t6}).finish();return(await p.broadcastTx(a6)).transactionHash}let g6=u(Q6),i6=await $(g6,Y);return(await p.signAndBroadcast(S,[i6],I,A)).transactionHash}return{...E,broadcastMultisigTx:U4({prefix:Q,rpcUrl:L}),buildAminoMsg:e,buildEncodedTxBody:o,convertToSignable:$,createDefaultAminoTypes:()=>w(Y),createDefaultRegistry:b,createMultisig:n6,createTransaction:_6(L),deposit:V,getFees:x,importSignature:v4,parseAminoMessageForDirectSigning:u,pubkeyToAddress:async(N)=>{let{pubkeyToAddress:A}=(await import("@cosmjs/amino")).default;return A(N,Q)},secp256k1HdWalletFromMnemonic:N4({derivationPath:O.derivationPathToString(_),prefix:Q}),signMultisigTx:x4(Y),signWithPrivateKey:A4,transfer:V}}var l,O,a;var U6=k(()=>{I6();i();L6();l=require("@scure/base"),O=require("@swapkit/helpers"),a=require("ts-pattern")});var j,K4=(Y,H)=>{switch(Y){case j.Chain.Cosmos:case j.Chain.Kujira:case j.Chain.Noble:return r({chain:Y,...H});case j.Chain.Maya:case j.Chain.THORChain:return x6({chain:Y,...H});default:throw new j.SwapKitError("toolbox_cosmos_not_supported",{chain:Y})}};var m6=k(()=>{L6();U6();j=require("@swapkit/helpers");L6();U6()});var R4={};V6(R4,{verifySignature:()=>p6,transferMsgAmino:()=>B6,toBase64:()=>Z4,parseAminoMessageForDirectSigning:()=>u,getSignerFromPrivateKey:()=>q4,getSignerFromPhrase:()=>E6,getMsgSendDenom:()=>P,getFeeRateFromThorswap:()=>T4,getFeeRateFromSwapKit:()=>c6,getDenomWithChain:()=>m,getDefaultChainFee:()=>f,getCreateTransaction:()=>_6,getCosmosToolbox:()=>K4,getAssetFromDenom:()=>T6,fromBase64:()=>H4,fetchFeeRateFromSwapKit:()=>O6,estimateTransactionFee:()=>B4,depositMsgAmino:()=>G6,createThorchainToolbox:()=>x6,createStargateClient:()=>y,createSigningStargateClient:()=>g,createOfflineStargateClient:()=>J6,createDefaultRegistry:()=>b,createDefaultAminoTypes:()=>w,createCosmosToolbox:()=>r,cosmosValidateAddress:()=>W4,cosmosCreateTransaction:()=>q6,convertToSignable:()=>$,buildTransferTx:()=>P6,buildEncodedTxBody:()=>o,buildDepositTx:()=>w6,buildAminoMsg:()=>e,bech32ToBase64:()=>d,base64ToBech32:()=>n,YUM_KUJIRA_FACTORY_DENOM:()=>k6,USK_KUJIRA_FACTORY_DENOM:()=>Y6,THORCHAIN_GAS_VALUE:()=>Y4,MAYA_GAS_VALUE:()=>J4,DEFAULT_NOBLE_FEE_MAINNET:()=>f6,DEFAULT_KUJI_FEE_MAINNET:()=>F6,DEFAULT_COSMOS_FEE_MAINNET:()=>M6});module.exports=z4(R4);var k4=k(()=>{I6();m6();i()});k4();
|
|
1
|
+
var sf=Object.create;var{getPrototypeOf:ef,defineProperty:j,getOwnPropertyNames:Sf,getOwnPropertyDescriptor:f0}=Object,Of=Object.prototype.hasOwnProperty;var K=(L,B,H)=>{H=L!=null?sf(ef(L)):{};let f=B||!L||!L.__esModule?j(H,"default",{value:L,enumerable:!0}):H;for(let x of Sf(L))if(!Of.call(f,x))j(f,x,{get:()=>L[x],enumerable:!0});return f},Kf=new WeakMap,T0=(L)=>{var B=Kf.get(L),H;if(B)return B;if(B=j({},"__esModule",{value:!0}),L&&typeof L==="object"||typeof L==="function")Sf(L).map((f)=>!Of.call(B,f)&&j(B,f,{get:()=>L[f],enumerable:!(H=f0(L,f))||H.enumerable}));return Kf.set(L,B),B};var Ef=(L,B)=>{for(var H in B)j(L,H,{get:B[H],enumerable:!0,configurable:!0,set:(f)=>B[H]=()=>f})};var A=(L,B)=>()=>(L&&(B=L(L=0)),B);function b(L){return P.base64.encode(Uint8Array.from(P.bech32.fromWords(P.bech32.decode(L).words)))}function d(L,B="thor"){return P.bech32.encode(B,P.bech32.toWords(P.base64.decode(L)))}function x0(L){return s.fromByteArray(L)}function B0(L){if(!L.match(/^[a-zA-Z0-9+/]*={0,2}$/))throw new Ff.SwapKitError("toolbox_cosmos_invalid_params",{error:"Invalid base64 string format"});return s.toByteArray(L)}var P,Ff,s;var Hf=A(()=>{P=require("@scure/base"),Ff=require("@swapkit/helpers"),s=require("base64-js")});function V(L){switch(L){case G.Chain.Maya:return{amount:[],gas:"10000000000"};case G.Chain.THORChain:return{amount:[],gas:"500000000"};case G.Chain.Kujira:return Uf;case G.Chain.Noble:return Rf;default:return kf}}async function D(L){let B=await import("@cosmjs/stargate"),H=B.StargateClient??B.default?.StargateClient,f=typeof window<"u"?{}:{referer:"https://sdk.swapkit.dev",referrer:"https://sdk.swapkit.dev"};return H.connect({headers:f,url:L})}async function o(L,B,H={}){let f=await import("@cosmjs/stargate"),x=f.SigningStargateClient??f.default?.SigningStargateClient,T=f.GasPrice??f.default?.GasPrice,v=typeof H==="string"?H:"0.0003uatom",y=typeof H==="string"?{}:H;return x.connectWithSigner(L,B,{gasPrice:T.fromString(v),...y})}async function yf(L,B){let H=await import("@cosmjs/stargate");return(H.SigningStargateClient??H.default?.SigningStargateClient).offline(L,B)}async function Wf({sender:L,recipient:B,assetValue:H,memo:f="",feeRate:x,sequence:T,accountNumber:v}){let{chain:y,chainId:Q}=H,I=await G.getRPCUrl(y),X=await(await D(I)).getAccount(L);if(!X)throw new G.SwapKitError("toolbox_cosmos_account_not_found",{sender:L});let N=G.AssetValue.from({chain:y}),E=M(N.symbol),J=V(y),q=E&&x?{amount:[{amount:x.toString(),denom:E}],gas:J.gas}:J,F={amount:[{amount:H.getBaseValue("string"),denom:M(H.symbol)}],fromAddress:L,toAddress:B};return{accountNumber:v??X.accountNumber,chainId:Q,fee:q,memo:f,msgs:[{typeUrl:v0(y),value:F}],sequence:T??X.sequence}}var G,Lf="FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK",Af="FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM",kf,Uf,Rf,M=(L,B=!1)=>{if(B)return L.toLowerCase();switch(L){case"uUSK":case"USK":return Lf;case"uYUM":case"YUM":return Af;case"uKUJI":case"KUJI":return"ukuji";case"ATOM":case"uATOM":return"uatom";case"uUSDC":case"USDC":return"uusdc";default:return L}},i=({symbol:L,chain:B})=>{if(B===G.Chain.Maya)return(L.toUpperCase()!=="CACAO"?L:`${G.Chain.Maya}.${L}`).toUpperCase();if(B===G.Chain.THORChain)return(["RUNE","TCY","RUJI"].includes(L.toUpperCase())?`${G.Chain.THORChain}.${L}`:L).toUpperCase();return M(L,!1)},v0=(L)=>{switch(L){case G.Chain.Maya:case G.Chain.THORChain:return"/types.MsgSend";case G.Chain.Cosmos:case G.Chain.Kujira:case G.Chain.Noble:return"/cosmos.bank.v1beta1.MsgSend";default:throw new G.SwapKitError("toolbox_cosmos_not_supported",{chain:L})}},H0,zf=(L,B)=>{let H=H0[L.toLowerCase()];if(!H)return G.AssetValue.from({asset:L,fromBaseDecimal:8,value:B});let{chain:f,asset:x,decimals:T}=H,v=f?{chain:f}:{asset:x};return G.AssetValue.from({...v,fromBaseDecimal:T,value:B})};var t=A(()=>{G=require("@swapkit/helpers"),kf={amount:[{amount:"500",denom:"uatom"}],gas:"200000"},Uf={amount:[{amount:"1000",denom:"ukuji"}],gas:"200000"},Rf={amount:[{amount:"1000",denom:"uusdc"}],gas:"200000"};H0={atom:{chain:G.Chain.Cosmos,decimals:G.getChainConfig(G.Chain.Cosmos).baseDecimal},cacao:{chain:G.Chain.Maya,decimals:10},kuji:{chain:G.Chain.Kujira,decimals:G.getChainConfig(G.Chain.Kujira).baseDecimal},maya:{asset:`${G.Chain.Maya}.${G.Chain.Maya}`,decimals:4},rune:{chain:G.Chain.THORChain,decimals:G.getChainConfig(G.Chain.THORChain).baseDecimal},tcy:{asset:"THOR.TCY",decimals:G.getChainConfig(G.Chain.THORChain).baseDecimal},uatom:{chain:G.Chain.Cosmos,decimals:G.getChainConfig(G.Chain.Cosmos).baseDecimal},ukuji:{chain:G.Chain.Kujira,decimals:G.getChainConfig(G.Chain.Kujira).baseDecimal},usdc:{chain:G.Chain.Noble,decimals:G.getChainConfig(G.Chain.Noble).baseDecimal},uusdc:{chain:G.Chain.Noble,decimals:G.getChainConfig(G.Chain.Noble).baseDecimal},"x/kuji":{asset:"THOR.KUJI",decimals:G.getChainConfig(G.Chain.THORChain).baseDecimal},[Lf.toLowerCase()]:{asset:`${G.Chain.Kujira}.USK`,decimals:G.getChainConfig(G.Chain.Kujira).baseDecimal}}});var Vf={};Ef(Vf,{$root:()=>W});var O,_,k,z,W;var Df=A(()=>{O=K(require("protobufjs/minimal.js")),_=O.default.Reader,k=O.default.Writer,z=O.default.util,W=O.default.roots.default||(O.default.roots.default={});W.common=(()=>{let L={};return L.Asset=(()=>{function B(H){if(H){for(let f=Object.keys(H),x=0;x<f.length;++x)if(H[f[x]]!=null)this[f[x]]=H[f[x]]}}return B.prototype.chain="",B.prototype.symbol="",B.prototype.ticker="",B.prototype.synth=!1,B.create=function(f){return new B(f)},B.encode=function(f,x){if(!x)x=k.create();if(f.chain!=null&&Object.hasOwnProperty.call(f,"chain"))x.uint32(10).string(f.chain);if(f.symbol!=null&&Object.hasOwnProperty.call(f,"symbol"))x.uint32(18).string(f.symbol);if(f.ticker!=null&&Object.hasOwnProperty.call(f,"ticker"))x.uint32(26).string(f.ticker);if(f.synth!=null&&Object.hasOwnProperty.call(f,"synth"))x.uint32(32).bool(f.synth);return x},B.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},B.decode=function(f,x){if(!(f instanceof _))f=_.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.Asset;while(f.pos<T){let y=f.uint32();switch(y>>>3){case 1:v.chain=f.string();break;case 2:v.symbol=f.string();break;case 3:v.ticker=f.string();break;case 4:v.synth=f.bool();break;default:f.skipType(y&7);break}}return v},B.decodeDelimited=function(f){if(!(f instanceof _))f=new _(f);return this.decode(f,f.uint32())},B.verify=function(f){if(typeof f!=="object"||f===null)return"object expected";if(f.chain!=null&&f.hasOwnProperty("chain")){if(!z.isString(f.chain))return"chain: string expected"}if(f.symbol!=null&&f.hasOwnProperty("symbol")){if(!z.isString(f.symbol))return"symbol: string expected"}if(f.ticker!=null&&f.hasOwnProperty("ticker")){if(!z.isString(f.ticker))return"ticker: string expected"}if(f.synth!=null&&f.hasOwnProperty("synth")){if(typeof f.synth!=="boolean")return"synth: boolean expected"}return null},B.fromObject=function(f){if(f instanceof W.common.Asset)return f;let x=new W.common.Asset;if(f.chain!=null)x.chain=String(f.chain);if(f.symbol!=null)x.symbol=String(f.symbol);if(f.ticker!=null)x.ticker=String(f.ticker);if(f.synth!=null)x.synth=Boolean(f.synth);return x},B.toObject=function(f,x){if(!x)x={};let T={};if(x.defaults)T.chain="",T.symbol="",T.ticker="",T.synth=!1;if(f.chain!=null&&f.hasOwnProperty("chain"))T.chain=f.chain;if(f.symbol!=null&&f.hasOwnProperty("symbol"))T.symbol=f.symbol;if(f.ticker!=null&&f.hasOwnProperty("ticker"))T.ticker=f.ticker;if(f.synth!=null&&f.hasOwnProperty("synth"))T.synth=f.synth;return T},B.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},B})(),L.Coin=(()=>{function B(H){if(H){for(let f=Object.keys(H),x=0;x<f.length;++x)if(H[f[x]]!=null)this[f[x]]=H[f[x]]}}return B.prototype.asset=null,B.prototype.amount="",B.prototype.decimals=z.Long?z.Long.fromBits(0,0,!1):0,B.create=function(f){return new B(f)},B.encode=function(f,x){if(!x)x=k.create();if(f.asset!=null&&Object.hasOwnProperty.call(f,"asset"))W.common.Asset.encode(f.asset,x.uint32(10).fork()).ldelim();if(f.amount!=null&&Object.hasOwnProperty.call(f,"amount"))x.uint32(18).string(f.amount);if(f.decimals!=null&&Object.hasOwnProperty.call(f,"decimals"))x.uint32(24).int64(f.decimals);return x},B.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},B.decode=function(f,x){if(!(f instanceof _))f=_.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.Coin;while(f.pos<T){let y=f.uint32();switch(y>>>3){case 1:v.asset=W.common.Asset.decode(f,f.uint32());break;case 2:v.amount=f.string();break;case 3:v.decimals=f.int64();break;default:f.skipType(y&7);break}}return v},B.decodeDelimited=function(f){if(!(f instanceof _))f=new _(f);return this.decode(f,f.uint32())},B.verify=function(f){if(typeof f!=="object"||f===null)return"object expected";if(f.asset!=null&&f.hasOwnProperty("asset")){let x=W.common.Asset.verify(f.asset);if(x)return"asset."+x}if(f.amount!=null&&f.hasOwnProperty("amount")){if(!z.isString(f.amount))return"amount: string expected"}if(f.decimals!=null&&f.hasOwnProperty("decimals")){if(!z.isInteger(f.decimals)&&!(f.decimals&&z.isInteger(f.decimals.low)&&z.isInteger(f.decimals.high)))return"decimals: integer|Long expected"}return null},B.fromObject=function(f){if(f instanceof W.common.Coin)return f;let x=new W.common.Coin;if(f.asset!=null){if(typeof f.asset!=="object")throw TypeError(".common.Coin.asset: object expected");x.asset=W.common.Asset.fromObject(f.asset)}if(f.amount!=null)x.amount=String(f.amount);if(f.decimals!=null){if(z.Long)(x.decimals=z.Long.fromValue(f.decimals)).unsigned=!1;else if(typeof f.decimals==="string")x.decimals=Number.parseInt(f.decimals,10);else if(typeof f.decimals==="number")x.decimals=f.decimals;else if(typeof f.decimals==="object")x.decimals=new z.LongBits(f.decimals.low>>>0,f.decimals.high>>>0).toNumber()}return x},B.toObject=function(f,x){if(!x)x={};let T={};if(x.defaults)if(T.asset=null,T.amount="",z.Long){let v=new z.Long(0,0,!1);T.decimals=x.longs===String?v.toString():x.longs===Number?v.toNumber():v}else T.decimals=x.longs===String?"0":0;if(f.asset!=null&&f.hasOwnProperty("asset"))T.asset=W.common.Asset.toObject(f.asset,x);if(f.amount!=null&&f.hasOwnProperty("amount"))T.amount=f.amount;if(f.decimals!=null&&f.hasOwnProperty("decimals"))if(typeof f.decimals==="number")T.decimals=x.longs===String?String(f.decimals):f.decimals;else T.decimals=x.longs===String?z.Long.prototype.toString.call(f.decimals):x.longs===Number?new z.LongBits(f.decimals.low>>>0,f.decimals.high>>>0).toNumber():f.decimals;return T},B.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},B})(),L.PubKeySet=(()=>{function B(H){if(H){for(let f=Object.keys(H),x=0;x<f.length;++x)if(H[f[x]]!=null)this[f[x]]=H[f[x]]}}return B.prototype.secp256k1="",B.prototype.ed25519="",B.create=function(f){return new B(f)},B.encode=function(f,x){if(!x)x=k.create();if(f.secp256k1!=null&&Object.hasOwnProperty.call(f,"secp256k1"))x.uint32(10).string(f.secp256k1);if(f.ed25519!=null&&Object.hasOwnProperty.call(f,"ed25519"))x.uint32(18).string(f.ed25519);return x},B.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},B.decode=function(f,x){if(!(f instanceof _))f=_.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.PubKeySet;while(f.pos<T){let y=f.uint32();switch(y>>>3){case 1:v.secp256k1=f.string();break;case 2:v.ed25519=f.string();break;default:f.skipType(y&7);break}}return v},B.decodeDelimited=function(f){if(!(f instanceof _))f=new _(f);return this.decode(f,f.uint32())},B.verify=function(f){if(typeof f!=="object"||f===null)return"object expected";if(f.secp256k1!=null&&f.hasOwnProperty("secp256k1")){if(!z.isString(f.secp256k1))return"secp256k1: string expected"}if(f.ed25519!=null&&f.hasOwnProperty("ed25519")){if(!z.isString(f.ed25519))return"ed25519: string expected"}return null},B.fromObject=function(f){if(f instanceof W.common.PubKeySet)return f;let x=new W.common.PubKeySet;if(f.secp256k1!=null)x.secp256k1=String(f.secp256k1);if(f.ed25519!=null)x.ed25519=String(f.ed25519);return x},B.toObject=function(f,x){if(!x)x={};let T={};if(x.defaults)T.secp256k1="",T.ed25519="";if(f.secp256k1!=null&&f.hasOwnProperty("secp256k1"))T.secp256k1=f.secp256k1;if(f.ed25519!=null&&f.hasOwnProperty("ed25519"))T.ed25519=f.ed25519;return T},B.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},B})(),L.Tx=(()=>{function B(H){if(this.coins=[],this.gas=[],H){for(let f=Object.keys(H),x=0;x<f.length;++x)if(H[f[x]]!=null)this[f[x]]=H[f[x]]}}return B.prototype.id="",B.prototype.chain="",B.prototype.fromAddress="",B.prototype.toAddress="",B.prototype.coins=z.emptyArray,B.prototype.gas=z.emptyArray,B.prototype.memo="",B.create=function(f){return new B(f)},B.encode=function(f,x){if(!x)x=k.create();if(f.id!=null&&Object.hasOwnProperty.call(f,"id"))x.uint32(10).string(f.id);if(f.chain!=null&&Object.hasOwnProperty.call(f,"chain"))x.uint32(18).string(f.chain);if(f.fromAddress!=null&&Object.hasOwnProperty.call(f,"fromAddress"))x.uint32(26).string(f.fromAddress);if(f.toAddress!=null&&Object.hasOwnProperty.call(f,"toAddress"))x.uint32(34).string(f.toAddress);if(f.coins?.length)for(let T=0;T<f.coins.length;++T)W.common.Coin.encode(f.coins[T],x.uint32(42).fork()).ldelim();if(f.gas?.length)for(let T=0;T<f.gas.length;++T)W.common.Coin.encode(f.gas[T],x.uint32(50).fork()).ldelim();if(f.memo!=null&&Object.hasOwnProperty.call(f,"memo"))x.uint32(58).string(f.memo);return x},B.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},B.decode=function(f,x){if(!(f instanceof _))f=_.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.Tx;while(f.pos<T){let y=f.uint32();switch(y>>>3){case 1:v.id=f.string();break;case 2:v.chain=f.string();break;case 3:v.fromAddress=f.string();break;case 4:v.toAddress=f.string();break;case 5:if(!v.coins?.length)v.coins=[];v.coins.push(W.common.Coin.decode(f,f.uint32()));break;case 6:if(!v.gas?.length)v.gas=[];v.gas.push(W.common.Coin.decode(f,f.uint32()));break;case 7:v.memo=f.string();break;default:f.skipType(y&7);break}}return v},B.decodeDelimited=function(f){if(!(f instanceof _))f=new _(f);return this.decode(f,f.uint32())},B.verify=function(f){if(typeof f!=="object"||f===null)return"object expected";if(f.id!=null&&f.hasOwnProperty("id")){if(!z.isString(f.id))return"id: string expected"}if(f.chain!=null&&f.hasOwnProperty("chain")){if(!z.isString(f.chain))return"chain: string expected"}if(f.fromAddress!=null&&f.hasOwnProperty("fromAddress")){if(!z.isString(f.fromAddress))return"fromAddress: string expected"}if(f.toAddress!=null&&f.hasOwnProperty("toAddress")){if(!z.isString(f.toAddress))return"toAddress: string expected"}if(f.coins!=null&&f.hasOwnProperty("coins")){if(!Array.isArray(f.coins))return"coins: array expected";for(let x=0;x<f.coins.length;++x){let T=W.common.Coin.verify(f.coins[x]);if(T)return"coins."+T}}if(f.gas!=null&&f.hasOwnProperty("gas")){if(!Array.isArray(f.gas))return"gas: array expected";for(let x=0;x<f.gas.length;++x){let T=W.common.Coin.verify(f.gas[x]);if(T)return"gas."+T}}if(f.memo!=null&&f.hasOwnProperty("memo")){if(!z.isString(f.memo))return"memo: string expected"}return null},B.fromObject=function(f){if(f instanceof W.common.Tx)return f;let x=new W.common.Tx;if(f.id!=null)x.id=String(f.id);if(f.chain!=null)x.chain=String(f.chain);if(f.fromAddress!=null)x.fromAddress=String(f.fromAddress);if(f.toAddress!=null)x.toAddress=String(f.toAddress);if(f.coins){if(!Array.isArray(f.coins))throw TypeError(".common.Tx.coins: array expected");x.coins=[];for(let T=0;T<f.coins.length;++T){if(typeof f.coins[T]!=="object")throw TypeError(".common.Tx.coins: object expected");x.coins[T]=W.common.Coin.fromObject(f.coins[T])}}if(f.gas){if(!Array.isArray(f.gas))throw TypeError(".common.Tx.gas: array expected");x.gas=[];for(let T=0;T<f.gas.length;++T){if(typeof f.gas[T]!=="object")throw TypeError(".common.Tx.gas: object expected");x.gas[T]=W.common.Coin.fromObject(f.gas[T])}}if(f.memo!=null)x.memo=String(f.memo);return x},B.toObject=function(f,x){if(!x)x={};let T={};if(x.arrays||x.defaults)T.coins=[],T.gas=[];if(x.defaults)T.id="",T.chain="",T.fromAddress="",T.toAddress="",T.memo="";if(f.id!=null&&f.hasOwnProperty("id"))T.id=f.id;if(f.chain!=null&&f.hasOwnProperty("chain"))T.chain=f.chain;if(f.fromAddress!=null&&f.hasOwnProperty("fromAddress"))T.fromAddress=f.fromAddress;if(f.toAddress!=null&&f.hasOwnProperty("toAddress"))T.toAddress=f.toAddress;if(f.coins?.length){T.coins=[];for(let v=0;v<f.coins.length;++v)T.coins[v]=W.common.Coin.toObject(f.coins[v],x)}if(f.gas?.length){T.gas=[];for(let v=0;v<f.gas.length;++v)T.gas[v]=W.common.Coin.toObject(f.gas[v],x)}if(f.memo!=null&&f.hasOwnProperty("memo"))T.memo=f.memo;return T},B.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},B})(),L.Fee=(()=>{function B(H){if(this.coins=[],H){for(let f=Object.keys(H),x=0;x<f.length;++x)if(H[f[x]]!=null)this[f[x]]=H[f[x]]}}return B.prototype.coins=z.emptyArray,B.prototype.poolDeduct="",B.create=function(f){return new B(f)},B.encode=function(f,x){if(!x)x=k.create();if(f.coins?.length)for(let T=0;T<f.coins.length;++T)W.common.Coin.encode(f.coins[T],x.uint32(10).fork()).ldelim();if(f.poolDeduct!=null&&Object.hasOwnProperty.call(f,"poolDeduct"))x.uint32(18).string(f.poolDeduct);return x},B.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},B.decode=function(f,x){if(!(f instanceof _))f=_.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.Fee;while(f.pos<T){let y=f.uint32();switch(y>>>3){case 1:if(!v.coins?.length)v.coins=[];v.coins.push(W.common.Coin.decode(f,f.uint32()));break;case 2:v.poolDeduct=f.string();break;default:f.skipType(y&7);break}}return v},B.decodeDelimited=function(f){if(!(f instanceof _))f=new _(f);return this.decode(f,f.uint32())},B.verify=function(f){if(typeof f!=="object"||f===null)return"object expected";if(f.coins!=null&&f.hasOwnProperty("coins")){if(!Array.isArray(f.coins))return"coins: array expected";for(let x=0;x<f.coins.length;++x){let T=W.common.Coin.verify(f.coins[x]);if(T)return"coins."+T}}if(f.poolDeduct!=null&&f.hasOwnProperty("poolDeduct")){if(!z.isString(f.poolDeduct))return"poolDeduct: string expected"}return null},B.fromObject=function(f){if(f instanceof W.common.Fee)return f;let x=new W.common.Fee;if(f.coins){if(!Array.isArray(f.coins))throw TypeError(".common.Fee.coins: array expected");x.coins=[];for(let T=0;T<f.coins.length;++T){if(typeof f.coins[T]!=="object")throw TypeError(".common.Fee.coins: object expected");x.coins[T]=W.common.Coin.fromObject(f.coins[T])}}if(f.poolDeduct!=null)x.poolDeduct=String(f.poolDeduct);return x},B.toObject=function(f,x){if(!x)x={};let T={};if(x.arrays||x.defaults)T.coins=[];if(x.defaults)T.poolDeduct="";if(f.coins?.length){T.coins=[];for(let v=0;v<f.coins.length;++v)T.coins[v]=W.common.Coin.toObject(f.coins[v],x)}if(f.poolDeduct!=null&&f.hasOwnProperty("poolDeduct"))T.poolDeduct=f.poolDeduct;return T},B.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},B})(),L.ProtoUint=(()=>{function B(H){if(H){for(let f=Object.keys(H),x=0;x<f.length;++x)if(H[f[x]]!=null)this[f[x]]=H[f[x]]}}return B.prototype.value="",B.create=function(f){return new B(f)},B.encode=function(f,x){if(!x)x=k.create();if(f.value!=null&&Object.hasOwnProperty.call(f,"value"))x.uint32(10).string(f.value);return x},B.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},B.decode=function(f,x){if(!(f instanceof _))f=_.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.ProtoUint;while(f.pos<T){let y=f.uint32();switch(y>>>3){case 1:v.value=f.string();break;default:f.skipType(y&7);break}}return v},B.decodeDelimited=function(f){if(!(f instanceof _))f=new _(f);return this.decode(f,f.uint32())},B.verify=function(f){if(typeof f!=="object"||f===null)return"object expected";if(f.value!=null&&f.hasOwnProperty("value")){if(!z.isString(f.value))return"value: string expected"}return null},B.fromObject=function(f){if(f instanceof W.common.ProtoUint)return f;let x=new W.common.ProtoUint;if(f.value!=null)x.value=String(f.value);return x},B.toObject=function(f,x){if(!x)x={};let T={};if(x.defaults)T.value="";if(f.value!=null&&f.hasOwnProperty("value"))T.value=f.value;return T},B.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},B})(),L})();W.types=(()=>{let L={};return L.MsgDeposit=(()=>{function B(H){if(this.coins=[],H){for(let f=Object.keys(H),x=0;x<f.length;++x)if(H[f[x]]!=null)this[f[x]]=H[f[x]]}}return B.prototype.coins=z.emptyArray,B.prototype.memo="",B.prototype.signer=z.newBuffer([]),B.create=function(f){return new B(f)},B.encode=function(f,x){if(!x)x=k.create();if(f.coins?.length)for(let T=0;T<f.coins.length;++T)W.common.Coin.encode(f.coins[T],x.uint32(10).fork()).ldelim();if(f.memo!=null&&Object.hasOwnProperty.call(f,"memo"))x.uint32(18).string(f.memo);if(f.signer!=null&&Object.hasOwnProperty.call(f,"signer"))x.uint32(26).bytes(f.signer);return x},B.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},B.decode=function(f,x){if(!(f instanceof _))f=_.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.types.MsgDeposit;while(f.pos<T){let y=f.uint32();switch(y>>>3){case 1:if(!v.coins?.length)v.coins=[];v.coins.push(W.common.Coin.decode(f,f.uint32()));break;case 2:v.memo=f.string();break;case 3:v.signer=f.bytes();break;default:f.skipType(y&7);break}}return v},B.decodeDelimited=function(f){if(!(f instanceof _))f=new _(f);return this.decode(f,f.uint32())},B.verify=function(f){if(typeof f!=="object"||f===null)return"object expected";if(f.coins!=null&&f.hasOwnProperty("coins")){if(!Array.isArray(f.coins))return"coins: array expected";for(let x=0;x<f.coins.length;++x){let T=W.common.Coin.verify(f.coins[x]);if(T)return"coins."+T}}if(f.memo!=null&&f.hasOwnProperty("memo")){if(!z.isString(f.memo))return"memo: string expected"}if(f.signer!=null&&f.hasOwnProperty("signer")){if(!(f.signer&&typeof f.signer.length==="number"||z.isString(f.signer)))return"signer: buffer expected"}return null},B.fromObject=function(f){if(f instanceof W.types.MsgDeposit)return f;let x=new W.types.MsgDeposit;if(f.coins){if(!Array.isArray(f.coins))throw TypeError(".types.MsgDeposit.coins: array expected");x.coins=[];for(let T=0;T<f.coins.length;++T){if(typeof f.coins[T]!=="object")throw TypeError(".types.MsgDeposit.coins: object expected");x.coins[T]=W.common.Coin.fromObject(f.coins[T])}}if(f.memo!=null)x.memo=String(f.memo);if(f.signer!=null){if(typeof f.signer==="string")z.base64.decode(f.signer,x.signer=z.newBuffer(z.base64.length(f.signer)),0);else if(f.signer.length)x.signer=f.signer}return x},B.toObject=function(f,x){if(!x)x={};let T={};if(x.arrays||x.defaults)T.coins=[];if(x.defaults){if(T.memo="",x.bytes===String)T.signer="";else if(T.signer=[],x.bytes!==Array)T.signer=z.newBuffer(T.signer)}if(f.coins?.length){T.coins=[];for(let v=0;v<f.coins.length;++v)T.coins[v]=W.common.Coin.toObject(f.coins[v],x)}if(f.memo!=null&&f.hasOwnProperty("memo"))T.memo=f.memo;if(f.signer!=null&&f.hasOwnProperty("signer"))T.signer=x.bytes===String?z.base64.encode(f.signer,0,f.signer.length):x.bytes===Array?Array.prototype.slice.call(f.signer):f.signer;return T},B.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},B})(),L.MsgSend=(()=>{function B(H){if(this.amount=[],H){for(let f=Object.keys(H),x=0;x<f.length;++x)if(H[f[x]]!=null)this[f[x]]=H[f[x]]}}return B.prototype.fromAddress=z.newBuffer([]),B.prototype.toAddress=z.newBuffer([]),B.prototype.amount=z.emptyArray,B.create=function(f){return new B(f)},B.encode=function(f,x){if(!x)x=k.create();if(f.fromAddress!=null&&Object.hasOwnProperty.call(f,"fromAddress"))x.uint32(10).bytes(f.fromAddress);if(f.toAddress!=null&&Object.hasOwnProperty.call(f,"toAddress"))x.uint32(18).bytes(f.toAddress);if(f.amount?.length)for(let T=0;T<f.amount.length;++T)W.cosmos.base.v1beta1.Coin.encode(f.amount[T],x.uint32(26).fork()).ldelim();return x},B.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},B.decode=function(f,x){if(!(f instanceof _))f=_.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.types.MsgSend;while(f.pos<T){let y=f.uint32();switch(y>>>3){case 1:v.fromAddress=f.bytes();break;case 2:v.toAddress=f.bytes();break;case 3:if(!v.amount?.length)v.amount=[];v.amount.push(W.cosmos.base.v1beta1.Coin.decode(f,f.uint32()));break;default:f.skipType(y&7);break}}return v},B.decodeDelimited=function(f){if(!(f instanceof _))f=new _(f);return this.decode(f,f.uint32())},B.verify=function(f){if(typeof f!=="object"||f===null)return"object expected";if(f.fromAddress!=null&&f.hasOwnProperty("fromAddress")){if(!(f.fromAddress&&typeof f.fromAddress.length==="number"||z.isString(f.fromAddress)))return"fromAddress: buffer expected"}if(f.toAddress!=null&&f.hasOwnProperty("toAddress")){if(!(f.toAddress&&typeof f.toAddress.length==="number"||z.isString(f.toAddress)))return"toAddress: buffer expected"}if(f.amount!=null&&f.hasOwnProperty("amount")){if(!Array.isArray(f.amount))return"amount: array expected";for(let x=0;x<f.amount.length;++x){let T=W.cosmos.base.v1beta1.Coin.verify(f.amount[x]);if(T)return"amount."+T}}return null},B.fromObject=function(f){if(f instanceof W.types.MsgSend)return f;let x=new W.types.MsgSend;if(f.fromAddress!=null){if(typeof f.fromAddress==="string")z.base64.decode(f.fromAddress,x.fromAddress=z.newBuffer(z.base64.length(f.fromAddress)),0);else if(f.fromAddress.length)x.fromAddress=f.fromAddress}if(f.toAddress!=null){if(typeof f.toAddress==="string")z.base64.decode(f.toAddress,x.toAddress=z.newBuffer(z.base64.length(f.toAddress)),0);else if(f.toAddress.length)x.toAddress=f.toAddress}if(f.amount){if(!Array.isArray(f.amount))throw TypeError(".types.MsgSend.amount: array expected");x.amount=[];for(let T=0;T<f.amount.length;++T){if(typeof f.amount[T]!=="object")throw TypeError(".types.MsgSend.amount: object expected");x.amount[T]=W.cosmos.base.v1beta1.Coin.fromObject(f.amount[T])}}return x},B.toObject=function(f,x){if(!x)x={};let T={};if(x.arrays||x.defaults)T.amount=[];if(x.defaults){if(x.bytes===String)T.fromAddress="";else if(T.fromAddress=[],x.bytes!==Array)T.fromAddress=z.newBuffer(T.fromAddress);if(x.bytes===String)T.toAddress="";else if(T.toAddress=[],x.bytes!==Array)T.toAddress=z.newBuffer(T.toAddress)}if(f.fromAddress!=null&&f.hasOwnProperty("fromAddress"))T.fromAddress=x.bytes===String?z.base64.encode(f.fromAddress,0,f.fromAddress.length):x.bytes===Array?Array.prototype.slice.call(f.fromAddress):f.fromAddress;if(f.toAddress!=null&&f.hasOwnProperty("toAddress"))T.toAddress=x.bytes===String?z.base64.encode(f.toAddress,0,f.toAddress.length):x.bytes===Array?Array.prototype.slice.call(f.toAddress):f.toAddress;if(f.amount?.length){T.amount=[];for(let v=0;v<f.amount.length;++v)T.amount[v]=W.cosmos.base.v1beta1.Coin.toObject(f.amount[v],x)}return T},B.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},B})(),L})();W.cosmos=(()=>{let L={};return L.base=(()=>{let B={};return B.v1beta1=(()=>{let H={};return H.Coin=(()=>{function f(x){if(x){for(let T=Object.keys(x),v=0;v<T.length;++v)if(x[T[v]]!=null)this[T[v]]=x[T[v]]}}return f.prototype.denom="",f.prototype.amount="",f.create=function(T){return new f(T)},f.encode=function(T,v){if(!v)v=k.create();if(T.denom!=null&&Object.hasOwnProperty.call(T,"denom"))v.uint32(10).string(T.denom);if(T.amount!=null&&Object.hasOwnProperty.call(T,"amount"))v.uint32(18).string(T.amount);return v},f.encodeDelimited=function(T,v){return this.encode(T,v).ldelim()},f.decode=function(T,v){if(!(T instanceof _))T=_.create(T);let y=v===void 0?T.len:T.pos+v,Q=new W.cosmos.base.v1beta1.Coin;while(T.pos<y){let I=T.uint32();switch(I>>>3){case 1:Q.denom=T.string();break;case 2:Q.amount=T.string();break;default:T.skipType(I&7);break}}return Q},f.decodeDelimited=function(T){if(!(T instanceof _))T=new _(T);return this.decode(T,T.uint32())},f.verify=function(T){if(typeof T!=="object"||T===null)return"object expected";if(T.denom!=null&&T.hasOwnProperty("denom")){if(!z.isString(T.denom))return"denom: string expected"}if(T.amount!=null&&T.hasOwnProperty("amount")){if(!z.isString(T.amount))return"amount: string expected"}return null},f.fromObject=function(T){if(T instanceof W.cosmos.base.v1beta1.Coin)return T;let v=new W.cosmos.base.v1beta1.Coin;if(T.denom!=null)v.denom=String(T.denom);if(T.amount!=null)v.amount=String(T.amount);return v},f.toObject=function(T,v){if(!v)v={};let y={};if(v.defaults)y.denom="",y.amount="";if(T.denom!=null&&T.hasOwnProperty("denom"))y.denom=T.denom;if(T.amount!=null&&T.hasOwnProperty("amount"))y.amount=T.amount;return y},f.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},f})(),H.DecCoin=(()=>{function f(x){if(x){for(let T=Object.keys(x),v=0;v<T.length;++v)if(x[T[v]]!=null)this[T[v]]=x[T[v]]}}return f.prototype.denom="",f.prototype.amount="",f.create=function(T){return new f(T)},f.encode=function(T,v){if(!v)v=k.create();if(T.denom!=null&&Object.hasOwnProperty.call(T,"denom"))v.uint32(10).string(T.denom);if(T.amount!=null&&Object.hasOwnProperty.call(T,"amount"))v.uint32(18).string(T.amount);return v},f.encodeDelimited=function(T,v){return this.encode(T,v).ldelim()},f.decode=function(T,v){if(!(T instanceof _))T=_.create(T);let y=v===void 0?T.len:T.pos+v,Q=new W.cosmos.base.v1beta1.DecCoin;while(T.pos<y){let I=T.uint32();switch(I>>>3){case 1:Q.denom=T.string();break;case 2:Q.amount=T.string();break;default:T.skipType(I&7);break}}return Q},f.decodeDelimited=function(T){if(!(T instanceof _))T=new _(T);return this.decode(T,T.uint32())},f.verify=function(T){if(typeof T!=="object"||T===null)return"object expected";if(T.denom!=null&&T.hasOwnProperty("denom")){if(!z.isString(T.denom))return"denom: string expected"}if(T.amount!=null&&T.hasOwnProperty("amount")){if(!z.isString(T.amount))return"amount: string expected"}return null},f.fromObject=function(T){if(T instanceof W.cosmos.base.v1beta1.DecCoin)return T;let v=new W.cosmos.base.v1beta1.DecCoin;if(T.denom!=null)v.denom=String(T.denom);if(T.amount!=null)v.amount=String(T.amount);return v},f.toObject=function(T,v){if(!v)v={};let y={};if(v.defaults)y.denom="",y.amount="";if(T.denom!=null&&T.hasOwnProperty("denom"))y.denom=T.denom;if(T.amount!=null&&T.hasOwnProperty("amount"))y.amount=T.amount;return y},f.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},f})(),H.IntProto=(()=>{function f(x){if(x){for(let T=Object.keys(x),v=0;v<T.length;++v)if(x[T[v]]!=null)this[T[v]]=x[T[v]]}}return f.prototype.int="",f.create=function(T){return new f(T)},f.encode=function(T,v){if(!v)v=k.create();if(T.int!=null&&Object.hasOwnProperty.call(T,"int"))v.uint32(10).string(T.int);return v},f.encodeDelimited=function(T,v){return this.encode(T,v).ldelim()},f.decode=function(T,v){if(!(T instanceof _))T=_.create(T);let y=v===void 0?T.len:T.pos+v,Q=new W.cosmos.base.v1beta1.IntProto;while(T.pos<y){let I=T.uint32();switch(I>>>3){case 1:Q.int=T.string();break;default:T.skipType(I&7);break}}return Q},f.decodeDelimited=function(T){if(!(T instanceof _))T=new _(T);return this.decode(T,T.uint32())},f.verify=function(T){if(typeof T!=="object"||T===null)return"object expected";if(T.int!=null&&T.hasOwnProperty("int")){if(!z.isString(T.int))return"int: string expected"}return null},f.fromObject=function(T){if(T instanceof W.cosmos.base.v1beta1.IntProto)return T;let v=new W.cosmos.base.v1beta1.IntProto;if(T.int!=null)v.int=String(T.int);return v},f.toObject=function(T,v){if(!v)v={};let y={};if(v.defaults)y.int="";if(T.int!=null&&T.hasOwnProperty("int"))y.int=T.int;return y},f.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},f})(),H.DecProto=(()=>{function f(x){if(x){for(let T=Object.keys(x),v=0;v<T.length;++v)if(x[T[v]]!=null)this[T[v]]=x[T[v]]}}return f.prototype.dec="",f.create=function(T){return new f(T)},f.encode=function(T,v){if(!v)v=k.create();if(T.dec!=null&&Object.hasOwnProperty.call(T,"dec"))v.uint32(10).string(T.dec);return v},f.encodeDelimited=function(T,v){return this.encode(T,v).ldelim()},f.decode=function(T,v){if(!(T instanceof _))T=_.create(T);let y=v===void 0?T.len:T.pos+v,Q=new W.cosmos.base.v1beta1.DecProto;while(T.pos<y){let I=T.uint32();switch(I>>>3){case 1:Q.dec=T.string();break;default:T.skipType(I&7);break}}return Q},f.decodeDelimited=function(T){if(!(T instanceof _))T=new _(T);return this.decode(T,T.uint32())},f.verify=function(T){if(typeof T!=="object"||T===null)return"object expected";if(T.dec!=null&&T.hasOwnProperty("dec")){if(!z.isString(T.dec))return"dec: string expected"}return null},f.fromObject=function(T){if(T instanceof W.cosmos.base.v1beta1.DecProto)return T;let v=new W.cosmos.base.v1beta1.DecProto;if(T.dec!=null)v.dec=String(T.dec);return v},f.toObject=function(T,v){if(!v)v={};let y={};if(v.defaults)y.dec="";if(T.dec!=null&&T.hasOwnProperty("dec"))y.dec=T.dec;return y},f.prototype.toJSON=function(){return this.constructor.toObject(this,O.default.util.toJSONOptions)},f})(),H})(),B})(),L})()});async function p(){let{$root:L}=await Promise.resolve().then(() => (Df(),Vf)),B=await import("@cosmjs/proto-signing"),H=B.Registry??B.default?.Registry,f=await import("@cosmjs/stargate"),x=f.defaultRegistryTypes??f.default?.defaultRegistryTypes;return new H([...x,["/types.MsgSend",L.types.MsgSend],["/types.MsgDeposit",L.types.MsgDeposit]])}async function u(L){let B=await import("@cosmjs/stargate"),H=B.AminoTypes??B.default?.AminoTypes,f=L===Cf.Chain.THORChain?"thorchain":"mayachain";return new H({"/types.MsgDeposit":{aminoType:`${f}/MsgDeposit`,fromAmino:({signer:x,...T})=>({...T,signer:b(x)}),toAmino:({signer:x,...T})=>({...T,signer:d(x)})},"/types.MsgSend":{aminoType:`${f}/MsgSend`,fromAmino:({from_address:x,to_address:T,...v})=>({...v,fromAddress:b(x),toAddress:b(T)}),toAmino:({fromAddress:x,toAddress:T,...v})=>({...v,from_address:d(x),to_address:d(T)})}})}var Cf;var Gf=A(()=>{Hf();Cf=require("@swapkit/helpers")});function Qf(L){return function(H){let{assetValue:f,recipient:x,memo:T,sender:v,asSignable:y,asAminoMessage:Q}=H;if(x)return Mf(L)({asAminoMessage:Q,asSignable:y,assetValue:f,memo:T,recipient:x,sender:v});return uf(L)({asAminoMessage:Q,asSignable:y,assetValue:f,memo:T,sender:v})}}function w(L){if(L.type==="thorchain/MsgSend"||L.type==="mayachain/MsgSend")return L;return{...L,value:{...L.value,coins:L.value.coins.map((B)=>{let H=U.AssetValue.from({asset:B.asset}),f=(H.isSynthetic?H.symbol.split("/")?.[1]:H.symbol)?.toUpperCase(),x=(H.isSynthetic?H.symbol.split("/")?.[0]:H.chain)?.toUpperCase();return{...B,asset:{chain:x,symbol:f,synth:H.isSynthetic,ticker:H.ticker}}})}}}async function m({chain:L,memo:B,msgs:H}){let f=await p(),x=await u(L),T={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:B,messages:H.map((v)=>x.fromAmino(v))}};return f.encode(T)}var U,L0,y0,Zf=({sender:L,recipient:B,assetValue:H})=>{return{type:`${H.chain===U.Chain.Maya?"mayachain":"thorchain"}/MsgSend`,value:{amount:[{amount:H.getBaseValue("string"),denom:M(H.symbol,!0)}],from_address:L,to_address:B}}},_f=({sender:L,assetValue:B,memo:H=""})=>{return{type:`${B.chain===U.Chain.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:B.getBaseValue("string"),asset:i(B)}],memo:H,signer:L}}},e=({sender:L,recipient:B,assetValue:H,memo:f})=>{return!B?_f({assetValue:H,memo:f,sender:L}):Zf({assetValue:H,recipient:B,sender:L})},h=async(L,B)=>{return(await u(B)).fromAmino(L)},Pf=async({rpcUrl:L,sender:B})=>{let f=await(await D(L)).getAccount(B);if(!f)throw new U.SwapKitError("toolbox_cosmos_account_not_found",{sender:B});return f},Mf=(L)=>async({sender:B,recipient:H,assetValue:f,memo:x="",asSignable:T=!0,asAminoMessage:v=!1,sequence:y,accountNumber:Q})=>{let I=await Pf({rpcUrl:L,sender:B}),S=f.chain,{chainId:X}=U.getChainConfig(S),N=Zf({assetValue:f,recipient:H,sender:B}),E=T?await h(v?N:w(N),S):N;return{accountNumber:Q||I.accountNumber,chainId:X,fee:V(S),memo:x,msgs:[E],sequence:y||I.sequence}},uf=(L)=>async({sender:B,assetValue:H,memo:f="",asSignable:x=!0,asAminoMessage:T=!1,sequence:v,accountNumber:y})=>{let Q=await Pf({rpcUrl:L,sender:B}),I=H.chain,{chainId:S}=U.getChainConfig(I),X=_f({assetValue:H,memo:f,sender:B}),N=x?await h(T?X:w(X),I):X;return{accountNumber:y||Q.accountNumber,chainId:S,fee:V(I),memo:f,msgs:[N],sequence:v||Q.sequence}};var hf=A(()=>{t();Gf();U=require("@swapkit/helpers"),L0=V(U.Chain.THORChain).gas,y0=V(U.Chain.Maya).gas});var wf=()=>{};var lf=A(()=>{wf()});var Xf=A(()=>{Hf();hf();Gf();lf()});async function Jf(L,B){try{let f=(await Yf.SwapKitApi.getGasRate()).find((x)=>x.chainId===L)?.value;return f?Number.parseFloat(f):B}catch{return B}}async function If({phrase:L,prefix:B,...H}){let f=await import("@cosmjs/proto-signing"),x=f.DirectSecp256k1HdWallet??f.default?.DirectSecp256k1HdWallet,T=await import("@cosmjs/crypto"),v=T.stringToPath??T.default?.stringToPath,y="derivationPath"in H?H.derivationPath:`${Z.DerivationPath[H.chain]}/${H.index}`;return x.fromMnemonic(L,{hdPaths:[v(y)],prefix:B})}async function W0({privateKey:L,prefix:B}){let H=await import("@cosmjs/proto-signing");return(H.DirectSecp256k1Wallet??H.default?.DirectSecp256k1Wallet).fromKey(L,B)}function cf(L){return async function({signature:H,message:f,address:x}){let T=await L(x);if(!T?.pubkey)throw new Z.SwapKitError("toolbox_cosmos_verify_signature_no_pubkey");let v=await import("@cosmjs/crypto"),y=v.Secp256k1Signature??v.default?.Secp256k1Signature,Q=v.Secp256k1??v.default?.Secp256k1,I=y.fromFixedLength(l.base64.decode(H));return Q.verifySignature(I,l.base64.decode(f),T.pubkey.value)}}async function a({chain:L,...B}){let H=await Z.getRPCUrl(L),f=Z.CosmosChainPrefixes[L],x="index"in B?B.index||0:0,T=Z.derivationPathToString("derivationPath"in B&&B.derivationPath?B.derivationPath:Z.updateDerivationPath(Z.NetworkDerivationPath[L],{index:x})),v=await g.match(B).with({phrase:g.P.string},({phrase:X})=>If({derivationPath:T,phrase:X,prefix:f})).with({signer:g.P.any},({signer:X})=>X).otherwise(()=>{return});async function y(X){return(await D(H)).getAccount(X)}async function Q(){let[X]=await v?.getAccounts()||[];return X?.address}async function I(){let[X]=await v?.getAccounts()||[];if(!X?.pubkey)throw new Z.SwapKitError("toolbox_cosmos_signer_not_defined");return l.base64.encode(X?.pubkey)}async function S({recipient:X,assetValue:N,memo:E="",feeRate:J,feeOptionKey:q=Z.FeeOption.Fast}){let F=await Q();if(!(v&&F))throw new Z.SwapKitError("toolbox_cosmos_signer_not_defined");let R=Z.AssetValue.from({chain:L}),C=i(R),Tf=J||Z0((await nf(L,$f[L]))[q],C),xf=await o(H,v),Bf=[{amount:N.getBaseValue("string"),denom:M(`u${N.symbol}`).toLowerCase()}],{transactionHash:c}=await xf.sendTokens(F,X,Bf,Tf,E);return c}return{createPrivateKeyFromPhrase:Q0(T),createTransaction:Wf,fetchFeeRateFromSwapKit:Jf,getAccount:y,getAddress:Q,getBalance:async(X,N)=>{let E=await pf(H)(X),J=await Promise.all(E.filter(({denom:q})=>q&&!q.includes("IBC/")).map(({denom:q,amount:F})=>{let R=[Z.Chain.THORChain,Z.Chain.Maya].includes(L)&&(q.includes("/")||q.includes("˜"))?`${L}.${q}`:q;return zf(R,F)}));if(J.length===0)return[Z.AssetValue.from({chain:L})];return J},getBalanceAsDenoms:pf(H),getFees:()=>nf(L,$f[L]),getPubKey:I,getSignerFromPhrase:async({phrase:X,derivationPath:N})=>If({derivationPath:Z.derivationPathToString(N),index:x,phrase:X,prefix:f}),getSignerFromPrivateKey:async(X)=>{let N=await import("@cosmjs/proto-signing");return(N.DirectSecp256k1Wallet??N.default?.DirectSecp256k1Wallet).fromKey(X,f)},transfer:S,validateAddress:jf(f),verifySignature:cf(y)}}async function z0(L,B){try{let f=(await Yf.SwapKitApi.getGasRate()).find((x)=>x.chainId===L)?.value;return f?Number.parseFloat(f):B}catch{return B}}function G0({assetValue:{chain:L}}){return Z.AssetValue.from({chain:L,value:_0(L)})}async function nf(L,B){let{chainId:H,baseDecimal:f}=Z.getChainConfig(L),x=await Jf(H,B);return{average:Z.SwapKitNumber.fromBigInt(BigInt(x),f),fast:Z.SwapKitNumber.fromBigInt(BigInt(Z.applyFeeMultiplier(x,Z.FeeOption.Fast,!0)),f),fastest:Z.SwapKitNumber.fromBigInt(BigInt(Z.applyFeeMultiplier(x,Z.FeeOption.Fastest,!0)),f)}}function Z0(L,B){return{amount:[{amount:L.getBaseValue("string"),denom:B}],gas:"200000"}}function _0(L){return{[Z.Chain.Cosmos]:0.007,[Z.Chain.Kujira]:0.02,[Z.Chain.Noble]:0.01,[Z.Chain.THORChain]:0.02,[Z.Chain.Maya]:0.02,[Z.Chain.Harbor]:0.02}[L]||0}function jf(L){return function(H){if(!H.startsWith(L))return!1;try{let{prefix:f,words:x}=l.bech32.decode(H);return l.bech32.encode(f,x)===H.toLocaleLowerCase()}catch{return!1}}}function pf(L){return async function(H){return(await(await D(L)).getAllBalances(H)).map((v)=>({...v,denom:v.denom.includes("/")?v.denom.toUpperCase():v.denom}))}}function Q0(L){return async function(H){let f=await import("@cosmjs/crypto"),x=f.stringToPath??f.default?.stringToPath,T=f.Slip10Curve??f.default?.Slip10Curve,v=f.Slip10??f.default?.Slip10,y=f.EnglishMnemonic??f.default?.EnglishMnemonic,Q=f.Bip39??f.default?.Bip39,I=new y(H),S=await Q.mnemonicToSeed(I),{privkey:X}=v.derivePath(T.Secp256k1,S,x(L));return X}}var l,Z,Yf,g,$f;var ff=A(()=>{t();l=require("@scure/base"),Z=require("@swapkit/helpers"),Yf=require("@swapkit/helpers/api"),g=require("ts-pattern");$f={[Z.Chain.Cosmos]:500,[Z.Chain.Kujira]:1000,[Z.Chain.Noble]:1000,[Z.Chain.THORChain]:5000000,[Z.Chain.Maya]:5000000,[Z.Chain.Harbor]:5000000}});function X0({prefix:L,derivationPath:B}){return async function(f,x=0){let T=await import("@cosmjs/amino"),v=T.Secp256k1HdWallet??T.default?.Secp256k1HdWallet,y=await import("@cosmjs/crypto"),Q=y.stringToPath??y.default?.stringToPath;return v.fromMnemonic(f,{hdPaths:[Q(`${B}/${x}`)],prefix:L})}}function I0(L){return $.base64.encode(L)}function Y0(L){return async function({wallet:H,tx:f}){let{msgs:x,accountNumber:T,sequence:v,chainId:y,fee:Q,memo:I}=typeof f==="string"?JSON.parse(f):f,S=(await H.getAccounts())?.[0]?.address||"",X=await u(L),N=await p(),E=await yf(H,{aminoTypes:X,registry:N}),J=[];for(let R of x){let C=await h(R,L);J.push(C)}let{signatures:[q]}=await E.sign(S,J,Q,I,{accountNumber:T,chainId:y,sequence:v});return{bodyBytes:await m({chain:L,memo:I,msgs:x.map(w)}),signature:I0(q)}}}function J0({prefix:L,rpcUrl:B}){return async function(f,x,T,v,y){let{encodeSecp256k1Pubkey:Q,pubkeyToAddress:I}=(await import("@cosmjs/amino")).default,{makeMultisignedTxBytes:S}=(await import("@cosmjs/stargate")).default,{sequence:X,fee:N}=JSON.parse(f),E=await bf(T,v),J=x.map((R)=>[I(Q($.base64.decode(R.pubKey)),L),$.base64.decode(R.signature)]),q=await D(B),{transactionHash:F}=await q.broadcastTx(S(E,X,N,y,new Map(J)));return F}}async function bf(L,B,H=!0){let{createMultisigThresholdPubkey:f,encodeSecp256k1Pubkey:x}=(await import("@cosmjs/amino")).default;return f(L.map((T)=>x($.base64.decode(T))),B,H)}function q0(L){return $.base64.decode(L)}async function N0({privateKey:L,message:B}){let{Secp256k1:H}=(await import("@cosmjs/crypto")).default,f=await H.createSignature($.base64.decode(B),L);return $.base64.encode(Buffer.concat([f.r(32),f.s(32)]))}async function qf({chain:L,...B}){let H=await Y.getRPCUrl(L),{nodeUrl:f}=Y.getChainConfig(L),{isStagenet:x}=Y.SKConfig.get("envs"),T=L===Y.Chain.THORChain,v=`${x?"s":""}${Y.CosmosChainPrefixes[L]}`,y="index"in B?B.index||0:0,Q="derivationPath"in B&&B.derivationPath?B.derivationPath:Y.updateDerivationPath(Y.NetworkDerivationPath[L],{index:y}),I=await a({chain:L,...B}),S=await r.match(B).with({phrase:r.P.string},({phrase:J})=>I.getSignerFromPhrase({derivationPath:Q,phrase:J})).with({signer:r.P.any},({signer:J})=>J).otherwise(()=>{return}),X=V(L);async function N(){let J,q=`${f}/${T?"thorchain":"mayachain"}/constants`;try{let{int_64_values:{NativeTransactionFee:F}}=await Y.RequestClient.get(q);if(!F||Number.isNaN(F)||F<0)throw new Y.SwapKitError("toolbox_cosmos_invalid_fee",{nativeFee:F.toString()});J=new Y.SwapKitNumber(F)}catch{J=new Y.SwapKitNumber({decimal:Y.getChainConfig(L).baseDecimal,value:T?0.02:1})}return{[Y.FeeOption.Average]:J,[Y.FeeOption.Fast]:J,[Y.FeeOption.Fastest]:J}}async function E({assetValue:J,memo:q="",recipient:F}){let{TxRaw:R}=await import("cosmjs-types/cosmos/tx/v1beta1/tx"),C=(await S?.getAccounts())?.[0]?.address;if(!(C&&S))throw new Y.SwapKitError("toolbox_cosmos_no_signer");let Tf="signAmino"in S,xf=await p(),Bf=await u(L),c=await o(H,S,{aminoTypes:Bf,registry:xf}),vf=e({assetValue:J,memo:q,recipient:F,sender:C});if(Tf){let mf=await h(vf,L),{signatures:gf,authInfoBytes:af}=await c.sign(C,[mf],X,q),rf=R.encode({authInfoBytes:af,bodyBytes:await m({chain:L,memo:q,msgs:[vf].map(w)}),signatures:gf}).finish();return(await c.broadcastTx(rf)).transactionHash}let of=w(vf),tf=await h(of,L);return(await c.signAndBroadcast(C,[tf],X,q)).transactionHash}return{...I,broadcastMultisigTx:J0({prefix:v,rpcUrl:H}),buildAminoMsg:e,buildEncodedTxBody:m,convertToSignable:h,createDefaultAminoTypes:()=>u(L),createDefaultRegistry:p,createMultisig:bf,createTransaction:Qf(H),deposit:E,getFees:N,importSignature:q0,parseAminoMessageForDirectSigning:w,pubkeyToAddress:async(J)=>{let{pubkeyToAddress:q}=(await import("@cosmjs/amino")).default;return q(J,v)},secp256k1HdWalletFromMnemonic:X0({derivationPath:Y.derivationPathToString(Q),prefix:v}),signMultisigTx:Y0(L),signWithPrivateKey:N0,transfer:E}}var $,Y,r;var Nf=A(()=>{Xf();t();ff();$=require("@scure/base"),Y=require("@swapkit/helpers"),r=require("ts-pattern")});var n,K0=(L,B)=>{switch(L){case n.Chain.Cosmos:case n.Chain.Kujira:case n.Chain.Noble:return a({chain:L,...B});case n.Chain.Maya:case n.Chain.THORChain:return qf({chain:L,...B});default:throw new n.SwapKitError("toolbox_cosmos_not_supported",{chain:L})}};var df=A(()=>{ff();Nf();n=require("@swapkit/helpers");ff();Nf()});var O0={};Ef(O0,{verifySignature:()=>cf,transferMsgAmino:()=>Zf,toBase64:()=>x0,parseAminoMessageForDirectSigning:()=>w,getSignerFromPrivateKey:()=>W0,getSignerFromPhrase:()=>If,getMsgSendDenom:()=>M,getFeeRateFromSwapKit:()=>z0,getDenomWithChain:()=>i,getDefaultChainFee:()=>V,getCreateTransaction:()=>Qf,getCosmosValidateAddress:()=>jf,getCosmosToolbox:()=>K0,getAssetFromDenom:()=>zf,fromBase64:()=>B0,fetchFeeRateFromSwapKit:()=>Jf,estimateTransactionFee:()=>G0,depositMsgAmino:()=>_f,createThorchainToolbox:()=>qf,createStargateClient:()=>D,createSigningStargateClient:()=>o,createOfflineStargateClient:()=>yf,createDefaultRegistry:()=>p,createDefaultAminoTypes:()=>u,createCosmosToolbox:()=>a,cosmosCreateTransaction:()=>Wf,convertToSignable:()=>h,buildTransferTx:()=>Mf,buildEncodedTxBody:()=>m,buildDepositTx:()=>uf,buildAminoMsg:()=>e,bech32ToBase64:()=>b,base64ToBech32:()=>d,YUM_KUJIRA_FACTORY_DENOM:()=>Af,USK_KUJIRA_FACTORY_DENOM:()=>Lf,THORCHAIN_GAS_VALUE:()=>L0,MAYA_GAS_VALUE:()=>y0,DEFAULT_NOBLE_FEE_MAINNET:()=>Rf,DEFAULT_KUJI_FEE_MAINNET:()=>Uf,DEFAULT_COSMOS_FEE_MAINNET:()=>kf});module.exports=T0(O0);var E0=A(()=>{Xf();df();t()});E0();
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=DF82ADBC1789C51F64756E2164756E21
|
|
4
4
|
//# sourceMappingURL=index.cjs.map
|