@aztec/ethereum 0.0.1-commit.fcb71a6 → 0.0.1-commit.fffb133c
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/config.d.ts +15 -28
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +46 -55
- package/dest/contracts/fee_asset_handler.d.ts +6 -5
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +9 -9
- package/dest/contracts/governance.d.ts +3 -1
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +9 -1
- package/dest/contracts/governance_proposer.js +382 -8
- package/dest/contracts/inbox.d.ts +18 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +32 -1
- package/dest/contracts/index.d.ts +3 -1
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +2 -0
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.js +1 -0
- package/dest/contracts/outbox.d.ts +41 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +86 -0
- package/dest/contracts/rollup.d.ts +160 -96
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +668 -129
- package/dest/deploy_aztec_l1_contracts.d.ts +15 -2
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +74 -12
- package/dest/generated/l1-contracts-defaults.d.ts +30 -0
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
- package/dest/generated/l1-contracts-defaults.js +30 -0
- package/dest/l1_artifacts.d.ts +4866 -1513
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +3 -2
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/index.js +2 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +2 -12
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +35 -17
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +2 -11
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +36 -18
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +14 -27
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/types.js +0 -21
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +2 -2
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.js +3 -3
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -5
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +14 -51
- package/dest/queries.d.ts +2 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +6 -3
- package/dest/test/chain_monitor.js +1 -2
- package/dest/test/eth_cheat_codes.d.ts +13 -1
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.d.ts +3 -2
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +10 -2
- package/package.json +8 -7
- package/src/config.ts +55 -54
- package/src/contracts/README.md +157 -0
- package/src/contracts/fee_asset_handler.ts +8 -7
- package/src/contracts/governance.ts +8 -1
- package/src/contracts/inbox.ts +48 -1
- package/src/contracts/index.ts +2 -0
- package/src/contracts/log.ts +13 -0
- package/src/contracts/outbox.ts +98 -0
- package/src/contracts/rollup.ts +333 -93
- package/src/deploy_aztec_l1_contracts.ts +76 -14
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_tx_utils/fee-strategies/index.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +45 -41
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +48 -44
- package/src/l1_tx_utils/fee-strategies/types.ts +14 -46
- package/src/l1_tx_utils/l1_fee_analyzer.ts +2 -3
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +20 -59
- package/src/queries.ts +5 -3
- package/src/test/chain_monitor.ts +1 -1
- package/src/test/rollup_cheat_codes.ts +12 -3
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { OutboxAbi } from '@aztec/l1-artifacts/OutboxAbi';
|
|
4
|
+
|
|
5
|
+
import { type GetContractReturnType, type Hex, encodeAbiParameters, getContract, hexToBigInt, keccak256 } from 'viem';
|
|
6
|
+
|
|
7
|
+
import { getPublicClient } from '../client.js';
|
|
8
|
+
import type { DeployAztecL1ContractsReturnType } from '../deploy_aztec_l1_contracts.js';
|
|
9
|
+
import type { L1ReaderConfig } from '../l1_reader.js';
|
|
10
|
+
import { type ExtendedViemWalletClient, type ViemClient, isExtendedClient } from '../types.js';
|
|
11
|
+
|
|
12
|
+
export type ViemL1Actor = {
|
|
13
|
+
actor: Hex;
|
|
14
|
+
chainId: bigint;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ViemL2Actor = {
|
|
18
|
+
actor: Hex;
|
|
19
|
+
version: bigint;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ViemL2ToL1Msg = {
|
|
23
|
+
sender: ViemL2Actor;
|
|
24
|
+
recipient: ViemL1Actor;
|
|
25
|
+
content: Hex;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export class OutboxContract {
|
|
29
|
+
private readonly outbox: GetContractReturnType<typeof OutboxAbi, ViemClient>;
|
|
30
|
+
|
|
31
|
+
static getFromL1ContractsValues(deployL1ContractsValues: DeployAztecL1ContractsReturnType) {
|
|
32
|
+
const {
|
|
33
|
+
l1Client,
|
|
34
|
+
l1ContractAddresses: { outboxAddress },
|
|
35
|
+
} = deployL1ContractsValues;
|
|
36
|
+
return new OutboxContract(l1Client, outboxAddress.toString());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static getFromConfig(config: L1ReaderConfig) {
|
|
40
|
+
const client = getPublicClient(config);
|
|
41
|
+
const address = config.l1Contracts.outboxAddress.toString();
|
|
42
|
+
return new OutboxContract(client, address);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static getEpochRootStorageSlot(epoch: EpochNumber) {
|
|
46
|
+
return hexToBigInt(keccak256(encodeAbiParameters([{ type: 'uint256' }, { type: 'uint256' }], [BigInt(epoch), 0n])));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
constructor(
|
|
50
|
+
public readonly client: ViemClient,
|
|
51
|
+
address: Hex | EthAddress,
|
|
52
|
+
) {
|
|
53
|
+
if (address instanceof EthAddress) {
|
|
54
|
+
address = address.toString();
|
|
55
|
+
}
|
|
56
|
+
this.outbox = getContract({ address, abi: OutboxAbi, client });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public get address() {
|
|
60
|
+
return this.outbox.address;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public getContract(): GetContractReturnType<typeof OutboxAbi, ViemClient> {
|
|
64
|
+
return this.outbox;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public hasMessageBeenConsumedAtEpoch(epoch: EpochNumber, leafId: bigint) {
|
|
68
|
+
return this.outbox.read.hasMessageBeenConsumedAtEpoch([BigInt(epoch), leafId]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public getRootData(epoch: EpochNumber) {
|
|
72
|
+
return this.outbox.read.getRootData([BigInt(epoch)]);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public consume(message: ViemL2ToL1Msg, epoch: EpochNumber, leafIndex: bigint, path: Hex[]) {
|
|
76
|
+
const wallet = this.assertWallet();
|
|
77
|
+
return wallet.write.consume([message, BigInt(epoch), leafIndex, path]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public async getMessageConsumedEvents(
|
|
81
|
+
l1BlockHash: Hex,
|
|
82
|
+
): Promise<{ epoch: bigint; root: Hex; messageHash: Hex; leafId: bigint }[]> {
|
|
83
|
+
const events = await this.outbox.getEvents.MessageConsumed({}, { blockHash: l1BlockHash, strict: true });
|
|
84
|
+
return events.map(event => ({
|
|
85
|
+
epoch: event.args.epoch!,
|
|
86
|
+
root: event.args.root!,
|
|
87
|
+
messageHash: event.args.messageHash!,
|
|
88
|
+
leafId: event.args.leafId!,
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private assertWallet(): GetContractReturnType<typeof OutboxAbi, ExtendedViemWalletClient> {
|
|
93
|
+
if (!isExtendedClient(this.client)) {
|
|
94
|
+
throw new Error('Wallet client is required for this operation');
|
|
95
|
+
}
|
|
96
|
+
return this.outbox as GetContractReturnType<typeof OutboxAbi, ExtendedViemWalletClient>;
|
|
97
|
+
}
|
|
98
|
+
}
|