diff --git a/e2e-contracts/clone-contracts.sh b/e2e-contracts/clone-contracts.sh index 0f99cb51c..baefc1de8 100755 --- a/e2e-contracts/clone-contracts.sh +++ b/e2e-contracts/clone-contracts.sh @@ -43,7 +43,7 @@ clone() { log "Cloning or updating repositories" clone brlc-multisig 918a226 clone brlc-periphery b8d507a -clone brlc-token 55770b9 +clone brlc-token 86d5d4f clone compound-periphery e4d68df clone brlc-yield-streamer e63d8ba clone brlc-pix-cashier 00cc007 \ No newline at end of file diff --git a/e2e-contracts/patches/brlc-token.patch b/e2e-contracts/patches/brlc-token.patch index a9f05fd7e..2225707e1 100644 --- a/e2e-contracts/patches/brlc-token.patch +++ b/e2e-contracts/patches/brlc-token.patch @@ -1,11 +1,11 @@ -diff --git a/test/BRLCToken.complex.test.ts b/test/BRLCToken.complex.test.ts -index f5cbce5..053cfc5 100644 ---- a/test/BRLCToken.complex.test.ts -+++ b/test/BRLCToken.complex.test.ts -@@ -54,6 +54,21 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +diff --git a/test/base/CWToken.complex.test.ts b/test/base/CWToken.complex.test.ts +index 267986e..1ef6e0e 100644 +--- a/test/base/CWToken.complex.test.ts ++++ b/test/base/CWToken.complex.test.ts +@@ -55,6 +55,21 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", return { token }; } - + + async function latest(): Promise { + return parseInt((await ethers.provider.send("eth_getBlockByNumber", ["latest", false])).timestamp, 16); + } @@ -21,11 +21,20 @@ index f5cbce5..053cfc5 100644 + } + } + - describe("Frozen and restricted balances", async () => { - it("Transfer to purpose account - test 5", async () => { - const { token } = await setUpFixture(deployAndConfigureToken); -@@ -168,15 +183,15 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios - + async function checkComplexBalanceGetter( + props: { + token: Contract; +@@ -66,7 +81,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", + }; + } + ) { +- const timestamp = (await time.latest()) + 100; ++ const timestamp = (await latest()) + 100; + const { token, amounts } = props; + if (amounts.mint > 0) { + await proveTx(token.connect(deployer).mint(user.address, amounts.mint)); +@@ -271,15 +286,15 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", + describe("Frozen and premint balances", async () => { let timestamp: number; - before(async () => { @@ -43,23 +52,16 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 5) ).to.changeTokenBalances( -@@ -191,7 +206,8 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -294,7 +309,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 10)); - await time.increaseTo(timestamp); -+ + await increaseTo(timestamp); await expect( token.connect(user).transfer(purposeAccount.address, 10) ).to.changeTokenBalances( -@@ -201,12 +217,12 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios - ); - }); - -- it("Transfer to purpose account - test 15 with release awaiting", async () => { -+ it("Transfer to purpose account - test 15 with release awaiting ff", async () => { - const { token } = await setUpFixture(deployAndConfigureToken); +@@ -309,7 +324,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 10)); @@ -68,7 +70,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 15) ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_FROZEN_AMOUNT); -@@ -217,7 +233,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -320,7 +335,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 10)); @@ -77,7 +79,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 20) ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_FROZEN_AMOUNT); -@@ -228,7 +244,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -331,7 +346,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 10)); @@ -86,7 +88,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 25) ).to.be.revertedWith(REVERT_MESSAGE_ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE); -@@ -239,7 +255,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -342,7 +357,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 10)); @@ -95,7 +97,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 5) ).to.changeTokenBalances( -@@ -254,7 +270,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -357,7 +372,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 10)); @@ -104,7 +106,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 10) ).to.changeTokenBalances( -@@ -269,7 +285,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -372,7 +387,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 10)); @@ -113,7 +115,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 15) ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_FROZEN_AMOUNT); -@@ -280,7 +296,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -383,7 +398,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 10)); @@ -122,7 +124,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 20) ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_FROZEN_AMOUNT); -@@ -291,7 +307,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -394,7 +409,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 10)); @@ -131,8 +133,8 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 25) ).to.be.revertedWith(REVERT_MESSAGE_ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE); -@@ -400,15 +416,15 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios - +@@ -503,15 +518,15 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", + describe("Premint and restricted balances", async () => { let timestamp: number; - before(async () => { @@ -150,7 +152,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 5) ).to.changeTokenBalances( -@@ -424,7 +440,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -527,7 +542,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 10)); @@ -159,7 +161,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 10) ).to.changeTokenBalances( -@@ -440,7 +456,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -543,7 +558,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 10)); @@ -168,7 +170,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 15) ).to.changeTokenBalances( -@@ -456,7 +472,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -559,7 +574,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 10)); @@ -177,7 +179,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 20) ).to.changeTokenBalances( -@@ -472,7 +488,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -575,7 +590,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 10)); @@ -186,7 +188,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 25) ).to.be.revertedWith(REVERT_MESSAGE_ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE); -@@ -484,7 +500,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -587,7 +602,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 10)); @@ -195,7 +197,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 5) ).to.changeTokenBalances( -@@ -500,7 +516,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -603,7 +618,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 10)); @@ -204,7 +206,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 10) ).to.changeTokenBalances( -@@ -516,7 +532,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -619,7 +634,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 10)); @@ -213,7 +215,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 15) ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_RESTRICTED_AMOUNT); -@@ -527,7 +543,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -630,7 +645,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 10)); @@ -222,7 +224,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 20) ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_RESTRICTED_AMOUNT); -@@ -538,7 +554,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -641,7 +656,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).mint(user.address, 10)); await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 10)); @@ -231,8 +233,8 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 25) ).to.be.revertedWith(REVERT_MESSAGE_ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE); -@@ -664,8 +680,8 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios - +@@ -767,8 +782,8 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", + describe("Frozen, restricted and premint balances", async () => { let timestamp: number; - before(async () => { @@ -242,7 +244,7 @@ index f5cbce5..053cfc5 100644 }); it("Transfer to purpose account - test 5 with release awaiting", async () => { const { token } = await setUpFixture(deployAndConfigureToken); -@@ -673,7 +689,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -776,7 +791,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).premint(user.address, 5, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 5)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 5)); @@ -251,7 +253,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 5) ).to.changeTokenBalances( -@@ -690,7 +706,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -793,7 +808,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).premint(user.address, 5, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 5)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 5)); @@ -260,7 +262,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 10) ).to.changeTokenBalances( -@@ -707,7 +723,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -810,7 +825,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).premint(user.address, 5, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 5)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 5)); @@ -269,7 +271,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 15) ).to.changeTokenBalances( -@@ -724,7 +740,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -827,7 +842,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).premint(user.address, 5, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 5)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 5)); @@ -278,7 +280,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 20) ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_FROZEN_AMOUNT); -@@ -736,7 +752,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -839,7 +854,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).premint(user.address, 5, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 5)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 5)); @@ -287,7 +289,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 25) ).to.be.revertedWith(REVERT_MESSAGE_ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE); -@@ -748,7 +764,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -851,7 +866,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).premint(user.address, 5, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 5)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 5)); @@ -296,7 +298,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 5) ).to.changeTokenBalances( -@@ -765,7 +781,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -868,7 +883,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).premint(user.address, 5, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 5)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 5)); @@ -305,7 +307,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 10) ).to.changeTokenBalances( -@@ -782,7 +798,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -885,7 +900,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).premint(user.address, 5, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 5)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 5)); @@ -314,7 +316,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 15) ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_RESTRICTED_AMOUNT); -@@ -794,7 +810,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -897,7 +912,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).premint(user.address, 5, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 5)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 5)); @@ -323,7 +325,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 20) ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_FROZEN_AMOUNT); -@@ -806,7 +822,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -909,7 +924,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", await proveTx(token.connect(deployer).premint(user.address, 5, timestamp)); await proveTx(token.connect(deployer).freeze(user.address, 5)); await proveTx(token.connect(deployer).updateRestriction(user.address, PURPOSE, 5)); @@ -332,8 +334,8 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 25) ).to.be.revertedWith(REVERT_MESSAGE_ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE); -@@ -1194,13 +1210,13 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios - +@@ -1297,13 +1312,13 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", + describe("Premint balance only, no frozen balance or restricted balance", async () => { let timestamp: number; - before(async () => { @@ -349,7 +351,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 5) ).to.changeTokenBalances( -@@ -1213,7 +1229,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -1316,7 +1331,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", it("Transfer to purpose account with release awaiting - test 10", async () => { const { token } = await setUpFixture(deployAndConfigureToken); await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); @@ -358,7 +360,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 10) ).to.changeTokenBalances( -@@ -1226,7 +1242,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -1329,7 +1344,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", it("Transfer to purpose account with release awaiting - test 15", async () => { const { token } = await setUpFixture(deployAndConfigureToken); await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); @@ -367,7 +369,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 15) ).to.changeTokenBalances( -@@ -1239,7 +1255,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -1342,7 +1357,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", it("Transfer to purpose account with release awaiting - test 20", async () => { const { token } = await setUpFixture(deployAndConfigureToken); await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); @@ -376,7 +378,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 20) ).to.changeTokenBalances( -@@ -1252,7 +1268,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -1355,7 +1370,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", it("Transfer to purpose account with release awaiting - test 25", async () => { const { token } = await setUpFixture(deployAndConfigureToken); await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); @@ -385,7 +387,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(purposeAccount.address, 25) ).to.be.revertedWith(REVERT_MESSAGE_ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE); -@@ -1261,7 +1277,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -1364,7 +1379,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", it("Transfer to non-purpose account with release awaiting - test 5", async () => { const { token } = await setUpFixture(deployAndConfigureToken); await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); @@ -394,7 +396,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 5) ).to.changeTokenBalances( -@@ -1274,7 +1290,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -1377,7 +1392,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", it("Transfer to non-purpose account with release awaiting - test 10", async () => { const { token } = await setUpFixture(deployAndConfigureToken); await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); @@ -403,7 +405,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 10) ).to.changeTokenBalances( -@@ -1287,7 +1303,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -1390,7 +1405,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", it("Transfer to non-purpose account with release awaiting - test 15", async () => { const { token } = await setUpFixture(deployAndConfigureToken); await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); @@ -412,7 +414,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 15) ).to.changeTokenBalances( -@@ -1300,7 +1316,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -1403,7 +1418,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", it("Transfer to non-purpose account with release awaiting - test 20", async () => { const { token } = await setUpFixture(deployAndConfigureToken); await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); @@ -421,7 +423,7 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 20) ).to.changeTokenBalances( -@@ -1313,7 +1329,7 @@ describe("Contract 'BRLCToken' - Premintable, Freezable & Restrictable scenarios +@@ -1416,7 +1431,7 @@ describe("Contract 'CWToken' - Premintable, Freezable & Restrictable scenarios", it("Transfer to non-purpose account with release awaiting - test 25", async () => { const { token } = await setUpFixture(deployAndConfigureToken); await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); @@ -430,208 +432,3 @@ index f5cbce5..053cfc5 100644 await expect( token.connect(user).transfer(nonPurposeAccount.address, 25) ).to.be.revertedWith(REVERT_MESSAGE_ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE); -diff --git a/test/USJimToken.complex.test.ts b/test/USJimToken.complex.test.ts -index 1e44d6e..a1c40ab 100644 ---- a/test/USJimToken.complex.test.ts -+++ b/test/USJimToken.complex.test.ts -@@ -49,17 +49,32 @@ describe("Contract 'USJimToken' - Premintable & Freezable scenarios", async () = - return { token }; - } - -+ async function latest(): Promise { -+ return parseInt((await ethers.provider.send("eth_getBlockByNumber", ["latest", false])).timestamp, 16); -+ } -+ -+ async function increaseTo(target: number) { -+ // Sends a RPC request to the blockchain. -+ if (network.name === "hardhat") { -+ // A virtual wait through network time shifting -+ await time.increaseTo(target); -+ } else if (network.name === "stratus") { -+ await ethers.provider.send("evm_setNextBlockTimestamp", [target]); -+ await ethers.provider.send("evm_mine", []); -+ } -+ } -+ - describe("Frozen and premint balances", async () => { - let timestamp: number; -- before(async () => { -- timestamp = (await time.latest()) + 100; -+ beforeEach(async () => { -+ timestamp = (await latest()) + 100; - }); - it("Transfer - test 5 with release awaiting", async () => { - const { token } = await setUpFixture(deployAndConfigureToken); - await proveTx(token.connect(deployer).mint(user.address, 10)); - await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); - await proveTx(token.connect(deployer).freeze(user.address, 10)); -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - await expect( - token.connect(user).transfer(reciever.address, 5) - ).to.changeTokenBalances( -@@ -74,7 +89,7 @@ describe("Contract 'USJimToken' - Premintable & Freezable scenarios", async () = - await proveTx(token.connect(deployer).mint(user.address, 10)); - await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); - await proveTx(token.connect(deployer).freeze(user.address, 10)); -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - await expect( - token.connect(user).transfer(reciever.address, 10) - ).to.changeTokenBalances( -@@ -89,7 +104,7 @@ describe("Contract 'USJimToken' - Premintable & Freezable scenarios", async () = - await proveTx(token.connect(deployer).mint(user.address, 10)); - await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); - await proveTx(token.connect(deployer).freeze(user.address, 10)); -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - await expect( - token.connect(user).transfer(reciever.address, 15) - ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_FROZEN_AMOUNT); -@@ -100,7 +115,7 @@ describe("Contract 'USJimToken' - Premintable & Freezable scenarios", async () = - await proveTx(token.connect(deployer).mint(user.address, 10)); - await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); - await proveTx(token.connect(deployer).freeze(user.address, 10)); -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - await expect( - token.connect(user).transfer(reciever.address, 20) - ).to.be.revertedWithCustomError(token, REVERT_ERROR_TRANSFER_EXCEEDED_FROZEN_AMOUNT); -@@ -111,7 +126,7 @@ describe("Contract 'USJimToken' - Premintable & Freezable scenarios", async () = - await proveTx(token.connect(deployer).mint(user.address, 10)); - await proveTx(token.connect(deployer).premint(user.address, 10, timestamp)); - await proveTx(token.connect(deployer).freeze(user.address, 10)); -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - await expect( - token.connect(user).transfer(reciever.address, 25) - ).to.be.revertedWith(REVERT_MESSAGE_ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE); -@@ -235,13 +250,13 @@ describe("Contract 'USJimToken' - Premintable & Freezable scenarios", async () = - - describe("Premint balance only, no frozen balance", async () => { - let timestamp: number; -- before(async () => { -- timestamp = (await time.latest()) + 100; -+ beforeEach(async () => { -+ timestamp = (await latest()) + 100; - }); - it("Transfer - test 5 with release awaiting", async () => { - const { token } = await setUpFixture(deployAndConfigureToken); - await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - await expect( - token.connect(user).transfer(reciever.address, 5) - ).to.changeTokenBalances( -@@ -254,7 +269,7 @@ describe("Contract 'USJimToken' - Premintable & Freezable scenarios", async () = - it("Transfer - test 10 with release awaiting", async () => { - const { token } = await setUpFixture(deployAndConfigureToken); - await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - await expect( - token.connect(user).transfer(reciever.address, 10) - ).to.changeTokenBalances( -@@ -267,7 +282,7 @@ describe("Contract 'USJimToken' - Premintable & Freezable scenarios", async () = - it("Transfer - test 15 with release awaiting", async () => { - const { token } = await setUpFixture(deployAndConfigureToken); - await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - await expect( - token.connect(user).transfer(reciever.address, 15) - ).to.changeTokenBalances( -@@ -280,7 +295,7 @@ describe("Contract 'USJimToken' - Premintable & Freezable scenarios", async () = - it("Transfer - test 20 with release awaiting", async () => { - const { token } = await setUpFixture(deployAndConfigureToken); - await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - await expect( - token.connect(user).transfer(reciever.address, 20) - ).to.changeTokenBalances( -@@ -293,7 +308,7 @@ describe("Contract 'USJimToken' - Premintable & Freezable scenarios", async () = - it("Transfer - test 25 with release awaiting", async () => { - const { token } = await setUpFixture(deployAndConfigureToken); - await proveTx(token.connect(deployer).premint(user.address, 20, timestamp)); -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - await expect( - token.connect(user).transfer(reciever.address, 25) - ).to.be.revertedWith(REVERT_MESSAGE_ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE); -diff --git a/test/base/ERC20Mintable.test.ts b/test/base/ERC20Mintable.test.ts -index 8d1afc1..a196969 100644 ---- a/test/base/ERC20Mintable.test.ts -+++ b/test/base/ERC20Mintable.test.ts -@@ -62,6 +62,21 @@ describe("Contract 'ERC20Mintable'", async () => { - tokenFactory = await ethers.getContractFactory("ERC20MintableMock"); - }); - -+ async function latest(): Promise { -+ return parseInt((await ethers.provider.send("eth_getBlockByNumber", ["latest", false])).timestamp, 16); -+ } -+ -+ async function increaseTo(target: number) { -+ // Sends a RPC request to the blockchain. -+ if (network.name === "hardhat") { -+ // A virtual wait through network time shifting -+ await time.increaseTo(target); -+ } else if (network.name === "stratus") { -+ await ethers.provider.send("evm_setNextBlockTimestamp", [target]); -+ await ethers.provider.send("evm_mine", []); -+ } -+ } -+ - async function deployToken(): Promise<{ token: Contract }> { - const token: Contract = await upgrades.deployProxy(tokenFactory, [TOKEN_NAME, TOKEN_SYMBOL]); - await token.deployed(); -@@ -334,8 +349,8 @@ describe("Contract 'ERC20Mintable'", async () => { - - describe("Function 'premint()'", async () => { - let timestamp: number; -- before(async () => { -- timestamp = (await time.latest()) + 100; -+ beforeEach(async () => { -+ timestamp = (await latest()) + 100; - }); - - describe("Executes as expected and emits the correct events if", async () => { -@@ -383,7 +398,7 @@ describe("Contract 'ERC20Mintable'", async () => { - await proveTx(token.connect(minter).premint(user.address, TOKEN_AMOUNT, timestamp + i * 10)); - } - expect(await token.balanceOfPremint(user.address)).to.eq(TOKEN_AMOUNT * MAX_PENDING_PREMINTS_COUNT); -- await time.increaseTo(timestamp + 1); -+ await increaseTo(timestamp + 1); - expect(await token.balanceOfPremint(user.address)).to.eq(TOKEN_AMOUNT * (MAX_PENDING_PREMINTS_COUNT - 1)); - await proveTx(token.connect(minter).premint(user.address, TOKEN_AMOUNT + 1, timestamp * 2)); - expect(await token.balanceOfPremint(user.address)).to.eq(TOKEN_AMOUNT * MAX_PENDING_PREMINTS_COUNT + 1); -@@ -400,7 +415,7 @@ describe("Contract 'ERC20Mintable'", async () => { - - it("The premint's release time is passed", async () => { - const { token } = await setUpFixture(deployAndConfigureToken); -- const timestamp = (await time.latest()) - 1; -+ const timestamp = (await latest()) - 1; - await expect(token.connect(minter).premint(user.address, TOKEN_AMOUNT, timestamp)) - .to.be.revertedWithCustomError(token, REVERT_ERROR_PREMINT_RELEASE_TIME_PASSED); - }); -@@ -491,17 +506,17 @@ describe("Contract 'ERC20Mintable'", async () => { - - describe("Function 'balanceOfPremint()'", async () => { - it("Returns the correct balance of premint", async () => { -- const timestamp = (await time.latest()) + 100; -+ const timestamp = (await latest()) + 100; - const { token } = await setUpFixture(deployAndConfigureToken); - - await proveTx(token.connect(minter).premint(user.address, TOKEN_AMOUNT, timestamp)); - await proveTx(token.connect(minter).premint(user.address, TOKEN_AMOUNT + 1, timestamp + 50)); - expect(await token.balanceOfPremint(user.address)).to.eq(TOKEN_AMOUNT * 2 + 1); - -- await time.increaseTo(timestamp); -+ await increaseTo(timestamp); - expect(await token.balanceOfPremint(user.address)).to.eq(TOKEN_AMOUNT + 1); - -- await time.increaseTo(timestamp + 50); -+ await increaseTo(timestamp + 50); - expect(await token.balanceOfPremint(user.address)).to.eq(0); - }); - }); diff --git a/e2e-contracts/test-contracts.sh b/e2e-contracts/test-contracts.sh index c4ef32e35..b4fae8303 100755 --- a/e2e-contracts/test-contracts.sh +++ b/e2e-contracts/test-contracts.sh @@ -71,10 +71,9 @@ fi # execute if [ "$token" == 1 ]; then - test brlc-token BRLCToken.base - test brlc-token BRLCToken.complex + test brlc-token BRLCToken + test brlc-token base/CWToken.complex test brlc-token BRLCTokenBridgeable - test brlc-token USJimToken.complex test brlc-token USJimToken fi diff --git a/static/contracts/BRLCToken.signatures b/static/contracts/BRLCToken.signatures index 561cb3fed..d9f2324ec 100644 --- a/static/contracts/BRLCToken.signatures +++ b/static/contracts/BRLCToken.signatures @@ -37,6 +37,7 @@ bf2fa22b: mainMinter() 8456cb59: pause() 5c975abb: paused() 9fd0506d: pauser() +f7bb5c88: premint(address,uint256,uint256) 3092afd5: removeMinter(address) 715018a6: renounceOwnership() b2118a8d: rescueERC20(address,address,uint256) @@ -67,7 +68,11 @@ d0de3bff: ExceededMintAllowance() 98b70ef7: FreezingAlreadyApproved() cecd8222: FreezingNotApproved() 390c2caa: LackOfFrozenBalance() +0522a022: MaxPendingPremintsCountAlreadyConfigured() +fb2deceb: MaxPendingPremintsLimitReached() +0f5d8c27: PremintReleaseTimePassed() 709e2c14: TransferExceededFrozenAmount() +bc260d1b: TransferExceededPremintedAmount() e96a60ef: TransferExceededRestrictedAmount() 07768670: UnauthorizedBlocklister(address) 07349a1d: UnauthorizedMainBlocklister(address)