viem 2.31.0 → 2.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/_cjs/actions/wallet/sendCalls.js +7 -1
- package/_cjs/actions/wallet/sendCalls.js.map +1 -1
- package/_cjs/chains/definitions/blast.js +18 -0
- package/_cjs/chains/definitions/blast.js.map +1 -1
- package/_cjs/chains/definitions/bscTestnet.js +1 -1
- package/_cjs/chains/definitions/bscTestnet.js.map +1 -1
- package/_cjs/constants/abis.js +1 -1
- package/_cjs/constants/abis.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/utils/transaction/serializeTransaction.js +33 -33
- package/_cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/_esm/actions/wallet/sendCalls.js +7 -1
- package/_esm/actions/wallet/sendCalls.js.map +1 -1
- package/_esm/chains/definitions/blast.js +18 -0
- package/_esm/chains/definitions/blast.js.map +1 -1
- package/_esm/chains/definitions/bscTestnet.js +1 -1
- package/_esm/chains/definitions/bscTestnet.js.map +1 -1
- package/_esm/constants/abis.js +1 -1
- package/_esm/constants/abis.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/utils/transaction/serializeTransaction.js +34 -34
- package/_esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/_types/actions/wallet/sendCalls.d.ts.map +1 -1
- package/_types/chains/definitions/blast.d.ts +18 -0
- package/_types/chains/definitions/blast.d.ts.map +1 -1
- package/_types/chains/definitions/bscTestnet.d.ts +1 -1
- package/_types/constants/abis.d.ts +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/utils/transaction/serializeTransaction.d.ts +6 -6
- package/_types/utils/transaction/serializeTransaction.d.ts.map +1 -1
- package/actions/wallet/sendCalls.ts +7 -1
- package/chains/definitions/blast.ts +18 -0
- package/chains/definitions/bscTestnet.ts +1 -1
- package/constants/abis.ts +1 -1
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/utils/transaction/serializeTransaction.ts +43 -39
@@ -48,7 +48,11 @@ import {
|
|
48
48
|
} from '../blob/toBlobSidecars.js'
|
49
49
|
import { type ConcatHexErrorType, concatHex } from '../data/concat.js'
|
50
50
|
import { trim } from '../data/trim.js'
|
51
|
-
import {
|
51
|
+
import {
|
52
|
+
type NumberToHexErrorType,
|
53
|
+
bytesToHex,
|
54
|
+
numberToHex,
|
55
|
+
} from '../encoding/toHex.js'
|
52
56
|
import { type ToRlpErrorType, toRlp } from '../encoding/toRlp.js'
|
53
57
|
|
54
58
|
import {
|
@@ -142,7 +146,7 @@ type SerializeTransactionEIP7702ErrorType =
|
|
142
146
|
| SerializeAuthorizationListErrorType
|
143
147
|
| ConcatHexErrorType
|
144
148
|
| InvalidLegacyVErrorType
|
145
|
-
|
|
149
|
+
| NumberToHexErrorType
|
146
150
|
| ToRlpErrorType
|
147
151
|
| SerializeAccessListErrorType
|
148
152
|
| ErrorType
|
@@ -173,13 +177,13 @@ function serializeTransactionEIP7702(
|
|
173
177
|
return concatHex([
|
174
178
|
'0x04',
|
175
179
|
toRlp([
|
176
|
-
|
177
|
-
nonce ?
|
178
|
-
maxPriorityFeePerGas ?
|
179
|
-
maxFeePerGas ?
|
180
|
-
gas ?
|
180
|
+
numberToHex(chainId),
|
181
|
+
nonce ? numberToHex(nonce) : '0x',
|
182
|
+
maxPriorityFeePerGas ? numberToHex(maxPriorityFeePerGas) : '0x',
|
183
|
+
maxFeePerGas ? numberToHex(maxFeePerGas) : '0x',
|
184
|
+
gas ? numberToHex(gas) : '0x',
|
181
185
|
to ?? '0x',
|
182
|
-
value ?
|
186
|
+
value ? numberToHex(value) : '0x',
|
183
187
|
data ?? '0x',
|
184
188
|
serializedAccessList,
|
185
189
|
serializedAuthorizationList,
|
@@ -196,7 +200,7 @@ type SerializeTransactionEIP4844ErrorType =
|
|
196
200
|
| ToBlobSidecarsErrorType
|
197
201
|
| ConcatHexErrorType
|
198
202
|
| InvalidLegacyVErrorType
|
199
|
-
|
|
203
|
+
| NumberToHexErrorType
|
200
204
|
| ToRlpErrorType
|
201
205
|
| SerializeAccessListErrorType
|
202
206
|
| ErrorType
|
@@ -252,16 +256,16 @@ function serializeTransactionEIP4844(
|
|
252
256
|
const serializedAccessList = serializeAccessList(accessList)
|
253
257
|
|
254
258
|
const serializedTransaction = [
|
255
|
-
|
256
|
-
nonce ?
|
257
|
-
maxPriorityFeePerGas ?
|
258
|
-
maxFeePerGas ?
|
259
|
-
gas ?
|
259
|
+
numberToHex(chainId),
|
260
|
+
nonce ? numberToHex(nonce) : '0x',
|
261
|
+
maxPriorityFeePerGas ? numberToHex(maxPriorityFeePerGas) : '0x',
|
262
|
+
maxFeePerGas ? numberToHex(maxFeePerGas) : '0x',
|
263
|
+
gas ? numberToHex(gas) : '0x',
|
260
264
|
to ?? '0x',
|
261
|
-
value ?
|
265
|
+
value ? numberToHex(value) : '0x',
|
262
266
|
data ?? '0x',
|
263
267
|
serializedAccessList,
|
264
|
-
maxFeePerBlobGas ?
|
268
|
+
maxFeePerBlobGas ? numberToHex(maxFeePerBlobGas) : '0x',
|
265
269
|
blobVersionedHashes ?? [],
|
266
270
|
...toYParitySignatureArray(transaction, signature),
|
267
271
|
] as const
|
@@ -291,7 +295,7 @@ type SerializeTransactionEIP1559ErrorType =
|
|
291
295
|
| AssertTransactionEIP1559ErrorType
|
292
296
|
| ConcatHexErrorType
|
293
297
|
| InvalidLegacyVErrorType
|
294
|
-
|
|
298
|
+
| NumberToHexErrorType
|
295
299
|
| ToRlpErrorType
|
296
300
|
| SerializeAccessListErrorType
|
297
301
|
| ErrorType
|
@@ -317,13 +321,13 @@ function serializeTransactionEIP1559(
|
|
317
321
|
const serializedAccessList = serializeAccessList(accessList)
|
318
322
|
|
319
323
|
const serializedTransaction = [
|
320
|
-
|
321
|
-
nonce ?
|
322
|
-
maxPriorityFeePerGas ?
|
323
|
-
maxFeePerGas ?
|
324
|
-
gas ?
|
324
|
+
numberToHex(chainId),
|
325
|
+
nonce ? numberToHex(nonce) : '0x',
|
326
|
+
maxPriorityFeePerGas ? numberToHex(maxPriorityFeePerGas) : '0x',
|
327
|
+
maxFeePerGas ? numberToHex(maxFeePerGas) : '0x',
|
328
|
+
gas ? numberToHex(gas) : '0x',
|
325
329
|
to ?? '0x',
|
326
|
-
value ?
|
330
|
+
value ? numberToHex(value) : '0x',
|
327
331
|
data ?? '0x',
|
328
332
|
serializedAccessList,
|
329
333
|
...toYParitySignatureArray(transaction, signature),
|
@@ -339,7 +343,7 @@ type SerializeTransactionEIP2930ErrorType =
|
|
339
343
|
| AssertTransactionEIP2930ErrorType
|
340
344
|
| ConcatHexErrorType
|
341
345
|
| InvalidLegacyVErrorType
|
342
|
-
|
|
346
|
+
| NumberToHexErrorType
|
343
347
|
| ToRlpErrorType
|
344
348
|
| SerializeAccessListErrorType
|
345
349
|
| ErrorType
|
@@ -356,12 +360,12 @@ function serializeTransactionEIP2930(
|
|
356
360
|
const serializedAccessList = serializeAccessList(accessList)
|
357
361
|
|
358
362
|
const serializedTransaction = [
|
359
|
-
|
360
|
-
nonce ?
|
361
|
-
gasPrice ?
|
362
|
-
gas ?
|
363
|
+
numberToHex(chainId),
|
364
|
+
nonce ? numberToHex(nonce) : '0x',
|
365
|
+
gasPrice ? numberToHex(gasPrice) : '0x',
|
366
|
+
gas ? numberToHex(gas) : '0x',
|
363
367
|
to ?? '0x',
|
364
|
-
value ?
|
368
|
+
value ? numberToHex(value) : '0x',
|
365
369
|
data ?? '0x',
|
366
370
|
serializedAccessList,
|
367
371
|
...toYParitySignatureArray(transaction, signature),
|
@@ -376,7 +380,7 @@ function serializeTransactionEIP2930(
|
|
376
380
|
type SerializeTransactionLegacyErrorType =
|
377
381
|
| AssertTransactionLegacyErrorType
|
378
382
|
| InvalidLegacyVErrorType
|
379
|
-
|
|
383
|
+
| NumberToHexErrorType
|
380
384
|
| ToRlpErrorType
|
381
385
|
| ErrorType
|
382
386
|
|
@@ -389,11 +393,11 @@ function serializeTransactionLegacy(
|
|
389
393
|
assertTransactionLegacy(transaction)
|
390
394
|
|
391
395
|
let serializedTransaction = [
|
392
|
-
nonce ?
|
393
|
-
gasPrice ?
|
394
|
-
gas ?
|
396
|
+
nonce ? numberToHex(nonce) : '0x',
|
397
|
+
gasPrice ? numberToHex(gasPrice) : '0x',
|
398
|
+
gas ? numberToHex(gas) : '0x',
|
395
399
|
to ?? '0x',
|
396
|
-
value ?
|
400
|
+
value ? numberToHex(value) : '0x',
|
397
401
|
data ?? '0x',
|
398
402
|
]
|
399
403
|
|
@@ -421,14 +425,14 @@ function serializeTransactionLegacy(
|
|
421
425
|
|
422
426
|
serializedTransaction = [
|
423
427
|
...serializedTransaction,
|
424
|
-
|
428
|
+
numberToHex(v),
|
425
429
|
r === '0x00' ? '0x' : r,
|
426
430
|
s === '0x00' ? '0x' : s,
|
427
431
|
]
|
428
432
|
} else if (chainId > 0) {
|
429
433
|
serializedTransaction = [
|
430
434
|
...serializedTransaction,
|
431
|
-
|
435
|
+
numberToHex(chainId),
|
432
436
|
'0x',
|
433
437
|
'0x',
|
434
438
|
]
|
@@ -452,11 +456,11 @@ export function toYParitySignatureArray(
|
|
452
456
|
const s = trim(signature.s)
|
453
457
|
|
454
458
|
const yParity_ = (() => {
|
455
|
-
if (typeof yParity === 'number') return yParity ?
|
459
|
+
if (typeof yParity === 'number') return yParity ? numberToHex(1) : '0x'
|
456
460
|
if (v === 0n) return '0x'
|
457
|
-
if (v === 1n) return
|
461
|
+
if (v === 1n) return numberToHex(1)
|
458
462
|
|
459
|
-
return v === 27n ? '0x' :
|
463
|
+
return v === 27n ? '0x' : numberToHex(1)
|
460
464
|
})()
|
461
465
|
|
462
466
|
return [yParity_, r === '0x00' ? '0x' : r, s === '0x00' ? '0x' : s]
|