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