@aztec/txe 0.0.1-commit.181e2d196 → 0.0.1-commit.1a421b1a1
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 +81 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +228 -149
- 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 +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 +242 -168
- package/src/state_machine/archiver.ts +5 -5
- package/src/txe_session.ts +3 -3
package/dest/rpc_translator.js
CHANGED
|
@@ -61,59 +61,69 @@ export class RPCTranslator {
|
|
|
61
61
|
return this.oracleHandler;
|
|
62
62
|
}
|
|
63
63
|
// TXE session state transition functions - these get handled by the state handler
|
|
64
|
-
|
|
64
|
+
// eslint-disable-next-line camelcase
|
|
65
|
+
async aztec_txe_setTopLevelTXEContext() {
|
|
65
66
|
await this.stateHandler.enterTopLevelState();
|
|
66
67
|
return toForeignCallResult([]);
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
// eslint-disable-next-line camelcase
|
|
70
|
+
async aztec_txe_setPrivateTXEContext(foreignContractAddressIsSome, foreignContractAddressValue, foreignAnchorBlockNumberIsSome, foreignAnchorBlockNumberValue) {
|
|
69
71
|
const contractAddress = fromSingle(foreignContractAddressIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignContractAddressValue)) : undefined;
|
|
70
72
|
const anchorBlockNumber = fromSingle(foreignAnchorBlockNumberIsSome).toBool() ? BlockNumber(fromSingle(foreignAnchorBlockNumberValue).toNumber()) : undefined;
|
|
71
73
|
const privateContextInputs = await this.stateHandler.enterPrivateState(contractAddress, anchorBlockNumber);
|
|
72
74
|
return toForeignCallResult(privateContextInputs.toFields().map(toSingle));
|
|
73
75
|
}
|
|
74
|
-
|
|
76
|
+
// eslint-disable-next-line camelcase
|
|
77
|
+
async aztec_txe_setPublicTXEContext(foreignContractAddressIsSome, foreignContractAddressValue) {
|
|
75
78
|
const contractAddress = fromSingle(foreignContractAddressIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignContractAddressValue)) : undefined;
|
|
76
79
|
await this.stateHandler.enterPublicState(contractAddress);
|
|
77
80
|
return toForeignCallResult([]);
|
|
78
81
|
}
|
|
79
|
-
|
|
82
|
+
// eslint-disable-next-line camelcase
|
|
83
|
+
async aztec_txe_setUtilityTXEContext(foreignContractAddressIsSome, foreignContractAddressValue) {
|
|
80
84
|
const contractAddress = fromSingle(foreignContractAddressIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignContractAddressValue)) : undefined;
|
|
81
85
|
await this.stateHandler.enterUtilityState(contractAddress);
|
|
82
86
|
return toForeignCallResult([]);
|
|
83
87
|
}
|
|
84
88
|
// Other oracles - these get handled by the oracle handler
|
|
85
89
|
// TXE-specific oracles
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
// eslint-disable-next-line camelcase
|
|
91
|
+
aztec_txe_getDefaultAddress() {
|
|
92
|
+
const defaultAddress = this.handlerAsTxe().getDefaultAddress();
|
|
88
93
|
return toForeignCallResult([
|
|
89
94
|
toSingle(defaultAddress)
|
|
90
95
|
]);
|
|
91
96
|
}
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
// eslint-disable-next-line camelcase
|
|
98
|
+
async aztec_txe_getNextBlockNumber() {
|
|
99
|
+
const nextBlockNumber = await this.handlerAsTxe().getNextBlockNumber();
|
|
94
100
|
return toForeignCallResult([
|
|
95
101
|
toSingle(nextBlockNumber)
|
|
96
102
|
]);
|
|
97
103
|
}
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
// eslint-disable-next-line camelcase
|
|
105
|
+
async aztec_txe_getNextBlockTimestamp() {
|
|
106
|
+
const nextBlockTimestamp = await this.handlerAsTxe().getNextBlockTimestamp();
|
|
100
107
|
return toForeignCallResult([
|
|
101
108
|
toSingle(nextBlockTimestamp)
|
|
102
109
|
]);
|
|
103
110
|
}
|
|
104
|
-
|
|
111
|
+
// eslint-disable-next-line camelcase
|
|
112
|
+
async aztec_txe_advanceBlocksBy(foreignBlocks) {
|
|
105
113
|
const blocks = fromSingle(foreignBlocks).toNumber();
|
|
106
|
-
await this.handlerAsTxe().
|
|
114
|
+
await this.handlerAsTxe().advanceBlocksBy(blocks);
|
|
107
115
|
return toForeignCallResult([]);
|
|
108
116
|
}
|
|
109
|
-
|
|
117
|
+
// eslint-disable-next-line camelcase
|
|
118
|
+
aztec_txe_advanceTimestampBy(foreignDuration) {
|
|
110
119
|
const duration = fromSingle(foreignDuration).toBigInt();
|
|
111
|
-
this.handlerAsTxe().
|
|
120
|
+
this.handlerAsTxe().advanceTimestampBy(duration);
|
|
112
121
|
return toForeignCallResult([]);
|
|
113
122
|
}
|
|
114
|
-
|
|
123
|
+
// eslint-disable-next-line camelcase
|
|
124
|
+
async aztec_txe_deploy(artifact, instance, foreignSecret) {
|
|
115
125
|
const secret = fromSingle(foreignSecret);
|
|
116
|
-
await this.handlerAsTxe().
|
|
126
|
+
await this.handlerAsTxe().deploy(artifact, instance, secret);
|
|
117
127
|
return toForeignCallResult([
|
|
118
128
|
toArray([
|
|
119
129
|
instance.salt,
|
|
@@ -124,55 +134,63 @@ export class RPCTranslator {
|
|
|
124
134
|
])
|
|
125
135
|
]);
|
|
126
136
|
}
|
|
127
|
-
|
|
137
|
+
// eslint-disable-next-line camelcase
|
|
138
|
+
async aztec_txe_createAccount(foreignSecret) {
|
|
128
139
|
const secret = fromSingle(foreignSecret);
|
|
129
|
-
const completeAddress = await this.handlerAsTxe().
|
|
140
|
+
const completeAddress = await this.handlerAsTxe().createAccount(secret);
|
|
130
141
|
return toForeignCallResult([
|
|
131
142
|
toSingle(completeAddress.address),
|
|
132
143
|
...completeAddress.publicKeys.toFields().map(toSingle)
|
|
133
144
|
]);
|
|
134
145
|
}
|
|
135
|
-
|
|
146
|
+
// eslint-disable-next-line camelcase
|
|
147
|
+
async aztec_txe_addAccount(artifact, instance, foreignSecret) {
|
|
136
148
|
const secret = fromSingle(foreignSecret);
|
|
137
|
-
const completeAddress = await this.handlerAsTxe().
|
|
149
|
+
const completeAddress = await this.handlerAsTxe().addAccount(artifact, instance, secret);
|
|
138
150
|
return toForeignCallResult([
|
|
139
151
|
toSingle(completeAddress.address),
|
|
140
152
|
...completeAddress.publicKeys.toFields().map(toSingle)
|
|
141
153
|
]);
|
|
142
154
|
}
|
|
143
|
-
|
|
155
|
+
// eslint-disable-next-line camelcase
|
|
156
|
+
async aztec_txe_addAuthWitness(foreignAddress, foreignMessageHash) {
|
|
144
157
|
const address = addressFromSingle(foreignAddress);
|
|
145
158
|
const messageHash = fromSingle(foreignMessageHash);
|
|
146
|
-
await this.handlerAsTxe().
|
|
159
|
+
await this.handlerAsTxe().addAuthWitness(address, messageHash);
|
|
147
160
|
return toForeignCallResult([]);
|
|
148
161
|
}
|
|
149
162
|
// PXE oracles
|
|
150
|
-
|
|
163
|
+
// eslint-disable-next-line camelcase
|
|
164
|
+
aztec_utl_assertCompatibleOracleVersion(foreignVersion) {
|
|
151
165
|
const version = fromSingle(foreignVersion).toNumber();
|
|
152
|
-
this.handlerAsMisc().
|
|
166
|
+
this.handlerAsMisc().assertCompatibleOracleVersion(version);
|
|
153
167
|
return toForeignCallResult([]);
|
|
154
168
|
}
|
|
155
|
-
|
|
156
|
-
|
|
169
|
+
// eslint-disable-next-line camelcase
|
|
170
|
+
aztec_utl_getRandomField() {
|
|
171
|
+
const randomField = this.handlerAsMisc().getRandomField();
|
|
157
172
|
return toForeignCallResult([
|
|
158
173
|
toSingle(randomField)
|
|
159
174
|
]);
|
|
160
175
|
}
|
|
161
|
-
|
|
162
|
-
|
|
176
|
+
// eslint-disable-next-line camelcase
|
|
177
|
+
async aztec_txe_getLastBlockTimestamp() {
|
|
178
|
+
const timestamp = await this.handlerAsTxe().getLastBlockTimestamp();
|
|
163
179
|
return toForeignCallResult([
|
|
164
180
|
toSingle(new Fr(timestamp))
|
|
165
181
|
]);
|
|
166
182
|
}
|
|
167
|
-
|
|
168
|
-
|
|
183
|
+
// eslint-disable-next-line camelcase
|
|
184
|
+
async aztec_txe_getLastTxEffects() {
|
|
185
|
+
const { txHash, noteHashes, nullifiers } = await this.handlerAsTxe().getLastTxEffects();
|
|
169
186
|
return toForeignCallResult([
|
|
170
187
|
toSingle(txHash.hash),
|
|
171
188
|
...arrayToBoundedVec(toArray(noteHashes), MAX_NOTE_HASHES_PER_TX),
|
|
172
189
|
...arrayToBoundedVec(toArray(nullifiers), MAX_NULLIFIERS_PER_TX)
|
|
173
190
|
]);
|
|
174
191
|
}
|
|
175
|
-
|
|
192
|
+
// eslint-disable-next-line camelcase
|
|
193
|
+
async aztec_txe_getPrivateEvents(foreignSelector, foreignContractAddress, foreignScope) {
|
|
176
194
|
const selector = EventSelector.fromField(fromSingle(foreignSelector));
|
|
177
195
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
178
196
|
const scope = addressFromSingle(foreignScope);
|
|
@@ -182,7 +200,7 @@ export class RPCTranslator {
|
|
|
182
200
|
// We cycle job to commit the stores after the contract sync.
|
|
183
201
|
await this.stateHandler.cycleJob();
|
|
184
202
|
}
|
|
185
|
-
const events = await this.handlerAsTxe().
|
|
203
|
+
const events = await this.handlerAsTxe().getPrivateEvents(selector, contractAddress, scope);
|
|
186
204
|
if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
|
|
187
205
|
throw new Error(`Array of length ${events.length} larger than maxLen ${MAX_PRIVATE_EVENTS_PER_TXE_QUERY}`);
|
|
188
206
|
}
|
|
@@ -200,48 +218,54 @@ export class RPCTranslator {
|
|
|
200
218
|
toSingle(queryLength)
|
|
201
219
|
]);
|
|
202
220
|
}
|
|
203
|
-
|
|
221
|
+
// eslint-disable-next-line camelcase
|
|
222
|
+
aztec_prv_storeInExecutionCache(foreignValues, foreignHash) {
|
|
204
223
|
const values = fromArray(foreignValues);
|
|
205
224
|
const hash = fromSingle(foreignHash);
|
|
206
|
-
this.handlerAsPrivate().
|
|
225
|
+
this.handlerAsPrivate().storeInExecutionCache(values, hash);
|
|
207
226
|
return toForeignCallResult([]);
|
|
208
227
|
}
|
|
209
|
-
|
|
228
|
+
// eslint-disable-next-line camelcase
|
|
229
|
+
async aztec_prv_loadFromExecutionCache(foreignHash) {
|
|
210
230
|
const hash = fromSingle(foreignHash);
|
|
211
|
-
const returns = await this.handlerAsPrivate().
|
|
231
|
+
const returns = await this.handlerAsPrivate().loadFromExecutionCache(hash);
|
|
212
232
|
return toForeignCallResult([
|
|
213
233
|
toArray(returns)
|
|
214
234
|
]);
|
|
215
235
|
}
|
|
216
236
|
// When the argument is a slice, noir automatically adds a length field to oracle call.
|
|
217
237
|
// When the argument is an array, we add the field length manually to the signature.
|
|
218
|
-
|
|
238
|
+
// eslint-disable-next-line camelcase
|
|
239
|
+
async aztec_utl_log(foreignLevel, foreignMessage, _foreignLength, foreignFields) {
|
|
219
240
|
const level = fromSingle(foreignLevel).toNumber();
|
|
220
241
|
const message = fromArray(foreignMessage).map((field)=>String.fromCharCode(field.toNumber())).join('');
|
|
221
242
|
const fields = fromArray(foreignFields);
|
|
222
|
-
await this.handlerAsMisc().
|
|
243
|
+
await this.handlerAsMisc().log(level, message, fields);
|
|
223
244
|
return toForeignCallResult([]);
|
|
224
245
|
}
|
|
225
|
-
|
|
246
|
+
// eslint-disable-next-line camelcase
|
|
247
|
+
async aztec_utl_storageRead(foreignBlockHash, foreignContractAddress, foreignStartStorageSlot, foreignNumberOfElements) {
|
|
226
248
|
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
227
249
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
228
250
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
229
251
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
230
|
-
const values = await this.handlerAsUtility().
|
|
252
|
+
const values = await this.handlerAsUtility().storageRead(blockHash, contractAddress, startStorageSlot, numberOfElements);
|
|
231
253
|
return toForeignCallResult([
|
|
232
254
|
toArray(values)
|
|
233
255
|
]);
|
|
234
256
|
}
|
|
235
|
-
|
|
257
|
+
// eslint-disable-next-line camelcase
|
|
258
|
+
async aztec_utl_getPublicDataWitness(foreignBlockHash, foreignLeafSlot) {
|
|
236
259
|
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
237
260
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
238
|
-
const witness = await this.handlerAsUtility().
|
|
261
|
+
const witness = await this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot);
|
|
239
262
|
if (!witness) {
|
|
240
263
|
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockHash.toString()}.`);
|
|
241
264
|
}
|
|
242
265
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
243
266
|
}
|
|
244
|
-
|
|
267
|
+
// eslint-disable-next-line camelcase
|
|
268
|
+
async aztec_utl_getNotes(foreignOwnerIsSome, foreignOwnerValue, foreignStorageSlot, foreignNumSelects, foreignSelectByIndexes, foreignSelectByOffsets, foreignSelectByLengths, foreignSelectValues, foreignSelectComparators, foreignSortByIndexes, foreignSortByOffsets, foreignSortByLengths, foreignSortOrder, foreignLimit, foreignOffset, foreignStatus, foreignMaxNotes, foreignPackedHintedNoteLength) {
|
|
245
269
|
// Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
|
|
246
270
|
const owner = fromSingle(foreignOwnerIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignOwnerValue)) : undefined;
|
|
247
271
|
const storageSlot = fromSingle(foreignStorageSlot);
|
|
@@ -260,7 +284,7 @@ export class RPCTranslator {
|
|
|
260
284
|
const status = fromSingle(foreignStatus).toNumber();
|
|
261
285
|
const maxNotes = fromSingle(foreignMaxNotes).toNumber();
|
|
262
286
|
const packedHintedNoteLength = fromSingle(foreignPackedHintedNoteLength).toNumber();
|
|
263
|
-
const noteDatas = await this.handlerAsUtility().
|
|
287
|
+
const noteDatas = await this.handlerAsUtility().getNotes(owner, storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status);
|
|
264
288
|
const returnDataAsArrayOfArrays = noteDatas.map((noteData)=>packAsHintedNote({
|
|
265
289
|
contractAddress: noteData.contractAddress,
|
|
266
290
|
owner: noteData.owner,
|
|
@@ -275,7 +299,8 @@ export class RPCTranslator {
|
|
|
275
299
|
// At last we convert the array of arrays to a bounded vec of arrays
|
|
276
300
|
return toForeignCallResult(arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfForeignCallSingleArrays, maxNotes, packedHintedNoteLength));
|
|
277
301
|
}
|
|
278
|
-
|
|
302
|
+
// eslint-disable-next-line camelcase
|
|
303
|
+
aztec_prv_notifyCreatedNote(foreignOwner, foreignStorageSlot, foreignRandomness, foreignNoteTypeId, foreignNote, foreignNoteHash, foreignCounter) {
|
|
279
304
|
const owner = addressFromSingle(foreignOwner);
|
|
280
305
|
const storageSlot = fromSingle(foreignStorageSlot);
|
|
281
306
|
const randomness = fromSingle(foreignRandomness);
|
|
@@ -283,39 +308,44 @@ export class RPCTranslator {
|
|
|
283
308
|
const note = fromArray(foreignNote);
|
|
284
309
|
const noteHash = fromSingle(foreignNoteHash);
|
|
285
310
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
286
|
-
this.handlerAsPrivate().
|
|
311
|
+
this.handlerAsPrivate().notifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter);
|
|
287
312
|
return toForeignCallResult([]);
|
|
288
313
|
}
|
|
289
|
-
|
|
314
|
+
// eslint-disable-next-line camelcase
|
|
315
|
+
async aztec_prv_notifyNullifiedNote(foreignInnerNullifier, foreignNoteHash, foreignCounter) {
|
|
290
316
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
291
317
|
const noteHash = fromSingle(foreignNoteHash);
|
|
292
318
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
293
|
-
await this.handlerAsPrivate().
|
|
319
|
+
await this.handlerAsPrivate().notifyNullifiedNote(innerNullifier, noteHash, counter);
|
|
294
320
|
return toForeignCallResult([]);
|
|
295
321
|
}
|
|
296
|
-
|
|
322
|
+
// eslint-disable-next-line camelcase
|
|
323
|
+
async aztec_prv_notifyCreatedNullifier(foreignInnerNullifier) {
|
|
297
324
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
298
|
-
await this.handlerAsPrivate().
|
|
325
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(innerNullifier);
|
|
299
326
|
return toForeignCallResult([]);
|
|
300
327
|
}
|
|
301
|
-
|
|
328
|
+
// eslint-disable-next-line camelcase
|
|
329
|
+
async aztec_prv_isNullifierPending(foreignInnerNullifier, foreignContractAddress) {
|
|
302
330
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
303
331
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
304
|
-
const isPending = await this.handlerAsPrivate().
|
|
332
|
+
const isPending = await this.handlerAsPrivate().isNullifierPending(innerNullifier, contractAddress);
|
|
305
333
|
return toForeignCallResult([
|
|
306
334
|
toSingle(new Fr(isPending))
|
|
307
335
|
]);
|
|
308
336
|
}
|
|
309
|
-
|
|
337
|
+
// eslint-disable-next-line camelcase
|
|
338
|
+
async aztec_utl_checkNullifierExists(foreignInnerNullifier) {
|
|
310
339
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
311
|
-
const exists = await this.handlerAsUtility().
|
|
340
|
+
const exists = await this.handlerAsUtility().checkNullifierExists(innerNullifier);
|
|
312
341
|
return toForeignCallResult([
|
|
313
342
|
toSingle(new Fr(exists))
|
|
314
343
|
]);
|
|
315
344
|
}
|
|
316
|
-
|
|
345
|
+
// eslint-disable-next-line camelcase
|
|
346
|
+
async aztec_utl_getContractInstance(foreignAddress) {
|
|
317
347
|
const address = addressFromSingle(foreignAddress);
|
|
318
|
-
const instance = await this.handlerAsUtility().
|
|
348
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
319
349
|
return toForeignCallResult([
|
|
320
350
|
instance.salt,
|
|
321
351
|
instance.deployer.toField(),
|
|
@@ -324,9 +354,10 @@ export class RPCTranslator {
|
|
|
324
354
|
...instance.publicKeys.toFields()
|
|
325
355
|
].map(toSingle));
|
|
326
356
|
}
|
|
327
|
-
|
|
357
|
+
// eslint-disable-next-line camelcase
|
|
358
|
+
async aztec_utl_tryGetPublicKeysAndPartialAddress(foreignAddress) {
|
|
328
359
|
const address = addressFromSingle(foreignAddress);
|
|
329
|
-
const result = await this.handlerAsUtility().
|
|
360
|
+
const result = await this.handlerAsUtility().tryGetPublicKeysAndPartialAddress(address);
|
|
330
361
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
331
362
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
332
363
|
if (result === undefined) {
|
|
@@ -346,26 +377,30 @@ export class RPCTranslator {
|
|
|
346
377
|
]);
|
|
347
378
|
}
|
|
348
379
|
}
|
|
349
|
-
|
|
380
|
+
// eslint-disable-next-line camelcase
|
|
381
|
+
async aztec_utl_getKeyValidationRequest(foreignPkMHash) {
|
|
350
382
|
const pkMHash = fromSingle(foreignPkMHash);
|
|
351
|
-
const keyValidationRequest = await this.handlerAsUtility().
|
|
383
|
+
const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(pkMHash);
|
|
352
384
|
return toForeignCallResult(keyValidationRequest.toFields().map(toSingle));
|
|
353
385
|
}
|
|
354
|
-
|
|
386
|
+
// eslint-disable-next-line camelcase
|
|
387
|
+
aztec_prv_callPrivateFunction(_foreignTargetContractAddress, _foreignFunctionSelector, _foreignArgsHash, _foreignSideEffectCounter, _foreignIsStaticCall) {
|
|
355
388
|
throw new Error('Contract calls are forbidden inside a `TestEnvironment::private_context`, use `private_call` instead');
|
|
356
389
|
}
|
|
357
|
-
|
|
390
|
+
// eslint-disable-next-line camelcase
|
|
391
|
+
async aztec_utl_getNullifierMembershipWitness(foreignBlockHash, foreignNullifier) {
|
|
358
392
|
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
359
393
|
const nullifier = fromSingle(foreignNullifier);
|
|
360
|
-
const witness = await this.handlerAsUtility().
|
|
394
|
+
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
|
|
361
395
|
if (!witness) {
|
|
362
396
|
throw new Error(`Nullifier membership witness not found at block ${blockHash}.`);
|
|
363
397
|
}
|
|
364
398
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
365
399
|
}
|
|
366
|
-
|
|
400
|
+
// eslint-disable-next-line camelcase
|
|
401
|
+
async aztec_utl_getAuthWitness(foreignMessageHash) {
|
|
367
402
|
const messageHash = fromSingle(foreignMessageHash);
|
|
368
|
-
const authWitness = await this.handlerAsUtility().
|
|
403
|
+
const authWitness = await this.handlerAsUtility().getAuthWitness(messageHash);
|
|
369
404
|
if (!authWitness) {
|
|
370
405
|
throw new Error(`Auth witness not found for message hash ${messageHash}.`);
|
|
371
406
|
}
|
|
@@ -373,92 +408,104 @@ export class RPCTranslator {
|
|
|
373
408
|
toArray(authWitness)
|
|
374
409
|
]);
|
|
375
410
|
}
|
|
376
|
-
|
|
411
|
+
// eslint-disable-next-line camelcase
|
|
412
|
+
aztec_prv_validatePublicCalldata(_foreignCalldataHash) {
|
|
377
413
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
378
414
|
}
|
|
379
|
-
|
|
415
|
+
// eslint-disable-next-line camelcase
|
|
416
|
+
aztec_prv_notifyRevertiblePhaseStart(_foreignMinRevertibleSideEffectCounter) {
|
|
380
417
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
381
418
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
async privateIsSideEffectCounterRevertible(foreignSideEffectCounter) {
|
|
419
|
+
// eslint-disable-next-line camelcase
|
|
420
|
+
async aztec_prv_inRevertiblePhase(foreignSideEffectCounter) {
|
|
386
421
|
const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
|
|
387
|
-
const isRevertible = await this.handlerAsPrivate().
|
|
422
|
+
const isRevertible = await this.handlerAsPrivate().inRevertiblePhase(sideEffectCounter);
|
|
388
423
|
return toForeignCallResult([
|
|
389
424
|
toSingle(new Fr(isRevertible))
|
|
390
425
|
]);
|
|
391
426
|
}
|
|
392
|
-
|
|
393
|
-
|
|
427
|
+
// eslint-disable-next-line camelcase
|
|
428
|
+
aztec_utl_getUtilityContext() {
|
|
429
|
+
const context = this.handlerAsUtility().getUtilityContext();
|
|
394
430
|
return toForeignCallResult(context.toNoirRepresentation());
|
|
395
431
|
}
|
|
396
|
-
|
|
432
|
+
// eslint-disable-next-line camelcase
|
|
433
|
+
async aztec_utl_getBlockHeader(foreignBlockNumber) {
|
|
397
434
|
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
398
|
-
const header = await this.handlerAsUtility().
|
|
435
|
+
const header = await this.handlerAsUtility().getBlockHeader(blockNumber);
|
|
399
436
|
if (!header) {
|
|
400
437
|
throw new Error(`Block header not found for block ${blockNumber}.`);
|
|
401
438
|
}
|
|
402
439
|
return toForeignCallResult(header.toFields().map(toSingle));
|
|
403
440
|
}
|
|
404
|
-
|
|
441
|
+
// eslint-disable-next-line camelcase
|
|
442
|
+
async aztec_utl_getNoteHashMembershipWitness(foreignAnchorBlockHash, foreignNoteHash) {
|
|
405
443
|
const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
406
444
|
const noteHash = fromSingle(foreignNoteHash);
|
|
407
|
-
const witness = await this.handlerAsUtility().
|
|
445
|
+
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
|
|
408
446
|
if (!witness) {
|
|
409
447
|
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
410
448
|
}
|
|
411
449
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
412
450
|
}
|
|
413
|
-
|
|
451
|
+
// eslint-disable-next-line camelcase
|
|
452
|
+
async aztec_utl_getBlockHashMembershipWitness(foreignAnchorBlockHash, foreignBlockHash) {
|
|
414
453
|
const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
415
454
|
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
416
|
-
const witness = await this.handlerAsUtility().
|
|
455
|
+
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
417
456
|
if (!witness) {
|
|
418
457
|
throw new Error(`Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`);
|
|
419
458
|
}
|
|
420
459
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
421
460
|
}
|
|
422
|
-
|
|
461
|
+
// eslint-disable-next-line camelcase
|
|
462
|
+
async aztec_utl_getLowNullifierMembershipWitness(foreignBlockHash, foreignNullifier) {
|
|
423
463
|
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
424
464
|
const nullifier = fromSingle(foreignNullifier);
|
|
425
|
-
const witness = await this.handlerAsUtility().
|
|
465
|
+
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
|
|
426
466
|
if (!witness) {
|
|
427
467
|
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockHash}.`);
|
|
428
468
|
}
|
|
429
469
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
430
470
|
}
|
|
431
|
-
|
|
471
|
+
// eslint-disable-next-line camelcase
|
|
472
|
+
async aztec_utl_fetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot) {
|
|
432
473
|
const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
|
|
433
|
-
await this.handlerAsUtility().
|
|
474
|
+
await this.handlerAsUtility().fetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
|
|
434
475
|
return toForeignCallResult([]);
|
|
435
476
|
}
|
|
436
|
-
|
|
477
|
+
// eslint-disable-next-line camelcase
|
|
478
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(foreignContractAddress, foreignNoteValidationRequestsArrayBaseSlot, foreignEventValidationRequestsArrayBaseSlot, foreignMaxNotePackedLen, foreignMaxEventSerializedLen) {
|
|
437
479
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
438
480
|
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
439
481
|
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
440
|
-
|
|
482
|
+
const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
|
|
483
|
+
const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
|
|
484
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(contractAddress, noteValidationRequestsArrayBaseSlot, eventValidationRequestsArrayBaseSlot, maxNotePackedLen, maxEventSerializedLen);
|
|
441
485
|
return toForeignCallResult([]);
|
|
442
486
|
}
|
|
443
|
-
|
|
487
|
+
// eslint-disable-next-line camelcase
|
|
488
|
+
async aztec_utl_bulkRetrieveLogs(foreignContractAddress, foreignLogRetrievalRequestsArrayBaseSlot, foreignLogRetrievalResponsesArrayBaseSlot) {
|
|
444
489
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
445
490
|
const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
|
|
446
491
|
const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
|
|
447
|
-
await this.handlerAsUtility().
|
|
492
|
+
await this.handlerAsUtility().bulkRetrieveLogs(contractAddress, logRetrievalRequestsArrayBaseSlot, logRetrievalResponsesArrayBaseSlot);
|
|
448
493
|
return toForeignCallResult([]);
|
|
449
494
|
}
|
|
450
|
-
|
|
495
|
+
// eslint-disable-next-line camelcase
|
|
496
|
+
async aztec_utl_storeCapsule(foreignContractAddress, foreignSlot, foreignCapsule) {
|
|
451
497
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
452
498
|
const slot = fromSingle(foreignSlot);
|
|
453
499
|
const capsule = fromArray(foreignCapsule);
|
|
454
|
-
await this.handlerAsUtility().
|
|
500
|
+
await this.handlerAsUtility().storeCapsule(contractAddress, slot, capsule);
|
|
455
501
|
return toForeignCallResult([]);
|
|
456
502
|
}
|
|
457
|
-
|
|
503
|
+
// eslint-disable-next-line camelcase
|
|
504
|
+
async aztec_utl_loadCapsule(foreignContractAddress, foreignSlot, foreignTSize) {
|
|
458
505
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
459
506
|
const slot = fromSingle(foreignSlot);
|
|
460
507
|
const tSize = fromSingle(foreignTSize).toNumber();
|
|
461
|
-
const values = await this.handlerAsUtility().
|
|
508
|
+
const values = await this.handlerAsUtility().loadCapsule(contractAddress, slot);
|
|
462
509
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
463
510
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
464
511
|
if (values === null) {
|
|
@@ -475,203 +522,233 @@ export class RPCTranslator {
|
|
|
475
522
|
]);
|
|
476
523
|
}
|
|
477
524
|
}
|
|
478
|
-
|
|
525
|
+
// eslint-disable-next-line camelcase
|
|
526
|
+
async aztec_utl_deleteCapsule(foreignContractAddress, foreignSlot) {
|
|
479
527
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
480
528
|
const slot = fromSingle(foreignSlot);
|
|
481
|
-
await this.handlerAsUtility().
|
|
529
|
+
await this.handlerAsUtility().deleteCapsule(contractAddress, slot);
|
|
482
530
|
return toForeignCallResult([]);
|
|
483
531
|
}
|
|
484
|
-
|
|
532
|
+
// eslint-disable-next-line camelcase
|
|
533
|
+
async aztec_utl_copyCapsule(foreignContractAddress, foreignSrcSlot, foreignDstSlot, foreignNumEntries) {
|
|
485
534
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
486
535
|
const srcSlot = fromSingle(foreignSrcSlot);
|
|
487
536
|
const dstSlot = fromSingle(foreignDstSlot);
|
|
488
537
|
const numEntries = fromSingle(foreignNumEntries).toNumber();
|
|
489
|
-
await this.handlerAsUtility().
|
|
538
|
+
await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
|
|
490
539
|
return toForeignCallResult([]);
|
|
491
540
|
}
|
|
492
541
|
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
493
542
|
// 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
|
|
494
543
|
// to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
|
|
495
544
|
// existence of a txe_oracle method?
|
|
496
|
-
|
|
545
|
+
// eslint-disable-next-line camelcase
|
|
546
|
+
async aztec_utl_aes128Decrypt(foreignCiphertextBVecStorage, foreignCiphertextLength, foreignIv, foreignSymKey) {
|
|
497
547
|
const ciphertext = fromUintBoundedVec(foreignCiphertextBVecStorage, foreignCiphertextLength, 8);
|
|
498
548
|
const iv = fromUintArray(foreignIv, 8);
|
|
499
549
|
const symKey = fromUintArray(foreignSymKey, 8);
|
|
500
|
-
const plaintextBuffer = await this.handlerAsUtility().
|
|
550
|
+
const plaintextBuffer = await this.handlerAsUtility().aes128Decrypt(ciphertext, iv, symKey);
|
|
501
551
|
return toForeignCallResult(arrayToBoundedVec(bufferToU8Array(plaintextBuffer), foreignCiphertextBVecStorage.length));
|
|
502
552
|
}
|
|
503
|
-
|
|
553
|
+
// eslint-disable-next-line camelcase
|
|
554
|
+
async aztec_utl_getSharedSecret(foreignAddress, foreignEphPKField0, foreignEphPKField1, foreignEphPKField2) {
|
|
504
555
|
const address = AztecAddress.fromField(fromSingle(foreignAddress));
|
|
505
556
|
const ephPK = Point.fromFields([
|
|
506
557
|
fromSingle(foreignEphPKField0),
|
|
507
558
|
fromSingle(foreignEphPKField1),
|
|
508
559
|
fromSingle(foreignEphPKField2)
|
|
509
560
|
]);
|
|
510
|
-
const secret = await this.handlerAsUtility().
|
|
561
|
+
const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK);
|
|
511
562
|
return toForeignCallResult(secret.toFields().map(toSingle));
|
|
512
563
|
}
|
|
513
|
-
|
|
564
|
+
// eslint-disable-next-line camelcase
|
|
565
|
+
aztec_utl_emitOffchainEffect(_foreignData) {
|
|
514
566
|
throw new Error('Offchain effects are not yet supported in the TestEnvironment');
|
|
515
567
|
}
|
|
516
568
|
// AVM opcodes
|
|
517
|
-
|
|
569
|
+
// eslint-disable-next-line camelcase
|
|
570
|
+
aztec_avm_emitPublicLog(_foreignMessage) {
|
|
518
571
|
// TODO(#8811): Implement
|
|
519
572
|
return toForeignCallResult([]);
|
|
520
573
|
}
|
|
521
|
-
|
|
574
|
+
// eslint-disable-next-line camelcase
|
|
575
|
+
async aztec_avm_storageRead(foreignSlot, foreignContractAddress) {
|
|
522
576
|
const slot = fromSingle(foreignSlot);
|
|
523
577
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
524
|
-
const value = (await this.handlerAsAvm().
|
|
578
|
+
const value = (await this.handlerAsAvm().storageRead(slot, contractAddress)).value;
|
|
525
579
|
return toForeignCallResult([
|
|
526
580
|
toSingle(new Fr(value))
|
|
527
581
|
]);
|
|
528
582
|
}
|
|
529
|
-
|
|
583
|
+
// eslint-disable-next-line camelcase
|
|
584
|
+
async aztec_avm_storageWrite(foreignSlot, foreignValue) {
|
|
530
585
|
const slot = fromSingle(foreignSlot);
|
|
531
586
|
const value = fromSingle(foreignValue);
|
|
532
|
-
await this.handlerAsAvm().
|
|
587
|
+
await this.handlerAsAvm().storageWrite(slot, value);
|
|
533
588
|
return toForeignCallResult([]);
|
|
534
589
|
}
|
|
535
|
-
|
|
590
|
+
// eslint-disable-next-line camelcase
|
|
591
|
+
async aztec_avm_getContractInstanceDeployer(foreignAddress) {
|
|
536
592
|
const address = addressFromSingle(foreignAddress);
|
|
537
|
-
const instance = await this.handlerAsUtility().
|
|
593
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
538
594
|
return toForeignCallResult([
|
|
539
595
|
toSingle(instance.deployer),
|
|
540
596
|
// AVM requires an extra boolean indicating the instance was found
|
|
541
597
|
toSingle(new Fr(1))
|
|
542
598
|
]);
|
|
543
599
|
}
|
|
544
|
-
|
|
600
|
+
// eslint-disable-next-line camelcase
|
|
601
|
+
async aztec_avm_getContractInstanceClassId(foreignAddress) {
|
|
545
602
|
const address = addressFromSingle(foreignAddress);
|
|
546
|
-
const instance = await this.handlerAsUtility().
|
|
603
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
547
604
|
return toForeignCallResult([
|
|
548
605
|
toSingle(instance.currentContractClassId),
|
|
549
606
|
// AVM requires an extra boolean indicating the instance was found
|
|
550
607
|
toSingle(new Fr(1))
|
|
551
608
|
]);
|
|
552
609
|
}
|
|
553
|
-
|
|
610
|
+
// eslint-disable-next-line camelcase
|
|
611
|
+
async aztec_avm_getContractInstanceInitializationHash(foreignAddress) {
|
|
554
612
|
const address = addressFromSingle(foreignAddress);
|
|
555
|
-
const instance = await this.handlerAsUtility().
|
|
613
|
+
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
556
614
|
return toForeignCallResult([
|
|
557
615
|
toSingle(instance.initializationHash),
|
|
558
616
|
// AVM requires an extra boolean indicating the instance was found
|
|
559
617
|
toSingle(new Fr(1))
|
|
560
618
|
]);
|
|
561
619
|
}
|
|
562
|
-
|
|
563
|
-
|
|
620
|
+
// eslint-disable-next-line camelcase
|
|
621
|
+
async aztec_avm_sender() {
|
|
622
|
+
const sender = await this.handlerAsAvm().sender();
|
|
564
623
|
return toForeignCallResult([
|
|
565
624
|
toSingle(sender)
|
|
566
625
|
]);
|
|
567
626
|
}
|
|
568
|
-
|
|
627
|
+
// eslint-disable-next-line camelcase
|
|
628
|
+
async aztec_avm_emitNullifier(foreignNullifier) {
|
|
569
629
|
const nullifier = fromSingle(foreignNullifier);
|
|
570
|
-
await this.handlerAsAvm().
|
|
630
|
+
await this.handlerAsAvm().emitNullifier(nullifier);
|
|
571
631
|
return toForeignCallResult([]);
|
|
572
632
|
}
|
|
573
|
-
|
|
633
|
+
// eslint-disable-next-line camelcase
|
|
634
|
+
async aztec_avm_emitNoteHash(foreignNoteHash) {
|
|
574
635
|
const noteHash = fromSingle(foreignNoteHash);
|
|
575
|
-
await this.handlerAsAvm().
|
|
636
|
+
await this.handlerAsAvm().emitNoteHash(noteHash);
|
|
576
637
|
return toForeignCallResult([]);
|
|
577
638
|
}
|
|
578
|
-
|
|
639
|
+
// eslint-disable-next-line camelcase
|
|
640
|
+
async aztec_avm_nullifierExists(foreignSiloedNullifier) {
|
|
579
641
|
const siloedNullifier = fromSingle(foreignSiloedNullifier);
|
|
580
|
-
const exists = await this.handlerAsAvm().
|
|
642
|
+
const exists = await this.handlerAsAvm().nullifierExists(siloedNullifier);
|
|
581
643
|
return toForeignCallResult([
|
|
582
644
|
toSingle(new Fr(exists))
|
|
583
645
|
]);
|
|
584
646
|
}
|
|
585
|
-
|
|
586
|
-
|
|
647
|
+
// eslint-disable-next-line camelcase
|
|
648
|
+
async aztec_avm_address() {
|
|
649
|
+
const contractAddress = await this.handlerAsAvm().address();
|
|
587
650
|
return toForeignCallResult([
|
|
588
651
|
toSingle(contractAddress.toField())
|
|
589
652
|
]);
|
|
590
653
|
}
|
|
591
|
-
|
|
592
|
-
|
|
654
|
+
// eslint-disable-next-line camelcase
|
|
655
|
+
async aztec_avm_blockNumber() {
|
|
656
|
+
const blockNumber = await this.handlerAsAvm().blockNumber();
|
|
593
657
|
return toForeignCallResult([
|
|
594
658
|
toSingle(new Fr(blockNumber))
|
|
595
659
|
]);
|
|
596
660
|
}
|
|
597
|
-
|
|
598
|
-
|
|
661
|
+
// eslint-disable-next-line camelcase
|
|
662
|
+
async aztec_avm_timestamp() {
|
|
663
|
+
const timestamp = await this.handlerAsAvm().timestamp();
|
|
599
664
|
return toForeignCallResult([
|
|
600
665
|
toSingle(new Fr(timestamp))
|
|
601
666
|
]);
|
|
602
667
|
}
|
|
603
|
-
|
|
604
|
-
|
|
668
|
+
// eslint-disable-next-line camelcase
|
|
669
|
+
async aztec_avm_isStaticCall() {
|
|
670
|
+
const isStaticCall = await this.handlerAsAvm().isStaticCall();
|
|
605
671
|
return toForeignCallResult([
|
|
606
672
|
toSingle(new Fr(isStaticCall ? 1 : 0))
|
|
607
673
|
]);
|
|
608
674
|
}
|
|
609
|
-
|
|
610
|
-
|
|
675
|
+
// eslint-disable-next-line camelcase
|
|
676
|
+
async aztec_avm_chainId() {
|
|
677
|
+
const chainId = await this.handlerAsAvm().chainId();
|
|
611
678
|
return toForeignCallResult([
|
|
612
679
|
toSingle(chainId)
|
|
613
680
|
]);
|
|
614
681
|
}
|
|
615
|
-
|
|
616
|
-
|
|
682
|
+
// eslint-disable-next-line camelcase
|
|
683
|
+
async aztec_avm_version() {
|
|
684
|
+
const version = await this.handlerAsAvm().version();
|
|
617
685
|
return toForeignCallResult([
|
|
618
686
|
toSingle(version)
|
|
619
687
|
]);
|
|
620
688
|
}
|
|
621
|
-
|
|
689
|
+
// eslint-disable-next-line camelcase
|
|
690
|
+
aztec_avm_returndataSize() {
|
|
622
691
|
throw new Error('Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead');
|
|
623
692
|
}
|
|
624
|
-
|
|
693
|
+
// eslint-disable-next-line camelcase
|
|
694
|
+
aztec_avm_returndataCopy(_foreignRdOffset, _foreignCopySize) {
|
|
625
695
|
throw new Error('Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead');
|
|
626
696
|
}
|
|
627
|
-
|
|
697
|
+
// eslint-disable-next-line camelcase
|
|
698
|
+
aztec_avm_call(_foreignL2Gas, _foreignDaGas, _foreignAddress, _foreignLength, _foreignArgs) {
|
|
628
699
|
throw new Error('Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead');
|
|
629
700
|
}
|
|
630
|
-
|
|
701
|
+
// eslint-disable-next-line camelcase
|
|
702
|
+
aztec_avm_staticCall(_foreignL2Gas, _foreignDaGas, _foreignAddress, _foreignLength, _foreignArgs) {
|
|
631
703
|
throw new Error('Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead');
|
|
632
704
|
}
|
|
633
|
-
|
|
705
|
+
// eslint-disable-next-line camelcase
|
|
706
|
+
aztec_avm_successCopy() {
|
|
634
707
|
throw new Error('Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead');
|
|
635
708
|
}
|
|
636
|
-
|
|
709
|
+
// eslint-disable-next-line camelcase
|
|
710
|
+
async aztec_txe_privateCallNewFlow(foreignFrom, foreignTargetContractAddress, foreignFunctionSelector, foreignArgs, foreignArgsHash, foreignIsStaticCall) {
|
|
637
711
|
const from = addressFromSingle(foreignFrom);
|
|
638
712
|
const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
|
|
639
713
|
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
640
714
|
const args = fromArray(foreignArgs);
|
|
641
715
|
const argsHash = fromSingle(foreignArgsHash);
|
|
642
716
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
643
|
-
const returnValues = await this.handlerAsTxe().
|
|
717
|
+
const returnValues = await this.handlerAsTxe().privateCallNewFlow(from, targetContractAddress, functionSelector, args, argsHash, isStaticCall, this.stateHandler.getCurrentJob());
|
|
644
718
|
// TODO(F-335): Avoid doing the following call here.
|
|
645
719
|
await this.stateHandler.cycleJob();
|
|
646
720
|
return toForeignCallResult([
|
|
647
721
|
toArray(returnValues)
|
|
648
722
|
]);
|
|
649
723
|
}
|
|
650
|
-
|
|
724
|
+
// eslint-disable-next-line camelcase
|
|
725
|
+
async aztec_txe_executeUtilityFunction(foreignTargetContractAddress, foreignFunctionSelector, foreignArgs) {
|
|
651
726
|
const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
|
|
652
727
|
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
653
728
|
const args = fromArray(foreignArgs);
|
|
654
|
-
const returnValues = await this.handlerAsTxe().
|
|
729
|
+
const returnValues = await this.handlerAsTxe().executeUtilityFunction(targetContractAddress, functionSelector, args, this.stateHandler.getCurrentJob());
|
|
655
730
|
// TODO(F-335): Avoid doing the following call here.
|
|
656
731
|
await this.stateHandler.cycleJob();
|
|
657
732
|
return toForeignCallResult([
|
|
658
733
|
toArray(returnValues)
|
|
659
734
|
]);
|
|
660
735
|
}
|
|
661
|
-
|
|
736
|
+
// eslint-disable-next-line camelcase
|
|
737
|
+
async aztec_txe_publicCallNewFlow(foreignFrom, foreignAddress, foreignCalldata, foreignIsStaticCall) {
|
|
662
738
|
const from = addressFromSingle(foreignFrom);
|
|
663
739
|
const address = addressFromSingle(foreignAddress);
|
|
664
740
|
const calldata = fromArray(foreignCalldata);
|
|
665
741
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
666
|
-
const returnValues = await this.handlerAsTxe().
|
|
742
|
+
const returnValues = await this.handlerAsTxe().publicCallNewFlow(from, address, calldata, isStaticCall);
|
|
667
743
|
// TODO(F-335): Avoid doing the following call here.
|
|
668
744
|
await this.stateHandler.cycleJob();
|
|
669
745
|
return toForeignCallResult([
|
|
670
746
|
toArray(returnValues)
|
|
671
747
|
]);
|
|
672
748
|
}
|
|
673
|
-
|
|
674
|
-
|
|
749
|
+
// eslint-disable-next-line camelcase
|
|
750
|
+
async aztec_prv_getSenderForTags() {
|
|
751
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
675
752
|
// Return a Noir Option struct with `some` and `value` fields
|
|
676
753
|
if (sender === undefined) {
|
|
677
754
|
// No sender found, return Option with some=0 and value=0
|
|
@@ -687,15 +764,17 @@ export class RPCTranslator {
|
|
|
687
764
|
]);
|
|
688
765
|
}
|
|
689
766
|
}
|
|
690
|
-
|
|
767
|
+
// eslint-disable-next-line camelcase
|
|
768
|
+
async aztec_prv_setSenderForTags(foreignSenderForTags) {
|
|
691
769
|
const senderForTags = AztecAddress.fromField(fromSingle(foreignSenderForTags));
|
|
692
|
-
await this.handlerAsPrivate().
|
|
770
|
+
await this.handlerAsPrivate().setSenderForTags(senderForTags);
|
|
693
771
|
return toForeignCallResult([]);
|
|
694
772
|
}
|
|
695
|
-
|
|
773
|
+
// eslint-disable-next-line camelcase
|
|
774
|
+
async aztec_prv_getNextAppTagAsSender(foreignSender, foreignRecipient) {
|
|
696
775
|
const sender = AztecAddress.fromField(fromSingle(foreignSender));
|
|
697
776
|
const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
|
|
698
|
-
const nextAppTag = await this.handlerAsPrivate().
|
|
777
|
+
const nextAppTag = await this.handlerAsPrivate().getNextAppTagAsSender(sender, recipient);
|
|
699
778
|
return toForeignCallResult([
|
|
700
779
|
toSingle(nextAppTag.value)
|
|
701
780
|
]);
|