Skip to content

Commit

Permalink
chore: add a Nargo workspace in noir-contracts (#2083)
Browse files Browse the repository at this point in the history
This PR creates a Nargo workspace for the `noir-contracts` package. This
is useful for a mystery project.

# Checklist:
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.
- [x] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [x] 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).
  • Loading branch information
TomAFrench authored Sep 13, 2023
1 parent e89b364 commit 728a79c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
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;
}

# Check nargo version matches the expected one
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

0 comments on commit 728a79c

Please sign in to comment.