@aztec/txe 0.0.1-commit.2f68f620 → 0.0.1-commit.321f6a9
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/AuthRegistry-QVGDDH5X.js +3 -0
- package/dest/AuthRegistry-QVGDDH5X.js.map +7 -0
- package/dest/ContractClassRegistry-VWR3F42P.js +3 -0
- package/dest/ContractClassRegistry-VWR3F42P.js.map +7 -0
- package/dest/ContractInstanceRegistry-FHIWE33X.js +3 -0
- package/dest/ContractInstanceRegistry-FHIWE33X.js.map +7 -0
- package/dest/FeeJuice-SAOWVGG7.js +3 -0
- package/dest/FeeJuice-SAOWVGG7.js.map +7 -0
- package/dest/HandshakeRegistry-GY5CPEPS.js +3 -0
- package/dest/HandshakeRegistry-GY5CPEPS.js.map +7 -0
- package/dest/MultiCallEntrypoint-QG5H33ZZ.js +3 -0
- package/dest/MultiCallEntrypoint-QG5H33ZZ.js.map +7 -0
- package/dest/SchnorrAccount-NME3E45O.js +3 -0
- package/dest/SchnorrAccount-NME3E45O.js.map +7 -0
- package/dest/SchnorrInitializerlessAccount-WTGXU6SW.js +3 -0
- package/dest/SchnorrInitializerlessAccount-WTGXU6SW.js.map +7 -0
- package/dest/bin/check_txe_oracle_version.js +7 -15
- package/dest/bin/index.js +1 -1
- package/dest/bin/oracle_test_server.js +2 -2
- package/dest/chunk-32UHX7YY.js +3 -0
- package/dest/chunk-SZPMCTJK.js +260 -0
- package/dest/chunk-SZPMCTJK.js.map +7 -0
- package/dest/{chunk-W2NSX64C.js → chunk-YS3UIBVR.js} +2 -2
- package/dest/{chunk-W2NSX64C.js.map → chunk-YS3UIBVR.js.map} +3 -3
- package/dest/constants.d.ts +1 -1
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +1 -1
- package/dest/dispatcher_pool.d.ts +2 -2
- package/dest/dispatcher_pool.d.ts.map +1 -1
- package/dest/dispatcher_pool.js +5 -3
- package/dest/index.d.ts +2 -136
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +5 -3
- package/dest/metafile.json +9632 -7418
- package/dest/oracle/interfaces.d.ts +24 -11
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
- package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
- package/dest/oracle/tagging_secret_strategy.js +12 -0
- package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
- package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/default_fixtures.js +200 -0
- package/dest/oracle/test-resolver/index.d.ts +1 -1
- package/dest/oracle/test-resolver/index.d.ts.map +1 -1
- package/dest/oracle/test-resolver/index.js +1 -2
- package/dest/oracle/test-resolver/resolver.d.ts +21 -7
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -1
- package/dest/oracle/test-resolver/resolver.js +100 -33
- package/dest/oracle/txe_oracle_public_context.d.ts +9 -9
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +15 -9
- package/dest/oracle/txe_oracle_registry.d.ts +51 -26
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_registry.js +258 -53
- package/dest/oracle/txe_oracle_top_level_context.d.ts +30 -9
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +454 -288
- package/dest/oracle/txe_oracle_version.d.ts +4 -4
- package/dest/oracle/txe_oracle_version.js +4 -4
- package/dest/rpc_translator.d.ts +23 -4
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +167 -81
- package/dest/server.bundle.js +1 -1
- package/dest/state_machine/archiver.d.ts +1 -1
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +1 -2
- 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 +9 -0
- package/dest/state_machine/global_variable_builder.d.ts +3 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +0 -3
- package/dest/state_machine/index.d.ts +8 -6
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +41 -19
- package/dest/state_machine/synchronizer.d.ts +10 -2
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +18 -5
- package/dest/txe_session.d.ts +29 -20
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +165 -41
- package/dest/utils/block_creation.d.ts +2 -2
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +2 -2
- package/dest/utils/encoding.d.ts +4 -3
- package/dest/utils/encoding.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.d.ts +1 -1
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +0 -1
- package/dest/utils/txe_public_contract_data_source.d.ts +1 -1
- package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/utils/txe_public_contract_data_source.js +7 -4
- package/dest/worker.bundle.js +1 -1
- package/package.json +17 -17
- package/src/bin/check_txe_oracle_version.ts +9 -12
- package/src/bin/oracle_test_server.ts +2 -2
- package/src/constants.ts +1 -1
- package/src/dispatcher_pool.ts +4 -3
- package/src/index.ts +6 -4
- package/src/oracle/interfaces.ts +26 -9
- package/src/oracle/tagging_secret_strategy.ts +25 -0
- package/src/oracle/test-resolver/default_fixtures.ts +271 -0
- package/src/oracle/test-resolver/index.ts +1 -2
- package/src/oracle/test-resolver/resolver.ts +121 -41
- package/src/oracle/txe_oracle_public_context.ts +16 -14
- package/src/oracle/txe_oracle_registry.ts +197 -42
- package/src/oracle/txe_oracle_top_level_context.ts +201 -66
- package/src/oracle/txe_oracle_version.ts +4 -4
- package/src/rpc_translator.ts +224 -108
- package/src/state_machine/archiver.ts +0 -1
- package/src/state_machine/dummy_p2p_client.ts +13 -0
- package/src/state_machine/global_variable_builder.ts +2 -16
- package/src/state_machine/index.ts +50 -34
- package/src/state_machine/synchronizer.ts +26 -5
- package/src/txe_session.ts +284 -45
- package/src/utils/block_creation.ts +2 -1
- package/src/utils/tx_effect_creation.ts +0 -2
- package/src/utils/txe_public_contract_data_source.ts +6 -4
- package/dest/ContractClassRegistry-PII7Q556.js +0 -3
- package/dest/ContractClassRegistry-PII7Q556.js.map +0 -7
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js +0 -3
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +0 -7
- package/dest/FeeJuice-TQV5AQK7.js +0 -3
- package/dest/FeeJuice-TQV5AQK7.js.map +0 -7
- package/dest/MultiCallEntrypoint-SBJUIJY7.js +0 -3
- package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +0 -7
- package/dest/SchnorrAccount-MQXPIZ44.js +0 -3
- package/dest/SchnorrAccount-MQXPIZ44.js.map +0 -7
- package/dest/chunk-BJVAAXNA.js +0 -3
- package/dest/chunk-CDITIZHX.js +0 -257
- package/dest/chunk-CDITIZHX.js.map +0 -7
- package/dest/oracle/test-resolver/fixtures.d.ts +0 -43
- package/dest/oracle/test-resolver/fixtures.d.ts.map +0 -1
- package/dest/oracle/test-resolver/fixtures.js +0 -39
- package/src/oracle/test-resolver/fixtures.ts +0 -84
- /package/dest/{chunk-BJVAAXNA.js.map → chunk-32UHX7YY.js.map} +0 -0
|
@@ -4,27 +4,38 @@ import {
|
|
|
4
4
|
MAX_NOTE_HASHES_PER_TX,
|
|
5
5
|
MAX_NULLIFIERS_PER_TX,
|
|
6
6
|
MAX_PRIVATE_LOGS_PER_TX,
|
|
7
|
+
PRIVATE_CONTEXT_INPUTS_LENGTH,
|
|
7
8
|
PRIVATE_LOG_SIZE_IN_FIELDS,
|
|
8
9
|
} from '@aztec/constants';
|
|
9
10
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
|
+
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
10
12
|
import { withHexPrefix, withoutHexPrefix } from '@aztec/foundation/string';
|
|
13
|
+
import type { TaggingSecretStrategy } from '@aztec/pxe/server';
|
|
11
14
|
import {
|
|
12
15
|
ARRAY,
|
|
13
16
|
AZTEC_ADDRESS,
|
|
14
|
-
BIGINT,
|
|
15
17
|
BLOCK_NUMBER,
|
|
16
18
|
BOOL,
|
|
19
|
+
ETH_ADDRESS,
|
|
17
20
|
FIELD,
|
|
21
|
+
FIXED_ARRAY,
|
|
18
22
|
FUNCTION_SELECTOR,
|
|
19
23
|
type InputSlot,
|
|
24
|
+
LEAF,
|
|
20
25
|
type MaybePromise,
|
|
21
26
|
OPTION,
|
|
22
27
|
ORACLE_REGISTRY,
|
|
23
28
|
type OracleRegistryEntry,
|
|
29
|
+
type OutputSlot,
|
|
24
30
|
type ParamTypes,
|
|
31
|
+
SCALAR,
|
|
25
32
|
STR,
|
|
33
|
+
STRUCT,
|
|
34
|
+
type SlotShape,
|
|
26
35
|
type TypeMapping,
|
|
27
36
|
U32,
|
|
37
|
+
U64,
|
|
38
|
+
buildACIRCallback,
|
|
28
39
|
makeEntry,
|
|
29
40
|
} from '@aztec/pxe/simulator';
|
|
30
41
|
import { EventSelector } from '@aztec/stdlib/abi';
|
|
@@ -42,28 +53,86 @@ import {
|
|
|
42
53
|
} from '../constants.js';
|
|
43
54
|
import type { ForeignCallArgs, ForeignCallResult } from '../utils/encoding.js';
|
|
44
55
|
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
// Spreading `ORACLE_REGISTRY` re-materializes its entries into `TXE_ORACLE_REGISTRY`'s inferred type, which names the
|
|
57
|
+
// protocol types below. Re-exporting them gives tsc a portable path to each instead of falling back to a deep
|
|
58
|
+
// node_modules path that breaks .d.ts portability (TS2742).
|
|
59
|
+
export type { ContractClassLogData, EmbeddedCurvePoint, TxEffectData } from '@aztec/pxe/simulator';
|
|
60
|
+
export type { BlockHash } from '@aztec/stdlib/block';
|
|
61
|
+
export type { MembershipWitness } from '@aztec/foundation/trees';
|
|
62
|
+
export type { NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
63
|
+
|
|
64
|
+
const GAS_SETTINGS: TypeMapping<GasSettings> = LEAF({
|
|
65
|
+
kind: 'gas-settings',
|
|
47
66
|
deserialization: {
|
|
48
67
|
fn: ([reader]) => GasSettings.fromFields(reader.readFieldArray(GAS_SETTINGS_LENGTH)),
|
|
49
|
-
slots: 1,
|
|
50
68
|
},
|
|
51
|
-
}
|
|
69
|
+
shape: [{ len: GAS_SETTINGS_LENGTH }],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Tagging secret strategy discriminants. Must match the Noir test helper `TaggingSecretStrategy` in
|
|
73
|
+
// aztec-nr `test/helpers/tagging_secret_strategy.nr`. This is a test-only oracle (only `set_tagging_secret_strategies`
|
|
74
|
+
// reads it), so the mapping lives here on the TXE side rather than in the production oracle type mappings.
|
|
75
|
+
const STRATEGY_NON_INTERACTIVE_HANDSHAKE = 1;
|
|
76
|
+
const STRATEGY_ARBITRARY_SECRET = 2;
|
|
77
|
+
const STRATEGY_ADDRESS_DERIVED = 3;
|
|
78
|
+
const STRATEGY_INTERACTIVE_HANDSHAKE = 4;
|
|
79
|
+
|
|
80
|
+
const TAGGING_SECRET_STRATEGY: TypeMapping<TaggingSecretStrategy> = LEAF({
|
|
81
|
+
kind: 'tagging-secret-strategy',
|
|
82
|
+
serialization: {
|
|
83
|
+
fn: strategy => {
|
|
84
|
+
switch (strategy.type) {
|
|
85
|
+
case 'non-interactive-handshake':
|
|
86
|
+
return [new Fr(STRATEGY_NON_INTERACTIVE_HANDSHAKE), Fr.ZERO, Fr.ZERO];
|
|
87
|
+
case 'interactive-handshake':
|
|
88
|
+
return [new Fr(STRATEGY_INTERACTIVE_HANDSHAKE), Fr.ZERO, Fr.ZERO];
|
|
89
|
+
case 'address-derived':
|
|
90
|
+
return [new Fr(STRATEGY_ADDRESS_DERIVED), Fr.ZERO, Fr.ZERO];
|
|
91
|
+
case 'arbitrary-secret':
|
|
92
|
+
return [new Fr(STRATEGY_ARBITRARY_SECRET), strategy.secret.x, strategy.secret.y];
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
deserialization: {
|
|
97
|
+
fn: ([kindReader, xReader, yReader]) => {
|
|
98
|
+
const kind = kindReader.readField().toNumber();
|
|
99
|
+
const [x, y] = [xReader.readField(), yReader.readField()];
|
|
100
|
+
switch (kind) {
|
|
101
|
+
case STRATEGY_NON_INTERACTIVE_HANDSHAKE:
|
|
102
|
+
return { type: 'non-interactive-handshake' };
|
|
103
|
+
case STRATEGY_INTERACTIVE_HANDSHAKE:
|
|
104
|
+
return { type: 'interactive-handshake' };
|
|
105
|
+
case STRATEGY_ADDRESS_DERIVED:
|
|
106
|
+
return { type: 'address-derived' };
|
|
107
|
+
case STRATEGY_ARBITRARY_SECRET:
|
|
108
|
+
return { type: 'arbitrary-secret', secret: Point.fromFields([x, y]) };
|
|
109
|
+
default:
|
|
110
|
+
throw new Error(`Unrecognized tagging secret strategy kind: ${kind}`);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
shape: ['scalar', 'scalar', 'scalar'],
|
|
115
|
+
});
|
|
52
116
|
|
|
53
|
-
const PRIVATE_CONTEXT_INPUTS: TypeMapping<PrivateContextInputs> = {
|
|
117
|
+
const PRIVATE_CONTEXT_INPUTS: TypeMapping<PrivateContextInputs> = LEAF({
|
|
118
|
+
kind: 'private-context-inputs',
|
|
54
119
|
serialization: { fn: v => v.toFields() },
|
|
55
|
-
|
|
120
|
+
shape: Array<SlotShape>(PRIVATE_CONTEXT_INPUTS_LENGTH).fill('scalar'),
|
|
121
|
+
});
|
|
56
122
|
|
|
57
|
-
const COMPLETE_ADDRESS: TypeMapping<CompleteAddress> = {
|
|
123
|
+
const COMPLETE_ADDRESS: TypeMapping<CompleteAddress> = LEAF({
|
|
124
|
+
kind: 'complete-address',
|
|
58
125
|
serialization: { fn: v => [v.address.toField(), ...v.publicKeys.toFields()] },
|
|
59
|
-
|
|
126
|
+
shape: Array<SlotShape>(8).fill('scalar'), // address + 7 public-key fields
|
|
127
|
+
});
|
|
60
128
|
|
|
61
129
|
const TXE_TX_EFFECTS: TypeMapping<{
|
|
62
130
|
txHash: TxHash;
|
|
63
131
|
noteHashes: Fr[];
|
|
64
132
|
nullifiers: Fr[];
|
|
65
133
|
privateLogs: PrivateLog[];
|
|
66
|
-
}> = {
|
|
134
|
+
}> = LEAF({
|
|
135
|
+
kind: 'txe-tx-effects',
|
|
67
136
|
serialization: {
|
|
68
137
|
fn: ({ txHash, noteHashes, nullifiers, privateLogs }) => {
|
|
69
138
|
const emittedLogs = privateLogs.map(log => log.getEmittedFields());
|
|
@@ -91,9 +160,21 @@ const TXE_TX_EFFECTS: TypeMapping<{
|
|
|
91
160
|
] as (Fr | Fr[])[];
|
|
92
161
|
},
|
|
93
162
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
163
|
+
// txHash, padded note hashes + count, padded nullifiers + count, flattened private-log storage + lengths + count.
|
|
164
|
+
shape: [
|
|
165
|
+
'scalar',
|
|
166
|
+
{ len: MAX_NOTE_HASHES_PER_TX },
|
|
167
|
+
'scalar',
|
|
168
|
+
{ len: MAX_NULLIFIERS_PER_TX },
|
|
169
|
+
'scalar',
|
|
170
|
+
{ len: MAX_PRIVATE_LOGS_PER_TX * PRIVATE_LOG_SIZE_IN_FIELDS },
|
|
171
|
+
{ len: MAX_PRIVATE_LOGS_PER_TX },
|
|
172
|
+
'scalar',
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const TXE_OFFCHAIN_EFFECTS: TypeMapping<{ effects: Fr[][] }> = LEAF({
|
|
177
|
+
kind: 'txe-offchain-effects',
|
|
97
178
|
serialization: {
|
|
98
179
|
fn: ({ effects }) => {
|
|
99
180
|
const rawArrayStorage = effects
|
|
@@ -109,27 +190,41 @@ const TXE_OFFCHAIN_EFFECTS: TypeMapping<{ effects: Fr[][] }> = {
|
|
|
109
190
|
return [rawArrayStorage, effectLengths, new Fr(effects.length)] as (Fr | Fr[])[];
|
|
110
191
|
},
|
|
111
192
|
},
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
193
|
+
// Flattened effect storage, per-effect lengths, then the effect count.
|
|
194
|
+
shape: [
|
|
195
|
+
{ len: MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY * MAX_OFFCHAIN_EFFECT_LEN },
|
|
196
|
+
{ len: MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY },
|
|
197
|
+
'scalar',
|
|
198
|
+
],
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const TXE_CALL_CONTEXT: TypeMapping<{ txHash: Fr; anchorBlockTimestamp: bigint }> = LEAF({
|
|
202
|
+
kind: 'txe-call-context',
|
|
115
203
|
serialization: {
|
|
116
204
|
fn: ({ txHash, anchorBlockTimestamp }) => {
|
|
117
205
|
const isSome = txHash.isZero() ? 0 : 1;
|
|
118
206
|
return [new Fr(isSome), txHash, new Fr(anchorBlockTimestamp)];
|
|
119
207
|
},
|
|
120
208
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
209
|
+
shape: ['scalar', 'scalar', 'scalar'], // discriminant, txHash, anchor block timestamp
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const CONTRACT_INSTANCE_MEMBER: TypeMapping<{ exists: boolean; member: Fr }[]> = FIXED_ARRAY(
|
|
213
|
+
STRUCT([
|
|
214
|
+
{ name: 'exists', type: BOOL },
|
|
215
|
+
{ name: 'member', type: FIELD },
|
|
216
|
+
]),
|
|
217
|
+
1,
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
const EVENT_SELECTOR: TypeMapping<EventSelector> = SCALAR({
|
|
221
|
+
kind: 'event-selector',
|
|
128
222
|
serialization: { fn: v => [v.toField()] },
|
|
129
|
-
deserialization: { fn: ([reader]) => EventSelector.fromField(reader.readField())
|
|
130
|
-
};
|
|
223
|
+
deserialization: { fn: ([reader]) => EventSelector.fromField(reader.readField()) },
|
|
224
|
+
});
|
|
131
225
|
|
|
132
|
-
const TXE_PRIVATE_EVENTS: TypeMapping<Fr[][]> = {
|
|
226
|
+
const TXE_PRIVATE_EVENTS: TypeMapping<Fr[][]> = LEAF({
|
|
227
|
+
kind: 'txe-private-events',
|
|
133
228
|
serialization: {
|
|
134
229
|
fn: events => {
|
|
135
230
|
const rawArrayStorage = events
|
|
@@ -144,7 +239,13 @@ const TXE_PRIVATE_EVENTS: TypeMapping<Fr[][]> = {
|
|
|
144
239
|
return [rawArrayStorage, eventLengths, new Fr(events.length)] as (Fr | Fr[])[];
|
|
145
240
|
},
|
|
146
241
|
},
|
|
147
|
-
|
|
242
|
+
// Flattened event storage, per-event lengths, then the event count.
|
|
243
|
+
shape: [
|
|
244
|
+
{ len: MAX_PRIVATE_EVENTS_PER_TXE_QUERY * MAX_PRIVATE_EVENT_LEN },
|
|
245
|
+
{ len: MAX_PRIVATE_EVENTS_PER_TXE_QUERY },
|
|
246
|
+
'scalar',
|
|
247
|
+
],
|
|
248
|
+
});
|
|
148
249
|
|
|
149
250
|
export const TXE_ORACLE_REGISTRY = {
|
|
150
251
|
...ORACLE_REGISTRY,
|
|
@@ -179,14 +280,14 @@ export const TXE_ORACLE_REGISTRY = {
|
|
|
179
280
|
|
|
180
281
|
aztec_txe_getNextBlockNumber: makeEntry({ returnType: BLOCK_NUMBER }),
|
|
181
282
|
|
|
182
|
-
aztec_txe_getNextBlockTimestamp: makeEntry({ returnType:
|
|
283
|
+
aztec_txe_getNextBlockTimestamp: makeEntry({ returnType: U64 }),
|
|
183
284
|
|
|
184
285
|
aztec_txe_advanceBlocksBy: makeEntry({
|
|
185
286
|
params: [{ name: 'blocks', type: U32 }],
|
|
186
287
|
}),
|
|
187
288
|
|
|
188
289
|
aztec_txe_advanceTimestampBy: makeEntry({
|
|
189
|
-
params: [{ name: 'duration', type:
|
|
290
|
+
params: [{ name: 'duration', type: U64 }],
|
|
190
291
|
}),
|
|
191
292
|
|
|
192
293
|
aztec_txe_deploy: makeEntry({
|
|
@@ -203,7 +304,10 @@ export const TXE_ORACLE_REGISTRY = {
|
|
|
203
304
|
}),
|
|
204
305
|
|
|
205
306
|
aztec_txe_createAccount: makeEntry({
|
|
206
|
-
params: [
|
|
307
|
+
params: [
|
|
308
|
+
{ name: 'secret', type: FIELD },
|
|
309
|
+
{ name: 'partialAddress', type: FIELD },
|
|
310
|
+
],
|
|
207
311
|
returnType: COMPLETE_ADDRESS,
|
|
208
312
|
}),
|
|
209
313
|
|
|
@@ -219,8 +323,29 @@ export const TXE_ORACLE_REGISTRY = {
|
|
|
219
323
|
],
|
|
220
324
|
}),
|
|
221
325
|
|
|
326
|
+
aztec_txe_sendL1ToL2Message: makeEntry({
|
|
327
|
+
params: [
|
|
328
|
+
{ name: 'content', type: FIELD },
|
|
329
|
+
{ name: 'secretHash', type: FIELD },
|
|
330
|
+
{ name: 'sender', type: ETH_ADDRESS },
|
|
331
|
+
{ name: 'recipient', type: AZTEC_ADDRESS },
|
|
332
|
+
],
|
|
333
|
+
returnType: FIELD,
|
|
334
|
+
}),
|
|
335
|
+
|
|
336
|
+
aztec_txe_setTaggingSecretStrategies: makeEntry({
|
|
337
|
+
params: [
|
|
338
|
+
{ name: 'unconstrainedStrategy', type: OPTION(TAGGING_SECRET_STRATEGY) },
|
|
339
|
+
{ name: 'constrainedStrategy', type: OPTION(TAGGING_SECRET_STRATEGY) },
|
|
340
|
+
],
|
|
341
|
+
}),
|
|
342
|
+
|
|
343
|
+
aztec_txe_setAuthorizeAllUtilityCallTargets: makeEntry({
|
|
344
|
+
params: [{ name: 'authorizeAll', type: BOOL }],
|
|
345
|
+
}),
|
|
346
|
+
|
|
222
347
|
aztec_txe_getLastBlockTimestamp: makeEntry({
|
|
223
|
-
returnType:
|
|
348
|
+
returnType: U64,
|
|
224
349
|
}),
|
|
225
350
|
|
|
226
351
|
aztec_txe_getLastTxEffects: makeEntry({ returnType: TXE_TX_EFFECTS }),
|
|
@@ -253,6 +378,7 @@ export const TXE_ORACLE_REGISTRY = {
|
|
|
253
378
|
|
|
254
379
|
aztec_txe_executeUtilityFunction: makeEntry({
|
|
255
380
|
params: [
|
|
381
|
+
{ name: 'from', type: OPTION(AZTEC_ADDRESS) },
|
|
256
382
|
{ name: 'targetContractAddress', type: AZTEC_ADDRESS },
|
|
257
383
|
{ name: 'functionSelector', type: FUNCTION_SELECTOR },
|
|
258
384
|
{ name: 'args', type: ARRAY(FIELD) },
|
|
@@ -278,7 +404,7 @@ export const TXE_ORACLE_REGISTRY = {
|
|
|
278
404
|
|
|
279
405
|
aztec_avm_blockNumber: makeEntry({ returnType: BLOCK_NUMBER }),
|
|
280
406
|
|
|
281
|
-
aztec_avm_timestamp: makeEntry({ returnType:
|
|
407
|
+
aztec_avm_timestamp: makeEntry({ returnType: U64 }),
|
|
282
408
|
|
|
283
409
|
aztec_avm_isStaticCall: makeEntry({ returnType: BOOL }),
|
|
284
410
|
|
|
@@ -318,7 +444,7 @@ export const TXE_ORACLE_REGISTRY = {
|
|
|
318
444
|
params: [{ name: 'message', type: ARRAY(FIELD) }],
|
|
319
445
|
}),
|
|
320
446
|
|
|
321
|
-
aztec_avm_returndataSize: makeEntry({ returnType:
|
|
447
|
+
aztec_avm_returndataSize: makeEntry({ returnType: U32 }),
|
|
322
448
|
|
|
323
449
|
aztec_avm_returndataCopy: makeEntry({
|
|
324
450
|
params: [
|
|
@@ -336,7 +462,6 @@ export const TXE_ORACLE_REGISTRY = {
|
|
|
336
462
|
{ name: 'argsLength', type: U32 },
|
|
337
463
|
{ name: 'args', type: ARRAY(FIELD) },
|
|
338
464
|
],
|
|
339
|
-
returnType: ARRAY(FIELD),
|
|
340
465
|
}),
|
|
341
466
|
|
|
342
467
|
aztec_avm_staticCall: makeEntry({
|
|
@@ -347,10 +472,9 @@ export const TXE_ORACLE_REGISTRY = {
|
|
|
347
472
|
{ name: 'argsLength', type: U32 },
|
|
348
473
|
{ name: 'args', type: ARRAY(FIELD) },
|
|
349
474
|
],
|
|
350
|
-
returnType: ARRAY(FIELD),
|
|
351
475
|
}),
|
|
352
476
|
|
|
353
|
-
aztec_avm_successCopy: makeEntry({ returnType:
|
|
477
|
+
aztec_avm_successCopy: makeEntry({ returnType: BOOL }),
|
|
354
478
|
|
|
355
479
|
aztec_avm_getContractInstanceDeployer: makeEntry({
|
|
356
480
|
params: [{ name: 'address', type: AZTEC_ADDRESS }],
|
|
@@ -370,6 +494,11 @@ export const TXE_ORACLE_REGISTRY = {
|
|
|
370
494
|
}),
|
|
371
495
|
} satisfies Record<string, OracleRegistryEntry>;
|
|
372
496
|
|
|
497
|
+
export function toInputSlots(inputs: ForeignCallArgs): InputSlot[] {
|
|
498
|
+
// TXE foreign calls use bare hex strings, but Fr.fromString requires a 0x prefix to parse as hex.
|
|
499
|
+
return inputs.map(v => (Array.isArray(v) ? (v as string[]).map(withHexPrefix) : [withHexPrefix(v as string)]));
|
|
500
|
+
}
|
|
501
|
+
|
|
373
502
|
/**
|
|
374
503
|
* Deserializes oracle inputs, calls the handler with typed params, serializes the result, and wraps
|
|
375
504
|
* it in a `ForeignCallResult`. Normalizes `ForeignCallArgs` (which may contain bare strings) into
|
|
@@ -387,14 +516,40 @@ export async function callTxeHandler<K extends keyof typeof TXE_ORACLE_REGISTRY>
|
|
|
387
516
|
) => MaybePromise<Parameters<(typeof TXE_ORACLE_REGISTRY)[K]['serializeReturn']>[0]>;
|
|
388
517
|
}): Promise<ForeignCallResult> {
|
|
389
518
|
const entry = TXE_ORACLE_REGISTRY[oracle] as OracleRegistryEntry;
|
|
390
|
-
|
|
391
|
-
const normalized: InputSlot[] = inputs.map(v =>
|
|
392
|
-
Array.isArray(v) ? (v as string[]).map(withHexPrefix) : [withHexPrefix(v as string)],
|
|
393
|
-
);
|
|
394
|
-
const named = entry.deserializeParams(normalized);
|
|
519
|
+
const named = entry.deserializeParams(toInputSlots(inputs));
|
|
395
520
|
const positional = named.map((p: { value: unknown }) => p.value);
|
|
396
521
|
const result = await handler(positional as any);
|
|
397
|
-
|
|
522
|
+
return outputSlotsToForeignCallResult(entry.serializeReturn(result));
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Dispatches an oracle that has been retired into the PXE legacy registry. TXE has no explicit handler method for such
|
|
527
|
+
* names; this runs them through the same `buildACIRCallback` legacy path that contract execution already uses, so
|
|
528
|
+
* TXE's top-level oracle path and its in-contract path treat the legacy registry identically.
|
|
529
|
+
*/
|
|
530
|
+
const legacyCallbacksByHandler = new WeakMap<object, ReturnType<typeof buildACIRCallback>>();
|
|
531
|
+
|
|
532
|
+
export async function callTxeLegacyHandler(
|
|
533
|
+
oracle: string,
|
|
534
|
+
inputs: ForeignCallArgs,
|
|
535
|
+
oracleHandler: Parameters<typeof buildACIRCallback>[0],
|
|
536
|
+
): Promise<ForeignCallResult> {
|
|
537
|
+
// `buildACIRCallback` materializes the whole real+legacy closure set, so memoize it per handler rather than
|
|
538
|
+
// rebuilding on every call (TXE routes one legacy oracle through here on each top-level discovery).
|
|
539
|
+
let callback = legacyCallbacksByHandler.get(oracleHandler);
|
|
540
|
+
if (!callback) {
|
|
541
|
+
callback = buildACIRCallback(oracleHandler);
|
|
542
|
+
legacyCallbacksByHandler.set(oracleHandler, callback);
|
|
543
|
+
}
|
|
544
|
+
const outputSlots = await callback[oracle](...toInputSlots(inputs));
|
|
545
|
+
return outputSlotsToForeignCallResult(outputSlots);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Strips the `0x` prefix from each serialized output slot (TXE foreign calls use bare hex strings) and wraps them in a
|
|
550
|
+
* `ForeignCallResult`.
|
|
551
|
+
*/
|
|
552
|
+
function outputSlotsToForeignCallResult(outputSlots: OutputSlot[]): ForeignCallResult {
|
|
398
553
|
return {
|
|
399
554
|
values: outputSlots.map(slot => (Array.isArray(slot) ? slot.map(withoutHexPrefix) : withoutHexPrefix(slot))),
|
|
400
555
|
};
|