viem 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/_cjs/actions/public/getTransaction.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/formatters/block.js +4 -0
- package/_cjs/utils/formatters/block.js.map +1 -1
- package/_cjs/utils/formatters/transaction.js +9 -0
- package/_cjs/utils/formatters/transaction.js.map +1 -1
- package/_cjs/utils/formatters/transactionReceipt.js +6 -1
- package/_cjs/utils/formatters/transactionReceipt.js.map +1 -1
- package/_cjs/utils/formatters/transactionRequest.js +1 -0
- package/_cjs/utils/formatters/transactionRequest.js.map +1 -1
- package/_esm/actions/public/getTransaction.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/utils/formatters/block.js +4 -0
- package/_esm/utils/formatters/block.js.map +1 -1
- package/_esm/utils/formatters/transaction.js +9 -0
- package/_esm/utils/formatters/transaction.js.map +1 -1
- package/_esm/utils/formatters/transactionReceipt.js +6 -1
- package/_esm/utils/formatters/transactionReceipt.js.map +1 -1
- package/_esm/utils/formatters/transactionRequest.js +1 -0
- package/_esm/utils/formatters/transactionRequest.js.map +1 -1
- package/_types/actions/public/getTransaction.d.ts +2 -1
- package/_types/actions/public/getTransaction.d.ts.map +1 -1
- package/_types/chains/celo/chainConfig.d.ts +375 -65
- package/_types/chains/celo/chainConfig.d.ts.map +1 -1
- package/_types/chains/celo/formatters.d.ts +375 -65
- package/_types/chains/celo/formatters.d.ts.map +1 -1
- package/_types/chains/definitions/base.d.ts +279 -49
- package/_types/chains/definitions/base.d.ts.map +1 -1
- package/_types/chains/definitions/baseGoerli.d.ts +279 -49
- package/_types/chains/definitions/baseGoerli.d.ts.map +1 -1
- package/_types/chains/definitions/baseSepolia.d.ts +279 -49
- package/_types/chains/definitions/baseSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/celo.d.ts +375 -65
- package/_types/chains/definitions/celo.d.ts.map +1 -1
- package/_types/chains/definitions/celoAlfajores.d.ts +375 -65
- package/_types/chains/definitions/celoAlfajores.d.ts.map +1 -1
- package/_types/chains/definitions/optimism.d.ts +279 -49
- package/_types/chains/definitions/optimism.d.ts.map +1 -1
- package/_types/chains/definitions/optimismGoerli.d.ts +279 -49
- package/_types/chains/definitions/optimismGoerli.d.ts.map +1 -1
- package/_types/chains/definitions/optimismSepolia.d.ts +279 -49
- package/_types/chains/definitions/optimismSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/pgn.d.ts +279 -49
- package/_types/chains/definitions/pgn.d.ts.map +1 -1
- package/_types/chains/definitions/pgnTestnet.d.ts +279 -49
- package/_types/chains/definitions/pgnTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/zkSync.d.ts +122 -6
- package/_types/chains/definitions/zkSync.d.ts.map +1 -1
- package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts +122 -6
- package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/zkSyncTestnet.d.ts +122 -6
- package/_types/chains/definitions/zkSyncTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/zora.d.ts +279 -49
- package/_types/chains/definitions/zora.d.ts.map +1 -1
- package/_types/chains/definitions/zoraSepolia.d.ts +279 -49
- package/_types/chains/definitions/zoraSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/zoraTestnet.d.ts +279 -49
- package/_types/chains/definitions/zoraTestnet.d.ts.map +1 -1
- package/_types/chains/opStack/chainConfig.d.ts +279 -49
- package/_types/chains/opStack/chainConfig.d.ts.map +1 -1
- package/_types/chains/opStack/formatters.d.ts +279 -49
- package/_types/chains/opStack/formatters.d.ts.map +1 -1
- package/_types/chains/zksync/chainConfig.d.ts +122 -6
- package/_types/chains/zksync/chainConfig.d.ts.map +1 -1
- package/_types/chains/zksync/formatters.d.ts +122 -6
- package/_types/chains/zksync/formatters.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +2 -2
- package/_types/index.d.ts.map +1 -1
- package/_types/types/block.d.ts +4 -0
- package/_types/types/block.d.ts.map +1 -1
- package/_types/types/fee.d.ts +9 -3
- package/_types/types/fee.d.ts.map +1 -1
- package/_types/types/rpc.d.ts +2 -2
- package/_types/types/rpc.d.ts.map +1 -1
- package/_types/types/transaction.d.ts +20 -5
- package/_types/types/transaction.d.ts.map +1 -1
- package/_types/utils/formatters/block.d.ts.map +1 -1
- package/_types/utils/formatters/transaction.d.ts +387 -2
- package/_types/utils/formatters/transaction.d.ts.map +1 -1
- package/_types/utils/formatters/transactionReceipt.d.ts.map +1 -1
- package/_types/utils/formatters/transactionRequest.d.ts +2 -1
- package/_types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/actions/public/getTransaction.ts +2 -1
- package/errors/version.ts +1 -1
- package/index.ts +2 -0
- package/package.json +1 -1
- package/types/block.ts +4 -0
- package/types/fee.ts +14 -2
- package/types/rpc.ts +3 -1
- package/types/transaction.ts +37 -6
- package/utils/formatters/block.ts +4 -0
- package/utils/formatters/transaction.ts +9 -0
- package/utils/formatters/transactionReceipt.ts +8 -1
- package/utils/formatters/transactionRequest.ts +1 -0
package/types/rpc.ts
CHANGED
@@ -11,6 +11,7 @@ import type { Proof } from './proof.js'
|
|
11
11
|
import type {
|
12
12
|
TransactionEIP1559,
|
13
13
|
TransactionEIP2930,
|
14
|
+
TransactionEIP4844,
|
14
15
|
TransactionLegacy,
|
15
16
|
TransactionReceipt,
|
16
17
|
TransactionRequestEIP1559,
|
@@ -50,7 +51,8 @@ export type RpcTransaction<TPending extends boolean = boolean> = UnionOmit<
|
|
50
51
|
UnionPartialBy<
|
51
52
|
| TransactionLegacy<Quantity, Index, TPending, '0x0'>
|
52
53
|
| TransactionEIP2930<Quantity, Index, TPending, '0x1'>
|
53
|
-
| TransactionEIP1559<Quantity, Index, TPending, '0x2'
|
54
|
+
| TransactionEIP1559<Quantity, Index, TPending, '0x2'>
|
55
|
+
| TransactionEIP4844<Quantity, Index, TPending, '0x3'>,
|
54
56
|
// `yParity` is optional on the RPC type as some nodes do not return it
|
55
57
|
// for 1559 & 2930 transactions (they should!).
|
56
58
|
'yParity'
|
package/types/transaction.ts
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
|
-
import type {
|
4
|
-
|
5
|
-
|
3
|
+
import type {
|
4
|
+
FeeValuesEIP1559,
|
5
|
+
FeeValuesEIP4844,
|
6
|
+
FeeValuesLegacy,
|
7
|
+
} from './fee.js'
|
6
8
|
import type { Log } from './log.js'
|
7
9
|
import type { Hash, Hex, Signature } from './misc.js'
|
8
|
-
import type {
|
10
|
+
import type { OneOf } from './utils.js'
|
9
11
|
|
10
12
|
export type AccessList = { address: Address; storageKeys: Hex[] }[]
|
11
13
|
|
12
|
-
export type TransactionType =
|
14
|
+
export type TransactionType =
|
15
|
+
| 'legacy'
|
16
|
+
| 'eip1559'
|
17
|
+
| 'eip2930'
|
18
|
+
| 'eip4844'
|
19
|
+
| (string & {})
|
13
20
|
|
14
21
|
export type TransactionReceipt<
|
15
22
|
TQuantity = bigint,
|
@@ -17,6 +24,10 @@ export type TransactionReceipt<
|
|
17
24
|
TStatus = 'success' | 'reverted',
|
18
25
|
TType = TransactionType,
|
19
26
|
> = {
|
27
|
+
/** The actual value per gas deducted from the sender's account for blob gas. Only specified for blob transactions as defined by EIP-4844. */
|
28
|
+
blobGasPrice?: TQuantity
|
29
|
+
/** The amount of blob gas used. Only specified for blob transactions as defined by EIP-4844. */
|
30
|
+
blobGasUsed?: TQuantity
|
20
31
|
/** Hash of block containing this transaction */
|
21
32
|
blockHash: Hash
|
22
33
|
/** Number of block containing this transaction */
|
@@ -94,6 +105,7 @@ export type TransactionLegacy<
|
|
94
105
|
FeeValuesLegacy<TQuantity> & {
|
95
106
|
/** EIP-2930 Access List. */
|
96
107
|
accessList?: never
|
108
|
+
blobVersionedHashes?: never
|
97
109
|
/** Chain ID that this transaction is valid on. */
|
98
110
|
chainId?: TIndex
|
99
111
|
yParity?: never
|
@@ -108,6 +120,7 @@ export type TransactionEIP2930<
|
|
108
120
|
FeeValuesLegacy<TQuantity> & {
|
109
121
|
/** EIP-2930 Access List. */
|
110
122
|
accessList: AccessList
|
123
|
+
blobVersionedHashes?: never
|
111
124
|
/** Chain ID that this transaction is valid on. */
|
112
125
|
chainId: TIndex
|
113
126
|
type: TType
|
@@ -121,6 +134,22 @@ export type TransactionEIP1559<
|
|
121
134
|
FeeValuesEIP1559<TQuantity> & {
|
122
135
|
/** EIP-2930 Access List. */
|
123
136
|
accessList: AccessList
|
137
|
+
blobVersionedHashes?: never
|
138
|
+
/** Chain ID that this transaction is valid on. */
|
139
|
+
chainId: TIndex
|
140
|
+
type: TType
|
141
|
+
}
|
142
|
+
export type TransactionEIP4844<
|
143
|
+
TQuantity = bigint,
|
144
|
+
TIndex = number,
|
145
|
+
TPending extends boolean = boolean,
|
146
|
+
TType = 'eip4844',
|
147
|
+
> = TransactionBase<TQuantity, TIndex, TPending> &
|
148
|
+
FeeValuesEIP4844<TQuantity> & {
|
149
|
+
/** EIP-2930 Access List. */
|
150
|
+
accessList: AccessList
|
151
|
+
/** List of versioned blob hashes associated with the transaction's blobs. */
|
152
|
+
blobVersionedHashes: Hex[]
|
124
153
|
/** Chain ID that this transaction is valid on. */
|
125
154
|
chainId: TIndex
|
126
155
|
type: TType
|
@@ -129,10 +158,12 @@ export type Transaction<
|
|
129
158
|
TQuantity = bigint,
|
130
159
|
TIndex = number,
|
131
160
|
TPending extends boolean = boolean,
|
132
|
-
> =
|
161
|
+
> = OneOf<
|
133
162
|
| TransactionLegacy<TQuantity, TIndex, TPending>
|
134
163
|
| TransactionEIP2930<TQuantity, TIndex, TPending>
|
135
164
|
| TransactionEIP1559<TQuantity, TIndex, TPending>
|
165
|
+
| TransactionEIP4844<TQuantity, TIndex, TPending>
|
166
|
+
>
|
136
167
|
|
137
168
|
export type TransactionRequestBase<TQuantity = bigint, TIndex = number> = {
|
138
169
|
/** Contract code or a hashed method call with encoded args */
|
@@ -48,7 +48,11 @@ export function formatBlock(block: Partial<RpcBlock>) {
|
|
48
48
|
return {
|
49
49
|
...block,
|
50
50
|
baseFeePerGas: block.baseFeePerGas ? BigInt(block.baseFeePerGas) : null,
|
51
|
+
blobGasUsed: block.blobGasUsed ? BigInt(block.blobGasUsed) : undefined,
|
51
52
|
difficulty: block.difficulty ? BigInt(block.difficulty) : undefined,
|
53
|
+
excessBlobGas: block.excessBlobGas
|
54
|
+
? BigInt(block.excessBlobGas)
|
55
|
+
: undefined,
|
52
56
|
gasLimit: block.gasLimit ? BigInt(block.gasLimit) : undefined,
|
53
57
|
gasUsed: block.gasUsed ? BigInt(block.gasUsed) : undefined,
|
54
58
|
hash: block.hash ? block.hash : null,
|
@@ -37,6 +37,7 @@ export const transactionType = {
|
|
37
37
|
'0x0': 'legacy',
|
38
38
|
'0x1': 'eip2930',
|
39
39
|
'0x2': 'eip1559',
|
40
|
+
'0x3': 'eip4844',
|
40
41
|
} as const
|
41
42
|
|
42
43
|
export type FormatTransactionErrorType = ErrorType
|
@@ -51,6 +52,9 @@ export function formatTransaction(transaction: Partial<RpcTransaction>) {
|
|
51
52
|
chainId: transaction.chainId ? hexToNumber(transaction.chainId) : undefined,
|
52
53
|
gas: transaction.gas ? BigInt(transaction.gas) : undefined,
|
53
54
|
gasPrice: transaction.gasPrice ? BigInt(transaction.gasPrice) : undefined,
|
55
|
+
maxFeePerBlobGas: transaction.maxFeePerBlobGas
|
56
|
+
? BigInt(transaction.maxFeePerBlobGas)
|
57
|
+
: undefined,
|
54
58
|
maxFeePerGas: transaction.maxFeePerGas
|
55
59
|
? BigInt(transaction.maxFeePerGas)
|
56
60
|
: undefined,
|
@@ -86,14 +90,19 @@ export function formatTransaction(transaction: Partial<RpcTransaction>) {
|
|
86
90
|
|
87
91
|
if (transaction_.type === 'legacy') {
|
88
92
|
delete transaction_.accessList
|
93
|
+
delete transaction_.maxFeePerBlobGas
|
89
94
|
delete transaction_.maxFeePerGas
|
90
95
|
delete transaction_.maxPriorityFeePerGas
|
91
96
|
delete transaction_.yParity
|
92
97
|
}
|
93
98
|
if (transaction_.type === 'eip2930') {
|
99
|
+
delete transaction_.maxFeePerBlobGas
|
94
100
|
delete transaction_.maxFeePerGas
|
95
101
|
delete transaction_.maxPriorityFeePerGas
|
96
102
|
}
|
103
|
+
if (transaction_.type === 'eip1559') {
|
104
|
+
delete transaction_.maxFeePerBlobGas
|
105
|
+
}
|
97
106
|
return transaction_
|
98
107
|
}
|
99
108
|
|
@@ -29,7 +29,7 @@ export type FormatTransactionReceiptErrorType = ErrorType
|
|
29
29
|
export function formatTransactionReceipt(
|
30
30
|
transactionReceipt: Partial<RpcTransactionReceipt>,
|
31
31
|
) {
|
32
|
-
|
32
|
+
const receipt = {
|
33
33
|
...transactionReceipt,
|
34
34
|
blockNumber: transactionReceipt.blockNumber
|
35
35
|
? BigInt(transactionReceipt.blockNumber)
|
@@ -62,6 +62,13 @@ export function formatTransactionReceipt(
|
|
62
62
|
] || transactionReceipt.type
|
63
63
|
: null,
|
64
64
|
} as TransactionReceipt
|
65
|
+
|
66
|
+
if (transactionReceipt.blobGasPrice)
|
67
|
+
receipt.blobGasPrice = BigInt(transactionReceipt.blobGasPrice)
|
68
|
+
if (transactionReceipt.blobGasUsed)
|
69
|
+
receipt.blobGasUsed = BigInt(transactionReceipt.blobGasUsed)
|
70
|
+
|
71
|
+
return receipt
|
65
72
|
}
|
66
73
|
|
67
74
|
export type DefineTransactionReceiptErrorType =
|