From a3b18048479ee3bed3931615e5eabd27efacd404 Mon Sep 17 00:00:00 2001 From: Dan Lee <142251406+dan-aztec@users.noreply.github.com> Date: Wed, 18 Oct 2023 03:23:32 -0700 Subject: [PATCH] fix: boxes boostrap dont use ts-node directly and add .prettierignore (#2890) since ts-node is available in subpackage, but not in yarn-packages in general --- .../boxes/blank-react/.prettierignore | 1 + yarn-project/boxes/blank-react/package.json | 1 + .../blank-react/src/artifacts/Blank.json | 2 +- .../boxes/blank-react/src/artifacts/Blank.ts | 36 +++++-- yarn-project/boxes/blank/.prettierignore | 1 + yarn-project/boxes/blank/package.json | 1 + .../boxes/blank/src/artifacts/Blank.json | 2 +- .../boxes/blank/src/artifacts/Blank.ts | 36 +++++-- yarn-project/boxes/bootstrap.sh | 11 +-- yarn-project/boxes/token/.prettierignore | 1 + yarn-project/boxes/token/package.json | 1 + .../boxes/token/src/artifacts/Token.json | 2 +- .../boxes/token/src/artifacts/Token.ts | 93 ++++++++----------- 13 files changed, 103 insertions(+), 85 deletions(-) create mode 100644 yarn-project/boxes/blank-react/.prettierignore create mode 100644 yarn-project/boxes/blank/.prettierignore create mode 100644 yarn-project/boxes/token/.prettierignore diff --git a/yarn-project/boxes/blank-react/.prettierignore b/yarn-project/boxes/blank-react/.prettierignore new file mode 100644 index 00000000000..a99f142a2d2 --- /dev/null +++ b/yarn-project/boxes/blank-react/.prettierignore @@ -0,0 +1 @@ +src/artifacts/**/*.{ts,json} \ No newline at end of file diff --git a/yarn-project/boxes/blank-react/package.json b/yarn-project/boxes/blank-react/package.json index 5948e40c4e1..41acf728f63 100644 --- a/yarn-project/boxes/blank-react/package.json +++ b/yarn-project/boxes/blank-react/package.json @@ -15,6 +15,7 @@ "formatting": "prettier --check ./src && eslint ./src", "formatting:fix": "prettier -w ./src", "compile": "aztec-cli compile src/contracts --outdir ../artifacts --typescript ../artifacts", + "compile:local": "ts-node --esm ../../cli/src/bin/index.ts compile \"src/contracts\" --outdir \"../artifacts\" --typescript \"../artifacts\"", "test:integration": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand" }, "jest": { diff --git a/yarn-project/boxes/blank-react/src/artifacts/Blank.json b/yarn-project/boxes/blank-react/src/artifacts/Blank.json index 9acb8bf4ddd..3ea55fe86ec 100644 --- a/yarn-project/boxes/blank-react/src/artifacts/Blank.json +++ b/yarn-project/boxes/blank-react/src/artifacts/Blank.json @@ -49,4 +49,4 @@ } } } -} +} \ No newline at end of file diff --git a/yarn-project/boxes/blank-react/src/artifacts/Blank.ts b/yarn-project/boxes/blank-react/src/artifacts/Blank.ts index 264ab2c785a..250472b6edb 100644 --- a/yarn-project/boxes/blank-react/src/artifacts/Blank.ts +++ b/yarn-project/boxes/blank-react/src/artifacts/Blank.ts @@ -1,23 +1,26 @@ + /* Autogenerated file, do not edit! */ /* eslint-disable */ import { AztecAddress, + AztecAddressLike, CompleteAddress, Contract, + ContractArtifact, ContractBase, ContractFunctionInteraction, ContractMethod, DeployMethod, EthAddress, - FieldLike, - AztecAddressLike, EthAddressLike, + FieldLike, + Fr, + PXE, + Point, + PublicKey, 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 BlankContractArtifactJson from './Blank.json' assert { type: 'json' }; export const BlankContractArtifact = BlankContractArtifactJson as ContractArtifact; @@ -25,43 +28,58 @@ export const BlankContractArtifact = BlankContractArtifactJson as ContractArtifa * Type-safe interface for contract Blank; */ export class BlankContract extends ContractBase { - private constructor(completeAddress: CompleteAddress, wallet: Wallet, portalContract = EthAddress.ZERO) { + + private constructor( + completeAddress: CompleteAddress, + wallet: Wallet, + portalContract = EthAddress.ZERO + ) { super(completeAddress, BlankContractArtifact, wallet, portalContract); } + + /** * Creates a contract instance. * @param address - The deployed contract's address. * @param wallet - The wallet to use when interacting with the contract. * @returns A promise that resolves to a new Contract instance. */ - public static async at(address: AztecAddress, wallet: Wallet) { + public static async at( + address: AztecAddress, + wallet: Wallet, + ) { return Contract.at(address, BlankContract.artifact, wallet) as Promise; } + /** * Creates a tx to deploy a new instance of this contract. */ - public static deploy(pxe: PXE) { + public static deploy(pxe: PXE, ) { return new DeployMethod(Point.ZERO, pxe, BlankContractArtifact, Array.from(arguments).slice(1)); } /** * Creates a tx to deploy a new instance of this contract using the specified public key to derive the address. */ - public static deployWithPublicKey(pxe: PXE, publicKey: PublicKey) { + public static deployWithPublicKey(pxe: PXE, publicKey: PublicKey, ) { return new DeployMethod(publicKey, pxe, BlankContractArtifact, Array.from(arguments).slice(2)); } + + /** * Returns this contract's artifact. */ public static get artifact(): ContractArtifact { return BlankContractArtifact; } + /** Type-safe wrappers for the public methods exposed by the contract. */ public methods!: { + /** getPublicKey(address: field) */ getPublicKey: ((address: FieldLike) => ContractFunctionInteraction) & Pick; }; diff --git a/yarn-project/boxes/blank/.prettierignore b/yarn-project/boxes/blank/.prettierignore new file mode 100644 index 00000000000..a99f142a2d2 --- /dev/null +++ b/yarn-project/boxes/blank/.prettierignore @@ -0,0 +1 @@ +src/artifacts/**/*.{ts,json} \ No newline at end of file diff --git a/yarn-project/boxes/blank/package.json b/yarn-project/boxes/blank/package.json index 180b6aa4a04..0312ca54c9d 100644 --- a/yarn-project/boxes/blank/package.json +++ b/yarn-project/boxes/blank/package.json @@ -15,6 +15,7 @@ "formatting": "prettier --check ./src && eslint ./src", "formatting:fix": "prettier -w ./src", "compile": "aztec-cli compile src/contracts --outdir ../artifacts --typescript ../artifacts", + "compile:local": "ts-node --esm ../../cli/src/bin/index.ts compile \"src/contracts\" --outdir \"../artifacts\" --typescript \"../artifacts\"", "test:integration": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand" }, "jest": { diff --git a/yarn-project/boxes/blank/src/artifacts/Blank.json b/yarn-project/boxes/blank/src/artifacts/Blank.json index 9acb8bf4ddd..3ea55fe86ec 100644 --- a/yarn-project/boxes/blank/src/artifacts/Blank.json +++ b/yarn-project/boxes/blank/src/artifacts/Blank.json @@ -49,4 +49,4 @@ } } } -} +} \ No newline at end of file diff --git a/yarn-project/boxes/blank/src/artifacts/Blank.ts b/yarn-project/boxes/blank/src/artifacts/Blank.ts index 264ab2c785a..250472b6edb 100644 --- a/yarn-project/boxes/blank/src/artifacts/Blank.ts +++ b/yarn-project/boxes/blank/src/artifacts/Blank.ts @@ -1,23 +1,26 @@ + /* Autogenerated file, do not edit! */ /* eslint-disable */ import { AztecAddress, + AztecAddressLike, CompleteAddress, Contract, + ContractArtifact, ContractBase, ContractFunctionInteraction, ContractMethod, DeployMethod, EthAddress, - FieldLike, - AztecAddressLike, EthAddressLike, + FieldLike, + Fr, + PXE, + Point, + PublicKey, 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 BlankContractArtifactJson from './Blank.json' assert { type: 'json' }; export const BlankContractArtifact = BlankContractArtifactJson as ContractArtifact; @@ -25,43 +28,58 @@ export const BlankContractArtifact = BlankContractArtifactJson as ContractArtifa * Type-safe interface for contract Blank; */ export class BlankContract extends ContractBase { - private constructor(completeAddress: CompleteAddress, wallet: Wallet, portalContract = EthAddress.ZERO) { + + private constructor( + completeAddress: CompleteAddress, + wallet: Wallet, + portalContract = EthAddress.ZERO + ) { super(completeAddress, BlankContractArtifact, wallet, portalContract); } + + /** * Creates a contract instance. * @param address - The deployed contract's address. * @param wallet - The wallet to use when interacting with the contract. * @returns A promise that resolves to a new Contract instance. */ - public static async at(address: AztecAddress, wallet: Wallet) { + public static async at( + address: AztecAddress, + wallet: Wallet, + ) { return Contract.at(address, BlankContract.artifact, wallet) as Promise; } + /** * Creates a tx to deploy a new instance of this contract. */ - public static deploy(pxe: PXE) { + public static deploy(pxe: PXE, ) { return new DeployMethod(Point.ZERO, pxe, BlankContractArtifact, Array.from(arguments).slice(1)); } /** * Creates a tx to deploy a new instance of this contract using the specified public key to derive the address. */ - public static deployWithPublicKey(pxe: PXE, publicKey: PublicKey) { + public static deployWithPublicKey(pxe: PXE, publicKey: PublicKey, ) { return new DeployMethod(publicKey, pxe, BlankContractArtifact, Array.from(arguments).slice(2)); } + + /** * Returns this contract's artifact. */ public static get artifact(): ContractArtifact { return BlankContractArtifact; } + /** Type-safe wrappers for the public methods exposed by the contract. */ public methods!: { + /** getPublicKey(address: field) */ getPublicKey: ((address: FieldLike) => ContractFunctionInteraction) & Pick; }; diff --git a/yarn-project/boxes/bootstrap.sh b/yarn-project/boxes/bootstrap.sh index 999014560aa..340bc0e8972 100755 --- a/yarn-project/boxes/bootstrap.sh +++ b/yarn-project/boxes/bootstrap.sh @@ -1,6 +1,5 @@ #!/bin/bash - # should be run from yarn-project/boxes original_path=$(pwd) @@ -9,16 +8,12 @@ for dir in *; do # Check if it's a directory if [ -d "${dir}" ]; then + cd "${dir}" # Run the compile command echo "Running compile command inside ${dir}..." - # Change directory to ../cli - cd ../cli - - # Run ts-node command to use latest "compile" code - ts-node --esm src/bin/index.ts compile "${original_path}/${dir}/src/contracts" --outdir "${original_path}/${dir}/src/artifacts" --typescript "${original_path}/${dir}/src/artifacts" - - yarn formatting:fix + # Runs ts-node command from "../cli" to use latest "compile" code. this uses the yarn command to use the subpackage ts-node dep + yarn compile:local # Change back to the original directory cd "${original_path}" diff --git a/yarn-project/boxes/token/.prettierignore b/yarn-project/boxes/token/.prettierignore new file mode 100644 index 00000000000..a99f142a2d2 --- /dev/null +++ b/yarn-project/boxes/token/.prettierignore @@ -0,0 +1 @@ +src/artifacts/**/*.{ts,json} \ No newline at end of file diff --git a/yarn-project/boxes/token/package.json b/yarn-project/boxes/token/package.json index 3bdccccf02d..00e080e3daa 100644 --- a/yarn-project/boxes/token/package.json +++ b/yarn-project/boxes/token/package.json @@ -15,6 +15,7 @@ "formatting": "prettier --check ./src && eslint ./src", "formatting:fix": "prettier -w ./src", "compile": "aztec-cli compile src/contracts --outdir ../artifacts --typescript ../artifacts", + "compile:local": "ts-node --esm ../../cli/src/bin/index.ts compile \"src/contracts\" --outdir \"../artifacts\" --typescript \"../artifacts\"", "test:integration": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand" }, "jest": { diff --git a/yarn-project/boxes/token/src/artifacts/Token.json b/yarn-project/boxes/token/src/artifacts/Token.json index 92cf7430560..152a1b40e75 100644 --- a/yarn-project/boxes/token/src/artifacts/Token.json +++ b/yarn-project/boxes/token/src/artifacts/Token.json @@ -3357,4 +3357,4 @@ } } } -} +} \ No newline at end of file diff --git a/yarn-project/boxes/token/src/artifacts/Token.ts b/yarn-project/boxes/token/src/artifacts/Token.ts index 4e0f7a0b494..d26317f5314 100644 --- a/yarn-project/boxes/token/src/artifacts/Token.ts +++ b/yarn-project/boxes/token/src/artifacts/Token.ts @@ -1,23 +1,26 @@ + /* Autogenerated file, do not edit! */ /* eslint-disable */ import { AztecAddress, + AztecAddressLike, CompleteAddress, Contract, + ContractArtifact, ContractBase, ContractFunctionInteraction, ContractMethod, DeployMethod, EthAddress, - FieldLike, - AztecAddressLike, EthAddressLike, + FieldLike, + Fr, + PXE, + Point, + PublicKey, 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 TokenContractArtifactJson from './Token.json' assert { type: 'json' }; export const TokenContractArtifact = TokenContractArtifactJson as ContractArtifact; @@ -25,20 +28,31 @@ export const TokenContractArtifact = TokenContractArtifactJson as ContractArtifa * Type-safe interface for contract Token; */ export class TokenContract extends ContractBase { - private constructor(completeAddress: CompleteAddress, wallet: Wallet, portalContract = EthAddress.ZERO) { + + private constructor( + completeAddress: CompleteAddress, + wallet: Wallet, + portalContract = EthAddress.ZERO + ) { super(completeAddress, TokenContractArtifact, wallet, portalContract); } + + /** * Creates a contract instance. * @param address - The deployed contract's address. * @param wallet - The wallet to use when interacting with the contract. * @returns A promise that resolves to a new Contract instance. */ - public static async at(address: AztecAddress, wallet: Wallet) { + public static async at( + address: AztecAddress, + wallet: Wallet, + ) { return Contract.at(address, TokenContract.artifact, wallet) as Promise; } + /** * Creates a tx to deploy a new instance of this contract. */ @@ -52,19 +66,22 @@ export class TokenContract extends ContractBase { public static deployWithPublicKey(pxe: PXE, publicKey: PublicKey, admin: AztecAddressLike) { return new DeployMethod(publicKey, pxe, TokenContractArtifact, Array.from(arguments).slice(2)); } + + /** * Returns this contract's artifact. */ public static get artifact(): ContractArtifact { return TokenContractArtifact; } + /** Type-safe wrappers for the public methods exposed by the contract. */ public methods!: { + /** _increase_public_balance(to: struct, amount: field) */ - _increase_public_balance: ((to: AztecAddressLike, amount: FieldLike) => ContractFunctionInteraction) & - Pick; + _increase_public_balance: ((to: AztecAddressLike, amount: FieldLike) => ContractFunctionInteraction) & Pick; /** _initialize(new_admin: struct) */ _initialize: ((new_admin: AztecAddressLike) => ContractFunctionInteraction) & Pick; @@ -82,81 +99,45 @@ export class TokenContract extends ContractBase { balance_of_public: ((owner: AztecAddressLike) => ContractFunctionInteraction) & Pick; /** burn(from: struct, amount: field, nonce: field) */ - burn: ((from: AztecAddressLike, amount: FieldLike, nonce: FieldLike) => ContractFunctionInteraction) & - Pick; + burn: ((from: AztecAddressLike, amount: FieldLike, nonce: FieldLike) => ContractFunctionInteraction) & Pick; /** burn_public(from: struct, amount: field, nonce: field) */ - burn_public: ((from: AztecAddressLike, amount: FieldLike, nonce: FieldLike) => ContractFunctionInteraction) & - Pick; + burn_public: ((from: AztecAddressLike, amount: FieldLike, nonce: FieldLike) => ContractFunctionInteraction) & Pick; /** compute_note_hash_and_nullifier(contract_address: field, nonce: field, storage_slot: field, preimage: array) */ - compute_note_hash_and_nullifier: (( - contract_address: FieldLike, - nonce: FieldLike, - storage_slot: FieldLike, - preimage: FieldLike[], - ) => ContractFunctionInteraction) & - Pick; + compute_note_hash_and_nullifier: ((contract_address: FieldLike, nonce: FieldLike, storage_slot: FieldLike, preimage: FieldLike[]) => ContractFunctionInteraction) & Pick; /** is_minter(minter: struct) */ is_minter: ((minter: AztecAddressLike) => ContractFunctionInteraction) & Pick; /** mint_private(amount: field, secret_hash: field) */ - mint_private: ((amount: FieldLike, secret_hash: FieldLike) => ContractFunctionInteraction) & - Pick; + mint_private: ((amount: FieldLike, secret_hash: FieldLike) => ContractFunctionInteraction) & Pick; /** mint_public(to: struct, amount: field) */ - mint_public: ((to: AztecAddressLike, amount: FieldLike) => ContractFunctionInteraction) & - Pick; + mint_public: ((to: AztecAddressLike, amount: FieldLike) => ContractFunctionInteraction) & Pick; /** redeem_shield(to: struct, amount: field, secret: field) */ - redeem_shield: ((to: AztecAddressLike, amount: FieldLike, secret: FieldLike) => ContractFunctionInteraction) & - Pick; + redeem_shield: ((to: AztecAddressLike, amount: FieldLike, secret: FieldLike) => ContractFunctionInteraction) & Pick; /** set_admin(new_admin: struct) */ set_admin: ((new_admin: AztecAddressLike) => ContractFunctionInteraction) & Pick; /** set_minter(minter: struct, approve: boolean) */ - set_minter: ((minter: AztecAddressLike, approve: boolean) => ContractFunctionInteraction) & - Pick; + set_minter: ((minter: AztecAddressLike, approve: boolean) => ContractFunctionInteraction) & Pick; /** shield(from: struct, amount: field, secret_hash: field, nonce: field) */ - shield: (( - from: AztecAddressLike, - amount: FieldLike, - secret_hash: FieldLike, - nonce: FieldLike, - ) => ContractFunctionInteraction) & - Pick; + shield: ((from: AztecAddressLike, amount: FieldLike, secret_hash: FieldLike, nonce: FieldLike) => ContractFunctionInteraction) & Pick; /** total_supply() */ total_supply: (() => ContractFunctionInteraction) & Pick; /** transfer(from: struct, to: struct, amount: field, nonce: field) */ - transfer: (( - from: AztecAddressLike, - to: AztecAddressLike, - amount: FieldLike, - nonce: FieldLike, - ) => ContractFunctionInteraction) & - Pick; + transfer: ((from: AztecAddressLike, to: AztecAddressLike, amount: FieldLike, nonce: FieldLike) => ContractFunctionInteraction) & Pick; /** transfer_public(from: struct, to: struct, amount: field, nonce: field) */ - transfer_public: (( - from: AztecAddressLike, - to: AztecAddressLike, - amount: FieldLike, - nonce: FieldLike, - ) => ContractFunctionInteraction) & - Pick; + transfer_public: ((from: AztecAddressLike, to: AztecAddressLike, amount: FieldLike, nonce: FieldLike) => ContractFunctionInteraction) & Pick; /** unshield(from: struct, to: struct, amount: field, nonce: field) */ - unshield: (( - from: AztecAddressLike, - to: AztecAddressLike, - amount: FieldLike, - nonce: FieldLike, - ) => ContractFunctionInteraction) & - Pick; + unshield: ((from: AztecAddressLike, to: AztecAddressLike, amount: FieldLike, nonce: FieldLike) => ContractFunctionInteraction) & Pick; }; }