@swapkit/toolboxes 4.20.0 → 4.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/{chunk-r2htb2ce.js → chunk-x9db9hmg.js} +1 -1
- package/dist/chunk-xs0j1eze.js +2 -0
- 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/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/types/evm/toolbox/baseEVMToolbox.d.ts +90 -5
- package/dist/types/evm/toolbox/evm.d.ts +1584 -88
- package/dist/types/evm/toolbox/op.d.ts +72 -4
- package/dist/types/evm/types.d.ts +7 -7
- package/dist/types/ton/toolbox.d.ts +5 -5
- package/dist/types/ton/types.d.ts +5 -0
- package/dist/types/tron/index.d.ts +2 -2
- package/dist/types/tron/toolbox.d.ts +3 -1
- package/dist/types/tron/types.d.ts +5 -0
- package/package.json +2 -2
- package/dist/chunk-4q573g5z.js +0 -2
|
@@ -33,11 +33,79 @@ export declare function OPToolbox({ provider, ...toolboxSignerParams }: EVMToolb
|
|
|
33
33
|
approvedAmount: ({ assetAddress, spenderAddress, from }: import("..").IsApprovedParams) => Promise<bigint>;
|
|
34
34
|
broadcastTransaction: ((signedTx: string) => Promise<import("ethers").TransactionResponse>) | ((signedTx: string) => Promise<import("ethers").TransactionResponse>);
|
|
35
35
|
call: <T>({ callProvider, contractAddress, abi, funcName, funcParams, txOverrides, feeOption, }: import("..").CallParams) => Promise<T>;
|
|
36
|
-
createApprovalTx: ({ assetAddress, spenderAddress, amount, from: fromParam }: import("..").ApproveParams) => Promise<
|
|
36
|
+
createApprovalTx: ({ assetAddress, spenderAddress, amount, from: fromParam }: import("..").ApproveParams) => Promise<{
|
|
37
|
+
value: string;
|
|
38
|
+
to: string;
|
|
39
|
+
data: string;
|
|
40
|
+
from?: string;
|
|
41
|
+
type?: number;
|
|
42
|
+
nonce?: number;
|
|
43
|
+
gasLimit?: bigint;
|
|
44
|
+
gasPrice?: bigint;
|
|
45
|
+
maxPriorityFeePerGas?: bigint;
|
|
46
|
+
maxFeePerGas?: bigint;
|
|
47
|
+
chainId?: bigint;
|
|
48
|
+
accessList?: import("ethers").AccessList;
|
|
49
|
+
authorizationList?: Array<Authorization>;
|
|
50
|
+
customData?: any;
|
|
51
|
+
blockTag?: import("ethers").BlockTag;
|
|
52
|
+
enableCcipRead?: boolean;
|
|
53
|
+
}>;
|
|
37
54
|
createContract: (address: string, abi: readonly (import("ethers").JsonFragment | import("ethers").Fragment)[]) => Contract;
|
|
38
|
-
createContractTxObject: ({ contractAddress, abi, funcName, funcParams, txOverrides }: import("..").CallParams) => Promise<
|
|
39
|
-
|
|
40
|
-
|
|
55
|
+
createContractTxObject: ({ contractAddress, abi, funcName, funcParams, txOverrides }: import("..").CallParams) => Promise<{
|
|
56
|
+
value: string;
|
|
57
|
+
to: string;
|
|
58
|
+
data: string;
|
|
59
|
+
from?: string;
|
|
60
|
+
type?: number;
|
|
61
|
+
nonce?: number;
|
|
62
|
+
gasLimit?: bigint;
|
|
63
|
+
gasPrice?: bigint;
|
|
64
|
+
maxPriorityFeePerGas?: bigint;
|
|
65
|
+
maxFeePerGas?: bigint;
|
|
66
|
+
chainId?: bigint;
|
|
67
|
+
accessList?: import("ethers").AccessList;
|
|
68
|
+
authorizationList?: Array<Authorization>;
|
|
69
|
+
customData?: any;
|
|
70
|
+
blockTag?: import("ethers").BlockTag;
|
|
71
|
+
enableCcipRead?: boolean;
|
|
72
|
+
}>;
|
|
73
|
+
createTransaction: ({ assetValue, memo, recipient, data, sender: fromOverride, maxFeePerGas, maxPriorityFeePerGas, gasPrice, ...tx }: import("..").EVMCreateTransactionParams) => Promise<{
|
|
74
|
+
value: string;
|
|
75
|
+
to: string;
|
|
76
|
+
data: string;
|
|
77
|
+
from?: string;
|
|
78
|
+
type?: number;
|
|
79
|
+
nonce?: number;
|
|
80
|
+
gasLimit?: bigint;
|
|
81
|
+
gasPrice?: bigint;
|
|
82
|
+
maxPriorityFeePerGas?: bigint;
|
|
83
|
+
maxFeePerGas?: bigint;
|
|
84
|
+
chainId?: bigint;
|
|
85
|
+
accessList?: import("ethers").AccessList;
|
|
86
|
+
authorizationList?: Array<Authorization>;
|
|
87
|
+
customData?: any;
|
|
88
|
+
blockTag?: import("ethers").BlockTag;
|
|
89
|
+
enableCcipRead?: boolean;
|
|
90
|
+
}>;
|
|
91
|
+
createTransferTx: ({ assetValue, memo, recipient, data, sender: fromOverride, maxFeePerGas, maxPriorityFeePerGas, gasPrice, ...tx }: import("..").EVMCreateTransactionParams) => Promise<{
|
|
92
|
+
value: string;
|
|
93
|
+
to: string;
|
|
94
|
+
data: string;
|
|
95
|
+
from?: string;
|
|
96
|
+
type?: number;
|
|
97
|
+
nonce?: number;
|
|
98
|
+
gasLimit?: bigint;
|
|
99
|
+
gasPrice?: bigint;
|
|
100
|
+
maxPriorityFeePerGas?: bigint;
|
|
101
|
+
maxFeePerGas?: bigint;
|
|
102
|
+
chainId?: bigint;
|
|
103
|
+
accessList?: import("ethers").AccessList;
|
|
104
|
+
authorizationList?: Array<Authorization>;
|
|
105
|
+
customData?: any;
|
|
106
|
+
blockTag?: import("ethers").BlockTag;
|
|
107
|
+
enableCcipRead?: boolean;
|
|
108
|
+
}>;
|
|
41
109
|
EIP1193SendTransaction: ({ value, ...params }: import("..").EVMTxParams | import("ethers").ContractTransaction) => Promise<string>;
|
|
42
110
|
estimateCall: ({ contractAddress, abi, funcName, funcParams, txOverrides }: import("..").EstimateCallParams) => Promise<bigint>;
|
|
43
111
|
estimateGasLimit: ({ assetValue, recipient, memo, data, sender, funcName, funcParams, txOverrides, }: import("..").EVMTransferParams & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AssetValue, ChainSigner, DerivationPathArray, FeeOption, GenericCreateTransactionParams, GenericTransferParams } from "@swapkit/helpers";
|
|
2
2
|
import { Chain } from "@swapkit/helpers";
|
|
3
|
-
import type { BigNumberish, BrowserProvider, JsonFragment, JsonRpcSigner, Provider, Signer,
|
|
3
|
+
import type { BigNumberish, BrowserProvider, JsonFragment, JsonRpcSigner, Provider, Signer, TransactionRequest, TypedDataField } from "ethers";
|
|
4
4
|
import type { getProvider } from "./index";
|
|
5
5
|
import type { ADIToolbox, ARBToolbox, AURORAToolbox, AVAXToolbox, BASEToolbox, BERAToolbox, BSCToolbox, COREToolbox, CORNToolbox, CROToolbox, ETHToolbox, GNOToolbox, HYPEREVMToolbox, LINEAToolbox, MATICToolbox, MEGAETHToolbox, MONADToolbox, OPToolbox, PLASMAToolbox, SONICToolbox, UNIToolbox, XLayerToolbox } from "./toolbox";
|
|
6
6
|
export declare enum EthNetwork {
|
|
@@ -30,7 +30,7 @@ export type CallParams = {
|
|
|
30
30
|
abi: readonly JsonFragment[];
|
|
31
31
|
funcName: string;
|
|
32
32
|
funcParams?: unknown[];
|
|
33
|
-
txOverrides?:
|
|
33
|
+
txOverrides?: TransactionRequest;
|
|
34
34
|
feeOption?: FeeOption;
|
|
35
35
|
};
|
|
36
36
|
export type EstimateCallParams = Pick<CallParams, "contractAddress" | "abi" | "funcName" | "funcParams" | "txOverrides">;
|
|
@@ -54,9 +54,9 @@ export type EVMMaxSendableAmountsParams = {
|
|
|
54
54
|
funcName?: string;
|
|
55
55
|
contractAddress?: string;
|
|
56
56
|
funcParams?: unknown[];
|
|
57
|
-
txOverrides?:
|
|
57
|
+
txOverrides?: TransactionRequest;
|
|
58
58
|
};
|
|
59
|
-
export type EVMTxBaseParams<T =
|
|
59
|
+
export type EVMTxBaseParams<T = BigNumberish> = {
|
|
60
60
|
to?: string;
|
|
61
61
|
from?: string;
|
|
62
62
|
nonce?: number;
|
|
@@ -65,12 +65,12 @@ export type EVMTxBaseParams<T = bigint> = {
|
|
|
65
65
|
value?: T;
|
|
66
66
|
chainId?: T;
|
|
67
67
|
};
|
|
68
|
-
export type EIP1559TxParams<T =
|
|
68
|
+
export type EIP1559TxParams<T = BigNumberish> = EVMTxBaseParams<T> & {
|
|
69
69
|
type?: number;
|
|
70
70
|
maxFeePerGas?: T;
|
|
71
71
|
maxPriorityFeePerGas?: T;
|
|
72
72
|
};
|
|
73
|
-
export type LegacyEVMTxParams<T =
|
|
73
|
+
export type LegacyEVMTxParams<T = BigNumberish> = EVMTxBaseParams<T> & {
|
|
74
74
|
gasPrice?: T;
|
|
75
75
|
};
|
|
76
76
|
export type { Authorization, TypedDataDomain, TypedDataField } from "ethers";
|
|
@@ -86,7 +86,7 @@ export interface EIP712TypedData {
|
|
|
86
86
|
primaryType: string;
|
|
87
87
|
types: Record<string, TypedDataField[]>;
|
|
88
88
|
}
|
|
89
|
-
export type EIP7702TxParams<T =
|
|
89
|
+
export type EIP7702TxParams<T = BigNumberish> = EIP1559TxParams<T> & {
|
|
90
90
|
type?: 4;
|
|
91
91
|
authorizations?: import("ethers").Authorization[];
|
|
92
92
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AssetValue, type GenericTransferParams } from "@swapkit/helpers";
|
|
2
2
|
import { Address, Cell } from "@ton/core";
|
|
3
|
-
import type { TONToolboxParams,
|
|
3
|
+
import type { TONToolboxParams, TONToolboxTransaction, TONTransactionInput } from "./types";
|
|
4
4
|
export declare function getTONToolbox(toolboxParams?: TONToolboxParams): {
|
|
5
5
|
broadcastTransaction: (transferCell: Cell) => Promise<string>;
|
|
6
|
-
createTransaction: ({ sender, ...params }: GenericTransferParams & {
|
|
6
|
+
createTransaction: ({ sender, sweep, ...params }: GenericTransferParams & {
|
|
7
7
|
sender?: string;
|
|
8
8
|
sweep?: boolean;
|
|
9
|
-
}) => Promise<
|
|
9
|
+
}) => Promise<TONToolboxTransaction>;
|
|
10
10
|
estimateTransactionFee: ({ sender, ...params }: GenericTransferParams & {
|
|
11
11
|
sender?: string;
|
|
12
12
|
}) => Promise<AssetValue>;
|
|
@@ -16,8 +16,8 @@ export declare function getTONToolbox(toolboxParams?: TONToolboxParams): {
|
|
|
16
16
|
jettonMasterAddress: string;
|
|
17
17
|
ownerAddress: string;
|
|
18
18
|
}) => Promise<Address>;
|
|
19
|
-
sign: (
|
|
20
|
-
signAndBroadcastTransaction: (
|
|
19
|
+
sign: (transactionInput: TONTransactionInput) => Promise<Cell>;
|
|
20
|
+
signAndBroadcastTransaction: (transaction: TONTransactionInput) => Promise<string>;
|
|
21
21
|
transfer: ({ assetValue, recipient, memo, sweep }: GenericTransferParams & {
|
|
22
22
|
sweep?: boolean;
|
|
23
23
|
}) => Promise<string>;
|
|
@@ -20,4 +20,9 @@ export type TONTransactionMessage = {
|
|
|
20
20
|
stateInit?: string;
|
|
21
21
|
sendMode?: number;
|
|
22
22
|
};
|
|
23
|
+
export type TONToolboxTransaction = {
|
|
24
|
+
messages: TONTransactionMessage[];
|
|
25
|
+
sendMode: number;
|
|
26
|
+
};
|
|
27
|
+
export type TONTransactionInput = TONToolboxTransaction | TONTransactionMessage[];
|
|
23
28
|
export type TONWallet = ReturnType<typeof getTONToolbox>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getTronPrivateKeyFromMnemonic, getTronToolbox, validateTronAddress, } from "./toolbox";
|
|
2
|
-
export type { TronApprovedParams, TronApproveParams, TronCreateTransactionParams, TronIsApprovedParams, TronSignedTransaction, TronSigner, TronToolboxOptions, TronTransaction, TronTransferParams, } from "./types";
|
|
1
|
+
export { getTronPrivateKeyFromMnemonic, getTronToolbox, validateTronAddress, withTronTransactionData, withTronTransactionValue, } from "./toolbox";
|
|
2
|
+
export type { TronApprovedParams, TronApproveParams, TronCreateTransactionParams, TronIsApprovedParams, TronSignedTransaction, TronSigner, TronToolboxOptions, TronTransaction, TronTransactionMetadata, TronTransactionWithMetadata, TronTransferParams, } from "./types";
|
|
3
3
|
import type { getTronToolbox } from "./toolbox";
|
|
4
4
|
export type TronWallet = ReturnType<typeof getTronToolbox>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AssetValue } from "@swapkit/helpers";
|
|
2
2
|
import { broadcastTronTransaction } from "./helpers/trongrid";
|
|
3
3
|
import { isValidTronAddress } from "./helpers/utils";
|
|
4
|
-
import type { TronApprovedParams, TronApproveParams, TronCreateTransactionParams, TronIsApprovedParams, TronToolboxOptions, TronTransaction, TronTransferParams } from "./types";
|
|
4
|
+
import type { TronApprovedParams, TronApproveParams, TronCreateTransactionParams, TronIsApprovedParams, TronToolboxOptions, TronTransaction, TronTransactionWithMetadata, TronTransferParams } from "./types";
|
|
5
5
|
export declare const validateTronAddress: typeof isValidTronAddress;
|
|
6
|
+
export declare function withTronTransactionValue<TTransaction extends TronTransaction>(transaction: TTransaction, value: string | number | bigint): TTransaction & Required<Pick<TronTransactionWithMetadata, "value">>;
|
|
7
|
+
export declare function withTronTransactionData<TTransaction extends TronTransaction>(transaction: TTransaction, data?: string): TTransaction & Pick<TronTransactionWithMetadata, "data">;
|
|
6
8
|
export declare function getTronPrivateKeyFromMnemonic({ phrase, derivationPath: customPath, index, }: {
|
|
7
9
|
phrase: string;
|
|
8
10
|
derivationPath?: string;
|
|
@@ -24,6 +24,11 @@ export interface TronTransaction {
|
|
|
24
24
|
contractRet?: string;
|
|
25
25
|
}>;
|
|
26
26
|
}
|
|
27
|
+
export type TronTransactionMetadata = {
|
|
28
|
+
data?: string;
|
|
29
|
+
value?: string;
|
|
30
|
+
};
|
|
31
|
+
export type TronTransactionWithMetadata = TronTransaction & TronTransactionMetadata;
|
|
27
32
|
export interface TronSignedTransaction extends TronTransaction {
|
|
28
33
|
signature: string[];
|
|
29
34
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"dependencies": { "@swapkit/helpers": "4.15.
|
|
2
|
+
"dependencies": { "@swapkit/helpers": "4.15.3", "@swapkit/utxo-signer": "2.2.2" },
|
|
3
3
|
"description": "SwapKit - Toolboxes",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@aptos-labs/ts-sdk": "7.0.1",
|
|
@@ -198,5 +198,5 @@
|
|
|
198
198
|
"type-check:go": "tsgo"
|
|
199
199
|
},
|
|
200
200
|
"type": "module",
|
|
201
|
-
"version": "4.20.
|
|
201
|
+
"version": "4.20.1"
|
|
202
202
|
}
|
package/dist/chunk-4q573g5z.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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};
|