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