From 9eb62413ad91d34d4bb315200bc9065aea2eebce Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Wed, 3 Nov 2021 23:16:35 +0400 Subject: [PATCH 1/2] event for adding a redeemable ; --- contracts/redeemableERC20/RedeemableERC20.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contracts/redeemableERC20/RedeemableERC20.sol b/contracts/redeemableERC20/RedeemableERC20.sol index a62f37874..2619b4ad2 100644 --- a/contracts/redeemableERC20/RedeemableERC20.sol +++ b/contracts/redeemableERC20/RedeemableERC20.sol @@ -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. @@ -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 From 031ad81db82d6da972528952a34503f1be40723f Mon Sep 17 00:00:00 2001 From: marcusnewton Date: Thu, 4 Nov 2021 16:27:32 +1100 Subject: [PATCH 2/2] test AddRedeemable event --- test/RedeemableERC20/RedeemableERC20.sol.ts | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/RedeemableERC20/RedeemableERC20.sol.ts b/test/RedeemableERC20/RedeemableERC20.sol.ts index aafb07829..408024eab 100644 --- a/test/RedeemableERC20/RedeemableERC20.sol.ts +++ b/test/RedeemableERC20/RedeemableERC20.sol.ts @@ -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);