diff --git a/yarn-project/accounts/src/ecdsa/artifact.ts b/yarn-project/accounts/src/ecdsa/artifact.ts index 54ec3212dd0..aec4e511570 100644 --- a/yarn-project/accounts/src/ecdsa/artifact.ts +++ b/yarn-project/accounts/src/ecdsa/artifact.ts @@ -1,5 +1,11 @@ import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js'; +import { fileURLToPath } from '@aztec/foundation/url'; -import EcdsaAccountContractJson from '../artifacts/EcdsaAccount.json' assert { type: 'json' }; +import { readFileSync } from 'fs'; +import { dirname, resolve } from 'path'; -export const EcdsaAccountContractArtifact = loadContractArtifact(EcdsaAccountContractJson as NoirCompiledContract); +const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/EcdsaAccount.json'); + +export const EcdsaAccountContractArtifact = loadContractArtifact( + JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract, +); diff --git a/yarn-project/accounts/src/schnorr/artifact.ts b/yarn-project/accounts/src/schnorr/artifact.ts index f7cac3337f7..bb57d96c14f 100644 --- a/yarn-project/accounts/src/schnorr/artifact.ts +++ b/yarn-project/accounts/src/schnorr/artifact.ts @@ -1,5 +1,11 @@ import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js'; +import { fileURLToPath } from '@aztec/foundation/url'; -import SchnorrAccountContractJson from '../artifacts/SchnorrAccount.json' assert { type: 'json' }; +import { readFileSync } from 'fs'; +import { dirname, resolve } from 'path'; -export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractJson as NoirCompiledContract); +const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/SchnorrAccount.json'); + +export const SchnorrAccountContractArtifact = loadContractArtifact( + JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract, +); diff --git a/yarn-project/accounts/src/single_key/artifact.ts b/yarn-project/accounts/src/single_key/artifact.ts index 55a819dc570..5cc4d7b5995 100644 --- a/yarn-project/accounts/src/single_key/artifact.ts +++ b/yarn-project/accounts/src/single_key/artifact.ts @@ -1,7 +1,11 @@ import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js'; +import { fileURLToPath } from '@aztec/foundation/url'; -import SchnorrSingleKeyAccountContractJson from '../artifacts/SchnorrSingleKeyAccount.json' assert { type: 'json' }; +import { readFileSync } from 'fs'; +import { dirname, resolve } from 'path'; + +const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/SchnorrSingleKeyAccount.json'); export const SchnorrSingleKeyAccountContractArtifact = loadContractArtifact( - SchnorrSingleKeyAccountContractJson as NoirCompiledContract, + JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract, ); diff --git a/yarn-project/aztec-node/src/aztec-node/config.ts b/yarn-project/aztec-node/src/aztec-node/config.ts index 54a73db1eb6..237a74807e1 100644 --- a/yarn-project/aztec-node/src/aztec-node/config.ts +++ b/yarn-project/aztec-node/src/aztec-node/config.ts @@ -1,4 +1,5 @@ import { type ArchiverConfig, getConfigEnvVars as getArchiverVars } from '@aztec/archiver'; +import { fileURLToPath } from '@aztec/foundation/url'; import { type P2PConfig, getP2PConfigEnvVars } from '@aztec/p2p'; import { type ProverClientConfig, getProverEnvVars } from '@aztec/prover-client'; import { type SequencerClientConfig, getConfigEnvVars as getSequencerVars } from '@aztec/sequencer-client'; @@ -6,7 +7,6 @@ import { getConfigEnvVars as getWorldStateVars } from '@aztec/world-state'; import { readFileSync } from 'fs'; import { dirname, resolve } from 'path'; -import { fileURLToPath } from 'url'; /** * The configuration the aztec node. diff --git a/yarn-project/builder/src/contract-interface-gen/typescript.ts b/yarn-project/builder/src/contract-interface-gen/typescript.ts index 4c2911fba97..ad18887c931 100644 --- a/yarn-project/builder/src/contract-interface-gen/typescript.ts +++ b/yarn-project/builder/src/contract-interface-gen/typescript.ts @@ -174,8 +174,8 @@ function generateArtifactGetter(name: string) { */ function generateAbiStatement(name: string, artifactImportPath: string) { const stmts = [ - `import ${name}ContractArtifactJson from '${artifactImportPath}' assert { type: 'json' };`, - `export const ${name}ContractArtifact = loadContractArtifact(${name}ContractArtifactJson as NoirCompiledContract);`, + `const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '${artifactImportPath}')`, + `export const ${name}ContractArtifact = loadContractArtifact(JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract);`, ]; return stmts.join('\n'); } @@ -259,6 +259,9 @@ export function generateTypescriptContractInterface(input: ContractArtifact, art /* Autogenerated file, do not edit! */ /* eslint-disable */ +import { readFileSync } from 'fs'; +import { dirname, resolve } from 'path'; + import { AztecAddress, AztecAddressLike, @@ -275,6 +278,7 @@ import { EthAddress, EthAddressLike, FieldLike, + fileURLToPath, Fr, FunctionSelectorLike, loadContractArtifact, diff --git a/yarn-project/circuits.js/src/scripts/constants.in.ts b/yarn-project/circuits.js/src/scripts/constants.in.ts index da2f6d4f221..e2027481a95 100644 --- a/yarn-project/circuits.js/src/scripts/constants.in.ts +++ b/yarn-project/circuits.js/src/scripts/constants.in.ts @@ -1,6 +1,7 @@ +import { fileURLToPath } from '@aztec/foundation/url'; + import * as fs from 'fs'; import { dirname, join } from 'path'; -import { fileURLToPath } from 'url'; const NOIR_CONSTANTS_FILE = '../../../../noir-projects/noir-protocol-circuits/crates/types/src/constants.nr'; const TS_CONSTANTS_FILE = '../constants.gen.ts'; diff --git a/yarn-project/circuits.js/src/tests/fixtures.ts b/yarn-project/circuits.js/src/tests/fixtures.ts index 1d45e9f834c..c04a95bd19e 100644 --- a/yarn-project/circuits.js/src/tests/fixtures.ts +++ b/yarn-project/circuits.js/src/tests/fixtures.ts @@ -1,10 +1,10 @@ import { type ContractArtifact } from '@aztec/foundation/abi'; +import { fileURLToPath } from '@aztec/foundation/url'; import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; import { readFileSync } from 'fs'; import { dirname, resolve } from 'path'; -import { fileURLToPath } from 'url'; // Copied from the build output for the contract `Benchmarking` in noir-contracts export function getBenchmarkContractArtifact(): ContractArtifact { diff --git a/yarn-project/noir-protocol-circuits-types/src/index.ts b/yarn-project/noir-protocol-circuits-types/src/index.ts index 0685ef195c3..f9fa05d6812 100644 --- a/yarn-project/noir-protocol-circuits-types/src/index.ts +++ b/yarn-project/noir-protocol-circuits-types/src/index.ts @@ -22,6 +22,7 @@ import { type RootRollupPublicInputs, } from '@aztec/circuits.js'; import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log'; +import { fileURLToPath } from '@aztec/foundation/url'; import { type NoirCompiledCircuit } from '@aztec/types/noir'; import { type ForeignCallInput, type ForeignCallOutput } from '@noir-lang/acvm_js'; @@ -29,41 +30,9 @@ import { type CompiledCircuit, type InputMap, Noir } from '@noir-lang/noir_js'; import { type Abi, abiDecode, abiEncode } from '@noir-lang/noirc_abi'; import { type WitnessMap } from '@noir-lang/types'; import { strict as assert } from 'assert'; +import { readFileSync } from 'fs'; +import { dirname, resolve } from 'path'; -import EmptyNestedJson from './target/empty_nested.json' assert { type: 'json' }; -import EmptyNestedSimulatedJson from './target/empty_nested_simulated.json' assert { type: 'json' }; -import BaseParityJson from './target/parity_base.json' assert { type: 'json' }; -import RootParityJson from './target/parity_root.json' assert { type: 'json' }; -import PrivateKernelEmptyJson from './target/private_kernel_empty.json' assert { type: 'json' }; -import PrivateKernelEmptySimulatedJson from './target/private_kernel_empty_simulated.json' assert { type: 'json' }; -import PrivateKernelInitJson from './target/private_kernel_init.json' assert { type: 'json' }; -import PrivateKernelInitSimulatedJson from './target/private_kernel_init_simulated.json' assert { type: 'json' }; -import PrivateKernelInnerJson from './target/private_kernel_inner.json' assert { type: 'json' }; -import PrivateKernelInnerSimulatedJson from './target/private_kernel_inner_simulated.json' assert { type: 'json' }; -import PrivateKernelResetJson from './target/private_kernel_reset.json' assert { type: 'json' }; -import PrivateKernelResetBigJson from './target/private_kernel_reset_big.json' assert { type: 'json' }; -import PrivateKernelResetMediumJson from './target/private_kernel_reset_medium.json' assert { type: 'json' }; -import PrivateKernelResetSimulatedJson from './target/private_kernel_reset_simulated.json' assert { type: 'json' }; -import PrivateKernelResetBigSimulatedJson from './target/private_kernel_reset_simulated_big.json' assert { type: 'json' }; -import PrivateKernelResetMediumSimulatedJson from './target/private_kernel_reset_simulated_medium.json' assert { type: 'json' }; -import PrivateKernelResetSmallSimulatedJson from './target/private_kernel_reset_simulated_small.json' assert { type: 'json' }; -import PrivateKernelResetSmallJson from './target/private_kernel_reset_small.json' assert { type: 'json' }; -import PrivateKernelTailJson from './target/private_kernel_tail.json' assert { type: 'json' }; -import PrivateKernelTailSimulatedJson from './target/private_kernel_tail_simulated.json' assert { type: 'json' }; -import PrivateKernelTailToPublicJson from './target/private_kernel_tail_to_public.json' assert { type: 'json' }; -import PrivateKernelTailToPublicSimulatedJson from './target/private_kernel_tail_to_public_simulated.json' assert { type: 'json' }; -import PublicKernelAppLogicJson from './target/public_kernel_app_logic.json' assert { type: 'json' }; -import PublicKernelAppLogicSimulatedJson from './target/public_kernel_app_logic_simulated.json' assert { type: 'json' }; -import PublicKernelSetupJson from './target/public_kernel_setup.json' assert { type: 'json' }; -import PublicKernelSetupSimulatedJson from './target/public_kernel_setup_simulated.json' assert { type: 'json' }; -import PublicKernelTailJson from './target/public_kernel_tail.json' assert { type: 'json' }; -import PublicKernelTailSimulatedJson from './target/public_kernel_tail_simulated.json' assert { type: 'json' }; -import PublicKernelTeardownJson from './target/public_kernel_teardown.json' assert { type: 'json' }; -import PublicKernelTeardownSimulatedJson from './target/public_kernel_teardown_simulated.json' assert { type: 'json' }; -import BaseRollupJson from './target/rollup_base.json' assert { type: 'json' }; -import BaseRollupSimulatedJson from './target/rollup_base_simulated.json' assert { type: 'json' }; -import MergeRollupJson from './target/rollup_merge.json' assert { type: 'json' }; -import RootRollupJson from './target/rollup_root.json' assert { type: 'json' }; import { mapBaseOrMergeRollupPublicInputsFromNoir, mapBaseParityInputsToNoir, @@ -106,6 +75,47 @@ import { PrivateKernelTail as executePrivateKernelTailWithACVM, } from './types/index.js'; +const __dirname = dirname(fileURLToPath(import.meta.url)); +function loadCircuit(name: string) { + const path = resolve(__dirname, `./target/${name}.json`); + return JSON.parse(readFileSync(path).toString()); +} + +const EmptyNestedJson = loadCircuit('empty_nested'); +const EmptyNestedSimulatedJson = loadCircuit('empty_nested_simulated'); +const BaseParityJson = loadCircuit('parity_base'); +const RootParityJson = loadCircuit('parity_root'); +const PrivateKernelEmptyJson = loadCircuit('private_kernel_empty'); +const PrivateKernelEmptySimulatedJson = loadCircuit('private_kernel_empty_simulated'); +const PrivateKernelInitJson = loadCircuit('private_kernel_init'); +const PrivateKernelInitSimulatedJson = loadCircuit('private_kernel_init_simulated'); +const PrivateKernelInnerJson = loadCircuit('private_kernel_inner'); +const PrivateKernelInnerSimulatedJson = loadCircuit('private_kernel_inner_simulated'); +const PrivateKernelResetJson = loadCircuit('private_kernel_reset'); +const PrivateKernelResetBigJson = loadCircuit('private_kernel_reset_big'); +const PrivateKernelResetMediumJson = loadCircuit('private_kernel_reset_medium'); +const PrivateKernelResetSimulatedJson = loadCircuit('private_kernel_reset_simulated'); +const PrivateKernelResetBigSimulatedJson = loadCircuit('private_kernel_reset_simulated_big'); +const PrivateKernelResetMediumSimulatedJson = loadCircuit('private_kernel_reset_simulated_medium'); +const PrivateKernelResetSmallSimulatedJson = loadCircuit('private_kernel_reset_simulated_small'); +const PrivateKernelResetSmallJson = loadCircuit('private_kernel_reset_small'); +const PrivateKernelTailJson = loadCircuit('private_kernel_tail'); +const PrivateKernelTailSimulatedJson = loadCircuit('private_kernel_tail_simulated'); +const PrivateKernelTailToPublicJson = loadCircuit('private_kernel_tail_to_public'); +const PrivateKernelTailToPublicSimulatedJson = loadCircuit('private_kernel_tail_to_public_simulated'); +const PublicKernelAppLogicJson = loadCircuit('public_kernel_app_logic'); +const PublicKernelAppLogicSimulatedJson = loadCircuit('public_kernel_app_logic_simulated'); +const PublicKernelSetupJson = loadCircuit('public_kernel_setup'); +const PublicKernelSetupSimulatedJson = loadCircuit('public_kernel_setup_simulated'); +const PublicKernelTailJson = loadCircuit('public_kernel_tail'); +const PublicKernelTailSimulatedJson = loadCircuit('public_kernel_tail_simulated'); +const PublicKernelTeardownJson = loadCircuit('public_kernel_teardown'); +const PublicKernelTeardownSimulatedJson = loadCircuit('public_kernel_teardown_simulated'); +const BaseRollupJson = loadCircuit('rollup_base'); +const BaseRollupSimulatedJson = loadCircuit('rollup_base_simulated'); +const MergeRollupJson = loadCircuit('rollup_merge'); +const RootRollupJson = loadCircuit('rollup_root'); + // TODO(Tom): This should be exported from noirc_abi /** * The decoded inputs from the circuit. diff --git a/yarn-project/protocol-contracts/src/class-registerer/artifact.ts b/yarn-project/protocol-contracts/src/class-registerer/artifact.ts index 433bf7b269c..eebec2af63f 100644 --- a/yarn-project/protocol-contracts/src/class-registerer/artifact.ts +++ b/yarn-project/protocol-contracts/src/class-registerer/artifact.ts @@ -1,8 +1,12 @@ +import { fileURLToPath } from '@aztec/foundation/url'; import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import ContractClassRegistererJson from '../artifacts/ContractClassRegisterer.json' assert { type: 'json' }; +import { readFileSync } from 'fs'; +import { dirname, resolve } from 'path'; + +const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/ContractClassRegisterer.json'); export const ContractClassRegistererArtifact = loadContractArtifact( - ContractClassRegistererJson as NoirCompiledContract, + JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract, ); diff --git a/yarn-project/protocol-contracts/src/gas-token/artifact.ts b/yarn-project/protocol-contracts/src/gas-token/artifact.ts index 0dbaf8c2d74..19cd98b4550 100644 --- a/yarn-project/protocol-contracts/src/gas-token/artifact.ts +++ b/yarn-project/protocol-contracts/src/gas-token/artifact.ts @@ -1,6 +1,12 @@ +import { fileURLToPath } from '@aztec/foundation/url'; import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import GasTokenJson from '../artifacts/GasToken.json' assert { type: 'json' }; +import { readFileSync } from 'fs'; +import { dirname, resolve } from 'path'; -export const GasTokenArtifact = loadContractArtifact(GasTokenJson as NoirCompiledContract); +const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/GasToken.json'); + +export const GasTokenArtifact = loadContractArtifact( + JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract, +); diff --git a/yarn-project/protocol-contracts/src/instance-deployer/artifact.ts b/yarn-project/protocol-contracts/src/instance-deployer/artifact.ts index 809e35873ac..f69daad6ad9 100644 --- a/yarn-project/protocol-contracts/src/instance-deployer/artifact.ts +++ b/yarn-project/protocol-contracts/src/instance-deployer/artifact.ts @@ -1,8 +1,12 @@ +import { fileURLToPath } from '@aztec/foundation/url'; import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import ContractInstanceDeployerJson from '../artifacts/ContractInstanceDeployer.json' assert { type: 'json' }; +import { readFileSync } from 'fs'; +import { dirname, resolve } from 'path'; + +const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/ContractInstanceDeployer.json'); export const ContractInstanceDeployerArtifact = loadContractArtifact( - ContractInstanceDeployerJson as NoirCompiledContract, + JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract, ); diff --git a/yarn-project/protocol-contracts/src/key-registry/artifact.ts b/yarn-project/protocol-contracts/src/key-registry/artifact.ts index 89436d313e6..4560ee49718 100644 --- a/yarn-project/protocol-contracts/src/key-registry/artifact.ts +++ b/yarn-project/protocol-contracts/src/key-registry/artifact.ts @@ -1,6 +1,12 @@ +import { fileURLToPath } from '@aztec/foundation/url'; import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import KeyRegistryJson from '../artifacts/KeyRegistry.json' assert { type: 'json' }; +import { readFileSync } from 'fs'; +import { dirname, resolve } from 'path'; -export const KeyRegistryArtifact = loadContractArtifact(KeyRegistryJson as NoirCompiledContract); +const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/KeyRegistry.json'); + +export const KeyRegistryArtifact = loadContractArtifact( + JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract, +); diff --git a/yarn-project/protocol-contracts/src/multi-call-entrypoint/artifact.ts b/yarn-project/protocol-contracts/src/multi-call-entrypoint/artifact.ts index b3cf23f9f41..f68cab2e142 100644 --- a/yarn-project/protocol-contracts/src/multi-call-entrypoint/artifact.ts +++ b/yarn-project/protocol-contracts/src/multi-call-entrypoint/artifact.ts @@ -1,6 +1,12 @@ +import { fileURLToPath } from '@aztec/foundation/url'; import { loadContractArtifact } from '@aztec/types/abi'; import { type NoirCompiledContract } from '@aztec/types/noir'; -import MultiCallEntrypoint from '../artifacts/MultiCallEntrypoint.json' assert { type: 'json' }; +import { readFileSync } from 'fs'; +import { dirname, resolve } from 'path'; -export const MultiCallEntrypointArtifact = loadContractArtifact(MultiCallEntrypoint as NoirCompiledContract); +const artifactPath = resolve(dirname(fileURLToPath(import.meta.url)), '../artifacts/MultiCallEntrypoint.json'); + +export const MultiCallEntrypointArtifact = loadContractArtifact( + JSON.parse(readFileSync(artifactPath, 'utf-8').toString()) as NoirCompiledContract, +); diff --git a/yarn-project/pxe/src/config/index.ts b/yarn-project/pxe/src/config/index.ts index b9caa044d73..601e00bf0c6 100644 --- a/yarn-project/pxe/src/config/index.ts +++ b/yarn-project/pxe/src/config/index.ts @@ -1,8 +1,8 @@ import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants'; +import { fileURLToPath } from '@aztec/foundation/url'; import { readFileSync } from 'fs'; import { dirname, resolve } from 'path'; -import { fileURLToPath } from 'url'; /** * Temporary configuration until WASM can be used instead of native diff --git a/yarn-project/types/src/test/fixtures.ts b/yarn-project/types/src/test/fixtures.ts index 9796b24cb12..7b3408ab18f 100644 --- a/yarn-project/types/src/test/fixtures.ts +++ b/yarn-project/types/src/test/fixtures.ts @@ -2,7 +2,7 @@ import { type ContractArtifact } from '@aztec/foundation/abi'; import { readFileSync } from 'fs'; import { dirname, resolve } from 'path'; -import { fileURLToPath } from 'url'; +import { fileURLToPath } from '@aztec/foundation/url'; import { loadContractArtifact } from '../abi/contract_artifact.js'; import { type NoirCompiledContract } from '../noir/index.js';