viem 2.10.11 → 2.11.0
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.
- package/CHANGELOG.md +10 -0
- package/_cjs/celo/formatters.js +1 -10
- package/_cjs/celo/formatters.js.map +1 -1
- package/_cjs/celo/serializers.js +0 -25
- package/_cjs/celo/serializers.js.map +1 -1
- package/_cjs/celo/utils.js +2 -15
- package/_cjs/celo/utils.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/zksync/actions/estimateFee.js +26 -0
- package/_cjs/zksync/actions/estimateFee.js.map +1 -0
- package/_cjs/zksync/actions/estimateGasL1ToL2.js +20 -0
- package/_cjs/zksync/actions/estimateGasL1ToL2.js.map +1 -0
- package/_cjs/zksync/actions/getAllBalances.js +19 -0
- package/_cjs/zksync/actions/getAllBalances.js.map +1 -0
- package/_cjs/zksync/actions/getBaseTokenL1Address.js +9 -0
- package/_cjs/zksync/actions/getBaseTokenL1Address.js.map +1 -0
- package/_cjs/zksync/actions/getBlockDetails.js +12 -0
- package/_cjs/zksync/actions/getBlockDetails.js.map +1 -0
- package/_cjs/zksync/actions/getBridgehubContractAddress.js +9 -0
- package/_cjs/zksync/actions/getBridgehubContractAddress.js.map +1 -0
- package/_cjs/zksync/actions/getDefaultBridgeAddresses.js +13 -0
- package/_cjs/zksync/actions/getDefaultBridgeAddresses.js.map +1 -0
- package/_cjs/zksync/actions/getL1Allowance.js +19 -0
- package/_cjs/zksync/actions/getL1Allowance.js.map +1 -0
- package/_cjs/zksync/actions/getL1Balance.js +23 -0
- package/_cjs/zksync/actions/getL1Balance.js.map +1 -0
- package/_cjs/zksync/actions/getL1BatchBlockRange.js +13 -0
- package/_cjs/zksync/actions/getL1BatchBlockRange.js.map +1 -0
- package/_cjs/zksync/actions/getL1BatchDetails.js +12 -0
- package/_cjs/zksync/actions/getL1BatchDetails.js.map +1 -0
- package/_cjs/zksync/actions/getL1BatchNumber.js +9 -0
- package/_cjs/zksync/actions/getL1BatchNumber.js.map +1 -0
- package/_cjs/zksync/actions/getL1ChainId.js +9 -0
- package/_cjs/zksync/actions/getL1ChainId.js.map +1 -0
- package/_cjs/zksync/actions/getL1TokenBalance.js +24 -0
- package/_cjs/zksync/actions/getL1TokenBalance.js.map +1 -0
- package/_cjs/zksync/actions/getLogProof.js +12 -0
- package/_cjs/zksync/actions/getLogProof.js.map +1 -0
- package/_cjs/zksync/actions/getMainContractAddress.js +9 -0
- package/_cjs/zksync/actions/getMainContractAddress.js.map +1 -0
- package/_cjs/zksync/actions/getRawBlockTransactions.js +13 -0
- package/_cjs/zksync/actions/getRawBlockTransactions.js.map +1 -0
- package/_cjs/zksync/actions/getTestnetPaymasterAddress.js +9 -0
- package/_cjs/zksync/actions/getTestnetPaymasterAddress.js.map +1 -0
- package/_cjs/zksync/actions/getTransactionDetails.js +12 -0
- package/_cjs/zksync/actions/getTransactionDetails.js.map +1 -0
- package/_cjs/zksync/constants/address.js +4 -1
- package/_cjs/zksync/constants/address.js.map +1 -1
- package/_cjs/zksync/decorators/publicL1.js +15 -0
- package/_cjs/zksync/decorators/publicL1.js.map +1 -0
- package/_cjs/zksync/decorators/publicL2.js +43 -0
- package/_cjs/zksync/decorators/publicL2.js.map +1 -0
- package/_cjs/zksync/errors/token-is-eth.js +17 -0
- package/_cjs/zksync/errors/token-is-eth.js.map +1 -0
- package/_cjs/zksync/index.js +41 -3
- package/_cjs/zksync/index.js.map +1 -1
- package/_cjs/zksync/types/eip1193.js +3 -0
- package/_cjs/zksync/types/eip1193.js.map +1 -0
- package/_cjs/zksync/types/proof.js +3 -0
- package/_cjs/zksync/types/proof.js.map +1 -0
- package/_cjs/zksync/utils/camelCaseKeys.js +17 -0
- package/_cjs/zksync/utils/camelCaseKeys.js.map +1 -0
- package/_cjs/zksync/utils/isEth.js +17 -0
- package/_cjs/zksync/utils/isEth.js.map +1 -0
- package/_cjs/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js +4 -3
- package/_cjs/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js.map +1 -1
- package/_cjs/zksync/utils/paymaster/getGeneralPaymasterInput.js +4 -3
- package/_cjs/zksync/utils/paymaster/getGeneralPaymasterInput.js.map +1 -1
- package/_esm/celo/formatters.js +2 -11
- package/_esm/celo/formatters.js.map +1 -1
- package/_esm/celo/serializers.js +1 -29
- package/_esm/celo/serializers.js.map +1 -1
- package/_esm/celo/utils.js +1 -15
- package/_esm/celo/utils.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/zksync/actions/estimateFee.js +22 -0
- package/_esm/zksync/actions/estimateFee.js.map +1 -0
- package/_esm/zksync/actions/estimateGasL1ToL2.js +16 -0
- package/_esm/zksync/actions/estimateGasL1ToL2.js.map +1 -0
- package/_esm/zksync/actions/getAllBalances.js +15 -0
- package/_esm/zksync/actions/getAllBalances.js.map +1 -0
- package/_esm/zksync/actions/getBaseTokenL1Address.js +5 -0
- package/_esm/zksync/actions/getBaseTokenL1Address.js.map +1 -0
- package/_esm/zksync/actions/getBlockDetails.js +8 -0
- package/_esm/zksync/actions/getBlockDetails.js.map +1 -0
- package/_esm/zksync/actions/getBridgehubContractAddress.js +5 -0
- package/_esm/zksync/actions/getBridgehubContractAddress.js.map +1 -0
- package/_esm/zksync/actions/getDefaultBridgeAddresses.js +9 -0
- package/_esm/zksync/actions/getDefaultBridgeAddresses.js.map +1 -0
- package/_esm/zksync/actions/getL1Allowance.js +15 -0
- package/_esm/zksync/actions/getL1Allowance.js.map +1 -0
- package/_esm/zksync/actions/getL1Balance.js +19 -0
- package/_esm/zksync/actions/getL1Balance.js.map +1 -0
- package/_esm/zksync/actions/getL1BatchBlockRange.js +9 -0
- package/_esm/zksync/actions/getL1BatchBlockRange.js.map +1 -0
- package/_esm/zksync/actions/getL1BatchDetails.js +8 -0
- package/_esm/zksync/actions/getL1BatchDetails.js.map +1 -0
- package/_esm/zksync/actions/getL1BatchNumber.js +5 -0
- package/_esm/zksync/actions/getL1BatchNumber.js.map +1 -0
- package/_esm/zksync/actions/getL1ChainId.js +5 -0
- package/_esm/zksync/actions/getL1ChainId.js.map +1 -0
- package/_esm/zksync/actions/getL1TokenBalance.js +20 -0
- package/_esm/zksync/actions/getL1TokenBalance.js.map +1 -0
- package/_esm/zksync/actions/getLogProof.js +8 -0
- package/_esm/zksync/actions/getLogProof.js.map +1 -0
- package/_esm/zksync/actions/getMainContractAddress.js +5 -0
- package/_esm/zksync/actions/getMainContractAddress.js.map +1 -0
- package/_esm/zksync/actions/getRawBlockTransactions.js +9 -0
- package/_esm/zksync/actions/getRawBlockTransactions.js.map +1 -0
- package/_esm/zksync/actions/getTestnetPaymasterAddress.js +5 -0
- package/_esm/zksync/actions/getTestnetPaymasterAddress.js.map +1 -0
- package/_esm/zksync/actions/getTransactionDetails.js +8 -0
- package/_esm/zksync/actions/getTransactionDetails.js.map +1 -0
- package/_esm/zksync/constants/address.js +3 -0
- package/_esm/zksync/constants/address.js.map +1 -1
- package/_esm/zksync/decorators/publicL1.js +12 -0
- package/_esm/zksync/decorators/publicL1.js.map +1 -0
- package/_esm/zksync/decorators/publicL2.js +39 -0
- package/_esm/zksync/decorators/publicL2.js.map +1 -0
- package/_esm/zksync/errors/token-is-eth.js +13 -0
- package/_esm/zksync/errors/token-is-eth.js.map +1 -0
- package/_esm/zksync/index.js +20 -1
- package/_esm/zksync/index.js.map +1 -1
- package/_esm/zksync/types/eip1193.js +2 -0
- package/_esm/zksync/types/eip1193.js.map +1 -0
- package/_esm/zksync/types/proof.js +2 -0
- package/_esm/zksync/types/proof.js.map +1 -0
- package/_esm/zksync/utils/camelCaseKeys.js +13 -0
- package/_esm/zksync/utils/camelCaseKeys.js.map +1 -0
- package/_esm/zksync/utils/isEth.js +13 -0
- package/_esm/zksync/utils/isEth.js.map +1 -0
- package/_esm/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js +2 -1
- package/_esm/zksync/utils/paymaster/getApprovalBasedPaymasterInput.js.map +1 -1
- package/_esm/zksync/utils/paymaster/getGeneralPaymasterInput.js +2 -1
- package/_esm/zksync/utils/paymaster/getGeneralPaymasterInput.js.map +1 -1
- package/_types/celo/chainConfig.d.ts +58 -526
- package/_types/celo/chainConfig.d.ts.map +1 -1
- package/_types/celo/formatters.d.ts +29 -263
- package/_types/celo/formatters.d.ts.map +1 -1
- package/_types/celo/index.d.ts +1 -1
- package/_types/celo/index.d.ts.map +1 -1
- package/_types/celo/serializers.d.ts +2 -3
- package/_types/celo/serializers.d.ts.map +1 -1
- package/_types/celo/types.d.ts +5 -29
- package/_types/celo/types.d.ts.map +1 -1
- package/_types/celo/utils.d.ts +1 -2
- package/_types/celo/utils.d.ts.map +1 -1
- package/_types/chains/definitions/celo.d.ts +58 -526
- package/_types/chains/definitions/celo.d.ts.map +1 -1
- package/_types/chains/definitions/celoAlfajores.d.ts +58 -526
- package/_types/chains/definitions/celoAlfajores.d.ts.map +1 -1
- package/_types/chains/definitions/lisk.d.ts +8 -8
- package/_types/chains/definitions/playfiAlbireo.d.ts +8 -8
- package/_types/chains/definitions/zkSync.d.ts +8 -8
- package/_types/chains/definitions/zkSyncInMemoryNode.d.ts +8 -8
- package/_types/chains/definitions/zkSyncLocalNode.d.ts +8 -8
- package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts +8 -8
- package/_types/chains/definitions/zkSyncTestnet.d.ts +8 -8
- package/_types/chains/index.d.ts +1 -1
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/zksync/actions/estimateFee.d.ts +11 -0
- package/_types/zksync/actions/estimateFee.d.ts.map +1 -0
- package/_types/zksync/actions/estimateGasL1ToL2.d.ts +10 -0
- package/_types/zksync/actions/estimateGasL1ToL2.d.ts.map +1 -0
- package/_types/zksync/actions/getAllBalances.d.ts +12 -0
- package/_types/zksync/actions/getAllBalances.d.ts.map +1 -0
- package/_types/zksync/actions/getBaseTokenL1Address.d.ts +9 -0
- package/_types/zksync/actions/getBaseTokenL1Address.d.ts.map +1 -0
- package/_types/zksync/actions/getBlockDetails.d.ts +10 -0
- package/_types/zksync/actions/getBlockDetails.d.ts.map +1 -0
- package/_types/zksync/actions/getBridgehubContractAddress.d.ts +9 -0
- package/_types/zksync/actions/getBridgehubContractAddress.d.ts.map +1 -0
- package/_types/zksync/actions/getDefaultBridgeAddresses.d.ts +9 -0
- package/_types/zksync/actions/getDefaultBridgeAddresses.d.ts.map +1 -0
- package/_types/zksync/actions/getL1Allowance.d.ts +17 -0
- package/_types/zksync/actions/getL1Allowance.d.ts.map +1 -0
- package/_types/zksync/actions/getL1Balance.d.ts +23 -0
- package/_types/zksync/actions/getL1Balance.d.ts.map +1 -0
- package/_types/zksync/actions/getL1BatchBlockRange.d.ts +11 -0
- package/_types/zksync/actions/getL1BatchBlockRange.d.ts.map +1 -0
- package/_types/zksync/actions/getL1BatchDetails.d.ts +10 -0
- package/_types/zksync/actions/getL1BatchDetails.d.ts.map +1 -0
- package/_types/zksync/actions/getL1BatchNumber.d.ts +9 -0
- package/_types/zksync/actions/getL1BatchNumber.d.ts.map +1 -0
- package/_types/zksync/actions/getL1ChainId.d.ts +9 -0
- package/_types/zksync/actions/getL1ChainId.d.ts.map +1 -0
- package/_types/zksync/actions/getL1TokenBalance.d.ts +24 -0
- package/_types/zksync/actions/getL1TokenBalance.d.ts.map +1 -0
- package/_types/zksync/actions/getLogProof.d.ts +14 -0
- package/_types/zksync/actions/getLogProof.d.ts.map +1 -0
- package/_types/zksync/actions/getMainContractAddress.d.ts +9 -0
- package/_types/zksync/actions/getMainContractAddress.d.ts.map +1 -0
- package/_types/zksync/actions/getRawBlockTransactions.d.ts +11 -0
- package/_types/zksync/actions/getRawBlockTransactions.d.ts.map +1 -0
- package/_types/zksync/actions/getTestnetPaymasterAddress.d.ts +9 -0
- package/_types/zksync/actions/getTestnetPaymasterAddress.d.ts.map +1 -0
- package/_types/zksync/actions/getTransactionDetails.d.ts +13 -0
- package/_types/zksync/actions/getTransactionDetails.d.ts.map +1 -0
- package/_types/zksync/chainConfig.d.ts +8 -8
- package/_types/zksync/constants/address.d.ts +3 -0
- package/_types/zksync/constants/address.d.ts.map +1 -1
- package/_types/zksync/decorators/publicL1.d.ts +145 -0
- package/_types/zksync/decorators/publicL1.d.ts.map +1 -0
- package/_types/zksync/decorators/publicL2.d.ts +322 -0
- package/_types/zksync/decorators/publicL2.d.ts.map +1 -0
- package/_types/zksync/errors/token-is-eth.d.ts +9 -0
- package/_types/zksync/errors/token-is-eth.d.ts.map +1 -0
- package/_types/zksync/formatters.d.ts +8 -8
- package/_types/zksync/index.d.ts +21 -2
- package/_types/zksync/index.d.ts.map +1 -1
- package/_types/zksync/types/block.d.ts +30 -1
- package/_types/zksync/types/block.d.ts.map +1 -1
- package/_types/zksync/types/contract.d.ts +6 -0
- package/_types/zksync/types/contract.d.ts.map +1 -1
- package/_types/zksync/types/eip1193.d.ts +152 -0
- package/_types/zksync/types/eip1193.d.ts.map +1 -0
- package/_types/zksync/types/fee.d.ts +6 -0
- package/_types/zksync/types/fee.d.ts.map +1 -1
- package/_types/zksync/types/proof.d.ts +7 -0
- package/_types/zksync/types/proof.d.ts.map +1 -0
- package/_types/zksync/types/transaction.d.ts +65 -5
- package/_types/zksync/types/transaction.d.ts.map +1 -1
- package/_types/zksync/utils/camelCaseKeys.d.ts +2 -0
- package/_types/zksync/utils/camelCaseKeys.d.ts.map +1 -0
- package/_types/zksync/utils/isEth.d.ts +3 -0
- package/_types/zksync/utils/isEth.d.ts.map +1 -0
- package/_types/zksync/utils/paymaster/getApprovalBasedPaymasterInput.d.ts +1 -1
- package/_types/zksync/utils/paymaster/getApprovalBasedPaymasterInput.d.ts.map +1 -1
- package/_types/zksync/utils/paymaster/getGeneralPaymasterInput.d.ts +1 -1
- package/_types/zksync/utils/paymaster/getGeneralPaymasterInput.d.ts.map +1 -1
- package/celo/formatters.ts +3 -11
- package/celo/index.ts +0 -2
- package/celo/serializers.ts +2 -50
- package/celo/types.ts +3 -38
- package/celo/utils.ts +1 -24
- package/chains/index.ts +0 -2
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/zksync/actions/estimateFee.ts +46 -0
- package/zksync/actions/estimateGasL1ToL2.ts +38 -0
- package/zksync/actions/getAllBalances.ts +33 -0
- package/zksync/actions/getBaseTokenL1Address.ts +18 -0
- package/zksync/actions/getBlockDetails.ts +27 -0
- package/zksync/actions/getBridgehubContractAddress.ts +18 -0
- package/zksync/actions/getDefaultBridgeAddresses.ts +22 -0
- package/zksync/actions/getL1Allowance.ts +43 -0
- package/zksync/actions/getL1Balance.ts +68 -0
- package/zksync/actions/getL1BatchBlockRange.ts +26 -0
- package/zksync/actions/getL1BatchDetails.ts +27 -0
- package/zksync/actions/getL1BatchNumber.ts +18 -0
- package/zksync/actions/getL1ChainId.ts +18 -0
- package/zksync/actions/getL1TokenBalance.ts +63 -0
- package/zksync/actions/getLogProof.ts +28 -0
- package/zksync/actions/getMainContractAddress.ts +18 -0
- package/zksync/actions/getRawBlockTransactions.ts +26 -0
- package/zksync/actions/getTestnetPaymasterAddress.ts +18 -0
- package/zksync/actions/getTransactionDetails.ts +27 -0
- package/zksync/constants/address.ts +9 -0
- package/zksync/decorators/publicL1.ts +180 -0
- package/zksync/decorators/publicL2.ts +443 -0
- package/zksync/errors/token-is-eth.ts +16 -0
- package/zksync/index.ts +85 -6
- package/zksync/types/block.ts +37 -1
- package/zksync/types/contract.ts +8 -0
- package/zksync/types/eip1193.ts +155 -0
- package/zksync/types/fee.ts +7 -0
- package/zksync/types/proof.ts +7 -0
- package/zksync/types/transaction.ts +84 -10
- package/zksync/utils/camelCaseKeys.ts +11 -0
- package/zksync/utils/isEth.ts +20 -0
- package/zksync/utils/paymaster/getApprovalBasedPaymasterInput.ts +5 -2
- package/zksync/utils/paymaster/getGeneralPaymasterInput.ts +5 -2
@@ -0,0 +1,28 @@
|
|
1
|
+
import type { Client } from '../../clients/createClient.js'
|
2
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
3
|
+
import type { Account } from '../../types/account.js'
|
4
|
+
import type { Chain } from '../../types/chain.js'
|
5
|
+
import type { Hash } from '../../types/misc.js'
|
6
|
+
import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
|
7
|
+
import type { MessageProof } from '../types/proof.js'
|
8
|
+
|
9
|
+
export type GetLogProofParameters = {
|
10
|
+
txHash: Hash
|
11
|
+
index?: number | undefined
|
12
|
+
}
|
13
|
+
|
14
|
+
export type GetLogProofReturnType = MessageProof | null
|
15
|
+
|
16
|
+
export async function getLogProof<
|
17
|
+
TChain extends Chain | undefined,
|
18
|
+
TAccount extends Account | undefined,
|
19
|
+
>(
|
20
|
+
client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
|
21
|
+
parameters: GetLogProofParameters,
|
22
|
+
): Promise<MessageProof | null> {
|
23
|
+
const result = await client.request({
|
24
|
+
method: 'zks_getL2ToL1LogProof',
|
25
|
+
params: [parameters.txHash, parameters.index],
|
26
|
+
})
|
27
|
+
return result
|
28
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
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 { Chain } from '../../types/chain.js'
|
6
|
+
import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
|
7
|
+
|
8
|
+
export type GetMainContractAddressReturnType = Address
|
9
|
+
|
10
|
+
export async function getMainContractAddress<
|
11
|
+
TChain extends Chain | undefined,
|
12
|
+
TAccount extends Account | undefined,
|
13
|
+
>(
|
14
|
+
client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
|
15
|
+
): Promise<GetMainContractAddressReturnType> {
|
16
|
+
const address = await client.request({ method: 'zks_getMainContract' })
|
17
|
+
return address
|
18
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import type { Client } from '../../clients/createClient.js'
|
2
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
3
|
+
import type { Account } from '../../types/account.js'
|
4
|
+
import type { Chain } from '../../types/chain.js'
|
5
|
+
import type { ZkSyncNumberParameter } from '../types/block.js'
|
6
|
+
import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
|
7
|
+
import type { ZkSyncRawBlockTransactions } from '../types/transaction.js'
|
8
|
+
import { camelCaseKeys } from '../utils/camelCaseKeys.js'
|
9
|
+
|
10
|
+
export type GetRawBlockTransactionsParameters = ZkSyncNumberParameter
|
11
|
+
|
12
|
+
export type GetRawBlockTransactionsReturnType = ZkSyncRawBlockTransactions
|
13
|
+
|
14
|
+
export async function getRawBlockTransactions<
|
15
|
+
TChain extends Chain | undefined,
|
16
|
+
TAccount extends Account | undefined,
|
17
|
+
>(
|
18
|
+
client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
|
19
|
+
parameters: GetRawBlockTransactionsParameters,
|
20
|
+
): Promise<GetRawBlockTransactionsReturnType> {
|
21
|
+
const result = await client.request({
|
22
|
+
method: 'zks_getRawBlockTransactions',
|
23
|
+
params: [parameters.number],
|
24
|
+
})
|
25
|
+
return camelCaseKeys(result) as GetRawBlockTransactionsReturnType
|
26
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
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 { Chain } from '../../types/chain.js'
|
6
|
+
import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
|
7
|
+
|
8
|
+
export type GetTestnetPaymasterAddressReturnType = Address | null
|
9
|
+
|
10
|
+
export async function getTestnetPaymasterAddress<
|
11
|
+
TChain extends Chain | undefined,
|
12
|
+
TAccount extends Account | undefined,
|
13
|
+
>(
|
14
|
+
client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
|
15
|
+
): Promise<GetTestnetPaymasterAddressReturnType> {
|
16
|
+
const result = await client.request({ method: 'zks_getTestnetPaymaster' })
|
17
|
+
return result
|
18
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import type { Client } from '../../clients/createClient.js'
|
2
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
3
|
+
import type { Account } from '../../types/account.js'
|
4
|
+
import type { Chain } from '../../types/chain.js'
|
5
|
+
import type { Hash } from '../../types/misc.js'
|
6
|
+
import type { PublicZkSyncRpcSchema } from '../types/eip1193.js'
|
7
|
+
import type { ZkSyncTransactionDetails } from '../types/transaction.js'
|
8
|
+
|
9
|
+
export type GetTransactionDetailsParameters = {
|
10
|
+
txHash: Hash
|
11
|
+
}
|
12
|
+
|
13
|
+
export type GetTransactionDetailsReturnType = ZkSyncTransactionDetails
|
14
|
+
|
15
|
+
export async function getTransactionDetails<
|
16
|
+
TChain extends Chain | undefined,
|
17
|
+
TAccount extends Account | undefined,
|
18
|
+
>(
|
19
|
+
client: Client<Transport, TChain, TAccount, PublicZkSyncRpcSchema>,
|
20
|
+
parameters: GetTransactionDetailsParameters,
|
21
|
+
): Promise<GetTransactionDetailsReturnType> {
|
22
|
+
const result = await client.request({
|
23
|
+
method: 'zks_getTransactionDetails',
|
24
|
+
params: [parameters.txHash],
|
25
|
+
})
|
26
|
+
return result
|
27
|
+
}
|
@@ -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
|
@@ -0,0 +1,180 @@
|
|
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 {
|
6
|
+
type GetL1AllowanceParameters,
|
7
|
+
type GetL1AllowanceReturnType,
|
8
|
+
getL1Allowance,
|
9
|
+
} from '../actions/getL1Allowance.js'
|
10
|
+
import {
|
11
|
+
type GetL1BalanceParameters,
|
12
|
+
type GetL1BalanceReturnType,
|
13
|
+
getL1Balance,
|
14
|
+
} from '../actions/getL1Balance.js'
|
15
|
+
import {
|
16
|
+
type GetL1TokenBalanceParameters,
|
17
|
+
type GetL1TokenBalanceReturnType,
|
18
|
+
getL1TokenBalance,
|
19
|
+
} from '../actions/getL1TokenBalance.js'
|
20
|
+
|
21
|
+
export type PublicActionsL1<
|
22
|
+
TAccount extends Account | undefined = Account | undefined,
|
23
|
+
> = {
|
24
|
+
/**
|
25
|
+
* Returns the amount of approved tokens for a specific L1 bridge.
|
26
|
+
*
|
27
|
+
* - Docs: https://viem.sh/zksync/actions/getL1Allowance
|
28
|
+
*
|
29
|
+
* @param client - Client to use
|
30
|
+
* @param parameters - {@link AllowanceL1Parameters}
|
31
|
+
* @returns The amount of approved tokens for a specific L1 bridge. {@link GetL1AllowanceReturnType}
|
32
|
+
*
|
33
|
+
* @example
|
34
|
+
* import { createPublicClient, custom, parseEther } from 'viem'
|
35
|
+
* import { base, mainnet } from 'viem/chains'
|
36
|
+
* import { publicActionsL1 } from 'viem/zksync'
|
37
|
+
*
|
38
|
+
* const client = createPublicClient({
|
39
|
+
* chain: mainnet,
|
40
|
+
* transport: custom(window.ethereum),
|
41
|
+
* }).extend(publicActionsL1())
|
42
|
+
*
|
43
|
+
* const data = await client.getL1Allowance({
|
44
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
45
|
+
* token: '0x5C221E77624690fff6dd741493D735a17716c26B'
|
46
|
+
* bridgeAddress: '0x84DbCC0B82124bee38e3Ce9a92CdE2f943bab60D',
|
47
|
+
* })
|
48
|
+
*
|
49
|
+
* @example
|
50
|
+
* // Account Hoisting
|
51
|
+
* import { createWalletClient, http } from 'viem'
|
52
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
53
|
+
* import { base, mainnet } from 'viem/chains'
|
54
|
+
* import { publicActionsL1 } from 'viem/zksync'
|
55
|
+
*
|
56
|
+
* const client = createWalletClient({
|
57
|
+
* account: privateKeyToAccount('0x…'),
|
58
|
+
* chain: mainnet,
|
59
|
+
* transport: http(),
|
60
|
+
* }).extend(publicActionsL1())
|
61
|
+
*
|
62
|
+
* const data = await client.getL1Allowance({
|
63
|
+
* token: '0x5C221E77624690fff6dd741493D735a17716c26B'
|
64
|
+
* bridgeAddress: '0x84DbCC0B82124bee38e3Ce9a92CdE2f943bab60D',
|
65
|
+
* })
|
66
|
+
*/
|
67
|
+
getL1Allowance: (
|
68
|
+
parameters: GetL1AllowanceParameters<TAccount>,
|
69
|
+
) => Promise<GetL1AllowanceReturnType>
|
70
|
+
/**
|
71
|
+
* Returns the amount of the ERC20 token the client has on specific address.
|
72
|
+
*
|
73
|
+
* - Docs: https://viem.sh/zksync/actions/getL1TokenBalance
|
74
|
+
*
|
75
|
+
* @param client - Client to use
|
76
|
+
* @param parameters - {@link GetL1TokenBalanceParameters}
|
77
|
+
* @returns The amount of the ERC20 token the client has on specific addresse. {@link GetL1TokenBalanceReturnType}
|
78
|
+
*
|
79
|
+
* @example
|
80
|
+
* import { createPublicClient, custom, parseEther } from 'viem'
|
81
|
+
* import { base, mainnet } from 'viem/chains'
|
82
|
+
* import { publicActionsL1 } from 'viem/zksync'
|
83
|
+
*
|
84
|
+
* const client = createPublicClient({
|
85
|
+
* chain: mainnet,
|
86
|
+
* transport: custom(window.ethereum),
|
87
|
+
* }).extend(publicActionsL1())
|
88
|
+
*
|
89
|
+
* const data = await client.getL1TokenBalance({
|
90
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
91
|
+
* token: '0x5C221E77624690fff6dd741493D735a17716c26B'
|
92
|
+
* })
|
93
|
+
*
|
94
|
+
* @example
|
95
|
+
* // Account Hoisting
|
96
|
+
* import { createWalletClient, http } from 'viem'
|
97
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
98
|
+
* import { base, mainnet } from 'viem/chains'
|
99
|
+
* import { publicActionsL1 } from 'viem/zksync'
|
100
|
+
*
|
101
|
+
* const client = createWalletClient({
|
102
|
+
* account: privateKeyToAccount('0x…'),
|
103
|
+
* chain: mainnet,
|
104
|
+
* transport: http(),
|
105
|
+
* }).extend(publicActionsL1())
|
106
|
+
*
|
107
|
+
* const data = await client.getL1TokenBalance({
|
108
|
+
* token: '0x5C221E77624690fff6dd741493D735a17716c26B'
|
109
|
+
* })
|
110
|
+
*/
|
111
|
+
getL1TokenBalance: (
|
112
|
+
parameters: GetL1TokenBalanceParameters<TAccount>,
|
113
|
+
) => Promise<GetL1TokenBalanceReturnType>
|
114
|
+
/**
|
115
|
+
* Returns the amount of the token held by the account on the L1 network.
|
116
|
+
*
|
117
|
+
* - Docs: https://viem.sh/zksync/actions/getL1TokenBalance
|
118
|
+
*
|
119
|
+
* @param client - Client to use
|
120
|
+
* @param parameters - {@link BalanceL1Parameters}
|
121
|
+
* @returns Returns the amount of the token held by the account on the L1 network. {@link GetL1BalanceReturnType}
|
122
|
+
*
|
123
|
+
* @example
|
124
|
+
* import { createPublicClient, custom, parseEther } from 'viem'
|
125
|
+
* import { base, mainnet } from 'viem/chains'
|
126
|
+
* import { publicActionsL1 } from 'viem/zksync'
|
127
|
+
*
|
128
|
+
* const client = createPublicClient({
|
129
|
+
* chain: mainnet,
|
130
|
+
* transport: custom(window.ethereum),
|
131
|
+
* }).extend(publicActionsL1())
|
132
|
+
*
|
133
|
+
* const data = await client.getL1Balance({
|
134
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'
|
135
|
+
* })
|
136
|
+
*
|
137
|
+
* const data = await client.getL1Balance({
|
138
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
139
|
+
* token: '0x5C221E77624690fff6dd741493D735a17716c26B'
|
140
|
+
* })
|
141
|
+
*
|
142
|
+
* @example
|
143
|
+
* // Account Hoisting
|
144
|
+
* import { createWalletClient, http } from 'viem'
|
145
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
146
|
+
* import { base, mainnet } from 'viem/chains'
|
147
|
+
* import { publicActionsL1 } from 'viem/zksync'
|
148
|
+
*
|
149
|
+
* const client = createWalletClient({
|
150
|
+
* account: privateKeyToAccount('0x…'),
|
151
|
+
* chain: mainnet,
|
152
|
+
* transport: http(),
|
153
|
+
* }).extend(publicActionsL1())
|
154
|
+
*
|
155
|
+
* const data = await client.getL1Balance({})
|
156
|
+
*
|
157
|
+
* const data = await client.getL1Balance({
|
158
|
+
* token: '0x5C221E77624690fff6dd741493D735a17716c26B'
|
159
|
+
* })
|
160
|
+
*/
|
161
|
+
getL1Balance: (
|
162
|
+
...parameters: TAccount extends undefined
|
163
|
+
? [GetL1BalanceParameters<TAccount>]
|
164
|
+
: [GetL1BalanceParameters<TAccount>] | []
|
165
|
+
) => Promise<GetL1BalanceReturnType>
|
166
|
+
}
|
167
|
+
|
168
|
+
export function publicActionsL1() {
|
169
|
+
return <
|
170
|
+
TChain extends Chain | undefined = Chain | undefined,
|
171
|
+
TAccount extends Account | undefined = Account | undefined,
|
172
|
+
>(
|
173
|
+
client: Client<Transport, TChain, TAccount>,
|
174
|
+
): PublicActionsL1<TAccount> => ({
|
175
|
+
getL1Allowance: (args) => getL1Allowance(client, args),
|
176
|
+
getL1TokenBalance: (args) => getL1TokenBalance(client, args),
|
177
|
+
// @ts-expect-error
|
178
|
+
getL1Balance: (args) => getL1Balance(client, args),
|
179
|
+
})
|
180
|
+
}
|