@aztec/txe 0.0.1-commit.993d240 → 0.0.1-commit.9a89641

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.
Files changed (144) hide show
  1. package/dest/AuthRegistry-QVGDDH5X.js +3 -0
  2. package/dest/AuthRegistry-QVGDDH5X.js.map +7 -0
  3. package/dest/ContractClassRegistry-PVNCKGG7.js +3 -0
  4. package/dest/ContractClassRegistry-PVNCKGG7.js.map +7 -0
  5. package/dest/ContractInstanceRegistry-WLOZKTR6.js +3 -0
  6. package/dest/ContractInstanceRegistry-WLOZKTR6.js.map +7 -0
  7. package/dest/FeeJuice-MAQJU53K.js +3 -0
  8. package/dest/FeeJuice-MAQJU53K.js.map +7 -0
  9. package/dest/HandshakeRegistry-GY5CPEPS.js +3 -0
  10. package/dest/HandshakeRegistry-GY5CPEPS.js.map +7 -0
  11. package/dest/MultiCallEntrypoint-QG5H33ZZ.js +3 -0
  12. package/dest/MultiCallEntrypoint-QG5H33ZZ.js.map +7 -0
  13. package/dest/SchnorrAccount-ADD65DYA.js +3 -0
  14. package/dest/SchnorrAccount-ADD65DYA.js.map +7 -0
  15. package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js +3 -0
  16. package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js.map +7 -0
  17. package/dest/bin/check_txe_oracle_version.js +9 -19
  18. package/dest/bin/index.js +1 -1
  19. package/dest/bin/oracle_test_server.d.ts +3 -0
  20. package/dest/bin/oracle_test_server.d.ts.map +1 -0
  21. package/dest/bin/oracle_test_server.js +41 -0
  22. package/dest/chunk-32UHX7YY.js +3 -0
  23. package/dest/{chunk-DF6RMOC6.js → chunk-RVEPNDEP.js} +2 -2
  24. package/dest/{chunk-DF6RMOC6.js.map → chunk-RVEPNDEP.js.map} +3 -3
  25. package/dest/chunk-XWIMXLKD.js +258 -0
  26. package/dest/chunk-XWIMXLKD.js.map +7 -0
  27. package/dest/constants.d.ts +3 -1
  28. package/dest/constants.d.ts.map +1 -1
  29. package/dest/constants.js +5 -2
  30. package/dest/dispatcher_pool.d.ts +2 -2
  31. package/dest/dispatcher_pool.d.ts.map +1 -1
  32. package/dest/dispatcher_pool.js +5 -3
  33. package/dest/index.d.ts +6 -143
  34. package/dest/index.d.ts.map +1 -1
  35. package/dest/index.js +12 -169
  36. package/dest/metafile.json +10267 -9581
  37. package/dest/oracle/interfaces.d.ts +38 -11
  38. package/dest/oracle/interfaces.d.ts.map +1 -1
  39. package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
  40. package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
  41. package/dest/oracle/tagging_secret_strategy.js +12 -0
  42. package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
  43. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
  44. package/dest/oracle/test-resolver/default_fixtures.js +200 -0
  45. package/dest/oracle/test-resolver/index.d.ts +9 -0
  46. package/dest/oracle/test-resolver/index.d.ts.map +1 -0
  47. package/dest/oracle/test-resolver/index.js +32 -0
  48. package/dest/oracle/test-resolver/resolver.d.ts +48 -0
  49. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
  50. package/dest/oracle/test-resolver/resolver.js +181 -0
  51. package/dest/oracle/txe_oracle_public_context.d.ts +25 -6
  52. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  53. package/dest/oracle/txe_oracle_public_context.js +34 -1
  54. package/dest/oracle/txe_oracle_registry.d.ts +172 -0
  55. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
  56. package/dest/oracle/txe_oracle_registry.js +767 -0
  57. package/dest/oracle/txe_oracle_top_level_context.d.ts +39 -14
  58. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  59. package/dest/oracle/txe_oracle_top_level_context.js +489 -289
  60. package/dest/{txe_oracle_version.d.ts → oracle/txe_oracle_version.d.ts} +5 -5
  61. package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
  62. package/dest/{txe_oracle_version.js → oracle/txe_oracle_version.js} +4 -4
  63. package/dest/rpc_translator.d.ts +116 -284
  64. package/dest/rpc_translator.d.ts.map +1 -1
  65. package/dest/rpc_translator.js +809 -860
  66. package/dest/server.bundle.js +1 -1
  67. package/dest/state_machine/archiver.d.ts +3 -2
  68. package/dest/state_machine/archiver.d.ts.map +1 -1
  69. package/dest/state_machine/archiver.js +9 -3
  70. package/dest/state_machine/dummy_p2p_client.d.ts +5 -2
  71. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  72. package/dest/state_machine/dummy_p2p_client.js +9 -0
  73. package/dest/state_machine/global_variable_builder.d.ts +3 -4
  74. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  75. package/dest/state_machine/global_variable_builder.js +0 -3
  76. package/dest/state_machine/index.d.ts +8 -6
  77. package/dest/state_machine/index.d.ts.map +1 -1
  78. package/dest/state_machine/index.js +41 -19
  79. package/dest/state_machine/mock_epoch_cache.d.ts +2 -3
  80. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  81. package/dest/state_machine/mock_epoch_cache.js +3 -6
  82. package/dest/state_machine/synchronizer.d.ts +10 -2
  83. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  84. package/dest/state_machine/synchronizer.js +18 -5
  85. package/dest/txe_session.d.ts +43 -28
  86. package/dest/txe_session.d.ts.map +1 -1
  87. package/dest/txe_session.js +183 -47
  88. package/dest/utils/block_creation.d.ts +2 -2
  89. package/dest/utils/block_creation.d.ts.map +1 -1
  90. package/dest/utils/block_creation.js +2 -2
  91. package/dest/utils/encoding.d.ts +8 -5
  92. package/dest/utils/encoding.d.ts.map +1 -1
  93. package/dest/utils/tx_effect_creation.d.ts +1 -1
  94. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  95. package/dest/utils/tx_effect_creation.js +0 -1
  96. package/dest/utils/txe_artifact_resolver.d.ts +37 -0
  97. package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
  98. package/dest/utils/txe_artifact_resolver.js +161 -0
  99. package/dest/utils/txe_public_contract_data_source.d.ts +1 -1
  100. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -1
  101. package/dest/utils/txe_public_contract_data_source.js +7 -4
  102. package/dest/worker.bundle.js +1 -1
  103. package/package.json +18 -17
  104. package/src/bin/check_txe_oracle_version.ts +11 -17
  105. package/src/bin/oracle_test_server.ts +51 -0
  106. package/src/constants.ts +6 -2
  107. package/src/dispatcher_pool.ts +4 -3
  108. package/src/index.ts +21 -198
  109. package/src/oracle/interfaces.ts +35 -9
  110. package/src/oracle/tagging_secret_strategy.ts +25 -0
  111. package/src/oracle/test-resolver/default_fixtures.ts +271 -0
  112. package/src/oracle/test-resolver/index.ts +44 -0
  113. package/src/oracle/test-resolver/resolver.ts +245 -0
  114. package/src/oracle/txe_oracle_public_context.ts +36 -4
  115. package/src/oracle/txe_oracle_registry.ts +556 -0
  116. package/src/oracle/txe_oracle_top_level_context.ts +249 -66
  117. package/src/{txe_oracle_version.ts → oracle/txe_oracle_version.ts} +4 -4
  118. package/src/rpc_translator.ts +850 -1065
  119. package/src/state_machine/archiver.ts +9 -3
  120. package/src/state_machine/dummy_p2p_client.ts +13 -0
  121. package/src/state_machine/global_variable_builder.ts +2 -16
  122. package/src/state_machine/index.ts +50 -34
  123. package/src/state_machine/mock_epoch_cache.ts +4 -8
  124. package/src/state_machine/synchronizer.ts +26 -5
  125. package/src/txe_session.ts +325 -56
  126. package/src/utils/block_creation.ts +2 -1
  127. package/src/utils/tx_effect_creation.ts +0 -2
  128. package/src/utils/txe_artifact_resolver.ts +217 -0
  129. package/src/utils/txe_public_contract_data_source.ts +6 -4
  130. package/dest/ContractClassRegistry-KKNT527R.js +0 -3
  131. package/dest/ContractClassRegistry-KKNT527R.js.map +0 -7
  132. package/dest/ContractInstanceRegistry-GSKBNL3Q.js +0 -3
  133. package/dest/ContractInstanceRegistry-GSKBNL3Q.js.map +0 -7
  134. package/dest/FeeJuice-GUJ5O6GB.js +0 -3
  135. package/dest/FeeJuice-GUJ5O6GB.js.map +0 -7
  136. package/dest/MultiCallEntrypoint-ZQPCKVKL.js +0 -3
  137. package/dest/MultiCallEntrypoint-ZQPCKVKL.js.map +0 -7
  138. package/dest/SchnorrAccount-QIXE5DXA.js +0 -3
  139. package/dest/SchnorrAccount-QIXE5DXA.js.map +0 -7
  140. package/dest/chunk-BJVAAXNA.js +0 -3
  141. package/dest/chunk-PPJTNNUG.js +0 -265
  142. package/dest/chunk-PPJTNNUG.js.map +0 -7
  143. package/dest/txe_oracle_version.d.ts.map +0 -1
  144. /package/dest/{chunk-BJVAAXNA.js.map → chunk-32UHX7YY.js.map} +0 -0
@@ -1,15 +1,4 @@
1
- import { Fr } from '@aztec/aztec.js/fields';
2
- import { ARCHIVE_HEIGHT, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
3
- import { BlockNumber } from '@aztec/foundation/branded-types';
4
- import { MembershipWitness } from '@aztec/foundation/trees';
5
- import { BoundedVec, Option, packAsHintedNote } from '@aztec/pxe/simulator';
6
- import { EventSelector, FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
7
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
- import { GasSettings } from '@aztec/stdlib/gas';
9
- import { MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY, MAX_OFFCHAIN_EFFECT_LEN } from './constants.js';
10
- import { addressFromSingle, arrayOfArraysToBoundedVecOfArrays, arrayToBoundedVec, blockHashFromSingle, bufferToU8Array, fromArray, fromSingle, fromUintArray, fromUintBoundedVec, toArray, toForeignCallResult, toSingle } from './utils/encoding.js';
11
- const MAX_EVENT_LEN = 10; // This is MAX_MESSAGE_CONTENT_LEN - PRIVATE_EVENT_MSG_PLAINTEXT_RESERVED_FIELDS_LEN
12
- const MAX_PRIVATE_EVENTS_PER_TXE_QUERY = 5;
1
+ import { callTxeHandler } from './oracle/txe_oracle_registry.js';
13
2
  export class UnavailableOracleError extends Error {
14
3
  constructor(oracleName){
15
4
  super(`${oracleName} oracles not available with the current handler`);
@@ -63,965 +52,925 @@ export class RPCTranslator {
63
52
  return this.oracleHandler;
64
53
  }
65
54
  // eslint-disable-next-line camelcase
66
- aztec_txe_assertCompatibleOracleVersion(foreignMajor, foreignMinor) {
67
- const major = fromSingle(foreignMajor).toNumber();
68
- const minor = fromSingle(foreignMinor).toNumber();
69
- this.stateHandler.setTxeOracleVersion(major, minor);
70
- return toForeignCallResult([]);
55
+ aztec_txe_assertCompatibleOracleVersion(...inputs) {
56
+ return callTxeHandler({
57
+ oracle: 'aztec_txe_assertCompatibleOracleVersion',
58
+ inputs,
59
+ handler: ([major, minor])=>{
60
+ this.stateHandler.setTxeOracleVersion(major, minor);
61
+ }
62
+ });
71
63
  }
72
64
  // TXE session state transition functions - these get handled by the state handler
73
65
  // eslint-disable-next-line camelcase
74
- async aztec_txe_setTopLevelTXEContext() {
75
- await this.stateHandler.enterTopLevelState();
76
- return toForeignCallResult([]);
66
+ aztec_txe_setTopLevelTXEContext() {
67
+ return callTxeHandler({
68
+ oracle: 'aztec_txe_setTopLevelTXEContext',
69
+ inputs: [],
70
+ handler: ()=>this.stateHandler.enterTopLevelState()
71
+ });
77
72
  }
78
73
  // eslint-disable-next-line camelcase
79
- async aztec_txe_setPrivateTXEContext(foreignContractAddressIsSome, foreignContractAddressValue, foreignAnchorBlockNumberIsSome, foreignAnchorBlockNumberValue, foreignGasSettings) {
80
- const contractAddress = fromSingle(foreignContractAddressIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignContractAddressValue)) : undefined;
81
- const anchorBlockNumber = fromSingle(foreignAnchorBlockNumberIsSome).toBool() ? BlockNumber(fromSingle(foreignAnchorBlockNumberValue).toNumber()) : undefined;
82
- const gasSettings = GasSettings.fromFields(fromArray(foreignGasSettings));
83
- const privateContextInputs = await this.stateHandler.enterPrivateState(contractAddress, anchorBlockNumber, gasSettings);
84
- return toForeignCallResult(privateContextInputs.toFields().map(toSingle));
74
+ aztec_txe_setPrivateTXEContext(...inputs) {
75
+ return callTxeHandler({
76
+ oracle: 'aztec_txe_setPrivateTXEContext',
77
+ inputs,
78
+ handler: ([contractAddress, anchorBlockNumber, gasSettings])=>this.stateHandler.enterPrivateState(contractAddress, anchorBlockNumber, gasSettings)
79
+ });
85
80
  }
86
81
  // eslint-disable-next-line camelcase
87
- async aztec_txe_setPublicTXEContext(foreignContractAddressIsSome, foreignContractAddressValue) {
88
- const contractAddress = fromSingle(foreignContractAddressIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignContractAddressValue)) : undefined;
89
- await this.stateHandler.enterPublicState(contractAddress);
90
- return toForeignCallResult([]);
82
+ aztec_txe_setPublicTXEContext(...inputs) {
83
+ return callTxeHandler({
84
+ oracle: 'aztec_txe_setPublicTXEContext',
85
+ inputs,
86
+ handler: ([contractAddress])=>this.stateHandler.enterPublicState(contractAddress)
87
+ });
91
88
  }
92
89
  // eslint-disable-next-line camelcase
93
- async aztec_txe_setUtilityTXEContext(foreignContractAddressIsSome, foreignContractAddressValue) {
94
- const contractAddress = fromSingle(foreignContractAddressIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignContractAddressValue)) : undefined;
95
- await this.stateHandler.enterUtilityState(contractAddress);
96
- return toForeignCallResult([]);
90
+ aztec_txe_setUtilityTXEContext(...inputs) {
91
+ return callTxeHandler({
92
+ oracle: 'aztec_txe_setUtilityTXEContext',
93
+ inputs,
94
+ handler: ([contractAddress])=>this.stateHandler.enterUtilityState(contractAddress)
95
+ });
97
96
  }
98
97
  // Other oracles - these get handled by the oracle handler
99
98
  // TXE-specific oracles
100
99
  // eslint-disable-next-line camelcase
101
100
  aztec_txe_getDefaultAddress() {
102
- const defaultAddress = this.handlerAsTxe().getDefaultAddress();
103
- return toForeignCallResult([
104
- toSingle(defaultAddress)
105
- ]);
101
+ return callTxeHandler({
102
+ oracle: 'aztec_txe_getDefaultAddress',
103
+ inputs: [],
104
+ handler: ()=>this.handlerAsTxe().getDefaultAddress()
105
+ });
106
+ }
107
+ // eslint-disable-next-line camelcase
108
+ aztec_txe_getNextBlockNumber() {
109
+ return callTxeHandler({
110
+ oracle: 'aztec_txe_getNextBlockNumber',
111
+ inputs: [],
112
+ handler: ()=>this.handlerAsTxe().getNextBlockNumber()
113
+ });
114
+ }
115
+ // eslint-disable-next-line camelcase
116
+ aztec_txe_getNextBlockTimestamp() {
117
+ return callTxeHandler({
118
+ oracle: 'aztec_txe_getNextBlockTimestamp',
119
+ inputs: [],
120
+ handler: ()=>this.handlerAsTxe().getNextBlockTimestamp()
121
+ });
122
+ }
123
+ // eslint-disable-next-line camelcase
124
+ aztec_txe_advanceBlocksBy(...inputs) {
125
+ return callTxeHandler({
126
+ oracle: 'aztec_txe_advanceBlocksBy',
127
+ inputs,
128
+ handler: ([blocks])=>this.handlerAsTxe().advanceBlocksBy(blocks)
129
+ });
106
130
  }
107
131
  // eslint-disable-next-line camelcase
108
- async aztec_txe_getNextBlockNumber() {
109
- const nextBlockNumber = await this.handlerAsTxe().getNextBlockNumber();
110
- return toForeignCallResult([
111
- toSingle(nextBlockNumber)
112
- ]);
132
+ aztec_txe_advanceTimestampBy(...inputs) {
133
+ return callTxeHandler({
134
+ oracle: 'aztec_txe_advanceTimestampBy',
135
+ inputs,
136
+ handler: ([duration])=>this.handlerAsTxe().advanceTimestampBy(duration)
137
+ });
113
138
  }
114
139
  // eslint-disable-next-line camelcase
115
- async aztec_txe_getNextBlockTimestamp() {
116
- const nextBlockTimestamp = await this.handlerAsTxe().getNextBlockTimestamp();
117
- return toForeignCallResult([
118
- toSingle(nextBlockTimestamp)
119
- ]);
140
+ aztec_txe_deploy(...inputs) {
141
+ return callTxeHandler({
142
+ oracle: 'aztec_txe_deploy',
143
+ inputs,
144
+ handler: ([contractPath, initializer, _, args, secret, salt, deployer])=>this.handlerAsTxe().deploy(contractPath, initializer, args, secret, salt, deployer)
145
+ });
120
146
  }
121
147
  // eslint-disable-next-line camelcase
122
- async aztec_txe_advanceBlocksBy(foreignBlocks) {
123
- const blocks = fromSingle(foreignBlocks).toNumber();
124
- await this.handlerAsTxe().advanceBlocksBy(blocks);
125
- return toForeignCallResult([]);
148
+ aztec_txe_createAccount(...inputs) {
149
+ return callTxeHandler({
150
+ oracle: 'aztec_txe_createAccount',
151
+ inputs,
152
+ handler: ([secret, partialAddress])=>this.handlerAsTxe().createAccount(secret, partialAddress)
153
+ });
126
154
  }
127
155
  // eslint-disable-next-line camelcase
128
- aztec_txe_advanceTimestampBy(foreignDuration) {
129
- const duration = fromSingle(foreignDuration).toBigInt();
130
- this.handlerAsTxe().advanceTimestampBy(duration);
131
- return toForeignCallResult([]);
156
+ aztec_txe_addAccount(...inputs) {
157
+ return callTxeHandler({
158
+ oracle: 'aztec_txe_addAccount',
159
+ inputs,
160
+ handler: ([secret])=>this.handlerAsTxe().addAccount(secret)
161
+ });
132
162
  }
133
163
  // eslint-disable-next-line camelcase
134
- async aztec_txe_deploy(artifact, instance, foreignSecret) {
135
- const secret = fromSingle(foreignSecret);
136
- await this.handlerAsTxe().deploy(artifact, instance, secret);
137
- return toForeignCallResult([
138
- toArray([
139
- instance.salt,
140
- instance.deployer.toField(),
141
- instance.currentContractClassId,
142
- instance.initializationHash,
143
- instance.immutablesHash,
144
- ...instance.publicKeys.toFields()
145
- ])
146
- ]);
164
+ aztec_txe_addAuthWitness(...inputs) {
165
+ return callTxeHandler({
166
+ oracle: 'aztec_txe_addAuthWitness',
167
+ inputs,
168
+ handler: ([address, messageHash])=>this.handlerAsTxe().addAuthWitness(address, messageHash)
169
+ });
147
170
  }
148
171
  // eslint-disable-next-line camelcase
149
- async aztec_txe_createAccount(foreignSecret) {
150
- const secret = fromSingle(foreignSecret);
151
- const completeAddress = await this.handlerAsTxe().createAccount(secret);
152
- return toForeignCallResult([
153
- toSingle(completeAddress.address),
154
- ...completeAddress.publicKeys.toFields().map(toSingle)
155
- ]);
172
+ aztec_txe_sendL1ToL2Message(...inputs) {
173
+ return callTxeHandler({
174
+ oracle: 'aztec_txe_sendL1ToL2Message',
175
+ inputs,
176
+ handler: ([content, secretHash, sender, recipient])=>this.handlerAsTxe().sendL1ToL2Message(content, secretHash, sender, recipient)
177
+ });
156
178
  }
157
179
  // eslint-disable-next-line camelcase
158
- async aztec_txe_addAccount(artifact, instance, foreignSecret) {
159
- const secret = fromSingle(foreignSecret);
160
- const completeAddress = await this.handlerAsTxe().addAccount(artifact, instance, secret);
161
- return toForeignCallResult([
162
- toSingle(completeAddress.address),
163
- ...completeAddress.publicKeys.toFields().map(toSingle)
164
- ]);
180
+ aztec_txe_setTaggingSecretStrategies(...inputs) {
181
+ return callTxeHandler({
182
+ oracle: 'aztec_txe_setTaggingSecretStrategies',
183
+ inputs,
184
+ handler: ([unconstrainedStrategy, constrainedStrategy])=>this.handlerAsTxe().setTaggingSecretStrategies(unconstrainedStrategy, constrainedStrategy)
185
+ });
165
186
  }
166
187
  // eslint-disable-next-line camelcase
167
- async aztec_txe_addAuthWitness(foreignAddress, foreignMessageHash) {
168
- const address = addressFromSingle(foreignAddress);
169
- const messageHash = fromSingle(foreignMessageHash);
170
- await this.handlerAsTxe().addAuthWitness(address, messageHash);
171
- return toForeignCallResult([]);
188
+ aztec_txe_setAuthorizeAllUtilityCallTargets(...inputs) {
189
+ return callTxeHandler({
190
+ oracle: 'aztec_txe_setAuthorizeAllUtilityCallTargets',
191
+ inputs,
192
+ handler: ([authorizeAll])=>this.handlerAsTxe().setAuthorizeAllUtilityCallTargets(authorizeAll)
193
+ });
172
194
  }
173
195
  // PXE oracles
174
196
  // eslint-disable-next-line camelcase
175
- aztec_utl_assertCompatibleOracleVersion(foreignMajor, foreignMinor) {
176
- const major = fromSingle(foreignMajor).toNumber();
177
- const minor = fromSingle(foreignMinor).toNumber();
178
- this.handlerAsMisc().assertCompatibleOracleVersion(major, minor);
179
- return toForeignCallResult([]);
180
- }
181
- // eslint-disable-next-line camelcase
182
- aztec_utl_getRandomField() {
183
- const randomField = this.handlerAsMisc().getRandomField();
184
- return toForeignCallResult([
185
- toSingle(randomField)
186
- ]);
187
- }
188
- // eslint-disable-next-line camelcase
189
- async aztec_txe_getLastBlockTimestamp() {
190
- const timestamp = await this.handlerAsTxe().getLastBlockTimestamp();
191
- return toForeignCallResult([
192
- toSingle(new Fr(timestamp))
193
- ]);
194
- }
195
- // eslint-disable-next-line camelcase
196
- async aztec_txe_getLastTxEffects() {
197
- const { txHash, noteHashes, nullifiers, privateLogs } = await this.handlerAsTxe().getLastTxEffects();
198
- // Same workaround as `aztec_txe_getPrivateEvents`: Noir cannot yet return nested structs with arrays, so we return
199
- // a flat multidimensional array plus per-log lengths and the total count, and reassemble into a
200
- // `BoundedVec<BoundedVec<T>>` on the Noir side. Each log contributes only its emitted fields. The rest
201
- // is zero-padded to `PRIVATE_LOG_SIZE_IN_FIELDS`.
202
- const emittedLogs = privateLogs.map((log)=>log.getEmittedFields());
203
- const rawLogStorage = emittedLogs.map((fields)=>fields.concat(Array(PRIVATE_LOG_SIZE_IN_FIELDS - fields.length).fill(new Fr(0)))).concat(Array(MAX_PRIVATE_LOGS_PER_TX - emittedLogs.length).fill(Array(PRIVATE_LOG_SIZE_IN_FIELDS).fill(new Fr(0)))).flat();
204
- const logLengths = emittedLogs.map((fields)=>new Fr(fields.length)).concat(Array(MAX_PRIVATE_LOGS_PER_TX - emittedLogs.length).fill(new Fr(0)));
205
- const logCount = new Fr(emittedLogs.length);
206
- return toForeignCallResult([
207
- toSingle(txHash.hash),
208
- ...arrayToBoundedVec(toArray(noteHashes), MAX_NOTE_HASHES_PER_TX),
209
- ...arrayToBoundedVec(toArray(nullifiers), MAX_NULLIFIERS_PER_TX),
210
- toArray(rawLogStorage),
211
- toArray(logLengths),
212
- toSingle(logCount)
213
- ]);
197
+ aztec_misc_assertCompatibleOracleVersion(...inputs) {
198
+ return callTxeHandler({
199
+ oracle: 'aztec_misc_assertCompatibleOracleVersion',
200
+ inputs,
201
+ handler: ([major, minor])=>this.handlerAsMisc().assertCompatibleOracleVersion(major, minor)
202
+ });
203
+ }
204
+ // eslint-disable-next-line camelcase
205
+ aztec_misc_getRandomField() {
206
+ return callTxeHandler({
207
+ oracle: 'aztec_misc_getRandomField',
208
+ inputs: [],
209
+ handler: ()=>this.handlerAsMisc().getRandomField()
210
+ });
211
+ }
212
+ // eslint-disable-next-line camelcase
213
+ aztec_txe_getLastBlockTimestamp() {
214
+ return callTxeHandler({
215
+ oracle: 'aztec_txe_getLastBlockTimestamp',
216
+ inputs: [],
217
+ handler: ()=>this.handlerAsTxe().getLastBlockTimestamp()
218
+ });
219
+ }
220
+ // eslint-disable-next-line camelcase
221
+ aztec_txe_getLastTxEffects() {
222
+ return callTxeHandler({
223
+ oracle: 'aztec_txe_getLastTxEffects',
224
+ inputs: [],
225
+ handler: ()=>this.handlerAsTxe().getLastTxEffects()
226
+ });
214
227
  }
215
228
  // eslint-disable-next-line camelcase
216
229
  aztec_txe_getLastCallOffchainEffects() {
217
- const { effects } = this.stateHandler.getLastCallOffchainEffects();
218
- const rawArrayStorage = effects.map((e)=>e.concat(Array(MAX_OFFCHAIN_EFFECT_LEN - e.length).fill(new Fr(0)))).concat(Array(MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY - effects.length).fill(Array(MAX_OFFCHAIN_EFFECT_LEN).fill(new Fr(0)))).flat();
219
- const effectLengths = effects.map((e)=>new Fr(e.length)).concat(Array(MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY - effects.length).fill(new Fr(0)));
220
- const count = new Fr(effects.length);
221
- return toForeignCallResult([
222
- toArray(rawArrayStorage),
223
- toArray(effectLengths),
224
- toSingle(count)
225
- ]);
230
+ return callTxeHandler({
231
+ oracle: 'aztec_txe_getLastCallOffchainEffects',
232
+ inputs: [],
233
+ handler: ()=>this.stateHandler.getLastCallOffchainEffects()
234
+ });
226
235
  }
227
236
  // eslint-disable-next-line camelcase
228
237
  aztec_txe_getLastCallContext() {
229
- const { txHash, anchorBlockTimestamp } = this.stateHandler.getLastCallContext();
230
- const isSome = txHash.isZero() ? 0 : 1;
231
- return toForeignCallResult([
232
- toSingle(isSome),
233
- toSingle(txHash),
234
- toSingle(new Fr(anchorBlockTimestamp))
235
- ]);
236
- }
237
- // eslint-disable-next-line camelcase
238
- async aztec_txe_getPrivateEvents(foreignSelector, foreignContractAddress, foreignScope) {
239
- const selector = EventSelector.fromField(fromSingle(foreignSelector));
240
- const contractAddress = addressFromSingle(foreignContractAddress);
241
- const scope = addressFromSingle(foreignScope);
242
- // TODO(F-335): Avoid doing the following 2 calls here.
243
- {
244
- await this.handlerAsTxe().syncContractNonOracleMethod(contractAddress, scope, this.stateHandler.getCurrentJob());
245
- // We cycle job to commit the stores after the contract sync.
246
- await this.stateHandler.cycleJob();
247
- }
248
- const events = await this.handlerAsTxe().getPrivateEvents(selector, contractAddress, scope);
249
- if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
250
- throw new Error(`Array of length ${events.length} larger than maxLen ${MAX_PRIVATE_EVENTS_PER_TXE_QUERY}`);
251
- }
252
- if (events.some((e)=>e.length > MAX_EVENT_LEN)) {
253
- throw new Error(`Some private event has length larger than maxLen ${MAX_EVENT_LEN}`);
254
- }
255
- // This is a workaround as Noir does not currently let us return nested structs with arrays. We instead return a raw
256
- // multidimensional array in get_private_events_oracle and create the BoundedVecs here.
257
- const rawArrayStorage = events.map((e)=>e.concat(Array(MAX_EVENT_LEN - e.length).fill(new Fr(0)))).concat(Array(MAX_PRIVATE_EVENTS_PER_TXE_QUERY - events.length).fill(Array(MAX_EVENT_LEN).fill(new Fr(0)))).flat();
258
- const eventLengths = events.map((e)=>new Fr(e.length)).concat(Array(MAX_PRIVATE_EVENTS_PER_TXE_QUERY - events.length).fill(new Fr(0)));
259
- const queryLength = new Fr(events.length);
260
- return toForeignCallResult([
261
- toArray(rawArrayStorage),
262
- toArray(eventLengths),
263
- toSingle(queryLength)
264
- ]);
265
- }
266
- // eslint-disable-next-line camelcase
267
- aztec_prv_setHashPreimage(foreignValues, foreignHash) {
268
- const values = fromArray(foreignValues);
269
- const hash = fromSingle(foreignHash);
270
- this.handlerAsPrivate().setHashPreimage(values, hash);
271
- return toForeignCallResult([]);
272
- }
273
- // eslint-disable-next-line camelcase
274
- async aztec_prv_getHashPreimage(foreignHash) {
275
- const hash = fromSingle(foreignHash);
276
- const returns = await this.handlerAsPrivate().getHashPreimage(hash);
277
- return toForeignCallResult([
278
- toArray(returns)
279
- ]);
280
- }
281
- // When the argument is a slice, noir automatically adds a length field to oracle call.
282
- // When the argument is an array, we add the field length manually to the signature.
283
- // eslint-disable-next-line camelcase
284
- async aztec_utl_log(foreignLevel, foreignMessage, _foreignLength, foreignFields) {
285
- const level = fromSingle(foreignLevel).toNumber();
286
- const message = fromArray(foreignMessage).map((field)=>String.fromCharCode(field.toNumber())).join('');
287
- const fields = fromArray(foreignFields);
288
- await this.handlerAsMisc().log(level, message, fields);
289
- return toForeignCallResult([]);
290
- }
291
- // eslint-disable-next-line camelcase
292
- async aztec_utl_getFromPublicStorage(foreignBlockHash, foreignContractAddress, foreignStartStorageSlot, foreignNumberOfElements) {
293
- const blockHash = blockHashFromSingle(foreignBlockHash);
294
- const contractAddress = addressFromSingle(foreignContractAddress);
295
- const startStorageSlot = fromSingle(foreignStartStorageSlot);
296
- const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
297
- const values = await this.handlerAsUtility().getFromPublicStorage(blockHash, contractAddress, startStorageSlot, numberOfElements);
298
- return toForeignCallResult([
299
- toArray(values)
300
- ]);
301
- }
302
- // eslint-disable-next-line camelcase
303
- async aztec_utl_getPublicDataWitness(foreignBlockHash, foreignLeafSlot) {
304
- const blockHash = blockHashFromSingle(foreignBlockHash);
305
- const leafSlot = fromSingle(foreignLeafSlot);
306
- const witness = await this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot);
307
- return toForeignCallResult(witness.toNoirRepresentation());
308
- }
309
- // eslint-disable-next-line camelcase
310
- async aztec_utl_getNotes(foreignOwnerIsSome, foreignOwnerValue, foreignStorageSlot, foreignNumSelects, foreignSelectByIndexes, foreignSelectByOffsets, foreignSelectByLengths, foreignSelectValues, foreignSelectComparators, foreignSortByIndexes, foreignSortByOffsets, foreignSortByLengths, foreignSortOrder, foreignLimit, foreignOffset, foreignStatus, foreignMaxNotes, foreignPackedHintedNoteLength) {
311
- // Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
312
- const owner = fromSingle(foreignOwnerIsSome).toBool() ? Option.some(AztecAddress.fromField(fromSingle(foreignOwnerValue))) : Option.none(AztecAddress.ZERO);
313
- const storageSlot = fromSingle(foreignStorageSlot);
314
- const numSelects = fromSingle(foreignNumSelects).toNumber();
315
- const selectByIndexes = fromArray(foreignSelectByIndexes).map((fr)=>fr.toNumber());
316
- const selectByOffsets = fromArray(foreignSelectByOffsets).map((fr)=>fr.toNumber());
317
- const selectByLengths = fromArray(foreignSelectByLengths).map((fr)=>fr.toNumber());
318
- const selectValues = fromArray(foreignSelectValues);
319
- const selectComparators = fromArray(foreignSelectComparators).map((fr)=>fr.toNumber());
320
- const sortByIndexes = fromArray(foreignSortByIndexes).map((fr)=>fr.toNumber());
321
- const sortByOffsets = fromArray(foreignSortByOffsets).map((fr)=>fr.toNumber());
322
- const sortByLengths = fromArray(foreignSortByLengths).map((fr)=>fr.toNumber());
323
- const sortOrder = fromArray(foreignSortOrder).map((fr)=>fr.toNumber());
324
- const limit = fromSingle(foreignLimit).toNumber();
325
- const offset = fromSingle(foreignOffset).toNumber();
326
- const status = fromSingle(foreignStatus).toNumber();
327
- const maxNotes = fromSingle(foreignMaxNotes).toNumber();
328
- const packedHintedNoteLength = fromSingle(foreignPackedHintedNoteLength).toNumber();
329
- const noteVec = await this.handlerAsUtility().getNotes(owner, storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status, maxNotes, packedHintedNoteLength);
330
- const returnDataAsArrayOfArrays = Array.from(noteVec.data).map((noteData)=>packAsHintedNote({
331
- contractAddress: noteData.contractAddress,
332
- owner: noteData.owner,
333
- randomness: noteData.randomness,
334
- storageSlot: noteData.storageSlot,
335
- noteNonce: noteData.noteNonce,
336
- isPending: noteData.isPending,
337
- note: noteData.note
338
- }));
339
- const returnDataAsArrayOfForeignCallSingleArrays = returnDataAsArrayOfArrays.map((subArray)=>subArray.map(toSingle));
340
- return toForeignCallResult(arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfForeignCallSingleArrays, maxNotes, packedHintedNoteLength));
341
- }
342
- // eslint-disable-next-line camelcase
343
- aztec_prv_notifyCreatedNote(foreignOwner, foreignStorageSlot, foreignRandomness, foreignNoteTypeId, foreignNote, foreignNoteHash, foreignCounter) {
344
- const owner = addressFromSingle(foreignOwner);
345
- const storageSlot = fromSingle(foreignStorageSlot);
346
- const randomness = fromSingle(foreignRandomness);
347
- const noteTypeId = NoteSelector.fromField(fromSingle(foreignNoteTypeId));
348
- const note = fromArray(foreignNote);
349
- const noteHash = fromSingle(foreignNoteHash);
350
- const counter = fromSingle(foreignCounter).toNumber();
351
- this.handlerAsPrivate().notifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter);
352
- return toForeignCallResult([]);
353
- }
354
- // eslint-disable-next-line camelcase
355
- async aztec_prv_notifyNullifiedNote(foreignInnerNullifier, foreignNoteHash, foreignCounter) {
356
- const innerNullifier = fromSingle(foreignInnerNullifier);
357
- const noteHash = fromSingle(foreignNoteHash);
358
- const counter = fromSingle(foreignCounter).toNumber();
359
- await this.handlerAsPrivate().notifyNullifiedNote(innerNullifier, noteHash, counter);
360
- return toForeignCallResult([]);
361
- }
362
- // eslint-disable-next-line camelcase
363
- async aztec_prv_notifyCreatedNullifier(foreignInnerNullifier) {
364
- const innerNullifier = fromSingle(foreignInnerNullifier);
365
- await this.handlerAsPrivate().notifyCreatedNullifier(innerNullifier);
366
- return toForeignCallResult([]);
367
- }
368
- // eslint-disable-next-line camelcase
369
- async aztec_prv_isNullifierPending(foreignInnerNullifier, foreignContractAddress) {
370
- const innerNullifier = fromSingle(foreignInnerNullifier);
371
- const contractAddress = addressFromSingle(foreignContractAddress);
372
- const isPending = await this.handlerAsPrivate().isNullifierPending(innerNullifier, contractAddress);
373
- return toForeignCallResult([
374
- toSingle(new Fr(isPending))
375
- ]);
376
- }
377
- // eslint-disable-next-line camelcase
378
- async aztec_utl_doesNullifierExist(foreignInnerNullifier) {
379
- const innerNullifier = fromSingle(foreignInnerNullifier);
380
- const exists = await this.handlerAsUtility().doesNullifierExist(innerNullifier);
381
- return toForeignCallResult([
382
- toSingle(new Fr(exists))
383
- ]);
384
- }
385
- // eslint-disable-next-line camelcase
386
- async aztec_utl_getContractInstance(foreignAddress) {
387
- const address = addressFromSingle(foreignAddress);
388
- const instance = await this.handlerAsUtility().getContractInstance(address);
389
- return toForeignCallResult([
390
- instance.salt,
391
- instance.deployer.toField(),
392
- instance.currentContractClassId,
393
- instance.initializationHash,
394
- instance.immutablesHash,
395
- ...instance.publicKeys.toFields()
396
- ].map(toSingle));
397
- }
398
- // eslint-disable-next-line camelcase
399
- async aztec_utl_getPublicKeysAndPartialAddress(foreignAddress) {
400
- const address = addressFromSingle(foreignAddress);
401
- const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(address);
402
- // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
403
- // with two fields: `some` (a boolean) and `value` (a field array in this case).
404
- if (!result.isSome()) {
405
- // No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
406
- // Wire shape: [npk_m_hash, ivpk_m.x, ivpk_m.y, ovpk_m_hash, tpk_m_hash, mspk_m_hash, fbpk_m_hash, partial_address] = 8 fields.
407
- return toForeignCallResult([
408
- toSingle(new Fr(0)),
409
- toArray(Array(8).fill(new Fr(0)))
410
- ]);
411
- } else {
412
- // The Noir side hand-decodes a `[Field; 8]` here (see aztec-nr/aztec/src/oracle/keys.nr), so we
413
- // emit the 7-field PublicKeys shape + partial_address explicitly
414
- // rather than going through `publicKeys.toFields()` (which is the struct-flattened 8-field
415
- // wire for oracle returns that decode via struct shape).
416
- const { publicKeys, partialAddress } = result.value;
417
- return toForeignCallResult([
418
- toSingle(new Fr(1)),
419
- toArray([
420
- publicKeys.npkMHash,
421
- publicKeys.ivpkM.x,
422
- publicKeys.ivpkM.y,
423
- publicKeys.ovpkMHash,
424
- publicKeys.tpkMHash,
425
- publicKeys.mspkMHash,
426
- publicKeys.fbpkMHash,
427
- partialAddress
428
- ])
429
- ]);
430
- }
238
+ return callTxeHandler({
239
+ oracle: 'aztec_txe_getLastCallContext',
240
+ inputs: [],
241
+ handler: ()=>this.stateHandler.getLastCallContext()
242
+ });
243
+ }
244
+ // eslint-disable-next-line camelcase
245
+ aztec_txe_getPrivateEvents(...inputs) {
246
+ return callTxeHandler({
247
+ oracle: 'aztec_txe_getPrivateEvents',
248
+ inputs,
249
+ handler: ([selector, contractAddress, scope])=>this.stateHandler.getPrivateEvents(selector, contractAddress, scope)
250
+ });
251
+ }
252
+ // eslint-disable-next-line camelcase
253
+ aztec_prv_setHashPreimage(...inputs) {
254
+ return callTxeHandler({
255
+ oracle: 'aztec_prv_setHashPreimage',
256
+ inputs,
257
+ handler: ([values, hash])=>this.handlerAsPrivate().setHashPreimage(values, hash)
258
+ });
259
+ }
260
+ // eslint-disable-next-line camelcase
261
+ aztec_prv_getHashPreimage(...inputs) {
262
+ return callTxeHandler({
263
+ oracle: 'aztec_prv_getHashPreimage',
264
+ inputs,
265
+ handler: ([hash])=>this.handlerAsPrivate().getHashPreimage(hash)
266
+ });
267
+ }
268
+ // eslint-disable-next-line camelcase
269
+ aztec_misc_log(...inputs) {
270
+ return callTxeHandler({
271
+ oracle: 'aztec_misc_log',
272
+ inputs,
273
+ handler: ([level, message, fieldsSize, fields])=>this.handlerAsMisc().log(level, message, fieldsSize, fields)
274
+ });
275
+ }
276
+ // eslint-disable-next-line camelcase
277
+ aztec_utl_getFromPublicStorage(...inputs) {
278
+ return callTxeHandler({
279
+ oracle: 'aztec_utl_getFromPublicStorage',
280
+ inputs,
281
+ handler: ([blockHash, contractAddress, startStorageSlot, numberOfElements])=>this.handlerAsUtility().getFromPublicStorage(blockHash, contractAddress, startStorageSlot, numberOfElements)
282
+ });
283
+ }
284
+ // eslint-disable-next-line camelcase
285
+ aztec_utl_getPublicDataWitness(...inputs) {
286
+ return callTxeHandler({
287
+ oracle: 'aztec_utl_getPublicDataWitness',
288
+ inputs,
289
+ handler: ([blockHash, leafSlot])=>this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot)
290
+ });
291
+ }
292
+ // eslint-disable-next-line camelcase
293
+ aztec_utl_getNotes(...inputs) {
294
+ return callTxeHandler({
295
+ oracle: 'aztec_utl_getNotes',
296
+ inputs,
297
+ handler: ([owner, storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status, maxNotes, packedHintedNoteLength])=>this.handlerAsUtility().getNotes(owner, storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status, maxNotes, packedHintedNoteLength)
298
+ });
299
+ }
300
+ // eslint-disable-next-line camelcase
301
+ aztec_prv_notifyCreatedNote(...inputs) {
302
+ return callTxeHandler({
303
+ oracle: 'aztec_prv_notifyCreatedNote',
304
+ inputs,
305
+ handler: ([owner, storageSlot, randomness, noteTypeId, note, noteHash, counter])=>this.handlerAsPrivate().notifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter)
306
+ });
307
+ }
308
+ // eslint-disable-next-line camelcase
309
+ aztec_prv_notifyNullifiedNote(...inputs) {
310
+ return callTxeHandler({
311
+ oracle: 'aztec_prv_notifyNullifiedNote',
312
+ inputs,
313
+ handler: ([innerNullifier, noteHash, counter])=>this.handlerAsPrivate().notifyNullifiedNote(innerNullifier, noteHash, counter)
314
+ });
315
+ }
316
+ // eslint-disable-next-line camelcase
317
+ aztec_prv_notifyCreatedNullifier(...inputs) {
318
+ return callTxeHandler({
319
+ oracle: 'aztec_prv_notifyCreatedNullifier',
320
+ inputs,
321
+ handler: ([innerNullifier])=>this.handlerAsPrivate().notifyCreatedNullifier(innerNullifier)
322
+ });
323
+ }
324
+ // eslint-disable-next-line camelcase
325
+ aztec_prv_isNullifierPending(...inputs) {
326
+ return callTxeHandler({
327
+ oracle: 'aztec_prv_isNullifierPending',
328
+ inputs,
329
+ handler: ([innerNullifier, contractAddress])=>this.handlerAsPrivate().isNullifierPending(innerNullifier, contractAddress)
330
+ });
331
+ }
332
+ // eslint-disable-next-line camelcase
333
+ aztec_utl_doesNullifierExist(...inputs) {
334
+ return callTxeHandler({
335
+ oracle: 'aztec_utl_doesNullifierExist',
336
+ inputs,
337
+ handler: ([innerNullifier])=>this.handlerAsUtility().doesNullifierExist(innerNullifier)
338
+ });
339
+ }
340
+ // eslint-disable-next-line camelcase
341
+ aztec_utl_getContractInstance(...inputs) {
342
+ return callTxeHandler({
343
+ oracle: 'aztec_utl_getContractInstance',
344
+ inputs,
345
+ handler: ([address])=>this.handlerAsUtility().getContractInstance(address)
346
+ });
431
347
  }
432
348
  // eslint-disable-next-line camelcase
433
- async aztec_utl_getKeyValidationRequest(foreignPkMHash) {
434
- const pkMHash = fromSingle(foreignPkMHash);
435
- const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(pkMHash);
436
- return toForeignCallResult(keyValidationRequest.toFields().map(toSingle));
349
+ aztec_utl_getPublicKeysAndPartialAddress(...inputs) {
350
+ return callTxeHandler({
351
+ oracle: 'aztec_utl_getPublicKeysAndPartialAddress',
352
+ inputs,
353
+ handler: ([address])=>this.handlerAsUtility().getPublicKeysAndPartialAddress(address)
354
+ });
355
+ }
356
+ // eslint-disable-next-line camelcase
357
+ aztec_utl_getKeyValidationRequest(...inputs) {
358
+ return callTxeHandler({
359
+ oracle: 'aztec_utl_getKeyValidationRequest',
360
+ inputs,
361
+ handler: ([pkMHash, keyIndex])=>this.handlerAsUtility().getKeyValidationRequest(pkMHash, keyIndex)
362
+ });
437
363
  }
438
364
  // eslint-disable-next-line camelcase
439
- async aztec_prv_callPrivateFunction(foreignTargetContractAddress, foreignFunctionSelector, foreignArgsHash, foreignSideEffectCounter, foreignIsStaticCall) {
440
- const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
441
- const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
442
- const argsHash = fromSingle(foreignArgsHash);
443
- const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
444
- const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
445
- const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(targetContractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall);
446
- return toForeignCallResult([
447
- [
448
- endSideEffectCounter,
449
- returnsHash
450
- ].map(toSingle)
451
- ]);
365
+ aztec_prv_callPrivateFunction(...inputs) {
366
+ return callTxeHandler({
367
+ oracle: 'aztec_prv_callPrivateFunction',
368
+ inputs,
369
+ handler: ([contractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall])=>this.handlerAsPrivate().callPrivateFunction(contractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall)
370
+ });
371
+ }
372
+ // eslint-disable-next-line camelcase
373
+ aztec_utl_getNullifierMembershipWitness(...inputs) {
374
+ return callTxeHandler({
375
+ oracle: 'aztec_utl_getNullifierMembershipWitness',
376
+ inputs,
377
+ handler: ([blockHash, nullifier])=>this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier)
378
+ });
452
379
  }
453
380
  // eslint-disable-next-line camelcase
454
- async aztec_utl_getNullifierMembershipWitness(foreignBlockHash, foreignNullifier) {
455
- const blockHash = blockHashFromSingle(foreignBlockHash);
456
- const nullifier = fromSingle(foreignNullifier);
457
- const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
458
- return toForeignCallResult(witness.toNoirRepresentation());
381
+ aztec_utl_getL1ToL2MembershipWitnessV2(...inputs) {
382
+ return callTxeHandler({
383
+ oracle: 'aztec_utl_getL1ToL2MembershipWitnessV2',
384
+ inputs,
385
+ handler: ([messageHash, nullifier])=>this.handlerAsUtility().getL1ToL2MembershipWitnessV2(messageHash, nullifier)
386
+ });
459
387
  }
460
388
  // eslint-disable-next-line camelcase
461
- async aztec_utl_getAuthWitness(foreignMessageHash) {
462
- const messageHash = fromSingle(foreignMessageHash);
463
- const authWitness = await this.handlerAsUtility().getAuthWitness(messageHash);
464
- return toForeignCallResult([
465
- toArray(authWitness)
466
- ]);
389
+ aztec_utl_getAuthWitness(...inputs) {
390
+ return callTxeHandler({
391
+ oracle: 'aztec_utl_getAuthWitness',
392
+ inputs,
393
+ handler: ([messageHash])=>this.handlerAsUtility().getAuthWitness(messageHash)
394
+ });
467
395
  }
468
396
  // eslint-disable-next-line camelcase
469
- async aztec_prv_assertValidPublicCalldata(foreignCalldataHash) {
470
- const calldataHash = fromSingle(foreignCalldataHash);
471
- await this.handlerAsPrivate().assertValidPublicCalldata(calldataHash);
472
- return toForeignCallResult([]);
397
+ aztec_prv_assertValidPublicCalldata(...inputs) {
398
+ return callTxeHandler({
399
+ oracle: 'aztec_prv_assertValidPublicCalldata',
400
+ inputs,
401
+ handler: ([calldataHash])=>this.handlerAsPrivate().assertValidPublicCalldata(calldataHash)
402
+ });
473
403
  }
474
404
  // eslint-disable-next-line camelcase
475
- async aztec_prv_notifyRevertiblePhaseStart(foreignMinRevertibleSideEffectCounter) {
476
- const minRevertibleSideEffectCounter = fromSingle(foreignMinRevertibleSideEffectCounter).toNumber();
477
- await this.handlerAsPrivate().notifyRevertiblePhaseStart(minRevertibleSideEffectCounter);
478
- return toForeignCallResult([]);
405
+ aztec_prv_notifyRevertiblePhaseStart(...inputs) {
406
+ return callTxeHandler({
407
+ oracle: 'aztec_prv_notifyRevertiblePhaseStart',
408
+ inputs,
409
+ handler: ([minRevertibleSideEffectCounter])=>this.handlerAsPrivate().notifyRevertiblePhaseStart(minRevertibleSideEffectCounter)
410
+ });
479
411
  }
480
412
  // eslint-disable-next-line camelcase
481
- async aztec_prv_isExecutionInRevertiblePhase(foreignSideEffectCounter) {
482
- const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
483
- const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(sideEffectCounter);
484
- return toForeignCallResult([
485
- toSingle(new Fr(isRevertible))
486
- ]);
413
+ aztec_prv_isExecutionInRevertiblePhase(...inputs) {
414
+ return callTxeHandler({
415
+ oracle: 'aztec_prv_isExecutionInRevertiblePhase',
416
+ inputs,
417
+ handler: ([sideEffectCounter])=>this.handlerAsPrivate().isExecutionInRevertiblePhase(sideEffectCounter)
418
+ });
487
419
  }
488
420
  // eslint-disable-next-line camelcase
489
421
  aztec_utl_getUtilityContext() {
490
- const context = this.handlerAsUtility().getUtilityContext();
491
- return toForeignCallResult(context.toNoirRepresentation());
492
- }
493
- // eslint-disable-next-line camelcase
494
- async aztec_utl_getBlockHeader(foreignBlockNumber) {
495
- const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
496
- const header = await this.handlerAsUtility().getBlockHeader(blockNumber);
497
- return toForeignCallResult(header.toFields().map(toSingle));
498
- }
499
- // eslint-disable-next-line camelcase
500
- async aztec_utl_getNoteHashMembershipWitness(foreignAnchorBlockHash, foreignNoteHash) {
501
- const blockHash = blockHashFromSingle(foreignAnchorBlockHash);
502
- const noteHash = fromSingle(foreignNoteHash);
503
- const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
504
- return toForeignCallResult(witness.toNoirRepresentation());
505
- }
506
- // eslint-disable-next-line camelcase
507
- async aztec_utl_getBlockHashMembershipWitness(foreignAnchorBlockHash, foreignBlockHash) {
508
- const anchorBlockHash = blockHashFromSingle(foreignAnchorBlockHash);
509
- const blockHash = blockHashFromSingle(foreignBlockHash);
510
- const witnessOpt = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
511
- const effective = witnessOpt.value ?? MembershipWitness.empty(ARCHIVE_HEIGHT);
512
- return toForeignCallResult([
513
- toSingle(new Fr(witnessOpt.isSome() ? 1 : 0)),
514
- ...effective.toNoirRepresentation()
515
- ]);
516
- }
517
- // eslint-disable-next-line camelcase
518
- async aztec_utl_getLowNullifierMembershipWitness(foreignBlockHash, foreignNullifier) {
519
- const blockHash = blockHashFromSingle(foreignBlockHash);
520
- const nullifier = fromSingle(foreignNullifier);
521
- const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
522
- return toForeignCallResult(witness.toNoirRepresentation());
523
- }
524
- // eslint-disable-next-line camelcase
525
- async aztec_utl_getPendingTaggedLogs(foreignScope) {
526
- const scope = AztecAddress.fromField(fromSingle(foreignScope));
527
- const slot = await this.handlerAsUtility().getPendingTaggedLogs(scope);
528
- return toForeignCallResult([
529
- toSingle(slot)
530
- ]);
531
- }
532
- // eslint-disable-next-line camelcase
533
- async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(foreignNoteValidationRequestsArrayBaseSlot, foreignEventValidationRequestsArrayBaseSlot, foreignScope) {
534
- const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
535
- const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
536
- const scope = AztecAddress.fromField(fromSingle(foreignScope));
537
- await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(noteValidationRequestsArrayBaseSlot, eventValidationRequestsArrayBaseSlot, scope);
538
- return toForeignCallResult([]);
539
- }
540
- // eslint-disable-next-line camelcase
541
- async aztec_utl_getLogsByTag(foreignRequestArrayBaseSlot) {
542
- const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
543
- const responseSlot = await this.handlerAsUtility().getLogsByTag(requestArrayBaseSlot);
544
- return toForeignCallResult([
545
- toSingle(responseSlot)
546
- ]);
547
- }
548
- // eslint-disable-next-line camelcase
549
- async aztec_utl_getMessageContextsByTxHash(foreignRequestArrayBaseSlot) {
550
- const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
551
- const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHash(requestArrayBaseSlot);
552
- return toForeignCallResult([
553
- toSingle(responseSlot)
554
- ]);
555
- }
556
- // eslint-disable-next-line camelcase
557
- aztec_utl_setCapsule(foreignContractAddress, foreignSlot, foreignCapsule, foreignScope) {
558
- const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
559
- const slot = fromSingle(foreignSlot);
560
- const capsule = fromArray(foreignCapsule);
561
- const scope = AztecAddress.fromField(fromSingle(foreignScope));
562
- this.handlerAsUtility().setCapsule(contractAddress, slot, capsule, scope);
563
- return toForeignCallResult([]);
564
- }
565
- // eslint-disable-next-line camelcase
566
- async aztec_utl_getCapsule(foreignContractAddress, foreignSlot, foreignTSize, foreignScope) {
567
- const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
568
- const slot = fromSingle(foreignSlot);
569
- const tSize = fromSingle(foreignTSize).toNumber();
570
- const scope = AztecAddress.fromField(fromSingle(foreignScope));
571
- const opt = await this.handlerAsUtility().getCapsule(contractAddress, slot, tSize, scope);
572
- // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
573
- // with two fields: `some` (a boolean) and `value` (a field array in this case).
574
- if (opt.isSome()) {
575
- // Data was found so we set `some` to 1 and return it along with `value`.
576
- return toForeignCallResult([
577
- toSingle(new Fr(1)),
578
- toArray(Array.from(opt.value))
579
- ]);
580
- } else {
581
- // No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
582
- return toForeignCallResult([
583
- toSingle(new Fr(0)),
584
- toArray(Array(tSize).fill(new Fr(0)))
585
- ]);
586
- }
422
+ return callTxeHandler({
423
+ oracle: 'aztec_utl_getUtilityContext',
424
+ inputs: [],
425
+ handler: ()=>this.handlerAsUtility().getUtilityContext()
426
+ });
427
+ }
428
+ // eslint-disable-next-line camelcase
429
+ aztec_utl_getBlockHeader(...inputs) {
430
+ return callTxeHandler({
431
+ oracle: 'aztec_utl_getBlockHeader',
432
+ inputs,
433
+ handler: ([blockNumber])=>this.handlerAsUtility().getBlockHeader(blockNumber)
434
+ });
435
+ }
436
+ // eslint-disable-next-line camelcase
437
+ aztec_utl_getNoteHashMembershipWitness(...inputs) {
438
+ return callTxeHandler({
439
+ oracle: 'aztec_utl_getNoteHashMembershipWitness',
440
+ inputs,
441
+ handler: ([blockHash, noteHash])=>this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash)
442
+ });
443
+ }
444
+ // eslint-disable-next-line camelcase
445
+ aztec_utl_getBlockHashMembershipWitness(...inputs) {
446
+ return callTxeHandler({
447
+ oracle: 'aztec_utl_getBlockHashMembershipWitness',
448
+ inputs,
449
+ handler: ([anchorBlockHash, blockHash])=>this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash)
450
+ });
451
+ }
452
+ // eslint-disable-next-line camelcase
453
+ aztec_utl_areBlockHashesInArchive(...inputs) {
454
+ return callTxeHandler({
455
+ oracle: 'aztec_utl_areBlockHashesInArchive',
456
+ inputs,
457
+ handler: ([anchorBlockHash, blockHashes])=>this.handlerAsUtility().areBlockHashesInArchive(anchorBlockHash, blockHashes)
458
+ });
459
+ }
460
+ // eslint-disable-next-line camelcase
461
+ aztec_utl_getLowNullifierMembershipWitness(...inputs) {
462
+ return callTxeHandler({
463
+ oracle: 'aztec_utl_getLowNullifierMembershipWitness',
464
+ inputs,
465
+ handler: ([blockHash, nullifier])=>this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier)
466
+ });
467
+ }
468
+ // eslint-disable-next-line camelcase
469
+ aztec_utl_getPendingTaggedLogsV2(...inputs) {
470
+ return callTxeHandler({
471
+ oracle: 'aztec_utl_getPendingTaggedLogsV2',
472
+ inputs,
473
+ handler: ([scope, providedSecrets])=>this.handlerAsUtility().getPendingTaggedLogsV2(scope, providedSecrets)
474
+ });
475
+ }
476
+ // eslint-disable-next-line camelcase
477
+ aztec_utl_validateAndStoreEnqueuedNotesAndEvents(...inputs) {
478
+ return callTxeHandler({
479
+ oracle: 'aztec_utl_validateAndStoreEnqueuedNotesAndEvents',
480
+ inputs,
481
+ handler: ([noteValidationRequests, eventValidationRequests, scope])=>this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(noteValidationRequests, eventValidationRequests, scope)
482
+ });
483
+ }
484
+ // eslint-disable-next-line camelcase
485
+ aztec_utl_getLogsByTagV2(...inputs) {
486
+ return callTxeHandler({
487
+ oracle: 'aztec_utl_getLogsByTagV2',
488
+ inputs,
489
+ handler: ([requestArrayBaseSlot])=>this.handlerAsUtility().getLogsByTagV2(requestArrayBaseSlot)
490
+ });
491
+ }
492
+ // eslint-disable-next-line camelcase
493
+ aztec_utl_getResolvedTxs(...inputs) {
494
+ return callTxeHandler({
495
+ oracle: 'aztec_utl_getResolvedTxs',
496
+ inputs,
497
+ handler: ([requestArrayBaseSlot])=>this.handlerAsUtility().getResolvedTxs(requestArrayBaseSlot)
498
+ });
499
+ }
500
+ // eslint-disable-next-line camelcase
501
+ aztec_utl_getTxEffects(...inputs) {
502
+ return callTxeHandler({
503
+ oracle: 'aztec_utl_getTxEffects',
504
+ inputs,
505
+ handler: ([txHashes])=>this.handlerAsUtility().getTxEffects(txHashes)
506
+ });
507
+ }
508
+ // eslint-disable-next-line camelcase
509
+ aztec_utl_setCapsule(...inputs) {
510
+ return callTxeHandler({
511
+ oracle: 'aztec_utl_setCapsule',
512
+ inputs,
513
+ handler: ([contractAddress, slot, capsule, scope])=>this.handlerAsUtility().setCapsule(contractAddress, slot, capsule, scope)
514
+ });
515
+ }
516
+ // eslint-disable-next-line camelcase
517
+ aztec_utl_getCapsule(...inputs) {
518
+ return callTxeHandler({
519
+ oracle: 'aztec_utl_getCapsule',
520
+ inputs,
521
+ handler: ([contractAddress, slot, tSize, scope])=>this.handlerAsUtility().getCapsule(contractAddress, slot, tSize, scope)
522
+ });
523
+ }
524
+ // eslint-disable-next-line camelcase
525
+ aztec_utl_deleteCapsule(...inputs) {
526
+ return callTxeHandler({
527
+ oracle: 'aztec_utl_deleteCapsule',
528
+ inputs,
529
+ handler: ([contractAddress, slot, scope])=>this.handlerAsUtility().deleteCapsule(contractAddress, slot, scope)
530
+ });
531
+ }
532
+ // eslint-disable-next-line camelcase
533
+ aztec_utl_copyCapsule(...inputs) {
534
+ return callTxeHandler({
535
+ oracle: 'aztec_utl_copyCapsule',
536
+ inputs,
537
+ handler: ([contractAddress, srcSlot, dstSlot, numEntries, scope])=>this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope)
538
+ });
539
+ }
540
+ // eslint-disable-next-line camelcase
541
+ aztec_utl_pushEphemeral(...inputs) {
542
+ return callTxeHandler({
543
+ oracle: 'aztec_utl_pushEphemeral',
544
+ inputs,
545
+ handler: ([slot, elements])=>this.handlerAsUtility().pushEphemeral(slot, elements)
546
+ });
547
+ }
548
+ // eslint-disable-next-line camelcase
549
+ aztec_utl_popEphemeral(...inputs) {
550
+ return callTxeHandler({
551
+ oracle: 'aztec_utl_popEphemeral',
552
+ inputs,
553
+ handler: ([slot])=>this.handlerAsUtility().popEphemeral(slot)
554
+ });
587
555
  }
588
556
  // eslint-disable-next-line camelcase
589
- aztec_utl_deleteCapsule(foreignContractAddress, foreignSlot, foreignScope) {
590
- const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
591
- const slot = fromSingle(foreignSlot);
592
- const scope = AztecAddress.fromField(fromSingle(foreignScope));
593
- this.handlerAsUtility().deleteCapsule(contractAddress, slot, scope);
594
- return toForeignCallResult([]);
557
+ aztec_utl_getEphemeral(...inputs) {
558
+ return callTxeHandler({
559
+ oracle: 'aztec_utl_getEphemeral',
560
+ inputs,
561
+ handler: ([slot, index])=>this.handlerAsUtility().getEphemeral(slot, index)
562
+ });
563
+ }
564
+ // eslint-disable-next-line camelcase
565
+ aztec_utl_setEphemeral(...inputs) {
566
+ return callTxeHandler({
567
+ oracle: 'aztec_utl_setEphemeral',
568
+ inputs,
569
+ handler: ([slot, index, elements])=>this.handlerAsUtility().setEphemeral(slot, index, elements)
570
+ });
595
571
  }
596
572
  // eslint-disable-next-line camelcase
597
- async aztec_utl_copyCapsule(foreignContractAddress, foreignSrcSlot, foreignDstSlot, foreignNumEntries, foreignScope) {
598
- const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
599
- const srcSlot = fromSingle(foreignSrcSlot);
600
- const dstSlot = fromSingle(foreignDstSlot);
601
- const numEntries = fromSingle(foreignNumEntries).toNumber();
602
- const scope = AztecAddress.fromField(fromSingle(foreignScope));
603
- await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope);
604
- return toForeignCallResult([]);
573
+ aztec_utl_getEphemeralLen(...inputs) {
574
+ return callTxeHandler({
575
+ oracle: 'aztec_utl_getEphemeralLen',
576
+ inputs,
577
+ handler: ([slot])=>this.handlerAsUtility().getEphemeralLen(slot)
578
+ });
579
+ }
580
+ // eslint-disable-next-line camelcase
581
+ aztec_utl_removeEphemeral(...inputs) {
582
+ return callTxeHandler({
583
+ oracle: 'aztec_utl_removeEphemeral',
584
+ inputs,
585
+ handler: ([slot, index])=>this.handlerAsUtility().removeEphemeral(slot, index)
586
+ });
605
587
  }
606
588
  // eslint-disable-next-line camelcase
607
- aztec_utl_pushEphemeral(foreignSlot, foreignElements) {
608
- const slot = fromSingle(foreignSlot);
609
- const elements = fromArray(foreignElements);
610
- const newLen = this.handlerAsUtility().pushEphemeral(slot, elements);
611
- return toForeignCallResult([
612
- toSingle(new Fr(newLen))
613
- ]);
589
+ aztec_utl_clearEphemeral(...inputs) {
590
+ return callTxeHandler({
591
+ oracle: 'aztec_utl_clearEphemeral',
592
+ inputs,
593
+ handler: ([slot])=>this.handlerAsUtility().clearEphemeral(slot)
594
+ });
614
595
  }
615
596
  // eslint-disable-next-line camelcase
616
- aztec_utl_popEphemeral(foreignSlot) {
617
- const slot = fromSingle(foreignSlot);
618
- const element = this.handlerAsUtility().popEphemeral(slot);
619
- return toForeignCallResult([
620
- toArray(element)
621
- ]);
597
+ aztec_utl_pushTransient(...inputs) {
598
+ return callTxeHandler({
599
+ oracle: 'aztec_utl_pushTransient',
600
+ inputs,
601
+ handler: ([slot, elements])=>this.handlerAsUtility().pushTransient(slot, elements)
602
+ });
622
603
  }
623
604
  // eslint-disable-next-line camelcase
624
- aztec_utl_getEphemeral(foreignSlot, foreignIndex) {
625
- const slot = fromSingle(foreignSlot);
626
- const index = fromSingle(foreignIndex).toNumber();
627
- const element = this.handlerAsUtility().getEphemeral(slot, index);
628
- return toForeignCallResult([
629
- toArray(element)
630
- ]);
605
+ aztec_utl_popTransient(...inputs) {
606
+ return callTxeHandler({
607
+ oracle: 'aztec_utl_popTransient',
608
+ inputs,
609
+ handler: ([slot])=>this.handlerAsUtility().popTransient(slot)
610
+ });
631
611
  }
632
612
  // eslint-disable-next-line camelcase
633
- aztec_utl_setEphemeral(foreignSlot, foreignIndex, foreignElements) {
634
- const slot = fromSingle(foreignSlot);
635
- const index = fromSingle(foreignIndex).toNumber();
636
- const elements = fromArray(foreignElements);
637
- this.handlerAsUtility().setEphemeral(slot, index, elements);
638
- return toForeignCallResult([]);
613
+ aztec_utl_getTransient(...inputs) {
614
+ return callTxeHandler({
615
+ oracle: 'aztec_utl_getTransient',
616
+ inputs,
617
+ handler: ([slot, index])=>this.handlerAsUtility().getTransient(slot, index)
618
+ });
639
619
  }
640
620
  // eslint-disable-next-line camelcase
641
- aztec_utl_getEphemeralLen(foreignSlot) {
642
- const slot = fromSingle(foreignSlot);
643
- const len = this.handlerAsUtility().getEphemeralLen(slot);
644
- return toForeignCallResult([
645
- toSingle(new Fr(len))
646
- ]);
621
+ aztec_utl_setTransient(...inputs) {
622
+ return callTxeHandler({
623
+ oracle: 'aztec_utl_setTransient',
624
+ inputs,
625
+ handler: ([slot, index, elements])=>this.handlerAsUtility().setTransient(slot, index, elements)
626
+ });
647
627
  }
648
628
  // eslint-disable-next-line camelcase
649
- aztec_utl_removeEphemeral(foreignSlot, foreignIndex) {
650
- const slot = fromSingle(foreignSlot);
651
- const index = fromSingle(foreignIndex).toNumber();
652
- this.handlerAsUtility().removeEphemeral(slot, index);
653
- return toForeignCallResult([]);
629
+ aztec_utl_getTransientLen(...inputs) {
630
+ return callTxeHandler({
631
+ oracle: 'aztec_utl_getTransientLen',
632
+ inputs,
633
+ handler: ([slot])=>this.handlerAsUtility().getTransientLen(slot)
634
+ });
654
635
  }
655
636
  // eslint-disable-next-line camelcase
656
- aztec_utl_clearEphemeral(foreignSlot) {
657
- const slot = fromSingle(foreignSlot);
658
- this.handlerAsUtility().clearEphemeral(slot);
659
- return toForeignCallResult([]);
637
+ aztec_utl_removeTransient(...inputs) {
638
+ return callTxeHandler({
639
+ oracle: 'aztec_utl_removeTransient',
640
+ inputs,
641
+ handler: ([slot, index])=>this.handlerAsUtility().removeTransient(slot, index)
642
+ });
643
+ }
644
+ // eslint-disable-next-line camelcase
645
+ aztec_utl_clearTransient(...inputs) {
646
+ return callTxeHandler({
647
+ oracle: 'aztec_utl_clearTransient',
648
+ inputs,
649
+ handler: ([slot])=>this.handlerAsUtility().clearTransient(slot)
650
+ });
660
651
  }
661
652
  // TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
662
653
  // The compiler didn't throw an error, so it took me a while to learn of the existence of this file, and that I need
663
654
  // to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
664
655
  // existence of a txe_oracle method?
665
656
  // eslint-disable-next-line camelcase
666
- async aztec_utl_decryptAes128(foreignCiphertextBVecStorage, foreignCiphertextLength, foreignIv, foreignSymKey) {
667
- const capacity = foreignCiphertextBVecStorage.length;
668
- const ciphertextBuf = fromUintBoundedVec(foreignCiphertextBVecStorage, foreignCiphertextLength, 8);
669
- const ciphertext = BoundedVec.from({
670
- data: [
671
- ...ciphertextBuf
672
- ],
673
- maxLength: capacity
674
- });
675
- const iv = fromUintArray(foreignIv, 8);
676
- const symKey = fromUintArray(foreignSymKey, 8);
677
- // Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
678
- const plaintextOpt = await this.handlerAsUtility().decryptAes128(ciphertext, iv, symKey);
679
- if (plaintextOpt.isSome()) {
680
- const [storage, length] = arrayToBoundedVec(bufferToU8Array(Buffer.from(plaintextOpt.value.data)), capacity);
681
- return toForeignCallResult([
682
- toSingle(new Fr(1)),
683
- storage,
684
- length
685
- ]);
686
- } else {
687
- const zeroStorage = toArray(Array(capacity).fill(new Fr(0)));
688
- return toForeignCallResult([
689
- toSingle(new Fr(0)),
690
- zeroStorage,
691
- toSingle(new Fr(0))
692
- ]);
693
- }
657
+ aztec_utl_decryptAes128(...inputs) {
658
+ return callTxeHandler({
659
+ oracle: 'aztec_utl_decryptAes128',
660
+ inputs,
661
+ handler: ([ciphertext, iv, symKey])=>this.handlerAsUtility().decryptAes128(ciphertext, iv, symKey)
662
+ });
663
+ }
664
+ // eslint-disable-next-line camelcase
665
+ aztec_utl_getSharedSecrets(...inputs) {
666
+ return callTxeHandler({
667
+ oracle: 'aztec_utl_getSharedSecrets',
668
+ inputs,
669
+ handler: ([address, ephPksSlot, contractAddress])=>this.handlerAsUtility().getSharedSecrets(address, ephPksSlot, contractAddress)
670
+ });
671
+ }
672
+ // eslint-disable-next-line camelcase
673
+ aztec_utl_setContractSyncCacheInvalid(...inputs) {
674
+ return callTxeHandler({
675
+ oracle: 'aztec_utl_setContractSyncCacheInvalid',
676
+ inputs,
677
+ handler: ([contractAddress, scopes])=>this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes)
678
+ });
694
679
  }
695
680
  // eslint-disable-next-line camelcase
696
- async aztec_utl_getSharedSecrets(foreignAddress, foreignEphPksSlot, foreignContractAddress) {
697
- const address = AztecAddress.fromField(fromSingle(foreignAddress));
698
- const ephPksSlot = fromSingle(foreignEphPksSlot);
699
- const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
700
- const responseSlot = await this.handlerAsUtility().getSharedSecrets(address, ephPksSlot, contractAddress);
701
- return toForeignCallResult([
702
- toSingle(responseSlot)
703
- ]);
681
+ aztec_utl_emitOffchainEffect(...inputs) {
682
+ return callTxeHandler({
683
+ oracle: 'aztec_utl_emitOffchainEffect',
684
+ inputs,
685
+ handler: ([data])=>{
686
+ // Record the raw payload against the currently-executing top-level call. The Noir side
687
+ // (via `env.offchain_messages()`) is responsible for decoding the protocol-reserved prefix
688
+ // (`OFFCHAIN_MESSAGE_IDENTIFIER`, recipient) and turning each payload into an `OffchainMessage` struct suitable
689
+ // for `offchain_receive`.
690
+ this.stateHandler.recordOffchainEffect(data);
691
+ }
692
+ });
704
693
  }
705
694
  // eslint-disable-next-line camelcase
706
- aztec_utl_setContractSyncCacheInvalid(foreignContractAddress, foreignScopes, foreignScopeCount) {
707
- const contractAddress = addressFromSingle(foreignContractAddress);
708
- const allFields = fromArray(foreignScopes);
709
- const count = fromSingle(foreignScopeCount).toNumber();
710
- const scopes = BoundedVec.from({
711
- data: allFields.slice(0, count).map((f)=>new AztecAddress(f)),
712
- maxLength: allFields.length
695
+ aztec_utl_recordFact(...inputs) {
696
+ return callTxeHandler({
697
+ oracle: 'aztec_utl_recordFact',
698
+ inputs,
699
+ handler: ([contractAddress, scope, factCollectionTypeId, factCollectionId, factTypeId, payload, originBlock])=>this.handlerAsUtility().recordFact(contractAddress, scope, factCollectionTypeId, factCollectionId, factTypeId, payload, originBlock)
713
700
  });
714
- this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes);
715
- return Promise.resolve(toForeignCallResult([]));
716
701
  }
717
702
  // eslint-disable-next-line camelcase
718
- aztec_utl_emitOffchainEffect(foreignData) {
719
- // Record the raw payload against the currently-executing top-level call. The Noir side
720
- // (via `env.offchain_messages()`) is responsible for decoding the protocol-reserved prefix
721
- // (`OFFCHAIN_MESSAGE_IDENTIFIER`, recipient) and turning each payload into an `OffchainMessage` struct suitable
722
- // for `offchain_receive`.
723
- this.stateHandler.recordOffchainEffect(fromArray(foreignData));
724
- return Promise.resolve(toForeignCallResult([]));
703
+ aztec_utl_deleteFactCollection(...inputs) {
704
+ return callTxeHandler({
705
+ oracle: 'aztec_utl_deleteFactCollection',
706
+ inputs,
707
+ handler: ([contractAddress, scope, factCollectionTypeId, factCollectionId])=>this.handlerAsUtility().deleteFactCollection(contractAddress, scope, factCollectionTypeId, factCollectionId)
708
+ });
709
+ }
710
+ // eslint-disable-next-line camelcase
711
+ aztec_utl_getFactCollection(...inputs) {
712
+ return callTxeHandler({
713
+ oracle: 'aztec_utl_getFactCollection',
714
+ inputs,
715
+ handler: ([contractAddress, scope, factCollectionTypeId, factCollectionId])=>this.handlerAsUtility().getFactCollection(contractAddress, scope, factCollectionTypeId, factCollectionId)
716
+ });
717
+ }
718
+ // eslint-disable-next-line camelcase
719
+ aztec_utl_getFactCollectionsByType(...inputs) {
720
+ return callTxeHandler({
721
+ oracle: 'aztec_utl_getFactCollectionsByType',
722
+ inputs,
723
+ handler: ([contractAddress, scope, factCollectionTypeId])=>this.handlerAsUtility().getFactCollectionsByType(contractAddress, scope, factCollectionTypeId)
724
+ });
725
+ }
726
+ // eslint-disable-next-line camelcase
727
+ aztec_utl_callUtilityFunction(...inputs) {
728
+ return callTxeHandler({
729
+ oracle: 'aztec_utl_callUtilityFunction',
730
+ inputs,
731
+ handler: ([contractAddress, functionSelector, args])=>this.handlerAsUtility().callUtilityFunction(contractAddress, functionSelector, args)
732
+ });
725
733
  }
726
734
  // AVM opcodes
727
735
  // eslint-disable-next-line camelcase
728
- aztec_avm_emitPublicLog(_foreignMessage) {
729
- // TODO(#8811): Implement
730
- return toForeignCallResult([]);
736
+ aztec_avm_emitPublicLog() {
737
+ return callTxeHandler({
738
+ oracle: 'aztec_avm_emitPublicLog',
739
+ inputs: [],
740
+ // TODO(#8811): Implement
741
+ handler: ()=>{}
742
+ });
743
+ }
744
+ // eslint-disable-next-line camelcase
745
+ aztec_avm_storageRead(...inputs) {
746
+ return callTxeHandler({
747
+ oracle: 'aztec_avm_storageRead',
748
+ inputs,
749
+ handler: ([slot, contractAddress])=>this.handlerAsAvm().storageRead(slot, contractAddress)
750
+ });
751
+ }
752
+ // eslint-disable-next-line camelcase
753
+ aztec_avm_storageWrite(...inputs) {
754
+ return callTxeHandler({
755
+ oracle: 'aztec_avm_storageWrite',
756
+ inputs,
757
+ handler: ([slot, value])=>this.handlerAsAvm().storageWrite(slot, value)
758
+ });
759
+ }
760
+ // eslint-disable-next-line camelcase
761
+ aztec_avm_getContractInstanceDeployer(...inputs) {
762
+ return callTxeHandler({
763
+ oracle: 'aztec_avm_getContractInstanceDeployer',
764
+ inputs,
765
+ handler: ([address])=>this.handlerAsAvm().getContractInstanceDeployer(address)
766
+ });
731
767
  }
732
768
  // eslint-disable-next-line camelcase
733
- async aztec_avm_storageRead(foreignSlot, foreignContractAddress) {
734
- const slot = fromSingle(foreignSlot);
735
- const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
736
- const value = (await this.handlerAsAvm().storageRead(slot, contractAddress)).value;
737
- return toForeignCallResult([
738
- toSingle(new Fr(value))
739
- ]);
769
+ aztec_avm_getContractInstanceClassId(...inputs) {
770
+ return callTxeHandler({
771
+ oracle: 'aztec_avm_getContractInstanceClassId',
772
+ inputs,
773
+ handler: ([address])=>this.handlerAsAvm().getContractInstanceClassId(address)
774
+ });
740
775
  }
741
776
  // eslint-disable-next-line camelcase
742
- async aztec_avm_storageWrite(foreignSlot, foreignValue) {
743
- const slot = fromSingle(foreignSlot);
744
- const value = fromSingle(foreignValue);
745
- await this.handlerAsAvm().storageWrite(slot, value);
746
- return toForeignCallResult([]);
777
+ aztec_avm_getContractInstanceInitializationHash(...inputs) {
778
+ return callTxeHandler({
779
+ oracle: 'aztec_avm_getContractInstanceInitializationHash',
780
+ inputs,
781
+ handler: ([address])=>this.handlerAsAvm().getContractInstanceInitializationHash(address)
782
+ });
747
783
  }
748
784
  // eslint-disable-next-line camelcase
749
- async aztec_avm_getContractInstanceDeployer(foreignAddress) {
750
- const address = addressFromSingle(foreignAddress);
751
- const instance = await this.handlerAsUtility().getContractInstance(address);
752
- return toForeignCallResult([
753
- toSingle(instance.deployer),
754
- // AVM requires an extra boolean indicating the instance was found
755
- toSingle(new Fr(1))
756
- ]);
785
+ aztec_avm_getContractInstanceImmutablesHash(...inputs) {
786
+ return callTxeHandler({
787
+ oracle: 'aztec_avm_getContractInstanceImmutablesHash',
788
+ inputs,
789
+ handler: ([address])=>this.handlerAsAvm().getContractInstanceImmutablesHash(address)
790
+ });
757
791
  }
758
792
  // eslint-disable-next-line camelcase
759
- async aztec_avm_getContractInstanceClassId(foreignAddress) {
760
- const address = addressFromSingle(foreignAddress);
761
- const instance = await this.handlerAsUtility().getContractInstance(address);
762
- return toForeignCallResult([
763
- toSingle(instance.currentContractClassId),
764
- // AVM requires an extra boolean indicating the instance was found
765
- toSingle(new Fr(1))
766
- ]);
793
+ aztec_avm_sender() {
794
+ return callTxeHandler({
795
+ oracle: 'aztec_avm_sender',
796
+ inputs: [],
797
+ handler: ()=>this.handlerAsAvm().sender()
798
+ });
767
799
  }
768
800
  // eslint-disable-next-line camelcase
769
- async aztec_avm_getContractInstanceInitializationHash(foreignAddress) {
770
- const address = addressFromSingle(foreignAddress);
771
- const instance = await this.handlerAsUtility().getContractInstance(address);
772
- return toForeignCallResult([
773
- toSingle(instance.initializationHash),
774
- // AVM requires an extra boolean indicating the instance was found
775
- toSingle(new Fr(1))
776
- ]);
801
+ aztec_avm_emitNullifier(...inputs) {
802
+ return callTxeHandler({
803
+ oracle: 'aztec_avm_emitNullifier',
804
+ inputs,
805
+ handler: ([nullifier])=>this.handlerAsAvm().emitNullifier(nullifier)
806
+ });
777
807
  }
778
808
  // eslint-disable-next-line camelcase
779
- async aztec_avm_getContractInstanceImmutablesHash(foreignAddress) {
780
- const address = addressFromSingle(foreignAddress);
781
- const instance = await this.handlerAsUtility().getContractInstance(address);
782
- return toForeignCallResult([
783
- toSingle(instance.immutablesHash),
784
- // AVM requires an extra boolean indicating the instance was found
785
- toSingle(new Fr(1))
786
- ]);
809
+ aztec_avm_emitNoteHash(...inputs) {
810
+ return callTxeHandler({
811
+ oracle: 'aztec_avm_emitNoteHash',
812
+ inputs,
813
+ handler: ([noteHash])=>this.handlerAsAvm().emitNoteHash(noteHash)
814
+ });
787
815
  }
788
816
  // eslint-disable-next-line camelcase
789
- async aztec_avm_sender() {
790
- const sender = await this.handlerAsAvm().sender();
791
- return toForeignCallResult([
792
- toSingle(sender)
793
- ]);
794
- }
795
- // eslint-disable-next-line camelcase
796
- async aztec_avm_emitNullifier(foreignNullifier) {
797
- const nullifier = fromSingle(foreignNullifier);
798
- await this.handlerAsAvm().emitNullifier(nullifier);
799
- return toForeignCallResult([]);
817
+ aztec_avm_nullifierExists(...inputs) {
818
+ return callTxeHandler({
819
+ oracle: 'aztec_avm_nullifierExists',
820
+ inputs,
821
+ handler: ([siloedNullifier])=>this.handlerAsAvm().nullifierExists(siloedNullifier)
822
+ });
800
823
  }
801
824
  // eslint-disable-next-line camelcase
802
- async aztec_avm_emitNoteHash(foreignNoteHash) {
803
- const noteHash = fromSingle(foreignNoteHash);
804
- await this.handlerAsAvm().emitNoteHash(noteHash);
805
- return toForeignCallResult([]);
825
+ aztec_avm_address() {
826
+ return callTxeHandler({
827
+ oracle: 'aztec_avm_address',
828
+ inputs: [],
829
+ handler: ()=>this.handlerAsAvm().address()
830
+ });
806
831
  }
807
832
  // eslint-disable-next-line camelcase
808
- async aztec_avm_nullifierExists(foreignSiloedNullifier) {
809
- const siloedNullifier = fromSingle(foreignSiloedNullifier);
810
- const exists = await this.handlerAsAvm().nullifierExists(siloedNullifier);
811
- return toForeignCallResult([
812
- toSingle(new Fr(exists))
813
- ]);
814
- }
815
- // eslint-disable-next-line camelcase
816
- async aztec_avm_address() {
817
- const contractAddress = await this.handlerAsAvm().address();
818
- return toForeignCallResult([
819
- toSingle(contractAddress.toField())
820
- ]);
821
- }
822
- // eslint-disable-next-line camelcase
823
- async aztec_avm_blockNumber() {
824
- const blockNumber = await this.handlerAsAvm().blockNumber();
825
- return toForeignCallResult([
826
- toSingle(new Fr(blockNumber))
827
- ]);
828
- }
829
- // eslint-disable-next-line camelcase
830
- async aztec_avm_timestamp() {
831
- const timestamp = await this.handlerAsAvm().timestamp();
832
- return toForeignCallResult([
833
- toSingle(new Fr(timestamp))
834
- ]);
835
- }
836
- // eslint-disable-next-line camelcase
837
- async aztec_avm_isStaticCall() {
838
- const isStaticCall = await this.handlerAsAvm().isStaticCall();
839
- return toForeignCallResult([
840
- toSingle(new Fr(isStaticCall ? 1 : 0))
841
- ]);
842
- }
843
- // eslint-disable-next-line camelcase
844
- async aztec_avm_chainId() {
845
- const chainId = await this.handlerAsAvm().chainId();
846
- return toForeignCallResult([
847
- toSingle(chainId)
848
- ]);
849
- }
850
- // eslint-disable-next-line camelcase
851
- async aztec_avm_version() {
852
- const version = await this.handlerAsAvm().version();
853
- return toForeignCallResult([
854
- toSingle(version)
855
- ]);
856
- }
857
- // eslint-disable-next-line camelcase
858
- async aztec_avm_returndataSize() {
859
- const result = await this.handlerAsAvm().returndataSize();
860
- return toForeignCallResult([
861
- toSingle(result)
862
- ]);
863
- }
864
- // eslint-disable-next-line camelcase
865
- async aztec_avm_returndataCopy(foreignRdOffset, foreignCopySize) {
866
- const rdOffset = fromSingle(foreignRdOffset).toNumber();
867
- const copySize = fromSingle(foreignCopySize).toNumber();
868
- const result = await this.handlerAsAvm().returndataCopy(rdOffset, copySize);
869
- return toForeignCallResult([
870
- toArray(result)
871
- ]);
872
- }
873
- // eslint-disable-next-line camelcase
874
- async aztec_avm_call(foreignL2Gas, foreignDaGas, foreignAddress, foreignLength, foreignArgs) {
875
- const l2Gas = fromSingle(foreignL2Gas).toNumber();
876
- const daGas = fromSingle(foreignDaGas).toNumber();
877
- const address = addressFromSingle(foreignAddress);
878
- const argsLength = fromSingle(foreignLength).toNumber();
879
- const args = fromArray(foreignArgs);
880
- const result = await this.handlerAsAvm().call(l2Gas, daGas, address, argsLength, args);
881
- return toForeignCallResult([
882
- toArray(result)
883
- ]);
884
- }
885
- // eslint-disable-next-line camelcase
886
- async aztec_avm_staticCall(foreignL2Gas, foreignDaGas, foreignAddress, foreignLength, foreignArgs) {
887
- const l2Gas = fromSingle(foreignL2Gas).toNumber();
888
- const daGas = fromSingle(foreignDaGas).toNumber();
889
- const address = addressFromSingle(foreignAddress);
890
- const argsLength = fromSingle(foreignLength).toNumber();
891
- const args = fromArray(foreignArgs);
892
- const result = await this.handlerAsAvm().staticCall(l2Gas, daGas, address, argsLength, args);
893
- return toForeignCallResult([
894
- toArray(result)
895
- ]);
896
- }
897
- // eslint-disable-next-line camelcase
898
- async aztec_avm_successCopy() {
899
- const result = await this.handlerAsAvm().successCopy();
900
- return toForeignCallResult([
901
- toSingle(result)
902
- ]);
903
- }
904
- // TODO(F-674): Move orchestration logic into the handler so the transport layer is pure serialize→delegate→deserialize.
905
- // eslint-disable-next-line camelcase
906
- async aztec_txe_privateCallNewFlow(foreignFromIsSome, foreignFromValue, foreignTargetContractAddress, foreignFunctionSelector, foreignArgs, foreignArgsHash, foreignIsStaticCall, foreignAdditionalScopes, foreignAuthorizedUtilityCallTargets, foreignGasSettings) {
907
- const from = fromSingle(foreignFromIsSome).toBool() ? addressFromSingle(foreignFromValue) : undefined;
908
- const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
909
- const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
910
- const args = fromArray(foreignArgs);
911
- const argsHash = fromSingle(foreignArgsHash);
912
- const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
913
- const additionalScopes = fromArray(foreignAdditionalScopes).map((field)=>AztecAddress.fromField(field));
914
- const authorizedUtilityCallTargets = fromArray(foreignAuthorizedUtilityCallTargets).map((field)=>AztecAddress.fromField(field));
915
- const gasSettings = GasSettings.fromFields(fromArray(foreignGasSettings));
916
- const returnValues = await this.stateHandler.withTopLevelCallTracking(async ()=>{
917
- const { returnValues, offchainEffects } = await this.handlerAsTxe().privateCallNewFlow(from, targetContractAddress, functionSelector, args, argsHash, isStaticCall, additionalScopes, this.stateHandler.getCurrentJob(), authorizedUtilityCallTargets, gasSettings);
918
- // Private execution collects offchain effects inside PXE's PrivateExecutionOracle rather than
919
- // round-tripping them through `aztec_utl_emitOffchainEffect`, so the session buffer is empty
920
- // at this point. Drain the effects from the execution tree into the session buffer so the
921
- // next `env.offchain_messages()` call in the test sees them.
922
- for (const data of offchainEffects){
923
- this.stateHandler.recordOffchainEffect(data);
924
- }
925
- // TODO(F-335): Avoid doing the following call here.
926
- await this.stateHandler.cycleJob();
927
- if (isStaticCall) {
928
- // Static calls revert their checkpoint and mine no block, so there is no tx hash to tag
929
- // offchain effects with. Querying `getLastTxEffects()` here would return an unrelated
930
- // predecessor tx.
931
- return {
932
- result: returnValues
933
- };
934
- }
935
- const { txHash } = await this.handlerAsTxe().getLastTxEffects();
936
- return {
937
- result: returnValues,
938
- txHash: txHash.hash
939
- };
940
- });
941
- return toForeignCallResult([
942
- toArray(returnValues)
943
- ]);
944
- }
945
- // TODO(F-674): Move orchestration logic into the handler so the transport layer is pure serialize→delegate→deserialize.
946
- // eslint-disable-next-line camelcase
947
- async aztec_txe_executeUtilityFunction(foreignTargetContractAddress, foreignFunctionSelector, foreignArgs, foreignAuthorizedUtilityCallTargets) {
948
- const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
949
- const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
950
- const args = fromArray(foreignArgs);
951
- const authorizedUtilityCallTargets = fromArray(foreignAuthorizedUtilityCallTargets).map((field)=>AztecAddress.fromField(field));
952
- const returnValues = await this.stateHandler.withTopLevelCallTracking(async ()=>{
953
- const returnValues = await this.handlerAsTxe().executeUtilityFunction(targetContractAddress, functionSelector, args, this.stateHandler.getCurrentJob(), authorizedUtilityCallTargets);
954
- // TODO(F-335): Avoid doing the following call here.
955
- await this.stateHandler.cycleJob();
956
- return {
957
- result: returnValues
958
- };
959
- });
960
- return toForeignCallResult([
961
- toArray(returnValues)
962
- ]);
963
- }
964
- // TODO(F-674): Move orchestration logic into the handler so the transport layer is pure serialize→delegate→deserialize.
965
- // eslint-disable-next-line camelcase
966
- async aztec_txe_publicCallNewFlow(foreignFromIsSome, foreignFromValue, foreignAddress, foreignCalldata, foreignIsStaticCall, foreignGasSettings) {
967
- const from = fromSingle(foreignFromIsSome).toBool() ? addressFromSingle(foreignFromValue) : undefined;
968
- const address = addressFromSingle(foreignAddress);
969
- const calldata = fromArray(foreignCalldata);
970
- const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
971
- const gasSettings = GasSettings.fromFields(fromArray(foreignGasSettings));
972
- const returnValues = await this.stateHandler.withTopLevelCallTracking(async ()=>{
973
- const returnValues = await this.handlerAsTxe().publicCallNewFlow(from, address, calldata, isStaticCall, gasSettings);
974
- // TODO(F-335): Avoid doing the following call here.
975
- await this.stateHandler.cycleJob();
976
- if (isStaticCall) {
977
- // See equivalent branch in `aztec_txe_privateCallNewFlow`.
978
- return {
979
- result: returnValues
980
- };
981
- }
982
- const { txHash } = await this.handlerAsTxe().getLastTxEffects();
983
- return {
984
- result: returnValues,
985
- txHash: txHash.hash
986
- };
987
- });
988
- return toForeignCallResult([
989
- toArray(returnValues)
990
- ]);
991
- }
992
- // eslint-disable-next-line camelcase
993
- async aztec_prv_getSenderForTags() {
994
- const senderOpt = await this.handlerAsPrivate().getSenderForTags();
995
- // Return a Noir Option struct with `some` and `value` fields
996
- if (senderOpt.isSome()) {
997
- // Sender found, return Option with some=1 and value=sender address
998
- return toForeignCallResult([
999
- toSingle(1),
1000
- toSingle(senderOpt.value)
1001
- ]);
1002
- } else {
1003
- // No sender found, return Option with some=0 and value=0
1004
- return toForeignCallResult([
1005
- toSingle(0),
1006
- toSingle(0)
1007
- ]);
1008
- }
833
+ aztec_avm_blockNumber() {
834
+ return callTxeHandler({
835
+ oracle: 'aztec_avm_blockNumber',
836
+ inputs: [],
837
+ handler: ()=>this.handlerAsAvm().blockNumber()
838
+ });
1009
839
  }
1010
840
  // eslint-disable-next-line camelcase
1011
- async aztec_prv_getNextAppTagAsSender(foreignSender, foreignRecipient) {
1012
- const sender = AztecAddress.fromField(fromSingle(foreignSender));
1013
- const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
1014
- const nextAppTag = await this.handlerAsPrivate().getNextAppTagAsSender(sender, recipient);
1015
- return toForeignCallResult([
1016
- toSingle(nextAppTag.value)
1017
- ]);
841
+ aztec_avm_timestamp() {
842
+ return callTxeHandler({
843
+ oracle: 'aztec_avm_timestamp',
844
+ inputs: [],
845
+ handler: ()=>this.handlerAsAvm().timestamp()
846
+ });
847
+ }
848
+ // eslint-disable-next-line camelcase
849
+ aztec_avm_isStaticCall() {
850
+ return callTxeHandler({
851
+ oracle: 'aztec_avm_isStaticCall',
852
+ inputs: [],
853
+ handler: ()=>this.handlerAsAvm().isStaticCall()
854
+ });
855
+ }
856
+ // eslint-disable-next-line camelcase
857
+ aztec_avm_chainId() {
858
+ return callTxeHandler({
859
+ oracle: 'aztec_avm_chainId',
860
+ inputs: [],
861
+ handler: ()=>this.handlerAsAvm().chainId()
862
+ });
863
+ }
864
+ // eslint-disable-next-line camelcase
865
+ aztec_avm_version() {
866
+ return callTxeHandler({
867
+ oracle: 'aztec_avm_version',
868
+ inputs: [],
869
+ handler: ()=>this.handlerAsAvm().version()
870
+ });
871
+ }
872
+ // eslint-disable-next-line camelcase
873
+ aztec_avm_returndataSize() {
874
+ return callTxeHandler({
875
+ oracle: 'aztec_avm_returndataSize',
876
+ inputs: [],
877
+ handler: ()=>this.handlerAsAvm().returndataSize()
878
+ });
879
+ }
880
+ // eslint-disable-next-line camelcase
881
+ aztec_avm_returndataCopy(...inputs) {
882
+ return callTxeHandler({
883
+ oracle: 'aztec_avm_returndataCopy',
884
+ inputs,
885
+ handler: ([rdOffset, copySize])=>this.handlerAsAvm().returndataCopy(rdOffset, copySize)
886
+ });
1018
887
  }
1019
888
  // eslint-disable-next-line camelcase
1020
- async aztec_prv_getNextConstrainedTaggingIndex(foreignAppSiloedSecret) {
1021
- const appSiloedSecret = fromSingle(foreignAppSiloedSecret);
1022
- const index = await this.handlerAsPrivate().getNextConstrainedTaggingIndex(appSiloedSecret);
1023
- return toForeignCallResult([
1024
- toSingle(new Fr(index))
1025
- ]);
889
+ aztec_avm_call(...inputs) {
890
+ return callTxeHandler({
891
+ oracle: 'aztec_avm_call',
892
+ inputs,
893
+ handler: ([l2Gas, daGas, address, argsLength, args])=>this.handlerAsAvm().call(l2Gas, daGas, address, argsLength, args)
894
+ });
895
+ }
896
+ // eslint-disable-next-line camelcase
897
+ aztec_avm_staticCall(...inputs) {
898
+ return callTxeHandler({
899
+ oracle: 'aztec_avm_staticCall',
900
+ inputs,
901
+ handler: ([l2Gas, daGas, address, argsLength, args])=>this.handlerAsAvm().staticCall(l2Gas, daGas, address, argsLength, args)
902
+ });
903
+ }
904
+ // eslint-disable-next-line camelcase
905
+ aztec_avm_successCopy() {
906
+ return callTxeHandler({
907
+ oracle: 'aztec_avm_successCopy',
908
+ inputs: [],
909
+ handler: ()=>this.handlerAsAvm().successCopy()
910
+ });
911
+ }
912
+ // eslint-disable-next-line camelcase
913
+ aztec_txe_privateCallNewFlow(...inputs) {
914
+ return callTxeHandler({
915
+ oracle: 'aztec_txe_privateCallNewFlow',
916
+ inputs,
917
+ handler: ([from, targetContractAddress, functionSelector, args, argsHash, isStaticCall, additionalScopes, authorizedUtilityCallTargets, gasSettings])=>this.stateHandler.executePrivateCall(from, targetContractAddress, functionSelector, args, argsHash, isStaticCall, additionalScopes, authorizedUtilityCallTargets, gasSettings)
918
+ });
919
+ }
920
+ // eslint-disable-next-line camelcase
921
+ aztec_txe_executeUtilityFunction(...inputs) {
922
+ return callTxeHandler({
923
+ oracle: 'aztec_txe_executeUtilityFunction',
924
+ inputs,
925
+ handler: ([from, targetContractAddress, functionSelector, args, authorizedUtilityCallTargets])=>this.stateHandler.executeUtilityFunction(from, targetContractAddress, functionSelector, args, authorizedUtilityCallTargets)
926
+ });
927
+ }
928
+ // eslint-disable-next-line camelcase
929
+ aztec_txe_publicCallNewFlow(...inputs) {
930
+ return callTxeHandler({
931
+ oracle: 'aztec_txe_publicCallNewFlow',
932
+ inputs,
933
+ handler: ([from, address, calldata, isStaticCall, gasSettings])=>this.stateHandler.executePublicCall(from, address, calldata, isStaticCall, gasSettings)
934
+ });
935
+ }
936
+ // eslint-disable-next-line camelcase
937
+ aztec_prv_getSenderForTags() {
938
+ return callTxeHandler({
939
+ oracle: 'aztec_prv_getSenderForTags',
940
+ inputs: [],
941
+ handler: ()=>this.handlerAsPrivate().getSenderForTags()
942
+ });
943
+ }
944
+ // eslint-disable-next-line camelcase
945
+ aztec_prv_resolveTaggingStrategy(...inputs) {
946
+ return callTxeHandler({
947
+ oracle: 'aztec_prv_resolveTaggingStrategy',
948
+ inputs,
949
+ handler: ([sender, recipient, deliveryMode])=>this.handlerAsPrivate().resolveTaggingStrategy(sender, recipient, deliveryMode)
950
+ });
951
+ }
952
+ // eslint-disable-next-line camelcase
953
+ aztec_prv_resolveCustomRequest(...inputs) {
954
+ return callTxeHandler({
955
+ oracle: 'aztec_prv_resolveCustomRequest',
956
+ inputs,
957
+ handler: ([kind, payload])=>this.handlerAsPrivate().resolveCustomRequest(kind, payload)
958
+ });
959
+ }
960
+ // eslint-disable-next-line camelcase
961
+ aztec_prv_getAppTaggingSecret(...inputs) {
962
+ return callTxeHandler({
963
+ oracle: 'aztec_prv_getAppTaggingSecret',
964
+ inputs,
965
+ handler: ([sender, recipient])=>this.handlerAsPrivate().getAppTaggingSecret(sender, recipient)
966
+ });
967
+ }
968
+ // eslint-disable-next-line camelcase
969
+ aztec_prv_getNextTaggingIndex(...inputs) {
970
+ return callTxeHandler({
971
+ oracle: 'aztec_prv_getNextTaggingIndex',
972
+ inputs,
973
+ handler: ([secret, deliveryMode])=>this.handlerAsPrivate().getNextTaggingIndex(secret, deliveryMode)
974
+ });
1026
975
  }
1027
976
  }