@swapkit/toolboxes 4.18.0 → 4.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/chunk-3pne8gaa.js +1 -0
- package/dist/chunk-44m22jy1.js +1 -0
- package/dist/chunk-4q573g5z.js +2 -0
- package/dist/chunk-54gntgt1.js +2 -0
- package/dist/chunk-ntbvmmch.js +2 -0
- package/dist/chunk-r2htb2ce.js +1 -0
- package/dist/src/aptos/index.js +1 -1
- package/dist/src/cardano/index.cjs +1 -1
- package/dist/src/cardano/index.js +1 -1
- package/dist/src/cosmos/index.cjs +1 -1
- package/dist/src/cosmos/index.js +1 -1
- package/dist/src/evm/index.cjs +1 -1
- package/dist/src/evm/index.js +1 -1
- package/dist/src/hypercore/index.cjs +1 -1
- package/dist/src/hypercore/index.js +1 -1
- package/dist/src/index.cjs +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/near/index.cjs +1 -1
- package/dist/src/near/index.js +1 -1
- package/dist/src/radix/index.cjs +1 -1
- package/dist/src/radix/index.js +1 -1
- package/dist/src/ripple/index.cjs +1 -1
- package/dist/src/ripple/index.js +1 -1
- package/dist/src/solana/index.js +1 -1
- package/dist/src/starknet/index.js +1 -1
- package/dist/src/stellar/index.js +1 -1
- package/dist/src/substrate/index.cjs +1 -1
- package/dist/src/substrate/index.js +1 -1
- package/dist/src/sui/index.js +1 -1
- package/dist/src/ton/index.cjs +1 -1
- package/dist/src/ton/index.js +1 -1
- package/dist/src/tron/index.cjs +1 -1
- package/dist/src/tron/index.js +1 -1
- package/dist/src/utxo/index.js +1 -1
- package/dist/types/cardano/toolbox.d.ts +1 -1
- package/dist/types/cosmos/toolbox/cosmos.d.ts +2 -3
- package/dist/types/evm/helpers.d.ts +11 -1
- package/dist/types/near/toolbox.d.ts +1 -2
- package/dist/types/radix/index.d.ts +2 -2
- package/dist/types/ripple/index.d.ts +4 -8
- package/dist/types/substrate/substrate.d.ts +1 -1
- package/dist/types/ton/toolbox.d.ts +5 -2
- package/dist/types/ton/types.d.ts +1 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @swapkit/toolboxes
|
|
2
2
|
|
|
3
|
+
## 4.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#294](https://github.com/swapkit/sdk/pull/294) [`01a1d86`](https://github.com/swapkit/sdk/commit/01a1d869ec879ee80f4118719d7746c1b4f8e9bf) Thanks [@ice-chillios](https://github.com/ice-chillios)! - Remove eager work from toolbox construction so `getToolbox()` does no network I/O and doesn't load heavy chain SDKs until a method actually needs them.
|
|
8
|
+
- [#299](https://github.com/swapkit/sdk/pull/299) [`78d430d`](https://github.com/swapkit/sdk/commit/78d430df03f86dfe2cea5dd4bdc5884de5ba1529) Thanks [@towanTG](https://github.com/towanTG)! - Fail TRC-20 transaction creation when both Tron energy probes fail instead of falling back to a hardcoded 65k energy estimate.
|
|
9
|
+
- [#294](https://github.com/swapkit/sdk/pull/294) [`01a1d86`](https://github.com/swapkit/sdk/commit/01a1d869ec879ee80f4118719d7746c1b4f8e9bf) Thanks [@ice-chillios](https://github.com/ice-chillios)! - Leaner published bundles: externalize sibling `@swapkit/*` workspace packages and enable ESM code-splitting for every package (builder change in `@swapkit/tools-builder`). (via @swapkit/helpers@4.15.2)
|
|
10
|
+
|
|
11
|
+
## 4.19.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#290](https://github.com/swapkit/sdk/pull/290) [`4e7d2d7`](https://github.com/swapkit/sdk/commit/4e7d2d72b4c1254d16a8a6084843bd49d0795b3b) Thanks [@olegpetroveth](https://github.com/olegpetroveth)! - Add TON native balance sweep. `createTransaction`/`transfer` accept a `sweep` flag that sets the `CARRY_ALL_REMAINING_BALANCE | IGNORE_ERRORS` send mode so the wallet sends its full balance minus fees. `TONTransactionMessage` gains an optional `sendMode` override (read per-transfer from the first message by `sign`/`estimateTransactionFee`). Sweep is native-only; jetton sweeps throw.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies []:
|
|
20
|
+
- @swapkit/helpers@4.15.1
|
|
21
|
+
|
|
3
22
|
## 4.18.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-ntbvmmch.js";import Y from"protobufjs/minimal.js";var X=Y.Reader,J=Y.Writer,Q=Y.util,L=Y.roots.default||(Y.roots.default={});L.common=(()=>{let Z={};return Z.Asset=(()=>{function G(H){if(H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.chain="",G.prototype.symbol="",G.prototype.ticker="",G.prototype.synth=!1,G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.chain!=null&&Object.hasOwnProperty.call(q,"chain"))B.uint32(10).string(q.chain);if(q.symbol!=null&&Object.hasOwnProperty.call(q,"symbol"))B.uint32(18).string(q.symbol);if(q.ticker!=null&&Object.hasOwnProperty.call(q,"ticker"))B.uint32(26).string(q.ticker);if(q.synth!=null&&Object.hasOwnProperty.call(q,"synth"))B.uint32(32).bool(q.synth);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.Asset;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.chain=q.string();break;case 2:E.symbol=q.string();break;case 3:E.ticker=q.string();break;case 4:E.synth=q.bool();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.chain!=null&&q.hasOwnProperty("chain")){if(!Q.isString(q.chain))return"chain: string expected"}if(q.symbol!=null&&q.hasOwnProperty("symbol")){if(!Q.isString(q.symbol))return"symbol: string expected"}if(q.ticker!=null&&q.hasOwnProperty("ticker")){if(!Q.isString(q.ticker))return"ticker: string expected"}if(q.synth!=null&&q.hasOwnProperty("synth")){if(typeof q.synth!=="boolean")return"synth: boolean expected"}return null},G.fromObject=function(q){if(q instanceof L.common.Asset)return q;let B=new L.common.Asset;if(q.chain!=null)B.chain=String(q.chain);if(q.symbol!=null)B.symbol=String(q.symbol);if(q.ticker!=null)B.ticker=String(q.ticker);if(q.synth!=null)B.synth=Boolean(q.synth);return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.defaults)z.chain="",z.symbol="",z.ticker="",z.synth=!1;if(q.chain!=null&&q.hasOwnProperty("chain"))z.chain=q.chain;if(q.symbol!=null&&q.hasOwnProperty("symbol"))z.symbol=q.symbol;if(q.ticker!=null&&q.hasOwnProperty("ticker"))z.ticker=q.ticker;if(q.synth!=null&&q.hasOwnProperty("synth"))z.synth=q.synth;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.Coin=(()=>{function G(H){if(H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.asset=null,G.prototype.amount="",G.prototype.decimals=Q.Long?Q.Long.fromBits(0,0,!1):0,G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.asset!=null&&Object.hasOwnProperty.call(q,"asset"))L.common.Asset.encode(q.asset,B.uint32(10).fork()).ldelim();if(q.amount!=null&&Object.hasOwnProperty.call(q,"amount"))B.uint32(18).string(q.amount);if(q.decimals!=null&&Object.hasOwnProperty.call(q,"decimals"))B.uint32(24).int64(q.decimals);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.Coin;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.asset=L.common.Asset.decode(q,q.uint32());break;case 2:E.amount=q.string();break;case 3:E.decimals=q.int64();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.asset!=null&&q.hasOwnProperty("asset")){let B=L.common.Asset.verify(q.asset);if(B)return"asset."+B}if(q.amount!=null&&q.hasOwnProperty("amount")){if(!Q.isString(q.amount))return"amount: string expected"}if(q.decimals!=null&&q.hasOwnProperty("decimals")){if(!Q.isInteger(q.decimals)&&!(q.decimals&&Q.isInteger(q.decimals.low)&&Q.isInteger(q.decimals.high)))return"decimals: integer|Long expected"}return null},G.fromObject=function(q){if(q instanceof L.common.Coin)return q;let B=new L.common.Coin;if(q.asset!=null){if(typeof q.asset!=="object")throw TypeError(".common.Coin.asset: object expected");B.asset=L.common.Asset.fromObject(q.asset)}if(q.amount!=null)B.amount=String(q.amount);if(q.decimals!=null){if(Q.Long)(B.decimals=Q.Long.fromValue(q.decimals)).unsigned=!1;else if(typeof q.decimals==="string")B.decimals=Number.parseInt(q.decimals,10);else if(typeof q.decimals==="number")B.decimals=q.decimals;else if(typeof q.decimals==="object")B.decimals=new Q.LongBits(q.decimals.low>>>0,q.decimals.high>>>0).toNumber()}return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.defaults)if(z.asset=null,z.amount="",Q.Long){let E=new Q.Long(0,0,!1);z.decimals=B.longs===String?E.toString():B.longs===Number?E.toNumber():E}else z.decimals=B.longs===String?"0":0;if(q.asset!=null&&q.hasOwnProperty("asset"))z.asset=L.common.Asset.toObject(q.asset,B);if(q.amount!=null&&q.hasOwnProperty("amount"))z.amount=q.amount;if(q.decimals!=null&&q.hasOwnProperty("decimals"))if(typeof q.decimals==="number")z.decimals=B.longs===String?String(q.decimals):q.decimals;else z.decimals=B.longs===String?Q.Long.prototype.toString.call(q.decimals):B.longs===Number?new Q.LongBits(q.decimals.low>>>0,q.decimals.high>>>0).toNumber():q.decimals;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.PubKeySet=(()=>{function G(H){if(H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.secp256k1="",G.prototype.ed25519="",G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.secp256k1!=null&&Object.hasOwnProperty.call(q,"secp256k1"))B.uint32(10).string(q.secp256k1);if(q.ed25519!=null&&Object.hasOwnProperty.call(q,"ed25519"))B.uint32(18).string(q.ed25519);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.PubKeySet;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.secp256k1=q.string();break;case 2:E.ed25519=q.string();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.secp256k1!=null&&q.hasOwnProperty("secp256k1")){if(!Q.isString(q.secp256k1))return"secp256k1: string expected"}if(q.ed25519!=null&&q.hasOwnProperty("ed25519")){if(!Q.isString(q.ed25519))return"ed25519: string expected"}return null},G.fromObject=function(q){if(q instanceof L.common.PubKeySet)return q;let B=new L.common.PubKeySet;if(q.secp256k1!=null)B.secp256k1=String(q.secp256k1);if(q.ed25519!=null)B.ed25519=String(q.ed25519);return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.defaults)z.secp256k1="",z.ed25519="";if(q.secp256k1!=null&&q.hasOwnProperty("secp256k1"))z.secp256k1=q.secp256k1;if(q.ed25519!=null&&q.hasOwnProperty("ed25519"))z.ed25519=q.ed25519;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.Tx=(()=>{function G(H){if(this.coins=[],this.gas=[],H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.id="",G.prototype.chain="",G.prototype.fromAddress="",G.prototype.toAddress="",G.prototype.coins=Q.emptyArray,G.prototype.gas=Q.emptyArray,G.prototype.memo="",G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.id!=null&&Object.hasOwnProperty.call(q,"id"))B.uint32(10).string(q.id);if(q.chain!=null&&Object.hasOwnProperty.call(q,"chain"))B.uint32(18).string(q.chain);if(q.fromAddress!=null&&Object.hasOwnProperty.call(q,"fromAddress"))B.uint32(26).string(q.fromAddress);if(q.toAddress!=null&&Object.hasOwnProperty.call(q,"toAddress"))B.uint32(34).string(q.toAddress);if(q.coins?.length)for(let z=0;z<q.coins.length;++z)L.common.Coin.encode(q.coins[z],B.uint32(42).fork()).ldelim();if(q.gas?.length)for(let z=0;z<q.gas.length;++z)L.common.Coin.encode(q.gas[z],B.uint32(50).fork()).ldelim();if(q.memo!=null&&Object.hasOwnProperty.call(q,"memo"))B.uint32(58).string(q.memo);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.Tx;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.id=q.string();break;case 2:E.chain=q.string();break;case 3:E.fromAddress=q.string();break;case 4:E.toAddress=q.string();break;case 5:if(!E.coins?.length)E.coins=[];E.coins.push(L.common.Coin.decode(q,q.uint32()));break;case 6:if(!E.gas?.length)E.gas=[];E.gas.push(L.common.Coin.decode(q,q.uint32()));break;case 7:E.memo=q.string();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.id!=null&&q.hasOwnProperty("id")){if(!Q.isString(q.id))return"id: string expected"}if(q.chain!=null&&q.hasOwnProperty("chain")){if(!Q.isString(q.chain))return"chain: string expected"}if(q.fromAddress!=null&&q.hasOwnProperty("fromAddress")){if(!Q.isString(q.fromAddress))return"fromAddress: string expected"}if(q.toAddress!=null&&q.hasOwnProperty("toAddress")){if(!Q.isString(q.toAddress))return"toAddress: string expected"}if(q.coins!=null&&q.hasOwnProperty("coins")){if(!Array.isArray(q.coins))return"coins: array expected";for(let B=0;B<q.coins.length;++B){let z=L.common.Coin.verify(q.coins[B]);if(z)return"coins."+z}}if(q.gas!=null&&q.hasOwnProperty("gas")){if(!Array.isArray(q.gas))return"gas: array expected";for(let B=0;B<q.gas.length;++B){let z=L.common.Coin.verify(q.gas[B]);if(z)return"gas."+z}}if(q.memo!=null&&q.hasOwnProperty("memo")){if(!Q.isString(q.memo))return"memo: string expected"}return null},G.fromObject=function(q){if(q instanceof L.common.Tx)return q;let B=new L.common.Tx;if(q.id!=null)B.id=String(q.id);if(q.chain!=null)B.chain=String(q.chain);if(q.fromAddress!=null)B.fromAddress=String(q.fromAddress);if(q.toAddress!=null)B.toAddress=String(q.toAddress);if(q.coins){if(!Array.isArray(q.coins))throw TypeError(".common.Tx.coins: array expected");B.coins=[];for(let z=0;z<q.coins.length;++z){if(typeof q.coins[z]!=="object")throw TypeError(".common.Tx.coins: object expected");B.coins[z]=L.common.Coin.fromObject(q.coins[z])}}if(q.gas){if(!Array.isArray(q.gas))throw TypeError(".common.Tx.gas: array expected");B.gas=[];for(let z=0;z<q.gas.length;++z){if(typeof q.gas[z]!=="object")throw TypeError(".common.Tx.gas: object expected");B.gas[z]=L.common.Coin.fromObject(q.gas[z])}}if(q.memo!=null)B.memo=String(q.memo);return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.arrays||B.defaults)z.coins=[],z.gas=[];if(B.defaults)z.id="",z.chain="",z.fromAddress="",z.toAddress="",z.memo="";if(q.id!=null&&q.hasOwnProperty("id"))z.id=q.id;if(q.chain!=null&&q.hasOwnProperty("chain"))z.chain=q.chain;if(q.fromAddress!=null&&q.hasOwnProperty("fromAddress"))z.fromAddress=q.fromAddress;if(q.toAddress!=null&&q.hasOwnProperty("toAddress"))z.toAddress=q.toAddress;if(q.coins?.length){z.coins=[];for(let E=0;E<q.coins.length;++E)z.coins[E]=L.common.Coin.toObject(q.coins[E],B)}if(q.gas?.length){z.gas=[];for(let E=0;E<q.gas.length;++E)z.gas[E]=L.common.Coin.toObject(q.gas[E],B)}if(q.memo!=null&&q.hasOwnProperty("memo"))z.memo=q.memo;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.Fee=(()=>{function G(H){if(this.coins=[],H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.coins=Q.emptyArray,G.prototype.poolDeduct="",G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.coins?.length)for(let z=0;z<q.coins.length;++z)L.common.Coin.encode(q.coins[z],B.uint32(10).fork()).ldelim();if(q.poolDeduct!=null&&Object.hasOwnProperty.call(q,"poolDeduct"))B.uint32(18).string(q.poolDeduct);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.Fee;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:if(!E.coins?.length)E.coins=[];E.coins.push(L.common.Coin.decode(q,q.uint32()));break;case 2:E.poolDeduct=q.string();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.coins!=null&&q.hasOwnProperty("coins")){if(!Array.isArray(q.coins))return"coins: array expected";for(let B=0;B<q.coins.length;++B){let z=L.common.Coin.verify(q.coins[B]);if(z)return"coins."+z}}if(q.poolDeduct!=null&&q.hasOwnProperty("poolDeduct")){if(!Q.isString(q.poolDeduct))return"poolDeduct: string expected"}return null},G.fromObject=function(q){if(q instanceof L.common.Fee)return q;let B=new L.common.Fee;if(q.coins){if(!Array.isArray(q.coins))throw TypeError(".common.Fee.coins: array expected");B.coins=[];for(let z=0;z<q.coins.length;++z){if(typeof q.coins[z]!=="object")throw TypeError(".common.Fee.coins: object expected");B.coins[z]=L.common.Coin.fromObject(q.coins[z])}}if(q.poolDeduct!=null)B.poolDeduct=String(q.poolDeduct);return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.arrays||B.defaults)z.coins=[];if(B.defaults)z.poolDeduct="";if(q.coins?.length){z.coins=[];for(let E=0;E<q.coins.length;++E)z.coins[E]=L.common.Coin.toObject(q.coins[E],B)}if(q.poolDeduct!=null&&q.hasOwnProperty("poolDeduct"))z.poolDeduct=q.poolDeduct;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.ProtoUint=(()=>{function G(H){if(H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.value="",G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.value!=null&&Object.hasOwnProperty.call(q,"value"))B.uint32(10).string(q.value);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.common.ProtoUint;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.value=q.string();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.value!=null&&q.hasOwnProperty("value")){if(!Q.isString(q.value))return"value: string expected"}return null},G.fromObject=function(q){if(q instanceof L.common.ProtoUint)return q;let B=new L.common.ProtoUint;if(q.value!=null)B.value=String(q.value);return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.defaults)z.value="";if(q.value!=null&&q.hasOwnProperty("value"))z.value=q.value;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z})();L.types=(()=>{let Z={};return Z.MsgDeposit=(()=>{function G(H){if(this.coins=[],H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.coins=Q.emptyArray,G.prototype.memo="",G.prototype.signer=Q.newBuffer([]),G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.coins?.length)for(let z=0;z<q.coins.length;++z)L.common.Coin.encode(q.coins[z],B.uint32(10).fork()).ldelim();if(q.memo!=null&&Object.hasOwnProperty.call(q,"memo"))B.uint32(18).string(q.memo);if(q.signer!=null&&Object.hasOwnProperty.call(q,"signer"))B.uint32(26).bytes(q.signer);return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.types.MsgDeposit;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:if(!E.coins?.length)E.coins=[];E.coins.push(L.common.Coin.decode(q,q.uint32()));break;case 2:E.memo=q.string();break;case 3:E.signer=q.bytes();break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.coins!=null&&q.hasOwnProperty("coins")){if(!Array.isArray(q.coins))return"coins: array expected";for(let B=0;B<q.coins.length;++B){let z=L.common.Coin.verify(q.coins[B]);if(z)return"coins."+z}}if(q.memo!=null&&q.hasOwnProperty("memo")){if(!Q.isString(q.memo))return"memo: string expected"}if(q.signer!=null&&q.hasOwnProperty("signer")){if(!(q.signer&&typeof q.signer.length==="number"||Q.isString(q.signer)))return"signer: buffer expected"}return null},G.fromObject=function(q){if(q instanceof L.types.MsgDeposit)return q;let B=new L.types.MsgDeposit;if(q.coins){if(!Array.isArray(q.coins))throw TypeError(".types.MsgDeposit.coins: array expected");B.coins=[];for(let z=0;z<q.coins.length;++z){if(typeof q.coins[z]!=="object")throw TypeError(".types.MsgDeposit.coins: object expected");B.coins[z]=L.common.Coin.fromObject(q.coins[z])}}if(q.memo!=null)B.memo=String(q.memo);if(q.signer!=null){if(typeof q.signer==="string")Q.base64.decode(q.signer,B.signer=Q.newBuffer(Q.base64.length(q.signer)),0);else if(q.signer.length)B.signer=q.signer}return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.arrays||B.defaults)z.coins=[];if(B.defaults){if(z.memo="",B.bytes===String)z.signer="";else if(z.signer=[],B.bytes!==Array)z.signer=Q.newBuffer(z.signer)}if(q.coins?.length){z.coins=[];for(let E=0;E<q.coins.length;++E)z.coins[E]=L.common.Coin.toObject(q.coins[E],B)}if(q.memo!=null&&q.hasOwnProperty("memo"))z.memo=q.memo;if(q.signer!=null&&q.hasOwnProperty("signer"))z.signer=B.bytes===String?Q.base64.encode(q.signer,0,q.signer.length):B.bytes===Array?Array.prototype.slice.call(q.signer):q.signer;return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z.MsgSend=(()=>{function G(H){if(this.amount=[],H){for(let q=Object.keys(H),B=0;B<q.length;++B)if(H[q[B]]!=null)this[q[B]]=H[q[B]]}}return G.prototype.fromAddress=Q.newBuffer([]),G.prototype.toAddress=Q.newBuffer([]),G.prototype.amount=Q.emptyArray,G.create=function(q){return new G(q)},G.encode=function(q,B){if(!B)B=J.create();if(q.fromAddress!=null&&Object.hasOwnProperty.call(q,"fromAddress"))B.uint32(10).bytes(q.fromAddress);if(q.toAddress!=null&&Object.hasOwnProperty.call(q,"toAddress"))B.uint32(18).bytes(q.toAddress);if(q.amount?.length)for(let z=0;z<q.amount.length;++z)L.cosmos.base.v1beta1.Coin.encode(q.amount[z],B.uint32(26).fork()).ldelim();return B},G.encodeDelimited=function(q,B){return this.encode(q,B).ldelim()},G.decode=function(q,B){if(!(q instanceof X))q=X.create(q);let z=B===void 0?q.len:q.pos+B,E=new L.types.MsgSend;while(q.pos<z){let V=q.uint32();switch(V>>>3){case 1:E.fromAddress=q.bytes();break;case 2:E.toAddress=q.bytes();break;case 3:if(!E.amount?.length)E.amount=[];E.amount.push(L.cosmos.base.v1beta1.Coin.decode(q,q.uint32()));break;default:q.skipType(V&7);break}}return E},G.decodeDelimited=function(q){if(!(q instanceof X))q=new X(q);return this.decode(q,q.uint32())},G.verify=function(q){if(typeof q!=="object"||q===null)return"object expected";if(q.fromAddress!=null&&q.hasOwnProperty("fromAddress")){if(!(q.fromAddress&&typeof q.fromAddress.length==="number"||Q.isString(q.fromAddress)))return"fromAddress: buffer expected"}if(q.toAddress!=null&&q.hasOwnProperty("toAddress")){if(!(q.toAddress&&typeof q.toAddress.length==="number"||Q.isString(q.toAddress)))return"toAddress: buffer expected"}if(q.amount!=null&&q.hasOwnProperty("amount")){if(!Array.isArray(q.amount))return"amount: array expected";for(let B=0;B<q.amount.length;++B){let z=L.cosmos.base.v1beta1.Coin.verify(q.amount[B]);if(z)return"amount."+z}}return null},G.fromObject=function(q){if(q instanceof L.types.MsgSend)return q;let B=new L.types.MsgSend;if(q.fromAddress!=null){if(typeof q.fromAddress==="string")Q.base64.decode(q.fromAddress,B.fromAddress=Q.newBuffer(Q.base64.length(q.fromAddress)),0);else if(q.fromAddress.length)B.fromAddress=q.fromAddress}if(q.toAddress!=null){if(typeof q.toAddress==="string")Q.base64.decode(q.toAddress,B.toAddress=Q.newBuffer(Q.base64.length(q.toAddress)),0);else if(q.toAddress.length)B.toAddress=q.toAddress}if(q.amount){if(!Array.isArray(q.amount))throw TypeError(".types.MsgSend.amount: array expected");B.amount=[];for(let z=0;z<q.amount.length;++z){if(typeof q.amount[z]!=="object")throw TypeError(".types.MsgSend.amount: object expected");B.amount[z]=L.cosmos.base.v1beta1.Coin.fromObject(q.amount[z])}}return B},G.toObject=function(q,B){if(!B)B={};let z={};if(B.arrays||B.defaults)z.amount=[];if(B.defaults){if(B.bytes===String)z.fromAddress="";else if(z.fromAddress=[],B.bytes!==Array)z.fromAddress=Q.newBuffer(z.fromAddress);if(B.bytes===String)z.toAddress="";else if(z.toAddress=[],B.bytes!==Array)z.toAddress=Q.newBuffer(z.toAddress)}if(q.fromAddress!=null&&q.hasOwnProperty("fromAddress"))z.fromAddress=B.bytes===String?Q.base64.encode(q.fromAddress,0,q.fromAddress.length):B.bytes===Array?Array.prototype.slice.call(q.fromAddress):q.fromAddress;if(q.toAddress!=null&&q.hasOwnProperty("toAddress"))z.toAddress=B.bytes===String?Q.base64.encode(q.toAddress,0,q.toAddress.length):B.bytes===Array?Array.prototype.slice.call(q.toAddress):q.toAddress;if(q.amount?.length){z.amount=[];for(let E=0;E<q.amount.length;++E)z.amount[E]=L.cosmos.base.v1beta1.Coin.toObject(q.amount[E],B)}return z},G.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},G})(),Z})();L.cosmos=(()=>{let Z={};return Z.base=(()=>{let G={};return G.v1beta1=(()=>{let H={};return H.Coin=(()=>{function q(B){if(B){for(let z=Object.keys(B),E=0;E<z.length;++E)if(B[z[E]]!=null)this[z[E]]=B[z[E]]}}return q.prototype.denom="",q.prototype.amount="",q.create=function(z){return new q(z)},q.encode=function(z,E){if(!E)E=J.create();if(z.denom!=null&&Object.hasOwnProperty.call(z,"denom"))E.uint32(10).string(z.denom);if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))E.uint32(18).string(z.amount);return E},q.encodeDelimited=function(z,E){return this.encode(z,E).ldelim()},q.decode=function(z,E){if(!(z instanceof X))z=X.create(z);let V=E===void 0?z.len:z.pos+E,_=new L.cosmos.base.v1beta1.Coin;while(z.pos<V){let N=z.uint32();switch(N>>>3){case 1:_.denom=z.string();break;case 2:_.amount=z.string();break;default:z.skipType(N&7);break}}return _},q.decodeDelimited=function(z){if(!(z instanceof X))z=new X(z);return this.decode(z,z.uint32())},q.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.denom!=null&&z.hasOwnProperty("denom")){if(!Q.isString(z.denom))return"denom: string expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!Q.isString(z.amount))return"amount: string expected"}return null},q.fromObject=function(z){if(z instanceof L.cosmos.base.v1beta1.Coin)return z;let E=new L.cosmos.base.v1beta1.Coin;if(z.denom!=null)E.denom=String(z.denom);if(z.amount!=null)E.amount=String(z.amount);return E},q.toObject=function(z,E){if(!E)E={};let V={};if(E.defaults)V.denom="",V.amount="";if(z.denom!=null&&z.hasOwnProperty("denom"))V.denom=z.denom;if(z.amount!=null&&z.hasOwnProperty("amount"))V.amount=z.amount;return V},q.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},q})(),H.DecCoin=(()=>{function q(B){if(B){for(let z=Object.keys(B),E=0;E<z.length;++E)if(B[z[E]]!=null)this[z[E]]=B[z[E]]}}return q.prototype.denom="",q.prototype.amount="",q.create=function(z){return new q(z)},q.encode=function(z,E){if(!E)E=J.create();if(z.denom!=null&&Object.hasOwnProperty.call(z,"denom"))E.uint32(10).string(z.denom);if(z.amount!=null&&Object.hasOwnProperty.call(z,"amount"))E.uint32(18).string(z.amount);return E},q.encodeDelimited=function(z,E){return this.encode(z,E).ldelim()},q.decode=function(z,E){if(!(z instanceof X))z=X.create(z);let V=E===void 0?z.len:z.pos+E,_=new L.cosmos.base.v1beta1.DecCoin;while(z.pos<V){let N=z.uint32();switch(N>>>3){case 1:_.denom=z.string();break;case 2:_.amount=z.string();break;default:z.skipType(N&7);break}}return _},q.decodeDelimited=function(z){if(!(z instanceof X))z=new X(z);return this.decode(z,z.uint32())},q.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.denom!=null&&z.hasOwnProperty("denom")){if(!Q.isString(z.denom))return"denom: string expected"}if(z.amount!=null&&z.hasOwnProperty("amount")){if(!Q.isString(z.amount))return"amount: string expected"}return null},q.fromObject=function(z){if(z instanceof L.cosmos.base.v1beta1.DecCoin)return z;let E=new L.cosmos.base.v1beta1.DecCoin;if(z.denom!=null)E.denom=String(z.denom);if(z.amount!=null)E.amount=String(z.amount);return E},q.toObject=function(z,E){if(!E)E={};let V={};if(E.defaults)V.denom="",V.amount="";if(z.denom!=null&&z.hasOwnProperty("denom"))V.denom=z.denom;if(z.amount!=null&&z.hasOwnProperty("amount"))V.amount=z.amount;return V},q.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},q})(),H.IntProto=(()=>{function q(B){if(B){for(let z=Object.keys(B),E=0;E<z.length;++E)if(B[z[E]]!=null)this[z[E]]=B[z[E]]}}return q.prototype.int="",q.create=function(z){return new q(z)},q.encode=function(z,E){if(!E)E=J.create();if(z.int!=null&&Object.hasOwnProperty.call(z,"int"))E.uint32(10).string(z.int);return E},q.encodeDelimited=function(z,E){return this.encode(z,E).ldelim()},q.decode=function(z,E){if(!(z instanceof X))z=X.create(z);let V=E===void 0?z.len:z.pos+E,_=new L.cosmos.base.v1beta1.IntProto;while(z.pos<V){let N=z.uint32();switch(N>>>3){case 1:_.int=z.string();break;default:z.skipType(N&7);break}}return _},q.decodeDelimited=function(z){if(!(z instanceof X))z=new X(z);return this.decode(z,z.uint32())},q.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.int!=null&&z.hasOwnProperty("int")){if(!Q.isString(z.int))return"int: string expected"}return null},q.fromObject=function(z){if(z instanceof L.cosmos.base.v1beta1.IntProto)return z;let E=new L.cosmos.base.v1beta1.IntProto;if(z.int!=null)E.int=String(z.int);return E},q.toObject=function(z,E){if(!E)E={};let V={};if(E.defaults)V.int="";if(z.int!=null&&z.hasOwnProperty("int"))V.int=z.int;return V},q.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},q})(),H.DecProto=(()=>{function q(B){if(B){for(let z=Object.keys(B),E=0;E<z.length;++E)if(B[z[E]]!=null)this[z[E]]=B[z[E]]}}return q.prototype.dec="",q.create=function(z){return new q(z)},q.encode=function(z,E){if(!E)E=J.create();if(z.dec!=null&&Object.hasOwnProperty.call(z,"dec"))E.uint32(10).string(z.dec);return E},q.encodeDelimited=function(z,E){return this.encode(z,E).ldelim()},q.decode=function(z,E){if(!(z instanceof X))z=X.create(z);let V=E===void 0?z.len:z.pos+E,_=new L.cosmos.base.v1beta1.DecProto;while(z.pos<V){let N=z.uint32();switch(N>>>3){case 1:_.dec=z.string();break;default:z.skipType(N&7);break}}return _},q.decodeDelimited=function(z){if(!(z instanceof X))z=new X(z);return this.decode(z,z.uint32())},q.verify=function(z){if(typeof z!=="object"||z===null)return"object expected";if(z.dec!=null&&z.hasOwnProperty("dec")){if(!Q.isString(z.dec))return"dec: string expected"}return null},q.fromObject=function(z){if(z instanceof L.cosmos.base.v1beta1.DecProto)return z;let E=new L.cosmos.base.v1beta1.DecProto;if(z.dec!=null)E.dec=String(z.dec);return E},q.toObject=function(z,E){if(!E)E={};let V={};if(E.defaults)V.dec="";if(z.dec!=null&&z.hasOwnProperty("dec"))V.dec=z.dec;return V},q.prototype.toJSON=function(){return this.constructor.toObject(this,Y.util.toJSONOptions)},q})(),H})(),G})(),Z})();export{L as $root};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r;((x)=>{x.Test="goerli";x.Main="homestead"})(r||={});export{r as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{da as Wt}from"./chunk-54gntgt1.js";import{ea as g}from"./chunk-ntbvmmch.js";import{Chain as H}from"@swapkit/helpers";import{match as Py}from"ts-pattern";import{Chain as W,getChainConfig as I,getRPCUrl as at,SKConfig as rt,SwapKitError as K}from"@swapkit/helpers";import{FallbackProvider as ty,getAddress as Dt,Interface as yy,JsonRpcProvider as s,Network as uy}from"ethers";import{match as Lt}from"ts-pattern";function ny(t){return new s(t)}async function cy(t,y){return ny(y||await at(t))}function Rt(t){let y=rt.get("rpcUrls")[t]?.filter(Boolean)??[];if(y.length===0)throw new K("helpers_chain_no_public_or_set_rpc_url",{chain:t});let{chainId:u}=I(t),n=uy.from(Number(u)),[T]=y;if(y.length===1)return new s(T,n,{staticNetwork:n});return new ty(y.map((l,b)=>({priority:b+1,provider:new s(l,n,{staticNetwork:n}),stallTimeout:2000})),n,{quorum:1})}function P(t){return t>0n?`0x${t.toString(16)}`:"0x0"}function qt(t){let{explorerUrl:y,chainIdHex:u,rpcUrls:n}=I(t);return function(){return t!==W.Ethereum?{...Ty({chain:t}),blockExplorerUrls:[y],chainId:u,rpcUrls:n}:void 0}}function Gt(t){return![W.Adi,W.Arbitrum,W.BinanceSmartChain].includes(t)}function Ty({chain:t}){let{name:y,nativeCurrency:u,baseDecimal:n}=I(t);return Lt(t).with(W.Arbitrum,()=>({chainName:"Arbitrum One",nativeCurrency:{decimals:n,name:"Ethereum",symbol:W.Ethereum}})).with(W.Aurora,()=>({chainName:"Aurora Mainnet",nativeCurrency:{decimals:n,name:"Ethereum",symbol:W.Ethereum}})).with(W.Avalanche,()=>({chainName:"Avalanche Network",nativeCurrency:{decimals:n,name:"Avalanche",symbol:t}})).with(W.Base,()=>({chainName:"Base Mainnet",nativeCurrency:{decimals:n,name:"Ethereum",symbol:W.Ethereum}})).with(W.Berachain,()=>({chainName:"Berachain",nativeCurrency:{decimals:n,name:"Berachain",symbol:"BERA"}})).with(W.XLayer,()=>({chainName:"X Layer",nativeCurrency:{decimals:n,name:"OKB",symbol:"OKB"}})).with(W.BinanceSmartChain,()=>({chainName:"BNB Smart Chain Mainnet",nativeCurrency:{decimals:n,name:"Binance Coin",symbol:"BNB"}})).with(W.Gnosis,()=>({chainName:"Gnosis",nativeCurrency:{decimals:n,name:"xDAI",symbol:"XDAI"}})).with(W.Optimism,()=>({chainName:"OP Mainnet",nativeCurrency:{decimals:n,name:"Ethereum",symbol:W.Ethereum}})).with(W.Polygon,()=>({chainName:"Polygon Mainnet",nativeCurrency:{decimals:n,name:"Polygon",symbol:W.Polygon}})).otherwise(()=>({chainName:y,nativeCurrency:{decimals:n,name:u,symbol:u}}))}async function Bt(t,y){if(!("authorize"in t))throw Error("Signer does not support EIP-7702 authorization. Requires ethers.js v6.14+");let u={...y,nonce:y.nonce!==void 0?BigInt(y.nonce):void 0};return await t.authorize(u)}var Mt=(t)=>typeof t==="string"&&/^0x[a-fA-F0-9]{64}$/.test(t),ly=(t)=>{try{return typeof t==="string"&&!!Dt(t)}catch{return!1}};function by(t,y){let u=y!==void 0?`index ${y}: `:"",n=(T,l)=>{throw new K({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{field:T,message:`${u}${l}`}})};Lt(t).when(({chainId:T})=>typeof T!=="bigint",()=>n("chainId","chainId must be a bigint")).when(({address:T})=>!ly(T),()=>n("address","address must be a valid checksummed address")).when(({nonce:T})=>typeof T!=="bigint"||T<0n,()=>n("nonce","nonce must be a non-negative bigint")).when(({signature:T})=>!T,()=>n("signature","signature is required")).when(({signature:T})=>typeof T?.yParity!=="number"||![0,1].includes(T.yParity),()=>n("signature.yParity","yParity must be 0 or 1")).when(({signature:T})=>!Mt(T?.r),()=>n("signature.r","r must be a 32-byte hex string")).when(({signature:T})=>!Mt(T?.s),()=>n("signature.s","s must be a 32-byte hex string")).otherwise(()=>{})}function My(t){return[{key:"name",type:"string"},{key:"version",type:"string"},{key:"chainId",type:"uint256"},{key:"verifyingContract",type:"address"},{key:"salt",type:"bytes32"}].filter(({key:y})=>t[y]!=null).map(({key:y,type:u})=>({name:y,type:u}))}function e(t){return t.charAt(0).toUpperCase()+t.slice(1)}function i(t,y){if(t.isTuple()&&t.components){let u=e(t.name);return y[u]=t.components.map((n)=>({name:n.name,type:i(n,y)})),u}if(t.isArray()){let u=t.arrayChildren;if(u?.isTuple()&&u.components){let n=e(t.name.replace(/s$/,""));return y[n]=u.components.map((T)=>({name:T.name,type:i(T,y)})),`${n}[]`}return`${u?.type??"bytes"}[]`}return t.type}function a(t,y){if(typeof t==="bigint")return t;if(y?.isTuple()&&typeof t?.toObject==="function"){let u=t.toObject(),n={};for(let[T,l]of(y.components??[]).entries())n[l.name]=a(u[l.name]??t[T],l);return n}if(Array.isArray(t)){let u=y?.arrayChildren;return t.map((n)=>a(n,u??void 0))}return t}function vy({chain:t,abi:y,data:u,to:n}){let l=new yy(y).parseTransaction({data:u});if(!l)throw new K({errorKey:"toolbox_evm_invalid_params",info:{error:"Could not decode calldata"}});let b={},M=e(l.name);b[M]=l.fragment.inputs.map((D)=>({name:D.name,type:i(D,b)}));let R={};for(let[D,w]of l.fragment.inputs.entries())R[w.name]=a(l.args[D],w);let{chainId:G}=I(t),q={chainId:Number(G),verifyingContract:Dt(n)},X=My(q);return{domain:q,message:R,primaryType:M,types:{EIP712Domain:X,...b}}}function Ht(t,y){if(!Array.isArray(t)||t.length===0)throw new K({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{message:"EIP-7702 transactions require at least one authorization"}});for(let[u,n]of t.entries())if(by(n,u),y!==void 0&&n.chainId!==y)throw new K({errorKey:"toolbox_evm_invalid_eip7702_authorization",info:{field:"chainId",message:`index ${u}: authorization chainId (${n.chainId}) does not match transaction chainId (${y})`}})}import{Chain as U,FeeOption as jy}from"@swapkit/helpers";import{HDNodeWallet as Ny}from"ethers";import{match as Sy,P as Jt}from"ts-pattern";var wt=[{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"aggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes[]",name:"returnData",type:"bytes[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"blockAndAggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes32",name:"blockHash",type:"bytes32"},{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBlockNumber",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockCoinbase",outputs:[{internalType:"address",name:"coinbase",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockDifficulty",outputs:[{internalType:"uint256",name:"difficulty",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockGasLimit",outputs:[{internalType:"uint256",name:"gaslimit",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"addr",type:"address"}],name:"getEthBalance",outputs:[{internalType:"uint256",name:"balance",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getLastBlockHash",outputs:[{internalType:"bytes32",name:"blockHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"requireSuccess",type:"bool"},{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"tryAggregate",outputs:[{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"requireSuccess",type:"bool"},{components:[{internalType:"address",name:"target",type:"address"},{internalType:"bytes",name:"callData",type:"bytes"}],internalType:"struct Multicall2.Call[]",name:"calls",type:"tuple[]"}],name:"tryBlockAndAggregate",outputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"},{internalType:"bytes32",name:"blockHash",type:"bytes32"},{components:[{internalType:"bool",name:"success",type:"bool"},{internalType:"bytes",name:"returnData",type:"bytes"}],internalType:"struct Multicall2.Result[]",name:"returnData",type:"tuple[]"}],stateMutability:"nonpayable",type:"function"}];import{AssetValue as Dy,applyFeeMultiplierToBigInt as $,Chain as _,EVMChains as Ly,FeeOption as L,isGasAsset as Ry,SwapKitError as B,SwapKitNumber as m}from"@swapkit/helpers";import{erc20ABI as o}from"@swapkit/helpers/contracts";import{BrowserProvider as qy,Contract as Ut,getAddress as p,Interface as Qt}from"ethers";import{match as Xt}from"ts-pattern";function C(t){return{getBalance:Wt(t)}}function ey(t){return t}var tt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function c({chain:t=_.Ethereum,provider:y,signer:u,isEIP1559Compatible:n=!0}){return{approve:Yy({chain:t,isEIP1559Compatible:n,provider:y,signer:u}),approvedAmount:Yt({chain:t,provider:y}),broadcastTransaction:y.broadcastTransaction,call:ut({chain:t,isEIP1559Compatible:n,provider:y,signer:u}),createApprovalTx:ky({chain:t,provider:y,signer:u}),createContract:By({chain:t,provider:y}),createContractTxObject:x({chain:t,provider:y}),createTransaction:r({chain:t,provider:y,signer:u}),createTransferTx:r({chain:t,provider:y,signer:u}),EIP1193SendTransaction:h(y),estimateCall:Zt({provider:y,signer:u}),estimateGasLimit:$y({chain:t,provider:y,signer:u}),estimateGasPrices:F({chain:t,isEIP1559Compatible:n,provider:y}),estimateTransactionFee:_y({chain:t,isEIP1559Compatible:n,provider:y}),getAddress:()=>{return u?u.getAddress():void 0},getBalance:C(t).getBalance,getNetworkParams:qt(t),isApproved:Xy({chain:t,provider:y}),sendTransaction:zt({chain:t,isEIP1559Compatible:n,provider:y,signer:u}),signAuthorization:zy({signer:u}),signMessage:u?(T)=>u.signMessage(T):void 0,signTypedData:u?({domain:T,types:l,value:b})=>u.signTypedData(T,l,b):void 0,transfer:Zy({chain:t,isEIP1559Compatible:n,provider:y,signer:u}),validateAddress:Gy}}function Gy(t){try{return p(t),!0}catch{return!1}}function v(t){return t instanceof qy}function yt(t,y,u){return new Ut(t,Qt.from(y),u)}function By({provider:t}){return function(u,n){return new Ut(u,Qt.from(n),t)}}var Hy=["payable","nonpayable"];function wy({abi:t,funcName:y}){let u=t.find((n)=>n.name===y);if(!u)throw new B("toolbox_evm_no_abi_fragment",{funcName:y});return u.stateMutability&&Hy.includes(u.stateMutability)}function Tu(t){return p(t)}function h(t){return function({value:u,...n}){if(!v(t))throw new B("toolbox_evm_provider_not_eip1193_compatible");let{gasLimit:T,gasPrice:l,maxFeePerGas:b,maxPriorityFeePerGas:M,...R}=n;return t.send("eth_sendTransaction",[{...R,value:P(BigInt(u||0))}])}}function lu(t,y){let u=d(t,y);if(u)return p(u.toLowerCase());throw new B("toolbox_evm_invalid_gas_asset_address")}var Wy=Ly.reduce((t,y)=>{return t[y]="0x0000000000000000000000000000000000000000",t},{}),Uy={...Wy,[_.Optimism]:"0x4200000000000000000000000000000000000042",[_.Polygon]:"0x0000000000000000000000000000000000001010"},Qy=[_.Arbitrum,_.Aurora,_.Base,_.Optimism];function d({chain:t,symbol:y,ticker:u},n){try{let T=t===_.BinanceSmartChain&&y==="BNB"&&u==="BNB",l=t===_.Hyperevm&&y==="HYPE"&&u==="HYPE",b=t===n&&y===n&&u===n,M=Qy.includes(t)&&y==="ETH"&&u==="ETH";if(b||T||l||M)return Uy[n];return p(y.slice(u.length+1).replace(/^0X/,""))}catch{return null}}function x({provider:t}){return async({contractAddress:y,abi:u,funcName:n,funcParams:T=[],txOverrides:l})=>yt(y,u,t).getFunction(n).populateTransaction(...T.concat(l).filter((b)=>typeof b<"u"))}function F({chain:t,provider:y,isEIP1559Compatible:u=!0}){return Xt(t).with(_.Gnosis,()=>{return async function(){try{let{gasPrice:T,maxPriorityFeePerGas:l}=await y.getFeeData();if(!T||l===null)throw new B("toolbox_evm_no_fee_data");return{[L.Average]:{maxFeePerGas:$(T,L.Average),maxPriorityFeePerGas:$(l,L.Average)},[L.Fast]:{maxFeePerGas:$(T,L.Fast),maxPriorityFeePerGas:$(l,L.Fast)},[L.Fastest]:{maxFeePerGas:$(T,L.Fastest),maxPriorityFeePerGas:$(l,L.Fastest)}}}catch(T){throw new B("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}}).with(_.Arbitrum,()=>{return async function(){try{let{gasPrice:T}=await y.getFeeData();if(!T)throw new B("toolbox_evm_no_fee_data");let l=T*12n/10n;return{[L.Average]:{gasPrice:l},[L.Fast]:{gasPrice:$(l,L.Fast)},[L.Fastest]:{gasPrice:$(l,L.Fastest)}}}catch(T){throw new B("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}}).otherwise(()=>{return async function(){try{let{maxFeePerGas:T,maxPriorityFeePerGas:l,gasPrice:b}=await y.getFeeData();if(u){if(T===null||l===null)throw new B("toolbox_evm_no_fee_data");return{[L.Average]:{maxFeePerGas:T,maxPriorityFeePerGas:l},[L.Fast]:{maxFeePerGas:$(T,L.Fast),maxPriorityFeePerGas:$(l,L.Fast)},[L.Fastest]:{maxFeePerGas:$(T,L.Fastest),maxPriorityFeePerGas:$(l,L.Fastest)}}}if(!b)throw new B("toolbox_evm_no_gas_price");return{[L.Average]:{gasPrice:b},[L.Fast]:{gasPrice:$(b,L.Fast)},[L.Fastest]:{gasPrice:$(b,L.Fastest)}}}catch(T){throw new B("toolbox_evm_gas_estimation_error",{error:T.msg??T.toString()})}}})}function ut({provider:t,isEIP1559Compatible:y,signer:u,chain:n}){return async function({callProvider:l,contractAddress:b,abi:M,funcName:R,funcParams:G=[],txOverrides:q={},feeOption:X=L.Fast}){let D=l||t;if(!b)throw new B("toolbox_evm_invalid_params",{error:"contractAddress must be provided"});let w=wy({abi:M,funcName:R});if(w&&v(D)&&u){let z=x({chain:n,provider:D}),k=q?.from||await u?.getAddress(),f=await z({abi:M,contractAddress:b,funcName:R,funcParams:G,txOverrides:{...q,from:k}});return h(D)(f)}let Y=yt(b,M,D);if(w){if(!u)throw new B("toolbox_evm_no_signer");let z=q?.from||await u.getAddress();if(!z)throw new B("toolbox_evm_no_signer_address");let k=Y.connect(u),f=F({chain:n,isEIP1559Compatible:y,provider:t}),{maxFeePerGas:N,maxPriorityFeePerGas:A,gasPrice:V}=(await f())[X],E=await Y.getFunction(R).estimateGas(...G,q),J=await k[R](...G,{...q,gasLimit:E,gasPrice:V,maxFeePerGas:N,maxPriorityFeePerGas:A,nonce:q?.nonce||await D.getTransactionCount(z)});return typeof J?.hash==="string"?J?.hash:J}let Z=await Y[R]?.(...G);return typeof Z?.hash==="string"?Z?.hash:Z}}function Yt({provider:t,chain:y}){return function({assetAddress:n,spenderAddress:T,from:l}){return ut({chain:y,isEIP1559Compatible:!0,provider:t})({abi:o,contractAddress:n,funcName:"allowance",funcParams:[l,T]})}}function Xy({provider:t,chain:y}){return async function({assetAddress:n,spenderAddress:T,from:l,amount:b=tt}){let M=await Yt({chain:y,provider:t})({assetAddress:n,from:l,spenderAddress:T});return m.fromBigInt(M).gte(m.fromBigInt(BigInt(b)))}}function Yy({signer:t,isEIP1559Compatible:y=!0,provider:u,chain:n}){return async function({assetAddress:l,spenderAddress:b,feeOptionKey:M=L.Fast,amount:R,gasLimitFallback:G,from:q,nonce:X}){let D=[b,BigInt(R||tt)],w=await t?.getAddress()||q,Y={abi:o,contractAddress:l,funcName:"approve",funcParams:D,signer:t,txOverrides:{from:w}};if(v(u)){let z=x({chain:n,provider:u}),k=h(u),f=await z(Y);return k(f)}return ut({chain:n,isEIP1559Compatible:y,provider:u,signer:t})({...Y,feeOption:M,funcParams:D,txOverrides:{from:w,gasLimit:G?BigInt(G.toString()):void 0,nonce:X}})}}function Zy({signer:t,isEIP1559Compatible:y=!0,provider:u}){return async function({assetValue:T,memo:l,recipient:b,feeOptionKey:M=L.Fast,sender:R,...G}){let{hexlify:q,toUtf8Bytes:X}=await import("ethers"),D=T.getBaseValue("bigint"),w=T.chain,Y=R||await t?.getAddress(),Z=zt({chain:w,isEIP1559Compatible:y,provider:u,signer:t});if(!Y)throw new B("toolbox_evm_no_from_address");if(T.isGasAsset){let V={...G,data:q(X(l||"")),feeOptionKey:M,from:Y,to:b,value:D};return Z(V)}if(!d(T,w))throw new B("toolbox_evm_no_contract_address");let{maxFeePerGas:k,maxPriorityFeePerGas:f,gasPrice:N}=(await F({chain:w,isEIP1559Compatible:y,provider:u})())[M],A=await r({chain:w,provider:u,signer:t})({assetValue:T,data:q(X(l||"")),gasPrice:N,maxFeePerGas:k,maxPriorityFeePerGas:f,memo:l,recipient:b,sender:Y});return Z(A)}}function Zt({provider:t,signer:y}){return function({contractAddress:n,abi:T,funcName:l,funcParams:b=[],txOverrides:M}){if(!n)throw new B("toolbox_evm_no_contract_address");let R=yt(n,T,t);return y?R.connect(y).getFunction(l).estimateGas(...b,M):R.getFunction(l).estimateGas(...b,M)}}function $y({provider:t,signer:y}){return async function({assetValue:n,recipient:T,memo:l,data:b,sender:M,funcName:R,funcParams:G,txOverrides:q}){let X=n.bigIntValue,D=n.isGasAsset?null:d(n,n.chain);if(D&&R)return Zt({provider:t,signer:y})({abi:o,contractAddress:D,funcName:R,funcParams:G,txOverrides:q});let{hexlify:w,toUtf8Bytes:Y}=await import("ethers");return t.estimateGas({data:b?b:l?w(Y(l)):void 0,from:M,to:T,value:X})}}function zy({signer:t}){if(!t)return;return(y)=>Bt(t,y)}var $t=(t)=>t.type===4||(t.authorizations?.length??0)>0,Jy=(t)=>!$t(t)&&(t.type===2||!!t.maxFeePerGas||!!t.maxPriorityFeePerGas),fy=(t,y=!0)=>{if($t(t))return"eip7702";if(Jy(t)||y)return"eip1559";return"legacy"};function zt({provider:t,signer:y,isEIP1559Compatible:u=!0,chain:n}){return async function({feeOptionKey:l=L.Fast,...b}){let{from:M,to:R,data:G,value:q,...X}=b;if(!y)throw new B("toolbox_evm_no_signer");if(!R)throw new B("toolbox_evm_no_to_address");let D={...X,data:G||"0x",from:M,to:R,value:BigInt(q||0)};if(v(t))return h(t)(D);let w=M||await y.getAddress(),Y=b.nonce||await t.getTransactionCount(w),Z=(await t.getNetwork()).chainId,z=fy(D,u);if(z==="eip7702")Ht(D.authorizations||[],Z);let k=Xt(z).with("eip7702",()=>4).with("eip1559",()=>2).otherwise(()=>0),f={...D,chainId:Z,nonce:Y,type:k,...z==="eip7702"&&{authorizationList:D.authorizations}},N=F({chain:n,isEIP1559Compatible:u,provider:t}),V=z!=="legacy"&&!(D.maxFeePerGas&&D.maxPriorityFeePerGas)||!D.gasPrice?Object.entries((await N())[l]).reduce((J,[O,bt])=>({...J,[O]:P(BigInt(bt))}),{}):{},E;try{E=P(D.gasLimit||await t.estimateGas(f)*11n/10n)}catch(J){throw new B("toolbox_evm_error_estimating_gas_limit",{error:J})}try{let J={...f,gasLimit:E,...V};try{return(await y.sendTransaction(J)).hash}catch{let O=await y.signTransaction({...J,from:w});return(await t.broadcastTransaction(O)).hash}}catch(J){throw new B("toolbox_evm_error_sending_transaction",{error:J})}}}function r({provider:t,signer:y}){return async function({assetValue:n,memo:T,recipient:l,data:b,sender:M,maxFeePerGas:R,maxPriorityFeePerGas:G,gasPrice:q,...X}){let D=n.getBaseValue("bigint"),w=n.chain,Y=M||await y?.getAddress();if(!Y)throw new B("toolbox_evm_no_from_address");if(Ry(n)){let{hexlify:k,toUtf8Bytes:f}=await import("ethers");return{...X,data:b||k(f(T||"")),from:Y,to:l,value:D}}let Z=d(n,w);if(!Z)throw new B("toolbox_evm_no_contract_address");return x({chain:n.chain,provider:t})({abi:o,contractAddress:Z,funcName:"transfer",funcParams:[l,D],txOverrides:{from:Y,gasPrice:q,maxFeePerGas:R,maxPriorityFeePerGas:G}})}}function ky({provider:t,signer:y,chain:u}){return async function({assetAddress:T,spenderAddress:l,amount:b,from:M}){let R=await y?.getAddress()||M,G=x({chain:u,provider:t}),q=["bigint","number"].includes(typeof b)?b:b||tt;return await G({abi:o,contractAddress:T,funcName:"approve",funcParams:[l,BigInt(q)],txOverrides:{from:R}})}}function _y({provider:t,isEIP1559Compatible:y=!0,chain:u}){return async function({feeOption:T=L.Fast,...l}){let M=await F({chain:u,isEIP1559Compatible:y,provider:t})(),R=await t.estimateGas(l),G=Dy.from({chain:u}),{gasPrice:q,maxFeePerGas:X,maxPriorityFeePerGas:D}=M[T];if(!y&&q)return G.set(m.fromBigInt(q*R,G.decimal));if(X&&D){let w=(X+D)*R;return G.set(m.fromBigInt(w,G.decimal))}throw new B("toolbox_evm_no_gas_price")}}function ft(t){let y=Q(U.Ethereum)(t);async function u(n,T="0x5ba1e12693dc8f9c48aad8770482f4739beed696",l="aggregate",b=jy.Fast){let M=await y.createContractTxObject({abi:wt,contractAddress:T,funcName:l,funcParams:[n]});return y.sendTransaction({...M,feeOptionKey:b})}return{...y,multicall:u}}var kt=Q(U.Adi),_t=Q(U.Arbitrum),jt=Q(U.Aurora),Nt=Q(U.Avalanche),St=Q(U.Base),Vt=Q(U.Berachain),Kt=Q(U.BinanceSmartChain),Bu=Q(U.Botanix),ot=Q(U.Core),xt=Q(U.Corn),Ft=Q(U.Cronos),At=Q(U.Gnosis),Et=Q(U.Hyperevm),Ot=Q(U.Linea),It=Q(U.Polygon),Pt=Q(U.MegaETH),Ct=Q(U.Monad),mt=Q(U.Plasma),nt=Q(U.Sonic),gt=Q(U.Unichain),pt=Q(U.XLayer);function Q(t){return function({provider:u,...n}){let T=Gt(t),l=Sy(n).with({phrase:Jt.string},({phrase:M})=>Ny.fromPhrase(M).connect(u)).with({signer:Jt.any},({signer:M})=>M).otherwise(()=>{return});return c({chain:t,isEIP1559Compatible:T,provider:u,signer:l})}}import{applyFeeMultiplierToBigInt as S,Chain as Ky,FeeOption as j,SwapKitError as Tt}from"@swapkit/helpers";import{Contract as oy,HDNodeWallet as xy}from"ethers";import{match as Fy,P as vt}from"ts-pattern";var ct=[{inputs:[{internalType:"address",name:"_owner",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"DecimalsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"GasPriceUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"L1BaseFeeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"OverheadUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"",type:"uint256"}],name:"ScalarUpdated",type:"event"},{inputs:[],name:"decimals",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"gasPrice",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"_data",type:"bytes"}],name:"getL1Fee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"_data",type:"bytes"}],name:"getL1GasUsed",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"l1BaseFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"overhead",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"scalar",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_decimals",type:"uint256"}],name:"setDecimals",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_gasPrice",type:"uint256"}],name:"setGasPrice",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_baseFee",type:"uint256"}],name:"setL1BaseFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_overhead",type:"uint256"}],name:"setOverhead",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_scalar",type:"uint256"}],name:"setScalar",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];var Ay="0x420000000000000000000000000000000000000f";function lt(t){return new oy(Ay,ct,t)}function ht(t){return async function(){let u=lt(t);if(u&&"l1BaseFee"in u)return await u?.l1BaseFee();return}}function dt(t){return async function({from:u,to:n,nonce:T,...l}){let{Transaction:b}=await import("ethers");if(!n)throw new Tt("toolbox_evm_invalid_transaction",{error:"Missing to address"});return b.from({...l,authorizationList:l.authorizationList,nonce:T?T:u?await t.getTransactionCount(u):0,to:n}).serialized}}function st(t){return async function(u){let n=lt(t),T=await dt(t)(u);if(n&&"getL1Fee"in n)return n.getL1Fee(T)}}function et(t){return async function(u){let T=(await t.getFeeData()).gasPrice??0n,l=await t.estimateGas(u);return T*l}}function Ey(t){return async function(u){let n=await st(t)(u)??0n,T=await et(t)(u);return n+T}}function Oy(t){return async function(u){let n=lt(t),T=await dt(t)(u);if(n&&"getL1GasUsed"in n)return n.getL1GasUsed(T)}}function Iy(t){return async function(){try{let{maxFeePerGas:u,maxPriorityFeePerGas:n,gasPrice:T}=await t.getFeeData(),l=await ht(t)(),b=T;if(!(u&&n))throw new Tt("toolbox_evm_no_fee_data");return{[j.Average]:{gasPrice:b,l1GasPrice:l,maxFeePerGas:u,maxPriorityFeePerGas:n},[j.Fast]:{gasPrice:S(b,j.Fast),l1GasPrice:S(l||0n,j.Fast),maxFeePerGas:u,maxPriorityFeePerGas:S(n,j.Fast)},[j.Fastest]:{gasPrice:S(b,j.Fastest),l1GasPrice:S(l||0n,j.Fastest),maxFeePerGas:u,maxPriorityFeePerGas:S(n,j.Fastest)}}}catch(u){throw new Tt("toolbox_evm_gas_estimation_error",{error:u.msg??u.toString()})}}}function it({provider:t,...y}){let u=Fy(y).with({phrase:vt.string},({phrase:l})=>xy.fromPhrase(l).connect(t)).with({signer:vt.any},({signer:l})=>l).otherwise(()=>{return}),n=c({provider:t,signer:u}),T=ht(t);return{...n,estimateGasPrices:Iy(t),estimateL1Gas:Oy(t),estimateL1GasCost:st(t),estimateL2GasCost:et(t),estimateTotalGasCost:Ey(t),getBalance:C(Ky.Optimism).getBalance,getL1GasPrice:T}}function Cy(t,y){return Py(t).with(H.Adi,()=>kt(y)).with(H.Arbitrum,()=>_t(y)).with(H.Aurora,()=>jt(y)).with(H.Avalanche,()=>Nt(y)).with(H.Base,()=>St(y)).with(H.Berachain,()=>Vt(y)).with(H.BinanceSmartChain,()=>Kt(y)).with(H.Botanix,()=>nt(y)).with(H.Core,()=>ot(y)).with(H.Corn,()=>xt(y)).with(H.Cronos,()=>Ft(y)).with(H.Ethereum,()=>ft(y)).with(H.Gnosis,()=>At(y)).with(H.Hyperevm,()=>Et(y)).with(H.Linea,()=>Ot(y)).with(H.MegaETH,()=>Pt(y)).with(H.Monad,()=>Ct(y)).with(H.Optimism,()=>it(y)).with(H.Plasma,()=>mt(y)).with(H.Polygon,()=>It(y)).with(H.Sonic,()=>nt(y)).with(H.Unichain,()=>gt(y)).with(H.XLayer,()=>pt(y)).exhaustive()}async function ku(t,y){let u={...y,provider:y?.provider||Rt(t)};return Cy(t,u)}
|
|
2
|
+
export{C as b,ey as c,ny as d,cy as e,Rt as f,P as g,qt as h,Gt as i,Bt as j,by as k,My as l,vy as m,Ht as n,tt as o,c as p,Gy as q,v as r,yt as s,By as t,wy as u,Tu as v,h as w,lu as x,Uy as y,d as z,x as A,F as B,$t as C,Jy as D,fy as E,ft as F,kt as G,_t as H,jt as I,Nt as J,St as K,Vt as L,Kt as M,Bu as N,ot as O,xt as P,Ft as Q,At as R,Et as S,Ot as T,It as U,Pt as V,Ct as W,mt as X,nt as Y,gt as Z,pt as _,it as $,Cy as aa,ku as ba};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{AssetValue as o,getChainConfig as l}from"@swapkit/helpers";import{SwapKitApi as m}from"@swapkit/helpers/api";var d=typeof process<"u"&&process.pid?process.pid.toString(36):"",i=0;function C(){function t(){let e=Date.now(),n=i||e;return i=n,e>i?e:n+1}return d+t().toString(36)}function h(t){return async function(n,r=!0){let c=await m.getChainBalance({address:n,chain:t,scamFilter:r}),{baseDecimal:p}=l(t),s=c.map(({identifier:a,value:u,decimal:f})=>{return new o({decimal:f||p,identifier:a,value:u})});if(!s.some((a)=>a.isGasAsset))return[o.from({chain:t}),...s];return s}}
|
|
2
|
+
export{C as ca,h as da};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as N,A as m,B as n,C as o,D as p,E as q,F as r,G as s,H as t,I as u,J as v,K as w,L as x,M as y,N as z,O as A,P as B,Q as C,R as D,S as E,T as F,U as G,V as H,W as I,X as J,Y as K,Z as L,_ as M,aa as O,ba as P,o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i,x as j,y as k,z as l}from"./chunk-4q573g5z.js";import"./chunk-54gntgt1.js";import"./chunk-ntbvmmch.js";export{c as validateEVMAddress,h as toChecksumAddress,g as isStateChangingCall,o as isEIP7702Transaction,p as isEIP1559Transaction,d as isBrowserProvider,l as getTokenAddress,P as getEvmToolboxAsync,O as getEvmToolbox,n as getEstimateGasPrices,q as getEVMTxType,i as getEIP1193SendTransaction,m as getCreateContractTxObject,f as getCreateContract,j as getChecksumAddressFromAsset,e as createContract,M as XLayerToolbox,L as UNIToolbox,K as SONICToolbox,J as PLASMAToolbox,N as OPToolbox,I as MONADToolbox,H as MEGAETHToolbox,a as MAX_APPROVAL,G as MATICToolbox,F as LINEAToolbox,E as HYPEREVMToolbox,D as GNOToolbox,r as ETHToolbox,k as ContractAddress,C as CROToolbox,B as CORNToolbox,A as COREToolbox,z as BotanixToolbox,b as BaseEVMToolbox,y as BSCToolbox,x as BERAToolbox,w as BASEToolbox,v as AVAXToolbox,u as AURORAToolbox,t as ARBToolbox,s as ADIToolbox};
|
package/dist/src/aptos/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ea as E}from"../../chunk-ntbvmmch.js";import{AssetValue as T,Chain as p,derivationPathToString as L,getChainConfig as P,getRPCUrlSync as v,NetworkDerivationPath as M,SwapKitError as o}from"@swapkit/helpers";import{match as C,P as B}from"ts-pattern";var g={COIN_TYPE:"0x1::aptos_coin::AptosCoin",FUNGIBLE_ASSET_METADATA:"0x1::fungible_asset::Metadata",FUNGIBLE_STORE_TRANSFER:"0x1::primary_fungible_store::transfer",TRANSFER:"0x1::aptos_account::transfer"},O=/^[0-9a-fA-F]+$/;function h(c){if(!c||typeof c!=="string"||!c.startsWith("0x"))return!1;let d=c.slice(2);if(d.length===0||d.length>64)return!1;return O.test(d)}function k({derivationPath:c,provider:d,...l}={}){let u,y=L(c||M[p.Aptos],{allHardened:!0});async function f(){if(u)return u;return u=await C(l).with({phrase:B.string},async({phrase:n})=>{let{Ed25519Account:t}=await import("@aptos-labs/ts-sdk");return t.fromDerivationPath({mnemonic:n,path:y})}).with({signer:B.any},({signer:n})=>n).otherwise(()=>{return}),u}async function A(){let{Aptos:n,AptosConfig:t,Network:s}=await import("@aptos-labs/ts-sdk"),r=new t({clientConfig:{http2:!1},fullnode:d||v(p.Aptos),network:s.MAINNET});return new n(r)}async function b(){return(await f())?.accountAddress.toString()||""}async function F(n){let t=n||await b();if(!t)throw new o("toolbox_aptos_address_required");let{baseDecimal:s,chain:r}=P(p.Aptos);try{let e=await A(),i=await e.getAccountAPTAmount({accountAddress:t}),m=[T.from({chain:r,fromBaseDecimal:s,value:i.toString()})],w=await e.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:t}}}});for(let a of w){if(a.asset_type===g.COIN_TYPE||Number(a.amount)<=0)continue;let _=a.asset_type;if(_){let U=("metadata"in a&&typeof a.metadata==="object"&&a.metadata!==null?a.metadata:void 0)?.decimals??s;m.push(T.from({asset:`${p.Aptos}.APT-${_}`,fromBaseDecimal:U,value:String(a.amount)}))}}return m}catch{return[T.from({chain:r})]}}async function D(n){if(!n){let{baseDecimal:w}=P(p.Aptos),a=d||v(p.Aptos),_=await fetch(`${a}/estimate_gas_price`),{gas_estimate:x}=await _.json();return T.from({chain:p.Aptos,fromBaseDecimal:w,value:String(x)})}let t=await f();if(!t)throw new o("toolbox_aptos_no_signer");let s=await S(n),r=await A(),[e]=await r.transaction.simulate.simple({signerPublicKey:t.publicKey,transaction:s});if(!e)throw new o("toolbox_aptos_transaction_creation_error");let i=BigInt(e.gas_used)*BigInt(e.gas_unit_price),{baseDecimal:m}=P(p.Aptos);return T.from({chain:p.Aptos,fromBaseDecimal:m,value:i.toString()})}async function S({recipient:n,assetValue:t,maxGasAmount:s,sender:r}){if(!h(n))throw new o("core_transaction_invalid_recipient_address");let e=r||await b();if(!e)throw new o("toolbox_aptos_no_sender");let{AccountAddress:i}=await import("@aptos-labs/ts-sdk"),m=await A(),w=i.from(e);try{let a=t.isGasAsset?g.TRANSFER:g.FUNGIBLE_STORE_TRANSFER,_=C({address:t?.address,isGasAsset:t.isGasAsset}).with({isGasAsset:!0},()=>[i.from(n),t.getBaseValue("bigint")]).with({address:B.string},({address:x})=>[i.from(x),i.from(n),t.getBaseValue("bigint")]).otherwise(()=>null);if(!_)throw new o("toolbox_aptos_missing_asset_type");return m.transaction.build.simple({data:{function:a,functionArguments:_,typeArguments:t.isGasAsset?[]:[g.FUNGIBLE_ASSET_METADATA]},options:s?{maxGasAmount:s}:void 0,sender:w})}catch(a){if(a instanceof o)throw a;throw new o("toolbox_aptos_transaction_creation_error",a)}}async function R(n){let t=await f();if(!t)throw new o("toolbox_aptos_no_signer");return(await A()).transaction.sign({signer:t,transaction:n})}async function G({assetValue:n,maxGasAmount:t,recipient:s}){let r=await f();if(!r)throw new o("toolbox_aptos_no_signer");if(!h(s))throw new o("core_transaction_invalid_recipient_address");try{let e=r.accountAddress.toString(),i=await S({assetValue:n,maxGasAmount:t,recipient:s,sender:e});return(await(await A()).signAndSubmitTransaction({signer:r,transaction:i})).hash}catch(e){if(e instanceof o)throw e;throw new o("toolbox_aptos_transaction_creation_error",e)}}async function N({senderAuthenticator:n,transaction:t}){try{return(await(await A()).transaction.submit.simple({senderAuthenticator:n,transaction:t})).hash}catch(s){throw new o("toolbox_aptos_broadcast_error",s)}}async function I(n){let t=await R(n);return N({senderAuthenticator:t,transaction:n})}return{broadcastTransaction:N,createTransaction:S,estimateTransactionFee:D,getAddress:b,getBalance:F,signAndBroadcastTransaction:I,signTransaction:R,transfer:G,validateAddress:h}}function $({provider:c}){return async function({assetValue:l,recipient:u}){if(!h(u))throw new o("core_transaction_invalid_recipient_address");let{AccountAddress:y}=await import("@aptos-labs/ts-sdk");if(l.isGasAsset)return(await c.signAndSubmitTransaction({arguments:[y.from(u).toString(),l.getBaseValue("string")],function:g.TRANSFER,type:"entry_function_payload",type_arguments:[]})).hash;let f=l.address;if(!f)throw new o("toolbox_aptos_missing_asset_type");return(await c.signAndSubmitTransaction({arguments:[f,y.from(u).toString(),l.getBaseValue("string")],function:g.FUNGIBLE_STORE_TRANSFER,type:"entry_function_payload",type_arguments:[g.FUNGIBLE_ASSET_METADATA]})).hash}}export{h as validateAptosAddress,k as getAptosToolbox,$ as createAptosExtensionTransfer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var XG=Object.create;var{getPrototypeOf:jG,defineProperty:
|
|
1
|
+
var XG=Object.create;var{getPrototypeOf:jG,defineProperty:E,getOwnPropertyNames:d,getOwnPropertyDescriptor:WG}=Object,i=Object.prototype.hasOwnProperty;function n(G){return this[G]}var qG,FG,UG=(G,J,Q)=>{var z=G!=null&&typeof G==="object";if(z){var W=J?qG??=new WeakMap:FG??=new WeakMap,F=W.get(G);if(F)return F}Q=G!=null?XG(jG(G)):{};let Z=J||!G||!G.__esModule?E(Q,"default",{value:G,enumerable:!0}):Q;for(let U of d(G))if(!i.call(Z,U))E(Z,U,{get:n.bind(G,U),enumerable:!0});if(z)W.set(G,Z);return Z},YG=(G)=>{var J=(c??=new WeakMap).get(G),Q;if(J)return J;if(J=E({},"__esModule",{value:!0}),G&&typeof G==="object"||typeof G==="function"){for(var z of d(G))if(!i.call(J,z))E(J,z,{get:n.bind(G,z),enumerable:!(Q=WG(G,z))||Q.enumerable})}return c.set(G,J),J},c;var MG=(G)=>G;function RG(G,J){this[G]=MG.bind(null,J)}var DG=(G,J)=>{for(var Q in J)E(G,Q,{get:J[Q],enumerable:!0,configurable:!0,set:RG.bind(J,Q)})};var o=(G,J)=>()=>(G&&(J=G(G=0)),J);async function p(G,J){let Q=await fetch(`${JG}${G}`,{...J,headers:{project_id:GG,...J?.headers}});if(!Q.ok)throw Error(`Blockfrost API error: ${Q.status} ${Q.statusText}`);return Q.json()}async function QG(G){try{return await p(`/addresses/${G}/utxos`)}catch{return[]}}async function HG(){return(await p("/blocks/latest")).slot}async function OG(){let G=await p("/epochs/latest/parameters"),J={PlutusScriptV1:G.cost_models.PlutusV1?Object.values(G.cost_models.PlutusV1):[],PlutusScriptV2:G.cost_models.PlutusV2?Object.values(G.cost_models.PlutusV2):[],PlutusScriptV3:G.cost_models.PlutusV3?Object.values(G.cost_models.PlutusV3):[]};return{collateralPercent:new q.default(G.collateral_percent),languageView:J,maxValueSize:Number.parseInt(G.max_val_size,10),minFeeA:new q.default(G.min_fee_a),minFeeB:new q.default(G.min_fee_b),minFeeRefScriptCostPerByte:new q.default(15),priceMem:new q.default(G.price_mem),priceSteps:new q.default(G.price_step),stakeKeyDeposit:new q.default(2000000),utxoCostPerByte:new q.default(G.coins_per_utxo_size)}}async function r(G){let J=await fetch(`${JG}/tx/submit`,{body:Buffer.from(G,"hex"),headers:{"Content-Type":"application/cbor",project_id:GG},method:"POST"});if(!J.ok){let Q=await J.text();throw Error(`Transaction submission failed: ${Q}`)}return J.json()}function _G(G,J){return G.map((Q)=>{let z=Q.amount.find((Z)=>Z.unit==="lovelace"),W=z?new q.default(z.quantity):new q.default(0),F=Q.amount.filter((Z)=>Z.unit!=="lovelace").map((Z)=>({amount:new q.default(Z.quantity),assetName:Z.unit.slice(56),policyId:Z.unit.slice(0,56)}));return{address:J,amount:W,index:Q.output_index,tokens:F,txId:Q.tx_hash}})}async function IG(G){try{let J=await QG(G),Q=0n,z=new Map;for(let Z of J){if(!Z.amount||!Array.isArray(Z.amount))continue;for(let U of Z.amount){let{unit:I,quantity:Y}=U;if(I==="lovelace")Q+=BigInt(Y);else{let R=z.get(I)||0n;z.set(I,R+BigInt(Y))}}}let W=[],{baseDecimal:F}=$.getChainConfig($.Chain.Cardano);if(Q>0n)W.push($.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:F,value:Q.toString()}));for(let[Z,U]of z)W.push($.AssetValue.from({asset:`${$.Chain.Cardano}.${Z}`,value:U.toString()}));if(W.length===0)return[$.AssetValue.from({chain:$.Chain.Cardano})];return W}catch(J){let Q=J instanceof Error?J.message:String(J);return console.error(`Cardano balance fetch error: ${Q}`),[$.AssetValue.from({chain:$.Chain.Cardano})]}}function ZG(G){if(!G||typeof G!=="string")return!1;try{let J=s.bech32.decode(G,120);return J.prefix==="addr"||J.prefix==="addr_test"}catch{return!1}}async function LG(G,J=0,Q=0){let{Bip32PrivateKey:z}=await import("@stricahq/bip32ed25519"),{types:W,address:F,crypto:Z}=await import("@stricahq/typhonjs"),U=a.mnemonicToEntropy(G,e.wordlist),Y=(await z.fromEntropy(Buffer.from(Array.from(U)))).derive(m+1852).derive(m+1815).derive(m+J),R=Y.derive(0).derive(Q),f=R.toBip32PublicKey().toPublicKey().toBytes(),K=Z.hash28(f),j=Y.derive(2).derive(0).toBip32PublicKey().toPublicKey().toBytes(),D=Z.hash28(j),M={hash:K,type:W.HashType.ADDRESS},O={hash:D,type:W.HashType.ADDRESS},k=new F.BaseAddress(W.NetworkId.MAINNET,M,O).getBech32(),v=R.toPrivateKey();return{getAddress:()=>k,publicKey:f,publicKeyHash:K,signTransaction:async(T)=>{try{let _=await import("@stricahq/cbors"),V=Buffer.from(T,"hex"),P=_.Decoder.decode(V),[w,S,h,b]=P.value,g=_.Encoder.encode(w),B=Z.hash32(g),x=v.sign(B),A=S instanceof Map?S:new Map,N=A.get(t)||[];N.push([f,x]),A.set(t,N);let y=[w,A,h,b];return _.Encoder.encode(y).toString("hex")}catch(_){throw new $.SwapKitError("toolbox_cardano_sign_transaction_failed",{message:String(_)})}}}}function fG(G){let J,Q,z;async function W(){if(!z)z=await OG();return z}async function F(){if(J!==void 0)return J;if(G&&"phrase"in G&&G.phrase){let X=G.index??0;return J=await LG(G.phrase,0,X),J}if(G&&"signer"in G&&G.signer)return J=G.signer,J;return}async function Z(){if(Q)return Q;let X=await F();if(!X)return"";if("getAddress"in X)return Q=await X.getAddress(),Q;return""}async function U(X){let j=X||await Z();if(!j)throw new $.SwapKitError("core_wallet_connection_not_found");return IG(j)}async function I(X){if(X)try{let{tx:O}=await Y(X),L=O.getFee();return $.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:6,value:L.toString()})}catch{}let j=await W(),D=400,M=j.minFeeB.plus(j.minFeeA.times(D));return $.AssetValue.from({chain:$.Chain.Cardano,fromBaseDecimal:6,value:M.toString()})}async function Y({sender:X="",recipient:j,assetValue:D,memo:M,pureLovelaceOnly:O=!1}){let{Transaction:L,utils:k}=await import("@stricahq/typhonjs"),v=X||await Z();if(!v)throw new $.SwapKitError("core_wallet_connection_not_found");let[T,_,V]=await Promise.all([QG(v),HG(),W()]),P=T.filter((H)=>O?H.amount.every((C)=>C.unit==="lovelace"):H.amount.some((C)=>C.unit==="lovelace")).sort((H,C)=>{let l=H.amount.some((u)=>u.unit!=="lovelace"),zG=C.amount.some((u)=>u.unit!=="lovelace");if(l===zG)return 0;return l?1:-1}),w=k.getAddressFromString(v),S=k.getAddressFromString(j),h=_G(P,w),b=new q.default(D.getBaseValue("string")),g=[{address:S,amount:b,tokens:[]}],B;if(M){let H=new Map;H.set("msg",[M]),B={metadata:[{data:H,label:674}]}}let x={...V,minFeeB:V.minFeeB.plus(V.minFeeA.times(4))},N=new L({protocolParams:x}).paymentTransaction({auxiliaryData:B,changeAddress:w,inputs:h,outputs:g,ttl:_+3600}),{payload:y}=N.buildTransaction();return{tx:N,unsignedTx:y}}async function R(X){let j=await F();if(!j||!("signTransaction"in j))throw new $.SwapKitError("core_wallet_connection_not_found");return j.signTransaction(X)}async function f({recipient:X,assetValue:j,memo:D}){let M=await F();if(!M||!("signTransaction"in M))throw new $.SwapKitError("core_wallet_connection_not_found");let{unsignedTx:O}=await Y({assetValue:j,memo:D,recipient:X,sender:await Z()}),L=await R(O);return await r(L)}async function K(X){let j=await R(X);return await r(j)}return{createTransaction:Y,estimateTransactionFee:I,getAddress:Z,getBalance:U,signAndBroadcastTransaction:K,signTransaction:R,transfer:f,validateAddress:ZG}}var s,a,e,$,q,GG="mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS",JG="https://cardano-mainnet.blockfrost.io/api/v0",m=2147483648,t=0;var $G=o(()=>{s=require("@scure/base"),a=require("@scure/bip39"),e=require("@scure/bip39/wordlists/english.js"),$=require("@swapkit/helpers"),q=UG(require("bignumber.js"))});var vG={};DG(vG,{validateCardanoAddress:()=>ZG,getCardanoToolbox:()=>fG});module.exports=YG(vG);var VG=o(()=>{$G()});VG();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ea as P}from"../../chunk-ntbvmmch.js";import{bech32 as a}from"@scure/base";import{mnemonicToEntropy as e}from"@scure/bip39";import{wordlist as GG}from"@scure/bip39/wordlists/english.js";import{AssetValue as f,Chain as _,getChainConfig as JG,SwapKitError as K}from"@swapkit/helpers";import W from"bignumber.js";var o="mainnet3YT7XK6NidLPlkHxxyBB5V0WzXUOTIJS",t="https://cardano-mainnet.blockfrost.io/api/v0",l=2147483648,i=0;async function c(G,J){let Q=await fetch(`${t}${G}`,{...J,headers:{project_id:o,...J?.headers}});if(!Q.ok)throw Error(`Blockfrost API error: ${Q.status} ${Q.statusText}`);return Q.json()}async function r(G){try{return await c(`/addresses/${G}/utxos`)}catch{return[]}}async function QG(){return(await c("/blocks/latest")).slot}async function ZG(){let G=await c("/epochs/latest/parameters"),J={PlutusScriptV1:G.cost_models.PlutusV1?Object.values(G.cost_models.PlutusV1):[],PlutusScriptV2:G.cost_models.PlutusV2?Object.values(G.cost_models.PlutusV2):[],PlutusScriptV3:G.cost_models.PlutusV3?Object.values(G.cost_models.PlutusV3):[]};return{collateralPercent:new W(G.collateral_percent),languageView:J,maxValueSize:Number.parseInt(G.max_val_size,10),minFeeA:new W(G.min_fee_a),minFeeB:new W(G.min_fee_b),minFeeRefScriptCostPerByte:new W(15),priceMem:new W(G.price_mem),priceSteps:new W(G.price_step),stakeKeyDeposit:new W(2000000),utxoCostPerByte:new W(G.coins_per_utxo_size)}}async function n(G){let J=await fetch(`${t}/tx/submit`,{body:Buffer.from(G,"hex"),headers:{"Content-Type":"application/cbor",project_id:o},method:"POST"});if(!J.ok){let Q=await J.text();throw Error(`Transaction submission failed: ${Q}`)}return J.json()}function $G(G,J){return G.map((Q)=>{let j=Q.amount.find((Z)=>Z.unit==="lovelace"),X=j?new W(j.quantity):new W(0),q=Q.amount.filter((Z)=>Z.unit!=="lovelace").map((Z)=>({amount:new W(Z.quantity),assetName:Z.unit.slice(56),policyId:Z.unit.slice(0,56)}));return{address:J,amount:X,index:Q.output_index,tokens:q,txId:Q.tx_hash}})}async function zG(G){try{let J=await r(G),Q=0n,j=new Map;for(let Z of J){if(!Z.amount||!Array.isArray(Z.amount))continue;for(let D of Z.amount){let{unit:I,quantity:F}=D;if(I==="lovelace")Q+=BigInt(F);else{let Y=j.get(I)||0n;j.set(I,Y+BigInt(F))}}}let X=[],{baseDecimal:q}=JG(_.Cardano);if(Q>0n)X.push(f.from({chain:_.Cardano,fromBaseDecimal:q,value:Q.toString()}));for(let[Z,D]of j)X.push(f.from({asset:`${_.Cardano}.${Z}`,value:D.toString()}));if(X.length===0)return[f.from({chain:_.Cardano})];return X}catch(J){let Q=J instanceof Error?J.message:String(J);return console.error(`Cardano balance fetch error: ${Q}`),[f.from({chain:_.Cardano})]}}function XG(G){if(!G||typeof G!=="string")return!1;try{let J=a.decode(G,120);return J.prefix==="addr"||J.prefix==="addr_test"}catch{return!1}}async function jG(G,J=0,Q=0){let{Bip32PrivateKey:j}=await import("@stricahq/bip32ed25519"),{types:X,address:q,crypto:Z}=await import("@stricahq/typhonjs"),D=e(G,GG),F=(await j.fromEntropy(Buffer.from(Array.from(D)))).derive(l+1852).derive(l+1815).derive(l+J),Y=F.derive(0).derive(Q),k=Y.toBip32PublicKey().toPublicKey().toBytes(),S=Z.hash28(k),z=F.derive(2).derive(0).toBip32PublicKey().toPublicKey().toBytes(),M=Z.hash28(z),U={hash:S,type:X.HashType.ADDRESS},H={hash:M,type:X.HashType.ADDRESS},v=new q.BaseAddress(X.NetworkId.MAINNET,U,H).getBech32(),V=Y.toPrivateKey();return{getAddress:()=>v,publicKey:k,publicKeyHash:S,signTransaction:async(h)=>{try{let O=await import("@stricahq/cbors"),w=Buffer.from(h,"hex"),b=O.Decoder.decode(w),[N,B,g,x]=b.value,y=O.Encoder.encode(N),A=Z.hash32(y),u=V.sign(A),T=B instanceof Map?B:new Map,C=T.get(i)||[];C.push([k,u]),T.set(i,C);let m=[N,T,g,x];return O.Encoder.encode(m).toString("hex")}catch(O){throw new K("toolbox_cardano_sign_transaction_failed",{message:String(O)})}}}}function MG(G){let J,Q,j;async function X(){if(!j)j=await ZG();return j}async function q(){if(J!==void 0)return J;if(G&&"phrase"in G&&G.phrase){let $=G.index??0;return J=await jG(G.phrase,0,$),J}if(G&&"signer"in G&&G.signer)return J=G.signer,J;return}async function Z(){if(Q)return Q;let $=await q();if(!$)return"";if("getAddress"in $)return Q=await $.getAddress(),Q;return""}async function D($){let z=$||await Z();if(!z)throw new K("core_wallet_connection_not_found");return zG(z)}async function I($){if($)try{let{tx:H}=await F($),L=H.getFee();return f.from({chain:_.Cardano,fromBaseDecimal:6,value:L.toString()})}catch{}let z=await X(),M=400,U=z.minFeeB.plus(z.minFeeA.times(M));return f.from({chain:_.Cardano,fromBaseDecimal:6,value:U.toString()})}async function F({sender:$="",recipient:z,assetValue:M,memo:U,pureLovelaceOnly:H=!1}){let{Transaction:L,utils:v}=await import("@stricahq/typhonjs"),V=$||await Z();if(!V)throw new K("core_wallet_connection_not_found");let[h,O,w]=await Promise.all([r(V),QG(),X()]),b=h.filter((R)=>H?R.amount.every((E)=>E.unit==="lovelace"):R.amount.some((E)=>E.unit==="lovelace")).sort((R,E)=>{let d=R.amount.some((p)=>p.unit!=="lovelace"),s=E.amount.some((p)=>p.unit!=="lovelace");if(d===s)return 0;return d?1:-1}),N=v.getAddressFromString(V),B=v.getAddressFromString(z),g=$G(b,N),x=new W(M.getBaseValue("string")),y=[{address:B,amount:x,tokens:[]}],A;if(U){let R=new Map;R.set("msg",[U]),A={metadata:[{data:R,label:674}]}}let u={...w,minFeeB:w.minFeeB.plus(w.minFeeA.times(4))},C=new L({protocolParams:u}).paymentTransaction({auxiliaryData:A,changeAddress:N,inputs:g,outputs:y,ttl:O+3600}),{payload:m}=C.buildTransaction();return{tx:C,unsignedTx:m}}async function Y($){let z=await q();if(!z||!("signTransaction"in z))throw new K("core_wallet_connection_not_found");return z.signTransaction($)}async function k({recipient:$,assetValue:z,memo:M}){let U=await q();if(!U||!("signTransaction"in U))throw new K("core_wallet_connection_not_found");let{unsignedTx:H}=await F({assetValue:z,memo:M,recipient:$,sender:await Z()}),L=await Y(H);return await n(L)}async function S($){let z=await Y($);return await n(z)}return{createTransaction:F,estimateTransactionFee:I,getAddress:Z,getBalance:D,signAndBroadcastTransaction:S,signTransaction:Y,transfer:k,validateAddress:XG}}export{XG as validateCardanoAddress,MG as getCardanoToolbox};
|