@aztec/txe 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212
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,14 +1,21 @@
|
|
|
1
|
-
import { Fr, Point } from '@aztec/aztec.js';
|
|
1
|
+
import { Fr, Point } from '@aztec/aztec.js/fields';
|
|
2
|
+
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX } from '@aztec/constants';
|
|
3
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
4
|
import { packAsRetrievedNote } from '@aztec/pxe/simulator';
|
|
3
5
|
import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
4
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
7
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
6
|
-
import { addressFromSingle, arrayOfArraysToBoundedVecOfArrays, arrayToBoundedVec, bufferToU8Array, fromArray, fromSingle, fromUintArray, fromUintBoundedVec, toArray, toForeignCallResult, toSingle } from '
|
|
7
|
-
export class
|
|
8
|
+
import { addressFromSingle, arrayOfArraysToBoundedVecOfArrays, arrayToBoundedVec, bufferToU8Array, fromArray, fromSingle, fromUintArray, fromUintBoundedVec, toArray, toForeignCallResult, toSingle } from './util/encoding.js';
|
|
9
|
+
export class UnavailableOracleError extends Error {
|
|
10
|
+
constructor(oracleName){
|
|
11
|
+
super(`${oracleName} oracles not available with the current handler`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class RPCTranslator {
|
|
8
15
|
stateHandler;
|
|
9
16
|
oracleHandler;
|
|
10
17
|
/**
|
|
11
|
-
* Create a new instance of `
|
|
18
|
+
* Create a new instance of `RPCTranslator` that will translate all TXE RPC calls to and from the foreign
|
|
12
19
|
* (`ForeignCallSingle`, `ForeignCallResult`, etc.) and native TS types, delegating actual execution of the oracles
|
|
13
20
|
* to the different handlers.
|
|
14
21
|
* @param stateHandler The handler that will process TXE session state transitions, such as entering a private or
|
|
@@ -19,42 +26,86 @@ export class TXEService {
|
|
|
19
26
|
this.stateHandler = stateHandler;
|
|
20
27
|
this.oracleHandler = oracleHandler;
|
|
21
28
|
}
|
|
29
|
+
// Note: If you rename the following functions to not start with "handlerAs", you must also update the validation
|
|
30
|
+
// check in `TXESession.processFunction`.
|
|
31
|
+
handlerAsMisc() {
|
|
32
|
+
if (!('isMisc' in this.oracleHandler)) {
|
|
33
|
+
throw new UnavailableOracleError('Misc');
|
|
34
|
+
}
|
|
35
|
+
return this.oracleHandler;
|
|
36
|
+
}
|
|
37
|
+
handlerAsUtility() {
|
|
38
|
+
if (!('isUtility' in this.oracleHandler)) {
|
|
39
|
+
throw new UnavailableOracleError('Utility');
|
|
40
|
+
}
|
|
41
|
+
return this.oracleHandler;
|
|
42
|
+
}
|
|
43
|
+
handlerAsPrivate() {
|
|
44
|
+
if (!('isPrivate' in this.oracleHandler)) {
|
|
45
|
+
throw new UnavailableOracleError('Private');
|
|
46
|
+
}
|
|
47
|
+
return this.oracleHandler;
|
|
48
|
+
}
|
|
49
|
+
handlerAsAvm() {
|
|
50
|
+
if (!('isAvm' in this.oracleHandler)) {
|
|
51
|
+
throw new UnavailableOracleError('Avm');
|
|
52
|
+
}
|
|
53
|
+
return this.oracleHandler;
|
|
54
|
+
}
|
|
55
|
+
handlerAsTxe() {
|
|
56
|
+
if (!('isTxe' in this.oracleHandler)) {
|
|
57
|
+
throw new UnavailableOracleError('Txe');
|
|
58
|
+
}
|
|
59
|
+
return this.oracleHandler;
|
|
60
|
+
}
|
|
22
61
|
// TXE session state transition functions - these get handled by the state handler
|
|
23
62
|
async txeSetTopLevelTXEContext() {
|
|
24
|
-
await this.stateHandler.
|
|
63
|
+
await this.stateHandler.enterTopLevelState();
|
|
25
64
|
return toForeignCallResult([]);
|
|
26
65
|
}
|
|
27
|
-
async txeSetPrivateTXEContext(foreignContractAddressIsSome, foreignContractAddressValue,
|
|
66
|
+
async txeSetPrivateTXEContext(foreignContractAddressIsSome, foreignContractAddressValue, foreignAnchorBlockNumberIsSome, foreignAnchorBlockNumberValue) {
|
|
28
67
|
const contractAddress = fromSingle(foreignContractAddressIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignContractAddressValue)) : undefined;
|
|
29
|
-
const
|
|
30
|
-
const privateContextInputs = await this.stateHandler.
|
|
68
|
+
const anchorBlockNumber = fromSingle(foreignAnchorBlockNumberIsSome).toBool() ? BlockNumber(fromSingle(foreignAnchorBlockNumberValue).toNumber()) : undefined;
|
|
69
|
+
const privateContextInputs = await this.stateHandler.enterPrivateState(contractAddress, anchorBlockNumber);
|
|
31
70
|
return toForeignCallResult(privateContextInputs.toFields().map(toSingle));
|
|
32
71
|
}
|
|
33
72
|
async txeSetPublicTXEContext(foreignContractAddressIsSome, foreignContractAddressValue) {
|
|
34
73
|
const contractAddress = fromSingle(foreignContractAddressIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignContractAddressValue)) : undefined;
|
|
35
|
-
await this.stateHandler.
|
|
74
|
+
await this.stateHandler.enterPublicState(contractAddress);
|
|
36
75
|
return toForeignCallResult([]);
|
|
37
76
|
}
|
|
38
77
|
async txeSetUtilityTXEContext(foreignContractAddressIsSome, foreignContractAddressValue) {
|
|
39
78
|
const contractAddress = fromSingle(foreignContractAddressIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignContractAddressValue)) : undefined;
|
|
40
|
-
await this.stateHandler.
|
|
79
|
+
await this.stateHandler.enterUtilityState(contractAddress);
|
|
41
80
|
return toForeignCallResult([]);
|
|
42
81
|
}
|
|
43
82
|
// Other oracles - these get handled by the oracle handler
|
|
44
83
|
// TXE-specific oracles
|
|
84
|
+
async txeGetNextBlockNumber() {
|
|
85
|
+
const nextBlockNumber = await this.handlerAsTxe().txeGetNextBlockNumber();
|
|
86
|
+
return toForeignCallResult([
|
|
87
|
+
toSingle(nextBlockNumber)
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
async txeGetNextBlockTimestamp() {
|
|
91
|
+
const nextBlockTimestamp = await this.handlerAsTxe().txeGetNextBlockTimestamp();
|
|
92
|
+
return toForeignCallResult([
|
|
93
|
+
toSingle(nextBlockTimestamp)
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
45
96
|
async txeAdvanceBlocksBy(foreignBlocks) {
|
|
46
97
|
const blocks = fromSingle(foreignBlocks).toNumber();
|
|
47
|
-
await this.
|
|
98
|
+
await this.handlerAsTxe().txeAdvanceBlocksBy(blocks);
|
|
48
99
|
return toForeignCallResult([]);
|
|
49
100
|
}
|
|
50
101
|
txeAdvanceTimestampBy(foreignDuration) {
|
|
51
102
|
const duration = fromSingle(foreignDuration).toBigInt();
|
|
52
|
-
this.
|
|
103
|
+
this.handlerAsTxe().txeAdvanceTimestampBy(duration);
|
|
53
104
|
return toForeignCallResult([]);
|
|
54
105
|
}
|
|
55
106
|
async txeDeploy(artifact, instance, foreignSecret) {
|
|
56
107
|
const secret = fromSingle(foreignSecret);
|
|
57
|
-
await this.
|
|
108
|
+
await this.handlerAsTxe().txeDeploy(artifact, instance, secret);
|
|
58
109
|
return toForeignCallResult([
|
|
59
110
|
toArray([
|
|
60
111
|
instance.salt,
|
|
@@ -67,7 +118,7 @@ export class TXEService {
|
|
|
67
118
|
}
|
|
68
119
|
async txeCreateAccount(foreignSecret) {
|
|
69
120
|
const secret = fromSingle(foreignSecret);
|
|
70
|
-
const completeAddress = await this.
|
|
121
|
+
const completeAddress = await this.handlerAsTxe().txeCreateAccount(secret);
|
|
71
122
|
return toForeignCallResult([
|
|
72
123
|
toSingle(completeAddress.address),
|
|
73
124
|
...completeAddress.publicKeys.toFields().map(toSingle)
|
|
@@ -75,7 +126,7 @@ export class TXEService {
|
|
|
75
126
|
}
|
|
76
127
|
async txeAddAccount(artifact, instance, foreignSecret) {
|
|
77
128
|
const secret = fromSingle(foreignSecret);
|
|
78
|
-
const completeAddress = await this.
|
|
129
|
+
const completeAddress = await this.handlerAsTxe().txeAddAccount(artifact, instance, secret);
|
|
79
130
|
return toForeignCallResult([
|
|
80
131
|
toSingle(completeAddress.address),
|
|
81
132
|
...completeAddress.publicKeys.toFields().map(toSingle)
|
|
@@ -84,87 +135,79 @@ export class TXEService {
|
|
|
84
135
|
async txeAddAuthWitness(foreignAddress, foreignMessageHash) {
|
|
85
136
|
const address = addressFromSingle(foreignAddress);
|
|
86
137
|
const messageHash = fromSingle(foreignMessageHash);
|
|
87
|
-
await this.
|
|
138
|
+
await this.handlerAsTxe().txeAddAuthWitness(address, messageHash);
|
|
88
139
|
return toForeignCallResult([]);
|
|
89
140
|
}
|
|
90
141
|
// PXE oracles
|
|
91
142
|
utilityAssertCompatibleOracleVersion(foreignVersion) {
|
|
92
143
|
const version = fromSingle(foreignVersion).toNumber();
|
|
93
|
-
this.
|
|
144
|
+
this.handlerAsMisc().utilityAssertCompatibleOracleVersion(version);
|
|
94
145
|
return toForeignCallResult([]);
|
|
95
146
|
}
|
|
96
147
|
utilityGetRandomField() {
|
|
97
|
-
const randomField = this.
|
|
148
|
+
const randomField = this.handlerAsMisc().utilityGetRandomField();
|
|
98
149
|
return toForeignCallResult([
|
|
99
150
|
toSingle(randomField)
|
|
100
151
|
]);
|
|
101
152
|
}
|
|
102
|
-
async
|
|
103
|
-
const
|
|
104
|
-
return toForeignCallResult([
|
|
105
|
-
toSingle(contractAddress.toField())
|
|
106
|
-
]);
|
|
107
|
-
}
|
|
108
|
-
async utilityGetBlockNumber() {
|
|
109
|
-
const blockNumber = await this.oracleHandler.utilityGetBlockNumber();
|
|
110
|
-
return toForeignCallResult([
|
|
111
|
-
toSingle(new Fr(blockNumber))
|
|
112
|
-
]);
|
|
113
|
-
}
|
|
114
|
-
// seems to be used to mean the timestamp of the last mined block in txe (but that's not what is done here)
|
|
115
|
-
async utilityGetTimestamp() {
|
|
116
|
-
const timestamp = await this.oracleHandler.utilityGetTimestamp();
|
|
153
|
+
async txeGetLastBlockTimestamp() {
|
|
154
|
+
const timestamp = await this.handlerAsTxe().txeGetLastBlockTimestamp();
|
|
117
155
|
return toForeignCallResult([
|
|
118
156
|
toSingle(new Fr(timestamp))
|
|
119
157
|
]);
|
|
120
158
|
}
|
|
121
|
-
async
|
|
122
|
-
const
|
|
159
|
+
async txeGetLastTxEffects() {
|
|
160
|
+
const { txHash, noteHashes, nullifiers } = await this.handlerAsTxe().txeGetLastTxEffects();
|
|
123
161
|
return toForeignCallResult([
|
|
124
|
-
toSingle(
|
|
162
|
+
toSingle(txHash.hash),
|
|
163
|
+
...arrayToBoundedVec(toArray(noteHashes), MAX_NOTE_HASHES_PER_TX),
|
|
164
|
+
...arrayToBoundedVec(toArray(nullifiers), MAX_NULLIFIERS_PER_TX)
|
|
125
165
|
]);
|
|
126
166
|
}
|
|
127
|
-
|
|
128
|
-
privateStoreInExecutionCache(_foreignLength, foreignValues, foreignHash) {
|
|
167
|
+
privateStoreInExecutionCache(foreignValues, foreignHash) {
|
|
129
168
|
const values = fromArray(foreignValues);
|
|
130
169
|
const hash = fromSingle(foreignHash);
|
|
131
|
-
this.
|
|
170
|
+
this.handlerAsPrivate().privateStoreInExecutionCache(values, hash);
|
|
132
171
|
return toForeignCallResult([]);
|
|
133
172
|
}
|
|
134
173
|
async privateLoadFromExecutionCache(foreignHash) {
|
|
135
174
|
const hash = fromSingle(foreignHash);
|
|
136
|
-
const returns = await this.
|
|
175
|
+
const returns = await this.handlerAsPrivate().privateLoadFromExecutionCache(hash);
|
|
137
176
|
return toForeignCallResult([
|
|
138
177
|
toArray(returns)
|
|
139
178
|
]);
|
|
140
179
|
}
|
|
141
|
-
//
|
|
142
|
-
|
|
180
|
+
// When the argument is a slice, noir automatically adds a length field to oracle call.
|
|
181
|
+
// When the argument is an array, we add the field length manually to the signature.
|
|
182
|
+
utilityDebugLog(foreignLevel, foreignMessage, _foreignLength, foreignFields) {
|
|
183
|
+
const level = fromSingle(foreignLevel).toNumber();
|
|
143
184
|
const message = fromArray(foreignMessage).map((field)=>String.fromCharCode(field.toNumber())).join('');
|
|
144
185
|
const fields = fromArray(foreignFields);
|
|
145
|
-
this.
|
|
186
|
+
this.handlerAsMisc().utilityDebugLog(level, message, fields);
|
|
146
187
|
return toForeignCallResult([]);
|
|
147
188
|
}
|
|
148
189
|
async utilityStorageRead(foreignContractAddress, foreignStartStorageSlot, foreignBlockNumber, foreignNumberOfElements) {
|
|
149
190
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
150
191
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
151
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
192
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
152
193
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
153
|
-
const values = await this.
|
|
194
|
+
const values = await this.handlerAsUtility().utilityStorageRead(contractAddress, startStorageSlot, blockNumber, numberOfElements);
|
|
154
195
|
return toForeignCallResult([
|
|
155
196
|
toArray(values)
|
|
156
197
|
]);
|
|
157
198
|
}
|
|
158
199
|
async utilityGetPublicDataWitness(foreignBlockNumber, foreignLeafSlot) {
|
|
159
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
200
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
160
201
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
161
|
-
const witness = await this.
|
|
202
|
+
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockNumber, leafSlot);
|
|
162
203
|
if (!witness) {
|
|
163
204
|
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockNumber}.`);
|
|
164
205
|
}
|
|
165
206
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
166
207
|
}
|
|
167
|
-
async utilityGetNotes(foreignStorageSlot, foreignNumSelects, foreignSelectByIndexes, foreignSelectByOffsets, foreignSelectByLengths, foreignSelectValues, foreignSelectComparators, foreignSortByIndexes, foreignSortByOffsets, foreignSortByLengths, foreignSortOrder, foreignLimit, foreignOffset, foreignStatus, foreignMaxNotes, foreignPackedRetrievedNoteLength) {
|
|
208
|
+
async utilityGetNotes(foreignOwnerIsSome, foreignOwnerValue, foreignStorageSlot, foreignNumSelects, foreignSelectByIndexes, foreignSelectByOffsets, foreignSelectByLengths, foreignSelectValues, foreignSelectComparators, foreignSortByIndexes, foreignSortByOffsets, foreignSortByLengths, foreignSortOrder, foreignLimit, foreignOffset, foreignStatus, foreignMaxNotes, foreignPackedRetrievedNoteLength) {
|
|
209
|
+
// Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
|
|
210
|
+
const owner = fromSingle(foreignOwnerIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignOwnerValue)) : undefined;
|
|
168
211
|
const storageSlot = fromSingle(foreignStorageSlot);
|
|
169
212
|
const numSelects = fromSingle(foreignNumSelects).toNumber();
|
|
170
213
|
const selectByIndexes = fromArray(foreignSelectByIndexes).map((fr)=>fr.toNumber());
|
|
@@ -181,44 +224,54 @@ export class TXEService {
|
|
|
181
224
|
const status = fromSingle(foreignStatus).toNumber();
|
|
182
225
|
const maxNotes = fromSingle(foreignMaxNotes).toNumber();
|
|
183
226
|
const packedRetrievedNoteLength = fromSingle(foreignPackedRetrievedNoteLength).toNumber();
|
|
184
|
-
const noteDatas = await this.
|
|
185
|
-
const returnDataAsArrayOfArrays = noteDatas.map(packAsRetrievedNote
|
|
227
|
+
const noteDatas = await this.handlerAsUtility().utilityGetNotes(owner, storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status);
|
|
228
|
+
const returnDataAsArrayOfArrays = noteDatas.map((noteData)=>packAsRetrievedNote({
|
|
229
|
+
contractAddress: noteData.contractAddress,
|
|
230
|
+
owner: noteData.owner,
|
|
231
|
+
randomness: noteData.randomness,
|
|
232
|
+
storageSlot: noteData.storageSlot,
|
|
233
|
+
noteNonce: noteData.noteNonce,
|
|
234
|
+
index: noteData.index,
|
|
235
|
+
note: noteData.note
|
|
236
|
+
}));
|
|
186
237
|
// Now we convert each sub-array to an array of ForeignCallSingles
|
|
187
238
|
const returnDataAsArrayOfForeignCallSingleArrays = returnDataAsArrayOfArrays.map((subArray)=>subArray.map(toSingle));
|
|
188
239
|
// At last we convert the array of arrays to a bounded vec of arrays
|
|
189
240
|
return toForeignCallResult(arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfForeignCallSingleArrays, maxNotes, packedRetrievedNoteLength));
|
|
190
241
|
}
|
|
191
|
-
privateNotifyCreatedNote(foreignStorageSlot, foreignNoteTypeId, foreignNote, foreignNoteHash, foreignCounter) {
|
|
242
|
+
privateNotifyCreatedNote(foreignOwner, foreignStorageSlot, foreignRandomness, foreignNoteTypeId, foreignNote, foreignNoteHash, foreignCounter) {
|
|
243
|
+
const owner = addressFromSingle(foreignOwner);
|
|
192
244
|
const storageSlot = fromSingle(foreignStorageSlot);
|
|
245
|
+
const randomness = fromSingle(foreignRandomness);
|
|
193
246
|
const noteTypeId = NoteSelector.fromField(fromSingle(foreignNoteTypeId));
|
|
194
247
|
const note = fromArray(foreignNote);
|
|
195
248
|
const noteHash = fromSingle(foreignNoteHash);
|
|
196
249
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
197
|
-
this.
|
|
250
|
+
this.handlerAsPrivate().privateNotifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter);
|
|
198
251
|
return toForeignCallResult([]);
|
|
199
252
|
}
|
|
200
253
|
async privateNotifyNullifiedNote(foreignInnerNullifier, foreignNoteHash, foreignCounter) {
|
|
201
254
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
202
255
|
const noteHash = fromSingle(foreignNoteHash);
|
|
203
256
|
const counter = fromSingle(foreignCounter).toNumber();
|
|
204
|
-
await this.
|
|
257
|
+
await this.handlerAsPrivate().privateNotifyNullifiedNote(innerNullifier, noteHash, counter);
|
|
205
258
|
return toForeignCallResult([]);
|
|
206
259
|
}
|
|
207
260
|
async privateNotifyCreatedNullifier(foreignInnerNullifier) {
|
|
208
261
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
209
|
-
await this.
|
|
262
|
+
await this.handlerAsPrivate().privateNotifyCreatedNullifier(innerNullifier);
|
|
210
263
|
return toForeignCallResult([]);
|
|
211
264
|
}
|
|
212
265
|
async utilityCheckNullifierExists(foreignInnerNullifier) {
|
|
213
266
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
214
|
-
const exists = await this.
|
|
267
|
+
const exists = await this.handlerAsUtility().utilityCheckNullifierExists(innerNullifier);
|
|
215
268
|
return toForeignCallResult([
|
|
216
269
|
toSingle(new Fr(exists))
|
|
217
270
|
]);
|
|
218
271
|
}
|
|
219
272
|
async utilityGetContractInstance(foreignAddress) {
|
|
220
273
|
const address = addressFromSingle(foreignAddress);
|
|
221
|
-
const instance = await this.
|
|
274
|
+
const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
|
|
222
275
|
return toForeignCallResult([
|
|
223
276
|
instance.salt,
|
|
224
277
|
instance.deployer.toField(),
|
|
@@ -229,7 +282,7 @@ export class TXEService {
|
|
|
229
282
|
}
|
|
230
283
|
async utilityGetPublicKeysAndPartialAddress(foreignAddress) {
|
|
231
284
|
const address = addressFromSingle(foreignAddress);
|
|
232
|
-
const { publicKeys, partialAddress } = await this.
|
|
285
|
+
const { publicKeys, partialAddress } = await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(address);
|
|
233
286
|
return toForeignCallResult([
|
|
234
287
|
toArray([
|
|
235
288
|
...publicKeys.toFields(),
|
|
@@ -239,16 +292,16 @@ export class TXEService {
|
|
|
239
292
|
}
|
|
240
293
|
async utilityGetKeyValidationRequest(foreignPkMHash) {
|
|
241
294
|
const pkMHash = fromSingle(foreignPkMHash);
|
|
242
|
-
const keyValidationRequest = await this.
|
|
295
|
+
const keyValidationRequest = await this.handlerAsUtility().utilityGetKeyValidationRequest(pkMHash);
|
|
243
296
|
return toForeignCallResult(keyValidationRequest.toFields().map(toSingle));
|
|
244
297
|
}
|
|
245
298
|
privateCallPrivateFunction(_foreignTargetContractAddress, _foreignFunctionSelector, _foreignArgsHash, _foreignSideEffectCounter, _foreignIsStaticCall) {
|
|
246
299
|
throw new Error('Contract calls are forbidden inside a `TestEnvironment::private_context`, use `private_call` instead');
|
|
247
300
|
}
|
|
248
301
|
async utilityGetNullifierMembershipWitness(foreignBlockNumber, foreignNullifier) {
|
|
249
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
302
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
250
303
|
const nullifier = fromSingle(foreignNullifier);
|
|
251
|
-
const witness = await this.
|
|
304
|
+
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockNumber, nullifier);
|
|
252
305
|
if (!witness) {
|
|
253
306
|
throw new Error(`Nullifier membership witness not found at block ${blockNumber}.`);
|
|
254
307
|
}
|
|
@@ -256,7 +309,7 @@ export class TXEService {
|
|
|
256
309
|
}
|
|
257
310
|
async utilityGetAuthWitness(foreignMessageHash) {
|
|
258
311
|
const messageHash = fromSingle(foreignMessageHash);
|
|
259
|
-
const authWitness = await this.
|
|
312
|
+
const authWitness = await this.handlerAsUtility().utilityGetAuthWitness(messageHash);
|
|
260
313
|
if (!authWitness) {
|
|
261
314
|
throw new Error(`Auth witness not found for message hash ${messageHash}.`);
|
|
262
315
|
}
|
|
@@ -273,31 +326,30 @@ export class TXEService {
|
|
|
273
326
|
privateNotifySetMinRevertibleSideEffectCounter(_foreignMinRevertibleSideEffectCounter) {
|
|
274
327
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
275
328
|
}
|
|
276
|
-
async
|
|
277
|
-
const
|
|
329
|
+
async privateIsSideEffectCounterRevertible(foreignSideEffectCounter) {
|
|
330
|
+
const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
|
|
331
|
+
const isRevertible = await this.handlerAsPrivate().privateIsSideEffectCounterRevertible(sideEffectCounter);
|
|
278
332
|
return toForeignCallResult([
|
|
279
|
-
toSingle(
|
|
333
|
+
toSingle(new Fr(isRevertible))
|
|
280
334
|
]);
|
|
281
335
|
}
|
|
282
|
-
async
|
|
283
|
-
const
|
|
284
|
-
return toForeignCallResult(
|
|
285
|
-
toSingle(version)
|
|
286
|
-
]);
|
|
336
|
+
async utilityGetUtilityContext() {
|
|
337
|
+
const context = await this.handlerAsUtility().utilityGetUtilityContext();
|
|
338
|
+
return toForeignCallResult(context.toNoirRepresentation());
|
|
287
339
|
}
|
|
288
340
|
async utilityGetBlockHeader(foreignBlockNumber) {
|
|
289
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
290
|
-
const header = await this.
|
|
341
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
342
|
+
const header = await this.handlerAsUtility().utilityGetBlockHeader(blockNumber);
|
|
291
343
|
if (!header) {
|
|
292
344
|
throw new Error(`Block header not found for block ${blockNumber}.`);
|
|
293
345
|
}
|
|
294
346
|
return toForeignCallResult(header.toFields().map(toSingle));
|
|
295
347
|
}
|
|
296
348
|
async utilityGetMembershipWitness(foreignBlockNumber, foreignTreeId, foreignLeafValue) {
|
|
297
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
349
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
298
350
|
const treeId = fromSingle(foreignTreeId).toNumber();
|
|
299
351
|
const leafValue = fromSingle(foreignLeafValue);
|
|
300
|
-
const witness = await this.
|
|
352
|
+
const witness = await this.handlerAsUtility().utilityGetMembershipWitness(blockNumber, treeId, leafValue);
|
|
301
353
|
if (!witness) {
|
|
302
354
|
throw new Error(`Membership witness in tree ${MerkleTreeId[treeId]} not found for value ${leafValue} at block ${blockNumber}.`);
|
|
303
355
|
}
|
|
@@ -307,51 +359,45 @@ export class TXEService {
|
|
|
307
359
|
]);
|
|
308
360
|
}
|
|
309
361
|
async utilityGetLowNullifierMembershipWitness(foreignBlockNumber, foreignNullifier) {
|
|
310
|
-
const blockNumber = fromSingle(foreignBlockNumber).toNumber();
|
|
362
|
+
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
311
363
|
const nullifier = fromSingle(foreignNullifier);
|
|
312
|
-
const witness = await this.
|
|
364
|
+
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockNumber, nullifier);
|
|
313
365
|
if (!witness) {
|
|
314
366
|
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockNumber}.`);
|
|
315
367
|
}
|
|
316
368
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
317
369
|
}
|
|
318
|
-
async utilityGetIndexedTaggingSecretAsSender(foreignSender, foreignRecipient) {
|
|
319
|
-
const sender = AztecAddress.fromField(fromSingle(foreignSender));
|
|
320
|
-
const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
|
|
321
|
-
const secret = await this.oracleHandler.utilityGetIndexedTaggingSecretAsSender(sender, recipient);
|
|
322
|
-
return toForeignCallResult(secret.toFields().map(toSingle));
|
|
323
|
-
}
|
|
324
370
|
async utilityFetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot) {
|
|
325
371
|
const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
|
|
326
|
-
await this.
|
|
372
|
+
await this.handlerAsUtility().utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
|
|
327
373
|
return toForeignCallResult([]);
|
|
328
374
|
}
|
|
329
375
|
async utilityValidateEnqueuedNotesAndEvents(foreignContractAddress, foreignNoteValidationRequestsArrayBaseSlot, foreignEventValidationRequestsArrayBaseSlot) {
|
|
330
376
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
331
377
|
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
332
378
|
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
333
|
-
await this.
|
|
379
|
+
await this.handlerAsUtility().utilityValidateEnqueuedNotesAndEvents(contractAddress, noteValidationRequestsArrayBaseSlot, eventValidationRequestsArrayBaseSlot);
|
|
334
380
|
return toForeignCallResult([]);
|
|
335
381
|
}
|
|
336
382
|
async utilityBulkRetrieveLogs(foreignContractAddress, foreignLogRetrievalRequestsArrayBaseSlot, foreignLogRetrievalResponsesArrayBaseSlot) {
|
|
337
383
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
338
384
|
const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
|
|
339
385
|
const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
|
|
340
|
-
await this.
|
|
386
|
+
await this.handlerAsUtility().utilityBulkRetrieveLogs(contractAddress, logRetrievalRequestsArrayBaseSlot, logRetrievalResponsesArrayBaseSlot);
|
|
341
387
|
return toForeignCallResult([]);
|
|
342
388
|
}
|
|
343
389
|
async utilityStoreCapsule(foreignContractAddress, foreignSlot, foreignCapsule) {
|
|
344
390
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
345
391
|
const slot = fromSingle(foreignSlot);
|
|
346
392
|
const capsule = fromArray(foreignCapsule);
|
|
347
|
-
await this.
|
|
393
|
+
await this.handlerAsUtility().utilityStoreCapsule(contractAddress, slot, capsule);
|
|
348
394
|
return toForeignCallResult([]);
|
|
349
395
|
}
|
|
350
396
|
async utilityLoadCapsule(foreignContractAddress, foreignSlot, foreignTSize) {
|
|
351
397
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
352
398
|
const slot = fromSingle(foreignSlot);
|
|
353
399
|
const tSize = fromSingle(foreignTSize).toNumber();
|
|
354
|
-
const values = await this.
|
|
400
|
+
const values = await this.handlerAsUtility().utilityLoadCapsule(contractAddress, slot);
|
|
355
401
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
356
402
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
357
403
|
if (values === null) {
|
|
@@ -371,7 +417,7 @@ export class TXEService {
|
|
|
371
417
|
async utilityDeleteCapsule(foreignContractAddress, foreignSlot) {
|
|
372
418
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
373
419
|
const slot = fromSingle(foreignSlot);
|
|
374
|
-
await this.
|
|
420
|
+
await this.handlerAsUtility().utilityDeleteCapsule(contractAddress, slot);
|
|
375
421
|
return toForeignCallResult([]);
|
|
376
422
|
}
|
|
377
423
|
async utilityCopyCapsule(foreignContractAddress, foreignSrcSlot, foreignDstSlot, foreignNumEntries) {
|
|
@@ -379,7 +425,7 @@ export class TXEService {
|
|
|
379
425
|
const srcSlot = fromSingle(foreignSrcSlot);
|
|
380
426
|
const dstSlot = fromSingle(foreignDstSlot);
|
|
381
427
|
const numEntries = fromSingle(foreignNumEntries).toNumber();
|
|
382
|
-
await this.
|
|
428
|
+
await this.handlerAsUtility().utilityCopyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
|
|
383
429
|
return toForeignCallResult([]);
|
|
384
430
|
}
|
|
385
431
|
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
@@ -390,7 +436,7 @@ export class TXEService {
|
|
|
390
436
|
const ciphertext = fromUintBoundedVec(foreignCiphertextBVecStorage, foreignCiphertextLength, 8);
|
|
391
437
|
const iv = fromUintArray(foreignIv, 8);
|
|
392
438
|
const symKey = fromUintArray(foreignSymKey, 8);
|
|
393
|
-
const plaintextBuffer = await this.
|
|
439
|
+
const plaintextBuffer = await this.handlerAsUtility().utilityAes128Decrypt(ciphertext, iv, symKey);
|
|
394
440
|
return toForeignCallResult(arrayToBoundedVec(bufferToU8Array(plaintextBuffer), foreignCiphertextBVecStorage.length));
|
|
395
441
|
}
|
|
396
442
|
async utilityGetSharedSecret(foreignAddress, foreignEphPKField0, foreignEphPKField1, foreignEphPKField2) {
|
|
@@ -400,7 +446,7 @@ export class TXEService {
|
|
|
400
446
|
fromSingle(foreignEphPKField1),
|
|
401
447
|
fromSingle(foreignEphPKField2)
|
|
402
448
|
]);
|
|
403
|
-
const secret = await this.
|
|
449
|
+
const secret = await this.handlerAsUtility().utilityGetSharedSecret(address, ephPK);
|
|
404
450
|
return toForeignCallResult(secret.toFields().map(toSingle));
|
|
405
451
|
}
|
|
406
452
|
emitOffchainEffect(_foreignData) {
|
|
@@ -413,7 +459,7 @@ export class TXEService {
|
|
|
413
459
|
}
|
|
414
460
|
async avmOpcodeStorageRead(foreignSlot) {
|
|
415
461
|
const slot = fromSingle(foreignSlot);
|
|
416
|
-
const value = (await this.
|
|
462
|
+
const value = (await this.handlerAsAvm().avmOpcodeStorageRead(slot)).value;
|
|
417
463
|
return toForeignCallResult([
|
|
418
464
|
toSingle(new Fr(value))
|
|
419
465
|
]);
|
|
@@ -421,12 +467,12 @@ export class TXEService {
|
|
|
421
467
|
async avmOpcodeStorageWrite(foreignSlot, foreignValue) {
|
|
422
468
|
const slot = fromSingle(foreignSlot);
|
|
423
469
|
const value = fromSingle(foreignValue);
|
|
424
|
-
await this.
|
|
470
|
+
await this.handlerAsAvm().avmOpcodeStorageWrite(slot, value);
|
|
425
471
|
return toForeignCallResult([]);
|
|
426
472
|
}
|
|
427
473
|
async avmOpcodeGetContractInstanceDeployer(foreignAddress) {
|
|
428
474
|
const address = addressFromSingle(foreignAddress);
|
|
429
|
-
const instance = await this.
|
|
475
|
+
const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
|
|
430
476
|
return toForeignCallResult([
|
|
431
477
|
toSingle(instance.deployer),
|
|
432
478
|
// AVM requires an extra boolean indicating the instance was found
|
|
@@ -435,7 +481,7 @@ export class TXEService {
|
|
|
435
481
|
}
|
|
436
482
|
async avmOpcodeGetContractInstanceClassId(foreignAddress) {
|
|
437
483
|
const address = addressFromSingle(foreignAddress);
|
|
438
|
-
const instance = await this.
|
|
484
|
+
const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
|
|
439
485
|
return toForeignCallResult([
|
|
440
486
|
toSingle(instance.currentContractClassId),
|
|
441
487
|
// AVM requires an extra boolean indicating the instance was found
|
|
@@ -444,69 +490,69 @@ export class TXEService {
|
|
|
444
490
|
}
|
|
445
491
|
async avmOpcodeGetContractInstanceInitializationHash(foreignAddress) {
|
|
446
492
|
const address = addressFromSingle(foreignAddress);
|
|
447
|
-
const instance = await this.
|
|
493
|
+
const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
|
|
448
494
|
return toForeignCallResult([
|
|
449
495
|
toSingle(instance.initializationHash),
|
|
450
496
|
// AVM requires an extra boolean indicating the instance was found
|
|
451
497
|
toSingle(new Fr(1))
|
|
452
498
|
]);
|
|
453
499
|
}
|
|
454
|
-
avmOpcodeSender() {
|
|
455
|
-
const sender = this.
|
|
500
|
+
async avmOpcodeSender() {
|
|
501
|
+
const sender = await this.handlerAsAvm().avmOpcodeSender();
|
|
456
502
|
return toForeignCallResult([
|
|
457
503
|
toSingle(sender)
|
|
458
504
|
]);
|
|
459
505
|
}
|
|
460
506
|
async avmOpcodeEmitNullifier(foreignNullifier) {
|
|
461
507
|
const nullifier = fromSingle(foreignNullifier);
|
|
462
|
-
await this.
|
|
508
|
+
await this.handlerAsAvm().avmOpcodeEmitNullifier(nullifier);
|
|
463
509
|
return toForeignCallResult([]);
|
|
464
510
|
}
|
|
465
511
|
async avmOpcodeEmitNoteHash(foreignNoteHash) {
|
|
466
512
|
const noteHash = fromSingle(foreignNoteHash);
|
|
467
|
-
await this.
|
|
513
|
+
await this.handlerAsAvm().avmOpcodeEmitNoteHash(noteHash);
|
|
468
514
|
return toForeignCallResult([]);
|
|
469
515
|
}
|
|
470
516
|
async avmOpcodeNullifierExists(foreignInnerNullifier, foreignTargetAddress) {
|
|
471
517
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
472
518
|
const targetAddress = AztecAddress.fromField(fromSingle(foreignTargetAddress));
|
|
473
|
-
const exists = await this.
|
|
519
|
+
const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(innerNullifier, targetAddress);
|
|
474
520
|
return toForeignCallResult([
|
|
475
521
|
toSingle(new Fr(exists))
|
|
476
522
|
]);
|
|
477
523
|
}
|
|
478
524
|
async avmOpcodeAddress() {
|
|
479
|
-
const contractAddress = await this.
|
|
525
|
+
const contractAddress = await this.handlerAsAvm().avmOpcodeAddress();
|
|
480
526
|
return toForeignCallResult([
|
|
481
527
|
toSingle(contractAddress.toField())
|
|
482
528
|
]);
|
|
483
529
|
}
|
|
484
530
|
async avmOpcodeBlockNumber() {
|
|
485
|
-
const blockNumber = await this.
|
|
531
|
+
const blockNumber = await this.handlerAsAvm().avmOpcodeBlockNumber();
|
|
486
532
|
return toForeignCallResult([
|
|
487
533
|
toSingle(new Fr(blockNumber))
|
|
488
534
|
]);
|
|
489
535
|
}
|
|
490
536
|
async avmOpcodeTimestamp() {
|
|
491
|
-
const timestamp = await this.
|
|
537
|
+
const timestamp = await this.handlerAsAvm().avmOpcodeTimestamp();
|
|
492
538
|
return toForeignCallResult([
|
|
493
539
|
toSingle(new Fr(timestamp))
|
|
494
540
|
]);
|
|
495
541
|
}
|
|
496
542
|
async avmOpcodeIsStaticCall() {
|
|
497
|
-
const isStaticCall = await this.
|
|
543
|
+
const isStaticCall = await this.handlerAsAvm().avmOpcodeIsStaticCall();
|
|
498
544
|
return toForeignCallResult([
|
|
499
545
|
toSingle(new Fr(isStaticCall ? 1 : 0))
|
|
500
546
|
]);
|
|
501
547
|
}
|
|
502
548
|
async avmOpcodeChainId() {
|
|
503
|
-
const chainId = await this.
|
|
549
|
+
const chainId = await this.handlerAsAvm().avmOpcodeChainId();
|
|
504
550
|
return toForeignCallResult([
|
|
505
551
|
toSingle(chainId)
|
|
506
552
|
]);
|
|
507
553
|
}
|
|
508
554
|
async avmOpcodeVersion() {
|
|
509
|
-
const version = await this.
|
|
555
|
+
const version = await this.handlerAsAvm().avmOpcodeVersion();
|
|
510
556
|
return toForeignCallResult([
|
|
511
557
|
toSingle(version)
|
|
512
558
|
]);
|
|
@@ -526,46 +572,39 @@ export class TXEService {
|
|
|
526
572
|
avmOpcodeSuccessCopy() {
|
|
527
573
|
throw new Error('Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead');
|
|
528
574
|
}
|
|
529
|
-
async txePrivateCallNewFlow(foreignFrom, foreignTargetContractAddress, foreignFunctionSelector,
|
|
575
|
+
async txePrivateCallNewFlow(foreignFrom, foreignTargetContractAddress, foreignFunctionSelector, foreignArgs, foreignArgsHash, foreignIsStaticCall) {
|
|
530
576
|
const from = addressFromSingle(foreignFrom);
|
|
531
577
|
const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
|
|
532
578
|
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
533
579
|
const args = fromArray(foreignArgs);
|
|
534
580
|
const argsHash = fromSingle(foreignArgsHash);
|
|
535
581
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
536
|
-
const
|
|
582
|
+
const returnValues = await this.handlerAsTxe().txePrivateCallNewFlow(from, targetContractAddress, functionSelector, args, argsHash, isStaticCall);
|
|
537
583
|
return toForeignCallResult([
|
|
538
|
-
toArray(
|
|
539
|
-
result.endSideEffectCounter,
|
|
540
|
-
result.returnsHash,
|
|
541
|
-
result.txHash.hash
|
|
542
|
-
])
|
|
584
|
+
toArray(returnValues)
|
|
543
585
|
]);
|
|
544
586
|
}
|
|
545
|
-
async
|
|
587
|
+
async txeSimulateUtilityFunction(foreignTargetContractAddress, foreignFunctionSelector, foreignArgs) {
|
|
546
588
|
const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
|
|
547
589
|
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
548
|
-
const
|
|
549
|
-
const
|
|
590
|
+
const args = fromArray(foreignArgs);
|
|
591
|
+
const returnValues = await this.handlerAsTxe().txeSimulateUtilityFunction(targetContractAddress, functionSelector, args);
|
|
550
592
|
return toForeignCallResult([
|
|
551
|
-
|
|
593
|
+
toArray(returnValues)
|
|
552
594
|
]);
|
|
553
595
|
}
|
|
554
|
-
async txePublicCallNewFlow(foreignFrom, foreignAddress,
|
|
596
|
+
async txePublicCallNewFlow(foreignFrom, foreignAddress, foreignCalldata, foreignIsStaticCall) {
|
|
555
597
|
const from = addressFromSingle(foreignFrom);
|
|
556
598
|
const address = addressFromSingle(foreignAddress);
|
|
557
599
|
const calldata = fromArray(foreignCalldata);
|
|
558
600
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
559
|
-
const
|
|
601
|
+
const returnValues = await this.handlerAsTxe().txePublicCallNewFlow(from, address, calldata, isStaticCall);
|
|
560
602
|
return toForeignCallResult([
|
|
561
|
-
toArray(
|
|
562
|
-
result.returnsHash,
|
|
563
|
-
result.txHash.hash
|
|
564
|
-
])
|
|
603
|
+
toArray(returnValues)
|
|
565
604
|
]);
|
|
566
605
|
}
|
|
567
606
|
async privateGetSenderForTags() {
|
|
568
|
-
const sender = await this.
|
|
607
|
+
const sender = await this.handlerAsPrivate().privateGetSenderForTags();
|
|
569
608
|
// Return a Noir Option struct with `some` and `value` fields
|
|
570
609
|
if (sender === undefined) {
|
|
571
610
|
// No sender found, return Option with some=0 and value=0
|
|
@@ -583,7 +622,15 @@ export class TXEService {
|
|
|
583
622
|
}
|
|
584
623
|
async privateSetSenderForTags(foreignSenderForTags) {
|
|
585
624
|
const senderForTags = AztecAddress.fromField(fromSingle(foreignSenderForTags));
|
|
586
|
-
await this.
|
|
625
|
+
await this.handlerAsPrivate().privateSetSenderForTags(senderForTags);
|
|
587
626
|
return toForeignCallResult([]);
|
|
588
627
|
}
|
|
628
|
+
async privateGetNextAppTagAsSender(foreignSender, foreignRecipient) {
|
|
629
|
+
const sender = AztecAddress.fromField(fromSingle(foreignSender));
|
|
630
|
+
const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
|
|
631
|
+
const nextAppTag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(sender, recipient);
|
|
632
|
+
return toForeignCallResult([
|
|
633
|
+
toSingle(nextAppTag.value)
|
|
634
|
+
]);
|
|
635
|
+
}
|
|
589
636
|
}
|