viem 2.55.2 → 2.55.5

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 (110) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/_cjs/actions/public/multicall.js +65 -18
  3. package/_cjs/actions/public/multicall.js.map +1 -1
  4. package/_cjs/actions/wallet/prepareTransactionRequest.js +8 -1
  5. package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
  6. package/_cjs/chains/definitions/mainnet.js +1 -1
  7. package/_cjs/chains/definitions/mainnet.js.map +1 -1
  8. package/_cjs/chains/definitions/robinhood.js +1 -0
  9. package/_cjs/chains/definitions/robinhood.js.map +1 -1
  10. package/_cjs/chains/definitions/xLayer.js +1 -0
  11. package/_cjs/chains/definitions/xLayer.js.map +1 -1
  12. package/_cjs/errors/version.js +1 -1
  13. package/_cjs/tempo/Transaction.js +1 -1
  14. package/_cjs/tempo/Transaction.js.map +1 -1
  15. package/_cjs/tempo/chainConfig.js +9 -0
  16. package/_cjs/tempo/chainConfig.js.map +1 -1
  17. package/_cjs/utils/abi/decodeAbiParameters.js +1 -2
  18. package/_cjs/utils/abi/decodeAbiParameters.js.map +1 -1
  19. package/_cjs/utils/unit/Value.js +118 -0
  20. package/_cjs/utils/unit/Value.js.map +1 -0
  21. package/_cjs/utils/unit/formatEther.js +2 -3
  22. package/_cjs/utils/unit/formatEther.js.map +1 -1
  23. package/_cjs/utils/unit/formatGwei.js +2 -3
  24. package/_cjs/utils/unit/formatGwei.js.map +1 -1
  25. package/_cjs/utils/unit/formatUnits.js +2 -11
  26. package/_cjs/utils/unit/formatUnits.js.map +1 -1
  27. package/_cjs/utils/unit/parseEther.js +2 -3
  28. package/_cjs/utils/unit/parseEther.js.map +1 -1
  29. package/_cjs/utils/unit/parseGwei.js +2 -3
  30. package/_cjs/utils/unit/parseGwei.js.map +1 -1
  31. package/_cjs/utils/unit/parseUnits.js +2 -34
  32. package/_cjs/utils/unit/parseUnits.js.map +1 -1
  33. package/_esm/actions/public/multicall.js +65 -18
  34. package/_esm/actions/public/multicall.js.map +1 -1
  35. package/_esm/actions/wallet/prepareTransactionRequest.js +25 -1
  36. package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
  37. package/_esm/chains/definitions/mainnet.js +1 -1
  38. package/_esm/chains/definitions/mainnet.js.map +1 -1
  39. package/_esm/chains/definitions/robinhood.js +1 -0
  40. package/_esm/chains/definitions/robinhood.js.map +1 -1
  41. package/_esm/chains/definitions/xLayer.js +1 -0
  42. package/_esm/chains/definitions/xLayer.js.map +1 -1
  43. package/_esm/errors/version.js +1 -1
  44. package/_esm/tempo/Transaction.js +1 -1
  45. package/_esm/tempo/Transaction.js.map +1 -1
  46. package/_esm/tempo/chainConfig.js +10 -0
  47. package/_esm/tempo/chainConfig.js.map +1 -1
  48. package/_esm/utils/abi/decodeAbiParameters.js +1 -2
  49. package/_esm/utils/abi/decodeAbiParameters.js.map +1 -1
  50. package/_esm/utils/unit/Value.js +240 -0
  51. package/_esm/utils/unit/Value.js.map +1 -0
  52. package/_esm/utils/unit/formatEther.js +2 -3
  53. package/_esm/utils/unit/formatEther.js.map +1 -1
  54. package/_esm/utils/unit/formatGwei.js +2 -3
  55. package/_esm/utils/unit/formatGwei.js.map +1 -1
  56. package/_esm/utils/unit/formatUnits.js +2 -11
  57. package/_esm/utils/unit/formatUnits.js.map +1 -1
  58. package/_esm/utils/unit/parseEther.js +2 -3
  59. package/_esm/utils/unit/parseEther.js.map +1 -1
  60. package/_esm/utils/unit/parseGwei.js +2 -3
  61. package/_esm/utils/unit/parseGwei.js.map +1 -1
  62. package/_esm/utils/unit/parseUnits.js +2 -36
  63. package/_esm/utils/unit/parseUnits.js.map +1 -1
  64. package/_types/actions/public/multicall.d.ts +2 -1
  65. package/_types/actions/public/multicall.d.ts.map +1 -1
  66. package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
  67. package/_types/chains/definitions/mainnet.d.ts +1 -1
  68. package/_types/chains/definitions/robinhood.d.ts +1 -1
  69. package/_types/chains/definitions/robinhood.d.ts.map +1 -1
  70. package/_types/chains/definitions/tempo.d.ts +22 -22
  71. package/_types/chains/definitions/tempoDevnet.d.ts +22 -22
  72. package/_types/chains/definitions/tempoLocalnet.d.ts +22 -22
  73. package/_types/chains/definitions/tempoModerato.d.ts +22 -22
  74. package/_types/chains/definitions/xLayer.d.ts +1 -1
  75. package/_types/chains/definitions/xLayer.d.ts.map +1 -1
  76. package/_types/errors/version.d.ts +1 -1
  77. package/_types/tempo/chainConfig.d.ts +11 -11
  78. package/_types/tempo/chainConfig.d.ts.map +1 -1
  79. package/_types/tempo/zones/zone.d.ts +66 -66
  80. package/_types/utils/abi/decodeAbiParameters.d.ts +1 -2
  81. package/_types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
  82. package/_types/utils/unit/Value.d.ts +115 -0
  83. package/_types/utils/unit/Value.d.ts.map +1 -0
  84. package/_types/utils/unit/formatEther.d.ts +1 -1
  85. package/_types/utils/unit/formatEther.d.ts.map +1 -1
  86. package/_types/utils/unit/formatGwei.d.ts +1 -1
  87. package/_types/utils/unit/formatGwei.d.ts.map +1 -1
  88. package/_types/utils/unit/formatUnits.d.ts.map +1 -1
  89. package/_types/utils/unit/parseEther.d.ts +1 -1
  90. package/_types/utils/unit/parseEther.d.ts.map +1 -1
  91. package/_types/utils/unit/parseGwei.d.ts +1 -1
  92. package/_types/utils/unit/parseGwei.d.ts.map +1 -1
  93. package/_types/utils/unit/parseUnits.d.ts.map +1 -1
  94. package/actions/public/multicall.ts +92 -12
  95. package/actions/wallet/prepareTransactionRequest.ts +28 -1
  96. package/chains/definitions/mainnet.ts +1 -1
  97. package/chains/definitions/robinhood.ts +1 -0
  98. package/chains/definitions/xLayer.ts +1 -0
  99. package/errors/version.ts +1 -1
  100. package/package.json +2 -2
  101. package/tempo/Transaction.ts +1 -1
  102. package/tempo/chainConfig.ts +10 -0
  103. package/utils/abi/decodeAbiParameters.ts +1 -3
  104. package/utils/unit/Value.ts +278 -0
  105. package/utils/unit/formatEther.ts +3 -4
  106. package/utils/unit/formatGwei.ts +3 -4
  107. package/utils/unit/formatUnits.ts +2 -15
  108. package/utils/unit/parseEther.ts +3 -4
  109. package/utils/unit/parseGwei.ts +3 -4
  110. package/utils/unit/parseUnits.ts +2 -40
@@ -6,7 +6,6 @@ import { type ChecksumAddressErrorType } from '../address/getAddress.js';
6
6
  import { type CreateCursorErrorType } from '../cursor.js';
7
7
  import { type SizeErrorType } from '../data/size.js';
8
8
  import { type SliceBytesErrorType } from '../data/slice.js';
9
- import { type TrimErrorType } from '../data/trim.js';
10
9
  import { type BytesToBigIntErrorType, type BytesToBoolErrorType, type BytesToNumberErrorType, type BytesToStringErrorType } from '../encoding/fromBytes.js';
11
10
  import { type HexToBytesErrorType } from '../encoding/toBytes.js';
12
11
  import { type BytesToHexErrorType } from '../encoding/toHex.js';
@@ -20,6 +19,6 @@ type DecodeBoolErrorType = BytesToBoolErrorType | ErrorType;
20
19
  type DecodeBytesErrorType = BytesToNumberErrorType | BytesToHexErrorType | ErrorType;
21
20
  type DecodeNumberErrorType = BytesToNumberErrorType | BytesToBigIntErrorType | ErrorType;
22
21
  type DecodeTupleErrorType = BytesToNumberErrorType | ErrorType;
23
- type DecodeStringErrorType = BytesToNumberErrorType | BytesToStringErrorType | TrimErrorType | ErrorType;
22
+ type DecodeStringErrorType = BytesToNumberErrorType | BytesToStringErrorType | ErrorType;
24
23
  export {};
25
24
  //# sourceMappingURL=decodeAbiParameters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decodeAbiParameters.d.ts","sourceRoot":"","sources":["../../../utils/abi/decodeAbiParameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,6BAA6B,EAC9B,MAAM,SAAS,CAAA;AAChB,OAAO,EAIL,KAAK,+BAA+B,EACrC,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,SAAS,EAA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to its string representation (divided by the given exponent).
3
+ *
4
+ * @example
5
+ * ```ts twoslash
6
+ * import { Value } from 'ox'
7
+ *
8
+ * Value.format(420_000_000_000n, 9)
9
+ * // @log: '420'
10
+ * ```
11
+ *
12
+ * @param value - The `bigint` Value to format.
13
+ * @param decimals - The exponent to divide the `bigint` Value by.
14
+ * @returns The string representation of the Value.
15
+ */
16
+ export declare function format(value: bigint, decimals?: number): string;
17
+ export declare namespace format {
18
+ type ErrorType = Error;
19
+ }
20
+ /**
21
+ * Formats a `bigint` Value (default: wei) to a string representation of Ether.
22
+ *
23
+ * @example
24
+ * ```ts twoslash
25
+ * import { Value } from 'ox'
26
+ *
27
+ * Value.formatEther(1_000_000_000_000_000_000n)
28
+ * // @log: '1'
29
+ * ```
30
+ *
31
+ * @param wei - The Value to format.
32
+ * @param unit - The unit to format the Value in. @default 'wei'.
33
+ * @returns The Ether string representation of the Value.
34
+ */
35
+ export declare function formatEther(wei: bigint, unit?: 'wei' | 'gwei' | 'szabo' | 'finney'): string;
36
+ export declare namespace formatEther {
37
+ type ErrorType = format.ErrorType | Error;
38
+ }
39
+ /**
40
+ * Formats a `bigint` Value (default: wei) to a string representation of Gwei.
41
+ *
42
+ * @example
43
+ * ```ts twoslash
44
+ * import { Value } from 'ox'
45
+ *
46
+ * Value.formatGwei(1_000_000_000n)
47
+ * // @log: '1'
48
+ * ```
49
+ *
50
+ * @param wei - The Value to format.
51
+ * @param unit - The unit to format the Value in. @default 'wei'.
52
+ * @returns The Gwei string representation of the Value.
53
+ */
54
+ export declare function formatGwei(wei: bigint, unit?: 'wei'): string;
55
+ export declare namespace formatGwei {
56
+ type ErrorType = format.ErrorType | Error;
57
+ }
58
+ /**
59
+ * Parses a `string` representation of a Value to `bigint` (multiplied by the given exponent).
60
+ *
61
+ * @example
62
+ * ```ts twoslash
63
+ * import { Value } from 'ox'
64
+ *
65
+ * Value.from('420', 9)
66
+ * // @log: 420000000000n
67
+ * ```
68
+ *
69
+ * @param value - The string representation of the Value.
70
+ * @param decimals - The exponent to multiply the Value by.
71
+ * @returns The `bigint` representation of the Value.
72
+ */
73
+ export declare function from(value: string, decimals?: number): bigint;
74
+ export declare namespace from {
75
+ type ErrorType = Error;
76
+ }
77
+ /**
78
+ * Parses a string representation of Ether to a `bigint` Value (default: wei).
79
+ *
80
+ * @example
81
+ * ```ts twoslash
82
+ * import { Value } from 'ox'
83
+ *
84
+ * Value.fromEther('420')
85
+ * // @log: 420000000000000000000n
86
+ * ```
87
+ *
88
+ * @param ether - String representation of Ether.
89
+ * @param unit - The unit to parse to. @default 'wei'.
90
+ * @returns A `bigint` Value.
91
+ */
92
+ export declare function fromEther(ether: string, unit?: 'wei' | 'gwei' | 'szabo' | 'finney'): bigint;
93
+ export declare namespace fromEther {
94
+ type ErrorType = from.ErrorType | Error;
95
+ }
96
+ /**
97
+ * Parses a string representation of Gwei to a `bigint` Value (default: wei).
98
+ *
99
+ * @example
100
+ * ```ts twoslash
101
+ * import { Value } from 'ox'
102
+ *
103
+ * Value.fromGwei('420')
104
+ * // @log: 420000000000n
105
+ * ```
106
+ *
107
+ * @param gwei - String representation of Gwei.
108
+ * @param unit - The unit to parse to. @default 'wei'.
109
+ * @returns A `bigint` Value.
110
+ */
111
+ export declare function fromGwei(gwei: string, unit?: 'wei'): bigint;
112
+ export declare namespace fromGwei {
113
+ type ErrorType = from.ErrorType | Error;
114
+ }
115
+ //# sourceMappingURL=Value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Value.d.ts","sourceRoot":"","sources":["../../../utils/unit/Value.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,UAmBjD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,KAAK,SAAS,GAAG,KAAK,CAAA;CACvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAgB,UAGlD;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,KAAK,SAAS,GAAG,MAAM,CAAC,SAAS,GAAG,KAAK,CAAA;CAC1C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,KAAa,UAE1D;AAED,MAAM,CAAC,OAAO,WAAW,UAAU,CAAC;IAClC,KAAK,SAAS,GAAG,MAAM,CAAC,SAAS,GAAG,KAAK,CAAA;CAC1C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,UAmD/C;AAwBD,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,KAAK,SAAS,GAAG,KAAK,CAAA;CACvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAgB,UAGlD;AAED,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,KAAK,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;CACxC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,KAAa,UAEzD;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,KAAK,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;CACxC"}
@@ -1,4 +1,4 @@
1
- import { type FormatUnitsErrorType } from './formatUnits.js';
1
+ import type { FormatUnitsErrorType } from './formatUnits.js';
2
2
  export type FormatEtherErrorType = FormatUnitsErrorType;
3
3
  /**
4
4
  * Converts numerical wei to a string representation of ether.
@@ -1 +1 @@
1
- {"version":3,"file":"formatEther.d.ts","sourceRoot":"","sources":["../../../utils/unit/formatEther.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,oBAAoB,EAAe,MAAM,kBAAkB,CAAA;AAEzE,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,CAAA;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,KAAK,GAAG,MAAc,UAEpE"}
1
+ {"version":3,"file":"formatEther.d.ts","sourceRoot":"","sources":["../../../utils/unit/formatEther.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAG5D,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,CAAA;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,KAAK,GAAG,MAAc,UAEpE"}
@@ -1,4 +1,4 @@
1
- import { type FormatUnitsErrorType } from './formatUnits.js';
1
+ import type { FormatUnitsErrorType } from './formatUnits.js';
2
2
  export type FormatGweiErrorType = FormatUnitsErrorType;
3
3
  /**
4
4
  * Converts numerical wei to a string representation of gwei.
@@ -1 +1 @@
1
- {"version":3,"file":"formatGwei.d.ts","sourceRoot":"","sources":["../../../utils/unit/formatGwei.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,oBAAoB,EAAe,MAAM,kBAAkB,CAAA;AAEzE,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,KAAa,UAE1D"}
1
+ {"version":3,"file":"formatGwei.d.ts","sourceRoot":"","sources":["../../../utils/unit/formatGwei.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAG5D,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,KAAa,UAE1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatUnits.d.ts","sourceRoot":"","sources":["../../../utils/unit/formatUnits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAgB1D"}
1
+ {"version":3,"file":"formatUnits.d.ts","sourceRoot":"","sources":["../../../utils/unit/formatUnits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGtD,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAE1D"}
@@ -1,5 +1,5 @@
1
1
  import type { ErrorType } from '../../errors/utils.js';
2
- import { type ParseUnitsErrorType } from './parseUnits.js';
2
+ import type { ParseUnitsErrorType } from './parseUnits.js';
3
3
  export type ParseEtherErrorType = ParseUnitsErrorType | ErrorType;
4
4
  /**
5
5
  * Converts a string representation of ether to numerical wei.
@@ -1 +1 @@
1
- {"version":3,"file":"parseEther.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseEther.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,iBAAiB,CAAA;AAEtE,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,GAAG,SAAS,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,KAAK,GAAG,MAAc,UAErE"}
1
+ {"version":3,"file":"parseEther.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseEther.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAG1D,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,GAAG,SAAS,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,KAAK,GAAG,MAAc,UAErE"}
@@ -1,5 +1,5 @@
1
1
  import type { ErrorType } from '../../errors/utils.js';
2
- import { type ParseUnitsErrorType } from './parseUnits.js';
2
+ import type { ParseUnitsErrorType } from './parseUnits.js';
3
3
  export type ParseGweiErrorType = ParseUnitsErrorType | ErrorType;
4
4
  /**
5
5
  * Converts a string representation of gwei to numerical wei.
@@ -1 +1 @@
1
- {"version":3,"file":"parseGwei.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseGwei.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,iBAAiB,CAAA;AAEtE,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,CAAA;AAEhE;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,KAAa,UAE3D"}
1
+ {"version":3,"file":"parseGwei.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseGwei.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAG1D,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,CAAA;AAEhE;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,KAAa,UAE3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"parseUnits.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseUnits.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAE3C;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAwCzD"}
1
+ {"version":3,"file":"parseUnits.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseUnits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGtD,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAE3C;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAEzD"}
@@ -32,6 +32,11 @@ import {
32
32
  getContractError,
33
33
  } from '../../utils/errors/getContractError.js'
34
34
  import { getAction } from '../../utils/getAction.js'
35
+ import {
36
+ type CreateBatchSchedulerErrorType,
37
+ createBatchScheduler,
38
+ } from '../../utils/promise/createBatchScheduler.js'
39
+ import { stringify } from '../../utils/stringify.js'
35
40
  import type { CallParameters } from './call.js'
36
41
  import { type ReadContractErrorType, readContract } from './readContract.js'
37
42
 
@@ -82,6 +87,7 @@ export type MulticallReturnType<
82
87
  >
83
88
 
84
89
  export type MulticallErrorType =
90
+ | CreateBatchSchedulerErrorType
85
91
  | GetChainContractAddressErrorType
86
92
  | ReadContractErrorType
87
93
  | GetContractErrorReturnType<
@@ -89,6 +95,14 @@ export type MulticallErrorType =
89
95
  >
90
96
  | ErrorType
91
97
 
98
+ type Aggregate3Call = {
99
+ allowFailure: boolean
100
+ callData: Hex
101
+ target: Address
102
+ }
103
+
104
+ type Aggregate3Calls = Aggregate3Call[]
105
+
92
106
  /**
93
107
  * Similar to [`readContract`](https://viem.sh/docs/contract/readContract), but batches up multiple functions on a contract in a single RPC call via the [`multicall3` contract](https://github.com/mds1/multicall).
94
108
  *
@@ -169,12 +183,6 @@ export async function multicall<
169
183
  )
170
184
  })()
171
185
 
172
- type Aggregate3Calls = {
173
- allowFailure: boolean
174
- callData: Hex
175
- target: Address
176
- }[]
177
-
178
186
  const chunkedCalls: Aggregate3Calls[] = [[]]
179
187
  let currentChunk = 0
180
188
  let currentChunkSize = 0
@@ -227,9 +235,27 @@ export async function multicall<
227
235
  }
228
236
  }
229
237
 
238
+ const batching = Boolean(client.batch?.multicall)
239
+ const batches = batching
240
+ ? chunkedCalls.flatMap((calls) => calls.map((call) => [call]))
241
+ : chunkedCalls
230
242
  const aggregate3Results = await Promise.allSettled(
231
- chunkedCalls.map((calls) =>
232
- getAction(
243
+ batches.map((calls) => {
244
+ if (batching)
245
+ return scheduleMulticall(client, {
246
+ account,
247
+ authorizationList,
248
+ batchSize,
249
+ blockHash,
250
+ blockNumber,
251
+ blockOverrides,
252
+ blockTag,
253
+ call: calls[0]!,
254
+ multicallAddress,
255
+ requireCanonical,
256
+ stateOverride,
257
+ }).then((result) => [result])
258
+ return getAction(
233
259
  client,
234
260
  readContract,
235
261
  'readContract',
@@ -248,8 +274,8 @@ export async function multicall<
248
274
  functionName: 'aggregate3',
249
275
  requireCanonical,
250
276
  stateOverride,
251
- }),
252
- ),
277
+ })
278
+ }),
253
279
  )
254
280
 
255
281
  const results = []
@@ -260,7 +286,7 @@ export async function multicall<
260
286
  // then append the failure reason to each contract result.
261
287
  if (result.status === 'rejected') {
262
288
  if (!allowFailure) throw result.reason
263
- for (let j = 0; j < chunkedCalls[i].length; j++) {
289
+ for (let j = 0; j < batches[i].length; j++) {
264
290
  results.push({
265
291
  status: 'failure',
266
292
  error: result.reason,
@@ -277,7 +303,7 @@ export async function multicall<
277
303
  const { returnData, success } = aggregate3Result[j]
278
304
 
279
305
  // Extract the request call data from the original call.
280
- const { callData } = chunkedCalls[i][j]
306
+ const { callData } = batches[i][j]
281
307
 
282
308
  // Extract the contract config for this call from the `contracts` argument
283
309
  // for decoding.
@@ -313,3 +339,57 @@ export async function multicall<
313
339
  throw new BaseError('multicall results mismatch')
314
340
  return results as MulticallReturnType<contracts, allowFailure>
315
341
  }
342
+
343
+ type ScheduleMulticallParameters = Pick<
344
+ MulticallParameters,
345
+ | 'account'
346
+ | 'authorizationList'
347
+ | 'blockHash'
348
+ | 'blockNumber'
349
+ | 'blockOverrides'
350
+ | 'blockTag'
351
+ | 'requireCanonical'
352
+ | 'stateOverride'
353
+ > & {
354
+ batchSize: number
355
+ call: Aggregate3Call
356
+ multicallAddress: Address | null
357
+ }
358
+
359
+ async function scheduleMulticall(
360
+ client: Client<Transport>,
361
+ parameters: ScheduleMulticallParameters,
362
+ ) {
363
+ const { batchSize, call, multicallAddress, ...rest } = parameters
364
+ const { wait = 0 } =
365
+ typeof client.batch?.multicall === 'object' ? client.batch.multicall : {}
366
+ const { schedule } = createBatchScheduler({
367
+ id: stringify(['multicall', client.uid, batchSize, multicallAddress, rest]),
368
+ wait,
369
+ shouldSplitBatch(calls: Aggregate3Calls) {
370
+ if (batchSize === 0) return false
371
+ const size = calls.reduce(
372
+ (size, { callData }) => size + (callData.length - 2) / 2,
373
+ 0,
374
+ )
375
+ return size > batchSize
376
+ },
377
+ fn: (calls: Aggregate3Calls) =>
378
+ getAction(
379
+ client,
380
+ readContract,
381
+ 'readContract',
382
+ )({
383
+ ...(multicallAddress === null
384
+ ? { code: multicall3Bytecode }
385
+ : { address: multicallAddress }),
386
+ ...rest,
387
+ abi: multicall3Abi,
388
+ args: [calls],
389
+ functionName: 'aggregate3',
390
+ }),
391
+ })
392
+
393
+ const [result] = await schedule(call)
394
+ return result
395
+ }
@@ -337,7 +337,7 @@ export async function prepareTransactionRequest<
337
337
  return chainId
338
338
  }
339
339
 
340
- const account = account_ ? parseAccount(account_) : account_
340
+ let account = account_ ? parseAccount(account_) : account_
341
341
 
342
342
  let nonce = request.nonce
343
343
  if (
@@ -366,6 +366,8 @@ export async function prepareTransactionRequest<
366
366
  },
367
367
  )
368
368
  nonce ??= request.nonce
369
+ const sender = request.account ?? (request as TransactionRequest).from
370
+ account = sender ? parseAccount(sender) : undefined
369
371
  }
370
372
 
371
373
  const attemptFill = (() => {
@@ -381,6 +383,31 @@ export async function prepareTransactionRequest<
381
383
  // Do not attempt if `eth_fillTransaction` is not supported.
382
384
  if (supportsFillTransaction.get(client.uid) === false) return false
383
385
 
386
+ // Always attempt if the caller explicitly requested a non-empty set of
387
+ // `parameters` and a fee payer signature is being requested (e.g. Tempo
388
+ // sponsorship via `feePayer: true`/`Account`) and has not already been
389
+ // filled. The fee payer signature can only be obtained as a side effect
390
+ // of `eth_fillTransaction` (the relay co-signs the returned transaction),
391
+ // so it must be called even when nonce/gas/fees are already fully
392
+ // populated, or when the caller's `parameters` option omits `'fees'`/
393
+ // `'gas'` entirely — otherwise the transaction silently ends up without
394
+ // a fee payer signature. This check intentionally runs before the
395
+ // `shouldAttempt` gate below, since fee-payer sponsorship is independent
396
+ // of which parameters the caller opted into filling.
397
+ //
398
+ // The `parameters.length > 0` guard excludes internal micro-prepare calls
399
+ // that explicitly pass an empty `parameters` array (e.g. `estimateGas`'s
400
+ // internal `prepareTransactionRequest` call for local accounts) — those
401
+ // are deliberately scoped to fill nothing, and should not independently
402
+ // re-attempt `eth_fillTransaction` for fee-payer sponsorship.
403
+ if (
404
+ parameters.length > 0 &&
405
+ 'feePayer' in request &&
406
+ (request as any).feePayer &&
407
+ !('feePayerSignature' in request && (request as any).feePayerSignature)
408
+ )
409
+ return true
410
+
384
411
  // Should attempt `eth_fillTransaction` if "fees" or "gas" are required to be populated,
385
412
  // otherwise, can just use the other individual calls.
386
413
  const shouldAttempt = ['fees', 'gas'].some((parameter) =>
@@ -7,7 +7,7 @@ export const mainnet = /*#__PURE__*/ defineChain({
7
7
  blockTime: 12_000,
8
8
  rpcUrls: {
9
9
  default: {
10
- http: ['https://eth.merkle.io'],
10
+ http: ['https://ethereum.reth.rs/rpc'],
11
11
  },
12
12
  },
13
13
  blockExplorers: {
@@ -4,6 +4,7 @@ export const robinhood = /*#__PURE__*/ defineChain({
4
4
  id: 4663,
5
5
  name: 'Robinhood Chain',
6
6
  nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
7
+ blockTime: 100,
7
8
  rpcUrls: {
8
9
  default: {
9
10
  http: ['https://rpc.mainnet.chain.robinhood.com'],
@@ -8,6 +8,7 @@ export const xLayer = /*#__PURE__*/ defineChain({
8
8
  name: 'OKB',
9
9
  symbol: 'OKB',
10
10
  },
11
+ blockTime: 1_000,
11
12
  rpcUrls: {
12
13
  default: { http: ['https://xlayerrpc.okx.com'] },
13
14
  },
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.55.2'
1
+ export const version = '2.55.5'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.55.2",
4
+ "version": "2.55.5",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -234,7 +234,7 @@
234
234
  "@scure/bip39": "1.6.0",
235
235
  "abitype": "1.2.3",
236
236
  "isows": "1.0.7",
237
- "ox": "0.14.30",
237
+ "ox": "0.14.31",
238
238
  "ws": "8.21.0"
239
239
  },
240
240
  "license": "MIT",
@@ -379,7 +379,7 @@ async function serializeTempo(
379
379
  return SignatureEnvelope.from({
380
380
  genesisConfig: transaction.multisig,
381
381
  signatures: sorted,
382
- ...(nonce ? {} : { init: true }),
382
+ ...(nonce || transaction.nonceKey ? {} : { init: true }),
383
383
  })
384
384
  })()
385
385
 
@@ -22,6 +22,14 @@ import * as Transaction from './Transaction.js'
22
22
 
23
23
  const maxExpirySecs = 25
24
24
 
25
+ /** Returns random past seconds to distinguish otherwise-identical expiring transactions. */
26
+ function randomValidAfter(): number {
27
+ const now = BigInt(Math.floor(Date.now() / 1_000))
28
+ const latest = now - 60n
29
+ if (latest <= 0n) return 0
30
+ return Number(BigInt(Hex.random(8)) % latest)
31
+ }
32
+
25
33
  export const chainConfig = {
26
34
  blockTime: 1_000,
27
35
  extendSchema: extendSchema<{
@@ -160,6 +168,8 @@ export const chainConfig = {
160
168
  if (useExpiringNonce) {
161
169
  request.nonceKey = maxUint256
162
170
  request.nonce = 0
171
+ if (typeof request.validAfter === 'undefined')
172
+ request.validAfter = randomValidAfter()
163
173
  if (typeof request.validBefore === 'undefined')
164
174
  request.validBefore = Math.floor(Date.now() / 1000) + maxExpirySecs
165
175
  } else if (typeof request.nonceKey !== 'undefined') {
@@ -22,7 +22,6 @@ import {
22
22
  } from '../cursor.js'
23
23
  import { type SizeErrorType, size } from '../data/size.js'
24
24
  import { type SliceBytesErrorType, sliceBytes } from '../data/slice.js'
25
- import { type TrimErrorType, trim } from '../data/trim.js'
26
25
  import {
27
26
  type BytesToBigIntErrorType,
28
27
  type BytesToBoolErrorType,
@@ -355,7 +354,6 @@ function decodeTuple(
355
354
  type DecodeStringErrorType =
356
355
  | BytesToNumberErrorType
357
356
  | BytesToStringErrorType
358
- | TrimErrorType
359
357
  | ErrorType
360
358
 
361
359
  function decodeString(
@@ -378,7 +376,7 @@ function decodeString(
378
376
  }
379
377
 
380
378
  const data = cursor.readBytes(length, 32)
381
- const value = bytesToString(trim(data))
379
+ const value = bytesToString(data)
382
380
 
383
381
  // As we have gone wondering, restore to the original position + next slot.
384
382
  cursor.setPosition(staticPosition + 32)