@swapkit/toolboxes 4.20.2 → 4.22.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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @swapkit/toolboxes
2
2
 
3
+ ## 4.22.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#313](https://github.com/swapkit/sdk/pull/313) [`d800a41`](https://github.com/swapkit/sdk/commit/d800a41b60219f2e792fd9e68761b4ae87240d4c) Thanks [@towanTG](https://github.com/towanTG)! - Add support for Robinhood Chain (RBH) — an Ethereum-compatible Arbitrum Orbit L2 (chain ID 4663) with ETH as the native gas token. Includes chain config, EVM toolbox (RBHToolbox), gas asset resolution (RBH.ETH), wallet network params, and explorer URLs via Blockscout. Default RPC is the public endpoint; production apps should configure a provider endpoint (e.g. QuickNode robinhood-mainnet) via SKConfig.setRpcUrl.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`d800a41`](https://github.com/swapkit/sdk/commit/d800a41b60219f2e792fd9e68761b4ae87240d4c)]:
12
+ - @swapkit/helpers@4.16.0
13
+
14
+ ## 4.21.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [#309](https://github.com/swapkit/sdk/pull/309) [`2cbca65`](https://github.com/swapkit/sdk/commit/2cbca65b786d9fb7e188b1fff36107887e963d3c) Thanks [@towanTG](https://github.com/towanTG)! - Return reserve-aware XLM balances, preserve Stellar issuer casing, and support USDC payments and trustline transactions.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [[`2cbca65`](https://github.com/swapkit/sdk/commit/2cbca65b786d9fb7e188b1fff36107887e963d3c)]:
23
+ - @swapkit/helpers@4.15.4
24
+
3
25
  ## 4.20.2
4
26
 
5
27
  ### Patch Changes
@@ -1 +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};
1
+ import"./chunk-fjyc6m34.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};
@@ -1,2 +1,2 @@
1
1
  var d=((a)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});
2
- export{d as ea};
2
+ export{d as fa};
@@ -1,2 +1,2 @@
1
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};
2
+ export{C as da,h as ea};
@@ -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,ca as Q,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-x9vsnagh.js";import"./chunk-jdh5asaw.js";import"./chunk-fjyc6m34.js";export{c as validateEVMAddress,h as toChecksumAddress,g as isStateChangingCall,o as isEIP7702Transaction,p as isEIP1559Transaction,d as isBrowserProvider,l as getTokenAddress,Q as getEvmToolboxAsync,P as getEvmToolbox,n as getEstimateGasPrices,q as getEVMTxType,i as getEIP1193SendTransaction,m as getCreateContractTxObject,f as getCreateContract,j as getChecksumAddressFromAsset,e as createContract,N as XLayerToolbox,M as UNIToolbox,L as SONICToolbox,K as RBHToolbox,J as PLASMAToolbox,O 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};
@@ -0,0 +1,2 @@
1
+ import{ea as Wt}from"./chunk-jdh5asaw.js";import{fa as g}from"./chunk-fjyc6m34.js";import{Chain as w}from"@swapkit/helpers";import{match as Cy}from"ts-pattern";import{Chain as q,getChainConfig as P,getRPCUrl as rt,SKConfig as ty,SwapKitError as K}from"@swapkit/helpers";import{FallbackProvider as yy,getAddress as Dt,Interface as uy,JsonRpcProvider as s,Network as ny}from"ethers";import{match as Lt}from"ts-pattern";function Ty(t){return new s(t)}async function vy(t,y){return Ty(y||await rt(t))}function Rt(t){let y=ty.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}=P(t),n=ny.from(Number(u)),[T]=y;if(y.length===1)return new s(T,n,{staticNetwork:n});return new yy(y.map((l,b)=>({priority:b+1,provider:new s(l,n,{staticNetwork:n}),stallTimeout:2000})),n,{quorum:1})}function N(t){return t>0n?`0x${t.toString(16)}`:"0x0"}function qt(t){let{explorerUrl:y,chainIdHex:u,rpcUrls:n}=P(t);return function(){return t!==q.Ethereum?{...ly({chain:t}),blockExplorerUrls:[y],chainId:u,rpcUrls:n}:void 0}}function Gt(t){return![q.Adi,q.Arbitrum,q.BinanceSmartChain,q.Robinhood].includes(t)}function ly({chain:t}){let{name:y,nativeCurrency:u,baseDecimal:n}=P(t);return Lt(t).with(q.Arbitrum,()=>({chainName:"Arbitrum One",nativeCurrency:{decimals:n,name:"Ethereum",symbol:q.Ethereum}})).with(q.Aurora,()=>({chainName:"Aurora Mainnet",nativeCurrency:{decimals:n,name:"Ethereum",symbol:q.Ethereum}})).with(q.Avalanche,()=>({chainName:"Avalanche Network",nativeCurrency:{decimals:n,name:"Avalanche",symbol:t}})).with(q.Base,()=>({chainName:"Base Mainnet",nativeCurrency:{decimals:n,name:"Ethereum",symbol:q.Ethereum}})).with(q.Berachain,()=>({chainName:"Berachain",nativeCurrency:{decimals:n,name:"Berachain",symbol:"BERA"}})).with(q.XLayer,()=>({chainName:"X Layer",nativeCurrency:{decimals:n,name:"OKB",symbol:"OKB"}})).with(q.BinanceSmartChain,()=>({chainName:"BNB Smart Chain Mainnet",nativeCurrency:{decimals:n,name:"Binance Coin",symbol:"BNB"}})).with(q.Gnosis,()=>({chainName:"Gnosis",nativeCurrency:{decimals:n,name:"xDAI",symbol:"XDAI"}})).with(q.Optimism,()=>({chainName:"OP Mainnet",nativeCurrency:{decimals:n,name:"Ethereum",symbol:q.Ethereum}})).with(q.Polygon,()=>({chainName:"Polygon Mainnet",nativeCurrency:{decimals:n,name:"Polygon",symbol:q.Polygon}})).with(q.Robinhood,()=>({chainName:"Robinhood Chain",nativeCurrency:{decimals:n,name:"Ethereum",symbol:q.Ethereum}})).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),by=(t)=>{try{return typeof t==="string"&&!!Dt(t)}catch{return!1}};function My(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})=>!by(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 Dy(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 hy({chain:t,abi:y,data:u,to:n}){let l=new uy(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,Q]of l.fragment.inputs.entries())R[Q.name]=a(l.args[D],Q);let{chainId:B}=P(t),G={chainId:Number(B),verifyingContract:Dt(n)},X=Dy(G);return{domain:G,message:R,primaryType:M,types:{EIP712Domain:X,...b}}}function wt(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(My(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 W,FeeOption as Ny}from"@swapkit/helpers";import{HDNodeWallet as Vy}from"ethers";import{match as Sy,P as Jt}from"ts-pattern";var Ht=[{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 Ly,applyFeeMultiplierToBigInt as $,Chain as k,EVMChains as Ry,FeeOption as L,isGasAsset as qy,SwapKitError as H,SwapKitNumber as m}from"@swapkit/helpers";import{erc20ABI as x}from"@swapkit/helpers/contracts";import{BrowserProvider as Gy,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 iy(t){return t}var tt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function c({chain:t=k.Ethereum,provider:y,signer:u,isEIP1559Compatible:n=!0}){return{approve:Zy({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:_y({chain:t,provider:y,signer:u}),createContract:wy({chain:t,provider:y}),createContractTxObject:F({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:zy({chain:t,provider:y,signer:u}),estimateGasPrices:A({chain:t,isEIP1559Compatible:n,provider:y}),estimateTransactionFee:jy({chain:t,isEIP1559Compatible:n,provider:y}),getAddress:()=>{return u?u.getAddress():void 0},getBalance:C(t).getBalance,getNetworkParams:qt(t),isApproved:Yy({chain:t,provider:y}),sendTransaction:zt({chain:t,isEIP1559Compatible:n,provider:y,signer:u}),signAuthorization:Jy({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:$y({chain:t,isEIP1559Compatible:n,provider:y,signer:u}),validateAddress:By}}function By(t){try{return p(t),!0}catch{return!1}}function v(t){return t instanceof Gy}function yt(t,y,u){return new Ut(t,Qt.from(y),u)}function wy({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 H("toolbox_evm_no_abi_fragment",{funcName:y});return u.stateMutability&&Hy.includes(u.stateMutability)}function lu(t){return p(t)}function h(t){return function({value:u,...n}){if(!v(t))throw new H("toolbox_evm_provider_not_eip1193_compatible");let{gasLimit:T,gasPrice:l,maxFeePerGas:b,maxPriorityFeePerGas:M,...R}=n;return t.send("eth_sendTransaction",[{...R,value:N(BigInt(u||0))}])}}function bu(t,y){let u=d(t,y);if(u)return p(u.toLowerCase());throw new H("toolbox_evm_invalid_gas_asset_address")}var Uy=Ry.reduce((t,y)=>{return t[y]="0x0000000000000000000000000000000000000000",t},{}),Qy={...Uy,[k.Optimism]:"0x4200000000000000000000000000000000000042",[k.Polygon]:"0x0000000000000000000000000000000000001010"},Xy=[k.Arbitrum,k.Aurora,k.Base,k.Optimism,k.Robinhood];function d({chain:t,symbol:y,ticker:u},n){try{let T=t===k.BinanceSmartChain&&y==="BNB"&&u==="BNB",l=t===k.Hyperevm&&y==="HYPE"&&u==="HYPE",b=t===n&&y===n&&u===n,M=Xy.includes(t)&&y==="ETH"&&u==="ETH";if(b||T||l||M)return Qy[n];return p(y.slice(u.length+1).replace(/^0X/,""))}catch{return null}}function F({provider:t}){return async({contractAddress:y,abi:u,funcName:n,funcParams:T=[],txOverrides:l})=>{let b=await yt(y,u,t).getFunction(n).populateTransaction(...T.concat(l).filter((M)=>typeof M<"u"));return{...b,value:N(BigInt(b.value||0))}}}function A({chain:t,provider:y,isEIP1559Compatible:u=!0}){return Xt(t).with(k.Gnosis,()=>{return async function(){try{let{gasPrice:T,maxPriorityFeePerGas:l}=await y.getFeeData();if(!T||l===null)throw new H("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 H("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}}).with(k.Arbitrum,()=>{return async function(){try{let{gasPrice:T}=await y.getFeeData();if(!T)throw new H("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 H("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 H("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 H("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 H("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:B=[],txOverrides:G={},feeOption:X=L.Fast}){let D=l||t;if(!b)throw new H("toolbox_evm_invalid_params",{error:"contractAddress must be provided"});let Q=Wy({abi:M,funcName:R});if(Q&&v(D)&&u){let z=F({chain:n,provider:D}),_=G?.from||await u?.getAddress(),f=await z({abi:M,contractAddress:b,funcName:R,funcParams:B,txOverrides:{...G,from:_}});return h(D)(f)}let Y=yt(b,M,D);if(Q){if(!u)throw new H("toolbox_evm_no_signer");let z=G?.from||await u.getAddress();if(!z)throw new H("toolbox_evm_no_signer_address");let _=Y.connect(u),f=A({chain:n,isEIP1559Compatible:y,provider:t}),{maxFeePerGas:V,maxPriorityFeePerGas:E,gasPrice:o}=(await f())[X],O=await Y.getFunction(R).estimateGas(...B,G),J=await _[R](...B,{...G,gasLimit:O,gasPrice:o,maxFeePerGas:V,maxPriorityFeePerGas:E,nonce:G?.nonce||await D.getTransactionCount(z)});return typeof J?.hash==="string"?J?.hash:J}let Z=await Y[R]?.(...B);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:x,contractAddress:n,funcName:"allowance",funcParams:[l,T]})}}function Yy({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 Zy({signer:t,isEIP1559Compatible:y=!0,provider:u,chain:n}){return async function({assetAddress:l,spenderAddress:b,feeOptionKey:M=L.Fast,amount:R,gasLimitFallback:B,from:G,nonce:X}){let D=[b,BigInt(R||tt)],Q=await t?.getAddress()||G,Y={abi:x,contractAddress:l,funcName:"approve",funcParams:D,signer:t,txOverrides:{from:Q}};if(v(u)){let z=F({chain:n,provider:u}),_=h(u),f=await z(Y);return _(f)}return ut({chain:n,isEIP1559Compatible:y,provider:u,signer:t})({...Y,feeOption:M,funcParams:D,txOverrides:{from:Q,gasLimit:B?BigInt(B.toString()):void 0,nonce:X}})}}function $y({signer:t,isEIP1559Compatible:y=!0,provider:u}){return async function({assetValue:T,memo:l,recipient:b,feeOptionKey:M=L.Fast,sender:R,...B}){let{hexlify:G,toUtf8Bytes:X}=await import("ethers"),D=T.getBaseValue("bigint"),Q=T.chain,Y=R||await t?.getAddress(),Z=zt({chain:Q,isEIP1559Compatible:y,provider:u,signer:t});if(!Y)throw new H("toolbox_evm_no_from_address");if(T.isGasAsset){let o={...B,data:G(X(l||"")),feeOptionKey:M,from:Y,to:b,value:N(D)};return Z(o)}if(!d(T,Q))throw new H("toolbox_evm_no_contract_address");let{maxFeePerGas:_,maxPriorityFeePerGas:f,gasPrice:V}=(await A({chain:Q,isEIP1559Compatible:y,provider:u})())[M],E=await r({chain:Q,provider:u,signer:t})({assetValue:T,data:G(X(l||"")),gasPrice:V,maxFeePerGas:_,maxPriorityFeePerGas:f,memo:l,recipient:b,sender:Y});return Z(E)}}function Zt({provider:t,signer:y}){return function({contractAddress:n,abi:T,funcName:l,funcParams:b=[],txOverrides:M}){if(!n)throw new H("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 zy({provider:t,signer:y}){return async function({assetValue:n,recipient:T,memo:l,data:b,sender:M,funcName:R,funcParams:B,txOverrides:G}){let X=n.bigIntValue,D=n.isGasAsset?null:d(n,n.chain);if(D&&R)return Zt({provider:t,signer:y})({abi:x,contractAddress:D,funcName:R,funcParams:B,txOverrides:G});let{hexlify:Q,toUtf8Bytes:Y}=await import("ethers");return t.estimateGas({data:b?b:l?Q(Y(l)):void 0,from:M,to:T,value:X})}}function Jy({signer:t}){if(!t)return;return(y)=>Bt(t,y)}var $t=(t)=>t.type===4||(t.authorizations?.length??0)>0,fy=(t)=>!$t(t)&&(t.type===2||!!t.maxFeePerGas||!!t.maxPriorityFeePerGas),ky=(t,y=!0)=>{if($t(t))return"eip7702";if(fy(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:B,value:G,...X}=b;if(!y)throw new H("toolbox_evm_no_signer");if(!R)throw new H("toolbox_evm_no_to_address");let D={...X,data:B||"0x",from:M,to:R,value:BigInt(G||0)};if(v(t))return h(t)(D);let Q=M||await y.getAddress(),Y=b.nonce||await t.getTransactionCount(Q),Z=(await t.getNetwork()).chainId,z=ky(D,u);if(z==="eip7702")wt(D.authorizations||[],Z);let _=Xt(z).with("eip7702",()=>4).with("eip1559",()=>2).otherwise(()=>0),f={...D,chainId:Z,nonce:Y,type:_,...z==="eip7702"&&{authorizationList:D.authorizations}},V=A({chain:n,isEIP1559Compatible:u,provider:t}),o=z!=="legacy"&&!(D.maxFeePerGas&&D.maxPriorityFeePerGas)||!D.gasPrice?Object.entries((await V())[l]).reduce((J,[I,bt])=>({...J,[I]:N(BigInt(bt))}),{}):{},O;try{O=N(D.gasLimit?BigInt(D.gasLimit):await t.estimateGas(f)*11n/10n)}catch(J){throw new H("toolbox_evm_error_estimating_gas_limit",{error:J})}try{let J={...f,gasLimit:O,...o};try{return(await y.sendTransaction(J)).hash}catch{let I=await y.signTransaction({...J,from:Q});return(await t.broadcastTransaction(I)).hash}}catch(J){throw new H("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:B,gasPrice:G,...X}){let D=n.getBaseValue("bigint"),Q=n.chain,Y=M||await y?.getAddress();if(!Y)throw new H("toolbox_evm_no_from_address");if(qy(n)){let{hexlify:_,toUtf8Bytes:f}=await import("ethers");return{...X,data:b||_(f(T||"")),from:Y,to:l,value:N(D)}}let Z=d(n,Q);if(!Z)throw new H("toolbox_evm_no_contract_address");return F({chain:n.chain,provider:t})({abi:x,contractAddress:Z,funcName:"transfer",funcParams:[l,D],txOverrides:{from:Y,gasPrice:G,maxFeePerGas:R,maxPriorityFeePerGas:B}})}}function _y({provider:t,signer:y,chain:u}){return async function({assetAddress:T,spenderAddress:l,amount:b,from:M}){let R=await y?.getAddress()||M,B=F({chain:u,provider:t}),G=["bigint","number"].includes(typeof b)?b:b||tt;return await B({abi:x,contractAddress:T,funcName:"approve",funcParams:[l,BigInt(G)],txOverrides:{from:R}})}}function jy({provider:t,isEIP1559Compatible:y=!0,chain:u}){return async function({feeOption:T=L.Fast,...l}){let M=await A({chain:u,isEIP1559Compatible:y,provider:t})(),R=await t.estimateGas(l),B=Ly.from({chain:u}),{gasPrice:G,maxFeePerGas:X,maxPriorityFeePerGas:D}=M[T];if(!y&&G)return B.set(m.fromBigInt(G*R,B.decimal));if(X&&D){let Q=(X+D)*R;return B.set(m.fromBigInt(Q,B.decimal))}throw new H("toolbox_evm_no_gas_price")}}function ft(t){let y=U(W.Ethereum)(t);async function u(n,T="0x5ba1e12693dc8f9c48aad8770482f4739beed696",l="aggregate",b=Ny.Fast){let M=await y.createContractTxObject({abi:Ht,contractAddress:T,funcName:l,funcParams:[n]});return y.sendTransaction({...M,feeOptionKey:b})}return{...y,multicall:u}}var kt=U(W.Adi),_t=U(W.Arbitrum),jt=U(W.Aurora),Nt=U(W.Avalanche),Vt=U(W.Base),St=U(W.Berachain),ot=U(W.BinanceSmartChain),wu=U(W.Botanix),Kt=U(W.Core),xt=U(W.Corn),Ft=U(W.Cronos),At=U(W.Gnosis),Et=U(W.Hyperevm),Ot=U(W.Linea),It=U(W.Polygon),Pt=U(W.MegaETH),Ct=U(W.Monad),mt=U(W.Plasma),gt=U(W.Robinhood),nt=U(W.Sonic),pt=U(W.Unichain),ct=U(W.XLayer);function U(t){return function({provider:u,...n}){let T=Gt(t),l=Sy(n).with({phrase:Jt.string},({phrase:M})=>Vy.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 xy,HDNodeWallet as Fy}from"ethers";import{match as Ay,P as ht}from"ts-pattern";var vt=[{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 Ey="0x420000000000000000000000000000000000000f";function lt(t){return new xy(Ey,vt,t)}function dt(t){return async function(){let u=lt(t);if(u&&"l1BaseFee"in u)return await u?.l1BaseFee();return}}function st(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 et(t){return async function(u){let n=lt(t),T=await st(t)(u);if(n&&"getL1Fee"in n)return n.getL1Fee(T)}}function it(t){return async function(u){let T=(await t.getFeeData()).gasPrice??0n,l=await t.estimateGas(u);return T*l}}function Oy(t){return async function(u){let n=await et(t)(u)??0n,T=await it(t)(u);return n+T}}function Iy(t){return async function(u){let n=lt(t),T=await st(t)(u);if(n&&"getL1GasUsed"in n)return n.getL1GasUsed(T)}}function Py(t){return async function(){try{let{maxFeePerGas:u,maxPriorityFeePerGas:n,gasPrice:T}=await t.getFeeData(),l=await dt(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 at({provider:t,...y}){let u=Ay(y).with({phrase:ht.string},({phrase:l})=>Fy.fromPhrase(l).connect(t)).with({signer:ht.any},({signer:l})=>l).otherwise(()=>{return}),n=c({provider:t,signer:u}),T=dt(t);return{...n,estimateGasPrices:Py(t),estimateL1Gas:Iy(t),estimateL1GasCost:et(t),estimateL2GasCost:it(t),estimateTotalGasCost:Oy(t),getBalance:C(Ky.Optimism).getBalance,getL1GasPrice:T}}function my(t,y){return Cy(t).with(w.Adi,()=>kt(y)).with(w.Arbitrum,()=>_t(y)).with(w.Aurora,()=>jt(y)).with(w.Avalanche,()=>Nt(y)).with(w.Base,()=>Vt(y)).with(w.Berachain,()=>St(y)).with(w.BinanceSmartChain,()=>ot(y)).with(w.Botanix,()=>nt(y)).with(w.Core,()=>Kt(y)).with(w.Corn,()=>xt(y)).with(w.Cronos,()=>Ft(y)).with(w.Ethereum,()=>ft(y)).with(w.Gnosis,()=>At(y)).with(w.Hyperevm,()=>Et(y)).with(w.Linea,()=>Ot(y)).with(w.MegaETH,()=>Pt(y)).with(w.Monad,()=>Ct(y)).with(w.Optimism,()=>at(y)).with(w.Plasma,()=>mt(y)).with(w.Polygon,()=>It(y)).with(w.Robinhood,()=>gt(y)).with(w.Sonic,()=>nt(y)).with(w.Unichain,()=>pt(y)).with(w.XLayer,()=>ct(y)).exhaustive()}async function _u(t,y){let u={...y,provider:y?.provider||Rt(t)};return my(t,u)}
2
+ export{C as b,iy as c,Ty as d,vy as e,Rt as f,N as g,qt as h,Gt as i,Bt as j,My as k,Dy as l,hy as m,wt as n,tt as o,c as p,By as q,v as r,yt as s,wy as t,Wy as u,lu as v,h as w,bu as x,Qy as y,d as z,F as A,A as B,$t as C,fy as D,ky as E,ft as F,kt as G,_t as H,jt as I,Nt as J,Vt as K,St as L,ot as M,wu as N,Kt 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,gt as Y,nt as Z,pt as _,ct as $,at as aa,my as ba,_u as ca};
@@ -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
+ import{fa as E}from"../../chunk-fjyc6m34.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
- 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
+ import{fa as P}from"../../chunk-fjyc6m34.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
- import{ea as i}from"../../chunk-ntbvmmch.js";import{base64 as N,bech32 as A}from"@scure/base";import{SwapKitError as Ko}from"@swapkit/helpers";function O(o){return N.encode(Uint8Array.from(A.fromWords(A.decode(o).words)))}function U(o,t="thor"){return A.encode(t,A.toWords(N.decode(o)))}function st(o){return N.encode(o)}function Pt(o){if(!o.match(/^[a-zA-Z0-9+/]*={0,2}$/))throw new Ko("toolbox_cosmos_invalid_params",{error:"Invalid base64 string format"});return N.decode(o)}import{AssetValue as Vo,Chain as b,getChainConfig as mo,getRPCUrl as eo,SwapKitError as ho}from"@swapkit/helpers";import{AssetValue as g,Chain as x,getChainConfig as C,getRPCUrl as lo,SwapKitError as yo}from"@swapkit/helpers";var wo="FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK",Ao="FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM",No={amount:[{amount:"500",denom:"uatom"}],gas:"200000"},Oo={amount:[{amount:"1000",denom:"ukuji"}],gas:"200000"},Uo={amount:[{amount:"1000",denom:"uusdc"}],gas:"200000"};function P(o){switch(o){case x.Maya:return{amount:[],gas:"10000000000"};case x.THORChain:return{amount:[],gas:"500000000"};case x.Kujira:return Oo;case x.Noble:return Uo;default:return No}}var z=(o,t=!1)=>{if(t)return o.toLowerCase();switch(o){case"uUSK":case"USK":return wo;case"uYUM":case"YUM":return Ao;case"uKUJI":case"KUJI":return"ukuji";case"ATOM":case"uATOM":return"uatom";case"uUSDC":case"USDC":return"uusdc";default:return o}},E=({symbol:o,chain:t})=>{if(t===x.Maya)return(o.toUpperCase()!=="CACAO"?o:`${x.Maya}.${o}`).toUpperCase();if(t===x.THORChain)return(["RUNE","TCY","RUJI"].includes(o.toUpperCase())?`${x.THORChain}.${o}`:o).toUpperCase();return z(o,!1)};async function j(o){let t=await import("@cosmjs/stargate"),p=t.StargateClient??t.default?.StargateClient,r=typeof window<"u"?{}:{referer:"https://sdk.swapkit.dev",referrer:"https://sdk.swapkit.dev"};return p.connect({headers:r,url:o})}async function X(o,t,p={}){let r=await import("@cosmjs/stargate"),f=r.SigningStargateClient??r.default?.SigningStargateClient,c=r.GasPrice??r.default?.GasPrice,n=typeof p==="string"?p:"0.0003uatom",T=typeof p==="string"?{}:p;return f.connectWithSigner(o,t,{gasPrice:c.fromString(n),...T})}async function To(o,t){let p=await import("@cosmjs/stargate");return(p.SigningStargateClient??p.default?.SigningStargateClient).offline(o,t)}var Eo=(o)=>{switch(o){case x.Maya:case x.THORChain:return"/types.MsgSend";case x.Cosmos:case x.Kujira:case x.Noble:return"/cosmos.bank.v1beta1.MsgSend";default:throw new yo("toolbox_cosmos_not_supported",{chain:o})}};async function xo({sender:o,recipient:t,assetValue:p,memo:r="",feeRate:f,sequence:c,accountNumber:n}){let{chain:T,chainId:m}=p,d=await lo(T),k=await(await j(d)).getAccount(o);if(!k)throw new yo("toolbox_cosmos_account_not_found",{sender:o});let R=g.from({chain:T}),w=z(R.symbol),u=P(T),v=w&&f?{amount:[{amount:f.toString(),denom:w}],gas:u.gas}:u,B={amount:[{amount:p.getBaseValue("string"),denom:z(p.symbol)}],fromAddress:o,toAddress:t};return{accountNumber:n??Number(k.accountNumber),chainId:m,fee:v,memo:r,msgs:[{typeUrl:Eo(T),value:B}],sequence:c??k.sequence}}var bo={atom:{chain:x.Cosmos,decimals:C(x.Cosmos).baseDecimal},cacao:{chain:x.Maya,decimals:10},kuji:{chain:x.Kujira,decimals:C(x.Kujira).baseDecimal},maya:{asset:`${x.Maya}.${x.Maya}`,decimals:4},rune:{chain:x.THORChain,decimals:C(x.THORChain).baseDecimal},tcy:{asset:"THOR.TCY",decimals:C(x.THORChain).baseDecimal},uatom:{chain:x.Cosmos,decimals:C(x.Cosmos).baseDecimal},ukuji:{chain:x.Kujira,decimals:C(x.Kujira).baseDecimal},usdc:{chain:x.Noble,decimals:C(x.Noble).baseDecimal},uusdc:{chain:x.Noble,decimals:C(x.Noble).baseDecimal},"x/kuji":{asset:"THOR.KUJI",decimals:C(x.THORChain).baseDecimal},[wo.toLowerCase()]:{asset:`${x.Kujira}.USK`,decimals:C(x.Kujira).baseDecimal}},uo=(o,t)=>{let p=bo[o.toLowerCase()];if(!p)return g.from({asset:o,fromBaseDecimal:8,value:t});let{chain:r,asset:f,decimals:c}=p,n=r?{chain:r}:{asset:f};return g.from({...n,fromBaseDecimal:c,value:t})};import{Chain as Mo}from"@swapkit/helpers";async function J(){let{$root:o}=await import("../../chunk-3pne8gaa.js"),t=await import("@cosmjs/proto-signing"),p=await import("@cosmjs/stargate"),r=t.Registry??t.default?.Registry,f=p.defaultRegistryTypes??p.default?.defaultRegistryTypes;return new r([...f,["/types.MsgSend",o.types.MsgSend],["/types.MsgDeposit",o.types.MsgDeposit]])}async function D(o){let t=await import("@cosmjs/stargate"),p=t.AminoTypes??t.default?.AminoTypes,r=o===Mo.THORChain?"thorchain":"mayachain";return new p({"/types.MsgDeposit":{aminoType:`${r}/MsgDeposit`,fromAmino:({signer:f,...c})=>({...c,signer:O(f)}),toAmino:({signer:f,...c})=>({...c,signer:U(f)})},"/types.MsgSend":{aminoType:`${r}/MsgSend`,fromAmino:({from_address:f,to_address:c,...n})=>({...n,fromAddress:O(f),toAddress:O(c)}),toAmino:({fromAddress:f,toAddress:c,...n})=>({...n,from_address:U(f),to_address:U(c)})}})}var Yt=P(b.THORChain).gas,Ft=P(b.Maya).gas,io=({sender:o,recipient:t,assetValue:p})=>{return{type:`${p.chain===b.Maya?"mayachain":"thorchain"}/MsgSend`,value:{amount:[{amount:p.getBaseValue("string"),denom:z(p.symbol,!0)}],from_address:o,to_address:t}}},ko=({sender:o,assetValue:t,memo:p=""})=>{return{type:`${t.chain===b.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:t.getBaseValue("string"),asset:E(t)}],memo:p,signer:o}}},oo=({sender:o,recipient:t,assetValue:p,memo:r})=>{return!t?ko({assetValue:p,memo:r,sender:o}):io({assetValue:p,recipient:t,sender:o})},G=async(o,t)=>{return(await D(t)).fromAmino(o)},vo=async({rpcUrl:o,sender:t})=>{let r=await(await j(o)).getAccount(t);if(!r)throw new ho("toolbox_cosmos_account_not_found",{sender:t});return r};function Wo(o){let{assetValue:t,recipient:p,memo:r,sender:f,asSignable:c,asAminoMessage:n}=o;if(p)return ao({asAminoMessage:n,asSignable:c,assetValue:t,memo:r,recipient:p,sender:f});return go({asAminoMessage:n,asSignable:c,assetValue:t,memo:r,sender:f})}async function ao({sender:o,recipient:t,assetValue:p,memo:r="",asSignable:f=!0,asAminoMessage:c=!1,sequence:n,accountNumber:T}){let m=p.chain,d=await eo(m),H=await vo({rpcUrl:d,sender:o}),{chainId:k}=mo(m),R=io({assetValue:p,recipient:t,sender:o}),w=f?await G(c?R:Z(R),m):R;return{accountNumber:T||Number(H.accountNumber),chainId:k,fee:P(m),memo:r,msgs:[w],sequence:n||H.sequence}}async function go({sender:o,assetValue:t,memo:p="",asSignable:r=!0,asAminoMessage:f=!1,sequence:c,accountNumber:n}){let T=t.chain,m=await eo(T),d=await vo({rpcUrl:m,sender:o}),{chainId:H}=mo(T),k=ko({assetValue:t,memo:p,sender:o}),R=r?await G(f?k:Z(k),T):k;return{accountNumber:n||Number(d.accountNumber),chainId:H,fee:P(T),memo:p,msgs:[R],sequence:c||d.sequence}}function Z(o){if(o.type==="thorchain/MsgSend"||o.type==="mayachain/MsgSend")return o;return{...o,value:{...o.value,coins:o.value.coins.map((t)=>{let p=Vo.from({asset:t.asset}),r=(p.isSynthetic?p.symbol.split("/")?.[1]:p.symbol)?.toUpperCase(),f=(p.isSynthetic?p.symbol.split("/")?.[0]:p.chain)?.toUpperCase();return{...t,asset:{chain:f,symbol:r,synth:p.isSynthetic,ticker:p.ticker}}})}}}async function M({chain:o,memo:t,msgs:p}){let r=await J(),f=await D(o),c={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:t,messages:p.map((n)=>f.fromAmino(n))}};return r.encode(c)}import{Chain as l,SwapKitError as _t}from"@swapkit/helpers";import{base64 as po,bech32 as to}from"@scure/base";import{AssetValue as fo,applyFeeMultiplier as Ho,Chain as I,CosmosChainPrefixes as Co,DerivationPath as ot,derivationPathToString as Bo,FeeOption as co,getChainConfig as tt,getRPCUrl as K,NetworkDerivationPath as rt,SwapKitError as Y,SwapKitNumber as ro,updateDerivationPath as pt}from"@swapkit/helpers";import{SwapKitApi as so}from"@swapkit/helpers/api";import{match as ft,P as Io}from"ts-pattern";async function Po(o,t){try{let r=(await so.getGasRate()).find((f)=>f.chainId===o)?.value;return r?Number.parseFloat(r):t}catch{return t}}async function Ro({phrase:o,prefix:t,...p}){let r=await import("@cosmjs/proto-signing"),f=await import("@cosmjs/crypto"),c=r.DirectSecp256k1HdWallet??r.default?.DirectSecp256k1HdWallet,n=f.stringToPath??f.default?.stringToPath,T="derivationPath"in p?p.derivationPath:`${ot[p.chain]}/${p.index}`;return await c.fromMnemonic(o,{hdPaths:[n(T)],prefix:t})}async function at({privateKey:o,prefix:t}){let p=await import("@cosmjs/proto-signing");return(p.DirectSecp256k1Wallet??p.default?.DirectSecp256k1Wallet).fromKey(o,t)}var _o={[I.Cosmos]:1000,[I.Kujira]:1000,[I.Noble]:1000,[I.THORChain]:5000000,[I.Maya]:5000000,[I.Harbor]:5000000};function ct(o){return async function({signature:p,message:r,address:f}){let c=await o(f);if(!c?.pubkey)throw new Y("toolbox_cosmos_verify_signature_no_pubkey");let n=await import("@cosmjs/crypto"),T=n.Secp256k1Signature??n.default?.Secp256k1Signature,m=n.Secp256k1??n.default?.Secp256k1,d=T.fromFixedLength(po.decode(p));return m.verifySignature(d,po.decode(r),c.pubkey.value)}}function V({chain:o,...t}){let p=Co[o],r="index"in t?t.index||0:0,f=Bo("derivationPath"in t&&t.derivationPath?t.derivationPath:pt(rt[o],{index:r})),c;async function n(){if(c)return c;return c=await ft(t).with({phrase:Io.string},({phrase:w})=>Ro({derivationPath:f,phrase:w,prefix:p})).with({signer:Io.any},({signer:w})=>w).otherwise(()=>{return}),c}async function T(w){let u=await K(o);return(await j(u)).getAccount(w)}async function m(){let w=await n(),[u]=await w?.getAccounts()||[];return u?.address}async function d(){let w=await n(),[u]=await w?.getAccounts()||[];if(!u?.pubkey)throw new Y("toolbox_cosmos_signer_not_defined");return po.encode(u?.pubkey)}async function H(w){let u=await n(),v=await m(),B=await K(o);if(!(u&&v))throw new Y("toolbox_cosmos_signer_not_defined");return await(await X(B,u)).sign(v,w.msgs,w.fee,w.memo,{accountNumber:BigInt(w.accountNumber),chainId:w.chainId,sequence:w.sequence})}async function k(w){let u=await n(),v=await m(),B=await K(o);if(!(u&&v))throw new Y("toolbox_cosmos_signer_not_defined");let y=await(await X(B,u)).signAndBroadcast(v,w.msgs,w.fee,w.memo);if(y.code!==0)throw new Y("core_swap_transaction_error",{code:y.code,message:y.rawLog});return y.transactionHash}async function R({recipient:w,assetValue:u,memo:v="",feeRate:B,feeOptionKey:W=co.Fast}){let y=await n(),e=await m();if(!(y&&e))throw new Y("toolbox_cosmos_signer_not_defined");let _=await K(o),$=fo.from({chain:o}),s=E($),S=B||nt((await $o(o,_o[o]))[W],s),L=await X(_,y),h=z(u.symbol),q=[{amount:u.getBaseValue("string"),denom:h}],{transactionHash:a}=await L.sendTokens(e,w,q,S,v);return a}return{createPrivateKeyFromPhrase:Tt(f),createTransaction:xo,fetchFeeRateFromSwapKit:Po,getAccount:T,getAddress:m,getBalance:async(w,u)=>{let v=await Lo(o)(w),B=await Promise.all(v.filter(({denom:W})=>W&&!W.includes("IBC/")&&!([I.THORChain,I.Maya].includes(o)&&W.split("-").length>2)).map(({denom:W,amount:y})=>{let e=[I.THORChain,I.Maya].includes(o)&&(W.includes("/")||W.includes("˜"))?`${o}.${W}`:W;return uo(e,y)}));if(B.length===0)return[fo.from({chain:o})];return B},getBalanceAsDenoms:Lo(o),getFees:()=>$o(o,_o[o]),getPubKey:d,getSignerFromPhrase:({phrase:w,derivationPath:u})=>Ro({derivationPath:Bo(u),index:r,phrase:w,prefix:p}),getSignerFromPrivateKey:async(w)=>{let u=await import("@cosmjs/proto-signing");return(u.DirectSecp256k1Wallet??u.default?.DirectSecp256k1Wallet).fromKey(w,p)},signAndBroadcastTransaction:k,signTransaction:H,transfer:R,validateAddress:wt(o),verifySignature:ct(T)}}async function gt(o,t){try{let r=(await so.getGasRate()).find((f)=>f.chainId===o)?.value;return r?Number.parseFloat(r):t}catch{return t}}function or({assetValue:{chain:o}}){return fo.from({chain:o,value:yt(o)})}async function $o(o,t){let{chainId:p,baseDecimal:r}=tt(o),f=await Po(p,t);return{average:ro.fromBigInt(BigInt(f),r),fast:ro.fromBigInt(BigInt(Ho(f,co.Fast,!0)),r),fastest:ro.fromBigInt(BigInt(Ho(f,co.Fastest,!0)),r)}}function nt(o,t){return{amount:[{amount:o.getBaseValue("string"),denom:t}],gas:"200000"}}function yt(o){return{[I.Cosmos]:0.007,[I.Kujira]:0.02,[I.Noble]:0.01,[I.THORChain]:0.02,[I.Maya]:0.02,[I.Harbor]:0.02}[o]||0}function wt(o){let t=Co[o];return function(r){if(!r.startsWith(t))return!1;try{let{prefix:f,words:c}=to.decode(r);return to.encode(f,c)===r.toLocaleLowerCase()}catch{return!1}}}function Lo(o){return async function(p){let r=await K(o);return(await(await j(r)).getAllBalances(p)).map((T)=>({...T,denom:T.denom.includes("/")?T.denom.toUpperCase():T.denom}))}}function Tt(o){return async function(p){let r=await import("@cosmjs/crypto"),f=r.stringToPath??r.default?.stringToPath,c=r.Slip10Curve??r.default?.Slip10Curve,n=r.Slip10??r.default?.Slip10,T=r.EnglishMnemonic??r.default?.EnglishMnemonic,m=r.Bip39??r.default?.Bip39,d=new T(p),H=await m.mnemonicToSeed(d),{privkey:k}=n.derivePath(c.Secp256k1,H,f(o));return k}}import{base64 as Q}from"@scure/base";import{Chain as xt,CosmosChainPrefixes as ut,derivationPathToString as mt,FeeOption as no,getChainConfig as et,getRPCUrl as Go,NetworkDerivationPath as it,RequestClient as dt,SKConfig as jo,SwapKitError as F,SwapKitNumber as So,updateDerivationPath as kt}from"@swapkit/helpers";import{match as zo,P as Do}from"ts-pattern";function vt({prefix:o,derivationPath:t}){return async function(r,f=0){let c=await import("@cosmjs/amino"),n=c.Secp256k1HdWallet??c.default?.Secp256k1HdWallet,T=await import("@cosmjs/crypto"),m=T.stringToPath??T.default?.stringToPath;return n.fromMnemonic(r,{hdPaths:[m(`${t}/${f}`)],prefix:o})}}function Wt(o){return Q.encode(o)}function Ht(o){return async function({wallet:p,tx:r}){let{msgs:f,accountNumber:c,sequence:n,chainId:T,fee:m,memo:d}=typeof r==="string"?JSON.parse(r):r,H=(await p.getAccounts())?.[0]?.address||"",k=await D(o),R=await J(),w=await To(p,{aminoTypes:k,registry:R}),u=[];for(let W of f){let y=await G(W,o);u.push(y)}let{signatures:[v]}=await w.sign(H,u,m,d,{accountNumber:BigInt(c),chainId:T,sequence:n});return{bodyBytes:await M({chain:o,memo:d,msgs:f.map(Z)}),signature:Wt(v)}}}function Bt({prefix:o,chain:t}){return async function(r,f,c,n,T){let m=await Go(t),{encodeSecp256k1Pubkey:d,pubkeyToAddress:H}=(await import("@cosmjs/amino")).default,{makeMultisignedTxBytes:k}=(await import("@cosmjs/stargate")).default,{sequence:R,fee:w}=JSON.parse(r),u=await Zo(c,n),v=f.map((y)=>[H(d(Q.decode(y.pubKey)),o),Q.decode(y.signature)]),B=await j(m),{transactionHash:W}=await B.broadcastTx(k(u,R,w,T,new Map(v)));return W}}async function Zo(o,t,p=!0){let{createMultisigThresholdPubkey:r,encodeSecp256k1Pubkey:f}=(await import("@cosmjs/amino")).default;return r(o.map((c)=>f(Q.decode(c))),t,p)}function It(o){return Q.decode(o)}async function Rt({privateKey:o,message:t}){let{Secp256k1:p}=(await import("@cosmjs/crypto")).default,r=await p.createSignature(Q.decode(t),o);return Q.encode(Buffer.concat([r.r(32),r.s(32)]))}function Qo({chain:o,...t}){let{isStagenet:p}=jo.get("envs"),r=jo.get("thornodeUrls"),f=o===xt.Maya,c=zo({isMayachain:f,isStagenet:p}).with({isMayachain:!0},({isStagenet:y})=>y?r.MAYA_STAGENET:r.MAYA).otherwise(({isStagenet:y})=>y?r.THOR_STAGENET:r.THOR),n=`${p?"s":""}${ut[o]}`,T="index"in t?t.index||0:0,m="derivationPath"in t&&t.derivationPath?t.derivationPath:kt(it[o],{index:T}),d=V({chain:o,...t}),H=P(o),k;function R(){return k??=zo(t).with({phrase:Do.string},({phrase:y})=>d.getSignerFromPhrase({derivationPath:m,phrase:y})).with({signer:Do.any},({signer:y})=>Promise.resolve(y)).otherwise(()=>Promise.resolve(void 0)),k}async function w(){let y=await Go(o),e=await R();if(!e)throw new F("toolbox_cosmos_no_signer");let _=await J(),$=await D(o),s=await X(y,e,{aminoTypes:$,registry:_});return{signer:e,signingClient:s}}async function u({fee:y,memo:e,msgs:_}){let{signer:$,signingClient:s}=await w(),S=(await $.getAccounts())?.[0]?.address;if(!S)throw new F("toolbox_cosmos_signer_not_defined");let L=await s.signAndBroadcast(S,_,y,e);if(L.code!==0)throw new F("core_swap_transaction_error",{code:L.code,message:L.rawLog});return L.transactionHash}async function v(){let y,e=`${c}/${f?"mayachain":"thorchain"}/constants`;try{let{int_64_values:{NativeTransactionFee:_}}=await dt.get(e);if(!_||Number.isNaN(_)||_<0)throw new F("toolbox_cosmos_invalid_fee",{nativeFee:_.toString()});y=new So(_)}catch{y=new So({decimal:et(o).baseDecimal,value:f?1:0.02})}return{[no.Average]:y,[no.Fast]:y,[no.Fastest]:y}}async function B({assetValue:y,memo:e="",recipient:_}){let{TxRaw:$}=await import("cosmjs-types/cosmos/tx/v1beta1/tx"),{signer:s,signingClient:S}=await w(),L=(await s.getAccounts())?.[0]?.address;if(!L)throw new F("toolbox_cosmos_no_signer");let h="signAmino"in s,q=oo({assetValue:y,memo:e,recipient:_,sender:L});if(h){let Jo=await G(q,o),{signatures:Yo,authInfoBytes:Fo}=await S.sign(L,[Jo],H,e),qo=$.encode({authInfoBytes:Fo,bodyBytes:await M({chain:o,memo:e,msgs:[q].map(Z)}),signatures:Yo}).finish();return(await S.broadcastTx(qo)).transactionHash}let a=Z(q),Xo=await G(a,o);return u({fee:H,memo:e,msgs:[Xo]})}async function W(y){let{signer:e,signingClient:_}=await w(),$=(await e.getAccounts())?.[0]?.address;if(!$)throw new F("toolbox_cosmos_signer_not_defined");return _.sign($,y.msgs,y.fee,y.memo,{accountNumber:BigInt(y.accountNumber),chainId:y.chainId,sequence:y.sequence})}return{...d,broadcastMultisigTx:Bt({chain:o,prefix:n}),buildAminoMsg:oo,buildEncodedTxBody:M,convertToSignable:G,createDefaultAminoTypes:()=>D(o),createDefaultRegistry:J,createMultisig:Zo,createTransaction:Wo,deposit:B,getFees:v,importSignature:It,parseAminoMessageForDirectSigning:Z,pubkeyToAddress:async(y)=>{let{pubkeyToAddress:e}=(await import("@cosmjs/amino")).default;return e(y,n)},secp256k1HdWalletFromMnemonic:vt({derivationPath:mt(m),prefix:n}),signAndBroadcastTransaction:u,signMultisigTx:Ht(o),signTransaction:W,signWithPrivateKey:Rt,transfer:B}}var mr=(o,t)=>{switch(o){case l.Cosmos:case l.Kujira:case l.Noble:return V({chain:o,...t});case l.Maya:case l.THORChain:return Qo({chain:o,...t});default:throw new _t("toolbox_cosmos_not_supported",{chain:o})}};export{ct as verifySignature,io as transferMsgAmino,st as toBase64,Z as parseAminoMessageForDirectSigning,at as getSignerFromPrivateKey,Ro as getSignerFromPhrase,z as getMsgSendDenom,gt as getFeeRateFromSwapKit,E as getDenomWithChain,P as getDefaultChainFee,mr as getCosmosToolbox,wt as getCosmosAddressValidator,uo as getAssetFromDenom,Pt as fromBase64,Po as fetchFeeRateFromSwapKit,or as estimateTransactionFee,ko as depositMsgAmino,Wo as createTransaction,Qo as createThorchainToolbox,j as createStargateClient,X as createSigningStargateClient,To as createOfflineStargateClient,J as createDefaultRegistry,D as createDefaultAminoTypes,V as createCosmosToolbox,xo as cosmosCreateTransaction,G as convertToSignable,ao as buildTransferTx,M as buildEncodedTxBody,go as buildDepositTx,oo as buildAminoMsg,O as bech32ToBase64,U as base64ToBech32,Ao as YUM_KUJIRA_FACTORY_DENOM,wo as USK_KUJIRA_FACTORY_DENOM,Yt as THORCHAIN_GAS_VALUE,Ft as MAYA_GAS_VALUE,Uo as DEFAULT_NOBLE_FEE_MAINNET,Oo as DEFAULT_KUJI_FEE_MAINNET,No as DEFAULT_COSMOS_FEE_MAINNET};
1
+ import{fa as i}from"../../chunk-fjyc6m34.js";import{base64 as N,bech32 as A}from"@scure/base";import{SwapKitError as Ko}from"@swapkit/helpers";function O(o){return N.encode(Uint8Array.from(A.fromWords(A.decode(o).words)))}function U(o,t="thor"){return A.encode(t,A.toWords(N.decode(o)))}function st(o){return N.encode(o)}function Pt(o){if(!o.match(/^[a-zA-Z0-9+/]*={0,2}$/))throw new Ko("toolbox_cosmos_invalid_params",{error:"Invalid base64 string format"});return N.decode(o)}import{AssetValue as Vo,Chain as b,getChainConfig as mo,getRPCUrl as eo,SwapKitError as ho}from"@swapkit/helpers";import{AssetValue as g,Chain as x,getChainConfig as C,getRPCUrl as lo,SwapKitError as yo}from"@swapkit/helpers";var wo="FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK",Ao="FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM",No={amount:[{amount:"500",denom:"uatom"}],gas:"200000"},Oo={amount:[{amount:"1000",denom:"ukuji"}],gas:"200000"},Uo={amount:[{amount:"1000",denom:"uusdc"}],gas:"200000"};function P(o){switch(o){case x.Maya:return{amount:[],gas:"10000000000"};case x.THORChain:return{amount:[],gas:"500000000"};case x.Kujira:return Oo;case x.Noble:return Uo;default:return No}}var z=(o,t=!1)=>{if(t)return o.toLowerCase();switch(o){case"uUSK":case"USK":return wo;case"uYUM":case"YUM":return Ao;case"uKUJI":case"KUJI":return"ukuji";case"ATOM":case"uATOM":return"uatom";case"uUSDC":case"USDC":return"uusdc";default:return o}},E=({symbol:o,chain:t})=>{if(t===x.Maya)return(o.toUpperCase()!=="CACAO"?o:`${x.Maya}.${o}`).toUpperCase();if(t===x.THORChain)return(["RUNE","TCY","RUJI"].includes(o.toUpperCase())?`${x.THORChain}.${o}`:o).toUpperCase();return z(o,!1)};async function j(o){let t=await import("@cosmjs/stargate"),p=t.StargateClient??t.default?.StargateClient,r=typeof window<"u"?{}:{referer:"https://sdk.swapkit.dev",referrer:"https://sdk.swapkit.dev"};return p.connect({headers:r,url:o})}async function X(o,t,p={}){let r=await import("@cosmjs/stargate"),f=r.SigningStargateClient??r.default?.SigningStargateClient,c=r.GasPrice??r.default?.GasPrice,n=typeof p==="string"?p:"0.0003uatom",T=typeof p==="string"?{}:p;return f.connectWithSigner(o,t,{gasPrice:c.fromString(n),...T})}async function To(o,t){let p=await import("@cosmjs/stargate");return(p.SigningStargateClient??p.default?.SigningStargateClient).offline(o,t)}var Eo=(o)=>{switch(o){case x.Maya:case x.THORChain:return"/types.MsgSend";case x.Cosmos:case x.Kujira:case x.Noble:return"/cosmos.bank.v1beta1.MsgSend";default:throw new yo("toolbox_cosmos_not_supported",{chain:o})}};async function xo({sender:o,recipient:t,assetValue:p,memo:r="",feeRate:f,sequence:c,accountNumber:n}){let{chain:T,chainId:m}=p,d=await lo(T),k=await(await j(d)).getAccount(o);if(!k)throw new yo("toolbox_cosmos_account_not_found",{sender:o});let R=g.from({chain:T}),w=z(R.symbol),u=P(T),v=w&&f?{amount:[{amount:f.toString(),denom:w}],gas:u.gas}:u,B={amount:[{amount:p.getBaseValue("string"),denom:z(p.symbol)}],fromAddress:o,toAddress:t};return{accountNumber:n??Number(k.accountNumber),chainId:m,fee:v,memo:r,msgs:[{typeUrl:Eo(T),value:B}],sequence:c??k.sequence}}var bo={atom:{chain:x.Cosmos,decimals:C(x.Cosmos).baseDecimal},cacao:{chain:x.Maya,decimals:10},kuji:{chain:x.Kujira,decimals:C(x.Kujira).baseDecimal},maya:{asset:`${x.Maya}.${x.Maya}`,decimals:4},rune:{chain:x.THORChain,decimals:C(x.THORChain).baseDecimal},tcy:{asset:"THOR.TCY",decimals:C(x.THORChain).baseDecimal},uatom:{chain:x.Cosmos,decimals:C(x.Cosmos).baseDecimal},ukuji:{chain:x.Kujira,decimals:C(x.Kujira).baseDecimal},usdc:{chain:x.Noble,decimals:C(x.Noble).baseDecimal},uusdc:{chain:x.Noble,decimals:C(x.Noble).baseDecimal},"x/kuji":{asset:"THOR.KUJI",decimals:C(x.THORChain).baseDecimal},[wo.toLowerCase()]:{asset:`${x.Kujira}.USK`,decimals:C(x.Kujira).baseDecimal}},uo=(o,t)=>{let p=bo[o.toLowerCase()];if(!p)return g.from({asset:o,fromBaseDecimal:8,value:t});let{chain:r,asset:f,decimals:c}=p,n=r?{chain:r}:{asset:f};return g.from({...n,fromBaseDecimal:c,value:t})};import{Chain as Mo}from"@swapkit/helpers";async function J(){let{$root:o}=await import("../../chunk-9psy287z.js"),t=await import("@cosmjs/proto-signing"),p=await import("@cosmjs/stargate"),r=t.Registry??t.default?.Registry,f=p.defaultRegistryTypes??p.default?.defaultRegistryTypes;return new r([...f,["/types.MsgSend",o.types.MsgSend],["/types.MsgDeposit",o.types.MsgDeposit]])}async function D(o){let t=await import("@cosmjs/stargate"),p=t.AminoTypes??t.default?.AminoTypes,r=o===Mo.THORChain?"thorchain":"mayachain";return new p({"/types.MsgDeposit":{aminoType:`${r}/MsgDeposit`,fromAmino:({signer:f,...c})=>({...c,signer:O(f)}),toAmino:({signer:f,...c})=>({...c,signer:U(f)})},"/types.MsgSend":{aminoType:`${r}/MsgSend`,fromAmino:({from_address:f,to_address:c,...n})=>({...n,fromAddress:O(f),toAddress:O(c)}),toAmino:({fromAddress:f,toAddress:c,...n})=>({...n,from_address:U(f),to_address:U(c)})}})}var Yt=P(b.THORChain).gas,Ft=P(b.Maya).gas,io=({sender:o,recipient:t,assetValue:p})=>{return{type:`${p.chain===b.Maya?"mayachain":"thorchain"}/MsgSend`,value:{amount:[{amount:p.getBaseValue("string"),denom:z(p.symbol,!0)}],from_address:o,to_address:t}}},ko=({sender:o,assetValue:t,memo:p=""})=>{return{type:`${t.chain===b.Maya?"mayachain":"thorchain"}/MsgDeposit`,value:{coins:[{amount:t.getBaseValue("string"),asset:E(t)}],memo:p,signer:o}}},oo=({sender:o,recipient:t,assetValue:p,memo:r})=>{return!t?ko({assetValue:p,memo:r,sender:o}):io({assetValue:p,recipient:t,sender:o})},G=async(o,t)=>{return(await D(t)).fromAmino(o)},vo=async({rpcUrl:o,sender:t})=>{let r=await(await j(o)).getAccount(t);if(!r)throw new ho("toolbox_cosmos_account_not_found",{sender:t});return r};function Wo(o){let{assetValue:t,recipient:p,memo:r,sender:f,asSignable:c,asAminoMessage:n}=o;if(p)return ao({asAminoMessage:n,asSignable:c,assetValue:t,memo:r,recipient:p,sender:f});return go({asAminoMessage:n,asSignable:c,assetValue:t,memo:r,sender:f})}async function ao({sender:o,recipient:t,assetValue:p,memo:r="",asSignable:f=!0,asAminoMessage:c=!1,sequence:n,accountNumber:T}){let m=p.chain,d=await eo(m),H=await vo({rpcUrl:d,sender:o}),{chainId:k}=mo(m),R=io({assetValue:p,recipient:t,sender:o}),w=f?await G(c?R:Z(R),m):R;return{accountNumber:T||Number(H.accountNumber),chainId:k,fee:P(m),memo:r,msgs:[w],sequence:n||H.sequence}}async function go({sender:o,assetValue:t,memo:p="",asSignable:r=!0,asAminoMessage:f=!1,sequence:c,accountNumber:n}){let T=t.chain,m=await eo(T),d=await vo({rpcUrl:m,sender:o}),{chainId:H}=mo(T),k=ko({assetValue:t,memo:p,sender:o}),R=r?await G(f?k:Z(k),T):k;return{accountNumber:n||Number(d.accountNumber),chainId:H,fee:P(T),memo:p,msgs:[R],sequence:c||d.sequence}}function Z(o){if(o.type==="thorchain/MsgSend"||o.type==="mayachain/MsgSend")return o;return{...o,value:{...o.value,coins:o.value.coins.map((t)=>{let p=Vo.from({asset:t.asset}),r=(p.isSynthetic?p.symbol.split("/")?.[1]:p.symbol)?.toUpperCase(),f=(p.isSynthetic?p.symbol.split("/")?.[0]:p.chain)?.toUpperCase();return{...t,asset:{chain:f,symbol:r,synth:p.isSynthetic,ticker:p.ticker}}})}}}async function M({chain:o,memo:t,msgs:p}){let r=await J(),f=await D(o),c={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{memo:t,messages:p.map((n)=>f.fromAmino(n))}};return r.encode(c)}import{Chain as l,SwapKitError as _t}from"@swapkit/helpers";import{base64 as po,bech32 as to}from"@scure/base";import{AssetValue as fo,applyFeeMultiplier as Ho,Chain as I,CosmosChainPrefixes as Co,DerivationPath as ot,derivationPathToString as Bo,FeeOption as co,getChainConfig as tt,getRPCUrl as K,NetworkDerivationPath as rt,SwapKitError as Y,SwapKitNumber as ro,updateDerivationPath as pt}from"@swapkit/helpers";import{SwapKitApi as so}from"@swapkit/helpers/api";import{match as ft,P as Io}from"ts-pattern";async function Po(o,t){try{let r=(await so.getGasRate()).find((f)=>f.chainId===o)?.value;return r?Number.parseFloat(r):t}catch{return t}}async function Ro({phrase:o,prefix:t,...p}){let r=await import("@cosmjs/proto-signing"),f=await import("@cosmjs/crypto"),c=r.DirectSecp256k1HdWallet??r.default?.DirectSecp256k1HdWallet,n=f.stringToPath??f.default?.stringToPath,T="derivationPath"in p?p.derivationPath:`${ot[p.chain]}/${p.index}`;return await c.fromMnemonic(o,{hdPaths:[n(T)],prefix:t})}async function at({privateKey:o,prefix:t}){let p=await import("@cosmjs/proto-signing");return(p.DirectSecp256k1Wallet??p.default?.DirectSecp256k1Wallet).fromKey(o,t)}var _o={[I.Cosmos]:1000,[I.Kujira]:1000,[I.Noble]:1000,[I.THORChain]:5000000,[I.Maya]:5000000,[I.Harbor]:5000000};function ct(o){return async function({signature:p,message:r,address:f}){let c=await o(f);if(!c?.pubkey)throw new Y("toolbox_cosmos_verify_signature_no_pubkey");let n=await import("@cosmjs/crypto"),T=n.Secp256k1Signature??n.default?.Secp256k1Signature,m=n.Secp256k1??n.default?.Secp256k1,d=T.fromFixedLength(po.decode(p));return m.verifySignature(d,po.decode(r),c.pubkey.value)}}function V({chain:o,...t}){let p=Co[o],r="index"in t?t.index||0:0,f=Bo("derivationPath"in t&&t.derivationPath?t.derivationPath:pt(rt[o],{index:r})),c;async function n(){if(c)return c;return c=await ft(t).with({phrase:Io.string},({phrase:w})=>Ro({derivationPath:f,phrase:w,prefix:p})).with({signer:Io.any},({signer:w})=>w).otherwise(()=>{return}),c}async function T(w){let u=await K(o);return(await j(u)).getAccount(w)}async function m(){let w=await n(),[u]=await w?.getAccounts()||[];return u?.address}async function d(){let w=await n(),[u]=await w?.getAccounts()||[];if(!u?.pubkey)throw new Y("toolbox_cosmos_signer_not_defined");return po.encode(u?.pubkey)}async function H(w){let u=await n(),v=await m(),B=await K(o);if(!(u&&v))throw new Y("toolbox_cosmos_signer_not_defined");return await(await X(B,u)).sign(v,w.msgs,w.fee,w.memo,{accountNumber:BigInt(w.accountNumber),chainId:w.chainId,sequence:w.sequence})}async function k(w){let u=await n(),v=await m(),B=await K(o);if(!(u&&v))throw new Y("toolbox_cosmos_signer_not_defined");let y=await(await X(B,u)).signAndBroadcast(v,w.msgs,w.fee,w.memo);if(y.code!==0)throw new Y("core_swap_transaction_error",{code:y.code,message:y.rawLog});return y.transactionHash}async function R({recipient:w,assetValue:u,memo:v="",feeRate:B,feeOptionKey:W=co.Fast}){let y=await n(),e=await m();if(!(y&&e))throw new Y("toolbox_cosmos_signer_not_defined");let _=await K(o),$=fo.from({chain:o}),s=E($),S=B||nt((await $o(o,_o[o]))[W],s),L=await X(_,y),h=z(u.symbol),q=[{amount:u.getBaseValue("string"),denom:h}],{transactionHash:a}=await L.sendTokens(e,w,q,S,v);return a}return{createPrivateKeyFromPhrase:Tt(f),createTransaction:xo,fetchFeeRateFromSwapKit:Po,getAccount:T,getAddress:m,getBalance:async(w,u)=>{let v=await Lo(o)(w),B=await Promise.all(v.filter(({denom:W})=>W&&!W.includes("IBC/")&&!([I.THORChain,I.Maya].includes(o)&&W.split("-").length>2)).map(({denom:W,amount:y})=>{let e=[I.THORChain,I.Maya].includes(o)&&(W.includes("/")||W.includes("˜"))?`${o}.${W}`:W;return uo(e,y)}));if(B.length===0)return[fo.from({chain:o})];return B},getBalanceAsDenoms:Lo(o),getFees:()=>$o(o,_o[o]),getPubKey:d,getSignerFromPhrase:({phrase:w,derivationPath:u})=>Ro({derivationPath:Bo(u),index:r,phrase:w,prefix:p}),getSignerFromPrivateKey:async(w)=>{let u=await import("@cosmjs/proto-signing");return(u.DirectSecp256k1Wallet??u.default?.DirectSecp256k1Wallet).fromKey(w,p)},signAndBroadcastTransaction:k,signTransaction:H,transfer:R,validateAddress:wt(o),verifySignature:ct(T)}}async function gt(o,t){try{let r=(await so.getGasRate()).find((f)=>f.chainId===o)?.value;return r?Number.parseFloat(r):t}catch{return t}}function or({assetValue:{chain:o}}){return fo.from({chain:o,value:yt(o)})}async function $o(o,t){let{chainId:p,baseDecimal:r}=tt(o),f=await Po(p,t);return{average:ro.fromBigInt(BigInt(f),r),fast:ro.fromBigInt(BigInt(Ho(f,co.Fast,!0)),r),fastest:ro.fromBigInt(BigInt(Ho(f,co.Fastest,!0)),r)}}function nt(o,t){return{amount:[{amount:o.getBaseValue("string"),denom:t}],gas:"200000"}}function yt(o){return{[I.Cosmos]:0.007,[I.Kujira]:0.02,[I.Noble]:0.01,[I.THORChain]:0.02,[I.Maya]:0.02,[I.Harbor]:0.02}[o]||0}function wt(o){let t=Co[o];return function(r){if(!r.startsWith(t))return!1;try{let{prefix:f,words:c}=to.decode(r);return to.encode(f,c)===r.toLocaleLowerCase()}catch{return!1}}}function Lo(o){return async function(p){let r=await K(o);return(await(await j(r)).getAllBalances(p)).map((T)=>({...T,denom:T.denom.includes("/")?T.denom.toUpperCase():T.denom}))}}function Tt(o){return async function(p){let r=await import("@cosmjs/crypto"),f=r.stringToPath??r.default?.stringToPath,c=r.Slip10Curve??r.default?.Slip10Curve,n=r.Slip10??r.default?.Slip10,T=r.EnglishMnemonic??r.default?.EnglishMnemonic,m=r.Bip39??r.default?.Bip39,d=new T(p),H=await m.mnemonicToSeed(d),{privkey:k}=n.derivePath(c.Secp256k1,H,f(o));return k}}import{base64 as Q}from"@scure/base";import{Chain as xt,CosmosChainPrefixes as ut,derivationPathToString as mt,FeeOption as no,getChainConfig as et,getRPCUrl as Go,NetworkDerivationPath as it,RequestClient as dt,SKConfig as jo,SwapKitError as F,SwapKitNumber as So,updateDerivationPath as kt}from"@swapkit/helpers";import{match as zo,P as Do}from"ts-pattern";function vt({prefix:o,derivationPath:t}){return async function(r,f=0){let c=await import("@cosmjs/amino"),n=c.Secp256k1HdWallet??c.default?.Secp256k1HdWallet,T=await import("@cosmjs/crypto"),m=T.stringToPath??T.default?.stringToPath;return n.fromMnemonic(r,{hdPaths:[m(`${t}/${f}`)],prefix:o})}}function Wt(o){return Q.encode(o)}function Ht(o){return async function({wallet:p,tx:r}){let{msgs:f,accountNumber:c,sequence:n,chainId:T,fee:m,memo:d}=typeof r==="string"?JSON.parse(r):r,H=(await p.getAccounts())?.[0]?.address||"",k=await D(o),R=await J(),w=await To(p,{aminoTypes:k,registry:R}),u=[];for(let W of f){let y=await G(W,o);u.push(y)}let{signatures:[v]}=await w.sign(H,u,m,d,{accountNumber:BigInt(c),chainId:T,sequence:n});return{bodyBytes:await M({chain:o,memo:d,msgs:f.map(Z)}),signature:Wt(v)}}}function Bt({prefix:o,chain:t}){return async function(r,f,c,n,T){let m=await Go(t),{encodeSecp256k1Pubkey:d,pubkeyToAddress:H}=(await import("@cosmjs/amino")).default,{makeMultisignedTxBytes:k}=(await import("@cosmjs/stargate")).default,{sequence:R,fee:w}=JSON.parse(r),u=await Zo(c,n),v=f.map((y)=>[H(d(Q.decode(y.pubKey)),o),Q.decode(y.signature)]),B=await j(m),{transactionHash:W}=await B.broadcastTx(k(u,R,w,T,new Map(v)));return W}}async function Zo(o,t,p=!0){let{createMultisigThresholdPubkey:r,encodeSecp256k1Pubkey:f}=(await import("@cosmjs/amino")).default;return r(o.map((c)=>f(Q.decode(c))),t,p)}function It(o){return Q.decode(o)}async function Rt({privateKey:o,message:t}){let{Secp256k1:p}=(await import("@cosmjs/crypto")).default,r=await p.createSignature(Q.decode(t),o);return Q.encode(Buffer.concat([r.r(32),r.s(32)]))}function Qo({chain:o,...t}){let{isStagenet:p}=jo.get("envs"),r=jo.get("thornodeUrls"),f=o===xt.Maya,c=zo({isMayachain:f,isStagenet:p}).with({isMayachain:!0},({isStagenet:y})=>y?r.MAYA_STAGENET:r.MAYA).otherwise(({isStagenet:y})=>y?r.THOR_STAGENET:r.THOR),n=`${p?"s":""}${ut[o]}`,T="index"in t?t.index||0:0,m="derivationPath"in t&&t.derivationPath?t.derivationPath:kt(it[o],{index:T}),d=V({chain:o,...t}),H=P(o),k;function R(){return k??=zo(t).with({phrase:Do.string},({phrase:y})=>d.getSignerFromPhrase({derivationPath:m,phrase:y})).with({signer:Do.any},({signer:y})=>Promise.resolve(y)).otherwise(()=>Promise.resolve(void 0)),k}async function w(){let y=await Go(o),e=await R();if(!e)throw new F("toolbox_cosmos_no_signer");let _=await J(),$=await D(o),s=await X(y,e,{aminoTypes:$,registry:_});return{signer:e,signingClient:s}}async function u({fee:y,memo:e,msgs:_}){let{signer:$,signingClient:s}=await w(),S=(await $.getAccounts())?.[0]?.address;if(!S)throw new F("toolbox_cosmos_signer_not_defined");let L=await s.signAndBroadcast(S,_,y,e);if(L.code!==0)throw new F("core_swap_transaction_error",{code:L.code,message:L.rawLog});return L.transactionHash}async function v(){let y,e=`${c}/${f?"mayachain":"thorchain"}/constants`;try{let{int_64_values:{NativeTransactionFee:_}}=await dt.get(e);if(!_||Number.isNaN(_)||_<0)throw new F("toolbox_cosmos_invalid_fee",{nativeFee:_.toString()});y=new So(_)}catch{y=new So({decimal:et(o).baseDecimal,value:f?1:0.02})}return{[no.Average]:y,[no.Fast]:y,[no.Fastest]:y}}async function B({assetValue:y,memo:e="",recipient:_}){let{TxRaw:$}=await import("cosmjs-types/cosmos/tx/v1beta1/tx"),{signer:s,signingClient:S}=await w(),L=(await s.getAccounts())?.[0]?.address;if(!L)throw new F("toolbox_cosmos_no_signer");let h="signAmino"in s,q=oo({assetValue:y,memo:e,recipient:_,sender:L});if(h){let Jo=await G(q,o),{signatures:Yo,authInfoBytes:Fo}=await S.sign(L,[Jo],H,e),qo=$.encode({authInfoBytes:Fo,bodyBytes:await M({chain:o,memo:e,msgs:[q].map(Z)}),signatures:Yo}).finish();return(await S.broadcastTx(qo)).transactionHash}let a=Z(q),Xo=await G(a,o);return u({fee:H,memo:e,msgs:[Xo]})}async function W(y){let{signer:e,signingClient:_}=await w(),$=(await e.getAccounts())?.[0]?.address;if(!$)throw new F("toolbox_cosmos_signer_not_defined");return _.sign($,y.msgs,y.fee,y.memo,{accountNumber:BigInt(y.accountNumber),chainId:y.chainId,sequence:y.sequence})}return{...d,broadcastMultisigTx:Bt({chain:o,prefix:n}),buildAminoMsg:oo,buildEncodedTxBody:M,convertToSignable:G,createDefaultAminoTypes:()=>D(o),createDefaultRegistry:J,createMultisig:Zo,createTransaction:Wo,deposit:B,getFees:v,importSignature:It,parseAminoMessageForDirectSigning:Z,pubkeyToAddress:async(y)=>{let{pubkeyToAddress:e}=(await import("@cosmjs/amino")).default;return e(y,n)},secp256k1HdWalletFromMnemonic:vt({derivationPath:mt(m),prefix:n}),signAndBroadcastTransaction:u,signMultisigTx:Ht(o),signTransaction:W,signWithPrivateKey:Rt,transfer:B}}var mr=(o,t)=>{switch(o){case l.Cosmos:case l.Kujira:case l.Noble:return V({chain:o,...t});case l.Maya:case l.THORChain:return Qo({chain:o,...t});default:throw new _t("toolbox_cosmos_not_supported",{chain:o})}};export{ct as verifySignature,io as transferMsgAmino,st as toBase64,Z as parseAminoMessageForDirectSigning,at as getSignerFromPrivateKey,Ro as getSignerFromPhrase,z as getMsgSendDenom,gt as getFeeRateFromSwapKit,E as getDenomWithChain,P as getDefaultChainFee,mr as getCosmosToolbox,wt as getCosmosAddressValidator,uo as getAssetFromDenom,Pt as fromBase64,Po as fetchFeeRateFromSwapKit,or as estimateTransactionFee,ko as depositMsgAmino,Wo as createTransaction,Qo as createThorchainToolbox,j as createStargateClient,X as createSigningStargateClient,To as createOfflineStargateClient,J as createDefaultRegistry,D as createDefaultAminoTypes,V as createCosmosToolbox,xo as cosmosCreateTransaction,G as convertToSignable,ao as buildTransferTx,M as buildEncodedTxBody,go as buildDepositTx,oo as buildAminoMsg,O as bech32ToBase64,U as base64ToBech32,Ao as YUM_KUJIRA_FACTORY_DENOM,wo as USK_KUJIRA_FACTORY_DENOM,Yt as THORCHAIN_GAS_VALUE,Ft as MAYA_GAS_VALUE,Uo as DEFAULT_NOBLE_FEE_MAINNET,Oo as DEFAULT_KUJI_FEE_MAINNET,No as DEFAULT_COSMOS_FEE_MAINNET};