@aztec/aztec.js 0.76.4 → 0.77.0-testnet-ignition.21
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/dest/account/contract.d.ts +9 -5
- package/dest/account/contract.d.ts.map +1 -1
- package/dest/account/contract.js +15 -2
- package/dest/account/index.d.ts +2 -2
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +8 -1
- package/dest/account/interface.d.ts +5 -4
- package/dest/account/interface.d.ts.map +1 -1
- package/dest/account/interface.js +4 -3
- package/dest/account/wallet.d.ts +4 -3
- package/dest/account/wallet.d.ts.map +1 -1
- package/dest/account/wallet.js +3 -2
- package/dest/account_manager/deploy_account_method.d.ts +5 -5
- package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_method.js +22 -25
- package/dest/account_manager/deploy_account_sent_tx.d.ts +4 -3
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_sent_tx.js +16 -17
- package/dest/account_manager/index.d.ts +20 -11
- package/dest/account_manager/index.d.ts.map +1 -1
- package/dest/account_manager/index.js +89 -87
- package/dest/api/abi.d.ts +2 -3
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/abi.js +1 -3
- package/dest/api/account.d.ts +1 -2
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +1 -2
- package/dest/api/addresses.d.ts +2 -2
- package/dest/api/addresses.d.ts.map +1 -1
- package/dest/api/addresses.js +2 -3
- package/dest/api/cheat_codes.d.ts +4 -4
- package/dest/api/cheat_codes.d.ts.map +1 -1
- package/dest/api/cheat_codes.js +10 -15
- package/dest/api/deployment.js +0 -1
- package/dest/api/entrypoint.js +0 -1
- package/dest/api/eth_address.js +0 -1
- package/dest/api/ethereum/anvil_test_watcher.d.ts +10 -6
- package/dest/api/ethereum/anvil_test_watcher.d.ts.map +1 -1
- package/dest/api/ethereum/anvil_test_watcher.js +43 -18
- package/dest/api/ethereum/chain_monitor.d.ts +6 -2
- package/dest/api/ethereum/chain_monitor.d.ts.map +1 -1
- package/dest/api/ethereum/chain_monitor.js +24 -8
- package/dest/api/ethereum/cheat_codes.d.ts +14 -3
- package/dest/api/ethereum/cheat_codes.d.ts.map +1 -1
- package/dest/api/ethereum/cheat_codes.js +106 -53
- package/dest/api/ethereum/index.d.ts +1 -1
- package/dest/api/ethereum/index.d.ts.map +1 -1
- package/dest/api/ethereum/index.js +1 -2
- package/dest/api/ethereum/l1_contracts.d.ts +1 -1
- package/dest/api/ethereum/l1_contracts.d.ts.map +1 -1
- package/dest/api/ethereum/l1_contracts.js +4 -6
- package/dest/api/ethereum/portal_manager.d.ts +16 -12
- package/dest/api/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/api/ethereum/portal_manager.js +134 -115
- package/dest/api/fee.d.ts +0 -1
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/fee.js +0 -2
- package/dest/api/fields.js +0 -1
- package/dest/api/interfaces/pxe.d.ts +1 -1
- package/dest/api/interfaces/pxe.d.ts.map +1 -1
- package/dest/api/interfaces/pxe.js +1 -2
- package/dest/api/log.js +0 -1
- package/dest/api/log_id.d.ts +1 -1
- package/dest/api/log_id.d.ts.map +1 -1
- package/dest/api/log_id.js +1 -2
- package/dest/api/tx_hash.d.ts +1 -1
- package/dest/api/tx_hash.d.ts.map +1 -1
- package/dest/api/tx_hash.js +1 -2
- package/dest/api/wallet.d.ts +1 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +1 -2
- package/dest/contract/base_contract_interaction.d.ts +21 -5
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +97 -55
- package/dest/contract/batch_call.d.ts +3 -2
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +64 -40
- package/dest/contract/checker.d.ts +1 -1
- package/dest/contract/checker.d.ts.map +1 -1
- package/dest/contract/checker.js +29 -20
- package/dest/contract/contract.d.ts +4 -4
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +30 -28
- package/dest/contract/contract_base.d.ts +5 -5
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +22 -31
- package/dest/contract/contract_function_interaction.d.ts +9 -8
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +63 -51
- package/dest/contract/deploy_method.d.ts +14 -11
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +115 -87
- package/dest/contract/deploy_proven_tx.d.ts +6 -4
- package/dest/contract/deploy_proven_tx.d.ts.map +1 -1
- package/dest/contract/deploy_proven_tx.js +8 -11
- package/dest/contract/deploy_sent_tx.d.ts +8 -6
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +19 -22
- package/dest/contract/get_gas_limits.d.ts +2 -2
- package/dest/contract/get_gas_limits.d.ts.map +1 -1
- package/dest/contract/get_gas_limits.js +2 -4
- package/dest/contract/index.js +2 -4
- package/dest/{deployment → contract}/protocol_contracts.d.ts +4 -2
- package/dest/contract/protocol_contracts.d.ts.map +1 -0
- package/dest/contract/protocol_contracts.js +26 -0
- package/dest/contract/proven_tx.d.ts +3 -2
- package/dest/contract/proven_tx.d.ts.map +1 -1
- package/dest/contract/proven_tx.js +8 -11
- package/dest/contract/sent_tx.d.ts +3 -2
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +33 -35
- package/dest/contract/unsafe_contract.d.ts +3 -3
- package/dest/contract/unsafe_contract.d.ts.map +1 -1
- package/dest/contract/unsafe_contract.js +2 -10
- package/dest/deployment/broadcast_function.d.ts +3 -3
- package/dest/deployment/broadcast_function.d.ts.map +1 -1
- package/dest/deployment/broadcast_function.js +39 -32
- package/dest/deployment/contract_deployer.d.ts +3 -3
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/contract_deployer.js +16 -15
- package/dest/deployment/deploy_instance.d.ts +3 -3
- package/dest/deployment/deploy_instance.d.ts.map +1 -1
- package/dest/deployment/deploy_instance.js +3 -5
- package/dest/deployment/index.js +0 -1
- package/dest/deployment/register_class.d.ts +3 -3
- package/dest/deployment/register_class.d.ts.map +1 -1
- package/dest/deployment/register_class.js +19 -14
- package/dest/entrypoint/default_entrypoint.d.ts +2 -2
- package/dest/entrypoint/default_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_entrypoint.js +11 -9
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts +2 -2
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_multi_call_entrypoint.js +68 -25
- package/dest/entrypoint/entrypoint.d.ts +7 -3
- package/dest/entrypoint/entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/entrypoint.js +0 -1
- package/dest/entrypoint/payload.d.ts +8 -5
- package/dest/entrypoint/payload.d.ts.map +1 -1
- package/dest/entrypoint/payload.js +78 -85
- package/dest/fee/fee_juice_payment_method.d.ts +3 -3
- package/dest/fee/fee_juice_payment_method.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method.js +5 -4
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +5 -4
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +18 -20
- package/dest/fee/fee_payment_method.d.ts +3 -3
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/fee_payment_method.js +3 -2
- package/dest/fee/private_fee_payment_method.d.ts +5 -5
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +40 -38
- package/dest/fee/public_fee_payment_method.d.ts +5 -5
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +38 -35
- package/dest/index.d.ts +25 -12
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +24 -14
- package/dest/rpc_clients/index.js +0 -1
- package/dest/rpc_clients/node/index.d.ts +2 -1
- package/dest/rpc_clients/node/index.d.ts.map +1 -1
- package/dest/rpc_clients/node/index.js +35 -18
- package/dest/rpc_clients/pxe_client.d.ts +2 -2
- package/dest/rpc_clients/pxe_client.d.ts.map +1 -1
- package/dest/rpc_clients/pxe_client.js +9 -7
- package/dest/utils/abi_types.d.ts +4 -1
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/abi_types.js +1 -2
- package/dest/utils/authwit.d.ts +3 -2
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +18 -17
- package/dest/utils/aztec_cheatcodes.d.ts +4 -2
- package/dest/utils/aztec_cheatcodes.d.ts.map +1 -1
- package/dest/utils/aztec_cheatcodes.js +32 -41
- package/dest/utils/field_compressed_string.js +3 -5
- package/dest/utils/index.d.ts +1 -1
- package/dest/utils/index.d.ts.map +1 -1
- package/dest/utils/index.js +1 -2
- package/dest/utils/node.d.ts +3 -3
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +4 -6
- package/dest/utils/pub_key.d.ts +2 -1
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pub_key.js +2 -4
- package/dest/utils/pxe.d.ts +2 -2
- package/dest/utils/pxe.d.ts.map +1 -1
- package/dest/utils/pxe.js +3 -5
- package/dest/wallet/account_wallet.d.ts +8 -5
- package/dest/wallet/account_wallet.d.ts.map +1 -1
- package/dest/wallet/account_wallet.js +120 -83
- package/dest/wallet/account_wallet_with_private_key.d.ts +5 -5
- package/dest/wallet/account_wallet_with_private_key.d.ts.map +1 -1
- package/dest/wallet/account_wallet_with_private_key.js +10 -16
- package/dest/wallet/base_wallet.d.ts +19 -10
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +12 -13
- package/dest/wallet/index.d.ts +3 -3
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +2 -4
- package/dest/wallet/signerless_wallet.d.ts +7 -4
- package/dest/wallet/signerless_wallet.d.ts.map +1 -1
- package/dest/wallet/signerless_wallet.js +4 -6
- package/package.json +10 -14
- package/src/account/contract.ts +22 -5
- package/src/account/index.ts +2 -2
- package/src/account/interface.ts +5 -4
- package/src/account/wallet.ts +4 -3
- package/src/account_manager/deploy_account_method.ts +5 -5
- package/src/account_manager/deploy_account_sent_tx.ts +4 -3
- package/src/account_manager/index.ts +51 -24
- package/src/api/abi.ts +10 -3
- package/src/api/account.ts +8 -3
- package/src/api/addresses.ts +2 -2
- package/src/api/cheat_codes.ts +6 -6
- package/src/api/ethereum/anvil_test_watcher.ts +31 -7
- package/src/api/ethereum/chain_monitor.ts +9 -2
- package/src/api/ethereum/cheat_codes.ts +65 -24
- package/src/api/ethereum/index.ts +5 -1
- package/src/api/ethereum/l1_contracts.ts +1 -1
- package/src/api/ethereum/portal_manager.ts +27 -32
- package/src/api/fee.ts +0 -1
- package/src/api/interfaces/pxe.ts +1 -1
- package/src/api/log_id.ts +1 -1
- package/src/api/tx_hash.ts +1 -1
- package/src/api/wallet.ts +1 -1
- package/src/contract/base_contract_interaction.ts +35 -9
- package/src/contract/batch_call.ts +9 -7
- package/src/contract/checker.ts +1 -1
- package/src/contract/contract.ts +11 -4
- package/src/contract/contract_base.ts +3 -3
- package/src/contract/contract_function_interaction.ts +24 -13
- package/src/contract/deploy_method.ts +27 -18
- package/src/contract/deploy_proven_tx.ts +6 -4
- package/src/contract/deploy_sent_tx.ts +8 -6
- package/src/contract/get_gas_limits.ts +2 -2
- package/src/contract/protocol_contracts.ts +35 -0
- package/src/contract/proven_tx.ts +3 -2
- package/src/contract/sent_tx.ts +3 -2
- package/src/contract/unsafe_contract.ts +3 -3
- package/src/deployment/broadcast_function.ts +47 -40
- package/src/deployment/contract_deployer.ts +4 -3
- package/src/deployment/deploy_instance.ts +5 -5
- package/src/deployment/register_class.ts +25 -18
- package/src/entrypoint/default_entrypoint.ts +5 -5
- package/src/entrypoint/default_multi_call_entrypoint.ts +5 -4
- package/src/entrypoint/entrypoint.ts +7 -3
- package/src/entrypoint/payload.ts +11 -6
- package/src/fee/fee_juice_payment_method.ts +5 -3
- package/src/fee/fee_juice_payment_method_with_claim.ts +11 -10
- package/src/fee/fee_payment_method.ts +3 -3
- package/src/fee/private_fee_payment_method.ts +10 -11
- package/src/fee/public_fee_payment_method.ts +11 -11
- package/src/index.ts +35 -58
- package/src/rpc_clients/node/index.ts +2 -1
- package/src/rpc_clients/pxe_client.ts +2 -2
- package/src/utils/abi_types.ts +4 -7
- package/src/utils/authwit.ts +5 -2
- package/src/utils/aztec_cheatcodes.ts +5 -3
- package/src/utils/field_compressed_string.ts +1 -1
- package/src/utils/index.ts +1 -1
- package/src/utils/node.ts +3 -3
- package/src/utils/pub_key.ts +3 -2
- package/src/utils/pxe.ts +2 -2
- package/src/wallet/account_wallet.ts +8 -5
- package/src/wallet/account_wallet_with_private_key.ts +5 -4
- package/src/wallet/base_wallet.ts +37 -46
- package/src/wallet/index.ts +3 -3
- package/src/wallet/signerless_wallet.ts +7 -4
- package/dest/deployment/protocol_contracts.d.ts.map +0 -1
- package/dest/deployment/protocol_contracts.js +0 -14
- package/dest/fee/no_fee_payment_method.d.ts +0 -13
- package/dest/fee/no_fee_payment_method.d.ts.map +0 -1
- package/dest/fee/no_fee_payment_method.js +0 -17
- package/src/deployment/protocol_contracts.ts +0 -17
- package/src/fee/no_fee_payment_method.ts +0 -23
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec.js",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.77.0-testnet-ignition.21",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dest/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"clean": "rm -rf ./dest .tsbuildinfo ./src/account_contract/artifacts",
|
|
39
39
|
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
40
40
|
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
41
|
-
"test": "
|
|
41
|
+
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
42
42
|
},
|
|
43
43
|
"inherits": [
|
|
44
44
|
"../package.common.json",
|
|
@@ -72,19 +72,18 @@
|
|
|
72
72
|
"reporters": [
|
|
73
73
|
"default"
|
|
74
74
|
],
|
|
75
|
-
"testTimeout":
|
|
75
|
+
"testTimeout": 120000,
|
|
76
76
|
"setupFiles": [
|
|
77
77
|
"../../foundation/src/jest/setup.mjs"
|
|
78
78
|
]
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@aztec/
|
|
82
|
-
"@aztec/
|
|
83
|
-
"@aztec/
|
|
84
|
-
"@aztec/
|
|
85
|
-
"@aztec/
|
|
86
|
-
"@aztec/
|
|
87
|
-
"@aztec/types": "0.76.4",
|
|
81
|
+
"@aztec/constants": "0.77.0-testnet-ignition.21",
|
|
82
|
+
"@aztec/ethereum": "0.77.0-testnet-ignition.21",
|
|
83
|
+
"@aztec/foundation": "0.77.0-testnet-ignition.21",
|
|
84
|
+
"@aztec/l1-artifacts": "0.77.0-testnet-ignition.21",
|
|
85
|
+
"@aztec/protocol-contracts": "0.77.0-testnet-ignition.21",
|
|
86
|
+
"@aztec/stdlib": "0.77.0-testnet-ignition.21",
|
|
88
87
|
"axios": "^1.7.2",
|
|
89
88
|
"tslib": "^2.4.0",
|
|
90
89
|
"viem": "2.22.8"
|
|
@@ -94,7 +93,6 @@
|
|
|
94
93
|
"@types/jest": "^29.5.0",
|
|
95
94
|
"@types/node": "^18.7.23",
|
|
96
95
|
"buffer": "^6.0.3",
|
|
97
|
-
"copy-webpack-plugin": "^12.0.2",
|
|
98
96
|
"crypto-browserify": "^3.12.0",
|
|
99
97
|
"jest": "^29.5.0",
|
|
100
98
|
"jest-mock-extended": "^3.0.3",
|
|
@@ -104,9 +102,7 @@
|
|
|
104
102
|
"ts-loader": "^9.4.4",
|
|
105
103
|
"ts-node": "^10.9.1",
|
|
106
104
|
"typescript": "^5.0.4",
|
|
107
|
-
"util": "^0.12.5"
|
|
108
|
-
"webpack": "^5.88.2",
|
|
109
|
-
"webpack-cli": "^5.1.4"
|
|
105
|
+
"util": "^0.12.5"
|
|
110
106
|
},
|
|
111
107
|
"files": [
|
|
112
108
|
"dest",
|
package/src/account/contract.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { CompleteAddress, NodeInfo } from '@aztec/stdlib/contract';
|
|
4
|
+
import { getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
|
|
5
|
+
import { deriveKeys } from '@aztec/stdlib/keys';
|
|
4
6
|
|
|
5
|
-
import {
|
|
7
|
+
import type { AccountInterface, AuthWitnessProvider } from './interface.js';
|
|
6
8
|
|
|
7
9
|
// docs:start:account-contract-interface
|
|
8
10
|
/**
|
|
@@ -13,7 +15,7 @@ export interface AccountContract {
|
|
|
13
15
|
/**
|
|
14
16
|
* Returns the artifact of this account contract.
|
|
15
17
|
*/
|
|
16
|
-
getContractArtifact(): ContractArtifact
|
|
18
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Returns the deployment arguments for this instance, or undefined if this contract does not require deployment.
|
|
@@ -37,3 +39,18 @@ export interface AccountContract {
|
|
|
37
39
|
getAuthWitnessProvider(address: CompleteAddress): AuthWitnessProvider;
|
|
38
40
|
}
|
|
39
41
|
// docs:end:account-contract-interface
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Compute the address of an account contract from secret and salt.
|
|
45
|
+
*/
|
|
46
|
+
export async function getAccountContractAddress(accountContract: AccountContract, secret: Fr, salt: Fr) {
|
|
47
|
+
const { publicKeys } = await deriveKeys(secret);
|
|
48
|
+
const constructorArgs = await accountContract.getDeploymentArgs();
|
|
49
|
+
const artifact = await accountContract.getContractArtifact();
|
|
50
|
+
const instance = await getContractInstanceFromDeployParams(artifact, {
|
|
51
|
+
constructorArgs,
|
|
52
|
+
salt,
|
|
53
|
+
publicKeys,
|
|
54
|
+
});
|
|
55
|
+
return instance.address;
|
|
56
|
+
}
|
package/src/account/index.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
10
10
|
|
|
11
|
-
export { type AccountContract } from './contract.js';
|
|
11
|
+
export { type AccountContract, getAccountContractAddress } from './contract.js';
|
|
12
12
|
export { type AccountInterface, type AuthWitnessProvider } from './interface.js';
|
|
13
13
|
export * from './wallet.js';
|
|
14
14
|
|
package/src/account/interface.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import type { EntrypointInterface } from '../entrypoint/entrypoint.js';
|
|
6
7
|
|
|
7
8
|
// docs:start:account-interface
|
|
8
9
|
/** Creates authorization witnesses. */
|
package/src/account/wallet.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
2
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import type { IntentAction, IntentInnerHash } from '../utils/authwit.js';
|
|
5
|
+
import type { AccountInterface } from './interface.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The wallet interface.
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { type PublicKeys } from '@aztec/circuits.js';
|
|
2
1
|
import {
|
|
3
2
|
type ContractArtifact,
|
|
4
3
|
type FunctionArtifact,
|
|
5
4
|
FunctionSelector,
|
|
6
5
|
encodeArguments,
|
|
7
6
|
getFunctionArtifactByName,
|
|
8
|
-
} from '@aztec/
|
|
7
|
+
} from '@aztec/stdlib/abi';
|
|
8
|
+
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import type { AuthWitnessProvider } from '../account/interface.js';
|
|
11
|
+
import type { Wallet } from '../account/wallet.js';
|
|
12
|
+
import type { ExecutionRequestInit } from '../api/entrypoint.js';
|
|
13
13
|
import { Contract } from '../contract/contract.js';
|
|
14
14
|
import { DeployMethod, type DeployOptions } from '../contract/deploy_method.js';
|
|
15
15
|
import { EntrypointPayload, computeCombinedPayloadHash } from '../entrypoint/payload.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
+
import type { Wallet } from '../account/index.js';
|
|
5
6
|
import { DefaultWaitOpts, SentTx, type WaitOpts } from '../contract/sent_tx.js';
|
|
6
7
|
|
|
7
8
|
/** Extends a transaction receipt with a wallet instance for the newly deployed contract. */
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { CompleteAddress, type PXE } from '@aztec/circuit-types';
|
|
2
|
-
import { type ContractInstanceWithAddress, deriveKeys, getContractInstanceFromDeployParams } from '@aztec/circuits.js';
|
|
3
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
2
|
+
import { CompleteAddress, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
+
import { getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
|
|
4
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
import { deriveKeys } from '@aztec/stdlib/keys';
|
|
6
|
+
|
|
7
|
+
import type { AccountContract } from '../account/contract.js';
|
|
8
|
+
import type { Salt, Wallet } from '../account/index.js';
|
|
9
|
+
import type { AccountInterface } from '../account/interface.js';
|
|
10
|
+
import { DeployMethod, type DeployOptions } from '../contract/deploy_method.js';
|
|
11
|
+
import { Contract } from '../contract/index.js';
|
|
9
12
|
import { DefaultWaitOpts, type WaitOpts } from '../contract/sent_tx.js';
|
|
10
13
|
import { DefaultMultiCallEntrypoint } from '../entrypoint/default_multi_call_entrypoint.js';
|
|
11
14
|
import { AccountWalletWithSecretKey, SignerlessWallet } from '../wallet/index.js';
|
|
@@ -18,7 +21,12 @@ import { DeployAccountSentTx } from './deploy_account_sent_tx.js';
|
|
|
18
21
|
export type DeployAccountOptions = Pick<
|
|
19
22
|
DeployOptions,
|
|
20
23
|
'fee' | 'skipClassRegistration' | 'skipPublicDeployment' | 'skipInitialization'
|
|
21
|
-
|
|
24
|
+
> & {
|
|
25
|
+
/**
|
|
26
|
+
* Wallet used for deploying the account contract. Must be funded in order to pay for the fee.
|
|
27
|
+
*/
|
|
28
|
+
deployWallet?: Wallet;
|
|
29
|
+
};
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
32
|
* Manages a user account. Provides methods for calculating the account's address, deploying the account contract,
|
|
@@ -40,7 +48,8 @@ export class AccountManager {
|
|
|
40
48
|
const { publicKeys } = await deriveKeys(secretKey);
|
|
41
49
|
salt = salt !== undefined ? new Fr(salt) : Fr.random();
|
|
42
50
|
|
|
43
|
-
const
|
|
51
|
+
const artifact = await accountContract.getContractArtifact();
|
|
52
|
+
const instance = await getContractInstanceFromDeployParams(artifact, {
|
|
44
53
|
constructorArgs: await accountContract.getDeploymentArgs(),
|
|
45
54
|
salt: salt,
|
|
46
55
|
publicKeys,
|
|
@@ -113,7 +122,7 @@ export class AccountManager {
|
|
|
113
122
|
*/
|
|
114
123
|
public async register(): Promise<AccountWalletWithSecretKey> {
|
|
115
124
|
await this.pxe.registerContract({
|
|
116
|
-
artifact: this.accountContract.getContractArtifact(),
|
|
125
|
+
artifact: await this.accountContract.getContractArtifact(),
|
|
117
126
|
instance: this.getInstance(),
|
|
118
127
|
});
|
|
119
128
|
|
|
@@ -126,31 +135,46 @@ export class AccountManager {
|
|
|
126
135
|
* Returns the pre-populated deployment method to deploy the account contract that backs this account.
|
|
127
136
|
* Typically you will not need this method and can call `deploy` directly. Use this for having finer
|
|
128
137
|
* grained control on when to create, simulate, and send the deployment tx.
|
|
138
|
+
* @param deployWallet - Wallet used for deploying the account contract.
|
|
129
139
|
* @returns A DeployMethod instance that deploys this account contract.
|
|
130
140
|
*/
|
|
131
|
-
public async getDeployMethod() {
|
|
141
|
+
public async getDeployMethod(deployWallet?: Wallet) {
|
|
142
|
+
const artifact = await this.accountContract.getContractArtifact();
|
|
143
|
+
|
|
132
144
|
if (!(await this.isDeployable())) {
|
|
133
|
-
throw new Error(
|
|
134
|
-
`Account contract ${this.accountContract.getContractArtifact().name} does not require deployment.`,
|
|
135
|
-
);
|
|
145
|
+
throw new Error(`Account contract ${artifact.name} does not require deployment.`);
|
|
136
146
|
}
|
|
137
147
|
|
|
138
148
|
const completeAddress = await this.getCompleteAddress();
|
|
139
149
|
|
|
140
150
|
await this.pxe.registerAccount(this.secretKey, completeAddress.partialAddress);
|
|
141
151
|
|
|
142
|
-
const
|
|
143
|
-
const deployWallet = new SignerlessWallet(this.pxe, new DefaultMultiCallEntrypoint(chainId, protocolVersion));
|
|
152
|
+
const args = (await this.accountContract.getDeploymentArgs()) ?? [];
|
|
144
153
|
|
|
145
|
-
|
|
154
|
+
if (deployWallet) {
|
|
155
|
+
// If deploying using an existing wallet/account, treat it like regular contract deployment.
|
|
156
|
+
const thisWallet = await this.getWallet();
|
|
157
|
+
return new DeployMethod(
|
|
158
|
+
this.getPublicKeys(),
|
|
159
|
+
deployWallet,
|
|
160
|
+
artifact,
|
|
161
|
+
address => Contract.at(address, artifact, thisWallet),
|
|
162
|
+
args,
|
|
163
|
+
'constructor',
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const { l1ChainId: chainId, protocolVersion } = await this.pxe.getNodeInfo();
|
|
168
|
+
// We use a signerless wallet with the multi call entrypoint in order to make multiple calls in one go.
|
|
146
169
|
// If we used getWallet, the deployment would get routed via the account contract entrypoint
|
|
147
|
-
// and it can't be used unless the contract is initialized
|
|
148
|
-
const
|
|
170
|
+
// and it can't be used unless the contract is initialized.
|
|
171
|
+
const wallet = new SignerlessWallet(this.pxe, new DefaultMultiCallEntrypoint(chainId, protocolVersion));
|
|
172
|
+
|
|
149
173
|
return new DeployAccountMethod(
|
|
150
174
|
this.accountContract.getAuthWitnessProvider(completeAddress),
|
|
151
175
|
this.getPublicKeys(),
|
|
152
|
-
|
|
153
|
-
|
|
176
|
+
wallet,
|
|
177
|
+
artifact,
|
|
154
178
|
args,
|
|
155
179
|
'constructor',
|
|
156
180
|
'entrypoint',
|
|
@@ -166,7 +190,7 @@ export class AccountManager {
|
|
|
166
190
|
* @returns A SentTx object that can be waited to get the associated Wallet.
|
|
167
191
|
*/
|
|
168
192
|
public deploy(opts?: DeployAccountOptions): DeployAccountSentTx {
|
|
169
|
-
const sentTx = this.getDeployMethod()
|
|
193
|
+
const sentTx = this.getDeployMethod(opts?.deployWallet)
|
|
170
194
|
.then(deployMethod =>
|
|
171
195
|
deployMethod.send({
|
|
172
196
|
contractAddressSalt: new Fr(this.salt),
|
|
@@ -188,8 +212,8 @@ export class AccountManager {
|
|
|
188
212
|
* @param opts - Options to wait for the tx to be mined.
|
|
189
213
|
* @returns A Wallet instance.
|
|
190
214
|
*/
|
|
191
|
-
public async waitSetup(opts: WaitOpts = DefaultWaitOpts): Promise<AccountWalletWithSecretKey> {
|
|
192
|
-
await ((await this.isDeployable()) ? this.deploy().wait(opts) : this.register());
|
|
215
|
+
public async waitSetup(opts: DeployAccountOptions & WaitOpts = DefaultWaitOpts): Promise<AccountWalletWithSecretKey> {
|
|
216
|
+
await ((await this.isDeployable()) ? this.deploy(opts).wait(opts) : this.register());
|
|
193
217
|
return this.getWallet();
|
|
194
218
|
}
|
|
195
219
|
|
|
@@ -200,3 +224,6 @@ export class AccountManager {
|
|
|
200
224
|
return (await this.accountContract.getDeploymentArgs()) !== undefined;
|
|
201
225
|
}
|
|
202
226
|
}
|
|
227
|
+
|
|
228
|
+
export { DeployAccountMethod } from './deploy_account_method.js';
|
|
229
|
+
export { type DeployAccountTxReceipt, DeployAccountSentTx } from './deploy_account_sent_tx.js';
|
package/src/api/abi.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export {
|
|
2
|
+
type ContractArtifact,
|
|
3
|
+
type FunctionArtifact,
|
|
4
|
+
EventSelector,
|
|
5
|
+
FunctionSelector,
|
|
6
|
+
loadContractArtifact,
|
|
7
|
+
contractArtifactToBuffer,
|
|
8
|
+
contractArtifactFromBuffer,
|
|
9
|
+
} from '@aztec/stdlib/abi';
|
|
10
|
+
export { type NoirCompiledContract } from '@aztec/stdlib/noir';
|
package/src/api/account.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
type AccountContract,
|
|
3
|
+
type AccountInterface,
|
|
4
|
+
type AuthWitnessProvider,
|
|
5
|
+
type Salt,
|
|
6
|
+
type Wallet,
|
|
7
|
+
getAccountContractAddress,
|
|
8
|
+
} from '../account/index.js';
|
|
2
9
|
|
|
3
10
|
export { AccountManager } from '../account_manager/index.js';
|
|
4
|
-
|
|
5
|
-
export { CompleteAddress } from '@aztec/circuit-types';
|
package/src/api/addresses.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AztecAddress } from '@aztec/
|
|
2
|
-
export { CompleteAddress } from '@aztec/
|
|
1
|
+
export { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
export { CompleteAddress } from '@aztec/stdlib/contract';
|
package/src/api/cheat_codes.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type PXE } from '@aztec/circuit-types';
|
|
2
1
|
import { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
3
|
-
import {
|
|
2
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
4
4
|
|
|
5
5
|
import { AztecCheatCodes } from '../utils/aztec_cheatcodes.js';
|
|
6
6
|
import { RollupCheatCodes } from './ethereum/cheat_codes.js';
|
|
@@ -18,8 +18,8 @@ export class CheatCodes {
|
|
|
18
18
|
public rollup: RollupCheatCodes,
|
|
19
19
|
) {}
|
|
20
20
|
|
|
21
|
-
static async create(
|
|
22
|
-
const ethCheatCodes = new EthCheatCodes(
|
|
21
|
+
static async create(rpcUrls: string[], pxe: PXE): Promise<CheatCodes> {
|
|
22
|
+
const ethCheatCodes = new EthCheatCodes(rpcUrls);
|
|
23
23
|
const aztecCheatCodes = new AztecCheatCodes(pxe);
|
|
24
24
|
const rollupCheatCodes = new RollupCheatCodes(
|
|
25
25
|
ethCheatCodes,
|
|
@@ -28,8 +28,8 @@ export class CheatCodes {
|
|
|
28
28
|
return new CheatCodes(ethCheatCodes, aztecCheatCodes, rollupCheatCodes);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
static createRollup(
|
|
32
|
-
const ethCheatCodes = new EthCheatCodes(
|
|
31
|
+
static createRollup(rpcUrls: string[], addresses: Pick<L1ContractAddresses, 'rollupAddress'>): RollupCheatCodes {
|
|
32
|
+
const ethCheatCodes = new EthCheatCodes(rpcUrls);
|
|
33
33
|
return new RollupCheatCodes(ethCheatCodes, addresses);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ViemPublicClient } from '@aztec/ethereum';
|
|
2
|
+
import type { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
5
|
-
import {
|
|
6
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
6
7
|
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
7
8
|
|
|
8
|
-
import { type GetContractReturnType,
|
|
9
|
-
|
|
9
|
+
import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
10
|
+
|
|
11
|
+
import { RollupCheatCodes } from './cheat_codes.js';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Represents a watcher for a rollup contract.
|
|
@@ -18,17 +20,21 @@ import type * as chains from 'viem/chains';
|
|
|
18
20
|
export class AnvilTestWatcher {
|
|
19
21
|
private isSandbox: boolean = false;
|
|
20
22
|
|
|
21
|
-
private rollup: GetContractReturnType<typeof RollupAbi,
|
|
23
|
+
private rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>;
|
|
24
|
+
private rollupCheatCodes: RollupCheatCodes;
|
|
22
25
|
|
|
23
26
|
private filledRunningPromise?: RunningPromise;
|
|
24
27
|
private mineIfOutdatedPromise?: RunningPromise;
|
|
28
|
+
private markingAsProvenRunningPromise?: RunningPromise;
|
|
25
29
|
|
|
26
30
|
private logger: Logger = createLogger(`aztecjs:utils:watcher`);
|
|
27
31
|
|
|
32
|
+
private isMarkingAsProven = true;
|
|
33
|
+
|
|
28
34
|
constructor(
|
|
29
35
|
private cheatcodes: EthCheatCodes,
|
|
30
36
|
rollupAddress: EthAddress,
|
|
31
|
-
publicClient:
|
|
37
|
+
publicClient: ViemPublicClient,
|
|
32
38
|
private dateProvider?: TestDateProvider,
|
|
33
39
|
) {
|
|
34
40
|
this.rollup = getContract({
|
|
@@ -37,9 +43,17 @@ export class AnvilTestWatcher {
|
|
|
37
43
|
client: publicClient,
|
|
38
44
|
});
|
|
39
45
|
|
|
46
|
+
this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
|
|
47
|
+
rollupAddress,
|
|
48
|
+
});
|
|
49
|
+
|
|
40
50
|
this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
|
|
41
51
|
}
|
|
42
52
|
|
|
53
|
+
setIsMarkingAsProven(isMarkingAsProven: boolean) {
|
|
54
|
+
this.isMarkingAsProven = isMarkingAsProven;
|
|
55
|
+
}
|
|
56
|
+
|
|
43
57
|
setIsSandbox(isSandbox: boolean) {
|
|
44
58
|
this.isSandbox = isSandbox;
|
|
45
59
|
}
|
|
@@ -60,6 +74,8 @@ export class AnvilTestWatcher {
|
|
|
60
74
|
this.filledRunningPromise.start();
|
|
61
75
|
this.mineIfOutdatedPromise = new RunningPromise(() => this.mineIfOutdated(), this.logger, 1000);
|
|
62
76
|
this.mineIfOutdatedPromise.start();
|
|
77
|
+
this.markingAsProvenRunningPromise = new RunningPromise(() => this.markAsProven(), this.logger, 1000);
|
|
78
|
+
this.markingAsProvenRunningPromise.start();
|
|
63
79
|
this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
|
|
64
80
|
} else {
|
|
65
81
|
this.logger.info(`Watcher not started because not auto mining`);
|
|
@@ -69,6 +85,14 @@ export class AnvilTestWatcher {
|
|
|
69
85
|
async stop() {
|
|
70
86
|
await this.filledRunningPromise?.stop();
|
|
71
87
|
await this.mineIfOutdatedPromise?.stop();
|
|
88
|
+
await this.markingAsProvenRunningPromise?.stop();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async markAsProven() {
|
|
92
|
+
if (!this.isMarkingAsProven) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
await this.rollupCheatCodes.markAsProven();
|
|
72
96
|
}
|
|
73
97
|
|
|
74
98
|
async mineIfOutdated() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { PublicClient } from 'viem';
|
|
5
5
|
|
|
6
6
|
/** Utility class that polls the chain on quick intervals and logs new L1 blocks, L2 blocks, and L2 proofs. */
|
|
7
7
|
export class ChainMonitor {
|
|
@@ -14,6 +14,10 @@ export class ChainMonitor {
|
|
|
14
14
|
public l2BlockNumber!: number;
|
|
15
15
|
/** Current L2 proven block number */
|
|
16
16
|
public l2ProvenBlockNumber!: number;
|
|
17
|
+
/** L1 timestamp for the current L2 block */
|
|
18
|
+
public l2BlockTimestamp!: bigint;
|
|
19
|
+
/** L1 timestamp for the proven L2 block */
|
|
20
|
+
public l2ProvenBlockTimestamp!: bigint;
|
|
17
21
|
|
|
18
22
|
constructor(
|
|
19
23
|
private readonly rollup: RollupContract,
|
|
@@ -28,6 +32,7 @@ export class ChainMonitor {
|
|
|
28
32
|
throw new Error('Chain monitor already started');
|
|
29
33
|
}
|
|
30
34
|
this.handle = setInterval(this.safeRun.bind(this), this.intervalMs);
|
|
35
|
+
return this;
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
stop() {
|
|
@@ -61,6 +66,7 @@ export class ChainMonitor {
|
|
|
61
66
|
const epochNumber = await this.rollup.getEpochNumber(BigInt(newL2BlockNumber));
|
|
62
67
|
msg += ` with new L2 block ${newL2BlockNumber} for epoch ${epochNumber}`;
|
|
63
68
|
this.l2BlockNumber = newL2BlockNumber;
|
|
69
|
+
this.l2BlockTimestamp = timestamp;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
const newL2ProvenBlockNumber = Number(await this.rollup.getProvenBlockNumber());
|
|
@@ -68,6 +74,7 @@ export class ChainMonitor {
|
|
|
68
74
|
const epochNumber = await this.rollup.getEpochNumber(BigInt(newL2ProvenBlockNumber));
|
|
69
75
|
msg += ` with proof up to L2 block ${newL2ProvenBlockNumber} for epoch ${epochNumber}`;
|
|
70
76
|
this.l2ProvenBlockNumber = newL2ProvenBlockNumber;
|
|
77
|
+
this.l2ProvenBlockTimestamp = timestamp;
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
this.logger.info(msg, {
|
|
@@ -1,31 +1,27 @@
|
|
|
1
|
+
import type { ViemPublicClient } from '@aztec/ethereum';
|
|
1
2
|
import { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
2
|
-
import {
|
|
3
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
4
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
6
|
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
5
7
|
|
|
6
|
-
import {
|
|
7
|
-
type GetContractReturnType,
|
|
8
|
-
type Hex,
|
|
9
|
-
type PublicClient,
|
|
10
|
-
type WalletClient,
|
|
11
|
-
createWalletClient,
|
|
12
|
-
getContract,
|
|
13
|
-
http,
|
|
14
|
-
publicActions,
|
|
15
|
-
} from 'viem';
|
|
8
|
+
import { type GetContractReturnType, type Hex, createPublicClient, fallback, getContract, http, keccak256 } from 'viem';
|
|
16
9
|
import { foundry } from 'viem/chains';
|
|
17
10
|
|
|
18
11
|
export { EthCheatCodes };
|
|
19
12
|
|
|
20
13
|
/** Cheat codes for the L1 rollup contract. */
|
|
21
14
|
export class RollupCheatCodes {
|
|
22
|
-
private client:
|
|
23
|
-
private rollup: GetContractReturnType<typeof RollupAbi,
|
|
15
|
+
private client: ViemPublicClient;
|
|
16
|
+
private rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>;
|
|
24
17
|
|
|
25
18
|
private logger = createLogger('aztecjs:cheat_codes');
|
|
26
19
|
|
|
27
20
|
constructor(private ethCheatCodes: EthCheatCodes, addresses: Pick<L1ContractAddresses, 'rollupAddress'>) {
|
|
28
|
-
this.client =
|
|
21
|
+
this.client = createPublicClient({
|
|
22
|
+
chain: foundry,
|
|
23
|
+
transport: fallback(ethCheatCodes.rpcUrls.map(url => http(url))),
|
|
24
|
+
});
|
|
29
25
|
this.rollup = getContract({
|
|
30
26
|
abi: RollupAbi,
|
|
31
27
|
address: addresses.rollupAddress.toString(),
|
|
@@ -110,14 +106,36 @@ export class RollupCheatCodes {
|
|
|
110
106
|
* @param maybeBlockNumber - The block number to mark as proven (defaults to latest pending)
|
|
111
107
|
*/
|
|
112
108
|
public async markAsProven(maybeBlockNumber?: number | bigint) {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
109
|
+
const { pending, proven } = await this.getTips();
|
|
110
|
+
|
|
111
|
+
let blockNumber = maybeBlockNumber;
|
|
112
|
+
if (blockNumber === undefined || blockNumber > pending) {
|
|
113
|
+
blockNumber = pending;
|
|
114
|
+
}
|
|
115
|
+
if (blockNumber <= proven) {
|
|
116
|
+
this.logger.warn(`Block ${blockNumber} is already proven`);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// @note @LHerskind this is heavily dependent on the storage layout and size of values
|
|
121
|
+
// The rollupStore is a struct and if the size of elements or the struct changes, this can break
|
|
122
|
+
|
|
123
|
+
// Convert string to bytes and then compute keccak256
|
|
124
|
+
const storageSlot = keccak256(Buffer.from('aztec.stf.storage', 'utf-8'));
|
|
125
|
+
const provenBlockNumberSlot = BigInt(storageSlot) + 1n;
|
|
126
|
+
|
|
127
|
+
const tipsBefore = await this.getTips();
|
|
128
|
+
|
|
129
|
+
await this.ethCheatCodes.store(
|
|
130
|
+
EthAddress.fromString(this.rollup.address),
|
|
131
|
+
provenBlockNumberSlot,
|
|
132
|
+
BigInt(blockNumber),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const tipsAfter = await this.getTips();
|
|
136
|
+
this.logger.info(
|
|
137
|
+
`Proven tip moved: ${tipsBefore.proven} -> ${tipsAfter.proven}. Pending tip: ${tipsAfter.pending}.`,
|
|
138
|
+
);
|
|
121
139
|
}
|
|
122
140
|
|
|
123
141
|
/**
|
|
@@ -125,7 +143,7 @@ export class RollupCheatCodes {
|
|
|
125
143
|
* @param action - The action to execute
|
|
126
144
|
*/
|
|
127
145
|
public async asOwner(
|
|
128
|
-
action: (owner: Hex, rollup: GetContractReturnType<typeof RollupAbi,
|
|
146
|
+
action: (owner: Hex, rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>) => Promise<void>,
|
|
129
147
|
) {
|
|
130
148
|
const owner = await this.rollup.read.owner();
|
|
131
149
|
await this.ethCheatCodes.startImpersonating(owner);
|
|
@@ -136,8 +154,31 @@ export class RollupCheatCodes {
|
|
|
136
154
|
/** Directly calls the L1 gas fee oracle. */
|
|
137
155
|
public async updateL1GasFeeOracle() {
|
|
138
156
|
await this.asOwner(async (account, rollup) => {
|
|
139
|
-
await rollup.write.updateL1GasFeeOracle({ account, chain: this.client.chain });
|
|
157
|
+
const hash = await rollup.write.updateL1GasFeeOracle({ account, chain: this.client.chain });
|
|
158
|
+
await this.client.waitForTransactionReceipt({ hash });
|
|
140
159
|
this.logger.warn(`Updated L1 gas fee oracle`);
|
|
141
160
|
});
|
|
142
161
|
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Bumps proving cost per mana.
|
|
165
|
+
* @param bumper - Callback to calculate the new proving cost per mana based on current value.
|
|
166
|
+
*/
|
|
167
|
+
public async bumpProvingCostPerMana(bumper: (before: bigint) => bigint) {
|
|
168
|
+
const currentCost = await this.rollup.read.getProvingCostPerManaInEth();
|
|
169
|
+
const newCost = bumper(currentCost);
|
|
170
|
+
await this.setProvingCostPerMana(newCost);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Directly updates proving cost per mana.
|
|
175
|
+
* @param ethValue - The new proving cost per mana in ETH
|
|
176
|
+
*/
|
|
177
|
+
public async setProvingCostPerMana(ethValue: bigint) {
|
|
178
|
+
await this.asOwner(async (account, rollup) => {
|
|
179
|
+
const hash = await rollup.write.setProvingCostPerMana([ethValue], { account, chain: this.client.chain });
|
|
180
|
+
await this.client.waitForTransactionReceipt({ hash });
|
|
181
|
+
this.logger.warn(`Updated proving cost per mana to ${ethValue}`);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
143
184
|
}
|
|
@@ -12,4 +12,8 @@ export { getL1ContractAddresses } from './l1_contracts.js';
|
|
|
12
12
|
export { RollupCheatCodes, EthCheatCodes } from './cheat_codes.js';
|
|
13
13
|
export { ChainMonitor } from './chain_monitor.js';
|
|
14
14
|
export { AnvilTestWatcher } from './anvil_test_watcher.js';
|
|
15
|
-
export {
|
|
15
|
+
export {
|
|
16
|
+
deployL1Contract,
|
|
17
|
+
deployL1Contracts,
|
|
18
|
+
type DeployL1ContractsReturnType,
|
|
19
|
+
} from '@aztec/ethereum/deploy-l1-contracts';
|