From 4b8fe868891620f78db4e486b67fa86a0b7bc268 Mon Sep 17 00:00:00 2001 From: oleh Date: Sun, 25 Aug 2024 17:28:29 +0000 Subject: [PATCH 1/2] fix: ts codegen for verbatimModuleSyntax --- .../src/contract-interface-gen/typescript.ts | 33 ++++++++++--------- yarn-project/noir-contracts.js/tsconfig.json | 3 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/yarn-project/builder/src/contract-interface-gen/typescript.ts b/yarn-project/builder/src/contract-interface-gen/typescript.ts index d092f4b0688..02b95571b6f 100644 --- a/yarn-project/builder/src/contract-interface-gen/typescript.ts +++ b/yarn-project/builder/src/contract-interface-gen/typescript.ts @@ -316,7 +316,10 @@ function generateEvents(events: any[] | undefined) { * @returns The corresponding ts code. */ export function generateTypescriptContractInterface(input: ContractArtifact, artifactImportPath?: string) { - const methods = input.functions.filter(f => !f.isInternal).map(generateMethod); + const methods = input.functions + .filter(f => !f.isInternal) + .sort((a, b) => a.name.localeCompare(b.name)) + .map(generateMethod); const deploy = artifactImportPath && generateDeploy(input); const ctor = artifactImportPath && generateConstructor(input.name); const at = artifactImportPath && generateAt(input.name); @@ -332,31 +335,31 @@ export function generateTypescriptContractInterface(input: ContractArtifact, art /* eslint-disable */ import { AztecAddress, - AztecAddressLike, + type AztecAddressLike, CompleteAddress, Contract, - ContractArtifact, + type ContractArtifact, ContractBase, ContractFunctionInteraction, - ContractInstanceWithAddress, - ContractMethod, - ContractStorageLayout, - ContractNotes, + type ContractInstanceWithAddress, + type ContractMethod, + type ContractStorageLayout, + type ContractNotes, DeployMethod, EthAddress, - EthAddressLike, + type EthAddressLike, EventSelector, - FieldLike, + type FieldLike, Fr, - FunctionSelectorLike, + type FunctionSelectorLike, L1EventPayload, loadContractArtifact, - NoirCompiledContract, + type NoirCompiledContract, NoteSelector, Point, - PublicKey, - Wallet, - WrappedFieldLike, + type PublicKey, + type Wallet, + type WrappedFieldLike, } from '@aztec/aztec.js'; ${artifactStatement} @@ -379,7 +382,7 @@ export class ${input.name}Contract extends ContractBase { ${notesGetter} /** Type-safe wrappers for the public methods exposed by the contract. */ - public override methods!: { + declare public methods: { ${methods.join('\n')} }; diff --git a/yarn-project/noir-contracts.js/tsconfig.json b/yarn-project/noir-contracts.js/tsconfig.json index 92add33fb36..759d328363d 100644 --- a/yarn-project/noir-contracts.js/tsconfig.json +++ b/yarn-project/noir-contracts.js/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "dest", "rootDir": "src", - "tsBuildInfoFile": ".tsbuildinfo" + "tsBuildInfoFile": ".tsbuildinfo", + "verbatimModuleSyntax": true }, "references": [ { From 2c46cb7a9a9b2fb60b8d4022cfb21fd5fe2591fd Mon Sep 17 00:00:00 2001 From: oleh Date: Tue, 27 Aug 2024 20:44:25 +0000 Subject: [PATCH 2/2] address review comments --- yarn-project/builder/src/contract-interface-gen/typescript.ts | 2 +- yarn-project/noir-contracts.js/tsconfig.json | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/yarn-project/builder/src/contract-interface-gen/typescript.ts b/yarn-project/builder/src/contract-interface-gen/typescript.ts index 02b95571b6f..056ef1154b3 100644 --- a/yarn-project/builder/src/contract-interface-gen/typescript.ts +++ b/yarn-project/builder/src/contract-interface-gen/typescript.ts @@ -382,7 +382,7 @@ export class ${input.name}Contract extends ContractBase { ${notesGetter} /** Type-safe wrappers for the public methods exposed by the contract. */ - declare public methods: { + public declare methods: { ${methods.join('\n')} }; diff --git a/yarn-project/noir-contracts.js/tsconfig.json b/yarn-project/noir-contracts.js/tsconfig.json index 759d328363d..92add33fb36 100644 --- a/yarn-project/noir-contracts.js/tsconfig.json +++ b/yarn-project/noir-contracts.js/tsconfig.json @@ -3,8 +3,7 @@ "compilerOptions": { "outDir": "dest", "rootDir": "src", - "tsBuildInfoFile": ".tsbuildinfo", - "verbatimModuleSyntax": true + "tsBuildInfoFile": ".tsbuildinfo" }, "references": [ {