5
5
type ContractClassPublic ,
6
6
type ContractInstanceWithAddress ,
7
7
DEFAULT_GAS_LIMIT ,
8
- type FunctionSelector ,
8
+ FunctionSelector ,
9
9
Gas ,
10
10
GasFees ,
11
11
GasSettings ,
@@ -23,15 +23,16 @@ import {
23
23
computePublicBytecodeCommitment ,
24
24
} from '@aztec/circuits.js' ;
25
25
import { makeContractClassPublic , makeContractInstanceFromClassId } from '@aztec/circuits.js/testing' ;
26
- import { type ContractArtifact } from '@aztec/foundation/abi' ;
26
+ import { type ContractArtifact , type FunctionArtifact } from '@aztec/foundation/abi' ;
27
27
import { AztecAddress } from '@aztec/foundation/aztec-address' ;
28
28
import { Fr , Point } from '@aztec/foundation/fields' ;
29
29
import { openTmpStore } from '@aztec/kv-store/utils' ;
30
+ import { AvmTestContractArtifact } from '@aztec/noir-contracts.js' ;
30
31
import { PublicTxSimulator , WorldStateDB } from '@aztec/simulator' ;
31
32
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop' ;
32
33
import { MerkleTrees } from '@aztec/world-state' ;
33
34
34
- import { getAvmTestContractBytecode , getAvmTestContractFunctionSelector } from '../../avm/fixtures/index.js ' ;
35
+ import { strict as assert } from 'assert ' ;
35
36
36
37
/**
37
38
* If assertionErrString is set, we expect a (non exceptional halting) revert due to a failing assertion and
@@ -210,3 +211,24 @@ class MockedAvmTestContractDataSource {
210
211
return Promise . resolve ( ) ;
211
212
}
212
213
}
214
+
215
+ function getAvmTestContractFunctionSelector ( functionName : string ) : FunctionSelector {
216
+ const artifact = AvmTestContractArtifact . functions . find ( f => f . name === functionName ) ! ;
217
+ assert ( ! ! artifact , `Function ${ functionName } not found in AvmTestContractArtifact` ) ;
218
+ const params = artifact . parameters ;
219
+ return FunctionSelector . fromNameAndParameters ( artifact . name , params ) ;
220
+ }
221
+
222
+ function getAvmTestContractArtifact ( functionName : string ) : FunctionArtifact {
223
+ const artifact = AvmTestContractArtifact . functions . find ( f => f . name === functionName ) ! ;
224
+ assert (
225
+ ! ! artifact ?. bytecode ,
226
+ `No bytecode found for function ${ functionName } . Try re-running bootstrap.sh on the repository root.` ,
227
+ ) ;
228
+ return artifact ;
229
+ }
230
+
231
+ function getAvmTestContractBytecode ( functionName : string ) : Buffer {
232
+ const artifact = getAvmTestContractArtifact ( functionName ) ;
233
+ return artifact . bytecode ;
234
+ }
0 commit comments