@aztec/txe 0.58.0 → 0.60.0
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/oracle/txe_oracle.d.ts +13 -15
- package/dest/oracle/txe_oracle.d.ts.map +1 -1
- package/dest/oracle/txe_oracle.js +95 -90
- package/dest/txe_service/txe_service.d.ts +50 -70
- package/dest/txe_service/txe_service.d.ts.map +1 -1
- package/dest/txe_service/txe_service.js +106 -118
- package/package.json +15 -15
- package/src/oracle/txe_oracle.ts +141 -139
- package/src/txe_service/txe_service.ts +148 -172
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { L2Block, MerkleTreeId, PublicDataWrite } from '@aztec/circuit-types';
|
|
2
|
+
import { L2Block, MerkleTreeId, PublicDataWrite, SimulationError } from '@aztec/circuit-types';
|
|
3
3
|
import {
|
|
4
4
|
Fr,
|
|
5
5
|
FunctionSelector,
|
|
@@ -17,6 +17,7 @@ import { type Logger } from '@aztec/foundation/log';
|
|
|
17
17
|
import { KeyStore } from '@aztec/key-store';
|
|
18
18
|
import { openTmpStore } from '@aztec/kv-store/utils';
|
|
19
19
|
import { getCanonicalProtocolContract, protocolContractNames } from '@aztec/protocol-contracts';
|
|
20
|
+
import { enrichPublicSimulationError } from '@aztec/pxe';
|
|
20
21
|
import { ExecutionNoteCache, PackedValuesCache, type TypedOracle } from '@aztec/simulator';
|
|
21
22
|
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
|
|
22
23
|
import { MerkleTrees } from '@aztec/world-state';
|
|
@@ -117,7 +118,7 @@ export class TXEService {
|
|
|
117
118
|
skipArgsDecoding: true,
|
|
118
119
|
salt: Fr.ONE,
|
|
119
120
|
// TODO: Modify this to allow for passing public keys.
|
|
120
|
-
publicKeys: PublicKeys.
|
|
121
|
+
publicKeys: PublicKeys.default(),
|
|
121
122
|
constructorArtifact: initializerStr ? initializerStr : undefined,
|
|
122
123
|
deployer: AztecAddress.ZERO,
|
|
123
124
|
});
|
|
@@ -200,16 +201,6 @@ export class TXEService {
|
|
|
200
201
|
]);
|
|
201
202
|
}
|
|
202
203
|
|
|
203
|
-
setMsgSender(msgSender: ForeignCallSingle) {
|
|
204
|
-
(this.typedOracle as TXE).setMsgSender(fromSingle(msgSender));
|
|
205
|
-
return toForeignCallResult([]);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
getMsgSender() {
|
|
209
|
-
const msgSender = (this.typedOracle as TXE).getMsgSender();
|
|
210
|
-
return toForeignCallResult([toSingle(msgSender)]);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
204
|
getSideEffectsCounter() {
|
|
214
205
|
const counter = (this.typedOracle as TXE).getSideEffectsCounter();
|
|
215
206
|
return toForeignCallResult([toSingle(new Fr(counter))]);
|
|
@@ -228,13 +219,7 @@ export class TXEService {
|
|
|
228
219
|
) {
|
|
229
220
|
const parsedAddress = fromSingle(address);
|
|
230
221
|
const parsedSelector = FunctionSelector.fromField(fromSingle(functionSelector));
|
|
231
|
-
const result = await (this.typedOracle as TXE).avmOpcodeCall(
|
|
232
|
-
parsedAddress,
|
|
233
|
-
parsedSelector,
|
|
234
|
-
fromArray(args),
|
|
235
|
-
false,
|
|
236
|
-
false,
|
|
237
|
-
);
|
|
222
|
+
const result = await (this.typedOracle as TXE).avmOpcodeCall(parsedAddress, parsedSelector, fromArray(args), false);
|
|
238
223
|
if (!result.reverted) {
|
|
239
224
|
throw new ExpectedFailureError('Public call did not revert');
|
|
240
225
|
}
|
|
@@ -248,7 +233,6 @@ export class TXEService {
|
|
|
248
233
|
argsHash: ForeignCallSingle,
|
|
249
234
|
sideEffectCounter: ForeignCallSingle,
|
|
250
235
|
isStaticCall: ForeignCallSingle,
|
|
251
|
-
isDelegateCall: ForeignCallSingle,
|
|
252
236
|
) {
|
|
253
237
|
try {
|
|
254
238
|
await this.typedOracle.callPrivateFunction(
|
|
@@ -257,7 +241,6 @@ export class TXEService {
|
|
|
257
241
|
fromSingle(argsHash),
|
|
258
242
|
fromSingle(sideEffectCounter).toNumber(),
|
|
259
243
|
fromSingle(isStaticCall).toBool(),
|
|
260
|
-
fromSingle(isDelegateCall).toBool(),
|
|
261
244
|
);
|
|
262
245
|
throw new ExpectedFailureError('Private call did not fail');
|
|
263
246
|
} catch (e) {
|
|
@@ -268,21 +251,6 @@ export class TXEService {
|
|
|
268
251
|
return toForeignCallResult([]);
|
|
269
252
|
}
|
|
270
253
|
|
|
271
|
-
setFunctionSelector(functionSelector: ForeignCallSingle) {
|
|
272
|
-
(this.typedOracle as TXE).setFunctionSelector(FunctionSelector.fromField(fromSingle(functionSelector)));
|
|
273
|
-
return toForeignCallResult([]);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
setCalldata(_length: ForeignCallSingle, calldata: ForeignCallArray) {
|
|
277
|
-
(this.typedOracle as TXE).setCalldata(fromArray(calldata));
|
|
278
|
-
return toForeignCallResult([]);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
getFunctionSelector() {
|
|
282
|
-
const functionSelector = (this.typedOracle as TXE).getFunctionSelector();
|
|
283
|
-
return toForeignCallResult([toSingle(functionSelector.toField())]);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
254
|
// PXE oracles
|
|
287
255
|
|
|
288
256
|
getRandomField() {
|
|
@@ -299,41 +267,6 @@ export class TXEService {
|
|
|
299
267
|
return toForeignCallResult([toSingle(new Fr(blockNumber))]);
|
|
300
268
|
}
|
|
301
269
|
|
|
302
|
-
async avmOpcodeAddress() {
|
|
303
|
-
const contractAddress = await this.typedOracle.getContractAddress();
|
|
304
|
-
return toForeignCallResult([toSingle(contractAddress.toField())]);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
async avmOpcodeBlockNumber() {
|
|
308
|
-
const blockNumber = await this.typedOracle.getBlockNumber();
|
|
309
|
-
return toForeignCallResult([toSingle(new Fr(blockNumber))]);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
avmOpcodeFunctionSelector() {
|
|
313
|
-
const functionSelector = (this.typedOracle as TXE).getFunctionSelector();
|
|
314
|
-
return toForeignCallResult([toSingle(functionSelector.toField())]);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
setIsStaticCall(isStaticCall: ForeignCallSingle) {
|
|
318
|
-
(this.typedOracle as TXE).setIsStaticCall(fromSingle(isStaticCall).toBool());
|
|
319
|
-
return toForeignCallResult([]);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
avmOpcodeIsStaticCall() {
|
|
323
|
-
const isStaticCall = (this.typedOracle as TXE).getIsStaticCall();
|
|
324
|
-
return toForeignCallResult([toSingle(new Fr(isStaticCall ? 1 : 0))]);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
async avmOpcodeChainId() {
|
|
328
|
-
const chainId = await (this.typedOracle as TXE).getChainId();
|
|
329
|
-
return toForeignCallResult([toSingle(chainId)]);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
async avmOpcodeVersion() {
|
|
333
|
-
const version = await (this.typedOracle as TXE).getVersion();
|
|
334
|
-
return toForeignCallResult([toSingle(version)]);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
270
|
async packArgumentsArray(args: ForeignCallArray) {
|
|
338
271
|
const packed = await this.typedOracle.packArgumentsArray(fromArray(args));
|
|
339
272
|
return toForeignCallResult([toSingle(packed)]);
|
|
@@ -514,101 +447,6 @@ export class TXEService {
|
|
|
514
447
|
]);
|
|
515
448
|
}
|
|
516
449
|
|
|
517
|
-
async avmOpcodeGetContractInstance(address: ForeignCallSingle) {
|
|
518
|
-
const instance = await this.typedOracle.getContractInstance(fromSingle(address));
|
|
519
|
-
return toForeignCallResult([
|
|
520
|
-
toArray([
|
|
521
|
-
// AVM requires an extra boolean indicating the instance was found
|
|
522
|
-
new Fr(1),
|
|
523
|
-
instance.salt,
|
|
524
|
-
instance.deployer,
|
|
525
|
-
instance.contractClassId,
|
|
526
|
-
instance.initializationHash,
|
|
527
|
-
...instance.publicKeys.toFields(),
|
|
528
|
-
]),
|
|
529
|
-
]);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
avmOpcodeSender() {
|
|
533
|
-
const sender = (this.typedOracle as TXE).getMsgSender();
|
|
534
|
-
return toForeignCallResult([toSingle(sender)]);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
async avmOpcodeEmitNullifier(nullifier: ForeignCallSingle) {
|
|
538
|
-
await (this.typedOracle as TXE).avmOpcodeEmitNullifier(fromSingle(nullifier));
|
|
539
|
-
return toForeignCallResult([]);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
async avmOpcodeEmitNoteHash(noteHash: ForeignCallSingle) {
|
|
543
|
-
await (this.typedOracle as TXE).avmOpcodeEmitNoteHash(fromSingle(noteHash));
|
|
544
|
-
return toForeignCallResult([]);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
async avmOpcodeNullifierExists(innerNullifier: ForeignCallSingle, targetAddress: ForeignCallSingle) {
|
|
548
|
-
const exists = await (this.typedOracle as TXE).avmOpcodeNullifierExists(
|
|
549
|
-
fromSingle(innerNullifier),
|
|
550
|
-
AztecAddress.fromField(fromSingle(targetAddress)),
|
|
551
|
-
);
|
|
552
|
-
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
async avmOpcodeCall(
|
|
556
|
-
_gas: ForeignCallArray,
|
|
557
|
-
address: ForeignCallSingle,
|
|
558
|
-
_length: ForeignCallSingle,
|
|
559
|
-
args: ForeignCallArray,
|
|
560
|
-
functionSelector: ForeignCallSingle,
|
|
561
|
-
) {
|
|
562
|
-
const result = await (this.typedOracle as TXE).avmOpcodeCall(
|
|
563
|
-
fromSingle(address),
|
|
564
|
-
FunctionSelector.fromField(fromSingle(functionSelector)),
|
|
565
|
-
fromArray(args),
|
|
566
|
-
/* isStaticCall */ false,
|
|
567
|
-
/* isDelegateCall */ false,
|
|
568
|
-
);
|
|
569
|
-
|
|
570
|
-
return toForeignCallResult([toArray(result.returnValues), toSingle(new Fr(1))]);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
async avmOpcodeStaticCall(
|
|
574
|
-
_gas: ForeignCallArray,
|
|
575
|
-
address: ForeignCallSingle,
|
|
576
|
-
_length: ForeignCallSingle,
|
|
577
|
-
args: ForeignCallArray,
|
|
578
|
-
functionSelector: ForeignCallSingle,
|
|
579
|
-
) {
|
|
580
|
-
const result = await (this.typedOracle as TXE).avmOpcodeCall(
|
|
581
|
-
fromSingle(address),
|
|
582
|
-
FunctionSelector.fromField(fromSingle(functionSelector)),
|
|
583
|
-
fromArray(args),
|
|
584
|
-
/* isStaticCall */ true,
|
|
585
|
-
/* isDelegateCall */ false,
|
|
586
|
-
);
|
|
587
|
-
|
|
588
|
-
return toForeignCallResult([toArray(result.returnValues), toSingle(new Fr(1))]);
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
async avmOpcodeStorageRead(slot: ForeignCallSingle) {
|
|
592
|
-
const value = await (this.typedOracle as TXE).avmOpcodeStorageRead(fromSingle(slot));
|
|
593
|
-
return toForeignCallResult([toSingle(value)]);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
async avmOpcodeStorageWrite(slot: ForeignCallSingle, value: ForeignCallSingle) {
|
|
597
|
-
await this.typedOracle.storageWrite(fromSingle(slot), [fromSingle(value)]);
|
|
598
|
-
return toForeignCallResult([]);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
//unconstrained fn calldata_copy_opcode<let N: u32>(cdoffset: u32, copy_size: u32) -> [Field; N] {}
|
|
602
|
-
avmOpcodeCalldataCopy(cdOffsetInput: ForeignCallSingle, copySizeInput: ForeignCallSingle) {
|
|
603
|
-
const cdOffset = fromSingle(cdOffsetInput).toNumber();
|
|
604
|
-
const copySize = fromSingle(copySizeInput).toNumber();
|
|
605
|
-
|
|
606
|
-
const calldata = (this.typedOracle as TXE).getCalldata();
|
|
607
|
-
const calldataSlice = calldata.slice(cdOffset, cdOffset + copySize);
|
|
608
|
-
|
|
609
|
-
return toForeignCallResult([toArray(calldataSlice)]);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
450
|
async getPublicKeysAndPartialAddress(address: ForeignCallSingle) {
|
|
613
451
|
const parsedAddress = AztecAddress.fromField(fromSingle(address));
|
|
614
452
|
const { publicKeys, partialAddress } = await this.typedOracle.getCompleteAddress(parsedAddress);
|
|
@@ -650,7 +488,6 @@ export class TXEService {
|
|
|
650
488
|
argsHash: ForeignCallSingle,
|
|
651
489
|
sideEffectCounter: ForeignCallSingle,
|
|
652
490
|
isStaticCall: ForeignCallSingle,
|
|
653
|
-
isDelegateCall: ForeignCallSingle,
|
|
654
491
|
) {
|
|
655
492
|
const result = await this.typedOracle.callPrivateFunction(
|
|
656
493
|
fromSingle(targetContractAddress),
|
|
@@ -658,7 +495,6 @@ export class TXEService {
|
|
|
658
495
|
fromSingle(argsHash),
|
|
659
496
|
fromSingle(sideEffectCounter).toNumber(),
|
|
660
497
|
fromSingle(isStaticCall).toBool(),
|
|
661
|
-
fromSingle(isDelegateCall).toBool(),
|
|
662
498
|
);
|
|
663
499
|
return toForeignCallResult([toArray([result.endSideEffectCounter, result.returnsHash])]);
|
|
664
500
|
}
|
|
@@ -687,7 +523,6 @@ export class TXEService {
|
|
|
687
523
|
argsHash: ForeignCallSingle,
|
|
688
524
|
sideEffectCounter: ForeignCallSingle,
|
|
689
525
|
isStaticCall: ForeignCallSingle,
|
|
690
|
-
isDelegateCall: ForeignCallSingle,
|
|
691
526
|
) {
|
|
692
527
|
const newArgsHash = await this.typedOracle.enqueuePublicFunctionCall(
|
|
693
528
|
fromSingle(targetContractAddress),
|
|
@@ -695,7 +530,6 @@ export class TXEService {
|
|
|
695
530
|
fromSingle(argsHash),
|
|
696
531
|
fromSingle(sideEffectCounter).toNumber(),
|
|
697
532
|
fromSingle(isStaticCall).toBool(),
|
|
698
|
-
fromSingle(isDelegateCall).toBool(),
|
|
699
533
|
);
|
|
700
534
|
return toForeignCallResult([toSingle(newArgsHash)]);
|
|
701
535
|
}
|
|
@@ -706,7 +540,6 @@ export class TXEService {
|
|
|
706
540
|
argsHash: ForeignCallSingle,
|
|
707
541
|
sideEffectCounter: ForeignCallSingle,
|
|
708
542
|
isStaticCall: ForeignCallSingle,
|
|
709
|
-
isDelegateCall: ForeignCallSingle,
|
|
710
543
|
) {
|
|
711
544
|
const newArgsHash = await this.typedOracle.setPublicTeardownFunctionCall(
|
|
712
545
|
fromSingle(targetContractAddress),
|
|
@@ -714,7 +547,6 @@ export class TXEService {
|
|
|
714
547
|
fromSingle(argsHash),
|
|
715
548
|
fromSingle(sideEffectCounter).toNumber(),
|
|
716
549
|
fromSingle(isStaticCall).toBool(),
|
|
717
|
-
fromSingle(isDelegateCall).toBool(),
|
|
718
550
|
);
|
|
719
551
|
return toForeignCallResult([toSingle(newArgsHash)]);
|
|
720
552
|
}
|
|
@@ -767,8 +599,152 @@ export class TXEService {
|
|
|
767
599
|
return toForeignCallResult([]);
|
|
768
600
|
}
|
|
769
601
|
|
|
602
|
+
// AVM opcodes
|
|
603
|
+
|
|
770
604
|
avmOpcodeEmitUnencryptedLog(_message: ForeignCallArray) {
|
|
771
605
|
// TODO(#8811): Implement
|
|
772
606
|
return toForeignCallResult([]);
|
|
773
607
|
}
|
|
608
|
+
|
|
609
|
+
async avmOpcodeStorageRead(slot: ForeignCallSingle) {
|
|
610
|
+
const value = await (this.typedOracle as TXE).avmOpcodeStorageRead(fromSingle(slot));
|
|
611
|
+
return toForeignCallResult([toSingle(value)]);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
async avmOpcodeStorageWrite(slot: ForeignCallSingle, value: ForeignCallSingle) {
|
|
615
|
+
await this.typedOracle.storageWrite(fromSingle(slot), [fromSingle(value)]);
|
|
616
|
+
return toForeignCallResult([]);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
async avmOpcodeGetContractInstance(address: ForeignCallSingle) {
|
|
620
|
+
const instance = await this.typedOracle.getContractInstance(fromSingle(address));
|
|
621
|
+
return toForeignCallResult([
|
|
622
|
+
toArray([
|
|
623
|
+
// AVM requires an extra boolean indicating the instance was found
|
|
624
|
+
new Fr(1),
|
|
625
|
+
instance.salt,
|
|
626
|
+
instance.deployer,
|
|
627
|
+
instance.contractClassId,
|
|
628
|
+
instance.initializationHash,
|
|
629
|
+
...instance.publicKeys.toFields(),
|
|
630
|
+
]),
|
|
631
|
+
]);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
avmOpcodeSender() {
|
|
635
|
+
const sender = (this.typedOracle as TXE).getMsgSender();
|
|
636
|
+
return toForeignCallResult([toSingle(sender)]);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
async avmOpcodeEmitNullifier(nullifier: ForeignCallSingle) {
|
|
640
|
+
await (this.typedOracle as TXE).avmOpcodeEmitNullifier(fromSingle(nullifier));
|
|
641
|
+
return toForeignCallResult([]);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
async avmOpcodeEmitNoteHash(noteHash: ForeignCallSingle) {
|
|
645
|
+
await (this.typedOracle as TXE).avmOpcodeEmitNoteHash(fromSingle(noteHash));
|
|
646
|
+
return toForeignCallResult([]);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
async avmOpcodeNullifierExists(innerNullifier: ForeignCallSingle, targetAddress: ForeignCallSingle) {
|
|
650
|
+
const exists = await (this.typedOracle as TXE).avmOpcodeNullifierExists(
|
|
651
|
+
fromSingle(innerNullifier),
|
|
652
|
+
AztecAddress.fromField(fromSingle(targetAddress)),
|
|
653
|
+
);
|
|
654
|
+
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
async avmOpcodeAddress() {
|
|
658
|
+
const contractAddress = await this.typedOracle.getContractAddress();
|
|
659
|
+
return toForeignCallResult([toSingle(contractAddress.toField())]);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
async avmOpcodeBlockNumber() {
|
|
663
|
+
const blockNumber = await this.typedOracle.getBlockNumber();
|
|
664
|
+
return toForeignCallResult([toSingle(new Fr(blockNumber))]);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
avmOpcodeFunctionSelector() {
|
|
668
|
+
const functionSelector = (this.typedOracle as TXE).getFunctionSelector();
|
|
669
|
+
return toForeignCallResult([toSingle(functionSelector.toField())]);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
avmOpcodeIsStaticCall() {
|
|
673
|
+
const isStaticCall = (this.typedOracle as TXE).getIsStaticCall();
|
|
674
|
+
return toForeignCallResult([toSingle(new Fr(isStaticCall ? 1 : 0))]);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
async avmOpcodeChainId() {
|
|
678
|
+
const chainId = await (this.typedOracle as TXE).getChainId();
|
|
679
|
+
return toForeignCallResult([toSingle(chainId)]);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
async avmOpcodeVersion() {
|
|
683
|
+
const version = await (this.typedOracle as TXE).getVersion();
|
|
684
|
+
return toForeignCallResult([toSingle(version)]);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
async avmOpcodeCall(
|
|
688
|
+
_gas: ForeignCallArray,
|
|
689
|
+
address: ForeignCallSingle,
|
|
690
|
+
_length: ForeignCallSingle,
|
|
691
|
+
args: ForeignCallArray,
|
|
692
|
+
functionSelector: ForeignCallSingle,
|
|
693
|
+
) {
|
|
694
|
+
const result = await (this.typedOracle as TXE).avmOpcodeCall(
|
|
695
|
+
fromSingle(address),
|
|
696
|
+
FunctionSelector.fromField(fromSingle(functionSelector)),
|
|
697
|
+
fromArray(args),
|
|
698
|
+
/* isStaticCall */ false,
|
|
699
|
+
);
|
|
700
|
+
|
|
701
|
+
// Poor man's revert handling
|
|
702
|
+
if (result.reverted) {
|
|
703
|
+
if (result.revertReason && result.revertReason instanceof SimulationError) {
|
|
704
|
+
await enrichPublicSimulationError(
|
|
705
|
+
result.revertReason,
|
|
706
|
+
(this.typedOracle as TXE).getContractDataOracle(),
|
|
707
|
+
(this.typedOracle as TXE).getTXEDatabase(),
|
|
708
|
+
this.logger,
|
|
709
|
+
);
|
|
710
|
+
throw new Error(result.revertReason.message);
|
|
711
|
+
} else {
|
|
712
|
+
throw new Error(`Public function call reverted: ${result.revertReason}`);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
return toForeignCallResult([toArray(result.returnValues), toSingle(new Fr(!result.reverted))]);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
async avmOpcodeStaticCall(
|
|
720
|
+
_gas: ForeignCallArray,
|
|
721
|
+
address: ForeignCallSingle,
|
|
722
|
+
_length: ForeignCallSingle,
|
|
723
|
+
args: ForeignCallArray,
|
|
724
|
+
functionSelector: ForeignCallSingle,
|
|
725
|
+
) {
|
|
726
|
+
const result = await (this.typedOracle as TXE).avmOpcodeCall(
|
|
727
|
+
fromSingle(address),
|
|
728
|
+
FunctionSelector.fromField(fromSingle(functionSelector)),
|
|
729
|
+
fromArray(args),
|
|
730
|
+
/* isStaticCall */ true,
|
|
731
|
+
);
|
|
732
|
+
|
|
733
|
+
// Poor man's revert handling
|
|
734
|
+
if (result.reverted) {
|
|
735
|
+
if (result.revertReason && result.revertReason instanceof SimulationError) {
|
|
736
|
+
await enrichPublicSimulationError(
|
|
737
|
+
result.revertReason,
|
|
738
|
+
(this.typedOracle as TXE).getContractDataOracle(),
|
|
739
|
+
(this.typedOracle as TXE).getTXEDatabase(),
|
|
740
|
+
this.logger,
|
|
741
|
+
);
|
|
742
|
+
throw new Error(result.revertReason.message);
|
|
743
|
+
} else {
|
|
744
|
+
throw new Error(`Public function call reverted: ${result.revertReason}`);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return toForeignCallResult([toArray(result.returnValues), toSingle(new Fr(!result.reverted))]);
|
|
749
|
+
}
|
|
774
750
|
}
|