@swapkit/toolboxes 4.23.1 → 4.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/chunk-ap5mzmjf.js +1 -0
- package/dist/{chunk-9psy287z.js → chunk-btth5bse.js} +1 -1
- package/dist/{chunk-jdh5asaw.js → chunk-nvfkjbyq.js} +1 -1
- package/dist/{chunk-fjyc6m34.js → chunk-xbdjxeqd.js} +1 -1
- package/dist/chunk-z61r1327.js +2 -0
- package/dist/src/aleo/index.cjs +1 -0
- package/dist/src/aleo/index.js +1 -0
- package/dist/src/aptos/index.cjs +1 -1
- package/dist/src/aptos/index.js +1 -1
- package/dist/src/cardano/index.cjs +1 -1
- package/dist/src/cardano/index.js +1 -1
- package/dist/src/cosmos/index.cjs +1 -1
- package/dist/src/cosmos/index.js +1 -1
- package/dist/src/evm/index.cjs +1 -1
- package/dist/src/evm/index.js +1 -1
- package/dist/src/hypercore/index.cjs +1 -1
- package/dist/src/hypercore/index.js +1 -1
- package/dist/src/index.cjs +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/near/index.cjs +1 -1
- package/dist/src/near/index.js +1 -1
- package/dist/src/radix/index.js +1 -1
- package/dist/src/ripple/index.cjs +1 -1
- package/dist/src/ripple/index.js +1 -1
- package/dist/src/solana/index.cjs +1 -1
- package/dist/src/solana/index.js +1 -1
- package/dist/src/starknet/index.cjs +1 -1
- package/dist/src/starknet/index.js +1 -1
- package/dist/src/stellar/index.cjs +1 -1
- package/dist/src/stellar/index.js +1 -1
- package/dist/src/substrate/index.cjs +1 -1
- package/dist/src/substrate/index.js +1 -1
- package/dist/src/sui/index.cjs +1 -1
- package/dist/src/sui/index.js +1 -1
- package/dist/src/ton/index.cjs +1 -1
- package/dist/src/ton/index.js +1 -1
- package/dist/src/tron/index.cjs +1 -1
- package/dist/src/tron/index.js +1 -1
- package/dist/src/utxo/index.cjs +1 -1
- package/dist/src/utxo/index.js +1 -1
- package/dist/types/aleo/helpers.d.ts +62 -0
- package/dist/types/aleo/index.d.ts +3 -0
- package/dist/types/aleo/toolbox.d.ts +40 -0
- package/dist/types/aleo/types.d.ts +32 -0
- package/dist/types/aptos/toolbox.d.ts +11 -7
- package/dist/types/cardano/toolbox.d.ts +2 -2
- package/dist/types/cosmos/thorchainUtils/messages.d.ts +2 -1
- package/dist/types/cosmos/thorchainUtils/registry.d.ts +1 -1
- package/dist/types/cosmos/toolbox/cosmos.d.ts +1 -1
- package/dist/types/cosmos/toolbox/thorchain.d.ts +6 -6
- package/dist/types/cosmos/util.d.ts +16 -2
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +66 -21
- package/dist/types/evm/toolbox/evm.d.ts +1603 -234
- package/dist/types/evm/toolbox/op.d.ts +235 -11
- package/dist/types/evm/types.d.ts +7 -13
- package/dist/types/hypercore/toolbox.d.ts +2 -2
- package/dist/types/hypercore/types.d.ts +3 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/near/toolbox.d.ts +22 -3
- package/dist/types/near/types.d.ts +4 -1
- package/dist/types/ripple/index.d.ts +3 -2
- package/dist/types/solana/toolbox.d.ts +2 -2
- package/dist/types/starknet/toolbox.d.ts +2 -2
- package/dist/types/starknet/types.d.ts +3 -12
- package/dist/types/stellar/toolbox.d.ts +2 -2
- package/dist/types/sui/toolbox.d.ts +3 -3
- package/dist/types/ton/toolbox.d.ts +1 -4
- package/dist/types/tron/toolbox.d.ts +2 -2
- package/dist/types/types.d.ts +2 -0
- package/dist/types/utxo/hdWallet.d.ts +1 -1
- package/dist/types/utxo/helpers/coinselect.d.ts +2 -1
- package/dist/types/utxo/toolbox/bitcoinCash.d.ts +7 -5
- package/dist/types/utxo/toolbox/utxo.d.ts +8 -5
- package/dist/types/utxo/toolbox/zcash.d.ts +6 -4
- package/package.json +9 -2
- package/dist/chunk-6b99avsd.js +0 -2
- package/dist/chunk-e02sjx7s.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @swapkit/toolboxes
|
|
2
2
|
|
|
3
|
+
## 4.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#319](https://github.com/swapkit/sdk/pull/319) [`67445d1`](https://github.com/swapkit/sdk/commit/67445d13c963492bbe4283f098b959de010ed0a7) Thanks [@towanTG](https://github.com/towanTG)! - Add Aleo chain metadata, assets, public-balance support, HD derivation, public transfers, fee estimates, broadcasting, transaction status, and keystore/server registration.
|
|
8
|
+
- [#328](https://github.com/swapkit/sdk/pull/328) [`0794dd0`](https://github.com/swapkit/sdk/commit/0794dd0d92a4ab1808c42069d483b91e5ae35f4a) Thanks [@towanTG](https://github.com/towanTG)! - Aleo review follow-up: surface `splitTransactionId` in unshield failure errors so an interrupted unshield is resumable, treat a 404 on the serial-number lookup as the authoritative unspent answer across RPC failover, filter record extraction to `credits.aleo` in `getRecords`, reject toolbox params carrying both a phrase and an external signer (`toolbox_aleo_conflicting_signers`), validate `feeRecordCredits`, and throw a clear `toolbox_aleo_no_rpc_urls` error when no RPC URL is configured.
|
|
9
|
+
- [#325](https://github.com/swapkit/sdk/pull/325) [`88aa0cc`](https://github.com/swapkit/sdk/commit/88aa0cc308af1010e5632a7fd9136e43ddbed6a4) Thanks [@paz-ts](https://github.com/paz-ts)! - toSignificant no longer corrupts values with long decimal parts: leading zeros are stripped as a string instead of through Number.parseInt, whose float round-trip rendered full-precision balances on 24-decimal chains like NEAR with two decimal points ("0.0003.2238") and silently lost digits past 2^53 on 18-decimal chains. (via @swapkit/helpers@4.18.0)
|
|
10
|
+
- Update generated token lists. (via @swapkit/helpers@4.18.0)
|
|
11
|
+
|
|
12
|
+
## 4.24.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#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.
|
|
17
|
+
- [#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.
|
|
18
|
+
- Update generated token lists. (via @swapkit/helpers@4.17.1)
|
|
19
|
+
|
|
20
|
+
## 4.24.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- [#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.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`d787a38`](https://github.com/swapkit/sdk/commit/d787a38c6c96f36afde3964957409f4b2e4356a3)]:
|
|
29
|
+
- @swapkit/helpers@4.17.0
|
|
30
|
+
|
|
3
31
|
## 4.23.1
|
|
4
32
|
|
|
5
33
|
### 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
|
|
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
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var CJ=Object.create;var{getPrototypeOf:vJ,defineProperty:F,getOwnPropertyNames:zJ,getOwnPropertyDescriptor:TJ}=Object,HJ=Object.prototype.hasOwnProperty;function WJ(J){return this[J]}var SJ,hJ,cJ=(J,Q,Z)=>{var H=J!=null&&typeof J==="object";if(H){var z=Q?SJ??=new WeakMap:hJ??=new WeakMap,L=z.get(J);if(L)return L}Z=J!=null?CJ(vJ(J)):{};let U=Q||!J||!J.__esModule?F(Z,"default",{value:J,enumerable:!0}):Z;for(let D of zJ(J))if(!HJ.call(U,D))F(U,D,{get:WJ.bind(J,D),enumerable:!0});if(H)z.set(J,U);return U},IJ=(J)=>{var Q=(YJ??=new WeakMap).get(J),Z;if(Q)return Q;if(Q=F({},"__esModule",{value:!0}),J&&typeof J==="object"||typeof J==="function"){for(var H of zJ(J))if(!HJ.call(Q,H))F(Q,H,{get:WJ.bind(J,H),enumerable:!(Z=TJ(J,H))||Z.enumerable})}return YJ.set(J,Q),Q},YJ;var mJ=(J)=>J;function RJ(J,Q){this[J]=mJ.bind(null,Q)}var AJ=(J,Q)=>{for(var Z in Q)F(J,Z,{get:Q[Z],enumerable:!0,configurable:!0,set:RJ.bind(Q,Z)})};var S=(J,Q)=>()=>(J&&(Q=J(J=0)),Q);function i(J,Q){if(!M(J))return[];let Z=M(J.transaction)?J.transaction:J,H=Z.execution,z=M(Z.fee)?Z.fee.transition:void 0;return[...M(H)&&Array.isArray(H.transitions)?H.transitions:[],...M(z)?[z]:[]].flatMap((U)=>{if(!M(U)||!Array.isArray(U.outputs))return[];if(Q&&U.program!==Q)return[];return U.outputs.flatMap((D)=>M(D)&&D.type==="record"&&typeof D.value==="string"?[D.value]:[])})}function n(J){return J.reduce((Q,Z)=>Z.spent?Q:Q+Z.microcredits,0n)}function b(J,Q){return Q instanceof j.SwapKitError&&Q.errorKey.startsWith("toolbox_aleo_")?Q:new j.SwapKitError(J,Q)}function EJ(...J){let Q=J.reduce((z,L)=>z+L.length,0),Z=new Uint8Array(Q),H=0;for(let z of J)Z.set(z,H),H+=z.length;return Z}function gJ(J){let Q=new Uint8Array(4);return new DataView(Q.buffer).setUint32(0,J,!1),Q}function GJ(J){let Q=p.hmac(l.sha512,jJ,J);return{chainCode:Q.slice(32),key:Q.slice(0,32)}}function LJ(J,Q){if(!Number.isSafeInteger(Q)||Q<0||Q>=u)throw new j.SwapKitError("toolbox_aleo_wasm_init_failed",{index:Q});let Z=Q+u,H=EJ(Uint8Array.of(0),J.key,gJ(Z)),z=p.hmac(l.sha512,J.chainCode,H);return{chainCode:z.slice(32),key:z.slice(0,32)}}function o(J,Q){let Z=J.split("/");if(Z.shift()!=="m"||Z.length===0)throw new j.SwapKitError("toolbox_aleo_wasm_init_failed",{path:J});return Z.reduce((H,z)=>{if(!/^\d+'$/.test(z))throw new j.SwapKitError("toolbox_aleo_wasm_init_failed",{path:J,segment:z});return LJ(H,Number.parseInt(z.slice(0,-1),10))},GJ(Q))}function _(J){return typeof J==="string"&&XJ.test(J)}async function s(J){if(!_(J))return!1;try{let{Account:Q}=await import("@provablehq/sdk/mainnet.js");return Q.isValidAddress(J)}catch{return!1}}function UJ(J){return qJ.test(J)}function t(J,Q){if(J===null)return 0n;if(typeof J!=="string")throw new j.SwapKitError("toolbox_aleo_balance_error",{integerType:Q,value:J});let Z=J.match(new RegExp(`^(\\d+)${Q}$`));if(!Z?.[1])throw new j.SwapKitError("toolbox_aleo_balance_error",{integerType:Q,value:J});return BigInt(Z[1])}function m(J){if(J.chain!==j.Chain.Aleo)throw new j.SwapKitError("toolbox_aleo_unsupported_token",{asset:J.toString()});let Q=J.getBaseValue("bigint");if(J.isGasAsset)return{amount:`${Q}u64`,functionName:h,isTokenTransfer:!1,programName:y};if(!J.address||!UJ(J.address))throw new j.SwapKitError("toolbox_aleo_unsupported_token",{asset:J.toString()});return{amount:`${Q}u128`,functionName:h,isTokenTransfer:!0,programName:J.address}}function P(){let J=[...new Set([...j.SKConfig.get("rpcUrls")[j.Chain.Aleo],...j.getChainConfig(j.Chain.Aleo).rpcUrls])].filter(Boolean);if(J.length===0)throw new j.SwapKitError("toolbox_aleo_no_rpc_urls");return J}function R(J){if(typeof J==="object"&&J!==null&&"status"in J&&J.status===404)return!0;return J instanceof Error&&J.message.includes("404")}function M(J){return typeof J==="object"&&J!==null}function BJ(J){if(!M(J))return!1;return[J.transaction,J.rejected].some((Q)=>{if(!M(Q)||!M(Q.execution))return!1;let{transitions:Z}=Q.execution;return Array.isArray(Z)&&Z.some((H)=>M(H)&&H.function===h&&typeof H.program==="string"&&H.program!==y)})}function DJ(J,Q){if(!M(J)||typeof J.status!=="string")throw new j.SwapKitError("toolbox_aleo_transaction_failed",{response:J,transactionId:Q});let Z=J.status.toLowerCase();if(Z==="rejected"){let H=BJ(J)?"toolbox_aleo_token_transfer_rejected":"toolbox_aleo_transaction_failed";throw new j.SwapKitError(H,{transactionId:Q})}return Z==="accepted"?"accepted":"pending"}async function xJ(J){if(!N.test(J))throw new j.SwapKitError("toolbox_aleo_transaction_failed",{transactionId:J});let Q,Z=!0;for(let H of P())try{let{AleoNetworkClient:z}=await import("@provablehq/sdk/mainnet.js"),L=await new z(H).getConfirmedTransaction(J);return DJ(L,J)}catch(z){if(z instanceof j.SwapKitError)throw z;Q=z,Z=Z&&R(z)}if(Z)return"pending";throw b("toolbox_aleo_transaction_failed",Q)}async function A(J,{intervalMs:Q=5000,timeoutMs:Z=60000}={}){let H=Date.now();while(Date.now()-H<Z){let z=await xJ(J);if(z==="accepted")return z;await new Promise((L)=>setTimeout(L,Q))}throw new j.SwapKitError("toolbox_aleo_transaction_failed",{reason:"confirmation_timeout",transactionId:J})}var p,l,j,XJ,qJ,N,jJ,u=2147483648,I=1e6,y="credits.aleo",h="transfer_public",c=1e6,d=2000000;var a=S(()=>{p=require("@noble/hashes/hmac.js"),l=require("@noble/hashes/sha2.js"),j=require("@swapkit/helpers"),XJ=/^aleo1[ac-hj-np-z02-9]{58}$/,qJ=/^[a-z0-9_]+\.aleo$/,N=/^at1[ac-hj-np-z02-9]+$/,jJ=new TextEncoder().encode("bls12_377 seed")});function nJ(){function J(){let Q=Date.now(),Z=e||Q;return e=Z,Q>e?Q:Z+1}return uJ+J().toString(36)}function MJ(J){return async function(Z,H=!0){let z=await kJ.SwapKitApi.getChainBalance({address:Z,chain:J,scamFilter:H}),{baseDecimal:L}=C.getChainConfig(J),U=z.map(({identifier:O,value:V,decimal:v})=>{return new C.AssetValue({decimal:v||L,identifier:O,value:V})});if(!U.some((O)=>O.isGasAsset))return[C.AssetValue.from({chain:J}),...U];return U}}var C,kJ,uJ,e=0;var fJ=S(()=>{C=require("@swapkit/helpers"),kJ=require("@swapkit/helpers/api"),uJ=typeof process<"u"&&process.pid?process.pid.toString(36):""});async function OJ(J,Q){try{let{Account:Z}=await import("@provablehq/sdk/mainnet.js"),{mnemonicToSeedSync:H}=await import("@scure/bip39"),z=W.derivationPathToString(Q||W.NetworkDerivationPath[W.Chain.Aleo],{allHardened:!0}),{key:L}=o(z,H(J));return new Z({seed:L})}catch(Z){throw b("toolbox_aleo_wasm_init_failed",Z)}}function bJ(J,Q){let Z,H=()=>{return Z??=OJ(J,Q),Z};return{getAddress:async()=>(await H()).address().to_string(),signTransaction:async(z)=>{let L=await H();if(z.sender!==L.address().to_string())throw new W.SwapKitError("toolbox_aleo_invalid_address",{address:z.sender});let U;for(let D of P())try{let{ProgramManager:O}=await import("@provablehq/sdk/mainnet.js"),V=new O(D);return V.setAccount(L),await V.buildExecutionTransaction({functionName:z.functionName,inputs:z.inputs,priorityFee:z.priorityFee/I,privateFee:!1,programName:z.programName})}catch(O){U=O}throw U}}}function yJ(J={}){if("phrase"in J&&J.phrase&&"signer"in J&&J.signer)throw new W.SwapKitError("toolbox_aleo_conflicting_signers");let Q;async function Z(){if(Q)return Q;let Y="phrase"in J?J.phrase:void 0;if(!Y)throw new W.SwapKitError("toolbox_aleo_no_signer");let $="derivationPath"in J?J.derivationPath:void 0;return Q=await OJ(Y,$),Q}let H;function z(){let Y="signer"in J?J.signer:void 0;if(Y)return Y;let $="phrase"in J?J.phrase:void 0;if(!$)throw new W.SwapKitError("toolbox_aleo_no_signer");return H??=bJ($,"derivationPath"in J?J.derivationPath:void 0),H}async function L(Y){let $;for(let X of P())try{let{AleoNetworkClient:q}=await import("@provablehq/sdk/mainnet.js");return await Y(new q(X))}catch(q){$=q}throw $}async function U(Y){let $;for(let X of P())try{let{AleoNetworkClient:q}=await import("@provablehq/sdk/mainnet.js");return await new q(X).getTransitionId(Y),!0}catch(q){if(R(q))return!1;$=q}throw $}async function D(){let Y=z();try{return await Y.getAddress()}catch($){throw b("toolbox_aleo_wasm_init_failed",$)}}async function O(Y){let $=await L((X)=>X.getProgramMappingValue(y,"account",Y));return t($,"u64")}async function V(Y){try{let $=await O(Y);return[W.AssetValue.from({chain:W.Chain.Aleo,fromBaseDecimal:6,value:$})]}catch($){throw b("toolbox_aleo_balance_error",$)}}let v=MJ(W.Chain.Aleo);async function r(Y,$=!0){try{return await v(Y,$)}catch{return V(Y)}}async function VJ(){return r(await D())}async function T({transactionIds:Y}){try{let $=await Z(),X=[];for(let q of Y){if(!N.test(q))throw new W.SwapKitError("toolbox_aleo_transaction_failed",{transactionId:q});let x=await L((G)=>G.getTransaction(q));for(let G of i(x,y)){if(!$.ownsRecordCiphertext(G))continue;let{RecordPlaintext:k}=await import("@provablehq/sdk/mainnet.js"),B=$.decryptRecord(G).toString(),f=k.fromString(B),w=f.microcredits();if(w===0n)continue;let K=$.generateRecordViewKey(G).toString(),g=f.serialNumberString($.privateKey(),y,"credits",K);X.push({microcredits:w,plaintext:B,spent:await U(g),transactionId:q})}}return X}catch($){throw b("toolbox_aleo_balance_error",$)}}async function KJ({transactionIds:Y}){let $=await T({transactionIds:Y});return W.AssetValue.from({chain:W.Chain.Aleo,fromBaseDecimal:6,value:n($)})}async function wJ(Y,$){if(!Number.isSafeInteger($)||$<=0)throw new W.SwapKitError("toolbox_aleo_insufficient_fee_balance",{feeRecordCredits:$});let X=await Z();if(!Y||Y.microcredits<=BigInt($)*BigInt(I))throw new W.SwapKitError("toolbox_aleo_insufficient_fee_balance",{available:Y?.microcredits.toString(),required:`${$} credits fee record`});let{ProgramManager:q,RecordPlaintext:x}=await import("@provablehq/sdk/mainnet.js"),G;for(let k of P())try{let B=new q(k);return B.setAccount(X),await B.split($,x.fromString(Y.plaintext))}catch(B){G=B}throw G}async function FJ(Y,$,X){let q=await Z(),{ProgramManager:x,RecordPlaintext:G}=await import("@provablehq/sdk/mainnet.js"),k;for(let B of P())try{let f=new x(B);return f.setAccount(q),await f.buildExecutionTransaction({feeRecord:G.fromString($.plaintext),functionName:"transfer_private_to_public",inputs:[Y.plaintext,X,`${Y.microcredits}u64`],priorityFee:0,privateFee:!0,programName:y})}catch(f){k=f}throw k}async function NJ({transactionId:Y,feeRecordCredits:$=4}){let X;try{let x=(await Z()).address().to_string(),G=(await T({transactionIds:[Y]})).filter((K)=>!K.spent);if(G.length===0)throw new W.SwapKitError("toolbox_aleo_no_unspent_records",{transactionId:Y});if(G.length===1){if(X=await wJ(G[0],$),await A(X),G=(await T({transactionIds:[X]})).filter((K)=>!K.spent),G.length<2)throw new W.SwapKitError("toolbox_aleo_transaction_failed",{transactionId:X})}let k=[...G].sort((K,g)=>K.microcredits<g.microcredits?-1:1),B=k[0],f=k[k.length-1];if(!B||!f||B===f)throw new W.SwapKitError("toolbox_aleo_no_unspent_records",{transactionId:Y});let w=await E(await FJ(f,B,x));return await A(w),{publicBalance:W.AssetValue.from({chain:W.Chain.Aleo,fromBaseDecimal:6,value:await O(x)}),splitTransactionId:X,unshieldTransactionId:w}}catch(q){if(X)throw new W.SwapKitError("toolbox_aleo_transaction_failed",{error:q,splitTransactionId:X});throw b("toolbox_aleo_transaction_failed",q)}}function JJ({assetValue:Y,priorityFee:$=0}){try{if(!Number.isSafeInteger($)||$<0)throw new W.SwapKitError("toolbox_aleo_fee_estimation_failed",{priorityFee:$});let q=m(Y).isTokenTransfer?d:c;return W.AssetValue.from({chain:W.Chain.Aleo,fromBaseDecimal:6,value:BigInt(q)+BigInt($)})}catch(X){throw b("toolbox_aleo_fee_estimation_failed",X)}}async function QJ({assetValue:Y,priorityFee:$=0,recipient:X,sender:q}){if(!await s(X))throw new W.SwapKitError("toolbox_aleo_invalid_address",{address:X});let x=q||await D();if(!_(x))throw new W.SwapKitError("toolbox_aleo_invalid_address",{address:x});let G=m(Y),k=await JJ({assetValue:Y,priorityFee:$,recipient:X});try{let B=await O(x);if(W.AssetValue.from({chain:W.Chain.Aleo,fromBaseDecimal:6,value:B}).lt(k))throw new W.SwapKitError("toolbox_aleo_insufficient_fee_balance",{available:B.toString(),required:k.getBaseValue("string")});return{functionName:G.functionName,inputs:[X,G.amount],priorityFee:$,programName:G.programName,sender:x}}catch(B){throw b("toolbox_aleo_transaction_failed",B)}}async function ZJ(Y){try{return await z().signTransaction(Y)}catch($){throw b("toolbox_aleo_transaction_failed",$)}}async function $J(Y){return E(await ZJ(Y))}async function E(Y){try{let $=typeof Y==="string"?Y:Y.toString(),X=await L((q)=>q.submitTransaction($));if(!N.test(X))throw new W.SwapKitError("toolbox_aleo_broadcast_error",{transactionId:X});return X}catch($){throw b("toolbox_aleo_broadcast_error",$)}}async function _J(Y){let $=await QJ({...Y,sender:await D()});return $J($)}return{broadcastTransaction:E,createSigner:bJ,createTransaction:QJ,estimateTransactionFee:JJ,getAddress:D,getBalance:v,getBalanceFromRpc:V,getBalances:VJ,getBalanceWithFallback:r,getRecords:T,getShieldedBalance:KJ,signAndBroadcastTransaction:$J,signTransaction:ZJ,transfer:_J,unshield:NJ,validateAddress:_}}var W;var PJ=S(()=>{fJ();a();W=require("@swapkit/helpers")});var pJ={};AJ(pJ,{waitForAleoTransaction:()=>A,validateAleoProgramId:()=>UJ,validateAleoAddressWithChecksum:()=>s,validateAleoAddress:()=>_,sumUnspentRecords:()=>n,parseAleoTransactionStatus:()=>DJ,parseAleoMappingValue:()=>t,isRecord:()=>M,isNotFoundError:()=>R,isAleoTokenTransferResponse:()=>BJ,getConfiguredAleoUrls:()=>P,getAleoTransferRoute:()=>m,getAleoTransactionStatus:()=>xJ,getAleoToolbox:()=>yJ,getAleoMasterSeed:()=>GJ,getAleoError:()=>b,extractAleoRecordCiphertexts:()=>i,deriveAleoPath:()=>o,deriveAleoChildKey:()=>LJ,TRANSFER_PUBLIC_FUNCTION:()=>h,NATIVE_PROGRAM_ID:()=>y,MICRO_CREDITS_PER_CREDIT:()=>I,HARDENED_OFFSET:()=>u,ALEO_TRANSFER_PUBLIC_FEE:()=>c,ALEO_TRANSACTION_ID_REGEX:()=>N,ALEO_TOKEN_TRANSFER_PUBLIC_FEE:()=>d,ALEO_PROGRAM_ID_REGEX:()=>qJ,ALEO_HD_KEY:()=>jJ,ALEO_ADDRESS_REGEX:()=>XJ});module.exports=IJ(pJ);var lJ=S(()=>{PJ();a()});lJ();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fa as YJ}from"../../chunk-nvfkjbyq.js";import{ga as b}from"../../chunk-xbdjxeqd.js";import{hmac as o}from"@noble/hashes/hmac.js";import{sha512 as s}from"@noble/hashes/sha2.js";import{Chain as I,getChainConfig as LJ,SKConfig as UJ,SwapKitError as U}from"@swapkit/helpers";var BJ=/^aleo1[ac-hj-np-z02-9]{58}$/,DJ=/^[a-z0-9_]+\.aleo$/,C=/^at1[ac-hj-np-z02-9]+$/,kJ=new TextEncoder().encode("bls12_377 seed"),n=2147483648,m=1e6,f="credits.aleo",R="transfer_public",t=1e6,a=2000000;function e(J,Z){if(!M(J))return[];let Y=M(J.transaction)?J.transaction:J,W=Y.execution,z=M(Y.fee)?Y.fee.transition:void 0;return[...M(W)&&Array.isArray(W.transitions)?W.transitions:[],...M(z)?[z]:[]].flatMap((P)=>{if(!M(P)||!Array.isArray(P.outputs))return[];if(Z&&P.program!==Z)return[];return P.outputs.flatMap((x)=>M(x)&&x.type==="record"&&typeof x.value==="string"?[x.value]:[])})}function r(J){return J.reduce((Z,Y)=>Y.spent?Z:Z+Y.microcredits,0n)}function O(J,Z){return Z instanceof U&&Z.errorKey.startsWith("toolbox_aleo_")?Z:new U(J,Z)}function MJ(...J){let Z=J.reduce((z,L)=>z+L.length,0),Y=new Uint8Array(Z),W=0;for(let z of J)Y.set(z,W),W+=z.length;return Y}function xJ(J){let Z=new Uint8Array(4);return new DataView(Z.buffer).setUint32(0,J,!1),Z}function OJ(J){let Z=o(s,kJ,J);return{chainCode:Z.slice(32),key:Z.slice(0,32)}}function bJ(J,Z){if(!Number.isSafeInteger(Z)||Z<0||Z>=n)throw new U("toolbox_aleo_wasm_init_failed",{index:Z});let Y=Z+n,W=MJ(Uint8Array.of(0),J.key,xJ(Y)),z=o(s,J.chainCode,W);return{chainCode:z.slice(32),key:z.slice(0,32)}}function JJ(J,Z){let Y=J.split("/");if(Y.shift()!=="m"||Y.length===0)throw new U("toolbox_aleo_wasm_init_failed",{path:J});return Y.reduce((W,z)=>{if(!/^\d+'$/.test(z))throw new U("toolbox_aleo_wasm_init_failed",{path:J,segment:z});return bJ(W,Number.parseInt(z.slice(0,-1),10))},OJ(Z))}function T(J){return typeof J==="string"&&BJ.test(J)}async function QJ(J){if(!T(J))return!1;try{let{Account:Z}=await import("@provablehq/sdk/mainnet.js");return Z.isValidAddress(J)}catch{return!1}}function PJ(J){return DJ.test(J)}function ZJ(J,Z){if(J===null)return 0n;if(typeof J!=="string")throw new U("toolbox_aleo_balance_error",{integerType:Z,value:J});let Y=J.match(new RegExp(`^(\\d+)${Z}$`));if(!Y?.[1])throw new U("toolbox_aleo_balance_error",{integerType:Z,value:J});return BigInt(Y[1])}function A(J){if(J.chain!==I.Aleo)throw new U("toolbox_aleo_unsupported_token",{asset:J.toString()});let Z=J.getBaseValue("bigint");if(J.isGasAsset)return{amount:`${Z}u64`,functionName:R,isTokenTransfer:!1,programName:f};if(!J.address||!PJ(J.address))throw new U("toolbox_aleo_unsupported_token",{asset:J.toString()});return{amount:`${Z}u128`,functionName:R,isTokenTransfer:!0,programName:J.address}}function K(){let J=[...new Set([...UJ.get("rpcUrls")[I.Aleo],...LJ(I.Aleo).rpcUrls])].filter(Boolean);if(J.length===0)throw new U("toolbox_aleo_no_rpc_urls");return J}function E(J){if(typeof J==="object"&&J!==null&&"status"in J&&J.status===404)return!0;return J instanceof Error&&J.message.includes("404")}function M(J){return typeof J==="object"&&J!==null}function yJ(J){if(!M(J))return!1;return[J.transaction,J.rejected].some((Z)=>{if(!M(Z)||!M(Z.execution))return!1;let{transitions:Y}=Z.execution;return Array.isArray(Y)&&Y.some((W)=>M(W)&&W.function===R&&typeof W.program==="string"&&W.program!==f)})}function VJ(J,Z){if(!M(J)||typeof J.status!=="string")throw new U("toolbox_aleo_transaction_failed",{response:J,transactionId:Z});let Y=J.status.toLowerCase();if(Y==="rejected"){let W=yJ(J)?"toolbox_aleo_token_transfer_rejected":"toolbox_aleo_transaction_failed";throw new U(W,{transactionId:Z})}return Y==="accepted"?"accepted":"pending"}async function fJ(J){if(!C.test(J))throw new U("toolbox_aleo_transaction_failed",{transactionId:J});let Z,Y=!0;for(let W of K())try{let{AleoNetworkClient:z}=await import("@provablehq/sdk/mainnet.js"),L=await new z(W).getConfirmedTransaction(J);return VJ(L,J)}catch(z){if(z instanceof U)throw z;Z=z,Y=Y&&E(z)}if(Y)return"pending";throw O("toolbox_aleo_transaction_failed",Z)}async function g(J,{intervalMs:Z=5000,timeoutMs:Y=60000}={}){let W=Date.now();while(Date.now()-W<Y){let z=await fJ(J);if(z==="accepted")return z;await new Promise((L)=>setTimeout(L,Z))}throw new U("toolbox_aleo_transaction_failed",{reason:"confirmation_timeout",transactionId:J})}import{AssetValue as _,Chain as F,derivationPathToString as KJ,NetworkDerivationPath as FJ,SwapKitError as G}from"@swapkit/helpers";async function zJ(J,Z){try{let{Account:Y}=await import("@provablehq/sdk/mainnet.js"),{mnemonicToSeedSync:W}=await import("@scure/bip39"),z=KJ(Z||FJ[F.Aleo],{allHardened:!0}),{key:L}=JJ(z,W(J));return new Y({seed:L})}catch(Y){throw O("toolbox_aleo_wasm_init_failed",Y)}}function $J(J,Z){let Y,W=()=>{return Y??=zJ(J,Z),Y};return{getAddress:async()=>(await W()).address().to_string(),signTransaction:async(z)=>{let L=await W();if(z.sender!==L.address().to_string())throw new G("toolbox_aleo_invalid_address",{address:z.sender});let P;for(let x of K())try{let{ProgramManager:y}=await import("@provablehq/sdk/mainnet.js"),w=new y(x);return w.setAccount(L),await w.buildExecutionTransaction({functionName:z.functionName,inputs:z.inputs,priorityFee:z.priorityFee/m,privateFee:!1,programName:z.programName})}catch(y){P=y}throw P}}}function wJ(J={}){if("phrase"in J&&J.phrase&&"signer"in J&&J.signer)throw new G("toolbox_aleo_conflicting_signers");let Z;async function Y(){if(Z)return Z;let $="phrase"in J?J.phrase:void 0;if(!$)throw new G("toolbox_aleo_no_signer");let Q="derivationPath"in J?J.derivationPath:void 0;return Z=await zJ($,Q),Z}let W;function z(){let $="signer"in J?J.signer:void 0;if($)return $;let Q="phrase"in J?J.phrase:void 0;if(!Q)throw new G("toolbox_aleo_no_signer");return W??=$J(Q,"derivationPath"in J?J.derivationPath:void 0),W}async function L($){let Q;for(let H of K())try{let{AleoNetworkClient:X}=await import("@provablehq/sdk/mainnet.js");return await $(new X(H))}catch(X){Q=X}throw Q}async function P($){let Q;for(let H of K())try{let{AleoNetworkClient:X}=await import("@provablehq/sdk/mainnet.js");return await new X(H).getTransitionId($),!0}catch(X){if(E(X))return!1;Q=X}throw Q}async function x(){let $=z();try{return await $.getAddress()}catch(Q){throw O("toolbox_aleo_wasm_init_failed",Q)}}async function y($){let Q=await L((H)=>H.getProgramMappingValue(f,"account",$));return ZJ(Q,"u64")}async function w($){try{let Q=await y($);return[_.from({chain:F.Aleo,fromBaseDecimal:6,value:Q})]}catch(Q){throw O("toolbox_aleo_balance_error",Q)}}let u=YJ(F.Aleo);async function p($,Q=!0){try{return await u($,Q)}catch{return w($)}}async function HJ(){return p(await x())}async function v({transactionIds:$}){try{let Q=await Y(),H=[];for(let X of $){if(!C.test(X))throw new G("toolbox_aleo_transaction_failed",{transactionId:X});let B=await L((q)=>q.getTransaction(X));for(let q of e(B,f)){if(!Q.ownsRecordCiphertext(q))continue;let{RecordPlaintext:D}=await import("@provablehq/sdk/mainnet.js"),j=Q.decryptRecord(q).toString(),k=D.fromString(j),N=k.microcredits();if(N===0n)continue;let V=Q.generateRecordViewKey(q).toString(),h=k.serialNumberString(Q.privateKey(),f,"credits",V);H.push({microcredits:N,plaintext:j,spent:await P(h),transactionId:X})}}return H}catch(Q){throw O("toolbox_aleo_balance_error",Q)}}async function WJ({transactionIds:$}){let Q=await v({transactionIds:$});return _.from({chain:F.Aleo,fromBaseDecimal:6,value:r(Q)})}async function XJ($,Q){if(!Number.isSafeInteger(Q)||Q<=0)throw new G("toolbox_aleo_insufficient_fee_balance",{feeRecordCredits:Q});let H=await Y();if(!$||$.microcredits<=BigInt(Q)*BigInt(m))throw new G("toolbox_aleo_insufficient_fee_balance",{available:$?.microcredits.toString(),required:`${Q} credits fee record`});let{ProgramManager:X,RecordPlaintext:B}=await import("@provablehq/sdk/mainnet.js"),q;for(let D of K())try{let j=new X(D);return j.setAccount(H),await j.split(Q,B.fromString($.plaintext))}catch(j){q=j}throw q}async function qJ($,Q,H){let X=await Y(),{ProgramManager:B,RecordPlaintext:q}=await import("@provablehq/sdk/mainnet.js"),D;for(let j of K())try{let k=new B(j);return k.setAccount(X),await k.buildExecutionTransaction({feeRecord:q.fromString(Q.plaintext),functionName:"transfer_private_to_public",inputs:[$.plaintext,H,`${$.microcredits}u64`],priorityFee:0,privateFee:!0,programName:f})}catch(k){D=k}throw D}async function jJ({transactionId:$,feeRecordCredits:Q=4}){let H;try{let B=(await Y()).address().to_string(),q=(await v({transactionIds:[$]})).filter((V)=>!V.spent);if(q.length===0)throw new G("toolbox_aleo_no_unspent_records",{transactionId:$});if(q.length===1){if(H=await XJ(q[0],Q),await g(H),q=(await v({transactionIds:[H]})).filter((V)=>!V.spent),q.length<2)throw new G("toolbox_aleo_transaction_failed",{transactionId:H})}let D=[...q].sort((V,h)=>V.microcredits<h.microcredits?-1:1),j=D[0],k=D[D.length-1];if(!j||!k||j===k)throw new G("toolbox_aleo_no_unspent_records",{transactionId:$});let N=await S(await qJ(k,j,B));return await g(N),{publicBalance:_.from({chain:F.Aleo,fromBaseDecimal:6,value:await y(B)}),splitTransactionId:H,unshieldTransactionId:N}}catch(X){if(H)throw new G("toolbox_aleo_transaction_failed",{error:X,splitTransactionId:H});throw O("toolbox_aleo_transaction_failed",X)}}function l({assetValue:$,priorityFee:Q=0}){try{if(!Number.isSafeInteger(Q)||Q<0)throw new G("toolbox_aleo_fee_estimation_failed",{priorityFee:Q});let X=A($).isTokenTransfer?a:t;return _.from({chain:F.Aleo,fromBaseDecimal:6,value:BigInt(X)+BigInt(Q)})}catch(H){throw O("toolbox_aleo_fee_estimation_failed",H)}}async function c({assetValue:$,priorityFee:Q=0,recipient:H,sender:X}){if(!await QJ(H))throw new G("toolbox_aleo_invalid_address",{address:H});let B=X||await x();if(!T(B))throw new G("toolbox_aleo_invalid_address",{address:B});let q=A($),D=await l({assetValue:$,priorityFee:Q,recipient:H});try{let j=await y(B);if(_.from({chain:F.Aleo,fromBaseDecimal:6,value:j}).lt(D))throw new G("toolbox_aleo_insufficient_fee_balance",{available:j.toString(),required:D.getBaseValue("string")});return{functionName:q.functionName,inputs:[H,q.amount],priorityFee:Q,programName:q.programName,sender:B}}catch(j){throw O("toolbox_aleo_transaction_failed",j)}}async function d($){try{return await z().signTransaction($)}catch(Q){throw O("toolbox_aleo_transaction_failed",Q)}}async function i($){return S(await d($))}async function S($){try{let Q=typeof $==="string"?$:$.toString(),H=await L((X)=>X.submitTransaction(Q));if(!C.test(H))throw new G("toolbox_aleo_broadcast_error",{transactionId:H});return H}catch(Q){throw O("toolbox_aleo_broadcast_error",Q)}}async function GJ($){let Q=await c({...$,sender:await x()});return i(Q)}return{broadcastTransaction:S,createSigner:$J,createTransaction:c,estimateTransactionFee:l,getAddress:x,getBalance:u,getBalanceFromRpc:w,getBalances:HJ,getBalanceWithFallback:p,getRecords:v,getShieldedBalance:WJ,signAndBroadcastTransaction:i,signTransaction:d,transfer:GJ,unshield:jJ,validateAddress:T}}export{g as waitForAleoTransaction,PJ as validateAleoProgramId,QJ as validateAleoAddressWithChecksum,T as validateAleoAddress,r as sumUnspentRecords,VJ as parseAleoTransactionStatus,ZJ as parseAleoMappingValue,M as isRecord,E as isNotFoundError,yJ as isAleoTokenTransferResponse,K as getConfiguredAleoUrls,A as getAleoTransferRoute,fJ as getAleoTransactionStatus,wJ as getAleoToolbox,OJ as getAleoMasterSeed,O as getAleoError,e as extractAleoRecordCiphertexts,JJ as deriveAleoPath,bJ as deriveAleoChildKey,R as TRANSFER_PUBLIC_FUNCTION,f as NATIVE_PROGRAM_ID,m as MICRO_CREDITS_PER_CREDIT,n as HARDENED_OFFSET,t as ALEO_TRANSFER_PUBLIC_FEE,C as ALEO_TRANSACTION_ID_REGEX,a as ALEO_TOKEN_TRANSFER_PUBLIC_FEE,DJ as ALEO_PROGRAM_ID_REGEX,kJ as ALEO_HD_KEY,BJ as ALEO_ADDRESS_REGEX};
|
package/dist/src/aptos/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
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();
|
package/dist/src/aptos/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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
|
|
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{
|
|
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};
|