@aztec/txe 3.0.0-canary.a9708bd → 3.0.0-devnet.2-patch.1
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/bin/index.js +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +5 -2
- package/dest/oracle/interfaces.d.ts +55 -0
- package/dest/oracle/interfaces.d.ts.map +1 -0
- package/dest/oracle/interfaces.js +3 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +11 -11
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +30 -32
- package/dest/oracle/txe_oracle_top_level_context.d.ts +57 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_top_level_context.js +432 -0
- package/dest/{txe_service/txe_service.d.ts → rpc_translator.d.ts} +40 -31
- package/dest/rpc_translator.d.ts.map +1 -0
- package/dest/{txe_service/txe_service.js → rpc_translator.js} +172 -125
- package/dest/state_machine/archiver.d.ts +18 -9
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +21 -4
- package/dest/state_machine/dummy_p2p_client.d.ts +5 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +6 -0
- package/dest/state_machine/global_variable_builder.d.ts +3 -15
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +3 -22
- package/dest/state_machine/index.d.ts +2 -2
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +8 -6
- package/dest/state_machine/mock_epoch_cache.d.ts +6 -5
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +8 -7
- package/dest/state_machine/synchronizer.d.ts +5 -4
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +5 -4
- package/dest/txe_session.d.ts +36 -46
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +200 -82
- package/dest/util/encoding.d.ts +24 -24
- 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_data_provider.d.ts +1 -1
- package/dest/util/txe_account_data_provider.d.ts.map +1 -1
- package/dest/util/txe_contract_data_provider.d.ts +3 -2
- package/dest/util/txe_contract_data_provider.d.ts.map +1 -1
- package/dest/util/txe_contract_data_provider.js +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts +8 -6
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +14 -12
- package/dest/utils/block_creation.d.ts +14 -0
- package/dest/utils/block_creation.d.ts.map +1 -0
- package/dest/utils/block_creation.js +24 -0
- package/dest/utils/tx_effect_creation.d.ts +6 -0
- package/dest/utils/tx_effect_creation.d.ts.map +1 -0
- package/dest/utils/tx_effect_creation.js +16 -0
- package/package.json +18 -17
- package/src/bin/index.ts +1 -1
- package/src/index.ts +5 -8
- package/src/oracle/interfaces.ts +84 -0
- package/src/oracle/txe_oracle_public_context.ts +38 -71
- package/src/oracle/txe_oracle_top_level_context.ts +667 -0
- package/src/{txe_service/txe_service.ts → rpc_translator.ts} +222 -128
- package/src/state_machine/archiver.ts +33 -13
- package/src/state_machine/dummy_p2p_client.ts +10 -1
- package/src/state_machine/global_variable_builder.ts +7 -41
- package/src/state_machine/index.ts +10 -8
- package/src/state_machine/mock_epoch_cache.ts +12 -11
- package/src/state_machine/synchronizer.ts +8 -7
- package/src/txe_session.ts +305 -92
- package/src/util/encoding.ts +1 -1
- package/src/util/txe_contract_data_provider.ts +2 -1
- package/src/util/txe_public_contract_data_source.ts +16 -13
- package/src/utils/block_creation.ts +64 -0
- package/src/utils/tx_effect_creation.ts +38 -0
- package/dest/oracle/txe_oracle.d.ts +0 -124
- package/dest/oracle/txe_oracle.d.ts.map +0 -1
- package/dest/oracle/txe_oracle.js +0 -770
- package/dest/oracle/txe_typed_oracle.d.ts +0 -42
- package/dest/oracle/txe_typed_oracle.d.ts.map +0 -1
- package/dest/oracle/txe_typed_oracle.js +0 -83
- package/dest/txe_constants.d.ts +0 -2
- package/dest/txe_constants.d.ts.map +0 -1
- package/dest/txe_constants.js +0 -7
- package/dest/txe_service/txe_service.d.ts.map +0 -1
- package/src/oracle/txe_oracle.ts +0 -1287
- package/src/oracle/txe_typed_oracle.ts +0 -142
- package/src/txe_constants.ts +0 -9
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { Fr, Point } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX } from '@aztec/constants';
|
|
4
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
5
|
+
import {
|
|
6
|
+
type IMiscOracle,
|
|
7
|
+
type IPrivateExecutionOracle,
|
|
8
|
+
type IUtilityExecutionOracle,
|
|
9
|
+
packAsRetrievedNote,
|
|
10
|
+
} from '@aztec/pxe/simulator';
|
|
3
11
|
import { type ContractArtifact, FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
4
12
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
13
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
6
14
|
|
|
7
|
-
import type {
|
|
8
|
-
import type { TXESessionStateHandler } from '
|
|
15
|
+
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
16
|
+
import type { TXESessionStateHandler } from './txe_session.js';
|
|
9
17
|
import {
|
|
10
18
|
type ForeignCallArray,
|
|
11
19
|
type ForeignCallSingle,
|
|
@@ -20,11 +28,17 @@ import {
|
|
|
20
28
|
toArray,
|
|
21
29
|
toForeignCallResult,
|
|
22
30
|
toSingle,
|
|
23
|
-
} from '
|
|
31
|
+
} from './util/encoding.js';
|
|
24
32
|
|
|
25
|
-
export class
|
|
33
|
+
export class UnavailableOracleError extends Error {
|
|
34
|
+
constructor(oracleName: string) {
|
|
35
|
+
super(`${oracleName} oracles not available with the current handler`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class RPCTranslator {
|
|
26
40
|
/**
|
|
27
|
-
* Create a new instance of `
|
|
41
|
+
* Create a new instance of `RPCTranslator` that will translate all TXE RPC calls to and from the foreign
|
|
28
42
|
* (`ForeignCallSingle`, `ForeignCallResult`, etc.) and native TS types, delegating actual execution of the oracles
|
|
29
43
|
* to the different handlers.
|
|
30
44
|
* @param stateHandler The handler that will process TXE session state transitions, such as entering a private or
|
|
@@ -34,13 +48,61 @@ export class TXEService {
|
|
|
34
48
|
*/
|
|
35
49
|
constructor(
|
|
36
50
|
private stateHandler: TXESessionStateHandler,
|
|
37
|
-
private oracleHandler:
|
|
51
|
+
private oracleHandler:
|
|
52
|
+
| IMiscOracle
|
|
53
|
+
| IUtilityExecutionOracle
|
|
54
|
+
| IPrivateExecutionOracle
|
|
55
|
+
| IAvmExecutionOracle
|
|
56
|
+
| ITxeExecutionOracle,
|
|
38
57
|
) {}
|
|
39
58
|
|
|
59
|
+
// Note: If you rename the following functions to not start with "handlerAs", you must also update the validation
|
|
60
|
+
// check in `TXESession.processFunction`.
|
|
61
|
+
|
|
62
|
+
private handlerAsMisc(): IMiscOracle {
|
|
63
|
+
if (!('isMisc' in this.oracleHandler)) {
|
|
64
|
+
throw new UnavailableOracleError('Misc');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return this.oracleHandler;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private handlerAsUtility(): IUtilityExecutionOracle {
|
|
71
|
+
if (!('isUtility' in this.oracleHandler)) {
|
|
72
|
+
throw new UnavailableOracleError('Utility');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return this.oracleHandler;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private handlerAsPrivate(): IPrivateExecutionOracle {
|
|
79
|
+
if (!('isPrivate' in this.oracleHandler)) {
|
|
80
|
+
throw new UnavailableOracleError('Private');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return this.oracleHandler;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private handlerAsAvm(): IAvmExecutionOracle {
|
|
87
|
+
if (!('isAvm' in this.oracleHandler)) {
|
|
88
|
+
throw new UnavailableOracleError('Avm');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return this.oracleHandler;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private handlerAsTxe(): ITxeExecutionOracle {
|
|
95
|
+
if (!('isTxe' in this.oracleHandler)) {
|
|
96
|
+
throw new UnavailableOracleError('Txe');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return this.oracleHandler;
|
|
100
|
+
}
|
|
101
|
+
|
|
40
102
|
// TXE session state transition functions - these get handled by the state handler
|
|
41
103
|
|
|
42
104
|
async txeSetTopLevelTXEContext() {
|
|
43
|
-
await this.stateHandler.
|
|
105
|
+
await this.stateHandler.enterTopLevelState();
|
|
44
106
|
|
|
45
107
|
return toForeignCallResult([]);
|
|
46
108
|
}
|
|
@@ -48,18 +110,18 @@ export class TXEService {
|
|
|
48
110
|
async txeSetPrivateTXEContext(
|
|
49
111
|
foreignContractAddressIsSome: ForeignCallSingle,
|
|
50
112
|
foreignContractAddressValue: ForeignCallSingle,
|
|
51
|
-
|
|
52
|
-
|
|
113
|
+
foreignAnchorBlockNumberIsSome: ForeignCallSingle,
|
|
114
|
+
foreignAnchorBlockNumberValue: ForeignCallSingle,
|
|
53
115
|
) {
|
|
54
116
|
const contractAddress = fromSingle(foreignContractAddressIsSome).toBool()
|
|
55
117
|
? AztecAddress.fromField(fromSingle(foreignContractAddressValue))
|
|
56
118
|
: undefined;
|
|
57
119
|
|
|
58
|
-
const
|
|
59
|
-
? fromSingle(
|
|
120
|
+
const anchorBlockNumber = fromSingle(foreignAnchorBlockNumberIsSome).toBool()
|
|
121
|
+
? BlockNumber(fromSingle(foreignAnchorBlockNumberValue).toNumber())
|
|
60
122
|
: undefined;
|
|
61
123
|
|
|
62
|
-
const privateContextInputs = await this.stateHandler.
|
|
124
|
+
const privateContextInputs = await this.stateHandler.enterPrivateState(contractAddress, anchorBlockNumber);
|
|
63
125
|
|
|
64
126
|
return toForeignCallResult(privateContextInputs.toFields().map(toSingle));
|
|
65
127
|
}
|
|
@@ -72,7 +134,7 @@ export class TXEService {
|
|
|
72
134
|
? AztecAddress.fromField(fromSingle(foreignContractAddressValue))
|
|
73
135
|
: undefined;
|
|
74
136
|
|
|
75
|
-
await this.stateHandler.
|
|
137
|
+
await this.stateHandler.enterPublicState(contractAddress);
|
|
76
138
|
|
|
77
139
|
return toForeignCallResult([]);
|
|
78
140
|
}
|
|
@@ -85,7 +147,7 @@ export class TXEService {
|
|
|
85
147
|
? AztecAddress.fromField(fromSingle(foreignContractAddressValue))
|
|
86
148
|
: undefined;
|
|
87
149
|
|
|
88
|
-
await this.stateHandler.
|
|
150
|
+
await this.stateHandler.enterUtilityState(contractAddress);
|
|
89
151
|
|
|
90
152
|
return toForeignCallResult([]);
|
|
91
153
|
}
|
|
@@ -94,10 +156,22 @@ export class TXEService {
|
|
|
94
156
|
|
|
95
157
|
// TXE-specific oracles
|
|
96
158
|
|
|
159
|
+
async txeGetNextBlockNumber() {
|
|
160
|
+
const nextBlockNumber = await this.handlerAsTxe().txeGetNextBlockNumber();
|
|
161
|
+
|
|
162
|
+
return toForeignCallResult([toSingle(nextBlockNumber)]);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async txeGetNextBlockTimestamp() {
|
|
166
|
+
const nextBlockTimestamp = await this.handlerAsTxe().txeGetNextBlockTimestamp();
|
|
167
|
+
|
|
168
|
+
return toForeignCallResult([toSingle(nextBlockTimestamp)]);
|
|
169
|
+
}
|
|
170
|
+
|
|
97
171
|
async txeAdvanceBlocksBy(foreignBlocks: ForeignCallSingle) {
|
|
98
172
|
const blocks = fromSingle(foreignBlocks).toNumber();
|
|
99
173
|
|
|
100
|
-
await this.
|
|
174
|
+
await this.handlerAsTxe().txeAdvanceBlocksBy(blocks);
|
|
101
175
|
|
|
102
176
|
return toForeignCallResult([]);
|
|
103
177
|
}
|
|
@@ -105,7 +179,7 @@ export class TXEService {
|
|
|
105
179
|
txeAdvanceTimestampBy(foreignDuration: ForeignCallSingle) {
|
|
106
180
|
const duration = fromSingle(foreignDuration).toBigInt();
|
|
107
181
|
|
|
108
|
-
this.
|
|
182
|
+
this.handlerAsTxe().txeAdvanceTimestampBy(duration);
|
|
109
183
|
|
|
110
184
|
return toForeignCallResult([]);
|
|
111
185
|
}
|
|
@@ -113,7 +187,7 @@ export class TXEService {
|
|
|
113
187
|
async txeDeploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, foreignSecret: ForeignCallSingle) {
|
|
114
188
|
const secret = fromSingle(foreignSecret);
|
|
115
189
|
|
|
116
|
-
await this.
|
|
190
|
+
await this.handlerAsTxe().txeDeploy(artifact, instance, secret);
|
|
117
191
|
|
|
118
192
|
return toForeignCallResult([
|
|
119
193
|
toArray([
|
|
@@ -129,7 +203,7 @@ export class TXEService {
|
|
|
129
203
|
async txeCreateAccount(foreignSecret: ForeignCallSingle) {
|
|
130
204
|
const secret = fromSingle(foreignSecret);
|
|
131
205
|
|
|
132
|
-
const completeAddress = await this.
|
|
206
|
+
const completeAddress = await this.handlerAsTxe().txeCreateAccount(secret);
|
|
133
207
|
|
|
134
208
|
return toForeignCallResult([
|
|
135
209
|
toSingle(completeAddress.address),
|
|
@@ -144,7 +218,7 @@ export class TXEService {
|
|
|
144
218
|
) {
|
|
145
219
|
const secret = fromSingle(foreignSecret);
|
|
146
220
|
|
|
147
|
-
const completeAddress = await this.
|
|
221
|
+
const completeAddress = await this.handlerAsTxe().txeAddAccount(artifact, instance, secret);
|
|
148
222
|
|
|
149
223
|
return toForeignCallResult([
|
|
150
224
|
toSingle(completeAddress.address),
|
|
@@ -156,7 +230,7 @@ export class TXEService {
|
|
|
156
230
|
const address = addressFromSingle(foreignAddress);
|
|
157
231
|
const messageHash = fromSingle(foreignMessageHash);
|
|
158
232
|
|
|
159
|
-
await this.
|
|
233
|
+
await this.handlerAsTxe().txeAddAuthWitness(address, messageHash);
|
|
160
234
|
|
|
161
235
|
return toForeignCallResult([]);
|
|
162
236
|
}
|
|
@@ -166,52 +240,38 @@ export class TXEService {
|
|
|
166
240
|
utilityAssertCompatibleOracleVersion(foreignVersion: ForeignCallSingle) {
|
|
167
241
|
const version = fromSingle(foreignVersion).toNumber();
|
|
168
242
|
|
|
169
|
-
this.
|
|
243
|
+
this.handlerAsMisc().utilityAssertCompatibleOracleVersion(version);
|
|
170
244
|
|
|
171
245
|
return toForeignCallResult([]);
|
|
172
246
|
}
|
|
173
247
|
|
|
174
248
|
utilityGetRandomField() {
|
|
175
|
-
const randomField = this.
|
|
249
|
+
const randomField = this.handlerAsMisc().utilityGetRandomField();
|
|
176
250
|
|
|
177
251
|
return toForeignCallResult([toSingle(randomField)]);
|
|
178
252
|
}
|
|
179
253
|
|
|
180
|
-
async
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
return toForeignCallResult([toSingle(contractAddress.toField())]);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async utilityGetBlockNumber() {
|
|
187
|
-
const blockNumber = await this.oracleHandler.utilityGetBlockNumber();
|
|
188
|
-
|
|
189
|
-
return toForeignCallResult([toSingle(new Fr(blockNumber))]);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// seems to be used to mean the timestamp of the last mined block in txe (but that's not what is done here)
|
|
193
|
-
async utilityGetTimestamp() {
|
|
194
|
-
const timestamp = await this.oracleHandler.utilityGetTimestamp();
|
|
254
|
+
async txeGetLastBlockTimestamp() {
|
|
255
|
+
const timestamp = await this.handlerAsTxe().txeGetLastBlockTimestamp();
|
|
195
256
|
|
|
196
257
|
return toForeignCallResult([toSingle(new Fr(timestamp))]);
|
|
197
258
|
}
|
|
198
259
|
|
|
199
|
-
async
|
|
200
|
-
const
|
|
260
|
+
async txeGetLastTxEffects() {
|
|
261
|
+
const { txHash, noteHashes, nullifiers } = await this.handlerAsTxe().txeGetLastTxEffects();
|
|
201
262
|
|
|
202
|
-
return toForeignCallResult([
|
|
263
|
+
return toForeignCallResult([
|
|
264
|
+
toSingle(txHash.hash),
|
|
265
|
+
...arrayToBoundedVec(toArray(noteHashes), MAX_NOTE_HASHES_PER_TX),
|
|
266
|
+
...arrayToBoundedVec(toArray(nullifiers), MAX_NULLIFIERS_PER_TX),
|
|
267
|
+
]);
|
|
203
268
|
}
|
|
204
269
|
|
|
205
|
-
|
|
206
|
-
privateStoreInExecutionCache(
|
|
207
|
-
_foreignLength: ForeignCallSingle,
|
|
208
|
-
foreignValues: ForeignCallArray,
|
|
209
|
-
foreignHash: ForeignCallSingle,
|
|
210
|
-
) {
|
|
270
|
+
privateStoreInExecutionCache(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
|
|
211
271
|
const values = fromArray(foreignValues);
|
|
212
272
|
const hash = fromSingle(foreignHash);
|
|
213
273
|
|
|
214
|
-
this.
|
|
274
|
+
this.handlerAsPrivate().privateStoreInExecutionCache(values, hash);
|
|
215
275
|
|
|
216
276
|
return toForeignCallResult([]);
|
|
217
277
|
}
|
|
@@ -219,23 +279,26 @@ export class TXEService {
|
|
|
219
279
|
async privateLoadFromExecutionCache(foreignHash: ForeignCallSingle) {
|
|
220
280
|
const hash = fromSingle(foreignHash);
|
|
221
281
|
|
|
222
|
-
const returns = await this.
|
|
282
|
+
const returns = await this.handlerAsPrivate().privateLoadFromExecutionCache(hash);
|
|
223
283
|
|
|
224
284
|
return toForeignCallResult([toArray(returns)]);
|
|
225
285
|
}
|
|
226
286
|
|
|
227
|
-
//
|
|
287
|
+
// When the argument is a slice, noir automatically adds a length field to oracle call.
|
|
288
|
+
// When the argument is an array, we add the field length manually to the signature.
|
|
228
289
|
utilityDebugLog(
|
|
290
|
+
foreignLevel: ForeignCallSingle,
|
|
229
291
|
foreignMessage: ForeignCallArray,
|
|
230
292
|
_foreignLength: ForeignCallSingle,
|
|
231
293
|
foreignFields: ForeignCallArray,
|
|
232
294
|
) {
|
|
295
|
+
const level = fromSingle(foreignLevel).toNumber();
|
|
233
296
|
const message = fromArray(foreignMessage)
|
|
234
297
|
.map(field => String.fromCharCode(field.toNumber()))
|
|
235
298
|
.join('');
|
|
236
299
|
const fields = fromArray(foreignFields);
|
|
237
300
|
|
|
238
|
-
this.
|
|
301
|
+
this.handlerAsMisc().utilityDebugLog(level, message, fields);
|
|
239
302
|
|
|
240
303
|
return toForeignCallResult([]);
|
|
241
304
|
}
|
|
@@ -248,10 +311,10 @@ export class TXEService {
|
|
|
248
311
|
) {
|
|
249
312
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
250
313
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
251
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
314
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
252
315
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
253
316
|
|
|
254
|
-
const values = await this.
|
|
317
|
+
const values = await this.handlerAsUtility().utilityStorageRead(
|
|
255
318
|
contractAddress,
|
|
256
319
|
startStorageSlot,
|
|
257
320
|
blockNumber,
|
|
@@ -262,10 +325,10 @@ export class TXEService {
|
|
|
262
325
|
}
|
|
263
326
|
|
|
264
327
|
async utilityGetPublicDataWitness(foreignBlockNumber: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
265
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
328
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
266
329
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
267
330
|
|
|
268
|
-
const witness = await this.
|
|
331
|
+
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockNumber, leafSlot);
|
|
269
332
|
|
|
270
333
|
if (!witness) {
|
|
271
334
|
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockNumber}.`);
|
|
@@ -274,6 +337,8 @@ export class TXEService {
|
|
|
274
337
|
}
|
|
275
338
|
|
|
276
339
|
async utilityGetNotes(
|
|
340
|
+
foreignOwnerIsSome: ForeignCallSingle,
|
|
341
|
+
foreignOwnerValue: ForeignCallSingle,
|
|
277
342
|
foreignStorageSlot: ForeignCallSingle,
|
|
278
343
|
foreignNumSelects: ForeignCallSingle,
|
|
279
344
|
foreignSelectByIndexes: ForeignCallArray,
|
|
@@ -291,6 +356,10 @@ export class TXEService {
|
|
|
291
356
|
foreignMaxNotes: ForeignCallSingle,
|
|
292
357
|
foreignPackedRetrievedNoteLength: ForeignCallSingle,
|
|
293
358
|
) {
|
|
359
|
+
// Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
|
|
360
|
+
const owner = fromSingle(foreignOwnerIsSome).toBool()
|
|
361
|
+
? AztecAddress.fromField(fromSingle(foreignOwnerValue))
|
|
362
|
+
: undefined;
|
|
294
363
|
const storageSlot = fromSingle(foreignStorageSlot);
|
|
295
364
|
const numSelects = fromSingle(foreignNumSelects).toNumber();
|
|
296
365
|
const selectByIndexes = fromArray(foreignSelectByIndexes).map(fr => fr.toNumber());
|
|
@@ -308,7 +377,8 @@ export class TXEService {
|
|
|
308
377
|
const maxNotes = fromSingle(foreignMaxNotes).toNumber();
|
|
309
378
|
const packedRetrievedNoteLength = fromSingle(foreignPackedRetrievedNoteLength).toNumber();
|
|
310
379
|
|
|
311
|
-
const noteDatas = await this.
|
|
380
|
+
const noteDatas = await this.handlerAsUtility().utilityGetNotes(
|
|
381
|
+
owner,
|
|
312
382
|
storageSlot,
|
|
313
383
|
numSelects,
|
|
314
384
|
selectByIndexes,
|
|
@@ -325,7 +395,17 @@ export class TXEService {
|
|
|
325
395
|
status,
|
|
326
396
|
);
|
|
327
397
|
|
|
328
|
-
const returnDataAsArrayOfArrays = noteDatas.map(
|
|
398
|
+
const returnDataAsArrayOfArrays = noteDatas.map(noteData =>
|
|
399
|
+
packAsRetrievedNote({
|
|
400
|
+
contractAddress: noteData.contractAddress,
|
|
401
|
+
owner: noteData.owner,
|
|
402
|
+
randomness: noteData.randomness,
|
|
403
|
+
storageSlot: noteData.storageSlot,
|
|
404
|
+
noteNonce: noteData.noteNonce,
|
|
405
|
+
index: noteData.index,
|
|
406
|
+
note: noteData.note,
|
|
407
|
+
}),
|
|
408
|
+
);
|
|
329
409
|
|
|
330
410
|
// Now we convert each sub-array to an array of ForeignCallSingles
|
|
331
411
|
const returnDataAsArrayOfForeignCallSingleArrays = returnDataAsArrayOfArrays.map(subArray =>
|
|
@@ -343,19 +423,31 @@ export class TXEService {
|
|
|
343
423
|
}
|
|
344
424
|
|
|
345
425
|
privateNotifyCreatedNote(
|
|
426
|
+
foreignOwner: ForeignCallSingle,
|
|
346
427
|
foreignStorageSlot: ForeignCallSingle,
|
|
428
|
+
foreignRandomness: ForeignCallSingle,
|
|
347
429
|
foreignNoteTypeId: ForeignCallSingle,
|
|
348
430
|
foreignNote: ForeignCallArray,
|
|
349
431
|
foreignNoteHash: ForeignCallSingle,
|
|
350
432
|
foreignCounter: ForeignCallSingle,
|
|
351
433
|
) {
|
|
434
|
+
const owner = addressFromSingle(foreignOwner);
|
|
352
435
|
const storageSlot = fromSingle(foreignStorageSlot);
|
|
436
|
+
const randomness = fromSingle(foreignRandomness);
|
|
353
437
|
const noteTypeId = NoteSelector.fromField(fromSingle(foreignNoteTypeId));
|
|
354
438
|
const note = fromArray(foreignNote);
|
|
355
439
|
const noteHash = fromSingle(foreignNoteHash);
|
|
356
440
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
357
441
|
|
|
358
|
-
this.
|
|
442
|
+
this.handlerAsPrivate().privateNotifyCreatedNote(
|
|
443
|
+
owner,
|
|
444
|
+
storageSlot,
|
|
445
|
+
randomness,
|
|
446
|
+
noteTypeId,
|
|
447
|
+
note,
|
|
448
|
+
noteHash,
|
|
449
|
+
counter,
|
|
450
|
+
);
|
|
359
451
|
|
|
360
452
|
return toForeignCallResult([]);
|
|
361
453
|
}
|
|
@@ -369,7 +461,7 @@ export class TXEService {
|
|
|
369
461
|
const noteHash = fromSingle(foreignNoteHash);
|
|
370
462
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
371
463
|
|
|
372
|
-
await this.
|
|
464
|
+
await this.handlerAsPrivate().privateNotifyNullifiedNote(innerNullifier, noteHash, counter);
|
|
373
465
|
|
|
374
466
|
return toForeignCallResult([]);
|
|
375
467
|
}
|
|
@@ -377,7 +469,7 @@ export class TXEService {
|
|
|
377
469
|
async privateNotifyCreatedNullifier(foreignInnerNullifier: ForeignCallSingle) {
|
|
378
470
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
379
471
|
|
|
380
|
-
await this.
|
|
472
|
+
await this.handlerAsPrivate().privateNotifyCreatedNullifier(innerNullifier);
|
|
381
473
|
|
|
382
474
|
return toForeignCallResult([]);
|
|
383
475
|
}
|
|
@@ -385,7 +477,7 @@ export class TXEService {
|
|
|
385
477
|
async utilityCheckNullifierExists(foreignInnerNullifier: ForeignCallSingle) {
|
|
386
478
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
387
479
|
|
|
388
|
-
const exists = await this.
|
|
480
|
+
const exists = await this.handlerAsUtility().utilityCheckNullifierExists(innerNullifier);
|
|
389
481
|
|
|
390
482
|
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
391
483
|
}
|
|
@@ -393,7 +485,7 @@ export class TXEService {
|
|
|
393
485
|
async utilityGetContractInstance(foreignAddress: ForeignCallSingle) {
|
|
394
486
|
const address = addressFromSingle(foreignAddress);
|
|
395
487
|
|
|
396
|
-
const instance = await this.
|
|
488
|
+
const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
|
|
397
489
|
|
|
398
490
|
return toForeignCallResult(
|
|
399
491
|
[
|
|
@@ -409,7 +501,7 @@ export class TXEService {
|
|
|
409
501
|
async utilityGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
|
|
410
502
|
const address = addressFromSingle(foreignAddress);
|
|
411
503
|
|
|
412
|
-
const { publicKeys, partialAddress } = await this.
|
|
504
|
+
const { publicKeys, partialAddress } = await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(address);
|
|
413
505
|
|
|
414
506
|
return toForeignCallResult([toArray([...publicKeys.toFields(), partialAddress])]);
|
|
415
507
|
}
|
|
@@ -417,7 +509,7 @@ export class TXEService {
|
|
|
417
509
|
async utilityGetKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
|
|
418
510
|
const pkMHash = fromSingle(foreignPkMHash);
|
|
419
511
|
|
|
420
|
-
const keyValidationRequest = await this.
|
|
512
|
+
const keyValidationRequest = await this.handlerAsUtility().utilityGetKeyValidationRequest(pkMHash);
|
|
421
513
|
|
|
422
514
|
return toForeignCallResult(keyValidationRequest.toFields().map(toSingle));
|
|
423
515
|
}
|
|
@@ -438,10 +530,10 @@ export class TXEService {
|
|
|
438
530
|
foreignBlockNumber: ForeignCallSingle,
|
|
439
531
|
foreignNullifier: ForeignCallSingle,
|
|
440
532
|
) {
|
|
441
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
533
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
442
534
|
const nullifier = fromSingle(foreignNullifier);
|
|
443
535
|
|
|
444
|
-
const witness = await this.
|
|
536
|
+
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockNumber, nullifier);
|
|
445
537
|
|
|
446
538
|
if (!witness) {
|
|
447
539
|
throw new Error(`Nullifier membership witness not found at block ${blockNumber}.`);
|
|
@@ -452,7 +544,7 @@ export class TXEService {
|
|
|
452
544
|
async utilityGetAuthWitness(foreignMessageHash: ForeignCallSingle) {
|
|
453
545
|
const messageHash = fromSingle(foreignMessageHash);
|
|
454
546
|
|
|
455
|
-
const authWitness = await this.
|
|
547
|
+
const authWitness = await this.handlerAsUtility().utilityGetAuthWitness(messageHash);
|
|
456
548
|
|
|
457
549
|
if (!authWitness) {
|
|
458
550
|
throw new Error(`Auth witness not found for message hash ${messageHash}.`);
|
|
@@ -482,22 +574,22 @@ export class TXEService {
|
|
|
482
574
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
483
575
|
}
|
|
484
576
|
|
|
485
|
-
async
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
return toForeignCallResult([toSingle(
|
|
577
|
+
public async privateIsSideEffectCounterRevertible(foreignSideEffectCounter: ForeignCallSingle) {
|
|
578
|
+
const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
|
|
579
|
+
const isRevertible = await this.handlerAsPrivate().privateIsSideEffectCounterRevertible(sideEffectCounter);
|
|
580
|
+
return toForeignCallResult([toSingle(new Fr(isRevertible))]);
|
|
489
581
|
}
|
|
490
582
|
|
|
491
|
-
async
|
|
492
|
-
const
|
|
583
|
+
async utilityGetUtilityContext() {
|
|
584
|
+
const context = await this.handlerAsUtility().utilityGetUtilityContext();
|
|
493
585
|
|
|
494
|
-
return toForeignCallResult(
|
|
586
|
+
return toForeignCallResult(context.toNoirRepresentation());
|
|
495
587
|
}
|
|
496
588
|
|
|
497
589
|
async utilityGetBlockHeader(foreignBlockNumber: ForeignCallSingle) {
|
|
498
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
590
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
499
591
|
|
|
500
|
-
const header = await this.
|
|
592
|
+
const header = await this.handlerAsUtility().utilityGetBlockHeader(blockNumber);
|
|
501
593
|
|
|
502
594
|
if (!header) {
|
|
503
595
|
throw new Error(`Block header not found for block ${blockNumber}.`);
|
|
@@ -510,11 +602,11 @@ export class TXEService {
|
|
|
510
602
|
foreignTreeId: ForeignCallSingle,
|
|
511
603
|
foreignLeafValue: ForeignCallSingle,
|
|
512
604
|
) {
|
|
513
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
605
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
514
606
|
const treeId = fromSingle(foreignTreeId).toNumber();
|
|
515
607
|
const leafValue = fromSingle(foreignLeafValue);
|
|
516
608
|
|
|
517
|
-
const witness = await this.
|
|
609
|
+
const witness = await this.handlerAsUtility().utilityGetMembershipWitness(blockNumber, treeId, leafValue);
|
|
518
610
|
|
|
519
611
|
if (!witness) {
|
|
520
612
|
throw new Error(
|
|
@@ -528,10 +620,10 @@ export class TXEService {
|
|
|
528
620
|
foreignBlockNumber: ForeignCallSingle,
|
|
529
621
|
foreignNullifier: ForeignCallSingle,
|
|
530
622
|
) {
|
|
531
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
623
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
532
624
|
const nullifier = fromSingle(foreignNullifier);
|
|
533
625
|
|
|
534
|
-
const witness = await this.
|
|
626
|
+
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockNumber, nullifier);
|
|
535
627
|
|
|
536
628
|
if (!witness) {
|
|
537
629
|
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockNumber}.`);
|
|
@@ -539,19 +631,10 @@ export class TXEService {
|
|
|
539
631
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
540
632
|
}
|
|
541
633
|
|
|
542
|
-
async utilityGetIndexedTaggingSecretAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) {
|
|
543
|
-
const sender = AztecAddress.fromField(fromSingle(foreignSender));
|
|
544
|
-
const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
|
|
545
|
-
|
|
546
|
-
const secret = await this.oracleHandler.utilityGetIndexedTaggingSecretAsSender(sender, recipient);
|
|
547
|
-
|
|
548
|
-
return toForeignCallResult(secret.toFields().map(toSingle));
|
|
549
|
-
}
|
|
550
|
-
|
|
551
634
|
async utilityFetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle) {
|
|
552
635
|
const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
|
|
553
636
|
|
|
554
|
-
await this.
|
|
637
|
+
await this.handlerAsUtility().utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
|
|
555
638
|
|
|
556
639
|
return toForeignCallResult([]);
|
|
557
640
|
}
|
|
@@ -565,7 +648,7 @@ export class TXEService {
|
|
|
565
648
|
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
566
649
|
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
567
650
|
|
|
568
|
-
await this.
|
|
651
|
+
await this.handlerAsUtility().utilityValidateEnqueuedNotesAndEvents(
|
|
569
652
|
contractAddress,
|
|
570
653
|
noteValidationRequestsArrayBaseSlot,
|
|
571
654
|
eventValidationRequestsArrayBaseSlot,
|
|
@@ -583,7 +666,7 @@ export class TXEService {
|
|
|
583
666
|
const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
|
|
584
667
|
const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
|
|
585
668
|
|
|
586
|
-
await this.
|
|
669
|
+
await this.handlerAsUtility().utilityBulkRetrieveLogs(
|
|
587
670
|
contractAddress,
|
|
588
671
|
logRetrievalRequestsArrayBaseSlot,
|
|
589
672
|
logRetrievalResponsesArrayBaseSlot,
|
|
@@ -601,7 +684,7 @@ export class TXEService {
|
|
|
601
684
|
const slot = fromSingle(foreignSlot);
|
|
602
685
|
const capsule = fromArray(foreignCapsule);
|
|
603
686
|
|
|
604
|
-
await this.
|
|
687
|
+
await this.handlerAsUtility().utilityStoreCapsule(contractAddress, slot, capsule);
|
|
605
688
|
|
|
606
689
|
return toForeignCallResult([]);
|
|
607
690
|
}
|
|
@@ -615,7 +698,7 @@ export class TXEService {
|
|
|
615
698
|
const slot = fromSingle(foreignSlot);
|
|
616
699
|
const tSize = fromSingle(foreignTSize).toNumber();
|
|
617
700
|
|
|
618
|
-
const values = await this.
|
|
701
|
+
const values = await this.handlerAsUtility().utilityLoadCapsule(contractAddress, slot);
|
|
619
702
|
|
|
620
703
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
621
704
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -632,7 +715,7 @@ export class TXEService {
|
|
|
632
715
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
633
716
|
const slot = fromSingle(foreignSlot);
|
|
634
717
|
|
|
635
|
-
await this.
|
|
718
|
+
await this.handlerAsUtility().utilityDeleteCapsule(contractAddress, slot);
|
|
636
719
|
|
|
637
720
|
return toForeignCallResult([]);
|
|
638
721
|
}
|
|
@@ -648,7 +731,7 @@ export class TXEService {
|
|
|
648
731
|
const dstSlot = fromSingle(foreignDstSlot);
|
|
649
732
|
const numEntries = fromSingle(foreignNumEntries).toNumber();
|
|
650
733
|
|
|
651
|
-
await this.
|
|
734
|
+
await this.handlerAsUtility().utilityCopyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
|
|
652
735
|
|
|
653
736
|
return toForeignCallResult([]);
|
|
654
737
|
}
|
|
@@ -667,7 +750,7 @@ export class TXEService {
|
|
|
667
750
|
const iv = fromUintArray(foreignIv, 8);
|
|
668
751
|
const symKey = fromUintArray(foreignSymKey, 8);
|
|
669
752
|
|
|
670
|
-
const plaintextBuffer = await this.
|
|
753
|
+
const plaintextBuffer = await this.handlerAsUtility().utilityAes128Decrypt(ciphertext, iv, symKey);
|
|
671
754
|
|
|
672
755
|
return toForeignCallResult(
|
|
673
756
|
arrayToBoundedVec(bufferToU8Array(plaintextBuffer), foreignCiphertextBVecStorage.length),
|
|
@@ -687,7 +770,7 @@ export class TXEService {
|
|
|
687
770
|
fromSingle(foreignEphPKField2),
|
|
688
771
|
]);
|
|
689
772
|
|
|
690
|
-
const secret = await this.
|
|
773
|
+
const secret = await this.handlerAsUtility().utilityGetSharedSecret(address, ephPK);
|
|
691
774
|
|
|
692
775
|
return toForeignCallResult(secret.toFields().map(toSingle));
|
|
693
776
|
}
|
|
@@ -706,7 +789,7 @@ export class TXEService {
|
|
|
706
789
|
async avmOpcodeStorageRead(foreignSlot: ForeignCallSingle) {
|
|
707
790
|
const slot = fromSingle(foreignSlot);
|
|
708
791
|
|
|
709
|
-
const value = (await this.
|
|
792
|
+
const value = (await this.handlerAsAvm().avmOpcodeStorageRead(slot)).value;
|
|
710
793
|
|
|
711
794
|
return toForeignCallResult([toSingle(new Fr(value))]);
|
|
712
795
|
}
|
|
@@ -715,7 +798,7 @@ export class TXEService {
|
|
|
715
798
|
const slot = fromSingle(foreignSlot);
|
|
716
799
|
const value = fromSingle(foreignValue);
|
|
717
800
|
|
|
718
|
-
await this.
|
|
801
|
+
await this.handlerAsAvm().avmOpcodeStorageWrite(slot, value);
|
|
719
802
|
|
|
720
803
|
return toForeignCallResult([]);
|
|
721
804
|
}
|
|
@@ -723,7 +806,7 @@ export class TXEService {
|
|
|
723
806
|
async avmOpcodeGetContractInstanceDeployer(foreignAddress: ForeignCallSingle) {
|
|
724
807
|
const address = addressFromSingle(foreignAddress);
|
|
725
808
|
|
|
726
|
-
const instance = await this.
|
|
809
|
+
const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
|
|
727
810
|
|
|
728
811
|
return toForeignCallResult([
|
|
729
812
|
toSingle(instance.deployer),
|
|
@@ -735,7 +818,7 @@ export class TXEService {
|
|
|
735
818
|
async avmOpcodeGetContractInstanceClassId(foreignAddress: ForeignCallSingle) {
|
|
736
819
|
const address = addressFromSingle(foreignAddress);
|
|
737
820
|
|
|
738
|
-
const instance = await this.
|
|
821
|
+
const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
|
|
739
822
|
|
|
740
823
|
return toForeignCallResult([
|
|
741
824
|
toSingle(instance.currentContractClassId),
|
|
@@ -747,7 +830,7 @@ export class TXEService {
|
|
|
747
830
|
async avmOpcodeGetContractInstanceInitializationHash(foreignAddress: ForeignCallSingle) {
|
|
748
831
|
const address = addressFromSingle(foreignAddress);
|
|
749
832
|
|
|
750
|
-
const instance = await this.
|
|
833
|
+
const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
|
|
751
834
|
|
|
752
835
|
return toForeignCallResult([
|
|
753
836
|
toSingle(instance.initializationHash),
|
|
@@ -756,8 +839,8 @@ export class TXEService {
|
|
|
756
839
|
]);
|
|
757
840
|
}
|
|
758
841
|
|
|
759
|
-
avmOpcodeSender() {
|
|
760
|
-
const sender = this.
|
|
842
|
+
async avmOpcodeSender() {
|
|
843
|
+
const sender = await this.handlerAsAvm().avmOpcodeSender();
|
|
761
844
|
|
|
762
845
|
return toForeignCallResult([toSingle(sender)]);
|
|
763
846
|
}
|
|
@@ -765,7 +848,7 @@ export class TXEService {
|
|
|
765
848
|
async avmOpcodeEmitNullifier(foreignNullifier: ForeignCallSingle) {
|
|
766
849
|
const nullifier = fromSingle(foreignNullifier);
|
|
767
850
|
|
|
768
|
-
await this.
|
|
851
|
+
await this.handlerAsAvm().avmOpcodeEmitNullifier(nullifier);
|
|
769
852
|
|
|
770
853
|
return toForeignCallResult([]);
|
|
771
854
|
}
|
|
@@ -773,7 +856,7 @@ export class TXEService {
|
|
|
773
856
|
async avmOpcodeEmitNoteHash(foreignNoteHash: ForeignCallSingle) {
|
|
774
857
|
const noteHash = fromSingle(foreignNoteHash);
|
|
775
858
|
|
|
776
|
-
await this.
|
|
859
|
+
await this.handlerAsAvm().avmOpcodeEmitNoteHash(noteHash);
|
|
777
860
|
|
|
778
861
|
return toForeignCallResult([]);
|
|
779
862
|
}
|
|
@@ -782,43 +865,43 @@ export class TXEService {
|
|
|
782
865
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
783
866
|
const targetAddress = AztecAddress.fromField(fromSingle(foreignTargetAddress));
|
|
784
867
|
|
|
785
|
-
const exists = await this.
|
|
868
|
+
const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(innerNullifier, targetAddress);
|
|
786
869
|
|
|
787
870
|
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
788
871
|
}
|
|
789
872
|
|
|
790
873
|
async avmOpcodeAddress() {
|
|
791
|
-
const contractAddress = await this.
|
|
874
|
+
const contractAddress = await this.handlerAsAvm().avmOpcodeAddress();
|
|
792
875
|
|
|
793
876
|
return toForeignCallResult([toSingle(contractAddress.toField())]);
|
|
794
877
|
}
|
|
795
878
|
|
|
796
879
|
async avmOpcodeBlockNumber() {
|
|
797
|
-
const blockNumber = await this.
|
|
880
|
+
const blockNumber = await this.handlerAsAvm().avmOpcodeBlockNumber();
|
|
798
881
|
|
|
799
882
|
return toForeignCallResult([toSingle(new Fr(blockNumber))]);
|
|
800
883
|
}
|
|
801
884
|
|
|
802
885
|
async avmOpcodeTimestamp() {
|
|
803
|
-
const timestamp = await this.
|
|
886
|
+
const timestamp = await this.handlerAsAvm().avmOpcodeTimestamp();
|
|
804
887
|
|
|
805
888
|
return toForeignCallResult([toSingle(new Fr(timestamp))]);
|
|
806
889
|
}
|
|
807
890
|
|
|
808
891
|
async avmOpcodeIsStaticCall() {
|
|
809
|
-
const isStaticCall = await this.
|
|
892
|
+
const isStaticCall = await this.handlerAsAvm().avmOpcodeIsStaticCall();
|
|
810
893
|
|
|
811
894
|
return toForeignCallResult([toSingle(new Fr(isStaticCall ? 1 : 0))]);
|
|
812
895
|
}
|
|
813
896
|
|
|
814
897
|
async avmOpcodeChainId() {
|
|
815
|
-
const chainId = await this.
|
|
898
|
+
const chainId = await this.handlerAsAvm().avmOpcodeChainId();
|
|
816
899
|
|
|
817
900
|
return toForeignCallResult([toSingle(chainId)]);
|
|
818
901
|
}
|
|
819
902
|
|
|
820
903
|
async avmOpcodeVersion() {
|
|
821
|
-
const version = await this.
|
|
904
|
+
const version = await this.handlerAsAvm().avmOpcodeVersion();
|
|
822
905
|
|
|
823
906
|
return toForeignCallResult([toSingle(version)]);
|
|
824
907
|
}
|
|
@@ -869,7 +952,6 @@ export class TXEService {
|
|
|
869
952
|
foreignFrom: ForeignCallSingle,
|
|
870
953
|
foreignTargetContractAddress: ForeignCallSingle,
|
|
871
954
|
foreignFunctionSelector: ForeignCallSingle,
|
|
872
|
-
_foreignArgsLength: ForeignCallSingle,
|
|
873
955
|
foreignArgs: ForeignCallArray,
|
|
874
956
|
foreignArgsHash: ForeignCallSingle,
|
|
875
957
|
foreignIsStaticCall: ForeignCallSingle,
|
|
@@ -881,7 +963,7 @@ export class TXEService {
|
|
|
881
963
|
const argsHash = fromSingle(foreignArgsHash);
|
|
882
964
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
883
965
|
|
|
884
|
-
const
|
|
966
|
+
const returnValues = await this.handlerAsTxe().txePrivateCallNewFlow(
|
|
885
967
|
from,
|
|
886
968
|
targetContractAddress,
|
|
887
969
|
functionSelector,
|
|
@@ -890,27 +972,30 @@ export class TXEService {
|
|
|
890
972
|
isStaticCall,
|
|
891
973
|
);
|
|
892
974
|
|
|
893
|
-
return toForeignCallResult([toArray(
|
|
975
|
+
return toForeignCallResult([toArray(returnValues)]);
|
|
894
976
|
}
|
|
895
977
|
|
|
896
|
-
async
|
|
978
|
+
async txeSimulateUtilityFunction(
|
|
897
979
|
foreignTargetContractAddress: ForeignCallSingle,
|
|
898
980
|
foreignFunctionSelector: ForeignCallSingle,
|
|
899
|
-
|
|
981
|
+
foreignArgs: ForeignCallArray,
|
|
900
982
|
) {
|
|
901
983
|
const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
|
|
902
984
|
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
903
|
-
const
|
|
985
|
+
const args = fromArray(foreignArgs);
|
|
904
986
|
|
|
905
|
-
const
|
|
987
|
+
const returnValues = await this.handlerAsTxe().txeSimulateUtilityFunction(
|
|
988
|
+
targetContractAddress,
|
|
989
|
+
functionSelector,
|
|
990
|
+
args,
|
|
991
|
+
);
|
|
906
992
|
|
|
907
|
-
return toForeignCallResult([
|
|
993
|
+
return toForeignCallResult([toArray(returnValues)]);
|
|
908
994
|
}
|
|
909
995
|
|
|
910
996
|
async txePublicCallNewFlow(
|
|
911
997
|
foreignFrom: ForeignCallSingle,
|
|
912
998
|
foreignAddress: ForeignCallSingle,
|
|
913
|
-
_foreignLength: ForeignCallSingle,
|
|
914
999
|
foreignCalldata: ForeignCallArray,
|
|
915
1000
|
foreignIsStaticCall: ForeignCallSingle,
|
|
916
1001
|
) {
|
|
@@ -919,13 +1004,13 @@ export class TXEService {
|
|
|
919
1004
|
const calldata = fromArray(foreignCalldata);
|
|
920
1005
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
921
1006
|
|
|
922
|
-
const
|
|
1007
|
+
const returnValues = await this.handlerAsTxe().txePublicCallNewFlow(from, address, calldata, isStaticCall);
|
|
923
1008
|
|
|
924
|
-
return toForeignCallResult([toArray(
|
|
1009
|
+
return toForeignCallResult([toArray(returnValues)]);
|
|
925
1010
|
}
|
|
926
1011
|
|
|
927
1012
|
async privateGetSenderForTags() {
|
|
928
|
-
const sender = await this.
|
|
1013
|
+
const sender = await this.handlerAsPrivate().privateGetSenderForTags();
|
|
929
1014
|
|
|
930
1015
|
// Return a Noir Option struct with `some` and `value` fields
|
|
931
1016
|
if (sender === undefined) {
|
|
@@ -940,8 +1025,17 @@ export class TXEService {
|
|
|
940
1025
|
async privateSetSenderForTags(foreignSenderForTags: ForeignCallSingle) {
|
|
941
1026
|
const senderForTags = AztecAddress.fromField(fromSingle(foreignSenderForTags));
|
|
942
1027
|
|
|
943
|
-
await this.
|
|
1028
|
+
await this.handlerAsPrivate().privateSetSenderForTags(senderForTags);
|
|
944
1029
|
|
|
945
1030
|
return toForeignCallResult([]);
|
|
946
1031
|
}
|
|
1032
|
+
|
|
1033
|
+
async privateGetNextAppTagAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) {
|
|
1034
|
+
const sender = AztecAddress.fromField(fromSingle(foreignSender));
|
|
1035
|
+
const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
|
|
1036
|
+
|
|
1037
|
+
const nextAppTag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(sender, recipient);
|
|
1038
|
+
|
|
1039
|
+
return toForeignCallResult([toSingle(nextAppTag.value)]);
|
|
1040
|
+
}
|
|
947
1041
|
}
|