Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions yarn-project/simulator/src/public/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type ContractClassPublic,
type ContractInstanceWithAddress,
DEFAULT_GAS_LIMIT,
type FunctionSelector,
FunctionSelector,
Gas,
GasFees,
GasSettings,
Expand All @@ -23,15 +23,16 @@ import {
computePublicBytecodeCommitment,
} from '@aztec/circuits.js';
import { makeContractClassPublic, makeContractInstanceFromClassId } from '@aztec/circuits.js/testing';
import { type ContractArtifact } from '@aztec/foundation/abi';
import { type ContractArtifact, type FunctionArtifact } from '@aztec/foundation/abi';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr, Point } from '@aztec/foundation/fields';
import { openTmpStore } from '@aztec/kv-store/utils';
import { AvmTestContractArtifact } from '@aztec/noir-contracts.js';
import { PublicTxSimulator, WorldStateDB } from '@aztec/simulator';
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
import { MerkleTrees } from '@aztec/world-state';

import { getAvmTestContractBytecode, getAvmTestContractFunctionSelector } from '../../avm/fixtures/index.js';
import { strict as assert } from 'assert';

/**
* If assertionErrString is set, we expect a (non exceptional halting) revert due to a failing assertion and
Expand Down Expand Up @@ -210,3 +211,24 @@ class MockedAvmTestContractDataSource {
return Promise.resolve();
}
}

function getAvmTestContractFunctionSelector(functionName: string): FunctionSelector {
const artifact = AvmTestContractArtifact.functions.find(f => f.name === functionName)!;
assert(!!artifact, `Function ${functionName} not found in AvmTestContractArtifact`);
const params = artifact.parameters;
return FunctionSelector.fromNameAndParameters(artifact.name, params);
}

function getAvmTestContractArtifact(functionName: string): FunctionArtifact {
const artifact = AvmTestContractArtifact.functions.find(f => f.name === functionName)!;
assert(
!!artifact?.bytecode,
`No bytecode found for function ${functionName}. Try re-running bootstrap.sh on the repository root.`,
);
return artifact;
}

function getAvmTestContractBytecode(functionName: string): Buffer {
const artifact = getAvmTestContractArtifact(functionName);
return artifact.bytecode;
}