@aztec/txe 0.0.1-commit.ec5f612 → 0.0.1-commit.ef17749e1
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/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +8 -6
- package/dest/oracle/interfaces.d.ts +28 -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 +12 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts +19 -19
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +24 -24
- package/dest/rpc_translator.d.ts +82 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +228 -147
- package/dest/txe_session.js +3 -3
- package/package.json +15 -15
- package/src/index.ts +8 -5
- package/src/oracle/interfaces.ts +27 -31
- package/src/oracle/txe_oracle_public_context.ts +12 -12
- package/src/oracle/txe_oracle_top_level_context.ts +24 -24
- package/src/rpc_translator.ts +238 -155
- package/src/txe_session.ts +3 -3
package/src/rpc_translator.ts
CHANGED
|
@@ -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,44 @@ 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
|
-
|
|
266
|
+
// eslint-disable-next-line camelcase
|
|
267
|
+
aztec_utl_assertCompatibleOracleVersion(foreignVersion: ForeignCallSingle) {
|
|
250
268
|
const version = fromSingle(foreignVersion).toNumber();
|
|
251
269
|
|
|
252
|
-
this.handlerAsMisc().
|
|
270
|
+
this.handlerAsMisc().assertCompatibleOracleVersion(version);
|
|
253
271
|
|
|
254
272
|
return toForeignCallResult([]);
|
|
255
273
|
}
|
|
256
274
|
|
|
257
|
-
|
|
258
|
-
|
|
275
|
+
// eslint-disable-next-line camelcase
|
|
276
|
+
aztec_utl_getRandomField() {
|
|
277
|
+
const randomField = this.handlerAsMisc().getRandomField();
|
|
259
278
|
|
|
260
279
|
return toForeignCallResult([toSingle(randomField)]);
|
|
261
280
|
}
|
|
262
281
|
|
|
263
|
-
|
|
264
|
-
|
|
282
|
+
// eslint-disable-next-line camelcase
|
|
283
|
+
async aztec_txe_getLastBlockTimestamp() {
|
|
284
|
+
const timestamp = await this.handlerAsTxe().getLastBlockTimestamp();
|
|
265
285
|
|
|
266
286
|
return toForeignCallResult([toSingle(new Fr(timestamp))]);
|
|
267
287
|
}
|
|
268
288
|
|
|
269
|
-
|
|
270
|
-
|
|
289
|
+
// eslint-disable-next-line camelcase
|
|
290
|
+
async aztec_txe_getLastTxEffects() {
|
|
291
|
+
const { txHash, noteHashes, nullifiers } = await this.handlerAsTxe().getLastTxEffects();
|
|
271
292
|
|
|
272
293
|
return toForeignCallResult([
|
|
273
294
|
toSingle(txHash.hash),
|
|
@@ -276,7 +297,8 @@ export class RPCTranslator {
|
|
|
276
297
|
]);
|
|
277
298
|
}
|
|
278
299
|
|
|
279
|
-
|
|
300
|
+
// eslint-disable-next-line camelcase
|
|
301
|
+
async aztec_txe_getPrivateEvents(
|
|
280
302
|
foreignSelector: ForeignCallSingle,
|
|
281
303
|
foreignContractAddress: ForeignCallSingle,
|
|
282
304
|
foreignScope: ForeignCallSingle,
|
|
@@ -292,7 +314,7 @@ export class RPCTranslator {
|
|
|
292
314
|
await this.stateHandler.cycleJob();
|
|
293
315
|
}
|
|
294
316
|
|
|
295
|
-
const events = await this.handlerAsTxe().
|
|
317
|
+
const events = await this.handlerAsTxe().getPrivateEvents(selector, contractAddress, scope);
|
|
296
318
|
|
|
297
319
|
if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
|
|
298
320
|
throw new Error(`Array of length ${events.length} larger than maxLen ${MAX_PRIVATE_EVENTS_PER_TXE_QUERY}`);
|
|
@@ -316,26 +338,29 @@ export class RPCTranslator {
|
|
|
316
338
|
return toForeignCallResult([toArray(rawArrayStorage), toArray(eventLengths), toSingle(queryLength)]);
|
|
317
339
|
}
|
|
318
340
|
|
|
319
|
-
|
|
341
|
+
// eslint-disable-next-line camelcase
|
|
342
|
+
aztec_prv_storeInExecutionCache(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
|
|
320
343
|
const values = fromArray(foreignValues);
|
|
321
344
|
const hash = fromSingle(foreignHash);
|
|
322
345
|
|
|
323
|
-
this.handlerAsPrivate().
|
|
346
|
+
this.handlerAsPrivate().storeInExecutionCache(values, hash);
|
|
324
347
|
|
|
325
348
|
return toForeignCallResult([]);
|
|
326
349
|
}
|
|
327
350
|
|
|
328
|
-
|
|
351
|
+
// eslint-disable-next-line camelcase
|
|
352
|
+
async aztec_prv_loadFromExecutionCache(foreignHash: ForeignCallSingle) {
|
|
329
353
|
const hash = fromSingle(foreignHash);
|
|
330
354
|
|
|
331
|
-
const returns = await this.handlerAsPrivate().
|
|
355
|
+
const returns = await this.handlerAsPrivate().loadFromExecutionCache(hash);
|
|
332
356
|
|
|
333
357
|
return toForeignCallResult([toArray(returns)]);
|
|
334
358
|
}
|
|
335
359
|
|
|
336
360
|
// When the argument is a slice, noir automatically adds a length field to oracle call.
|
|
337
361
|
// When the argument is an array, we add the field length manually to the signature.
|
|
338
|
-
|
|
362
|
+
// eslint-disable-next-line camelcase
|
|
363
|
+
async aztec_utl_log(
|
|
339
364
|
foreignLevel: ForeignCallSingle,
|
|
340
365
|
foreignMessage: ForeignCallArray,
|
|
341
366
|
_foreignLength: ForeignCallSingle,
|
|
@@ -347,12 +372,13 @@ export class RPCTranslator {
|
|
|
347
372
|
.join('');
|
|
348
373
|
const fields = fromArray(foreignFields);
|
|
349
374
|
|
|
350
|
-
await this.handlerAsMisc().
|
|
375
|
+
await this.handlerAsMisc().log(level, message, fields);
|
|
351
376
|
|
|
352
377
|
return toForeignCallResult([]);
|
|
353
378
|
}
|
|
354
379
|
|
|
355
|
-
|
|
380
|
+
// eslint-disable-next-line camelcase
|
|
381
|
+
async aztec_utl_storageRead(
|
|
356
382
|
foreignBlockHash: ForeignCallSingle,
|
|
357
383
|
foreignContractAddress: ForeignCallSingle,
|
|
358
384
|
foreignStartStorageSlot: ForeignCallSingle,
|
|
@@ -363,7 +389,7 @@ export class RPCTranslator {
|
|
|
363
389
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
364
390
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
365
391
|
|
|
366
|
-
const values = await this.handlerAsUtility().
|
|
392
|
+
const values = await this.handlerAsUtility().storageRead(
|
|
367
393
|
blockHash,
|
|
368
394
|
contractAddress,
|
|
369
395
|
startStorageSlot,
|
|
@@ -373,11 +399,12 @@ export class RPCTranslator {
|
|
|
373
399
|
return toForeignCallResult([toArray(values)]);
|
|
374
400
|
}
|
|
375
401
|
|
|
376
|
-
|
|
402
|
+
// eslint-disable-next-line camelcase
|
|
403
|
+
async aztec_utl_getPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
377
404
|
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
378
405
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
379
406
|
|
|
380
|
-
const witness = await this.handlerAsUtility().
|
|
407
|
+
const witness = await this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot);
|
|
381
408
|
|
|
382
409
|
if (!witness) {
|
|
383
410
|
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockHash.toString()}.`);
|
|
@@ -385,7 +412,8 @@ export class RPCTranslator {
|
|
|
385
412
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
386
413
|
}
|
|
387
414
|
|
|
388
|
-
|
|
415
|
+
// eslint-disable-next-line camelcase
|
|
416
|
+
async aztec_utl_getNotes(
|
|
389
417
|
foreignOwnerIsSome: ForeignCallSingle,
|
|
390
418
|
foreignOwnerValue: ForeignCallSingle,
|
|
391
419
|
foreignStorageSlot: ForeignCallSingle,
|
|
@@ -426,7 +454,7 @@ export class RPCTranslator {
|
|
|
426
454
|
const maxNotes = fromSingle(foreignMaxNotes).toNumber();
|
|
427
455
|
const packedHintedNoteLength = fromSingle(foreignPackedHintedNoteLength).toNumber();
|
|
428
456
|
|
|
429
|
-
const noteDatas = await this.handlerAsUtility().
|
|
457
|
+
const noteDatas = await this.handlerAsUtility().getNotes(
|
|
430
458
|
owner,
|
|
431
459
|
storageSlot,
|
|
432
460
|
numSelects,
|
|
@@ -467,7 +495,8 @@ export class RPCTranslator {
|
|
|
467
495
|
);
|
|
468
496
|
}
|
|
469
497
|
|
|
470
|
-
|
|
498
|
+
// eslint-disable-next-line camelcase
|
|
499
|
+
aztec_prv_notifyCreatedNote(
|
|
471
500
|
foreignOwner: ForeignCallSingle,
|
|
472
501
|
foreignStorageSlot: ForeignCallSingle,
|
|
473
502
|
foreignRandomness: ForeignCallSingle,
|
|
@@ -484,20 +513,13 @@ export class RPCTranslator {
|
|
|
484
513
|
const noteHash = fromSingle(foreignNoteHash);
|
|
485
514
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
486
515
|
|
|
487
|
-
this.handlerAsPrivate().
|
|
488
|
-
owner,
|
|
489
|
-
storageSlot,
|
|
490
|
-
randomness,
|
|
491
|
-
noteTypeId,
|
|
492
|
-
note,
|
|
493
|
-
noteHash,
|
|
494
|
-
counter,
|
|
495
|
-
);
|
|
516
|
+
this.handlerAsPrivate().notifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter);
|
|
496
517
|
|
|
497
518
|
return toForeignCallResult([]);
|
|
498
519
|
}
|
|
499
520
|
|
|
500
|
-
|
|
521
|
+
// eslint-disable-next-line camelcase
|
|
522
|
+
async aztec_prv_notifyNullifiedNote(
|
|
501
523
|
foreignInnerNullifier: ForeignCallSingle,
|
|
502
524
|
foreignNoteHash: ForeignCallSingle,
|
|
503
525
|
foreignCounter: ForeignCallSingle,
|
|
@@ -506,40 +528,47 @@ export class RPCTranslator {
|
|
|
506
528
|
const noteHash = fromSingle(foreignNoteHash);
|
|
507
529
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
508
530
|
|
|
509
|
-
await this.handlerAsPrivate().
|
|
531
|
+
await this.handlerAsPrivate().notifyNullifiedNote(innerNullifier, noteHash, counter);
|
|
510
532
|
|
|
511
533
|
return toForeignCallResult([]);
|
|
512
534
|
}
|
|
513
535
|
|
|
514
|
-
|
|
536
|
+
// eslint-disable-next-line camelcase
|
|
537
|
+
async aztec_prv_notifyCreatedNullifier(foreignInnerNullifier: ForeignCallSingle) {
|
|
515
538
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
516
539
|
|
|
517
|
-
await this.handlerAsPrivate().
|
|
540
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(innerNullifier);
|
|
518
541
|
|
|
519
542
|
return toForeignCallResult([]);
|
|
520
543
|
}
|
|
521
544
|
|
|
522
|
-
|
|
545
|
+
// eslint-disable-next-line camelcase
|
|
546
|
+
async aztec_prv_isNullifierPending(
|
|
547
|
+
foreignInnerNullifier: ForeignCallSingle,
|
|
548
|
+
foreignContractAddress: ForeignCallSingle,
|
|
549
|
+
) {
|
|
523
550
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
524
551
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
525
552
|
|
|
526
|
-
const isPending = await this.handlerAsPrivate().
|
|
553
|
+
const isPending = await this.handlerAsPrivate().isNullifierPending(innerNullifier, contractAddress);
|
|
527
554
|
|
|
528
555
|
return toForeignCallResult([toSingle(new Fr(isPending))]);
|
|
529
556
|
}
|
|
530
557
|
|
|
531
|
-
|
|
558
|
+
// eslint-disable-next-line camelcase
|
|
559
|
+
async aztec_utl_checkNullifierExists(foreignInnerNullifier: ForeignCallSingle) {
|
|
532
560
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
533
561
|
|
|
534
|
-
const exists = await this.handlerAsUtility().
|
|
562
|
+
const exists = await this.handlerAsUtility().checkNullifierExists(innerNullifier);
|
|
535
563
|
|
|
536
564
|
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
537
565
|
}
|
|
538
566
|
|
|
539
|
-
|
|
567
|
+
// eslint-disable-next-line camelcase
|
|
568
|
+
async aztec_utl_getContractInstance(foreignAddress: ForeignCallSingle) {
|
|
540
569
|
const address = addressFromSingle(foreignAddress);
|
|
541
570
|
|
|
542
|
-
const instance = await this.handlerAsUtility().
|
|
571
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
543
572
|
|
|
544
573
|
return toForeignCallResult(
|
|
545
574
|
[
|
|
@@ -552,10 +581,11 @@ export class RPCTranslator {
|
|
|
552
581
|
);
|
|
553
582
|
}
|
|
554
583
|
|
|
555
|
-
|
|
584
|
+
// eslint-disable-next-line camelcase
|
|
585
|
+
async aztec_utl_tryGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
|
|
556
586
|
const address = addressFromSingle(foreignAddress);
|
|
557
587
|
|
|
558
|
-
const result = await this.handlerAsUtility().
|
|
588
|
+
const result = await this.handlerAsUtility().tryGetPublicKeysAndPartialAddress(address);
|
|
559
589
|
|
|
560
590
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
561
591
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -571,15 +601,17 @@ export class RPCTranslator {
|
|
|
571
601
|
}
|
|
572
602
|
}
|
|
573
603
|
|
|
574
|
-
|
|
604
|
+
// eslint-disable-next-line camelcase
|
|
605
|
+
async aztec_utl_getKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
|
|
575
606
|
const pkMHash = fromSingle(foreignPkMHash);
|
|
576
607
|
|
|
577
|
-
const keyValidationRequest = await this.handlerAsUtility().
|
|
608
|
+
const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(pkMHash);
|
|
578
609
|
|
|
579
610
|
return toForeignCallResult(keyValidationRequest.toFields().map(toSingle));
|
|
580
611
|
}
|
|
581
612
|
|
|
582
|
-
|
|
613
|
+
// eslint-disable-next-line camelcase
|
|
614
|
+
aztec_prv_callPrivateFunction(
|
|
583
615
|
_foreignTargetContractAddress: ForeignCallSingle,
|
|
584
616
|
_foreignFunctionSelector: ForeignCallSingle,
|
|
585
617
|
_foreignArgsHash: ForeignCallSingle,
|
|
@@ -591,11 +623,15 @@ export class RPCTranslator {
|
|
|
591
623
|
);
|
|
592
624
|
}
|
|
593
625
|
|
|
594
|
-
|
|
626
|
+
// eslint-disable-next-line camelcase
|
|
627
|
+
async aztec_utl_getNullifierMembershipWitness(
|
|
628
|
+
foreignBlockHash: ForeignCallSingle,
|
|
629
|
+
foreignNullifier: ForeignCallSingle,
|
|
630
|
+
) {
|
|
595
631
|
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
596
632
|
const nullifier = fromSingle(foreignNullifier);
|
|
597
633
|
|
|
598
|
-
const witness = await this.handlerAsUtility().
|
|
634
|
+
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
|
|
599
635
|
|
|
600
636
|
if (!witness) {
|
|
601
637
|
throw new Error(`Nullifier membership witness not found at block ${blockHash}.`);
|
|
@@ -603,10 +639,11 @@ export class RPCTranslator {
|
|
|
603
639
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
604
640
|
}
|
|
605
641
|
|
|
606
|
-
|
|
642
|
+
// eslint-disable-next-line camelcase
|
|
643
|
+
async aztec_utl_getAuthWitness(foreignMessageHash: ForeignCallSingle) {
|
|
607
644
|
const messageHash = fromSingle(foreignMessageHash);
|
|
608
645
|
|
|
609
|
-
const authWitness = await this.handlerAsUtility().
|
|
646
|
+
const authWitness = await this.handlerAsUtility().getAuthWitness(messageHash);
|
|
610
647
|
|
|
611
648
|
if (!authWitness) {
|
|
612
649
|
throw new Error(`Auth witness not found for message hash ${messageHash}.`);
|
|
@@ -614,7 +651,8 @@ export class RPCTranslator {
|
|
|
614
651
|
return toForeignCallResult([toArray(authWitness)]);
|
|
615
652
|
}
|
|
616
653
|
|
|
617
|
-
|
|
654
|
+
// eslint-disable-next-line camelcase
|
|
655
|
+
public aztec_prv_notifyEnqueuedPublicFunctionCall(
|
|
618
656
|
_foreignTargetContractAddress: ForeignCallSingle,
|
|
619
657
|
_foreignCalldataHash: ForeignCallSingle,
|
|
620
658
|
_foreignSideEffectCounter: ForeignCallSingle,
|
|
@@ -623,7 +661,8 @@ export class RPCTranslator {
|
|
|
623
661
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
624
662
|
}
|
|
625
663
|
|
|
626
|
-
|
|
664
|
+
// eslint-disable-next-line camelcase
|
|
665
|
+
public aztec_prv_notifySetPublicTeardownFunctionCall(
|
|
627
666
|
_foreignTargetContractAddress: ForeignCallSingle,
|
|
628
667
|
_foreignCalldataHash: ForeignCallSingle,
|
|
629
668
|
_foreignSideEffectCounter: ForeignCallSingle,
|
|
@@ -632,26 +671,30 @@ export class RPCTranslator {
|
|
|
632
671
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
633
672
|
}
|
|
634
673
|
|
|
635
|
-
|
|
674
|
+
// eslint-disable-next-line camelcase
|
|
675
|
+
public aztec_prv_notifySetMinRevertibleSideEffectCounter(_foreignMinRevertibleSideEffectCounter: ForeignCallSingle) {
|
|
636
676
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
637
677
|
}
|
|
638
678
|
|
|
639
|
-
|
|
679
|
+
// eslint-disable-next-line camelcase
|
|
680
|
+
public async aztec_prv_isSideEffectCounterRevertible(foreignSideEffectCounter: ForeignCallSingle) {
|
|
640
681
|
const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
|
|
641
|
-
const isRevertible = await this.handlerAsPrivate().
|
|
682
|
+
const isRevertible = await this.handlerAsPrivate().isSideEffectCounterRevertible(sideEffectCounter);
|
|
642
683
|
return toForeignCallResult([toSingle(new Fr(isRevertible))]);
|
|
643
684
|
}
|
|
644
685
|
|
|
645
|
-
|
|
646
|
-
|
|
686
|
+
// eslint-disable-next-line camelcase
|
|
687
|
+
aztec_utl_getUtilityContext() {
|
|
688
|
+
const context = this.handlerAsUtility().getUtilityContext();
|
|
647
689
|
|
|
648
690
|
return toForeignCallResult(context.toNoirRepresentation());
|
|
649
691
|
}
|
|
650
692
|
|
|
651
|
-
|
|
693
|
+
// eslint-disable-next-line camelcase
|
|
694
|
+
async aztec_utl_getBlockHeader(foreignBlockNumber: ForeignCallSingle) {
|
|
652
695
|
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
653
696
|
|
|
654
|
-
const header = await this.handlerAsUtility().
|
|
697
|
+
const header = await this.handlerAsUtility().getBlockHeader(blockNumber);
|
|
655
698
|
|
|
656
699
|
if (!header) {
|
|
657
700
|
throw new Error(`Block header not found for block ${blockNumber}.`);
|
|
@@ -659,14 +702,15 @@ export class RPCTranslator {
|
|
|
659
702
|
return toForeignCallResult(header.toFields().map(toSingle));
|
|
660
703
|
}
|
|
661
704
|
|
|
662
|
-
|
|
705
|
+
// eslint-disable-next-line camelcase
|
|
706
|
+
async aztec_utl_getNoteHashMembershipWitness(
|
|
663
707
|
foreignAnchorBlockHash: ForeignCallSingle,
|
|
664
708
|
foreignNoteHash: ForeignCallSingle,
|
|
665
709
|
) {
|
|
666
710
|
const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
667
711
|
const noteHash = fromSingle(foreignNoteHash);
|
|
668
712
|
|
|
669
|
-
const witness = await this.handlerAsUtility().
|
|
713
|
+
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
|
|
670
714
|
|
|
671
715
|
if (!witness) {
|
|
672
716
|
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
@@ -674,14 +718,15 @@ export class RPCTranslator {
|
|
|
674
718
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
675
719
|
}
|
|
676
720
|
|
|
677
|
-
|
|
721
|
+
// eslint-disable-next-line camelcase
|
|
722
|
+
async aztec_utl_getBlockHashMembershipWitness(
|
|
678
723
|
foreignAnchorBlockHash: ForeignCallSingle,
|
|
679
724
|
foreignBlockHash: ForeignCallSingle,
|
|
680
725
|
) {
|
|
681
726
|
const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
682
727
|
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
683
728
|
|
|
684
|
-
const witness = await this.handlerAsUtility().
|
|
729
|
+
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
685
730
|
|
|
686
731
|
if (!witness) {
|
|
687
732
|
throw new Error(
|
|
@@ -691,14 +736,15 @@ export class RPCTranslator {
|
|
|
691
736
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
692
737
|
}
|
|
693
738
|
|
|
694
|
-
|
|
739
|
+
// eslint-disable-next-line camelcase
|
|
740
|
+
async aztec_utl_getLowNullifierMembershipWitness(
|
|
695
741
|
foreignBlockHash: ForeignCallSingle,
|
|
696
742
|
foreignNullifier: ForeignCallSingle,
|
|
697
743
|
) {
|
|
698
744
|
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
699
745
|
const nullifier = fromSingle(foreignNullifier);
|
|
700
746
|
|
|
701
|
-
const witness = await this.handlerAsUtility().
|
|
747
|
+
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
|
|
702
748
|
|
|
703
749
|
if (!witness) {
|
|
704
750
|
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockHash}.`);
|
|
@@ -706,15 +752,17 @@ export class RPCTranslator {
|
|
|
706
752
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
707
753
|
}
|
|
708
754
|
|
|
709
|
-
|
|
755
|
+
// eslint-disable-next-line camelcase
|
|
756
|
+
async aztec_utl_fetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle) {
|
|
710
757
|
const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
|
|
711
758
|
|
|
712
|
-
await this.handlerAsUtility().
|
|
759
|
+
await this.handlerAsUtility().fetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
|
|
713
760
|
|
|
714
761
|
return toForeignCallResult([]);
|
|
715
762
|
}
|
|
716
763
|
|
|
717
|
-
|
|
764
|
+
// eslint-disable-next-line camelcase
|
|
765
|
+
public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
718
766
|
foreignContractAddress: ForeignCallSingle,
|
|
719
767
|
foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
720
768
|
foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
@@ -723,7 +771,7 @@ export class RPCTranslator {
|
|
|
723
771
|
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
724
772
|
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
725
773
|
|
|
726
|
-
await this.handlerAsUtility().
|
|
774
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
727
775
|
contractAddress,
|
|
728
776
|
noteValidationRequestsArrayBaseSlot,
|
|
729
777
|
eventValidationRequestsArrayBaseSlot,
|
|
@@ -732,7 +780,8 @@ export class RPCTranslator {
|
|
|
732
780
|
return toForeignCallResult([]);
|
|
733
781
|
}
|
|
734
782
|
|
|
735
|
-
|
|
783
|
+
// eslint-disable-next-line camelcase
|
|
784
|
+
public async aztec_utl_bulkRetrieveLogs(
|
|
736
785
|
foreignContractAddress: ForeignCallSingle,
|
|
737
786
|
foreignLogRetrievalRequestsArrayBaseSlot: ForeignCallSingle,
|
|
738
787
|
foreignLogRetrievalResponsesArrayBaseSlot: ForeignCallSingle,
|
|
@@ -741,7 +790,7 @@ export class RPCTranslator {
|
|
|
741
790
|
const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
|
|
742
791
|
const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
|
|
743
792
|
|
|
744
|
-
await this.handlerAsUtility().
|
|
793
|
+
await this.handlerAsUtility().bulkRetrieveLogs(
|
|
745
794
|
contractAddress,
|
|
746
795
|
logRetrievalRequestsArrayBaseSlot,
|
|
747
796
|
logRetrievalResponsesArrayBaseSlot,
|
|
@@ -750,7 +799,8 @@ export class RPCTranslator {
|
|
|
750
799
|
return toForeignCallResult([]);
|
|
751
800
|
}
|
|
752
801
|
|
|
753
|
-
|
|
802
|
+
// eslint-disable-next-line camelcase
|
|
803
|
+
async aztec_utl_storeCapsule(
|
|
754
804
|
foreignContractAddress: ForeignCallSingle,
|
|
755
805
|
foreignSlot: ForeignCallSingle,
|
|
756
806
|
foreignCapsule: ForeignCallArray,
|
|
@@ -759,12 +809,13 @@ export class RPCTranslator {
|
|
|
759
809
|
const slot = fromSingle(foreignSlot);
|
|
760
810
|
const capsule = fromArray(foreignCapsule);
|
|
761
811
|
|
|
762
|
-
await this.handlerAsUtility().
|
|
812
|
+
await this.handlerAsUtility().storeCapsule(contractAddress, slot, capsule);
|
|
763
813
|
|
|
764
814
|
return toForeignCallResult([]);
|
|
765
815
|
}
|
|
766
816
|
|
|
767
|
-
|
|
817
|
+
// eslint-disable-next-line camelcase
|
|
818
|
+
async aztec_utl_loadCapsule(
|
|
768
819
|
foreignContractAddress: ForeignCallSingle,
|
|
769
820
|
foreignSlot: ForeignCallSingle,
|
|
770
821
|
foreignTSize: ForeignCallSingle,
|
|
@@ -773,7 +824,7 @@ export class RPCTranslator {
|
|
|
773
824
|
const slot = fromSingle(foreignSlot);
|
|
774
825
|
const tSize = fromSingle(foreignTSize).toNumber();
|
|
775
826
|
|
|
776
|
-
const values = await this.handlerAsUtility().
|
|
827
|
+
const values = await this.handlerAsUtility().loadCapsule(contractAddress, slot);
|
|
777
828
|
|
|
778
829
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
779
830
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -786,16 +837,18 @@ export class RPCTranslator {
|
|
|
786
837
|
}
|
|
787
838
|
}
|
|
788
839
|
|
|
789
|
-
|
|
840
|
+
// eslint-disable-next-line camelcase
|
|
841
|
+
async aztec_utl_deleteCapsule(foreignContractAddress: ForeignCallSingle, foreignSlot: ForeignCallSingle) {
|
|
790
842
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
791
843
|
const slot = fromSingle(foreignSlot);
|
|
792
844
|
|
|
793
|
-
await this.handlerAsUtility().
|
|
845
|
+
await this.handlerAsUtility().deleteCapsule(contractAddress, slot);
|
|
794
846
|
|
|
795
847
|
return toForeignCallResult([]);
|
|
796
848
|
}
|
|
797
849
|
|
|
798
|
-
|
|
850
|
+
// eslint-disable-next-line camelcase
|
|
851
|
+
async aztec_utl_copyCapsule(
|
|
799
852
|
foreignContractAddress: ForeignCallSingle,
|
|
800
853
|
foreignSrcSlot: ForeignCallSingle,
|
|
801
854
|
foreignDstSlot: ForeignCallSingle,
|
|
@@ -806,7 +859,7 @@ export class RPCTranslator {
|
|
|
806
859
|
const dstSlot = fromSingle(foreignDstSlot);
|
|
807
860
|
const numEntries = fromSingle(foreignNumEntries).toNumber();
|
|
808
861
|
|
|
809
|
-
await this.handlerAsUtility().
|
|
862
|
+
await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
|
|
810
863
|
|
|
811
864
|
return toForeignCallResult([]);
|
|
812
865
|
}
|
|
@@ -815,7 +868,8 @@ export class RPCTranslator {
|
|
|
815
868
|
// 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
|
|
816
869
|
// to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
|
|
817
870
|
// existence of a txe_oracle method?
|
|
818
|
-
|
|
871
|
+
// eslint-disable-next-line camelcase
|
|
872
|
+
async aztec_utl_aes128Decrypt(
|
|
819
873
|
foreignCiphertextBVecStorage: ForeignCallArray,
|
|
820
874
|
foreignCiphertextLength: ForeignCallSingle,
|
|
821
875
|
foreignIv: ForeignCallArray,
|
|
@@ -825,14 +879,15 @@ export class RPCTranslator {
|
|
|
825
879
|
const iv = fromUintArray(foreignIv, 8);
|
|
826
880
|
const symKey = fromUintArray(foreignSymKey, 8);
|
|
827
881
|
|
|
828
|
-
const plaintextBuffer = await this.handlerAsUtility().
|
|
882
|
+
const plaintextBuffer = await this.handlerAsUtility().aes128Decrypt(ciphertext, iv, symKey);
|
|
829
883
|
|
|
830
884
|
return toForeignCallResult(
|
|
831
885
|
arrayToBoundedVec(bufferToU8Array(plaintextBuffer), foreignCiphertextBVecStorage.length),
|
|
832
886
|
);
|
|
833
887
|
}
|
|
834
888
|
|
|
835
|
-
|
|
889
|
+
// eslint-disable-next-line camelcase
|
|
890
|
+
async aztec_utl_getSharedSecret(
|
|
836
891
|
foreignAddress: ForeignCallSingle,
|
|
837
892
|
foreignEphPKField0: ForeignCallSingle,
|
|
838
893
|
foreignEphPKField1: ForeignCallSingle,
|
|
@@ -845,44 +900,49 @@ export class RPCTranslator {
|
|
|
845
900
|
fromSingle(foreignEphPKField2),
|
|
846
901
|
]);
|
|
847
902
|
|
|
848
|
-
const secret = await this.handlerAsUtility().
|
|
903
|
+
const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK);
|
|
849
904
|
|
|
850
905
|
return toForeignCallResult(secret.toFields().map(toSingle));
|
|
851
906
|
}
|
|
852
907
|
|
|
853
|
-
|
|
908
|
+
// eslint-disable-next-line camelcase
|
|
909
|
+
aztec_utl_emitOffchainEffect(_foreignData: ForeignCallArray) {
|
|
854
910
|
throw new Error('Offchain effects are not yet supported in the TestEnvironment');
|
|
855
911
|
}
|
|
856
912
|
|
|
857
913
|
// AVM opcodes
|
|
858
914
|
|
|
859
|
-
|
|
915
|
+
// eslint-disable-next-line camelcase
|
|
916
|
+
aztec_avm_emitPublicLog(_foreignMessage: ForeignCallArray) {
|
|
860
917
|
// TODO(#8811): Implement
|
|
861
918
|
return toForeignCallResult([]);
|
|
862
919
|
}
|
|
863
920
|
|
|
864
|
-
|
|
921
|
+
// eslint-disable-next-line camelcase
|
|
922
|
+
async aztec_avm_storageRead(foreignSlot: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
|
|
865
923
|
const slot = fromSingle(foreignSlot);
|
|
866
924
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
867
925
|
|
|
868
|
-
const value = (await this.handlerAsAvm().
|
|
926
|
+
const value = (await this.handlerAsAvm().storageRead(slot, contractAddress)).value;
|
|
869
927
|
|
|
870
928
|
return toForeignCallResult([toSingle(new Fr(value))]);
|
|
871
929
|
}
|
|
872
930
|
|
|
873
|
-
|
|
931
|
+
// eslint-disable-next-line camelcase
|
|
932
|
+
async aztec_avm_storageWrite(foreignSlot: ForeignCallSingle, foreignValue: ForeignCallSingle) {
|
|
874
933
|
const slot = fromSingle(foreignSlot);
|
|
875
934
|
const value = fromSingle(foreignValue);
|
|
876
935
|
|
|
877
|
-
await this.handlerAsAvm().
|
|
936
|
+
await this.handlerAsAvm().storageWrite(slot, value);
|
|
878
937
|
|
|
879
938
|
return toForeignCallResult([]);
|
|
880
939
|
}
|
|
881
940
|
|
|
882
|
-
|
|
941
|
+
// eslint-disable-next-line camelcase
|
|
942
|
+
async aztec_avm_getContractInstanceDeployer(foreignAddress: ForeignCallSingle) {
|
|
883
943
|
const address = addressFromSingle(foreignAddress);
|
|
884
944
|
|
|
885
|
-
const instance = await this.handlerAsUtility().
|
|
945
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
886
946
|
|
|
887
947
|
return toForeignCallResult([
|
|
888
948
|
toSingle(instance.deployer),
|
|
@@ -891,10 +951,11 @@ export class RPCTranslator {
|
|
|
891
951
|
]);
|
|
892
952
|
}
|
|
893
953
|
|
|
894
|
-
|
|
954
|
+
// eslint-disable-next-line camelcase
|
|
955
|
+
async aztec_avm_getContractInstanceClassId(foreignAddress: ForeignCallSingle) {
|
|
895
956
|
const address = addressFromSingle(foreignAddress);
|
|
896
957
|
|
|
897
|
-
const instance = await this.handlerAsUtility().
|
|
958
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
898
959
|
|
|
899
960
|
return toForeignCallResult([
|
|
900
961
|
toSingle(instance.currentContractClassId),
|
|
@@ -903,10 +964,11 @@ export class RPCTranslator {
|
|
|
903
964
|
]);
|
|
904
965
|
}
|
|
905
966
|
|
|
906
|
-
|
|
967
|
+
// eslint-disable-next-line camelcase
|
|
968
|
+
async aztec_avm_getContractInstanceInitializationHash(foreignAddress: ForeignCallSingle) {
|
|
907
969
|
const address = addressFromSingle(foreignAddress);
|
|
908
970
|
|
|
909
|
-
const instance = await this.handlerAsUtility().
|
|
971
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
910
972
|
|
|
911
973
|
return toForeignCallResult([
|
|
912
974
|
toSingle(instance.initializationHash),
|
|
@@ -915,85 +977,98 @@ export class RPCTranslator {
|
|
|
915
977
|
]);
|
|
916
978
|
}
|
|
917
979
|
|
|
918
|
-
|
|
919
|
-
|
|
980
|
+
// eslint-disable-next-line camelcase
|
|
981
|
+
async aztec_avm_sender() {
|
|
982
|
+
const sender = await this.handlerAsAvm().sender();
|
|
920
983
|
|
|
921
984
|
return toForeignCallResult([toSingle(sender)]);
|
|
922
985
|
}
|
|
923
986
|
|
|
924
|
-
|
|
987
|
+
// eslint-disable-next-line camelcase
|
|
988
|
+
async aztec_avm_emitNullifier(foreignNullifier: ForeignCallSingle) {
|
|
925
989
|
const nullifier = fromSingle(foreignNullifier);
|
|
926
990
|
|
|
927
|
-
await this.handlerAsAvm().
|
|
991
|
+
await this.handlerAsAvm().emitNullifier(nullifier);
|
|
928
992
|
|
|
929
993
|
return toForeignCallResult([]);
|
|
930
994
|
}
|
|
931
995
|
|
|
932
|
-
|
|
996
|
+
// eslint-disable-next-line camelcase
|
|
997
|
+
async aztec_avm_emitNoteHash(foreignNoteHash: ForeignCallSingle) {
|
|
933
998
|
const noteHash = fromSingle(foreignNoteHash);
|
|
934
999
|
|
|
935
|
-
await this.handlerAsAvm().
|
|
1000
|
+
await this.handlerAsAvm().emitNoteHash(noteHash);
|
|
936
1001
|
|
|
937
1002
|
return toForeignCallResult([]);
|
|
938
1003
|
}
|
|
939
1004
|
|
|
940
|
-
|
|
1005
|
+
// eslint-disable-next-line camelcase
|
|
1006
|
+
async aztec_avm_nullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
|
|
941
1007
|
const siloedNullifier = fromSingle(foreignSiloedNullifier);
|
|
942
1008
|
|
|
943
|
-
const exists = await this.handlerAsAvm().
|
|
1009
|
+
const exists = await this.handlerAsAvm().nullifierExists(siloedNullifier);
|
|
944
1010
|
|
|
945
1011
|
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
946
1012
|
}
|
|
947
1013
|
|
|
948
|
-
|
|
949
|
-
|
|
1014
|
+
// eslint-disable-next-line camelcase
|
|
1015
|
+
async aztec_avm_address() {
|
|
1016
|
+
const contractAddress = await this.handlerAsAvm().address();
|
|
950
1017
|
|
|
951
1018
|
return toForeignCallResult([toSingle(contractAddress.toField())]);
|
|
952
1019
|
}
|
|
953
1020
|
|
|
954
|
-
|
|
955
|
-
|
|
1021
|
+
// eslint-disable-next-line camelcase
|
|
1022
|
+
async aztec_avm_blockNumber() {
|
|
1023
|
+
const blockNumber = await this.handlerAsAvm().blockNumber();
|
|
956
1024
|
|
|
957
1025
|
return toForeignCallResult([toSingle(new Fr(blockNumber))]);
|
|
958
1026
|
}
|
|
959
1027
|
|
|
960
|
-
|
|
961
|
-
|
|
1028
|
+
// eslint-disable-next-line camelcase
|
|
1029
|
+
async aztec_avm_timestamp() {
|
|
1030
|
+
const timestamp = await this.handlerAsAvm().timestamp();
|
|
962
1031
|
|
|
963
1032
|
return toForeignCallResult([toSingle(new Fr(timestamp))]);
|
|
964
1033
|
}
|
|
965
1034
|
|
|
966
|
-
|
|
967
|
-
|
|
1035
|
+
// eslint-disable-next-line camelcase
|
|
1036
|
+
async aztec_avm_isStaticCall() {
|
|
1037
|
+
const isStaticCall = await this.handlerAsAvm().isStaticCall();
|
|
968
1038
|
|
|
969
1039
|
return toForeignCallResult([toSingle(new Fr(isStaticCall ? 1 : 0))]);
|
|
970
1040
|
}
|
|
971
1041
|
|
|
972
|
-
|
|
973
|
-
|
|
1042
|
+
// eslint-disable-next-line camelcase
|
|
1043
|
+
async aztec_avm_chainId() {
|
|
1044
|
+
const chainId = await this.handlerAsAvm().chainId();
|
|
974
1045
|
|
|
975
1046
|
return toForeignCallResult([toSingle(chainId)]);
|
|
976
1047
|
}
|
|
977
1048
|
|
|
978
|
-
|
|
979
|
-
|
|
1049
|
+
// eslint-disable-next-line camelcase
|
|
1050
|
+
async aztec_avm_version() {
|
|
1051
|
+
const version = await this.handlerAsAvm().version();
|
|
980
1052
|
|
|
981
1053
|
return toForeignCallResult([toSingle(version)]);
|
|
982
1054
|
}
|
|
983
1055
|
|
|
984
|
-
|
|
1056
|
+
// eslint-disable-next-line camelcase
|
|
1057
|
+
aztec_avm_returndataSize() {
|
|
985
1058
|
throw new Error(
|
|
986
1059
|
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
987
1060
|
);
|
|
988
1061
|
}
|
|
989
1062
|
|
|
990
|
-
|
|
1063
|
+
// eslint-disable-next-line camelcase
|
|
1064
|
+
aztec_avm_returndataCopy(_foreignRdOffset: ForeignCallSingle, _foreignCopySize: ForeignCallSingle) {
|
|
991
1065
|
throw new Error(
|
|
992
1066
|
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
993
1067
|
);
|
|
994
1068
|
}
|
|
995
1069
|
|
|
996
|
-
|
|
1070
|
+
// eslint-disable-next-line camelcase
|
|
1071
|
+
aztec_avm_call(
|
|
997
1072
|
_foreignL2Gas: ForeignCallSingle,
|
|
998
1073
|
_foreignDaGas: ForeignCallSingle,
|
|
999
1074
|
_foreignAddress: ForeignCallSingle,
|
|
@@ -1005,7 +1080,8 @@ export class RPCTranslator {
|
|
|
1005
1080
|
);
|
|
1006
1081
|
}
|
|
1007
1082
|
|
|
1008
|
-
|
|
1083
|
+
// eslint-disable-next-line camelcase
|
|
1084
|
+
aztec_avm_staticCall(
|
|
1009
1085
|
_foreignL2Gas: ForeignCallSingle,
|
|
1010
1086
|
_foreignDaGas: ForeignCallSingle,
|
|
1011
1087
|
_foreignAddress: ForeignCallSingle,
|
|
@@ -1017,13 +1093,15 @@ export class RPCTranslator {
|
|
|
1017
1093
|
);
|
|
1018
1094
|
}
|
|
1019
1095
|
|
|
1020
|
-
|
|
1096
|
+
// eslint-disable-next-line camelcase
|
|
1097
|
+
aztec_avm_successCopy() {
|
|
1021
1098
|
throw new Error(
|
|
1022
1099
|
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
1023
1100
|
);
|
|
1024
1101
|
}
|
|
1025
1102
|
|
|
1026
|
-
|
|
1103
|
+
// eslint-disable-next-line camelcase
|
|
1104
|
+
async aztec_txe_privateCallNewFlow(
|
|
1027
1105
|
foreignFrom: ForeignCallSingle,
|
|
1028
1106
|
foreignTargetContractAddress: ForeignCallSingle,
|
|
1029
1107
|
foreignFunctionSelector: ForeignCallSingle,
|
|
@@ -1038,7 +1116,7 @@ export class RPCTranslator {
|
|
|
1038
1116
|
const argsHash = fromSingle(foreignArgsHash);
|
|
1039
1117
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
1040
1118
|
|
|
1041
|
-
const returnValues = await this.handlerAsTxe().
|
|
1119
|
+
const returnValues = await this.handlerAsTxe().privateCallNewFlow(
|
|
1042
1120
|
from,
|
|
1043
1121
|
targetContractAddress,
|
|
1044
1122
|
functionSelector,
|
|
@@ -1053,7 +1131,8 @@ export class RPCTranslator {
|
|
|
1053
1131
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1054
1132
|
}
|
|
1055
1133
|
|
|
1056
|
-
|
|
1134
|
+
// eslint-disable-next-line camelcase
|
|
1135
|
+
async aztec_txe_executeUtilityFunction(
|
|
1057
1136
|
foreignTargetContractAddress: ForeignCallSingle,
|
|
1058
1137
|
foreignFunctionSelector: ForeignCallSingle,
|
|
1059
1138
|
foreignArgs: ForeignCallArray,
|
|
@@ -1062,7 +1141,7 @@ export class RPCTranslator {
|
|
|
1062
1141
|
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
1063
1142
|
const args = fromArray(foreignArgs);
|
|
1064
1143
|
|
|
1065
|
-
const returnValues = await this.handlerAsTxe().
|
|
1144
|
+
const returnValues = await this.handlerAsTxe().executeUtilityFunction(
|
|
1066
1145
|
targetContractAddress,
|
|
1067
1146
|
functionSelector,
|
|
1068
1147
|
args,
|
|
@@ -1074,7 +1153,8 @@ export class RPCTranslator {
|
|
|
1074
1153
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1075
1154
|
}
|
|
1076
1155
|
|
|
1077
|
-
|
|
1156
|
+
// eslint-disable-next-line camelcase
|
|
1157
|
+
async aztec_txe_publicCallNewFlow(
|
|
1078
1158
|
foreignFrom: ForeignCallSingle,
|
|
1079
1159
|
foreignAddress: ForeignCallSingle,
|
|
1080
1160
|
foreignCalldata: ForeignCallArray,
|
|
@@ -1085,15 +1165,16 @@ export class RPCTranslator {
|
|
|
1085
1165
|
const calldata = fromArray(foreignCalldata);
|
|
1086
1166
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
1087
1167
|
|
|
1088
|
-
const returnValues = await this.handlerAsTxe().
|
|
1168
|
+
const returnValues = await this.handlerAsTxe().publicCallNewFlow(from, address, calldata, isStaticCall);
|
|
1089
1169
|
|
|
1090
1170
|
// TODO(F-335): Avoid doing the following call here.
|
|
1091
1171
|
await this.stateHandler.cycleJob();
|
|
1092
1172
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1093
1173
|
}
|
|
1094
1174
|
|
|
1095
|
-
|
|
1096
|
-
|
|
1175
|
+
// eslint-disable-next-line camelcase
|
|
1176
|
+
async aztec_prv_getSenderForTags() {
|
|
1177
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
1097
1178
|
|
|
1098
1179
|
// Return a Noir Option struct with `some` and `value` fields
|
|
1099
1180
|
if (sender === undefined) {
|
|
@@ -1105,19 +1186,21 @@ export class RPCTranslator {
|
|
|
1105
1186
|
}
|
|
1106
1187
|
}
|
|
1107
1188
|
|
|
1108
|
-
|
|
1189
|
+
// eslint-disable-next-line camelcase
|
|
1190
|
+
async aztec_prv_setSenderForTags(foreignSenderForTags: ForeignCallSingle) {
|
|
1109
1191
|
const senderForTags = AztecAddress.fromField(fromSingle(foreignSenderForTags));
|
|
1110
1192
|
|
|
1111
|
-
await this.handlerAsPrivate().
|
|
1193
|
+
await this.handlerAsPrivate().setSenderForTags(senderForTags);
|
|
1112
1194
|
|
|
1113
1195
|
return toForeignCallResult([]);
|
|
1114
1196
|
}
|
|
1115
1197
|
|
|
1116
|
-
|
|
1198
|
+
// eslint-disable-next-line camelcase
|
|
1199
|
+
async aztec_prv_getNextAppTagAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) {
|
|
1117
1200
|
const sender = AztecAddress.fromField(fromSingle(foreignSender));
|
|
1118
1201
|
const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
|
|
1119
1202
|
|
|
1120
|
-
const nextAppTag = await this.handlerAsPrivate().
|
|
1203
|
+
const nextAppTag = await this.handlerAsPrivate().getNextAppTagAsSender(sender, recipient);
|
|
1121
1204
|
|
|
1122
1205
|
return toForeignCallResult([toSingle(nextAppTag.value)]);
|
|
1123
1206
|
}
|