@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.03f7ef2
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/README.md +27 -6
- package/dest/archiver/archiver.d.ts +201 -94
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +1141 -396
- package/dest/archiver/archiver_store.d.ts +171 -83
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +2389 -393
- package/dest/archiver/config.d.ts +7 -22
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +30 -14
- package/dest/archiver/errors.d.ts +33 -1
- package/dest/archiver/errors.d.ts.map +1 -1
- package/dest/archiver/errors.js +49 -0
- package/dest/archiver/index.d.ts +3 -4
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/index.js +1 -2
- package/dest/archiver/instrumentation.d.ts +14 -6
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +69 -17
- package/dest/archiver/kv_archiver_store/block_store.d.ts +91 -21
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +476 -86
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +4 -4
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +13 -19
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +12 -9
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +30 -16
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +80 -75
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +142 -83
- package/dest/archiver/kv_archiver_store/log_store.d.ts +12 -16
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +153 -113
- package/dest/archiver/kv_archiver_store/message_store.d.ts +25 -18
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +152 -49
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts +3 -0
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/archiver/l1/bin/retrieve-calldata.js +149 -0
- package/dest/archiver/l1/calldata_retriever.d.ts +112 -0
- package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/archiver/l1/calldata_retriever.js +471 -0
- package/dest/archiver/l1/data_retrieval.d.ts +90 -0
- package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
- package/dest/archiver/l1/data_retrieval.js +331 -0
- package/dest/archiver/l1/debug_tx.d.ts +19 -0
- package/dest/archiver/l1/debug_tx.d.ts.map +1 -0
- package/dest/archiver/l1/debug_tx.js +73 -0
- package/dest/archiver/l1/spire_proposer.d.ts +70 -0
- package/dest/archiver/l1/spire_proposer.d.ts.map +1 -0
- package/dest/archiver/l1/spire_proposer.js +157 -0
- package/dest/archiver/l1/trace_tx.d.ts +97 -0
- package/dest/archiver/l1/trace_tx.d.ts.map +1 -0
- package/dest/archiver/l1/trace_tx.js +91 -0
- package/dest/archiver/l1/types.d.ts +12 -0
- package/dest/archiver/l1/types.d.ts.map +1 -0
- package/dest/archiver/l1/types.js +3 -0
- package/dest/archiver/l1/validate_trace.d.ts +29 -0
- package/dest/archiver/l1/validate_trace.d.ts.map +1 -0
- package/dest/archiver/l1/validate_trace.js +150 -0
- package/dest/archiver/structs/data_retrieval.d.ts +1 -1
- package/dest/archiver/structs/inbox_message.d.ts +15 -0
- package/dest/archiver/structs/inbox_message.d.ts.map +1 -0
- package/dest/archiver/structs/inbox_message.js +39 -0
- package/dest/archiver/structs/published.d.ts +2 -11
- package/dest/archiver/structs/published.d.ts.map +1 -1
- package/dest/archiver/structs/published.js +1 -1
- package/dest/archiver/validation.d.ts +17 -0
- package/dest/archiver/validation.d.ts.map +1 -0
- package/dest/archiver/validation.js +98 -0
- package/dest/factory.d.ts +9 -14
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +22 -52
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/rpc/index.d.ts +2 -3
- package/dest/rpc/index.d.ts.map +1 -1
- package/dest/rpc/index.js +1 -4
- package/dest/test/index.d.ts +1 -1
- package/dest/test/mock_archiver.d.ts +16 -8
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +19 -14
- package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +21 -7
- package/dest/test/mock_l2_block_source.d.ts +52 -13
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +140 -15
- package/dest/test/mock_structs.d.ts +10 -0
- package/dest/test/mock_structs.d.ts.map +1 -0
- package/dest/test/mock_structs.js +38 -0
- package/package.json +29 -30
- package/src/archiver/archiver.ts +1477 -501
- package/src/archiver/archiver_store.ts +197 -88
- package/src/archiver/archiver_store_test_suite.ts +2403 -350
- package/src/archiver/config.ts +38 -46
- package/src/archiver/errors.ts +85 -0
- package/src/archiver/index.ts +2 -3
- package/src/archiver/instrumentation.ts +91 -22
- package/src/archiver/kv_archiver_store/block_store.ts +640 -101
- package/src/archiver/kv_archiver_store/contract_class_store.ts +14 -24
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +36 -28
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +193 -113
- package/src/archiver/kv_archiver_store/log_store.ts +205 -127
- package/src/archiver/kv_archiver_store/message_store.ts +213 -54
- package/src/archiver/l1/README.md +98 -0
- package/src/archiver/l1/bin/retrieve-calldata.ts +182 -0
- package/src/archiver/l1/calldata_retriever.ts +641 -0
- package/src/archiver/l1/data_retrieval.ts +512 -0
- package/src/archiver/l1/debug_tx.ts +99 -0
- package/src/archiver/l1/spire_proposer.ts +160 -0
- package/src/archiver/l1/trace_tx.ts +128 -0
- package/src/archiver/l1/types.ts +13 -0
- package/src/archiver/l1/validate_trace.ts +211 -0
- package/src/archiver/structs/inbox_message.ts +41 -0
- package/src/archiver/structs/published.ts +1 -11
- package/src/archiver/validation.ts +124 -0
- package/src/factory.ts +28 -69
- package/src/index.ts +1 -1
- package/src/rpc/index.ts +1 -5
- package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
- package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
- package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
- package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
- package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
- package/src/test/fixtures/trace_transaction-proxied.json +128 -0
- package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
- package/src/test/mock_archiver.ts +22 -16
- package/src/test/mock_l1_to_l2_message_source.ts +20 -8
- package/src/test/mock_l2_block_source.ts +186 -21
- package/src/test/mock_structs.ts +50 -0
- package/dest/archiver/data_retrieval.d.ts +0 -74
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.js +0 -283
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +0 -23
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
- package/src/archiver/data_retrieval.ts +0 -422
- package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +0 -61
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
3
|
import { BufferReader, numToUInt8, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
4
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
ContractClassPublic,
|
|
8
8
|
ContractClassPublicWithBlockNumber,
|
|
9
9
|
ExecutablePrivateFunctionWithMembershipProof,
|
|
10
|
-
|
|
10
|
+
UtilityFunctionWithMembershipProof,
|
|
11
11
|
} from '@aztec/stdlib/contract';
|
|
12
12
|
import { Vector } from '@aztec/stdlib/types';
|
|
13
13
|
|
|
@@ -60,7 +60,7 @@ export class ContractClassStore {
|
|
|
60
60
|
async addFunctions(
|
|
61
61
|
contractClassId: Fr,
|
|
62
62
|
newPrivateFunctions: ExecutablePrivateFunctionWithMembershipProof[],
|
|
63
|
-
|
|
63
|
+
newUtilityFunctions: UtilityFunctionWithMembershipProof[],
|
|
64
64
|
): Promise<boolean> {
|
|
65
65
|
await this.db.transactionAsync(async () => {
|
|
66
66
|
const existingClassBuffer = await this.#contractClasses.getAsync(contractClassId.toString());
|
|
@@ -69,7 +69,7 @@ export class ContractClassStore {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const existingClass = deserializeContractClassPublic(existingClassBuffer);
|
|
72
|
-
const { privateFunctions: existingPrivateFns,
|
|
72
|
+
const { privateFunctions: existingPrivateFns, utilityFunctions: existingUtilityFns } = existingClass;
|
|
73
73
|
|
|
74
74
|
const updatedClass: Omit<ContractClassPublicWithBlockNumber, 'id'> = {
|
|
75
75
|
...existingClass,
|
|
@@ -77,11 +77,9 @@ export class ContractClassStore {
|
|
|
77
77
|
...existingPrivateFns,
|
|
78
78
|
...newPrivateFunctions.filter(newFn => !existingPrivateFns.some(f => f.selector.equals(newFn.selector))),
|
|
79
79
|
],
|
|
80
|
-
|
|
81
|
-
...
|
|
82
|
-
...
|
|
83
|
-
newFn => !existingUnconstrainedFns.some(f => f.selector.equals(newFn.selector)),
|
|
84
|
-
),
|
|
80
|
+
utilityFunctions: [
|
|
81
|
+
...existingUtilityFns,
|
|
82
|
+
...newUtilityFunctions.filter(newFn => !existingUtilityFns.some(f => f.selector.equals(newFn.selector))),
|
|
85
83
|
],
|
|
86
84
|
};
|
|
87
85
|
await this.#contractClasses.set(contractClassId.toString(), serializeContractClassPublic(updatedClass));
|
|
@@ -96,12 +94,10 @@ function serializeContractClassPublic(contractClass: Omit<ContractClassPublicWit
|
|
|
96
94
|
contractClass.l2BlockNumber,
|
|
97
95
|
numToUInt8(contractClass.version),
|
|
98
96
|
contractClass.artifactHash,
|
|
99
|
-
contractClass.publicFunctions.length,
|
|
100
|
-
contractClass.publicFunctions?.map(f => serializeToBuffer(f.selector, f.bytecode.length, f.bytecode)) ?? [],
|
|
101
97
|
contractClass.privateFunctions.length,
|
|
102
98
|
contractClass.privateFunctions.map(serializePrivateFunction),
|
|
103
|
-
contractClass.
|
|
104
|
-
contractClass.
|
|
99
|
+
contractClass.utilityFunctions.length,
|
|
100
|
+
contractClass.utilityFunctions.map(serializeUtilityFunction),
|
|
105
101
|
contractClass.packedBytecode.length,
|
|
106
102
|
contractClass.packedBytecode,
|
|
107
103
|
contractClass.privateFunctionsRoot,
|
|
@@ -116,7 +112,7 @@ function serializePrivateFunction(fn: ExecutablePrivateFunctionWithMembershipPro
|
|
|
116
112
|
fn.bytecode,
|
|
117
113
|
fn.functionMetadataHash,
|
|
118
114
|
fn.artifactMetadataHash,
|
|
119
|
-
fn.
|
|
115
|
+
fn.utilityFunctionsTreeRoot,
|
|
120
116
|
new Vector(fn.privateFunctionTreeSiblingPath),
|
|
121
117
|
fn.privateFunctionTreeLeafIndex,
|
|
122
118
|
new Vector(fn.artifactTreeSiblingPath),
|
|
@@ -124,7 +120,7 @@ function serializePrivateFunction(fn: ExecutablePrivateFunctionWithMembershipPro
|
|
|
124
120
|
);
|
|
125
121
|
}
|
|
126
122
|
|
|
127
|
-
function
|
|
123
|
+
function serializeUtilityFunction(fn: UtilityFunctionWithMembershipProof): Buffer {
|
|
128
124
|
return serializeToBuffer(
|
|
129
125
|
fn.selector,
|
|
130
126
|
fn.bytecode.length,
|
|
@@ -143,14 +139,8 @@ function deserializeContractClassPublic(buffer: Buffer): Omit<ContractClassPubli
|
|
|
143
139
|
l2BlockNumber: reader.readNumber(),
|
|
144
140
|
version: reader.readUInt8() as 1,
|
|
145
141
|
artifactHash: reader.readObject(Fr),
|
|
146
|
-
publicFunctions: reader.readVector({
|
|
147
|
-
fromBuffer: reader => ({
|
|
148
|
-
selector: reader.readObject(FunctionSelector),
|
|
149
|
-
bytecode: reader.readBuffer(),
|
|
150
|
-
}),
|
|
151
|
-
}),
|
|
152
142
|
privateFunctions: reader.readVector({ fromBuffer: deserializePrivateFunction }),
|
|
153
|
-
|
|
143
|
+
utilityFunctions: reader.readVector({ fromBuffer: deserializeUtilityFunction }),
|
|
154
144
|
packedBytecode: reader.readBuffer(),
|
|
155
145
|
privateFunctionsRoot: reader.readObject(Fr),
|
|
156
146
|
};
|
|
@@ -164,7 +154,7 @@ function deserializePrivateFunction(buffer: Buffer | BufferReader): ExecutablePr
|
|
|
164
154
|
bytecode: reader.readBuffer(),
|
|
165
155
|
functionMetadataHash: reader.readObject(Fr),
|
|
166
156
|
artifactMetadataHash: reader.readObject(Fr),
|
|
167
|
-
|
|
157
|
+
utilityFunctionsTreeRoot: reader.readObject(Fr),
|
|
168
158
|
privateFunctionTreeSiblingPath: reader.readVector(Fr),
|
|
169
159
|
privateFunctionTreeLeafIndex: reader.readNumber(),
|
|
170
160
|
artifactTreeSiblingPath: reader.readVector(Fr),
|
|
@@ -172,7 +162,7 @@ function deserializePrivateFunction(buffer: Buffer | BufferReader): ExecutablePr
|
|
|
172
162
|
};
|
|
173
163
|
}
|
|
174
164
|
|
|
175
|
-
function
|
|
165
|
+
function deserializeUtilityFunction(buffer: Buffer | BufferReader): UtilityFunctionWithMembershipProof {
|
|
176
166
|
const reader = BufferReader.asReader(buffer);
|
|
177
167
|
return {
|
|
178
168
|
selector: reader.readObject(FunctionSelector),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import {
|
|
@@ -7,71 +7,75 @@ import {
|
|
|
7
7
|
SerializableContractInstance,
|
|
8
8
|
SerializableContractInstanceUpdate,
|
|
9
9
|
} from '@aztec/stdlib/contract';
|
|
10
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
10
11
|
|
|
11
|
-
type ContractInstanceUpdateKey = [string,
|
|
12
|
+
type ContractInstanceUpdateKey = [string, string] | [string, string, number];
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* LMDB implementation of the ArchiverDataStore interface.
|
|
15
16
|
*/
|
|
16
17
|
export class ContractInstanceStore {
|
|
17
18
|
#contractInstances: AztecAsyncMap<string, Buffer>;
|
|
19
|
+
#contractInstancePublishedAt: AztecAsyncMap<string, number>;
|
|
18
20
|
#contractInstanceUpdates: AztecAsyncMap<ContractInstanceUpdateKey, Buffer>;
|
|
19
21
|
|
|
20
|
-
constructor(db: AztecAsyncKVStore) {
|
|
22
|
+
constructor(private db: AztecAsyncKVStore) {
|
|
21
23
|
this.#contractInstances = db.openMap('archiver_contract_instances');
|
|
24
|
+
this.#contractInstancePublishedAt = db.openMap('archiver_contract_instances_publication_block_number');
|
|
22
25
|
this.#contractInstanceUpdates = db.openMap('archiver_contract_instance_updates');
|
|
23
26
|
}
|
|
24
27
|
|
|
25
|
-
addContractInstance(contractInstance: ContractInstanceWithAddress): Promise<void> {
|
|
26
|
-
return this
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
addContractInstance(contractInstance: ContractInstanceWithAddress, blockNumber: number): Promise<void> {
|
|
29
|
+
return this.db.transactionAsync(async () => {
|
|
30
|
+
await this.#contractInstances.set(
|
|
31
|
+
contractInstance.address.toString(),
|
|
32
|
+
new SerializableContractInstance(contractInstance).toBuffer(),
|
|
33
|
+
);
|
|
34
|
+
await this.#contractInstancePublishedAt.set(contractInstance.address.toString(), blockNumber);
|
|
35
|
+
});
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
deleteContractInstance(contractInstance: ContractInstanceWithAddress): Promise<void> {
|
|
33
|
-
return this
|
|
39
|
+
return this.db.transactionAsync(async () => {
|
|
40
|
+
await this.#contractInstances.delete(contractInstance.address.toString());
|
|
41
|
+
await this.#contractInstancePublishedAt.delete(contractInstance.address.toString());
|
|
42
|
+
});
|
|
34
43
|
}
|
|
35
44
|
|
|
36
|
-
getUpdateKey(contractAddress: AztecAddress,
|
|
45
|
+
getUpdateKey(contractAddress: AztecAddress, timestamp: UInt64, logIndex?: number): ContractInstanceUpdateKey {
|
|
37
46
|
if (logIndex === undefined) {
|
|
38
|
-
return [contractAddress.toString(),
|
|
47
|
+
return [contractAddress.toString(), timestamp.toString()];
|
|
39
48
|
} else {
|
|
40
|
-
return [contractAddress.toString(),
|
|
49
|
+
return [contractAddress.toString(), timestamp.toString(), logIndex];
|
|
41
50
|
}
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
addContractInstanceUpdate(
|
|
45
54
|
contractInstanceUpdate: ContractInstanceUpdateWithAddress,
|
|
46
|
-
|
|
55
|
+
timestamp: UInt64,
|
|
47
56
|
logIndex: number,
|
|
48
57
|
): Promise<void> {
|
|
49
58
|
return this.#contractInstanceUpdates.set(
|
|
50
|
-
this.getUpdateKey(contractInstanceUpdate.address,
|
|
59
|
+
this.getUpdateKey(contractInstanceUpdate.address, timestamp, logIndex),
|
|
51
60
|
new SerializableContractInstanceUpdate(contractInstanceUpdate).toBuffer(),
|
|
52
61
|
);
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
deleteContractInstanceUpdate(
|
|
56
65
|
contractInstanceUpdate: ContractInstanceUpdateWithAddress,
|
|
57
|
-
|
|
66
|
+
timestamp: UInt64,
|
|
58
67
|
logIndex: number,
|
|
59
68
|
): Promise<void> {
|
|
60
|
-
return this.#contractInstanceUpdates.delete(
|
|
61
|
-
this.getUpdateKey(contractInstanceUpdate.address, blockNumber, logIndex),
|
|
62
|
-
);
|
|
69
|
+
return this.#contractInstanceUpdates.delete(this.getUpdateKey(contractInstanceUpdate.address, timestamp, logIndex));
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
async getCurrentContractInstanceClassId(
|
|
66
|
-
|
|
67
|
-
blockNumber: number,
|
|
68
|
-
originalClassId: Fr,
|
|
69
|
-
): Promise<Fr> {
|
|
70
|
-
// We need to find the last update before the given block number
|
|
72
|
+
async getCurrentContractInstanceClassId(address: AztecAddress, timestamp: UInt64, originalClassId: Fr): Promise<Fr> {
|
|
73
|
+
// We need to find the last update before the given timestamp
|
|
71
74
|
const queryResult = await this.#contractInstanceUpdates
|
|
72
75
|
.valuesAsync({
|
|
73
76
|
reverse: true,
|
|
74
|
-
|
|
77
|
+
start: this.getUpdateKey(address, 0n), // Make sure we only look at updates for this contract
|
|
78
|
+
end: this.getUpdateKey(address, timestamp + 1n), // No update can match this key since it doesn't have a log index. We want the highest key <= timestamp
|
|
75
79
|
limit: 1,
|
|
76
80
|
})
|
|
77
81
|
.next();
|
|
@@ -81,7 +85,7 @@ export class ContractInstanceStore {
|
|
|
81
85
|
|
|
82
86
|
const serializedUpdate = queryResult.value;
|
|
83
87
|
const update = SerializableContractInstanceUpdate.fromBuffer(serializedUpdate);
|
|
84
|
-
if (
|
|
88
|
+
if (timestamp < update.timestampOfChange) {
|
|
85
89
|
return update.prevContractClassId.isZero() ? originalClassId : update.prevContractClassId;
|
|
86
90
|
}
|
|
87
91
|
return update.newContractClassId;
|
|
@@ -89,7 +93,7 @@ export class ContractInstanceStore {
|
|
|
89
93
|
|
|
90
94
|
async getContractInstance(
|
|
91
95
|
address: AztecAddress,
|
|
92
|
-
|
|
96
|
+
timestamp: UInt64,
|
|
93
97
|
): Promise<ContractInstanceWithAddress | undefined> {
|
|
94
98
|
const contractInstance = await this.#contractInstances.getAsync(address.toString());
|
|
95
99
|
if (!contractInstance) {
|
|
@@ -99,9 +103,13 @@ export class ContractInstanceStore {
|
|
|
99
103
|
const instance = SerializableContractInstance.fromBuffer(contractInstance).withAddress(address);
|
|
100
104
|
instance.currentContractClassId = await this.getCurrentContractInstanceClassId(
|
|
101
105
|
address,
|
|
102
|
-
|
|
106
|
+
timestamp,
|
|
103
107
|
instance.originalContractClassId,
|
|
104
108
|
);
|
|
105
109
|
return instance;
|
|
106
110
|
}
|
|
111
|
+
|
|
112
|
+
getContractInstanceDeploymentBlockNumber(address: AztecAddress): Promise<number | undefined> {
|
|
113
|
+
return this.#contractInstancePublishedAt.getAsync(address.toString());
|
|
114
|
+
}
|
|
107
115
|
}
|