Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #120 from beehive-innovation/2021-11-03-add-redeem…
Browse files Browse the repository at this point in the history
…able-event

event for adding a redeemable
  • Loading branch information
thedavidmeister authored Nov 4, 2021
2 parents c1ef198 + 031ad81 commit fbe60f9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contracts/redeemableERC20/RedeemableERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ contract RedeemableERC20 is
keccak256("DISTRIBUTOR_BURNER");
bytes32 public constant REDEEMABLE_ADDER = keccak256("REDEEMABLE_ADDER");

/// Redeemable token added by creator.
event AddRedeemable(address indexed newRedeemable);

/// Redeemable token burn for reserve.
event Redeem(
// Account burning and receiving.
Expand Down Expand Up @@ -225,6 +228,8 @@ contract RedeemableERC20 is
require(redeemables[i_] != newRedeemable_, "DUPLICATE_REDEEMABLE");
}
redeemables.push(newRedeemable_);

emit AddRedeemable(address(newRedeemable_));
}

/// Public getter for underlying registered redeemables as a fixed sized
Expand Down
55 changes: 55 additions & 0 deletions test/RedeemableERC20/RedeemableERC20.sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,61 @@ enum Phase {
}

describe("RedeemableERC20", async function () {
it("should emit AddRedeemable event", async function () {
this.timeout(0);

const FIVE_TOKENS = ethers.BigNumber.from("5" + Util.eighteenZeros);
const TEN_TOKENS = ethers.BigNumber.from("10" + Util.eighteenZeros);
const TWENTY_TOKENS = ethers.BigNumber.from("20" + Util.eighteenZeros);

const signers = await ethers.getSigners();

const reserve1 = (await Util.basicDeploy(
"ReserveToken",
{}
)) as ReserveToken;
const reserve2 = (await Util.basicDeploy(
"ReserveToken",
{}
)) as ReserveToken;

// Constructing the RedeemableERC20 sets the parameters but nothing stateful happens.

const tierFactory = await ethers.getContractFactory("ReadWriteTier");
const tier = (await tierFactory.deploy()) as ReadWriteTier;

const minimumStatus = Tier.NIL;

const redeemableERC20Factory = await ethers.getContractFactory(
"RedeemableERC20"
);
const tokenName = "RedeemableERC20";
const tokenSymbol = "RDX";
const totalSupply = ethers.BigNumber.from("5000" + Util.eighteenZeros);

const redeemableERC20 = (await redeemableERC20Factory.deploy({
admin: signers[0].address,
name: tokenName,
symbol: tokenSymbol,
tier: tier.address,
minimumStatus: minimumStatus,
totalSupply: totalSupply,
})) as RedeemableERC20;

await redeemableERC20.deployed();
await redeemableERC20.grantRole(
await redeemableERC20.REDEEMABLE_ADDER(),
signers[0].address
);

await expect(redeemableERC20.addRedeemable(reserve1.address))
.to.emit(redeemableERC20, "AddRedeemable")
.withArgs(reserve1.address);
await expect(redeemableERC20.addRedeemable(reserve2.address))
.to.emit(redeemableERC20, "AddRedeemable")
.withArgs(reserve2.address);
});

it("should have 18 decimals", async () => {
this.timeout(0);

Expand Down

0 comments on commit fbe60f9

Please sign in to comment.