viem 2.57.11 → 2.57.12

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 (315) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/_cjs/actions/public/waitForTransactionReceipt.js +83 -23
  3. package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  4. package/_cjs/actions/public/watchEvent.js +1 -0
  5. package/_cjs/actions/public/watchEvent.js.map +1 -1
  6. package/_cjs/actions/token/approve.js +1 -1
  7. package/_cjs/actions/token/approve.js.map +1 -1
  8. package/_cjs/actions/token/getAllowance.js +1 -1
  9. package/_cjs/actions/token/getAllowance.js.map +1 -1
  10. package/_cjs/actions/token/getBalance.js +1 -1
  11. package/_cjs/actions/token/getBalance.js.map +1 -1
  12. package/_cjs/actions/token/getTotalSupply.js +1 -1
  13. package/_cjs/actions/token/getTotalSupply.js.map +1 -1
  14. package/_cjs/actions/token/transfer.js +1 -1
  15. package/_cjs/actions/token/transfer.js.map +1 -1
  16. package/_cjs/actions/wallet/sendCalls.js +1 -1
  17. package/_cjs/actions/wallet/sendCalls.js.map +1 -1
  18. package/_cjs/chains/definitions/valuechain.js +22 -0
  19. package/_cjs/chains/definitions/valuechain.js.map +1 -0
  20. package/_cjs/chains/definitions/valuechainTestnet.js +23 -0
  21. package/_cjs/chains/definitions/valuechainTestnet.js.map +1 -0
  22. package/_cjs/chains/index.js +6 -2
  23. package/_cjs/chains/index.js.map +1 -1
  24. package/_cjs/clients/decorators/public.js.map +1 -1
  25. package/_cjs/clients/transports/http.js +5 -1
  26. package/_cjs/clients/transports/http.js.map +1 -1
  27. package/_cjs/errors/node.js +1 -1
  28. package/_cjs/errors/node.js.map +1 -1
  29. package/_cjs/errors/request.js +20 -2
  30. package/_cjs/errors/request.js.map +1 -1
  31. package/_cjs/errors/typedData.js +3 -1
  32. package/_cjs/errors/typedData.js.map +1 -1
  33. package/_cjs/errors/version.js +1 -1
  34. package/_cjs/op-stack/abis.js +52 -0
  35. package/_cjs/op-stack/abis.js.map +1 -1
  36. package/_cjs/op-stack/actions/getTimeToFinalize.js +53 -4
  37. package/_cjs/op-stack/actions/getTimeToFinalize.js.map +1 -1
  38. package/_cjs/op-stack/actions/getTimeToProve.js +29 -2
  39. package/_cjs/op-stack/actions/getTimeToProve.js.map +1 -1
  40. package/_cjs/op-stack/actions/getWithdrawalStatus.js +20 -4
  41. package/_cjs/op-stack/actions/getWithdrawalStatus.js.map +1 -1
  42. package/_cjs/op-stack/actions/waitToProve.js +28 -2
  43. package/_cjs/op-stack/actions/waitToProve.js.map +1 -1
  44. package/_cjs/op-stack/errors/withdrawal.js +12 -1
  45. package/_cjs/op-stack/errors/withdrawal.js.map +1 -1
  46. package/_cjs/tempo/Account.js +2 -5
  47. package/_cjs/tempo/Account.js.map +1 -1
  48. package/_cjs/tempo/Addresses.js +1 -2
  49. package/_cjs/tempo/Addresses.js.map +1 -1
  50. package/_cjs/tempo/accounts/Config.js +1 -4
  51. package/_cjs/tempo/accounts/Config.js.map +1 -1
  52. package/_cjs/tempo/actions/accessKey.js +8 -8
  53. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  54. package/_cjs/tempo/actions/accounts.js +5 -5
  55. package/_cjs/tempo/actions/accounts.js.map +1 -1
  56. package/_cjs/tempo/actions/amm.js +4 -4
  57. package/_cjs/tempo/actions/amm.js.map +1 -1
  58. package/_cjs/tempo/actions/channel.js +7 -7
  59. package/_cjs/tempo/actions/channel.js.map +1 -1
  60. package/_cjs/tempo/actions/dex.js +14 -14
  61. package/_cjs/tempo/actions/dex.js.map +1 -1
  62. package/_cjs/tempo/actions/earn/deployment.js +3 -3
  63. package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
  64. package/_cjs/tempo/actions/earn.js +6 -6
  65. package/_cjs/tempo/actions/earn.js.map +1 -1
  66. package/_cjs/tempo/actions/fee.js +4 -4
  67. package/_cjs/tempo/actions/fee.js.map +1 -1
  68. package/_cjs/tempo/actions/nonce.js +1 -1
  69. package/_cjs/tempo/actions/nonce.js.map +1 -1
  70. package/_cjs/tempo/actions/policy.js +6 -6
  71. package/_cjs/tempo/actions/policy.js.map +1 -1
  72. package/_cjs/tempo/actions/propAmm.js +10 -10
  73. package/_cjs/tempo/actions/propAmm.js.map +1 -1
  74. package/_cjs/tempo/actions/receivePolicy.js +6 -6
  75. package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
  76. package/_cjs/tempo/actions/reward.js +6 -6
  77. package/_cjs/tempo/actions/reward.js.map +1 -1
  78. package/_cjs/tempo/actions/token.js +21 -21
  79. package/_cjs/tempo/actions/token.js.map +1 -1
  80. package/_cjs/tempo/actions/validator.js +11 -11
  81. package/_cjs/tempo/actions/validator.js.map +1 -1
  82. package/_cjs/tempo/actions/virtualAddress.js +2 -2
  83. package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
  84. package/_cjs/tempo/internal/relay/accounts.js +1 -3
  85. package/_cjs/tempo/internal/relay/accounts.js.map +1 -1
  86. package/_cjs/utils/abi/getAbiItem.js +33 -12
  87. package/_cjs/utils/abi/getAbiItem.js.map +1 -1
  88. package/_cjs/utils/abi/parseEventLogs.js +18 -10
  89. package/_cjs/utils/abi/parseEventLogs.js.map +1 -1
  90. package/_cjs/utils/authorization/serializeAuthorizationList.js +4 -1
  91. package/_cjs/utils/authorization/serializeAuthorizationList.js.map +1 -1
  92. package/_cjs/utils/buildRequest.js +25 -14
  93. package/_cjs/utils/buildRequest.js.map +1 -1
  94. package/_cjs/utils/data/isHex.js +3 -1
  95. package/_cjs/utils/data/isHex.js.map +1 -1
  96. package/_cjs/utils/hash/normalizeSignature.js +1 -1
  97. package/_cjs/utils/hash/normalizeSignature.js.map +1 -1
  98. package/_cjs/utils/rpc/http.js +24 -4
  99. package/_cjs/utils/rpc/http.js.map +1 -1
  100. package/_cjs/utils/signature/compactSignatureToSignature.js +3 -2
  101. package/_cjs/utils/signature/compactSignatureToSignature.js.map +1 -1
  102. package/_cjs/utils/signature/hashTypedData.js +1 -2
  103. package/_cjs/utils/signature/hashTypedData.js.map +1 -1
  104. package/_cjs/utils/signature/signatureToCompactSignature.js +15 -7
  105. package/_cjs/utils/signature/signatureToCompactSignature.js.map +1 -1
  106. package/_cjs/utils/siwe/createSiweMessage.js +1 -1
  107. package/_cjs/utils/siwe/createSiweMessage.js.map +1 -1
  108. package/_cjs/utils/typedData.js +6 -7
  109. package/_cjs/utils/typedData.js.map +1 -1
  110. package/_cjs/utils/wait.js +1 -1
  111. package/_cjs/utils/wait.js.map +1 -1
  112. package/_esm/actions/public/waitForTransactionReceipt.js +101 -23
  113. package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  114. package/_esm/actions/public/watchEvent.js +1 -0
  115. package/_esm/actions/public/watchEvent.js.map +1 -1
  116. package/_esm/actions/token/approve.js +1 -1
  117. package/_esm/actions/token/approve.js.map +1 -1
  118. package/_esm/actions/token/getAllowance.js +1 -1
  119. package/_esm/actions/token/getAllowance.js.map +1 -1
  120. package/_esm/actions/token/getBalance.js +1 -1
  121. package/_esm/actions/token/getBalance.js.map +1 -1
  122. package/_esm/actions/token/getTotalSupply.js +1 -1
  123. package/_esm/actions/token/getTotalSupply.js.map +1 -1
  124. package/_esm/actions/token/transfer.js +1 -1
  125. package/_esm/actions/token/transfer.js.map +1 -1
  126. package/_esm/actions/wallet/sendCalls.js +1 -1
  127. package/_esm/actions/wallet/sendCalls.js.map +1 -1
  128. package/_esm/chains/definitions/valuechain.js +20 -0
  129. package/_esm/chains/definitions/valuechain.js.map +1 -0
  130. package/_esm/chains/definitions/valuechainTestnet.js +21 -0
  131. package/_esm/chains/definitions/valuechainTestnet.js.map +1 -0
  132. package/_esm/chains/index.js +4 -0
  133. package/_esm/chains/index.js.map +1 -1
  134. package/_esm/clients/decorators/public.js.map +1 -1
  135. package/_esm/clients/transports/http.js +6 -1
  136. package/_esm/clients/transports/http.js.map +1 -1
  137. package/_esm/errors/node.js +1 -1
  138. package/_esm/errors/node.js.map +1 -1
  139. package/_esm/errors/request.js +22 -2
  140. package/_esm/errors/request.js.map +1 -1
  141. package/_esm/errors/typedData.js +3 -1
  142. package/_esm/errors/typedData.js.map +1 -1
  143. package/_esm/errors/version.js +1 -1
  144. package/_esm/op-stack/abis.js +52 -0
  145. package/_esm/op-stack/abis.js.map +1 -1
  146. package/_esm/op-stack/actions/getTimeToFinalize.js +64 -6
  147. package/_esm/op-stack/actions/getTimeToFinalize.js.map +1 -1
  148. package/_esm/op-stack/actions/getTimeToProve.js +30 -2
  149. package/_esm/op-stack/actions/getTimeToProve.js.map +1 -1
  150. package/_esm/op-stack/actions/getWithdrawalStatus.js +24 -5
  151. package/_esm/op-stack/actions/getWithdrawalStatus.js.map +1 -1
  152. package/_esm/op-stack/actions/waitToProve.js +30 -3
  153. package/_esm/op-stack/actions/waitToProve.js.map +1 -1
  154. package/_esm/op-stack/errors/withdrawal.js +10 -0
  155. package/_esm/op-stack/errors/withdrawal.js.map +1 -1
  156. package/_esm/tempo/Account.js +2 -5
  157. package/_esm/tempo/Account.js.map +1 -1
  158. package/_esm/tempo/Addresses.js +0 -2
  159. package/_esm/tempo/Addresses.js.map +1 -1
  160. package/_esm/tempo/accounts/Config.js +1 -4
  161. package/_esm/tempo/accounts/Config.js.map +1 -1
  162. package/_esm/tempo/actions/accessKey.js +8 -8
  163. package/_esm/tempo/actions/accessKey.js.map +1 -1
  164. package/_esm/tempo/actions/accounts.js +7 -7
  165. package/_esm/tempo/actions/accounts.js.map +1 -1
  166. package/_esm/tempo/actions/amm.js +4 -4
  167. package/_esm/tempo/actions/amm.js.map +1 -1
  168. package/_esm/tempo/actions/channel.js +7 -7
  169. package/_esm/tempo/actions/channel.js.map +1 -1
  170. package/_esm/tempo/actions/dex.js +14 -14
  171. package/_esm/tempo/actions/dex.js.map +1 -1
  172. package/_esm/tempo/actions/earn/deployment.js +3 -3
  173. package/_esm/tempo/actions/earn/deployment.js.map +1 -1
  174. package/_esm/tempo/actions/earn.js +6 -6
  175. package/_esm/tempo/actions/earn.js.map +1 -1
  176. package/_esm/tempo/actions/fee.js +4 -4
  177. package/_esm/tempo/actions/fee.js.map +1 -1
  178. package/_esm/tempo/actions/nonce.js +1 -1
  179. package/_esm/tempo/actions/nonce.js.map +1 -1
  180. package/_esm/tempo/actions/policy.js +6 -6
  181. package/_esm/tempo/actions/policy.js.map +1 -1
  182. package/_esm/tempo/actions/propAmm.js +10 -10
  183. package/_esm/tempo/actions/propAmm.js.map +1 -1
  184. package/_esm/tempo/actions/receivePolicy.js +6 -6
  185. package/_esm/tempo/actions/receivePolicy.js.map +1 -1
  186. package/_esm/tempo/actions/reward.js +6 -6
  187. package/_esm/tempo/actions/reward.js.map +1 -1
  188. package/_esm/tempo/actions/token.js +21 -21
  189. package/_esm/tempo/actions/token.js.map +1 -1
  190. package/_esm/tempo/actions/validator.js +11 -11
  191. package/_esm/tempo/actions/validator.js.map +1 -1
  192. package/_esm/tempo/actions/virtualAddress.js +2 -2
  193. package/_esm/tempo/actions/virtualAddress.js.map +1 -1
  194. package/_esm/tempo/internal/relay/accounts.js +1 -3
  195. package/_esm/tempo/internal/relay/accounts.js.map +1 -1
  196. package/_esm/utils/abi/getAbiItem.js +36 -14
  197. package/_esm/utils/abi/getAbiItem.js.map +1 -1
  198. package/_esm/utils/abi/parseEventLogs.js +25 -11
  199. package/_esm/utils/abi/parseEventLogs.js.map +1 -1
  200. package/_esm/utils/authorization/serializeAuthorizationList.js +7 -1
  201. package/_esm/utils/authorization/serializeAuthorizationList.js.map +1 -1
  202. package/_esm/utils/buildRequest.js +29 -15
  203. package/_esm/utils/buildRequest.js.map +1 -1
  204. package/_esm/utils/data/isHex.js +3 -1
  205. package/_esm/utils/data/isHex.js.map +1 -1
  206. package/_esm/utils/hash/normalizeSignature.js +1 -1
  207. package/_esm/utils/hash/normalizeSignature.js.map +1 -1
  208. package/_esm/utils/hash/toSignature.js +1 -1
  209. package/_esm/utils/hash/toSignatureHash.js +1 -1
  210. package/_esm/utils/rpc/http.js +29 -7
  211. package/_esm/utils/rpc/http.js.map +1 -1
  212. package/_esm/utils/signature/compactSignatureToSignature.js +3 -2
  213. package/_esm/utils/signature/compactSignatureToSignature.js.map +1 -1
  214. package/_esm/utils/signature/hashTypedData.js +1 -2
  215. package/_esm/utils/signature/hashTypedData.js.map +1 -1
  216. package/_esm/utils/signature/signatureToCompactSignature.js +16 -7
  217. package/_esm/utils/signature/signatureToCompactSignature.js.map +1 -1
  218. package/_esm/utils/siwe/createSiweMessage.js +1 -1
  219. package/_esm/utils/siwe/createSiweMessage.js.map +1 -1
  220. package/_esm/utils/typedData.js +12 -8
  221. package/_esm/utils/typedData.js.map +1 -1
  222. package/_esm/utils/wait.js +2 -1
  223. package/_esm/utils/wait.js.map +1 -1
  224. package/_types/actions/public/waitForTransactionReceipt.d.ts +31 -1
  225. package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  226. package/_types/actions/public/watchEvent.d.ts.map +1 -1
  227. package/_types/chains/definitions/valuechain.d.ts +53 -0
  228. package/_types/chains/definitions/valuechain.d.ts.map +1 -0
  229. package/_types/chains/definitions/valuechainTestnet.d.ts +53 -0
  230. package/_types/chains/definitions/valuechainTestnet.d.ts.map +1 -0
  231. package/_types/chains/index.d.ts +4 -0
  232. package/_types/chains/index.d.ts.map +1 -1
  233. package/_types/clients/decorators/public.d.ts +3 -0
  234. package/_types/clients/decorators/public.d.ts.map +1 -1
  235. package/_types/clients/transports/http.d.ts.map +1 -1
  236. package/_types/errors/node.d.ts.map +1 -1
  237. package/_types/errors/request.d.ts +7 -1
  238. package/_types/errors/request.d.ts.map +1 -1
  239. package/_types/errors/typedData.d.ts.map +1 -1
  240. package/_types/errors/version.d.ts +1 -1
  241. package/_types/op-stack/abis.d.ts +40 -0
  242. package/_types/op-stack/abis.d.ts.map +1 -1
  243. package/_types/op-stack/actions/getTimeToFinalize.d.ts +3 -2
  244. package/_types/op-stack/actions/getTimeToFinalize.d.ts.map +1 -1
  245. package/_types/op-stack/actions/getTimeToProve.d.ts +3 -1
  246. package/_types/op-stack/actions/getTimeToProve.d.ts.map +1 -1
  247. package/_types/op-stack/actions/getWithdrawalStatus.d.ts +2 -2
  248. package/_types/op-stack/actions/getWithdrawalStatus.d.ts.map +1 -1
  249. package/_types/op-stack/actions/waitToProve.d.ts +3 -1
  250. package/_types/op-stack/actions/waitToProve.d.ts.map +1 -1
  251. package/_types/op-stack/errors/withdrawal.d.ts +8 -0
  252. package/_types/op-stack/errors/withdrawal.d.ts.map +1 -1
  253. package/_types/tempo/Account.d.ts +0 -5
  254. package/_types/tempo/Account.d.ts.map +1 -1
  255. package/_types/tempo/Addresses.d.ts +0 -2
  256. package/_types/tempo/Addresses.d.ts.map +1 -1
  257. package/_types/tempo/accounts/Config.d.ts.map +1 -1
  258. package/_types/tempo/actions/accounts.d.ts +2 -2
  259. package/_types/tempo/internal/relay/accounts.d.ts.map +1 -1
  260. package/_types/utils/abi/getAbiItem.d.ts.map +1 -1
  261. package/_types/utils/abi/parseEventLogs.d.ts.map +1 -1
  262. package/_types/utils/authorization/serializeAuthorizationList.d.ts.map +1 -1
  263. package/_types/utils/buildRequest.d.ts.map +1 -1
  264. package/_types/utils/data/isHex.d.ts +12 -1
  265. package/_types/utils/data/isHex.d.ts.map +1 -1
  266. package/_types/utils/hash/toSignature.d.ts +1 -1
  267. package/_types/utils/hash/toSignatureHash.d.ts +1 -1
  268. package/_types/utils/rpc/http.d.ts +2 -2
  269. package/_types/utils/rpc/http.d.ts.map +1 -1
  270. package/_types/utils/signature/compactSignatureToSignature.d.ts +2 -1
  271. package/_types/utils/signature/compactSignatureToSignature.d.ts.map +1 -1
  272. package/_types/utils/signature/hashTypedData.d.ts.map +1 -1
  273. package/_types/utils/signature/signatureToCompactSignature.d.ts +2 -1
  274. package/_types/utils/signature/signatureToCompactSignature.d.ts.map +1 -1
  275. package/_types/utils/typedData.d.ts.map +1 -1
  276. package/_types/utils/wait.d.ts.map +1 -1
  277. package/actions/public/waitForTransactionReceipt.ts +164 -33
  278. package/actions/public/watchEvent.ts +1 -0
  279. package/actions/wallet/sendCalls.ts +1 -1
  280. package/chains/definitions/valuechain.ts +20 -0
  281. package/chains/definitions/valuechainTestnet.ts +21 -0
  282. package/chains/index.ts +4 -0
  283. package/clients/decorators/public.ts +3 -0
  284. package/clients/transports/http.ts +6 -1
  285. package/errors/node.ts +1 -1
  286. package/errors/request.ts +15 -1
  287. package/errors/typedData.ts +3 -1
  288. package/errors/version.ts +1 -1
  289. package/op-stack/abis.ts +52 -0
  290. package/op-stack/actions/getTimeToFinalize.ts +89 -10
  291. package/op-stack/actions/getTimeToProve.ts +43 -2
  292. package/op-stack/actions/getWithdrawalStatus.ts +30 -6
  293. package/op-stack/actions/waitToProve.ts +45 -3
  294. package/op-stack/errors/withdrawal.ts +17 -0
  295. package/package.json +2 -2
  296. package/tempo/Account.ts +2 -14
  297. package/tempo/Addresses.ts +0 -3
  298. package/tempo/accounts/Config.ts +1 -9
  299. package/tempo/actions/accounts.ts +2 -2
  300. package/tempo/internal/relay/accounts.ts +1 -3
  301. package/utils/abi/getAbiItem.ts +49 -17
  302. package/utils/abi/parseEventLogs.ts +32 -11
  303. package/utils/authorization/serializeAuthorizationList.ts +7 -1
  304. package/utils/buildRequest.ts +29 -14
  305. package/utils/data/isHex.ts +18 -1
  306. package/utils/hash/normalizeSignature.ts +1 -1
  307. package/utils/hash/toSignature.ts +1 -1
  308. package/utils/hash/toSignatureHash.ts +1 -1
  309. package/utils/rpc/http.ts +33 -8
  310. package/utils/signature/compactSignatureToSignature.ts +4 -2
  311. package/utils/signature/hashTypedData.ts +1 -2
  312. package/utils/signature/signatureToCompactSignature.ts +13 -8
  313. package/utils/siwe/createSiweMessage.ts +1 -1
  314. package/utils/typedData.ts +11 -8
  315. package/utils/wait.ts +8 -4
@@ -4,7 +4,6 @@ import type * as Hex from 'ox/Hex'
4
4
  import * as Json from 'ox/Json'
5
5
  import { AccountConfig } from 'ox/tempo'
6
6
  import { BaseError } from '../../errors/base.js'
7
- import { configurableAccountRecoveryFactory } from '../Addresses.js'
8
7
  import type * as Store from '../Store.js'
9
8
 
10
9
  /** A valid 48-owner config is much smaller; 64 KiB bounds hostile store parsing work. */
@@ -76,14 +75,7 @@ function assertKey(options: {
76
75
  if (!Address.validate(address) || !Hash.validate(commitment))
77
76
  throw new InvalidStoreValueError()
78
77
  if (config.version === 0n) {
79
- if (
80
- !Address.isEqual(
81
- AccountConfig.getAddress(config, {
82
- factory: configurableAccountRecoveryFactory,
83
- }),
84
- address,
85
- )
86
- )
78
+ if (!Address.isEqual(AccountConfig.getAddress(config), address))
87
79
  throw new InvalidStoreValueError()
88
80
  if (commitment.toLowerCase() === zeroCommitment) return
89
81
  }
@@ -28,8 +28,8 @@ import type * as Transaction from '../Transaction.js'
28
28
  * Derives a configurable account address from an initial config with the
29
29
  * configurable account precompile.
30
30
  *
31
- * The precompile validates the config and derives the address with the chain's
32
- * recovery factory. To derive the address locally, use
31
+ * The precompile validates the config and derives the address from its hash.
32
+ * To derive the address locally, use
33
33
  * `AccountConfig.getAddress` or `Account.fromConfig({ address: 'infer' })`.
34
34
  *
35
35
  * @example
@@ -765,9 +765,7 @@ function assertConfig(options: {
765
765
  const { account, commitment, config } = options
766
766
  if (
767
767
  config.version === 0n &&
768
- AccountConfig.getAddress(config, {
769
- factory: Addresses.configurableAccountRecoveryFactory,
770
- }).toLowerCase() !== account.toLowerCase()
768
+ AccountConfig.getAddress(config).toLowerCase() !== account.toLowerCase()
771
769
  )
772
770
  throw new RpcResponse.InvalidParamsError({
773
771
  message:
@@ -21,6 +21,7 @@ import {
21
21
  type ToFunctionSelectorErrorType,
22
22
  toFunctionSelector,
23
23
  } from '../hash/toFunctionSelector.js'
24
+ import { getArrayComponents } from './encodeAbiParameters.js'
24
25
 
25
26
  export type GetAbiItemParameters<
26
27
  abi extends Abi | readonly unknown[] = Abi,
@@ -174,9 +175,7 @@ export function isArgOfType(arg: unknown, abiParameter: AbiParameter): boolean {
174
175
  return (
175
176
  argType === 'object' &&
176
177
  isArgOfType(
177
- Object.values(arg as unknown[] | Record<string, unknown>)[
178
- index
179
- ],
178
+ getComponentValue(arg, component, index),
180
179
  component as AbiParameter,
181
180
  )
182
181
  )
@@ -198,16 +197,14 @@ export function isArgOfType(arg: unknown, abiParameter: AbiParameter): boolean {
198
197
  return argType === 'string' || arg instanceof Uint8Array
199
198
 
200
199
  // fixed-length (`<type>[M]`) and dynamic (`<type>[]`) arrays
201
- // https://regexr.com/6va6i
202
- if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
200
+ const arrayComponents = getArrayComponents(abiParameterType)
201
+ if (arrayComponents) {
202
+ const [length, type] = arrayComponents
203
203
  return (
204
204
  Array.isArray(arg) &&
205
+ (length === null || arg.length === length) &&
205
206
  arg.every((x: unknown) =>
206
- isArgOfType(x, {
207
- ...abiParameter,
208
- // Pop off `[]` or `[M]` from end of type
209
- type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, ''),
210
- } as AbiParameter),
207
+ isArgOfType(x, { ...abiParameter, type } as AbiParameter),
211
208
  )
212
209
  )
213
210
  }
@@ -226,27 +223,52 @@ export function getAmbiguousTypes(
226
223
  for (const parameterIndex in sourceParameters) {
227
224
  const sourceParameter = sourceParameters[parameterIndex]
228
225
  const targetParameter = targetParameters[parameterIndex]
226
+ if (!targetParameter) continue
229
227
 
230
228
  if (
231
229
  sourceParameter.type === 'tuple' &&
232
230
  targetParameter.type === 'tuple' &&
233
231
  'components' in sourceParameter &&
234
232
  'components' in targetParameter
235
- )
236
- return getAmbiguousTypes(
233
+ ) {
234
+ const value = args[parameterIndex]
235
+ const types = getAmbiguousTypes(
237
236
  sourceParameter.components,
238
237
  targetParameter.components,
239
- (args as any)[parameterIndex],
238
+ sourceParameter.components.map((component, index) =>
239
+ getComponentValue(value, component, index),
240
+ ),
240
241
  )
242
+ if (types) return types
243
+ continue
244
+ }
245
+
246
+ const sourceArray = getArrayComponents(sourceParameter.type)
247
+ const targetArray = getArrayComponents(targetParameter.type)
248
+ if (sourceArray && targetArray) {
249
+ // Every item matches both element types, so the first item (or `undefined` for an empty array) decides.
250
+ const types = getAmbiguousTypes(
251
+ [{ ...sourceParameter, type: sourceArray[1] } as AbiParameter],
252
+ [{ ...targetParameter, type: targetArray[1] } as AbiParameter],
253
+ [(args[parameterIndex] as readonly unknown[] | undefined)?.[0]],
254
+ )
255
+ if (types) return types
256
+ continue
257
+ }
241
258
 
242
259
  const types = [sourceParameter.type, targetParameter.type]
260
+ const value = args[parameterIndex]
243
261
 
244
262
  const ambiguous = (() => {
245
263
  if (types.includes('address') && types.includes('bytes20')) return true
246
- if (types.includes('address') && types.includes('string'))
247
- return isAddress(args[parameterIndex] as Address, { strict: false })
248
- if (types.includes('address') && types.includes('bytes'))
249
- return isAddress(args[parameterIndex] as Address, { strict: false })
264
+ // An `undefined` value comes from an empty array, which matches both types.
265
+ if (
266
+ types.includes('address') &&
267
+ (types.includes('string') || types.includes('bytes'))
268
+ )
269
+ return (
270
+ value === undefined || isAddress(value as Address, { strict: false })
271
+ )
250
272
  return false
251
273
  })()
252
274
 
@@ -255,3 +277,13 @@ export function getAmbiguousTypes(
255
277
 
256
278
  return
257
279
  }
280
+
281
+ /** Reads a tuple component's value by index from arrays and by name from objects, like `encodeAbiParameters`. */
282
+ function getComponentValue(
283
+ arg: unknown,
284
+ component: AbiParameter,
285
+ index: number,
286
+ ): unknown {
287
+ if (Array.isArray(arg)) return arg[index]
288
+ return (arg as Record<string, unknown> | undefined)?.[component.name!]
289
+ }
@@ -10,6 +10,7 @@ import { stringToBytes, toBytes } from '../encoding/toBytes.js'
10
10
  import { formatLog } from '../formatters/log.js'
11
11
  import { keccak256 } from '../hash/keccak256.js'
12
12
  import { toEventSelector } from '../hash/toEventSelector.js'
13
+ import { bytesRegex } from '../regex.js'
13
14
  import {
14
15
  type DecodeEventLogErrorType,
15
16
  decodeEventLog,
@@ -162,15 +163,11 @@ export function parseEventLogs<
162
163
  strict: false,
163
164
  })
164
165
  } catch {
165
- // If decoding still fails, return partial log in non-strict mode.
166
+ // If decoding still fails, use a partial log in non-strict mode.
166
167
  const isUnnamed = abiItem.abi.inputs?.some(
167
168
  (x) => !('name' in x && x.name),
168
169
  )
169
- return {
170
- ...formattedLog,
171
- args: isUnnamed ? [] : {},
172
- eventName: abiItem.abi.name,
173
- }
170
+ event = { eventName: abiItem.abi.name, args: isUnnamed ? [] : {} }
174
171
  }
175
172
  }
176
173
 
@@ -186,6 +183,7 @@ export function parseEventLogs<
186
183
  args: event.args,
187
184
  inputs: abiItem.abi.inputs,
188
185
  matchArgs: args,
186
+ topics: formattedLog.topics,
189
187
  })
190
188
  )
191
189
  return null
@@ -203,20 +201,43 @@ function includesArgs(parameters: {
203
201
  args: unknown
204
202
  inputs: AbiEvent['inputs']
205
203
  matchArgs: unknown
204
+ topics: Log['topics']
206
205
  }) {
207
- const { args, inputs, matchArgs } = parameters
206
+ const { args, inputs, matchArgs, topics } = parameters
208
207
 
209
208
  if (!matchArgs) return true
210
209
  if (!args) return false
211
210
 
211
+ // Topics hold the signature, then indexed inputs in order. Non-strict
212
+ // decoding reads indexed inputs without a topic from data.
213
+ const topicInputs = inputs
214
+ .filter((input) => input.indexed)
215
+ .slice(0, topics.length - 1)
216
+
212
217
  function isEqual(input: AbiEventParameter, value: unknown, arg: unknown) {
213
218
  try {
214
219
  if (input.type === 'address')
215
220
  return isAddressEqual(value as Address, arg as Address)
216
- if (input.type === 'string')
217
- return keccak256(stringToBytes(value as string)) === arg
218
- if (input.type === 'bytes')
219
- return keccak256(toBytes(value as string)) === arg
221
+ // `string` and `bytes` topics hold the keccak256 of their contents.
222
+ // Other values are ABI-decoded.
223
+ if (
224
+ topicInputs.includes(input) &&
225
+ (input.type === 'string' || input.type === 'bytes')
226
+ ) {
227
+ const bytes =
228
+ input.type === 'string'
229
+ ? stringToBytes(value as string)
230
+ : toBytes(value as string)
231
+ return keccak256(bytes) === arg
232
+ }
233
+ // Decoded `bytes` and `bytesN` are lowercase hex. Match either case,
234
+ // same as the indexed `bytes` hash path.
235
+ if (
236
+ typeof value === 'string' &&
237
+ typeof arg === 'string' &&
238
+ bytesRegex.test(input.type)
239
+ )
240
+ return value.toLowerCase() === arg.toLowerCase()
220
241
  return value === arg
221
242
  } catch {
222
243
  return false
@@ -22,11 +22,17 @@ export function serializeAuthorizationList(
22
22
  for (const authorization of authorizationList) {
23
23
  const { chainId, nonce, ...signature } = authorization
24
24
  const contractAddress = authorization.address
25
+ const signatureArray = toYParitySignatureArray({}, signature)
26
+ // EIP-7702 permits any `y_parity` below 2**8 in an authorization tuple, and a
27
+ // tuple that fails recovery does not invalidate the transaction. Encode a
28
+ // numeric `yParity` as is, so that serialization preserves the transaction hash.
29
+ if (signatureArray.length > 0 && signature.yParity)
30
+ signatureArray[0] = toHex(signature.yParity)
25
31
  serializedAuthorizationList.push([
26
32
  chainId ? toHex(chainId) : '0x',
27
33
  contractAddress,
28
34
  nonce ? toHex(nonce) : '0x',
29
- ...toYParitySignatureArray({}, signature),
35
+ ...signatureArray,
30
36
  ])
31
37
  }
32
38
 
@@ -2,6 +2,7 @@ import { BaseError } from '../errors/base.js'
2
2
  import {
3
3
  HttpRequestError,
4
4
  type HttpRequestErrorType,
5
+ RpcRequestError,
5
6
  type RpcRequestErrorType,
6
7
  type TimeoutErrorType,
7
8
  type WebSocketRequestErrorType,
@@ -268,10 +269,14 @@ export function buildRequest<
268
269
  {
269
270
  delay: ({ count, error }) => {
270
271
  // If we find a Retry-After header, let's retry after the given time.
271
- if (error && error instanceof HttpRequestError) {
272
- const retryAfter = error?.headers?.get('Retry-After')
273
- if (retryAfter?.match(/\d/))
274
- return Number.parseInt(retryAfter, 10) * 1000
272
+ const retryAfter =
273
+ getHttpError(error)?.headers?.get('Retry-After')
274
+ if (retryAfter) {
275
+ const seconds = Number.parseInt(retryAfter, 10)
276
+ if (!Number.isNaN(seconds)) return seconds * 1000
277
+ // HTTP-date form. A past or invalid date falls back to backoff.
278
+ const delay = Date.parse(retryAfter) - Date.now()
279
+ if (delay > 0) return delay
275
280
  }
276
281
 
277
282
  // Otherwise, let's retry with an exponential backoff.
@@ -290,6 +295,7 @@ export function buildRequest<
290
295
  /** @internal */
291
296
  export function shouldRetry(error: Error) {
292
297
  if (isAbortError(error)) return false
298
+ const status = getHttpError(error)?.status
293
299
  if ('code' in error && typeof error.code === 'number') {
294
300
  if (error.code === -1) return true // Unknown error
295
301
  if (error.code === LimitExceededRpcError.code) return true
@@ -304,30 +310,39 @@ export function shouldRetry(error: Error) {
304
310
  // reached - reduce calls per second or upgrade your account at
305
311
  // quicknode.com" }`.
306
312
  if (error.code === -32007) return true
307
- return false
313
+ // A JSON-RPC error from a non-2xx response also retries by its HTTP status.
314
+ if (!status) return false
308
315
  }
309
- if (error instanceof HttpRequestError && error.status) {
316
+ if (status) {
310
317
  // Forbidden
311
- if (error.status === 403) return true
318
+ if (status === 403) return true
312
319
  // Request Timeout
313
- if (error.status === 408) return true
320
+ if (status === 408) return true
314
321
  // Request Entity Too Large
315
- if (error.status === 413) return true
322
+ if (status === 413) return true
316
323
  // Too Many Requests
317
- if (error.status === 429) return true
324
+ if (status === 429) return true
318
325
  // Internal Server Error
319
- if (error.status === 500) return true
326
+ if (status === 500) return true
320
327
  // Bad Gateway
321
- if (error.status === 502) return true
328
+ if (status === 502) return true
322
329
  // Service Unavailable
323
- if (error.status === 503) return true
330
+ if (status === 503) return true
324
331
  // Gateway Timeout
325
- if (error.status === 504) return true
332
+ if (status === 504) return true
326
333
  return false
327
334
  }
328
335
  return true
329
336
  }
330
337
 
338
+ /** Returns the error in the cause chain that carries the HTTP response. */
339
+ function getHttpError(error: Error | undefined) {
340
+ if (!(error instanceof BaseError)) return undefined
341
+ return error.walk(
342
+ (err) => err instanceof HttpRequestError || err instanceof RpcRequestError,
343
+ ) as HttpRequestError | RpcRequestError | null
344
+ }
345
+
331
346
  /** @internal cyrb53 – fast, non-cryptographic 53-bit string hash */
332
347
  function hashString(str: string, seed = 0): string {
333
348
  let h1 = 0xdeadbeef ^ seed
@@ -5,9 +5,26 @@ export type IsHexErrorType = ErrorType
5
5
 
6
6
  export function isHex(
7
7
  value: unknown,
8
- { strict = true }: { strict?: boolean | undefined } = {},
8
+ {
9
+ even = false,
10
+ strict = true,
11
+ }: {
12
+ /**
13
+ * Whether or not to require an even number of hex characters (whole bytes).
14
+ *
15
+ * @default false
16
+ */
17
+ even?: boolean | undefined
18
+ /**
19
+ * Whether or not to require only hex characters after the `0x` prefix.
20
+ *
21
+ * @default true
22
+ */
23
+ strict?: boolean | undefined
24
+ } = {},
9
25
  ): value is Hex {
10
26
  if (!value) return false
11
27
  if (typeof value !== 'string') return false
28
+ if (even && value.length % 2 !== 0) return false
12
29
  return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith('0x')
13
30
  }
@@ -29,7 +29,7 @@ export function normalizeSignature(
29
29
 
30
30
  // If level === 0, we are at the definition level.
31
31
  if (level === 0) {
32
- if (char === ' ' && ['event', 'function', ''].includes(result))
32
+ if (char === ' ' && ['event', 'function', 'error', ''].includes(result))
33
33
  result = ''
34
34
  else {
35
35
  result += char
@@ -9,7 +9,7 @@ import {
9
9
  export type ToSignatureErrorType = NormalizeSignatureErrorType | ErrorType
10
10
 
11
11
  /**
12
- * Returns the signature for a given function or event definition.
12
+ * Returns the signature for a given function, event, or error definition.
13
13
  *
14
14
  * @example
15
15
  * const signature = toSignature('function ownerOf(uint256 tokenId)')
@@ -10,7 +10,7 @@ export type ToSignatureHashErrorType =
10
10
  | ErrorType
11
11
 
12
12
  /**
13
- * Returns the hash (of the function/event signature) for a given event or function definition.
13
+ * Returns the hash (of the function/event/error signature) for a given function, event, or error definition.
14
14
  */
15
15
  export function toSignatureHash(fn: string | AbiFunction | AbiEvent) {
16
16
  return hashSignature(toSignature(fn))
package/utils/rpc/http.ts CHANGED
@@ -3,6 +3,8 @@ import {
3
3
  type HttpRequestErrorType as HttpRequestErrorType_,
4
4
  ResponseBodyTooLargeError,
5
5
  type ResponseBodyTooLargeErrorType,
6
+ RpcRequestError,
7
+ type RpcRequestErrorType,
6
8
  TimeoutError,
7
9
  type TimeoutErrorType,
8
10
  } from '../../errors/request.js'
@@ -77,6 +79,7 @@ export type HttpRequestReturnType<
77
79
  export type HttpRequestErrorType =
78
80
  | HttpRequestErrorType_
79
81
  | ResponseBodyTooLargeErrorType
82
+ | RpcRequestErrorType
80
83
  | TimeoutErrorType
81
84
  | WithTimeoutErrorType
82
85
  | ErrorType
@@ -188,14 +191,24 @@ export function getHttpRpcClient(
188
191
  }
189
192
  }
190
193
 
194
+ // A server that rejects a whole batch replies with a single error, bare
195
+ // or in a one-element array (geth).
196
+ const error =
197
+ Array.isArray(body) && Array.isArray(data) && data.length === 1
198
+ ? data[0]
199
+ : data
200
+
191
201
  if (!response.ok) {
192
- // If the response body contains a valid JSON-RPC error, return it
193
- // so it flows through the normal RPC error handling pipeline.
194
- if (
195
- typeof data.error?.code === 'number' &&
196
- typeof data.error?.message === 'string'
197
- )
198
- return data
202
+ // A valid JSON-RPC error body keeps its RPC error class and the
203
+ // response status and headers for retries.
204
+ if (isRpcError(error))
205
+ throw new RpcRequestError({
206
+ body,
207
+ error: error.error,
208
+ headers: response.headers,
209
+ status: response.status,
210
+ url,
211
+ })
199
212
 
200
213
  throw new HttpRequestError({
201
214
  body,
@@ -206,12 +219,17 @@ export function getHttpRpcClient(
206
219
  })
207
220
  }
208
221
 
209
- return data
222
+ if (!Array.isArray(body) || !body.length) return data
223
+ if (Array.isArray(data) && data.length >= body.length) return data
224
+ if (!isRpcError(error))
225
+ throw new Error(`Expected ${body.length} responses to batch request.`)
226
+ return body.map(() => error)
210
227
  } catch (err) {
211
228
  if (signal_?.aborted) throw getAbortError(signal_)
212
229
  if (isAbortError(err)) throw err
213
230
  if (err instanceof HttpRequestError) throw err
214
231
  if (err instanceof ResponseBodyTooLargeError) throw err
232
+ if (err instanceof RpcRequestError) throw err
215
233
  if (err instanceof TimeoutError) throw err
216
234
  throw new HttpRequestError({
217
235
  body,
@@ -306,6 +324,13 @@ async function readResponseBody(
306
324
  }
307
325
  }
308
326
 
327
+ function isRpcError(data: any) {
328
+ return (
329
+ typeof data?.error?.code === 'number' &&
330
+ typeof data?.error?.message === 'string'
331
+ )
332
+ }
333
+
309
334
  /** @internal */
310
335
  export function parseUrl(url_: string) {
311
336
  try {
@@ -1,11 +1,13 @@
1
1
  import type { ErrorType } from '../../errors/utils.js'
2
2
  import type { CompactSignature, Signature } from '../../types/misc.js'
3
+ import { type PadErrorType, pad } from '../data/pad.js'
3
4
  import { type HexToBytesErrorType, hexToBytes } from '../encoding/toBytes.js'
4
5
  import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
5
6
 
6
7
  export type CompactSignatureToSignatureErrorType =
7
8
  | BytesToHexErrorType
8
9
  | HexToBytesErrorType
10
+ | PadErrorType
9
11
  | ErrorType
10
12
 
11
13
  /**
@@ -29,9 +31,9 @@ export function compactSignatureToSignature({
29
31
  r,
30
32
  yParityAndS,
31
33
  }: CompactSignature): Signature {
32
- const yParityAndS_bytes = hexToBytes(yParityAndS)
34
+ const yParityAndS_bytes = hexToBytes(pad(yParityAndS))
33
35
  const yParity = yParityAndS_bytes[0] & 0x80 ? 1 : 0
34
36
  const s = yParityAndS_bytes
35
37
  if (yParity === 1) s[0] &= 0x7f
36
- return { r, s: bytesToHex(s), yParity }
38
+ return { r: pad(r), s: bytesToHex(s), yParity }
37
39
  }
@@ -209,8 +209,7 @@ function findTypeDependencies(
209
209
  },
210
210
  results: Set<string> = new Set(),
211
211
  ): Set<string> {
212
- const match = primaryType_.match(/^\w*/u)
213
- const primaryType = match?.[0]!
212
+ const primaryType = primaryType_.replace(/(\[[0-9]*\])+$/, '')
214
213
  if (results.has(primaryType) || types[primaryType] === undefined) {
215
214
  return results
216
215
  }
@@ -1,11 +1,13 @@
1
1
  import type { ErrorType } from '../../errors/utils.js'
2
2
  import type { CompactSignature, Signature } from '../../types/misc.js'
3
+ import { type PadErrorType, pad } from '../data/pad.js'
3
4
  import { type HexToBytesErrorType, hexToBytes } from '../encoding/toBytes.js'
4
5
  import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
5
6
 
6
7
  export type SignatureToCompactSignatureErrorType =
7
8
  | HexToBytesErrorType
8
9
  | BytesToHexErrorType
10
+ | PadErrorType
9
11
  | ErrorType
10
12
 
11
13
  /**
@@ -29,12 +31,15 @@ export function signatureToCompactSignature(
29
31
  signature: Signature,
30
32
  ): CompactSignature {
31
33
  const { r, s, v, yParity } = signature
32
- const yParity_ = Number(yParity ?? v! - 27n)
33
- let yParityAndS = s
34
- if (yParity_ === 1) {
35
- const bytes = hexToBytes(s)
36
- bytes[0] |= 0x80
37
- yParityAndS = bytesToHex(bytes)
38
- }
39
- return { r, yParityAndS }
34
+ const yParity_ = (() => {
35
+ if (yParity === 0 || yParity === 1) return yParity
36
+ if (v === 0n || v === 1n) return Number(v)
37
+ if (v && (v === 27n || v === 28n || v >= 35n)) return v % 2n === 0n ? 1 : 0
38
+ throw new Error('Invalid `v` or `yParity` value')
39
+ })()
40
+ const bytes = hexToBytes(pad(s))
41
+ // EIP-2098 stores yParity in the top bit, which is always clear for a low `s`.
42
+ if (bytes[0] & 0x80) throw new Error('Invalid `s` value')
43
+ if (yParity_ === 1) bytes[0] |= 0x80
44
+ return { r: pad(r), yParityAndS: bytesToHex(bytes) }
40
45
  }
@@ -170,7 +170,7 @@ export function createSiweMessage(
170
170
  }
171
171
 
172
172
  const domainRegex =
173
- /^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/
173
+ /^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+([a-zA-Z]{2,63}|[xX][nN]--[a-zA-Z0-9-]{0,58}[a-zA-Z0-9])(:[0-9]{1,5})?$/
174
174
  const ipRegex =
175
175
  /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/
176
176
  const localhostRegex = /^localhost(:[0-9]{1,5})?$/
@@ -119,13 +119,14 @@ export function validateTypedData<
119
119
  }
120
120
 
121
121
  const struct = types[type]
122
- if (struct) {
123
- validateReference(type)
124
- validateData(struct, value as Record<string, unknown>)
125
- }
122
+ if (struct) validateData(struct, value as Record<string, unknown>)
126
123
  }
127
124
  }
128
125
 
126
+ // Validate struct types, including ones that are only referenced as array
127
+ // elements.
128
+ for (const type of Object.keys(types)) validateReference(type)
129
+
129
130
  // Validate domain types.
130
131
  if (types.EIP712Domain && domain) {
131
132
  if (typeof domain !== 'object') throw new InvalidDomainError({ domain })
@@ -178,14 +179,16 @@ export function domainSeparator({ domain }: { domain: TypedDataDomain }): Hex {
178
179
 
179
180
  /** @internal */
180
181
  function validateReference(type: string) {
181
- // Struct type must not be a Solidity type.
182
+ // Struct type must contain only letters, digits, `_` and `$`, and must not be
183
+ // a Solidity type, so it cannot shadow a Solidity type or an array of one. A
184
+ // struct such as `intent` or `bytesInfo` is valid, while `uint7` or `bytes33`
185
+ // is rejected, since other implementations parse it as a Solidity type.
182
186
  if (
187
+ !/^[A-Za-z0-9_$]+$/.test(type) ||
183
188
  type === 'address' ||
184
189
  type === 'bool' ||
185
190
  type === 'string' ||
186
- type.startsWith('bytes') ||
187
- type.startsWith('uint') ||
188
- type.startsWith('int')
191
+ /^(u?int|bytes)[0-9]*$/.test(type)
189
192
  )
190
193
  throw new InvalidStructTypeError({ type })
191
194
  }
package/utils/wait.ts CHANGED
@@ -11,10 +11,14 @@ export async function wait(
11
11
  }
12
12
 
13
13
  const cleanup = () => signal?.removeEventListener('abort', onAbort)
14
- const timeout = setTimeout(() => {
15
- cleanup()
16
- resolve()
17
- }, time)
14
+ // `setTimeout` fires after 1ms for delays above the 32-bit limit (~24.8 days).
15
+ const timeout = setTimeout(
16
+ () => {
17
+ cleanup()
18
+ resolve()
19
+ },
20
+ Math.min(time, 2 ** 31 - 1),
21
+ )
18
22
  const onAbort = () => {
19
23
  clearTimeout(timeout)
20
24
  cleanup()