viem 2.33.1 → 2.33.3
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 +22 -0
- package/_cjs/account-abstraction/index.js +3 -1
- package/_cjs/account-abstraction/index.js.map +1 -1
- package/_cjs/account-abstraction/utils/userOperation/toUserOperation.js +6 -0
- package/_cjs/account-abstraction/utils/userOperation/toUserOperation.js.map +1 -0
- package/_cjs/actions/wallet/waitForCallsStatus.js +12 -2
- package/_cjs/actions/wallet/waitForCallsStatus.js.map +1 -1
- package/_cjs/chains/definitions/autheoTestnet.js +28 -0
- package/_cjs/chains/definitions/autheoTestnet.js.map +1 -0
- package/_cjs/chains/definitions/celoSepolia.js +55 -0
- package/_cjs/chains/definitions/celoSepolia.js.map +1 -0
- package/_cjs/chains/definitions/humanityTestnet.js +27 -0
- package/_cjs/chains/definitions/humanityTestnet.js.map +1 -0
- package/_cjs/chains/definitions/pulsechain.js +1 -1
- package/_cjs/chains/definitions/pulsechain.js.map +1 -1
- package/_cjs/chains/index.js +19 -13
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/calls.js +20 -0
- package/_cjs/errors/calls.js.map +1 -0
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +8 -6
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/transaction/parseTransaction.js +2 -2
- package/_cjs/utils/transaction/parseTransaction.js.map +1 -1
- package/_cjs/zksync/actions/getAllBalances.js.map +1 -1
- package/_cjs/zksync/actions/getBaseTokenL1Address.js.map +1 -1
- package/_cjs/zksync/actions/getGasPerPubdata.js +13 -0
- package/_cjs/zksync/actions/getGasPerPubdata.js.map +1 -0
- package/_cjs/zksync/actions/getL1ChainId.js.map +1 -1
- package/_cjs/zksync/actions/getMainContractAddress.js.map +1 -1
- package/_cjs/zksync/actions/getRawBlockTransactions.js.map +1 -1
- package/_cjs/zksync/actions/getTestnetPaymasterAddress.js.map +1 -1
- package/_cjs/zksync/decorators/publicL2.js +2 -0
- package/_cjs/zksync/decorators/publicL2.js.map +1 -1
- package/_cjs/zksync/index.js +4 -2
- package/_cjs/zksync/index.js.map +1 -1
- package/_esm/account-abstraction/index.js +1 -0
- package/_esm/account-abstraction/index.js.map +1 -1
- package/_esm/account-abstraction/utils/userOperation/toUserOperation.js +3 -0
- package/_esm/account-abstraction/utils/userOperation/toUserOperation.js.map +1 -0
- package/_esm/actions/wallet/waitForCallsStatus.js +13 -2
- package/_esm/actions/wallet/waitForCallsStatus.js.map +1 -1
- package/_esm/chains/definitions/autheoTestnet.js +25 -0
- package/_esm/chains/definitions/autheoTestnet.js.map +1 -0
- package/_esm/chains/definitions/celoSepolia.js +53 -0
- package/_esm/chains/definitions/celoSepolia.js.map +1 -0
- package/_esm/chains/definitions/humanityTestnet.js +24 -0
- package/_esm/chains/definitions/humanityTestnet.js.map +1 -0
- package/_esm/chains/definitions/pulsechain.js +1 -1
- package/_esm/chains/definitions/pulsechain.js.map +1 -1
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/calls.js +16 -0
- package/_esm/errors/calls.js.map +1 -0
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/utils/transaction/parseTransaction.js +2 -2
- package/_esm/utils/transaction/parseTransaction.js.map +1 -1
- package/_esm/zksync/actions/estimateFee.js +1 -0
- package/_esm/zksync/actions/estimateFee.js.map +1 -1
- package/_esm/zksync/actions/getAllBalances.js +1 -0
- package/_esm/zksync/actions/getAllBalances.js.map +1 -1
- package/_esm/zksync/actions/getBaseTokenL1Address.js +1 -0
- package/_esm/zksync/actions/getBaseTokenL1Address.js.map +1 -1
- package/_esm/zksync/actions/getGasPerPubdata.js +10 -0
- package/_esm/zksync/actions/getGasPerPubdata.js.map +1 -0
- package/_esm/zksync/actions/getL1ChainId.js +1 -0
- package/_esm/zksync/actions/getL1ChainId.js.map +1 -1
- package/_esm/zksync/actions/getMainContractAddress.js +1 -0
- package/_esm/zksync/actions/getMainContractAddress.js.map +1 -1
- package/_esm/zksync/actions/getRawBlockTransactions.js +1 -0
- package/_esm/zksync/actions/getRawBlockTransactions.js.map +1 -1
- package/_esm/zksync/actions/getTestnetPaymasterAddress.js +1 -0
- package/_esm/zksync/actions/getTestnetPaymasterAddress.js.map +1 -1
- package/_esm/zksync/decorators/publicL2.js +2 -0
- package/_esm/zksync/decorators/publicL2.js.map +1 -1
- package/_esm/zksync/index.js +1 -0
- package/_esm/zksync/index.js.map +1 -1
- package/_types/account-abstraction/index.d.ts +1 -0
- package/_types/account-abstraction/index.d.ts.map +1 -1
- package/_types/account-abstraction/utils/userOperation/toUserOperation.d.ts +3 -0
- package/_types/account-abstraction/utils/userOperation/toUserOperation.d.ts.map +1 -0
- package/_types/actions/wallet/waitForCallsStatus.d.ts +17 -0
- package/_types/actions/wallet/waitForCallsStatus.d.ts.map +1 -1
- package/_types/chains/definitions/autheoTestnet.d.ts +39 -0
- package/_types/chains/definitions/autheoTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/celoSepolia.d.ts +887 -0
- package/_types/chains/definitions/celoSepolia.d.ts.map +1 -0
- package/_types/chains/definitions/humanityTestnet.d.ts +40 -0
- package/_types/chains/definitions/humanityTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/pulsechain.d.ts +1 -1
- package/_types/chains/index.d.ts +3 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/calls.d.ts +10 -0
- package/_types/errors/calls.d.ts.map +1 -0
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +1 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/zksync/actions/getAllBalances.d.ts.map +1 -1
- package/_types/zksync/actions/getBaseTokenL1Address.d.ts.map +1 -1
- package/_types/zksync/actions/getGasPerPubdata.d.ts +8 -0
- package/_types/zksync/actions/getGasPerPubdata.d.ts.map +1 -0
- package/_types/zksync/actions/getL1ChainId.d.ts.map +1 -1
- package/_types/zksync/actions/getMainContractAddress.d.ts.map +1 -1
- package/_types/zksync/actions/getRawBlockTransactions.d.ts.map +1 -1
- package/_types/zksync/actions/getTestnetPaymasterAddress.d.ts.map +1 -1
- package/_types/zksync/decorators/publicL2.d.ts +21 -0
- package/_types/zksync/decorators/publicL2.d.ts.map +1 -1
- package/_types/zksync/index.d.ts +1 -0
- package/_types/zksync/index.d.ts.map +1 -1
- package/_types/zksync/types/eip1193.d.ts +5 -0
- package/_types/zksync/types/eip1193.d.ts.map +1 -1
- package/account-abstraction/index.ts +1 -0
- package/account-abstraction/utils/userOperation/toUserOperation.ts +3 -0
- package/actions/wallet/waitForCallsStatus.ts +37 -2
- package/chains/definitions/autheoTestnet.ts +25 -0
- package/chains/definitions/celoSepolia.ts +53 -0
- package/chains/definitions/humanityTestnet.ts +24 -0
- package/chains/definitions/pulsechain.ts +1 -1
- package/chains/index.ts +3 -0
- package/errors/calls.ts +17 -0
- package/errors/version.ts +1 -1
- package/index.ts +4 -0
- package/package.json +2 -2
- package/utils/transaction/parseTransaction.ts +2 -2
- package/zksync/actions/estimateFee.ts +1 -1
- package/zksync/actions/getAllBalances.ts +1 -0
- package/zksync/actions/getBaseTokenL1Address.ts +1 -0
- package/zksync/actions/getGasPerPubdata.ts +26 -0
- package/zksync/actions/getL1ChainId.ts +1 -0
- package/zksync/actions/getMainContractAddress.ts +1 -0
- package/zksync/actions/getRawBlockTransactions.ts +1 -0
- package/zksync/actions/getTestnetPaymasterAddress.ts +1 -0
- package/zksync/decorators/publicL2.ts +26 -0
- package/zksync/index.ts +4 -0
- package/zksync/types/eip1193.ts +5 -0
@@ -253,3 +253,4 @@ export {
|
|
253
253
|
getUserOperationTypedData,
|
254
254
|
} from './utils/userOperation/getUserOperationTypedData.js'
|
255
255
|
export { toPackedUserOperation } from './utils/userOperation/toPackedUserOperation.js'
|
256
|
+
export { toUserOperation } from './utils/userOperation/toUserOperation.js'
|
@@ -1,11 +1,16 @@
|
|
1
1
|
import type { Client } from '../../clients/createClient.js'
|
2
2
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
3
3
|
import { BaseError } from '../../errors/base.js'
|
4
|
+
import { BundleFailedError } from '../../errors/calls.js'
|
4
5
|
import type { ErrorType } from '../../errors/utils.js'
|
5
6
|
import type { Chain } from '../../types/chain.js'
|
6
7
|
import { type ObserveErrorType, observe } from '../../utils/observe.js'
|
7
8
|
import { type PollErrorType, poll } from '../../utils/poll.js'
|
8
9
|
import { withResolvers } from '../../utils/promise/withResolvers.js'
|
10
|
+
import {
|
11
|
+
type WithRetryParameters,
|
12
|
+
withRetry,
|
13
|
+
} from '../../utils/promise/withRetry.js'
|
9
14
|
import { stringify } from '../../utils/stringify.js'
|
10
15
|
import {
|
11
16
|
type GetCallsStatusErrorType,
|
@@ -24,12 +29,28 @@ export type WaitForCallsStatusParameters = {
|
|
24
29
|
* @default client.pollingInterval
|
25
30
|
*/
|
26
31
|
pollingInterval?: number | undefined
|
32
|
+
/**
|
33
|
+
* Number of times to retry if the call bundle failed.
|
34
|
+
* @default 4 (exponential backoff)
|
35
|
+
*/
|
36
|
+
retryCount?: WithRetryParameters['retryCount'] | undefined
|
37
|
+
/**
|
38
|
+
* Time to wait (in ms) between retries.
|
39
|
+
* @default `({ count }) => ~~(1 << count) * 200` (exponential backoff)
|
40
|
+
*/
|
41
|
+
retryDelay?: WithRetryParameters['delay'] | undefined
|
27
42
|
/**
|
28
43
|
* The status range to wait for.
|
29
44
|
*
|
30
45
|
* @default (status) => status >= 200
|
31
46
|
*/
|
32
47
|
status?: ((parameters: GetCallsStatusReturnType) => boolean) | undefined
|
48
|
+
/**
|
49
|
+
* Whether to throw an error if the call bundle fails.
|
50
|
+
*
|
51
|
+
* @default false
|
52
|
+
*/
|
53
|
+
throwOnFailure?: boolean | undefined
|
33
54
|
/**
|
34
55
|
* Optional timeout (in milliseconds) to wait before stopping polling.
|
35
56
|
*
|
@@ -76,8 +97,11 @@ export async function waitForCallsStatus<chain extends Chain | undefined>(
|
|
76
97
|
const {
|
77
98
|
id,
|
78
99
|
pollingInterval = client.pollingInterval,
|
79
|
-
status = ({ statusCode }) => statusCode >=
|
100
|
+
status = ({ statusCode }) => statusCode === 200 || statusCode >= 300,
|
101
|
+
retryCount = 4,
|
102
|
+
retryDelay = ({ count }) => ~~(1 << count) * 200, // exponential backoff
|
80
103
|
timeout = 60_000,
|
104
|
+
throwOnFailure = false,
|
81
105
|
} = parameters
|
82
106
|
const observerId = stringify(['waitForCallsStatus', client.uid, id])
|
83
107
|
|
@@ -97,7 +121,18 @@ export async function waitForCallsStatus<chain extends Chain | undefined>(
|
|
97
121
|
}
|
98
122
|
|
99
123
|
try {
|
100
|
-
const result = await
|
124
|
+
const result = await withRetry(
|
125
|
+
async () => {
|
126
|
+
const result = await getCallsStatus(client, { id })
|
127
|
+
if (throwOnFailure && result.status === 'failure')
|
128
|
+
throw new BundleFailedError(result)
|
129
|
+
return result
|
130
|
+
},
|
131
|
+
{
|
132
|
+
retryCount,
|
133
|
+
delay: retryDelay,
|
134
|
+
},
|
135
|
+
)
|
101
136
|
if (!status(result)) return
|
102
137
|
done(() => emit.resolve(result))
|
103
138
|
} catch (error) {
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const autheoTestnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 785,
|
5
|
+
name: 'Autheo Testnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'Autheo',
|
9
|
+
symbol: 'THEO',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: {
|
13
|
+
http: [
|
14
|
+
'https://testnet-rpc1.autheo.com',
|
15
|
+
'https://testnet-rpc2.autheo.com',
|
16
|
+
],
|
17
|
+
},
|
18
|
+
},
|
19
|
+
blockExplorers: {
|
20
|
+
default: {
|
21
|
+
name: 'Autheo Testnet Block Explorer',
|
22
|
+
url: 'https://testnet-explorer.autheo.com/',
|
23
|
+
},
|
24
|
+
},
|
25
|
+
})
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { chainConfig } from '../../celo/chainConfig.js'
|
2
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
3
|
+
|
4
|
+
const sourceId = 11_155_111 // sepolia
|
5
|
+
// source https://storage.googleapis.com/cel2-rollup-files/celo-sepolia/deployment-l1.json
|
6
|
+
export const celoSepolia = /*#__PURE__*/ defineChain({
|
7
|
+
...chainConfig,
|
8
|
+
id: 11_142_220,
|
9
|
+
name: 'Celo Sepolia Testnet',
|
10
|
+
nativeCurrency: {
|
11
|
+
decimals: 18,
|
12
|
+
name: 'CELO',
|
13
|
+
symbol: 'S-CELO',
|
14
|
+
},
|
15
|
+
rpcUrls: {
|
16
|
+
default: {
|
17
|
+
http: ['https://forno.celo-sepolia.celo-testnet.org'],
|
18
|
+
},
|
19
|
+
},
|
20
|
+
blockExplorers: {
|
21
|
+
default: {
|
22
|
+
name: 'Celo Sepolia Explorer',
|
23
|
+
url: 'https://celo-sepolia.blockscout.com/',
|
24
|
+
apiUrl: 'https://celo-sepolia.blockscout.com/api',
|
25
|
+
},
|
26
|
+
},
|
27
|
+
contracts: {
|
28
|
+
...chainConfig.contracts,
|
29
|
+
multicall3: {
|
30
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
31
|
+
blockCreated: 1,
|
32
|
+
},
|
33
|
+
portal: {
|
34
|
+
[sourceId]: {
|
35
|
+
address: '0x44ae3d41a335a7d05eb533029917aad35662dcc2',
|
36
|
+
blockCreated: 8825790,
|
37
|
+
},
|
38
|
+
},
|
39
|
+
disputeGameFactory: {
|
40
|
+
[sourceId]: {
|
41
|
+
address: '0x57c45d82d1a995f1e135b8d7edc0a6bb5211cfaa',
|
42
|
+
blockCreated: 8825790,
|
43
|
+
},
|
44
|
+
},
|
45
|
+
l1StandardBridge: {
|
46
|
+
[sourceId]: {
|
47
|
+
address: '0xec18a3c30131a0db4246e785355fbc16e2eaf408',
|
48
|
+
blockCreated: 8825790,
|
49
|
+
},
|
50
|
+
},
|
51
|
+
},
|
52
|
+
testnet: true,
|
53
|
+
})
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const humanityTestnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 7_080_969,
|
5
|
+
name: 'Humanity Testnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
name: 'tHP',
|
8
|
+
symbol: 'tHP',
|
9
|
+
decimals: 18,
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: {
|
13
|
+
http: ['https://rpc.testnet.humanity.org'],
|
14
|
+
},
|
15
|
+
},
|
16
|
+
blockExplorers: {
|
17
|
+
default: {
|
18
|
+
name: 'Humanity Testnet Explorer',
|
19
|
+
url: 'https://humanity-testnet.explorer.alchemy.com',
|
20
|
+
apiUrl: 'https://humanity-testnet.explorer.alchemy.com/api',
|
21
|
+
},
|
22
|
+
},
|
23
|
+
testnet: true,
|
24
|
+
})
|
package/chains/index.ts
CHANGED
@@ -37,6 +37,7 @@ export { atletaOlympia } from './definitions/atletaOlympia.js'
|
|
37
37
|
export { aurora } from './definitions/aurora.js'
|
38
38
|
export { auroraTestnet } from './definitions/auroraTestnet.js'
|
39
39
|
export { auroria } from './definitions/auroria.js'
|
40
|
+
export { autheoTestnet } from './definitions/autheoTestnet.js'
|
40
41
|
export { avalanche } from './definitions/avalanche.js'
|
41
42
|
export { avalancheFuji } from './definitions/avalancheFuji.js'
|
42
43
|
export { b3 } from './definitions/b3.js'
|
@@ -90,6 +91,7 @@ export { cannon } from './definitions/cannon.js'
|
|
90
91
|
export { canto } from './definitions/canto.js'
|
91
92
|
export { celo } from './definitions/celo.js'
|
92
93
|
export { celoAlfajores } from './definitions/celoAlfajores.js'
|
94
|
+
export { celoSepolia } from './definitions/celoSepolia.js'
|
93
95
|
export { chang } from './definitions/chang.js'
|
94
96
|
export { chiliz } from './definitions/chiliz.js'
|
95
97
|
export { chips } from './definitions/chips.js'
|
@@ -240,6 +242,7 @@ export { hoodi } from './definitions/hoodi.js'
|
|
240
242
|
export { hpb } from './definitions/hpb.js'
|
241
243
|
export { huddle01Mainnet } from './definitions/huddle01Mainnet.js'
|
242
244
|
export { huddle01Testnet } from './definitions/huddle01Testnet.js'
|
245
|
+
export { humanityTestnet } from './definitions/humanityTestnet.js'
|
243
246
|
export { humanode } from './definitions/humanode.js'
|
244
247
|
export { humanodeTestnet5 } from './definitions/humanodeTestnet5.js'
|
245
248
|
export { hychain } from './definitions/hychain.js'
|
package/errors/calls.ts
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { GetCallsStatusReturnType } from '../actions/wallet/getCallsStatus.js'
|
2
|
+
import { BaseError } from './base.js'
|
3
|
+
|
4
|
+
export type BundleFailedErrorType = BundleFailedError & {
|
5
|
+
name: 'BundleFailedError'
|
6
|
+
}
|
7
|
+
export class BundleFailedError extends BaseError {
|
8
|
+
result: GetCallsStatusReturnType
|
9
|
+
|
10
|
+
constructor(result: GetCallsStatusReturnType) {
|
11
|
+
super(`Call bundle failed with status: ${result.statusCode}`, {
|
12
|
+
name: 'BundleFailedError',
|
13
|
+
})
|
14
|
+
|
15
|
+
this.result = result
|
16
|
+
}
|
17
|
+
}
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.33.
|
1
|
+
export const version = '2.33.3'
|
package/index.ts
CHANGED
@@ -779,6 +779,10 @@ export {
|
|
779
779
|
type UnsupportedPackedAbiTypeErrorType,
|
780
780
|
} from './errors/abi.js'
|
781
781
|
export { BaseError, type BaseErrorType, setErrorConfig } from './errors/base.js'
|
782
|
+
export {
|
783
|
+
BundleFailedError,
|
784
|
+
type BundleFailedErrorType,
|
785
|
+
} from './errors/calls.js'
|
782
786
|
export {
|
783
787
|
BlockNotFoundError,
|
784
788
|
type BlockNotFoundErrorType,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "viem",
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
4
|
-
"version": "2.33.
|
4
|
+
"version": "2.33.3",
|
5
5
|
"main": "./_cjs/index.js",
|
6
6
|
"module": "./_esm/index.js",
|
7
7
|
"types": "./_types/index.d.ts",
|
@@ -196,7 +196,7 @@
|
|
196
196
|
"@scure/bip39": "1.6.0",
|
197
197
|
"abitype": "1.0.8",
|
198
198
|
"isows": "1.0.7",
|
199
|
-
"ox": "0.8.
|
199
|
+
"ox": "0.8.6",
|
200
200
|
"ws": "8.18.2"
|
201
201
|
},
|
202
202
|
"license": "MIT",
|
@@ -581,8 +581,8 @@ function parseAuthorizationList(
|
|
581
581
|
|
582
582
|
authorizationList.push({
|
583
583
|
address,
|
584
|
-
chainId: hexToNumber(chainId),
|
585
|
-
nonce: hexToNumber(nonce),
|
584
|
+
chainId: chainId === '0x' ? 0 : hexToNumber(chainId),
|
585
|
+
nonce: nonce === '0x' ? 0 : hexToNumber(nonce),
|
586
586
|
...parseEIP155Signature([yParity, r, s]),
|
587
587
|
})
|
588
588
|
}
|
@@ -15,7 +15,7 @@ export type EstimateFeeParameters<
|
|
15
15
|
> = SendTransactionParameters<chain, account, chainOverride>
|
16
16
|
|
17
17
|
export type EstimateFeeReturnType = ZksyncFee
|
18
|
-
|
18
|
+
/* @deprecated Use `eth_gasPrice` for `maxFeePerGas`, `eth_estimateGas` to get the `gasLimit`, set `maxPriorityFeePerGas` to `0`, and use `zks_gasPerPubdata` for `gasPerPubdataLimit` instead. */
|
19
19
|
export async function estimateFee<
|
20
20
|
chain extends ChainEIP712 | undefined,
|
21
21
|
account extends Account | undefined,
|
@@ -13,6 +13,7 @@ export type GetAllBalancesParameters<
|
|
13
13
|
|
14
14
|
export type GetAllBalancesReturnType = { [key: Address]: bigint }
|
15
15
|
|
16
|
+
/* @deprecated This method has been removed from the node API. */
|
16
17
|
export async function getAllBalances<
|
17
18
|
chain extends Chain | undefined,
|
18
19
|
account extends Account | undefined,
|
@@ -7,6 +7,7 @@ import type { PublicZksyncRpcSchema } from '../types/eip1193.js'
|
|
7
7
|
|
8
8
|
export type GetBaseTokenL1AddressReturnType = Address
|
9
9
|
|
10
|
+
/* @deprecated Use `getBridgeHubContractAddress` and call `baseToken(chainId)` instead. */
|
10
11
|
export async function getBaseTokenL1Address<
|
11
12
|
chain extends Chain | undefined,
|
12
13
|
account extends Account | undefined,
|
@@ -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 { hexToBigInt } from '../../utils/encoding/fromHex.js'
|
5
|
+
import type { ChainEIP712 } from '../types/chain.js'
|
6
|
+
import type { PublicZksyncRpcSchema } from '../types/eip1193.js'
|
7
|
+
|
8
|
+
export type GetGasPerPubdataReturnType = bigint
|
9
|
+
|
10
|
+
export async function getGasPerPubdata<
|
11
|
+
chain extends ChainEIP712 | undefined,
|
12
|
+
account extends Account | undefined,
|
13
|
+
>(
|
14
|
+
client: Client<Transport, chain, account, PublicZksyncRpcSchema>,
|
15
|
+
): Promise<GetGasPerPubdataReturnType> {
|
16
|
+
const result = await client.request(
|
17
|
+
{
|
18
|
+
method: 'zks_gasPerPubdata',
|
19
|
+
},
|
20
|
+
{
|
21
|
+
dedupe: true,
|
22
|
+
},
|
23
|
+
)
|
24
|
+
|
25
|
+
return hexToBigInt(result)
|
26
|
+
}
|
@@ -7,6 +7,7 @@ import type { PublicZksyncRpcSchema } from '../types/eip1193.js'
|
|
7
7
|
|
8
8
|
export type GetL1ChainIdReturnType = Hex
|
9
9
|
|
10
|
+
/* @deprecated Use the `L1_CHAIN_ID()` method on the `L2AssetRouter` contract (deployed on `0x0000000000000000000000000000000000010003` address) */
|
10
11
|
export async function getL1ChainId<
|
11
12
|
chain extends Chain | undefined,
|
12
13
|
account extends Account | undefined,
|
@@ -7,6 +7,7 @@ import type { PublicZksyncRpcSchema } from '../types/eip1193.js'
|
|
7
7
|
|
8
8
|
export type GetMainContractAddressReturnType = Address
|
9
9
|
|
10
|
+
/* @deprecated Use `getBridgeHubContractAddress` and call `getZKChain(chainId)` instead. */
|
10
11
|
export async function getMainContractAddress<
|
11
12
|
chain extends Chain | undefined,
|
12
13
|
account extends Account | undefined,
|
@@ -11,6 +11,7 @@ export type GetRawBlockTransactionsParameters = ZksyncNumberParameter
|
|
11
11
|
|
12
12
|
export type GetRawBlockTransactionsReturnType = ZksyncRawBlockTransactions
|
13
13
|
|
14
|
+
/* @deprecated Use `debug_getRawTransaction` and `debug_getRawTransactions` instead. */
|
14
15
|
export async function getRawBlockTransactions<
|
15
16
|
chain extends Chain | undefined,
|
16
17
|
account extends Account | undefined,
|
@@ -7,6 +7,7 @@ import type { PublicZksyncRpcSchema } from '../types/eip1193.js'
|
|
7
7
|
|
8
8
|
export type GetTestnetPaymasterAddressReturnType = Address | null
|
9
9
|
|
10
|
+
/* @deprecated Check the corresponding ZKsync chain technical documentation to find the testnet paymaster address */
|
10
11
|
export async function getTestnetPaymasterAddress<
|
11
12
|
chain extends Chain | undefined,
|
12
13
|
account extends Account | undefined,
|
@@ -34,6 +34,10 @@ import {
|
|
34
34
|
type GetDefaultBridgeAddressesReturnType,
|
35
35
|
getDefaultBridgeAddresses,
|
36
36
|
} from '../actions/getDefaultBridgeAddresses.js'
|
37
|
+
import {
|
38
|
+
type GetGasPerPubdataReturnType,
|
39
|
+
getGasPerPubdata,
|
40
|
+
} from '../actions/getGasPerPubdata.js'
|
37
41
|
import {
|
38
42
|
type GetL1BatchBlockRangeParameters,
|
39
43
|
type GetL1BatchBlockRangeReturnParameters,
|
@@ -169,6 +173,8 @@ export type PublicActionsL2<
|
|
169
173
|
getMainContractAddress: () => Promise<GetMainContractAddressReturnType>
|
170
174
|
|
171
175
|
/**
|
176
|
+
* @deprecated This method has been removed from the node API.
|
177
|
+
*
|
172
178
|
* Returns all known balances for a given account.
|
173
179
|
*
|
174
180
|
* @returns The balances for a given account. {@link GetAllBalancesReturnType}
|
@@ -471,6 +477,25 @@ export type PublicActionsL2<
|
|
471
477
|
getL1TokenAddress: (
|
472
478
|
args: GetL1TokenAddressParameters,
|
473
479
|
) => Promise<GetL1TokenAddressReturnType>
|
480
|
+
|
481
|
+
/**
|
482
|
+
* Returns the scaled gas per pubdata limit for the currently open batch. Available since node version 28.7.0.
|
483
|
+
*
|
484
|
+
* @returns the scaled gas per pubdata limit for the currently open batch
|
485
|
+
*
|
486
|
+
* @example
|
487
|
+
* import { createPublicClient, http } from 'viem'
|
488
|
+
* import { zksyncLocalNode } from 'viem/chains'
|
489
|
+
* import { publicActionsL2 } from 'viem/zksync'
|
490
|
+
*
|
491
|
+
* const client = createPublicClient({
|
492
|
+
* chain: zksyncLocalNode,
|
493
|
+
* transport: http(),
|
494
|
+
* }).extend(publicActionsL2())
|
495
|
+
*
|
496
|
+
* const gasPerPubdata = await client.getGasPerPubdata();
|
497
|
+
*/
|
498
|
+
getGasPerPubdata: () => Promise<GetGasPerPubdataReturnType>
|
474
499
|
}
|
475
500
|
|
476
501
|
export function publicActionsL2() {
|
@@ -500,6 +525,7 @@ export function publicActionsL2() {
|
|
500
525
|
getBaseTokenL1Address: () => getBaseTokenL1Address(client),
|
501
526
|
getL2TokenAddress: (args) => getL2TokenAddress(client, args),
|
502
527
|
getL1TokenAddress: (args) => getL1TokenAddress(client, args),
|
528
|
+
getGasPerPubdata: () => getGasPerPubdata(client),
|
503
529
|
}
|
504
530
|
}
|
505
531
|
}
|
package/zksync/index.ts
CHANGED
@@ -60,6 +60,10 @@ export {
|
|
60
60
|
getDefaultBridgeAddresses,
|
61
61
|
} from './actions/getDefaultBridgeAddresses.js'
|
62
62
|
export { getBridgehubContractAddress } from './actions/getBridgehubContractAddress.js'
|
63
|
+
export {
|
64
|
+
type GetGasPerPubdataReturnType,
|
65
|
+
getGasPerPubdata,
|
66
|
+
} from './actions/getGasPerPubdata.js'
|
63
67
|
export {
|
64
68
|
type GetL1AllowanceErrorType,
|
65
69
|
type GetL1AllowanceParameters,
|