@dynamic-labs/ethereum-core 3.0.0-alpha.49
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 +3894 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/_virtual/_tslib.cjs +49 -0
- package/_virtual/_tslib.js +44 -0
- package/package.json +37 -0
- package/src/index.cjs +34 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +13 -0
- package/src/lib/utils/index.d.ts +2 -0
- package/src/lib/utils/logger.cjs +10 -0
- package/src/lib/utils/logger.d.ts +2 -0
- package/src/lib/utils/logger.js +6 -0
- package/src/lib/utils/validateAddressFormat.cjs +8 -0
- package/src/lib/utils/validateAddressFormat.d.ts +1 -0
- package/src/lib/utils/validateAddressFormat.js +4 -0
- package/src/lib/utils/viem/Eip1559FeeFeed.cjs +51 -0
- package/src/lib/utils/viem/Eip1559FeeFeed.d.ts +20 -0
- package/src/lib/utils/viem/Eip1559FeeFeed.js +47 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.cjs +98 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.d.ts +37 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.js +94 -0
- package/src/lib/utils/viem/ViemRpcUiTransaction/index.d.ts +1 -0
- package/src/lib/utils/viem/ViemUiTransaction/ViemUiTransaction.cjs +121 -0
- package/src/lib/utils/viem/ViemUiTransaction/ViemUiTransaction.d.ts +56 -0
- package/src/lib/utils/viem/ViemUiTransaction/ViemUiTransaction.js +117 -0
- package/src/lib/utils/viem/ViemUiTransaction/index.d.ts +2 -0
- package/src/lib/utils/viem/chainsMap/chainsMap.cjs +31 -0
- package/src/lib/utils/viem/chainsMap/chainsMap.d.ts +2 -0
- package/src/lib/utils/viem/chainsMap/chainsMap.js +7 -0
- package/src/lib/utils/viem/chainsMap/index.d.ts +1 -0
- package/src/lib/utils/viem/confirmationTransport/confirmationTransport.cjs +39 -0
- package/src/lib/utils/viem/confirmationTransport/confirmationTransport.d.ts +11 -0
- package/src/lib/utils/viem/confirmationTransport/confirmationTransport.js +35 -0
- package/src/lib/utils/viem/confirmationTransport/index.d.ts +1 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.cjs +41 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.d.ts +12 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.js +37 -0
- package/src/lib/utils/viem/createAccountWithUiConfirmation/index.d.ts +1 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.cjs +33 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.d.ts +25 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/createTransportWithUiConfirmation.js +29 -0
- package/src/lib/utils/viem/createTransportWithUiConfirmation/index.d.ts +1 -0
- package/src/lib/utils/viem/createViemUiTransaction/createViemUiTransaction.cjs +40 -0
- package/src/lib/utils/viem/createViemUiTransaction/createViemUiTransaction.d.ts +9 -0
- package/src/lib/utils/viem/createViemUiTransaction/createViemUiTransaction.js +36 -0
- package/src/lib/utils/viem/createViemUiTransaction/index.d.ts +1 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.cjs +70 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.d.ts +19 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/createWalletClientFromWallet.js +46 -0
- package/src/lib/utils/viem/createWalletClientFromWallet/index.d.ts +1 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.cjs +73 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.d.ts +29 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.js +69 -0
- package/src/lib/utils/viem/createWalletClientWithUiConfirmation/index.d.ts +1 -0
- package/src/lib/utils/viem/erc20/abi.cjs +230 -0
- package/src/lib/utils/viem/erc20/abi.d.ts +38 -0
- package/src/lib/utils/viem/erc20/abi.js +226 -0
- package/src/lib/utils/viem/erc20/index.d.ts +1 -0
- package/src/lib/utils/viem/estimateL1Fee/estimateL1Fee.cjs +31 -0
- package/src/lib/utils/viem/estimateL1Fee/estimateL1Fee.d.ts +10 -0
- package/src/lib/utils/viem/estimateL1Fee/estimateL1Fee.js +26 -0
- package/src/lib/utils/viem/estimateL1Fee/index.d.ts +1 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/abi.cjs +23 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/abi.d.ts +20 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/abi.js +18 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/estimateL1Fee.cjs +30 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/estimateL1Fee.d.ts +3 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/estimateL1Fee.js +25 -0
- package/src/lib/utils/viem/estimateL1Fee/opStack/index.d.ts +1 -0
- package/src/lib/utils/viem/formatEther/formatEther.cjs +11 -0
- package/src/lib/utils/viem/formatEther/formatEther.d.ts +2 -0
- package/src/lib/utils/viem/formatEther/formatEther.js +7 -0
- package/src/lib/utils/viem/formatEther/index.d.ts +1 -0
- package/src/lib/utils/viem/getOrMapViemChain/getOrMapViemChain.cjs +77 -0
- package/src/lib/utils/viem/getOrMapViemChain/getOrMapViemChain.d.ts +11 -0
- package/src/lib/utils/viem/getOrMapViemChain/getOrMapViemChain.js +51 -0
- package/src/lib/utils/viem/getOrMapViemChain/index.d.ts +1 -0
- package/src/lib/utils/viem/index.d.ts +11 -0
- package/src/lib/utils/viem/interceptTransport/index.d.ts +1 -0
- package/src/lib/utils/viem/interceptTransport/interceptTransport.cjs +35 -0
- package/src/lib/utils/viem/interceptTransport/interceptTransport.d.ts +29 -0
- package/src/lib/utils/viem/interceptTransport/interceptTransport.js +31 -0
- package/src/lib/utils/viem/parseEther/index.d.ts +1 -0
- package/src/lib/utils/viem/parseEther/parseEther.cjs +10 -0
- package/src/lib/utils/viem/parseEther/parseEther.d.ts +1 -0
- package/src/lib/utils/viem/parseEther/parseEther.js +6 -0
- package/src/lib/utils/viem/unFormatTransaction/index.d.ts +1 -0
- package/src/lib/utils/viem/unFormatTransaction/unFormatTransaction.cjs +30 -0
- package/src/lib/utils/viem/unFormatTransaction/unFormatTransaction.d.ts +8 -0
- package/src/lib/utils/viem/unFormatTransaction/unFormatTransaction.js +26 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/* eslint-disable max-len */
|
|
3
|
+
const erc20Abi = [
|
|
4
|
+
{
|
|
5
|
+
constant: true,
|
|
6
|
+
inputs: [],
|
|
7
|
+
name: 'name',
|
|
8
|
+
outputs: [
|
|
9
|
+
{
|
|
10
|
+
name: '',
|
|
11
|
+
type: 'string',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
payable: false,
|
|
15
|
+
stateMutability: 'view',
|
|
16
|
+
type: 'function',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
constant: false,
|
|
20
|
+
inputs: [
|
|
21
|
+
{
|
|
22
|
+
name: '_spender',
|
|
23
|
+
type: 'address',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: '_value',
|
|
27
|
+
type: 'uint256',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
name: 'approve',
|
|
31
|
+
outputs: [
|
|
32
|
+
{
|
|
33
|
+
name: '',
|
|
34
|
+
type: 'bool',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
payable: false,
|
|
38
|
+
stateMutability: 'nonpayable',
|
|
39
|
+
type: 'function',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
constant: true,
|
|
43
|
+
inputs: [],
|
|
44
|
+
name: 'totalSupply',
|
|
45
|
+
outputs: [
|
|
46
|
+
{
|
|
47
|
+
name: '',
|
|
48
|
+
type: 'uint256',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
payable: false,
|
|
52
|
+
stateMutability: 'view',
|
|
53
|
+
type: 'function',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
constant: false,
|
|
57
|
+
inputs: [
|
|
58
|
+
{
|
|
59
|
+
name: '_from',
|
|
60
|
+
type: 'address',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: '_to',
|
|
64
|
+
type: 'address',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: '_value',
|
|
68
|
+
type: 'uint256',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
name: 'transferFrom',
|
|
72
|
+
outputs: [
|
|
73
|
+
{
|
|
74
|
+
name: '',
|
|
75
|
+
type: 'bool',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
payable: false,
|
|
79
|
+
stateMutability: 'nonpayable',
|
|
80
|
+
type: 'function',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
constant: true,
|
|
84
|
+
inputs: [],
|
|
85
|
+
name: 'decimals',
|
|
86
|
+
outputs: [
|
|
87
|
+
{
|
|
88
|
+
name: '',
|
|
89
|
+
type: 'uint8',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
payable: false,
|
|
93
|
+
stateMutability: 'view',
|
|
94
|
+
type: 'function',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
constant: true,
|
|
98
|
+
inputs: [
|
|
99
|
+
{
|
|
100
|
+
name: '_owner',
|
|
101
|
+
type: 'address',
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
name: 'balanceOf',
|
|
105
|
+
outputs: [
|
|
106
|
+
{
|
|
107
|
+
name: 'balance',
|
|
108
|
+
type: 'uint256',
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
payable: false,
|
|
112
|
+
stateMutability: 'view',
|
|
113
|
+
type: 'function',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
constant: true,
|
|
117
|
+
inputs: [],
|
|
118
|
+
name: 'symbol',
|
|
119
|
+
outputs: [
|
|
120
|
+
{
|
|
121
|
+
name: '',
|
|
122
|
+
type: 'string',
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
payable: false,
|
|
126
|
+
stateMutability: 'view',
|
|
127
|
+
type: 'function',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
constant: false,
|
|
131
|
+
inputs: [
|
|
132
|
+
{
|
|
133
|
+
name: '_to',
|
|
134
|
+
type: 'address',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: '_value',
|
|
138
|
+
type: 'uint256',
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
name: 'transfer',
|
|
142
|
+
outputs: [
|
|
143
|
+
{
|
|
144
|
+
name: '',
|
|
145
|
+
type: 'bool',
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
payable: false,
|
|
149
|
+
stateMutability: 'nonpayable',
|
|
150
|
+
type: 'function',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
constant: true,
|
|
154
|
+
inputs: [
|
|
155
|
+
{
|
|
156
|
+
name: '_owner',
|
|
157
|
+
type: 'address',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: '_spender',
|
|
161
|
+
type: 'address',
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
name: 'allowance',
|
|
165
|
+
outputs: [
|
|
166
|
+
{
|
|
167
|
+
name: '',
|
|
168
|
+
type: 'uint256',
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
payable: false,
|
|
172
|
+
stateMutability: 'view',
|
|
173
|
+
type: 'function',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
payable: true,
|
|
177
|
+
stateMutability: 'payable',
|
|
178
|
+
type: 'fallback',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
anonymous: false,
|
|
182
|
+
inputs: [
|
|
183
|
+
{
|
|
184
|
+
indexed: true,
|
|
185
|
+
name: 'owner',
|
|
186
|
+
type: 'address',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
indexed: true,
|
|
190
|
+
name: 'spender',
|
|
191
|
+
type: 'address',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
indexed: false,
|
|
195
|
+
name: 'value',
|
|
196
|
+
type: 'uint256',
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
name: 'Approval',
|
|
200
|
+
type: 'event',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
anonymous: false,
|
|
204
|
+
inputs: [
|
|
205
|
+
{
|
|
206
|
+
indexed: true,
|
|
207
|
+
name: 'from',
|
|
208
|
+
type: 'address',
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
indexed: true,
|
|
212
|
+
name: 'to',
|
|
213
|
+
type: 'address',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
indexed: false,
|
|
217
|
+
name: 'value',
|
|
218
|
+
type: 'uint256',
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
name: 'Transfer',
|
|
222
|
+
type: 'event',
|
|
223
|
+
},
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
export { erc20Abi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { erc20Abi } from './abi';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var estimateL1Fee$1 = require('./opStack/estimateL1Fee.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Estimates the L1 fee for the transaction.
|
|
11
|
+
* Currently only supports opStack.
|
|
12
|
+
*/
|
|
13
|
+
const estimateL1Fee = (publicClient, transaction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const { chain } = publicClient;
|
|
15
|
+
if (!chain) {
|
|
16
|
+
throw new Error('Chain is not defined');
|
|
17
|
+
}
|
|
18
|
+
const publicClientWithChain = publicClient;
|
|
19
|
+
if (estimateL1Fee$1.opStackSupportedChains.includes(chain.id)) {
|
|
20
|
+
return estimateL1Fee$1.estimateL1Fee(publicClientWithChain, transaction);
|
|
21
|
+
}
|
|
22
|
+
throw new Error('Chain is not supported');
|
|
23
|
+
});
|
|
24
|
+
const estimateL1FeeSupportedChains = [...estimateL1Fee$1.opStackSupportedChains];
|
|
25
|
+
/**
|
|
26
|
+
* Checks if the chain supports L1 fee estimation.
|
|
27
|
+
*/
|
|
28
|
+
const isL1FeeSupportedByChain = (chainId) => estimateL1FeeSupportedChains.includes(chainId);
|
|
29
|
+
|
|
30
|
+
exports.estimateL1Fee = estimateL1Fee;
|
|
31
|
+
exports.isL1FeeSupportedByChain = isL1FeeSupportedByChain;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Chain, PublicClient, TransactionRequest, Transport } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Estimates the L1 fee for the transaction.
|
|
4
|
+
* Currently only supports opStack.
|
|
5
|
+
*/
|
|
6
|
+
export declare const estimateL1Fee: (publicClient: PublicClient<Transport, Chain>, transaction: Omit<TransactionRequest, 'from'>) => Promise<bigint>;
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the chain supports L1 fee estimation.
|
|
9
|
+
*/
|
|
10
|
+
export declare const isL1FeeSupportedByChain: (chainId: number) => boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { opStackSupportedChains, estimateL1Fee as estimateL1Fee$1 } from './opStack/estimateL1Fee.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Estimates the L1 fee for the transaction.
|
|
7
|
+
* Currently only supports opStack.
|
|
8
|
+
*/
|
|
9
|
+
const estimateL1Fee = (publicClient, transaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
+
const { chain } = publicClient;
|
|
11
|
+
if (!chain) {
|
|
12
|
+
throw new Error('Chain is not defined');
|
|
13
|
+
}
|
|
14
|
+
const publicClientWithChain = publicClient;
|
|
15
|
+
if (opStackSupportedChains.includes(chain.id)) {
|
|
16
|
+
return estimateL1Fee$1(publicClientWithChain, transaction);
|
|
17
|
+
}
|
|
18
|
+
throw new Error('Chain is not supported');
|
|
19
|
+
});
|
|
20
|
+
const estimateL1FeeSupportedChains = [...opStackSupportedChains];
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the chain supports L1 fee estimation.
|
|
23
|
+
*/
|
|
24
|
+
const isL1FeeSupportedByChain = (chainId) => estimateL1FeeSupportedChains.includes(chainId);
|
|
25
|
+
|
|
26
|
+
export { estimateL1Fee, isL1FeeSupportedByChain };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { estimateL1Fee, isL1FeeSupportedByChain } from './estimateL1Fee';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/* eslint-disable max-len */
|
|
7
|
+
const gasPriceOracleAbiAddress = '0x420000000000000000000000000000000000000F';
|
|
8
|
+
/**
|
|
9
|
+
* ABI for the OP Stack [`GasPriceOracle` contract](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/GasPriceOracle.sol).
|
|
10
|
+
* @see https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f
|
|
11
|
+
*/
|
|
12
|
+
const gasPriceOracleAbi = [
|
|
13
|
+
{
|
|
14
|
+
inputs: [{ internalType: 'bytes', name: '_data', type: 'bytes' }],
|
|
15
|
+
name: 'getL1Fee',
|
|
16
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
17
|
+
stateMutability: 'view',
|
|
18
|
+
type: 'function',
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
exports.gasPriceOracleAbi = gasPriceOracleAbi;
|
|
23
|
+
exports.gasPriceOracleAbiAddress = gasPriceOracleAbiAddress;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const gasPriceOracleAbiAddress = "0x420000000000000000000000000000000000000F";
|
|
2
|
+
/**
|
|
3
|
+
* ABI for the OP Stack [`GasPriceOracle` contract](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/GasPriceOracle.sol).
|
|
4
|
+
* @see https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f
|
|
5
|
+
*/
|
|
6
|
+
export declare const gasPriceOracleAbi: readonly [{
|
|
7
|
+
readonly inputs: readonly [{
|
|
8
|
+
readonly internalType: "bytes";
|
|
9
|
+
readonly name: "_data";
|
|
10
|
+
readonly type: "bytes";
|
|
11
|
+
}];
|
|
12
|
+
readonly name: "getL1Fee";
|
|
13
|
+
readonly outputs: readonly [{
|
|
14
|
+
readonly internalType: "uint256";
|
|
15
|
+
readonly name: "";
|
|
16
|
+
readonly type: "uint256";
|
|
17
|
+
}];
|
|
18
|
+
readonly stateMutability: "view";
|
|
19
|
+
readonly type: "function";
|
|
20
|
+
}];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/* eslint-disable max-len */
|
|
3
|
+
const gasPriceOracleAbiAddress = '0x420000000000000000000000000000000000000F';
|
|
4
|
+
/**
|
|
5
|
+
* ABI for the OP Stack [`GasPriceOracle` contract](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/GasPriceOracle.sol).
|
|
6
|
+
* @see https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f
|
|
7
|
+
*/
|
|
8
|
+
const gasPriceOracleAbi = [
|
|
9
|
+
{
|
|
10
|
+
inputs: [{ internalType: 'bytes', name: '_data', type: 'bytes' }],
|
|
11
|
+
name: 'getL1Fee',
|
|
12
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
13
|
+
stateMutability: 'view',
|
|
14
|
+
type: 'function',
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
export { gasPriceOracleAbi, gasPriceOracleAbiAddress };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var viem = require('viem');
|
|
8
|
+
var chains = require('viem/chains');
|
|
9
|
+
var abi = require('./abi.cjs');
|
|
10
|
+
|
|
11
|
+
const estimateL1Fee = (publicClient, transaction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const serializedTransaction = viem.serializeTransaction(Object.assign(Object.assign({ chainId: publicClient.chain.id }, transaction), { type: transaction.type ? transaction.type : 'eip1559' }));
|
|
13
|
+
return publicClient.readContract({
|
|
14
|
+
abi: abi.gasPriceOracleAbi,
|
|
15
|
+
address: abi.gasPriceOracleAbiAddress,
|
|
16
|
+
args: [serializedTransaction],
|
|
17
|
+
functionName: 'getL1Fee',
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
const opStackSupportedChains = [
|
|
21
|
+
chains.optimism.id,
|
|
22
|
+
chains.optimismGoerli.id,
|
|
23
|
+
chains.optimismSepolia.id,
|
|
24
|
+
chains.base.id,
|
|
25
|
+
chains.baseGoerli.id,
|
|
26
|
+
chains.baseSepolia.id,
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
exports.estimateL1Fee = estimateL1Fee;
|
|
30
|
+
exports.opStackSupportedChains = opStackSupportedChains;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Chain, PublicClient, TransactionRequest, Transport } from 'viem';
|
|
2
|
+
export declare const estimateL1Fee: (publicClient: PublicClient<Transport, Chain>, transaction: Omit<TransactionRequest, 'from'>) => Promise<bigint>;
|
|
3
|
+
export declare const opStackSupportedChains: number[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { serializeTransaction } from 'viem';
|
|
4
|
+
import { optimism, optimismGoerli, optimismSepolia, base, baseGoerli, baseSepolia } from 'viem/chains';
|
|
5
|
+
import { gasPriceOracleAbi, gasPriceOracleAbiAddress } from './abi.js';
|
|
6
|
+
|
|
7
|
+
const estimateL1Fee = (publicClient, transaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
+
const serializedTransaction = serializeTransaction(Object.assign(Object.assign({ chainId: publicClient.chain.id }, transaction), { type: transaction.type ? transaction.type : 'eip1559' }));
|
|
9
|
+
return publicClient.readContract({
|
|
10
|
+
abi: gasPriceOracleAbi,
|
|
11
|
+
address: gasPriceOracleAbiAddress,
|
|
12
|
+
args: [serializedTransaction],
|
|
13
|
+
functionName: 'getL1Fee',
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
const opStackSupportedChains = [
|
|
17
|
+
optimism.id,
|
|
18
|
+
optimismGoerli.id,
|
|
19
|
+
optimismSepolia.id,
|
|
20
|
+
base.id,
|
|
21
|
+
baseGoerli.id,
|
|
22
|
+
baseSepolia.id,
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export { estimateL1Fee, opStackSupportedChains };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { estimateL1Fee, opStackSupportedChains } from './estimateL1Fee';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var viem = require('viem');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
|
|
9
|
+
const formatEther = (value, { precision } = {}) => utils.formatNumberText(viem.formatEther(value), { precision });
|
|
10
|
+
|
|
11
|
+
exports.formatEther = formatEther;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { formatEther } from './formatEther';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var chains = require('viem/chains');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n["default"] = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var chains__namespace = /*#__PURE__*/_interopNamespace(chains);
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line import/no-namespace
|
|
29
|
+
/**
|
|
30
|
+
* Gets the chain object for the given chain id.
|
|
31
|
+
* @param chainId - Chain id of the target EVM chain.
|
|
32
|
+
* @returns Viem's chain object.
|
|
33
|
+
*/
|
|
34
|
+
const getChain = (chainId) => {
|
|
35
|
+
for (const chain of Object.values(chains__namespace)) {
|
|
36
|
+
if ('id' in chain) {
|
|
37
|
+
if (chain.id === chainId) {
|
|
38
|
+
return chain;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`Chain with id ${chainId} not found`);
|
|
43
|
+
};
|
|
44
|
+
const mapChain = (network) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return ({
|
|
47
|
+
blockExplorers: ((_a = network.blockExplorerUrls) === null || _a === void 0 ? void 0 : _a[0])
|
|
48
|
+
? {
|
|
49
|
+
default: {
|
|
50
|
+
name: network.blockExplorerUrls[0],
|
|
51
|
+
url: network.blockExplorerUrls[0],
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
: undefined,
|
|
55
|
+
id: network.chainId,
|
|
56
|
+
name: network.vanityName || network.name || network.chainName,
|
|
57
|
+
nativeCurrency: network.nativeCurrency,
|
|
58
|
+
rpcUrls: {
|
|
59
|
+
default: { http: network.rpcUrls },
|
|
60
|
+
public: { http: network.rpcUrls },
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const getOrMapViemChain = (network) => {
|
|
65
|
+
let chain;
|
|
66
|
+
try {
|
|
67
|
+
chain = getChain(network.chainId);
|
|
68
|
+
}
|
|
69
|
+
catch (_a) {
|
|
70
|
+
chain = mapChain(network);
|
|
71
|
+
}
|
|
72
|
+
return chain;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.getChain = getChain;
|
|
76
|
+
exports.getOrMapViemChain = getOrMapViemChain;
|
|
77
|
+
exports.mapChain = mapChain;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Chain } from 'viem';
|
|
2
|
+
import * as chains from 'viem/chains';
|
|
3
|
+
import { EvmNetwork } from '@dynamic-labs/types';
|
|
4
|
+
/**
|
|
5
|
+
* Gets the chain object for the given chain id.
|
|
6
|
+
* @param chainId - Chain id of the target EVM chain.
|
|
7
|
+
* @returns Viem's chain object.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getChain: (chainId: number) => chains.Chain;
|
|
10
|
+
export declare const mapChain: (network: EvmNetwork) => Chain;
|
|
11
|
+
export declare const getOrMapViemChain: (network: EvmNetwork) => Chain;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import * as chains from 'viem/chains';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line import/no-namespace
|
|
5
|
+
/**
|
|
6
|
+
* Gets the chain object for the given chain id.
|
|
7
|
+
* @param chainId - Chain id of the target EVM chain.
|
|
8
|
+
* @returns Viem's chain object.
|
|
9
|
+
*/
|
|
10
|
+
const getChain = (chainId) => {
|
|
11
|
+
for (const chain of Object.values(chains)) {
|
|
12
|
+
if ('id' in chain) {
|
|
13
|
+
if (chain.id === chainId) {
|
|
14
|
+
return chain;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`Chain with id ${chainId} not found`);
|
|
19
|
+
};
|
|
20
|
+
const mapChain = (network) => {
|
|
21
|
+
var _a;
|
|
22
|
+
return ({
|
|
23
|
+
blockExplorers: ((_a = network.blockExplorerUrls) === null || _a === void 0 ? void 0 : _a[0])
|
|
24
|
+
? {
|
|
25
|
+
default: {
|
|
26
|
+
name: network.blockExplorerUrls[0],
|
|
27
|
+
url: network.blockExplorerUrls[0],
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
: undefined,
|
|
31
|
+
id: network.chainId,
|
|
32
|
+
name: network.vanityName || network.name || network.chainName,
|
|
33
|
+
nativeCurrency: network.nativeCurrency,
|
|
34
|
+
rpcUrls: {
|
|
35
|
+
default: { http: network.rpcUrls },
|
|
36
|
+
public: { http: network.rpcUrls },
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const getOrMapViemChain = (network) => {
|
|
41
|
+
let chain;
|
|
42
|
+
try {
|
|
43
|
+
chain = getChain(network.chainId);
|
|
44
|
+
}
|
|
45
|
+
catch (_a) {
|
|
46
|
+
chain = mapChain(network);
|
|
47
|
+
}
|
|
48
|
+
return chain;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { getChain, getOrMapViemChain, mapChain };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getOrMapViemChain';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './ViemRpcUiTransaction';
|
|
2
|
+
export * from './ViemUiTransaction';
|
|
3
|
+
export { chainsMap } from './chainsMap';
|
|
4
|
+
export * from './confirmationTransport';
|
|
5
|
+
export * from './createTransportWithUiConfirmation';
|
|
6
|
+
export * from './createViemUiTransaction';
|
|
7
|
+
export { createWalletClientFromWallet } from './createWalletClientFromWallet';
|
|
8
|
+
export * from './createWalletClientWithUiConfirmation';
|
|
9
|
+
export * from './getOrMapViemChain';
|
|
10
|
+
export * from './unFormatTransaction';
|
|
11
|
+
export * from './erc20';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { interceptTransport, type InterceptTransportProps, } from './interceptTransport';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var viem = require('viem');
|
|
8
|
+
|
|
9
|
+
const interceptTransport = ({ getAccounts, onPersonalSign, onSendTransaction, onSignTypedData, transport, }) => (props) => {
|
|
10
|
+
const provider = transport(props);
|
|
11
|
+
return viem.custom({
|
|
12
|
+
request: (args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
var _a;
|
|
14
|
+
const { method, params } = args;
|
|
15
|
+
if (getAccounts && method === 'eth_accounts') {
|
|
16
|
+
return getAccounts({ provider });
|
|
17
|
+
}
|
|
18
|
+
if (onPersonalSign && method === 'personal_sign') {
|
|
19
|
+
const [message] = params;
|
|
20
|
+
return onPersonalSign({ args, message, provider });
|
|
21
|
+
}
|
|
22
|
+
if (onSendTransaction && method === 'eth_sendTransaction') {
|
|
23
|
+
const [transaction] = params;
|
|
24
|
+
return onSendTransaction({ args, provider, transaction });
|
|
25
|
+
}
|
|
26
|
+
if (onSignTypedData && method === 'eth_signTypedData_v4') {
|
|
27
|
+
const [, message] = (_a = params) !== null && _a !== void 0 ? _a : [];
|
|
28
|
+
return onSignTypedData({ args, message, provider });
|
|
29
|
+
}
|
|
30
|
+
return provider.request(args);
|
|
31
|
+
}),
|
|
32
|
+
})(props);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.interceptTransport = interceptTransport;
|