@swapkit/toolboxes 4.23.1 → 4.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/chunk-ap5mzmjf.js +1 -0
  3. package/dist/{chunk-9psy287z.js → chunk-btth5bse.js} +1 -1
  4. package/dist/{chunk-jdh5asaw.js → chunk-nvfkjbyq.js} +1 -1
  5. package/dist/{chunk-fjyc6m34.js → chunk-xbdjxeqd.js} +1 -1
  6. package/dist/chunk-z61r1327.js +2 -0
  7. package/dist/src/aptos/index.cjs +1 -1
  8. package/dist/src/aptos/index.js +1 -1
  9. package/dist/src/cardano/index.cjs +1 -1
  10. package/dist/src/cardano/index.js +1 -1
  11. package/dist/src/cosmos/index.cjs +1 -1
  12. package/dist/src/cosmos/index.js +1 -1
  13. package/dist/src/evm/index.cjs +1 -1
  14. package/dist/src/evm/index.js +1 -1
  15. package/dist/src/hypercore/index.cjs +1 -1
  16. package/dist/src/hypercore/index.js +1 -1
  17. package/dist/src/index.cjs +1 -1
  18. package/dist/src/index.js +1 -1
  19. package/dist/src/near/index.cjs +1 -1
  20. package/dist/src/near/index.js +1 -1
  21. package/dist/src/radix/index.js +1 -1
  22. package/dist/src/ripple/index.cjs +1 -1
  23. package/dist/src/ripple/index.js +1 -1
  24. package/dist/src/solana/index.cjs +1 -1
  25. package/dist/src/solana/index.js +1 -1
  26. package/dist/src/starknet/index.cjs +1 -1
  27. package/dist/src/starknet/index.js +1 -1
  28. package/dist/src/stellar/index.cjs +1 -1
  29. package/dist/src/stellar/index.js +1 -1
  30. package/dist/src/substrate/index.cjs +1 -1
  31. package/dist/src/substrate/index.js +1 -1
  32. package/dist/src/sui/index.cjs +1 -1
  33. package/dist/src/sui/index.js +1 -1
  34. package/dist/src/ton/index.cjs +1 -1
  35. package/dist/src/ton/index.js +1 -1
  36. package/dist/src/tron/index.cjs +1 -1
  37. package/dist/src/tron/index.js +1 -1
  38. package/dist/src/utxo/index.cjs +1 -1
  39. package/dist/src/utxo/index.js +1 -1
  40. package/dist/types/aptos/toolbox.d.ts +11 -7
  41. package/dist/types/cardano/toolbox.d.ts +2 -2
  42. package/dist/types/cosmos/thorchainUtils/messages.d.ts +2 -1
  43. package/dist/types/cosmos/thorchainUtils/registry.d.ts +1 -1
  44. package/dist/types/cosmos/toolbox/cosmos.d.ts +1 -1
  45. package/dist/types/cosmos/toolbox/thorchain.d.ts +6 -6
  46. package/dist/types/cosmos/util.d.ts +16 -2
  47. package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +66 -21
  48. package/dist/types/evm/toolbox/evm.d.ts +1603 -234
  49. package/dist/types/evm/toolbox/op.d.ts +235 -11
  50. package/dist/types/evm/types.d.ts +7 -13
  51. package/dist/types/hypercore/toolbox.d.ts +2 -2
  52. package/dist/types/hypercore/types.d.ts +3 -1
  53. package/dist/types/near/toolbox.d.ts +22 -3
  54. package/dist/types/near/types.d.ts +4 -1
  55. package/dist/types/ripple/index.d.ts +3 -2
  56. package/dist/types/solana/toolbox.d.ts +2 -2
  57. package/dist/types/starknet/toolbox.d.ts +2 -2
  58. package/dist/types/starknet/types.d.ts +3 -12
  59. package/dist/types/stellar/toolbox.d.ts +2 -2
  60. package/dist/types/sui/toolbox.d.ts +3 -3
  61. package/dist/types/ton/toolbox.d.ts +1 -4
  62. package/dist/types/tron/toolbox.d.ts +2 -2
  63. package/dist/types/utxo/helpers/coinselect.d.ts +2 -1
  64. package/dist/types/utxo/toolbox/bitcoinCash.d.ts +7 -5
  65. package/dist/types/utxo/toolbox/utxo.d.ts +8 -5
  66. package/dist/types/utxo/toolbox/zcash.d.ts +6 -4
  67. package/package.json +2 -2
  68. package/dist/chunk-6b99avsd.js +0 -2
  69. package/dist/chunk-e02sjx7s.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @swapkit/toolboxes
2
2
 
3
+ ## 4.24.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#306](https://github.com/swapkit/sdk/pull/306) [`be7e885`](https://github.com/swapkit/sdk/commit/be7e885d3779005b4a2e2e4d6560b2a1031994a3) Thanks [@towanTG](https://github.com/towanTG)! - Update generated token lists and preserve Maya address prefixes when signing THOR/Maya Amino messages.
8
+ - [#324](https://github.com/swapkit/sdk/pull/324) [`9641c5d`](https://github.com/swapkit/sdk/commit/9641c5d55b12e7e7263f4ef4d1c276eff9c866a9) Thanks [@towanTG](https://github.com/towanTG)! - Sweep hardening from post-merge adversarial review: EVM sweeps fail closed when the near-final gas probe is unaffordable instead of broadcasting with an under-validated gas limit; clamped Sui sweep budgets are dry-run verified so dust wallets cannot burn their balance on an insufficient budget; native TON sweeps throw the shared sweep guard for empty wallets; NEAR token-sweep gas shortfalls use the standard sweep error key.
9
+ - Update generated token lists. (via @swapkit/helpers@4.17.1)
10
+
11
+ ## 4.24.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#311](https://github.com/swapkit/sdk/pull/311) [`d787a38`](https://github.com/swapkit/sdk/commit/d787a38c6c96f36afde3964957409f4b2e4356a3) Thanks [@towanTG](https://github.com/towanTG)! - Add a `sweep` flag to `createTransaction` and `transfer` across all toolboxes. For native/gas assets, sweep sends the maximum spendable amount while keeping the sender account alive (fees, reserves, rent, existential deposits, and storage stakes are reserved per chain); for tokens, sweep resolves the full token balance. Also fixes Starknet balance decoding (uint256 halves order and decimals), the shared `GenericCreateTransactionParams` Omit, and the Chainflip EIP-7702 authorization signature type.
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [[`d787a38`](https://github.com/swapkit/sdk/commit/d787a38c6c96f36afde3964957409f4b2e4356a3)]:
20
+ - @swapkit/helpers@4.17.0
21
+
3
22
  ## 4.23.1
4
23
 
5
24
  ### Patch Changes
@@ -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,da as R,o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i,x as j,y as k,z as l}from"./chunk-z61r1327.js";import"./chunk-nvfkjbyq.js";import"./chunk-xbdjxeqd.js";export{c as validateEVMAddress,h as toChecksumAddress,g as isStateChangingCall,o as isEIP7702Transaction,p as isEIP1559Transaction,d as isBrowserProvider,l as getTokenAddress,R as getEvmToolboxAsync,Q as getEvmToolbox,n as getEstimateGasPrices,q as getEVMTxType,i as getEIP1193SendTransaction,m as getCreateContractTxObject,f as getCreateContract,j as getChecksumAddressFromAsset,r as createOPStackToolbox,e as createContract,P as XLayerToolbox,O as UNIToolbox,N as SONICToolbox,M as PLASMAToolbox,s as OPToolbox,L as MONADToolbox,K as MEGAETHToolbox,a as MAX_APPROVAL,J as MATICToolbox,I as LINEAToolbox,H as HYPEREVMToolbox,G as HOODToolbox,F as GNOToolbox,t as ETHToolbox,k as ContractAddress,E as CROToolbox,D as CORNToolbox,C as COREToolbox,B as BotanixToolbox,b as BaseEVMToolbox,A as BSCToolbox,z as BERAToolbox,y as BASEToolbox,x as AVAXToolbox,w as AURORAToolbox,v as ARBToolbox,u as ADIToolbox};
@@ -1 +1 @@
1
- import"./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
+ import"./chunk-xbdjxeqd.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
  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 da,h as ea};
2
+ export{C as ea,h as fa};
@@ -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 fa};
2
+ export{d as ga};
@@ -0,0 +1,2 @@
1
+ import{fa as Ny}from"./chunk-nvfkjbyq.js";import{ga as Uy}from"./chunk-xbdjxeqd.js";import{Chain as H}from"@swapkit/helpers";import{match as b5}from"ts-pattern";import{Chain as $,getChainConfig as p,getRPCUrl as Wu,SKConfig as Qu,SwapKitError as c}from"@swapkit/helpers";import{FallbackProvider as Xu,getAddress as Hy,Interface as Yu,JsonRpcProvider as ty,Network as Zu}from"ethers";import{match as Ry}from"ts-pattern";function $u(y){return new ty(y)}async function X5(y,u){return $u(u||await Wu(y))}function ky(y){let u=Qu.get("rpcUrls")[y]?.filter(Boolean)??[];if(u.length===0)throw new c("helpers_chain_no_public_or_set_rpc_url",{chain:y});let{chainId:n}=p(y),t=Zu.from(Number(n)),[T]=u;if(u.length===1)return new ty(T,t,{staticNetwork:t});return new Xu(u.map((M,b)=>({priority:b+1,provider:new ty(M,t,{staticNetwork:t}),stallTimeout:2000})),t,{quorum:1})}function _(y){return y>0n?`0x${y.toString(16)}`:"0x0"}function Dy(y){let{explorerUrl:u,chainIdHex:n,rpcUrls:t}=p(y);return function(){return y!==$.Ethereum?{...Bu({chain:y}),blockExplorerUrls:[u],chainId:n,rpcUrls:t}:void 0}}function Ly(y){return![$.Adi,$.Arbitrum,$.BinanceSmartChain,$.Robinhood].includes(y)}function Bu({chain:y}){let{name:u,nativeCurrency:n,baseDecimal:t}=p(y);return Ry(y).with($.Arbitrum,()=>({chainName:"Arbitrum One",nativeCurrency:{decimals:t,name:"Ethereum",symbol:$.Ethereum}})).with($.Aurora,()=>({chainName:"Aurora Mainnet",nativeCurrency:{decimals:t,name:"Ethereum",symbol:$.Ethereum}})).with($.Avalanche,()=>({chainName:"Avalanche Network",nativeCurrency:{decimals:t,name:"Avalanche",symbol:y}})).with($.Base,()=>({chainName:"Base Mainnet",nativeCurrency:{decimals:t,name:"Ethereum",symbol:$.Ethereum}})).with($.Berachain,()=>({chainName:"Berachain",nativeCurrency:{decimals:t,name:"Berachain",symbol:"BERA"}})).with($.XLayer,()=>({chainName:"X Layer",nativeCurrency:{decimals:t,name:"OKB",symbol:"OKB"}})).with($.BinanceSmartChain,()=>({chainName:"BNB Smart Chain Mainnet",nativeCurrency:{decimals:t,name:"Binance Coin",symbol:"BNB"}})).with($.Gnosis,()=>({chainName:"Gnosis",nativeCurrency:{decimals:t,name:"xDAI",symbol:"XDAI"}})).with($.Optimism,()=>({chainName:"OP Mainnet",nativeCurrency:{decimals:t,name:"Ethereum",symbol:$.Ethereum}})).with($.Polygon,()=>({chainName:"Polygon Mainnet",nativeCurrency:{decimals:t,name:"Polygon",symbol:$.Polygon}})).with($.Robinhood,()=>({chainName:"Robinhood Chain",nativeCurrency:{decimals:t,name:"Ethereum",symbol:$.Ethereum}})).otherwise(()=>({chainName:u,nativeCurrency:{decimals:t,name:n,symbol:n}}))}async function zy(y,u){if(!("authorize"in y))throw Error("Signer does not support EIP-7702 authorization. Requires ethers.js v6.14+");let n={...u,nonce:u.nonce!==void 0?BigInt(u.nonce):void 0};return await y.authorize(n)}var Jy=(y)=>typeof y==="string"&&/^0x[a-fA-F0-9]{64}$/.test(y),Ju=(y)=>{try{return typeof y==="string"&&!!Hy(y)}catch{return!1}};function Hu(y,u){let n=u!==void 0?`index ${u}: `:"",t=(T,M)=>{throw new c({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{field:T,message:`${n}${M}`}})};Ry(y).when(({chainId:T})=>typeof T!=="bigint",()=>t("chainId","chainId must be a bigint")).when(({address:T})=>!Ju(T),()=>t("address","address must be a valid checksummed address")).when(({nonce:T})=>typeof T!=="bigint"||T<0n,()=>t("nonce","nonce must be a non-negative bigint")).when(({signature:T})=>!T,()=>t("signature","signature is required")).when(({signature:T})=>typeof T?.yParity!=="number"||![0,1].includes(T.yParity),()=>t("signature.yParity","yParity must be 0 or 1")).when(({signature:T})=>!Jy(T?.r),()=>t("signature.r","r must be a 32-byte hex string")).when(({signature:T})=>!Jy(T?.s),()=>t("signature.s","s must be a 32-byte hex string")).otherwise(()=>{})}function Ru(y){return[{key:"name",type:"string"},{key:"version",type:"string"},{key:"chainId",type:"uint256"},{key:"verifyingContract",type:"address"},{key:"salt",type:"bytes32"}].filter(({key:u})=>y[u]!=null).map(({key:u,type:n})=>({name:u,type:n}))}function Ty(y){return y.charAt(0).toUpperCase()+y.slice(1)}function My(y,u){if(y.isTuple()&&y.components){let n=Ty(y.name);return u[n]=y.components.map((t)=>({name:t.name,type:My(t,u)})),n}if(y.isArray()){let n=y.arrayChildren;if(n?.isTuple()&&n.components){let t=Ty(y.name.replace(/s$/,""));return u[t]=n.components.map((T)=>({name:T.name,type:My(T,u)})),`${t}[]`}return`${n?.type??"bytes"}[]`}return y.type}function by(y,u){if(typeof y==="bigint")return y;if(u?.isTuple()&&typeof y?.toObject==="function"){let n=y.toObject(),t={};for(let[T,M]of(u.components??[]).entries())t[M.name]=by(n[M.name]??y[T],M);return t}if(Array.isArray(y)){let n=u?.arrayChildren;return y.map((t)=>by(t,n??void 0))}return y}function Y5({chain:y,abi:u,data:n,to:t}){let M=new Yu(u).parseTransaction({data:n});if(!M)throw new c({errorKey:"toolbox_evm_invalid_params",info:{error:"Could not decode calldata"}});let b={},q=Ty(M.name);b[q]=M.fragment.inputs.map((X)=>({name:X.name,type:My(X,b)}));let W={};for(let[X,B]of M.fragment.inputs.entries())W[B.name]=by(M.args[X],B);let{chainId:Q}=p(y),U={chainId:Number(Q),verifyingContract:Hy(t)},k=Ru(U);return{domain:U,message:W,primaryType:q,types:{EIP712Domain:k,...b}}}function jy(y,u){if(!Array.isArray(y)||y.length===0)throw new c({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{message:"EIP-7702 transactions require at least one authorization"}});for(let[n,t]of y.entries())if(Hu(t,n),u!==void 0&&t.chainId!==u)throw new c({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{field:"chainId",message:`index ${n}: authorization chainId (${t.chainId}) does not match transaction chainId (${u})`}})}import{Chain as R,FeeOption as n5}from"@swapkit/helpers";import{HDNodeWallet as t5}from"ethers";import{match as T5,P as oy}from"ts-pattern";var Gy=[{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"aggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes[]",name:"returnData",type:"bytes[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"blockAndAggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes32",name:"blockHash",type:"bytes32"},{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBlockNumber",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockCoinbase",outputs:[{internalType:"address",name:"coinbase",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockDifficulty",outputs:[{internalType:"uint256",name:"difficulty",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockGasLimit",outputs:[{internalType:"uint256",name:"gaslimit",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"addr",type:"address"}],name:"getEthBalance",outputs:[{internalType:"uint256",name:"balance",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"requireSuccess",type:"bool"},{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"tryAggregate",outputs:[{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"requireSuccess",type:"bool"},{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"tryBlockAndAggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes32",name:"blockHash",type:"bytes32"},{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"}];import{AssetValue as ku,applyFeeMultiplierToBigInt as N,Chain as l,EVMChains as Du,FeeOption as Y,isGasAsset as Lu,SwapKitError as Z,SwapKitNumber as s}from"@swapkit/helpers";import{erc20ABI as A}from"@swapkit/helpers/contracts";import{BrowserProvider as zu,Contract as _y,getAddress as i,getBytes as ju,Interface as Vy}from"ethers";import{match as wy}from"ts-pattern";function d(y){return{getBalance:Ny(y)}}function J5(y){return y}var Wy=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function a({chain:y=l.Ethereum,provider:u,signer:n,isEIP1559Compatible:t=!0,estimateGasPrices:T,estimateAdditionalFee:M}){let b=T??m({chain:y,isEIP1559Compatible:t,provider:u}),q=fy({chain:y,estimateAdditionalFee:M,estimateGasPrices:b,isEIP1559Compatible:t,provider:u,signer:n});return{approve:Ou({chain:y,isEIP1559Compatible:t,provider:u,signer:n}),approvedAmount:ly({chain:y,provider:u}),broadcastTransaction:u.broadcastTransaction,call:yy({chain:y,isEIP1559Compatible:t,provider:u,signer:n}),createApprovalTx:hu({chain:y,provider:u,signer:n}),createContract:Nu({chain:y,provider:u}),createContractTxObject:h({chain:y,provider:u}),createTransaction:q,createTransferTx:q,EIP1193SendTransaction:r(u),estimateCall:Sy({provider:u,signer:n}),estimateGasLimit:xu({chain:y,provider:u,signer:n}),estimateGasPrices:b,estimateTransactionFee:mu({chain:y,isEIP1559Compatible:t,provider:u}),getAddress:()=>{return n?n.getAddress():void 0},getBalance:d(y).getBalance,getNetworkParams:Dy(y),isApproved:Ku({chain:y,provider:u}),sendTransaction:Oy({chain:y,estimateGasPrices:b,isEIP1559Compatible:t,provider:u,signer:n}),signAuthorization:Fu({signer:n}),signMessage:n?(W)=>n.signMessage(W):void 0,signTypedData:n?({domain:W,types:Q,value:U})=>n.signTypedData(W,Q,U):void 0,transfer:fu({chain:y,estimateAdditionalFee:M,estimateGasPrices:b,isEIP1559Compatible:t,provider:u,signer:n}),validateAddress:Gu}}function Gu(y){try{return i(y),!0}catch{return!1}}function e(y){return y instanceof zu}function Qy(y,u,n){return new _y(y,Vy.from(u),n)}function Nu({provider:y}){return function(n,t){return new _y(n,Vy.from(t),y)}}var _u=["payable","nonpayable"];function Vu({abi:y,funcName:u}){let n=y.find((t)=>t.name===u);if(!n)throw new Z("toolbox_evm_no_abi_fragment",{funcName:u});return n.stateMutability&&_u.includes(n.stateMutability)}function G5(y){return i(y)}function r(y,u=!1){return function({value:t,...T}){if(!e(y))throw new Z("toolbox_evm_provider_not_eip1193_compatible");let M={...T,gasPrice:"gasPrice"in T?T.gasPrice:void 0,maxFeePerGas:"maxFeePerGas"in T?T.maxFeePerGas:void 0,maxPriorityFeePerGas:"maxPriorityFeePerGas"in T?T.maxPriorityFeePerGas:void 0},{gasLimit:b,gasPrice:q,maxFeePerGas:W,maxPriorityFeePerGas:Q,...U}=M,k={...U,...u&&b!==void 0&&{gas:_(BigInt(b))},...u&&q!==void 0&&{gasPrice:_(BigInt(q))},...u&&W!==void 0&&{maxFeePerGas:_(BigInt(W))},...u&&Q!==void 0&&{maxPriorityFeePerGas:_(BigInt(Q))},value:_(BigInt(t||0))};return y.send("eth_sendTransaction",[k])}}function N5(y,u){let n=Xy(y,u);if(n)return i(n.toLowerCase());throw new Z("toolbox_evm_invalid_gas_asset_address")}var wu=Du.reduce((y,u)=>{return y[u]="0x0000000000000000000000000000000000000000",y},{}),lu={...wu,[l.Optimism]:"0x4200000000000000000000000000000000000042",[l.Polygon]:"0x0000000000000000000000000000000000001010"},Su=[l.Arbitrum,l.Aurora,l.Base,l.Optimism,l.Robinhood];function Xy({chain:y,symbol:u,ticker:n},t){try{let T=y===l.BinanceSmartChain&&u==="BNB"&&n==="BNB",M=y===l.Hyperevm&&u==="HYPE"&&n==="HYPE",b=y===t&&u===t&&n===t,q=Su.includes(y)&&u==="ETH"&&n==="ETH";if(b||T||M||q)return lu[t];return i(u.slice(n.length+1).replace(/^0X/,""))}catch{return null}}function h({provider:y}){return async({contractAddress:u,abi:n,funcName:t,funcParams:T=[],txOverrides:M})=>{let b=await Qy(u,n,y).getFunction(t).populateTransaction(...T.concat(M).filter((q)=>typeof q<"u"));return{...b,value:_(BigInt(b.value||0))}}}function m({chain:y,provider:u,isEIP1559Compatible:n=!0}){return wy(y).with(l.Gnosis,()=>{return async function(){try{let{gasPrice:T,maxPriorityFeePerGas:M}=await u.getFeeData();if(!T||M===null)throw new Z("toolbox_evm_no_fee_data");return{[Y.Average]:{maxFeePerGas:N(T,Y.Average),maxPriorityFeePerGas:N(M,Y.Average)},[Y.Fast]:{maxFeePerGas:N(T,Y.Fast),maxPriorityFeePerGas:N(M,Y.Fast)},[Y.Fastest]:{maxFeePerGas:N(T,Y.Fastest),maxPriorityFeePerGas:N(M,Y.Fastest)}}}catch(T){throw new Z("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}}).with(l.Arbitrum,()=>{return async function(){try{let{gasPrice:T}=await u.getFeeData();if(!T)throw new Z("toolbox_evm_no_fee_data");let M=T*12n/10n;return{[Y.Average]:{gasPrice:M},[Y.Fast]:{gasPrice:N(M,Y.Fast)},[Y.Fastest]:{gasPrice:N(M,Y.Fastest)}}}catch(T){throw new Z("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}}).otherwise(()=>{return async function(){try{let{maxFeePerGas:T,maxPriorityFeePerGas:M,gasPrice:b}=await u.getFeeData();if(n){if(T===null||M===null)throw new Z("toolbox_evm_no_fee_data");return{[Y.Average]:{maxFeePerGas:T,maxPriorityFeePerGas:M},[Y.Fast]:{maxFeePerGas:N(T,Y.Fast),maxPriorityFeePerGas:N(M,Y.Fast)},[Y.Fastest]:{maxFeePerGas:N(T,Y.Fastest),maxPriorityFeePerGas:N(M,Y.Fastest)}}}if(!b)throw new Z("toolbox_evm_no_gas_price");return{[Y.Average]:{gasPrice:b},[Y.Fast]:{gasPrice:N(b,Y.Fast)},[Y.Fastest]:{gasPrice:N(b,Y.Fastest)}}}catch(T){throw new Z("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}})}function yy({provider:y,isEIP1559Compatible:u,signer:n,chain:t}){return async function({callProvider:M,contractAddress:b,abi:q,funcName:W,funcParams:Q=[],txOverrides:U={},feeOption:k=Y.Fast}){let X=M||y;if(!b)throw new Z("toolbox_evm_invalid_params",{error:"contractAddress must be provided"});let B=Vu({abi:q,funcName:W});if(B&&e(X)&&n){let z=h({chain:t,provider:X}),V=U?.from||await n?.getAddress(),j=await z({abi:q,contractAddress:b,funcName:W,funcParams:Q,txOverrides:{...U,from:V}});return r(X)(j)}let J=Qy(b,q,X);if(B){if(!n)throw new Z("toolbox_evm_no_signer");let z=U?.from||await n.getAddress();if(!z)throw new Z("toolbox_evm_no_signer_address");let V=J.connect(n),j=m({chain:t,isEIP1559Compatible:u,provider:y}),{maxFeePerGas:K,maxPriorityFeePerGas:x,gasPrice:I}=(await j())[k],w=await J.getFunction(W).estimateGas(...Q,U),S=await V[W](...Q,{...U,gasLimit:w,gasPrice:I,maxFeePerGas:K,maxPriorityFeePerGas:x,nonce:U?.nonce||await X.getTransactionCount(z)});return typeof S?.hash==="string"?S?.hash:S}let D=await J[W]?.(...Q);return typeof D?.hash==="string"?D?.hash:D}}function ly({provider:y,chain:u}){return function({assetAddress:t,spenderAddress:T,from:M}){return yy({chain:u,isEIP1559Compatible:!0,provider:y})({abi:A,contractAddress:t,funcName:"allowance",funcParams:[M,T]})}}function Ku({provider:y,chain:u}){return async function({assetAddress:t,spenderAddress:T,from:M,amount:b=Wy}){let q=await ly({chain:u,provider:y})({assetAddress:t,from:M,spenderAddress:T});return s.fromBigInt(q).gte(s.fromBigInt(BigInt(b)))}}function Ou({signer:y,isEIP1559Compatible:u=!0,provider:n,chain:t}){return async function({assetAddress:M,spenderAddress:b,feeOptionKey:q=Y.Fast,amount:W,gasLimitFallback:Q,from:U,nonce:k}){let X=[b,BigInt(W||Wy)],B=await y?.getAddress()||U,J={abi:A,contractAddress:M,funcName:"approve",funcParams:X,signer:y,txOverrides:{from:B}};if(e(n)){let z=h({chain:t,provider:n}),V=r(n),j=await z(J);return V(j)}return yy({chain:t,isEIP1559Compatible:u,provider:n,signer:y})({...J,feeOption:q,funcParams:X,txOverrides:{from:B,gasLimit:Q?BigInt(Q.toString()):void 0,nonce:k}})}}function fu({chain:y,estimateGasPrices:u,estimateAdditionalFee:n,signer:t,isEIP1559Compatible:T=!0,provider:M}){return async function({assetValue:q,memo:W,recipient:Q,feeOptionKey:U=Y.Fast,sender:k,sweep:X,...B}){let J=k||await t?.getAddress(),D=Oy({chain:y,estimateGasPrices:u,isEIP1559Compatible:T,provider:M,signer:t});if(!J)throw new Z("toolbox_evm_no_from_address");let z=await fy({chain:y,estimateAdditionalFee:n,estimateGasPrices:u,isEIP1559Compatible:T,provider:M,signer:t})({assetValue:q,feeOptionKey:U,memo:W,recipient:Q,sender:J,sweep:X,...B});return D({...z,feeOptionKey:U,sweep:X})}}function Sy({provider:y,signer:u}){return function({contractAddress:t,abi:T,funcName:M,funcParams:b=[],txOverrides:q}){if(!t)throw new Z("toolbox_evm_no_contract_address");let W=Qy(t,T,y);return u?W.connect(u).getFunction(M).estimateGas(...b,q):W.getFunction(M).estimateGas(...b,q)}}function xu({provider:y,signer:u}){return async function({assetValue:t,recipient:T,memo:M,data:b,sender:q,funcName:W,funcParams:Q,txOverrides:U}){let k=t.bigIntValue,X=t.isGasAsset?null:Xy(t,t.chain);if(X&&W)return Sy({provider:y,signer:u})({abi:A,contractAddress:X,funcName:W,funcParams:Q,txOverrides:U});let{hexlify:B,toUtf8Bytes:J}=await import("ethers");return y.estimateGas({data:b?b:M?B(J(M)):void 0,from:q,to:T,value:k})}}function Fu({signer:y}){if(!y)return;return(u)=>zy(y,u)}var Ky=(y)=>y.type===4||(y.authorizations?.length??0)>0,Iu=(y)=>!Ky(y)&&(y.type===2||!!y.maxFeePerGas||!!y.maxPriorityFeePerGas),Eu=(y,u=!0)=>{if(Ky(y))return"eip7702";if(Iu(y)||u)return"eip1559";return"legacy"};function Au(y,u){if(y==="legacy"){if(u.gasPrice===void 0)throw new Z("toolbox_evm_no_fee_data");return{gasPrice:_(u.gasPrice)}}if(u.maxFeePerGas===void 0||u.maxPriorityFeePerGas===void 0)throw new Z("toolbox_evm_no_fee_data");return{maxFeePerGas:_(u.maxFeePerGas),maxPriorityFeePerGas:_(u.maxPriorityFeePerGas)}}function Oy({chain:y,estimateGasPrices:u,provider:n,signer:t,isEIP1559Compatible:T=!0}){return async function({feeOptionKey:b=Y.Fast,sweep:q,...W}){let{from:Q,to:U,data:k,value:X,...B}=W;if(!t)throw new Z("toolbox_evm_no_signer");if(!U)throw new Z("toolbox_evm_no_to_address");let J={...B,data:k||"0x",from:Q,to:U,value:BigInt(X||0)};if(e(n))return r(n,q)(J);let D=Q||await t.getAddress(),z=W.nonce??await n.getTransactionCount(D),V=(await n.getNetwork()).chainId,j=Eu(J,T);if(j==="eip7702")jy(J.authorizations||[],V);let K=wy(j).with("eip7702",()=>4).with("eip1559",()=>2).otherwise(()=>0),x={...J,chainId:V,nonce:z,type:K,...j==="eip7702"&&{authorizationList:J.authorizations}},I=u??m({chain:y,isEIP1559Compatible:T,provider:n}),S=(j==="legacy"?J.gasPrice!==void 0:J.maxFeePerGas!==void 0&&J.maxPriorityFeePerGas!==void 0)?{}:Au(j,(await I())[b]),O;try{O=_(J.gasLimit?BigInt(J.gasLimit):await n.estimateGas(x)*11n/10n)}catch(G){throw new Z("toolbox_evm_error_estimating_gas_limit",{error:G})}try{let G={...x,gasLimit:O,...S};try{return(await t.sendTransaction(G)).hash}catch{let F=await t.signTransaction({...G,from:D});return(await n.broadcastTransaction(F)).hash}}catch(G){throw new Z("toolbox_evm_error_sending_transaction",{error:G})}}}function E(y,u){throw new Z({errorKey:"toolbox_sweep_amount_too_low",info:{balance:y.toString(),fee:u.toString()}})}function Pu(y,u){if(u){if(y.maxFeePerGas===void 0||y.maxPriorityFeePerGas===void 0)throw new Z("toolbox_evm_no_fee_data");return{feeFields:{maxFeePerGas:y.maxFeePerGas,maxPriorityFeePerGas:y.maxPriorityFeePerGas},feePerGas:y.maxFeePerGas}}if(y.gasPrice===void 0)throw new Z("toolbox_evm_no_fee_data");return{feeFields:{gasPrice:y.gasPrice},feePerGas:y.gasPrice}}function Cu(y,u){if(y>u)return y;return u}function ou(y){return ju(y).reduce((u,n)=>u+(n===0?4n:16n),21000n)}function qy(y){let n=(y instanceof Error?y.message:String(y)).toLowerCase();return n.includes("insufficient funds")||n.includes("insufficient balance")||n.includes("gas required exceeds allowance")}async function gu({balance:y,estimateAdditionalFee:u,feeOptionKey:n,l2Reserve:t,sweepTx:T,valueBeforeL1Fee:M}){if(!u)return 0n;let b=await u({...T,value:M})??0n,q=N(b,n),W=M-q;if(W<=0n)E(y,t+q);let Q=await u({...T,value:W})??b;return N(Cu(b,Q),n)}async function vu({chain:y,data:u,estimateGasPrices:n,estimateAdditionalFee:t,feeOptionKey:T,from:M,isEIP1559Compatible:b,provider:q,recipient:W,transaction:Q}){let U=await q.getBalance(M),k=n??m({chain:y,isEIP1559Compatible:b,provider:q}),{feeFields:X,feePerGas:B}=Pu((await k())[T],b),D={...t&&Q.nonce===void 0?{...Q,nonce:await q.getTransactionCount(M)}:Q,...X,data:u,from:M,to:W},z=ou(u)*B;if(U-z<=0n)E(U,z);let V=(U-z)/2n,j;try{j=await q.estimateGas({...D,value:V})}catch(v){if(!qy(v))throw v;try{j=await q.estimateGas({...D,value:0n})}catch(By){if(qy(By))E(U,z);throw By}}let K=j*B;if(U-K<=0n)E(U,K);let w=j*11n/10n*B,S=U>w?U-w:0n,O;try{O=await q.estimateGas({...D,value:S})}catch(v){if(!qy(v))throw v;E(U,w)}let G=O*B,F=U-G;if(F<=0n)E(U,G);let o=await gu({balance:U,estimateAdditionalFee:t,feeOptionKey:T,l2Reserve:G,sweepTx:{...D,gasLimit:O},valueBeforeL1Fee:F}),g=F-o;if(g<=0n)E(U,G+o);return{...D,gasLimit:O,value:_(g)}}async function cu({chain:y,contractAddress:u,from:n,provider:t}){let T=await yy({chain:y,provider:t})({abi:A,contractAddress:u,funcName:"balanceOf",funcParams:[n]});if(typeof T!=="bigint")throw new Z({errorKey:"toolbox_evm_invalid_transaction",info:{error:"Invalid ERC20 balance"}});return T}function fy({chain:y,estimateAdditionalFee:u,estimateGasPrices:n,isEIP1559Compatible:t=!0,provider:T,signer:M}){return async function({assetValue:q,authorizations:W,memo:Q,recipient:U,data:k,feeOptionKey:X=Y.Fast,gasLimit:B,sender:J,sweep:D,type:z,maxFeePerGas:V,maxPriorityFeePerGas:j,gasPrice:K,...x}){let I=q.getBaseValue("bigint"),w=J||await M?.getAddress();if(!w)throw new Z("toolbox_evm_no_from_address");if(D&&(z===4||(W?.length??0)>0))throw new Z({errorKey:"toolbox_not_supported",info:{chain:y,reason:"EIP-7702 sweep transactions are not supported"}});if(Lu(q)){let{hexlify:F,toUtf8Bytes:o}=await import("ethers"),g=k||F(o(Q||""));if(!D)return{...x,...W!==void 0&&{authorizations:W},data:g,from:w,...B!==void 0&&{gasLimit:B},to:U,...z!==void 0&&{type:z},value:_(I)};return vu({chain:y,data:g,estimateAdditionalFee:u,estimateGasPrices:n,feeOptionKey:X,from:w,isEIP1559Compatible:t,provider:T,recipient:U,transaction:{nonce:x.nonce,type:z}})}let S=Xy(q,y);if(!S)throw new Z("toolbox_evm_no_contract_address");let O=h({chain:y,provider:T}),G=D?await cu({chain:y,contractAddress:S,from:w,provider:T}):I;if(D&&G<=0n)throw new Z({errorKey:"toolbox_sweep_amount_too_low",info:{asset:q.toString(),balance:G.toString()}});return O({abi:A,contractAddress:S,funcName:"transfer",funcParams:[U,G],txOverrides:{from:w,gasLimit:B,gasPrice:K,maxFeePerGas:V,maxPriorityFeePerGas:j}})}}function hu({provider:y,signer:u,chain:n}){return async function({assetAddress:T,spenderAddress:M,amount:b,from:q}){let W=await u?.getAddress()||q,Q=h({chain:n,provider:y}),U=["bigint","number"].includes(typeof b)?b:b||Wy;return await Q({abi:A,contractAddress:T,funcName:"approve",funcParams:[M,BigInt(U)],txOverrides:{from:W}})}}function mu({provider:y,isEIP1559Compatible:u=!0,chain:n}){return async function({feeOption:T=Y.Fast,...M}){let q=await m({chain:n,isEIP1559Compatible:u,provider:y})(),W=await y.estimateGas(M),Q=ku.from({chain:n}),{gasPrice:U,maxFeePerGas:k,maxPriorityFeePerGas:X}=q[T];if(!u&&U)return Q.set(s.fromBigInt(U*W,Q.decimal));if(k&&X){let B=(k+X)*W;return Q.set(s.fromBigInt(B,Q.decimal))}throw new Z("toolbox_evm_no_gas_price")}}import{applyFeeMultiplierToBigInt as P,Chain as Iy,FeeOption as f,getChainConfig as pu,SwapKitError as C}from"@swapkit/helpers";import{Contract as du,HDNodeWallet as su}from"ethers";import{match as iu,P as Fy}from"ts-pattern";var xy=[{inputs:[{internalType:"address",name:"_owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"DecimalsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"GasPriceUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"L1BaseFeeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"OverheadUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"ScalarUpdated",type:"event"},{inputs:[],name:"decimals",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"gasPrice",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"_data",type:"bytes"}],name:"getL1Fee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"_data",type:"bytes"}],name:"getL1GasUsed",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_gasUsed",type:"uint256"}],name:"getOperatorFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"l1BaseFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"overhead",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"scalar",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_decimals",type:"uint256"}],name:"setDecimals",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_gasPrice",type:"uint256"}],name:"setGasPrice",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_baseFee",type:"uint256"}],name:"setL1BaseFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_overhead",type:"uint256"}],name:"setOverhead",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_scalar",type:"uint256"}],name:"setScalar",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];var au="0x420000000000000000000000000000000000000f";function uy(y){return new du(au,xy,y)}function Ey(y){return async function(){let n=uy(y);if(n&&"l1BaseFee"in n)return await n?.l1BaseFee();return}}function Ay(y){return async function({from:n,to:t,nonce:T,...M}){let{Transaction:b}=await import("ethers");if(!t)throw new C("toolbox_evm_invalid_transaction",{error:"Missing to address"});return b.from({...M,authorizationList:M.authorizationList,nonce:T??(n?await y.getTransactionCount(n):0),to:t}).unsignedSerialized}}function Yy(y,u){return async function(t){let T=uy(y),M=t.chainId??u??(await y.getNetwork()).chainId,b=await Ay(y)({...t,chainId:M});if(T&&"getL1Fee"in T){let q=await T.getL1Fee(b);if(typeof q!=="bigint")throw new C({errorKey:"toolbox_evm_invalid_transaction",info:{error:"Invalid OP-stack L1 fee"}});return q}return}}function Zy(y){return async function(n){let t=uy(y);if(t&&"getOperatorFee"in t){let T=await t.getOperatorFee(n);if(typeof T!=="bigint")throw new C({errorKey:"toolbox_evm_invalid_transaction",info:{error:"Invalid OP-stack operator fee"}});return T}return 0n}}function eu(y,u){let n=Yy(y,u),t=Zy(y);return async function(M){if(M.gasLimit===void 0||M.gasLimit===null)throw new C({errorKey:"toolbox_evm_invalid_transaction",info:{error:"Missing gas limit for OP-stack fee estimation"}});let[b,q]=await Promise.all([n(M),t(BigInt(M.gasLimit.toString()))]);return(b??0n)+q}}function Py(y){return async function(n){let T=(await y.getFeeData()).gasPrice??0n,M=await y.estimateGas(n);return T*M}}function ru(y){return async function(n){let t=await Yy(y)(n)??0n,T=await Py(y)(n),M=n.gasLimit??await y.estimateGas(n),b=await Zy(y)(BigInt(M.toString()));return t+T+b}}function y5(y){return async function(n){let t=uy(y),T=await Ay(y)(n);if(t&&"getL1GasUsed"in t)return t.getL1GasUsed(T)}}function u5(y){return async function(){try{let{maxFeePerGas:n,maxPriorityFeePerGas:t,gasPrice:T}=await y.getFeeData(),M=await Ey(y)(),b=T;if(!(n&&t))throw new C("toolbox_evm_no_fee_data");return{[f.Average]:{gasPrice:b,l1GasPrice:M,maxFeePerGas:n,maxPriorityFeePerGas:t},[f.Fast]:{gasPrice:P(b,f.Fast),l1GasPrice:P(M||0n,f.Fast),maxFeePerGas:n,maxPriorityFeePerGas:P(t,f.Fast)},[f.Fastest]:{gasPrice:P(b,f.Fastest),l1GasPrice:P(M||0n,f.Fastest),maxFeePerGas:n,maxPriorityFeePerGas:P(t,f.Fastest)}}}catch(n){throw new C("toolbox_evm_gas_estimation_error",{error:n.msg??n.toString()})}}}function ny(y){return function({provider:n,...t}){let T=iu(t).with({phrase:Fy.string},({phrase:X})=>su.fromPhrase(X).connect(n)).with({signer:Fy.any},({signer:X})=>X).otherwise(()=>{return}),M=Ey(n),b=BigInt(pu(y).chainId),q=Yy(n,b),W=eu(n,b),Q=Zy(n),U=y===Iy.Optimism?u5(n):void 0;return{...a({chain:y,estimateAdditionalFee:W,estimateGasPrices:U,provider:n,signer:T}),estimateL1Gas:y5(n),estimateL1GasCost:q,estimateL2GasCost:Py(n),estimateOperatorFee:Q,estimateTotalGasCost:ru(n),getBalance:d(y).getBalance,getL1GasPrice:M}}}var Cy=ny(Iy.Optimism);function gy(y){let u=L(R.Ethereum)(y);async function n(t,T="0x5ba1e12693dc8f9c48aad8770482f4739beed696",M="aggregate",b=n5.Fast){let q=await u.createContractTxObject({abi:Gy,contractAddress:T,funcName:M,funcParams:[t]});return u.sendTransaction({...q,feeOptionKey:b})}return{...u,multicall:n}}var vy=L(R.Adi),cy=L(R.Arbitrum),hy=L(R.Aurora),my=L(R.Avalanche),py=ny(R.Base),dy=L(R.Berachain),sy=L(R.BinanceSmartChain),g5=L(R.Botanix),iy=L(R.Core),ay=L(R.Corn),ey=L(R.Cronos),ry=L(R.Gnosis),yu=L(R.Robinhood),uu=L(R.Hyperevm),nu=L(R.Linea),tu=L(R.Polygon),Tu=L(R.MegaETH),Mu=L(R.Monad),bu=L(R.Plasma),$y=L(R.Sonic),qu=ny(R.Unichain),Uu=L(R.XLayer);function L(y){return function({provider:n,...t}){let T=Ly(y),M=T5(t).with({phrase:oy.string},({phrase:q})=>t5.fromPhrase(q).connect(n)).with({signer:oy.any},({signer:q})=>q).otherwise(()=>{return});return a({chain:y,isEIP1559Compatible:T,provider:n,signer:M})}}function q5(y,u){return b5(y).with(H.Adi,()=>vy(u)).with(H.Arbitrum,()=>cy(u)).with(H.Aurora,()=>hy(u)).with(H.Avalanche,()=>my(u)).with(H.Base,()=>py(u)).with(H.Berachain,()=>dy(u)).with(H.BinanceSmartChain,()=>sy(u)).with(H.Botanix,()=>$y(u)).with(H.Core,()=>iy(u)).with(H.Corn,()=>ay(u)).with(H.Cronos,()=>ey(u)).with(H.Ethereum,()=>gy(u)).with(H.Gnosis,()=>ry(u)).with(H.Hyperevm,()=>uu(u)).with(H.Linea,()=>nu(u)).with(H.MegaETH,()=>Tu(u)).with(H.Monad,()=>Mu(u)).with(H.Optimism,()=>Cy(u)).with(H.Plasma,()=>bu(u)).with(H.Polygon,()=>tu(u)).with(H.Robinhood,()=>yu(u)).with(H.Sonic,()=>$y(u)).with(H.Unichain,()=>qu(u)).with(H.XLayer,()=>Uu(u)).exhaustive()}async function p5(y,u){let n={...u,provider:u?.provider||ky(y)};return q5(y,n)}
2
+ export{d as b,J5 as c,$u as d,X5 as e,ky as f,_ as g,Dy as h,Ly as i,zy as j,Hu as k,Ru as l,Y5 as m,jy as n,Wy as o,a as p,Gu as q,e as r,Qy as s,Nu as t,Vu as u,G5 as v,r as w,N5 as x,lu as y,Xy as z,h as A,m as B,Ky as C,Iu as D,Eu as E,ny as F,Cy as G,gy as H,vy as I,cy as J,hy as K,my as L,py as M,dy as N,sy as O,g5 as P,iy as Q,ay as R,ey as S,ry as T,yu as U,uu as V,nu as W,tu as X,Tu as Y,Mu as Z,bu as _,$y as $,qu as aa,Uu as ba,q5 as ca,p5 as da};
@@ -1 +1 @@
1
- var k=Object.create;var{getPrototypeOf:$,defineProperty:b,getOwnPropertyNames:R,getOwnPropertyDescriptor:K}=Object,N=Object.prototype.hasOwnProperty;function v(n){return this[n]}var j,q,Z=(n,s,e)=>{var r=n!=null&&typeof n==="object";if(r){var _=s?j??=new WeakMap:q??=new WeakMap,f=_.get(n);if(f)return f}e=n!=null?k($(n)):{};let d=s||!n||!n.__esModule?b(e,"default",{value:n,enumerable:!0}):e;for(let m of R(n))if(!N.call(d,m))b(d,m,{get:v.bind(n,m),enumerable:!0});if(r)_.set(n,d);return d},W=(n)=>{var s=(B??=new WeakMap).get(n),e;if(s)return s;if(s=b({},"__esModule",{value:!0}),n&&typeof n==="object"||typeof n==="function"){for(var r of R(n))if(!N.call(s,r))b(s,r,{get:v.bind(n,r),enumerable:!(e=K(n,r))||e.enumerable})}return B.set(n,s),s},B;var Y=(n)=>n;function H(n,s){this[n]=Y.bind(null,s)}var Q=(n,s)=>{for(var e in s)b(n,e,{get:s[e],enumerable:!0,configurable:!0,set:H.bind(s,e)})};var C=(n,s)=>()=>(n&&(s=n(n=0)),s);function y(n){if(!n||typeof n!=="string"||!n.startsWith("0x"))return!1;let s=n.slice(2);if(s.length===0||s.length>64)return!1;return z.test(s)}function F({derivationPath:n,provider:s,...e}={}){let r,_=t.derivationPathToString(n||t.NetworkDerivationPath[t.Chain.Aptos],{allHardened:!0});async function f(){if(r)return r;return r=await T.match(e).with({phrase:T.P.string},async({phrase:o})=>{let{Ed25519Account:a}=await import("@aptos-labs/ts-sdk");return a.fromDerivationPath({mnemonic:o,path:_})}).with({signer:T.P.any},({signer:o})=>o).otherwise(()=>{return}),r}async function d(){let{Aptos:o,AptosConfig:a,Network:i}=await import("@aptos-labs/ts-sdk"),u=new a({clientConfig:{http2:!1},fullnode:s||t.getRPCUrlSync(t.Chain.Aptos),network:i.MAINNET});return new o(u)}async function m(){return(await f())?.accountAddress.toString()||""}async function I(o){let a=o||await m();if(!a)throw new t.SwapKitError("toolbox_aptos_address_required");let{baseDecimal:i,chain:u}=t.getChainConfig(t.Chain.Aptos);try{let p=await d(),A=await p.getAccountAPTAmount({accountAddress:a}),g=[t.AssetValue.from({chain:u,fromBaseDecimal:i,value:A.toString()})],h=await p.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:a}}}});for(let c of h){if(c.asset_type===w.COIN_TYPE||Number(c.amount)<=0)continue;let l=c.asset_type;if(l){let O=("metadata"in c&&typeof c.metadata==="object"&&c.metadata!==null?c.metadata:void 0)?.decimals??i;g.push(t.AssetValue.from({asset:`${t.Chain.Aptos}.APT-${l}`,fromBaseDecimal:O,value:String(c.amount)}))}}return g}catch{return[t.AssetValue.from({chain:u})]}}async function U(o){if(!o){let{baseDecimal:h}=t.getChainConfig(t.Chain.Aptos),c=s||t.getRPCUrlSync(t.Chain.Aptos),l=await fetch(`${c}/estimate_gas_price`),{gas_estimate:x}=await l.json();return t.AssetValue.from({chain:t.Chain.Aptos,fromBaseDecimal:h,value:String(x)})}let a=await f();if(!a)throw new t.SwapKitError("toolbox_aptos_no_signer");let i=await E(o),u=await d(),[p]=await u.transaction.simulate.simple({signerPublicKey:a.publicKey,transaction:i});if(!p)throw new t.SwapKitError("toolbox_aptos_transaction_creation_error");let A=BigInt(p.gas_used)*BigInt(p.gas_unit_price),{baseDecimal:g}=t.getChainConfig(t.Chain.Aptos);return t.AssetValue.from({chain:t.Chain.Aptos,fromBaseDecimal:g,value:A.toString()})}async function E({recipient:o,assetValue:a,maxGasAmount:i,sender:u}){if(!y(o))throw new t.SwapKitError("core_transaction_invalid_recipient_address");let p=u||await m();if(!p)throw new t.SwapKitError("toolbox_aptos_no_sender");let{AccountAddress:A}=await import("@aptos-labs/ts-sdk"),g=await d(),h=A.from(p);try{let c=a.isGasAsset?w.TRANSFER:w.FUNGIBLE_STORE_TRANSFER,l=T.match({address:a?.address,isGasAsset:a.isGasAsset}).with({isGasAsset:!0},()=>[A.from(o),a.getBaseValue("bigint")]).with({address:T.P.string},({address:x})=>[A.from(x),A.from(o),a.getBaseValue("bigint")]).otherwise(()=>null);if(!l)throw new t.SwapKitError("toolbox_aptos_missing_asset_type");return g.transaction.build.simple({data:{function:c,functionArguments:l,typeArguments:a.isGasAsset?[]:[w.FUNGIBLE_ASSET_METADATA]},options:i?{maxGasAmount:i}:void 0,sender:h})}catch(c){if(c instanceof t.SwapKitError)throw c;throw new t.SwapKitError("toolbox_aptos_transaction_creation_error",c)}}async function S(o){let a=await f();if(!a)throw new t.SwapKitError("toolbox_aptos_no_signer");return(await d()).transaction.sign({signer:a,transaction:o})}async function L({assetValue:o,maxGasAmount:a,recipient:i}){let u=await f();if(!u)throw new t.SwapKitError("toolbox_aptos_no_signer");if(!y(i))throw new t.SwapKitError("core_transaction_invalid_recipient_address");try{let p=u.accountAddress.toString(),A=await E({assetValue:o,maxGasAmount:a,recipient:i,sender:p});return(await(await d()).signAndSubmitTransaction({signer:u,transaction:A})).hash}catch(p){if(p instanceof t.SwapKitError)throw p;throw new t.SwapKitError("toolbox_aptos_transaction_creation_error",p)}}async function P({senderAuthenticator:o,transaction:a}){try{return(await(await d()).transaction.submit.simple({senderAuthenticator:o,transaction:a})).hash}catch(i){throw new t.SwapKitError("toolbox_aptos_broadcast_error",i)}}async function M(o){let a=await S(o);return P({senderAuthenticator:a,transaction:o})}return{broadcastTransaction:P,createTransaction:E,estimateTransactionFee:U,getAddress:m,getBalance:I,signAndBroadcastTransaction:M,signTransaction:S,transfer:L,validateAddress:y}}function D({provider:n}){return async function({assetValue:e,recipient:r}){if(!y(r))throw new t.SwapKitError("core_transaction_invalid_recipient_address");let{AccountAddress:_}=await import("@aptos-labs/ts-sdk");if(e.isGasAsset)return(await n.signAndSubmitTransaction({arguments:[_.from(r).toString(),e.getBaseValue("string")],function:w.TRANSFER,type:"entry_function_payload",type_arguments:[]})).hash;let f=e.address;if(!f)throw new t.SwapKitError("toolbox_aptos_missing_asset_type");return(await n.signAndSubmitTransaction({arguments:[f,_.from(r).toString(),e.getBaseValue("string")],function:w.FUNGIBLE_STORE_TRANSFER,type:"entry_function_payload",type_arguments:[w.FUNGIBLE_ASSET_METADATA]})).hash}}var t,T,w,z;var G=C(()=>{t=require("@swapkit/helpers"),T=require("ts-pattern"),w={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"},z=/^[0-9a-fA-F]+$/});var J={};Q(J,{validateAptosAddress:()=>y,getAptosToolbox:()=>F,createAptosExtensionTransfer:()=>D});module.exports=W(J);var X=C(()=>{G()});X();
1
+ var e=Object.create;var{getPrototypeOf:jj,defineProperty:_,getOwnPropertyNames:m,getOwnPropertyDescriptor:qj}=Object,A=Object.prototype.hasOwnProperty;function l(q){return this[q]}var zj,Hj,Ij=(q,z,R)=>{var W=q!=null&&typeof q==="object";if(W){var N=z?zj??=new WeakMap:Hj??=new WeakMap,D=N.get(q);if(D)return D}R=q!=null?e(jj(q)):{};let Z=z||!q||!q.__esModule?_(R,"default",{value:q,enumerable:!0}):R;for(let y of m(q))if(!A.call(Z,y))_(Z,y,{get:l.bind(q,y),enumerable:!0});if(W)N.set(q,Z);return Z},Jj=(q)=>{var z=(g??=new WeakMap).get(q),R;if(z)return z;if(z=_({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var W of m(q))if(!A.call(z,W))_(z,W,{get:l.bind(q,W),enumerable:!(R=qj(q,W))||R.enumerable})}return g.set(q,z),z},g;var Rj=(q)=>q;function Wj(q,z){this[q]=Rj.bind(null,z)}var Yj=(q,z)=>{for(var R in z)_(q,R,{get:z[R],enumerable:!0,configurable:!0,set:Wj.bind(z,R)})};var p=(q,z)=>()=>(q&&(z=q(q=0)),z);function B(q){if(!q||typeof q!=="string"||!q.startsWith("0x"))return!1;let z=q.slice(2);if(z.length===0||z.length>64)return!1;return $j.test(z)}function c(q,z,R){if(q<=0n)throw new j.SwapKitError({errorKey:"toolbox_sweep_amount_too_low",info:{amount:q.toString(),asset:z.toString(),...R}});return q}async function kj({aptos:q,assetValue:z,senderAddress:R}){let W=z.address;if(!W)throw new j.SwapKitError("toolbox_aptos_missing_asset_type");let[N]=await q.getCurrentFungibleAssetBalances({options:{limit:1,where:{asset_type:{_eq:W},is_primary:{_eq:!0},owner_address:{_eq:R}}}});return c(BigInt(N?.amount??0),z)}function u({derivationPath:q,provider:z,...R}={}){let W,N=j.derivationPathToString(q||j.NetworkDerivationPath[j.Chain.Aptos],{allHardened:!0});async function D(){if(W)return W;return W=await C.match(R).with({phrase:C.P.string},async({phrase:J})=>{let{Ed25519Account:H}=await import("@aptos-labs/ts-sdk");return H.fromDerivationPath({mnemonic:J,path:N})}).with({signer:C.P.any},({signer:J})=>J).otherwise(()=>{return}),W}async function Z(){let{Aptos:J,AptosConfig:H,Network:Y}=await import("@aptos-labs/ts-sdk"),k=new H({clientConfig:{http2:!1},fullnode:z||j.getRPCUrlSync(j.Chain.Aptos),network:Y.MAINNET});return new J(k)}async function y(){return(await D())?.accountAddress.toString()||""}async function b(J){let H=J||await y();if(!H)throw new j.SwapKitError("toolbox_aptos_address_required");let{baseDecimal:Y,chain:k}=j.getChainConfig(j.Chain.Aptos);try{let I=await Z(),$=await I.getAccountAPTAmount({accountAddress:H}),X=[j.AssetValue.from({chain:k,fromBaseDecimal:Y,value:$.toString()})],F=await I.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:H}}}});for(let L of F){if(L.asset_type===U.COIN_TYPE||Number(L.amount)<=0)continue;let Q=L.asset_type;if(Q){let M=("metadata"in L&&typeof L.metadata==="object"&&L.metadata!==null?L.metadata:void 0)?.decimals??Y;X.push(j.AssetValue.from({asset:`${j.Chain.Aptos}.APT-${Q}`,fromBaseDecimal:M,value:String(L.amount)}))}}return X}catch{return[j.AssetValue.from({chain:k})]}}async function i(J){if(!J){let{baseDecimal:X}=j.getChainConfig(j.Chain.Aptos),F=z||j.getRPCUrlSync(j.Chain.Aptos),L=await fetch(`${F}/estimate_gas_price`),{gas_estimate:Q}=await L.json();return j.AssetValue.from({chain:j.Chain.Aptos,fromBaseDecimal:X,value:String(Q)})}let H=await x(J),Y=await Z(),[k]=await Y.transaction.simulate.simple({transaction:H});if(!k)throw new j.SwapKitError("toolbox_aptos_transaction_creation_error");let I=BigInt(k.gas_used)*BigInt(k.gas_unit_price),{baseDecimal:$}=j.getChainConfig(j.Chain.Aptos);return j.AssetValue.from({chain:j.Chain.Aptos,fromBaseDecimal:$,value:I.toString()})}async function x({recipient:J,assetValue:H,maxGasAmount:Y,sender:k,sweep:I}){if(!B(J))throw new j.SwapKitError("core_transaction_invalid_recipient_address");let $=k||await y();if(!$)throw new j.SwapKitError("toolbox_aptos_no_sender");let{AccountAddress:X}=await import("@aptos-labs/ts-sdk"),F=await Z(),L=X.from($);try{let Q=H.isGasAsset?U.TRANSFER:U.FUNGIBLE_STORE_TRANSFER,h=H.address,M=(f,O)=>{let S=C.match({address:h,isGasAsset:H.isGasAsset}).with({isGasAsset:!0},()=>[X.from(J),f]).with({address:C.P.string},({address:s})=>[X.from(s),X.from(J),f]).otherwise(()=>null);if(!S)throw new j.SwapKitError("toolbox_aptos_missing_asset_type");let V=O?.maxGasAmount??Y;return F.transaction.build.simple({data:{function:Q,functionArguments:S,typeArguments:H.isGasAsset?[]:[U.FUNGIBLE_ASSET_METADATA]},options:V!==void 0||O?.gasUnitPrice!==void 0?{gasUnitPrice:O?.gasUnitPrice,maxGasAmount:V}:void 0,sender:L})};if(!I)return M(H.getBaseValue("bigint"));if(!H.isGasAsset){let f=await kj({aptos:F,assetValue:H,senderAddress:$});return M(f)}let T=BigInt(await F.getAccountAPTAmount({accountAddress:$})),t=await M(1n,{maxGasAmount:Y??Zj}),[P]=await F.transaction.simulate.simple({options:{estimateMaxGasAmount:Y===void 0},transaction:t});if(!P)throw new j.SwapKitError("toolbox_aptos_transaction_creation_error");if(!P.success)throw new j.SwapKitError({errorKey:"toolbox_aptos_transaction_creation_error",info:{vmStatus:P.vm_status}});let K=BigInt(P.gas_used),E=K>0n?(K*6n+4n)/5n:1n,w=E*BigInt(P.gas_unit_price),a=c(T-w,H,{balance:T.toString(),fee:w.toString()});return M(a,{gasUnitPrice:Number(P.gas_unit_price),maxGasAmount:Number(E)})}catch(Q){if(Q instanceof j.SwapKitError)throw Q;throw new j.SwapKitError("toolbox_aptos_transaction_creation_error",Q)}}async function v(J){let H=await D();if(!H)throw new j.SwapKitError("toolbox_aptos_no_signer");return(await Z()).transaction.sign({signer:H,transaction:J})}async function n({assetValue:J,maxGasAmount:H,recipient:Y,sweep:k}){let I=await D();if(!I)throw new j.SwapKitError("toolbox_aptos_no_signer");if(!B(Y))throw new j.SwapKitError("core_transaction_invalid_recipient_address");try{let $=I.accountAddress.toString(),X=await x({assetValue:J,maxGasAmount:H,recipient:Y,sender:$,sweep:k});return(await(await Z()).signAndSubmitTransaction({signer:I,transaction:X})).hash}catch($){if($ instanceof j.SwapKitError)throw $;throw new j.SwapKitError("toolbox_aptos_transaction_creation_error",$)}}async function G({senderAuthenticator:J,transaction:H}){try{return(await(await Z()).transaction.submit.simple({senderAuthenticator:J,transaction:H})).hash}catch(Y){throw new j.SwapKitError("toolbox_aptos_broadcast_error",Y)}}async function r(J){let H=await v(J);return G({senderAuthenticator:H,transaction:J})}return{broadcastTransaction:G,createTransaction:x,estimateTransactionFee:i,getAddress:y,getBalance:b,signAndBroadcastTransaction:r,signTransaction:v,transfer:n,validateAddress:B}}function d({provider:q}){return async function({assetValue:R,recipient:W,sweep:N}){if(N)throw new j.SwapKitError({errorKey:"toolbox_not_supported",info:{chain:j.Chain.Aptos,feature:"extension_provider_sweep",reason:"Aptos extension providers cannot query balances or simulate transactions"}});if(!B(W))throw new j.SwapKitError("core_transaction_invalid_recipient_address");let{AccountAddress:D}=await import("@aptos-labs/ts-sdk");if(R.isGasAsset)return(await q.signAndSubmitTransaction({arguments:[D.from(W).toString(),R.getBaseValue("string")],function:U.TRANSFER,type:"entry_function_payload",type_arguments:[]})).hash;let Z=R.address;if(!Z)throw new j.SwapKitError("toolbox_aptos_missing_asset_type");return(await q.signAndSubmitTransaction({arguments:[Z,D.from(W).toString(),R.getBaseValue("string")],function:U.FUNGIBLE_STORE_TRANSFER,type:"entry_function_payload",type_arguments:[U.FUNGIBLE_ASSET_METADATA]})).hash}}var j,C,U,Zj=2000,$j;var o=p(()=>{j=require("@swapkit/helpers"),C=require("ts-pattern"),U={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"},$j=/^[0-9a-fA-F]+$/});var Lj={};Yj(Lj,{validateAptosAddress:()=>B,getAptosToolbox:()=>u,createAptosExtensionTransfer:()=>d});module.exports=Jj(Lj);var Xj=p(()=>{o()});Xj();
@@ -1 +1 @@
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
+ import{ga as x}from"../../chunk-xbdjxeqd.js";import{AssetValue as P,Chain as Q,derivationPathToString as t,getChainConfig as v,getRPCUrlSync as l,NetworkDerivationPath as a,SwapKitError as z}from"@swapkit/helpers";import{match as p,P as G}from"ts-pattern";var N={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"},s=2000,e=/^[0-9a-fA-F]+$/;function B(J){if(!J||typeof J!=="string"||!J.startsWith("0x"))return!1;let Z=J.slice(2);if(Z.length===0||Z.length>64)return!1;return e.test(Z)}function c(J,Z,L){if(J<=0n)throw new z({errorKey:"toolbox_sweep_amount_too_low",info:{amount:J.toString(),asset:Z.toString(),...L}});return J}async function jj({aptos:J,assetValue:Z,senderAddress:L}){let $=Z.address;if(!$)throw new z("toolbox_aptos_missing_asset_type");let[M]=await J.getCurrentFungibleAssetBalances({options:{limit:1,where:{asset_type:{_eq:$},is_primary:{_eq:!0},owner_address:{_eq:L}}}});return c(BigInt(M?.amount??0),Z)}function qj({derivationPath:J,provider:Z,...L}={}){let $,M=t(J||a[Q.Aptos],{allHardened:!0});async function y(){if($)return $;return $=await p(L).with({phrase:G.string},async({phrase:q})=>{let{Ed25519Account:j}=await import("@aptos-labs/ts-sdk");return j.fromDerivationPath({mnemonic:q,path:M})}).with({signer:G.any},({signer:q})=>q).otherwise(()=>{return}),$}async function D(){let{Aptos:q,AptosConfig:j,Network:H}=await import("@aptos-labs/ts-sdk"),W=new j({clientConfig:{http2:!1},fullnode:Z||l(Q.Aptos),network:H.MAINNET});return new q(W)}async function _(){return(await y())?.accountAddress.toString()||""}async function h(q){let j=q||await _();if(!j)throw new z("toolbox_aptos_address_required");let{baseDecimal:H,chain:W}=v(Q.Aptos);try{let X=await D(),R=await X.getAccountAPTAmount({accountAddress:j}),k=[P.from({chain:W,fromBaseDecimal:H,value:R.toString()})],F=await X.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:j}}}});for(let Y of F){if(Y.asset_type===N.COIN_TYPE||Number(Y.amount)<=0)continue;let I=Y.asset_type;if(I){let U=("metadata"in Y&&typeof Y.metadata==="object"&&Y.metadata!==null?Y.metadata:void 0)?.decimals??H;k.push(P.from({asset:`${Q.Aptos}.APT-${I}`,fromBaseDecimal:U,value:String(Y.amount)}))}}return k}catch{return[P.from({chain:W})]}}async function u(q){if(!q){let{baseDecimal:k}=v(Q.Aptos),F=Z||l(Q.Aptos),Y=await fetch(`${F}/estimate_gas_price`),{gas_estimate:I}=await Y.json();return P.from({chain:Q.Aptos,fromBaseDecimal:k,value:String(I)})}let j=await O(q),H=await D(),[W]=await H.transaction.simulate.simple({transaction:j});if(!W)throw new z("toolbox_aptos_transaction_creation_error");let X=BigInt(W.gas_used)*BigInt(W.gas_unit_price),{baseDecimal:R}=v(Q.Aptos);return P.from({chain:Q.Aptos,fromBaseDecimal:R,value:X.toString()})}async function O({recipient:q,assetValue:j,maxGasAmount:H,sender:W,sweep:X}){if(!B(q))throw new z("core_transaction_invalid_recipient_address");let R=W||await _();if(!R)throw new z("toolbox_aptos_no_sender");let{AccountAddress:k}=await import("@aptos-labs/ts-sdk"),F=await D(),Y=k.from(R);try{let I=j.isGasAsset?N.TRANSFER:N.FUNGIBLE_STORE_TRANSFER,E=j.address,U=(f,b)=>{let m=p({address:E,isGasAsset:j.isGasAsset}).with({isGasAsset:!0},()=>[k.from(q),f]).with({address:G.string},({address:r})=>[k.from(r),k.from(q),f]).otherwise(()=>null);if(!m)throw new z("toolbox_aptos_missing_asset_type");let A=b?.maxGasAmount??H;return F.transaction.build.simple({data:{function:I,functionArguments:m,typeArguments:j.isGasAsset?[]:[N.FUNGIBLE_ASSET_METADATA]},options:A!==void 0||b?.gasUnitPrice!==void 0?{gasUnitPrice:b?.gasUnitPrice,maxGasAmount:A}:void 0,sender:Y})};if(!X)return U(j.getBaseValue("bigint"));if(!j.isGasAsset){let f=await jj({aptos:F,assetValue:j,senderAddress:R});return U(f)}let w=BigInt(await F.getAccountAPTAmount({accountAddress:R})),i=await U(1n,{maxGasAmount:H??s}),[C]=await F.transaction.simulate.simple({options:{estimateMaxGasAmount:H===void 0},transaction:i});if(!C)throw new z("toolbox_aptos_transaction_creation_error");if(!C.success)throw new z({errorKey:"toolbox_aptos_transaction_creation_error",info:{vmStatus:C.vm_status}});let S=BigInt(C.gas_used),V=S>0n?(S*6n+4n)/5n:1n,g=V*BigInt(C.gas_unit_price),n=c(w-g,j,{balance:w.toString(),fee:g.toString()});return U(n,{gasUnitPrice:Number(C.gas_unit_price),maxGasAmount:Number(V)})}catch(I){if(I instanceof z)throw I;throw new z("toolbox_aptos_transaction_creation_error",I)}}async function T(q){let j=await y();if(!j)throw new z("toolbox_aptos_no_signer");return(await D()).transaction.sign({signer:j,transaction:q})}async function d({assetValue:q,maxGasAmount:j,recipient:H,sweep:W}){let X=await y();if(!X)throw new z("toolbox_aptos_no_signer");if(!B(H))throw new z("core_transaction_invalid_recipient_address");try{let R=X.accountAddress.toString(),k=await O({assetValue:q,maxGasAmount:j,recipient:H,sender:R,sweep:W});return(await(await D()).signAndSubmitTransaction({signer:X,transaction:k})).hash}catch(R){if(R instanceof z)throw R;throw new z("toolbox_aptos_transaction_creation_error",R)}}async function K({senderAuthenticator:q,transaction:j}){try{return(await(await D()).transaction.submit.simple({senderAuthenticator:q,transaction:j})).hash}catch(H){throw new z("toolbox_aptos_broadcast_error",H)}}async function o(q){let j=await T(q);return K({senderAuthenticator:j,transaction:q})}return{broadcastTransaction:K,createTransaction:O,estimateTransactionFee:u,getAddress:_,getBalance:h,signAndBroadcastTransaction:o,signTransaction:T,transfer:d,validateAddress:B}}function zj({provider:J}){return async function({assetValue:L,recipient:$,sweep:M}){if(M)throw new z({errorKey:"toolbox_not_supported",info:{chain:Q.Aptos,feature:"extension_provider_sweep",reason:"Aptos extension providers cannot query balances or simulate transactions"}});if(!B($))throw new z("core_transaction_invalid_recipient_address");let{AccountAddress:y}=await import("@aptos-labs/ts-sdk");if(L.isGasAsset)return(await J.signAndSubmitTransaction({arguments:[y.from($).toString(),L.getBaseValue("string")],function:N.TRANSFER,type:"entry_function_payload",type_arguments:[]})).hash;let D=L.address;if(!D)throw new z("toolbox_aptos_missing_asset_type");return(await J.signAndSubmitTransaction({arguments:[D,y.from($).toString(),L.getBaseValue("string")],function:N.FUNGIBLE_STORE_TRANSFER,type:"entry_function_payload",type_arguments:[N.FUNGIBLE_ASSET_METADATA]})).hash}}export{B as validateAptosAddress,qj as getAptosToolbox,zj as createAptosExtensionTransfer};
@@ -1 +1 @@
1
- var XG=Object.create;var{getPrototypeOf:jG,defineProperty:E,getOwnPropertyNames:d,getOwnPropertyDescriptor:WG}=Object,i=Object.prototype.hasOwnProperty;function n(G){return this[G]}var qG,FG,UG=(G,J,Q)=>{var z=G!=null&&typeof G==="object";if(z){var W=J?qG??=new WeakMap:FG??=new WeakMap,F=W.get(G);if(F)return F}Q=G!=null?XG(jG(G)):{};let Z=J||!G||!G.__esModule?E(Q,"default",{value:G,enumerable:!0}):Q;for(let U of d(G))if(!i.call(Z,U))E(Z,U,{get:n.bind(G,U),enumerable:!0});if(z)W.set(G,Z);return Z},YG=(G)=>{var J=(c??=new WeakMap).get(G),Q;if(J)return J;if(J=E({},"__esModule",{value:!0}),G&&typeof G==="object"||typeof G==="function"){for(var z of d(G))if(!i.call(J,z))E(J,z,{get:n.bind(G,z),enumerable:!(Q=WG(G,z))||Q.enumerable})}return c.set(G,J),J},c;var MG=(G)=>G;function RG(G,J){this[G]=MG.bind(null,J)}var DG=(G,J)=>{for(var Q in J)E(G,Q,{get:J[Q],enumerable:!0,configurable:!0,set:RG.bind(J,Q)})};var o=(G,J)=>()=>(G&&(J=G(G=0)),J);async function p(G,J){let Q=await fetch(`${JG}${G}`,{...J,headers:{project_id:GG,...J?.headers}});if(!Q.ok)throw Error(`Blockfrost API error: ${Q.status} ${Q.statusText}`);return Q.json()}async function QG(G){try{return await p(`/addresses/${G}/utxos`)}catch{return[]}}async function HG(){return(await p("/blocks/latest")).slot}async function OG(){let G=await p("/epochs/latest/parameters"),J={PlutusScriptV1:G.cost_models.PlutusV1?Object.values(G.cost_models.PlutusV1):[],PlutusScriptV2:G.cost_models.PlutusV2?Object.values(G.cost_models.PlutusV2):[],PlutusScriptV3:G.cost_models.PlutusV3?Object.values(G.cost_models.PlutusV3):[]};return{collateralPercent:new q.default(G.collateral_percent),languageView:J,maxValueSize:Number.parseInt(G.max_val_size,10),minFeeA:new q.default(G.min_fee_a),minFeeB:new q.default(G.min_fee_b),minFeeRefScriptCostPerByte:new q.default(15),priceMem:new q.default(G.price_mem),priceSteps:new q.default(G.price_step),stakeKeyDeposit:new q.default(2000000),utxoCostPerByte:new q.default(G.coins_per_utxo_size)}}async function r(G){let J=await fetch(`${JG}/tx/submit`,{body:Buffer.from(G,"hex"),headers:{"Content-Type":"application/cbor",project_id:GG},method:"POST"});if(!J.ok){let Q=await J.text();throw Error(`Transaction submission failed: ${Q}`)}return J.json()}function _G(G,J){return G.map((Q)=>{let z=Q.amount.find((Z)=>Z.unit==="lovelace"),W=z?new q.default(z.quantity):new q.default(0),F=Q.amount.filter((Z)=>Z.unit!=="lovelace").map((Z)=>({amount:new q.default(Z.quantity),assetName:Z.unit.slice(56),policyId:Z.unit.slice(0,56)}));return{address:J,amount:W,index:Q.output_index,tokens:F,txId:Q.tx_hash}})}async function IG(G){try{let J=await QG(G),Q=0n,z=new Map;for(let Z of J){if(!Z.amount||!Array.isArray(Z.amount))continue;for(let U of Z.amount){let{unit:I,quantity:Y}=U;if(I==="lovelace")Q+=BigInt(Y);else{let R=z.get(I)||0n;z.set(I,R+BigInt(Y))}}}let W=[],{baseDecimal:F}=$.getChainConfig($.Chain.Cardano);if(Q>0n)W.push($.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:F,value:Q.toString()}));for(let[Z,U]of z)W.push($.AssetValue.from({asset:`${$.Chain.Cardano}.${Z}`,value:U.toString()}));if(W.length===0)return[$.AssetValue.from({chain:$.Chain.Cardano})];return W}catch(J){let Q=J instanceof Error?J.message:String(J);return console.error(`Cardano balance fetch error: ${Q}`),[$.AssetValue.from({chain:$.Chain.Cardano})]}}function ZG(G){if(!G||typeof G!=="string")return!1;try{let J=s.bech32.decode(G,120);return J.prefix==="addr"||J.prefix==="addr_test"}catch{return!1}}async function LG(G,J=0,Q=0){let{Bip32PrivateKey:z}=await import("@stricahq/bip32ed25519"),{types:W,address:F,crypto:Z}=await import("@stricahq/typhonjs"),U=a.mnemonicToEntropy(G,e.wordlist),Y=(await z.fromEntropy(Buffer.from(Array.from(U)))).derive(m+1852).derive(m+1815).derive(m+J),R=Y.derive(0).derive(Q),f=R.toBip32PublicKey().toPublicKey().toBytes(),K=Z.hash28(f),j=Y.derive(2).derive(0).toBip32PublicKey().toPublicKey().toBytes(),D=Z.hash28(j),M={hash:K,type:W.HashType.ADDRESS},O={hash:D,type:W.HashType.ADDRESS},k=new F.BaseAddress(W.NetworkId.MAINNET,M,O).getBech32(),v=R.toPrivateKey();return{getAddress:()=>k,publicKey:f,publicKeyHash:K,signTransaction:async(T)=>{try{let _=await import("@stricahq/cbors"),V=Buffer.from(T,"hex"),P=_.Decoder.decode(V),[w,S,h,b]=P.value,g=_.Encoder.encode(w),B=Z.hash32(g),x=v.sign(B),A=S instanceof Map?S:new Map,N=A.get(t)||[];N.push([f,x]),A.set(t,N);let y=[w,A,h,b];return _.Encoder.encode(y).toString("hex")}catch(_){throw new $.SwapKitError("toolbox_cardano_sign_transaction_failed",{message:String(_)})}}}}function fG(G){let J,Q,z;async function W(){if(!z)z=await OG();return z}async function F(){if(J!==void 0)return J;if(G&&"phrase"in G&&G.phrase){let X=G.index??0;return J=await LG(G.phrase,0,X),J}if(G&&"signer"in G&&G.signer)return J=G.signer,J;return}async function Z(){if(Q)return Q;let X=await F();if(!X)return"";if("getAddress"in X)return Q=await X.getAddress(),Q;return""}async function U(X){let j=X||await Z();if(!j)throw new $.SwapKitError("core_wallet_connection_not_found");return IG(j)}async function I(X){if(X)try{let{tx:O}=await Y(X),L=O.getFee();return $.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:6,value:L.toString()})}catch{}let j=await W(),D=400,M=j.minFeeB.plus(j.minFeeA.times(D));return $.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:6,value:M.toString()})}async function Y({sender:X="",recipient:j,assetValue:D,memo:M,pureLovelaceOnly:O=!1}){let{Transaction:L,utils:k}=await import("@stricahq/typhonjs"),v=X||await Z();if(!v)throw new $.SwapKitError("core_wallet_connection_not_found");let[T,_,V]=await Promise.all([QG(v),HG(),W()]),P=T.filter((H)=>O?H.amount.every((C)=>C.unit==="lovelace"):H.amount.some((C)=>C.unit==="lovelace")).sort((H,C)=>{let l=H.amount.some((u)=>u.unit!=="lovelace"),zG=C.amount.some((u)=>u.unit!=="lovelace");if(l===zG)return 0;return l?1:-1}),w=k.getAddressFromString(v),S=k.getAddressFromString(j),h=_G(P,w),b=new q.default(D.getBaseValue("string")),g=[{address:S,amount:b,tokens:[]}],B;if(M){let H=new Map;H.set("msg",[M]),B={metadata:[{data:H,label:674}]}}let x={...V,minFeeB:V.minFeeB.plus(V.minFeeA.times(4))},N=new L({protocolParams:x}).paymentTransaction({auxiliaryData:B,changeAddress:w,inputs:h,outputs:g,ttl:_+3600}),{payload:y}=N.buildTransaction();return{tx:N,unsignedTx:y}}async function R(X){let j=await F();if(!j||!("signTransaction"in j))throw new $.SwapKitError("core_wallet_connection_not_found");return j.signTransaction(X)}async function f({recipient:X,assetValue:j,memo:D}){let M=await F();if(!M||!("signTransaction"in M))throw new $.SwapKitError("core_wallet_connection_not_found");let{unsignedTx:O}=await Y({assetValue:j,memo:D,recipient:X,sender:await Z()}),L=await R(O);return await r(L)}async function K(X){let j=await R(X);return await r(j)}return{createTransaction:Y,estimateTransactionFee:I,getAddress:Z,getBalance:U,signAndBroadcastTransaction:K,signTransaction:R,transfer:f,validateAddress:ZG}}var s,a,e,$,q,GG="mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS",JG="https://cardano-mainnet.blockfrost.io/api/v0",m=2147483648,t=0;var $G=o(()=>{s=require("@scure/base"),a=require("@scure/bip39"),e=require("@scure/bip39/wordlists/english.js"),$=require("@swapkit/helpers"),q=UG(require("bignumber.js"))});var vG={};DG(vG,{validateCardanoAddress:()=>ZG,getCardanoToolbox:()=>fG});module.exports=YG(vG);var VG=o(()=>{$G()});VG();
1
+ var qG=Object.create;var{getPrototypeOf:FG,defineProperty:S,getOwnPropertyNames:i,getOwnPropertyDescriptor:UG}=Object,n=Object.prototype.hasOwnProperty;function o(G){return this[G]}var YG,MG,RG=(G,J,Q)=>{var z=G!=null&&typeof G==="object";if(z){var j=J?YG??=new WeakMap:MG??=new WeakMap,F=j.get(G);if(F)return F}Q=G!=null?qG(FG(G)):{};let Z=J||!G||!G.__esModule?S(Q,"default",{value:G,enumerable:!0}):Q;for(let W of i(G))if(!n.call(Z,W))S(Z,W,{get:o.bind(G,W),enumerable:!0});if(z)j.set(G,Z);return Z},HG=(G)=>{var J=(d??=new WeakMap).get(G),Q;if(J)return J;if(J=S({},"__esModule",{value:!0}),G&&typeof G==="object"||typeof G==="function"){for(var z of i(G))if(!n.call(J,z))S(J,z,{get:o.bind(G,z),enumerable:!(Q=UG(G,z))||Q.enumerable})}return d.set(G,J),J},d;var _G=(G)=>G;function IG(G,J){this[G]=_G.bind(null,J)}var kG=(G,J)=>{for(var Q in J)S(G,Q,{get:J[Q],enumerable:!0,configurable:!0,set:IG.bind(J,Q)})};var t=(G,J)=>()=>(G&&(J=G(G=0)),J);async function u(G,J){let Q=await fetch(`${QG}${G}`,{...J,headers:{project_id:JG,...J?.headers}});if(!Q.ok)throw Error(`Blockfrost API error: ${Q.status} ${Q.statusText}`);return Q.json()}async function ZG(G){try{return await u(`/addresses/${G}/utxos`)}catch{return[]}}async function OG(){return(await u("/blocks/latest")).slot}async function DG(){let G=await u("/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 U.default(G.collateral_percent),languageView:J,maxValueSize:Number.parseInt(G.max_val_size,10),minFeeA:new U.default(G.min_fee_a),minFeeB:new U.default(G.min_fee_b),minFeeRefScriptCostPerByte:new U.default(15),priceMem:new U.default(G.price_mem),priceSteps:new U.default(G.price_step),stakeKeyDeposit:new U.default(2000000),utxoCostPerByte:new U.default(G.coins_per_utxo_size)}}async function s(G){let J=await fetch(`${QG}/tx/submit`,{body:Buffer.from(G,"hex"),headers:{"Content-Type":"application/cbor",project_id:JG},method:"POST"});if(!J.ok){let Q=await J.text();throw Error(`Transaction submission failed: ${Q}`)}return J.json()}function NG(G,J){return G.map((Q)=>{let z=Q.amount.find((Z)=>Z.unit==="lovelace"),j=z?new U.default(z.quantity):new U.default(0),F=Q.amount.filter((Z)=>Z.unit!=="lovelace").map((Z)=>({amount:new U.default(Z.quantity),assetName:Z.unit.slice(56),policyId:Z.unit.slice(0,56)}));return{address:J,amount:j,index:Q.output_index,tokens:F,txId:Q.tx_hash}})}function LG({TransactionConstructor:G,auxiliaryData:J,bufferedParams:Q,currentSlot:z,inputs:j,recipientAddress:F}){let Z=j.reduce((X,q)=>X.plus(q.amount),new U.default(0));if(!Z.isPositive())throw new $.SwapKitError({errorKey:"toolbox_sweep_amount_too_low",info:{available:Z.toString()}});let W=new G({protocolParams:Q});for(let X of j)W.addInput(X);if(W.addOutput({address:F,amount:Z,tokens:[]}),W.setTTL(z+3600),J)W.setAuxiliaryData(J);W.setFee(W.calculateFee());let _=W.getFee(),Y=Z.minus(_),M={address:F,amount:Y,tokens:[]},k=W.calculateMinUtxoAmountBabbage(M);if(!Y.isPositive()||Y.lt(k))throw new $.SwapKitError({errorKey:"toolbox_sweep_amount_too_low",info:{available:Z.toString(),fee:_.toString(),minimumOutput:k.toString()}});return new G({protocolParams:Q}).paymentTransaction({auxiliaryData:J,changeAddress:F,inputs:j,outputs:[M],ttl:z+3600})}async function vG(G){try{let J=await ZG(G),Q=0n,z=new Map;for(let Z of J){if(!Z.amount||!Array.isArray(Z.amount))continue;for(let W of Z.amount){let{unit:_,quantity:Y}=W;if(_==="lovelace")Q+=BigInt(Y);else{let M=z.get(_)||0n;z.set(_,M+BigInt(Y))}}}let j=[],{baseDecimal:F}=$.getChainConfig($.Chain.Cardano);if(Q>0n)j.push($.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:F,value:Q.toString()}));for(let[Z,W]of z)j.push($.AssetValue.from({asset:`${$.Chain.Cardano}.${Z}`,value:W.toString()}));if(j.length===0)return[$.AssetValue.from({chain:$.Chain.Cardano})];return j}catch(J){let Q=J instanceof Error?J.message:String(J);return console.error(`Cardano balance fetch error: ${Q}`),[$.AssetValue.from({chain:$.Chain.Cardano})]}}function $G(G){if(!G||typeof G!=="string")return!1;try{let J=a.bech32.decode(G,120);return J.prefix==="addr"||J.prefix==="addr_test"}catch{return!1}}async function VG(G,J=0,Q=0){let{Bip32PrivateKey:z}=await import("@stricahq/bip32ed25519"),{types:j,address:F,crypto:Z}=await import("@stricahq/typhonjs"),W=e.mnemonicToEntropy(G,GG.wordlist),Y=(await z.fromEntropy(Buffer.from(Array.from(W)))).derive(l+1852).derive(l+1815).derive(l+J),M=Y.derive(0).derive(Q),k=M.toBip32PublicKey().toPublicKey().toBytes(),E=Z.hash28(k),q=Y.derive(2).derive(0).toBip32PublicKey().toPublicKey().toBytes(),R=Z.hash28(q),O={hash:E,type:j.HashType.ADDRESS},D={hash:R,type:j.HashType.ADDRESS},v=new F.BaseAddress(j.NetworkId.MAINNET,O,D).getBech32(),B=M.toPrivateKey();return{getAddress:()=>v,publicKey:k,publicKeyHash:E,signTransaction:async(C)=>{try{let L=await import("@stricahq/cbors"),A=Buffer.from(C,"hex"),K=L.Decoder.decode(A),[w,T,x,h]=K.value,P=L.Encoder.encode(w),g=Z.hash32(P),f=B.sign(g),V=T instanceof Map?T:new Map,y=V.get(r)||[];y.push([k,f]),V.set(r,y);let b=[w,V,x,h];return L.Encoder.encode(b).toString("hex")}catch(L){throw new $.SwapKitError("toolbox_cardano_sign_transaction_failed",{message:String(L)})}}}}function EG(G){let J,Q,z;async function j(){if(!z)z=await DG();return z}async function F(){if(J!==void 0)return J;if(G&&"phrase"in G&&G.phrase){let X=G.index??0;return J=await VG(G.phrase,0,X),J}if(G&&"signer"in G&&G.signer)return J=G.signer,J;return}async function Z(){if(Q)return Q;let X=await F();if(!X)return"";if("getAddress"in X)return Q=await X.getAddress(),Q;return""}async function W(X){let q=X||await Z();if(!q)throw new $.SwapKitError("core_wallet_connection_not_found");return vG(q)}async function _(X){if(X)try{let{tx:D}=await Y(X),N=D.getFee();return $.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:6,value:N.toString()})}catch{}let q=await j(),R=400,O=q.minFeeB.plus(q.minFeeA.times(R));return $.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:6,value:O.toString()})}async function Y({sender:X="",recipient:q,assetValue:R,memo:O,pureLovelaceOnly:D=!1,sweep:N=!1}){let{Transaction:v,utils:B}=await import("@stricahq/typhonjs"),C=X||await Z();if(!C)throw new $.SwapKitError("core_wallet_connection_not_found");let[L,A,K]=await Promise.all([ZG(C),OG(),j()]);if(N&&!R.isGasAsset)throw new $.SwapKitError({errorKey:"toolbox_not_supported",info:{asset:R.toString(),chain:$.Chain.Cardano,feature:"token_sweep"}});let w=N&&R.isGasAsset,T=D||w,x=L.filter((H)=>T?H.amount.some((I)=>I.unit==="lovelace")&&H.amount.every((I)=>I.unit==="lovelace"):H.amount.some((I)=>I.unit==="lovelace")).sort((H,I)=>{let c=H.amount.some((m)=>m.unit!=="lovelace"),WG=I.amount.some((m)=>m.unit!=="lovelace");if(c===WG)return 0;return c?1:-1}),h=B.getAddressFromString(C),P=B.getAddressFromString(q),g=NG(x,h),f;if(O){let H=new Map;H.set("msg",[O]),f={metadata:[{data:H,label:674}]}}let V={...K,minFeeB:K.minFeeB.plus(K.minFeeA.times(4))};if(w){let H=LG({auxiliaryData:f,bufferedParams:V,currentSlot:A,inputs:g,recipientAddress:P,TransactionConstructor:v}),{payload:I}=H.buildTransaction();return{tx:H,unsignedTx:I}}let y=new U.default(R.getBaseValue("string")),b=[{address:P,amount:y,tokens:[]}],p=new v({protocolParams:V}).paymentTransaction({auxiliaryData:f,changeAddress:h,inputs:g,outputs:b,ttl:A+3600}),{payload:jG}=p.buildTransaction();return{tx:p,unsignedTx:jG}}async function M(X){let q=await F();if(!q||!("signTransaction"in q))throw new $.SwapKitError("core_wallet_connection_not_found");return q.signTransaction(X)}async function k({recipient:X,assetValue:q,memo:R,sweep:O}){let D=await F();if(!D||!("signTransaction"in D))throw new $.SwapKitError("core_wallet_connection_not_found");let{unsignedTx:N}=await Y({assetValue:q,memo:R,recipient:X,sender:await Z(),sweep:O}),v=await M(N);return await s(v)}async function E(X){let q=await M(X);return await s(q)}return{createTransaction:Y,estimateTransactionFee:_,getAddress:Z,getBalance:W,signAndBroadcastTransaction:E,signTransaction:M,transfer:k,validateAddress:$G}}var a,e,GG,$,U,JG="mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS",QG="https://cardano-mainnet.blockfrost.io/api/v0",l=2147483648,r=0;var zG=t(()=>{a=require("@scure/base"),e=require("@scure/bip39"),GG=require("@scure/bip39/wordlists/english.js"),$=require("@swapkit/helpers"),U=RG(require("bignumber.js"))});var CG={};kG(CG,{validateCardanoAddress:()=>$G,getCardanoToolbox:()=>EG});module.exports=HG(CG);var KG=t(()=>{zG()});KG();
@@ -1 +1 @@
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
+ import{ga as b}from"../../chunk-xbdjxeqd.js";import{bech32 as JG}from"@scure/base";import{mnemonicToEntropy as QG}from"@scure/bip39";import{wordlist as ZG}from"@scure/bip39/wordlists/english.js";import{AssetValue as B,Chain as D,getChainConfig as $G,SwapKitError as N}from"@swapkit/helpers";import U from"bignumber.js";var t="mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS",r="https://cardano-mainnet.blockfrost.io/api/v0",p=2147483648,n=0;async function c(G,J){let Z=await fetch(`${r}${G}`,{...J,headers:{project_id:t,...J?.headers}});if(!Z.ok)throw Error(`Blockfrost API error: ${Z.status} ${Z.statusText}`);return Z.json()}async function s(G){try{return await c(`/addresses/${G}/utxos`)}catch{return[]}}async function zG(){return(await c("/blocks/latest")).slot}async function XG(){let G=await c("/epochs/latest/parameters"),J={PlutusScriptV1:G.cost_models.PlutusV1?Object.values(G.cost_models.PlutusV1):[],PlutusScriptV2:G.cost_models.PlutusV2?Object.values(G.cost_models.PlutusV2):[],PlutusScriptV3:G.cost_models.PlutusV3?Object.values(G.cost_models.PlutusV3):[]};return{collateralPercent:new U(G.collateral_percent),languageView:J,maxValueSize:Number.parseInt(G.max_val_size,10),minFeeA:new U(G.min_fee_a),minFeeB:new U(G.min_fee_b),minFeeRefScriptCostPerByte:new U(15),priceMem:new U(G.price_mem),priceSteps:new U(G.price_step),stakeKeyDeposit:new U(2000000),utxoCostPerByte:new U(G.coins_per_utxo_size)}}async function o(G){let J=await fetch(`${r}/tx/submit`,{body:Buffer.from(G,"hex"),headers:{"Content-Type":"application/cbor",project_id:t},method:"POST"});if(!J.ok){let Z=await J.text();throw Error(`Transaction submission failed: ${Z}`)}return J.json()}function jG(G,J){return G.map((Z)=>{let W=Z.amount.find((Q)=>Q.unit==="lovelace"),X=W?new U(W.quantity):new U(0),q=Z.amount.filter((Q)=>Q.unit!=="lovelace").map((Q)=>({amount:new U(Q.quantity),assetName:Q.unit.slice(56),policyId:Q.unit.slice(0,56)}));return{address:J,amount:X,index:Z.output_index,tokens:q,txId:Z.tx_hash}})}function WG({TransactionConstructor:G,auxiliaryData:J,bufferedParams:Z,currentSlot:W,inputs:X,recipientAddress:q}){let Q=X.reduce(($,z)=>$.plus(z.amount),new U(0));if(!Q.isPositive())throw new N({errorKey:"toolbox_sweep_amount_too_low",info:{available:Q.toString()}});let j=new G({protocolParams:Z});for(let $ of X)j.addInput($);if(j.addOutput({address:q,amount:Q,tokens:[]}),j.setTTL(W+3600),J)j.setAuxiliaryData(J);j.setFee(j.calculateFee());let H=j.getFee(),F=Q.minus(H),Y={address:q,amount:F,tokens:[]},I=j.calculateMinUtxoAmountBabbage(Y);if(!F.isPositive()||F.lt(I))throw new N({errorKey:"toolbox_sweep_amount_too_low",info:{available:Q.toString(),fee:H.toString(),minimumOutput:I.toString()}});return new G({protocolParams:Z}).paymentTransaction({auxiliaryData:J,changeAddress:q,inputs:X,outputs:[Y],ttl:W+3600})}async function qG(G){try{let J=await s(G),Z=0n,W=new Map;for(let Q of J){if(!Q.amount||!Array.isArray(Q.amount))continue;for(let j of Q.amount){let{unit:H,quantity:F}=j;if(H==="lovelace")Z+=BigInt(F);else{let Y=W.get(H)||0n;W.set(H,Y+BigInt(F))}}}let X=[],{baseDecimal:q}=$G(D.Cardano);if(Z>0n)X.push(B.from({chain:D.Cardano,fromBaseDecimal:q,value:Z.toString()}));for(let[Q,j]of W)X.push(B.from({asset:`${D.Cardano}.${Q}`,value:j.toString()}));if(X.length===0)return[B.from({chain:D.Cardano})];return X}catch(J){let Z=J instanceof Error?J.message:String(J);return console.error(`Cardano balance fetch error: ${Z}`),[B.from({chain:D.Cardano})]}}function FG(G){if(!G||typeof G!=="string")return!1;try{let J=JG.decode(G,120);return J.prefix==="addr"||J.prefix==="addr_test"}catch{return!1}}async function UG(G,J=0,Z=0){let{Bip32PrivateKey:W}=await import("@stricahq/bip32ed25519"),{types:X,address:q,crypto:Q}=await import("@stricahq/typhonjs"),j=QG(G,ZG),F=(await W.fromEntropy(Buffer.from(Array.from(j)))).derive(p+1852).derive(p+1815).derive(p+J),Y=F.derive(0).derive(Z),I=Y.toBip32PublicKey().toPublicKey().toBytes(),C=Q.hash28(I),z=F.derive(2).derive(0).toBip32PublicKey().toPublicKey().toBytes(),M=Q.hash28(z),k={hash:C,type:X.HashType.ADDRESS},O={hash:M,type:X.HashType.ADDRESS},V=new q.BaseAddress(X.NetworkId.MAINNET,k,O).getBech32(),K=Y.toPrivateKey();return{getAddress:()=>V,publicKey:I,publicKeyHash:C,signTransaction:async(w)=>{try{let v=await import("@stricahq/cbors"),T=Buffer.from(w,"hex"),f=v.Decoder.decode(T),[S,h,m,P]=f.value,g=v.Encoder.encode(S),y=Q.hash32(g),A=K.sign(y),E=h instanceof Map?h:new Map,x=E.get(n)||[];x.push([I,A]),E.set(n,x);let l=[S,E,m,P];return v.Encoder.encode(l).toString("hex")}catch(v){throw new N("toolbox_cardano_sign_transaction_failed",{message:String(v)})}}}}function IG(G){let J,Z,W;async function X(){if(!W)W=await XG();return W}async function q(){if(J!==void 0)return J;if(G&&"phrase"in G&&G.phrase){let $=G.index??0;return J=await UG(G.phrase,0,$),J}if(G&&"signer"in G&&G.signer)return J=G.signer,J;return}async function Q(){if(Z)return Z;let $=await q();if(!$)return"";if("getAddress"in $)return Z=await $.getAddress(),Z;return""}async function j($){let z=$||await Q();if(!z)throw new N("core_wallet_connection_not_found");return qG(z)}async function H($){if($)try{let{tx:O}=await F($),L=O.getFee();return B.from({chain:D.Cardano,fromBaseDecimal:6,value:L.toString()})}catch{}let z=await X(),M=400,k=z.minFeeB.plus(z.minFeeA.times(M));return B.from({chain:D.Cardano,fromBaseDecimal:6,value:k.toString()})}async function F({sender:$="",recipient:z,assetValue:M,memo:k,pureLovelaceOnly:O=!1,sweep:L=!1}){let{Transaction:V,utils:K}=await import("@stricahq/typhonjs"),w=$||await Q();if(!w)throw new N("core_wallet_connection_not_found");let[v,T,f]=await Promise.all([s(w),zG(),X()]);if(L&&!M.isGasAsset)throw new N({errorKey:"toolbox_not_supported",info:{asset:M.toString(),chain:D.Cardano,feature:"token_sweep"}});let S=L&&M.isGasAsset,h=O||S,m=v.filter((R)=>h?R.amount.some((_)=>_.unit==="lovelace")&&R.amount.every((_)=>_.unit==="lovelace"):R.amount.some((_)=>_.unit==="lovelace")).sort((R,_)=>{let i=R.amount.some((u)=>u.unit!=="lovelace"),GG=_.amount.some((u)=>u.unit!=="lovelace");if(i===GG)return 0;return i?1:-1}),P=K.getAddressFromString(w),g=K.getAddressFromString(z),y=jG(m,P),A;if(k){let R=new Map;R.set("msg",[k]),A={metadata:[{data:R,label:674}]}}let E={...f,minFeeB:f.minFeeB.plus(f.minFeeA.times(4))};if(S){let R=WG({auxiliaryData:A,bufferedParams:E,currentSlot:T,inputs:y,recipientAddress:g,TransactionConstructor:V}),{payload:_}=R.buildTransaction();return{tx:R,unsignedTx:_}}let x=new U(M.getBaseValue("string")),l=[{address:g,amount:x,tokens:[]}],d=new V({protocolParams:E}).paymentTransaction({auxiliaryData:A,changeAddress:P,inputs:y,outputs:l,ttl:T+3600}),{payload:e}=d.buildTransaction();return{tx:d,unsignedTx:e}}async function Y($){let z=await q();if(!z||!("signTransaction"in z))throw new N("core_wallet_connection_not_found");return z.signTransaction($)}async function I({recipient:$,assetValue:z,memo:M,sweep:k}){let O=await q();if(!O||!("signTransaction"in O))throw new N("core_wallet_connection_not_found");let{unsignedTx:L}=await F({assetValue:z,memo:M,recipient:$,sender:await Q(),sweep:k}),V=await Y(L);return await o(V)}async function C($){let z=await Y($);return await o(z)}return{createTransaction:F,estimateTransactionFee:H,getAddress:Q,getBalance:j,signAndBroadcastTransaction:C,signTransaction:Y,transfer:I,validateAddress:FG}}export{FG as validateCardanoAddress,IG as getCardanoToolbox};