@aztec/txe 0.0.1-commit.1142ef1 → 0.0.1-commit.11bf3dd6e
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/constants.d.ts +1 -2
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +0 -1
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +88 -54
- package/dest/oracle/interfaces.d.ts +29 -28
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +16 -16
- package/dest/oracle/txe_oracle_top_level_context.d.ts +28 -22
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +165 -71
- package/dest/rpc_translator.d.ts +125 -81
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +426 -179
- package/dest/state_machine/archiver.d.ts +20 -69
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +36 -179
- package/dest/state_machine/dummy_p2p_client.d.ts +18 -13
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +33 -18
- package/dest/state_machine/global_variable_builder.d.ts +9 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +9 -3
- package/dest/state_machine/index.d.ts +7 -5
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +40 -13
- package/dest/state_machine/mock_epoch_cache.d.ts +25 -8
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +46 -9
- package/dest/state_machine/synchronizer.d.ts +6 -6
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +3 -3
- package/dest/txe_session.d.ts +12 -6
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +115 -28
- package/dest/util/encoding.d.ts +88 -18
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +4 -0
- package/dest/util/txe_public_contract_data_source.d.ts +2 -3
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +6 -25
- package/dest/utils/block_creation.d.ts +4 -4
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +18 -4
- package/dest/utils/tx_effect_creation.d.ts +2 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +3 -6
- package/package.json +16 -16
- package/src/constants.ts +0 -1
- package/src/index.ts +89 -52
- package/src/oracle/interfaces.ts +32 -31
- package/src/oracle/txe_oracle_public_context.ts +16 -18
- package/src/oracle/txe_oracle_top_level_context.ts +208 -123
- package/src/rpc_translator.ts +493 -204
- package/src/state_machine/archiver.ts +38 -234
- package/src/state_machine/dummy_p2p_client.ts +46 -24
- package/src/state_machine/global_variable_builder.ts +18 -3
- package/src/state_machine/index.ts +56 -12
- package/src/state_machine/mock_epoch_cache.ts +57 -14
- package/src/state_machine/synchronizer.ts +5 -5
- package/src/txe_session.ts +132 -88
- package/src/util/encoding.ts +5 -0
- package/src/util/txe_public_contract_data_source.ts +10 -38
- package/src/utils/block_creation.ts +19 -16
- package/src/utils/tx_effect_creation.ts +3 -11
- package/dest/util/txe_contract_store.d.ts +0 -12
- package/dest/util/txe_contract_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.js +0 -22
- package/src/util/txe_contract_store.ts +0 -36
package/src/rpc_translator.ts
CHANGED
|
@@ -6,11 +6,10 @@ import {
|
|
|
6
6
|
type IMiscOracle,
|
|
7
7
|
type IPrivateExecutionOracle,
|
|
8
8
|
type IUtilityExecutionOracle,
|
|
9
|
-
|
|
9
|
+
packAsHintedNote,
|
|
10
10
|
} from '@aztec/pxe/simulator';
|
|
11
11
|
import { type ContractArtifact, EventSelector, FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
12
12
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
14
13
|
|
|
15
14
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
16
15
|
import type { TXESessionStateHandler } from './txe_session.js';
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
addressFromSingle,
|
|
21
20
|
arrayOfArraysToBoundedVecOfArrays,
|
|
22
21
|
arrayToBoundedVec,
|
|
22
|
+
blockHashFromSingle,
|
|
23
23
|
bufferToU8Array,
|
|
24
24
|
fromArray,
|
|
25
25
|
fromSingle,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
toSingle,
|
|
31
31
|
} from './util/encoding.js';
|
|
32
32
|
|
|
33
|
-
const MAX_EVENT_LEN =
|
|
33
|
+
const MAX_EVENT_LEN = 10; // This is MAX_MESSAGE_CONTENT_LEN - PRIVATE_EVENT_MSG_PLAINTEXT_RESERVED_FIELDS_LEN
|
|
34
34
|
const MAX_PRIVATE_EVENTS_PER_TXE_QUERY = 5;
|
|
35
35
|
|
|
36
36
|
export class UnavailableOracleError extends Error {
|
|
@@ -104,13 +104,15 @@ export class RPCTranslator {
|
|
|
104
104
|
|
|
105
105
|
// TXE session state transition functions - these get handled by the state handler
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
// eslint-disable-next-line camelcase
|
|
108
|
+
async aztec_txe_setTopLevelTXEContext() {
|
|
108
109
|
await this.stateHandler.enterTopLevelState();
|
|
109
110
|
|
|
110
111
|
return toForeignCallResult([]);
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
// eslint-disable-next-line camelcase
|
|
115
|
+
async aztec_txe_setPrivateTXEContext(
|
|
114
116
|
foreignContractAddressIsSome: ForeignCallSingle,
|
|
115
117
|
foreignContractAddressValue: ForeignCallSingle,
|
|
116
118
|
foreignAnchorBlockNumberIsSome: ForeignCallSingle,
|
|
@@ -129,7 +131,8 @@ export class RPCTranslator {
|
|
|
129
131
|
return toForeignCallResult(privateContextInputs.toFields().map(toSingle));
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
|
|
134
|
+
// eslint-disable-next-line camelcase
|
|
135
|
+
async aztec_txe_setPublicTXEContext(
|
|
133
136
|
foreignContractAddressIsSome: ForeignCallSingle,
|
|
134
137
|
foreignContractAddressValue: ForeignCallSingle,
|
|
135
138
|
) {
|
|
@@ -142,7 +145,8 @@ export class RPCTranslator {
|
|
|
142
145
|
return toForeignCallResult([]);
|
|
143
146
|
}
|
|
144
147
|
|
|
145
|
-
|
|
148
|
+
// eslint-disable-next-line camelcase
|
|
149
|
+
async aztec_txe_setUtilityTXEContext(
|
|
146
150
|
foreignContractAddressIsSome: ForeignCallSingle,
|
|
147
151
|
foreignContractAddressValue: ForeignCallSingle,
|
|
148
152
|
) {
|
|
@@ -159,44 +163,54 @@ export class RPCTranslator {
|
|
|
159
163
|
|
|
160
164
|
// TXE-specific oracles
|
|
161
165
|
|
|
162
|
-
|
|
163
|
-
|
|
166
|
+
// eslint-disable-next-line camelcase
|
|
167
|
+
aztec_txe_getDefaultAddress() {
|
|
168
|
+
const defaultAddress = this.handlerAsTxe().getDefaultAddress();
|
|
164
169
|
|
|
165
170
|
return toForeignCallResult([toSingle(defaultAddress)]);
|
|
166
171
|
}
|
|
167
172
|
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
// eslint-disable-next-line camelcase
|
|
174
|
+
async aztec_txe_getNextBlockNumber() {
|
|
175
|
+
const nextBlockNumber = await this.handlerAsTxe().getNextBlockNumber();
|
|
170
176
|
|
|
171
177
|
return toForeignCallResult([toSingle(nextBlockNumber)]);
|
|
172
178
|
}
|
|
173
179
|
|
|
174
|
-
|
|
175
|
-
|
|
180
|
+
// eslint-disable-next-line camelcase
|
|
181
|
+
async aztec_txe_getNextBlockTimestamp() {
|
|
182
|
+
const nextBlockTimestamp = await this.handlerAsTxe().getNextBlockTimestamp();
|
|
176
183
|
|
|
177
184
|
return toForeignCallResult([toSingle(nextBlockTimestamp)]);
|
|
178
185
|
}
|
|
179
186
|
|
|
180
|
-
|
|
187
|
+
// eslint-disable-next-line camelcase
|
|
188
|
+
async aztec_txe_advanceBlocksBy(foreignBlocks: ForeignCallSingle) {
|
|
181
189
|
const blocks = fromSingle(foreignBlocks).toNumber();
|
|
182
190
|
|
|
183
|
-
await this.handlerAsTxe().
|
|
191
|
+
await this.handlerAsTxe().advanceBlocksBy(blocks);
|
|
184
192
|
|
|
185
193
|
return toForeignCallResult([]);
|
|
186
194
|
}
|
|
187
195
|
|
|
188
|
-
|
|
196
|
+
// eslint-disable-next-line camelcase
|
|
197
|
+
aztec_txe_advanceTimestampBy(foreignDuration: ForeignCallSingle) {
|
|
189
198
|
const duration = fromSingle(foreignDuration).toBigInt();
|
|
190
199
|
|
|
191
|
-
this.handlerAsTxe().
|
|
200
|
+
this.handlerAsTxe().advanceTimestampBy(duration);
|
|
192
201
|
|
|
193
202
|
return toForeignCallResult([]);
|
|
194
203
|
}
|
|
195
204
|
|
|
196
|
-
|
|
205
|
+
// eslint-disable-next-line camelcase
|
|
206
|
+
async aztec_txe_deploy(
|
|
207
|
+
artifact: ContractArtifact,
|
|
208
|
+
instance: ContractInstanceWithAddress,
|
|
209
|
+
foreignSecret: ForeignCallSingle,
|
|
210
|
+
) {
|
|
197
211
|
const secret = fromSingle(foreignSecret);
|
|
198
212
|
|
|
199
|
-
await this.handlerAsTxe().
|
|
213
|
+
await this.handlerAsTxe().deploy(artifact, instance, secret);
|
|
200
214
|
|
|
201
215
|
return toForeignCallResult([
|
|
202
216
|
toArray([
|
|
@@ -209,10 +223,11 @@ export class RPCTranslator {
|
|
|
209
223
|
]);
|
|
210
224
|
}
|
|
211
225
|
|
|
212
|
-
|
|
226
|
+
// eslint-disable-next-line camelcase
|
|
227
|
+
async aztec_txe_createAccount(foreignSecret: ForeignCallSingle) {
|
|
213
228
|
const secret = fromSingle(foreignSecret);
|
|
214
229
|
|
|
215
|
-
const completeAddress = await this.handlerAsTxe().
|
|
230
|
+
const completeAddress = await this.handlerAsTxe().createAccount(secret);
|
|
216
231
|
|
|
217
232
|
return toForeignCallResult([
|
|
218
233
|
toSingle(completeAddress.address),
|
|
@@ -220,14 +235,15 @@ export class RPCTranslator {
|
|
|
220
235
|
]);
|
|
221
236
|
}
|
|
222
237
|
|
|
223
|
-
|
|
238
|
+
// eslint-disable-next-line camelcase
|
|
239
|
+
async aztec_txe_addAccount(
|
|
224
240
|
artifact: ContractArtifact,
|
|
225
241
|
instance: ContractInstanceWithAddress,
|
|
226
242
|
foreignSecret: ForeignCallSingle,
|
|
227
243
|
) {
|
|
228
244
|
const secret = fromSingle(foreignSecret);
|
|
229
245
|
|
|
230
|
-
const completeAddress = await this.handlerAsTxe().
|
|
246
|
+
const completeAddress = await this.handlerAsTxe().addAccount(artifact, instance, secret);
|
|
231
247
|
|
|
232
248
|
return toForeignCallResult([
|
|
233
249
|
toSingle(completeAddress.address),
|
|
@@ -235,39 +251,45 @@ export class RPCTranslator {
|
|
|
235
251
|
]);
|
|
236
252
|
}
|
|
237
253
|
|
|
238
|
-
|
|
254
|
+
// eslint-disable-next-line camelcase
|
|
255
|
+
async aztec_txe_addAuthWitness(foreignAddress: ForeignCallSingle, foreignMessageHash: ForeignCallSingle) {
|
|
239
256
|
const address = addressFromSingle(foreignAddress);
|
|
240
257
|
const messageHash = fromSingle(foreignMessageHash);
|
|
241
258
|
|
|
242
|
-
await this.handlerAsTxe().
|
|
259
|
+
await this.handlerAsTxe().addAuthWitness(address, messageHash);
|
|
243
260
|
|
|
244
261
|
return toForeignCallResult([]);
|
|
245
262
|
}
|
|
246
263
|
|
|
247
264
|
// PXE oracles
|
|
248
265
|
|
|
249
|
-
|
|
250
|
-
|
|
266
|
+
// eslint-disable-next-line camelcase
|
|
267
|
+
aztec_utl_assertCompatibleOracleVersionV2(foreignMajor: ForeignCallSingle, foreignMinor: ForeignCallSingle) {
|
|
268
|
+
const major = fromSingle(foreignMajor).toNumber();
|
|
269
|
+
const minor = fromSingle(foreignMinor).toNumber();
|
|
251
270
|
|
|
252
|
-
this.handlerAsMisc().
|
|
271
|
+
this.handlerAsMisc().assertCompatibleOracleVersion(major, minor);
|
|
253
272
|
|
|
254
273
|
return toForeignCallResult([]);
|
|
255
274
|
}
|
|
256
275
|
|
|
257
|
-
|
|
258
|
-
|
|
276
|
+
// eslint-disable-next-line camelcase
|
|
277
|
+
aztec_utl_getRandomField() {
|
|
278
|
+
const randomField = this.handlerAsMisc().getRandomField();
|
|
259
279
|
|
|
260
280
|
return toForeignCallResult([toSingle(randomField)]);
|
|
261
281
|
}
|
|
262
282
|
|
|
263
|
-
|
|
264
|
-
|
|
283
|
+
// eslint-disable-next-line camelcase
|
|
284
|
+
async aztec_txe_getLastBlockTimestamp() {
|
|
285
|
+
const timestamp = await this.handlerAsTxe().getLastBlockTimestamp();
|
|
265
286
|
|
|
266
287
|
return toForeignCallResult([toSingle(new Fr(timestamp))]);
|
|
267
288
|
}
|
|
268
289
|
|
|
269
|
-
|
|
270
|
-
|
|
290
|
+
// eslint-disable-next-line camelcase
|
|
291
|
+
async aztec_txe_getLastTxEffects() {
|
|
292
|
+
const { txHash, noteHashes, nullifiers } = await this.handlerAsTxe().getLastTxEffects();
|
|
271
293
|
|
|
272
294
|
return toForeignCallResult([
|
|
273
295
|
toSingle(txHash.hash),
|
|
@@ -276,7 +298,8 @@ export class RPCTranslator {
|
|
|
276
298
|
]);
|
|
277
299
|
}
|
|
278
300
|
|
|
279
|
-
|
|
301
|
+
// eslint-disable-next-line camelcase
|
|
302
|
+
async aztec_txe_getPrivateEvents(
|
|
280
303
|
foreignSelector: ForeignCallSingle,
|
|
281
304
|
foreignContractAddress: ForeignCallSingle,
|
|
282
305
|
foreignScope: ForeignCallSingle,
|
|
@@ -285,7 +308,14 @@ export class RPCTranslator {
|
|
|
285
308
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
286
309
|
const scope = addressFromSingle(foreignScope);
|
|
287
310
|
|
|
288
|
-
|
|
311
|
+
// TODO(F-335): Avoid doing the following 2 calls here.
|
|
312
|
+
{
|
|
313
|
+
await this.handlerAsTxe().syncContractNonOracleMethod(contractAddress, scope, this.stateHandler.getCurrentJob());
|
|
314
|
+
// We cycle job to commit the stores after the contract sync.
|
|
315
|
+
await this.stateHandler.cycleJob();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const events = await this.handlerAsTxe().getPrivateEvents(selector, contractAddress, scope);
|
|
289
319
|
|
|
290
320
|
if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
|
|
291
321
|
throw new Error(`Array of length ${events.length} larger than maxLen ${MAX_PRIVATE_EVENTS_PER_TXE_QUERY}`);
|
|
@@ -309,26 +339,29 @@ export class RPCTranslator {
|
|
|
309
339
|
return toForeignCallResult([toArray(rawArrayStorage), toArray(eventLengths), toSingle(queryLength)]);
|
|
310
340
|
}
|
|
311
341
|
|
|
312
|
-
|
|
342
|
+
// eslint-disable-next-line camelcase
|
|
343
|
+
aztec_prv_setHashPreimage(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
|
|
313
344
|
const values = fromArray(foreignValues);
|
|
314
345
|
const hash = fromSingle(foreignHash);
|
|
315
346
|
|
|
316
|
-
this.handlerAsPrivate().
|
|
347
|
+
this.handlerAsPrivate().setHashPreimage(values, hash);
|
|
317
348
|
|
|
318
349
|
return toForeignCallResult([]);
|
|
319
350
|
}
|
|
320
351
|
|
|
321
|
-
|
|
352
|
+
// eslint-disable-next-line camelcase
|
|
353
|
+
async aztec_prv_getHashPreimage(foreignHash: ForeignCallSingle) {
|
|
322
354
|
const hash = fromSingle(foreignHash);
|
|
323
355
|
|
|
324
|
-
const returns = await this.handlerAsPrivate().
|
|
356
|
+
const returns = await this.handlerAsPrivate().getHashPreimage(hash);
|
|
325
357
|
|
|
326
358
|
return toForeignCallResult([toArray(returns)]);
|
|
327
359
|
}
|
|
328
360
|
|
|
329
361
|
// When the argument is a slice, noir automatically adds a length field to oracle call.
|
|
330
362
|
// When the argument is an array, we add the field length manually to the signature.
|
|
331
|
-
|
|
363
|
+
// eslint-disable-next-line camelcase
|
|
364
|
+
async aztec_utl_log(
|
|
332
365
|
foreignLevel: ForeignCallSingle,
|
|
333
366
|
foreignMessage: ForeignCallArray,
|
|
334
367
|
_foreignLength: ForeignCallSingle,
|
|
@@ -340,45 +373,48 @@ export class RPCTranslator {
|
|
|
340
373
|
.join('');
|
|
341
374
|
const fields = fromArray(foreignFields);
|
|
342
375
|
|
|
343
|
-
this.handlerAsMisc().
|
|
376
|
+
await this.handlerAsMisc().log(level, message, fields);
|
|
344
377
|
|
|
345
378
|
return toForeignCallResult([]);
|
|
346
379
|
}
|
|
347
380
|
|
|
348
|
-
|
|
381
|
+
// eslint-disable-next-line camelcase
|
|
382
|
+
async aztec_utl_getFromPublicStorage(
|
|
383
|
+
foreignBlockHash: ForeignCallSingle,
|
|
349
384
|
foreignContractAddress: ForeignCallSingle,
|
|
350
385
|
foreignStartStorageSlot: ForeignCallSingle,
|
|
351
|
-
foreignBlockNumber: ForeignCallSingle,
|
|
352
386
|
foreignNumberOfElements: ForeignCallSingle,
|
|
353
387
|
) {
|
|
388
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
354
389
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
355
390
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
356
|
-
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
357
391
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
358
392
|
|
|
359
|
-
const values = await this.handlerAsUtility().
|
|
393
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(
|
|
394
|
+
blockHash,
|
|
360
395
|
contractAddress,
|
|
361
396
|
startStorageSlot,
|
|
362
|
-
blockNumber,
|
|
363
397
|
numberOfElements,
|
|
364
398
|
);
|
|
365
399
|
|
|
366
400
|
return toForeignCallResult([toArray(values)]);
|
|
367
401
|
}
|
|
368
402
|
|
|
369
|
-
|
|
370
|
-
|
|
403
|
+
// eslint-disable-next-line camelcase
|
|
404
|
+
async aztec_utl_getPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
405
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
371
406
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
372
407
|
|
|
373
|
-
const witness = await this.handlerAsUtility().
|
|
408
|
+
const witness = await this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot);
|
|
374
409
|
|
|
375
410
|
if (!witness) {
|
|
376
|
-
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${
|
|
411
|
+
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockHash.toString()}.`);
|
|
377
412
|
}
|
|
378
413
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
379
414
|
}
|
|
380
415
|
|
|
381
|
-
|
|
416
|
+
// eslint-disable-next-line camelcase
|
|
417
|
+
async aztec_utl_getNotes(
|
|
382
418
|
foreignOwnerIsSome: ForeignCallSingle,
|
|
383
419
|
foreignOwnerValue: ForeignCallSingle,
|
|
384
420
|
foreignStorageSlot: ForeignCallSingle,
|
|
@@ -396,7 +432,7 @@ export class RPCTranslator {
|
|
|
396
432
|
foreignOffset: ForeignCallSingle,
|
|
397
433
|
foreignStatus: ForeignCallSingle,
|
|
398
434
|
foreignMaxNotes: ForeignCallSingle,
|
|
399
|
-
|
|
435
|
+
foreignPackedHintedNoteLength: ForeignCallSingle,
|
|
400
436
|
) {
|
|
401
437
|
// Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
|
|
402
438
|
const owner = fromSingle(foreignOwnerIsSome).toBool()
|
|
@@ -417,9 +453,9 @@ export class RPCTranslator {
|
|
|
417
453
|
const offset = fromSingle(foreignOffset).toNumber();
|
|
418
454
|
const status = fromSingle(foreignStatus).toNumber();
|
|
419
455
|
const maxNotes = fromSingle(foreignMaxNotes).toNumber();
|
|
420
|
-
const
|
|
456
|
+
const packedHintedNoteLength = fromSingle(foreignPackedHintedNoteLength).toNumber();
|
|
421
457
|
|
|
422
|
-
const noteDatas = await this.handlerAsUtility().
|
|
458
|
+
const noteDatas = await this.handlerAsUtility().getNotes(
|
|
423
459
|
owner,
|
|
424
460
|
storageSlot,
|
|
425
461
|
numSelects,
|
|
@@ -438,13 +474,13 @@ export class RPCTranslator {
|
|
|
438
474
|
);
|
|
439
475
|
|
|
440
476
|
const returnDataAsArrayOfArrays = noteDatas.map(noteData =>
|
|
441
|
-
|
|
477
|
+
packAsHintedNote({
|
|
442
478
|
contractAddress: noteData.contractAddress,
|
|
443
479
|
owner: noteData.owner,
|
|
444
480
|
randomness: noteData.randomness,
|
|
445
481
|
storageSlot: noteData.storageSlot,
|
|
446
482
|
noteNonce: noteData.noteNonce,
|
|
447
|
-
|
|
483
|
+
isPending: noteData.isPending,
|
|
448
484
|
note: noteData.note,
|
|
449
485
|
}),
|
|
450
486
|
);
|
|
@@ -456,15 +492,12 @@ export class RPCTranslator {
|
|
|
456
492
|
|
|
457
493
|
// At last we convert the array of arrays to a bounded vec of arrays
|
|
458
494
|
return toForeignCallResult(
|
|
459
|
-
arrayOfArraysToBoundedVecOfArrays(
|
|
460
|
-
returnDataAsArrayOfForeignCallSingleArrays,
|
|
461
|
-
maxNotes,
|
|
462
|
-
packedRetrievedNoteLength,
|
|
463
|
-
),
|
|
495
|
+
arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfForeignCallSingleArrays, maxNotes, packedHintedNoteLength),
|
|
464
496
|
);
|
|
465
497
|
}
|
|
466
498
|
|
|
467
|
-
|
|
499
|
+
// eslint-disable-next-line camelcase
|
|
500
|
+
aztec_prv_notifyCreatedNote(
|
|
468
501
|
foreignOwner: ForeignCallSingle,
|
|
469
502
|
foreignStorageSlot: ForeignCallSingle,
|
|
470
503
|
foreignRandomness: ForeignCallSingle,
|
|
@@ -481,20 +514,13 @@ export class RPCTranslator {
|
|
|
481
514
|
const noteHash = fromSingle(foreignNoteHash);
|
|
482
515
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
483
516
|
|
|
484
|
-
this.handlerAsPrivate().
|
|
485
|
-
owner,
|
|
486
|
-
storageSlot,
|
|
487
|
-
randomness,
|
|
488
|
-
noteTypeId,
|
|
489
|
-
note,
|
|
490
|
-
noteHash,
|
|
491
|
-
counter,
|
|
492
|
-
);
|
|
517
|
+
this.handlerAsPrivate().notifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter);
|
|
493
518
|
|
|
494
519
|
return toForeignCallResult([]);
|
|
495
520
|
}
|
|
496
521
|
|
|
497
|
-
|
|
522
|
+
// eslint-disable-next-line camelcase
|
|
523
|
+
async aztec_prv_notifyNullifiedNote(
|
|
498
524
|
foreignInnerNullifier: ForeignCallSingle,
|
|
499
525
|
foreignNoteHash: ForeignCallSingle,
|
|
500
526
|
foreignCounter: ForeignCallSingle,
|
|
@@ -503,31 +529,47 @@ export class RPCTranslator {
|
|
|
503
529
|
const noteHash = fromSingle(foreignNoteHash);
|
|
504
530
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
505
531
|
|
|
506
|
-
await this.handlerAsPrivate().
|
|
532
|
+
await this.handlerAsPrivate().notifyNullifiedNote(innerNullifier, noteHash, counter);
|
|
507
533
|
|
|
508
534
|
return toForeignCallResult([]);
|
|
509
535
|
}
|
|
510
536
|
|
|
511
|
-
|
|
537
|
+
// eslint-disable-next-line camelcase
|
|
538
|
+
async aztec_prv_notifyCreatedNullifier(foreignInnerNullifier: ForeignCallSingle) {
|
|
512
539
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
513
540
|
|
|
514
|
-
await this.handlerAsPrivate().
|
|
541
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(innerNullifier);
|
|
515
542
|
|
|
516
543
|
return toForeignCallResult([]);
|
|
517
544
|
}
|
|
518
545
|
|
|
519
|
-
|
|
546
|
+
// eslint-disable-next-line camelcase
|
|
547
|
+
async aztec_prv_isNullifierPending(
|
|
548
|
+
foreignInnerNullifier: ForeignCallSingle,
|
|
549
|
+
foreignContractAddress: ForeignCallSingle,
|
|
550
|
+
) {
|
|
551
|
+
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
552
|
+
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
553
|
+
|
|
554
|
+
const isPending = await this.handlerAsPrivate().isNullifierPending(innerNullifier, contractAddress);
|
|
555
|
+
|
|
556
|
+
return toForeignCallResult([toSingle(new Fr(isPending))]);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// eslint-disable-next-line camelcase
|
|
560
|
+
async aztec_utl_doesNullifierExist(foreignInnerNullifier: ForeignCallSingle) {
|
|
520
561
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
521
562
|
|
|
522
|
-
const exists = await this.handlerAsUtility().
|
|
563
|
+
const exists = await this.handlerAsUtility().doesNullifierExist(innerNullifier);
|
|
523
564
|
|
|
524
565
|
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
525
566
|
}
|
|
526
567
|
|
|
527
|
-
|
|
568
|
+
// eslint-disable-next-line camelcase
|
|
569
|
+
async aztec_utl_getContractInstance(foreignAddress: ForeignCallSingle) {
|
|
528
570
|
const address = addressFromSingle(foreignAddress);
|
|
529
571
|
|
|
530
|
-
const instance = await this.handlerAsUtility().
|
|
572
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
531
573
|
|
|
532
574
|
return toForeignCallResult(
|
|
533
575
|
[
|
|
@@ -540,23 +582,37 @@ export class RPCTranslator {
|
|
|
540
582
|
);
|
|
541
583
|
}
|
|
542
584
|
|
|
543
|
-
|
|
585
|
+
// eslint-disable-next-line camelcase
|
|
586
|
+
async aztec_utl_getPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
|
|
544
587
|
const address = addressFromSingle(foreignAddress);
|
|
545
588
|
|
|
546
|
-
const
|
|
589
|
+
const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(address);
|
|
547
590
|
|
|
548
|
-
return
|
|
591
|
+
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
592
|
+
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
593
|
+
if (result === undefined) {
|
|
594
|
+
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
595
|
+
return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(13).fill(new Fr(0)))]);
|
|
596
|
+
} else {
|
|
597
|
+
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
598
|
+
return toForeignCallResult([
|
|
599
|
+
toSingle(new Fr(1)),
|
|
600
|
+
toArray([...result.publicKeys.toFields(), result.partialAddress]),
|
|
601
|
+
]);
|
|
602
|
+
}
|
|
549
603
|
}
|
|
550
604
|
|
|
551
|
-
|
|
605
|
+
// eslint-disable-next-line camelcase
|
|
606
|
+
async aztec_utl_getKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
|
|
552
607
|
const pkMHash = fromSingle(foreignPkMHash);
|
|
553
608
|
|
|
554
|
-
const keyValidationRequest = await this.handlerAsUtility().
|
|
609
|
+
const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(pkMHash);
|
|
555
610
|
|
|
556
611
|
return toForeignCallResult(keyValidationRequest.toFields().map(toSingle));
|
|
557
612
|
}
|
|
558
613
|
|
|
559
|
-
|
|
614
|
+
// eslint-disable-next-line camelcase
|
|
615
|
+
aztec_prv_callPrivateFunction(
|
|
560
616
|
_foreignTargetContractAddress: ForeignCallSingle,
|
|
561
617
|
_foreignFunctionSelector: ForeignCallSingle,
|
|
562
618
|
_foreignArgsHash: ForeignCallSingle,
|
|
@@ -568,25 +624,27 @@ export class RPCTranslator {
|
|
|
568
624
|
);
|
|
569
625
|
}
|
|
570
626
|
|
|
571
|
-
|
|
572
|
-
|
|
627
|
+
// eslint-disable-next-line camelcase
|
|
628
|
+
async aztec_utl_getNullifierMembershipWitness(
|
|
629
|
+
foreignBlockHash: ForeignCallSingle,
|
|
573
630
|
foreignNullifier: ForeignCallSingle,
|
|
574
631
|
) {
|
|
575
|
-
const
|
|
632
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
576
633
|
const nullifier = fromSingle(foreignNullifier);
|
|
577
634
|
|
|
578
|
-
const witness = await this.handlerAsUtility().
|
|
635
|
+
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
|
|
579
636
|
|
|
580
637
|
if (!witness) {
|
|
581
|
-
throw new Error(`Nullifier membership witness not found at block ${
|
|
638
|
+
throw new Error(`Nullifier membership witness not found at block ${blockHash}.`);
|
|
582
639
|
}
|
|
583
640
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
584
641
|
}
|
|
585
642
|
|
|
586
|
-
|
|
643
|
+
// eslint-disable-next-line camelcase
|
|
644
|
+
async aztec_utl_getAuthWitness(foreignMessageHash: ForeignCallSingle) {
|
|
587
645
|
const messageHash = fromSingle(foreignMessageHash);
|
|
588
646
|
|
|
589
|
-
const authWitness = await this.handlerAsUtility().
|
|
647
|
+
const authWitness = await this.handlerAsUtility().getAuthWitness(messageHash);
|
|
590
648
|
|
|
591
649
|
if (!authWitness) {
|
|
592
650
|
throw new Error(`Auth witness not found for message hash ${messageHash}.`);
|
|
@@ -594,44 +652,35 @@ export class RPCTranslator {
|
|
|
594
652
|
return toForeignCallResult([toArray(authWitness)]);
|
|
595
653
|
}
|
|
596
654
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
_foreignCalldataHash: ForeignCallSingle,
|
|
600
|
-
_foreignSideEffectCounter: ForeignCallSingle,
|
|
601
|
-
_foreignIsStaticCall: ForeignCallSingle,
|
|
602
|
-
) {
|
|
603
|
-
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
public privateNotifySetPublicTeardownFunctionCall(
|
|
607
|
-
_foreignTargetContractAddress: ForeignCallSingle,
|
|
608
|
-
_foreignCalldataHash: ForeignCallSingle,
|
|
609
|
-
_foreignSideEffectCounter: ForeignCallSingle,
|
|
610
|
-
_foreignIsStaticCall: ForeignCallSingle,
|
|
611
|
-
) {
|
|
655
|
+
// eslint-disable-next-line camelcase
|
|
656
|
+
public aztec_prv_assertValidPublicCalldata(_foreignCalldataHash: ForeignCallSingle) {
|
|
612
657
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
613
658
|
}
|
|
614
659
|
|
|
615
|
-
|
|
660
|
+
// eslint-disable-next-line camelcase
|
|
661
|
+
public aztec_prv_notifyRevertiblePhaseStart(_foreignMinRevertibleSideEffectCounter: ForeignCallSingle) {
|
|
616
662
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
617
663
|
}
|
|
618
664
|
|
|
619
|
-
|
|
665
|
+
// eslint-disable-next-line camelcase
|
|
666
|
+
public async aztec_prv_isExecutionInRevertiblePhase(foreignSideEffectCounter: ForeignCallSingle) {
|
|
620
667
|
const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
|
|
621
|
-
const isRevertible = await this.handlerAsPrivate().
|
|
668
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(sideEffectCounter);
|
|
622
669
|
return toForeignCallResult([toSingle(new Fr(isRevertible))]);
|
|
623
670
|
}
|
|
624
671
|
|
|
625
|
-
|
|
626
|
-
|
|
672
|
+
// eslint-disable-next-line camelcase
|
|
673
|
+
aztec_utl_getUtilityContext() {
|
|
674
|
+
const context = this.handlerAsUtility().getUtilityContext();
|
|
627
675
|
|
|
628
676
|
return toForeignCallResult(context.toNoirRepresentation());
|
|
629
677
|
}
|
|
630
678
|
|
|
631
|
-
|
|
679
|
+
// eslint-disable-next-line camelcase
|
|
680
|
+
async aztec_utl_getBlockHeader(foreignBlockNumber: ForeignCallSingle) {
|
|
632
681
|
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
633
682
|
|
|
634
|
-
const header = await this.handlerAsUtility().
|
|
683
|
+
const header = await this.handlerAsUtility().getBlockHeader(blockNumber);
|
|
635
684
|
|
|
636
685
|
if (!header) {
|
|
637
686
|
throw new Error(`Block header not found for block ${blockNumber}.`);
|
|
@@ -639,108 +688,217 @@ export class RPCTranslator {
|
|
|
639
688
|
return toForeignCallResult(header.toFields().map(toSingle));
|
|
640
689
|
}
|
|
641
690
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
691
|
+
// eslint-disable-next-line camelcase
|
|
692
|
+
async aztec_utl_getNoteHashMembershipWitness(
|
|
693
|
+
foreignAnchorBlockHash: ForeignCallSingle,
|
|
694
|
+
foreignNoteHash: ForeignCallSingle,
|
|
646
695
|
) {
|
|
647
|
-
const
|
|
648
|
-
const
|
|
649
|
-
const leafValue = fromSingle(foreignLeafValue);
|
|
696
|
+
const blockHash = blockHashFromSingle(foreignAnchorBlockHash);
|
|
697
|
+
const noteHash = fromSingle(foreignNoteHash);
|
|
650
698
|
|
|
651
|
-
const witness = await this.handlerAsUtility().
|
|
699
|
+
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
|
|
700
|
+
|
|
701
|
+
if (!witness) {
|
|
702
|
+
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
703
|
+
}
|
|
704
|
+
return toForeignCallResult(witness.toNoirRepresentation());
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// eslint-disable-next-line camelcase
|
|
708
|
+
async aztec_utl_getBlockHashMembershipWitness(
|
|
709
|
+
foreignAnchorBlockHash: ForeignCallSingle,
|
|
710
|
+
foreignBlockHash: ForeignCallSingle,
|
|
711
|
+
) {
|
|
712
|
+
const anchorBlockHash = blockHashFromSingle(foreignAnchorBlockHash);
|
|
713
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
714
|
+
|
|
715
|
+
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
652
716
|
|
|
653
717
|
if (!witness) {
|
|
654
718
|
throw new Error(
|
|
655
|
-
`
|
|
719
|
+
`Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`,
|
|
656
720
|
);
|
|
657
721
|
}
|
|
658
|
-
return toForeignCallResult(
|
|
722
|
+
return toForeignCallResult(witness.toNoirRepresentation());
|
|
659
723
|
}
|
|
660
724
|
|
|
661
|
-
|
|
662
|
-
|
|
725
|
+
// eslint-disable-next-line camelcase
|
|
726
|
+
async aztec_utl_getLowNullifierMembershipWitness(
|
|
727
|
+
foreignBlockHash: ForeignCallSingle,
|
|
663
728
|
foreignNullifier: ForeignCallSingle,
|
|
664
729
|
) {
|
|
665
|
-
const
|
|
730
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
666
731
|
const nullifier = fromSingle(foreignNullifier);
|
|
667
732
|
|
|
668
|
-
const witness = await this.handlerAsUtility().
|
|
733
|
+
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
|
|
669
734
|
|
|
670
735
|
if (!witness) {
|
|
671
|
-
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${
|
|
736
|
+
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockHash}.`);
|
|
672
737
|
}
|
|
673
738
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
674
739
|
}
|
|
675
740
|
|
|
676
|
-
|
|
741
|
+
// eslint-disable-next-line camelcase
|
|
742
|
+
async aztec_utl_getPendingTaggedLogs(
|
|
743
|
+
foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle,
|
|
744
|
+
foreignScope: ForeignCallSingle,
|
|
745
|
+
) {
|
|
677
746
|
const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
|
|
747
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
678
748
|
|
|
679
|
-
await this.handlerAsUtility().
|
|
749
|
+
await this.handlerAsUtility().getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot, scope);
|
|
680
750
|
|
|
681
751
|
return toForeignCallResult([]);
|
|
682
752
|
}
|
|
683
753
|
|
|
684
|
-
|
|
754
|
+
// eslint-disable-next-line camelcase
|
|
755
|
+
async aztec_utl_getPendingTaggedLogs_v2(foreignScope: ForeignCallSingle) {
|
|
756
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
757
|
+
const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(scope);
|
|
758
|
+
return toForeignCallResult([toSingle(slot)]);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// eslint-disable-next-line camelcase
|
|
762
|
+
public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
685
763
|
foreignContractAddress: ForeignCallSingle,
|
|
686
764
|
foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
687
765
|
foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
766
|
+
foreignMaxNotePackedLen: ForeignCallSingle,
|
|
767
|
+
foreignMaxEventSerializedLen: ForeignCallSingle,
|
|
768
|
+
foreignScope: ForeignCallSingle,
|
|
688
769
|
) {
|
|
689
770
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
690
771
|
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
691
772
|
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
773
|
+
const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
|
|
774
|
+
const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
|
|
775
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
692
776
|
|
|
693
|
-
await this.handlerAsUtility().
|
|
777
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
694
778
|
contractAddress,
|
|
695
779
|
noteValidationRequestsArrayBaseSlot,
|
|
696
780
|
eventValidationRequestsArrayBaseSlot,
|
|
781
|
+
maxNotePackedLen,
|
|
782
|
+
maxEventSerializedLen,
|
|
783
|
+
scope,
|
|
697
784
|
);
|
|
698
785
|
|
|
699
786
|
return toForeignCallResult([]);
|
|
700
787
|
}
|
|
701
788
|
|
|
702
|
-
|
|
789
|
+
// eslint-disable-next-line camelcase
|
|
790
|
+
public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2(
|
|
791
|
+
foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
792
|
+
foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
793
|
+
foreignMaxNotePackedLen: ForeignCallSingle,
|
|
794
|
+
foreignMaxEventSerializedLen: ForeignCallSingle,
|
|
795
|
+
foreignScope: ForeignCallSingle,
|
|
796
|
+
) {
|
|
797
|
+
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
798
|
+
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
799
|
+
const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
|
|
800
|
+
const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
|
|
801
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
802
|
+
|
|
803
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(
|
|
804
|
+
noteValidationRequestsArrayBaseSlot,
|
|
805
|
+
eventValidationRequestsArrayBaseSlot,
|
|
806
|
+
maxNotePackedLen,
|
|
807
|
+
maxEventSerializedLen,
|
|
808
|
+
scope,
|
|
809
|
+
);
|
|
810
|
+
|
|
811
|
+
return toForeignCallResult([]);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// eslint-disable-next-line camelcase
|
|
815
|
+
public async aztec_utl_getLogsByTag(
|
|
703
816
|
foreignContractAddress: ForeignCallSingle,
|
|
704
817
|
foreignLogRetrievalRequestsArrayBaseSlot: ForeignCallSingle,
|
|
705
818
|
foreignLogRetrievalResponsesArrayBaseSlot: ForeignCallSingle,
|
|
819
|
+
foreignScope: ForeignCallSingle,
|
|
706
820
|
) {
|
|
707
821
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
708
822
|
const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
|
|
709
823
|
const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
|
|
824
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
710
825
|
|
|
711
|
-
await this.handlerAsUtility().
|
|
826
|
+
await this.handlerAsUtility().getLogsByTag(
|
|
712
827
|
contractAddress,
|
|
713
828
|
logRetrievalRequestsArrayBaseSlot,
|
|
714
829
|
logRetrievalResponsesArrayBaseSlot,
|
|
830
|
+
scope,
|
|
715
831
|
);
|
|
716
832
|
|
|
717
833
|
return toForeignCallResult([]);
|
|
718
834
|
}
|
|
719
835
|
|
|
720
|
-
|
|
836
|
+
// eslint-disable-next-line camelcase
|
|
837
|
+
public async aztec_utl_getMessageContextsByTxHash(
|
|
838
|
+
foreignContractAddress: ForeignCallSingle,
|
|
839
|
+
foreignMessageContextRequestsArrayBaseSlot: ForeignCallSingle,
|
|
840
|
+
foreignMessageContextResponsesArrayBaseSlot: ForeignCallSingle,
|
|
841
|
+
foreignScope: ForeignCallSingle,
|
|
842
|
+
) {
|
|
843
|
+
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
844
|
+
const messageContextRequestsArrayBaseSlot = fromSingle(foreignMessageContextRequestsArrayBaseSlot);
|
|
845
|
+
const messageContextResponsesArrayBaseSlot = fromSingle(foreignMessageContextResponsesArrayBaseSlot);
|
|
846
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
847
|
+
|
|
848
|
+
await this.handlerAsUtility().getMessageContextsByTxHash(
|
|
849
|
+
contractAddress,
|
|
850
|
+
messageContextRequestsArrayBaseSlot,
|
|
851
|
+
messageContextResponsesArrayBaseSlot,
|
|
852
|
+
scope,
|
|
853
|
+
);
|
|
854
|
+
|
|
855
|
+
return toForeignCallResult([]);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// eslint-disable-next-line camelcase
|
|
859
|
+
async aztec_utl_getLogsByTag_v2(foreignRequestArrayBaseSlot: ForeignCallSingle) {
|
|
860
|
+
const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
|
|
861
|
+
const responseSlot = await this.handlerAsUtility().getLogsByTagV2(requestArrayBaseSlot);
|
|
862
|
+
return toForeignCallResult([toSingle(responseSlot)]);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// eslint-disable-next-line camelcase
|
|
866
|
+
async aztec_utl_getMessageContextsByTxHash_v2(foreignRequestArrayBaseSlot: ForeignCallSingle) {
|
|
867
|
+
const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
|
|
868
|
+
const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(requestArrayBaseSlot);
|
|
869
|
+
return toForeignCallResult([toSingle(responseSlot)]);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// eslint-disable-next-line camelcase
|
|
873
|
+
aztec_utl_setCapsule(
|
|
721
874
|
foreignContractAddress: ForeignCallSingle,
|
|
722
875
|
foreignSlot: ForeignCallSingle,
|
|
723
876
|
foreignCapsule: ForeignCallArray,
|
|
877
|
+
foreignScope: ForeignCallSingle,
|
|
724
878
|
) {
|
|
725
879
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
726
880
|
const slot = fromSingle(foreignSlot);
|
|
727
881
|
const capsule = fromArray(foreignCapsule);
|
|
882
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
728
883
|
|
|
729
|
-
|
|
884
|
+
this.handlerAsUtility().setCapsule(contractAddress, slot, capsule, scope);
|
|
730
885
|
|
|
731
886
|
return toForeignCallResult([]);
|
|
732
887
|
}
|
|
733
888
|
|
|
734
|
-
|
|
889
|
+
// eslint-disable-next-line camelcase
|
|
890
|
+
async aztec_utl_getCapsule(
|
|
735
891
|
foreignContractAddress: ForeignCallSingle,
|
|
736
892
|
foreignSlot: ForeignCallSingle,
|
|
737
893
|
foreignTSize: ForeignCallSingle,
|
|
894
|
+
foreignScope: ForeignCallSingle,
|
|
738
895
|
) {
|
|
739
896
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
740
897
|
const slot = fromSingle(foreignSlot);
|
|
741
898
|
const tSize = fromSingle(foreignTSize).toNumber();
|
|
899
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
742
900
|
|
|
743
|
-
const values = await this.handlerAsUtility().
|
|
901
|
+
const values = await this.handlerAsUtility().getCapsule(contractAddress, slot, scope);
|
|
744
902
|
|
|
745
903
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
746
904
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -753,36 +911,104 @@ export class RPCTranslator {
|
|
|
753
911
|
}
|
|
754
912
|
}
|
|
755
913
|
|
|
756
|
-
|
|
914
|
+
// eslint-disable-next-line camelcase
|
|
915
|
+
aztec_utl_deleteCapsule(
|
|
916
|
+
foreignContractAddress: ForeignCallSingle,
|
|
917
|
+
foreignSlot: ForeignCallSingle,
|
|
918
|
+
foreignScope: ForeignCallSingle,
|
|
919
|
+
) {
|
|
757
920
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
758
921
|
const slot = fromSingle(foreignSlot);
|
|
922
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
759
923
|
|
|
760
|
-
|
|
924
|
+
this.handlerAsUtility().deleteCapsule(contractAddress, slot, scope);
|
|
761
925
|
|
|
762
926
|
return toForeignCallResult([]);
|
|
763
927
|
}
|
|
764
928
|
|
|
765
|
-
|
|
929
|
+
// eslint-disable-next-line camelcase
|
|
930
|
+
async aztec_utl_copyCapsule(
|
|
766
931
|
foreignContractAddress: ForeignCallSingle,
|
|
767
932
|
foreignSrcSlot: ForeignCallSingle,
|
|
768
933
|
foreignDstSlot: ForeignCallSingle,
|
|
769
934
|
foreignNumEntries: ForeignCallSingle,
|
|
935
|
+
foreignScope: ForeignCallSingle,
|
|
770
936
|
) {
|
|
771
937
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
772
938
|
const srcSlot = fromSingle(foreignSrcSlot);
|
|
773
939
|
const dstSlot = fromSingle(foreignDstSlot);
|
|
774
940
|
const numEntries = fromSingle(foreignNumEntries).toNumber();
|
|
941
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
775
942
|
|
|
776
|
-
await this.handlerAsUtility().
|
|
943
|
+
await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope);
|
|
777
944
|
|
|
778
945
|
return toForeignCallResult([]);
|
|
779
946
|
}
|
|
780
947
|
|
|
948
|
+
// eslint-disable-next-line camelcase
|
|
949
|
+
aztec_utl_pushEphemeral(foreignSlot: ForeignCallSingle, foreignElements: ForeignCallArray) {
|
|
950
|
+
const slot = fromSingle(foreignSlot);
|
|
951
|
+
const elements = fromArray(foreignElements);
|
|
952
|
+
const newLen = this.handlerAsUtility().pushEphemeral(slot, elements);
|
|
953
|
+
return toForeignCallResult([toSingle(new Fr(newLen))]);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// eslint-disable-next-line camelcase
|
|
957
|
+
aztec_utl_popEphemeral(foreignSlot: ForeignCallSingle) {
|
|
958
|
+
const slot = fromSingle(foreignSlot);
|
|
959
|
+
const element = this.handlerAsUtility().popEphemeral(slot);
|
|
960
|
+
return toForeignCallResult([toArray(element)]);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// eslint-disable-next-line camelcase
|
|
964
|
+
aztec_utl_getEphemeral(foreignSlot: ForeignCallSingle, foreignIndex: ForeignCallSingle) {
|
|
965
|
+
const slot = fromSingle(foreignSlot);
|
|
966
|
+
const index = fromSingle(foreignIndex).toNumber();
|
|
967
|
+
const element = this.handlerAsUtility().getEphemeral(slot, index);
|
|
968
|
+
return toForeignCallResult([toArray(element)]);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// eslint-disable-next-line camelcase
|
|
972
|
+
aztec_utl_setEphemeral(
|
|
973
|
+
foreignSlot: ForeignCallSingle,
|
|
974
|
+
foreignIndex: ForeignCallSingle,
|
|
975
|
+
foreignElements: ForeignCallArray,
|
|
976
|
+
) {
|
|
977
|
+
const slot = fromSingle(foreignSlot);
|
|
978
|
+
const index = fromSingle(foreignIndex).toNumber();
|
|
979
|
+
const elements = fromArray(foreignElements);
|
|
980
|
+
this.handlerAsUtility().setEphemeral(slot, index, elements);
|
|
981
|
+
return toForeignCallResult([]);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// eslint-disable-next-line camelcase
|
|
985
|
+
aztec_utl_getEphemeralLen(foreignSlot: ForeignCallSingle) {
|
|
986
|
+
const slot = fromSingle(foreignSlot);
|
|
987
|
+
const len = this.handlerAsUtility().getEphemeralLen(slot);
|
|
988
|
+
return toForeignCallResult([toSingle(new Fr(len))]);
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// eslint-disable-next-line camelcase
|
|
992
|
+
aztec_utl_removeEphemeral(foreignSlot: ForeignCallSingle, foreignIndex: ForeignCallSingle) {
|
|
993
|
+
const slot = fromSingle(foreignSlot);
|
|
994
|
+
const index = fromSingle(foreignIndex).toNumber();
|
|
995
|
+
this.handlerAsUtility().removeEphemeral(slot, index);
|
|
996
|
+
return toForeignCallResult([]);
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
// eslint-disable-next-line camelcase
|
|
1000
|
+
aztec_utl_clearEphemeral(foreignSlot: ForeignCallSingle) {
|
|
1001
|
+
const slot = fromSingle(foreignSlot);
|
|
1002
|
+
this.handlerAsUtility().clearEphemeral(slot);
|
|
1003
|
+
return toForeignCallResult([]);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
781
1006
|
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
782
1007
|
// The compiler didn't throw an error, so it took me a while to learn of the existence of this file, and that I need
|
|
783
1008
|
// to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
|
|
784
1009
|
// existence of a txe_oracle method?
|
|
785
|
-
|
|
1010
|
+
// eslint-disable-next-line camelcase
|
|
1011
|
+
async aztec_utl_decryptAes128(
|
|
786
1012
|
foreignCiphertextBVecStorage: ForeignCallArray,
|
|
787
1013
|
foreignCiphertextLength: ForeignCallSingle,
|
|
788
1014
|
foreignIv: ForeignCallArray,
|
|
@@ -792,18 +1018,27 @@ export class RPCTranslator {
|
|
|
792
1018
|
const iv = fromUintArray(foreignIv, 8);
|
|
793
1019
|
const symKey = fromUintArray(foreignSymKey, 8);
|
|
794
1020
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
1021
|
+
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
1022
|
+
try {
|
|
1023
|
+
const plaintextBuffer = await this.handlerAsUtility().decryptAes128(ciphertext, iv, symKey);
|
|
1024
|
+
const [storage, length] = arrayToBoundedVec(
|
|
1025
|
+
bufferToU8Array(plaintextBuffer),
|
|
1026
|
+
foreignCiphertextBVecStorage.length,
|
|
1027
|
+
);
|
|
1028
|
+
return toForeignCallResult([toSingle(new Fr(1)), storage, length]);
|
|
1029
|
+
} catch {
|
|
1030
|
+
const zeroStorage = toArray(Array(foreignCiphertextBVecStorage.length).fill(new Fr(0)));
|
|
1031
|
+
return toForeignCallResult([toSingle(new Fr(0)), zeroStorage, toSingle(new Fr(0))]);
|
|
1032
|
+
}
|
|
800
1033
|
}
|
|
801
1034
|
|
|
802
|
-
|
|
1035
|
+
// eslint-disable-next-line camelcase
|
|
1036
|
+
async aztec_utl_getSharedSecret(
|
|
803
1037
|
foreignAddress: ForeignCallSingle,
|
|
804
1038
|
foreignEphPKField0: ForeignCallSingle,
|
|
805
1039
|
foreignEphPKField1: ForeignCallSingle,
|
|
806
1040
|
foreignEphPKField2: ForeignCallSingle,
|
|
1041
|
+
foreignContractAddress: ForeignCallSingle,
|
|
807
1042
|
) {
|
|
808
1043
|
const address = AztecAddress.fromField(fromSingle(foreignAddress));
|
|
809
1044
|
const ephPK = Point.fromFields([
|
|
@@ -811,44 +1046,68 @@ export class RPCTranslator {
|
|
|
811
1046
|
fromSingle(foreignEphPKField1),
|
|
812
1047
|
fromSingle(foreignEphPKField2),
|
|
813
1048
|
]);
|
|
1049
|
+
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
1050
|
+
|
|
1051
|
+
const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK, contractAddress);
|
|
814
1052
|
|
|
815
|
-
|
|
1053
|
+
return toForeignCallResult([toSingle(secret)]);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
// eslint-disable-next-line camelcase
|
|
1057
|
+
aztec_utl_setContractSyncCacheInvalid(
|
|
1058
|
+
foreignContractAddress: ForeignCallSingle,
|
|
1059
|
+
foreignScopes: ForeignCallArray,
|
|
1060
|
+
foreignScopeCount: ForeignCallSingle,
|
|
1061
|
+
) {
|
|
1062
|
+
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
1063
|
+
const count = fromSingle(foreignScopeCount).toNumber();
|
|
1064
|
+
const scopes = fromArray(foreignScopes)
|
|
1065
|
+
.slice(0, count)
|
|
1066
|
+
.map(f => new AztecAddress(f));
|
|
1067
|
+
|
|
1068
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes);
|
|
816
1069
|
|
|
817
|
-
return
|
|
1070
|
+
return Promise.resolve(toForeignCallResult([]));
|
|
818
1071
|
}
|
|
819
1072
|
|
|
820
|
-
|
|
1073
|
+
// eslint-disable-next-line camelcase
|
|
1074
|
+
aztec_utl_emitOffchainEffect(_foreignData: ForeignCallArray) {
|
|
821
1075
|
throw new Error('Offchain effects are not yet supported in the TestEnvironment');
|
|
822
1076
|
}
|
|
823
1077
|
|
|
824
1078
|
// AVM opcodes
|
|
825
1079
|
|
|
826
|
-
|
|
1080
|
+
// eslint-disable-next-line camelcase
|
|
1081
|
+
aztec_avm_emitPublicLog(_foreignMessage: ForeignCallArray) {
|
|
827
1082
|
// TODO(#8811): Implement
|
|
828
1083
|
return toForeignCallResult([]);
|
|
829
1084
|
}
|
|
830
1085
|
|
|
831
|
-
|
|
1086
|
+
// eslint-disable-next-line camelcase
|
|
1087
|
+
async aztec_avm_storageRead(foreignSlot: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
|
|
832
1088
|
const slot = fromSingle(foreignSlot);
|
|
1089
|
+
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
833
1090
|
|
|
834
|
-
const value = (await this.handlerAsAvm().
|
|
1091
|
+
const value = (await this.handlerAsAvm().storageRead(slot, contractAddress)).value;
|
|
835
1092
|
|
|
836
1093
|
return toForeignCallResult([toSingle(new Fr(value))]);
|
|
837
1094
|
}
|
|
838
1095
|
|
|
839
|
-
|
|
1096
|
+
// eslint-disable-next-line camelcase
|
|
1097
|
+
async aztec_avm_storageWrite(foreignSlot: ForeignCallSingle, foreignValue: ForeignCallSingle) {
|
|
840
1098
|
const slot = fromSingle(foreignSlot);
|
|
841
1099
|
const value = fromSingle(foreignValue);
|
|
842
1100
|
|
|
843
|
-
await this.handlerAsAvm().
|
|
1101
|
+
await this.handlerAsAvm().storageWrite(slot, value);
|
|
844
1102
|
|
|
845
1103
|
return toForeignCallResult([]);
|
|
846
1104
|
}
|
|
847
1105
|
|
|
848
|
-
|
|
1106
|
+
// eslint-disable-next-line camelcase
|
|
1107
|
+
async aztec_avm_getContractInstanceDeployer(foreignAddress: ForeignCallSingle) {
|
|
849
1108
|
const address = addressFromSingle(foreignAddress);
|
|
850
1109
|
|
|
851
|
-
const instance = await this.handlerAsUtility().
|
|
1110
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
852
1111
|
|
|
853
1112
|
return toForeignCallResult([
|
|
854
1113
|
toSingle(instance.deployer),
|
|
@@ -857,10 +1116,11 @@ export class RPCTranslator {
|
|
|
857
1116
|
]);
|
|
858
1117
|
}
|
|
859
1118
|
|
|
860
|
-
|
|
1119
|
+
// eslint-disable-next-line camelcase
|
|
1120
|
+
async aztec_avm_getContractInstanceClassId(foreignAddress: ForeignCallSingle) {
|
|
861
1121
|
const address = addressFromSingle(foreignAddress);
|
|
862
1122
|
|
|
863
|
-
const instance = await this.handlerAsUtility().
|
|
1123
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
864
1124
|
|
|
865
1125
|
return toForeignCallResult([
|
|
866
1126
|
toSingle(instance.currentContractClassId),
|
|
@@ -869,10 +1129,11 @@ export class RPCTranslator {
|
|
|
869
1129
|
]);
|
|
870
1130
|
}
|
|
871
1131
|
|
|
872
|
-
|
|
1132
|
+
// eslint-disable-next-line camelcase
|
|
1133
|
+
async aztec_avm_getContractInstanceInitializationHash(foreignAddress: ForeignCallSingle) {
|
|
873
1134
|
const address = addressFromSingle(foreignAddress);
|
|
874
1135
|
|
|
875
|
-
const instance = await this.handlerAsUtility().
|
|
1136
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
876
1137
|
|
|
877
1138
|
return toForeignCallResult([
|
|
878
1139
|
toSingle(instance.initializationHash),
|
|
@@ -881,86 +1142,98 @@ export class RPCTranslator {
|
|
|
881
1142
|
]);
|
|
882
1143
|
}
|
|
883
1144
|
|
|
884
|
-
|
|
885
|
-
|
|
1145
|
+
// eslint-disable-next-line camelcase
|
|
1146
|
+
async aztec_avm_sender() {
|
|
1147
|
+
const sender = await this.handlerAsAvm().sender();
|
|
886
1148
|
|
|
887
1149
|
return toForeignCallResult([toSingle(sender)]);
|
|
888
1150
|
}
|
|
889
1151
|
|
|
890
|
-
|
|
1152
|
+
// eslint-disable-next-line camelcase
|
|
1153
|
+
async aztec_avm_emitNullifier(foreignNullifier: ForeignCallSingle) {
|
|
891
1154
|
const nullifier = fromSingle(foreignNullifier);
|
|
892
1155
|
|
|
893
|
-
await this.handlerAsAvm().
|
|
1156
|
+
await this.handlerAsAvm().emitNullifier(nullifier);
|
|
894
1157
|
|
|
895
1158
|
return toForeignCallResult([]);
|
|
896
1159
|
}
|
|
897
1160
|
|
|
898
|
-
|
|
1161
|
+
// eslint-disable-next-line camelcase
|
|
1162
|
+
async aztec_avm_emitNoteHash(foreignNoteHash: ForeignCallSingle) {
|
|
899
1163
|
const noteHash = fromSingle(foreignNoteHash);
|
|
900
1164
|
|
|
901
|
-
await this.handlerAsAvm().
|
|
1165
|
+
await this.handlerAsAvm().emitNoteHash(noteHash);
|
|
902
1166
|
|
|
903
1167
|
return toForeignCallResult([]);
|
|
904
1168
|
}
|
|
905
1169
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
const
|
|
1170
|
+
// eslint-disable-next-line camelcase
|
|
1171
|
+
async aztec_avm_nullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
|
|
1172
|
+
const siloedNullifier = fromSingle(foreignSiloedNullifier);
|
|
909
1173
|
|
|
910
|
-
const exists = await this.handlerAsAvm().
|
|
1174
|
+
const exists = await this.handlerAsAvm().nullifierExists(siloedNullifier);
|
|
911
1175
|
|
|
912
1176
|
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
913
1177
|
}
|
|
914
1178
|
|
|
915
|
-
|
|
916
|
-
|
|
1179
|
+
// eslint-disable-next-line camelcase
|
|
1180
|
+
async aztec_avm_address() {
|
|
1181
|
+
const contractAddress = await this.handlerAsAvm().address();
|
|
917
1182
|
|
|
918
1183
|
return toForeignCallResult([toSingle(contractAddress.toField())]);
|
|
919
1184
|
}
|
|
920
1185
|
|
|
921
|
-
|
|
922
|
-
|
|
1186
|
+
// eslint-disable-next-line camelcase
|
|
1187
|
+
async aztec_avm_blockNumber() {
|
|
1188
|
+
const blockNumber = await this.handlerAsAvm().blockNumber();
|
|
923
1189
|
|
|
924
1190
|
return toForeignCallResult([toSingle(new Fr(blockNumber))]);
|
|
925
1191
|
}
|
|
926
1192
|
|
|
927
|
-
|
|
928
|
-
|
|
1193
|
+
// eslint-disable-next-line camelcase
|
|
1194
|
+
async aztec_avm_timestamp() {
|
|
1195
|
+
const timestamp = await this.handlerAsAvm().timestamp();
|
|
929
1196
|
|
|
930
1197
|
return toForeignCallResult([toSingle(new Fr(timestamp))]);
|
|
931
1198
|
}
|
|
932
1199
|
|
|
933
|
-
|
|
934
|
-
|
|
1200
|
+
// eslint-disable-next-line camelcase
|
|
1201
|
+
async aztec_avm_isStaticCall() {
|
|
1202
|
+
const isStaticCall = await this.handlerAsAvm().isStaticCall();
|
|
935
1203
|
|
|
936
1204
|
return toForeignCallResult([toSingle(new Fr(isStaticCall ? 1 : 0))]);
|
|
937
1205
|
}
|
|
938
1206
|
|
|
939
|
-
|
|
940
|
-
|
|
1207
|
+
// eslint-disable-next-line camelcase
|
|
1208
|
+
async aztec_avm_chainId() {
|
|
1209
|
+
const chainId = await this.handlerAsAvm().chainId();
|
|
941
1210
|
|
|
942
1211
|
return toForeignCallResult([toSingle(chainId)]);
|
|
943
1212
|
}
|
|
944
1213
|
|
|
945
|
-
|
|
946
|
-
|
|
1214
|
+
// eslint-disable-next-line camelcase
|
|
1215
|
+
async aztec_avm_version() {
|
|
1216
|
+
const version = await this.handlerAsAvm().version();
|
|
947
1217
|
|
|
948
1218
|
return toForeignCallResult([toSingle(version)]);
|
|
949
1219
|
}
|
|
950
1220
|
|
|
951
|
-
|
|
1221
|
+
// eslint-disable-next-line camelcase
|
|
1222
|
+
aztec_avm_returndataSize() {
|
|
952
1223
|
throw new Error(
|
|
953
1224
|
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
954
1225
|
);
|
|
955
1226
|
}
|
|
956
1227
|
|
|
957
|
-
|
|
1228
|
+
// eslint-disable-next-line camelcase
|
|
1229
|
+
aztec_avm_returndataCopy(_foreignRdOffset: ForeignCallSingle, _foreignCopySize: ForeignCallSingle) {
|
|
958
1230
|
throw new Error(
|
|
959
1231
|
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
960
1232
|
);
|
|
961
1233
|
}
|
|
962
1234
|
|
|
963
|
-
|
|
1235
|
+
// eslint-disable-next-line camelcase
|
|
1236
|
+
aztec_avm_call(
|
|
964
1237
|
_foreignL2Gas: ForeignCallSingle,
|
|
965
1238
|
_foreignDaGas: ForeignCallSingle,
|
|
966
1239
|
_foreignAddress: ForeignCallSingle,
|
|
@@ -972,7 +1245,8 @@ export class RPCTranslator {
|
|
|
972
1245
|
);
|
|
973
1246
|
}
|
|
974
1247
|
|
|
975
|
-
|
|
1248
|
+
// eslint-disable-next-line camelcase
|
|
1249
|
+
aztec_avm_staticCall(
|
|
976
1250
|
_foreignL2Gas: ForeignCallSingle,
|
|
977
1251
|
_foreignDaGas: ForeignCallSingle,
|
|
978
1252
|
_foreignAddress: ForeignCallSingle,
|
|
@@ -984,13 +1258,15 @@ export class RPCTranslator {
|
|
|
984
1258
|
);
|
|
985
1259
|
}
|
|
986
1260
|
|
|
987
|
-
|
|
1261
|
+
// eslint-disable-next-line camelcase
|
|
1262
|
+
aztec_avm_successCopy() {
|
|
988
1263
|
throw new Error(
|
|
989
1264
|
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
990
1265
|
);
|
|
991
1266
|
}
|
|
992
1267
|
|
|
993
|
-
|
|
1268
|
+
// eslint-disable-next-line camelcase
|
|
1269
|
+
async aztec_txe_privateCallNewFlow(
|
|
994
1270
|
foreignFrom: ForeignCallSingle,
|
|
995
1271
|
foreignTargetContractAddress: ForeignCallSingle,
|
|
996
1272
|
foreignFunctionSelector: ForeignCallSingle,
|
|
@@ -1005,19 +1281,23 @@ export class RPCTranslator {
|
|
|
1005
1281
|
const argsHash = fromSingle(foreignArgsHash);
|
|
1006
1282
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
1007
1283
|
|
|
1008
|
-
const returnValues = await this.handlerAsTxe().
|
|
1284
|
+
const returnValues = await this.handlerAsTxe().privateCallNewFlow(
|
|
1009
1285
|
from,
|
|
1010
1286
|
targetContractAddress,
|
|
1011
1287
|
functionSelector,
|
|
1012
1288
|
args,
|
|
1013
1289
|
argsHash,
|
|
1014
1290
|
isStaticCall,
|
|
1291
|
+
this.stateHandler.getCurrentJob(),
|
|
1015
1292
|
);
|
|
1016
1293
|
|
|
1294
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1295
|
+
await this.stateHandler.cycleJob();
|
|
1017
1296
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1018
1297
|
}
|
|
1019
1298
|
|
|
1020
|
-
|
|
1299
|
+
// eslint-disable-next-line camelcase
|
|
1300
|
+
async aztec_txe_executeUtilityFunction(
|
|
1021
1301
|
foreignTargetContractAddress: ForeignCallSingle,
|
|
1022
1302
|
foreignFunctionSelector: ForeignCallSingle,
|
|
1023
1303
|
foreignArgs: ForeignCallArray,
|
|
@@ -1026,16 +1306,20 @@ export class RPCTranslator {
|
|
|
1026
1306
|
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
1027
1307
|
const args = fromArray(foreignArgs);
|
|
1028
1308
|
|
|
1029
|
-
const returnValues = await this.handlerAsTxe().
|
|
1309
|
+
const returnValues = await this.handlerAsTxe().executeUtilityFunction(
|
|
1030
1310
|
targetContractAddress,
|
|
1031
1311
|
functionSelector,
|
|
1032
1312
|
args,
|
|
1313
|
+
this.stateHandler.getCurrentJob(),
|
|
1033
1314
|
);
|
|
1034
1315
|
|
|
1316
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1317
|
+
await this.stateHandler.cycleJob();
|
|
1035
1318
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1036
1319
|
}
|
|
1037
1320
|
|
|
1038
|
-
|
|
1321
|
+
// eslint-disable-next-line camelcase
|
|
1322
|
+
async aztec_txe_publicCallNewFlow(
|
|
1039
1323
|
foreignFrom: ForeignCallSingle,
|
|
1040
1324
|
foreignAddress: ForeignCallSingle,
|
|
1041
1325
|
foreignCalldata: ForeignCallArray,
|
|
@@ -1046,13 +1330,16 @@ export class RPCTranslator {
|
|
|
1046
1330
|
const calldata = fromArray(foreignCalldata);
|
|
1047
1331
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
1048
1332
|
|
|
1049
|
-
const returnValues = await this.handlerAsTxe().
|
|
1333
|
+
const returnValues = await this.handlerAsTxe().publicCallNewFlow(from, address, calldata, isStaticCall);
|
|
1050
1334
|
|
|
1335
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1336
|
+
await this.stateHandler.cycleJob();
|
|
1051
1337
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1052
1338
|
}
|
|
1053
1339
|
|
|
1054
|
-
|
|
1055
|
-
|
|
1340
|
+
// eslint-disable-next-line camelcase
|
|
1341
|
+
async aztec_prv_getSenderForTags() {
|
|
1342
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
1056
1343
|
|
|
1057
1344
|
// Return a Noir Option struct with `some` and `value` fields
|
|
1058
1345
|
if (sender === undefined) {
|
|
@@ -1064,19 +1351,21 @@ export class RPCTranslator {
|
|
|
1064
1351
|
}
|
|
1065
1352
|
}
|
|
1066
1353
|
|
|
1067
|
-
|
|
1354
|
+
// eslint-disable-next-line camelcase
|
|
1355
|
+
async aztec_prv_setSenderForTags(foreignSenderForTags: ForeignCallSingle) {
|
|
1068
1356
|
const senderForTags = AztecAddress.fromField(fromSingle(foreignSenderForTags));
|
|
1069
1357
|
|
|
1070
|
-
await this.handlerAsPrivate().
|
|
1358
|
+
await this.handlerAsPrivate().setSenderForTags(senderForTags);
|
|
1071
1359
|
|
|
1072
1360
|
return toForeignCallResult([]);
|
|
1073
1361
|
}
|
|
1074
1362
|
|
|
1075
|
-
|
|
1363
|
+
// eslint-disable-next-line camelcase
|
|
1364
|
+
async aztec_prv_getNextAppTagAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) {
|
|
1076
1365
|
const sender = AztecAddress.fromField(fromSingle(foreignSender));
|
|
1077
1366
|
const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
|
|
1078
1367
|
|
|
1079
|
-
const nextAppTag = await this.handlerAsPrivate().
|
|
1368
|
+
const nextAppTag = await this.handlerAsPrivate().getNextAppTagAsSender(sender, recipient);
|
|
1080
1369
|
|
|
1081
1370
|
return toForeignCallResult([toSingle(nextAppTag.value)]);
|
|
1082
1371
|
}
|