@aztec/ethereum 0.0.1-commit.f295ac2 → 0.0.1-commit.f2ce05ee
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 +3 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +6 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +13 -15
- package/dest/contracts/fee_asset_handler.d.ts +1 -1
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +2 -0
- package/dest/contracts/governance.d.ts +3 -1
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +11 -1
- package/dest/contracts/governance_proposer.d.ts +1 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +4 -1
- package/dest/contracts/multicall.d.ts +1 -1
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +2 -1
- package/dest/contracts/rollup.d.ts +4 -3
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +12 -6
- package/dest/contracts/tally_slashing_proposer.d.ts +1 -1
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +8 -1
- package/dest/deploy_aztec_l1_contracts.d.ts +3 -1
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +7 -5
- package/dest/generated/l1-contracts-defaults.d.ts +2 -1
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -1
- package/dest/generated/l1-contracts-defaults.js +1 -0
- package/dest/l1_artifacts.d.ts +846 -50
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_tx_utils/constants.d.ts +1 -1
- package/dest/l1_tx_utils/constants.js +2 -2
- package/dest/l1_tx_utils/l1_tx_utils.js +6 -6
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +3 -3
- package/dest/publisher_manager.d.ts +3 -2
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +2 -2
- package/dest/queries.d.ts +1 -1
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +2 -1
- package/dest/test/rollup_cheat_codes.d.ts +4 -2
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +10 -1
- package/dest/test/start_anvil.js +1 -1
- package/dest/utils.d.ts +2 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +46 -0
- package/package.json +5 -5
- package/src/config.ts +8 -1
- package/src/contracts/empire_slashing_proposer.ts +16 -27
- package/src/contracts/fee_asset_handler.ts +2 -0
- package/src/contracts/governance.ts +10 -1
- package/src/contracts/governance_proposer.ts +4 -1
- package/src/contracts/multicall.ts +5 -2
- package/src/contracts/rollup.ts +19 -11
- package/src/contracts/tally_slashing_proposer.ts +5 -1
- package/src/deploy_aztec_l1_contracts.ts +7 -2
- package/src/generated/l1-contracts-defaults.ts +1 -0
- package/src/l1_tx_utils/constants.ts +2 -2
- package/src/l1_tx_utils/l1_tx_utils.ts +6 -6
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +3 -3
- package/src/publisher_manager.ts +4 -2
- package/src/queries.ts +1 -0
- package/src/test/rollup_cheat_codes.ts +11 -2
- package/src/test/start_anvil.ts +1 -1
- package/src/utils.ts +53 -0
|
@@ -56,6 +56,15 @@ export class RollupCheatCodes {
|
|
|
56
56
|
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([ts]));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */
|
|
60
|
+
public async getSecondsUntilSlot(slot: SlotNumber): Promise<number> {
|
|
61
|
+
const [currentTimestamp, targetTimestamp] = await Promise.all([
|
|
62
|
+
this.client.getBlock().then(b => BigInt(b.timestamp)),
|
|
63
|
+
this.rollup.read.getTimestampForSlot([BigInt(slot)]),
|
|
64
|
+
]);
|
|
65
|
+
return Math.max(0, Number(targetTimestamp - currentTimestamp));
|
|
66
|
+
}
|
|
67
|
+
|
|
59
68
|
/** Returns the current epoch */
|
|
60
69
|
public async getEpoch(): Promise<EpochNumber> {
|
|
61
70
|
const slotNumber = await this.getSlot();
|
|
@@ -124,7 +133,7 @@ export class RollupCheatCodes {
|
|
|
124
133
|
} = {},
|
|
125
134
|
) {
|
|
126
135
|
const { epochDuration: slotsInEpoch } = await this.getConfig();
|
|
127
|
-
const slotNumber = SlotNumber(epoch * Number(slotsInEpoch));
|
|
136
|
+
const slotNumber = SlotNumber(Number(epoch) * Number(slotsInEpoch));
|
|
128
137
|
const timestamp = (await this.rollup.read.getTimestampForSlot([BigInt(slotNumber)])) + BigInt(opts.offset ?? 0);
|
|
129
138
|
try {
|
|
130
139
|
await this.ethCheatCodes.warp(Number(timestamp), { ...opts, silent: true, resetBlockInterval: true });
|
|
@@ -176,7 +185,7 @@ export class RollupCheatCodes {
|
|
|
176
185
|
* Marks the specified checkpoint (or latest if none) as proven
|
|
177
186
|
* @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
|
|
178
187
|
*/
|
|
179
|
-
public markAsProven(maybeCheckpointNumber?:
|
|
188
|
+
public markAsProven(maybeCheckpointNumber?: CheckpointNumber) {
|
|
180
189
|
return this.ethCheatCodes.execWithPausedAnvil(async () => {
|
|
181
190
|
const tipsBefore = await this.getTips();
|
|
182
191
|
const { pending, proven } = tipsBefore;
|
package/src/test/start_anvil.ts
CHANGED
|
@@ -33,7 +33,7 @@ export async function startAnvil(
|
|
|
33
33
|
const anvil = createAnvil({
|
|
34
34
|
anvilBinary,
|
|
35
35
|
host: '127.0.0.1',
|
|
36
|
-
port: opts.port ?? 8545,
|
|
36
|
+
port: opts.port ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : 8545),
|
|
37
37
|
blockTime: opts.l1BlockTime,
|
|
38
38
|
stopTimeout: 1000,
|
|
39
39
|
accounts: opts.accounts ?? 20,
|
package/src/utils.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ErrorsAbi } from '@aztec/l1-artifacts/ErrorsAbi';
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
type Abi,
|
|
7
|
+
type AbiItem,
|
|
7
8
|
BaseError,
|
|
8
9
|
type ContractEventName,
|
|
9
10
|
ContractFunctionRevertedError,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
decodeErrorResult,
|
|
15
16
|
decodeEventLog,
|
|
16
17
|
} from 'viem';
|
|
18
|
+
import { formatAbiItem, formatAbiParams } from 'viem/utils';
|
|
17
19
|
|
|
18
20
|
export interface L2Claim {
|
|
19
21
|
claimSecret: Fr;
|
|
@@ -93,6 +95,57 @@ export function prettyLogViemErrorMsg(err: any) {
|
|
|
93
95
|
return err?.message ?? err;
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
export function mergeAbis(abis: Abi[]): Abi {
|
|
99
|
+
let merged: Abi = [];
|
|
100
|
+
const seen = new Set<string>();
|
|
101
|
+
|
|
102
|
+
for (const abi of abis) {
|
|
103
|
+
for (const item of abi) {
|
|
104
|
+
const key = getAbiItemKey(item);
|
|
105
|
+
if (!seen.has(key)) {
|
|
106
|
+
seen.add(key);
|
|
107
|
+
merged = [...merged, item];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return merged;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function getAbiItemKey(item: AbiItem): string {
|
|
116
|
+
if (item.type === 'function') {
|
|
117
|
+
const signature = formatAbiItem(item);
|
|
118
|
+
const outputs = formatAbiParams(item.outputs);
|
|
119
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
120
|
+
return `function:${signature}:${outputs}:${stateMutability}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (item.type === 'event') {
|
|
124
|
+
const signature = formatAbiItem(item);
|
|
125
|
+
const indexed = (item.inputs ?? []).map(input => ((input as { indexed?: boolean }).indexed ? '1' : '0')).join('');
|
|
126
|
+
const anonymous = item.anonymous ? 'anonymous' : 'not-anonymous';
|
|
127
|
+
return `event:${signature}:${indexed}:${anonymous}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (item.type === 'error') {
|
|
131
|
+
const signature = formatAbiItem(item);
|
|
132
|
+
return `error:${signature}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (item.type === 'constructor') {
|
|
136
|
+
const inputs = formatAbiParams(item.inputs);
|
|
137
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
138
|
+
return `constructor::${inputs}:${stateMutability}`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (item.type === 'fallback' || item.type === 'receive') {
|
|
142
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
143
|
+
return `${item.type}:::${stateMutability}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return 'unknown';
|
|
147
|
+
}
|
|
148
|
+
|
|
96
149
|
function getNestedErrorData(error: unknown): string | undefined {
|
|
97
150
|
// If nothing, bail
|
|
98
151
|
if (!error) {
|