Skip to content

Commit

Permalink
feat: auto-recompile the boxes and fix broken frontend CompleteAddres…
Browse files Browse the repository at this point in the history
…s import (#2727)

[forking prior PR to see where e2e tests
failed](#2635), got
in a bad state so splitting into smaller PRs.

This will help keep the boxes up to date by introducing a `bootstrap.sh`
for boxes, which recompiles within the monorepo using the latest local
`aztec-cli compile` command.

The artifact casing changes because `noir-contracts` compile script does
some manual changing to kebab case.

--> changes box contract Nargo.toml to be buildable within monorepo by
using relative paths for deps. These get updated now in the `unbox`
command.

Also discovered `CompleteAddress` was broken in the frontend, Leila
helped resolve import errors. added a test for the in e2e browser. This
means boxes are broken on current release of our packages, so need to
release again after this lands.

Will do a follow up PR for reducing dependencies to just
`@aztec/aztec.js`, as this PR is getting big
  • Loading branch information
dan-aztec authored Oct 10, 2023
1 parent 6ff7bed commit 4ec4ea0
Show file tree
Hide file tree
Showing 42 changed files with 466 additions and 414 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Point } from '@aztec/circuits.js';
import { ContractAbi } from '@aztec/foundation/abi';
import { Point } from '@aztec/foundation/fields';
import { PXE, PublicKey } from '@aztec/types';

import { DeployMethod } from './deploy_method.js';
Expand Down
1 change: 1 addition & 0 deletions yarn-project/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ yarn --cwd circuits.js remake-bindings
yarn --cwd circuits.js remake-constants

(cd noir-contracts && ./bootstrap.sh)
(cd boxes && ./bootstrap.sh)
(cd .. && l1-contracts/bootstrap.sh)

# Until we push .yarn/cache, we still need to install.
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/boxes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This contains the "boxes" that are meant for quickstarts for Aztec smart contract developers, containing simple Noir smart contracts and frontends.

If CI is failing, it may be due to incompatibility with previous build artifacts - running "./bootstrap.sh" inside this boxes folder should regenerate the artifacts.
1 change: 0 additions & 1 deletion yarn-project/boxes/blank-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"@aztec/aztec-ui": "^0.1.14",
"@aztec/aztec.js": "workspace:^",
"@aztec/circuits.js": "workspace:^",
"@aztec/cli": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/types": "workspace:^",
"classnames": "^2.3.2",
Expand Down
51 changes: 51 additions & 0 deletions yarn-project/boxes/blank-react/src/artifacts/Blank.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { Fr, Point } from '@aztec/foundation/fields';
import { PXE, PublicKey } from '@aztec/types';
import { ContractAbi } from '@aztec/foundation/abi';
import BlankContractAbiJson from './blank_contract.json' assert { type: 'json' };
import BlankContractAbiJson from './Blank.json' assert { type: 'json' };
export const BlankContractAbi = BlankContractAbiJson as ContractAbi;

/**
Expand Down
51 changes: 0 additions & 51 deletions yarn-project/boxes/blank-react/src/artifacts/blank_contract.json

This file was deleted.

2 changes: 1 addition & 1 deletion yarn-project/boxes/blank-react/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PXE, createPXEClient } from '@aztec/aztec.js';
import { ContractAbi } from '@aztec/foundation/abi';
import { BlankContractAbi } from './artifacts/blank.js';
import { BlankContractAbi } from './artifacts/Blank.js';

// update this if using a different contract

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank-react/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ compiler_version = "0.1"
type = "contract"

[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages", tag="master", directory="yarn-project/aztec-nr/aztec" }
aztec = { path = "../../../../aztec-nr/aztec" }
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { BlankContract } from '../artifacts/blank.js';
import { callContractFunction, deployContract, getWallet } from '../scripts/index.js';
import {
AccountWallet,
AztecAddress,
PXE,
CompleteAddress,
Contract,
Fr,
PXE,
TxStatus,
Wallet,
createPXEClient,
waitForSandbox,
} from '@aztec/aztec.js';
import { createDebugLogger } from '@aztec/foundation/log';
import { BlankContract } from '../artifacts/Blank.js';
import { callContractFunction, deployContract, getWallet } from '../scripts/index.js';

const logger = createDebugLogger('aztec:http-pxe-client');

Expand Down
1 change: 0 additions & 1 deletion yarn-project/boxes/blank-react/tsconfig.dest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": ".",
"references": [
{ "path": "../../aztec.js" },
{ "path": "../../cli" },
{ "path": "../../foundation" },
{ "path": "../../types" }
],
Expand Down
3 changes: 0 additions & 3 deletions yarn-project/boxes/blank-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
{
"path": "../../circuits.js"
},
{
"path": "../../cli"
},
{
"path": "../../foundation"
},
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank-react/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const require = createRequire(import.meta.url);
export default (_, argv) => ({
target: 'web',
mode: 'production',
devtool: false,
devtool: 'source-map',
entry: {
main: './src/app/index.tsx',
},
Expand Down
1 change: 0 additions & 1 deletion yarn-project/boxes/blank/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"@aztec/aztec-ui": "^0.1.14",
"@aztec/aztec.js": "workspace:^",
"@aztec/circuits.js": "workspace:^",
"@aztec/cli": "workspace:^",
"@aztec/foundation": "workspace:^",
"serve": "^14.2.1"
},
Expand Down
51 changes: 51 additions & 0 deletions yarn-project/boxes/blank/src/artifacts/Blank.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { Fr, Point } from '@aztec/foundation/fields';
import { PXE, PublicKey } from '@aztec/types';
import { ContractAbi } from '@aztec/foundation/abi';
import BlankContractAbiJson from './blank_contract.json' assert { type: 'json' };
import BlankContractAbiJson from './Blank.json' assert { type: 'json' };
export const BlankContractAbi = BlankContractAbiJson as ContractAbi;

/**
Expand Down
51 changes: 0 additions & 51 deletions yarn-project/boxes/blank/src/artifacts/blank_contract.json

This file was deleted.

2 changes: 1 addition & 1 deletion yarn-project/boxes/blank/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ compiler_version = "0.1"
type = "contract"

[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages", tag="master", directory="yarn-project/aztec-nr/aztec" }
aztec = { path = "../../../../aztec-nr/aztec" }
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@aztec/aztec.js';
import { ContractAbi, FunctionAbi, encodeArguments } from '@aztec/foundation/abi';
import { FieldsOf } from '@aztec/foundation/types';
import { BlankContractAbi } from './artifacts/blank.js';
import { BlankContractAbi } from './artifacts/Blank.js';
export const contractAbi: ContractAbi = BlankContractAbi;

export const PXE_URL: string = process.env.PXE_URL || 'http://localhost:8080';
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/boxes/blank/src/tests/blank.contract.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {
AccountWallet,
AztecAddress,
PXE,
CompleteAddress,
Contract,
Fr,
PXE,
TxStatus,
Wallet,
createPXEClient,
waitForSandbox,
} from '@aztec/aztec.js';
import { createDebugLogger } from '@aztec/foundation/log';
import { BlankContract } from '../artifacts/blank.js';
import { BlankContract } from '../artifacts/Blank.js';
import { callContractFunction, deployContract, getWallet } from '../index.js';
const logger = createDebugLogger('aztec:blank-box-test');

Expand Down
1 change: 0 additions & 1 deletion yarn-project/boxes/blank/tsconfig.dest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": ".",
"references": [
{ "path": "../../aztec.js" },
{ "path": "../../cli" },
{ "path": "../../foundation" },
{ "path": "../../types" }
],
Expand Down
3 changes: 0 additions & 3 deletions yarn-project/boxes/blank/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
{
"path": "../../circuits.js"
},
{
"path": "../../cli"
},
{
"path": "../../foundation"
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const require = createRequire(import.meta.url);
export default (_, argv) => ({
target: 'web',
mode: 'production',
devtool: false,
devtool: 'source-map',
entry: {
main: './src/index.ts',
},
Expand Down
25 changes: 25 additions & 0 deletions yarn-project/boxes/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash


# should be run from yarn-project/boxes
original_path=$(pwd)

# Loop through all directories in 'boxes'
for dir in *; do
# Check if it's a directory
if [ -d "${dir}" ]; then

# 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"

# Change back to the original directory
cd "${original_path}"

fi
done
1 change: 0 additions & 1 deletion yarn-project/boxes/private-token/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"@aztec/aztec-ui": "^0.1.14",
"@aztec/aztec.js": "workspace:^",
"@aztec/circuits.js": "workspace:^",
"@aztec/cli": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/types": "workspace:^",
"classnames": "^2.3.2",
Expand Down
Loading

0 comments on commit 4ec4ea0

Please sign in to comment.