Skip to content
Merged

nits #103

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
4 changes: 1 addition & 3 deletions .github/scripts/update-readme-version.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { readFileSync, writeFileSync } from 'fs';
import { dirname } from 'path';
import { fileURLToPath } from 'url';

// Read Nargo.toml
const nargoContent = readFileSync('Nargo.toml', 'utf8');
Expand All @@ -24,4 +22,4 @@ const updatedContent = readmeContent.replace(

// Write back to README
writeFileSync(readmePath, updatedContent);
console.log(`Updated README.md with version ${version}`);
console.log(`Updated README.md with version ${version}`);
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

This repo is meant to be a starting point for writing Aztec contracts and tests on the Aztec sandbox (local development environment).

You can find the **Easy Private Voting contract** in `./src/main.nr`. A simple integration test is in `./src/test/index.test.ts`.
You can find the **Easy Private Voting contract** in `./src/main.nr`. A simple integration test is in `./src/test/e2e/index.test.ts`.

The corresponding tutorial can be found in the [Aztec docs here](https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/private_voting_contract).

Expand Down Expand Up @@ -121,7 +121,7 @@ Then test with:
yarn test
```

Testing will run the **TypeScript tests** defined in `index.test.ts` inside `./src/test`, as well as the [Aztec Testing eXecution Environment (TXE)](https://docs.aztec.network/developers/guides/smart_contracts/testing) tests defined in [`first.nr`](./src/test/first.nr) (imported in the contract file with `mod test;`).
Testing will run the **TypeScript tests** defined in `index.test.ts` inside `./src/test/e2e`, as well as the [Aztec Testing eXecution Environment (TXE)](https://docs.aztec.network/developers/guides/smart_contracts/testing) tests defined in [`first.nr`](./src/test/first.nr) (imported in the contract file with `mod test;`).

Note: The Typescript tests spawn an instance of the sandbox to test against, and close it once the TS tests are complete.

Expand All @@ -131,8 +131,8 @@ Note: The Typescript tests spawn an instance of the sandbox to test against, and

You can find a handful of scripts in the `./scripts` folder.

- `./scripts/deploy-accounts.ts` is an example of how to deploy a schnorr account.
- `./scripts/deploy.ts` is an example of how to deploy a contract.
- `./scripts/deploy_account.ts` is an example of how to deploy a schnorr account.
- `./scripts/deploy_contract.ts` is an example of how to deploy a contract.
- `./scripts/fees.ts` is an example of how to pay for a contract deployment using various fee payment methods.
- `./scripts/multiple_pxe.ts` is an example of how to deploy a contract from one PXE instance and interact with it from another.
- `./scripts/profile_deploy.ts` shows how to profile a transaction and print the results.
Expand All @@ -158,7 +158,7 @@ yarn update
You may need to update permissions with:

```bash
chmod +x update_contract.sh
chmod +x .github/scripts/update_contract.sh
```

### 💬 Join the Community:
Expand Down
10 changes: 5 additions & 5 deletions scripts/fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ async function main() {
logger.info(`Fee Juice minted to ${feeJuiceRecipient} on L2.`)

// set up sponsored fee payments
const sponseredFPC = await getSponsoredFPCInstance();
await pxe.registerContract({ instance: sponseredFPC, artifact: SponsoredFPCContract.artifact });
const paymentMethod = new SponsoredFeePaymentMethod(sponseredFPC.address);
const sponsoredFPC = await getSponsoredFPCInstance();
await pxe.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
const paymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address);

// Two arbitrary txs to make the L1 message available on L2
const votingContract = await EasyPrivateVotingContract.deploy(wallet1, wallet1.getAddress()).send({ fee: { paymentMethod } }).deployed();
Expand Down Expand Up @@ -120,8 +120,8 @@ async function main() {
// Sponsored Fee Payment

// This method will only work in environments where there is a sponsored fee contract deployed
const deployedSponseredFPC = await getDeployedSponsoredFPCAddress(pxe);
const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(deployedSponseredFPC);
const deployedSponsoredFPC = await getDeployedSponsoredFPCAddress(pxe);
const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(deployedSponsoredFPC);
await bananaCoin.withWallet(wallet2).methods.transfer_in_private(wallet2.getAddress(), wallet1.getAddress(), 10, 0).send({ fee: { paymentMethod: sponsoredPaymentMethod } }).wait()
logger.info(`Transfer paid with fees from Sponsored FPC.`)
}
Expand Down
12 changes: 6 additions & 6 deletions scripts/multiple_pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ async function main() {

const pxe1 = await setupPxe1();
const pxe2 = await setupPxe2();
const sponseredFPC = await getSponsoredFPCInstance();
await pxe1.registerContract({ instance: sponseredFPC, artifact: SponsoredFPCContract.artifact });
await pxe2.registerContract({ instance: sponseredFPC, artifact: SponsoredFPCContract.artifact });
const paymentMethod = new SponsoredFeePaymentMethod(sponseredFPC.address);
const sponsoredFPC = await getSponsoredFPCInstance();
await pxe1.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
await pxe2.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
const paymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address);
// deploy token contract

let secretKey = Fr.random();
Expand All @@ -74,7 +74,7 @@ async function main() {

// setup account on 2nd pxe

pxe2.registerSender(ownerAddress)
await pxe2.registerSender(ownerAddress)

let secretKey2 = Fr.random();
let salt2 = Fr.random();
Expand All @@ -83,7 +83,7 @@ async function main() {
// deploy account on 2nd pxe
let tx2 = await schnorrAccount2.deploy({ fee: { paymentMethod } }).wait();
let wallet2 = await schnorrAccount2.getWallet();
wallet2.registerSender(ownerAddress)
await wallet2.registerSender(ownerAddress)

// mint to account on 2nd pxe

Expand Down
13 changes: 12 additions & 1 deletion src/test/e2e/accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,18 @@ describe("Accounts", () => {
});

it("Deploys first unfunded account from first funded account", async () => {
const tx_acc = await randomAccountManagers[0].deploy({ fee: { paymentMethod: sponsoredPaymentMethod }, deployWallet: ownerWallet }).wait();
const receipt = await randomAccountManagers[0]
.deploy({ fee: { paymentMethod: sponsoredPaymentMethod }, deployWallet: ownerWallet })
.wait();

expect(receipt).toEqual(
expect.objectContaining({
status: TxStatus.SUCCESS,
}),
);

const deployedWallet = await randomAccountManagers[0].getWallet();
expect(deployedWallet.getAddress()).toEqual(randomAccountManagers[0].getAddress());
});

it("Sponsored contract deployment", async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/first.nr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ unconstrained fn test_initializer() {
let block_number = get_block_number();
let admin_slot = EasyPrivateVoting::storage_layout().admin.slot;
let admin_storage_value = storage_read(voting_contract_address, admin_slot, block_number);
assert(admin_storage_value == admin, "Vote ended should be false");
assert(admin_storage_value == admin, "Admin address mismatch");
}

#[test]
Expand Down