@aztec/ethereum 0.85.0 → 0.86.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/dest/client.d.ts +3 -1
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +15 -1
- package/dest/contracts/fee_asset_handler.js +1 -1
- package/dest/contracts/fee_juice.d.ts +4 -6
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/fee_juice.js +12 -19
- package/dest/contracts/forwarder.d.ts +4 -4
- package/dest/contracts/forwarder.d.ts.map +1 -1
- package/dest/contracts/forwarder.js +4 -4
- package/dest/contracts/governance.d.ts +17 -14
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +61 -64
- package/dest/contracts/governance_proposer.d.ts +3 -3
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/registry.d.ts +5 -4
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +16 -2
- package/dest/contracts/rollup.d.ts +4 -7
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +2 -2
- package/dest/contracts/slashing_proposer.d.ts +3 -3
- package/dest/contracts/slashing_proposer.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.d.ts +415 -666
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +77 -94
- package/dest/l1_tx_utils.d.ts +41 -27
- package/dest/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils.js +285 -262
- package/dest/l1_tx_utils_with_blobs.js +3 -3
- package/dest/queries.js +2 -2
- package/dest/test/chain_monitor.d.ts +3 -1
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +18 -4
- package/dest/test/delayed_tx_utils.js +4 -4
- package/dest/test/tx_delayer.d.ts +2 -2
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +4 -0
- package/dest/test/upgrade_utils.d.ts +4 -4
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +5 -5
- package/dest/types.d.ts +6 -7
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/package.json +4 -6
- package/src/client.ts +38 -2
- package/src/contracts/fee_asset_handler.ts +1 -1
- package/src/contracts/fee_juice.ts +11 -17
- package/src/contracts/forwarder.ts +7 -14
- package/src/contracts/governance.ts +52 -60
- package/src/contracts/governance_proposer.ts +3 -3
- package/src/contracts/registry.ts +18 -14
- package/src/contracts/rollup.ts +6 -8
- package/src/contracts/slashing_proposer.ts +3 -3
- package/src/deploy_l1_contracts.ts +89 -137
- package/src/l1_tx_utils.ts +343 -305
- package/src/l1_tx_utils_with_blobs.ts +3 -3
- package/src/queries.ts +2 -2
- package/src/test/chain_monitor.ts +14 -3
- package/src/test/delayed_tx_utils.ts +4 -4
- package/src/test/tx_delayer.ts +5 -2
- package/src/test/upgrade_utils.ts +9 -10
- package/src/types.ts +10 -8
package/dest/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
-
import type
|
|
2
|
+
import { type Chain, type HDAccount, type LocalAccount, type PrivateKeyAccount } from 'viem';
|
|
3
|
+
import type { ExtendedViemWalletClient, ViemPublicClient } from './types.js';
|
|
3
4
|
type Config = {
|
|
4
5
|
/** The RPC Url of the ethereum host. */
|
|
5
6
|
l1RpcUrls: string[];
|
|
@@ -13,4 +14,5 @@ export type { Config as EthereumClientConfig };
|
|
|
13
14
|
export declare function getPublicClient(config: Config): ViemPublicClient;
|
|
14
15
|
/** Returns a viem public client after waiting for the L1 RPC node to become available. */
|
|
15
16
|
export declare function waitForPublicClient(config: Config, logger?: Logger): Promise<ViemPublicClient>;
|
|
17
|
+
export declare function createExtendedL1Client(rpcUrls: string[], mnemonicOrPrivateKeyOrHdAccount: string | `0x${string}` | HDAccount | PrivateKeyAccount | LocalAccount, chain?: Chain, pollingIntervalMS?: number, addressIndex?: number): ExtendedViemWalletClient;
|
|
16
18
|
//# sourceMappingURL=client.d.ts.map
|
package/dest/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EACL,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAMvB,MAAM,MAAM,CAAC;AAKd,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE7E,KAAK,MAAM,GAAG;IACZ,wCAAwC;IACxC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,YAAY,EAAE,MAAM,IAAI,oBAAoB,EAAE,CAAC;AAI/C,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAOhE;AAED,0FAA0F;AAC1F,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAIpG;AAyBD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EAAE,EACjB,+BAA+B,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,GAAG,SAAS,GAAG,iBAAiB,GAAG,YAAY,EACtG,KAAK,GAAE,KAAe,EACtB,iBAAiB,CAAC,EAAE,MAAM,EAC1B,YAAY,CAAC,EAAE,MAAM,GACpB,wBAAwB,CAgB1B"}
|
package/dest/client.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
|
-
import { createPublicClient, fallback, http } from 'viem';
|
|
2
|
+
import { createPublicClient, createWalletClient, fallback, http, publicActions } from 'viem';
|
|
3
|
+
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
4
|
+
import { foundry } from 'viem/chains';
|
|
3
5
|
import { createEthereumChain } from './chain.js';
|
|
4
6
|
// TODO: Use these methods to abstract the creation of viem clients.
|
|
5
7
|
/** Returns a viem public client given the L1 config. */ export function getPublicClient(config) {
|
|
@@ -29,3 +31,15 @@ async function waitForRpc(client, config, logger) {
|
|
|
29
31
|
throw new Error(`Ethereum node at ${config.l1RpcUrls.join(', ')} has chain ID ${l1ChainId} but expected ${config.l1ChainId}`);
|
|
30
32
|
}
|
|
31
33
|
}
|
|
34
|
+
export function createExtendedL1Client(rpcUrls, mnemonicOrPrivateKeyOrHdAccount, chain = foundry, pollingIntervalMS, addressIndex) {
|
|
35
|
+
const hdAccount = typeof mnemonicOrPrivateKeyOrHdAccount === 'string' ? mnemonicOrPrivateKeyOrHdAccount.startsWith('0x') ? privateKeyToAccount(mnemonicOrPrivateKeyOrHdAccount) : mnemonicToAccount(mnemonicOrPrivateKeyOrHdAccount, {
|
|
36
|
+
addressIndex
|
|
37
|
+
}) : mnemonicOrPrivateKeyOrHdAccount;
|
|
38
|
+
const extendedClient = createWalletClient({
|
|
39
|
+
account: hdAccount,
|
|
40
|
+
chain,
|
|
41
|
+
transport: fallback(rpcUrls.map((url)=>http(url))),
|
|
42
|
+
pollingInterval: pollingIntervalMS
|
|
43
|
+
}).extend(publicActions);
|
|
44
|
+
return extendedClient;
|
|
45
|
+
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import { type Hex } from 'viem';
|
|
3
|
-
import type
|
|
3
|
+
import { type ViemClient } from '../types.js';
|
|
4
4
|
export declare class FeeJuiceContract {
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
|
|
8
|
-
private readonly walletFeeJuice;
|
|
9
|
-
constructor(address: Hex, publicClient: L1Clients['publicClient'], walletClient: L1Clients['walletClient'] | undefined);
|
|
5
|
+
readonly client: ViemClient;
|
|
6
|
+
private readonly feeJuiceContract;
|
|
7
|
+
constructor(address: Hex, client: ViemClient);
|
|
10
8
|
get address(): EthAddress;
|
|
11
9
|
private assertWalletFeeJuice;
|
|
12
10
|
mint(to: Hex, amount: bigint): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee_juice.d.ts","sourceRoot":"","sources":["../../src/contracts/fee_juice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAA8B,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAEzE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"fee_juice.d.ts","sourceRoot":"","sources":["../../src/contracts/fee_juice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAA8B,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAEzE,OAAO,EAAiC,KAAK,UAAU,EAAoB,MAAM,aAAa,CAAC;AAE/F,qBAAa,gBAAgB;aAGe,MAAM,EAAE,UAAU;IAF5D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAwD;gBAE7E,OAAO,EAAE,GAAG,EAAkB,MAAM,EAAE,UAAU;IAI5D,IAAW,OAAO,eAEjB;IAED,OAAO,CAAC,oBAAoB;IAOf,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM;IAW5B,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM;CAUlD"}
|
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import { TestERC20Abi as FeeJuiceAbi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
3
3
|
import { getContract } from 'viem';
|
|
4
|
+
import { isExtendedClient } from '../types.js';
|
|
4
5
|
export class FeeJuiceContract {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.publicClient = publicClient;
|
|
11
|
-
this.walletClient = walletClient;
|
|
12
|
-
this.publicFeeJuice = getContract({
|
|
6
|
+
client;
|
|
7
|
+
feeJuiceContract;
|
|
8
|
+
constructor(address, client){
|
|
9
|
+
this.client = client;
|
|
10
|
+
this.feeJuiceContract = getContract({
|
|
13
11
|
address,
|
|
14
12
|
abi: FeeJuiceAbi,
|
|
15
|
-
client
|
|
13
|
+
client
|
|
16
14
|
});
|
|
17
|
-
this.walletFeeJuice = walletClient ? getContract({
|
|
18
|
-
address,
|
|
19
|
-
abi: FeeJuiceAbi,
|
|
20
|
-
client: walletClient
|
|
21
|
-
}) : undefined;
|
|
22
15
|
}
|
|
23
16
|
get address() {
|
|
24
|
-
return EthAddress.fromString(this.
|
|
17
|
+
return EthAddress.fromString(this.feeJuiceContract.address);
|
|
25
18
|
}
|
|
26
19
|
assertWalletFeeJuice() {
|
|
27
|
-
if (!this.
|
|
20
|
+
if (!isExtendedClient(this.client)) {
|
|
28
21
|
throw new Error('Wallet client is required for this operation');
|
|
29
22
|
}
|
|
30
|
-
return this.
|
|
23
|
+
return this.feeJuiceContract;
|
|
31
24
|
}
|
|
32
25
|
async mint(to, amount) {
|
|
33
26
|
const walletFeeJuice = this.assertWalletFeeJuice();
|
|
@@ -35,7 +28,7 @@ export class FeeJuiceContract {
|
|
|
35
28
|
to,
|
|
36
29
|
amount
|
|
37
30
|
]);
|
|
38
|
-
const receipt = await this.
|
|
31
|
+
const receipt = await this.client.waitForTransactionReceipt({
|
|
39
32
|
hash: tx
|
|
40
33
|
});
|
|
41
34
|
if (receipt.status === 'success') {
|
|
@@ -49,7 +42,7 @@ export class FeeJuiceContract {
|
|
|
49
42
|
spender,
|
|
50
43
|
amount
|
|
51
44
|
]);
|
|
52
|
-
const receipt = await this.
|
|
45
|
+
const receipt = await this.client.waitForTransactionReceipt({
|
|
53
46
|
hash: tx
|
|
54
47
|
});
|
|
55
48
|
if (receipt.status === 'success') {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
2
|
import { type Hex } from 'viem';
|
|
3
3
|
import type { L1BlobInputs, L1GasConfig, L1TxRequest, L1TxUtils } from '../l1_tx_utils.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ExtendedViemWalletClient } from '../types.js';
|
|
5
5
|
export declare class ForwarderContract {
|
|
6
|
-
readonly client:
|
|
6
|
+
readonly client: ExtendedViemWalletClient;
|
|
7
7
|
readonly rollupAddress: Hex;
|
|
8
8
|
private readonly forwarder;
|
|
9
|
-
constructor(client:
|
|
9
|
+
constructor(client: ExtendedViemWalletClient, address: Hex, rollupAddress: Hex);
|
|
10
10
|
static expectedAddress(owner: Hex): `0x${string}`;
|
|
11
|
-
static create(owner: Hex,
|
|
11
|
+
static create(owner: Hex, l1Client: ExtendedViemWalletClient, logger: Logger, rollupAddress: Hex): Promise<ForwarderContract>;
|
|
12
12
|
getAddress(): `0x${string}`;
|
|
13
13
|
forward(requests: L1TxRequest[], l1TxUtils: L1TxUtils, gasConfig: L1GasConfig | undefined, blobConfig: L1BlobInputs | undefined, logger: Logger): Promise<{
|
|
14
14
|
receipt: import("viem").TransactionReceipt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forwarder.d.ts","sourceRoot":"","sources":["../../src/contracts/forwarder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,EAGL,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"forwarder.d.ts","sourceRoot":"","sources":["../../src/contracts/forwarder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,EAGL,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,KAAK,EAAE,wBAAwB,EAAc,MAAM,aAAa,CAAC;AAGxE,qBAAa,iBAAiB;aAGA,MAAM,EAAE,wBAAwB;aAAgC,aAAa,EAAE,GAAG;IAF9G,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyD;gBAEvD,MAAM,EAAE,wBAAwB,EAAE,OAAO,EAAE,GAAG,EAAkB,aAAa,EAAE,GAAG;IAI9G,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG;WAKpB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG;IAsB/F,UAAU;IAIJ,OAAO,CAClB,QAAQ,EAAE,WAAW,EAAE,EACvB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,WAAW,GAAG,SAAS,EAClC,UAAU,EAAE,YAAY,GAAG,SAAS,EACpC,MAAM,EAAE,MAAM;;;;;;;;;;;CAqEjB"}
|
|
@@ -23,18 +23,18 @@ export class ForwarderContract {
|
|
|
23
23
|
], owner);
|
|
24
24
|
return address;
|
|
25
25
|
}
|
|
26
|
-
static async create(owner,
|
|
26
|
+
static async create(owner, l1Client, logger, rollupAddress) {
|
|
27
27
|
logger.info('Deploying forwarder contract');
|
|
28
|
-
const { address, txHash } = await deployL1Contract(
|
|
28
|
+
const { address, txHash } = await deployL1Contract(l1Client, ForwarderAbi, ForwarderBytecode, [
|
|
29
29
|
owner
|
|
30
30
|
], owner, undefined, logger);
|
|
31
31
|
if (txHash) {
|
|
32
|
-
await
|
|
32
|
+
await l1Client.waitForTransactionReceipt({
|
|
33
33
|
hash: txHash
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
logger.info(`Forwarder contract deployed at ${address} with owner ${owner}`);
|
|
37
|
-
return new ForwarderContract(
|
|
37
|
+
return new ForwarderContract(l1Client, address.toString(), rollupAddress);
|
|
38
38
|
}
|
|
39
39
|
getAddress() {
|
|
40
40
|
return this.forwarder.address;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
3
|
+
import { GovernanceAbi } from '@aztec/l1-artifacts/GovernanceAbi';
|
|
4
|
+
import { type GetContractReturnType, type Hex, type Log } from 'viem';
|
|
4
5
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
5
|
-
import type
|
|
6
|
+
import { type ExtendedViemWalletClient, type ViemClient } from '../types.js';
|
|
6
7
|
export type L1GovernanceContractAddresses = Pick<L1ContractAddresses, 'governanceAddress' | 'rollupAddress' | 'registryAddress' | 'governanceProposerAddress'>;
|
|
7
8
|
export declare enum ProposalState {
|
|
8
9
|
Pending = 0,
|
|
@@ -15,12 +16,10 @@ export declare enum ProposalState {
|
|
|
15
16
|
Expired = 7
|
|
16
17
|
}
|
|
17
18
|
export declare function extractProposalIdFromLogs(logs: Log[]): bigint;
|
|
18
|
-
export declare class
|
|
19
|
-
readonly
|
|
20
|
-
readonly
|
|
21
|
-
|
|
22
|
-
private readonly walletGovernance;
|
|
23
|
-
constructor(address: Hex, publicClient: ViemPublicClient, walletClient: ViemWalletClient | undefined);
|
|
19
|
+
export declare class ReadOnlyGovernanceContract {
|
|
20
|
+
readonly client: ViemClient;
|
|
21
|
+
protected readonly governanceContract: GetContractReturnType<typeof GovernanceAbi, ViemClient>;
|
|
22
|
+
constructor(address: Hex, client: ViemClient);
|
|
24
23
|
get address(): EthAddress;
|
|
25
24
|
getGovernanceProposerAddress(): Promise<EthAddress>;
|
|
26
25
|
getConfiguration(): Promise<{
|
|
@@ -60,12 +59,6 @@ export declare class GovernanceContract {
|
|
|
60
59
|
};
|
|
61
60
|
}>;
|
|
62
61
|
getProposalState(proposalId: bigint): Promise<ProposalState>;
|
|
63
|
-
private assertWalletGovernance;
|
|
64
|
-
deposit(onBehalfOf: Hex, amount: bigint): Promise<void>;
|
|
65
|
-
proposeWithLock({ payloadAddress, withdrawAddress, }: {
|
|
66
|
-
payloadAddress: Hex;
|
|
67
|
-
withdrawAddress: Hex;
|
|
68
|
-
}): Promise<bigint>;
|
|
69
62
|
awaitProposalActive({ proposalId, logger }: {
|
|
70
63
|
proposalId: bigint;
|
|
71
64
|
logger: Logger;
|
|
@@ -74,6 +67,16 @@ export declare class GovernanceContract {
|
|
|
74
67
|
proposalId: bigint;
|
|
75
68
|
logger: Logger;
|
|
76
69
|
}): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
export declare class GovernanceContract extends ReadOnlyGovernanceContract {
|
|
72
|
+
readonly client: ExtendedViemWalletClient;
|
|
73
|
+
protected readonly governanceContract: GetContractReturnType<typeof GovernanceAbi, ExtendedViemWalletClient>;
|
|
74
|
+
constructor(address: Hex, client: ExtendedViemWalletClient);
|
|
75
|
+
deposit(onBehalfOf: Hex, amount: bigint): Promise<void>;
|
|
76
|
+
proposeWithLock({ payloadAddress, withdrawAddress, }: {
|
|
77
|
+
payloadAddress: Hex;
|
|
78
|
+
withdrawAddress: Hex;
|
|
79
|
+
}): Promise<bigint>;
|
|
77
80
|
getPower(): Promise<bigint>;
|
|
78
81
|
vote({ proposalId, voteAmount, inFavor, retries, logger, }: {
|
|
79
82
|
proposalId: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../../src/contracts/governance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../../src/contracts/governance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,GAAG,EACR,KAAK,GAAG,EAIT,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,UAAU,EAAoB,MAAM,aAAa,CAAC;AAE/F,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAC9C,mBAAmB,EACnB,mBAAmB,GAAG,eAAe,GAAG,iBAAiB,GAAG,2BAA2B,CACxF,CAAC;AAGF,oBAAY,aAAa;IACvB,OAAO,IAAA;IACP,MAAM,IAAA;IACN,MAAM,IAAA;IACN,UAAU,IAAA;IACV,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,OAAO,IAAA;IACP,OAAO,IAAA;CACR;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAW7D;AAED,qBAAa,0BAA0B;aAGK,MAAM,EAAE,UAAU;IAF5D,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,OAAO,aAAa,EAAE,UAAU,CAAC,CAAC;gBAEnF,OAAO,EAAE,GAAG,EAAkB,MAAM,EAAE,UAAU;IAI5D,IAAW,OAAO,eAEjB;IAEY,4BAA4B;IAIlC,gBAAgB;;;;;;;;;;;;;IAIhB,WAAW,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;IAIxB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ5D,mBAAmB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAsBlF,uBAAuB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CA0BpG;AAED,qBAAa,kBAAmB,SAAQ,0BAA0B;aAGb,MAAM,EAAE,wBAAwB;IAFnF,mBAA4B,kBAAkB,EAAE,qBAAqB,CAAC,OAAO,aAAa,EAAE,wBAAwB,CAAC,CAAC;gBAE1G,OAAO,EAAE,GAAG,EAA2B,MAAM,EAAE,wBAAwB;IAQtE,OAAO,CAAC,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM;IAKvC,eAAe,CAAC,EAC3B,cAAc,EACd,eAAe,GAChB,EAAE;QACD,cAAc,EAAE,GAAG,CAAC;QACpB,eAAe,EAAE,GAAG,CAAC;KACtB,GAAG,OAAO,CAAC,MAAM,CAAC;IASN,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAK3B,IAAI,CAAC,EAChB,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAY,EACZ,MAAM,GACP,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB;IAiDY,eAAe,CAAC,EAC3B,UAAU,EACV,OAAY,EACZ,MAAM,GACP,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB;CA0CF"}
|
|
@@ -3,6 +3,7 @@ import { sleep } from '@aztec/foundation/sleep';
|
|
|
3
3
|
import { GovernanceAbi } from '@aztec/l1-artifacts/GovernanceAbi';
|
|
4
4
|
import { encodeFunctionData, getContract, parseEventLogs } from 'viem';
|
|
5
5
|
import { L1TxUtils } from '../l1_tx_utils.js';
|
|
6
|
+
import { isExtendedClient } from '../types.js';
|
|
6
7
|
// NOTE: Must be kept in sync with DataStructures.ProposalState in l1-contracts
|
|
7
8
|
export var ProposalState = /*#__PURE__*/ function(ProposalState) {
|
|
8
9
|
ProposalState[ProposalState["Pending"] = 0] = "Pending";
|
|
@@ -26,41 +27,33 @@ export function extractProposalIdFromLogs(logs) {
|
|
|
26
27
|
}
|
|
27
28
|
return parsedLogs[0].args.proposalId;
|
|
28
29
|
}
|
|
29
|
-
export class
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.publicClient = publicClient;
|
|
36
|
-
this.walletClient = walletClient;
|
|
37
|
-
this.publicGovernance = getContract({
|
|
30
|
+
export class ReadOnlyGovernanceContract {
|
|
31
|
+
client;
|
|
32
|
+
governanceContract;
|
|
33
|
+
constructor(address, client){
|
|
34
|
+
this.client = client;
|
|
35
|
+
this.governanceContract = getContract({
|
|
38
36
|
address,
|
|
39
37
|
abi: GovernanceAbi,
|
|
40
|
-
client:
|
|
38
|
+
client: client
|
|
41
39
|
});
|
|
42
|
-
this.walletGovernance = walletClient ? getContract({
|
|
43
|
-
address,
|
|
44
|
-
abi: GovernanceAbi,
|
|
45
|
-
client: walletClient
|
|
46
|
-
}) : undefined;
|
|
47
40
|
}
|
|
48
41
|
get address() {
|
|
49
|
-
return EthAddress.fromString(this.
|
|
42
|
+
return EthAddress.fromString(this.governanceContract.address);
|
|
50
43
|
}
|
|
51
44
|
async getGovernanceProposerAddress() {
|
|
52
|
-
return EthAddress.fromString(await this.
|
|
45
|
+
return EthAddress.fromString(await this.governanceContract.read.governanceProposer());
|
|
53
46
|
}
|
|
54
47
|
getConfiguration() {
|
|
55
|
-
return this.
|
|
48
|
+
return this.governanceContract.read.getConfiguration();
|
|
56
49
|
}
|
|
57
50
|
getProposal(proposalId) {
|
|
58
|
-
return this.
|
|
51
|
+
return this.governanceContract.read.getProposal([
|
|
59
52
|
proposalId
|
|
60
53
|
]);
|
|
61
54
|
}
|
|
62
55
|
async getProposalState(proposalId) {
|
|
63
|
-
const state = await this.
|
|
56
|
+
const state = await this.governanceContract.read.getProposalState([
|
|
64
57
|
proposalId
|
|
65
58
|
]);
|
|
66
59
|
if (state < 0 || state > 7) {
|
|
@@ -68,36 +61,6 @@ export class GovernanceContract {
|
|
|
68
61
|
}
|
|
69
62
|
return state;
|
|
70
63
|
}
|
|
71
|
-
assertWalletGovernance() {
|
|
72
|
-
if (!this.walletGovernance) {
|
|
73
|
-
throw new Error('Wallet client is required for this operation');
|
|
74
|
-
}
|
|
75
|
-
return this.walletGovernance;
|
|
76
|
-
}
|
|
77
|
-
async deposit(onBehalfOf, amount) {
|
|
78
|
-
const walletGovernance = this.assertWalletGovernance();
|
|
79
|
-
const depositTx = await walletGovernance.write.deposit([
|
|
80
|
-
onBehalfOf,
|
|
81
|
-
amount
|
|
82
|
-
]);
|
|
83
|
-
await this.publicClient.waitForTransactionReceipt({
|
|
84
|
-
hash: depositTx
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
async proposeWithLock({ payloadAddress, withdrawAddress }) {
|
|
88
|
-
const walletGovernance = this.assertWalletGovernance();
|
|
89
|
-
const proposeTx = await walletGovernance.write.proposeWithLock([
|
|
90
|
-
payloadAddress,
|
|
91
|
-
withdrawAddress
|
|
92
|
-
]);
|
|
93
|
-
const receipt = await this.publicClient.waitForTransactionReceipt({
|
|
94
|
-
hash: proposeTx
|
|
95
|
-
});
|
|
96
|
-
if (receipt.status !== 'success') {
|
|
97
|
-
throw new Error(`Proposal failed: ${receipt.status}`);
|
|
98
|
-
}
|
|
99
|
-
return extractProposalIdFromLogs(receipt.logs);
|
|
100
|
-
}
|
|
101
64
|
async awaitProposalActive({ proposalId, logger }) {
|
|
102
65
|
const state = await this.getProposalState(proposalId);
|
|
103
66
|
if (state === 1) {
|
|
@@ -107,7 +70,7 @@ export class GovernanceContract {
|
|
|
107
70
|
} else {
|
|
108
71
|
const proposal = await this.getProposal(proposalId);
|
|
109
72
|
const startOfActive = proposal.creation + proposal.config.votingDelay;
|
|
110
|
-
const block = await this.
|
|
73
|
+
const block = await this.client.getBlock();
|
|
111
74
|
// Add 12 seconds to the time to make sure we don't vote too early
|
|
112
75
|
const secondsToActive = Number(startOfActive - block.timestamp) + 12;
|
|
113
76
|
const now = new Date();
|
|
@@ -133,7 +96,7 @@ export class GovernanceContract {
|
|
|
133
96
|
} else {
|
|
134
97
|
const proposal = await this.getProposal(proposalId);
|
|
135
98
|
const startOfExecutable = proposal.creation + proposal.config.votingDelay + proposal.config.votingDuration + proposal.config.executionDelay;
|
|
136
|
-
const block = await this.
|
|
99
|
+
const block = await this.client.getBlock();
|
|
137
100
|
const secondsToExecutable = Number(startOfExecutable - block.timestamp) + 12;
|
|
138
101
|
const now = new Date();
|
|
139
102
|
logger.info(`
|
|
@@ -144,17 +107,52 @@ export class GovernanceContract {
|
|
|
144
107
|
await sleep(secondsToExecutable * 1000);
|
|
145
108
|
}
|
|
146
109
|
}
|
|
110
|
+
}
|
|
111
|
+
export class GovernanceContract extends ReadOnlyGovernanceContract {
|
|
112
|
+
client;
|
|
113
|
+
governanceContract;
|
|
114
|
+
constructor(address, client){
|
|
115
|
+
super(address, client), this.client = client;
|
|
116
|
+
if (!isExtendedClient(client)) {
|
|
117
|
+
throw new Error('GovernanceContract has to be instantiated with a wallet client.');
|
|
118
|
+
}
|
|
119
|
+
this.governanceContract = getContract({
|
|
120
|
+
address,
|
|
121
|
+
abi: GovernanceAbi,
|
|
122
|
+
client
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
async deposit(onBehalfOf, amount) {
|
|
126
|
+
const depositTx = await this.governanceContract.write.deposit([
|
|
127
|
+
onBehalfOf,
|
|
128
|
+
amount
|
|
129
|
+
]);
|
|
130
|
+
await this.client.waitForTransactionReceipt({
|
|
131
|
+
hash: depositTx
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async proposeWithLock({ payloadAddress, withdrawAddress }) {
|
|
135
|
+
const proposeTx = await this.governanceContract.write.proposeWithLock([
|
|
136
|
+
payloadAddress,
|
|
137
|
+
withdrawAddress
|
|
138
|
+
]);
|
|
139
|
+
const receipt = await this.client.waitForTransactionReceipt({
|
|
140
|
+
hash: proposeTx
|
|
141
|
+
});
|
|
142
|
+
if (receipt.status !== 'success') {
|
|
143
|
+
throw new Error(`Proposal failed: ${receipt.status}`);
|
|
144
|
+
}
|
|
145
|
+
return extractProposalIdFromLogs(receipt.logs);
|
|
146
|
+
}
|
|
147
147
|
async getPower() {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.walletClient.account.address,
|
|
148
|
+
const now = await this.client.getBlock();
|
|
149
|
+
return this.governanceContract.read.powerAt([
|
|
150
|
+
this.client.account.address,
|
|
152
151
|
now.timestamp
|
|
153
152
|
]);
|
|
154
153
|
}
|
|
155
154
|
async vote({ proposalId, voteAmount, inFavor, retries = 10, logger }) {
|
|
156
|
-
const
|
|
157
|
-
const l1TxUtils = new L1TxUtils(this.publicClient, this.walletClient, logger);
|
|
155
|
+
const l1TxUtils = new L1TxUtils(this.client, logger);
|
|
158
156
|
const retryDelaySeconds = 12;
|
|
159
157
|
voteAmount = voteAmount ?? await this.getPower();
|
|
160
158
|
let success = false;
|
|
@@ -171,7 +169,7 @@ export class GovernanceContract {
|
|
|
171
169
|
};
|
|
172
170
|
const encodedVoteData = encodeFunctionData(voteFunctionData);
|
|
173
171
|
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
174
|
-
to:
|
|
172
|
+
to: this.governanceContract.address,
|
|
175
173
|
data: encodedVoteData
|
|
176
174
|
});
|
|
177
175
|
if (receipt.status === 'success') {
|
|
@@ -180,7 +178,7 @@ export class GovernanceContract {
|
|
|
180
178
|
} else {
|
|
181
179
|
const args = {
|
|
182
180
|
...voteFunctionData,
|
|
183
|
-
address:
|
|
181
|
+
address: this.governanceContract.address
|
|
184
182
|
};
|
|
185
183
|
const errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(encodedVoteData, args, undefined, []);
|
|
186
184
|
logger.error(`Error voting on proposal ${proposalId}: ${errorMsg}`);
|
|
@@ -201,8 +199,7 @@ export class GovernanceContract {
|
|
|
201
199
|
logger.info(`Proposal [${proposalId}] has summedBallot nea [${proposal.summedBallot.nea}]`);
|
|
202
200
|
}
|
|
203
201
|
async executeProposal({ proposalId, retries = 10, logger }) {
|
|
204
|
-
const
|
|
205
|
-
const l1TxUtils = new L1TxUtils(this.publicClient, this.walletClient, logger);
|
|
202
|
+
const l1TxUtils = new L1TxUtils(this.client, logger);
|
|
206
203
|
const retryDelaySeconds = 12;
|
|
207
204
|
let success = false;
|
|
208
205
|
for(let i = 0; i < retries; i++){
|
|
@@ -216,7 +213,7 @@ export class GovernanceContract {
|
|
|
216
213
|
};
|
|
217
214
|
const encodedExecuteData = encodeFunctionData(executeFunctionData);
|
|
218
215
|
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
219
|
-
to:
|
|
216
|
+
to: this.governanceContract.address,
|
|
220
217
|
data: encodedExecuteData
|
|
221
218
|
});
|
|
222
219
|
if (receipt.status === 'success') {
|
|
@@ -225,7 +222,7 @@ export class GovernanceContract {
|
|
|
225
222
|
} else {
|
|
226
223
|
const args = {
|
|
227
224
|
...executeFunctionData,
|
|
228
|
-
address:
|
|
225
|
+
address: this.governanceContract.address
|
|
229
226
|
};
|
|
230
227
|
const errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(encodedExecuteData, args, undefined, []);
|
|
231
228
|
logger.error(`Error executing proposal ${proposalId}: ${errorMsg}`);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import { type Hex, type TransactionReceipt } from 'viem';
|
|
3
3
|
import type { GasPrice, L1TxRequest, L1TxUtils } from '../l1_tx_utils.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ViemClient } from '../types.js';
|
|
5
5
|
import { type IEmpireBase } from './empire_base.js';
|
|
6
6
|
export declare class GovernanceProposerContract implements IEmpireBase {
|
|
7
|
-
readonly client:
|
|
7
|
+
readonly client: ViemClient;
|
|
8
8
|
private readonly proposer;
|
|
9
|
-
constructor(client:
|
|
9
|
+
constructor(client: ViemClient, address: Hex);
|
|
10
10
|
get address(): EthAddress;
|
|
11
11
|
getRollupAddress(): Promise<EthAddress>;
|
|
12
12
|
getRegistryAddress(): Promise<EthAddress>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"governance_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/governance_proposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAA8B,KAAK,GAAG,EAAE,KAAK,kBAAkB,EAAmC,MAAM,MAAM,CAAC;AAEtH,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"governance_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/governance_proposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAA8B,KAAK,GAAG,EAAE,KAAK,kBAAkB,EAAmC,MAAM,MAAM,CAAC;AAEtH,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,KAAK,WAAW,EAAc,MAAM,kBAAkB,CAAC;AAGhE,qBAAa,0BAA2B,YAAW,WAAW;aAGhC,MAAM,EAAE,UAAU;IAF9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkE;gBAE/D,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG;IAI5D,IAAW,OAAO,eAEjB;IAEY,gBAAgB;IAKhB,kBAAkB;IAIxB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhC,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrC,YAAY,CACvB,aAAa,EAAE,GAAG,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IASzD,gBAAgB,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAInF,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW;IAOtC,eAAe,CAC1B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;QACT,OAAO,EAAE,kBAAkB,CAAC;QAC5B,QAAQ,EAAE,QAAQ,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CAYH"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import { type Hex } from 'viem';
|
|
3
3
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ViemClient } from '../types.js';
|
|
5
5
|
export declare class RegistryContract {
|
|
6
|
-
readonly client:
|
|
6
|
+
readonly client: ViemClient;
|
|
7
7
|
address: EthAddress;
|
|
8
|
+
private readonly log;
|
|
8
9
|
private readonly registry;
|
|
9
|
-
constructor(client:
|
|
10
|
+
constructor(client: ViemClient, address: Hex | EthAddress);
|
|
10
11
|
/**
|
|
11
12
|
* Returns the address of the rollup for a given version.
|
|
12
13
|
* @param version - The version of the rollup. 'canonical' can be used to get the canonical address (i.e. the latest version).
|
|
@@ -19,7 +20,7 @@ export declare class RegistryContract {
|
|
|
19
20
|
*/
|
|
20
21
|
getCanonicalAddress(): Promise<EthAddress>;
|
|
21
22
|
getGovernanceAddresses(): Promise<Pick<L1ContractAddresses, 'governanceProposerAddress' | 'governanceAddress'>>;
|
|
22
|
-
static collectAddresses(client:
|
|
23
|
+
static collectAddresses(client: ViemClient, registryAddress: Hex | EthAddress, rollupVersion: number | bigint | 'canonical'): Promise<L1ContractAddresses>;
|
|
23
24
|
getNumberOfVersions(): Promise<number>;
|
|
24
25
|
getRollupVersions(): Promise<bigint[]>;
|
|
25
26
|
getRewardDistributor(): Promise<EthAddress>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/contracts/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/contracts/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAK3D,OAAO,EAA8B,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,qBAAa,gBAAgB;aAMC,MAAM,EAAE,UAAU;IALvC,OAAO,EAAE,UAAU,CAAC;IAE3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA+C;IACnE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwD;gBAErD,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,GAAG,UAAU;IAQzE;;;;OAIG;IACU,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAwB1F;;;OAGG;IACU,mBAAmB,IAAI,OAAO,CAAC,UAAU,CAAC;IAI1C,sBAAsB,IAAI,OAAO,CAC5C,IAAI,CAAC,mBAAmB,EAAE,2BAA2B,GAAG,mBAAmB,CAAC,CAC7E;WAUmB,gBAAgB,CAClC,MAAM,EAAE,UAAU,EAClB,eAAe,EAAE,GAAG,GAAG,UAAU,EACjC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,GAC3C,OAAO,CAAC,mBAAmB,CAAC;IAyBlB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKtC,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAWtC,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC;CAGzD"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { RegistryAbi } from '@aztec/l1-artifacts/RegistryAbi';
|
|
3
4
|
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
4
5
|
import { getContract } from 'viem';
|
|
5
|
-
import {
|
|
6
|
+
import { ReadOnlyGovernanceContract } from './governance.js';
|
|
6
7
|
import { RollupContract } from './rollup.js';
|
|
7
8
|
export class RegistryContract {
|
|
8
9
|
client;
|
|
9
10
|
address;
|
|
11
|
+
log;
|
|
10
12
|
registry;
|
|
11
13
|
constructor(client, address){
|
|
12
14
|
this.client = client;
|
|
15
|
+
this.log = createLogger('ethereum:contracts:registry');
|
|
13
16
|
if (address instanceof EthAddress) {
|
|
14
17
|
address = address.toString();
|
|
15
18
|
}
|
|
@@ -35,6 +38,17 @@ export class RegistryContract {
|
|
|
35
38
|
return EthAddress.fromString(await this.registry.read.getRollup([
|
|
36
39
|
version
|
|
37
40
|
]));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
this.log.warn(`Failed fetching rollup address for version ${version}. Retrying as index.`);
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const actualVersion = await this.registry.read.getVersion([
|
|
46
|
+
version
|
|
47
|
+
]);
|
|
48
|
+
const rollupAddress = await this.registry.read.getRollup([
|
|
49
|
+
actualVersion
|
|
50
|
+
]);
|
|
51
|
+
return EthAddress.fromString(rollupAddress);
|
|
38
52
|
} catch (e) {
|
|
39
53
|
throw new Error('Rollup address is undefined');
|
|
40
54
|
}
|
|
@@ -47,7 +61,7 @@ export class RegistryContract {
|
|
|
47
61
|
}
|
|
48
62
|
async getGovernanceAddresses() {
|
|
49
63
|
const governanceAddress = await this.registry.read.getGovernance();
|
|
50
|
-
const governance = new
|
|
64
|
+
const governance = new ReadOnlyGovernanceContract(governanceAddress, this.client);
|
|
51
65
|
const governanceProposerAddress = await governance.getGovernanceProposerAddress();
|
|
52
66
|
return {
|
|
53
67
|
governanceAddress: governance.address,
|
|
@@ -7,27 +7,25 @@ import { type Account, type GetContractReturnType, type Hex } from 'viem';
|
|
|
7
7
|
import type { DeployL1ContractsReturnType } from '../deploy_l1_contracts.js';
|
|
8
8
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
9
9
|
import type { L1ReaderConfig } from '../l1_reader.js';
|
|
10
|
-
import type {
|
|
10
|
+
import type { ViemClient } from '../types.js';
|
|
11
11
|
import { SlashingProposerContract } from './slashing_proposer.js';
|
|
12
12
|
export type L1RollupContractAddresses = Pick<L1ContractAddresses, 'rollupAddress' | 'inboxAddress' | 'outboxAddress' | 'feeJuicePortalAddress' | 'feeJuiceAddress' | 'stakingAssetAddress' | 'rewardDistributorAddress' | 'slashFactoryAddress'>;
|
|
13
13
|
export type EpochProofPublicInputArgs = {
|
|
14
14
|
previousArchive: `0x${string}`;
|
|
15
15
|
endArchive: `0x${string}`;
|
|
16
|
-
previousBlockHash: `0x${string}`;
|
|
17
|
-
endBlockHash: `0x${string}`;
|
|
18
16
|
endTimestamp: bigint;
|
|
19
17
|
outHash: `0x${string}`;
|
|
20
18
|
proverId: `0x${string}`;
|
|
21
19
|
};
|
|
22
20
|
export declare class RollupContract {
|
|
23
|
-
readonly client:
|
|
21
|
+
readonly client: ViemClient;
|
|
24
22
|
private readonly rollup;
|
|
25
23
|
static get checkBlobStorageSlot(): bigint;
|
|
26
24
|
static getFromL1ContractsValues(deployL1ContractsValues: DeployL1ContractsReturnType): RollupContract;
|
|
27
25
|
static getFromConfig(config: L1ReaderConfig): RollupContract;
|
|
28
|
-
constructor(client:
|
|
26
|
+
constructor(client: ViemClient, address: Hex | EthAddress);
|
|
29
27
|
get address(): `0x${string}`;
|
|
30
|
-
getContract(): GetContractReturnType<typeof RollupAbi,
|
|
28
|
+
getContract(): GetContractReturnType<typeof RollupAbi, ViemClient>;
|
|
31
29
|
getSlashingProposer(): Promise<SlashingProposerContract>;
|
|
32
30
|
getL1StartBlock(): Promise<bigint>;
|
|
33
31
|
getL1GenesisTime(): Promise<bigint>;
|
|
@@ -57,7 +55,6 @@ export declare class RollupContract {
|
|
|
57
55
|
getEpochCommittee(epoch: bigint): Promise<readonly `0x${string}`[]>;
|
|
58
56
|
getBlock(blockNumber: bigint): Promise<{
|
|
59
57
|
archive: `0x${string}`;
|
|
60
|
-
blockHash: `0x${string}`;
|
|
61
58
|
slotNumber: bigint;
|
|
62
59
|
}>;
|
|
63
60
|
getTips(): Promise<{
|