From 6952a1ab95b1febd0f1767e3560b2a8cc59622d2 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Tue, 17 Oct 2023 13:06:58 +0100 Subject: [PATCH] feat: contract ts interface to use only aztec.js imports (#2876) Currently we expect users to have `@aztec/foundation` npm package imported when everything except `ContractArtifact` is also exported from aztec.js Seems nice to just use 1 package! Also lint it! --- yarn-project/aztec.js/src/index.ts | 2 +- .../src/__snapshots__/index.test.ts.snap | 23 +++++++++++++++---- .../src/contract-interface-gen/typescript.ts | 23 +++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/yarn-project/aztec.js/src/index.ts b/yarn-project/aztec.js/src/index.ts index dd8d2ecc845..49d7c3b30dc 100644 --- a/yarn-project/aztec.js/src/index.ts +++ b/yarn-project/aztec.js/src/index.ts @@ -32,7 +32,7 @@ export { TxStatus, emptyFunctionCall, } from '@aztec/types'; - +export { ContractArtifact } from '@aztec/foundation/abi'; export { createDebugLogger, DebugLogger } from '@aztec/foundation/log'; export { fileURLToPath } from '@aztec/foundation/url'; export { sleep } from '@aztec/foundation/sleep'; diff --git a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap index 7a7d4d491db..015c050e6b7 100644 --- a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap +++ b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap @@ -265,10 +265,25 @@ exports[`noir-compiler using nargo binary generates typescript interface 1`] = ` /* Autogenerated file, do not edit! */ /* eslint-disable */ -import { AztecAddress, CompleteAddress, Contract, ContractBase, ContractFunctionInteraction, ContractMethod, DeployMethod, EthAddress, FieldLike, AztecAddressLike, EthAddressLike, Wallet } from '@aztec/aztec.js'; -import { Fr, Point } from '@aztec/foundation/fields'; -import { PXE, PublicKey } from '@aztec/types'; -import { ContractArtifact } from '@aztec/foundation/abi'; +import { + AztecAddress, + AztecAddressLike, + CompleteAddress, + Contract, + ContractArtifact, + ContractBase, + ContractFunctionInteraction, + ContractMethod, + DeployMethod, + EthAddress, + EthAddressLike, + FieldLike, + Fr, + PXE, + Point, + PublicKey, + Wallet, +} from '@aztec/aztec.js'; import TestContractContractArtifactJson from '../target/test.json' assert { type: 'json' }; export const TestContractContractArtifact = TestContractContractArtifactJson as ContractArtifact; diff --git a/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts b/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts index cda7c47e4a8..38e6db4066f 100644 --- a/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts +++ b/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts @@ -171,10 +171,25 @@ export function generateTypescriptContractInterface(input: ContractArtifact, art /* Autogenerated file, do not edit! */ /* eslint-disable */ -import { AztecAddress, CompleteAddress, Contract, ContractBase, ContractFunctionInteraction, ContractMethod, DeployMethod, EthAddress, FieldLike, AztecAddressLike, EthAddressLike, Wallet } from '@aztec/aztec.js'; -import { Fr, Point } from '@aztec/foundation/fields'; -import { PXE, PublicKey } from '@aztec/types'; -import { ContractArtifact } from '@aztec/foundation/abi'; +import { + AztecAddress, + AztecAddressLike, + CompleteAddress, + Contract, + ContractArtifact, + ContractBase, + ContractFunctionInteraction, + ContractMethod, + DeployMethod, + EthAddress, + EthAddressLike, + FieldLike, + Fr, + PXE, + Point, + PublicKey, + Wallet, +} from '@aztec/aztec.js'; ${artifactStatement} /**