viem 0.0.0-w-20230821171049 → 0.0.0-w-20230828183856
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/README.md +6 -0
- package/dist/cjs/actions/ens/getEnsAddress.js +2 -2
- package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/cjs/actions/index.js +8 -2
- package/dist/cjs/actions/index.js.map +1 -1
- package/dist/cjs/actions/public/estimateFeesPerGas.js +60 -0
- package/dist/cjs/actions/public/estimateFeesPerGas.js.map +1 -0
- package/dist/cjs/actions/public/estimateGas.js +2 -2
- package/dist/cjs/actions/public/estimateGas.js.map +1 -1
- package/dist/cjs/actions/public/estimateMaxPriorityFeePerGas.js +44 -0
- package/dist/cjs/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -0
- package/dist/cjs/actions/public/verifyHash.js.map +1 -1
- package/dist/cjs/actions/public/verifyMessage.js.map +1 -1
- package/dist/cjs/actions/public/verifyTypedData.js.map +1 -1
- package/dist/cjs/actions/public/waitForTransactionReceipt.js +35 -30
- package/dist/cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/public/watchContractEvent.js +10 -7
- package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
- package/dist/cjs/actions/wallet/deployContract.js.map +1 -1
- package/dist/cjs/actions/wallet/prepareTransactionRequest.js +70 -0
- package/dist/cjs/actions/wallet/prepareTransactionRequest.js.map +1 -0
- package/dist/cjs/actions/wallet/sendRawTransaction.js +11 -0
- package/dist/cjs/actions/wallet/sendRawTransaction.js.map +1 -0
- package/dist/cjs/actions/wallet/sendTransaction.js +6 -6
- package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/wallet/signTransaction.js +47 -0
- package/dist/cjs/actions/wallet/signTransaction.js.map +1 -0
- package/dist/cjs/chains/celo/formatters.js +4 -1
- package/dist/cjs/chains/celo/formatters.js.map +1 -1
- package/dist/cjs/chains/celo/parsers.js +76 -0
- package/dist/cjs/chains/celo/parsers.js.map +1 -0
- package/dist/cjs/chains/celo/serializers.js +2 -1
- package/dist/cjs/chains/celo/serializers.js.map +1 -1
- package/dist/cjs/chains/index.js +3 -2
- package/dist/cjs/chains/index.js.map +1 -1
- package/dist/cjs/chains/utils.js +3 -1
- package/dist/cjs/chains/utils.js.map +1 -1
- package/dist/cjs/clients/createTestClient.js.map +1 -1
- package/dist/cjs/clients/decorators/public.js +8 -0
- package/dist/cjs/clients/decorators/public.js.map +1 -1
- package/dist/cjs/clients/decorators/wallet.js +6 -0
- package/dist/cjs/clients/decorators/wallet.js.map +1 -1
- package/dist/cjs/errors/fee.js +42 -0
- package/dist/cjs/errors/fee.js.map +1 -0
- package/dist/cjs/index.js +9 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/public.js +5 -1
- package/dist/cjs/public.js.map +1 -1
- package/dist/cjs/utils/data/isBytesEqual.js +4 -3
- package/dist/cjs/utils/data/isBytesEqual.js.map +1 -1
- package/dist/cjs/utils/ens/encodedLabelToLabelhash.js +2 -2
- package/dist/cjs/utils/ens/encodedLabelToLabelhash.js.map +1 -1
- package/dist/cjs/utils/formatters/transactionRequest.js +9 -1
- package/dist/cjs/utils/formatters/transactionRequest.js.map +1 -1
- package/dist/cjs/utils/index.js +3 -3
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/rpc.js +5 -7
- package/dist/cjs/utils/rpc.js.map +1 -1
- package/dist/cjs/utils/transaction/parseTransaction.js +8 -3
- package/dist/cjs/utils/transaction/parseTransaction.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/actions/ens/getEnsAddress.js +2 -2
- package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/esm/actions/index.js +3 -0
- package/dist/esm/actions/index.js.map +1 -1
- package/dist/esm/actions/public/estimateFeesPerGas.js +78 -0
- package/dist/esm/actions/public/estimateFeesPerGas.js.map +1 -0
- package/dist/esm/actions/public/estimateGas.js +2 -2
- package/dist/esm/actions/public/estimateGas.js.map +1 -1
- package/dist/esm/actions/public/estimateMaxPriorityFeePerGas.js +64 -0
- package/dist/esm/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -0
- package/dist/esm/actions/public/verifyHash.js.map +1 -1
- package/dist/esm/actions/public/verifyMessage.js.map +1 -1
- package/dist/esm/actions/public/verifyTypedData.js.map +1 -1
- package/dist/esm/actions/public/waitForTransactionReceipt.js +39 -34
- package/dist/esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/public/watchContractEvent.js +5 -2
- package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
- package/dist/esm/actions/wallet/deployContract.js.map +1 -1
- package/dist/esm/actions/wallet/prepareTransactionRequest.js +109 -0
- package/dist/esm/actions/wallet/prepareTransactionRequest.js.map +1 -0
- package/dist/esm/actions/wallet/sendRawTransaction.js +31 -0
- package/dist/esm/actions/wallet/sendRawTransaction.js.map +1 -0
- package/dist/esm/actions/wallet/sendTransaction.js +6 -6
- package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/esm/actions/wallet/signTransaction.js +87 -0
- package/dist/esm/actions/wallet/signTransaction.js.map +1 -0
- package/dist/esm/chains/celo/formatters.js +4 -1
- package/dist/esm/chains/celo/formatters.js.map +1 -1
- package/dist/esm/chains/celo/parsers.js +72 -0
- package/dist/esm/chains/celo/parsers.js.map +1 -0
- package/dist/esm/chains/celo/serializers.js +1 -3
- package/dist/esm/chains/celo/serializers.js.map +1 -1
- package/dist/esm/chains/index.js +1 -0
- package/dist/esm/chains/index.js.map +1 -1
- package/dist/esm/chains/utils.js +1 -0
- package/dist/esm/chains/utils.js.map +1 -1
- package/dist/esm/clients/createTestClient.js.map +1 -1
- package/dist/esm/clients/decorators/public.js +8 -0
- package/dist/esm/clients/decorators/public.js.map +1 -1
- package/dist/esm/clients/decorators/wallet.js +6 -0
- package/dist/esm/clients/decorators/wallet.js.map +1 -1
- package/dist/esm/errors/fee.js +36 -0
- package/dist/esm/errors/fee.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/public.js +2 -0
- package/dist/esm/public.js.map +1 -1
- package/dist/esm/utils/data/isBytesEqual.js +2 -1
- package/dist/esm/utils/data/isBytesEqual.js.map +1 -1
- package/dist/esm/utils/ens/encodedLabelToLabelhash.js +1 -1
- package/dist/esm/utils/ens/encodedLabelToLabelhash.js.map +1 -1
- package/dist/esm/utils/formatters/transactionRequest.js +8 -0
- package/dist/esm/utils/formatters/transactionRequest.js.map +1 -1
- package/dist/esm/utils/index.js +3 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/rpc.js +5 -7
- package/dist/esm/utils/rpc.js.map +1 -1
- package/dist/esm/utils/transaction/parseTransaction.js +6 -3
- package/dist/esm/utils/transaction/parseTransaction.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/dist/types/actions/index.d.ts +3 -0
- package/dist/types/actions/index.d.ts.map +1 -1
- package/dist/types/actions/public/estimateFeesPerGas.d.ts +48 -0
- package/dist/types/actions/public/estimateFeesPerGas.d.ts.map +1 -0
- package/dist/types/actions/public/estimateMaxPriorityFeePerGas.d.ts +37 -0
- package/dist/types/actions/public/estimateMaxPriorityFeePerGas.d.ts.map +1 -0
- package/dist/types/actions/public/verifyHash.d.ts +1 -1
- package/dist/types/actions/public/verifyHash.d.ts.map +1 -1
- package/dist/types/actions/public/verifyMessage.d.ts +2 -2
- package/dist/types/actions/public/verifyMessage.d.ts.map +1 -1
- package/dist/types/actions/public/verifyTypedData.d.ts +2 -2
- package/dist/types/actions/public/verifyTypedData.d.ts.map +1 -1
- package/dist/types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +2 -1
- package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
- package/dist/types/actions/wallet/prepareTransactionRequest.d.ts +52 -0
- package/dist/types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -0
- package/dist/types/actions/wallet/sendRawTransaction.d.ts +38 -0
- package/dist/types/actions/wallet/sendRawTransaction.d.ts.map +1 -0
- package/dist/types/actions/wallet/sendTransaction.d.ts +2 -1
- package/dist/types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/wallet/signTransaction.d.ts +55 -0
- package/dist/types/actions/wallet/signTransaction.d.ts.map +1 -0
- package/dist/types/chains/celo/formatters.d.ts +503 -5
- package/dist/types/chains/celo/formatters.d.ts.map +1 -1
- package/dist/types/chains/celo/parsers.d.ts +6 -0
- package/dist/types/chains/celo/parsers.d.ts.map +1 -0
- package/dist/types/chains/celo/serializers.d.ts +3 -14
- package/dist/types/chains/celo/serializers.d.ts.map +1 -1
- package/dist/types/chains/celo/types.d.ts +54 -14
- package/dist/types/chains/celo/types.d.ts.map +1 -1
- package/dist/types/chains/index.d.ts +15876 -3730
- package/dist/types/chains/index.d.ts.map +1 -1
- package/dist/types/chains/utils.d.ts +3 -2
- package/dist/types/chains/utils.d.ts.map +1 -1
- package/dist/types/clients/createTestClient.d.ts +1 -1
- package/dist/types/clients/createTestClient.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +112 -0
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +111 -0
- package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/types/errors/fee.d.ts +16 -0
- package/dist/types/errors/fee.d.ts.map +1 -0
- package/dist/types/index.d.ts +23 -17
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/public.d.ts +2 -0
- package/dist/types/public.d.ts.map +1 -1
- package/dist/types/types/chain.d.ts +64 -11
- package/dist/types/types/chain.d.ts.map +1 -1
- package/dist/types/types/contract.d.ts +2 -2
- package/dist/types/types/contract.d.ts.map +1 -1
- package/dist/types/types/eip1193.d.ts +14 -2
- package/dist/types/types/eip1193.d.ts.map +1 -1
- package/dist/types/types/fee.d.ts +1 -0
- package/dist/types/types/fee.d.ts.map +1 -1
- package/dist/types/utils/chain.d.ts +2 -2
- package/dist/types/utils/chain.d.ts.map +1 -1
- package/dist/types/utils/data/isBytesEqual.d.ts +1 -1
- package/dist/types/utils/data/isBytesEqual.d.ts.map +1 -1
- package/dist/types/utils/ens/encodeLabelhash.d.ts +1 -1
- package/dist/types/utils/ens/encodeLabelhash.d.ts.map +1 -1
- package/dist/types/utils/ens/encodedLabelToLabelhash.d.ts +1 -1
- package/dist/types/utils/ens/encodedLabelToLabelhash.d.ts.map +1 -1
- package/dist/types/utils/formatters/transactionRequest.d.ts +5 -0
- package/dist/types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +3 -1
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/rpc.d.ts +1 -1
- package/dist/types/utils/rpc.d.ts.map +1 -1
- package/dist/types/utils/transaction/parseTransaction.d.ts +5 -1
- package/dist/types/utils/transaction/parseTransaction.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/actions/ens/getEnsAddress.ts +6 -8
- package/src/actions/index.ts +15 -0
- package/src/actions/public/estimateFeesPerGas.ts +154 -0
- package/src/actions/public/estimateGas.ts +5 -5
- package/src/actions/public/estimateMaxPriorityFeePerGas.ts +98 -0
- package/src/actions/public/verifyHash.ts +1 -1
- package/src/actions/public/verifyMessage.ts +3 -2
- package/src/actions/public/verifyTypedData.ts +3 -2
- package/src/actions/public/waitForTransactionReceipt.ts +48 -44
- package/src/actions/public/watchContractEvent.ts +9 -6
- package/src/actions/wallet/deployContract.ts +2 -1
- package/src/actions/wallet/prepareTransactionRequest.ts +179 -0
- package/src/actions/wallet/sendRawTransaction.ts +48 -0
- package/src/actions/wallet/sendTransaction.ts +8 -7
- package/src/actions/wallet/signTransaction.ts +137 -0
- package/src/chains/celo/formatters.ts +11 -12
- package/src/chains/celo/parsers.ts +123 -0
- package/src/chains/celo/serializers.ts +13 -34
- package/src/chains/celo/types.ts +114 -26
- package/src/chains/index.ts +1 -0
- package/src/chains/utils.ts +10 -6
- package/src/clients/createTestClient.ts +2 -1
- package/src/clients/decorators/public.ts +145 -0
- package/src/clients/decorators/wallet.ts +133 -0
- package/src/errors/fee.ts +27 -0
- package/src/errors/rpc.ts +1 -1
- package/src/index.ts +46 -25
- package/src/public.ts +10 -0
- package/src/types/chain.ts +80 -12
- package/src/types/contract.ts +2 -2
- package/src/types/eip1193.ts +14 -2
- package/src/types/fee.ts +2 -0
- package/src/utils/chain.ts +2 -2
- package/src/utils/data/isBytesEqual.ts +4 -1
- package/src/utils/ens/encodeLabelhash.ts +1 -1
- package/src/utils/ens/encodedLabelToLabelhash.ts +2 -2
- package/src/utils/formatters/transactionRequest.ts +10 -0
- package/src/utils/index.ts +4 -1
- package/src/utils/rpc.ts +5 -8
- package/src/utils/transaction/parseTransaction.ts +7 -9
- package/src/version.ts +1 -1
- package/dist/cjs/utils/transaction/prepareRequest.js +0 -64
- package/dist/cjs/utils/transaction/prepareRequest.js.map +0 -1
- package/dist/esm/utils/transaction/prepareRequest.js +0 -64
- package/dist/esm/utils/transaction/prepareRequest.js.map +0 -1
- package/dist/types/utils/transaction/prepareRequest.d.ts +0 -20
- package/dist/types/utils/transaction/prepareRequest.d.ts.map +0 -1
- package/src/utils/transaction/prepareRequest.ts +0 -143
@@ -22,6 +22,11 @@ import {
|
|
22
22
|
type GetPermissionsReturnType,
|
23
23
|
getPermissions,
|
24
24
|
} from '../../actions/wallet/getPermissions.js'
|
25
|
+
import {
|
26
|
+
type PrepareTransactionRequestParameters,
|
27
|
+
type PrepareTransactionRequestReturnType,
|
28
|
+
prepareTransactionRequest,
|
29
|
+
} from '../../actions/wallet/prepareTransactionRequest.js'
|
25
30
|
import {
|
26
31
|
type RequestAddressesReturnType,
|
27
32
|
requestAddresses,
|
@@ -31,6 +36,11 @@ import {
|
|
31
36
|
type RequestPermissionsReturnType,
|
32
37
|
requestPermissions,
|
33
38
|
} from '../../actions/wallet/requestPermissions.js'
|
39
|
+
import {
|
40
|
+
type SendRawTransactionParameters,
|
41
|
+
type SendRawTransactionReturnType,
|
42
|
+
sendRawTransaction,
|
43
|
+
} from '../../actions/wallet/sendRawTransaction.js'
|
34
44
|
import {
|
35
45
|
type SendTransactionParameters,
|
36
46
|
type SendTransactionReturnType,
|
@@ -41,6 +51,11 @@ import {
|
|
41
51
|
type SignMessageReturnType,
|
42
52
|
signMessage,
|
43
53
|
} from '../../actions/wallet/signMessage.js'
|
54
|
+
import {
|
55
|
+
type SignTransactionParameters,
|
56
|
+
type SignTransactionReturnType,
|
57
|
+
signTransaction,
|
58
|
+
} from '../../actions/wallet/signTransaction.js'
|
44
59
|
import {
|
45
60
|
type SignTypedDataParameters,
|
46
61
|
type SignTypedDataReturnType,
|
@@ -179,6 +194,47 @@ export type WalletActions<
|
|
179
194
|
* const permissions = await client.getPermissions()
|
180
195
|
*/
|
181
196
|
getPermissions: () => Promise<GetPermissionsReturnType>
|
197
|
+
/**
|
198
|
+
* Prepares a transaction request for signing.
|
199
|
+
*
|
200
|
+
* - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html
|
201
|
+
*
|
202
|
+
* @param args - {@link PrepareTransactionRequestParameters}
|
203
|
+
* @returns The transaction request. {@link PrepareTransactionRequestReturnType}
|
204
|
+
*
|
205
|
+
* @example
|
206
|
+
* import { createWalletClient, custom } from 'viem'
|
207
|
+
* import { mainnet } from 'viem/chains'
|
208
|
+
*
|
209
|
+
* const client = createWalletClient({
|
210
|
+
* chain: mainnet,
|
211
|
+
* transport: custom(window.ethereum),
|
212
|
+
* })
|
213
|
+
* const request = await client.prepareTransactionRequest({
|
214
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
215
|
+
* to: '0x0000000000000000000000000000000000000000',
|
216
|
+
* value: 1n,
|
217
|
+
* })
|
218
|
+
*
|
219
|
+
* @example
|
220
|
+
* // Account Hoisting
|
221
|
+
* import { createWalletClient, http } from 'viem'
|
222
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
223
|
+
* import { mainnet } from 'viem/chains'
|
224
|
+
*
|
225
|
+
* const client = createWalletClient({
|
226
|
+
* account: privateKeyToAccount('0x…'),
|
227
|
+
* chain: mainnet,
|
228
|
+
* transport: custom(window.ethereum),
|
229
|
+
* })
|
230
|
+
* const request = await client.prepareTransactionRequest({
|
231
|
+
* to: '0x0000000000000000000000000000000000000000',
|
232
|
+
* value: 1n,
|
233
|
+
* })
|
234
|
+
*/
|
235
|
+
prepareTransactionRequest: <TChainOverride extends Chain | undefined,>(
|
236
|
+
args: PrepareTransactionRequestParameters<TChain, TAccount, TChainOverride>,
|
237
|
+
) => Promise<PrepareTransactionRequestReturnType>
|
182
238
|
/**
|
183
239
|
* Requests a list of accounts managed by a wallet.
|
184
240
|
*
|
@@ -226,6 +282,33 @@ export type WalletActions<
|
|
226
282
|
requestPermissions: (
|
227
283
|
args: RequestPermissionsParameters,
|
228
284
|
) => Promise<RequestPermissionsReturnType>
|
285
|
+
/**
|
286
|
+
* Sends a **signed** transaction to the network
|
287
|
+
*
|
288
|
+
* - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html
|
289
|
+
* - JSON-RPC Method: [`eth_sendRawTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)
|
290
|
+
*
|
291
|
+
* @param client - Client to use
|
292
|
+
* @param parameters - {@link SendRawTransactionParameters}
|
293
|
+
* @returns The transaction hash. {@link SendRawTransactionReturnType}
|
294
|
+
*
|
295
|
+
* @example
|
296
|
+
* import { createWalletClient, custom } from 'viem'
|
297
|
+
* import { mainnet } from 'viem/chains'
|
298
|
+
* import { sendRawTransaction } from 'viem/wallet'
|
299
|
+
*
|
300
|
+
* const client = createWalletClient({
|
301
|
+
* chain: mainnet,
|
302
|
+
* transport: custom(window.ethereum),
|
303
|
+
* })
|
304
|
+
*
|
305
|
+
* const hash = await client.sendRawTransaction({
|
306
|
+
* serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'
|
307
|
+
* })
|
308
|
+
*/
|
309
|
+
sendRawTransaction: (
|
310
|
+
args: SendRawTransactionParameters,
|
311
|
+
) => Promise<SendRawTransactionReturnType>
|
229
312
|
/**
|
230
313
|
* Creates, signs, and sends a new transaction to the network.
|
231
314
|
*
|
@@ -317,6 +400,52 @@ export type WalletActions<
|
|
317
400
|
signMessage: (
|
318
401
|
args: SignMessageParameters<TAccount>,
|
319
402
|
) => Promise<SignMessageReturnType>
|
403
|
+
/**
|
404
|
+
* Signs a transaction.
|
405
|
+
*
|
406
|
+
* - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html
|
407
|
+
* - JSON-RPC Methods:
|
408
|
+
* - JSON-RPC Accounts: [`eth_signTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)
|
409
|
+
* - Local Accounts: Signs locally. No JSON-RPC request.
|
410
|
+
*
|
411
|
+
* @param args - {@link SignTransactionParameters}
|
412
|
+
* @returns The signed message. {@link SignTransactionReturnType}
|
413
|
+
*
|
414
|
+
* @example
|
415
|
+
* import { createWalletClient, custom } from 'viem'
|
416
|
+
* import { mainnet } from 'viem/chains'
|
417
|
+
*
|
418
|
+
* const client = createWalletClient({
|
419
|
+
* chain: mainnet,
|
420
|
+
* transport: custom(window.ethereum),
|
421
|
+
* })
|
422
|
+
* const request = await client.prepareTransactionRequest({
|
423
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
424
|
+
* to: '0x0000000000000000000000000000000000000000',
|
425
|
+
* value: 1n,
|
426
|
+
* })
|
427
|
+
* const signature = await client.signTransaction(request)
|
428
|
+
*
|
429
|
+
* @example
|
430
|
+
* // Account Hoisting
|
431
|
+
* import { createWalletClient, http } from 'viem'
|
432
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
433
|
+
* import { mainnet } from 'viem/chains'
|
434
|
+
*
|
435
|
+
* const client = createWalletClient({
|
436
|
+
* account: privateKeyToAccount('0x…'),
|
437
|
+
* chain: mainnet,
|
438
|
+
* transport: custom(window.ethereum),
|
439
|
+
* })
|
440
|
+
* const request = await client.prepareTransactionRequest({
|
441
|
+
* to: '0x0000000000000000000000000000000000000000',
|
442
|
+
* value: 1n,
|
443
|
+
* })
|
444
|
+
* const signature = await client.signTransaction(request)
|
445
|
+
*/
|
446
|
+
signTransaction: <TChainOverride extends Chain | undefined,>(
|
447
|
+
args: SignTransactionParameters<TChain, TAccount, TChainOverride>,
|
448
|
+
) => Promise<SignTransactionReturnType>
|
320
449
|
/**
|
321
450
|
* Signs typed data and calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
322
451
|
*
|
@@ -542,10 +671,14 @@ export function walletActions<
|
|
542
671
|
getAddresses: () => getAddresses(client),
|
543
672
|
getChainId: () => getChainId(client),
|
544
673
|
getPermissions: () => getPermissions(client),
|
674
|
+
prepareTransactionRequest: (args) =>
|
675
|
+
prepareTransactionRequest(client as any, args as any),
|
545
676
|
requestAddresses: () => requestAddresses(client),
|
546
677
|
requestPermissions: (args) => requestPermissions(client, args),
|
678
|
+
sendRawTransaction: (args) => sendRawTransaction(client, args),
|
547
679
|
sendTransaction: (args) => sendTransaction(client, args),
|
548
680
|
signMessage: (args) => signMessage(client, args),
|
681
|
+
signTransaction: (args) => signTransaction(client, args),
|
549
682
|
signTypedData: (args) => signTypedData(client, args),
|
550
683
|
switchChain: (args) => switchChain(client, args),
|
551
684
|
watchAsset: (args) => watchAsset(client, args),
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { formatGwei } from '../utils/unit/formatGwei.js'
|
2
|
+
import { BaseError } from './base.js'
|
3
|
+
|
4
|
+
export class BaseFeeScalarError extends BaseError {
|
5
|
+
override name = 'BaseFeeScalarError'
|
6
|
+
constructor() {
|
7
|
+
super('`baseFeeMultiplier` must be greater than 1.')
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
export class Eip1559FeesNotSupportedError extends BaseError {
|
12
|
+
override name = 'Eip1559FeesNotSupportedError'
|
13
|
+
constructor() {
|
14
|
+
super('Chain does not support EIP-1559 fees.')
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
export class MaxFeePerGasTooLowError extends BaseError {
|
19
|
+
override name = 'MaxFeePerGasTooLowError'
|
20
|
+
constructor({ maxPriorityFeePerGas }: { maxPriorityFeePerGas: bigint }) {
|
21
|
+
super(
|
22
|
+
`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${formatGwei(
|
23
|
+
maxPriorityFeePerGas,
|
24
|
+
)} gwei).`,
|
25
|
+
)
|
26
|
+
}
|
27
|
+
}
|
package/src/errors/rpc.ts
CHANGED
@@ -60,7 +60,7 @@ export type ProviderRpcErrorCode =
|
|
60
60
|
| 4200 // Unsupported Method
|
61
61
|
| 4900 // Disconnected
|
62
62
|
| 4901 // Chain Disconnected
|
63
|
-
| 4902 // Chain Not
|
63
|
+
| 4902 // Chain Not Recognized
|
64
64
|
|
65
65
|
/**
|
66
66
|
* Error subclass implementing Ethereum Provider errors per EIP-1193.
|
package/src/index.ts
CHANGED
@@ -71,6 +71,14 @@ export type {
|
|
71
71
|
EstimateGasParameters,
|
72
72
|
EstimateGasReturnType,
|
73
73
|
} from './actions/public/estimateGas.js'
|
74
|
+
export type {
|
75
|
+
EstimateFeesPerGasParameters,
|
76
|
+
EstimateFeesPerGasReturnType,
|
77
|
+
} from './actions/public/estimateFeesPerGas.js'
|
78
|
+
export type {
|
79
|
+
EstimateMaxPriorityFeePerGasParameters,
|
80
|
+
EstimateMaxPriorityFeePerGasReturnType,
|
81
|
+
} from './actions/public/estimateMaxPriorityFeePerGas.js'
|
74
82
|
export type { GetAddressesReturnType } from './actions/wallet/getAddresses.js'
|
75
83
|
export type {
|
76
84
|
GetBalanceParameters,
|
@@ -202,6 +210,12 @@ export type {
|
|
202
210
|
SendTransactionParameters,
|
203
211
|
SendTransactionReturnType,
|
204
212
|
} from './actions/wallet/sendTransaction.js'
|
213
|
+
export type {
|
214
|
+
PrepareTransactionRequestParameters,
|
215
|
+
PrepareTransactionRequestReturnType,
|
216
|
+
/** @deprecated import `prepareTransactionRequest` from `viem/actions` instead. */
|
217
|
+
prepareTransactionRequest as prepareRequest,
|
218
|
+
} from './actions/wallet/prepareTransactionRequest.js'
|
205
219
|
export type {
|
206
220
|
SendUnsignedTransactionParameters,
|
207
221
|
SendUnsignedTransactionReturnType,
|
@@ -252,6 +266,29 @@ export type {
|
|
252
266
|
WriteContractParameters,
|
253
267
|
WriteContractReturnType,
|
254
268
|
} from './actions/wallet/writeContract.js'
|
269
|
+
export type {
|
270
|
+
Chain,
|
271
|
+
ChainContract,
|
272
|
+
ChainFees,
|
273
|
+
ChainFormatter,
|
274
|
+
/** @deprecated use `ChainFormatter` instead. */
|
275
|
+
ChainFormatter as Formatter,
|
276
|
+
ChainFormatters,
|
277
|
+
/** @deprecated use `ChainFormatters` instead. */
|
278
|
+
ChainFormatters as Formatters,
|
279
|
+
ChainSerializers,
|
280
|
+
/** @deprecated use `ChainSerializers` instead. */
|
281
|
+
ChainSerializers as Serializers,
|
282
|
+
ExtractChainFormatterExclude,
|
283
|
+
/** @deprecated use `ExtractChainFormatterExclude` instead. */
|
284
|
+
ExtractChainFormatterExclude as ExtractFormatterExclude,
|
285
|
+
ExtractChainFormatterParameters,
|
286
|
+
/** @deprecated use `ExtractChainFormatterParameters` instead. */
|
287
|
+
ExtractChainFormatterParameters as ExtractFormatterParameters,
|
288
|
+
ExtractChainFormatterReturnType,
|
289
|
+
/** @deprecated use `ExtractChainFormatterReturnType` instead. */
|
290
|
+
ExtractChainFormatterReturnType as ExtractFormatterReturnType,
|
291
|
+
} from './types/chain.js'
|
255
292
|
export {
|
256
293
|
type Client,
|
257
294
|
type ClientConfig,
|
@@ -442,6 +479,11 @@ export {
|
|
442
479
|
ContractFunctionZeroDataError,
|
443
480
|
RawContractError,
|
444
481
|
} from './errors/contract.js'
|
482
|
+
export {
|
483
|
+
BaseFeeScalarError,
|
484
|
+
Eip1559FeesNotSupportedError,
|
485
|
+
MaxFeePerGasTooLowError,
|
486
|
+
} from './errors/fee.js'
|
445
487
|
export {
|
446
488
|
ChainDisconnectedError,
|
447
489
|
InternalRpcError,
|
@@ -581,32 +623,10 @@ export type {
|
|
581
623
|
Signature,
|
582
624
|
SignableMessage,
|
583
625
|
} from './types/misc.js'
|
584
|
-
export type {
|
585
|
-
Chain,
|
586
|
-
ChainContract,
|
587
|
-
ChainFees,
|
588
|
-
ChainFormatter,
|
589
|
-
/** @deprecated use `ChainFormatter` instead. */
|
590
|
-
ChainFormatter as Formatter,
|
591
|
-
ChainFormatters,
|
592
|
-
/** @deprecated use `ChainFormatters` instead. */
|
593
|
-
ChainFormatters as Formatters,
|
594
|
-
ChainSerializers,
|
595
|
-
/** @deprecated use `ChainSerializers` instead. */
|
596
|
-
ChainSerializers as Serializers,
|
597
|
-
ExtractChainFormatterExclude,
|
598
|
-
/** @deprecated use `ExtractChainFormatterExclude` instead. */
|
599
|
-
ExtractChainFormatterExclude as ExtractFormatterExclude,
|
600
|
-
ExtractChainFormatterParameters,
|
601
|
-
/** @deprecated use `ExtractChainFormatterParameters` instead. */
|
602
|
-
ExtractChainFormatterParameters as ExtractFormatterParameters,
|
603
|
-
ExtractChainFormatterReturnType,
|
604
|
-
/** @deprecated use `ExtractChainFormatterReturnType` instead. */
|
605
|
-
ExtractChainFormatterReturnType as ExtractFormatterReturnType,
|
606
|
-
GetChain,
|
607
|
-
} from './types/chain.js'
|
626
|
+
export type { GetChain } from './types/chain.js'
|
608
627
|
export type {
|
609
628
|
AddEthereumChainParameter,
|
629
|
+
EIP1193EventMap,
|
610
630
|
EIP1193Events,
|
611
631
|
EIP1193Parameters,
|
612
632
|
EIP1193Provider,
|
@@ -630,6 +650,7 @@ export type {
|
|
630
650
|
FeeValues,
|
631
651
|
FeeValuesEIP1559,
|
632
652
|
FeeValuesLegacy,
|
653
|
+
FeeValuesType,
|
633
654
|
} from './types/fee.js'
|
634
655
|
export type { Filter } from './types/filter.js'
|
635
656
|
export type { TypedDataDefinition } from './types/typedData.js'
|
@@ -728,6 +749,7 @@ export {
|
|
728
749
|
type FormattedTransactionRequest,
|
729
750
|
defineTransactionRequest,
|
730
751
|
formatTransactionRequest,
|
752
|
+
rpcTransactionType,
|
731
753
|
} from './utils/formatters/transactionRequest.js'
|
732
754
|
export {
|
733
755
|
type GetAbiItemParameters,
|
@@ -850,7 +872,6 @@ export { parseEther } from './utils/unit/parseEther.js'
|
|
850
872
|
export { parseGwei } from './utils/unit/parseGwei.js'
|
851
873
|
export { parseTransaction } from './utils/transaction/parseTransaction.js'
|
852
874
|
export { parseUnits } from './utils/unit/parseUnits.js'
|
853
|
-
export { prepareRequest } from './utils/transaction/prepareRequest.js'
|
854
875
|
export { serializeAccessList } from './utils/transaction/serializeAccessList.js'
|
855
876
|
export {
|
856
877
|
serializeTransaction,
|
package/src/public.ts
CHANGED
@@ -53,6 +53,11 @@ export {
|
|
53
53
|
type GetFeeHistoryParameters,
|
54
54
|
type GetFeeHistoryReturnType,
|
55
55
|
} from './actions/public/getFeeHistory.js'
|
56
|
+
export {
|
57
|
+
estimateFeesPerGas,
|
58
|
+
type EstimateFeesPerGasParameters,
|
59
|
+
type EstimateFeesPerGasReturnType,
|
60
|
+
} from './actions/public/estimateFeesPerGas.js'
|
56
61
|
export {
|
57
62
|
getFilterChanges,
|
58
63
|
type GetFilterChangesParameters,
|
@@ -68,6 +73,11 @@ export {
|
|
68
73
|
getGasPrice,
|
69
74
|
type GetGasPriceReturnType,
|
70
75
|
} from './actions/public/getGasPrice.js'
|
76
|
+
export {
|
77
|
+
estimateMaxPriorityFeePerGas,
|
78
|
+
type EstimateMaxPriorityFeePerGasParameters,
|
79
|
+
type EstimateMaxPriorityFeePerGasReturnType,
|
80
|
+
} from './actions/public/estimateMaxPriorityFeePerGas.js'
|
71
81
|
export {
|
72
82
|
getTransaction,
|
73
83
|
type GetTransactionParameters,
|
package/src/types/chain.ts
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
import type {
|
3
|
+
import type { EstimateFeesPerGasReturnType } from '../actions/public/estimateFeesPerGas.js'
|
4
|
+
import type { PrepareTransactionRequestParameters } from '../actions/wallet/prepareTransactionRequest.js'
|
5
|
+
import type { Client } from '../clients/createClient.js'
|
6
|
+
import type { Transport } from '../clients/transports/createTransport.js'
|
7
|
+
import type { Account } from '../types/account.js'
|
8
|
+
import type { FeeValuesType } from '../types/fee.js'
|
6
9
|
import type {
|
7
10
|
TransactionSerializable,
|
8
11
|
TransactionSerializableGeneric,
|
9
|
-
} from '
|
10
|
-
import type { IsUndefined, Prettify } from '
|
12
|
+
} from '../types/transaction.js'
|
13
|
+
import type { IsUndefined, Prettify } from '../types/utils.js'
|
14
|
+
import type { FormattedBlock } from '../utils/formatters/block.js'
|
15
|
+
import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
|
11
16
|
|
12
17
|
export type Chain<
|
13
18
|
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
@@ -16,8 +21,14 @@ export type Chain<
|
|
16
21
|
export type ChainConfig<
|
17
22
|
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
18
23
|
> = {
|
24
|
+
/**
|
25
|
+
* Modifies how chain data structures (ie. Blocks, Transactions, etc)
|
26
|
+
* are formatted & typed.
|
27
|
+
*/
|
19
28
|
formatters?: formatters | undefined
|
29
|
+
/** Modifies how data (ie. Transactions) is serialized. */
|
20
30
|
serializers?: ChainSerializers<formatters> | undefined
|
31
|
+
/** Modifies how fees are derived. */
|
21
32
|
fees?: ChainFees<formatters> | undefined
|
22
33
|
}
|
23
34
|
|
@@ -29,20 +40,42 @@ export type ChainContract = {
|
|
29
40
|
export type ChainFees<
|
30
41
|
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
31
42
|
> = {
|
32
|
-
|
43
|
+
/**
|
44
|
+
* The fee multiplier to use to account for fee fluctuations.
|
45
|
+
* Used in the [`estimateFeesPerGas` Action](/docs/actions/public/estimateFeesPerGas).
|
46
|
+
*
|
47
|
+
* @default 1.2
|
48
|
+
*/
|
49
|
+
baseFeeMultiplier?:
|
50
|
+
| number
|
51
|
+
| ((args: ChainFeesFnParameters<formatters>) => Promise<number> | number)
|
52
|
+
/**
|
53
|
+
* The default `maxPriorityFeePerGas` to use when a priority
|
54
|
+
* fee is not defined upon sending a transaction.
|
55
|
+
*
|
56
|
+
* Overrides the return value in the [`estimateMaxPriorityFeePerGas` Action](/docs/actions/public/estimateMaxPriorityFeePerGas).
|
57
|
+
*/
|
58
|
+
defaultPriorityFee?:
|
33
59
|
| bigint
|
34
|
-
| ((args:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
60
|
+
| ((args: ChainFeesFnParameters<formatters>) => Promise<bigint> | bigint)
|
61
|
+
/**
|
62
|
+
* Allows customization of fee per gas values (e.g. `maxFeePerGas`/`maxPriorityFeePerGas`).
|
63
|
+
*
|
64
|
+
* Overrides the return value in the [`estimateFeesPerGas` Action](/docs/actions/public/estimateFeesPerGas).
|
65
|
+
*/
|
66
|
+
estimateFeesPerGas?: (
|
67
|
+
args: ChainEstimateFeesPerGasFnParameters<formatters>,
|
68
|
+
) => Promise<EstimateFeesPerGasReturnType> | bigint
|
40
69
|
}
|
41
70
|
|
42
71
|
export type ChainFormatters = {
|
72
|
+
/** Modifies how the Block structure is formatted & typed. */
|
43
73
|
block?: ChainFormatter<'block'>
|
74
|
+
/** Modifies how the Transaction structure is formatted & typed. */
|
44
75
|
transaction?: ChainFormatter<'transaction'>
|
76
|
+
/** Modifies how the TransactionReceipt structure is formatted & typed. */
|
45
77
|
transactionReceipt?: ChainFormatter<'transactionReceipt'>
|
78
|
+
/** Modifies how the TransactionRequest structure is formatted & typed. */
|
46
79
|
transactionRequest?: ChainFormatter<'transactionRequest'>
|
47
80
|
}
|
48
81
|
|
@@ -54,6 +87,7 @@ export type ChainFormatter<type extends string = string> = {
|
|
54
87
|
export type ChainSerializers<
|
55
88
|
formatters extends ChainFormatters | undefined = undefined,
|
56
89
|
> = {
|
90
|
+
/** Modifies how Transactions are serialized. */
|
57
91
|
transaction?: SerializeTransactionFn<
|
58
92
|
formatters extends ChainFormatters
|
59
93
|
? formatters['transactionRequest'] extends ChainFormatter
|
@@ -64,6 +98,40 @@ export type ChainSerializers<
|
|
64
98
|
>
|
65
99
|
}
|
66
100
|
|
101
|
+
/////////////////////////////////////////////////////////////////////
|
102
|
+
// Parameters
|
103
|
+
|
104
|
+
export type ChainFeesFnParameters<
|
105
|
+
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
106
|
+
> = {
|
107
|
+
/** The latest block. */
|
108
|
+
block: Prettify<FormattedBlock<{ formatters: formatters }>>
|
109
|
+
client: Client<Transport, Chain>
|
110
|
+
/**
|
111
|
+
* A transaction request. This value will be undefined if the caller
|
112
|
+
* is outside of a transaction request context (e.g. a direct call to
|
113
|
+
* the `estimateFeesPerGas` Action).
|
114
|
+
*/
|
115
|
+
request?: PrepareTransactionRequestParameters<
|
116
|
+
Omit<Chain, 'formatters'> & { formatters: formatters },
|
117
|
+
Account | undefined,
|
118
|
+
undefined
|
119
|
+
>
|
120
|
+
}
|
121
|
+
|
122
|
+
export type ChainEstimateFeesPerGasFnParameters<
|
123
|
+
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
124
|
+
> = {
|
125
|
+
/**
|
126
|
+
* A function to multiply the base fee based on the `baseFeeMultiplier` value.
|
127
|
+
*/
|
128
|
+
multiply(x: bigint): bigint
|
129
|
+
/**
|
130
|
+
* The type of fees to return.
|
131
|
+
*/
|
132
|
+
type: FeeValuesType
|
133
|
+
} & ChainFeesFnParameters<formatters>
|
134
|
+
|
67
135
|
/////////////////////////////////////////////////////////////////////
|
68
136
|
// Utils
|
69
137
|
|
package/src/types/contract.ts
CHANGED
@@ -217,9 +217,9 @@ export type GetValue<
|
|
217
217
|
_Narrowable extends boolean = IsNarrowable<TAbi, Abi>,
|
218
218
|
> = _Narrowable extends true
|
219
219
|
? TAbiFunction['stateMutability'] extends 'payable'
|
220
|
-
? { value
|
220
|
+
? { value?: NoUndefined<TValueType> }
|
221
221
|
: TAbiFunction['payable'] extends true
|
222
|
-
? { value
|
222
|
+
? { value?: NoUndefined<TValueType> }
|
223
223
|
: { value?: never }
|
224
224
|
: { value?: TValueType }
|
225
225
|
|
package/src/types/eip1193.ts
CHANGED
@@ -51,7 +51,7 @@ export type ProviderMessage = {
|
|
51
51
|
data: unknown
|
52
52
|
}
|
53
53
|
|
54
|
-
type EIP1193EventMap = {
|
54
|
+
export type EIP1193EventMap = {
|
55
55
|
accountsChanged(accounts: Address[]): void
|
56
56
|
chainChanged(chainId: string): void
|
57
57
|
connect(connectInfo: ProviderConnectInfo): void
|
@@ -571,6 +571,18 @@ export type PublicRpcSchema = [
|
|
571
571
|
Parameters: [block: BlockNumber | BlockTag]
|
572
572
|
ReturnType: Quantity
|
573
573
|
},
|
574
|
+
/**
|
575
|
+
* @description Returns the current maxPriorityFeePerGas in wei.
|
576
|
+
* @link https://ethereum.github.io/execution-apis/api-documentation/
|
577
|
+
* @example
|
578
|
+
* provider.request({ method: 'eth_maxPriorityFeePerGas' })
|
579
|
+
* // => '0x5f5e100'
|
580
|
+
*/
|
581
|
+
{
|
582
|
+
Method: 'eth_maxPriorityFeePerGas'
|
583
|
+
Parameters?: undefined
|
584
|
+
ReturnType: Quantity
|
585
|
+
},
|
574
586
|
/**
|
575
587
|
* @description Creates a filter to listen for new blocks that can be used with `eth_getFilterChanges`
|
576
588
|
* @link https://eips.ethereum.org/EIPS/eip-1474
|
@@ -627,7 +639,7 @@ export type PublicRpcSchema = [
|
|
627
639
|
ReturnType: string
|
628
640
|
},
|
629
641
|
/**
|
630
|
-
* @description Sends
|
642
|
+
* @description Sends a **signed** transaction to the network
|
631
643
|
* @link https://eips.ethereum.org/EIPS/eip-1474
|
632
644
|
* @example
|
633
645
|
* provider.request({ method: 'eth_sendRawTransaction', params: ['0x...'] })
|
package/src/types/fee.ts
CHANGED
package/src/utils/chain.ts
CHANGED
@@ -9,7 +9,7 @@ import type {
|
|
9
9
|
ChainContract,
|
10
10
|
ChainFormatters,
|
11
11
|
} from '../types/chain.js'
|
12
|
-
import type { Assign } from '../types/utils.js'
|
12
|
+
import type { Assign, Prettify } from '../types/utils.js'
|
13
13
|
|
14
14
|
export type AssertCurrentChainParameters = {
|
15
15
|
chain?: Chain
|
@@ -31,7 +31,7 @@ export function defineChain<
|
|
31
31
|
>(
|
32
32
|
chain: chain,
|
33
33
|
config: ChainConfig<formatters> = {},
|
34
|
-
): Assign<chain, ChainConfig<formatters
|
34
|
+
): Prettify<Assign<chain, ChainConfig<formatters>>> {
|
35
35
|
const {
|
36
36
|
fees = chain.fees,
|
37
37
|
formatters = chain.formatters,
|
@@ -1,6 +1,9 @@
|
|
1
|
-
import { type ByteArray, type Hex, isHex, toBytes } from '../../index.js'
|
2
1
|
import { equalBytes } from '@noble/curves/abstract/utils'
|
3
2
|
|
3
|
+
import type { ByteArray, Hex } from '../../types/misc.js'
|
4
|
+
import { toBytes } from '../encoding/toBytes.js'
|
5
|
+
import { isHex } from './isHex.js'
|
6
|
+
|
4
7
|
export function isBytesEqual(a_: ByteArray | Hex, b_: ByteArray | Hex) {
|
5
8
|
const a = isHex(a_) ? toBytes(a_) : a_
|
6
9
|
const b = isHex(b_) ? toBytes(b_) : b_
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type { Hex } from '../../
|
2
|
-
import { isHex } from '../
|
1
|
+
import type { Hex } from '../../types/misc.js'
|
2
|
+
import { isHex } from '../data/isHex.js'
|
3
3
|
|
4
4
|
export function encodedLabelToLabelhash(label: string): Hex | null {
|
5
5
|
if (label.length !== 66) return null
|
@@ -15,6 +15,12 @@ export type FormattedTransactionRequest<
|
|
15
15
|
TransactionRequest
|
16
16
|
>
|
17
17
|
|
18
|
+
export const rpcTransactionType = {
|
19
|
+
legacy: '0x0',
|
20
|
+
eip2930: '0x1',
|
21
|
+
eip1559: '0x2',
|
22
|
+
} as const
|
23
|
+
|
18
24
|
export function formatTransactionRequest(
|
19
25
|
transactionRequest: Partial<TransactionRequest>,
|
20
26
|
) {
|
@@ -40,6 +46,10 @@ export function formatTransactionRequest(
|
|
40
46
|
typeof transactionRequest.nonce !== 'undefined'
|
41
47
|
? numberToHex(transactionRequest.nonce)
|
42
48
|
: undefined,
|
49
|
+
type:
|
50
|
+
typeof transactionRequest.type !== 'undefined'
|
51
|
+
? rpcTransactionType[transactionRequest.type]
|
52
|
+
: undefined,
|
43
53
|
value:
|
44
54
|
typeof transactionRequest.value !== 'undefined'
|
45
55
|
? numberToHex(transactionRequest.value)
|
package/src/utils/index.ts
CHANGED
@@ -230,7 +230,10 @@ export {
|
|
230
230
|
assertTransactionLegacy,
|
231
231
|
} from './transaction/assertTransaction.js'
|
232
232
|
export { parseTransaction } from './transaction/parseTransaction.js'
|
233
|
-
export {
|
233
|
+
export {
|
234
|
+
/** @deprecated import `prepareTransactionRequest` from `viem/actions` instead. */
|
235
|
+
prepareTransactionRequest,
|
236
|
+
} from '../actions/wallet/prepareTransactionRequest.js'
|
234
237
|
export {
|
235
238
|
serializeTransaction,
|
236
239
|
type SerializeTransactionFn,
|