@swapkit/toolboxes 4.19.0 → 4.20.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/CHANGELOG.md +8 -0
- package/dist/chunk-3pne8gaa.js +1 -0
- package/dist/chunk-44m22jy1.js +1 -0
- package/dist/chunk-4q573g5z.js +2 -0
- package/dist/chunk-54gntgt1.js +2 -0
- package/dist/chunk-ntbvmmch.js +2 -0
- package/dist/chunk-r2htb2ce.js +1 -0
- package/dist/src/aptos/index.js +1 -1
- package/dist/src/cardano/index.cjs +1 -1
- package/dist/src/cardano/index.js +1 -1
- package/dist/src/cosmos/index.cjs +1 -1
- package/dist/src/cosmos/index.js +1 -1
- package/dist/src/evm/index.cjs +1 -1
- package/dist/src/evm/index.js +1 -1
- package/dist/src/hypercore/index.cjs +1 -1
- package/dist/src/hypercore/index.js +1 -1
- package/dist/src/index.cjs +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/near/index.cjs +1 -1
- package/dist/src/near/index.js +1 -1
- package/dist/src/radix/index.cjs +1 -1
- package/dist/src/radix/index.js +1 -1
- package/dist/src/ripple/index.cjs +1 -1
- package/dist/src/ripple/index.js +1 -1
- package/dist/src/solana/index.js +1 -1
- package/dist/src/starknet/index.js +1 -1
- package/dist/src/stellar/index.js +1 -1
- package/dist/src/substrate/index.cjs +1 -1
- package/dist/src/substrate/index.js +1 -1
- package/dist/src/sui/index.js +1 -1
- package/dist/src/ton/index.cjs +1 -1
- package/dist/src/ton/index.js +1 -1
- package/dist/src/tron/index.cjs +1 -1
- package/dist/src/tron/index.js +1 -1
- package/dist/src/utxo/index.js +1 -1
- package/dist/types/cardano/toolbox.d.ts +1 -1
- package/dist/types/cosmos/toolbox/cosmos.d.ts +2 -3
- package/dist/types/evm/helpers.d.ts +11 -1
- package/dist/types/near/toolbox.d.ts +1 -2
- package/dist/types/radix/index.d.ts +2 -2
- package/dist/types/ripple/index.d.ts +4 -8
- package/dist/types/substrate/substrate.d.ts +1 -1
- package/dist/types/ton/toolbox.d.ts +1 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @swapkit/toolboxes
|
|
2
2
|
|
|
3
|
+
## 4.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#294](https://github.com/swapkit/sdk/pull/294) [`01a1d86`](https://github.com/swapkit/sdk/commit/01a1d869ec879ee80f4118719d7746c1b4f8e9bf) Thanks [@ice-chillios](https://github.com/ice-chillios)! - Remove eager work from toolbox construction so `getToolbox()` does no network I/O and doesn't load heavy chain SDKs until a method actually needs them.
|
|
8
|
+
- [#299](https://github.com/swapkit/sdk/pull/299) [`78d430d`](https://github.com/swapkit/sdk/commit/78d430df03f86dfe2cea5dd4bdc5884de5ba1529) Thanks [@towanTG](https://github.com/towanTG)! - Fail TRC-20 transaction creation when both Tron energy probes fail instead of falling back to a hardcoded 65k energy estimate.
|
|
9
|
+
- [#294](https://github.com/swapkit/sdk/pull/294) [`01a1d86`](https://github.com/swapkit/sdk/commit/01a1d869ec879ee80f4118719d7746c1b4f8e9bf) Thanks [@ice-chillios](https://github.com/ice-chillios)! - Leaner published bundles: externalize sibling `@swapkit/*` workspace packages and enable ESM code-splitting for every package (builder change in `@swapkit/tools-builder`). (via @swapkit/helpers@4.15.2)
|
|
10
|
+
|
|
3
11
|
## 4.19.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-ntbvmmch.js";import Y from"protobufjs/minimal.js";var X=Y.Reader,J=Y.Writer,Q=Y.util,L=Y.roots.default||(Y.roots.default={});L.common=(()=>{let Z={};return Z.Asset=(()=>{function G(H){if(H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.chain="",G.prototype.symbol="",G.prototype.ticker="",G.prototype.synth=!1,G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.chain!=null&&Object.hasOwnProperty.call(q,"chain"))B.uint32(10).string(q.chain);if(q.symbol!=null&&Object.hasOwnProperty.call(q,"symbol"))B.uint32(18).string(q.symbol);if(q.ticker!=null&&Object.hasOwnProperty.call(q,"ticker"))B.uint32(26).string(q.ticker);if(q.synth!=null&&Object.hasOwnProperty.call(q,"synth"))B.uint32(32).bool(q.synth);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.Asset;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.chain=q.string();break;case 2:E.symbol=q.string();break;case 3:E.ticker=q.string();break;case 4:E.synth=q.bool();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.chain!=null&&q.hasOwnProperty("chain")){if(!Q.isString(q.chain))return"chain: string expected"}if(q.symbol!=null&&q.hasOwnProperty("symbol")){if(!Q.isString(q.symbol))return"symbol: string expected"}if(q.ticker!=null&&q.hasOwnProperty("ticker")){if(!Q.isString(q.ticker))return"ticker: string expected"}if(q.synth!=null&&q.hasOwnProperty("synth")){if(typeof q.synth!=="boolean")return"synth: boolean expected"}return null},G.fromObject=function(q){if(q instanceof L.common.Asset)return q;let B=new L.common.Asset;if(q.chain!=null)B.chain=String(q.chain);if(q.symbol!=null)B.symbol=String(q.symbol);if(q.ticker!=null)B.ticker=String(q.ticker);if(q.synth!=null)B.synth=Boolean(q.synth);return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.defaults)z.chain="",z.symbol="",z.ticker="",z.synth=!1;if(q.chain!=null&&q.hasOwnProperty("chain"))z.chain=q.chain;if(q.symbol!=null&&q.hasOwnProperty("symbol"))z.symbol=q.symbol;if(q.ticker!=null&&q.hasOwnProperty("ticker"))z.ticker=q.ticker;if(q.synth!=null&&q.hasOwnProperty("synth"))z.synth=q.synth;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.Coin=(()=>{function G(H){if(H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.asset=null,G.prototype.amount="",G.prototype.decimals=Q.Long?Q.Long.fromBits(0,0,!1):0,G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.asset!=null&&Object.hasOwnProperty.call(q,"asset"))L.common.Asset.encode(q.asset,B.uint32(10).fork()).ldelim();if(q.amount!=null&&Object.hasOwnProperty.call(q,"amount"))B.uint32(18).string(q.amount);if(q.decimals!=null&&Object.hasOwnProperty.call(q,"decimals"))B.uint32(24).int64(q.decimals);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.Coin;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.asset=L.common.Asset.decode(q,q.uint32());break;case 2:E.amount=q.string();break;case 3:E.decimals=q.int64();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.asset!=null&&q.hasOwnProperty("asset")){let B=L.common.Asset.verify(q.asset);if(B)return"asset."+B}if(q.amount!=null&&q.hasOwnProperty("amount")){if(!Q.isString(q.amount))return"amount: string expected"}if(q.decimals!=null&&q.hasOwnProperty("decimals")){if(!Q.isInteger(q.decimals)&&!(q.decimals&&Q.isInteger(q.decimals.low)&&Q.isInteger(q.decimals.high)))return"decimals: integer|Long expected"}return null},G.fromObject=function(q){if(q instanceof L.common.Coin)return q;let B=new L.common.Coin;if(q.asset!=null){if(typeof q.asset!=="object")throw TypeError(".common.Coin.asset: object expected");B.asset=L.common.Asset.fromObject(q.asset)}if(q.amount!=null)B.amount=String(q.amount);if(q.decimals!=null){if(Q.Long)(B.decimals=Q.Long.fromValue(q.decimals)).unsigned=!1;else if(typeof q.decimals==="string")B.decimals=Number.parseInt(q.decimals,10);else if(typeof q.decimals==="number")B.decimals=q.decimals;else if(typeof q.decimals==="object")B.decimals=new Q.LongBits(q.decimals.low>>>0,q.decimals.high>>>0).toNumber()}return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.defaults)if(z.asset=null,z.amount="",Q.Long){let E=new Q.Long(0,0,!1);z.decimals=B.longs===String?E.toString():B.longs===Number?E.toNumber():E}else z.decimals=B.longs===String?"0":0;if(q.asset!=null&&q.hasOwnProperty("asset"))z.asset=L.common.Asset.toObject(q.asset,B);if(q.amount!=null&&q.hasOwnProperty("amount"))z.amount=q.amount;if(q.decimals!=null&&q.hasOwnProperty("decimals"))if(typeof q.decimals==="number")z.decimals=B.longs===String?String(q.decimals):q.decimals;else z.decimals=B.longs===String?Q.Long.prototype.toString.call(q.decimals):B.longs===Number?new Q.LongBits(q.decimals.low>>>0,q.decimals.high>>>0).toNumber():q.decimals;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.PubKeySet=(()=>{function G(H){if(H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.secp256k1="",G.prototype.ed25519="",G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.secp256k1!=null&&Object.hasOwnProperty.call(q,"secp256k1"))B.uint32(10).string(q.secp256k1);if(q.ed25519!=null&&Object.hasOwnProperty.call(q,"ed25519"))B.uint32(18).string(q.ed25519);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.PubKeySet;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.secp256k1=q.string();break;case 2:E.ed25519=q.string();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.secp256k1!=null&&q.hasOwnProperty("secp256k1")){if(!Q.isString(q.secp256k1))return"secp256k1: string expected"}if(q.ed25519!=null&&q.hasOwnProperty("ed25519")){if(!Q.isString(q.ed25519))return"ed25519: string expected"}return null},G.fromObject=function(q){if(q instanceof L.common.PubKeySet)return q;let B=new L.common.PubKeySet;if(q.secp256k1!=null)B.secp256k1=String(q.secp256k1);if(q.ed25519!=null)B.ed25519=String(q.ed25519);return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.defaults)z.secp256k1="",z.ed25519="";if(q.secp256k1!=null&&q.hasOwnProperty("secp256k1"))z.secp256k1=q.secp256k1;if(q.ed25519!=null&&q.hasOwnProperty("ed25519"))z.ed25519=q.ed25519;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.Tx=(()=>{function G(H){if(this.coins=[],this.gas=[],H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.id="",G.prototype.chain="",G.prototype.fromAddress="",G.prototype.toAddress="",G.prototype.coins=Q.emptyArray,G.prototype.gas=Q.emptyArray,G.prototype.memo="",G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.id!=null&&Object.hasOwnProperty.call(q,"id"))B.uint32(10).string(q.id);if(q.chain!=null&&Object.hasOwnProperty.call(q,"chain"))B.uint32(18).string(q.chain);if(q.fromAddress!=null&&Object.hasOwnProperty.call(q,"fromAddress"))B.uint32(26).string(q.fromAddress);if(q.toAddress!=null&&Object.hasOwnProperty.call(q,"toAddress"))B.uint32(34).string(q.toAddress);if(q.coins?.length)for(let z=0;z<q.coins.length;++z)L.common.Coin.encode(q.coins[z],B.uint32(42).fork()).ldelim();if(q.gas?.length)for(let z=0;z<q.gas.length;++z)L.common.Coin.encode(q.gas[z],B.uint32(50).fork()).ldelim();if(q.memo!=null&&Object.hasOwnProperty.call(q,"memo"))B.uint32(58).string(q.memo);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.Tx;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.id=q.string();break;case 2:E.chain=q.string();break;case 3:E.fromAddress=q.string();break;case 4:E.toAddress=q.string();break;case 5:if(!E.coins?.length)E.coins=[];E.coins.push(L.common.Coin.decode(q,q.uint32()));break;case 6:if(!E.gas?.length)E.gas=[];E.gas.push(L.common.Coin.decode(q,q.uint32()));break;case 7:E.memo=q.string();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.id!=null&&q.hasOwnProperty("id")){if(!Q.isString(q.id))return"id: string expected"}if(q.chain!=null&&q.hasOwnProperty("chain")){if(!Q.isString(q.chain))return"chain: string expected"}if(q.fromAddress!=null&&q.hasOwnProperty("fromAddress")){if(!Q.isString(q.fromAddress))return"fromAddress: string expected"}if(q.toAddress!=null&&q.hasOwnProperty("toAddress")){if(!Q.isString(q.toAddress))return"toAddress: string expected"}if(q.coins!=null&&q.hasOwnProperty("coins")){if(!Array.isArray(q.coins))return"coins: array expected";for(let B=0;B<q.coins.length;++B){let z=L.common.Coin.verify(q.coins[B]);if(z)return"coins."+z}}if(q.gas!=null&&q.hasOwnProperty("gas")){if(!Array.isArray(q.gas))return"gas: array expected";for(let B=0;B<q.gas.length;++B){let z=L.common.Coin.verify(q.gas[B]);if(z)return"gas."+z}}if(q.memo!=null&&q.hasOwnProperty("memo")){if(!Q.isString(q.memo))return"memo: string expected"}return null},G.fromObject=function(q){if(q instanceof L.common.Tx)return q;let B=new L.common.Tx;if(q.id!=null)B.id=String(q.id);if(q.chain!=null)B.chain=String(q.chain);if(q.fromAddress!=null)B.fromAddress=String(q.fromAddress);if(q.toAddress!=null)B.toAddress=String(q.toAddress);if(q.coins){if(!Array.isArray(q.coins))throw TypeError(".common.Tx.coins: array expected");B.coins=[];for(let z=0;z<q.coins.length;++z){if(typeof q.coins[z]!=="object")throw TypeError(".common.Tx.coins: object expected");B.coins[z]=L.common.Coin.fromObject(q.coins[z])}}if(q.gas){if(!Array.isArray(q.gas))throw TypeError(".common.Tx.gas: array expected");B.gas=[];for(let z=0;z<q.gas.length;++z){if(typeof q.gas[z]!=="object")throw TypeError(".common.Tx.gas: object expected");B.gas[z]=L.common.Coin.fromObject(q.gas[z])}}if(q.memo!=null)B.memo=String(q.memo);return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.arrays||B.defaults)z.coins=[],z.gas=[];if(B.defaults)z.id="",z.chain="",z.fromAddress="",z.toAddress="",z.memo="";if(q.id!=null&&q.hasOwnProperty("id"))z.id=q.id;if(q.chain!=null&&q.hasOwnProperty("chain"))z.chain=q.chain;if(q.fromAddress!=null&&q.hasOwnProperty("fromAddress"))z.fromAddress=q.fromAddress;if(q.toAddress!=null&&q.hasOwnProperty("toAddress"))z.toAddress=q.toAddress;if(q.coins?.length){z.coins=[];for(let E=0;E<q.coins.length;++E)z.coins[E]=L.common.Coin.toObject(q.coins[E],B)}if(q.gas?.length){z.gas=[];for(let E=0;E<q.gas.length;++E)z.gas[E]=L.common.Coin.toObject(q.gas[E],B)}if(q.memo!=null&&q.hasOwnProperty("memo"))z.memo=q.memo;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.Fee=(()=>{function G(H){if(this.coins=[],H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.coins=Q.emptyArray,G.prototype.poolDeduct="",G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.coins?.length)for(let z=0;z<q.coins.length;++z)L.common.Coin.encode(q.coins[z],B.uint32(10).fork()).ldelim();if(q.poolDeduct!=null&&Object.hasOwnProperty.call(q,"poolDeduct"))B.uint32(18).string(q.poolDeduct);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.Fee;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:if(!E.coins?.length)E.coins=[];E.coins.push(L.common.Coin.decode(q,q.uint32()));break;case 2:E.poolDeduct=q.string();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.coins!=null&&q.hasOwnProperty("coins")){if(!Array.isArray(q.coins))return"coins: array expected";for(let B=0;B<q.coins.length;++B){let z=L.common.Coin.verify(q.coins[B]);if(z)return"coins."+z}}if(q.poolDeduct!=null&&q.hasOwnProperty("poolDeduct")){if(!Q.isString(q.poolDeduct))return"poolDeduct: string expected"}return null},G.fromObject=function(q){if(q instanceof L.common.Fee)return q;let B=new L.common.Fee;if(q.coins){if(!Array.isArray(q.coins))throw TypeError(".common.Fee.coins: array expected");B.coins=[];for(let z=0;z<q.coins.length;++z){if(typeof q.coins[z]!=="object")throw TypeError(".common.Fee.coins: object expected");B.coins[z]=L.common.Coin.fromObject(q.coins[z])}}if(q.poolDeduct!=null)B.poolDeduct=String(q.poolDeduct);return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.arrays||B.defaults)z.coins=[];if(B.defaults)z.poolDeduct="";if(q.coins?.length){z.coins=[];for(let E=0;E<q.coins.length;++E)z.coins[E]=L.common.Coin.toObject(q.coins[E],B)}if(q.poolDeduct!=null&&q.hasOwnProperty("poolDeduct"))z.poolDeduct=q.poolDeduct;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.ProtoUint=(()=>{function G(H){if(H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.value="",G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.value!=null&&Object.hasOwnProperty.call(q,"value"))B.uint32(10).string(q.value);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.ProtoUint;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.value=q.string();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.value!=null&&q.hasOwnProperty("value")){if(!Q.isString(q.value))return"value: string expected"}return null},G.fromObject=function(q){if(q instanceof L.common.ProtoUint)return q;let B=new L.common.ProtoUint;if(q.value!=null)B.value=String(q.value);return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.defaults)z.value="";if(q.value!=null&&q.hasOwnProperty("value"))z.value=q.value;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z})();L.types=(()=>{let Z={};return Z.MsgDeposit=(()=>{function G(H){if(this.coins=[],H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.coins=Q.emptyArray,G.prototype.memo="",G.prototype.signer=Q.newBuffer([]),G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.coins?.length)for(let z=0;z<q.coins.length;++z)L.common.Coin.encode(q.coins[z],B.uint32(10).fork()).ldelim();if(q.memo!=null&&Object.hasOwnProperty.call(q,"memo"))B.uint32(18).string(q.memo);if(q.signer!=null&&Object.hasOwnProperty.call(q,"signer"))B.uint32(26).bytes(q.signer);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.types.MsgDeposit;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:if(!E.coins?.length)E.coins=[];E.coins.push(L.common.Coin.decode(q,q.uint32()));break;case 2:E.memo=q.string();break;case 3:E.signer=q.bytes();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.coins!=null&&q.hasOwnProperty("coins")){if(!Array.isArray(q.coins))return"coins: array expected";for(let B=0;B<q.coins.length;++B){let z=L.common.Coin.verify(q.coins[B]);if(z)return"coins."+z}}if(q.memo!=null&&q.hasOwnProperty("memo")){if(!Q.isString(q.memo))return"memo: string expected"}if(q.signer!=null&&q.hasOwnProperty("signer")){if(!(q.signer&&typeof q.signer.length==="number"||Q.isString(q.signer)))return"signer: buffer expected"}return null},G.fromObject=function(q){if(q instanceof L.types.MsgDeposit)return q;let B=new L.types.MsgDeposit;if(q.coins){if(!Array.isArray(q.coins))throw TypeError(".types.MsgDeposit.coins: array expected");B.coins=[];for(let z=0;z<q.coins.length;++z){if(typeof q.coins[z]!=="object")throw TypeError(".types.MsgDeposit.coins: object expected");B.coins[z]=L.common.Coin.fromObject(q.coins[z])}}if(q.memo!=null)B.memo=String(q.memo);if(q.signer!=null){if(typeof q.signer==="string")Q.base64.decode(q.signer,B.signer=Q.newBuffer(Q.base64.length(q.signer)),0);else if(q.signer.length)B.signer=q.signer}return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.arrays||B.defaults)z.coins=[];if(B.defaults){if(z.memo="",B.bytes===String)z.signer="";else if(z.signer=[],B.bytes!==Array)z.signer=Q.newBuffer(z.signer)}if(q.coins?.length){z.coins=[];for(let E=0;E<q.coins.length;++E)z.coins[E]=L.common.Coin.toObject(q.coins[E],B)}if(q.memo!=null&&q.hasOwnProperty("memo"))z.memo=q.memo;if(q.signer!=null&&q.hasOwnProperty("signer"))z.signer=B.bytes===String?Q.base64.encode(q.signer,0,q.signer.length):B.bytes===Array?Array.prototype.slice.call(q.signer):q.signer;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.MsgSend=(()=>{function G(H){if(this.amount=[],H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.fromAddress=Q.newBuffer([]),G.prototype.toAddress=Q.newBuffer([]),G.prototype.amount=Q.emptyArray,G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.fromAddress!=null&&Object.hasOwnProperty.call(q,"fromAddress"))B.uint32(10).bytes(q.fromAddress);if(q.toAddress!=null&&Object.hasOwnProperty.call(q,"toAddress"))B.uint32(18).bytes(q.toAddress);if(q.amount?.length)for(let z=0;z<q.amount.length;++z)L.cosmos.base.v1beta1.Coin.encode(q.amount[z],B.uint32(26).fork()).ldelim();return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.types.MsgSend;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.fromAddress=q.bytes();break;case 2:E.toAddress=q.bytes();break;case 3:if(!E.amount?.length)E.amount=[];E.amount.push(L.cosmos.base.v1beta1.Coin.decode(q,q.uint32()));break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.fromAddress!=null&&q.hasOwnProperty("fromAddress")){if(!(q.fromAddress&&typeof q.fromAddress.length==="number"||Q.isString(q.fromAddress)))return"fromAddress: buffer expected"}if(q.toAddress!=null&&q.hasOwnProperty("toAddress")){if(!(q.toAddress&&typeof q.toAddress.length==="number"||Q.isString(q.toAddress)))return"toAddress: buffer expected"}if(q.amount!=null&&q.hasOwnProperty("amount")){if(!Array.isArray(q.amount))return"amount: array expected";for(let B=0;B<q.amount.length;++B){let z=L.cosmos.base.v1beta1.Coin.verify(q.amount[B]);if(z)return"amount."+z}}return null},G.fromObject=function(q){if(q instanceof L.types.MsgSend)return q;let B=new L.types.MsgSend;if(q.fromAddress!=null){if(typeof q.fromAddress==="string")Q.base64.decode(q.fromAddress,B.fromAddress=Q.newBuffer(Q.base64.length(q.fromAddress)),0);else if(q.fromAddress.length)B.fromAddress=q.fromAddress}if(q.toAddress!=null){if(typeof q.toAddress==="string")Q.base64.decode(q.toAddress,B.toAddress=Q.newBuffer(Q.base64.length(q.toAddress)),0);else if(q.toAddress.length)B.toAddress=q.toAddress}if(q.amount){if(!Array.isArray(q.amount))throw TypeError(".types.MsgSend.amount: array expected");B.amount=[];for(let z=0;z<q.amount.length;++z){if(typeof q.amount[z]!=="object")throw TypeError(".types.MsgSend.amount: object expected");B.amount[z]=L.cosmos.base.v1beta1.Coin.fromObject(q.amount[z])}}return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.arrays||B.defaults)z.amount=[];if(B.defaults){if(B.bytes===String)z.fromAddress="";else if(z.fromAddress=[],B.bytes!==Array)z.fromAddress=Q.newBuffer(z.fromAddress);if(B.bytes===String)z.toAddress="";else if(z.toAddress=[],B.bytes!==Array)z.toAddress=Q.newBuffer(z.toAddress)}if(q.fromAddress!=null&&q.hasOwnProperty("fromAddress"))z.fromAddress=B.bytes===String?Q.base64.encode(q.fromAddress,0,q.fromAddress.length):B.bytes===Array?Array.prototype.slice.call(q.fromAddress):q.fromAddress;if(q.toAddress!=null&&q.hasOwnProperty("toAddress"))z.toAddress=B.bytes===String?Q.base64.encode(q.toAddress,0,q.toAddress.length):B.bytes===Array?Array.prototype.slice.call(q.toAddress):q.toAddress;if(q.amount?.length){z.amount=[];for(let E=0;E<q.amount.length;++E)z.amount[E]=L.cosmos.base.v1beta1.Coin.toObject(q.amount[E],B)}return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z})();L.cosmos=(()=>{let Z={};return Z.base=(()=>{let G={};return G.v1beta1=(()=>{let H={};return H.Coin=(()=>{function q(B){if(B){for(let z=Object.keys(B),E=0;E<z.length;++E)if(B[z[E]]!=null)this[z[E]]=B[z[E]]}}return q.prototype.denom="",q.prototype.amount="",q.create=function(z){return new q(z)},q.encode=function(z,E){if(!E)E=J.create();if(z.denom!=null&&Object.hasOwnProperty.call(z,"denom"))E.uint32(10).string(z.denom);if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))E.uint32(18).string(z.amount);return E},q.encodeDelimited=function(z,E){return this.encode(z,E).ldelim()},q.decode=function(z,E){if(!(z instanceof X))z=X.create(z);let V=E===void 0?z.len:z.pos+E,_=new L.cosmos.base.v1beta1.Coin;while(z.pos<V){let N=z.uint32();switch(N>>>3){case 1:_.denom=z.string();break;case 2:_.amount=z.string();break;default:z.skipType(N&7);break}}return _},q.decodeDelimited=function(z){if(!(z instanceof X))z=new X(z);return this.decode(z,z.uint32())},q.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.denom!=null&&z.hasOwnProperty("denom")){if(!Q.isString(z.denom))return"denom: string expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!Q.isString(z.amount))return"amount: string expected"}return null},q.fromObject=function(z){if(z instanceof L.cosmos.base.v1beta1.Coin)return z;let E=new L.cosmos.base.v1beta1.Coin;if(z.denom!=null)E.denom=String(z.denom);if(z.amount!=null)E.amount=String(z.amount);return E},q.toObject=function(z,E){if(!E)E={};let V={};if(E.defaults)V.denom="",V.amount="";if(z.denom!=null&&z.hasOwnProperty("denom"))V.denom=z.denom;if(z.amount!=null&&z.hasOwnProperty("amount"))V.amount=z.amount;return V},q.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},q})(),H.DecCoin=(()=>{function q(B){if(B){for(let z=Object.keys(B),E=0;E<z.length;++E)if(B[z[E]]!=null)this[z[E]]=B[z[E]]}}return q.prototype.denom="",q.prototype.amount="",q.create=function(z){return new q(z)},q.encode=function(z,E){if(!E)E=J.create();if(z.denom!=null&&Object.hasOwnProperty.call(z,"denom"))E.uint32(10).string(z.denom);if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))E.uint32(18).string(z.amount);return E},q.encodeDelimited=function(z,E){return this.encode(z,E).ldelim()},q.decode=function(z,E){if(!(z instanceof X))z=X.create(z);let V=E===void 0?z.len:z.pos+E,_=new L.cosmos.base.v1beta1.DecCoin;while(z.pos<V){let N=z.uint32();switch(N>>>3){case 1:_.denom=z.string();break;case 2:_.amount=z.string();break;default:z.skipType(N&7);break}}return _},q.decodeDelimited=function(z){if(!(z instanceof X))z=new X(z);return this.decode(z,z.uint32())},q.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.denom!=null&&z.hasOwnProperty("denom")){if(!Q.isString(z.denom))return"denom: string expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!Q.isString(z.amount))return"amount: string expected"}return null},q.fromObject=function(z){if(z instanceof L.cosmos.base.v1beta1.DecCoin)return z;let E=new L.cosmos.base.v1beta1.DecCoin;if(z.denom!=null)E.denom=String(z.denom);if(z.amount!=null)E.amount=String(z.amount);return E},q.toObject=function(z,E){if(!E)E={};let V={};if(E.defaults)V.denom="",V.amount="";if(z.denom!=null&&z.hasOwnProperty("denom"))V.denom=z.denom;if(z.amount!=null&&z.hasOwnProperty("amount"))V.amount=z.amount;return V},q.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},q})(),H.IntProto=(()=>{function q(B){if(B){for(let z=Object.keys(B),E=0;E<z.length;++E)if(B[z[E]]!=null)this[z[E]]=B[z[E]]}}return q.prototype.int="",q.create=function(z){return new q(z)},q.encode=function(z,E){if(!E)E=J.create();if(z.int!=null&&Object.hasOwnProperty.call(z,"int"))E.uint32(10).string(z.int);return E},q.encodeDelimited=function(z,E){return this.encode(z,E).ldelim()},q.decode=function(z,E){if(!(z instanceof X))z=X.create(z);let V=E===void 0?z.len:z.pos+E,_=new L.cosmos.base.v1beta1.IntProto;while(z.pos<V){let N=z.uint32();switch(N>>>3){case 1:_.int=z.string();break;default:z.skipType(N&7);break}}return _},q.decodeDelimited=function(z){if(!(z instanceof X))z=new X(z);return this.decode(z,z.uint32())},q.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.int!=null&&z.hasOwnProperty("int")){if(!Q.isString(z.int))return"int: string expected"}return null},q.fromObject=function(z){if(z instanceof L.cosmos.base.v1beta1.IntProto)return z;let E=new L.cosmos.base.v1beta1.IntProto;if(z.int!=null)E.int=String(z.int);return E},q.toObject=function(z,E){if(!E)E={};let V={};if(E.defaults)V.int="";if(z.int!=null&&z.hasOwnProperty("int"))V.int=z.int;return V},q.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},q})(),H.DecProto=(()=>{function q(B){if(B){for(let z=Object.keys(B),E=0;E<z.length;++E)if(B[z[E]]!=null)this[z[E]]=B[z[E]]}}return q.prototype.dec="",q.create=function(z){return new q(z)},q.encode=function(z,E){if(!E)E=J.create();if(z.dec!=null&&Object.hasOwnProperty.call(z,"dec"))E.uint32(10).string(z.dec);return E},q.encodeDelimited=function(z,E){return this.encode(z,E).ldelim()},q.decode=function(z,E){if(!(z instanceof X))z=X.create(z);let V=E===void 0?z.len:z.pos+E,_=new L.cosmos.base.v1beta1.DecProto;while(z.pos<V){let N=z.uint32();switch(N>>>3){case 1:_.dec=z.string();break;default:z.skipType(N&7);break}}return _},q.decodeDelimited=function(z){if(!(z instanceof X))z=new X(z);return this.decode(z,z.uint32())},q.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.dec!=null&&z.hasOwnProperty("dec")){if(!Q.isString(z.dec))return"dec: string expected"}return null},q.fromObject=function(z){if(z instanceof L.cosmos.base.v1beta1.DecProto)return z;let E=new L.cosmos.base.v1beta1.DecProto;if(z.dec!=null)E.dec=String(z.dec);return E},q.toObject=function(z,E){if(!E)E={};let V={};if(E.defaults)V.dec="";if(z.dec!=null&&z.hasOwnProperty("dec"))V.dec=z.dec;return V},q.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},q})(),H})(),G})(),Z})();export{L as $root};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r;((x)=>{x.Test="goerli";x.Main="homestead"})(r||={});export{r as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{da as Wt}from"./chunk-54gntgt1.js";import{ea as g}from"./chunk-ntbvmmch.js";import{Chain as H}from"@swapkit/helpers";import{match as Py}from"ts-pattern";import{Chain as W,getChainConfig as I,getRPCUrl as at,SKConfig as rt,SwapKitError as K}from"@swapkit/helpers";import{FallbackProvider as ty,getAddress as Dt,Interface as yy,JsonRpcProvider as s,Network as uy}from"ethers";import{match as Lt}from"ts-pattern";function ny(t){return new s(t)}async function cy(t,y){return ny(y||await at(t))}function Rt(t){let y=rt.get("rpcUrls")[t]?.filter(Boolean)??[];if(y.length===0)throw new K("helpers_chain_no_public_or_set_rpc_url",{chain:t});let{chainId:u}=I(t),n=uy.from(Number(u)),[T]=y;if(y.length===1)return new s(T,n,{staticNetwork:n});return new ty(y.map((l,b)=>({priority:b+1,provider:new s(l,n,{staticNetwork:n}),stallTimeout:2000})),n,{quorum:1})}function P(t){return t>0n?`0x${t.toString(16)}`:"0x0"}function qt(t){let{explorerUrl:y,chainIdHex:u,rpcUrls:n}=I(t);return function(){return t!==W.Ethereum?{...Ty({chain:t}),blockExplorerUrls:[y],chainId:u,rpcUrls:n}:void 0}}function Gt(t){return![W.Adi,W.Arbitrum,W.BinanceSmartChain].includes(t)}function Ty({chain:t}){let{name:y,nativeCurrency:u,baseDecimal:n}=I(t);return Lt(t).with(W.Arbitrum,()=>({chainName:"Arbitrum One",nativeCurrency:{decimals:n,name:"Ethereum",symbol:W.Ethereum}})).with(W.Aurora,()=>({chainName:"Aurora Mainnet",nativeCurrency:{decimals:n,name:"Ethereum",symbol:W.Ethereum}})).with(W.Avalanche,()=>({chainName:"Avalanche Network",nativeCurrency:{decimals:n,name:"Avalanche",symbol:t}})).with(W.Base,()=>({chainName:"Base Mainnet",nativeCurrency:{decimals:n,name:"Ethereum",symbol:W.Ethereum}})).with(W.Berachain,()=>({chainName:"Berachain",nativeCurrency:{decimals:n,name:"Berachain",symbol:"BERA"}})).with(W.XLayer,()=>({chainName:"X Layer",nativeCurrency:{decimals:n,name:"OKB",symbol:"OKB"}})).with(W.BinanceSmartChain,()=>({chainName:"BNB Smart Chain Mainnet",nativeCurrency:{decimals:n,name:"Binance Coin",symbol:"BNB"}})).with(W.Gnosis,()=>({chainName:"Gnosis",nativeCurrency:{decimals:n,name:"xDAI",symbol:"XDAI"}})).with(W.Optimism,()=>({chainName:"OP Mainnet",nativeCurrency:{decimals:n,name:"Ethereum",symbol:W.Ethereum}})).with(W.Polygon,()=>({chainName:"Polygon Mainnet",nativeCurrency:{decimals:n,name:"Polygon",symbol:W.Polygon}})).otherwise(()=>({chainName:y,nativeCurrency:{decimals:n,name:u,symbol:u}}))}async function Bt(t,y){if(!("authorize"in t))throw Error("Signer does not support EIP-7702 authorization. Requires ethers.js v6.14+");let u={...y,nonce:y.nonce!==void 0?BigInt(y.nonce):void 0};return await t.authorize(u)}var Mt=(t)=>typeof t==="string"&&/^0x[a-fA-F0-9]{64}$/.test(t),ly=(t)=>{try{return typeof t==="string"&&!!Dt(t)}catch{return!1}};function by(t,y){let u=y!==void 0?`index ${y}: `:"",n=(T,l)=>{throw new K({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{field:T,message:`${u}${l}`}})};Lt(t).when(({chainId:T})=>typeof T!=="bigint",()=>n("chainId","chainId must be a bigint")).when(({address:T})=>!ly(T),()=>n("address","address must be a valid checksummed address")).when(({nonce:T})=>typeof T!=="bigint"||T<0n,()=>n("nonce","nonce must be a non-negative bigint")).when(({signature:T})=>!T,()=>n("signature","signature is required")).when(({signature:T})=>typeof T?.yParity!=="number"||![0,1].includes(T.yParity),()=>n("signature.yParity","yParity must be 0 or 1")).when(({signature:T})=>!Mt(T?.r),()=>n("signature.r","r must be a 32-byte hex string")).when(({signature:T})=>!Mt(T?.s),()=>n("signature.s","s must be a 32-byte hex string")).otherwise(()=>{})}function My(t){return[{key:"name",type:"string"},{key:"version",type:"string"},{key:"chainId",type:"uint256"},{key:"verifyingContract",type:"address"},{key:"salt",type:"bytes32"}].filter(({key:y})=>t[y]!=null).map(({key:y,type:u})=>({name:y,type:u}))}function e(t){return t.charAt(0).toUpperCase()+t.slice(1)}function i(t,y){if(t.isTuple()&&t.components){let u=e(t.name);return y[u]=t.components.map((n)=>({name:n.name,type:i(n,y)})),u}if(t.isArray()){let u=t.arrayChildren;if(u?.isTuple()&&u.components){let n=e(t.name.replace(/s$/,""));return y[n]=u.components.map((T)=>({name:T.name,type:i(T,y)})),`${n}[]`}return`${u?.type??"bytes"}[]`}return t.type}function a(t,y){if(typeof t==="bigint")return t;if(y?.isTuple()&&typeof t?.toObject==="function"){let u=t.toObject(),n={};for(let[T,l]of(y.components??[]).entries())n[l.name]=a(u[l.name]??t[T],l);return n}if(Array.isArray(t)){let u=y?.arrayChildren;return t.map((n)=>a(n,u??void 0))}return t}function vy({chain:t,abi:y,data:u,to:n}){let l=new yy(y).parseTransaction({data:u});if(!l)throw new K({errorKey:"toolbox_evm_invalid_params",info:{error:"Could not decode calldata"}});let b={},M=e(l.name);b[M]=l.fragment.inputs.map((D)=>({name:D.name,type:i(D,b)}));let R={};for(let[D,w]of l.fragment.inputs.entries())R[w.name]=a(l.args[D],w);let{chainId:G}=I(t),q={chainId:Number(G),verifyingContract:Dt(n)},X=My(q);return{domain:q,message:R,primaryType:M,types:{EIP712Domain:X,...b}}}function Ht(t,y){if(!Array.isArray(t)||t.length===0)throw new K({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{message:"EIP-7702 transactions require at least one authorization"}});for(let[u,n]of t.entries())if(by(n,u),y!==void 0&&n.chainId!==y)throw new K({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{field:"chainId",message:`index ${u}: authorization chainId (${n.chainId}) does not match transaction chainId (${y})`}})}import{Chain as U,FeeOption as jy}from"@swapkit/helpers";import{HDNodeWallet as Ny}from"ethers";import{match as Sy,P as Jt}from"ts-pattern";var wt=[{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"aggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes[]",name:"returnData",type:"bytes[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"blockAndAggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes32",name:"blockHash",type:"bytes32"},{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBlockNumber",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockCoinbase",outputs:[{internalType:"address",name:"coinbase",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockDifficulty",outputs:[{internalType:"uint256",name:"difficulty",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockGasLimit",outputs:[{internalType:"uint256",name:"gaslimit",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"addr",type:"address"}],name:"getEthBalance",outputs:[{internalType:"uint256",name:"balance",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"requireSuccess",type:"bool"},{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"tryAggregate",outputs:[{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"requireSuccess",type:"bool"},{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"tryBlockAndAggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes32",name:"blockHash",type:"bytes32"},{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"}];import{AssetValue as Dy,applyFeeMultiplierToBigInt as $,Chain as _,EVMChains as Ly,FeeOption as L,isGasAsset as Ry,SwapKitError as B,SwapKitNumber as m}from"@swapkit/helpers";import{erc20ABI as o}from"@swapkit/helpers/contracts";import{BrowserProvider as qy,Contract as Ut,getAddress as p,Interface as Qt}from"ethers";import{match as Xt}from"ts-pattern";function C(t){return{getBalance:Wt(t)}}function ey(t){return t}var tt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function c({chain:t=_.Ethereum,provider:y,signer:u,isEIP1559Compatible:n=!0}){return{approve:Yy({chain:t,isEIP1559Compatible:n,provider:y,signer:u}),approvedAmount:Yt({chain:t,provider:y}),broadcastTransaction:y.broadcastTransaction,call:ut({chain:t,isEIP1559Compatible:n,provider:y,signer:u}),createApprovalTx:ky({chain:t,provider:y,signer:u}),createContract:By({chain:t,provider:y}),createContractTxObject:x({chain:t,provider:y}),createTransaction:r({chain:t,provider:y,signer:u}),createTransferTx:r({chain:t,provider:y,signer:u}),EIP1193SendTransaction:h(y),estimateCall:Zt({provider:y,signer:u}),estimateGasLimit:$y({chain:t,provider:y,signer:u}),estimateGasPrices:F({chain:t,isEIP1559Compatible:n,provider:y}),estimateTransactionFee:_y({chain:t,isEIP1559Compatible:n,provider:y}),getAddress:()=>{return u?u.getAddress():void 0},getBalance:C(t).getBalance,getNetworkParams:qt(t),isApproved:Xy({chain:t,provider:y}),sendTransaction:zt({chain:t,isEIP1559Compatible:n,provider:y,signer:u}),signAuthorization:zy({signer:u}),signMessage:u?(T)=>u.signMessage(T):void 0,signTypedData:u?({domain:T,types:l,value:b})=>u.signTypedData(T,l,b):void 0,transfer:Zy({chain:t,isEIP1559Compatible:n,provider:y,signer:u}),validateAddress:Gy}}function Gy(t){try{return p(t),!0}catch{return!1}}function v(t){return t instanceof qy}function yt(t,y,u){return new Ut(t,Qt.from(y),u)}function By({provider:t}){return function(u,n){return new Ut(u,Qt.from(n),t)}}var Hy=["payable","nonpayable"];function wy({abi:t,funcName:y}){let u=t.find((n)=>n.name===y);if(!u)throw new B("toolbox_evm_no_abi_fragment",{funcName:y});return u.stateMutability&&Hy.includes(u.stateMutability)}function Tu(t){return p(t)}function h(t){return function({value:u,...n}){if(!v(t))throw new B("toolbox_evm_provider_not_eip1193_compatible");let{gasLimit:T,gasPrice:l,maxFeePerGas:b,maxPriorityFeePerGas:M,...R}=n;return t.send("eth_sendTransaction",[{...R,value:P(BigInt(u||0))}])}}function lu(t,y){let u=d(t,y);if(u)return p(u.toLowerCase());throw new B("toolbox_evm_invalid_gas_asset_address")}var Wy=Ly.reduce((t,y)=>{return t[y]="0x0000000000000000000000000000000000000000",t},{}),Uy={...Wy,[_.Optimism]:"0x4200000000000000000000000000000000000042",[_.Polygon]:"0x0000000000000000000000000000000000001010"},Qy=[_.Arbitrum,_.Aurora,_.Base,_.Optimism];function d({chain:t,symbol:y,ticker:u},n){try{let T=t===_.BinanceSmartChain&&y==="BNB"&&u==="BNB",l=t===_.Hyperevm&&y==="HYPE"&&u==="HYPE",b=t===n&&y===n&&u===n,M=Qy.includes(t)&&y==="ETH"&&u==="ETH";if(b||T||l||M)return Uy[n];return p(y.slice(u.length+1).replace(/^0X/,""))}catch{return null}}function x({provider:t}){return async({contractAddress:y,abi:u,funcName:n,funcParams:T=[],txOverrides:l})=>yt(y,u,t).getFunction(n).populateTransaction(...T.concat(l).filter((b)=>typeof b<"u"))}function F({chain:t,provider:y,isEIP1559Compatible:u=!0}){return Xt(t).with(_.Gnosis,()=>{return async function(){try{let{gasPrice:T,maxPriorityFeePerGas:l}=await y.getFeeData();if(!T||l===null)throw new B("toolbox_evm_no_fee_data");return{[L.Average]:{maxFeePerGas:$(T,L.Average),maxPriorityFeePerGas:$(l,L.Average)},[L.Fast]:{maxFeePerGas:$(T,L.Fast),maxPriorityFeePerGas:$(l,L.Fast)},[L.Fastest]:{maxFeePerGas:$(T,L.Fastest),maxPriorityFeePerGas:$(l,L.Fastest)}}}catch(T){throw new B("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}}).with(_.Arbitrum,()=>{return async function(){try{let{gasPrice:T}=await y.getFeeData();if(!T)throw new B("toolbox_evm_no_fee_data");let l=T*12n/10n;return{[L.Average]:{gasPrice:l},[L.Fast]:{gasPrice:$(l,L.Fast)},[L.Fastest]:{gasPrice:$(l,L.Fastest)}}}catch(T){throw new B("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}}).otherwise(()=>{return async function(){try{let{maxFeePerGas:T,maxPriorityFeePerGas:l,gasPrice:b}=await y.getFeeData();if(u){if(T===null||l===null)throw new B("toolbox_evm_no_fee_data");return{[L.Average]:{maxFeePerGas:T,maxPriorityFeePerGas:l},[L.Fast]:{maxFeePerGas:$(T,L.Fast),maxPriorityFeePerGas:$(l,L.Fast)},[L.Fastest]:{maxFeePerGas:$(T,L.Fastest),maxPriorityFeePerGas:$(l,L.Fastest)}}}if(!b)throw new B("toolbox_evm_no_gas_price");return{[L.Average]:{gasPrice:b},[L.Fast]:{gasPrice:$(b,L.Fast)},[L.Fastest]:{gasPrice:$(b,L.Fastest)}}}catch(T){throw new B("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}})}function ut({provider:t,isEIP1559Compatible:y,signer:u,chain:n}){return async function({callProvider:l,contractAddress:b,abi:M,funcName:R,funcParams:G=[],txOverrides:q={},feeOption:X=L.Fast}){let D=l||t;if(!b)throw new B("toolbox_evm_invalid_params",{error:"contractAddress must be provided"});let w=wy({abi:M,funcName:R});if(w&&v(D)&&u){let z=x({chain:n,provider:D}),k=q?.from||await u?.getAddress(),f=await z({abi:M,contractAddress:b,funcName:R,funcParams:G,txOverrides:{...q,from:k}});return h(D)(f)}let Y=yt(b,M,D);if(w){if(!u)throw new B("toolbox_evm_no_signer");let z=q?.from||await u.getAddress();if(!z)throw new B("toolbox_evm_no_signer_address");let k=Y.connect(u),f=F({chain:n,isEIP1559Compatible:y,provider:t}),{maxFeePerGas:N,maxPriorityFeePerGas:A,gasPrice:V}=(await f())[X],E=await Y.getFunction(R).estimateGas(...G,q),J=await k[R](...G,{...q,gasLimit:E,gasPrice:V,maxFeePerGas:N,maxPriorityFeePerGas:A,nonce:q?.nonce||await D.getTransactionCount(z)});return typeof J?.hash==="string"?J?.hash:J}let Z=await Y[R]?.(...G);return typeof Z?.hash==="string"?Z?.hash:Z}}function Yt({provider:t,chain:y}){return function({assetAddress:n,spenderAddress:T,from:l}){return ut({chain:y,isEIP1559Compatible:!0,provider:t})({abi:o,contractAddress:n,funcName:"allowance",funcParams:[l,T]})}}function Xy({provider:t,chain:y}){return async function({assetAddress:n,spenderAddress:T,from:l,amount:b=tt}){let M=await Yt({chain:y,provider:t})({assetAddress:n,from:l,spenderAddress:T});return m.fromBigInt(M).gte(m.fromBigInt(BigInt(b)))}}function Yy({signer:t,isEIP1559Compatible:y=!0,provider:u,chain:n}){return async function({assetAddress:l,spenderAddress:b,feeOptionKey:M=L.Fast,amount:R,gasLimitFallback:G,from:q,nonce:X}){let D=[b,BigInt(R||tt)],w=await t?.getAddress()||q,Y={abi:o,contractAddress:l,funcName:"approve",funcParams:D,signer:t,txOverrides:{from:w}};if(v(u)){let z=x({chain:n,provider:u}),k=h(u),f=await z(Y);return k(f)}return ut({chain:n,isEIP1559Compatible:y,provider:u,signer:t})({...Y,feeOption:M,funcParams:D,txOverrides:{from:w,gasLimit:G?BigInt(G.toString()):void 0,nonce:X}})}}function Zy({signer:t,isEIP1559Compatible:y=!0,provider:u}){return async function({assetValue:T,memo:l,recipient:b,feeOptionKey:M=L.Fast,sender:R,...G}){let{hexlify:q,toUtf8Bytes:X}=await import("ethers"),D=T.getBaseValue("bigint"),w=T.chain,Y=R||await t?.getAddress(),Z=zt({chain:w,isEIP1559Compatible:y,provider:u,signer:t});if(!Y)throw new B("toolbox_evm_no_from_address");if(T.isGasAsset){let V={...G,data:q(X(l||"")),feeOptionKey:M,from:Y,to:b,value:D};return Z(V)}if(!d(T,w))throw new B("toolbox_evm_no_contract_address");let{maxFeePerGas:k,maxPriorityFeePerGas:f,gasPrice:N}=(await F({chain:w,isEIP1559Compatible:y,provider:u})())[M],A=await r({chain:w,provider:u,signer:t})({assetValue:T,data:q(X(l||"")),gasPrice:N,maxFeePerGas:k,maxPriorityFeePerGas:f,memo:l,recipient:b,sender:Y});return Z(A)}}function Zt({provider:t,signer:y}){return function({contractAddress:n,abi:T,funcName:l,funcParams:b=[],txOverrides:M}){if(!n)throw new B("toolbox_evm_no_contract_address");let R=yt(n,T,t);return y?R.connect(y).getFunction(l).estimateGas(...b,M):R.getFunction(l).estimateGas(...b,M)}}function $y({provider:t,signer:y}){return async function({assetValue:n,recipient:T,memo:l,data:b,sender:M,funcName:R,funcParams:G,txOverrides:q}){let X=n.bigIntValue,D=n.isGasAsset?null:d(n,n.chain);if(D&&R)return Zt({provider:t,signer:y})({abi:o,contractAddress:D,funcName:R,funcParams:G,txOverrides:q});let{hexlify:w,toUtf8Bytes:Y}=await import("ethers");return t.estimateGas({data:b?b:l?w(Y(l)):void 0,from:M,to:T,value:X})}}function zy({signer:t}){if(!t)return;return(y)=>Bt(t,y)}var $t=(t)=>t.type===4||(t.authorizations?.length??0)>0,Jy=(t)=>!$t(t)&&(t.type===2||!!t.maxFeePerGas||!!t.maxPriorityFeePerGas),fy=(t,y=!0)=>{if($t(t))return"eip7702";if(Jy(t)||y)return"eip1559";return"legacy"};function zt({provider:t,signer:y,isEIP1559Compatible:u=!0,chain:n}){return async function({feeOptionKey:l=L.Fast,...b}){let{from:M,to:R,data:G,value:q,...X}=b;if(!y)throw new B("toolbox_evm_no_signer");if(!R)throw new B("toolbox_evm_no_to_address");let D={...X,data:G||"0x",from:M,to:R,value:BigInt(q||0)};if(v(t))return h(t)(D);let w=M||await y.getAddress(),Y=b.nonce||await t.getTransactionCount(w),Z=(await t.getNetwork()).chainId,z=fy(D,u);if(z==="eip7702")Ht(D.authorizations||[],Z);let k=Xt(z).with("eip7702",()=>4).with("eip1559",()=>2).otherwise(()=>0),f={...D,chainId:Z,nonce:Y,type:k,...z==="eip7702"&&{authorizationList:D.authorizations}},N=F({chain:n,isEIP1559Compatible:u,provider:t}),V=z!=="legacy"&&!(D.maxFeePerGas&&D.maxPriorityFeePerGas)||!D.gasPrice?Object.entries((await N())[l]).reduce((J,[O,bt])=>({...J,[O]:P(BigInt(bt))}),{}):{},E;try{E=P(D.gasLimit||await t.estimateGas(f)*11n/10n)}catch(J){throw new B("toolbox_evm_error_estimating_gas_limit",{error:J})}try{let J={...f,gasLimit:E,...V};try{return(await y.sendTransaction(J)).hash}catch{let O=await y.signTransaction({...J,from:w});return(await t.broadcastTransaction(O)).hash}}catch(J){throw new B("toolbox_evm_error_sending_transaction",{error:J})}}}function r({provider:t,signer:y}){return async function({assetValue:n,memo:T,recipient:l,data:b,sender:M,maxFeePerGas:R,maxPriorityFeePerGas:G,gasPrice:q,...X}){let D=n.getBaseValue("bigint"),w=n.chain,Y=M||await y?.getAddress();if(!Y)throw new B("toolbox_evm_no_from_address");if(Ry(n)){let{hexlify:k,toUtf8Bytes:f}=await import("ethers");return{...X,data:b||k(f(T||"")),from:Y,to:l,value:D}}let Z=d(n,w);if(!Z)throw new B("toolbox_evm_no_contract_address");return x({chain:n.chain,provider:t})({abi:o,contractAddress:Z,funcName:"transfer",funcParams:[l,D],txOverrides:{from:Y,gasPrice:q,maxFeePerGas:R,maxPriorityFeePerGas:G}})}}function ky({provider:t,signer:y,chain:u}){return async function({assetAddress:T,spenderAddress:l,amount:b,from:M}){let R=await y?.getAddress()||M,G=x({chain:u,provider:t}),q=["bigint","number"].includes(typeof b)?b:b||tt;return await G({abi:o,contractAddress:T,funcName:"approve",funcParams:[l,BigInt(q)],txOverrides:{from:R}})}}function _y({provider:t,isEIP1559Compatible:y=!0,chain:u}){return async function({feeOption:T=L.Fast,...l}){let M=await F({chain:u,isEIP1559Compatible:y,provider:t})(),R=await t.estimateGas(l),G=Dy.from({chain:u}),{gasPrice:q,maxFeePerGas:X,maxPriorityFeePerGas:D}=M[T];if(!y&&q)return G.set(m.fromBigInt(q*R,G.decimal));if(X&&D){let w=(X+D)*R;return G.set(m.fromBigInt(w,G.decimal))}throw new B("toolbox_evm_no_gas_price")}}function ft(t){let y=Q(U.Ethereum)(t);async function u(n,T="0x5ba1e12693dc8f9c48aad8770482f4739beed696",l="aggregate",b=jy.Fast){let M=await y.createContractTxObject({abi:wt,contractAddress:T,funcName:l,funcParams:[n]});return y.sendTransaction({...M,feeOptionKey:b})}return{...y,multicall:u}}var kt=Q(U.Adi),_t=Q(U.Arbitrum),jt=Q(U.Aurora),Nt=Q(U.Avalanche),St=Q(U.Base),Vt=Q(U.Berachain),Kt=Q(U.BinanceSmartChain),Bu=Q(U.Botanix),ot=Q(U.Core),xt=Q(U.Corn),Ft=Q(U.Cronos),At=Q(U.Gnosis),Et=Q(U.Hyperevm),Ot=Q(U.Linea),It=Q(U.Polygon),Pt=Q(U.MegaETH),Ct=Q(U.Monad),mt=Q(U.Plasma),nt=Q(U.Sonic),gt=Q(U.Unichain),pt=Q(U.XLayer);function Q(t){return function({provider:u,...n}){let T=Gt(t),l=Sy(n).with({phrase:Jt.string},({phrase:M})=>Ny.fromPhrase(M).connect(u)).with({signer:Jt.any},({signer:M})=>M).otherwise(()=>{return});return c({chain:t,isEIP1559Compatible:T,provider:u,signer:l})}}import{applyFeeMultiplierToBigInt as S,Chain as Ky,FeeOption as j,SwapKitError as Tt}from"@swapkit/helpers";import{Contract as oy,HDNodeWallet as xy}from"ethers";import{match as Fy,P as vt}from"ts-pattern";var ct=[{inputs:[{internalType:"address",name:"_owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"DecimalsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"GasPriceUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"L1BaseFeeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"OverheadUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"ScalarUpdated",type:"event"},{inputs:[],name:"decimals",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"gasPrice",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"_data",type:"bytes"}],name:"getL1Fee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"_data",type:"bytes"}],name:"getL1GasUsed",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"l1BaseFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"overhead",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"scalar",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_decimals",type:"uint256"}],name:"setDecimals",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_gasPrice",type:"uint256"}],name:"setGasPrice",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_baseFee",type:"uint256"}],name:"setL1BaseFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_overhead",type:"uint256"}],name:"setOverhead",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_scalar",type:"uint256"}],name:"setScalar",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];var Ay="0x420000000000000000000000000000000000000f";function lt(t){return new oy(Ay,ct,t)}function ht(t){return async function(){let u=lt(t);if(u&&"l1BaseFee"in u)return await u?.l1BaseFee();return}}function dt(t){return async function({from:u,to:n,nonce:T,...l}){let{Transaction:b}=await import("ethers");if(!n)throw new Tt("toolbox_evm_invalid_transaction",{error:"Missing to address"});return b.from({...l,authorizationList:l.authorizationList,nonce:T?T:u?await t.getTransactionCount(u):0,to:n}).serialized}}function st(t){return async function(u){let n=lt(t),T=await dt(t)(u);if(n&&"getL1Fee"in n)return n.getL1Fee(T)}}function et(t){return async function(u){let T=(await t.getFeeData()).gasPrice??0n,l=await t.estimateGas(u);return T*l}}function Ey(t){return async function(u){let n=await st(t)(u)??0n,T=await et(t)(u);return n+T}}function Oy(t){return async function(u){let n=lt(t),T=await dt(t)(u);if(n&&"getL1GasUsed"in n)return n.getL1GasUsed(T)}}function Iy(t){return async function(){try{let{maxFeePerGas:u,maxPriorityFeePerGas:n,gasPrice:T}=await t.getFeeData(),l=await ht(t)(),b=T;if(!(u&&n))throw new Tt("toolbox_evm_no_fee_data");return{[j.Average]:{gasPrice:b,l1GasPrice:l,maxFeePerGas:u,maxPriorityFeePerGas:n},[j.Fast]:{gasPrice:S(b,j.Fast),l1GasPrice:S(l||0n,j.Fast),maxFeePerGas:u,maxPriorityFeePerGas:S(n,j.Fast)},[j.Fastest]:{gasPrice:S(b,j.Fastest),l1GasPrice:S(l||0n,j.Fastest),maxFeePerGas:u,maxPriorityFeePerGas:S(n,j.Fastest)}}}catch(u){throw new Tt("toolbox_evm_gas_estimation_error",{error:u.msg??u.toString()})}}}function it({provider:t,...y}){let u=Fy(y).with({phrase:vt.string},({phrase:l})=>xy.fromPhrase(l).connect(t)).with({signer:vt.any},({signer:l})=>l).otherwise(()=>{return}),n=c({provider:t,signer:u}),T=ht(t);return{...n,estimateGasPrices:Iy(t),estimateL1Gas:Oy(t),estimateL1GasCost:st(t),estimateL2GasCost:et(t),estimateTotalGasCost:Ey(t),getBalance:C(Ky.Optimism).getBalance,getL1GasPrice:T}}function Cy(t,y){return Py(t).with(H.Adi,()=>kt(y)).with(H.Arbitrum,()=>_t(y)).with(H.Aurora,()=>jt(y)).with(H.Avalanche,()=>Nt(y)).with(H.Base,()=>St(y)).with(H.Berachain,()=>Vt(y)).with(H.BinanceSmartChain,()=>Kt(y)).with(H.Botanix,()=>nt(y)).with(H.Core,()=>ot(y)).with(H.Corn,()=>xt(y)).with(H.Cronos,()=>Ft(y)).with(H.Ethereum,()=>ft(y)).with(H.Gnosis,()=>At(y)).with(H.Hyperevm,()=>Et(y)).with(H.Linea,()=>Ot(y)).with(H.MegaETH,()=>Pt(y)).with(H.Monad,()=>Ct(y)).with(H.Optimism,()=>it(y)).with(H.Plasma,()=>mt(y)).with(H.Polygon,()=>It(y)).with(H.Sonic,()=>nt(y)).with(H.Unichain,()=>gt(y)).with(H.XLayer,()=>pt(y)).exhaustive()}async function ku(t,y){let u={...y,provider:y?.provider||Rt(t)};return Cy(t,u)}
|
|
2
|
+
export{C as b,ey as c,ny as d,cy as e,Rt as f,P as g,qt as h,Gt as i,Bt as j,by as k,My as l,vy as m,Ht as n,tt as o,c as p,Gy as q,v as r,yt as s,By as t,wy as u,Tu as v,h as w,lu as x,Uy as y,d as z,x as A,F as B,$t as C,Jy as D,fy as E,ft as F,kt as G,_t as H,jt as I,Nt as J,St as K,Vt as L,Kt as M,Bu as N,ot as O,xt as P,Ft as Q,At as R,Et as S,Ot as T,It as U,Pt as V,Ct as W,mt as X,nt as Y,gt as Z,pt as _,it as $,Cy as aa,ku as ba};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{AssetValue as o,getChainConfig as l}from"@swapkit/helpers";import{SwapKitApi as m}from"@swapkit/helpers/api";var d=typeof process<"u"&&process.pid?process.pid.toString(36):"",i=0;function C(){function t(){let e=Date.now(),n=i||e;return i=n,e>i?e:n+1}return d+t().toString(36)}function h(t){return async function(n,r=!0){let c=await m.getChainBalance({address:n,chain:t,scamFilter:r}),{baseDecimal:p}=l(t),s=c.map(({identifier:a,value:u,decimal:f})=>{return new o({decimal:f||p,identifier:a,value:u})});if(!s.some((a)=>a.isGasAsset))return[o.from({chain:t}),...s];return s}}
|
|
2
|
+
export{C as ca,h as da};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as N,A as m,B as n,C as o,D as p,E as q,F as r,G as s,H as t,I as u,J as v,K as w,L as x,M as y,N as z,O as A,P as B,Q as C,R as D,S as E,T as F,U as G,V as H,W as I,X as J,Y as K,Z as L,_ as M,aa as O,ba as P,o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i,x as j,y as k,z as l}from"./chunk-4q573g5z.js";import"./chunk-54gntgt1.js";import"./chunk-ntbvmmch.js";export{c as validateEVMAddress,h as toChecksumAddress,g as isStateChangingCall,o as isEIP7702Transaction,p as isEIP1559Transaction,d as isBrowserProvider,l as getTokenAddress,P as getEvmToolboxAsync,O as getEvmToolbox,n as getEstimateGasPrices,q as getEVMTxType,i as getEIP1193SendTransaction,m as getCreateContractTxObject,f as getCreateContract,j as getChecksumAddressFromAsset,e as createContract,M as XLayerToolbox,L as UNIToolbox,K as SONICToolbox,J as PLASMAToolbox,N as OPToolbox,I as MONADToolbox,H as MEGAETHToolbox,a as MAX_APPROVAL,G as MATICToolbox,F as LINEAToolbox,E as HYPEREVMToolbox,D as GNOToolbox,r as ETHToolbox,k as ContractAddress,C as CROToolbox,B as CORNToolbox,A as COREToolbox,z as BotanixToolbox,b as BaseEVMToolbox,y as BSCToolbox,x as BERAToolbox,w as BASEToolbox,v as AVAXToolbox,u as AURORAToolbox,t as ARBToolbox,s as ADIToolbox};
|
package/dist/src/aptos/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ea as E}from"../../chunk-ntbvmmch.js";import{AssetValue as T,Chain as p,derivationPathToString as L,getChainConfig as P,getRPCUrlSync as v,NetworkDerivationPath as M,SwapKitError as o}from"@swapkit/helpers";import{match as C,P as B}from"ts-pattern";var g={COIN_TYPE:"0x1::aptos_coin::AptosCoin",FUNGIBLE_ASSET_METADATA:"0x1::fungible_asset::Metadata",FUNGIBLE_STORE_TRANSFER:"0x1::primary_fungible_store::transfer",TRANSFER:"0x1::aptos_account::transfer"},O=/^[0-9a-fA-F]+$/;function h(c){if(!c||typeof c!=="string"||!c.startsWith("0x"))return!1;let d=c.slice(2);if(d.length===0||d.length>64)return!1;return O.test(d)}function k({derivationPath:c,provider:d,...l}={}){let u,y=L(c||M[p.Aptos],{allHardened:!0});async function f(){if(u)return u;return u=await C(l).with({phrase:B.string},async({phrase:n})=>{let{Ed25519Account:t}=await import("@aptos-labs/ts-sdk");return t.fromDerivationPath({mnemonic:n,path:y})}).with({signer:B.any},({signer:n})=>n).otherwise(()=>{return}),u}async function A(){let{Aptos:n,AptosConfig:t,Network:s}=await import("@aptos-labs/ts-sdk"),r=new t({clientConfig:{http2:!1},fullnode:d||v(p.Aptos),network:s.MAINNET});return new n(r)}async function b(){return(await f())?.accountAddress.toString()||""}async function F(n){let t=n||await b();if(!t)throw new o("toolbox_aptos_address_required");let{baseDecimal:s,chain:r}=P(p.Aptos);try{let e=await A(),i=await e.getAccountAPTAmount({accountAddress:t}),m=[T.from({chain:r,fromBaseDecimal:s,value:i.toString()})],w=await e.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:t}}}});for(let a of w){if(a.asset_type===g.COIN_TYPE||Number(a.amount)<=0)continue;let _=a.asset_type;if(_){let U=("metadata"in a&&typeof a.metadata==="object"&&a.metadata!==null?a.metadata:void 0)?.decimals??s;m.push(T.from({asset:`${p.Aptos}.APT-${_}`,fromBaseDecimal:U,value:String(a.amount)}))}}return m}catch{return[T.from({chain:r})]}}async function D(n){if(!n){let{baseDecimal:w}=P(p.Aptos),a=d||v(p.Aptos),_=await fetch(`${a}/estimate_gas_price`),{gas_estimate:x}=await _.json();return T.from({chain:p.Aptos,fromBaseDecimal:w,value:String(x)})}let t=await f();if(!t)throw new o("toolbox_aptos_no_signer");let s=await S(n),r=await A(),[e]=await r.transaction.simulate.simple({signerPublicKey:t.publicKey,transaction:s});if(!e)throw new o("toolbox_aptos_transaction_creation_error");let i=BigInt(e.gas_used)*BigInt(e.gas_unit_price),{baseDecimal:m}=P(p.Aptos);return T.from({chain:p.Aptos,fromBaseDecimal:m,value:i.toString()})}async function S({recipient:n,assetValue:t,maxGasAmount:s,sender:r}){if(!h(n))throw new o("core_transaction_invalid_recipient_address");let e=r||await b();if(!e)throw new o("toolbox_aptos_no_sender");let{AccountAddress:i}=await import("@aptos-labs/ts-sdk"),m=await A(),w=i.from(e);try{let a=t.isGasAsset?g.TRANSFER:g.FUNGIBLE_STORE_TRANSFER,_=C({address:t?.address,isGasAsset:t.isGasAsset}).with({isGasAsset:!0},()=>[i.from(n),t.getBaseValue("bigint")]).with({address:B.string},({address:x})=>[i.from(x),i.from(n),t.getBaseValue("bigint")]).otherwise(()=>null);if(!_)throw new o("toolbox_aptos_missing_asset_type");return m.transaction.build.simple({data:{function:a,functionArguments:_,typeArguments:t.isGasAsset?[]:[g.FUNGIBLE_ASSET_METADATA]},options:s?{maxGasAmount:s}:void 0,sender:w})}catch(a){if(a instanceof o)throw a;throw new o("toolbox_aptos_transaction_creation_error",a)}}async function R(n){let t=await f();if(!t)throw new o("toolbox_aptos_no_signer");return(await A()).transaction.sign({signer:t,transaction:n})}async function G({assetValue:n,maxGasAmount:t,recipient:s}){let r=await f();if(!r)throw new o("toolbox_aptos_no_signer");if(!h(s))throw new o("core_transaction_invalid_recipient_address");try{let e=r.accountAddress.toString(),i=await S({assetValue:n,maxGasAmount:t,recipient:s,sender:e});return(await(await A()).signAndSubmitTransaction({signer:r,transaction:i})).hash}catch(e){if(e instanceof o)throw e;throw new o("toolbox_aptos_transaction_creation_error",e)}}async function N({senderAuthenticator:n,transaction:t}){try{return(await(await A()).transaction.submit.simple({senderAuthenticator:n,transaction:t})).hash}catch(s){throw new o("toolbox_aptos_broadcast_error",s)}}async function I(n){let t=await R(n);return N({senderAuthenticator:t,transaction:n})}return{broadcastTransaction:N,createTransaction:S,estimateTransactionFee:D,getAddress:b,getBalance:F,signAndBroadcastTransaction:I,signTransaction:R,transfer:G,validateAddress:h}}function $({provider:c}){return async function({assetValue:l,recipient:u}){if(!h(u))throw new o("core_transaction_invalid_recipient_address");let{AccountAddress:y}=await import("@aptos-labs/ts-sdk");if(l.isGasAsset)return(await c.signAndSubmitTransaction({arguments:[y.from(u).toString(),l.getBaseValue("string")],function:g.TRANSFER,type:"entry_function_payload",type_arguments:[]})).hash;let f=l.address;if(!f)throw new o("toolbox_aptos_missing_asset_type");return(await c.signAndSubmitTransaction({arguments:[f,y.from(u).toString(),l.getBaseValue("string")],function:g.FUNGIBLE_STORE_TRANSFER,type:"entry_function_payload",type_arguments:[g.FUNGIBLE_ASSET_METADATA]})).hash}}export{h as validateAptosAddress,k as getAptosToolbox,$ as createAptosExtensionTransfer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var XG=Object.create;var{getPrototypeOf:jG,defineProperty:
|
|
1
|
+
var XG=Object.create;var{getPrototypeOf:jG,defineProperty:E,getOwnPropertyNames:d,getOwnPropertyDescriptor:WG}=Object,i=Object.prototype.hasOwnProperty;function n(G){return this[G]}var qG,FG,UG=(G,J,Q)=>{var z=G!=null&&typeof G==="object";if(z){var W=J?qG??=new WeakMap:FG??=new WeakMap,F=W.get(G);if(F)return F}Q=G!=null?XG(jG(G)):{};let Z=J||!G||!G.__esModule?E(Q,"default",{value:G,enumerable:!0}):Q;for(let U of d(G))if(!i.call(Z,U))E(Z,U,{get:n.bind(G,U),enumerable:!0});if(z)W.set(G,Z);return Z},YG=(G)=>{var J=(c??=new WeakMap).get(G),Q;if(J)return J;if(J=E({},"__esModule",{value:!0}),G&&typeof G==="object"||typeof G==="function"){for(var z of d(G))if(!i.call(J,z))E(J,z,{get:n.bind(G,z),enumerable:!(Q=WG(G,z))||Q.enumerable})}return c.set(G,J),J},c;var MG=(G)=>G;function RG(G,J){this[G]=MG.bind(null,J)}var DG=(G,J)=>{for(var Q in J)E(G,Q,{get:J[Q],enumerable:!0,configurable:!0,set:RG.bind(J,Q)})};var o=(G,J)=>()=>(G&&(J=G(G=0)),J);async function p(G,J){let Q=await fetch(`${JG}${G}`,{...J,headers:{project_id:GG,...J?.headers}});if(!Q.ok)throw Error(`Blockfrost API error: ${Q.status} ${Q.statusText}`);return Q.json()}async function QG(G){try{return await p(`/addresses/${G}/utxos`)}catch{return[]}}async function HG(){return(await p("/blocks/latest")).slot}async function OG(){let G=await p("/epochs/latest/parameters"),J={PlutusScriptV1:G.cost_models.PlutusV1?Object.values(G.cost_models.PlutusV1):[],PlutusScriptV2:G.cost_models.PlutusV2?Object.values(G.cost_models.PlutusV2):[],PlutusScriptV3:G.cost_models.PlutusV3?Object.values(G.cost_models.PlutusV3):[]};return{collateralPercent:new q.default(G.collateral_percent),languageView:J,maxValueSize:Number.parseInt(G.max_val_size,10),minFeeA:new q.default(G.min_fee_a),minFeeB:new q.default(G.min_fee_b),minFeeRefScriptCostPerByte:new q.default(15),priceMem:new q.default(G.price_mem),priceSteps:new q.default(G.price_step),stakeKeyDeposit:new q.default(2000000),utxoCostPerByte:new q.default(G.coins_per_utxo_size)}}async function r(G){let J=await fetch(`${JG}/tx/submit`,{body:Buffer.from(G,"hex"),headers:{"Content-Type":"application/cbor",project_id:GG},method:"POST"});if(!J.ok){let Q=await J.text();throw Error(`Transaction submission failed: ${Q}`)}return J.json()}function _G(G,J){return G.map((Q)=>{let z=Q.amount.find((Z)=>Z.unit==="lovelace"),W=z?new q.default(z.quantity):new q.default(0),F=Q.amount.filter((Z)=>Z.unit!=="lovelace").map((Z)=>({amount:new q.default(Z.quantity),assetName:Z.unit.slice(56),policyId:Z.unit.slice(0,56)}));return{address:J,amount:W,index:Q.output_index,tokens:F,txId:Q.tx_hash}})}async function IG(G){try{let J=await QG(G),Q=0n,z=new Map;for(let Z of J){if(!Z.amount||!Array.isArray(Z.amount))continue;for(let U of Z.amount){let{unit:I,quantity:Y}=U;if(I==="lovelace")Q+=BigInt(Y);else{let R=z.get(I)||0n;z.set(I,R+BigInt(Y))}}}let W=[],{baseDecimal:F}=$.getChainConfig($.Chain.Cardano);if(Q>0n)W.push($.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:F,value:Q.toString()}));for(let[Z,U]of z)W.push($.AssetValue.from({asset:`${$.Chain.Cardano}.${Z}`,value:U.toString()}));if(W.length===0)return[$.AssetValue.from({chain:$.Chain.Cardano})];return W}catch(J){let Q=J instanceof Error?J.message:String(J);return console.error(`Cardano balance fetch error: ${Q}`),[$.AssetValue.from({chain:$.Chain.Cardano})]}}function ZG(G){if(!G||typeof G!=="string")return!1;try{let J=s.bech32.decode(G,120);return J.prefix==="addr"||J.prefix==="addr_test"}catch{return!1}}async function LG(G,J=0,Q=0){let{Bip32PrivateKey:z}=await import("@stricahq/bip32ed25519"),{types:W,address:F,crypto:Z}=await import("@stricahq/typhonjs"),U=a.mnemonicToEntropy(G,e.wordlist),Y=(await z.fromEntropy(Buffer.from(Array.from(U)))).derive(m+1852).derive(m+1815).derive(m+J),R=Y.derive(0).derive(Q),f=R.toBip32PublicKey().toPublicKey().toBytes(),K=Z.hash28(f),j=Y.derive(2).derive(0).toBip32PublicKey().toPublicKey().toBytes(),D=Z.hash28(j),M={hash:K,type:W.HashType.ADDRESS},O={hash:D,type:W.HashType.ADDRESS},k=new F.BaseAddress(W.NetworkId.MAINNET,M,O).getBech32(),v=R.toPrivateKey();return{getAddress:()=>k,publicKey:f,publicKeyHash:K,signTransaction:async(T)=>{try{let _=await import("@stricahq/cbors"),V=Buffer.from(T,"hex"),P=_.Decoder.decode(V),[w,S,h,b]=P.value,g=_.Encoder.encode(w),B=Z.hash32(g),x=v.sign(B),A=S instanceof Map?S:new Map,N=A.get(t)||[];N.push([f,x]),A.set(t,N);let y=[w,A,h,b];return _.Encoder.encode(y).toString("hex")}catch(_){throw new $.SwapKitError("toolbox_cardano_sign_transaction_failed",{message:String(_)})}}}}function fG(G){let J,Q,z;async function W(){if(!z)z=await OG();return z}async function F(){if(J!==void 0)return J;if(G&&"phrase"in G&&G.phrase){let X=G.index??0;return J=await LG(G.phrase,0,X),J}if(G&&"signer"in G&&G.signer)return J=G.signer,J;return}async function Z(){if(Q)return Q;let X=await F();if(!X)return"";if("getAddress"in X)return Q=await X.getAddress(),Q;return""}async function U(X){let j=X||await Z();if(!j)throw new $.SwapKitError("core_wallet_connection_not_found");return IG(j)}async function I(X){if(X)try{let{tx:O}=await Y(X),L=O.getFee();return $.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:6,value:L.toString()})}catch{}let j=await W(),D=400,M=j.minFeeB.plus(j.minFeeA.times(D));return $.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:6,value:M.toString()})}async function Y({sender:X="",recipient:j,assetValue:D,memo:M,pureLovelaceOnly:O=!1}){let{Transaction:L,utils:k}=await import("@stricahq/typhonjs"),v=X||await Z();if(!v)throw new $.SwapKitError("core_wallet_connection_not_found");let[T,_,V]=await Promise.all([QG(v),HG(),W()]),P=T.filter((H)=>O?H.amount.every((C)=>C.unit==="lovelace"):H.amount.some((C)=>C.unit==="lovelace")).sort((H,C)=>{let l=H.amount.some((u)=>u.unit!=="lovelace"),zG=C.amount.some((u)=>u.unit!=="lovelace");if(l===zG)return 0;return l?1:-1}),w=k.getAddressFromString(v),S=k.getAddressFromString(j),h=_G(P,w),b=new q.default(D.getBaseValue("string")),g=[{address:S,amount:b,tokens:[]}],B;if(M){let H=new Map;H.set("msg",[M]),B={metadata:[{data:H,label:674}]}}let x={...V,minFeeB:V.minFeeB.plus(V.minFeeA.times(4))},N=new L({protocolParams:x}).paymentTransaction({auxiliaryData:B,changeAddress:w,inputs:h,outputs:g,ttl:_+3600}),{payload:y}=N.buildTransaction();return{tx:N,unsignedTx:y}}async function R(X){let j=await F();if(!j||!("signTransaction"in j))throw new $.SwapKitError("core_wallet_connection_not_found");return j.signTransaction(X)}async function f({recipient:X,assetValue:j,memo:D}){let M=await F();if(!M||!("signTransaction"in M))throw new $.SwapKitError("core_wallet_connection_not_found");let{unsignedTx:O}=await Y({assetValue:j,memo:D,recipient:X,sender:await Z()}),L=await R(O);return await r(L)}async function K(X){let j=await R(X);return await r(j)}return{createTransaction:Y,estimateTransactionFee:I,getAddress:Z,getBalance:U,signAndBroadcastTransaction:K,signTransaction:R,transfer:f,validateAddress:ZG}}var s,a,e,$,q,GG="mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS",JG="https://cardano-mainnet.blockfrost.io/api/v0",m=2147483648,t=0;var $G=o(()=>{s=require("@scure/base"),a=require("@scure/bip39"),e=require("@scure/bip39/wordlists/english.js"),$=require("@swapkit/helpers"),q=UG(require("bignumber.js"))});var vG={};DG(vG,{validateCardanoAddress:()=>ZG,getCardanoToolbox:()=>fG});module.exports=YG(vG);var VG=o(()=>{$G()});VG();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ea as P}from"../../chunk-ntbvmmch.js";import{bech32 as a}from"@scure/base";import{mnemonicToEntropy as e}from"@scure/bip39";import{wordlist as GG}from"@scure/bip39/wordlists/english.js";import{AssetValue as f,Chain as _,getChainConfig as JG,SwapKitError as K}from"@swapkit/helpers";import W from"bignumber.js";var o="mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS",t="https://cardano-mainnet.blockfrost.io/api/v0",l=2147483648,i=0;async function c(G,J){let Q=await fetch(`${t}${G}`,{...J,headers:{project_id:o,...J?.headers}});if(!Q.ok)throw Error(`Blockfrost API error: ${Q.status} ${Q.statusText}`);return Q.json()}async function r(G){try{return await c(`/addresses/${G}/utxos`)}catch{return[]}}async function QG(){return(await c("/blocks/latest")).slot}async function ZG(){let G=await c("/epochs/latest/parameters"),J={PlutusScriptV1:G.cost_models.PlutusV1?Object.values(G.cost_models.PlutusV1):[],PlutusScriptV2:G.cost_models.PlutusV2?Object.values(G.cost_models.PlutusV2):[],PlutusScriptV3:G.cost_models.PlutusV3?Object.values(G.cost_models.PlutusV3):[]};return{collateralPercent:new W(G.collateral_percent),languageView:J,maxValueSize:Number.parseInt(G.max_val_size,10),minFeeA:new W(G.min_fee_a),minFeeB:new W(G.min_fee_b),minFeeRefScriptCostPerByte:new W(15),priceMem:new W(G.price_mem),priceSteps:new W(G.price_step),stakeKeyDeposit:new W(2000000),utxoCostPerByte:new W(G.coins_per_utxo_size)}}async function n(G){let J=await fetch(`${t}/tx/submit`,{body:Buffer.from(G,"hex"),headers:{"Content-Type":"application/cbor",project_id:o},method:"POST"});if(!J.ok){let Q=await J.text();throw Error(`Transaction submission failed: ${Q}`)}return J.json()}function $G(G,J){return G.map((Q)=>{let j=Q.amount.find((Z)=>Z.unit==="lovelace"),X=j?new W(j.quantity):new W(0),q=Q.amount.filter((Z)=>Z.unit!=="lovelace").map((Z)=>({amount:new W(Z.quantity),assetName:Z.unit.slice(56),policyId:Z.unit.slice(0,56)}));return{address:J,amount:X,index:Q.output_index,tokens:q,txId:Q.tx_hash}})}async function zG(G){try{let J=await r(G),Q=0n,j=new Map;for(let Z of J){if(!Z.amount||!Array.isArray(Z.amount))continue;for(let D of Z.amount){let{unit:I,quantity:F}=D;if(I==="lovelace")Q+=BigInt(F);else{let Y=j.get(I)||0n;j.set(I,Y+BigInt(F))}}}let X=[],{baseDecimal:q}=JG(_.Cardano);if(Q>0n)X.push(f.from({chain:_.Cardano,fromBaseDecimal:q,value:Q.toString()}));for(let[Z,D]of j)X.push(f.from({asset:`${_.Cardano}.${Z}`,value:D.toString()}));if(X.length===0)return[f.from({chain:_.Cardano})];return X}catch(J){let Q=J instanceof Error?J.message:String(J);return console.error(`Cardano balance fetch error: ${Q}`),[f.from({chain:_.Cardano})]}}function XG(G){if(!G||typeof G!=="string")return!1;try{let J=a.decode(G,120);return J.prefix==="addr"||J.prefix==="addr_test"}catch{return!1}}async function jG(G,J=0,Q=0){let{Bip32PrivateKey:j}=await import("@stricahq/bip32ed25519"),{types:X,address:q,crypto:Z}=await import("@stricahq/typhonjs"),D=e(G,GG),F=(await j.fromEntropy(Buffer.from(Array.from(D)))).derive(l+1852).derive(l+1815).derive(l+J),Y=F.derive(0).derive(Q),k=Y.toBip32PublicKey().toPublicKey().toBytes(),S=Z.hash28(k),z=F.derive(2).derive(0).toBip32PublicKey().toPublicKey().toBytes(),M=Z.hash28(z),U={hash:S,type:X.HashType.ADDRESS},H={hash:M,type:X.HashType.ADDRESS},v=new q.BaseAddress(X.NetworkId.MAINNET,U,H).getBech32(),V=Y.toPrivateKey();return{getAddress:()=>v,publicKey:k,publicKeyHash:S,signTransaction:async(h)=>{try{let O=await import("@stricahq/cbors"),w=Buffer.from(h,"hex"),b=O.Decoder.decode(w),[N,B,g,x]=b.value,y=O.Encoder.encode(N),A=Z.hash32(y),u=V.sign(A),T=B instanceof Map?B:new Map,C=T.get(i)||[];C.push([k,u]),T.set(i,C);let m=[N,T,g,x];return O.Encoder.encode(m).toString("hex")}catch(O){throw new K("toolbox_cardano_sign_transaction_failed",{message:String(O)})}}}}function MG(G){let J,Q,j;async function X(){if(!j)j=await ZG();return j}async function q(){if(J!==void 0)return J;if(G&&"phrase"in G&&G.phrase){let $=G.index??0;return J=await jG(G.phrase,0,$),J}if(G&&"signer"in G&&G.signer)return J=G.signer,J;return}async function Z(){if(Q)return Q;let $=await q();if(!$)return"";if("getAddress"in $)return Q=await $.getAddress(),Q;return""}async function D($){let z=$||await Z();if(!z)throw new K("core_wallet_connection_not_found");return zG(z)}async function I($){if($)try{let{tx:H}=await F($),L=H.getFee();return f.from({chain:_.Cardano,fromBaseDecimal:6,value:L.toString()})}catch{}let z=await X(),M=400,U=z.minFeeB.plus(z.minFeeA.times(M));return f.from({chain:_.Cardano,fromBaseDecimal:6,value:U.toString()})}async function F({sender:$="",recipient:z,assetValue:M,memo:U,pureLovelaceOnly:H=!1}){let{Transaction:L,utils:v}=await import("@stricahq/typhonjs"),V=$||await Z();if(!V)throw new K("core_wallet_connection_not_found");let[h,O,w]=await Promise.all([r(V),QG(),X()]),b=h.filter((R)=>H?R.amount.every((E)=>E.unit==="lovelace"):R.amount.some((E)=>E.unit==="lovelace")).sort((R,E)=>{let d=R.amount.some((p)=>p.unit!=="lovelace"),s=E.amount.some((p)=>p.unit!=="lovelace");if(d===s)return 0;return d?1:-1}),N=v.getAddressFromString(V),B=v.getAddressFromString(z),g=$G(b,N),x=new W(M.getBaseValue("string")),y=[{address:B,amount:x,tokens:[]}],A;if(U){let R=new Map;R.set("msg",[U]),A={metadata:[{data:R,label:674}]}}let u={...w,minFeeB:w.minFeeB.plus(w.minFeeA.times(4))},C=new L({protocolParams:u}).paymentTransaction({auxiliaryData:A,changeAddress:N,inputs:g,outputs:y,ttl:O+3600}),{payload:m}=C.buildTransaction();return{tx:C,unsignedTx:m}}async function Y($){let z=await q();if(!z||!("signTransaction"in z))throw new K("core_wallet_connection_not_found");return z.signTransaction($)}async function k({recipient:$,assetValue:z,memo:M}){let U=await q();if(!U||!("signTransaction"in U))throw new K("core_wallet_connection_not_found");let{unsignedTx:H}=await F({assetValue:z,memo:M,recipient:$,sender:await Z()}),L=await Y(H);return await n(L)}async function S($){let z=await Y($);return await n(z)}return{createTransaction:F,estimateTransactionFee:I,getAddress:Z,getBalance:D,signAndBroadcastTransaction:S,signTransaction:Y,transfer:k,validateAddress:XG}}export{XG as validateCardanoAddress,MG as getCardanoToolbox};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var x0=Object.create;var{getPrototypeOf:v0,defineProperty:g,getOwnPropertyNames:Ef,getOwnPropertyDescriptor:B0}=Object,Af=Object.prototype.hasOwnProperty;function Uf(H){return this[H]}var _0,H0,L0=(H,v,_)=>{var f=H!=null&&typeof H==="object";if(f){var x=v?_0??=new WeakMap:H0??=new WeakMap,T=x.get(H);if(T)return T}_=H!=null?x0(v0(H)):{};let B=v||!H||!H.__esModule?g(_,"default",{value:H,enumerable:!0}):_;for(let L of Ef(H))if(!Af.call(B,L))g(B,L,{get:Uf.bind(H,L),enumerable:!0});if(f)x.set(H,B);return B},y0=(H)=>{var v=(Kf??=new WeakMap).get(H),_;if(v)return v;if(v=g({},"__esModule",{value:!0}),H&&typeof H==="object"||typeof H==="function"){for(var f of Ef(H))if(!Af.call(v,f))g(v,f,{get:Uf.bind(H,f),enumerable:!(_=B0(H,f))||_.enumerable})}return Kf.set(H,v),v},Kf;var W0=(H)=>H;function z0(H,v){this[H]=W0.bind(null,v)}var kf=(H,v)=>{for(var _ in v)g(H,_,{get:v[_],enumerable:!0,configurable:!0,set:z0.bind(v,_)})};var R=(H,v)=>()=>(H&&(v=H(H=0)),v);function a(H){return u.base64.encode(Uint8Array.from(u.bech32.fromWords(u.bech32.decode(H).words)))}function r(H,v="thor"){return u.bech32.encode(v,u.bech32.toWords(u.base64.decode(H)))}function G0(H){return u.base64.encode(H)}function Z0(H){if(!H.match(/^[a-zA-Z0-9+/]*={0,2}$/))throw new Sf.SwapKitError("toolbox_cosmos_invalid_params",{error:"Invalid base64 string format"});return u.base64.decode(H)}var u,Sf;var Lf=R(()=>{u=require("@scure/base"),Sf=require("@swapkit/helpers")});function M(H){switch(H){case G.Chain.Maya:return{amount:[],gas:"10000000000"};case G.Chain.THORChain:return{amount:[],gas:"500000000"};case G.Chain.Kujira:return Vf;case G.Chain.Noble:return Df;default:return Rf}}async function w(H){let v=await import("@cosmjs/stargate"),_=v.StargateClient??v.default?.StargateClient,f=typeof window<"u"?{}:{referer:"https://sdk.swapkit.dev",referrer:"https://sdk.swapkit.dev"};return _.connect({headers:f,url:H})}async function i(H,v,_={}){let f=await import("@cosmjs/stargate"),x=f.SigningStargateClient??f.default?.SigningStargateClient,T=f.GasPrice??f.default?.GasPrice,B=typeof _==="string"?_:"0.0003uatom",L=typeof _==="string"?{}:_;return x.connectWithSigner(H,v,{gasPrice:T.fromString(B),...L})}async function Wf(H,v){let _=await import("@cosmjs/stargate");return(_.SigningStargateClient??_.default?.SigningStargateClient).offline(H,v)}async function zf({sender:H,recipient:v,assetValue:_,memo:f="",feeRate:x,sequence:T,accountNumber:B}){let{chain:L,chainId:X}=_,J=await G.getRPCUrl(L),O=await(await w(J)).getAccount(H);if(!O)throw new G.SwapKitError("toolbox_cosmos_account_not_found",{sender:H});let k=G.AssetValue.from({chain:L}),Q=l(k.symbol),q=M(L),F=Q&&x?{amount:[{amount:x.toString(),denom:Q}],gas:q.gas}:q,U={amount:[{amount:_.getBaseValue("string"),denom:l(_.symbol)}],fromAddress:H,toAddress:v};return{accountNumber:B??Number(O.accountNumber),chainId:X,fee:F,memo:f,msgs:[{typeUrl:I0(L),value:U}],sequence:T??O.sequence}}var G,yf="FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK",Cf="FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM",Rf,Vf,Df,l=(H,v=!1)=>{if(v)return H.toLowerCase();switch(H){case"uUSK":case"USK":return yf;case"uYUM":case"YUM":return Cf;case"uKUJI":case"KUJI":return"ukuji";case"ATOM":case"uATOM":return"uatom";case"uUSDC":case"USDC":return"uusdc";default:return H}},s=({symbol:H,chain:v})=>{if(v===G.Chain.Maya)return(H.toUpperCase()!=="CACAO"?H:`${G.Chain.Maya}.${H}`).toUpperCase();if(v===G.Chain.THORChain)return(["RUNE","TCY","RUJI"].includes(H.toUpperCase())?`${G.Chain.THORChain}.${H}`:H).toUpperCase();return l(H,!1)},I0=(H)=>{switch(H){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:H})}},Q0,Gf=(H,v)=>{let _=Q0[H.toLowerCase()];if(!_)return G.AssetValue.from({asset:H,fromBaseDecimal:8,value:v});let{chain:f,asset:x,decimals:T}=_,B=f?{chain:f}:{asset:x};return G.AssetValue.from({...B,fromBaseDecimal:T,value:v})};var e=R(()=>{G=require("@swapkit/helpers"),Rf={amount:[{amount:"500",denom:"uatom"}],gas:"200000"},Vf={amount:[{amount:"1000",denom:"ukuji"}],gas:"200000"},Df={amount:[{amount:"1000",denom:"uusdc"}],gas:"200000"};Q0={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},[yf.toLowerCase()]:{asset:`${G.Chain.Kujira}.USK`,decimals:G.getChainConfig(G.Chain.Kujira).baseDecimal}}});var Pf={};kf(Pf,{$root:()=>y});var E,Z,V,z,y;var uf=R(()=>{E=L0(require("protobufjs/minimal.js")),Z=E.default.Reader,V=E.default.Writer,z=E.default.util,y=E.default.roots.default||(E.default.roots.default={});y.common=(()=>{let H={};return H.Asset=(()=>{function v(_){if(_){for(let f=Object.keys(_),x=0;x<f.length;++x)if(_[f[x]]!=null)this[f[x]]=_[f[x]]}}return v.prototype.chain="",v.prototype.symbol="",v.prototype.ticker="",v.prototype.synth=!1,v.create=function(f){return new v(f)},v.encode=function(f,x){if(!x)x=V.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},v.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},v.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,B=new y.common.Asset;while(f.pos<T){let L=f.uint32();switch(L>>>3){case 1:B.chain=f.string();break;case 2:B.symbol=f.string();break;case 3:B.ticker=f.string();break;case 4:B.synth=f.bool();break;default:f.skipType(L&7);break}}return B},v.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},v.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},v.fromObject=function(f){if(f instanceof y.common.Asset)return f;let x=new y.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},v.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},v.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},v})(),H.Coin=(()=>{function v(_){if(_){for(let f=Object.keys(_),x=0;x<f.length;++x)if(_[f[x]]!=null)this[f[x]]=_[f[x]]}}return v.prototype.asset=null,v.prototype.amount="",v.prototype.decimals=z.Long?z.Long.fromBits(0,0,!1):0,v.create=function(f){return new v(f)},v.encode=function(f,x){if(!x)x=V.create();if(f.asset!=null&&Object.hasOwnProperty.call(f,"asset"))y.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},v.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},v.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,B=new y.common.Coin;while(f.pos<T){let L=f.uint32();switch(L>>>3){case 1:B.asset=y.common.Asset.decode(f,f.uint32());break;case 2:B.amount=f.string();break;case 3:B.decimals=f.int64();break;default:f.skipType(L&7);break}}return B},v.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},v.verify=function(f){if(typeof f!=="object"||f===null)return"object expected";if(f.asset!=null&&f.hasOwnProperty("asset")){let x=y.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},v.fromObject=function(f){if(f instanceof y.common.Coin)return f;let x=new y.common.Coin;if(f.asset!=null){if(typeof f.asset!=="object")throw TypeError(".common.Coin.asset: object expected");x.asset=y.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},v.toObject=function(f,x){if(!x)x={};let T={};if(x.defaults)if(T.asset=null,T.amount="",z.Long){let B=new z.Long(0,0,!1);T.decimals=x.longs===String?B.toString():x.longs===Number?B.toNumber():B}else T.decimals=x.longs===String?"0":0;if(f.asset!=null&&f.hasOwnProperty("asset"))T.asset=y.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},v.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},v})(),H.PubKeySet=(()=>{function v(_){if(_){for(let f=Object.keys(_),x=0;x<f.length;++x)if(_[f[x]]!=null)this[f[x]]=_[f[x]]}}return v.prototype.secp256k1="",v.prototype.ed25519="",v.create=function(f){return new v(f)},v.encode=function(f,x){if(!x)x=V.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},v.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},v.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,B=new y.common.PubKeySet;while(f.pos<T){let L=f.uint32();switch(L>>>3){case 1:B.secp256k1=f.string();break;case 2:B.ed25519=f.string();break;default:f.skipType(L&7);break}}return B},v.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},v.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},v.fromObject=function(f){if(f instanceof y.common.PubKeySet)return f;let x=new y.common.PubKeySet;if(f.secp256k1!=null)x.secp256k1=String(f.secp256k1);if(f.ed25519!=null)x.ed25519=String(f.ed25519);return x},v.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},v.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},v})(),H.Tx=(()=>{function v(_){if(this.coins=[],this.gas=[],_){for(let f=Object.keys(_),x=0;x<f.length;++x)if(_[f[x]]!=null)this[f[x]]=_[f[x]]}}return v.prototype.id="",v.prototype.chain="",v.prototype.fromAddress="",v.prototype.toAddress="",v.prototype.coins=z.emptyArray,v.prototype.gas=z.emptyArray,v.prototype.memo="",v.create=function(f){return new v(f)},v.encode=function(f,x){if(!x)x=V.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)y.common.Coin.encode(f.coins[T],x.uint32(42).fork()).ldelim();if(f.gas?.length)for(let T=0;T<f.gas.length;++T)y.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},v.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},v.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,B=new y.common.Tx;while(f.pos<T){let L=f.uint32();switch(L>>>3){case 1:B.id=f.string();break;case 2:B.chain=f.string();break;case 3:B.fromAddress=f.string();break;case 4:B.toAddress=f.string();break;case 5:if(!B.coins?.length)B.coins=[];B.coins.push(y.common.Coin.decode(f,f.uint32()));break;case 6:if(!B.gas?.length)B.gas=[];B.gas.push(y.common.Coin.decode(f,f.uint32()));break;case 7:B.memo=f.string();break;default:f.skipType(L&7);break}}return B},v.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},v.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=y.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=y.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},v.fromObject=function(f){if(f instanceof y.common.Tx)return f;let x=new y.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]=y.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]=y.common.Coin.fromObject(f.gas[T])}}if(f.memo!=null)x.memo=String(f.memo);return x},v.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 B=0;B<f.coins.length;++B)T.coins[B]=y.common.Coin.toObject(f.coins[B],x)}if(f.gas?.length){T.gas=[];for(let B=0;B<f.gas.length;++B)T.gas[B]=y.common.Coin.toObject(f.gas[B],x)}if(f.memo!=null&&f.hasOwnProperty("memo"))T.memo=f.memo;return T},v.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},v})(),H.Fee=(()=>{function v(_){if(this.coins=[],_){for(let f=Object.keys(_),x=0;x<f.length;++x)if(_[f[x]]!=null)this[f[x]]=_[f[x]]}}return v.prototype.coins=z.emptyArray,v.prototype.poolDeduct="",v.create=function(f){return new v(f)},v.encode=function(f,x){if(!x)x=V.create();if(f.coins?.length)for(let T=0;T<f.coins.length;++T)y.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},v.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},v.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,B=new y.common.Fee;while(f.pos<T){let L=f.uint32();switch(L>>>3){case 1:if(!B.coins?.length)B.coins=[];B.coins.push(y.common.Coin.decode(f,f.uint32()));break;case 2:B.poolDeduct=f.string();break;default:f.skipType(L&7);break}}return B},v.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},v.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=y.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},v.fromObject=function(f){if(f instanceof y.common.Fee)return f;let x=new y.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]=y.common.Coin.fromObject(f.coins[T])}}if(f.poolDeduct!=null)x.poolDeduct=String(f.poolDeduct);return x},v.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 B=0;B<f.coins.length;++B)T.coins[B]=y.common.Coin.toObject(f.coins[B],x)}if(f.poolDeduct!=null&&f.hasOwnProperty("poolDeduct"))T.poolDeduct=f.poolDeduct;return T},v.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},v})(),H.ProtoUint=(()=>{function v(_){if(_){for(let f=Object.keys(_),x=0;x<f.length;++x)if(_[f[x]]!=null)this[f[x]]=_[f[x]]}}return v.prototype.value="",v.create=function(f){return new v(f)},v.encode=function(f,x){if(!x)x=V.create();if(f.value!=null&&Object.hasOwnProperty.call(f,"value"))x.uint32(10).string(f.value);return x},v.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},v.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,B=new y.common.ProtoUint;while(f.pos<T){let L=f.uint32();switch(L>>>3){case 1:B.value=f.string();break;default:f.skipType(L&7);break}}return B},v.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},v.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},v.fromObject=function(f){if(f instanceof y.common.ProtoUint)return f;let x=new y.common.ProtoUint;if(f.value!=null)x.value=String(f.value);return x},v.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},v.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},v})(),H})();y.types=(()=>{let H={};return H.MsgDeposit=(()=>{function v(_){if(this.coins=[],_){for(let f=Object.keys(_),x=0;x<f.length;++x)if(_[f[x]]!=null)this[f[x]]=_[f[x]]}}return v.prototype.coins=z.emptyArray,v.prototype.memo="",v.prototype.signer=z.newBuffer([]),v.create=function(f){return new v(f)},v.encode=function(f,x){if(!x)x=V.create();if(f.coins?.length)for(let T=0;T<f.coins.length;++T)y.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},v.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},v.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,B=new y.types.MsgDeposit;while(f.pos<T){let L=f.uint32();switch(L>>>3){case 1:if(!B.coins?.length)B.coins=[];B.coins.push(y.common.Coin.decode(f,f.uint32()));break;case 2:B.memo=f.string();break;case 3:B.signer=f.bytes();break;default:f.skipType(L&7);break}}return B},v.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},v.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=y.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},v.fromObject=function(f){if(f instanceof y.types.MsgDeposit)return f;let x=new y.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]=y.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},v.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 B=0;B<f.coins.length;++B)T.coins[B]=y.common.Coin.toObject(f.coins[B],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},v.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},v})(),H.MsgSend=(()=>{function v(_){if(this.amount=[],_){for(let f=Object.keys(_),x=0;x<f.length;++x)if(_[f[x]]!=null)this[f[x]]=_[f[x]]}}return v.prototype.fromAddress=z.newBuffer([]),v.prototype.toAddress=z.newBuffer([]),v.prototype.amount=z.emptyArray,v.create=function(f){return new v(f)},v.encode=function(f,x){if(!x)x=V.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)y.cosmos.base.v1beta1.Coin.encode(f.amount[T],x.uint32(26).fork()).ldelim();return x},v.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},v.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,B=new y.types.MsgSend;while(f.pos<T){let L=f.uint32();switch(L>>>3){case 1:B.fromAddress=f.bytes();break;case 2:B.toAddress=f.bytes();break;case 3:if(!B.amount?.length)B.amount=[];B.amount.push(y.cosmos.base.v1beta1.Coin.decode(f,f.uint32()));break;default:f.skipType(L&7);break}}return B},v.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},v.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=y.cosmos.base.v1beta1.Coin.verify(f.amount[x]);if(T)return"amount."+T}}return null},v.fromObject=function(f){if(f instanceof y.types.MsgSend)return f;let x=new y.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]=y.cosmos.base.v1beta1.Coin.fromObject(f.amount[T])}}return x},v.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 B=0;B<f.amount.length;++B)T.amount[B]=y.cosmos.base.v1beta1.Coin.toObject(f.amount[B],x)}return T},v.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},v})(),H})();y.cosmos=(()=>{let H={};return H.base=(()=>{let v={};return v.v1beta1=(()=>{let _={};return _.Coin=(()=>{function f(x){if(x){for(let T=Object.keys(x),B=0;B<T.length;++B)if(x[T[B]]!=null)this[T[B]]=x[T[B]]}}return f.prototype.denom="",f.prototype.amount="",f.create=function(T){return new f(T)},f.encode=function(T,B){if(!B)B=V.create();if(T.denom!=null&&Object.hasOwnProperty.call(T,"denom"))B.uint32(10).string(T.denom);if(T.amount!=null&&Object.hasOwnProperty.call(T,"amount"))B.uint32(18).string(T.amount);return B},f.encodeDelimited=function(T,B){return this.encode(T,B).ldelim()},f.decode=function(T,B){if(!(T instanceof Z))T=Z.create(T);let L=B===void 0?T.len:T.pos+B,X=new y.cosmos.base.v1beta1.Coin;while(T.pos<L){let J=T.uint32();switch(J>>>3){case 1:X.denom=T.string();break;case 2:X.amount=T.string();break;default:T.skipType(J&7);break}}return X},f.decodeDelimited=function(T){if(!(T instanceof Z))T=new Z(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 y.cosmos.base.v1beta1.Coin)return T;let B=new y.cosmos.base.v1beta1.Coin;if(T.denom!=null)B.denom=String(T.denom);if(T.amount!=null)B.amount=String(T.amount);return B},f.toObject=function(T,B){if(!B)B={};let L={};if(B.defaults)L.denom="",L.amount="";if(T.denom!=null&&T.hasOwnProperty("denom"))L.denom=T.denom;if(T.amount!=null&&T.hasOwnProperty("amount"))L.amount=T.amount;return L},f.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},f})(),_.DecCoin=(()=>{function f(x){if(x){for(let T=Object.keys(x),B=0;B<T.length;++B)if(x[T[B]]!=null)this[T[B]]=x[T[B]]}}return f.prototype.denom="",f.prototype.amount="",f.create=function(T){return new f(T)},f.encode=function(T,B){if(!B)B=V.create();if(T.denom!=null&&Object.hasOwnProperty.call(T,"denom"))B.uint32(10).string(T.denom);if(T.amount!=null&&Object.hasOwnProperty.call(T,"amount"))B.uint32(18).string(T.amount);return B},f.encodeDelimited=function(T,B){return this.encode(T,B).ldelim()},f.decode=function(T,B){if(!(T instanceof Z))T=Z.create(T);let L=B===void 0?T.len:T.pos+B,X=new y.cosmos.base.v1beta1.DecCoin;while(T.pos<L){let J=T.uint32();switch(J>>>3){case 1:X.denom=T.string();break;case 2:X.amount=T.string();break;default:T.skipType(J&7);break}}return X},f.decodeDelimited=function(T){if(!(T instanceof Z))T=new Z(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 y.cosmos.base.v1beta1.DecCoin)return T;let B=new y.cosmos.base.v1beta1.DecCoin;if(T.denom!=null)B.denom=String(T.denom);if(T.amount!=null)B.amount=String(T.amount);return B},f.toObject=function(T,B){if(!B)B={};let L={};if(B.defaults)L.denom="",L.amount="";if(T.denom!=null&&T.hasOwnProperty("denom"))L.denom=T.denom;if(T.amount!=null&&T.hasOwnProperty("amount"))L.amount=T.amount;return L},f.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},f})(),_.IntProto=(()=>{function f(x){if(x){for(let T=Object.keys(x),B=0;B<T.length;++B)if(x[T[B]]!=null)this[T[B]]=x[T[B]]}}return f.prototype.int="",f.create=function(T){return new f(T)},f.encode=function(T,B){if(!B)B=V.create();if(T.int!=null&&Object.hasOwnProperty.call(T,"int"))B.uint32(10).string(T.int);return B},f.encodeDelimited=function(T,B){return this.encode(T,B).ldelim()},f.decode=function(T,B){if(!(T instanceof Z))T=Z.create(T);let L=B===void 0?T.len:T.pos+B,X=new y.cosmos.base.v1beta1.IntProto;while(T.pos<L){let J=T.uint32();switch(J>>>3){case 1:X.int=T.string();break;default:T.skipType(J&7);break}}return X},f.decodeDelimited=function(T){if(!(T instanceof Z))T=new Z(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 y.cosmos.base.v1beta1.IntProto)return T;let B=new y.cosmos.base.v1beta1.IntProto;if(T.int!=null)B.int=String(T.int);return B},f.toObject=function(T,B){if(!B)B={};let L={};if(B.defaults)L.int="";if(T.int!=null&&T.hasOwnProperty("int"))L.int=T.int;return L},f.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},f})(),_.DecProto=(()=>{function f(x){if(x){for(let T=Object.keys(x),B=0;B<T.length;++B)if(x[T[B]]!=null)this[T[B]]=x[T[B]]}}return f.prototype.dec="",f.create=function(T){return new f(T)},f.encode=function(T,B){if(!B)B=V.create();if(T.dec!=null&&Object.hasOwnProperty.call(T,"dec"))B.uint32(10).string(T.dec);return B},f.encodeDelimited=function(T,B){return this.encode(T,B).ldelim()},f.decode=function(T,B){if(!(T instanceof Z))T=Z.create(T);let L=B===void 0?T.len:T.pos+B,X=new y.cosmos.base.v1beta1.DecProto;while(T.pos<L){let J=T.uint32();switch(J>>>3){case 1:X.dec=T.string();break;default:T.skipType(J&7);break}}return X},f.decodeDelimited=function(T){if(!(T instanceof Z))T=new Z(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 y.cosmos.base.v1beta1.DecProto)return T;let B=new y.cosmos.base.v1beta1.DecProto;if(T.dec!=null)B.dec=String(T.dec);return B},f.toObject=function(T,B){if(!B)B={};let L={};if(B.defaults)L.dec="";if(T.dec!=null&&T.hasOwnProperty("dec"))L.dec=T.dec;return L},f.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},f})(),_})(),v})(),H})()});async function o(){let{$root:H}=await Promise.resolve().then(() => (uf(),Pf)),v=await import("@cosmjs/proto-signing"),_=v.Registry??v.default?.Registry,f=await import("@cosmjs/stargate"),x=f.defaultRegistryTypes??f.default?.defaultRegistryTypes;return new _([...x,["/types.MsgSend",H.types.MsgSend],["/types.MsgDeposit",H.types.MsgDeposit]])}async function $(H){let v=await import("@cosmjs/stargate"),_=v.AminoTypes??v.default?.AminoTypes,f=H===Mf.Chain.THORChain?"thorchain":"mayachain";return new _({"/types.MsgDeposit":{aminoType:`${f}/MsgDeposit`,fromAmino:({signer:x,...T})=>({...T,signer:a(x)}),toAmino:({signer:x,...T})=>({...T,signer:r(x)})},"/types.MsgSend":{aminoType:`${f}/MsgSend`,fromAmino:({from_address:x,to_address:T,...B})=>({...B,fromAddress:a(x),toAddress:a(T)}),toAmino:({fromAddress:x,toAddress:T,...B})=>({...B,from_address:r(x),to_address:r(T)})}})}var Mf;var Zf=R(()=>{Lf();Mf=require("@swapkit/helpers")});function Xf(H){let{assetValue:v,recipient:_,memo:f,sender:x,asSignable:T,asAminoMessage:B}=H;if(_)return hf({asAminoMessage:B,asSignable:T,assetValue:v,memo:f,recipient:_,sender:x});return lf({asAminoMessage:B,asSignable:T,assetValue:v,memo:f,sender:x})}async function hf({sender:H,recipient:v,assetValue:_,memo:f="",asSignable:x=!0,asAminoMessage:T=!1,sequence:B,accountNumber:L}){let X=_.chain,J=await C.getRPCUrl(X),A=await wf({rpcUrl:J,sender:H}),{chainId:O}=C.getChainConfig(X),k=If({assetValue:_,recipient:v,sender:H}),Q=x?await n(T?k:p(k),X):k;return{accountNumber:L||Number(A.accountNumber),chainId:O,fee:M(X),memo:f,msgs:[Q],sequence:B||A.sequence}}async function lf({sender:H,assetValue:v,memo:_="",asSignable:f=!0,asAminoMessage:x=!1,sequence:T,accountNumber:B}){let L=v.chain,X=await C.getRPCUrl(L),J=await wf({rpcUrl:X,sender:H}),{chainId:A}=C.getChainConfig(L),O=Qf({assetValue:v,memo:_,sender:H}),k=f?await n(x?O:p(O),L):O;return{accountNumber:B||Number(J.accountNumber),chainId:A,fee:M(L),memo:_,msgs:[k],sequence:T||J.sequence}}function p(H){if(H.type==="thorchain/MsgSend"||H.type==="mayachain/MsgSend")return H;return{...H,value:{...H.value,coins:H.value.coins.map((v)=>{let _=C.AssetValue.from({asset:v.asset}),f=(_.isSynthetic?_.symbol.split("/")?.[1]:_.symbol)?.toUpperCase(),x=(_.isSynthetic?_.symbol.split("/")?.[0]:_.chain)?.toUpperCase();return{...v,asset:{chain:x,symbol:f,synth:_.isSynthetic,ticker:_.ticker}}})}}}async function ff({chain:H,memo:v,msgs:_}){let f=await o(),x=await $(H),T={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:v,messages:_.map((B)=>x.fromAmino(B))}};return f.encode(T)}var C,X0,Y0,If=({sender:H,recipient:v,assetValue:_})=>{return{type:`${_.chain===C.Chain.Maya?"mayachain":"thorchain"}/MsgSend`,value:{amount:[{amount:_.getBaseValue("string"),denom:l(_.symbol,!0)}],from_address:H,to_address:v}}},Qf=({sender:H,assetValue:v,memo:_=""})=>{return{type:`${v.chain===C.Chain.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:v.getBaseValue("string"),asset:s(v)}],memo:_,signer:H}}},vf=({sender:H,recipient:v,assetValue:_,memo:f})=>{return!v?Qf({assetValue:_,memo:f,sender:H}):If({assetValue:_,recipient:v,sender:H})},n=async(H,v)=>{return(await $(v)).fromAmino(H)},wf=async({rpcUrl:H,sender:v})=>{let f=await(await w(H)).getAccount(v);if(!f)throw new C.SwapKitError("toolbox_cosmos_account_not_found",{sender:v});return f};var $f=R(()=>{e();Zf();C=require("@swapkit/helpers"),X0=M(C.Chain.THORChain).gas,Y0=M(C.Chain.Maya).gas});var nf=()=>{};var pf=R(()=>{nf()});var Yf=R(()=>{Lf();$f();Zf();pf()});async function Nf(H,v){try{let f=(await Jf.SwapKitApi.getGasRate()).find((x)=>x.chainId===H)?.value;return f?Number.parseFloat(f):v}catch{return v}}async function qf({phrase:H,prefix:v,..._}){let f="derivationPath"in _?_.derivationPath:`${W.DerivationPath[_.chain]}/${_.index}`;return await of.DirectSecp256k1HdWallet.fromMnemonic(H,{hdPaths:[df.stringToPath(f)],prefix:v})}async function q0({privateKey:H,prefix:v}){let _=await import("@cosmjs/proto-signing");return(_.DirectSecp256k1Wallet??_.default?.DirectSecp256k1Wallet).fromKey(H,v)}function mf(H){return async function({signature:_,message:f,address:x}){let T=await H(x);if(!T?.pubkey)throw new W.SwapKitError("toolbox_cosmos_verify_signature_no_pubkey");let B=await import("@cosmjs/crypto"),L=B.Secp256k1Signature??B.default?.Secp256k1Signature,X=B.Secp256k1??B.default?.Secp256k1,J=L.fromFixedLength(c.base64.decode(_));return X.verifySignature(J,c.base64.decode(f),T.pubkey.value)}}function xf({chain:H,...v}){let _=W.CosmosChainPrefixes[H],f="index"in v?v.index||0:0,x=W.derivationPathToString("derivationPath"in v&&v.derivationPath?v.derivationPath:W.updateDerivationPath(W.NetworkDerivationPath[H],{index:f})),T;async function B(){if(T)return T;return T=await Tf.match(v).with({phrase:Tf.P.string},({phrase:Q})=>qf({derivationPath:x,phrase:Q,prefix:_})).with({signer:Tf.P.any},({signer:Q})=>Q).otherwise(()=>{return}),T}async function L(Q){let q=await W.getRPCUrl(H);return(await w(q)).getAccount(Q)}async function X(){let Q=await B(),[q]=await Q?.getAccounts()||[];return q?.address}async function J(){let Q=await B(),[q]=await Q?.getAccounts()||[];if(!q?.pubkey)throw new W.SwapKitError("toolbox_cosmos_signer_not_defined");return c.base64.encode(q?.pubkey)}async function A(Q){let q=await B(),F=await X(),U=await W.getRPCUrl(H);if(!(q&&F))throw new W.SwapKitError("toolbox_cosmos_signer_not_defined");return await(await i(U,q)).sign(F,Q.msgs,Q.fee,Q.memo,{accountNumber:BigInt(Q.accountNumber),chainId:Q.chainId,sequence:Q.sequence})}async function O(Q){let q=await B(),F=await X(),U=await W.getRPCUrl(H);if(!(q&&F))throw new W.SwapKitError("toolbox_cosmos_signer_not_defined");let I=await(await i(U,q)).signAndBroadcast(F,Q.msgs,Q.fee,Q.memo);if(I.code!==0)throw new W.SwapKitError("core_swap_transaction_error",{code:I.code,message:I.rawLog});return I.transactionHash}async function k({recipient:Q,assetValue:q,memo:F="",feeRate:U,feeOptionKey:K=W.FeeOption.Fast}){let I=await B(),N=await X();if(!(I&&N))throw new W.SwapKitError("toolbox_cosmos_signer_not_defined");let S=await W.getRPCUrl(H),D=W.AssetValue.from({chain:H}),h=s(D),d=U||O0((await jf(H,cf[H]))[K],h),P=await i(S,I),_f=l(q.symbol),t=[{amount:q.getBaseValue("string"),denom:_f}],{transactionHash:Hf}=await P.sendTokens(N,Q,t,d,F);return Hf}return{createPrivateKeyFromPhrase:K0(x),createTransaction:zf,fetchFeeRateFromSwapKit:Nf,getAccount:L,getAddress:X,getBalance:async(Q,q)=>{let F=await bf(H)(Q),U=await Promise.all(F.filter(({denom:K})=>K&&!K.includes("IBC/")&&!([W.Chain.THORChain,W.Chain.Maya].includes(H)&&K.split("-").length>2)).map(({denom:K,amount:I})=>{let N=[W.Chain.THORChain,W.Chain.Maya].includes(H)&&(K.includes("/")||K.includes("˜"))?`${H}.${K}`:K;return Gf(N,I)}));if(U.length===0)return[W.AssetValue.from({chain:H})];return U},getBalanceAsDenoms:bf(H),getFees:()=>jf(H,cf[H]),getPubKey:J,getSignerFromPhrase:({phrase:Q,derivationPath:q})=>qf({derivationPath:W.derivationPathToString(q),index:f,phrase:Q,prefix:_}),getSignerFromPrivateKey:async(Q)=>{let q=await import("@cosmjs/proto-signing");return(q.DirectSecp256k1Wallet??q.default?.DirectSecp256k1Wallet).fromKey(Q,_)},signAndBroadcastTransaction:O,signTransaction:A,transfer:k,validateAddress:tf(H),verifySignature:mf(L)}}async function J0(H,v){try{let f=(await Jf.SwapKitApi.getGasRate()).find((x)=>x.chainId===H)?.value;return f?Number.parseFloat(f):v}catch{return v}}function N0({assetValue:{chain:H}}){return W.AssetValue.from({chain:H,value:F0(H)})}async function jf(H,v){let{chainId:_,baseDecimal:f}=W.getChainConfig(H),x=await Nf(_,v);return{average:W.SwapKitNumber.fromBigInt(BigInt(x),f),fast:W.SwapKitNumber.fromBigInt(BigInt(W.applyFeeMultiplier(x,W.FeeOption.Fast,!0)),f),fastest:W.SwapKitNumber.fromBigInt(BigInt(W.applyFeeMultiplier(x,W.FeeOption.Fastest,!0)),f)}}function O0(H,v){return{amount:[{amount:H.getBaseValue("string"),denom:v}],gas:"200000"}}function F0(H){return{[W.Chain.Cosmos]:0.007,[W.Chain.Kujira]:0.02,[W.Chain.Noble]:0.01,[W.Chain.THORChain]:0.02,[W.Chain.Maya]:0.02,[W.Chain.Harbor]:0.02}[H]||0}function tf(H){let v=W.CosmosChainPrefixes[H];return function(f){if(!f.startsWith(v))return!1;try{let{prefix:x,words:T}=c.bech32.decode(f);return c.bech32.encode(x,T)===f.toLocaleLowerCase()}catch{return!1}}}function bf(H){return async function(_){let f=await W.getRPCUrl(H);return(await(await w(f)).getAllBalances(_)).map((L)=>({...L,denom:L.denom.includes("/")?L.denom.toUpperCase():L.denom}))}}function K0(H){return async function(_){let f=await import("@cosmjs/crypto"),x=f.stringToPath??f.default?.stringToPath,T=f.Slip10Curve??f.default?.Slip10Curve,B=f.Slip10??f.default?.Slip10,L=f.EnglishMnemonic??f.default?.EnglishMnemonic,X=f.Bip39??f.default?.Bip39,J=new L(_),A=await X.mnemonicToSeed(J),{privkey:O}=B.derivePath(T.Secp256k1,A,x(H));return O}}var df,of,c,W,Jf,Tf,cf;var Bf=R(()=>{e();df=require("@cosmjs/crypto"),of=require("@cosmjs/proto-signing"),c=require("@scure/base"),W=require("@swapkit/helpers"),Jf=require("@swapkit/helpers/api"),Tf=require("ts-pattern");cf={[W.Chain.Cosmos]:1000,[W.Chain.Kujira]:1000,[W.Chain.Noble]:1000,[W.Chain.THORChain]:5000000,[W.Chain.Maya]:5000000,[W.Chain.Harbor]:5000000}});function E0({prefix:H,derivationPath:v}){return async function(f,x=0){let T=await import("@cosmjs/amino"),B=T.Secp256k1HdWallet??T.default?.Secp256k1HdWallet,L=await import("@cosmjs/crypto"),X=L.stringToPath??L.default?.stringToPath;return B.fromMnemonic(f,{hdPaths:[X(`${v}/${x}`)],prefix:H})}}function A0(H){return j.base64.encode(H)}function U0(H){return async function({wallet:_,tx:f}){let{msgs:x,accountNumber:T,sequence:B,chainId:L,fee:X,memo:J}=typeof f==="string"?JSON.parse(f):f,A=(await _.getAccounts())?.[0]?.address||"",O=await $(H),k=await o(),Q=await Wf(_,{aminoTypes:O,registry:k}),q=[];for(let K of x){let I=await n(K,H);q.push(I)}let{signatures:[F]}=await Q.sign(A,q,X,J,{accountNumber:BigInt(T),chainId:L,sequence:B});return{bodyBytes:await ff({chain:H,memo:J,msgs:x.map(p)}),signature:A0(F)}}}function k0({prefix:H,chain:v}){return async function(f,x,T,B,L){let X=await Y.getRPCUrl(v),{encodeSecp256k1Pubkey:J,pubkeyToAddress:A}=(await import("@cosmjs/amino")).default,{makeMultisignedTxBytes:O}=(await import("@cosmjs/stargate")).default,{sequence:k,fee:Q}=JSON.parse(f),q=await gf(T,B),F=x.map((I)=>[A(J(j.base64.decode(I.pubKey)),H),j.base64.decode(I.signature)]),U=await w(X),{transactionHash:K}=await U.broadcastTx(O(q,k,Q,L,new Map(F)));return K}}async function gf(H,v,_=!0){let{createMultisigThresholdPubkey:f,encodeSecp256k1Pubkey:x}=(await import("@cosmjs/amino")).default;return f(H.map((T)=>x(j.base64.decode(T))),v,_)}function S0(H){return j.base64.decode(H)}async function C0({privateKey:H,message:v}){let{Secp256k1:_}=(await import("@cosmjs/crypto")).default,f=await _.createSignature(j.base64.decode(v),H);return j.base64.encode(Buffer.concat([f.r(32),f.s(32)]))}function Of({chain:H,...v}){let{isStagenet:_}=Y.SKConfig.get("envs"),f=Y.SKConfig.get("thornodeUrls"),x=H===Y.Chain.Maya,T=m.match({isMayachain:x,isStagenet:_}).with({isMayachain:!0},({isStagenet:I})=>I?f.MAYA_STAGENET:f.MAYA).otherwise(({isStagenet:I})=>I?f.THOR_STAGENET:f.THOR),B=`${_?"s":""}${Y.CosmosChainPrefixes[H]}`,L="index"in v?v.index||0:0,X="derivationPath"in v&&v.derivationPath?v.derivationPath:Y.updateDerivationPath(Y.NetworkDerivationPath[H],{index:L}),J=xf({chain:H,...v}),A=M(H),O;function k(){return O??=m.match(v).with({phrase:m.P.string},({phrase:I})=>J.getSignerFromPhrase({derivationPath:X,phrase:I})).with({signer:m.P.any},({signer:I})=>Promise.resolve(I)).otherwise(()=>Promise.resolve(void 0)),O}async function Q(){let I=await Y.getRPCUrl(H),N=await k();if(!N)throw new Y.SwapKitError("toolbox_cosmos_no_signer");let S=await o(),D=await $(H),h=await i(I,N,{aminoTypes:D,registry:S});return{signer:N,signingClient:h}}async function q({fee:I,memo:N,msgs:S}){let{signer:D,signingClient:h}=await Q(),d=(await D.getAccounts())?.[0]?.address;if(!d)throw new Y.SwapKitError("toolbox_cosmos_signer_not_defined");let P=await h.signAndBroadcast(d,S,I,N);if(P.code!==0)throw new Y.SwapKitError("core_swap_transaction_error",{code:P.code,message:P.rawLog});return P.transactionHash}async function F(){let I,N=`${T}/${x?"mayachain":"thorchain"}/constants`;try{let{int_64_values:{NativeTransactionFee:S}}=await Y.RequestClient.get(N);if(!S||Number.isNaN(S)||S<0)throw new Y.SwapKitError("toolbox_cosmos_invalid_fee",{nativeFee:S.toString()});I=new Y.SwapKitNumber(S)}catch{I=new Y.SwapKitNumber({decimal:Y.getChainConfig(H).baseDecimal,value:x?1:0.02})}return{[Y.FeeOption.Average]:I,[Y.FeeOption.Fast]:I,[Y.FeeOption.Fastest]:I}}async function U({assetValue:I,memo:N="",recipient:S}){let{TxRaw:D}=await import("cosmjs-types/cosmos/tx/v1beta1/tx"),{signer:h,signingClient:d}=await Q(),P=(await h.getAccounts())?.[0]?.address;if(!P)throw new Y.SwapKitError("toolbox_cosmos_no_signer");let _f="signAmino"in h,t=vf({assetValue:I,memo:N,recipient:S,sender:P});if(_f){let sf=await n(t,H),{signatures:ef,authInfoBytes:f0}=await d.sign(P,[sf],A,N),T0=D.encode({authInfoBytes:f0,bodyBytes:await ff({chain:H,memo:N,msgs:[t].map(p)}),signatures:ef}).finish();return(await d.broadcastTx(T0)).transactionHash}let Hf=p(t),rf=await n(Hf,H);return q({fee:A,memo:N,msgs:[rf]})}async function K(I){let{signer:N,signingClient:S}=await Q(),D=(await N.getAccounts())?.[0]?.address;if(!D)throw new Y.SwapKitError("toolbox_cosmos_signer_not_defined");return S.sign(D,I.msgs,I.fee,I.memo,{accountNumber:BigInt(I.accountNumber),chainId:I.chainId,sequence:I.sequence})}return{...J,broadcastMultisigTx:k0({chain:H,prefix:B}),buildAminoMsg:vf,buildEncodedTxBody:ff,convertToSignable:n,createDefaultAminoTypes:()=>$(H),createDefaultRegistry:o,createMultisig:gf,createTransaction:Xf,deposit:U,getFees:F,importSignature:S0,parseAminoMessageForDirectSigning:p,pubkeyToAddress:async(I)=>{let{pubkeyToAddress:N}=(await import("@cosmjs/amino")).default;return N(I,B)},secp256k1HdWalletFromMnemonic:E0({derivationPath:Y.derivationPathToString(X),prefix:B}),signAndBroadcastTransaction:q,signMultisigTx:U0(H),signTransaction:K,signWithPrivateKey:C0,transfer:U}}var j,Y,m;var Ff=R(()=>{Yf();e();Bf();j=require("@scure/base"),Y=require("@swapkit/helpers"),m=require("ts-pattern")});var b,R0=(H,v)=>{switch(H){case b.Chain.Cosmos:case b.Chain.Kujira:case b.Chain.Noble:return xf({chain:H,...v});case b.Chain.Maya:case b.Chain.THORChain:return Of({chain:H,...v});default:throw new b.SwapKitError("toolbox_cosmos_not_supported",{chain:H})}};var af=R(()=>{Bf();Ff();b=require("@swapkit/helpers");Bf();Ff()});var D0={};kf(D0,{verifySignature:()=>mf,transferMsgAmino:()=>If,toBase64:()=>G0,parseAminoMessageForDirectSigning:()=>p,getSignerFromPrivateKey:()=>q0,getSignerFromPhrase:()=>qf,getMsgSendDenom:()=>l,getFeeRateFromSwapKit:()=>J0,getDenomWithChain:()=>s,getDefaultChainFee:()=>M,getCosmosToolbox:()=>R0,getCosmosAddressValidator:()=>tf,getAssetFromDenom:()=>Gf,fromBase64:()=>Z0,fetchFeeRateFromSwapKit:()=>Nf,estimateTransactionFee:()=>N0,depositMsgAmino:()=>Qf,createTransaction:()=>Xf,createThorchainToolbox:()=>Of,createStargateClient:()=>w,createSigningStargateClient:()=>i,createOfflineStargateClient:()=>Wf,createDefaultRegistry:()=>o,createDefaultAminoTypes:()=>$,createCosmosToolbox:()=>xf,cosmosCreateTransaction:()=>zf,convertToSignable:()=>n,buildTransferTx:()=>hf,buildEncodedTxBody:()=>ff,buildDepositTx:()=>lf,buildAminoMsg:()=>vf,bech32ToBase64:()=>a,base64ToBech32:()=>r,YUM_KUJIRA_FACTORY_DENOM:()=>Cf,USK_KUJIRA_FACTORY_DENOM:()=>yf,THORCHAIN_GAS_VALUE:()=>X0,MAYA_GAS_VALUE:()=>Y0,DEFAULT_NOBLE_FEE_MAINNET:()=>Df,DEFAULT_KUJI_FEE_MAINNET:()=>Vf,DEFAULT_COSMOS_FEE_MAINNET:()=>Rf});module.exports=y0(D0);var P0=R(()=>{Yf();af();e()});P0();
|
|
1
|
+
var f0=Object.create;var{getPrototypeOf:T0,defineProperty:g,getOwnPropertyNames:Ef,getOwnPropertyDescriptor:x0}=Object,Af=Object.prototype.hasOwnProperty;function Sf(_){return this[_]}var H0,v0,B0=(_,H,B)=>{var f=_!=null&&typeof _==="object";if(f){var x=H?H0??=new WeakMap:v0??=new WeakMap,T=x.get(_);if(T)return T}B=_!=null?f0(T0(_)):{};let v=H||!_||!_.__esModule?g(B,"default",{value:_,enumerable:!0}):B;for(let L of Ef(_))if(!Af.call(v,L))g(v,L,{get:Sf.bind(_,L),enumerable:!0});if(f)x.set(_,v);return v},_0=(_)=>{var H=(Kf??=new WeakMap).get(_),B;if(H)return H;if(H=g({},"__esModule",{value:!0}),_&&typeof _==="object"||typeof _==="function"){for(var f of Ef(_))if(!Af.call(H,f))g(H,f,{get:Sf.bind(_,f),enumerable:!(B=x0(_,f))||B.enumerable})}return Kf.set(_,H),H},Kf;var L0=(_)=>_;function W0(_,H){this[_]=L0.bind(null,H)}var kf=(_,H)=>{for(var B in H)g(_,B,{get:H[B],enumerable:!0,configurable:!0,set:W0.bind(H,B)})};var R=(_,H)=>()=>(_&&(H=_(_=0)),H);function a(_){return u.base64.encode(Uint8Array.from(u.bech32.fromWords(u.bech32.decode(_).words)))}function r(_,H="thor"){return u.bech32.encode(H,u.bech32.toWords(u.base64.decode(_)))}function y0(_){return u.base64.encode(_)}function z0(_){if(!_.match(/^[a-zA-Z0-9+/]*={0,2}$/))throw new Uf.SwapKitError("toolbox_cosmos_invalid_params",{error:"Invalid base64 string format"});return u.base64.decode(_)}var u,Uf;var Lf=R(()=>{u=require("@scure/base"),Uf=require("@swapkit/helpers")});function M(_){switch(_){case G.Chain.Maya:return{amount:[],gas:"10000000000"};case G.Chain.THORChain:return{amount:[],gas:"500000000"};case G.Chain.Kujira:return Vf;case G.Chain.Noble:return Df;default:return Rf}}async function w(_){let H=await import("@cosmjs/stargate"),B=H.StargateClient??H.default?.StargateClient,f=typeof window<"u"?{}:{referer:"https://sdk.swapkit.dev",referrer:"https://sdk.swapkit.dev"};return B.connect({headers:f,url:_})}async function i(_,H,B={}){let f=await import("@cosmjs/stargate"),x=f.SigningStargateClient??f.default?.SigningStargateClient,T=f.GasPrice??f.default?.GasPrice,v=typeof B==="string"?B:"0.0003uatom",L=typeof B==="string"?{}:B;return x.connectWithSigner(_,H,{gasPrice:T.fromString(v),...L})}async function yf(_,H){let B=await import("@cosmjs/stargate");return(B.SigningStargateClient??B.default?.SigningStargateClient).offline(_,H)}async function zf({sender:_,recipient:H,assetValue:B,memo:f="",feeRate:x,sequence:T,accountNumber:v}){let{chain:L,chainId:X}=B,J=await G.getRPCUrl(L),O=await(await w(J)).getAccount(_);if(!O)throw new G.SwapKitError("toolbox_cosmos_account_not_found",{sender:_});let k=G.AssetValue.from({chain:L}),Q=l(k.symbol),q=M(L),F=Q&&x?{amount:[{amount:x.toString(),denom:Q}],gas:q.gas}:q,S={amount:[{amount:B.getBaseValue("string"),denom:l(B.symbol)}],fromAddress:_,toAddress:H};return{accountNumber:v??Number(O.accountNumber),chainId:X,fee:F,memo:f,msgs:[{typeUrl:G0(L),value:S}],sequence:T??O.sequence}}var G,Wf="FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK",Cf="FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM",Rf,Vf,Df,l=(_,H=!1)=>{if(H)return _.toLowerCase();switch(_){case"uUSK":case"USK":return Wf;case"uYUM":case"YUM":return Cf;case"uKUJI":case"KUJI":return"ukuji";case"ATOM":case"uATOM":return"uatom";case"uUSDC":case"USDC":return"uusdc";default:return _}},s=({symbol:_,chain:H})=>{if(H===G.Chain.Maya)return(_.toUpperCase()!=="CACAO"?_:`${G.Chain.Maya}.${_}`).toUpperCase();if(H===G.Chain.THORChain)return(["RUNE","TCY","RUJI"].includes(_.toUpperCase())?`${G.Chain.THORChain}.${_}`:_).toUpperCase();return l(_,!1)},G0=(_)=>{switch(_){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:_})}},Z0,Gf=(_,H)=>{let B=Z0[_.toLowerCase()];if(!B)return G.AssetValue.from({asset:_,fromBaseDecimal:8,value:H});let{chain:f,asset:x,decimals:T}=B,v=f?{chain:f}:{asset:x};return G.AssetValue.from({...v,fromBaseDecimal:T,value:H})};var e=R(()=>{G=require("@swapkit/helpers"),Rf={amount:[{amount:"500",denom:"uatom"}],gas:"200000"},Vf={amount:[{amount:"1000",denom:"ukuji"}],gas:"200000"},Df={amount:[{amount:"1000",denom:"uusdc"}],gas:"200000"};Z0={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},[Wf.toLowerCase()]:{asset:`${G.Chain.Kujira}.USK`,decimals:G.getChainConfig(G.Chain.Kujira).baseDecimal}}});var Pf={};kf(Pf,{$root:()=>W});var E,Z,V,z,W;var uf=R(()=>{E=B0(require("protobufjs/minimal.js")),Z=E.default.Reader,V=E.default.Writer,z=E.default.util,W=E.default.roots.default||(E.default.roots.default={});W.common=(()=>{let _={};return _.Asset=(()=>{function H(B){if(B){for(let f=Object.keys(B),x=0;x<f.length;++x)if(B[f[x]]!=null)this[f[x]]=B[f[x]]}}return H.prototype.chain="",H.prototype.symbol="",H.prototype.ticker="",H.prototype.synth=!1,H.create=function(f){return new H(f)},H.encode=function(f,x){if(!x)x=V.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},H.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},H.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.Asset;while(f.pos<T){let L=f.uint32();switch(L>>>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(L&7);break}}return v},H.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},H.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},H.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},H.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},H.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},H})(),_.Coin=(()=>{function H(B){if(B){for(let f=Object.keys(B),x=0;x<f.length;++x)if(B[f[x]]!=null)this[f[x]]=B[f[x]]}}return H.prototype.asset=null,H.prototype.amount="",H.prototype.decimals=z.Long?z.Long.fromBits(0,0,!1):0,H.create=function(f){return new H(f)},H.encode=function(f,x){if(!x)x=V.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},H.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},H.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.Coin;while(f.pos<T){let L=f.uint32();switch(L>>>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(L&7);break}}return v},H.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},H.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},H.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},H.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},H.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},H})(),_.PubKeySet=(()=>{function H(B){if(B){for(let f=Object.keys(B),x=0;x<f.length;++x)if(B[f[x]]!=null)this[f[x]]=B[f[x]]}}return H.prototype.secp256k1="",H.prototype.ed25519="",H.create=function(f){return new H(f)},H.encode=function(f,x){if(!x)x=V.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},H.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},H.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.PubKeySet;while(f.pos<T){let L=f.uint32();switch(L>>>3){case 1:v.secp256k1=f.string();break;case 2:v.ed25519=f.string();break;default:f.skipType(L&7);break}}return v},H.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},H.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},H.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},H.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},H.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},H})(),_.Tx=(()=>{function H(B){if(this.coins=[],this.gas=[],B){for(let f=Object.keys(B),x=0;x<f.length;++x)if(B[f[x]]!=null)this[f[x]]=B[f[x]]}}return H.prototype.id="",H.prototype.chain="",H.prototype.fromAddress="",H.prototype.toAddress="",H.prototype.coins=z.emptyArray,H.prototype.gas=z.emptyArray,H.prototype.memo="",H.create=function(f){return new H(f)},H.encode=function(f,x){if(!x)x=V.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},H.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},H.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.Tx;while(f.pos<T){let L=f.uint32();switch(L>>>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(L&7);break}}return v},H.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},H.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},H.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},H.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},H.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},H})(),_.Fee=(()=>{function H(B){if(this.coins=[],B){for(let f=Object.keys(B),x=0;x<f.length;++x)if(B[f[x]]!=null)this[f[x]]=B[f[x]]}}return H.prototype.coins=z.emptyArray,H.prototype.poolDeduct="",H.create=function(f){return new H(f)},H.encode=function(f,x){if(!x)x=V.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},H.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},H.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.Fee;while(f.pos<T){let L=f.uint32();switch(L>>>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(L&7);break}}return v},H.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},H.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},H.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},H.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},H.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},H})(),_.ProtoUint=(()=>{function H(B){if(B){for(let f=Object.keys(B),x=0;x<f.length;++x)if(B[f[x]]!=null)this[f[x]]=B[f[x]]}}return H.prototype.value="",H.create=function(f){return new H(f)},H.encode=function(f,x){if(!x)x=V.create();if(f.value!=null&&Object.hasOwnProperty.call(f,"value"))x.uint32(10).string(f.value);return x},H.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},H.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.common.ProtoUint;while(f.pos<T){let L=f.uint32();switch(L>>>3){case 1:v.value=f.string();break;default:f.skipType(L&7);break}}return v},H.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},H.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},H.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},H.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},H.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},H})(),_})();W.types=(()=>{let _={};return _.MsgDeposit=(()=>{function H(B){if(this.coins=[],B){for(let f=Object.keys(B),x=0;x<f.length;++x)if(B[f[x]]!=null)this[f[x]]=B[f[x]]}}return H.prototype.coins=z.emptyArray,H.prototype.memo="",H.prototype.signer=z.newBuffer([]),H.create=function(f){return new H(f)},H.encode=function(f,x){if(!x)x=V.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},H.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},H.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.types.MsgDeposit;while(f.pos<T){let L=f.uint32();switch(L>>>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(L&7);break}}return v},H.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},H.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},H.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},H.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},H.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},H})(),_.MsgSend=(()=>{function H(B){if(this.amount=[],B){for(let f=Object.keys(B),x=0;x<f.length;++x)if(B[f[x]]!=null)this[f[x]]=B[f[x]]}}return H.prototype.fromAddress=z.newBuffer([]),H.prototype.toAddress=z.newBuffer([]),H.prototype.amount=z.emptyArray,H.create=function(f){return new H(f)},H.encode=function(f,x){if(!x)x=V.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},H.encodeDelimited=function(f,x){return this.encode(f,x).ldelim()},H.decode=function(f,x){if(!(f instanceof Z))f=Z.create(f);let T=x===void 0?f.len:f.pos+x,v=new W.types.MsgSend;while(f.pos<T){let L=f.uint32();switch(L>>>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(L&7);break}}return v},H.decodeDelimited=function(f){if(!(f instanceof Z))f=new Z(f);return this.decode(f,f.uint32())},H.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},H.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},H.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},H.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},H})(),_})();W.cosmos=(()=>{let _={};return _.base=(()=>{let H={};return H.v1beta1=(()=>{let B={};return B.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=V.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 Z))T=Z.create(T);let L=v===void 0?T.len:T.pos+v,X=new W.cosmos.base.v1beta1.Coin;while(T.pos<L){let J=T.uint32();switch(J>>>3){case 1:X.denom=T.string();break;case 2:X.amount=T.string();break;default:T.skipType(J&7);break}}return X},f.decodeDelimited=function(T){if(!(T instanceof Z))T=new Z(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 L={};if(v.defaults)L.denom="",L.amount="";if(T.denom!=null&&T.hasOwnProperty("denom"))L.denom=T.denom;if(T.amount!=null&&T.hasOwnProperty("amount"))L.amount=T.amount;return L},f.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},f})(),B.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=V.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 Z))T=Z.create(T);let L=v===void 0?T.len:T.pos+v,X=new W.cosmos.base.v1beta1.DecCoin;while(T.pos<L){let J=T.uint32();switch(J>>>3){case 1:X.denom=T.string();break;case 2:X.amount=T.string();break;default:T.skipType(J&7);break}}return X},f.decodeDelimited=function(T){if(!(T instanceof Z))T=new Z(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 L={};if(v.defaults)L.denom="",L.amount="";if(T.denom!=null&&T.hasOwnProperty("denom"))L.denom=T.denom;if(T.amount!=null&&T.hasOwnProperty("amount"))L.amount=T.amount;return L},f.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},f})(),B.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=V.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 Z))T=Z.create(T);let L=v===void 0?T.len:T.pos+v,X=new W.cosmos.base.v1beta1.IntProto;while(T.pos<L){let J=T.uint32();switch(J>>>3){case 1:X.int=T.string();break;default:T.skipType(J&7);break}}return X},f.decodeDelimited=function(T){if(!(T instanceof Z))T=new Z(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 L={};if(v.defaults)L.int="";if(T.int!=null&&T.hasOwnProperty("int"))L.int=T.int;return L},f.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},f})(),B.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=V.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 Z))T=Z.create(T);let L=v===void 0?T.len:T.pos+v,X=new W.cosmos.base.v1beta1.DecProto;while(T.pos<L){let J=T.uint32();switch(J>>>3){case 1:X.dec=T.string();break;default:T.skipType(J&7);break}}return X},f.decodeDelimited=function(T){if(!(T instanceof Z))T=new Z(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 L={};if(v.defaults)L.dec="";if(T.dec!=null&&T.hasOwnProperty("dec"))L.dec=T.dec;return L},f.prototype.toJSON=function(){return this.constructor.toObject(this,E.default.util.toJSONOptions)},f})(),B})(),H})(),_})()});async function o(){let{$root:_}=await Promise.resolve().then(() => (uf(),Pf)),H=await import("@cosmjs/proto-signing"),B=await import("@cosmjs/stargate"),f=H.Registry??H.default?.Registry,x=B.defaultRegistryTypes??B.default?.defaultRegistryTypes;return new f([...x,["/types.MsgSend",_.types.MsgSend],["/types.MsgDeposit",_.types.MsgDeposit]])}async function $(_){let H=await import("@cosmjs/stargate"),B=H.AminoTypes??H.default?.AminoTypes,f=_===Mf.Chain.THORChain?"thorchain":"mayachain";return new B({"/types.MsgDeposit":{aminoType:`${f}/MsgDeposit`,fromAmino:({signer:x,...T})=>({...T,signer:a(x)}),toAmino:({signer:x,...T})=>({...T,signer:r(x)})},"/types.MsgSend":{aminoType:`${f}/MsgSend`,fromAmino:({from_address:x,to_address:T,...v})=>({...v,fromAddress:a(x),toAddress:a(T)}),toAmino:({fromAddress:x,toAddress:T,...v})=>({...v,from_address:r(x),to_address:r(T)})}})}var Mf;var Zf=R(()=>{Lf();Mf=require("@swapkit/helpers")});function Xf(_){let{assetValue:H,recipient:B,memo:f,sender:x,asSignable:T,asAminoMessage:v}=_;if(B)return hf({asAminoMessage:v,asSignable:T,assetValue:H,memo:f,recipient:B,sender:x});return lf({asAminoMessage:v,asSignable:T,assetValue:H,memo:f,sender:x})}async function hf({sender:_,recipient:H,assetValue:B,memo:f="",asSignable:x=!0,asAminoMessage:T=!1,sequence:v,accountNumber:L}){let X=B.chain,J=await C.getRPCUrl(X),A=await wf({rpcUrl:J,sender:_}),{chainId:O}=C.getChainConfig(X),k=If({assetValue:B,recipient:H,sender:_}),Q=x?await n(T?k:p(k),X):k;return{accountNumber:L||Number(A.accountNumber),chainId:O,fee:M(X),memo:f,msgs:[Q],sequence:v||A.sequence}}async function lf({sender:_,assetValue:H,memo:B="",asSignable:f=!0,asAminoMessage:x=!1,sequence:T,accountNumber:v}){let L=H.chain,X=await C.getRPCUrl(L),J=await wf({rpcUrl:X,sender:_}),{chainId:A}=C.getChainConfig(L),O=Qf({assetValue:H,memo:B,sender:_}),k=f?await n(x?O:p(O),L):O;return{accountNumber:v||Number(J.accountNumber),chainId:A,fee:M(L),memo:B,msgs:[k],sequence:T||J.sequence}}function p(_){if(_.type==="thorchain/MsgSend"||_.type==="mayachain/MsgSend")return _;return{..._,value:{..._.value,coins:_.value.coins.map((H)=>{let B=C.AssetValue.from({asset:H.asset}),f=(B.isSynthetic?B.symbol.split("/")?.[1]:B.symbol)?.toUpperCase(),x=(B.isSynthetic?B.symbol.split("/")?.[0]:B.chain)?.toUpperCase();return{...H,asset:{chain:x,symbol:f,synth:B.isSynthetic,ticker:B.ticker}}})}}}async function ff({chain:_,memo:H,msgs:B}){let f=await o(),x=await $(_),T={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:H,messages:B.map((v)=>x.fromAmino(v))}};return f.encode(T)}var C,I0,Q0,If=({sender:_,recipient:H,assetValue:B})=>{return{type:`${B.chain===C.Chain.Maya?"mayachain":"thorchain"}/MsgSend`,value:{amount:[{amount:B.getBaseValue("string"),denom:l(B.symbol,!0)}],from_address:_,to_address:H}}},Qf=({sender:_,assetValue:H,memo:B=""})=>{return{type:`${H.chain===C.Chain.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:H.getBaseValue("string"),asset:s(H)}],memo:B,signer:_}}},Hf=({sender:_,recipient:H,assetValue:B,memo:f})=>{return!H?Qf({assetValue:B,memo:f,sender:_}):If({assetValue:B,recipient:H,sender:_})},n=async(_,H)=>{return(await $(H)).fromAmino(_)},wf=async({rpcUrl:_,sender:H})=>{let f=await(await w(_)).getAccount(H);if(!f)throw new C.SwapKitError("toolbox_cosmos_account_not_found",{sender:H});return f};var $f=R(()=>{e();Zf();C=require("@swapkit/helpers"),I0=M(C.Chain.THORChain).gas,Q0=M(C.Chain.Maya).gas});var nf=()=>{};var pf=R(()=>{nf()});var Yf=R(()=>{Lf();$f();Zf();pf()});async function Nf(_,H){try{let f=(await Jf.SwapKitApi.getGasRate()).find((x)=>x.chainId===_)?.value;return f?Number.parseFloat(f):H}catch{return H}}async function qf({phrase:_,prefix:H,...B}){let f=await import("@cosmjs/proto-signing"),x=await import("@cosmjs/crypto"),T=f.DirectSecp256k1HdWallet??f.default?.DirectSecp256k1HdWallet,v=x.stringToPath??x.default?.stringToPath,L="derivationPath"in B?B.derivationPath:`${y.DerivationPath[B.chain]}/${B.index}`;return await T.fromMnemonic(_,{hdPaths:[v(L)],prefix:H})}async function X0({privateKey:_,prefix:H}){let B=await import("@cosmjs/proto-signing");return(B.DirectSecp256k1Wallet??B.default?.DirectSecp256k1Wallet).fromKey(_,H)}function df(_){return async function({signature:B,message:f,address:x}){let T=await _(x);if(!T?.pubkey)throw new y.SwapKitError("toolbox_cosmos_verify_signature_no_pubkey");let v=await import("@cosmjs/crypto"),L=v.Secp256k1Signature??v.default?.Secp256k1Signature,X=v.Secp256k1??v.default?.Secp256k1,J=L.fromFixedLength(c.base64.decode(B));return X.verifySignature(J,c.base64.decode(f),T.pubkey.value)}}function xf({chain:_,...H}){let B=y.CosmosChainPrefixes[_],f="index"in H?H.index||0:0,x=y.derivationPathToString("derivationPath"in H&&H.derivationPath?H.derivationPath:y.updateDerivationPath(y.NetworkDerivationPath[_],{index:f})),T;async function v(){if(T)return T;return T=await Tf.match(H).with({phrase:Tf.P.string},({phrase:Q})=>qf({derivationPath:x,phrase:Q,prefix:B})).with({signer:Tf.P.any},({signer:Q})=>Q).otherwise(()=>{return}),T}async function L(Q){let q=await y.getRPCUrl(_);return(await w(q)).getAccount(Q)}async function X(){let Q=await v(),[q]=await Q?.getAccounts()||[];return q?.address}async function J(){let Q=await v(),[q]=await Q?.getAccounts()||[];if(!q?.pubkey)throw new y.SwapKitError("toolbox_cosmos_signer_not_defined");return c.base64.encode(q?.pubkey)}async function A(Q){let q=await v(),F=await X(),S=await y.getRPCUrl(_);if(!(q&&F))throw new y.SwapKitError("toolbox_cosmos_signer_not_defined");return await(await i(S,q)).sign(F,Q.msgs,Q.fee,Q.memo,{accountNumber:BigInt(Q.accountNumber),chainId:Q.chainId,sequence:Q.sequence})}async function O(Q){let q=await v(),F=await X(),S=await y.getRPCUrl(_);if(!(q&&F))throw new y.SwapKitError("toolbox_cosmos_signer_not_defined");let I=await(await i(S,q)).signAndBroadcast(F,Q.msgs,Q.fee,Q.memo);if(I.code!==0)throw new y.SwapKitError("core_swap_transaction_error",{code:I.code,message:I.rawLog});return I.transactionHash}async function k({recipient:Q,assetValue:q,memo:F="",feeRate:S,feeOptionKey:K=y.FeeOption.Fast}){let I=await v(),N=await X();if(!(I&&N))throw new y.SwapKitError("toolbox_cosmos_signer_not_defined");let U=await y.getRPCUrl(_),D=y.AssetValue.from({chain:_}),h=s(D),d=S||J0((await jf(_,cf[_]))[K],h),P=await i(U,I),Bf=l(q.symbol),m=[{amount:q.getBaseValue("string"),denom:Bf}],{transactionHash:_f}=await P.sendTokens(N,Q,m,d,F);return _f}return{createPrivateKeyFromPhrase:O0(x),createTransaction:zf,fetchFeeRateFromSwapKit:Nf,getAccount:L,getAddress:X,getBalance:async(Q,q)=>{let F=await bf(_)(Q),S=await Promise.all(F.filter(({denom:K})=>K&&!K.includes("IBC/")&&!([y.Chain.THORChain,y.Chain.Maya].includes(_)&&K.split("-").length>2)).map(({denom:K,amount:I})=>{let N=[y.Chain.THORChain,y.Chain.Maya].includes(_)&&(K.includes("/")||K.includes("˜"))?`${_}.${K}`:K;return Gf(N,I)}));if(S.length===0)return[y.AssetValue.from({chain:_})];return S},getBalanceAsDenoms:bf(_),getFees:()=>jf(_,cf[_]),getPubKey:J,getSignerFromPhrase:({phrase:Q,derivationPath:q})=>qf({derivationPath:y.derivationPathToString(q),index:f,phrase:Q,prefix:B}),getSignerFromPrivateKey:async(Q)=>{let q=await import("@cosmjs/proto-signing");return(q.DirectSecp256k1Wallet??q.default?.DirectSecp256k1Wallet).fromKey(Q,B)},signAndBroadcastTransaction:O,signTransaction:A,transfer:k,validateAddress:of(_),verifySignature:df(L)}}async function Y0(_,H){try{let f=(await Jf.SwapKitApi.getGasRate()).find((x)=>x.chainId===_)?.value;return f?Number.parseFloat(f):H}catch{return H}}function q0({assetValue:{chain:_}}){return y.AssetValue.from({chain:_,value:N0(_)})}async function jf(_,H){let{chainId:B,baseDecimal:f}=y.getChainConfig(_),x=await Nf(B,H);return{average:y.SwapKitNumber.fromBigInt(BigInt(x),f),fast:y.SwapKitNumber.fromBigInt(BigInt(y.applyFeeMultiplier(x,y.FeeOption.Fast,!0)),f),fastest:y.SwapKitNumber.fromBigInt(BigInt(y.applyFeeMultiplier(x,y.FeeOption.Fastest,!0)),f)}}function J0(_,H){return{amount:[{amount:_.getBaseValue("string"),denom:H}],gas:"200000"}}function N0(_){return{[y.Chain.Cosmos]:0.007,[y.Chain.Kujira]:0.02,[y.Chain.Noble]:0.01,[y.Chain.THORChain]:0.02,[y.Chain.Maya]:0.02,[y.Chain.Harbor]:0.02}[_]||0}function of(_){let H=y.CosmosChainPrefixes[_];return function(f){if(!f.startsWith(H))return!1;try{let{prefix:x,words:T}=c.bech32.decode(f);return c.bech32.encode(x,T)===f.toLocaleLowerCase()}catch{return!1}}}function bf(_){return async function(B){let f=await y.getRPCUrl(_);return(await(await w(f)).getAllBalances(B)).map((L)=>({...L,denom:L.denom.includes("/")?L.denom.toUpperCase():L.denom}))}}function O0(_){return async function(B){let f=await import("@cosmjs/crypto"),x=f.stringToPath??f.default?.stringToPath,T=f.Slip10Curve??f.default?.Slip10Curve,v=f.Slip10??f.default?.Slip10,L=f.EnglishMnemonic??f.default?.EnglishMnemonic,X=f.Bip39??f.default?.Bip39,J=new L(B),A=await X.mnemonicToSeed(J),{privkey:O}=v.derivePath(T.Secp256k1,A,x(_));return O}}var c,y,Jf,Tf,cf;var vf=R(()=>{e();c=require("@scure/base"),y=require("@swapkit/helpers"),Jf=require("@swapkit/helpers/api"),Tf=require("ts-pattern");cf={[y.Chain.Cosmos]:1000,[y.Chain.Kujira]:1000,[y.Chain.Noble]:1000,[y.Chain.THORChain]:5000000,[y.Chain.Maya]:5000000,[y.Chain.Harbor]:5000000}});function F0({prefix:_,derivationPath:H}){return async function(f,x=0){let T=await import("@cosmjs/amino"),v=T.Secp256k1HdWallet??T.default?.Secp256k1HdWallet,L=await import("@cosmjs/crypto"),X=L.stringToPath??L.default?.stringToPath;return v.fromMnemonic(f,{hdPaths:[X(`${H}/${x}`)],prefix:_})}}function K0(_){return j.base64.encode(_)}function E0(_){return async function({wallet:B,tx:f}){let{msgs:x,accountNumber:T,sequence:v,chainId:L,fee:X,memo:J}=typeof f==="string"?JSON.parse(f):f,A=(await B.getAccounts())?.[0]?.address||"",O=await $(_),k=await o(),Q=await yf(B,{aminoTypes:O,registry:k}),q=[];for(let K of x){let I=await n(K,_);q.push(I)}let{signatures:[F]}=await Q.sign(A,q,X,J,{accountNumber:BigInt(T),chainId:L,sequence:v});return{bodyBytes:await ff({chain:_,memo:J,msgs:x.map(p)}),signature:K0(F)}}}function A0({prefix:_,chain:H}){return async function(f,x,T,v,L){let X=await Y.getRPCUrl(H),{encodeSecp256k1Pubkey:J,pubkeyToAddress:A}=(await import("@cosmjs/amino")).default,{makeMultisignedTxBytes:O}=(await import("@cosmjs/stargate")).default,{sequence:k,fee:Q}=JSON.parse(f),q=await tf(T,v),F=x.map((I)=>[A(J(j.base64.decode(I.pubKey)),_),j.base64.decode(I.signature)]),S=await w(X),{transactionHash:K}=await S.broadcastTx(O(q,k,Q,L,new Map(F)));return K}}async function tf(_,H,B=!0){let{createMultisigThresholdPubkey:f,encodeSecp256k1Pubkey:x}=(await import("@cosmjs/amino")).default;return f(_.map((T)=>x(j.base64.decode(T))),H,B)}function S0(_){return j.base64.decode(_)}async function k0({privateKey:_,message:H}){let{Secp256k1:B}=(await import("@cosmjs/crypto")).default,f=await B.createSignature(j.base64.decode(H),_);return j.base64.encode(Buffer.concat([f.r(32),f.s(32)]))}function Of({chain:_,...H}){let{isStagenet:B}=Y.SKConfig.get("envs"),f=Y.SKConfig.get("thornodeUrls"),x=_===Y.Chain.Maya,T=t.match({isMayachain:x,isStagenet:B}).with({isMayachain:!0},({isStagenet:I})=>I?f.MAYA_STAGENET:f.MAYA).otherwise(({isStagenet:I})=>I?f.THOR_STAGENET:f.THOR),v=`${B?"s":""}${Y.CosmosChainPrefixes[_]}`,L="index"in H?H.index||0:0,X="derivationPath"in H&&H.derivationPath?H.derivationPath:Y.updateDerivationPath(Y.NetworkDerivationPath[_],{index:L}),J=xf({chain:_,...H}),A=M(_),O;function k(){return O??=t.match(H).with({phrase:t.P.string},({phrase:I})=>J.getSignerFromPhrase({derivationPath:X,phrase:I})).with({signer:t.P.any},({signer:I})=>Promise.resolve(I)).otherwise(()=>Promise.resolve(void 0)),O}async function Q(){let I=await Y.getRPCUrl(_),N=await k();if(!N)throw new Y.SwapKitError("toolbox_cosmos_no_signer");let U=await o(),D=await $(_),h=await i(I,N,{aminoTypes:D,registry:U});return{signer:N,signingClient:h}}async function q({fee:I,memo:N,msgs:U}){let{signer:D,signingClient:h}=await Q(),d=(await D.getAccounts())?.[0]?.address;if(!d)throw new Y.SwapKitError("toolbox_cosmos_signer_not_defined");let P=await h.signAndBroadcast(d,U,I,N);if(P.code!==0)throw new Y.SwapKitError("core_swap_transaction_error",{code:P.code,message:P.rawLog});return P.transactionHash}async function F(){let I,N=`${T}/${x?"mayachain":"thorchain"}/constants`;try{let{int_64_values:{NativeTransactionFee:U}}=await Y.RequestClient.get(N);if(!U||Number.isNaN(U)||U<0)throw new Y.SwapKitError("toolbox_cosmos_invalid_fee",{nativeFee:U.toString()});I=new Y.SwapKitNumber(U)}catch{I=new Y.SwapKitNumber({decimal:Y.getChainConfig(_).baseDecimal,value:x?1:0.02})}return{[Y.FeeOption.Average]:I,[Y.FeeOption.Fast]:I,[Y.FeeOption.Fastest]:I}}async function S({assetValue:I,memo:N="",recipient:U}){let{TxRaw:D}=await import("cosmjs-types/cosmos/tx/v1beta1/tx"),{signer:h,signingClient:d}=await Q(),P=(await h.getAccounts())?.[0]?.address;if(!P)throw new Y.SwapKitError("toolbox_cosmos_no_signer");let Bf="signAmino"in h,m=Hf({assetValue:I,memo:N,recipient:U,sender:P});if(Bf){let af=await n(m,_),{signatures:rf,authInfoBytes:sf}=await d.sign(P,[af],A,N),ef=D.encode({authInfoBytes:sf,bodyBytes:await ff({chain:_,memo:N,msgs:[m].map(p)}),signatures:rf}).finish();return(await d.broadcastTx(ef)).transactionHash}let _f=p(m),gf=await n(_f,_);return q({fee:A,memo:N,msgs:[gf]})}async function K(I){let{signer:N,signingClient:U}=await Q(),D=(await N.getAccounts())?.[0]?.address;if(!D)throw new Y.SwapKitError("toolbox_cosmos_signer_not_defined");return U.sign(D,I.msgs,I.fee,I.memo,{accountNumber:BigInt(I.accountNumber),chainId:I.chainId,sequence:I.sequence})}return{...J,broadcastMultisigTx:A0({chain:_,prefix:v}),buildAminoMsg:Hf,buildEncodedTxBody:ff,convertToSignable:n,createDefaultAminoTypes:()=>$(_),createDefaultRegistry:o,createMultisig:tf,createTransaction:Xf,deposit:S,getFees:F,importSignature:S0,parseAminoMessageForDirectSigning:p,pubkeyToAddress:async(I)=>{let{pubkeyToAddress:N}=(await import("@cosmjs/amino")).default;return N(I,v)},secp256k1HdWalletFromMnemonic:F0({derivationPath:Y.derivationPathToString(X),prefix:v}),signAndBroadcastTransaction:q,signMultisigTx:E0(_),signTransaction:K,signWithPrivateKey:k0,transfer:S}}var j,Y,t;var Ff=R(()=>{Yf();e();vf();j=require("@scure/base"),Y=require("@swapkit/helpers"),t=require("ts-pattern")});var b,U0=(_,H)=>{switch(_){case b.Chain.Cosmos:case b.Chain.Kujira:case b.Chain.Noble:return xf({chain:_,...H});case b.Chain.Maya:case b.Chain.THORChain:return Of({chain:_,...H});default:throw new b.SwapKitError("toolbox_cosmos_not_supported",{chain:_})}};var mf=R(()=>{vf();Ff();b=require("@swapkit/helpers");vf();Ff()});var R0={};kf(R0,{verifySignature:()=>df,transferMsgAmino:()=>If,toBase64:()=>y0,parseAminoMessageForDirectSigning:()=>p,getSignerFromPrivateKey:()=>X0,getSignerFromPhrase:()=>qf,getMsgSendDenom:()=>l,getFeeRateFromSwapKit:()=>Y0,getDenomWithChain:()=>s,getDefaultChainFee:()=>M,getCosmosToolbox:()=>U0,getCosmosAddressValidator:()=>of,getAssetFromDenom:()=>Gf,fromBase64:()=>z0,fetchFeeRateFromSwapKit:()=>Nf,estimateTransactionFee:()=>q0,depositMsgAmino:()=>Qf,createTransaction:()=>Xf,createThorchainToolbox:()=>Of,createStargateClient:()=>w,createSigningStargateClient:()=>i,createOfflineStargateClient:()=>yf,createDefaultRegistry:()=>o,createDefaultAminoTypes:()=>$,createCosmosToolbox:()=>xf,cosmosCreateTransaction:()=>zf,convertToSignable:()=>n,buildTransferTx:()=>hf,buildEncodedTxBody:()=>ff,buildDepositTx:()=>lf,buildAminoMsg:()=>Hf,bech32ToBase64:()=>a,base64ToBech32:()=>r,YUM_KUJIRA_FACTORY_DENOM:()=>Cf,USK_KUJIRA_FACTORY_DENOM:()=>Wf,THORCHAIN_GAS_VALUE:()=>I0,MAYA_GAS_VALUE:()=>Q0,DEFAULT_NOBLE_FEE_MAINNET:()=>Df,DEFAULT_KUJI_FEE_MAINNET:()=>Vf,DEFAULT_COSMOS_FEE_MAINNET:()=>Rf});module.exports=_0(R0);var V0=R(()=>{Yf();mf();e()});V0();
|