viem 2.19.7 → 2.19.9
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 +14 -0
- package/_cjs/accounts/privateKeyToAccount.js.map +1 -1
- package/_cjs/actions/test/setCode.js +10 -4
- package/_cjs/actions/test/setCode.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/op-stack/abis.js +666 -117
- package/_cjs/op-stack/abis.js.map +1 -1
- package/_cjs/op-stack/actions/getWithdrawalStatus.js +4 -1
- package/_cjs/op-stack/actions/getWithdrawalStatus.js.map +1 -1
- package/_cjs/zksync/accounts/toMultisigSmartAccount.js +16 -0
- package/_cjs/zksync/accounts/toMultisigSmartAccount.js.map +1 -0
- package/_cjs/zksync/accounts/toSinglesigSmartAccount.js +15 -0
- package/_cjs/zksync/accounts/toSinglesigSmartAccount.js.map +1 -0
- package/_cjs/zksync/accounts/toSmartAccount.js +42 -0
- package/_cjs/zksync/accounts/toSmartAccount.js.map +1 -0
- package/_cjs/zksync/index.js +7 -1
- package/_cjs/zksync/index.js.map +1 -1
- package/_cjs/zksync/types/account.js +3 -0
- package/_cjs/zksync/types/account.js.map +1 -0
- package/_esm/accounts/privateKeyToAccount.js.map +1 -1
- package/_esm/actions/test/setCode.js +10 -4
- package/_esm/actions/test/setCode.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/op-stack/abis.js +666 -117
- package/_esm/op-stack/abis.js.map +1 -1
- package/_esm/op-stack/actions/getWithdrawalStatus.js +4 -1
- package/_esm/op-stack/actions/getWithdrawalStatus.js.map +1 -1
- package/_esm/zksync/accounts/toMultisigSmartAccount.js +17 -0
- package/_esm/zksync/accounts/toMultisigSmartAccount.js.map +1 -0
- package/_esm/zksync/accounts/toSinglesigSmartAccount.js +16 -0
- package/_esm/zksync/accounts/toSinglesigSmartAccount.js.map +1 -0
- package/_esm/zksync/accounts/toSmartAccount.js +43 -0
- package/_esm/zksync/accounts/toSmartAccount.js.map +1 -0
- package/_esm/zksync/index.js +3 -0
- package/_esm/zksync/index.js.map +1 -1
- package/_esm/zksync/types/account.js +2 -0
- package/_esm/zksync/types/account.js.map +1 -0
- package/_types/actions/test/setCode.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/op-stack/abis.d.ts +269 -95
- package/_types/op-stack/abis.d.ts.map +1 -1
- package/_types/op-stack/actions/getWithdrawalStatus.d.ts.map +1 -1
- package/_types/types/eip1193.d.ts +17 -3
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/zksync/accounts/toMultisigSmartAccount.d.ts +15 -0
- package/_types/zksync/accounts/toMultisigSmartAccount.d.ts.map +1 -0
- package/_types/zksync/accounts/toSinglesigSmartAccount.d.ts +15 -0
- package/_types/zksync/accounts/toSinglesigSmartAccount.d.ts.map +1 -0
- package/_types/zksync/accounts/toSmartAccount.d.ts +19 -0
- package/_types/zksync/accounts/toSmartAccount.d.ts.map +1 -0
- package/_types/zksync/index.d.ts +4 -0
- package/_types/zksync/index.d.ts.map +1 -1
- package/_types/zksync/types/account.d.ts +5 -0
- package/_types/zksync/types/account.d.ts.map +1 -0
- package/accounts/privateKeyToAccount.ts +1 -1
- package/actions/test/setCode.ts +10 -4
- package/errors/version.ts +1 -1
- package/op-stack/abis.ts +666 -117
- package/op-stack/actions/getWithdrawalStatus.ts +4 -0
- package/package.json +1 -1
- package/types/eip1193.ts +17 -3
- package/zksync/accounts/toMultisigSmartAccount.ts +37 -0
- package/zksync/accounts/toSinglesigSmartAccount.ts +30 -0
- package/zksync/accounts/toSmartAccount.ts +63 -0
- package/zksync/index.ts +15 -0
- package/zksync/types/account.ts +5 -0
@@ -238,6 +238,7 @@ export async function getWithdrawalStatus<
|
|
238
238
|
if (error.cause instanceof ContractFunctionRevertedError) {
|
239
239
|
const errorMessage = error.cause.data?.args?.[0]
|
240
240
|
if (
|
241
|
+
errorMessage === 'OptimismPortal: invalid game type' ||
|
241
242
|
errorMessage === 'OptimismPortal: withdrawal has not been proven yet' ||
|
242
243
|
errorMessage ===
|
243
244
|
'OptimismPortal: withdrawal has not been proven by proof submitter address yet'
|
@@ -251,6 +252,9 @@ export async function getWithdrawalStatus<
|
|
251
252
|
errorMessage === 'OptimismPortal: output proposal in air-gap'
|
252
253
|
)
|
253
254
|
return 'waiting-to-finalize'
|
255
|
+
|
256
|
+
if (error.cause.data?.errorName === 'InvalidGameType')
|
257
|
+
return 'ready-to-prove'
|
254
258
|
}
|
255
259
|
throw checkWithdrawalResult.reason
|
256
260
|
}
|
package/package.json
CHANGED
package/types/eip1193.ts
CHANGED
@@ -1335,7 +1335,7 @@ export type TestRpcSchema<mode extends string> = [
|
|
1335
1335
|
* @link https://ganache.dev/#evm_setAccountBalance
|
1336
1336
|
*/
|
1337
1337
|
{
|
1338
|
-
Method:
|
1338
|
+
Method: 'evm_setAccountBalance'
|
1339
1339
|
Parameters: [
|
1340
1340
|
/** The address of the target account. */
|
1341
1341
|
address: Address,
|
@@ -1344,12 +1344,26 @@ export type TestRpcSchema<mode extends string> = [
|
|
1344
1344
|
]
|
1345
1345
|
ReturnType: void
|
1346
1346
|
},
|
1347
|
+
/**
|
1348
|
+
* @description Modifies the bytecode stored at an account's address.
|
1349
|
+
* @link https://ganache.dev/#evm_setAccountCode
|
1350
|
+
*/
|
1351
|
+
{
|
1352
|
+
Method: 'evm_setAccountCode'
|
1353
|
+
Parameters: [
|
1354
|
+
/** The address of the contract. */
|
1355
|
+
address: Address,
|
1356
|
+
/** Data bytecode. */
|
1357
|
+
data: string,
|
1358
|
+
]
|
1359
|
+
ReturnType: void
|
1360
|
+
},
|
1347
1361
|
/**
|
1348
1362
|
* @description Enables or disables, based on the single boolean argument, the automatic mining of new blocks with each new transaction submitted to the network.
|
1349
1363
|
* @link https://hardhat.org/hardhat-network/docs/reference#evm_setautomine
|
1350
1364
|
*/
|
1351
1365
|
{
|
1352
|
-
Method:
|
1366
|
+
Method: 'evm_setAutomine'
|
1353
1367
|
Parameters: [boolean]
|
1354
1368
|
ReturnType: void
|
1355
1369
|
},
|
@@ -1367,7 +1381,7 @@ export type TestRpcSchema<mode extends string> = [
|
|
1367
1381
|
* @link https://github.com/trufflesuite/ganache/blob/ef1858d5d6f27e4baeb75cccd57fb3dc77a45ae8/src/chains/ethereum/ethereum/RPC-METHODS.md#evm_increasetime
|
1368
1382
|
*/
|
1369
1383
|
{
|
1370
|
-
Method:
|
1384
|
+
Method: 'evm_increaseTime'
|
1371
1385
|
Parameters: [seconds: Quantity]
|
1372
1386
|
ReturnType: Quantity
|
1373
1387
|
},
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
|
3
|
+
import { sign } from '../../accounts/utils/sign.js'
|
4
|
+
import type { Hex } from '../../types/misc.js'
|
5
|
+
import { concatHex } from '../../utils/index.js'
|
6
|
+
import type { ZksyncSmartAccount } from '../types/account.js'
|
7
|
+
import { toSmartAccount } from './toSmartAccount.js'
|
8
|
+
|
9
|
+
export type ToMultisigSmartAccountParameters = {
|
10
|
+
/** Address of the deployed Account's Contract implementation. */
|
11
|
+
address: Address
|
12
|
+
/** Array of Private Keys belonging to the owners. */
|
13
|
+
privateKeys: readonly Hex[]
|
14
|
+
}
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Creates a [ZKsync Smart Account](https://docs.zksync.io/build/developer-reference/account-abstraction/building-smart-accounts)
|
18
|
+
* from a Contract Address and an array of Private Keys belonging to the owners.
|
19
|
+
*/
|
20
|
+
export function toMultisigSmartAccount(
|
21
|
+
parameters: ToMultisigSmartAccountParameters,
|
22
|
+
): ZksyncSmartAccount {
|
23
|
+
const { address, privateKeys } = parameters
|
24
|
+
|
25
|
+
return toSmartAccount({
|
26
|
+
address,
|
27
|
+
async sign({ hash }) {
|
28
|
+
return concatHex(
|
29
|
+
await Promise.all(
|
30
|
+
privateKeys.map((privateKey) =>
|
31
|
+
sign({ hash, privateKey, to: 'hex' }),
|
32
|
+
),
|
33
|
+
),
|
34
|
+
)
|
35
|
+
},
|
36
|
+
})
|
37
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
|
3
|
+
import { sign } from '../../accounts/utils/sign.js'
|
4
|
+
import type { Hex } from '../../types/misc.js'
|
5
|
+
import type { ZksyncSmartAccount } from '../types/account.js'
|
6
|
+
import { toSmartAccount } from './toSmartAccount.js'
|
7
|
+
|
8
|
+
export type ToSinglesigSmartAccountParameters = {
|
9
|
+
/** Address of the deployed Account's Contract implementation. */
|
10
|
+
address: Address
|
11
|
+
/** Private Key of the owner. */
|
12
|
+
privateKey: Hex
|
13
|
+
}
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Creates a [ZKsync Smart Account](https://docs.zksync.io/build/developer-reference/account-abstraction/building-smart-accounts)
|
17
|
+
* from a Contract Address and a Private Key belonging to the owner.
|
18
|
+
*/
|
19
|
+
export function toSinglesigSmartAccount(
|
20
|
+
parameters: ToSinglesigSmartAccountParameters,
|
21
|
+
): ZksyncSmartAccount {
|
22
|
+
const { address, privateKey } = parameters
|
23
|
+
|
24
|
+
return toSmartAccount({
|
25
|
+
address,
|
26
|
+
async sign({ hash }) {
|
27
|
+
return sign({ hash, privateKey, to: 'hex' })
|
28
|
+
},
|
29
|
+
})
|
30
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
|
3
|
+
import { toAccount } from '../../accounts/toAccount.js'
|
4
|
+
import type { ErrorType } from '../../errors/utils.js'
|
5
|
+
import type { Hash, Hex } from '../../types/misc.js'
|
6
|
+
import { keccak256 } from '../../utils/index.js'
|
7
|
+
import { hashMessage } from '../../utils/signature/hashMessage.js'
|
8
|
+
import { hashTypedData } from '../../utils/signature/hashTypedData.js'
|
9
|
+
import { serializeTransaction } from '../serializers.js'
|
10
|
+
import type { ZksyncSmartAccount } from '../types/account.js'
|
11
|
+
import type { ZksyncTransactionSerializableEIP712 } from '../types/transaction.js'
|
12
|
+
|
13
|
+
export type ToSmartAccountParameters = {
|
14
|
+
/** Address of the deployed Account's Contract implementation. */
|
15
|
+
address: Address
|
16
|
+
/** Function to sign a hash. */
|
17
|
+
sign: (parameters: { hash: Hash }) => Promise<Hex>
|
18
|
+
}
|
19
|
+
|
20
|
+
export type ToSmartAccountErrorType = ErrorType
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Creates a [ZKsync Smart Account](https://docs.zksync.io/build/developer-reference/account-abstraction/building-smart-accounts)
|
24
|
+
* from a Contract Address and a custom sign function.
|
25
|
+
*/
|
26
|
+
export function toSmartAccount(
|
27
|
+
parameters: ToSmartAccountParameters,
|
28
|
+
): ZksyncSmartAccount {
|
29
|
+
const { address, sign } = parameters
|
30
|
+
|
31
|
+
const account = toAccount({
|
32
|
+
address,
|
33
|
+
sign,
|
34
|
+
async signMessage({ message }) {
|
35
|
+
return sign({
|
36
|
+
hash: hashMessage(message),
|
37
|
+
})
|
38
|
+
},
|
39
|
+
async signTransaction(transaction) {
|
40
|
+
const signableTransaction = {
|
41
|
+
...transaction,
|
42
|
+
from: this.address!,
|
43
|
+
} as ZksyncTransactionSerializableEIP712
|
44
|
+
|
45
|
+
return serializeTransaction({
|
46
|
+
...signableTransaction,
|
47
|
+
customSignature: await sign({
|
48
|
+
hash: keccak256(serializeTransaction(signableTransaction)),
|
49
|
+
}),
|
50
|
+
})
|
51
|
+
},
|
52
|
+
async signTypedData(typedData) {
|
53
|
+
return sign({
|
54
|
+
hash: hashTypedData(typedData),
|
55
|
+
})
|
56
|
+
},
|
57
|
+
})
|
58
|
+
|
59
|
+
return {
|
60
|
+
...account,
|
61
|
+
source: 'smartAccountZksync',
|
62
|
+
} as ZksyncSmartAccount
|
63
|
+
}
|
package/zksync/index.ts
CHANGED
@@ -1,4 +1,18 @@
|
|
1
1
|
// biome-ignore lint/performance/noBarrelFile: entrypoint module
|
2
|
+
export {
|
3
|
+
type ToSmartAccountErrorType,
|
4
|
+
type ToSmartAccountParameters,
|
5
|
+
toSmartAccount,
|
6
|
+
} from './accounts/toSmartAccount.js'
|
7
|
+
export {
|
8
|
+
type ToMultisigSmartAccountParameters,
|
9
|
+
toMultisigSmartAccount,
|
10
|
+
} from './accounts/toMultisigSmartAccount.js'
|
11
|
+
export {
|
12
|
+
type ToSinglesigSmartAccountParameters,
|
13
|
+
toSinglesigSmartAccount,
|
14
|
+
} from './accounts/toSinglesigSmartAccount.js'
|
15
|
+
|
2
16
|
export {
|
3
17
|
type DeployContractErrorType,
|
4
18
|
type DeployContractParameters,
|
@@ -131,6 +145,7 @@ export {
|
|
131
145
|
|
132
146
|
export { serializeTransaction } from './serializers.js'
|
133
147
|
|
148
|
+
export type { ZksyncSmartAccount } from './types/account.js'
|
134
149
|
export type {
|
135
150
|
/** @deprecated Use `ZksyncBlock` instead */
|
136
151
|
ZksyncBlock as ZkSyncBlock,
|