Skip to content

Commit a2dee07

Browse files
authored
Merge pull request #103 from critesjosh/main
nits
2 parents b15af1b + 3ff15b2 commit a2dee07

File tree

6 files changed

+30
-21
lines changed

6 files changed

+30
-21
lines changed

.github/scripts/update-readme-version.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { readFileSync, writeFileSync } from 'fs';
2-
import { dirname } from 'path';
3-
import { fileURLToPath } from 'url';
42

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

2523
// Write back to README
2624
writeFileSync(readmePath, updatedContent);
27-
console.log(`Updated README.md with version ${version}`);
25+
console.log(`Updated README.md with version ${version}`);

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

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

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

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

@@ -121,7 +121,7 @@ Then test with:
121121
yarn test
122122
```
123123

124-
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;`).
124+
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;`).
125125

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

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

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

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

160160
```bash
161-
chmod +x update_contract.sh
161+
chmod +x .github/scripts/update_contract.sh
162162
```
163163

164164
### 💬 Join the Community:

scripts/fees.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ async function main() {
6262
logger.info(`Fee Juice minted to ${feeJuiceRecipient} on L2.`)
6363

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

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

122122
// This method will only work in environments where there is a sponsored fee contract deployed
123-
const deployedSponseredFPC = await getDeployedSponsoredFPCAddress(pxe);
124-
const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(deployedSponseredFPC);
123+
const deployedSponsoredFPC = await getDeployedSponsoredFPCAddress(pxe);
124+
const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(deployedSponsoredFPC);
125125
await bananaCoin.withWallet(wallet2).methods.transfer_in_private(wallet2.getAddress(), wallet1.getAddress(), 10, 0).send({ fee: { paymentMethod: sponsoredPaymentMethod } }).wait()
126126
logger.info(`Transfer paid with fees from Sponsored FPC.`)
127127
}

scripts/multiple_pxe.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ async function main() {
5858

5959
const pxe1 = await setupPxe1();
6060
const pxe2 = await setupPxe2();
61-
const sponseredFPC = await getSponsoredFPCInstance();
62-
await pxe1.registerContract({ instance: sponseredFPC, artifact: SponsoredFPCContract.artifact });
63-
await pxe2.registerContract({ instance: sponseredFPC, artifact: SponsoredFPCContract.artifact });
64-
const paymentMethod = new SponsoredFeePaymentMethod(sponseredFPC.address);
61+
const sponsoredFPC = await getSponsoredFPCInstance();
62+
await pxe1.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
63+
await pxe2.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
64+
const paymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address);
6565
// deploy token contract
6666

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

7575
// setup account on 2nd pxe
7676

77-
pxe2.registerSender(ownerAddress)
77+
await pxe2.registerSender(ownerAddress)
7878

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

8888
// mint to account on 2nd pxe
8989

src/test/e2e/accounts.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,18 @@ describe("Accounts", () => {
122122
});
123123

124124
it("Deploys first unfunded account from first funded account", async () => {
125-
const tx_acc = await randomAccountManagers[0].deploy({ fee: { paymentMethod: sponsoredPaymentMethod }, deployWallet: ownerWallet }).wait();
125+
const receipt = await randomAccountManagers[0]
126+
.deploy({ fee: { paymentMethod: sponsoredPaymentMethod }, deployWallet: ownerWallet })
127+
.wait();
128+
129+
expect(receipt).toEqual(
130+
expect.objectContaining({
131+
status: TxStatus.SUCCESS,
132+
}),
133+
);
134+
135+
const deployedWallet = await randomAccountManagers[0].getWallet();
136+
expect(deployedWallet.getAddress()).toEqual(randomAccountManagers[0].getAddress());
126137
});
127138

128139
it("Sponsored contract deployment", async () => {

src/test/first.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ unconstrained fn test_initializer() {
1111
let block_number = get_block_number();
1212
let admin_slot = EasyPrivateVoting::storage_layout().admin.slot;
1313
let admin_storage_value = storage_read(voting_contract_address, admin_slot, block_number);
14-
assert(admin_storage_value == admin, "Vote ended should be false");
14+
assert(admin_storage_value == admin, "Admin address mismatch");
1515
}
1616

1717
#[test]

0 commit comments

Comments
 (0)