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