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: add a Nargo workspace in noir-contracts #2083

Merged
merged 8 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions yarn-project/noir-contracts/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[workspace]
members = [
"src/contracts/card_game_contract",
"src/contracts/child_contract",
"src/contracts/docs_example_contract",
"src/contracts/easy_private_token_contract",
"src/contracts/ecdsa_account_contract",
"src/contracts/escrow_contract",
"src/contracts/import_test_contract",
"src/contracts/lending_contract",
"src/contracts/multi_transfer_contract",
"src/contracts/native_token_contract",
"src/contracts/non_native_token_contract",
"src/contracts/parent_contract",
"src/contracts/pending_commitments_contract",
"src/contracts/pokeable_token_contract",
"src/contracts/price_feed_contract",
"src/contracts/private_token_airdrop_contract",
"src/contracts/private_token_contract",
"src/contracts/public_token_contract",
"src/contracts/schnorr_account_contract",
"src/contracts/schnorr_auth_witness_account_contract",
"src/contracts/schnorr_hardcoded_account_contract",
"src/contracts/schnorr_single_key_account_contract",
"src/contracts/test_contract",
"src/contracts/uniswap_contract",
]
6 changes: 3 additions & 3 deletions yarn-project/noir-contracts/scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ build() {
CONTRACT_NAME=$1
CONTRACT_FOLDER="${CONTRACT_NAME}_contract"
echo "Compiling $CONTRACT_NAME..."
cd src/contracts/$CONTRACT_FOLDER
rm -f target/*
rm -f target/${CONTRACT_FOLDER}-*
rm -f target/debug_${CONTRACT_FOLDER}-*

# If the compilation fails, rerun the compilation with 'nargo' and show the compiler output.
nargo compile --output-debug;
nargo compile --package $CONTRACT_FOLDER --output-debug;
}

echo "Using $(nargo --version)"
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/noir-contracts/src/scripts/copy_output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,18 @@ const main = () => {
if (!name) throw new Error(`Missing argument contract name`);

const projectName = `${snakeCase(name)}_contract`;
const projectDirPath = `src/contracts/${projectName}`;

const contractName = upperFirst(camelCase(name));
const artifactFile = `${projectName}-${contractName}.json`;

const buildJsonFilePath = `${projectDirPath}/target/${artifactFile}`;
const buildJsonFilePath = `./target/${artifactFile}`;
const buildJson = JSON.parse(readFileSync(buildJsonFilePath).toString());

const debugArtifactFile = `debug_${artifactFile}`;
let debug = undefined;

try {
const debugJsonFilePath = `${projectDirPath}/target/${debugArtifactFile}`;
const debugJsonFilePath = `./target/${debugArtifactFile}`;
const debugJson = JSON.parse(readFileSync(debugJsonFilePath).toString());
if (debugJson) {
debug = debugJson;
Expand Down Expand Up @@ -91,6 +90,7 @@ const main = () => {

// Write a .nr contract interface, for consumption by other Noir Contracts
if (INTERFACE_CONTRACTS.includes(name)) {
const projectDirPath = `src/contracts/${projectName}`;
const noirInterfaceDestFilePath = `${projectDirPath}/src/interface.nr`;
try {
writeFileSync(noirInterfaceDestFilePath, generateNoirContractInterface(artifactJson));
Expand Down
1 change: 1 addition & 0 deletions yarn-project/yarn-project-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ WORKDIR /usr/src/yarn-project
FROM builder_ as noir_types
COPY . .
COPY --from=noir /usr/src/yarn-project/noir-contracts/src/contracts /usr/src/yarn-project/noir-contracts/src/contracts
COPY --from=noir /usr/src/yarn-project/noir-contracts/target /usr/src/yarn-project/noir-contracts/target
WORKDIR /usr/src/yarn-project/noir-contracts

# Run yarn build to have the json ABIs available for the types generator
Expand Down