forked from rarible/protocol-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from liteflow-labs/feature/mint-control-enumerable
Implement feedback on Mint Access Control
- Loading branch information
Showing
16 changed files
with
218 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const TestingV1 = artifacts.require("MinterAccessControlTestV1.sol"); | ||
const TestingV2 = artifacts.require("MinterAccessControlTestV2.sol"); | ||
|
||
const { expectThrow } = require('@daonomic/tests-common'); | ||
const { deployProxy, upgradeProxy } = require('@openzeppelin/truffle-upgrades'); | ||
|
||
function creators(list) { | ||
const value = 10000 / list.length | ||
return list.map(account => ({ account, value })) | ||
} | ||
|
||
contract("MinterAccessControl", accounts => { | ||
let token; | ||
let tokenOwner = accounts[9]; | ||
|
||
beforeEach(async () => { | ||
token = await deployProxy(TestingV1, [], { initializer: 'initialize' }); | ||
await token.transferOwnership(tokenOwner); | ||
}); | ||
|
||
it("conserve minter access control after upgrade", async () => { | ||
const minter = accounts[1]; | ||
|
||
await token.grantMinter(minter, {from: tokenOwner}) | ||
assert.equal(await token.isValidMinter(minter), true); | ||
|
||
// upgrade contract | ||
const newInstance = await upgradeProxy(token.address, TestingV2); | ||
assert.equal(await newInstance.version(), 2); | ||
|
||
assert.equal(await newInstance.isValidMinter(minter), true); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
tokens/test/contracts/access/MinterAccessControlTestV1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity >=0.6.0 <0.8.0; | ||
|
||
import "../../../contracts/access/MinterAccessControl.sol"; | ||
|
||
contract MinterAccessControlTestV1 is MinterAccessControl { | ||
|
||
function initialize() external initializer { | ||
__Ownable_init_unchained(); | ||
__MinterAccessControl_init_unchained(); | ||
} | ||
|
||
uint256[50] private __gap; | ||
} |
19 changes: 19 additions & 0 deletions
19
tokens/test/contracts/access/MinterAccessControlTestV2.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity >=0.6.0 <0.8.0; | ||
|
||
import "../../../contracts/access/MinterAccessControl.sol"; | ||
|
||
contract MinterAccessControlTestV2 is MinterAccessControl { | ||
|
||
function initialize() external initializer { | ||
__Ownable_init_unchained(); | ||
__MinterAccessControl_init_unchained(); | ||
} | ||
|
||
function version() public view returns (uint256) { | ||
return 2; | ||
} | ||
|
||
uint256[50] private __gap; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.