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

feat: aztec-cli "unbox" command #1825

Closed
wants to merge 27 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e306668
recopy changes
dan-aztec Aug 25, 2023
2dd2b14
also add generated TS class temporarily for dev
dan-aztec Aug 25, 2023
42e286b
update README
dan-aztec Aug 25, 2023
08e1e54
cleanup the contract form slightly
dan-aztec Aug 25, 2023
4b7ddce
sketch of deploy function
dan-aztec Aug 25, 2023
9fffad0
create rpcClient in top level component
dan-aztec Aug 25, 2023
467aa4e
remove publickey from deploy command
dan-aztec Aug 25, 2023
a60c2c5
make undefined publickey explicit, to match default aztec-cli deploy …
dan-aztec Aug 25, 2023
a4f3170
lint
dan-aztec Aug 25, 2023
666c674
stub view logic
dan-aztec Aug 26, 2023
a10bd6f
unconnected wallet selector
dan-aztec Aug 26, 2023
ec46e02
linting
dan-aztec Aug 26, 2023
9e8d693
bad CSS but less reloading of setWallet
dan-aztec Aug 26, 2023
942d4da
alvaro helped with types and wiring
dan-aztec Aug 28, 2023
26530f4
Merge branch 'master' into dan/aztec-cli-unbox-gitfix
dan-aztec Aug 31, 2023
3dd4076
Merge branch 'master' into dan/aztec-cli-unbox-gitfix
dan-aztec Sep 1, 2023
6e1f88b
fix wallet selector and default set default param for owner to ALICE
dan-aztec Sep 1, 2023
8bbcb01
still broken copying e2e
dan-aztec Sep 1, 2023
dc95b4e
revert yarn.lock
dan-aztec Sep 1, 2023
6876d26
undo old copy
dan-aztec Sep 1, 2023
66a0403
fix: polyfill by bundling fileURLToPath
ludamad Sep 1, 2023
d17b6a8
fix: workspaceify starter-kit
ludamad Sep 1, 2023
e8b0753
update sandbox link
dan-aztec Sep 5, 2023
eac5f06
Revert "fix: polyfill by bundling fileURLToPath"
dan-aztec Sep 5, 2023
6f4dce0
revert polyfill and log
dan-aztec Sep 5, 2023
7dbccd3
Merge branch 'master' into dan/aztec-cli-unbox-gitfix
dan-aztec Sep 5, 2023
a41e1c9
remove package-lock.json
dan-aztec Sep 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
alvaro helped with types and wiring
dan-aztec committed Aug 28, 2023
commit 942d4da81770536eaec4f77fe2da5fa1c8608081
3 changes: 2 additions & 1 deletion yarn-project/starter-kit/package.json
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
"eslint": "^8.45.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"node-stdlib-browser": "^1.2.0",
"postcss": "^8.4.28",
"tailwindcss": "^3.3.3",
"typescript": "^5.0.2",
@@ -62,6 +61,7 @@
"@aztec/cli": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/noir-compiler": "workspace:^",
"@rollup/plugin-inject": "^5.0.3",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
@@ -74,6 +74,7 @@
"eslint-config-next": "13.4.19",
"formik": "^2.4.3",
"jest": "^29.5.0",
"node-stdlib-browser": "^1.2.0",
"postcss": "^8.4.28",
"react": "18.2.0",
"react-dom": "18.2.0",
41 changes: 31 additions & 10 deletions yarn-project/starter-kit/src/app/contractFunction.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import {
AztecAddress,
ContractBase, Fr, PrivateKey,
ContractBase, Fr,
PrivateKey,
PublicKey,
getAccountWallets, isContractDeployed
} from "@aztec/aztec.js";
import { ContractAbi, FunctionAbi } from "@aztec/foundation/abi";
import { SchnorrSingleKeyAccountContractAbi } from '@aztec/noir-contracts/artifacts';
import { AztecRPC } from '@aztec/types';
// TODO: consider removing dependency on this? then we can just read the contract ABI
import { PrivateTokenContract } from '../artifacts/PrivateToken';
import { deployContract } from '../scripts/deploy_contract';

import { useFormik } from 'formik';
import * as Yup from 'yup';
@@ -33,7 +34,8 @@ async function executeFunction(contractAddress: string, functionName: string, fu
rpcClient: AztecRPC
) {
const wallet = await getAccountWallets(rpcClient, SchnorrSingleKeyAccountContractAbi, privateKey, privateKey, accountCreationSalt);
console.log(wallet);
console.log('wallet', wallet);


// next line is erroring out with 404
// const _contract = await jsonClient.getContractData(contractAddress);
@@ -42,7 +44,8 @@ async function executeFunction(contractAddress: string, functionName: string, fu
// const _contract = await jsonClient.getContractDataAndBytecode(contractAddress);
const isDeployed = await isContractDeployed(rpcClient, contractAddress);
console.log(isDeployed);
const contract: ContractBase = await PrivateTokenContract.at(contractAddress, wallet);
const contractAddress2 = AztecAddress.fromString('0x070a10f77db469768cd7068a284be1dc78e9b7f80bd706b98c8e6fb9effb2468');
const contract: ContractBase = await PrivateTokenContract.at(contractAddress2, wallet);
console.log(contract);
console.log(contract.abi);
console.log(contract.methods); // why is this undefined?
@@ -75,7 +78,7 @@ type NoirFunctionYupSchema = {
[key: string]: Yup.NumberSchema | Yup.ArraySchema<number[], {}> | Yup.BooleanSchema | any;
};
type NoirFunctionFormValues = {
[key: string]: number | number[] | boolean;
[key: string]: string| number | number[] | boolean;
}

function generateYupSchema(functionAbi: FunctionAbi) {
@@ -85,8 +88,10 @@ function generateYupSchema(functionAbi: FunctionAbi) {
// set some super crude default values
switch (param.type.kind) {
case 'field':
parameterSchema[param.name] = Yup.number().required();
initialValues[param.name] = 100;
// todo: make these hex strings instead, because they are bigints
// and yup doesn't support bigint
parameterSchema[param.name] = Yup.string().required();
initialValues[param.name] = '0x64';
break;
case 'array':
// eslint-disable-next-line no-case-declarations
@@ -111,17 +116,33 @@ async function viewTx(contractAddress: string, functionName: string, functionArg
return;
}

async function deployContract(contractAbi: ContractAbi, rpcClient: AztecRPC, publicKey: PublicKey){
const deployer = new ContractDeployer(contractAbi, client, publicKey);

}

async function handleFunctionCall(functionType: string, contractAbi: ContractAbi, contractAddress: string, functionName: string, functionArgs: any,
rpcClient: AztecRPC){
if (functionType === 'unconstrained') {
return await viewTx(contractAddress, functionName, functionArgs);
} else if (functionName === 'constructor') {
// eslint-disable-next-line no-console
console.log('about to get wallet', privateKey);

const wallet = await getAccountWallets(rpcClient, SchnorrSingleKeyAccountContractAbi, [privateKey], [privateKey], [accountCreationSalt]);
console.log('got wallet', wallet);
console.log(`Function ${functionName} calling with:`, functionArgs);
console.log('deploying contract with null pubkey');
await deployContract(contractAbi, functionArgs,
// TODO: let them pick a salt
Fr.ZERO, rpcClient);
console.log("fn args", functionArgs);
const tx = PrivateTokenContract.deploy(wallet, BigInt(functionArgs['initial_supply']), BigInt(functionArgs['owner'])).send();
// const tx = PrivateTokenContract.deploy(rpcClient, BigInt(functionArgs['initial_supply']), BigInt(functionArgs['owner'])).send();
console.log('tx sent', tx);
await tx.isMined({ interval: 0.1});
const receipt = await tx.getReceipt();
console.log("sc addr", receipt.contractAddress!);
// await deployContract(contractAbi, functionArgs,
// // TODO: let them pick a salt
// Fr.ZERO, rpcClient);
} else {
console.log(`querying Contract address: ${contractAddress}`);
return await executeFunction(contractAddress, functionName, functionArgs, rpcClient);
27 changes: 27 additions & 0 deletions yarn-project/starter-kit/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import inject from '@rollup/plugin-inject';
import react from '@vitejs/plugin-react';
// Get require functionality in ESM
import { createRequire } from 'module';
import { defineConfig } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';

const require = createRequire(import.meta.url);
console.log('logging the path');
console.log(require.resolve('node-stdlib-browser/helpers/esbuild/shim'));

const { default: stdLibBrowser } = await import('node-stdlib-browser');
const esbuildShim = require.resolve('node-stdlib-browser/helpers/esbuild/shim');

// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: stdLibBrowser,
},
optimizeDeps: {
include: ['buffer', 'process'],
},
plugins: [
react(),
viteStaticCopy({
@@ -14,5 +30,16 @@ export default defineConfig({
},
],
}),
{
...inject({
global: [esbuildShim, 'global'],
process: [esbuildShim, 'process'],
Buffer: [esbuildShim, 'Buffer'],
// global: [require.resolve('node-stdlib-browser/helpers/esbuild/shim'), 'global'],
// process: [require.resolve('node-stdlib-browser/helpers/esbuild/shim'), 'process'],
// Buffer: [require.resolve('node-stdlib-browser/helpers/esbuild/shim'), 'Buffer'],
}),
enforce: 'post',
},
],
});
16,420 changes: 4,333 additions & 12,087 deletions yarn-project/starter-kit/yarn.lock

Large diffs are not rendered by default.