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.
Files changed (38) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/_cjs/actions/wallet/sendCalls.js +7 -1
  3. package/_cjs/actions/wallet/sendCalls.js.map +1 -1
  4. package/_cjs/chains/definitions/blast.js +18 -0
  5. package/_cjs/chains/definitions/blast.js.map +1 -1
  6. package/_cjs/chains/definitions/bscTestnet.js +1 -1
  7. package/_cjs/chains/definitions/bscTestnet.js.map +1 -1
  8. package/_cjs/constants/abis.js +1 -1
  9. package/_cjs/constants/abis.js.map +1 -1
  10. package/_cjs/errors/version.js +1 -1
  11. package/_cjs/utils/transaction/serializeTransaction.js +33 -33
  12. package/_cjs/utils/transaction/serializeTransaction.js.map +1 -1
  13. package/_esm/actions/wallet/sendCalls.js +7 -1
  14. package/_esm/actions/wallet/sendCalls.js.map +1 -1
  15. package/_esm/chains/definitions/blast.js +18 -0
  16. package/_esm/chains/definitions/blast.js.map +1 -1
  17. package/_esm/chains/definitions/bscTestnet.js +1 -1
  18. package/_esm/chains/definitions/bscTestnet.js.map +1 -1
  19. package/_esm/constants/abis.js +1 -1
  20. package/_esm/constants/abis.js.map +1 -1
  21. package/_esm/errors/version.js +1 -1
  22. package/_esm/utils/transaction/serializeTransaction.js +34 -34
  23. package/_esm/utils/transaction/serializeTransaction.js.map +1 -1
  24. package/_types/actions/wallet/sendCalls.d.ts.map +1 -1
  25. package/_types/chains/definitions/blast.d.ts +18 -0
  26. package/_types/chains/definitions/blast.d.ts.map +1 -1
  27. package/_types/chains/definitions/bscTestnet.d.ts +1 -1
  28. package/_types/constants/abis.d.ts +1 -1
  29. package/_types/errors/version.d.ts +1 -1
  30. package/_types/utils/transaction/serializeTransaction.d.ts +6 -6
  31. package/_types/utils/transaction/serializeTransaction.d.ts.map +1 -1
  32. package/actions/wallet/sendCalls.ts +7 -1
  33. package/chains/definitions/blast.ts +18 -0
  34. package/chains/definitions/bscTestnet.ts +1 -1
  35. package/constants/abis.ts +1 -1
  36. package/errors/version.ts +1 -1
  37. package/package.json +1 -1
  38. 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 { type ToHexErrorType, bytesToHex, toHex } from '../encoding/toHex.js'
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
- | ToHexErrorType
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
- toHex(chainId),
177
- nonce ? toHex(nonce) : '0x',
178
- maxPriorityFeePerGas ? toHex(maxPriorityFeePerGas) : '0x',
179
- maxFeePerGas ? toHex(maxFeePerGas) : '0x',
180
- gas ? toHex(gas) : '0x',
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 ? toHex(value) : '0x',
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
- | ToHexErrorType
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
- toHex(chainId),
256
- nonce ? toHex(nonce) : '0x',
257
- maxPriorityFeePerGas ? toHex(maxPriorityFeePerGas) : '0x',
258
- maxFeePerGas ? toHex(maxFeePerGas) : '0x',
259
- gas ? toHex(gas) : '0x',
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 ? toHex(value) : '0x',
265
+ value ? numberToHex(value) : '0x',
262
266
  data ?? '0x',
263
267
  serializedAccessList,
264
- maxFeePerBlobGas ? toHex(maxFeePerBlobGas) : '0x',
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
- | ToHexErrorType
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
- toHex(chainId),
321
- nonce ? toHex(nonce) : '0x',
322
- maxPriorityFeePerGas ? toHex(maxPriorityFeePerGas) : '0x',
323
- maxFeePerGas ? toHex(maxFeePerGas) : '0x',
324
- gas ? toHex(gas) : '0x',
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 ? toHex(value) : '0x',
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
- | ToHexErrorType
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
- toHex(chainId),
360
- nonce ? toHex(nonce) : '0x',
361
- gasPrice ? toHex(gasPrice) : '0x',
362
- gas ? toHex(gas) : '0x',
363
+ numberToHex(chainId),
364
+ nonce ? numberToHex(nonce) : '0x',
365
+ gasPrice ? numberToHex(gasPrice) : '0x',
366
+ gas ? numberToHex(gas) : '0x',
363
367
  to ?? '0x',
364
- value ? toHex(value) : '0x',
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
- | ToHexErrorType
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 ? toHex(nonce) : '0x',
393
- gasPrice ? toHex(gasPrice) : '0x',
394
- gas ? toHex(gas) : '0x',
396
+ nonce ? numberToHex(nonce) : '0x',
397
+ gasPrice ? numberToHex(gasPrice) : '0x',
398
+ gas ? numberToHex(gas) : '0x',
395
399
  to ?? '0x',
396
- value ? toHex(value) : '0x',
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
- toHex(v),
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
- toHex(chainId),
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 ? toHex(1) : '0x'
459
+ if (typeof yParity === 'number') return yParity ? numberToHex(1) : '0x'
456
460
  if (v === 0n) return '0x'
457
- if (v === 1n) return toHex(1)
461
+ if (v === 1n) return numberToHex(1)
458
462
 
459
- return v === 27n ? '0x' : toHex(1)
463
+ return v === 27n ? '0x' : numberToHex(1)
460
464
  })()
461
465
 
462
466
  return [yParity_, r === '0x00' ? '0x' : r, s === '0x00' ? '0x' : s]