@swapkit/toolboxes 1.0.0-beta.0 → 1.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/chunk-0f0249b1.js +3 -0
  2. package/dist/chunk-0f0249b1.js.map +10 -0
  3. package/dist/chunk-0h4xdrwz.js +4 -0
  4. package/dist/chunk-0h4xdrwz.js.map +10 -0
  5. package/dist/chunk-4yap1fvd.js +3 -0
  6. package/dist/chunk-4yap1fvd.js.map +10 -0
  7. package/dist/chunk-fjfxga2v.js +3 -0
  8. package/dist/chunk-fjfxga2v.js.map +10 -0
  9. package/dist/{chunk-tvrdndbw.js → chunk-p1kdg37m.js} +2 -2
  10. package/dist/{chunk-tvrdndbw.js.map → chunk-p1kdg37m.js.map} +1 -1
  11. package/dist/cosmos/index.cjs +2 -2
  12. package/dist/cosmos/index.cjs.map +10 -13
  13. package/dist/cosmos/index.js +2 -2
  14. package/dist/cosmos/index.js.map +10 -13
  15. package/dist/evm/index.cjs +2 -2
  16. package/dist/evm/index.cjs.map +10 -16
  17. package/dist/evm/index.js +2 -2
  18. package/dist/evm/index.js.map +10 -16
  19. package/dist/index.cjs +2 -2
  20. package/dist/index.cjs.map +4 -3
  21. package/dist/index.js +2 -2
  22. package/dist/index.js.map +4 -3
  23. package/dist/radix/index.cjs +2 -2
  24. package/dist/radix/index.cjs.map +3 -3
  25. package/dist/radix/index.js +2 -2
  26. package/dist/radix/index.js.map +3 -3
  27. package/dist/ripple/index.cjs +3 -0
  28. package/dist/ripple/index.cjs.map +10 -0
  29. package/dist/ripple/index.js +3 -0
  30. package/dist/ripple/index.js.map +10 -0
  31. package/dist/solana/index.cjs +2 -2
  32. package/dist/solana/index.cjs.map +3 -3
  33. package/dist/solana/index.js +2 -2
  34. package/dist/solana/index.js.map +3 -3
  35. package/dist/substrate/index.cjs +2 -2
  36. package/dist/substrate/index.cjs.map +5 -6
  37. package/dist/substrate/index.js +2 -2
  38. package/dist/substrate/index.js.map +5 -6
  39. package/dist/utxo/index.cjs +2 -2
  40. package/dist/utxo/index.cjs.map +9 -11
  41. package/dist/utxo/index.js +2 -2
  42. package/dist/utxo/index.js.map +9 -11
  43. package/package.json +27 -23
  44. package/src/cosmos/index.ts +2 -9
  45. package/src/cosmos/thorchainUtils/addressFormat.ts +1 -2
  46. package/src/cosmos/thorchainUtils/index.ts +1 -1
  47. package/src/cosmos/thorchainUtils/messages.ts +74 -56
  48. package/src/cosmos/thorchainUtils/registry.ts +19 -26
  49. package/src/cosmos/thorchainUtils/types/{proto/MsgCompiled.ts → MsgCompiled.ts} +1 -3
  50. package/src/cosmos/thorchainUtils/types/client-types.ts +16 -23
  51. package/src/cosmos/toolbox/cosmos.ts +334 -0
  52. package/src/cosmos/toolbox/index.ts +33 -0
  53. package/src/cosmos/toolbox/thorchain.ts +125 -137
  54. package/src/cosmos/types.ts +37 -18
  55. package/src/cosmos/util.ts +24 -74
  56. package/src/evm/__tests__/ethereum.test.ts +110 -116
  57. package/src/evm/api.ts +11 -147
  58. package/src/evm/helpers.ts +111 -83
  59. package/src/evm/index.ts +1 -17
  60. package/src/evm/toolbox/baseEVMToolbox.ts +744 -0
  61. package/src/evm/toolbox/evm.ts +69 -0
  62. package/src/evm/toolbox/index.ts +36 -0
  63. package/src/evm/toolbox/op.ts +97 -143
  64. package/src/evm/types.ts +50 -28
  65. package/src/index.ts +235 -0
  66. package/src/radix/index.ts +18 -19
  67. package/src/ripple/index.ts +199 -0
  68. package/src/solana/index.ts +11 -5
  69. package/src/solana/toolbox.ts +227 -137
  70. package/src/substrate/index.ts +2 -3
  71. package/src/substrate/{toolbox/baseSubstrateToolbox.ts → substrate.ts} +104 -72
  72. package/src/substrate/types.ts +120 -0
  73. package/src/utils.ts +27 -0
  74. package/src/utxo/helpers/api.ts +27 -23
  75. package/src/utxo/helpers/bchaddrjs.ts +21 -21
  76. package/src/utxo/helpers/index.ts +0 -1
  77. package/src/utxo/helpers/txSize.ts +3 -4
  78. package/src/utxo/index.ts +3 -7
  79. package/src/utxo/toolbox/bitcoinCash.ts +165 -155
  80. package/src/utxo/toolbox/index.ts +63 -24
  81. package/src/utxo/toolbox/utxo.ts +376 -229
  82. package/src/utxo/types.ts +26 -39
  83. package/src/cosmos/thorchainUtils/types/proto/MsgCompiled.js +0 -2806
  84. package/src/cosmos/thorchainUtils/util.ts +0 -46
  85. package/src/cosmos/toolbox/BaseCosmosToolbox.ts +0 -254
  86. package/src/cosmos/toolbox/gaia.ts +0 -39
  87. package/src/cosmos/toolbox/getToolboxByChain.ts +0 -29
  88. package/src/cosmos/toolbox/kujira.ts +0 -61
  89. package/src/evm/provider.ts +0 -6
  90. package/src/evm/toolbox/EVMToolbox.ts +0 -662
  91. package/src/evm/toolbox/arb.ts +0 -61
  92. package/src/evm/toolbox/avax.ts +0 -36
  93. package/src/evm/toolbox/base.ts +0 -42
  94. package/src/evm/toolbox/bsc.ts +0 -34
  95. package/src/evm/toolbox/eth.ts +0 -44
  96. package/src/evm/toolbox/getToolboxByChain.ts +0 -42
  97. package/src/evm/toolbox/matic.ts +0 -42
  98. package/src/radix/toolbox.ts +0 -693
  99. package/src/substrate/toolbox/index.ts +0 -40
  100. package/src/substrate/types/index.ts +0 -2
  101. package/src/substrate/types/network.ts +0 -42
  102. package/src/substrate/types/wallet.ts +0 -78
  103. package/src/utxo/helpers/utils.ts +0 -45
@@ -0,0 +1,69 @@
1
+ import { Chain, type EVMChain, FeeOption, SKConfig } from "@swapkit/helpers";
2
+ import { HDNodeWallet } from "ethers";
3
+ import { P, match } from "ts-pattern";
4
+ import { getEvmApi } from "../api";
5
+ import { multicallAbi } from "../contracts/eth/multicall";
6
+ import {
7
+ getEstimateTransactionFee,
8
+ getIsEIP1559Compatible,
9
+ getNetworkParams,
10
+ getProvider,
11
+ } from "../helpers";
12
+ import type { EVMToolboxParams } from "../types";
13
+ import { BaseEVMToolbox } from "./baseEVMToolbox";
14
+
15
+ export async function ETHToolbox({ provider, ...signer }: EVMToolboxParams) {
16
+ const evmToolbox = await createEvmToolbox(Chain.Ethereum)({
17
+ provider,
18
+ ...signer,
19
+ });
20
+ async function multicall(
21
+ callTuples: { address: string; data: string }[],
22
+ multicallAddress = "0x5ba1e12693dc8f9c48aad8770482f4739beed696",
23
+ funcName = "aggregate",
24
+ feeOptionKey: FeeOption = FeeOption.Fast,
25
+ ) {
26
+ const txObject = await evmToolbox.createContractTxObject({
27
+ contractAddress: multicallAddress,
28
+ abi: multicallAbi,
29
+ funcName,
30
+ funcParams: [callTuples],
31
+ });
32
+
33
+ return evmToolbox.sendTransaction({ ...txObject, feeOptionKey });
34
+ }
35
+
36
+ return { ...evmToolbox, multicall };
37
+ }
38
+
39
+ export const ARBToolbox = createEvmToolbox(Chain.Arbitrum);
40
+ export const AVAXToolbox = createEvmToolbox(Chain.Avalanche);
41
+ export const BASEToolbox = createEvmToolbox(Chain.Base);
42
+ export const BSCToolbox = createEvmToolbox(Chain.BinanceSmartChain);
43
+ export const MATICToolbox = createEvmToolbox(Chain.Polygon);
44
+
45
+ function createEvmToolbox<C extends EVMChain>(chain: C) {
46
+ return async function createEvmToolbox({
47
+ provider: providerParam,
48
+ ...toolboxSignerParams
49
+ }: EVMToolboxParams) {
50
+ const rpcUrl = SKConfig.get("rpcUrls")[chain];
51
+
52
+ const provider = providerParam || (await getProvider(chain, rpcUrl));
53
+
54
+ const isEIP1559Compatible = getIsEIP1559Compatible(chain);
55
+ const signer = match(toolboxSignerParams)
56
+ .with({ phrase: P.string }, ({ phrase }) => HDNodeWallet.fromPhrase(phrase).connect(provider))
57
+ .with({ signer: P.any }, ({ signer }) => signer)
58
+ .otherwise(() => undefined);
59
+
60
+ const evmToolbox = BaseEVMToolbox({ provider, signer, isEIP1559Compatible, chain });
61
+
62
+ return {
63
+ ...evmToolbox,
64
+ estimateTransactionFee: getEstimateTransactionFee({ provider, isEIP1559Compatible, chain }),
65
+ getNetworkParams: getNetworkParams(chain),
66
+ getBalance: getEvmApi(chain).getBalance,
67
+ };
68
+ };
69
+ }
@@ -0,0 +1,36 @@
1
+ import { Chain, type EVMChain } from "@swapkit/helpers";
2
+
3
+ import { getProvider } from "../helpers";
4
+ import type { EVMToolboxParams } from "../types";
5
+ import { ARBToolbox, AVAXToolbox, BASEToolbox, BSCToolbox, ETHToolbox, MATICToolbox } from "./evm";
6
+ import { OPToolbox } from "./op";
7
+
8
+ export async function getEvmToolbox<T extends EVMChain>(chain: T, params?: EVMToolboxParams) {
9
+ const toolboxParams = {
10
+ ...params,
11
+ provider: params?.provider || (await getProvider(chain)),
12
+ };
13
+
14
+ switch (chain) {
15
+ case Chain.Avalanche:
16
+ return AVAXToolbox(toolboxParams);
17
+ case Chain.Arbitrum:
18
+ return ARBToolbox(toolboxParams);
19
+ case Chain.Base:
20
+ return BASEToolbox(toolboxParams);
21
+ case Chain.Optimism:
22
+ return OPToolbox(toolboxParams);
23
+ case Chain.Polygon:
24
+ return MATICToolbox(toolboxParams);
25
+ case Chain.BinanceSmartChain:
26
+ return BSCToolbox(toolboxParams);
27
+ case Chain.Ethereum:
28
+ return ETHToolbox(toolboxParams);
29
+ default:
30
+ throw new Error(`Chain ${chain} is not supported`);
31
+ }
32
+ }
33
+
34
+ export * from "./baseEVMToolbox";
35
+ export * from "./evm";
36
+ export * from "./op";
@@ -1,92 +1,85 @@
1
- import {
2
- BaseDecimal,
3
- Chain,
4
- ChainId,
5
- ChainToExplorerUrl,
6
- FeeOption,
7
- SKConfig,
8
- } from "@swapkit/helpers";
9
- import type { BrowserProvider, JsonRpcProvider, Signer, TransactionRequest } from "ethers";
10
- import { Contract, Transaction } from "ethers";
1
+ import { BaseDecimal, Chain, ChainId, ChainToExplorerUrl, SKConfig } from "@swapkit/helpers";
2
+ import type { BrowserProvider, JsonRpcProvider, Provider, TransactionRequest } from "ethers";
3
+ import { Contract, HDNodeWallet } from "ethers";
11
4
 
5
+ import { P } from "ts-pattern";
6
+ import { match } from "ts-pattern";
7
+ import { getEvmApi } from "../api";
12
8
  import { gasOracleAbi } from "../contracts/op/gasOracle";
13
- import { getBalance } from "../index";
14
-
15
- import { EVMToolbox } from "./EVMToolbox";
9
+ import { getProvider } from "../helpers";
10
+ import type { EVMToolboxParams } from "../types";
11
+ import { BaseEVMToolbox } from "./baseEVMToolbox";
16
12
 
17
13
  const GAS_PRICE_ORACLE_ADDRESS = "0x420000000000000000000000000000000000000f";
18
14
 
19
- export const connectGasPriceOracle = (provider: JsonRpcProvider | BrowserProvider) => {
15
+ function connectGasPriceOracle<P extends Provider>(provider: P) {
20
16
  return new Contract(GAS_PRICE_ORACLE_ADDRESS, gasOracleAbi, provider);
21
- };
22
-
23
- export const getL1GasPrice = (provider: JsonRpcProvider | BrowserProvider) => {
24
- const gasPriceOracle = connectGasPriceOracle(provider);
25
-
26
- if (gasPriceOracle && "l1BaseFee" in gasPriceOracle) {
27
- return gasPriceOracle?.l1BaseFee() as unknown as bigint;
28
- }
29
-
30
- return undefined;
31
- };
32
-
33
- const _serializeTx = async (
34
- provider: JsonRpcProvider | BrowserProvider,
35
- { data, from, to, gasPrice, type, gasLimit, nonce }: TransactionRequest,
36
- ) => {
37
- if (!to) throw new Error("Missing to address");
38
-
39
- return Transaction.from({
40
- data,
41
- to: to as string,
42
- gasPrice,
43
- type,
44
- gasLimit,
45
- nonce: nonce ? nonce : from ? await provider.getTransactionCount(from) : 0,
46
- }).serialized;
47
- };
48
-
49
- export const estimateL1GasCost = async (
50
- provider: JsonRpcProvider | BrowserProvider,
51
- tx: TransactionRequest,
52
- ) => {
53
- const gasPriceOracle = await connectGasPriceOracle(provider);
54
- const serializedTx = await _serializeTx(provider, tx);
55
-
56
- if (gasPriceOracle && "getL1Fee" in gasPriceOracle) {
57
- return gasPriceOracle.getL1Fee(serializedTx);
58
- }
59
- };
60
-
61
- export const estimateL2GasCost = async (
62
- provider: JsonRpcProvider | BrowserProvider,
63
- tx: TransactionRequest,
64
- ) => {
65
- const l2GasPrice = await provider.send("eth_gasPrice", []);
66
- const l2GasCost = await provider.estimateGas(tx);
67
- return l2GasPrice.mul(l2GasCost);
68
- };
69
-
70
- export const estimateTotalGasCost = async (
71
- provider: JsonRpcProvider | BrowserProvider,
72
- tx: TransactionRequest,
73
- ) => {
74
- const l1GasCost = await estimateL1GasCost(provider, tx);
75
- const l2GasCost = await estimateL2GasCost(provider, tx);
76
- return l1GasCost.add(l2GasCost);
77
- };
78
-
79
- export const estimateL1Gas = async (
80
- provider: JsonRpcProvider | BrowserProvider,
81
- tx: TransactionRequest,
82
- ) => {
83
- const gasPriceOracle = connectGasPriceOracle(provider);
84
- const serializedTx = await _serializeTx(provider, tx);
85
-
86
- if (gasPriceOracle && "getL1GasUsed" in gasPriceOracle) {
87
- return gasPriceOracle.getL1GasUsed(serializedTx);
88
- }
89
- };
17
+ }
18
+
19
+ export function getL1GasPriceFetcher<P extends Provider>(provider: P) {
20
+ return function getL1GasPrice() {
21
+ const gasPriceOracle = connectGasPriceOracle(provider);
22
+
23
+ if (gasPriceOracle && "l1BaseFee" in gasPriceOracle) {
24
+ return gasPriceOracle?.l1BaseFee() as unknown as bigint;
25
+ }
26
+
27
+ return undefined;
28
+ };
29
+ }
30
+
31
+ function serializeTx<P extends JsonRpcProvider | BrowserProvider>(provider: P) {
32
+ return async function serializeTx({ from, to, nonce, ...tx }: TransactionRequest) {
33
+ const { Transaction } = await import("ethers");
34
+
35
+ if (!to) throw new Error("Missing to address");
36
+ const txParams = {
37
+ ...tx,
38
+ to: to as string,
39
+ nonce: nonce ? nonce : from ? await provider.getTransactionCount(from) : 0,
40
+ };
41
+
42
+ return Transaction.from(txParams).serialized;
43
+ };
44
+ }
45
+
46
+ function estimateL1GasCost<P extends JsonRpcProvider | BrowserProvider>(provider: P) {
47
+ return async function estimateL1GasCost(tx: TransactionRequest) {
48
+ const gasPriceOracle = connectGasPriceOracle(provider);
49
+ const serializedTx = await serializeTx(provider)(tx);
50
+
51
+ if (gasPriceOracle && "getL1Fee" in gasPriceOracle) {
52
+ return gasPriceOracle.getL1Fee(serializedTx);
53
+ }
54
+ };
55
+ }
56
+
57
+ function estimateL2GasCost<P extends JsonRpcProvider | BrowserProvider>(provider: P) {
58
+ return async function estimateL2GasCost(tx: TransactionRequest) {
59
+ const l2GasPrice = await provider.send("eth_gasPrice", []);
60
+ const l2GasCost = await provider.estimateGas(tx);
61
+ return l2GasPrice.mul(l2GasCost);
62
+ };
63
+ }
64
+
65
+ function estimateTotalGasCost<P extends JsonRpcProvider | BrowserProvider>(provider: P) {
66
+ return async function estimateTotalGasCost(tx: TransactionRequest) {
67
+ const l1GasCost = await estimateL1GasCost(provider)(tx);
68
+ const l2GasCost = await estimateL2GasCost(provider)(tx);
69
+ return l1GasCost.add(l2GasCost);
70
+ };
71
+ }
72
+
73
+ export function estimateL1Gas<P extends JsonRpcProvider | BrowserProvider>(provider: P) {
74
+ return async function estimateL1Gas(tx: TransactionRequest) {
75
+ const gasPriceOracle = connectGasPriceOracle(provider);
76
+ const serializedTx = await serializeTx(provider)(tx);
77
+
78
+ if (gasPriceOracle && "getL1GasUsed" in gasPriceOracle) {
79
+ return gasPriceOracle.getL1GasUsed(serializedTx);
80
+ }
81
+ };
82
+ }
90
83
 
91
84
  const getNetworkParams = () => ({
92
85
  chainId: ChainId.OptimismHex,
@@ -96,68 +89,29 @@ const getNetworkParams = () => ({
96
89
  blockExplorerUrls: [ChainToExplorerUrl[Chain.Optimism]],
97
90
  });
98
91
 
99
- const estimateGasPrices = async (provider: JsonRpcProvider | BrowserProvider) => {
100
- try {
101
- const { maxFeePerGas, maxPriorityFeePerGas, gasPrice } = await provider.getFeeData();
102
- const l1GasPrice = await getL1GasPrice(provider);
103
- const price = gasPrice as bigint;
104
-
105
- if (!(maxFeePerGas && maxPriorityFeePerGas)) {
106
- throw new Error("No fee data available");
107
- }
108
-
109
- return {
110
- [FeeOption.Average]: {
111
- l1GasPrice,
112
- gasPrice,
113
- maxFeePerGas,
114
- maxPriorityFeePerGas,
115
- },
116
- [FeeOption.Fast]: {
117
- l1GasPrice: ((l1GasPrice || 0n) * 15n) / 10n,
118
- gasPrice: (price * 15n) / 10n,
119
- maxFeePerGas,
120
- maxPriorityFeePerGas: (maxPriorityFeePerGas * 15n) / 10n,
121
- },
122
- [FeeOption.Fastest]: {
123
- l1GasPrice: (l1GasPrice || 0n) * 2n,
124
- gasPrice: price * 2n,
125
- maxFeePerGas,
126
- maxPriorityFeePerGas: maxPriorityFeePerGas * 2n,
127
- },
128
- };
129
- } catch (error) {
130
- throw new Error(
131
- `Failed to estimate gas price: ${(error as any).msg ?? (error as any).toString()}`,
132
- );
133
- }
134
- };
135
-
136
- export const OPToolbox = ({
137
- provider,
138
- signer,
139
- }: { signer?: Signer; provider: JsonRpcProvider | BrowserProvider }) => {
140
- const evmToolbox = EVMToolbox({ provider, signer });
92
+ export async function OPToolbox({
93
+ provider: providerParam,
94
+ ...toolboxSignerParams
95
+ }: EVMToolboxParams) {
96
+ const chain = Chain.Optimism;
97
+ const rpcUrl = SKConfig.get("rpcUrls")[chain];
98
+ const provider = providerParam || (await getProvider(chain, rpcUrl));
99
+ const signer = match(toolboxSignerParams)
100
+ .with({ phrase: P.string }, ({ phrase }) => HDNodeWallet.fromPhrase(phrase).connect(provider))
101
+ .with({ signer: P.any }, ({ signer }) => signer)
102
+ .otherwise(() => undefined);
103
+
104
+ const evmToolbox = BaseEVMToolbox({ provider, signer });
105
+ const getL1GasPrice = getL1GasPriceFetcher(provider);
141
106
 
142
107
  return {
143
108
  ...evmToolbox,
144
- estimateTotalGasCost: (tx: TransactionRequest) => estimateTotalGasCost(provider, tx),
145
- estimateL1GasCost: (tx: TransactionRequest) => estimateL1GasCost(provider, tx),
146
- estimateL2GasCost: (tx: TransactionRequest) => estimateL2GasCost(provider, tx),
147
- getL1GasPrice: () => getL1GasPrice(provider),
148
- estimateL1Gas: (tx: TransactionRequest) => estimateL1Gas(provider, tx),
109
+ estimateL1Gas: estimateL1Gas(provider),
110
+ estimateL1GasCost: estimateL1GasCost(provider),
111
+ estimateL2GasCost: estimateL2GasCost(provider),
112
+ estimateTotalGasCost: estimateTotalGasCost(provider),
113
+ getBalance: getEvmApi(Chain.Optimism).getBalance,
114
+ getL1GasPrice,
149
115
  getNetworkParams,
150
- estimateGasPrices: () => estimateGasPrices(provider),
151
- getBalance: (
152
- address: string,
153
- potentialScamFilter = true,
154
- overwriteProvider?: JsonRpcProvider | BrowserProvider,
155
- ) =>
156
- getBalance({
157
- provider: overwriteProvider || provider,
158
- address,
159
- chain: Chain.Optimism,
160
- potentialScamFilter,
161
- }),
162
116
  };
163
- };
117
+ }
package/src/evm/types.ts CHANGED
@@ -1,6 +1,21 @@
1
- import type { AssetValue, FeeOption, WalletTxParams } from "@swapkit/helpers";
2
- import type { BigNumberish, JsonFragment, Transaction } from "ethers";
3
-
1
+ import type {
2
+ AssetValue,
3
+ ChainSigner,
4
+ DerivationPathArray,
5
+ FeeOption,
6
+ GenericCreateTransactionParams,
7
+ GenericTransferParams,
8
+ } from "@swapkit/helpers";
9
+ import { Chain } from "@swapkit/helpers";
10
+ import type {
11
+ BigNumberish,
12
+ BrowserProvider,
13
+ JsonFragment,
14
+ JsonRpcProvider,
15
+ JsonRpcSigner,
16
+ Signer,
17
+ Transaction,
18
+ } from "ethers";
4
19
  import type {
5
20
  ARBToolbox,
6
21
  AVAXToolbox,
@@ -9,8 +24,9 @@ import type {
9
24
  ETHToolbox,
10
25
  MATICToolbox,
11
26
  OPToolbox,
12
- } from "./index";
13
- import type { getProvider } from "./provider";
27
+ } from "./toolbox";
28
+
29
+ import type { getProvider } from "./index";
14
30
 
15
31
  export enum EthNetwork {
16
32
  Test = "goerli",
@@ -22,7 +38,7 @@ export type ApproveParams = {
22
38
  spenderAddress: string;
23
39
  feeOptionKey?: FeeOption;
24
40
  amount?: BigNumberish;
25
- from: string;
41
+ from?: string;
26
42
  // Optional fallback in case estimation for gas limit fails
27
43
  gasLimitFallback?: BigNumberish;
28
44
  nonce?: number;
@@ -39,7 +55,7 @@ export type IsApprovedParams = ApprovedParams & {
39
55
  };
40
56
 
41
57
  export type CallParams = {
42
- callProvider?: ReturnType<typeof getProvider>;
58
+ callProvider?: Awaited<ReturnType<typeof getProvider>>;
43
59
  contractAddress: string;
44
60
  abi: readonly JsonFragment[];
45
61
  funcName: string;
@@ -53,30 +69,21 @@ export type EstimateCallParams = Pick<
53
69
  "contractAddress" | "abi" | "funcName" | "funcParams" | "txOverrides"
54
70
  >;
55
71
 
56
- export type TransferParams = WalletTxParams & {
72
+ export type EVMTransferParams = GenericTransferParams & {
73
+ sender?: string;
74
+ };
75
+
76
+ export type EVMCreateTransactionParams = Omit<GenericCreateTransactionParams, "feeRate"> & {
57
77
  gasLimit?: bigint;
58
78
  gasPrice?: bigint;
59
79
  maxFeePerGas?: bigint;
60
80
  maxPriorityFeePerGas?: bigint;
61
81
  data?: string;
62
- from: string;
63
82
  nonce?: number;
64
- assetValue: AssetValue;
65
83
  };
66
84
 
67
- export type EVMToolboxType = ReturnType<
68
- | typeof ARBToolbox
69
- | typeof AVAXToolbox
70
- | typeof BASEToolbox
71
- | typeof BSCToolbox
72
- | typeof ETHToolbox
73
- | typeof MATICToolbox
74
- | typeof OPToolbox
75
- >;
76
-
77
85
  export type EVMMaxSendableAmountsParams = {
78
86
  from: string;
79
- toolbox: EVMToolboxType;
80
87
  assetValue: AssetValue;
81
88
  feeOptionKey?: FeeOption;
82
89
  memo?: string;
@@ -109,10 +116,25 @@ export type LegacyEVMTxParams<T = bigint> = EVMTxBaseParams<T> & {
109
116
 
110
117
  export type EVMTxParams = EIP1559TxParams | LegacyEVMTxParams;
111
118
 
112
- export type NonETHToolbox =
113
- | ReturnType<typeof ARBToolbox>
114
- | ReturnType<typeof AVAXToolbox>
115
- | ReturnType<typeof BSCToolbox>
116
- | ReturnType<typeof MATICToolbox>
117
- | ReturnType<typeof OPToolbox>
118
- | ReturnType<typeof BASEToolbox>;
119
+ export type EVMToolboxParams = {
120
+ provider?: BrowserProvider | JsonRpcProvider;
121
+ } & (
122
+ | {
123
+ signer?: (ChainSigner<EVMTransferParams, string> & Signer) | JsonRpcSigner;
124
+ }
125
+ | {
126
+ phrase?: string;
127
+ derivationPath?: DerivationPathArray;
128
+ index?: number;
129
+ }
130
+ );
131
+
132
+ export type EVMToolboxes = {
133
+ [Chain.Arbitrum]: Awaited<ReturnType<typeof ARBToolbox>>;
134
+ [Chain.Avalanche]: Awaited<ReturnType<typeof AVAXToolbox>>;
135
+ [Chain.Base]: Awaited<ReturnType<typeof BASEToolbox>>;
136
+ [Chain.BinanceSmartChain]: Awaited<ReturnType<typeof BSCToolbox>>;
137
+ [Chain.Ethereum]: Awaited<ReturnType<typeof ETHToolbox>>;
138
+ [Chain.Optimism]: Awaited<ReturnType<typeof OPToolbox>>;
139
+ [Chain.Polygon]: Awaited<ReturnType<typeof MATICToolbox>>;
140
+ };