viem 2.21.3 → 2.21.4

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 (66) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
  3. package/_cjs/chains/definitions/abstractTestnet.js +32 -0
  4. package/_cjs/chains/definitions/abstractTestnet.js.map +1 -1
  5. package/_cjs/chains/definitions/opBNB.js +19 -0
  6. package/_cjs/chains/definitions/opBNB.js.map +1 -1
  7. package/_cjs/chains/definitions/opBNBTestnet.js +19 -0
  8. package/_cjs/chains/definitions/opBNBTestnet.js.map +1 -1
  9. package/_cjs/chains/definitions/shapeSepolia.js +14 -2
  10. package/_cjs/chains/definitions/shapeSepolia.js.map +1 -1
  11. package/_cjs/errors/version.js +1 -1
  12. package/_cjs/utils/lru.js +6 -3
  13. package/_cjs/utils/lru.js.map +1 -1
  14. package/_cjs/utils/rpc/ipc.js +4 -1
  15. package/_cjs/utils/rpc/ipc.js.map +1 -1
  16. package/_cjs/zksync/utils/getEip712Domain.js +1 -0
  17. package/_cjs/zksync/utils/getEip712Domain.js.map +1 -1
  18. package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -1
  19. package/_esm/chains/definitions/abstractTestnet.js +32 -0
  20. package/_esm/chains/definitions/abstractTestnet.js.map +1 -1
  21. package/_esm/chains/definitions/opBNB.js +19 -0
  22. package/_esm/chains/definitions/opBNB.js.map +1 -1
  23. package/_esm/chains/definitions/opBNBTestnet.js +19 -0
  24. package/_esm/chains/definitions/opBNBTestnet.js.map +1 -1
  25. package/_esm/chains/definitions/shapeSepolia.js +14 -2
  26. package/_esm/chains/definitions/shapeSepolia.js.map +1 -1
  27. package/_esm/errors/version.js +1 -1
  28. package/_esm/experimental/eip7702/actions/signAuthorization.js +2 -2
  29. package/_esm/utils/lru.js +6 -3
  30. package/_esm/utils/lru.js.map +1 -1
  31. package/_esm/utils/rpc/ipc.js +4 -1
  32. package/_esm/utils/rpc/ipc.js.map +1 -1
  33. package/_esm/zksync/utils/getEip712Domain.js +1 -1
  34. package/_esm/zksync/utils/getEip712Domain.js.map +1 -1
  35. package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts +3 -3
  36. package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts.map +1 -1
  37. package/_types/account-abstraction/actions/paymaster/getPaymasterStubData.d.ts +1 -1
  38. package/_types/account-abstraction/actions/paymaster/getPaymasterStubData.d.ts.map +1 -1
  39. package/_types/chains/definitions/abstractTestnet.d.ts +21 -6
  40. package/_types/chains/definitions/abstractTestnet.d.ts.map +1 -1
  41. package/_types/chains/definitions/opBNB.d.ts +34 -1
  42. package/_types/chains/definitions/opBNB.d.ts.map +1 -1
  43. package/_types/chains/definitions/opBNBTestnet.d.ts +34 -1
  44. package/_types/chains/definitions/opBNBTestnet.d.ts.map +1 -1
  45. package/_types/chains/definitions/shapeSepolia.d.ts +261 -15
  46. package/_types/chains/definitions/shapeSepolia.d.ts.map +1 -1
  47. package/_types/errors/version.d.ts +1 -1
  48. package/_types/experimental/eip7702/actions/signAuthorization.d.ts +2 -2
  49. package/_types/experimental/eip7702/decorators/eip7702.d.ts +2 -2
  50. package/_types/utils/lru.d.ts.map +1 -1
  51. package/_types/utils/rpc/ipc.d.ts.map +1 -1
  52. package/_types/zksync/utils/getEip712Domain.d.ts +2 -1
  53. package/_types/zksync/utils/getEip712Domain.d.ts.map +1 -1
  54. package/account-abstraction/actions/paymaster/getPaymasterData.ts +4 -2
  55. package/account-abstraction/actions/paymaster/getPaymasterStubData.ts +1 -1
  56. package/chains/definitions/abstractTestnet.ts +34 -0
  57. package/chains/definitions/opBNB.ts +20 -0
  58. package/chains/definitions/opBNBTestnet.ts +20 -0
  59. package/chains/definitions/shapeSepolia.ts +15 -2
  60. package/errors/version.ts +1 -1
  61. package/experimental/eip7702/actions/signAuthorization.ts +2 -2
  62. package/experimental/eip7702/decorators/eip7702.ts +2 -2
  63. package/package.json +1 -1
  64. package/utils/lru.ts +5 -3
  65. package/utils/rpc/ipc.ts +4 -1
  66. package/zksync/utils/getEip712Domain.ts +1 -1
@@ -1,5 +1,7 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
  import { chainConfig } from '../../zksync/chainConfig.js'
3
+ import type { ZksyncTransactionSerializableEIP712 } from '../../zksync/types/transaction.js'
4
+ import { transactionToMessage } from '../../zksync/utils/getEip712Domain.js'
3
5
 
4
6
  export const abstractTestnet = /*#__PURE__*/ defineChain({
5
7
  ...chainConfig,
@@ -20,4 +22,36 @@ export const abstractTestnet = /*#__PURE__*/ defineChain({
20
22
  },
21
23
  },
22
24
  testnet: true,
25
+ custom: {
26
+ getEip712Domain(transaction: ZksyncTransactionSerializableEIP712) {
27
+ const message = transactionToMessage(transaction)
28
+
29
+ return {
30
+ domain: {
31
+ name: 'Abstract', // Use 'Abstract' rather than 'zkSync'
32
+ version: '2',
33
+ chainId: transaction.chainId,
34
+ },
35
+ types: {
36
+ Transaction: [
37
+ { name: 'txType', type: 'uint256' },
38
+ { name: 'from', type: 'uint256' },
39
+ { name: 'to', type: 'uint256' },
40
+ { name: 'gasLimit', type: 'uint256' },
41
+ { name: 'gasPerPubdataByteLimit', type: 'uint256' },
42
+ { name: 'maxFeePerGas', type: 'uint256' },
43
+ { name: 'maxPriorityFeePerGas', type: 'uint256' },
44
+ { name: 'paymaster', type: 'uint256' },
45
+ { name: 'nonce', type: 'uint256' },
46
+ { name: 'value', type: 'uint256' },
47
+ { name: 'data', type: 'bytes' },
48
+ { name: 'factoryDeps', type: 'bytes32[]' },
49
+ { name: 'paymasterInput', type: 'bytes' },
50
+ ],
51
+ },
52
+ primaryType: 'Transaction',
53
+ message: message,
54
+ }
55
+ },
56
+ },
23
57
  })
@@ -1,5 +1,8 @@
1
+ import { chainConfig } from '../../op-stack/chainConfig.js'
1
2
  import { defineChain } from '../../utils/chain/defineChain.js'
2
3
 
4
+ const sourceId = 56 // bsc mainnet
5
+
3
6
  export const opBNB = /*#__PURE__*/ defineChain({
4
7
  id: 204,
5
8
  name: 'opBNB',
@@ -18,9 +21,26 @@ export const opBNB = /*#__PURE__*/ defineChain({
18
21
  },
19
22
  },
20
23
  contracts: {
24
+ ...chainConfig.contracts,
21
25
  multicall3: {
22
26
  address: '0xcA11bde05977b3631167028862bE2a173976CA11',
23
27
  blockCreated: 512881,
24
28
  },
29
+ l2OutputOracle: {
30
+ [sourceId]: {
31
+ address: '0x153CAB79f4767E2ff862C94aa49573294B13D169',
32
+ },
33
+ },
34
+ portal: {
35
+ [sourceId]: {
36
+ address: '0x1876EA7702C0ad0C6A2ae6036DE7733edfBca519',
37
+ },
38
+ },
39
+ l1StandardBridge: {
40
+ [sourceId]: {
41
+ address: '0xF05F0e4362859c3331Cb9395CBC201E3Fa6757Ea',
42
+ },
43
+ },
25
44
  },
45
+ sourceId,
26
46
  })
@@ -1,5 +1,8 @@
1
+ import { chainConfig } from '../../op-stack/chainConfig.js'
1
2
  import { defineChain } from '../../utils/chain/defineChain.js'
2
3
 
4
+ const sourceId = 97 // bsc testnet
5
+
3
6
  export const opBNBTestnet = /*#__PURE__*/ defineChain({
4
7
  id: 5611,
5
8
  name: 'opBNB Testnet',
@@ -18,10 +21,27 @@ export const opBNBTestnet = /*#__PURE__*/ defineChain({
18
21
  },
19
22
  },
20
23
  contracts: {
24
+ ...chainConfig.contracts,
21
25
  multicall3: {
22
26
  address: '0xcA11bde05977b3631167028862bE2a173976CA11',
23
27
  blockCreated: 3705108,
24
28
  },
29
+ l2OutputOracle: {
30
+ [sourceId]: {
31
+ address: '0xFf2394Bb843012562f4349C6632a0EcB92fC8810',
32
+ },
33
+ },
34
+ portal: {
35
+ [sourceId]: {
36
+ address: '0x4386C8ABf2009aC0c263462Da568DD9d46e52a31',
37
+ },
38
+ },
39
+ l1StandardBridge: {
40
+ [sourceId]: {
41
+ address: '0x677311Fd2cCc511Bbc0f581E8d9a07B033D5E840',
42
+ },
43
+ },
25
44
  },
26
45
  testnet: true,
46
+ sourceId,
27
47
  })
@@ -1,6 +1,10 @@
1
+ import { chainConfig } from '../../op-stack/chainConfig.js'
1
2
  import { defineChain } from '../../utils/chain/defineChain.js'
2
3
 
4
+ const sourceId = 11_155_111 // sepolia
5
+
3
6
  export const shapeSepolia = /*#__PURE__*/ defineChain({
7
+ ...chainConfig,
4
8
  id: 11_011,
5
9
  name: 'Shape Sepolia Testnet',
6
10
  nativeCurrency: { name: 'Sepolia Ether', symbol: 'ETH', decimals: 18 },
@@ -12,8 +16,17 @@ export const shapeSepolia = /*#__PURE__*/ defineChain({
12
16
  blockExplorers: {
13
17
  default: {
14
18
  name: 'blockscout',
15
- url: 'https://shape-sepolia-explorer.alchemy.com',
16
- apiUrl: 'https://shape-sepolia-explorer.alchemy.com/api/v2',
19
+ url: 'https://explorer-sepolia.shape.network/',
20
+ apiUrl: 'https://explorer-sepolia.shape.network/api/v2',
21
+ },
22
+ },
23
+ contracts: {
24
+ ...chainConfig.contracts,
25
+ multicall3: {
26
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
27
+ blockCreated: 1,
17
28
  },
18
29
  },
30
+ testnet: true,
31
+ sourceId,
19
32
  })
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.21.3'
1
+ export const version = '2.21.4'
@@ -62,7 +62,7 @@ export type SignAuthorizationErrorType =
62
62
  * })
63
63
  * const signature = await signAuthorization(client, {
64
64
  * account: privateKeyToAccount('0x..'),
65
- * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
65
+ * contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
66
66
  * })
67
67
  *
68
68
  * @example
@@ -78,7 +78,7 @@ export type SignAuthorizationErrorType =
78
78
  * transport: http(),
79
79
  * })
80
80
  * const signature = await signAuthorization(client, {
81
- * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
81
+ * contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
82
82
  * })
83
83
  */
84
84
  export async function signAuthorization<
@@ -35,7 +35,7 @@ export type Eip7702Actions<
35
35
  *
36
36
  * const signature = await client.signAuthorization({
37
37
  * account: privateKeyToAccount('0x..'),
38
- * authorization: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
38
+ * contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
39
39
  * })
40
40
  *
41
41
  * @example
@@ -52,7 +52,7 @@ export type Eip7702Actions<
52
52
  * }).extend(eip7702Actions())
53
53
  *
54
54
  * const signature = await client.signAuthorization({
55
- * authorization: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
55
+ * contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
56
56
  * })
57
57
  */
58
58
  signAuthorization: (
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.3",
4
+ "version": "2.21.4",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
package/utils/lru.ts CHANGED
@@ -14,7 +14,7 @@ export class LruMap<value = unknown> extends Map<string, value> {
14
14
  override get(key: string) {
15
15
  const value = super.get(key)
16
16
 
17
- if (value !== undefined) {
17
+ if (super.has(key) && value !== undefined) {
18
18
  this.delete(key)
19
19
  super.set(key, value)
20
20
  }
@@ -24,8 +24,10 @@ export class LruMap<value = unknown> extends Map<string, value> {
24
24
 
25
25
  override set(key: string, value: value) {
26
26
  super.set(key, value)
27
- if (this.maxSize && this.size > this.maxSize)
28
- this.delete(this.keys().next().value)
27
+ if (this.maxSize && this.size > this.maxSize) {
28
+ const firstKey = this.keys().next().value
29
+ if (firstKey) this.delete(firstKey)
30
+ }
29
31
  return this
30
32
  }
31
33
  }
package/utils/rpc/ipc.ts CHANGED
@@ -60,7 +60,10 @@ export async function getIpcRpcClient(
60
60
  let lastRemaining = Buffer.alloc(0)
61
61
  function onData(buffer: Buffer) {
62
62
  const [messages, remaining] = extractMessages(
63
- Buffer.concat([lastRemaining, buffer]),
63
+ Buffer.concat([
64
+ Uint8Array.from(lastRemaining),
65
+ Uint8Array.from(buffer),
66
+ ]),
64
67
  )
65
68
  for (const message of messages) {
66
69
  const response = JSON.parse(Buffer.from(message).toString())
@@ -50,7 +50,7 @@ export const getEip712Domain: EIP712DomainFn<
50
50
  //////////////////////////////////////////////////////////////////////////////
51
51
  // Utilities
52
52
 
53
- function transactionToMessage(
53
+ export function transactionToMessage(
54
54
  transaction: ZksyncTransactionSerializableEIP712,
55
55
  ): ZksyncEIP712TransactionSignable {
56
56
  const {