@aztec/aztec.js 1.0.0-nightly.20250708 → 1.0.0-staging.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/api/testing.d.ts +6 -0
- package/dest/api/testing.d.ts.map +1 -0
- package/dest/api/testing.js +5 -0
- package/dest/contract/contract_function_interaction.js +1 -1
- package/dest/contract/deploy_proven_tx.js +1 -1
- package/dest/contract/proven_tx.d.ts +2 -2
- package/dest/contract/proven_tx.d.ts.map +1 -1
- package/dest/contract/proven_tx.js +7 -7
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/test/anvil_test_watcher.d.ts +34 -0
- package/dest/test/anvil_test_watcher.d.ts.map +1 -0
- package/dest/test/anvil_test_watcher.js +139 -0
- package/dest/test/aztec_cheat_codes.d.ts +59 -0
- package/dest/test/aztec_cheat_codes.d.ts.map +1 -0
- package/dest/test/aztec_cheat_codes.js +62 -0
- package/dest/test/cheat_codes.d.ts +26 -0
- package/dest/test/cheat_codes.d.ts.map +1 -0
- package/dest/test/cheat_codes.js +25 -0
- package/dest/test/rollup_cheat_codes.d.ts +78 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +201 -0
- package/package.json +9 -8
- package/src/api/testing.ts +5 -0
- package/src/contract/contract_function_interaction.ts +1 -1
- package/src/contract/deploy_proven_tx.ts +1 -1
- package/src/contract/proven_tx.ts +6 -8
- package/src/index.ts +1 -1
- package/src/test/anvil_test_watcher.ts +165 -0
- package/src/test/aztec_cheat_codes.ts +77 -0
- package/src/test/cheat_codes.ts +35 -0
- package/src/test/rollup_cheat_codes.ts +233 -0
- package/dest/api/authorization.d.ts +0 -3
- package/dest/api/authorization.d.ts.map +0 -1
- package/dest/api/authorization.js +0 -2
- package/dest/authorization/call_authorization_request.d.ts +0 -67
- package/dest/authorization/call_authorization_request.d.ts.map +0 -1
- package/dest/authorization/call_authorization_request.js +0 -49
- package/src/api/authorization.ts +0 -3
- package/src/authorization/call_authorization_request.ts +0 -63
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AnvilTestWatcher } from '../test/anvil_test_watcher.js';
|
|
2
|
+
export { RollupCheatCodes } from '../test/rollup_cheat_codes.js';
|
|
3
|
+
export { AztecCheatCodes } from '../test/aztec_cheat_codes.js';
|
|
4
|
+
export { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
5
|
+
export { CheatCodes } from '../test/cheat_codes.js';
|
|
6
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/api/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AnvilTestWatcher } from '../test/anvil_test_watcher.js';
|
|
2
|
+
export { RollupCheatCodes } from '../test/rollup_cheat_codes.js';
|
|
3
|
+
export { AztecCheatCodes } from '../test/aztec_cheat_codes.js';
|
|
4
|
+
export { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
5
|
+
export { CheatCodes } from '../test/cheat_codes.js';
|
|
@@ -91,7 +91,7 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
91
91
|
}
|
|
92
92
|
} else {
|
|
93
93
|
// For public functions we retrieve the first values directly from the public output.
|
|
94
|
-
rawReturnValues = simulatedTx.getPublicReturnValues()?.[0]
|
|
94
|
+
rawReturnValues = simulatedTx.getPublicReturnValues()?.[0].values;
|
|
95
95
|
}
|
|
96
96
|
const returnValue = rawReturnValues ? decodeFromAbi(this.functionDao.returnTypes, rawReturnValues) : [];
|
|
97
97
|
if (options.includeMetadata) {
|
|
@@ -11,7 +11,7 @@ import { ProvenTx } from './proven_tx.js';
|
|
|
11
11
|
/**
|
|
12
12
|
* Sends the transaction to the network via the provided wallet.
|
|
13
13
|
*/ send() {
|
|
14
|
-
const sendTx = ()=>this.wallet.sendTx(this);
|
|
14
|
+
const sendTx = ()=>this.wallet.sendTx(this.getPlainDataTx());
|
|
15
15
|
return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, this.instanceGetter);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -5,14 +5,14 @@ import { SentTx } from './sent_tx.js';
|
|
|
5
5
|
* A proven transaction that can be sent to the network. Returned by the `prove` method of a contract interaction.
|
|
6
6
|
*/
|
|
7
7
|
export declare class ProvenTx extends Tx {
|
|
8
|
-
|
|
8
|
+
protected wallet: Wallet;
|
|
9
9
|
/** The offchain effects emitted during the execution of the transaction. */
|
|
10
10
|
offchainEffects: OffchainEffect[];
|
|
11
11
|
stats?: ProvingStats | undefined;
|
|
12
12
|
constructor(wallet: Wallet, tx: Tx,
|
|
13
13
|
/** The offchain effects emitted during the execution of the transaction. */
|
|
14
14
|
offchainEffects: OffchainEffect[], stats?: ProvingStats | undefined);
|
|
15
|
-
protected
|
|
15
|
+
protected getPlainDataTx(): Tx;
|
|
16
16
|
/**
|
|
17
17
|
* Sends the transaction to the network via the provided wallet.
|
|
18
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proven_tx.d.ts","sourceRoot":"","sources":["../../src/contract/proven_tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;GAEG;AACH,qBAAa,QAAS,SAAQ,EAAE
|
|
1
|
+
{"version":3,"file":"proven_tx.d.ts","sourceRoot":"","sources":["../../src/contract/proven_tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;GAEG;AACH,qBAAa,QAAS,SAAQ,EAAE;IAE5B,SAAS,CAAC,MAAM,EAAE,MAAM;IAExB,4EAA4E;IACrE,eAAe,EAAE,cAAc,EAAE;IAEjC,KAAK,CAAC,EAAE,YAAY;gBALjB,MAAM,EAAE,MAAM,EACxB,EAAE,EAAE,EAAE;IACN,4EAA4E;IACrE,eAAe,EAAE,cAAc,EAAE,EAEjC,KAAK,CAAC,EAAE,YAAY,YAAA;IAM7B,SAAS,CAAC,cAAc,IAAI,EAAE;IAI9B;;OAEG;IACI,IAAI,IAAI,MAAM;CAKtB"}
|
|
@@ -3,21 +3,21 @@ import { SentTx } from './sent_tx.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* A proven transaction that can be sent to the network. Returned by the `prove` method of a contract interaction.
|
|
5
5
|
*/ export class ProvenTx extends Tx {
|
|
6
|
+
wallet;
|
|
6
7
|
offchainEffects;
|
|
7
8
|
stats;
|
|
8
|
-
#wallet;
|
|
9
9
|
constructor(wallet, tx, /** The offchain effects emitted during the execution of the transaction. */ offchainEffects, // eslint-disable-next-line jsdoc/require-jsdoc
|
|
10
10
|
stats){
|
|
11
|
-
super(tx.data, tx.clientIvcProof, tx.contractClassLogFields, tx.publicFunctionCalldata), this.offchainEffects = offchainEffects, this.stats = stats;
|
|
12
|
-
this.#wallet = wallet;
|
|
11
|
+
super(tx.data, tx.clientIvcProof, tx.contractClassLogFields, tx.publicFunctionCalldata), this.wallet = wallet, this.offchainEffects = offchainEffects, this.stats = stats;
|
|
13
12
|
}
|
|
14
|
-
get
|
|
15
|
-
|
|
13
|
+
// Clone the TX data to get a serializable object.
|
|
14
|
+
getPlainDataTx() {
|
|
15
|
+
return new Tx(this.data, this.clientIvcProof, this.contractClassLogFields, this.publicFunctionCalldata);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Sends the transaction to the network via the provided wallet.
|
|
19
19
|
*/ send() {
|
|
20
|
-
const sendTx = ()=>this
|
|
21
|
-
return new SentTx(this
|
|
20
|
+
const sendTx = ()=>this.wallet.sendTx(this.getPlainDataTx());
|
|
21
|
+
return new SentTx(this.wallet, sendTx);
|
|
22
22
|
}
|
|
23
23
|
}
|
package/dest/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export { MerkleTreeId, merkleTreeIds } from '@aztec/stdlib/trees';
|
|
|
26
26
|
export { type PublicKey, PublicKeys } from '@aztec/stdlib/keys';
|
|
27
27
|
export { computeSecretHash } from '@aztec/stdlib/hash';
|
|
28
28
|
export { computeAppNullifierSecretKey, deriveKeys, deriveMasterIncomingViewingSecretKey, deriveMasterNullifierSecretKey, } from '@aztec/stdlib/keys';
|
|
29
|
+
export { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
29
30
|
export { getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
30
31
|
export { Tx, TxExecutionRequest, TxHash, TxReceipt, TxStatus, Capsule, HashedValues, GlobalVariables, } from '@aztec/stdlib/tx';
|
|
31
32
|
export { Body, L2Block } from '@aztec/stdlib/block';
|
|
@@ -44,7 +45,6 @@ export { elapsed } from '@aztec/foundation/timer';
|
|
|
44
45
|
export { type FieldsOf } from '@aztec/foundation/types';
|
|
45
46
|
export { fileURLToPath } from '@aztec/foundation/url';
|
|
46
47
|
export * from './api/abi.js';
|
|
47
|
-
export * from './api/authorization.js';
|
|
48
48
|
export * from './api/account.js';
|
|
49
49
|
export * from './api/addresses.js';
|
|
50
50
|
export * from './api/deployment.js';
|
package/dest/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,KAAK,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,4BAA4B,EAC5B,UAAU,EACV,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,EAAE,EACF,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,KAAK,GAAG,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE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AAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
|
package/dest/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export { MerkleTreeId, merkleTreeIds } from '@aztec/stdlib/trees';
|
|
|
25
25
|
export { PublicKeys } from '@aztec/stdlib/keys';
|
|
26
26
|
export { computeSecretHash } from '@aztec/stdlib/hash';
|
|
27
27
|
export { computeAppNullifierSecretKey, deriveKeys, deriveMasterIncomingViewingSecretKey, deriveMasterNullifierSecretKey } from '@aztec/stdlib/keys';
|
|
28
|
+
export { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
28
29
|
export { getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
29
30
|
export { Tx, TxExecutionRequest, TxHash, TxReceipt, TxStatus, Capsule, HashedValues, GlobalVariables } from '@aztec/stdlib/tx';
|
|
30
31
|
export { Body, L2Block } from '@aztec/stdlib/block';
|
|
@@ -48,7 +49,6 @@ export { fileURLToPath } from '@aztec/foundation/url';
|
|
|
48
49
|
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
|
|
49
50
|
// This entire index file will be deprecated at some point after we're satisfied.
|
|
50
51
|
export * from './api/abi.js';
|
|
51
|
-
export * from './api/authorization.js';
|
|
52
52
|
export * from './api/account.js';
|
|
53
53
|
export * from './api/addresses.js';
|
|
54
54
|
export * from './api/deployment.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ViemClient } from '@aztec/ethereum';
|
|
2
|
+
import type { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a watcher for a rollup contract.
|
|
7
|
+
*
|
|
8
|
+
* It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
|
|
9
|
+
* it will periodically check if the current slot have already been filled, e.g., there was an L2
|
|
10
|
+
* block within the slot. And if so, it will time travel into the next slot.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AnvilTestWatcher {
|
|
13
|
+
private cheatcodes;
|
|
14
|
+
private dateProvider?;
|
|
15
|
+
private isSandbox;
|
|
16
|
+
private rollup;
|
|
17
|
+
private rollupCheatCodes;
|
|
18
|
+
private l2SlotDuration;
|
|
19
|
+
private filledRunningPromise?;
|
|
20
|
+
private syncDateProviderPromise?;
|
|
21
|
+
private markingAsProvenRunningPromise?;
|
|
22
|
+
private logger;
|
|
23
|
+
private isMarkingAsProven;
|
|
24
|
+
constructor(cheatcodes: EthCheatCodes, rollupAddress: EthAddress, l1Client: ViemClient, dateProvider?: TestDateProvider | undefined);
|
|
25
|
+
setIsMarkingAsProven(isMarkingAsProven: boolean): void;
|
|
26
|
+
setIsSandbox(isSandbox: boolean): void;
|
|
27
|
+
start(): Promise<void>;
|
|
28
|
+
stop(): Promise<void>;
|
|
29
|
+
trigger(): Promise<void>;
|
|
30
|
+
markAsProven(): Promise<void>;
|
|
31
|
+
syncDateProviderToL1IfBehind(): Promise<void>;
|
|
32
|
+
warpTimeIfNeeded(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=anvil_test_watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anvil_test_watcher.d.ts","sourceRoot":"","sources":["../../src/test/anvil_test_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAOhE;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAgBzB,OAAO,CAAC,UAAU;IAGlB,OAAO,CAAC,YAAY,CAAC;IAlBvB,OAAO,CAAC,SAAS,CAAkB;IAEnC,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,cAAc,CAAU;IAEhC,OAAO,CAAC,oBAAoB,CAAC,CAAiB;IAC9C,OAAO,CAAC,uBAAuB,CAAC,CAAiB;IACjD,OAAO,CAAC,6BAA6B,CAAC,CAAiB;IAEvD,OAAO,CAAC,MAAM,CAAiD;IAE/D,OAAO,CAAC,iBAAiB,CAAQ;gBAGvB,UAAU,EAAE,aAAa,EACjC,aAAa,EAAE,UAAU,EACzB,QAAQ,EAAE,UAAU,EACZ,YAAY,CAAC,EAAE,gBAAgB,YAAA;IAezC,oBAAoB,CAAC,iBAAiB,EAAE,OAAO;IAI/C,YAAY,CAAC,SAAS,EAAE,OAAO;IAIzB,KAAK;IA2BL,IAAI;IAMJ,OAAO;IAMP,YAAY;IAOZ,4BAA4B;IAiB5B,gBAAgB;CAwCvB"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
3
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
4
|
+
import { getAddress, getContract } from 'viem';
|
|
5
|
+
import { RollupCheatCodes } from './rollup_cheat_codes.js';
|
|
6
|
+
/**
|
|
7
|
+
* Represents a watcher for a rollup contract.
|
|
8
|
+
*
|
|
9
|
+
* It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
|
|
10
|
+
* it will periodically check if the current slot have already been filled, e.g., there was an L2
|
|
11
|
+
* block within the slot. And if so, it will time travel into the next slot.
|
|
12
|
+
*/ export class AnvilTestWatcher {
|
|
13
|
+
cheatcodes;
|
|
14
|
+
dateProvider;
|
|
15
|
+
isSandbox;
|
|
16
|
+
rollup;
|
|
17
|
+
rollupCheatCodes;
|
|
18
|
+
l2SlotDuration;
|
|
19
|
+
filledRunningPromise;
|
|
20
|
+
syncDateProviderPromise;
|
|
21
|
+
markingAsProvenRunningPromise;
|
|
22
|
+
logger;
|
|
23
|
+
isMarkingAsProven;
|
|
24
|
+
constructor(cheatcodes, rollupAddress, l1Client, dateProvider){
|
|
25
|
+
this.cheatcodes = cheatcodes;
|
|
26
|
+
this.dateProvider = dateProvider;
|
|
27
|
+
this.isSandbox = false;
|
|
28
|
+
this.logger = createLogger(`aztecjs:utils:watcher`);
|
|
29
|
+
this.isMarkingAsProven = true;
|
|
30
|
+
this.rollup = getContract({
|
|
31
|
+
address: getAddress(rollupAddress.toString()),
|
|
32
|
+
abi: RollupAbi,
|
|
33
|
+
client: l1Client
|
|
34
|
+
});
|
|
35
|
+
this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
|
|
36
|
+
rollupAddress
|
|
37
|
+
});
|
|
38
|
+
this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
|
|
39
|
+
}
|
|
40
|
+
setIsMarkingAsProven(isMarkingAsProven) {
|
|
41
|
+
this.isMarkingAsProven = isMarkingAsProven;
|
|
42
|
+
}
|
|
43
|
+
setIsSandbox(isSandbox) {
|
|
44
|
+
this.isSandbox = isSandbox;
|
|
45
|
+
}
|
|
46
|
+
async start() {
|
|
47
|
+
if (this.filledRunningPromise) {
|
|
48
|
+
throw new Error('Watcher already watching for filled slot');
|
|
49
|
+
}
|
|
50
|
+
const config = await this.rollupCheatCodes.getConfig();
|
|
51
|
+
this.l2SlotDuration = config.slotDuration;
|
|
52
|
+
// If auto mining is not supported (e.g., we are on a real network), then we
|
|
53
|
+
// will simple do nothing. But if on an anvil or the like, this make sure that
|
|
54
|
+
// the sandbox and tests don't break because time is frozen and we never get to
|
|
55
|
+
// the next slot.
|
|
56
|
+
const isAutoMining = await this.cheatcodes.isAutoMining();
|
|
57
|
+
if (isAutoMining) {
|
|
58
|
+
this.filledRunningPromise = new RunningPromise(()=>this.warpTimeIfNeeded(), this.logger, 200);
|
|
59
|
+
this.filledRunningPromise.start();
|
|
60
|
+
this.syncDateProviderPromise = new RunningPromise(()=>this.syncDateProviderToL1IfBehind(), this.logger, 200);
|
|
61
|
+
this.syncDateProviderPromise.start();
|
|
62
|
+
this.markingAsProvenRunningPromise = new RunningPromise(()=>this.markAsProven(), this.logger, 200);
|
|
63
|
+
this.markingAsProvenRunningPromise.start();
|
|
64
|
+
this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
|
|
65
|
+
} else {
|
|
66
|
+
this.logger.info(`Watcher not started because not auto mining`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async stop() {
|
|
70
|
+
await this.filledRunningPromise?.stop();
|
|
71
|
+
await this.syncDateProviderPromise?.stop();
|
|
72
|
+
await this.markingAsProvenRunningPromise?.stop();
|
|
73
|
+
}
|
|
74
|
+
async trigger() {
|
|
75
|
+
await this.filledRunningPromise?.trigger();
|
|
76
|
+
await this.syncDateProviderPromise?.trigger();
|
|
77
|
+
await this.markingAsProvenRunningPromise?.trigger();
|
|
78
|
+
}
|
|
79
|
+
async markAsProven() {
|
|
80
|
+
if (!this.isMarkingAsProven) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
await this.rollupCheatCodes.markAsProven();
|
|
84
|
+
}
|
|
85
|
+
async syncDateProviderToL1IfBehind() {
|
|
86
|
+
// this doesn't apply to the sandbox, because we don't have a date provider in the sandbox
|
|
87
|
+
if (!this.dateProvider) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const l1Time = await this.cheatcodes.timestamp() * 1000;
|
|
91
|
+
const wallTime = this.dateProvider.now();
|
|
92
|
+
if (l1Time > wallTime) {
|
|
93
|
+
this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
|
|
94
|
+
this.dateProvider.setTime(l1Time);
|
|
95
|
+
} else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
|
|
96
|
+
this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
|
|
97
|
+
await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async warpTimeIfNeeded() {
|
|
101
|
+
try {
|
|
102
|
+
const currentSlot = await this.rollup.read.getCurrentSlot();
|
|
103
|
+
const pendingBlockNumber = BigInt(await this.rollup.read.getPendingBlockNumber());
|
|
104
|
+
const blockLog = await this.rollup.read.getBlock([
|
|
105
|
+
pendingBlockNumber
|
|
106
|
+
]);
|
|
107
|
+
const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([
|
|
108
|
+
currentSlot + 1n
|
|
109
|
+
]));
|
|
110
|
+
if (currentSlot === blockLog.slotNumber) {
|
|
111
|
+
// We should jump to the next slot
|
|
112
|
+
try {
|
|
113
|
+
await this.cheatcodes.warp(nextSlotTimestamp);
|
|
114
|
+
this.dateProvider?.setTime(nextSlotTimestamp * 1000);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
117
|
+
}
|
|
118
|
+
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// If we are not in sandbox, we don't need to warp time
|
|
122
|
+
if (!this.isSandbox) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
126
|
+
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
127
|
+
try {
|
|
128
|
+
await this.cheatcodes.warp(nextSlotTimestamp);
|
|
129
|
+
this.dateProvider?.setTime(nextSlotTimestamp * 1000);
|
|
130
|
+
} catch (e) {
|
|
131
|
+
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
132
|
+
}
|
|
133
|
+
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
134
|
+
}
|
|
135
|
+
} catch {
|
|
136
|
+
this.logger.error('mineIfSlotFilled failed');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
import type { Note } from '@aztec/stdlib/note';
|
|
5
|
+
/**
|
|
6
|
+
* A class that provides utility functions for interacting with the aztec chain.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AztecCheatCodes {
|
|
9
|
+
/**
|
|
10
|
+
* The PXE Service to use for interacting with the chain
|
|
11
|
+
*/
|
|
12
|
+
pxe: PXE;
|
|
13
|
+
/**
|
|
14
|
+
* The logger to use for the aztec cheatcodes
|
|
15
|
+
*/
|
|
16
|
+
logger: import("@aztec/foundation/log").Logger;
|
|
17
|
+
constructor(
|
|
18
|
+
/**
|
|
19
|
+
* The PXE Service to use for interacting with the chain
|
|
20
|
+
*/
|
|
21
|
+
pxe: PXE,
|
|
22
|
+
/**
|
|
23
|
+
* The logger to use for the aztec cheatcodes
|
|
24
|
+
*/
|
|
25
|
+
logger?: import("@aztec/foundation/log").Logger);
|
|
26
|
+
/**
|
|
27
|
+
* Computes the slot value for a given map and key.
|
|
28
|
+
* @param mapSlot - The slot of the map (specified in Aztec.nr contract)
|
|
29
|
+
* @param key - The key to lookup in the map
|
|
30
|
+
* @returns The storage slot of the value in the map
|
|
31
|
+
*/
|
|
32
|
+
computeSlotInMap(mapSlot: Fr | bigint, key: Fr | bigint | AztecAddress): Promise<Fr>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the current blocknumber
|
|
35
|
+
* @returns The current block number
|
|
36
|
+
*/
|
|
37
|
+
blockNumber(): Promise<number>;
|
|
38
|
+
/**
|
|
39
|
+
* Get the current timestamp
|
|
40
|
+
* @returns The current timestamp
|
|
41
|
+
*/
|
|
42
|
+
timestamp(): Promise<number>;
|
|
43
|
+
/**
|
|
44
|
+
* Loads the value stored at the given slot in the public storage of the given contract.
|
|
45
|
+
* @param who - The address of the contract
|
|
46
|
+
* @param slot - The storage slot to lookup
|
|
47
|
+
* @returns The value stored at the given slot
|
|
48
|
+
*/
|
|
49
|
+
loadPublic(who: AztecAddress, slot: Fr | bigint): Promise<Fr>;
|
|
50
|
+
/**
|
|
51
|
+
* Loads the value stored at the given slot in the private storage of the given contract.
|
|
52
|
+
* @param contract - The address of the contract
|
|
53
|
+
* @param recipient - The address whose public key was used to encrypt the note
|
|
54
|
+
* @param slot - The storage slot to lookup
|
|
55
|
+
* @returns The notes stored at the given slot
|
|
56
|
+
*/
|
|
57
|
+
loadPrivate(recipient: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise<Note[]>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=aztec_cheat_codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aztec_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/aztec_cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,qBAAa,eAAe;IAExB;;OAEG;IACI,GAAG,EAAE,GAAG;IACf;;OAEG;IACI,MAAM;;IAPb;;OAEG;IACI,GAAG,EAAE,GAAG;IACf;;OAEG;IACI,MAAM,yCAAsC;IAGrD;;;;;OAKG;IACI,gBAAgB,CAAC,OAAO,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,EAAE,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,EAAE,CAAC;IAK3F;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAKzC;;;;;OAKG;IACU,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAK1E;;;;;;OAMG;IACU,WAAW,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAQ9G"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
|
|
4
|
+
/**
|
|
5
|
+
* A class that provides utility functions for interacting with the aztec chain.
|
|
6
|
+
*/ export class AztecCheatCodes {
|
|
7
|
+
pxe;
|
|
8
|
+
logger;
|
|
9
|
+
constructor(/**
|
|
10
|
+
* The PXE Service to use for interacting with the chain
|
|
11
|
+
*/ pxe, /**
|
|
12
|
+
* The logger to use for the aztec cheatcodes
|
|
13
|
+
*/ logger = createLogger('aztecjs:cheat_codes')){
|
|
14
|
+
this.pxe = pxe;
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Computes the slot value for a given map and key.
|
|
19
|
+
* @param mapSlot - The slot of the map (specified in Aztec.nr contract)
|
|
20
|
+
* @param key - The key to lookup in the map
|
|
21
|
+
* @returns The storage slot of the value in the map
|
|
22
|
+
*/ computeSlotInMap(mapSlot, key) {
|
|
23
|
+
const keyFr = typeof key === 'bigint' ? new Fr(key) : key.toField();
|
|
24
|
+
return deriveStorageSlotInMap(mapSlot, keyFr);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get the current blocknumber
|
|
28
|
+
* @returns The current block number
|
|
29
|
+
*/ async blockNumber() {
|
|
30
|
+
return await this.pxe.getBlockNumber();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the current timestamp
|
|
34
|
+
* @returns The current timestamp
|
|
35
|
+
*/ async timestamp() {
|
|
36
|
+
const res = await this.pxe.getBlock(await this.blockNumber());
|
|
37
|
+
return Number(res?.header.globalVariables.timestamp ?? 0);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Loads the value stored at the given slot in the public storage of the given contract.
|
|
41
|
+
* @param who - The address of the contract
|
|
42
|
+
* @param slot - The storage slot to lookup
|
|
43
|
+
* @returns The value stored at the given slot
|
|
44
|
+
*/ async loadPublic(who, slot) {
|
|
45
|
+
const storageValue = await this.pxe.getPublicStorageAt(who, new Fr(slot));
|
|
46
|
+
return storageValue;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Loads the value stored at the given slot in the private storage of the given contract.
|
|
50
|
+
* @param contract - The address of the contract
|
|
51
|
+
* @param recipient - The address whose public key was used to encrypt the note
|
|
52
|
+
* @param slot - The storage slot to lookup
|
|
53
|
+
* @returns The notes stored at the given slot
|
|
54
|
+
*/ async loadPrivate(recipient, contract, slot) {
|
|
55
|
+
const extendedNotes = await this.pxe.getNotes({
|
|
56
|
+
recipient,
|
|
57
|
+
contractAddress: contract,
|
|
58
|
+
storageSlot: new Fr(slot)
|
|
59
|
+
});
|
|
60
|
+
return extendedNotes.map((extendedNote)=>extendedNote.note);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
2
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
import { AztecCheatCodes } from './aztec_cheat_codes.js';
|
|
5
|
+
import { RollupCheatCodes } from './rollup_cheat_codes.js';
|
|
6
|
+
/**
|
|
7
|
+
* A class that provides utility functions for interacting with the chain.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CheatCodes {
|
|
10
|
+
/** Cheat codes for L1.*/
|
|
11
|
+
eth: EthCheatCodes;
|
|
12
|
+
/** Cheat codes for Aztec L2. */
|
|
13
|
+
aztec: AztecCheatCodes;
|
|
14
|
+
/** Cheat codes for the Aztec Rollup contract on L1. */
|
|
15
|
+
rollup: RollupCheatCodes;
|
|
16
|
+
constructor(
|
|
17
|
+
/** Cheat codes for L1.*/
|
|
18
|
+
eth: EthCheatCodes,
|
|
19
|
+
/** Cheat codes for Aztec L2. */
|
|
20
|
+
aztec: AztecCheatCodes,
|
|
21
|
+
/** Cheat codes for the Aztec Rollup contract on L1. */
|
|
22
|
+
rollup: RollupCheatCodes);
|
|
23
|
+
static create(rpcUrls: string[], pxe: PXE): Promise<CheatCodes>;
|
|
24
|
+
static createRollup(rpcUrls: string[], addresses: Pick<L1ContractAddresses, 'rollupAddress'>): RollupCheatCodes;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=cheat_codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,qBAAa,UAAU;IAEnB,yBAAyB;IAClB,GAAG,EAAE,aAAa;IACzB,gCAAgC;IACzB,KAAK,EAAE,eAAe;IAC7B,uDAAuD;IAChD,MAAM,EAAE,gBAAgB;;IAL/B,yBAAyB;IAClB,GAAG,EAAE,aAAa;IACzB,gCAAgC;IACzB,KAAK,EAAE,eAAe;IAC7B,uDAAuD;IAChD,MAAM,EAAE,gBAAgB;WAGpB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC;IAUrE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,GAAG,gBAAgB;CAIhH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
2
|
+
import { AztecCheatCodes } from './aztec_cheat_codes.js';
|
|
3
|
+
import { RollupCheatCodes } from './rollup_cheat_codes.js';
|
|
4
|
+
/**
|
|
5
|
+
* A class that provides utility functions for interacting with the chain.
|
|
6
|
+
*/ export class CheatCodes {
|
|
7
|
+
eth;
|
|
8
|
+
aztec;
|
|
9
|
+
rollup;
|
|
10
|
+
constructor(/** Cheat codes for L1.*/ eth, /** Cheat codes for Aztec L2. */ aztec, /** Cheat codes for the Aztec Rollup contract on L1. */ rollup){
|
|
11
|
+
this.eth = eth;
|
|
12
|
+
this.aztec = aztec;
|
|
13
|
+
this.rollup = rollup;
|
|
14
|
+
}
|
|
15
|
+
static async create(rpcUrls, pxe) {
|
|
16
|
+
const ethCheatCodes = new EthCheatCodes(rpcUrls);
|
|
17
|
+
const aztecCheatCodes = new AztecCheatCodes(pxe);
|
|
18
|
+
const rollupCheatCodes = new RollupCheatCodes(ethCheatCodes, await pxe.getNodeInfo().then((n)=>n.l1ContractAddresses));
|
|
19
|
+
return new CheatCodes(ethCheatCodes, aztecCheatCodes, rollupCheatCodes);
|
|
20
|
+
}
|
|
21
|
+
static createRollup(rpcUrls, addresses) {
|
|
22
|
+
const ethCheatCodes = new EthCheatCodes(rpcUrls);
|
|
23
|
+
return new RollupCheatCodes(ethCheatCodes, addresses);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type ViemPublicClient } from '@aztec/ethereum';
|
|
2
|
+
import { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
|
|
3
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
4
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
|
+
import { type GetContractReturnType, type Hex } from 'viem';
|
|
7
|
+
/** Cheat codes for the L1 rollup contract. */
|
|
8
|
+
export declare class RollupCheatCodes {
|
|
9
|
+
private ethCheatCodes;
|
|
10
|
+
private client;
|
|
11
|
+
private rollup;
|
|
12
|
+
private logger;
|
|
13
|
+
constructor(ethCheatCodes: EthCheatCodes, addresses: Pick<L1ContractAddresses, 'rollupAddress'>);
|
|
14
|
+
/** Returns the current slot */
|
|
15
|
+
getSlot(): Promise<bigint>;
|
|
16
|
+
/** Returns the current epoch */
|
|
17
|
+
getEpoch(): Promise<bigint>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the pending and proven chain tips
|
|
20
|
+
* @returns The pending and proven chain tips
|
|
21
|
+
*/
|
|
22
|
+
getTips(): Promise<{
|
|
23
|
+
/** The pending chain tip */ pending: bigint;
|
|
24
|
+
/** The proven chain tip */ proven: bigint;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Logs the current state of the rollup contract.
|
|
28
|
+
*/
|
|
29
|
+
debugRollup(): Promise<void>;
|
|
30
|
+
/** Fetches the epoch and slot duration config from the rollup contract */
|
|
31
|
+
getConfig(): Promise<{
|
|
32
|
+
/** Epoch duration */ epochDuration: bigint;
|
|
33
|
+
/** Slot duration */ slotDuration: bigint;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Advances time to the beginning of the given epoch
|
|
37
|
+
* @param epoch - The epoch to advance to
|
|
38
|
+
* @param opts - Options
|
|
39
|
+
*/
|
|
40
|
+
advanceToEpoch(epoch: bigint, opts?: {
|
|
41
|
+
/** Whether to reset the L1 block interval so the next block is mined L1-block-time after thie call */
|
|
42
|
+
resetBlockInterval?: boolean;
|
|
43
|
+
/** Optional test date provider to update with the epoch timestamp */
|
|
44
|
+
updateDateProvider?: TestDateProvider;
|
|
45
|
+
}): Promise<bigint>;
|
|
46
|
+
/** Warps time in L1 until the next epoch */
|
|
47
|
+
advanceToNextEpoch(): Promise<void>;
|
|
48
|
+
/** Warps time in L1 until the beginning of the next slot. */
|
|
49
|
+
advanceToNextSlot(): Promise<bigint[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Warps time in L1 equivalent to however many slots.
|
|
52
|
+
* @param howMany - The number of slots to advance.
|
|
53
|
+
*/
|
|
54
|
+
advanceSlots(howMany: number): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Marks the specified block (or latest if none) as proven
|
|
57
|
+
* @param maybeBlockNumber - The block number to mark as proven (defaults to latest pending)
|
|
58
|
+
*/
|
|
59
|
+
markAsProven(maybeBlockNumber?: number | bigint): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Executes an action impersonated as the owner of the Rollup contract.
|
|
62
|
+
* @param action - The action to execute
|
|
63
|
+
*/
|
|
64
|
+
asOwner(action: (owner: Hex, rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>) => Promise<void>): Promise<void>;
|
|
65
|
+
/** Directly calls the L1 gas fee oracle. */
|
|
66
|
+
updateL1GasFeeOracle(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Bumps proving cost per mana.
|
|
69
|
+
* @param bumper - Callback to calculate the new proving cost per mana based on current value.
|
|
70
|
+
*/
|
|
71
|
+
bumpProvingCostPerMana(bumper: (before: bigint) => bigint): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Directly updates proving cost per mana.
|
|
74
|
+
* @param ethValue - The new proving cost per mana in ETH
|
|
75
|
+
*/
|
|
76
|
+
setProvingCostPerMana(ethValue: bigint): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=rollup_cheat_codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAGjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,GAAG,EAA8D,MAAM,MAAM,CAAC;AAGxH,8CAA8C;AAC9C,qBAAa,gBAAgB;IAOzB,OAAO,CAAC,aAAa;IANvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,MAAM,CAA4D;IAE1E,OAAO,CAAC,MAAM,CAAuC;gBAG3C,aAAa,EAAE,aAAa,EACpC,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC;IAavD,+BAA+B;IAClB,OAAO;IAKpB,gCAAgC;IACnB,QAAQ;IAKrB;;;OAGG;IACU,OAAO,IAAI,OAAO,CAAC;QAC9B,4BAA4B,CAAC,OAAO,EAAE,MAAM,CAAC;QAC7C,2BAA2B,CAAC,MAAM,EAAE,MAAM,CAAC;KAC5C,CAAC;IAQF;;OAEG;IACU,WAAW;IAmBxB,0EAA0E;IAC7D,SAAS,IAAI,OAAO,CAAC;QAChC,qBAAqB,CAAC,aAAa,EAAE,MAAM,CAAC;QAC5C,oBAAoB,CA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