@aztec/archiver 0.79.0 → 0.81.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/archiver/archiver.d.ts +5 -9
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +36 -49
- package/dest/archiver/archiver_store.d.ts +5 -4
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +104 -91
- package/dest/archiver/data_retrieval.d.ts +3 -4
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +8 -3
- package/dest/archiver/index.d.ts +1 -1
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +6 -6
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +24 -21
- package/dest/archiver/kv_archiver_store/contract_class_store.js +2 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +4 -4
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +2 -3
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +9 -41
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +4 -4
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +25 -54
- package/dest/archiver/structs/published.d.ts +1 -10
- package/dest/archiver/structs/published.d.ts.map +1 -1
- package/dest/archiver/structs/published.js +1 -1
- package/dest/test/mock_l2_block_source.d.ts +9 -0
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +13 -0
- package/package.json +13 -13
- package/src/archiver/archiver.ts +44 -60
- package/src/archiver/archiver_store.ts +5 -4
- package/src/archiver/archiver_store_test_suite.ts +116 -93
- package/src/archiver/data_retrieval.ts +11 -10
- package/src/archiver/index.ts +1 -1
- package/src/archiver/kv_archiver_store/block_store.ts +28 -27
- package/src/archiver/kv_archiver_store/contract_class_store.ts +1 -0
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +5 -6
- package/src/archiver/kv_archiver_store/log_store.ts +11 -59
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +35 -66
- package/src/archiver/structs/published.ts +1 -11
- package/src/test/mock_l2_block_source.ts +14 -0
|
@@ -7,7 +7,7 @@ import { type Logger } from '@aztec/foundation/log';
|
|
|
7
7
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
8
8
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
9
|
import { type InBlock, type L2Block, type L2BlockSource, type L2Tips, type NullifierWithBlockSource } from '@aztec/stdlib/block';
|
|
10
|
-
import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress
|
|
10
|
+
import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
11
11
|
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
12
12
|
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
13
13
|
import type { L2LogsSource } from '@aztec/stdlib/interfaces/server';
|
|
@@ -19,6 +19,7 @@ import { EventEmitter } from 'events';
|
|
|
19
19
|
import type { ArchiverDataStore } from './archiver_store.js';
|
|
20
20
|
import type { ArchiverConfig } from './config.js';
|
|
21
21
|
import { ArchiverInstrumentation } from './instrumentation.js';
|
|
22
|
+
import type { PublishedL2Block } from './structs/published.js';
|
|
22
23
|
/**
|
|
23
24
|
* Helper interface to combine all sources this archiver implementation provides.
|
|
24
25
|
*/
|
|
@@ -115,6 +116,8 @@ export declare class Archiver extends EventEmitter implements ArchiveSource, Tra
|
|
|
115
116
|
* @returns The requested L2 blocks.
|
|
116
117
|
*/
|
|
117
118
|
getBlocks(from: number, limit: number, proven?: boolean): Promise<L2Block[]>;
|
|
119
|
+
/** Equivalent to getBlocks but includes publish data. */
|
|
120
|
+
getPublishedBlocks(from: number, limit: number, proven?: boolean): Promise<PublishedL2Block[]>;
|
|
118
121
|
/**
|
|
119
122
|
* Gets an l2 block.
|
|
120
123
|
* @param number - The block number to return.
|
|
@@ -124,13 +127,6 @@ export declare class Archiver extends EventEmitter implements ArchiveSource, Tra
|
|
|
124
127
|
getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined>;
|
|
125
128
|
getTxEffect(txHash: TxHash): Promise<InBlock<TxEffect> | undefined>;
|
|
126
129
|
getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined>;
|
|
127
|
-
/**
|
|
128
|
-
* Gets the public function data for a contract.
|
|
129
|
-
* @param address - The contract address containing the function to fetch.
|
|
130
|
-
* @param selector - The function selector of the function to fetch.
|
|
131
|
-
* @returns The public function data (if found).
|
|
132
|
-
*/
|
|
133
|
-
getPublicFunction(address: AztecAddress, selector: FunctionSelector): Promise<PublicFunction | undefined>;
|
|
134
130
|
/**
|
|
135
131
|
* Retrieves all private logs from up to `limit` blocks, starting from the block number `from`.
|
|
136
132
|
* @param from - The block number from which to begin retrieving logs.
|
|
@@ -175,7 +171,7 @@ export declare class Archiver extends EventEmitter implements ArchiveSource, Tra
|
|
|
175
171
|
setProvenBlockNumber(blockNumber: number): Promise<void>;
|
|
176
172
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
177
173
|
getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
|
|
178
|
-
getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
174
|
+
getContract(address: AztecAddress, blockNumber?: number): Promise<ContractInstanceWithAddress | undefined>;
|
|
179
175
|
/**
|
|
180
176
|
* Gets L1 to L2 message (to be) included in a given block.
|
|
181
177
|
* @param blockNumber - L2 block number to get messages for.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,KAAK,gBAAgB,EAAuB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAclE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EAEZ,KAAK,aAAa,EAElB,KAAK,MAAM,EACX,KAAK,wBAAwB,EAC9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,
|
|
1
|
+
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,KAAK,gBAAgB,EAAuB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAclE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,OAAO,EACZ,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IAK9B,gBAAgB,CAAC,aAAa,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IASzE,kCAAkC,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9F,uBAAuB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIjG,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;CAuCnC"}
|
|
@@ -367,21 +367,21 @@ import { ArchiverInstrumentation } from './instrumentation.js';
|
|
|
367
367
|
const lastProcessedL1BlockNumber = retrievedBlocks[retrievedBlocks.length - 1].l1.blockNumber;
|
|
368
368
|
this.log.debug(`Retrieved ${retrievedBlocks.length} new L2 blocks between L1 blocks ${searchStartBlock} and ${searchEndBlock} with last processed L1 block ${lastProcessedL1BlockNumber}.`);
|
|
369
369
|
for (const block of retrievedBlocks){
|
|
370
|
-
this.log.debug(`Ingesting new L2 block ${block.
|
|
371
|
-
blockHash: block.
|
|
370
|
+
this.log.debug(`Ingesting new L2 block ${block.block.number} with ${block.block.body.txEffects.length} txs`, {
|
|
371
|
+
blockHash: block.block.hash(),
|
|
372
372
|
l1BlockNumber: block.l1.blockNumber,
|
|
373
|
-
...block.
|
|
374
|
-
...block.
|
|
373
|
+
...block.block.header.globalVariables.toInspect(),
|
|
374
|
+
...block.block.getStats()
|
|
375
375
|
});
|
|
376
376
|
}
|
|
377
377
|
const [processDuration] = await elapsed(()=>this.store.addBlocks(retrievedBlocks));
|
|
378
|
-
this.instrumentation.processNewBlocks(processDuration / retrievedBlocks.length, retrievedBlocks.map((b)=>b.
|
|
378
|
+
this.instrumentation.processNewBlocks(processDuration / retrievedBlocks.length, retrievedBlocks.map((b)=>b.block));
|
|
379
379
|
for (const block of retrievedBlocks){
|
|
380
|
-
this.log.info(`Downloaded L2 block ${block.
|
|
381
|
-
blockHash: block.
|
|
382
|
-
blockNumber: block.
|
|
383
|
-
txCount: block.
|
|
384
|
-
globalVariables: block.
|
|
380
|
+
this.log.info(`Downloaded L2 block ${block.block.number}`, {
|
|
381
|
+
blockHash: block.block.hash(),
|
|
382
|
+
blockNumber: block.block.number,
|
|
383
|
+
txCount: block.block.body.txEffects.length,
|
|
384
|
+
globalVariables: block.block.header.globalVariables.toInspect()
|
|
385
385
|
});
|
|
386
386
|
}
|
|
387
387
|
}while (searchEndBlock < currentL1BlockNumber)
|
|
@@ -474,9 +474,12 @@ import { ArchiverInstrumentation } from './instrumentation.js';
|
|
|
474
474
|
* @param limit - The number of blocks to return.
|
|
475
475
|
* @param proven - If true, only return blocks that have been proven.
|
|
476
476
|
* @returns The requested L2 blocks.
|
|
477
|
-
*/
|
|
477
|
+
*/ getBlocks(from, limit, proven) {
|
|
478
|
+
return this.getPublishedBlocks(from, limit, proven).then((blocks)=>blocks.map((b)=>b.block));
|
|
479
|
+
}
|
|
480
|
+
/** Equivalent to getBlocks but includes publish data. */ async getPublishedBlocks(from, limit, proven) {
|
|
478
481
|
const limitWithProven = proven ? Math.min(limit, Math.max(await this.store.getProvenL2BlockNumber() - from + 1, 0)) : limit;
|
|
479
|
-
return limitWithProven === 0 ? [] :
|
|
482
|
+
return limitWithProven === 0 ? [] : await this.store.getBlocks(from, limitWithProven);
|
|
480
483
|
}
|
|
481
484
|
/**
|
|
482
485
|
* Gets an l2 block.
|
|
@@ -491,7 +494,7 @@ import { ArchiverInstrumentation } from './instrumentation.js';
|
|
|
491
494
|
return undefined;
|
|
492
495
|
}
|
|
493
496
|
const blocks = await this.store.getBlocks(number, 1);
|
|
494
|
-
return blocks.length === 0 ? undefined : blocks[0].
|
|
497
|
+
return blocks.length === 0 ? undefined : blocks[0].block;
|
|
495
498
|
}
|
|
496
499
|
async getBlockHeader(number) {
|
|
497
500
|
if (number === 'latest') {
|
|
@@ -510,22 +513,6 @@ import { ArchiverInstrumentation } from './instrumentation.js';
|
|
|
510
513
|
return this.store.getSettledTxReceipt(txHash);
|
|
511
514
|
}
|
|
512
515
|
/**
|
|
513
|
-
* Gets the public function data for a contract.
|
|
514
|
-
* @param address - The contract address containing the function to fetch.
|
|
515
|
-
* @param selector - The function selector of the function to fetch.
|
|
516
|
-
* @returns The public function data (if found).
|
|
517
|
-
*/ async getPublicFunction(address, selector) {
|
|
518
|
-
const instance = await this.getContract(address);
|
|
519
|
-
if (!instance) {
|
|
520
|
-
throw new Error(`Contract ${address.toString()} not found`);
|
|
521
|
-
}
|
|
522
|
-
const contractClass = await this.getContractClass(instance.currentContractClassId);
|
|
523
|
-
if (!contractClass) {
|
|
524
|
-
throw new Error(`Contract class ${instance.currentContractClassId.toString()} for ${address.toString()} not found`);
|
|
525
|
-
}
|
|
526
|
-
return contractClass.publicFunctions.find((f)=>f.selector.equals(selector));
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
516
|
* Retrieves all private logs from up to `limit` blocks, starting from the block number `from`.
|
|
530
517
|
* @param from - The block number from which to begin retrieving logs.
|
|
531
518
|
* @param limit - The maximum number of blocks to retrieve logs from.
|
|
@@ -582,8 +569,8 @@ import { ArchiverInstrumentation } from './instrumentation.js';
|
|
|
582
569
|
getBytecodeCommitment(id) {
|
|
583
570
|
return this.store.getBytecodeCommitment(id);
|
|
584
571
|
}
|
|
585
|
-
getContract(address) {
|
|
586
|
-
return this.store.getContractInstance(address);
|
|
572
|
+
async getContract(address, blockNumber) {
|
|
573
|
+
return this.store.getContractInstance(address, blockNumber ?? await this.getBlockNumber());
|
|
587
574
|
}
|
|
588
575
|
/**
|
|
589
576
|
* Gets L1 to L2 message (to be) included in a given block.
|
|
@@ -777,21 +764,21 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
777
764
|
}
|
|
778
765
|
async addBlocks(blocks) {
|
|
779
766
|
const opResults = await Promise.all([
|
|
780
|
-
this.store.addLogs(blocks.map((block)=>block.
|
|
767
|
+
this.store.addLogs(blocks.map((block)=>block.block)),
|
|
781
768
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
782
769
|
...blocks.map(async (block)=>{
|
|
783
|
-
const contractClassLogs = block.
|
|
770
|
+
const contractClassLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.contractClassLogs);
|
|
784
771
|
// ContractInstanceDeployed event logs are broadcast in privateLogs.
|
|
785
|
-
const privateLogs = block.
|
|
786
|
-
const publicLogs = block.
|
|
772
|
+
const privateLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.privateLogs);
|
|
773
|
+
const publicLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.publicLogs);
|
|
787
774
|
return (await Promise.all([
|
|
788
|
-
this.#updateRegisteredContractClasses(contractClassLogs, block.
|
|
789
|
-
this.#updateDeployedContractInstances(privateLogs, block.
|
|
790
|
-
this.#updateUpdatedContractInstances(publicLogs, block.
|
|
791
|
-
this.#storeBroadcastedIndividualFunctions(contractClassLogs, block.
|
|
775
|
+
this.#updateRegisteredContractClasses(contractClassLogs, block.block.number, 0),
|
|
776
|
+
this.#updateDeployedContractInstances(privateLogs, block.block.number, 0),
|
|
777
|
+
this.#updateUpdatedContractInstances(publicLogs, block.block.number, 0),
|
|
778
|
+
this.#storeBroadcastedIndividualFunctions(contractClassLogs, block.block.number)
|
|
792
779
|
])).every(Boolean);
|
|
793
780
|
}),
|
|
794
|
-
this.store.addNullifiers(blocks.map((block)=>block.
|
|
781
|
+
this.store.addNullifiers(blocks.map((block)=>block.block)),
|
|
795
782
|
this.store.addBlocks(blocks)
|
|
796
783
|
]);
|
|
797
784
|
return opResults.every(Boolean);
|
|
@@ -806,17 +793,17 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
806
793
|
const opResults = await Promise.all([
|
|
807
794
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
808
795
|
...blocks.map(async (block)=>{
|
|
809
|
-
const contractClassLogs = block.
|
|
796
|
+
const contractClassLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.contractClassLogs);
|
|
810
797
|
// ContractInstanceDeployed event logs are broadcast in privateLogs.
|
|
811
|
-
const privateLogs = block.
|
|
812
|
-
const publicLogs = block.
|
|
798
|
+
const privateLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.privateLogs);
|
|
799
|
+
const publicLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.publicLogs);
|
|
813
800
|
return (await Promise.all([
|
|
814
|
-
this.#updateRegisteredContractClasses(contractClassLogs, block.
|
|
815
|
-
this.#updateDeployedContractInstances(privateLogs, block.
|
|
816
|
-
this.#updateUpdatedContractInstances(publicLogs, block.
|
|
801
|
+
this.#updateRegisteredContractClasses(contractClassLogs, block.block.number, 1),
|
|
802
|
+
this.#updateDeployedContractInstances(privateLogs, block.block.number, 1),
|
|
803
|
+
this.#updateUpdatedContractInstances(publicLogs, block.block.number, 1)
|
|
817
804
|
])).every(Boolean);
|
|
818
805
|
}),
|
|
819
|
-
this.store.deleteLogs(blocks.map((b)=>b.
|
|
806
|
+
this.store.deleteLogs(blocks.map((b)=>b.block)),
|
|
820
807
|
this.store.unwindBlocks(from, blocksToUnwind)
|
|
821
808
|
]);
|
|
822
809
|
return opResults.every(Boolean);
|
|
@@ -881,8 +868,8 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
881
868
|
getBytecodeCommitment(contractClassId) {
|
|
882
869
|
return this.store.getBytecodeCommitment(contractClassId);
|
|
883
870
|
}
|
|
884
|
-
getContractInstance(address) {
|
|
885
|
-
return this.store.getContractInstance(address);
|
|
871
|
+
getContractInstance(address, blockNumber) {
|
|
872
|
+
return this.store.getContractInstance(address, blockNumber);
|
|
886
873
|
}
|
|
887
874
|
getContractClassIds() {
|
|
888
875
|
return this.store.getContractClassIds();
|
|
@@ -8,7 +8,7 @@ import type { LogFilter, PrivateLog, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
|
8
8
|
import type { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
9
9
|
import { BlockHeader, type TxEffect, type TxHash, type TxReceipt } from '@aztec/stdlib/tx';
|
|
10
10
|
import type { DataRetrieval } from './structs/data_retrieval.js';
|
|
11
|
-
import type {
|
|
11
|
+
import type { PublishedL2Block } from './structs/published.js';
|
|
12
12
|
/**
|
|
13
13
|
* Represents the latest L1 block processed by the archiver for various objects in L2.
|
|
14
14
|
*/
|
|
@@ -30,7 +30,7 @@ export interface ArchiverDataStore {
|
|
|
30
30
|
* @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
|
|
31
31
|
* @returns True if the operation is successful.
|
|
32
32
|
*/
|
|
33
|
-
addBlocks(blocks:
|
|
33
|
+
addBlocks(blocks: PublishedL2Block[]): Promise<boolean>;
|
|
34
34
|
/**
|
|
35
35
|
* Unwinds blocks from the database
|
|
36
36
|
* @param from - The tip of the chain, passed for verification purposes,
|
|
@@ -45,7 +45,7 @@ export interface ArchiverDataStore {
|
|
|
45
45
|
* @param limit - The number of blocks to return.
|
|
46
46
|
* @returns The requested L2 blocks.
|
|
47
47
|
*/
|
|
48
|
-
getBlocks(from: number, limit: number): Promise<
|
|
48
|
+
getBlocks(from: number, limit: number): Promise<PublishedL2Block[]>;
|
|
49
49
|
/**
|
|
50
50
|
* Gets up to `limit` amount of L2 block headers starting from `from`.
|
|
51
51
|
* @param from - Number of the first block to return (inclusive).
|
|
@@ -202,8 +202,9 @@ export interface ArchiverDataStore {
|
|
|
202
202
|
/**
|
|
203
203
|
* Returns a contract instance given its address and the given block number, or undefined if not exists.
|
|
204
204
|
* @param address - Address of the contract.
|
|
205
|
+
* @param blockNumber - Block number to get the contract instance at. Contract updates might change the instance at a given block.
|
|
205
206
|
*/
|
|
206
|
-
getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
207
|
+
getContractInstance(address: AztecAddress, blockNumber: number): Promise<ContractInstanceWithAddress | undefined>;
|
|
207
208
|
/** Returns the list of all class ids known by the archiver. */
|
|
208
209
|
getContractClassIds(): Promise<Fr[]>;
|
|
209
210
|
registerContractFunctionSignatures(address: AztecAddress, signatures: string[]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver_store.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EACV,mBAAmB,EACnB,iCAAiC,EACjC,2BAA2B,EAC3B,4CAA4C,EAC5C,wCAAwC,EACzC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC3G,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"archiver_store.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAA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|
|
|
1
|
-
{"version":3,"file":"archiver_store_test_suite.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver_store_test_suite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"archiver_store_test_suite.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver_store_test_suite.ts"],"names":[],"mappings":"AA0BA,OAAO,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,qBAAqB,CAAC;AAGnF;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,QA0xB/D"}
|