Skip to content

Commit

Permalink
add aztec banner
Browse files Browse the repository at this point in the history
fix colorscheme

fix banner

aztec logo

prettier working?

add api endpoint

switch to cjs file

parse contract functions, but no working form

delete unneeded text

comments

slightly cleaner form

slightly better css

fix: Remove automatic update to `AztecProtocol/dev-bb.js` (#1712)

Related to #1711

Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).

git subrepo push --branch=master circuits/cpp/barretenberg

subrepo:
  subdir:   "circuits/cpp/barretenberg"
  merged:   "d883900f9"
upstream:
  origin:   "https://github.com/AztecProtocol/barretenberg"
  branch:   "master"
  commit:   "d883900f9"
git-subrepo:
  version:  "0.4.6"
  origin:   "???"
  commit:   "???"

chore: sync bb master (#1713)

Ran:

```
./scripts/git_subrepo.sh pull circuits/cpp/barretenberg
git checkout origin/master -- .gitmodules
```

Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).

copy the contract ABI into the new subdirectory

fix output json name
  • Loading branch information
dan-aztec committed Aug 22, 2023
1 parent d046d92 commit bf67347
Show file tree
Hide file tree
Showing 27 changed files with 502 additions and 211 deletions.
18 changes: 0 additions & 18 deletions circuits/cpp/barretenberg/.github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,6 @@ jobs:
cd ts
yarn install && yarn && yarn build
- name: Checkout destination repository
uses: actions/checkout@v3
with:
repository: AztecProtocol/dev-bb.js
path: ./dev-bb.js
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}

- name: Push to destination repository
run: |
cd ./dev-bb.js
cp -R ../ts/dest/* .
git config --global user.name AztecBot
git config --global user.email [email protected]
git checkout -b dev || git checkout dev
git add .
git commit -m "Tracking changes"
git push origin dev
- name: Tar and GZip barretenberg.wasm
run: tar -cvzf barretenberg.wasm.tar.gz cpp/build-wasm/bin/barretenberg.wasm

Expand Down
4 changes: 2 additions & 2 deletions circuits/cpp/barretenberg/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/AztecProtocol/barretenberg
branch = master
commit = a7331d4b8e1f8e0ee2564dbca1ef1d0d35a67d6f
parent = 6ea24b149cd53edc2c565932ce58fab6707f25f3
commit = 9b6fc607d7c7de57033d10fd8a3e1c424e400a5b
parent = 0039c4fdf7c713d9f375d6abda15353325e38d56
method = merge
cmdver = 0.4.6
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{".":"0.4.1","ts":"0.4.1"}
{".":"0.4.2","ts":"0.4.2"}
7 changes: 7 additions & 0 deletions circuits/cpp/barretenberg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.4.2](https://github.com/AztecProtocol/barretenberg/compare/barretenberg-v0.4.1...barretenberg-v0.4.2) (2023-08-21)


### Bug Fixes

* Remove automatic update to `AztecProtocol/dev-bb.js` ([#1712](https://github.com/AztecProtocol/barretenberg/issues/1712)) ([d883900](https://github.com/AztecProtocol/barretenberg/commit/d883900f9b297f659d14583ac93eede5160f9aae))

## [0.4.1](https://github.com/AztecProtocol/barretenberg/compare/barretenberg-v0.4.0...barretenberg-v0.4.1) (2023-08-21)


Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.4.1 x-release-please-version
v0.4.2 x-release-please-version
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/barretenberg-wasm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ in
stdenv.mkDerivation
{
pname = "barretenberg.wasm";
version = "0.4.1"; # x-release-please-version
version = "0.4.2"; # x-release-please-version

src = ./cpp;

Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/barretenberg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ in
buildEnv.mkDerivation
{
pname = "libbarretenberg";
version = "0.4.1"; # x-release-please-version
version = "0.4.2"; # x-release-please-version

src = ./cpp;

Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24)
project(
Barretenberg
DESCRIPTION "BN254 elliptic curve library, and PLONK SNARK prover"
VERSION 0.4.1 # x-release-please-version
VERSION 0.4.2 # x-release-please-version
LANGUAGES CXX C
)

Expand Down
7 changes: 7 additions & 0 deletions circuits/cpp/barretenberg/ts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.4.2](https://github.com/AztecProtocol/barretenberg/compare/barretenberg.js-v0.4.1...barretenberg.js-v0.4.2) (2023-08-21)


### Miscellaneous Chores

* **barretenberg.js:** Synchronize barretenberg versions

## [0.4.1](https://github.com/AztecProtocol/barretenberg/compare/barretenberg.js-v0.4.0...barretenberg.js-v0.4.1) (2023-08-21)


Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg/ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aztec/bb.js",
"version": "0.4.1",
"version": "0.4.2",
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/circuits/cpp/barretenberg/ts",
"license": "MIT",
"type": "module",
Expand Down
111 changes: 56 additions & 55 deletions yarn-project/aztec-cli/src/unbox.ts
Original file line number Diff line number Diff line change
@@ -1,91 +1,92 @@
// heavily inspired by https://github.com/trufflesuite/truffle/blob/develop/packages/box/lib/utils/unbox.ts
import fetch from 'node-fetch';
import JSZip from 'jszip';
import { promises as fs } from 'fs';
import JSZip from 'jszip';
import fetch from 'node-fetch';

const GITHUB_OWNER = 'AztecProtocol';
const GITHUB_REPO = 'aztec-packages';
const NOIR_CONTRACTS_PATH = 'yarn-project/noir-contracts/src/contracts'
const STARTER_KIT_PATH = 'yarn-project/starter-kit'
const NOIR_CONTRACTS_PATH = 'yarn-project/noir-contracts/src/contracts';
const STARTER_KIT_PATH = 'yarn-project/starter-kit';

/**
* Converts a contract name in "upper camel case" to a folder name in snake case.
* @param contractName - The contract name.
* @returns The folder name.
* */
function contractNameToFolder(contractName: string): string {

return contractName
.replace(/[\w]([A-Z])/g, (m) => m[0] + "_" + m[1])
.toLowerCase();
export function contractNameToFolder(contractName: string): string {
return contractName.replace(/[\w]([A-Z])/g, m => m[0] + '_' + m[1]).toLowerCase();
}

/**
*
*
* @param contractName - The contract name, in upper camel case.
* @param outputPath - The output path, by default this is the current working directory
* @returns The path to the downloaded contract.
*/
export async function downloadContractFromGithub(
contractName: string='PrivateToken',
outputPath: string
contractName: string = 'PrivateToken',
outputPath: string,
): Promise<void> {
// small string conversion, in the ABI the contract name looks like PrivateToken
// but in the repostory it looks like private_token
const contractFolder = `${NOIR_CONTRACTS_PATH}/${contractNameToFolder(contractName)}_contract`;
await _downloadNoirFilesFromGithub(contractFolder, outputPath);
}
// small string conversion, in the ABI the contract name looks like PrivateToken
// but in the repostory it looks like private_token
const contractFolder = `${NOIR_CONTRACTS_PATH}/${contractNameToFolder(contractName)}_contract`;
await _downloadNoirFilesFromGithub(contractFolder, outputPath);
}

/**
* Not flexible at at all, but quick fix to download a noir smart contract from our
* monorepo on github. this will copy over the `yarn-projects/starter-kit` folder in its entirey
* as well as the specfieid directoryPath, which should point to a single noir contract in
* as well as the specfieid directoryPath, which should point to a single noir contract in
* `yarn-projects/noir-contracts/src/contracts/...`
* @param directoryPath - path to the directory in the github repo
* @param outputPath - local path that we will copy the noir contracts and web3 starter kit to
* @returns
* @returns
*/
async function _downloadNoirFilesFromGithub(
directoryPath: string,
outputPath: string,
outputPrefix: string = 'starter-kit'
directoryPath: string,
outputPath: string,
outputPrefix: string = 'starter-kit',
): Promise<string> {
const owner = GITHUB_OWNER;
const repo = GITHUB_REPO;
// Step 1: Fetch the ZIP from GitHub, hardcoded to the master branch
const url = `https://github.com/${owner}/${repo}/archive/refs/heads/master.zip`;
const response = await fetch(url);
const buffer = await response.arrayBuffer();
const owner = GITHUB_OWNER;
const repo = GITHUB_REPO;
// Step 1: Fetch the ZIP from GitHub, hardcoded to the master branch
const url = `https://github.com/${owner}/${repo}/archive/refs/heads/master.zip`;
const response = await fetch(url);
const buffer = await response.arrayBuffer();

// Step 2: Use JSZip to read the ZIP contents
const zip = new JSZip();
const data = await zip.loadAsync(buffer);

// Step 2: Use JSZip to read the ZIP contents
const zip = new JSZip();
const data = await zip.loadAsync(buffer);
// Step 3: Extract the specific directory from the ZIP
const repoDirectoryPrefix = `${repo}-master/`;
const fullDirectoryPath = `${repoDirectoryPrefix}${directoryPath}/`;
const starterKitPath = `${repoDirectoryPrefix}${STARTER_KIT_PATH}/`;

// Step 3: Extract the specific directory from the ZIP
const repoDirectoryPrefix = `${repo}-master/`;
const fullDirectoryPath = `${repoDirectoryPrefix}${directoryPath}/`;
const starterKitPath = `${repoDirectoryPrefix}${STARTER_KIT_PATH}/`;
const contractFiles = Object.values(data.files).filter(file => {
return file.dir && (file.name.startsWith(fullDirectoryPath) || file.name.startsWith(starterKitPath));
});

const contractFiles = Object.values(data.files).filter(file => {
return file.dir && (file.name.startsWith(fullDirectoryPath) || file.name.startsWith(starterKitPath));
});

for (const file of contractFiles) {
// note that we strip out the entire "directoryPath"!
const relativePath = file.name.replace(fullDirectoryPath, `${outputPrefix}/noir-contracts/`).replace(starterKitPath, `${outputPrefix}/`);
const targetPath = `${outputPath}/${relativePath}`;
await fs.mkdir(targetPath, { recursive: true });
}
for (const file of contractFiles) {
// note that we strip out the entire "directoryPath"!
const relativePath = file.name
.replace(fullDirectoryPath, `${outputPrefix}/noir-contracts/`)
.replace(starterKitPath, `${outputPrefix}/`);
const targetPath = `${outputPath}/${relativePath}`;
await fs.mkdir(targetPath, { recursive: true });
}

const directoryFiles = Object.values(data.files).filter(file => {
return !file.dir && (file.name.startsWith(fullDirectoryPath) || file.name.startsWith(starterKitPath));
});
const directoryFiles = Object.values(data.files).filter(file => {
return !file.dir && (file.name.startsWith(fullDirectoryPath) || file.name.startsWith(starterKitPath));
});

for (const file of directoryFiles) {
const relativePath = file.name.replace(fullDirectoryPath, `${outputPrefix}/noir-contracts/`).replace(starterKitPath, `${outputPrefix}/`);
const targetPath = `${outputPath}/${relativePath}`;
const content = await file.async("nodebuffer");
await fs.writeFile(targetPath, content);
}
return Promise.resolve(`${outputPath}/${outputPrefix}`);
for (const file of directoryFiles) {
const relativePath = file.name
.replace(fullDirectoryPath, `${outputPrefix}/noir-contracts/`)
.replace(starterKitPath, `${outputPrefix}/`);
const targetPath = `${outputPath}/${relativePath}`;
const content = await file.async('nodebuffer');
await fs.writeFile(targetPath, content);
}
return Promise.resolve(`${outputPath}/${outputPrefix}`);
}
50 changes: 28 additions & 22 deletions yarn-project/aztec-cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { createEthereumChain, deployL1Contracts } from '@aztec/ethereum';
import { ContractAbi } from '@aztec/foundation/abi';
import { DebugLogger, LogFn } from '@aztec/foundation/log';

import { assert } from 'console';
import fs from 'fs';
import * as path from 'path';
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';

import { encodeArgs } from './encoding.js';
import { assert } from 'console';
import { downloadContractFromGithub } from './unbox.js';
import { contractNameToFolder, downloadContractFromGithub } from './unbox.js';

/**
* Helper type to dynamically import contracts.
Expand Down Expand Up @@ -153,27 +154,32 @@ export async function prepTx(
* TODO: 4. Frontend parses the contract ABI and generates a UI to interact with the contract.
* @param contractName - name of contract from `@aztec/noir-contracts`
*/
export async function unboxContract(
contractName: string,
log: LogFn,
) {
const contracts = await import('@aztec/noir-contracts/artifacts');
export async function unboxContract(contractName: string, log: LogFn) {
const contracts = await import('@aztec/noir-contracts/artifacts');

//console.log(contracts);
const contractNames = Object.values(contracts).map((contract) => contract.name);
const contractNames = Object.values(contracts).map(contract => contract.name);
// console.log(contractNames);
assert(contractNames.includes(contractName),
`Contract ${contractName} not found in @aztec/noir-contracts: ${contractNames}
We recommend "PrivateToken" as a default.`);

// download the noir source code into `starter-kit`, along with the starter-kit subpackage.
// TODO: add the jest tests
await downloadContractFromGithub(contractName, process.cwd());
log(`Downloaded ${contractName} from @aztec/noir-contracts. to ${process.cwd()}/starter-kit`);
return;

const chosenContractAbi = Object.values(contracts).filter((contract) => contract.name === contractName)[0];
console.log(chosenContractAbi);

assert(
contractNames.includes(contractName),
`Contract ${contractName} not found in @aztec/noir-contracts: ${contractNames}
We recommend "PrivateToken" as a default.`,
);

// downloads the selected contract's noir source code into `starter-kit`, along with the @aztec/starter-kit subpackage.
// TODO: add the jest tests
await downloadContractFromGithub(contractName, process.cwd());
log(`Downloaded ${contractName} from @aztec/noir-contracts. to ${process.cwd()}/starter-kit`);

const chosenContractAbi = Object.values(contracts).filter(contract => contract.name === contractName)[0];
const outputPath = path.join(
process.cwd(),
'starter-kit',
'noir-contracts',
`${contractNameToFolder(contractName)}_contract.json`,
);
// TODO: confirm naming convention will match what will be compiled when the contract is recompiled
fs.writeFileSync(outputPath, JSON.stringify(chosenContractAbi, null, 4));
log(`copied contract ABI to ${outputPath}`);
return;
}
}
1 change: 1 addition & 0 deletions yarn-project/starter-kit/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@aztec/foundation/eslint');
File renamed without changes.
27 changes: 24 additions & 3 deletions yarn-project/starter-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
{
"name": "starter-kit",
"version": "0.1.0",
"private": true,
"packageManager": "[email protected]",
"type": "module",
"exports": {
"./prettier": "./.prettierrc.json"
},
"scripts": {
"dev": "next dev",
"build": "next build",
"build:dev": "tsc -b --watch",
"start": "next start",
"lint": "next lint"
"clean": "rm -rf ./dest .tsbuildinfo",
"prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json",
"prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check",
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src"
},
"inherits": [
"../package.common.json",
"./package.local.json"
],
"dependencies": {
"@aztec/aztec.js": "0.1.0",
"@aztec/foundation": "0.1.0",
"@types/node": "20.5.1",
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.15",
"eslint": "8.47.0",
"eslint-config-next": "13.4.19",
"formik": "^2.4.3",
"next": "13.4.19",
"postcss": "8.4.28",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.3",
"typescript": "5.1.6"
"typescript": "5.1.6",
"yup": "^1.2.0"
},
"engines": {
"node": ">=18"
}
}
File renamed without changes.
8 changes: 8 additions & 0 deletions yarn-project/starter-kit/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion yarn-project/starter-kit/public/next.svg

This file was deleted.

Loading

0 comments on commit bf67347

Please sign in to comment.