viem 2.9.27 → 2.9.29

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 (111) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/_cjs/actions/public/verifyHash.js +2 -2
  3. package/_cjs/actions/public/verifyHash.js.map +1 -1
  4. package/_cjs/actions/public/verifyMessage.js +2 -2
  5. package/_cjs/actions/public/verifyMessage.js.map +1 -1
  6. package/_cjs/actions/public/watchEvent.js +7 -5
  7. package/_cjs/actions/public/watchEvent.js.map +1 -1
  8. package/_cjs/chains/definitions/areonNetwork.js.map +1 -1
  9. package/_cjs/chains/definitions/areonNetworkTestnet.js.map +1 -1
  10. package/_cjs/chains/definitions/cyber.js +2 -2
  11. package/_cjs/chains/definitions/cyber.js.map +1 -1
  12. package/_cjs/chains/definitions/darwinia.js.map +1 -1
  13. package/_cjs/chains/definitions/immutableZkEvmTestnet.js.map +1 -1
  14. package/_cjs/chains/definitions/reyaNetwork.js.map +1 -1
  15. package/_cjs/errors/version.js +1 -1
  16. package/_cjs/experimental/eip5792/actions/sendCalls.js +2 -2
  17. package/_cjs/experimental/eip5792/actions/sendCalls.js.map +1 -1
  18. package/_cjs/utils/abi/parseEventLogs.js +4 -4
  19. package/_cjs/utils/abi/parseEventLogs.js.map +1 -1
  20. package/_cjs/utils/encoding/toRlp.js +2 -2
  21. package/_cjs/utils/encoding/toRlp.js.map +1 -1
  22. package/_cjs/utils/rpc/http.js +6 -2
  23. package/_cjs/utils/rpc/http.js.map +1 -1
  24. package/_cjs/utils/signature/recoverTransactionAddress.js +6 -8
  25. package/_cjs/utils/signature/recoverTransactionAddress.js.map +1 -1
  26. package/_cjs/utils/signature/signatureToCompactSignature.js +4 -3
  27. package/_cjs/utils/signature/signatureToCompactSignature.js.map +1 -1
  28. package/_cjs/utils/signature/signatureToHex.js +7 -7
  29. package/_cjs/utils/signature/signatureToHex.js.map +1 -1
  30. package/_cjs/utils/transaction/parseTransaction.js +1 -1
  31. package/_cjs/utils/transaction/parseTransaction.js.map +1 -1
  32. package/_cjs/zksync/utils/assertEip712Request.js +2 -2
  33. package/_cjs/zksync/utils/assertEip712Request.js.map +1 -1
  34. package/_esm/actions/public/verifyHash.js +1 -1
  35. package/_esm/actions/public/verifyHash.js.map +1 -1
  36. package/_esm/actions/public/verifyMessage.js +1 -1
  37. package/_esm/actions/public/verifyMessage.js.map +1 -1
  38. package/_esm/actions/public/watchEvent.js +3 -1
  39. package/_esm/actions/public/watchEvent.js.map +1 -1
  40. package/_esm/celo/fees.js +0 -1
  41. package/_esm/celo/fees.js.map +1 -1
  42. package/_esm/chains/definitions/areonNetwork.js +1 -1
  43. package/_esm/chains/definitions/areonNetwork.js.map +1 -1
  44. package/_esm/chains/definitions/areonNetworkTestnet.js +1 -1
  45. package/_esm/chains/definitions/areonNetworkTestnet.js.map +1 -1
  46. package/_esm/chains/definitions/cyber.js +2 -2
  47. package/_esm/chains/definitions/cyber.js.map +1 -1
  48. package/_esm/chains/definitions/darwinia.js +1 -1
  49. package/_esm/chains/definitions/darwinia.js.map +1 -1
  50. package/_esm/chains/definitions/immutableZkEvmTestnet.js +1 -1
  51. package/_esm/chains/definitions/immutableZkEvmTestnet.js.map +1 -1
  52. package/_esm/chains/definitions/reyaNetwork.js +1 -1
  53. package/_esm/chains/definitions/reyaNetwork.js.map +1 -1
  54. package/_esm/errors/version.js +1 -1
  55. package/_esm/experimental/eip5792/actions/sendCalls.js +1 -1
  56. package/_esm/experimental/eip5792/actions/sendCalls.js.map +1 -1
  57. package/_esm/utils/abi/parseEventLogs.js +1 -1
  58. package/_esm/utils/abi/parseEventLogs.js.map +1 -1
  59. package/_esm/utils/encoding/toRlp.js +1 -1
  60. package/_esm/utils/encoding/toRlp.js.map +1 -1
  61. package/_esm/utils/rpc/http.js +6 -2
  62. package/_esm/utils/rpc/http.js.map +1 -1
  63. package/_esm/utils/signature/recoverTransactionAddress.js +6 -8
  64. package/_esm/utils/signature/recoverTransactionAddress.js.map +1 -1
  65. package/_esm/utils/signature/signatureToCompactSignature.js +2 -1
  66. package/_esm/utils/signature/signatureToCompactSignature.js.map +1 -1
  67. package/_esm/utils/signature/signatureToHex.js +7 -8
  68. package/_esm/utils/signature/signatureToHex.js.map +1 -1
  69. package/_esm/utils/transaction/parseTransaction.js +1 -1
  70. package/_esm/utils/transaction/parseTransaction.js.map +1 -1
  71. package/_esm/zksync/utils/assertEip712Request.js +1 -1
  72. package/_esm/zksync/utils/assertEip712Request.js.map +1 -1
  73. package/_types/actions/public/verifyHash.d.ts.map +1 -1
  74. package/_types/actions/public/watchEvent.d.ts.map +1 -1
  75. package/_types/celo/fees.d.ts +1 -1
  76. package/_types/celo/fees.d.ts.map +1 -1
  77. package/_types/chains/definitions/cyber.d.ts +2 -2
  78. package/_types/errors/version.d.ts +1 -1
  79. package/_types/utils/abi/parseEventLogs.d.ts +1 -1
  80. package/_types/utils/abi/parseEventLogs.d.ts.map +1 -1
  81. package/_types/utils/encoding/toRlp.d.ts.map +1 -1
  82. package/_types/utils/rpc/http.d.ts.map +1 -1
  83. package/_types/utils/signature/recoverTransactionAddress.d.ts +1 -1
  84. package/_types/utils/signature/recoverTransactionAddress.d.ts.map +1 -1
  85. package/_types/utils/signature/signatureToCompactSignature.d.ts +2 -1
  86. package/_types/utils/signature/signatureToCompactSignature.d.ts.map +1 -1
  87. package/_types/utils/signature/signatureToHex.d.ts +1 -1
  88. package/_types/utils/signature/signatureToHex.d.ts.map +1 -1
  89. package/_types/zksync/utils/assertEip712Request.d.ts +1 -1
  90. package/_types/zksync/utils/assertEip712Request.d.ts.map +1 -1
  91. package/actions/public/verifyHash.ts +1 -1
  92. package/actions/public/verifyMessage.ts +1 -1
  93. package/actions/public/watchEvent.ts +6 -6
  94. package/celo/fees.ts +5 -5
  95. package/chains/definitions/areonNetwork.ts +1 -1
  96. package/chains/definitions/areonNetworkTestnet.ts +1 -1
  97. package/chains/definitions/cyber.ts +2 -2
  98. package/chains/definitions/darwinia.ts +1 -1
  99. package/chains/definitions/immutableZkEvmTestnet.ts +1 -1
  100. package/chains/definitions/reyaNetwork.ts +1 -1
  101. package/errors/version.ts +1 -1
  102. package/experimental/eip5792/actions/sendCalls.ts +1 -1
  103. package/package.json +1 -1
  104. package/utils/abi/parseEventLogs.ts +3 -3
  105. package/utils/encoding/toRlp.ts +1 -1
  106. package/utils/rpc/http.ts +7 -6
  107. package/utils/signature/recoverTransactionAddress.ts +7 -12
  108. package/utils/signature/signatureToCompactSignature.ts +2 -6
  109. package/utils/signature/signatureToHex.ts +6 -6
  110. package/utils/transaction/parseTransaction.ts +1 -1
  111. package/zksync/utils/assertEip712Request.ts +4 -1
@@ -1 +1 @@
1
- {"version":3,"file":"assertEip712Request.d.ts","sourceRoot":"","sources":["../../../zksync/utils/assertEip712Request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,KAAK,sBAAsB,EAAiB,MAAM,gBAAgB,CAAA;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAI9E,MAAM,MAAM,6BAA6B,GAAG,YAAY,CACtD,yBAAyB,CAAC,OAAO,MAAM,CAAC,CACzC,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG,sBAAsB,GAAG,SAAS,CAAA;AAE7E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,6BAA6B,QAItE"}
1
+ {"version":3,"file":"assertEip712Request.d.ts","sourceRoot":"","sources":["../../../zksync/utils/assertEip712Request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,0CAA0C,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAI9E,MAAM,MAAM,6BAA6B,GAAG,YAAY,CACtD,yBAAyB,CAAC,OAAO,MAAM,CAAC,CACzC,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG,sBAAsB,GAAG,SAAS,CAAA;AAE7E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,6BAA6B,QAItE"}
@@ -1,6 +1,5 @@
1
1
  import type { Address } from 'abitype'
2
2
 
3
- import { signatureToHex } from '../../accounts/index.js'
4
3
  import type { Client } from '../../clients/createClient.js'
5
4
  import type { Transport } from '../../clients/transports/createTransport.js'
6
5
  import { universalSignatureValidatorAbi } from '../../constants/abis.js'
@@ -20,6 +19,7 @@ import {
20
19
  import { type IsHexErrorType, isHex } from '../../utils/data/isHex.js'
21
20
  import { type ToHexErrorType, bytesToHex } from '../../utils/encoding/toHex.js'
22
21
  import { getAction } from '../../utils/getAction.js'
22
+ import { signatureToHex } from '../../utils/signature/signatureToHex.js'
23
23
  import { type CallErrorType, type CallParameters, call } from './call.js'
24
24
 
25
25
  export type VerifyHashParameters = Pick<
@@ -10,7 +10,7 @@ import type {
10
10
  SignableMessage,
11
11
  Signature,
12
12
  } from '../../types/misc.js'
13
- import { hashMessage } from '../../utils/index.js'
13
+ import { hashMessage } from '../../utils/signature/hashMessage.js'
14
14
  import type { HashMessageErrorType } from '../../utils/signature/hashMessage.js'
15
15
  import {
16
16
  type VerifyHashErrorType,
@@ -11,7 +11,10 @@ import type { Filter } from '../../types/filter.js'
11
11
  import type { Log } from '../../types/log.js'
12
12
  import type { LogTopic } from '../../types/misc.js'
13
13
  import type { GetPollOptions } from '../../types/transport.js'
14
- import type { EncodeEventTopicsParameters } from '../../utils/index.js'
14
+ import {
15
+ type EncodeEventTopicsParameters,
16
+ encodeEventTopics,
17
+ } from '../../utils/abi/encodeEventTopics.js'
15
18
  import { type ObserveErrorType, observe } from '../../utils/observe.js'
16
19
  import { poll } from '../../utils/poll.js'
17
20
  import { type StringifyErrorType, stringify } from '../../utils/stringify.js'
@@ -23,12 +26,9 @@ import {
23
26
  import { InvalidInputRpcError } from '../../errors/rpc.js'
24
27
  import type { ErrorType } from '../../errors/utils.js'
25
28
  import type { BlockNumber } from '../../types/block.js'
29
+ import { decodeEventLog } from '../../utils/abi/decodeEventLog.js'
30
+ import { formatLog } from '../../utils/formatters/log.js'
26
31
  import { getAction } from '../../utils/getAction.js'
27
- import {
28
- decodeEventLog,
29
- encodeEventTopics,
30
- formatLog,
31
- } from '../../utils/index.js'
32
32
  import {
33
33
  type CreateEventFilterParameters,
34
34
  createEventFilter,
package/celo/fees.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { Client } from '../clients/createClient.js'
2
- import {
3
- type Address,
4
- type ChainEstimateFeesPerGasFnParameters,
5
- type ChainFees,
6
- type Hex,
2
+ import type {
3
+ Address,
4
+ ChainEstimateFeesPerGasFnParameters,
5
+ ChainFees,
6
+ Hex,
7
7
  } from '../index.js'
8
8
 
9
9
  import { formatters } from './formatters.js'
@@ -1,6 +1,6 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
- export const areonNetwork = defineChain({
3
+ export const areonNetwork = /*#__PURE__*/ defineChain({
4
4
  id: 463,
5
5
  name: 'Areon Network',
6
6
  nativeCurrency: { decimals: 18, name: 'AREA', symbol: 'AREA' },
@@ -1,6 +1,6 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
- export const areonNetworkTestnet = defineChain({
3
+ export const areonNetworkTestnet = /*#__PURE__*/ defineChain({
4
4
  id: 462,
5
5
  name: 'Areon Network Testnet',
6
6
  nativeCurrency: { decimals: 18, name: 'TAREA', symbol: 'TAREA' },
@@ -18,8 +18,8 @@ export const cyber = /*#__PURE__*/ defineChain({
18
18
  },
19
19
  contracts: {
20
20
  multicall3: {
21
- address: '0xd1A3cb95E97Abc83777Ced3d474CCdD1AC948F0E',
22
- blockCreated: 43798,
21
+ address: '0xcA11bde05977b3631167028862bE2a173976CA11',
22
+ blockCreated: 0,
23
23
  },
24
24
  },
25
25
  })
@@ -1,6 +1,6 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
- export const darwinia = defineChain({
3
+ export const darwinia = /*#__PURE__*/ defineChain({
4
4
  id: 46,
5
5
  name: 'Darwinia Network',
6
6
  nativeCurrency: {
@@ -1,6 +1,6 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
- export const immutableZkEvmTestnet = defineChain({
3
+ export const immutableZkEvmTestnet = /*#__PURE__*/ defineChain({
4
4
  id: 13473,
5
5
  name: 'Immutable zkEVM Testnet',
6
6
  nativeCurrency: {
@@ -1,6 +1,6 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
- export const reyaNetwork = defineChain({
3
+ export const reyaNetwork = /*#__PURE__*/ defineChain({
4
4
  id: 1729,
5
5
  name: 'Reya Network',
6
6
  nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' },
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.9.27'
1
+ export const version = '2.9.29'
@@ -15,7 +15,7 @@ import type { OneOf } from '../../../types/utils.js'
15
15
  import { parseAccount } from '../../../utils/accounts.js'
16
16
  import type { RequestErrorType } from '../../../utils/buildRequest.js'
17
17
  import { numberToHex } from '../../../utils/encoding/toHex.js'
18
- import { getTransactionError } from '../../../utils/index.js'
18
+ import { getTransactionError } from '../../../utils/errors/getTransactionError.js'
19
19
 
20
20
  export type SendCallsParameters<
21
21
  chain extends Chain | undefined = Chain | undefined,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.9.27",
4
+ "version": "2.9.29",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -1,13 +1,13 @@
1
1
  import type { Abi } from 'abitype'
2
- import type { ErrorType } from '../../errors/utils.js'
3
2
  import {
4
3
  AbiEventSignatureNotFoundError,
5
4
  DecodeLogDataMismatch,
6
5
  DecodeLogTopicsMismatch,
7
- type RpcLog,
8
- } from '../../index.js'
6
+ } from '../../errors/abi.js'
7
+ import type { ErrorType } from '../../errors/utils.js'
9
8
  import type { ContractEventName } from '../../types/contract.js'
10
9
  import type { Log } from '../../types/log.js'
10
+ import type { RpcLog } from '../../types/rpc.js'
11
11
  import {
12
12
  type DecodeEventLogErrorType,
13
13
  decodeEventLog,
@@ -1,5 +1,5 @@
1
+ import { BaseError } from '../../errors/base.js'
1
2
  import type { ErrorType } from '../../errors/utils.js'
2
- import { BaseError } from '../../index.js'
3
3
  import type { ByteArray, Hex } from '../../types/misc.js'
4
4
  import {
5
5
  type CreateCursorErrorType,
package/utils/rpc/http.ts CHANGED
@@ -63,16 +63,17 @@ export function getHttpRpcClient(
63
63
  async request(params) {
64
64
  const {
65
65
  body,
66
- fetchOptions = {},
67
66
  onRequest = options.onRequest,
68
67
  onResponse = options.onResponse,
69
68
  timeout = options.timeout ?? 10_000,
70
69
  } = params
71
- const {
72
- headers,
73
- method,
74
- signal: signal_,
75
- } = { ...options.fetchOptions, ...fetchOptions }
70
+
71
+ const fetchOptions = {
72
+ ...(options.fetchOptions ?? {}),
73
+ ...(params.fetchOptions ?? {}),
74
+ }
75
+
76
+ const { headers, method, signal: signal_ } = fetchOptions
76
77
 
77
78
  try {
78
79
  const response = await withTimeout(
@@ -12,10 +12,7 @@ import {
12
12
  type RecoverAddressErrorType,
13
13
  recoverAddress,
14
14
  } from './recoverAddress.js'
15
- import {
16
- type SignatureToHexErrorType,
17
- signatureToHex,
18
- } from './signatureToHex.js'
15
+ import type { SignatureToHexErrorType } from './signatureToHex.js'
19
16
 
20
17
  export type RecoverTransactionAddressParameters = {
21
18
  serializedTransaction: TransactionSerialized
@@ -38,14 +35,12 @@ export async function recoverTransactionAddress(
38
35
 
39
36
  const transaction = parseTransaction(serializedTransaction)
40
37
 
41
- const signature =
42
- signature_ ??
43
- signatureToHex({
44
- r: transaction.r!,
45
- s: transaction.s!,
46
- v: transaction.v!,
47
- yParity: transaction.yParity!,
48
- })
38
+ const signature = signature_ ?? {
39
+ r: transaction.r!,
40
+ s: transaction.s!,
41
+ v: transaction.v!,
42
+ yParity: transaction.yParity!,
43
+ }
49
44
 
50
45
  const serialized = serializeTransaction({
51
46
  ...transaction,
@@ -1,11 +1,7 @@
1
1
  import type { ErrorType } from '../../errors/utils.js'
2
2
  import type { CompactSignature, Signature } from '../../types/misc.js'
3
- import {
4
- type BytesToHexErrorType,
5
- type HexToBytesErrorType,
6
- bytesToHex,
7
- hexToBytes,
8
- } from '../index.js'
3
+ import { type HexToBytesErrorType, hexToBytes } from '../encoding/toBytes.js'
4
+ import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
9
5
 
10
6
  export type SignatureToCompactSignatureErrorType =
11
7
  | HexToBytesErrorType
@@ -6,7 +6,7 @@ import {
6
6
  type HexToBigIntErrorType,
7
7
  hexToBigInt,
8
8
  } from '../../utils/encoding/fromHex.js'
9
- import { type ToHexErrorType } from '../../utils/encoding/toHex.js'
9
+ import type { ToHexErrorType } from '../../utils/encoding/toHex.js'
10
10
 
11
11
  export type SignatureToHexErrorType =
12
12
  | HexToBigIntErrorType
@@ -28,13 +28,13 @@ export type SignatureToHexErrorType =
28
28
  * // "0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c"
29
29
  */
30
30
  export function signatureToHex({ r, s, v, yParity }: Signature): Hex {
31
- const vHex = (() => {
32
- if (v === 27n || yParity === 0) return '1b'
33
- if (v === 28n || yParity === 1) return '1c'
34
- throw new Error('Invalid v value')
31
+ const yParity_ = (() => {
32
+ if (yParity === 0 || yParity === 1) return yParity
33
+ if (v && (v === 27n || v === 28n || v >= 35n)) return v % 2n === 0n ? 1 : 0
34
+ throw new Error('Invalid `v` or `yParity` value')
35
35
  })()
36
36
  return `0x${new secp256k1.Signature(
37
37
  hexToBigInt(r),
38
38
  hexToBigInt(s),
39
- ).toCompactHex()}${vHex}`
39
+ ).toCompactHex()}${yParity_ === 0 ? '1b' : '1c'}`
40
40
  }
@@ -422,10 +422,10 @@ function parseTransactionLegacy(
422
422
  if (chainId > 0) transaction.chainId = chainId
423
423
  else if (v !== 27n && v !== 28n) throw new InvalidLegacyVError({ v })
424
424
 
425
- delete transaction.yParity
426
425
  transaction.v = v
427
426
  transaction.s = s as Hex
428
427
  transaction.r = r as Hex
428
+ transaction.yParity = v % 2n === 0n ? 1 : 0
429
429
 
430
430
  return transaction
431
431
  }
@@ -1,6 +1,9 @@
1
1
  import type { ErrorType } from '../../errors/utils.js'
2
- import { type AssertRequestErrorType, assertRequest } from '../../index.js'
3
2
  import type { ExactPartial } from '../../types/utils.js'
3
+ import {
4
+ type AssertRequestErrorType,
5
+ assertRequest,
6
+ } from '../../utils/transaction/assertRequest.js'
4
7
  import type { zkSync } from '../../zksync/chains.js'
5
8
  import type { SendTransactionParameters } from '../actions/sendTransaction.js'
6
9
  import { InvalidEip712TransactionError } from '../errors/transaction.js'