viem 0.0.0-main.20240519T233212 → 0.0.0-main.20240520T005450

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 (78) hide show
  1. package/_cjs/errors/version.js +1 -1
  2. package/_cjs/zksync/actions/getL1Allowance.js +19 -0
  3. package/_cjs/zksync/actions/getL1Allowance.js.map +1 -0
  4. package/_cjs/zksync/actions/getL1Balance.js +23 -0
  5. package/_cjs/zksync/actions/getL1Balance.js.map +1 -0
  6. package/_cjs/zksync/actions/getL1TokenBalance.js +24 -0
  7. package/_cjs/zksync/actions/getL1TokenBalance.js.map +1 -0
  8. package/_cjs/zksync/actions/{getRawBlockTransaction.js → getRawBlockTransactions.js} +1 -1
  9. package/_cjs/zksync/actions/getRawBlockTransactions.js.map +1 -0
  10. package/_cjs/zksync/constants/address.js +4 -1
  11. package/_cjs/zksync/constants/address.js.map +1 -1
  12. package/_cjs/zksync/decorators/publicL1.js +15 -0
  13. package/_cjs/zksync/decorators/publicL1.js.map +1 -0
  14. package/_cjs/zksync/decorators/publicL2.js +2 -2
  15. package/_cjs/zksync/decorators/publicL2.js.map +1 -1
  16. package/_cjs/zksync/errors/token-is-eth.js +17 -0
  17. package/_cjs/zksync/errors/token-is-eth.js.map +1 -0
  18. package/_cjs/zksync/index.js +13 -5
  19. package/_cjs/zksync/index.js.map +1 -1
  20. package/_cjs/zksync/utils/isEth.js +17 -0
  21. package/_cjs/zksync/utils/isEth.js.map +1 -0
  22. package/_esm/errors/version.js +1 -1
  23. package/_esm/zksync/actions/getL1Allowance.js +15 -0
  24. package/_esm/zksync/actions/getL1Allowance.js.map +1 -0
  25. package/_esm/zksync/actions/getL1Balance.js +19 -0
  26. package/_esm/zksync/actions/getL1Balance.js.map +1 -0
  27. package/_esm/zksync/actions/getL1TokenBalance.js +20 -0
  28. package/_esm/zksync/actions/getL1TokenBalance.js.map +1 -0
  29. package/_esm/zksync/actions/{getRawBlockTransaction.js → getRawBlockTransactions.js} +1 -1
  30. package/_esm/zksync/actions/getRawBlockTransactions.js.map +1 -0
  31. package/_esm/zksync/constants/address.js +3 -0
  32. package/_esm/zksync/constants/address.js.map +1 -1
  33. package/_esm/zksync/decorators/publicL1.js +12 -0
  34. package/_esm/zksync/decorators/publicL1.js.map +1 -0
  35. package/_esm/zksync/decorators/publicL2.js +7 -7
  36. package/_esm/zksync/decorators/publicL2.js.map +1 -1
  37. package/_esm/zksync/errors/token-is-eth.js +13 -0
  38. package/_esm/zksync/errors/token-is-eth.js.map +1 -0
  39. package/_esm/zksync/index.js +6 -2
  40. package/_esm/zksync/index.js.map +1 -1
  41. package/_esm/zksync/utils/isEth.js +13 -0
  42. package/_esm/zksync/utils/isEth.js.map +1 -0
  43. package/_types/errors/version.d.ts +1 -1
  44. package/_types/zksync/actions/getL1Allowance.d.ts +17 -0
  45. package/_types/zksync/actions/getL1Allowance.d.ts.map +1 -0
  46. package/_types/zksync/actions/getL1Balance.d.ts +23 -0
  47. package/_types/zksync/actions/getL1Balance.d.ts.map +1 -0
  48. package/_types/zksync/actions/getL1TokenBalance.d.ts +24 -0
  49. package/_types/zksync/actions/getL1TokenBalance.d.ts.map +1 -0
  50. package/_types/zksync/actions/{getRawBlockTransaction.d.ts → getRawBlockTransactions.d.ts} +4 -4
  51. package/_types/zksync/actions/getRawBlockTransactions.d.ts.map +1 -0
  52. package/_types/zksync/constants/address.d.ts +3 -0
  53. package/_types/zksync/constants/address.d.ts.map +1 -1
  54. package/_types/zksync/decorators/publicL1.d.ts +145 -0
  55. package/_types/zksync/decorators/publicL1.d.ts.map +1 -0
  56. package/_types/zksync/decorators/publicL2.d.ts +17 -13
  57. package/_types/zksync/decorators/publicL2.d.ts.map +1 -1
  58. package/_types/zksync/errors/token-is-eth.d.ts +9 -0
  59. package/_types/zksync/errors/token-is-eth.d.ts.map +1 -0
  60. package/_types/zksync/index.d.ts +6 -2
  61. package/_types/zksync/index.d.ts.map +1 -1
  62. package/_types/zksync/utils/isEth.d.ts +3 -0
  63. package/_types/zksync/utils/isEth.d.ts.map +1 -0
  64. package/errors/version.ts +1 -1
  65. package/package.json +1 -1
  66. package/zksync/actions/getL1Allowance.ts +43 -0
  67. package/zksync/actions/getL1Balance.ts +68 -0
  68. package/zksync/actions/getL1TokenBalance.ts +63 -0
  69. package/zksync/actions/{getRawBlockTransaction.ts → getRawBlockTransactions.ts} +5 -5
  70. package/zksync/constants/address.ts +9 -0
  71. package/zksync/decorators/publicL1.ts +180 -0
  72. package/zksync/decorators/publicL2.ts +38 -20
  73. package/zksync/errors/token-is-eth.ts +16 -0
  74. package/zksync/index.ts +27 -4
  75. package/zksync/utils/isEth.ts +20 -0
  76. package/_cjs/zksync/actions/getRawBlockTransaction.js.map +0 -1
  77. package/_esm/zksync/actions/getRawBlockTransaction.js.map +0 -1
  78. package/_types/zksync/actions/getRawBlockTransaction.d.ts.map +0 -1
@@ -0,0 +1,24 @@
1
+ import type { Address } from '../../accounts/index.js';
2
+ import type { Client } from '../../clients/createClient.js';
3
+ import type { Transport } from '../../clients/transports/createTransport.js';
4
+ import type { AccountNotFoundError } from '../../errors/account.js';
5
+ import type { BaseError } from '../../errors/base.js';
6
+ import type { Account, GetAccountParameter } from '../../types/account.js';
7
+ import type { BlockTag } from '../../types/block.js';
8
+ import type { Chain } from '../../types/chain.js';
9
+ import { TokenIsEthError } from '../errors/token-is-eth.js';
10
+ export type GetL1TokenBalanceParameters<TAccount extends Account | undefined = Account | undefined> = GetAccountParameter<TAccount> & {
11
+ token: Address;
12
+ } & ({
13
+ /** The balance of the account at a block number. */
14
+ blockNumber?: bigint | undefined;
15
+ blockTag?: never | undefined;
16
+ } | {
17
+ blockNumber?: never | undefined;
18
+ /** The balance of the account at a block tag. */
19
+ blockTag?: BlockTag | undefined;
20
+ });
21
+ export type GetL1TokenBalanceReturnType = bigint;
22
+ export type GetL1TokenBalanceErrorType = AccountNotFoundError | BaseError | TokenIsEthError;
23
+ export declare function getL1TokenBalance<TChain extends Chain | undefined, TAccount extends Account | undefined>(client: Client<Transport, TChain, TAccount>, parameters: GetL1TokenBalanceParameters<TAccount>): Promise<GetL1TokenBalanceReturnType>;
24
+ //# sourceMappingURL=getL1TokenBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getL1TokenBalance.d.ts","sourceRoot":"","sources":["../../../zksync/actions/getL1TokenBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAE5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAG3D,MAAM,MAAM,2BAA2B,CACrC,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,IACxD,mBAAmB,CAAC,QAAQ,CAAC,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,CACnD;IACE,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;CAC7B,GACD;IACE,WAAW,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;IAC/B,iDAAiD;IACjD,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAChC,CACJ,CAAA;AAEH,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAAA;AAEhD,MAAM,MAAM,0BAA0B,GAClC,oBAAoB,GACpB,SAAS,GACT,eAAe,CAAA;AAEnB,wBAAsB,iBAAiB,CACrC,MAAM,SAAS,KAAK,GAAG,SAAS,EAChC,QAAQ,SAAS,OAAO,GAAG,SAAS,EAEpC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAC3C,UAAU,EAAE,2BAA2B,CAAC,QAAQ,CAAC,GAChD,OAAO,CAAC,2BAA2B,CAAC,CAoBtC"}
@@ -5,7 +5,7 @@ import type { Chain } from '../../types/chain.js';
5
5
  import type { ZkSyncNumberParameter } from '../types/block.js';
6
6
  import type { PublicZkSyncRpcSchema } from '../types/eip1193.js';
7
7
  import type { ZkSyncRawBlockTransactions } from '../types/transaction.js';
8
- export type GetRawBlockTransactionParameters = ZkSyncNumberParameter;
9
- export type GetRawBlockTransactionReturnType = ZkSyncRawBlockTransactions;
10
- export declare function getRawBlockTransactions<TChain extends Chain | undefined, TAccount extends Account | undefined>(client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>, parameters: GetRawBlockTransactionParameters): Promise<GetRawBlockTransactionReturnType>;
11
- //# sourceMappingURL=getRawBlockTransaction.d.ts.map
8
+ export type GetRawBlockTransactionsParameters = ZkSyncNumberParameter;
9
+ export type GetRawBlockTransactionsReturnType = ZkSyncRawBlockTransactions;
10
+ export declare function getRawBlockTransactions<TChain extends Chain | undefined, TAccount extends Account | undefined>(client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>, parameters: GetRawBlockTransactionsParameters): Promise<GetRawBlockTransactionsReturnType>;
11
+ //# sourceMappingURL=getRawBlockTransactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRawBlockTransactions.d.ts","sourceRoot":"","sources":["../../../zksync/actions/getRawBlockTransactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAA;AAGzE,MAAM,MAAM,iCAAiC,GAAG,qBAAqB,CAAA;AAErE,MAAM,MAAM,iCAAiC,GAAG,0BAA0B,CAAA;AAE1E,wBAAsB,uBAAuB,CAC3C,MAAM,SAAS,KAAK,GAAG,SAAS,EAChC,QAAQ,SAAS,OAAO,GAAG,SAAS,EAEpC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,qBAAqB,CAAC,EAClE,UAAU,EAAE,iCAAiC,GAC5C,OAAO,CAAC,iCAAiC,CAAC,CAM5C"}
@@ -1,2 +1,5 @@
1
1
  export declare const contractDeployerAddress: "0x0000000000000000000000000000000000008006";
2
+ export declare const legacyEthAddress: "0x0000000000000000000000000000000000000000";
3
+ export declare const ethAddressInContracts: "0x0000000000000000000000000000000000000001";
4
+ export declare const l2BaseTokenAddress: "0x000000000000000000000000000000000000800a";
2
5
  //# sourceMappingURL=address.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../zksync/constants/address.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,8CACmB,CAAA"}
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../zksync/constants/address.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,8CACmB,CAAA;AAEvD,eAAO,MAAM,gBAAgB,8CAC0B,CAAA;AAEvD,eAAO,MAAM,qBAAqB,8CACqB,CAAA;AAEvD,eAAO,MAAM,kBAAkB,8CACwB,CAAA"}
@@ -0,0 +1,145 @@
1
+ import type { Chain } from '../../chains/index.js';
2
+ import type { Client } from '../../clients/createClient.js';
3
+ import type { Transport } from '../../clients/transports/createTransport.js';
4
+ import type { Account } from '../../types/account.js';
5
+ import { type GetL1AllowanceParameters, type GetL1AllowanceReturnType } from '../actions/getL1Allowance.js';
6
+ import { type GetL1BalanceParameters, type GetL1BalanceReturnType } from '../actions/getL1Balance.js';
7
+ import { type GetL1TokenBalanceParameters, type GetL1TokenBalanceReturnType } from '../actions/getL1TokenBalance.js';
8
+ export type PublicActionsL1<TAccount extends Account | undefined = Account | undefined> = {
9
+ /**
10
+ * Returns the amount of approved tokens for a specific L1 bridge.
11
+ *
12
+ * - Docs: https://viem.sh/zksync/actions/getL1Allowance
13
+ *
14
+ * @param client - Client to use
15
+ * @param parameters - {@link AllowanceL1Parameters}
16
+ * @returns The amount of approved tokens for a specific L1 bridge. {@link GetL1AllowanceReturnType}
17
+ *
18
+ * @example
19
+ * import { createPublicClient, custom, parseEther } from 'viem'
20
+ * import { base, mainnet } from 'viem/chains'
21
+ * import { publicActionsL1 } from 'viem/zksync'
22
+ *
23
+ * const client = createPublicClient({
24
+ * chain: mainnet,
25
+ * transport: custom(window.ethereum),
26
+ * }).extend(publicActionsL1())
27
+ *
28
+ * const data = await client.getL1Allowance({
29
+ * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
30
+ * token: '0x5C221E77624690fff6dd741493D735a17716c26B'
31
+ * bridgeAddress: '0x84DbCC0B82124bee38e3Ce9a92CdE2f943bab60D',
32
+ * })
33
+ *
34
+ * @example
35
+ * // Account Hoisting
36
+ * import { createWalletClient, http } from 'viem'
37
+ * import { privateKeyToAccount } from 'viem/accounts'
38
+ * import { base, mainnet } from 'viem/chains'
39
+ * import { publicActionsL1 } from 'viem/zksync'
40
+ *
41
+ * const client = createWalletClient({
42
+ * account: privateKeyToAccount('0x…'),
43
+ * chain: mainnet,
44
+ * transport: http(),
45
+ * }).extend(publicActionsL1())
46
+ *
47
+ * const data = await client.getL1Allowance({
48
+ * token: '0x5C221E77624690fff6dd741493D735a17716c26B'
49
+ * bridgeAddress: '0x84DbCC0B82124bee38e3Ce9a92CdE2f943bab60D',
50
+ * })
51
+ */
52
+ getL1Allowance: (parameters: GetL1AllowanceParameters<TAccount>) => Promise<GetL1AllowanceReturnType>;
53
+ /**
54
+ * Returns the amount of the ERC20 token the client has on specific address.
55
+ *
56
+ * - Docs: https://viem.sh/zksync/actions/getL1TokenBalance
57
+ *
58
+ * @param client - Client to use
59
+ * @param parameters - {@link GetL1TokenBalanceParameters}
60
+ * @returns The amount of the ERC20 token the client has on specific addresse. {@link GetL1TokenBalanceReturnType}
61
+ *
62
+ * @example
63
+ * import { createPublicClient, custom, parseEther } from 'viem'
64
+ * import { base, mainnet } from 'viem/chains'
65
+ * import { publicActionsL1 } from 'viem/zksync'
66
+ *
67
+ * const client = createPublicClient({
68
+ * chain: mainnet,
69
+ * transport: custom(window.ethereum),
70
+ * }).extend(publicActionsL1())
71
+ *
72
+ * const data = await client.getL1TokenBalance({
73
+ * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
74
+ * token: '0x5C221E77624690fff6dd741493D735a17716c26B'
75
+ * })
76
+ *
77
+ * @example
78
+ * // Account Hoisting
79
+ * import { createWalletClient, http } from 'viem'
80
+ * import { privateKeyToAccount } from 'viem/accounts'
81
+ * import { base, mainnet } from 'viem/chains'
82
+ * import { publicActionsL1 } from 'viem/zksync'
83
+ *
84
+ * const client = createWalletClient({
85
+ * account: privateKeyToAccount('0x…'),
86
+ * chain: mainnet,
87
+ * transport: http(),
88
+ * }).extend(publicActionsL1())
89
+ *
90
+ * const data = await client.getL1TokenBalance({
91
+ * token: '0x5C221E77624690fff6dd741493D735a17716c26B'
92
+ * })
93
+ */
94
+ getL1TokenBalance: (parameters: GetL1TokenBalanceParameters<TAccount>) => Promise<GetL1TokenBalanceReturnType>;
95
+ /**
96
+ * Returns the amount of the token held by the account on the L1 network.
97
+ *
98
+ * - Docs: https://viem.sh/zksync/actions/getL1TokenBalance
99
+ *
100
+ * @param client - Client to use
101
+ * @param parameters - {@link BalanceL1Parameters}
102
+ * @returns Returns the amount of the token held by the account on the L1 network. {@link GetL1BalanceReturnType}
103
+ *
104
+ * @example
105
+ * import { createPublicClient, custom, parseEther } from 'viem'
106
+ * import { base, mainnet } from 'viem/chains'
107
+ * import { publicActionsL1 } from 'viem/zksync'
108
+ *
109
+ * const client = createPublicClient({
110
+ * chain: mainnet,
111
+ * transport: custom(window.ethereum),
112
+ * }).extend(publicActionsL1())
113
+ *
114
+ * const data = await client.getL1Balance({
115
+ * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'
116
+ * })
117
+ *
118
+ * const data = await client.getL1Balance({
119
+ * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
120
+ * token: '0x5C221E77624690fff6dd741493D735a17716c26B'
121
+ * })
122
+ *
123
+ * @example
124
+ * // Account Hoisting
125
+ * import { createWalletClient, http } from 'viem'
126
+ * import { privateKeyToAccount } from 'viem/accounts'
127
+ * import { base, mainnet } from 'viem/chains'
128
+ * import { publicActionsL1 } from 'viem/zksync'
129
+ *
130
+ * const client = createWalletClient({
131
+ * account: privateKeyToAccount('0x…'),
132
+ * chain: mainnet,
133
+ * transport: http(),
134
+ * }).extend(publicActionsL1())
135
+ *
136
+ * const data = await client.getL1Balance({})
137
+ *
138
+ * const data = await client.getL1Balance({
139
+ * token: '0x5C221E77624690fff6dd741493D735a17716c26B'
140
+ * })
141
+ */
142
+ getL1Balance: (...parameters: TAccount extends undefined ? [GetL1BalanceParameters<TAccount>] : [GetL1BalanceParameters<TAccount>] | []) => Promise<GetL1BalanceReturnType>;
143
+ };
144
+ export declare function publicActionsL1(): <TChain extends Chain | undefined = Chain | undefined, TAccount extends Account | undefined = Account | undefined>(client: Client<Transport, TChain, TAccount>) => PublicActionsL1<TAccount>;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,CAAC,GAAG,EAAE,KACxC,OAAO,CAAC,sBAAsB,CAAC,CAAA;CACrC,CAAA;AAED,wBAAgB,eAAe,+HAKnB,OAAO,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,KAC1C,gBAAgB,QAAQ,CAAC,CAM7B"}
@@ -1,17 +1,21 @@
1
- import type { Address } from 'abitype';
2
1
  import type { Client } from '../../clients/createClient.js';
3
2
  import type { Transport } from '../../clients/transports/createTransport.js';
4
3
  import type { Account } from '../../types/account.js';
5
- import type { Hex } from '../../types/misc.js';
6
4
  import type { EstimateFeeParameters, EstimateFeeReturnType } from '../actions/estimateFee.js';
7
- import { type EstimateGasL1ToL2Parameters } from '../actions/estimateGasL1ToL2.js';
5
+ import { type EstimateGasL1ToL2Parameters, type EstimateGasL1ToL2ReturnType } from '../actions/estimateGasL1ToL2.js';
8
6
  import { type GetAllBalancesParameters, type GetAllBalancesReturnType } from '../actions/getAllBalances.js';
7
+ import { type GetBaseTokenL1AddressReturnType } from '../actions/getBaseTokenL1Address.js';
9
8
  import { type GetBlockDetailsParameters, type GetBlockDetailsReturnType } from '../actions/getBlockDetails.js';
9
+ import { type GetBridgehubContractAddressReturnType } from '../actions/getBridgehubContractAddress.js';
10
10
  import { type GetDefaultBridgeAddressesReturnType } from '../actions/getDefaultBridgeAddresses.js';
11
11
  import { type GetL1BatchBlockRangeParameters, type GetL1BatchBlockRangeReturnParameters } from '../actions/getL1BatchBlockRange.js';
12
12
  import { type GetL1BatchDetailsParameters, type GetL1BatchDetailsReturnType } from '../actions/getL1BatchDetails.js';
13
+ import { type GetL1BatchNumberReturnType } from '../actions/getL1BatchNumber.js';
14
+ import { type GetL1ChainIdReturnType } from '../actions/getL1ChainId.js';
13
15
  import { type GetLogProofParameters, type GetLogProofReturnType } from '../actions/getLogProof.js';
14
- import { type GetRawBlockTransactionParameters, type GetRawBlockTransactionReturnType } from '../actions/getRawBlockTransaction.js';
16
+ import { type GetMainContractAddressReturnType } from '../actions/getMainContractAddress.js';
17
+ import { type GetRawBlockTransactionsParameters, type GetRawBlockTransactionsReturnType } from '../actions/getRawBlockTransactions.js';
18
+ import { type GetTestnetPaymasterAddressReturnType } from '../actions/getTestnetPaymasterAddress.js';
15
19
  import { type GetTransactionDetailsParameters, type GetTransactionDetailsReturnType } from '../actions/getTransactionDetails.js';
16
20
  import type { ChainEIP712 } from '../types/chain.js';
17
21
  export type PublicActionsL2<TChain extends ChainEIP712 | undefined = ChainEIP712 | undefined, TAccount extends Account | undefined = Account | undefined> = {
@@ -50,7 +54,7 @@ export type PublicActionsL2<TChain extends ChainEIP712 | undefined = ChainEIP712
50
54
  *
51
55
  * const address = await client.getTestnetPaymasterAddress();
52
56
  */
53
- getTestnetPaymasterAddress: () => Promise<Address | null>;
57
+ getTestnetPaymasterAddress: () => Promise<GetTestnetPaymasterAddressReturnType>;
54
58
  /**
55
59
  * Returns the Chain Id of underlying L1 network.
56
60
  *
@@ -68,7 +72,7 @@ export type PublicActionsL2<TChain extends ChainEIP712 | undefined = ChainEIP712
68
72
  *
69
73
  * const chainId = await client.getL1ChainId();
70
74
  */
71
- getL1ChainId: () => Promise<Hex>;
75
+ getL1ChainId: () => Promise<GetL1ChainIdReturnType>;
72
76
  /**
73
77
  * Returns the address of a Main zkSync Contract.
74
78
  *
@@ -86,7 +90,7 @@ export type PublicActionsL2<TChain extends ChainEIP712 | undefined = ChainEIP712
86
90
  *
87
91
  * const address = await client.getMainContractAddress();
88
92
  */
89
- getMainContractAddress: () => Promise<Address>;
93
+ getMainContractAddress: () => Promise<GetMainContractAddressReturnType>;
90
94
  /**
91
95
  * Returns all known balances for a given account.
92
96
  *
@@ -110,7 +114,7 @@ export type PublicActionsL2<TChain extends ChainEIP712 | undefined = ChainEIP712
110
114
  * Returns data of transactions in a block.
111
115
  *
112
116
  * @returns data of transactions {@link RawBlockTransactions}
113
- * @param args - {@link GetRawBlockTransactionParameters}
117
+ * @param args - {@link GetRawBlockTransactionsParameters}
114
118
  *
115
119
  * @example
116
120
  * import { createPublicClient, http } from 'viem'
@@ -124,7 +128,7 @@ export type PublicActionsL2<TChain extends ChainEIP712 | undefined = ChainEIP712
124
128
  *
125
129
  * const rawTx = await client.getRawBlockTransaction({number: 1});
126
130
  */
127
- getRawBlockTransaction: (args: GetRawBlockTransactionParameters) => Promise<GetRawBlockTransactionReturnType>;
131
+ getRawBlockTransaction: (args: GetRawBlockTransactionsParameters) => Promise<GetRawBlockTransactionsReturnType>;
128
132
  /**
129
133
  * Returns additional zkSync-specific information about the L2 block.
130
134
  *
@@ -199,7 +203,7 @@ export type PublicActionsL2<TChain extends ChainEIP712 | undefined = ChainEIP712
199
203
  *
200
204
  * const latestNumber = await client.getL1BatchNumber({number: 1});
201
205
  */
202
- getL1BatchNumber: () => Promise<Hex>;
206
+ getL1BatchNumber: () => Promise<GetL1BatchNumberReturnType>;
203
207
  /**
204
208
  * Given a transaction hash, and an index of the L2 to L1 log produced within the transaction, it returns the proof for the corresponding L2 to L1 log.
205
209
  *
@@ -274,7 +278,7 @@ export type PublicActionsL2<TChain extends ChainEIP712 | undefined = ChainEIP712
274
278
  *
275
279
  * const details = await client.estimateGasL1ToL2({transactionRequest: {...}}});
276
280
  */
277
- estimateGasL1ToL2: (args: EstimateGasL1ToL2Parameters<TChain, TAccount>) => Promise<bigint>;
281
+ estimateGasL1ToL2: (args: EstimateGasL1ToL2Parameters<TChain, TAccount>) => Promise<EstimateGasL1ToL2ReturnType>;
278
282
  /**
279
283
  * Returns the Bridgehub smart contract address.
280
284
  *
@@ -293,7 +297,7 @@ export type PublicActionsL2<TChain extends ChainEIP712 | undefined = ChainEIP712
293
297
  *
294
298
  * const address = await client.getBridgehubContractAddress();
295
299
  */
296
- getBridgehubContractAddress: () => Promise<Address>;
300
+ getBridgehubContractAddress: () => Promise<GetBridgehubContractAddressReturnType>;
297
301
  /**
298
302
  * Returns the address of the base L1 token.
299
303
  *
@@ -312,7 +316,7 @@ export type PublicActionsL2<TChain extends ChainEIP712 | undefined = ChainEIP712
312
316
  *
313
317
  * const address = await client.getBaseTokenL1Address();
314
318
  */
315
- getBaseTokenL1Address: () => Promise<Address>;
319
+ getBaseTokenL1Address: () => Promise<GetBaseTokenL1AddressReturnType>;
316
320
  };
317
321
  export declare function publicActionsL2(): <TTransport extends Transport = Transport, TChain extends ChainEIP712 | undefined = ChainEIP712 | undefined, TAccount extends Account | undefined = Account | undefined>(client: Client<TTransport, TChain, TAccount>) => PublicActionsL2<TChain, TAccount>;
318
322
  //# sourceMappingURL=publicL2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publicL2.d.ts","sourceRoot":"","sources":["../../../zksync/decorators/publicL2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAE9C,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAE9B,MAAM,8BAA8B,CAAA;AAErC,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAE/B,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EACL,KAAK,mCAAmC,EAEzC,MAAM,yCAAyC,CAAA;AAChD,OAAO,EACL,KAAK,8BAA8B,EACnC,KAAK,oCAAoC,EAE1C,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAEjC,MAAM,iCAAiC,CAAA;AAGxC,OAAO,EACL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A;IAE3D;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAE5E;;;;;;;;;;;;;;;;;OAiBG;IACH,qBAAqB,EAAE,CACrB,IAAI,EAAE,+BAA+B,KAClC,OAAO,CAAC,+BAA+B,CAAC,CAAA;IAE7C;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,EAAE,CACX,IAAI,EAAE,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,KAC1C,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAEnC;;;;;;;;;;;;;;;;;OAiBG;IACH,iBAAiB,EAAE,CACjB,IAAI,EAAE,2BAA2B,CAAC,MAAM,EAAE,QAAQ,CAAC,KAChD,OAAO,CAAC,2BAA2B,CAAC,CAAA;IAEzC;;;;;;;;;;;;;;;;;OAiBG;IACH,2BAA2B,EAAE,MAAM,OAAO,CAAC,qCAAqC,CAAC,CAAA;IAEjF;;;;;;;;;;;;;;;;;OAiBG;IACH,qBAAqB,EAAE,MAAM,OAAO,CAAC,+BAA+B,CAAC,CAAA;CACtE,CAAA;AAED,wBAAgB,eAAe,qLAMnB,OAAO,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,KAC3C,gBAAgB,MAAM,EAAE,QAAQ,CAAC,CAoBrC"}
@@ -0,0 +1,9 @@
1
+ import { BaseError } from '../../errors/base.js';
2
+ export type TokenIsEthErrorType = TokenIsEthError & {
3
+ name: 'TokenIsEthError';
4
+ };
5
+ export declare class TokenIsEthError extends BaseError {
6
+ name: string;
7
+ constructor();
8
+ }
9
+ //# sourceMappingURL=token-is-eth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-is-eth.d.ts","sourceRoot":"","sources":["../../../zksync/errors/token-is-eth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG;IAClD,IAAI,EAAE,iBAAiB,CAAA;CACxB,CAAA;AACD,qBAAa,eAAgB,SAAQ,SAAS;IACnC,IAAI,SAAoB;;CASlC"}
@@ -4,13 +4,16 @@ export { type GetAllBalancesParameters, type GetAllBalancesReturnType, getAllBal
4
4
  export { type GetBlockDetailsParameters, type GetBlockDetailsReturnType, getBlockDetails, } from './actions/getBlockDetails.js';
5
5
  export { type GetDefaultBridgeAddressesReturnType, getDefaultBridgeAddresses, } from './actions/getDefaultBridgeAddresses.js';
6
6
  export { getBridgehubContractAddress } from './actions/getBridgehubContractAddress.js';
7
+ export { type GetL1AllowanceErrorType, type GetL1AllowanceParameters, type GetL1AllowanceReturnType, getL1Allowance, } from './actions/getL1Allowance.js';
8
+ export { type GetL1BalanceErrorType, type GetL1BalanceParameters, type GetL1BalanceReturnType, getL1Balance, } from './actions/getL1Balance.js';
7
9
  export { type GetL1BatchBlockRangeParameters, type GetL1BatchBlockRangeReturnParameters, getL1BatchBlockRange, } from './actions/getL1BatchBlockRange.js';
8
10
  export { type GetL1BatchDetailsParameters, type GetL1BatchDetailsReturnType, getL1BatchDetails, } from './actions/getL1BatchDetails.js';
9
11
  export { getL1BatchNumber } from './actions/getL1BatchNumber.js';
10
12
  export { getL1ChainId } from './actions/getL1ChainId.js';
13
+ export { type GetL1TokenBalanceErrorType, type GetL1TokenBalanceParameters, type GetL1TokenBalanceReturnType, getL1TokenBalance, } from './actions/getL1TokenBalance.js';
11
14
  export { type GetLogProofReturnType, type GetLogProofParameters, getLogProof, } from './actions/getLogProof.js';
12
15
  export { getMainContractAddress } from './actions/getMainContractAddress.js';
13
- export { type GetRawBlockTransactionParameters, type GetRawBlockTransactionReturnType, getRawBlockTransactions, } from './actions/getRawBlockTransaction.js';
16
+ export { type GetRawBlockTransactionsParameters, type GetRawBlockTransactionsReturnType, getRawBlockTransactions, } from './actions/getRawBlockTransactions.js';
14
17
  export { getTestnetPaymasterAddress } from './actions/getTestnetPaymasterAddress.js';
15
18
  export { type GetTransactionDetailsParameters, type GetTransactionDetailsReturnType, getTransactionDetails, } from './actions/getTransactionDetails.js';
16
19
  export { type SendTransactionErrorType, type SendTransactionParameters, type SendTransactionReturnType, sendTransaction, } from './actions/sendTransaction.js';
@@ -20,8 +23,9 @@ export { type SignTransactionErrorType, type SignTransactionParameters, type Sig
20
23
  export { zkSync, zkSyncTestnet, zkSyncSepoliaTestnet, } from './chains.js';
21
24
  export { chainConfig } from './chainConfig.js';
22
25
  export { eip712WalletActions, type Eip712WalletActions, } from './decorators/eip712.js';
23
- export { serializeTransaction } from './serializers.js';
26
+ export { publicActionsL1, type PublicActionsL1, } from './decorators/publicL1.js';
24
27
  export { publicActionsL2, type PublicActionsL2, } from './decorators/publicL2.js';
28
+ export { serializeTransaction } from './serializers.js';
25
29
  export type { ZkSyncBlock, ZkSyncBlockOverrides, ZkSyncRpcBlock, ZkSyncRpcBlockOverrides, } from './types/block.js';
26
30
  export type { ChainEIP712 } from './types/chain.js';
27
31
  export type { EIP712Domain, EIP712DomainFn, ZkSyncEip712Meta, } from './types/eip712.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../zksync/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,cAAc,GACf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,WAAW,GACZ,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,cAAc,GACf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,eAAe,GAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,KAAK,mCAAmC,EACxC,yBAAyB,GAC1B,MAAM,wCAAwC,CAAA;AAC/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A;AACzB,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,YAAY,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,GACjB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,YAAY,EACV,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,YAAY,GACb,MAAM,gBAAgB,CAAA;AACvB,YAAY,EACV,wBAAwB,EACxB,+BAA+B,EAC/B,0BAA0B,EAC1B,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,oCAAoC,EACpC,2BAA2B,EAC3B,iCAAiC,EACjC,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,iCAAiC,EACjC,wBAAwB,EACxB,8BAA8B,EAC9B,6BAA6B,EAC7B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EACjC,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EACL,KAAK,wCAAwC,EAC7C,KAAK,wCAAwC,EAC7C,8BAA8B,GAC/B,MAAM,qDAAqD,CAAA;AAC5D,OAAO,EACL,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EACvC,wBAAwB,GACzB,MAAM,+CAA+C,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Address } from '../../accounts/index.js';
2
+ export declare function isEth(token: Address): boolean;
3
+ //# sourceMappingURL=isEth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEth.d.ts","sourceRoot":"","sources":["../../../zksync/utils/isEth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAOtD,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,WAYnC"}
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '0.0.0-main.20240519T233212'
1
+ export const version = '0.0.0-main.20240520T005450'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "0.0.0-main.20240519T233212",
4
+ "version": "0.0.0-main.20240520T005450",
5
5
  "type": "module",
6
6
  "main": "./_cjs/index.js",
7
7
  "module": "./_esm/index.js",
@@ -0,0 +1,43 @@
1
+ import type { Address } from 'abitype'
2
+ import { readContract } from '../../actions/public/readContract.js'
3
+ import type { Client } from '../../clients/createClient.js'
4
+ import type { Transport } from '../../clients/transports/createTransport.js'
5
+ import { erc20Abi } from '../../constants/abis.js'
6
+ import type { AccountNotFoundError } from '../../errors/account.js'
7
+ import type { BaseError } from '../../errors/base.js'
8
+ import type { Account, GetAccountParameter } from '../../types/account.js'
9
+ import type { BlockTag } from '../../types/block.js'
10
+ import type { Chain } from '../../types/chain.js'
11
+ import { parseAccount } from '../../utils/accounts.js'
12
+
13
+ export type GetL1AllowanceParameters<
14
+ TAccount extends Account | undefined = Account | undefined,
15
+ > = GetAccountParameter<TAccount> & {
16
+ bridgeAddress: Address
17
+ blockTag?: BlockTag
18
+ token: Address
19
+ }
20
+
21
+ export type GetL1AllowanceReturnType = bigint
22
+
23
+ export type GetL1AllowanceErrorType = AccountNotFoundError | BaseError
24
+
25
+ export async function getL1Allowance<
26
+ TChain extends Chain | undefined,
27
+ TAccount extends Account | undefined,
28
+ >(
29
+ client: Client<Transport, TChain, TAccount>,
30
+ parameters: GetL1AllowanceParameters<TAccount>,
31
+ ): Promise<GetL1AllowanceReturnType> {
32
+ const { token, bridgeAddress, blockTag, account: account_ } = parameters
33
+
34
+ const account = account_ ? parseAccount(account_) : client.account
35
+
36
+ return await readContract(client, {
37
+ abi: erc20Abi,
38
+ address: token,
39
+ functionName: 'allowance',
40
+ args: [account!.address, bridgeAddress],
41
+ blockTag: blockTag,
42
+ })
43
+ }
@@ -0,0 +1,68 @@
1
+ import type { Address } from 'abitype'
2
+ import {
3
+ type GetBalanceParameters,
4
+ getBalance,
5
+ } from '../../actions/public/getBalance.js'
6
+ import type { Client } from '../../clients/createClient.js'
7
+ import type { Transport } from '../../clients/transports/createTransport.js'
8
+ import type { AccountNotFoundError } from '../../errors/account.js'
9
+ import type { BaseError } from '../../errors/base.js'
10
+ import type { Account, GetAccountParameter } from '../../types/account.js'
11
+ import type { BlockTag } from '../../types/block.js'
12
+ import type { Chain } from '../../types/chain.js'
13
+ import { parseAccount } from '../../utils/accounts.js'
14
+ import { legacyEthAddress } from '../constants/address.js'
15
+ import { isEth } from '../utils/isEth.js'
16
+ import {
17
+ type GetL1TokenBalanceParameters,
18
+ getL1TokenBalance,
19
+ } from './getL1TokenBalance.js'
20
+
21
+ export type GetL1BalanceParameters<
22
+ TAccount extends Account | undefined = Account | undefined,
23
+ > = GetAccountParameter<TAccount> & { token?: Address | undefined } & (
24
+ | {
25
+ /** The balance of the account at a block number. */
26
+ blockNumber?: bigint | undefined
27
+ blockTag?: never | undefined
28
+ }
29
+ | {
30
+ blockNumber?: never | undefined
31
+ /** The balance of the account at a block tag. */
32
+ blockTag?: BlockTag | undefined
33
+ }
34
+ )
35
+
36
+ export type GetL1BalanceReturnType = bigint
37
+
38
+ export type GetL1BalanceErrorType = AccountNotFoundError | BaseError
39
+
40
+ export async function getL1Balance<
41
+ TChain extends Chain | undefined,
42
+ TAccount extends Account | undefined,
43
+ >(
44
+ client: Client<Transport, TChain, TAccount>,
45
+ ...[parameters = {}]: TAccount extends undefined
46
+ ? [GetL1BalanceParameters<TAccount>]
47
+ : [GetL1BalanceParameters<TAccount>] | []
48
+ ): Promise<GetL1BalanceReturnType> {
49
+ const {
50
+ account: account_ = client.account,
51
+ blockNumber,
52
+ blockTag,
53
+ token = legacyEthAddress,
54
+ } = parameters
55
+
56
+ const account = account_ ? parseAccount(account_) : undefined
57
+
58
+ if (isEth(token))
59
+ return await getBalance(client, {
60
+ address: account!.address,
61
+ blockNumber,
62
+ blockTag,
63
+ } as GetBalanceParameters)
64
+
65
+ return await getL1TokenBalance(client, {
66
+ ...(parameters as GetL1TokenBalanceParameters<TAccount>),
67
+ })
68
+ }
@@ -0,0 +1,63 @@
1
+ import type { Address } from '../../accounts/index.js'
2
+ import { readContract } from '../../actions/index.js'
3
+ import type { Client } from '../../clients/createClient.js'
4
+ import type { Transport } from '../../clients/transports/createTransport.js'
5
+ import { erc20Abi } from '../../constants/abis.js'
6
+ import type { AccountNotFoundError } from '../../errors/account.js'
7
+ import type { BaseError } from '../../errors/base.js'
8
+ import type { Account, GetAccountParameter } from '../../types/account.js'
9
+ import type { BlockTag } from '../../types/block.js'
10
+ import type { Chain } from '../../types/chain.js'
11
+ import { parseAccount } from '../../utils/accounts.js'
12
+ import { TokenIsEthError } from '../errors/token-is-eth.js'
13
+ import { isEth } from '../utils/isEth.js'
14
+
15
+ export type GetL1TokenBalanceParameters<
16
+ TAccount extends Account | undefined = Account | undefined,
17
+ > = GetAccountParameter<TAccount> & { token: Address } & (
18
+ | {
19
+ /** The balance of the account at a block number. */
20
+ blockNumber?: bigint | undefined
21
+ blockTag?: never | undefined
22
+ }
23
+ | {
24
+ blockNumber?: never | undefined
25
+ /** The balance of the account at a block tag. */
26
+ blockTag?: BlockTag | undefined
27
+ }
28
+ )
29
+
30
+ export type GetL1TokenBalanceReturnType = bigint
31
+
32
+ export type GetL1TokenBalanceErrorType =
33
+ | AccountNotFoundError
34
+ | BaseError
35
+ | TokenIsEthError
36
+
37
+ export async function getL1TokenBalance<
38
+ TChain extends Chain | undefined,
39
+ TAccount extends Account | undefined,
40
+ >(
41
+ client: Client<Transport, TChain, TAccount>,
42
+ parameters: GetL1TokenBalanceParameters<TAccount>,
43
+ ): Promise<GetL1TokenBalanceReturnType> {
44
+ const {
45
+ account: account_ = client.account,
46
+ blockTag,
47
+ blockNumber,
48
+ token,
49
+ } = parameters
50
+
51
+ if (isEth(token!)) throw new TokenIsEthError()
52
+
53
+ const account = account_ ? parseAccount(account_) : client.account
54
+
55
+ return await readContract(client, {
56
+ abi: erc20Abi,
57
+ address: token!,
58
+ functionName: 'balanceOf',
59
+ args: [account!.address],
60
+ blockNumber: blockNumber,
61
+ blockTag: blockTag,
62
+ })
63
+ }
@@ -7,20 +7,20 @@ import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
7
7
  import type { ZkSyncRawBlockTransactions } from '../types/transaction.js'
8
8
  import { camelCaseKeys } from '../utils/camelCaseKeys.js'
9
9
 
10
- export type GetRawBlockTransactionParameters = ZkSyncNumberParameter
10
+ export type GetRawBlockTransactionsParameters = ZkSyncNumberParameter
11
11
 
12
- export type GetRawBlockTransactionReturnType = ZkSyncRawBlockTransactions
12
+ export type GetRawBlockTransactionsReturnType = ZkSyncRawBlockTransactions
13
13
 
14
14
  export async function getRawBlockTransactions<
15
15
  TChain extends Chain | undefined,
16
16
  TAccount extends Account | undefined,
17
17
  >(
18
18
  client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
19
- parameters: GetRawBlockTransactionParameters,
20
- ): Promise<GetRawBlockTransactionReturnType> {
19
+ parameters: GetRawBlockTransactionsParameters,
20
+ ): Promise<GetRawBlockTransactionsReturnType> {
21
21
  const result = await client.request({
22
22
  method: 'zks_getRawBlockTransactions',
23
23
  params: [parameters.number],
24
24
  })
25
- return camelCaseKeys(result) as GetRawBlockTransactionReturnType
25
+ return camelCaseKeys(result) as GetRawBlockTransactionsReturnType
26
26
  }
@@ -1,2 +1,11 @@
1
1
  export const contractDeployerAddress =
2
2
  '0x0000000000000000000000000000000000008006' as const
3
+
4
+ export const legacyEthAddress =
5
+ '0x0000000000000000000000000000000000000000' as const
6
+
7
+ export const ethAddressInContracts =
8
+ '0x0000000000000000000000000000000000000001' as const
9
+
10
+ export const l2BaseTokenAddress =
11
+ '0x000000000000000000000000000000000000800a' as const