Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix box noir versioning #2578

Merged
merged 13 commits into from
Sep 28, 2023
6 changes: 4 additions & 2 deletions yarn-project/boxes/blank-react/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
parserOptions: {
project: './tsconfig.json',
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
Expand All @@ -15,14 +18,13 @@ module.exports = {
node: true,
},
},
ignorePatterns: ['dist', '.eslintrc.cjs'],
ignorePatterns: ['dest', 'webpack.config.js', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
overrides: [
{
files: ['*.ts', '*.tsx'],
parserOptions: {
// hacky workaround for CI not having the same tsconfig setup
project: true,
},
},
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "./dest/index.js",
"scripts": {
"build": "yarn clean && tsc -b && webpack",
"install:noir": "curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup -v aztec",
"install:noir": "curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup -v NOIR_VERSION",
"install:sandbox": "docker pull aztecprotocol/aztec-sandbox:latest",
"clean": "rm -rf ./dest .tsbuildinfo",
"start": "serve -p 3000 ./dest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AztecAddress, CompleteAddress, Fr } from '@aztec/aztec.js';
import { ContractAbi, FunctionAbi } from '@aztec/foundation/abi';
import { useFormik } from 'formik';
import * as Yup from 'yup';
import { CONTRACT_ADDRESS_PARAM_NAMES, rpcClient } from '../../config.js';
import { CONTRACT_ADDRESS_PARAM_NAMES, pxe } from '../../config.js';
import { callContractFunction, deployContract, viewContractFunction } from '../../scripts/index.js';
import { convertArgs } from '../../scripts/util.js';
import styles from './contract_function_form.module.scss';
Expand Down Expand Up @@ -80,20 +80,13 @@ async function handleFunctionCall(
// for now, dont let user change the salt. requires some change to the form generation if we want to let user choose one
// since everything is currently based on parsing the contractABI, and the salt parameter is not present there
const salt = Fr.random();
return await deployContract(wallet, contractAbi, typedArgs, salt, rpcClient);
return await deployContract(wallet, contractAbi, typedArgs, salt, pxe);
}

if (functionAbi.functionType === 'unconstrained') {
return await viewContractFunction(contractAddress!, contractAbi, functionName, typedArgs, rpcClient, wallet);
return await viewContractFunction(contractAddress!, contractAbi, functionName, typedArgs, pxe, wallet);
} else {
const txnReceipt = await callContractFunction(
contractAddress!,
contractAbi,
functionName,
typedArgs,
rpcClient,
wallet,
);
const txnReceipt = await callContractFunction(contractAddress!, contractAbi, functionName, typedArgs, pxe, wallet);
return `Transaction ${txnReceipt.status} on block number ${txnReceipt.blockNumber}`;
}
}
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/boxes/blank-react/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BlankContractAbi } from './artifacts/blank.js';
import { PXE, createPXEClient } from '@aztec/aztec.js';
import { ContractAbi } from '@aztec/foundation/abi';
import { BlankContractAbi } from './artifacts/blank.js';

// update this if using a different contract

Expand All @@ -10,4 +10,3 @@ export const SANDBOX_URL: string = process.env.SANDBOX_URL || 'http://localhost:
export const pxe: PXE = createPXEClient(SANDBOX_URL);

export const CONTRACT_ADDRESS_PARAM_NAMES = ['address'];
export const FILTERED_FUNCTION_NAMES = [];
51 changes: 0 additions & 51 deletions yarn-project/boxes/blank-react/src/contracts/src/interface.nr

This file was deleted.

6 changes: 4 additions & 2 deletions yarn-project/boxes/blank/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
parserOptions: {
project: './tsconfig.json',
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
Expand All @@ -14,14 +17,13 @@ module.exports = {
node: true,
},
},
ignorePatterns: ['dist', '.eslintrc.cjs'],
ignorePatterns: ['dest', 'webpack.config.js', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: [],
overrides: [
{
files: ['*.ts', '*.tsx'],
parserOptions: {
// hacky workaround for CI not having the same tsconfig setup
project: true,
},
},
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "./dest/index.js",
"scripts": {
"build": "yarn clean && tsc -b && webpack",
"install:noir": "curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup -v aztec",
"install:noir": "curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup -v NOIR_VERSION",
"install:sandbox": "docker pull aztecprotocol/aztec-sandbox:latest",
"clean": "rm -rf ./dest .tsbuildinfo",
"start": "serve -p 3000 ./dest",
Expand Down
51 changes: 0 additions & 51 deletions yarn-project/boxes/blank/src/contracts/src/interface.nr

This file was deleted.

17 changes: 10 additions & 7 deletions yarn-project/boxes/blank/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
AccountWallet,
AztecAddress,
PXE,
CompleteAddress,
Contract,
DeployMethod,
Fr,
PXE,
TxReceipt,
createPXEClient,
getSandboxAccountsWallets,
Expand All @@ -18,27 +18,25 @@ export const contractAbi: ContractAbi = BlankContractAbi;
export const SANDBOX_URL: string = process.env.SANDBOX_URL || 'http://localhost:8080';
export const pxe: PXE = createPXEClient(SANDBOX_URL);

export const CONTRACT_ADDRESS_PARAM_NAMES = ['owner', 'contract_address', 'recipient'];
export const FILTERED_FUNCTION_NAMES = [];

export const DEFAULT_PUBLIC_ADDRESS: string = '0x25048e8c1b7dea68053d597ac2d920637c99523651edfb123d0632da785970d0';

let contractAddress: string = '';

// interaction with the buttons, but conditional check so node env can also import from this file
if (typeof document !== 'undefined') {
document.getElementById('deploy')?.addEventListener('click', async () => {
contractAddress = await handleDeployClick();
// eslint-disable-next-line no-console
console.log('Deploy Succeeded, contract deployed at', contractAddress);
});

document.getElementById('interact')?.addEventListener('click', async () => {
const interactionResult = await handleInteractClick(contractAddress);
// eslint-disable-next-line no-console
console.log('Interaction transaction succeeded', interactionResult);
});
}

export async function handleDeployClick(): Promise<string> {
// eslint-disable-next-line no-console
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inclined to leave these in, so there's at least some sign things are working for the user's browser in the console

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, agree!

console.log('Deploying Contract');
const [wallet, ..._rest] = await getSandboxAccountsWallets(pxe);

Expand All @@ -52,6 +50,8 @@ export async function handleInteractClick(contractAddress: string) {
const callArgs = { address: wallet.getCompleteAddress().address };
const getPkAbi = getFunctionAbi(BlankContractAbi, 'getPublicKey');
const typedArgs = convertArgs(getPkAbi, callArgs);

// eslint-disable-next-line no-console
console.log('Interacting with Contract');

return await callContractFunction(
Expand Down Expand Up @@ -81,7 +81,10 @@ export async function callContractFunction(
// selectedWallet is how we specify the "sender" of the transaction
const selectedWallet = await getWallet(wallet, pxe);

// TODO: switch to the generated typescript class?
// Note: when you start implementing the contract with more methods, it may be useful
// to use the typescript class for your contract generated by the `yarn compile` command,
// which providen an object with methods corresponding to the noir contract functions
dan-aztec marked this conversation as resolved.
Show resolved Hide resolved
// that are named and typed and can be called directly.
const contract = await Contract.at(address, abi, selectedWallet);

return contract.methods[functionName](...typedArgs)
Expand Down
5 changes: 4 additions & 1 deletion yarn-project/boxes/private-token/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
parserOptions: {
project: './tsconfig.json',
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
Expand All @@ -15,7 +18,7 @@ module.exports = {
node: true,
},
},
ignorePatterns: ['dist', '.eslintrc.cjs'],
ignorePatterns: ['dest', 'webpack.config.js', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
overrides: [
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/private-token/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "./dest/index.js",
"scripts": {
"build": "yarn clean && tsc -b && webpack",
"install:noir": "curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup -v aztec",
"install:noir": "curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup -v NOIR_VERSION",
"install:sandbox": "docker pull aztecprotocol/aztec-sandbox:latest",
"clean": "rm -rf ./dest .tsbuildinfo",
"start": "serve -p 3000 ./dest",
Expand Down
67 changes: 0 additions & 67 deletions yarn-project/boxes/private-token/src/contracts/src/interface.nr

This file was deleted.

Loading