viem 2.21.47 → 2.21.49

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/_cjs/accounts/index.js +2 -1
  3. package/_cjs/accounts/index.js.map +1 -1
  4. package/_cjs/accounts/utils/sign.js +8 -1
  5. package/_cjs/accounts/utils/sign.js.map +1 -1
  6. package/_cjs/actions/public/simulateContract.js.map +1 -1
  7. package/_cjs/chains/definitions/bitgert.js +6 -0
  8. package/_cjs/chains/definitions/bitgert.js.map +1 -1
  9. package/_cjs/chains/definitions/disChain.js +25 -0
  10. package/_cjs/chains/definitions/disChain.js.map +1 -0
  11. package/_cjs/chains/definitions/energy.js +22 -0
  12. package/_cjs/chains/definitions/energy.js.map +1 -0
  13. package/_cjs/chains/definitions/guruNetwork.js +32 -0
  14. package/_cjs/chains/definitions/guruNetwork.js.map +1 -0
  15. package/_cjs/chains/definitions/guruTestnet.js +2 -2
  16. package/_cjs/chains/definitions/guruTestnet.js.map +1 -1
  17. package/_cjs/chains/definitions/iSunCoin.js +25 -0
  18. package/_cjs/chains/definitions/iSunCoin.js.map +1 -0
  19. package/_cjs/chains/definitions/mchVerse.js +23 -0
  20. package/_cjs/chains/definitions/mchVerse.js.map +1 -0
  21. package/_cjs/chains/definitions/metadium.js +24 -0
  22. package/_cjs/chains/definitions/metadium.js.map +1 -0
  23. package/_cjs/chains/definitions/sixProtocol.js +26 -0
  24. package/_cjs/chains/definitions/sixProtocol.js.map +1 -0
  25. package/_cjs/chains/definitions/vanar.js +22 -0
  26. package/_cjs/chains/definitions/vanar.js.map +1 -0
  27. package/_cjs/chains/index.js +24 -7
  28. package/_cjs/chains/index.js.map +1 -1
  29. package/_cjs/errors/version.js +1 -1
  30. package/_cjs/zksync/formatters.js +3 -1
  31. package/_cjs/zksync/formatters.js.map +1 -1
  32. package/_cjs/zksync/index.js +3 -1
  33. package/_cjs/zksync/index.js.map +1 -1
  34. package/_cjs/zksync/utils/parseEip712Transaction.js +48 -0
  35. package/_cjs/zksync/utils/parseEip712Transaction.js.map +1 -0
  36. package/_esm/accounts/index.js +1 -1
  37. package/_esm/accounts/index.js.map +1 -1
  38. package/_esm/accounts/utils/sign.js +10 -1
  39. package/_esm/accounts/utils/sign.js.map +1 -1
  40. package/_esm/actions/public/simulateContract.js.map +1 -1
  41. package/_esm/chains/definitions/bitgert.js +6 -0
  42. package/_esm/chains/definitions/bitgert.js.map +1 -1
  43. package/_esm/chains/definitions/disChain.js +22 -0
  44. package/_esm/chains/definitions/disChain.js.map +1 -0
  45. package/_esm/chains/definitions/energy.js +19 -0
  46. package/_esm/chains/definitions/energy.js.map +1 -0
  47. package/_esm/chains/definitions/guruNetwork.js +29 -0
  48. package/_esm/chains/definitions/guruNetwork.js.map +1 -0
  49. package/_esm/chains/definitions/guruTestnet.js +2 -2
  50. package/_esm/chains/definitions/guruTestnet.js.map +1 -1
  51. package/_esm/chains/definitions/iSunCoin.js +22 -0
  52. package/_esm/chains/definitions/iSunCoin.js.map +1 -0
  53. package/_esm/chains/definitions/mchVerse.js +20 -0
  54. package/_esm/chains/definitions/mchVerse.js.map +1 -0
  55. package/_esm/chains/definitions/metadium.js +21 -0
  56. package/_esm/chains/definitions/metadium.js.map +1 -0
  57. package/_esm/chains/definitions/sixProtocol.js +23 -0
  58. package/_esm/chains/definitions/sixProtocol.js.map +1 -0
  59. package/_esm/chains/definitions/vanar.js +19 -0
  60. package/_esm/chains/definitions/vanar.js.map +1 -0
  61. package/_esm/chains/index.js +8 -0
  62. package/_esm/chains/index.js.map +1 -1
  63. package/_esm/errors/version.js +1 -1
  64. package/_esm/zksync/formatters.js +3 -1
  65. package/_esm/zksync/formatters.js.map +1 -1
  66. package/_esm/zksync/index.js +1 -0
  67. package/_esm/zksync/index.js.map +1 -1
  68. package/_esm/zksync/utils/parseEip712Transaction.js +45 -0
  69. package/_esm/zksync/utils/parseEip712Transaction.js.map +1 -0
  70. package/_types/accounts/index.d.ts +1 -1
  71. package/_types/accounts/index.d.ts.map +1 -1
  72. package/_types/accounts/utils/sign.d.ts +4 -0
  73. package/_types/accounts/utils/sign.d.ts.map +1 -1
  74. package/_types/actions/public/simulateContract.d.ts +6 -6
  75. package/_types/actions/public/simulateContract.d.ts.map +1 -1
  76. package/_types/chains/definitions/bitgert.d.ts +6 -10
  77. package/_types/chains/definitions/bitgert.d.ts.map +1 -1
  78. package/_types/chains/definitions/disChain.d.ts +37 -0
  79. package/_types/chains/definitions/disChain.d.ts.map +1 -0
  80. package/_types/chains/definitions/energy.d.ts +37 -0
  81. package/_types/chains/definitions/energy.d.ts.map +1 -0
  82. package/_types/chains/definitions/guruNetwork.d.ts +33 -0
  83. package/_types/chains/definitions/guruNetwork.d.ts.map +1 -0
  84. package/_types/chains/definitions/guruTestnet.d.ts +2 -2
  85. package/_types/chains/definitions/guruTestnet.d.ts.map +1 -1
  86. package/_types/chains/definitions/iSunCoin.d.ts +37 -0
  87. package/_types/chains/definitions/iSunCoin.d.ts.map +1 -0
  88. package/_types/chains/definitions/mchVerse.d.ts +38 -0
  89. package/_types/chains/definitions/mchVerse.d.ts.map +1 -0
  90. package/_types/chains/definitions/metadium.d.ts +37 -0
  91. package/_types/chains/definitions/metadium.d.ts.map +1 -0
  92. package/_types/chains/definitions/sixProtocol.d.ts +37 -0
  93. package/_types/chains/definitions/sixProtocol.d.ts.map +1 -0
  94. package/_types/chains/definitions/vanar.d.ts +37 -0
  95. package/_types/chains/definitions/vanar.d.ts.map +1 -0
  96. package/_types/chains/index.d.ts +8 -0
  97. package/_types/chains/index.d.ts.map +1 -1
  98. package/_types/errors/version.d.ts +1 -1
  99. package/_types/types/account.d.ts +1 -1
  100. package/_types/types/account.d.ts.map +1 -1
  101. package/_types/zksync/formatters.d.ts.map +1 -1
  102. package/_types/zksync/index.d.ts +1 -0
  103. package/_types/zksync/index.d.ts.map +1 -1
  104. package/_types/zksync/types/log.d.ts +1 -1
  105. package/_types/zksync/types/log.d.ts.map +1 -1
  106. package/_types/zksync/utils/parseEip712Transaction.d.ts +4 -0
  107. package/_types/zksync/utils/parseEip712Transaction.d.ts.map +1 -0
  108. package/accounts/index.ts +1 -0
  109. package/accounts/utils/sign.ts +15 -1
  110. package/actions/public/simulateContract.ts +9 -7
  111. package/chains/definitions/bitgert.ts +6 -0
  112. package/chains/definitions/disChain.ts +22 -0
  113. package/chains/definitions/energy.ts +19 -0
  114. package/chains/definitions/guruNetwork.ts +29 -0
  115. package/chains/definitions/guruTestnet.ts +2 -2
  116. package/chains/definitions/iSunCoin.ts +22 -0
  117. package/chains/definitions/mchVerse.ts +20 -0
  118. package/chains/definitions/metadium.ts +21 -0
  119. package/chains/definitions/sixProtocol.ts +23 -0
  120. package/chains/definitions/vanar.ts +19 -0
  121. package/chains/index.ts +8 -0
  122. package/errors/version.ts +1 -1
  123. package/package.json +1 -1
  124. package/types/account.ts +2 -1
  125. package/zksync/formatters.ts +3 -1
  126. package/zksync/index.ts +1 -0
  127. package/zksync/types/log.ts +1 -1
  128. package/zksync/utils/parseEip712Transaction.ts +57 -0
package/chains/index.ts CHANGED
@@ -103,6 +103,7 @@ export { defichainEvmTestnet } from './definitions/defichainEvmTestnet.js'
103
103
  export { degen } from './definitions/degen.js'
104
104
  export { dfk } from './definitions/dfk.js'
105
105
  export { diode } from './definitions/diode.js'
106
+ export { disChain } from './definitions/disChain.js'
106
107
  export { dodochainTestnet } from './definitions/dodochainTestnet.js'
107
108
  export { dogechain } from './definitions/dogechain.js'
108
109
  export { dosChain } from './definitions/dosChain.js'
@@ -122,6 +123,7 @@ export { elastosTestnet } from './definitions/elastosTestnet.js'
122
123
  export { electroneum } from './definitions/electroneum.js'
123
124
  export { electroneumTestnet } from './definitions/electroneumTestnet.js'
124
125
  export { elysiumTestnet } from './definitions/elysiumTestnet.js'
126
+ export { energy } from './definitions/energy.js'
125
127
  export { enuls } from './definitions/enuls.js'
126
128
  export { eon } from './definitions/eon.js'
127
129
  export { eos } from './definitions/eos.js'
@@ -171,6 +173,7 @@ export { goChain } from './definitions/goChain.js'
171
173
  export { godwoken } from './definitions/godwoken.js'
172
174
  export { goerli } from './definitions/goerli.js'
173
175
  export { gravity } from './definitions/gravity.js'
176
+ export { guruNetwork } from './definitions/guruNetwork.js'
174
177
  export { guruTestnet } from './definitions/guruTestnet.js'
175
178
  export { ham } from './definitions/ham.js'
176
179
  export { haqqMainnet } from './definitions/haqqMainnet.js'
@@ -196,6 +199,7 @@ export { iota } from './definitions/iota.js'
196
199
  export { iotaTestnet } from './definitions/iotaTestnet.js'
197
200
  export { iotex } from './definitions/iotex.js'
198
201
  export { iotexTestnet } from './definitions/iotexTestnet.js'
202
+ export { iSunCoin } from './definitions/iSunCoin.js'
199
203
  export { jbc } from './definitions/jbc.js'
200
204
  export { jbcTestnet } from './definitions/jbcTestnet.js'
201
205
  export { karura } from './definitions/karura.js'
@@ -245,11 +249,13 @@ export { mantleTestnet } from './definitions/mantleTestnet.js'
245
249
  export { mapProtocol } from './definitions/mapProtocol.js'
246
250
  export { matchain } from './definitions/matchain.js'
247
251
  export { matchainTestnet } from './definitions/matchainTestnet.js'
252
+ export { mchVerse } from './definitions/mchVerse.js'
248
253
  export { mekong } from './definitions/mekong.js'
249
254
  export { meld } from './definitions/meld.js'
250
255
  export { merlin } from './definitions/merlin.js'
251
256
  export { metachain } from './definitions/metachain.js'
252
257
  export { metachainIstanbul } from './definitions/metachainIstanbul.js'
258
+ export { metadium } from './definitions/metadium.js'
253
259
  export { metalL2 } from './definitions/metalL2.js'
254
260
  export { meter } from './definitions/meter.js'
255
261
  export { meterTestnet } from './definitions/meterTestnet.js'
@@ -348,6 +354,7 @@ export { shimmer } from './definitions/shimmer.js'
348
354
  export { shimmerTestnet } from './definitions/shimmerTestnet.js'
349
355
  export { silicon } from './definitions/silicon.js'
350
356
  export { siliconSepolia } from './definitions/siliconSepolia.js'
357
+ export { sixProtocol } from './definitions/sixProtocol.js'
351
358
  export { skaleBlockBrawlers } from './definitions/skale/brawl.js'
352
359
  export { skaleCalypso } from './definitions/skale/calypso.js'
353
360
  export { skaleCalypsoTestnet } from './definitions/skale/calypsoTestnet.js'
@@ -409,6 +416,7 @@ export { unique } from './definitions/unique.js'
409
416
  export { uniqueOpal } from './definitions/uniqueOpal.js'
410
417
  export { uniqueQuartz } from './definitions/uniqueQuartz.js'
411
418
  export { unreal } from './definitions/unreal.js'
419
+ export { vanar } from './definitions/vanar.js'
412
420
  export { vechain } from './definitions/vechain.js'
413
421
  export { velas } from './definitions/velas.js'
414
422
  export { viction } from './definitions/viction.js'
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.21.47'
1
+ export const version = '2.21.49'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.21.47",
4
+ "version": "2.21.49",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
package/types/account.ts CHANGED
@@ -30,9 +30,10 @@ export type GetAccountParameter<
30
30
  >
31
31
 
32
32
  export type ParseAccount<
33
- accountOrAddress extends Account | Address | undefined =
33
+ accountOrAddress extends Account | Address | null | undefined =
34
34
  | Account
35
35
  | Address
36
+ | null
36
37
  | undefined,
37
38
  > = accountOrAddress extends Address
38
39
  ? Prettify<JsonRpcAccount<accountOrAddress>>
@@ -81,7 +81,9 @@ export const formatters = {
81
81
  return {
82
82
  blockNumber: hexToBigInt(l2ToL1Log.blockHash),
83
83
  blockHash: l2ToL1Log.blockHash,
84
- l1BatchNumber: hexToBigInt(l2ToL1Log.l1BatchNumber),
84
+ l1BatchNumber: l2ToL1Log.l1BatchNumber
85
+ ? hexToBigInt(l2ToL1Log.l1BatchNumber)
86
+ : null,
85
87
  transactionIndex: hexToBigInt(l2ToL1Log.transactionIndex),
86
88
  shardId: hexToBigInt(l2ToL1Log.shardId),
87
89
  isService: l2ToL1Log.isService,
package/zksync/index.ts CHANGED
@@ -281,3 +281,4 @@ export {
281
281
  type GetGeneralPaymasterInputReturnType,
282
282
  getGeneralPaymasterInput,
283
283
  } from './utils/paymaster/getGeneralPaymasterInput.js'
284
+ export { parseEip712Transaction } from './utils/parseEip712Transaction.js'
@@ -45,7 +45,7 @@ export type ZksyncL2ToL1Log = {
45
45
  export type ZksyncRpcL2ToL1Log = {
46
46
  blockNumber: Hex
47
47
  blockHash: Hex
48
- l1BatchNumber: Hex
48
+ l1BatchNumber: Hex | null
49
49
  transactionIndex: Hex
50
50
  shardId: Hex
51
51
  isService: boolean
@@ -0,0 +1,57 @@
1
+ import { BaseError } from '../../errors/base.js'
2
+ import type { Hex } from '../../types/misc.js'
3
+ import {
4
+ fromHex,
5
+ fromRlp,
6
+ hexToBigInt,
7
+ hexToNumber,
8
+ } from '../../utils/index.js'
9
+ import type { ZksyncTransactionSerializableEIP712 } from '../types/transaction.js'
10
+
11
+ export function parseEip712Transaction(
12
+ transaction: Hex,
13
+ ): ZksyncTransactionSerializableEIP712 {
14
+ const payload = fromHex(transaction, 'bytes')
15
+ if (payload[0] !== 113) throw new BaseError('transaction type must be eip712')
16
+
17
+ function validHex(value: Hex): Hex {
18
+ if (!value || value === '0x') return '0x0'
19
+ return value
20
+ }
21
+
22
+ function parsePaymasterArray(arr: Hex[]) {
23
+ if (arr.length === 0) return undefined
24
+ if (arr.length !== 2)
25
+ throw new BaseError(
26
+ `Invalid paymaster parameters, expected to have length of 2, found ${arr.length}!`,
27
+ )
28
+
29
+ return {
30
+ paymaster: arr[0],
31
+ paymasterInput: arr[1],
32
+ }
33
+ }
34
+
35
+ const raw = fromRlp(payload.slice(1)) as Hex[]
36
+ const paymasterParams = parsePaymasterArray(raw[15] as unknown as Hex[])
37
+ return {
38
+ type: 'eip712',
39
+ nonce: hexToNumber(validHex(raw[0])),
40
+ maxPriorityFeePerGas: hexToBigInt(validHex(raw[1])),
41
+ maxFeePerGas: hexToBigInt(validHex(raw[2])),
42
+ gas: hexToBigInt(validHex(raw[3])),
43
+ to: raw[4],
44
+ value: hexToBigInt(validHex(raw[5])),
45
+ data: raw[6],
46
+ v: hexToBigInt(validHex(raw[7])),
47
+ r: raw[8],
48
+ s: raw[9],
49
+ chainId: hexToNumber(validHex(raw[10])),
50
+ from: raw[11],
51
+ gasPerPubdata: hexToBigInt(validHex(raw[12])),
52
+ factoryDeps: raw[13] as unknown as Hex[],
53
+ customSignature: raw[14],
54
+ paymaster: paymasterParams?.paymaster,
55
+ paymasterInput: paymasterParams?.paymasterInput,
56
+ }
57
+ }