Skip to content

Commit

Permalink
fix: Use bool for set_minter (#2313)
Browse files Browse the repository at this point in the history
With the newest version of aztec.nr bools in function params are
allowed, so this pr updates the `set_minter` function in the token to
use this instead of a field that is constrained to be 0 or 1.
  • Loading branch information
LHerskind authored Sep 15, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent cb25bc9 commit 5b18f9e
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/e2e_lending_contract.test.ts
Original file line number Diff line number Diff line change
@@ -87,9 +87,9 @@ describe('e2e_lending_contract', () => {
}

await waitForSuccess(collateralAsset.methods._initialize(accounts[0]).send());
await waitForSuccess(collateralAsset.methods.set_minter({ address: lendingContract.address }, 1).send());
await waitForSuccess(collateralAsset.methods.set_minter({ address: lendingContract.address }, true).send());
await waitForSuccess(stableCoin.methods._initialize(accounts[0]).send());
await waitForSuccess(stableCoin.methods.set_minter({ address: lendingContract.address }, 1).send());
await waitForSuccess(stableCoin.methods.set_minter({ address: lendingContract.address }, true).send());

return { priceFeedContract, lendingContract, collateralAsset, stableCoin };
};
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/src/e2e_token_contract.test.ts
Original file line number Diff line number Diff line change
@@ -127,14 +127,14 @@ describe('e2e_token_contract', () => {
});

it('Add minter as admin', async () => {
const tx = asset.withWallet(wallets[1]).methods.set_minter({ address: accounts[1].address }, 1).send();
const tx = asset.withWallet(wallets[1]).methods.set_minter({ address: accounts[1].address }, true).send();
const receipt = await tx.wait();
expect(receipt.status).toBe(TxStatus.MINED);
expect(await asset.methods.is_minter({ address: accounts[1].address }).view()).toBe(true);
});

it('Revoke minter as admin', async () => {
const tx = asset.withWallet(wallets[1]).methods.set_minter({ address: accounts[1].address }, 0).send();
const tx = asset.withWallet(wallets[1]).methods.set_minter({ address: accounts[1].address }, false).send();
const receipt = await tx.wait();
expect(receipt.status).toBe(TxStatus.MINED);
expect(await asset.methods.is_minter({ address: accounts[1].address }).view()).toBe(false);
@@ -147,7 +147,7 @@ describe('e2e_token_contract', () => {
);
});
it('Revoke minter not as admin', async () => {
await expect(asset.methods.set_minter({ address: accounts[0].address }, 0).simulate()).rejects.toThrowError(
await expect(asset.methods.set_minter({ address: accounts[0].address }, false).simulate()).rejects.toThrowError(
'Assertion failed: caller is not admin',
);
});
Original file line number Diff line number Diff line change
@@ -113,9 +113,8 @@ contract Token {
#[aztec(public)]
fn set_minter(
minter: AztecAddress,
approve: Field,
approve: bool,
) {
assert((approve == 1) | (approve == 0), "not providing boolean");
let storage = Storage::init(Context::public(&mut context));
assert(storage.admin.read() == context.msg_sender(), "caller is not admin");
storage.minters.at(minter.address).write(approve as Field);

0 comments on commit 5b18f9e

Please sign in to comment.