Remove presets (#3637)

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
Co-authored-by: JulissaDantes <julissadcj@gmail.com>
This commit is contained in:
Hadrien Croubois
2022-11-25 16:46:47 +01:00
committed by GitHub
parent 887985413c
commit 4a9db80cb9
26 changed files with 7 additions and 1025 deletions

View File

@ -1,146 +0,0 @@
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { shouldSupportInterfaces } = require('../../../utils/introspection/SupportsInterface.behavior');
const { expect } = require('chai');
const ERC1155PresetMinterPauser = artifacts.require('ERC1155PresetMinterPauser');
contract('ERC1155PresetMinterPauser', function (accounts) {
const [ deployer, other ] = accounts;
const firstTokenId = new BN('845');
const firstTokenIdAmount = new BN('5000');
const secondTokenId = new BN('48324');
const secondTokenIdAmount = new BN('77875');
const DEFAULT_ADMIN_ROLE = '0x0000000000000000000000000000000000000000000000000000000000000000';
const MINTER_ROLE = web3.utils.soliditySha3('MINTER_ROLE');
const PAUSER_ROLE = web3.utils.soliditySha3('PAUSER_ROLE');
const uri = 'https://token.com';
beforeEach(async function () {
this.token = await ERC1155PresetMinterPauser.new(uri, { from: deployer });
});
shouldSupportInterfaces(['ERC1155', 'AccessControl', 'AccessControlEnumerable']);
it('deployer has the default admin role', async function () {
expect(await this.token.getRoleMemberCount(DEFAULT_ADMIN_ROLE)).to.be.bignumber.equal('1');
expect(await this.token.getRoleMember(DEFAULT_ADMIN_ROLE, 0)).to.equal(deployer);
});
it('deployer has the minter role', async function () {
expect(await this.token.getRoleMemberCount(MINTER_ROLE)).to.be.bignumber.equal('1');
expect(await this.token.getRoleMember(MINTER_ROLE, 0)).to.equal(deployer);
});
it('deployer has the pauser role', async function () {
expect(await this.token.getRoleMemberCount(PAUSER_ROLE)).to.be.bignumber.equal('1');
expect(await this.token.getRoleMember(PAUSER_ROLE, 0)).to.equal(deployer);
});
it('minter and pauser role admin is the default admin', async function () {
expect(await this.token.getRoleAdmin(MINTER_ROLE)).to.equal(DEFAULT_ADMIN_ROLE);
expect(await this.token.getRoleAdmin(PAUSER_ROLE)).to.equal(DEFAULT_ADMIN_ROLE);
});
describe('minting', function () {
it('deployer can mint tokens', async function () {
const receipt = await this.token.mint(other, firstTokenId, firstTokenIdAmount, '0x', { from: deployer });
expectEvent(receipt, 'TransferSingle',
{ operator: deployer, from: ZERO_ADDRESS, to: other, value: firstTokenIdAmount, id: firstTokenId },
);
expect(await this.token.balanceOf(other, firstTokenId)).to.be.bignumber.equal(firstTokenIdAmount);
});
it('other accounts cannot mint tokens', async function () {
await expectRevert(
this.token.mint(other, firstTokenId, firstTokenIdAmount, '0x', { from: other }),
'ERC1155PresetMinterPauser: must have minter role to mint',
);
});
});
describe('batched minting', function () {
it('deployer can batch mint tokens', async function () {
const receipt = await this.token.mintBatch(
other, [firstTokenId, secondTokenId], [firstTokenIdAmount, secondTokenIdAmount], '0x', { from: deployer },
);
expectEvent(receipt, 'TransferBatch',
{ operator: deployer, from: ZERO_ADDRESS, to: other },
);
expect(await this.token.balanceOf(other, firstTokenId)).to.be.bignumber.equal(firstTokenIdAmount);
});
it('other accounts cannot batch mint tokens', async function () {
await expectRevert(
this.token.mintBatch(
other, [firstTokenId, secondTokenId], [firstTokenIdAmount, secondTokenIdAmount], '0x', { from: other },
),
'ERC1155PresetMinterPauser: must have minter role to mint',
);
});
});
describe('pausing', function () {
it('deployer can pause', async function () {
const receipt = await this.token.pause({ from: deployer });
expectEvent(receipt, 'Paused', { account: deployer });
expect(await this.token.paused()).to.equal(true);
});
it('deployer can unpause', async function () {
await this.token.pause({ from: deployer });
const receipt = await this.token.unpause({ from: deployer });
expectEvent(receipt, 'Unpaused', { account: deployer });
expect(await this.token.paused()).to.equal(false);
});
it('cannot mint while paused', async function () {
await this.token.pause({ from: deployer });
await expectRevert(
this.token.mint(other, firstTokenId, firstTokenIdAmount, '0x', { from: deployer }),
'ERC1155Pausable: token transfer while paused',
);
});
it('other accounts cannot pause', async function () {
await expectRevert(
this.token.pause({ from: other }),
'ERC1155PresetMinterPauser: must have pauser role to pause',
);
});
it('other accounts cannot unpause', async function () {
await this.token.pause({ from: deployer });
await expectRevert(
this.token.unpause({ from: other }),
'ERC1155PresetMinterPauser: must have pauser role to unpause',
);
});
});
describe('burning', function () {
it('holders can burn their tokens', async function () {
await this.token.mint(other, firstTokenId, firstTokenIdAmount, '0x', { from: deployer });
const receipt = await this.token.burn(other, firstTokenId, firstTokenIdAmount.subn(1), { from: other });
expectEvent(receipt, 'TransferSingle',
{ operator: other, from: other, to: ZERO_ADDRESS, value: firstTokenIdAmount.subn(1), id: firstTokenId },
);
expect(await this.token.balanceOf(other, firstTokenId)).to.be.bignumber.equal('1');
});
});
});

View File

@ -1,42 +0,0 @@
const { BN, constants, expectEvent } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const ERC20PresetFixedSupply = artifacts.require('ERC20PresetFixedSupply');
contract('ERC20PresetFixedSupply', function (accounts) {
const [deployer, owner] = accounts;
const name = 'PresetFixedSupply';
const symbol = 'PFS';
const initialSupply = new BN('50000');
const amount = new BN('10000');
before(async function () {
this.token = await ERC20PresetFixedSupply.new(name, symbol, initialSupply, owner, { from: deployer });
});
it('deployer has the balance equal to initial supply', async function () {
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(initialSupply);
});
it('total supply is equal to initial supply', async function () {
expect(await this.token.totalSupply()).to.be.bignumber.equal(initialSupply);
});
describe('burning', function () {
it('holders can burn their tokens', async function () {
const remainingBalance = initialSupply.sub(amount);
const receipt = await this.token.burn(amount, { from: owner });
expectEvent(receipt, 'Transfer', { from: owner, to: ZERO_ADDRESS, value: amount });
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(remainingBalance);
});
it('decrements totalSupply', async function () {
const expectedSupply = initialSupply.sub(amount);
expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedSupply);
});
});
});

View File

@ -1,113 +0,0 @@
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const ERC20PresetMinterPauser = artifacts.require('ERC20PresetMinterPauser');
contract('ERC20PresetMinterPauser', function (accounts) {
const [ deployer, other ] = accounts;
const name = 'MinterPauserToken';
const symbol = 'DRT';
const amount = new BN('5000');
const DEFAULT_ADMIN_ROLE = '0x0000000000000000000000000000000000000000000000000000000000000000';
const MINTER_ROLE = web3.utils.soliditySha3('MINTER_ROLE');
const PAUSER_ROLE = web3.utils.soliditySha3('PAUSER_ROLE');
beforeEach(async function () {
this.token = await ERC20PresetMinterPauser.new(name, symbol, { from: deployer });
});
it('deployer has the default admin role', async function () {
expect(await this.token.getRoleMemberCount(DEFAULT_ADMIN_ROLE)).to.be.bignumber.equal('1');
expect(await this.token.getRoleMember(DEFAULT_ADMIN_ROLE, 0)).to.equal(deployer);
});
it('deployer has the minter role', async function () {
expect(await this.token.getRoleMemberCount(MINTER_ROLE)).to.be.bignumber.equal('1');
expect(await this.token.getRoleMember(MINTER_ROLE, 0)).to.equal(deployer);
});
it('deployer has the pauser role', async function () {
expect(await this.token.getRoleMemberCount(PAUSER_ROLE)).to.be.bignumber.equal('1');
expect(await this.token.getRoleMember(PAUSER_ROLE, 0)).to.equal(deployer);
});
it('minter and pauser role admin is the default admin', async function () {
expect(await this.token.getRoleAdmin(MINTER_ROLE)).to.equal(DEFAULT_ADMIN_ROLE);
expect(await this.token.getRoleAdmin(PAUSER_ROLE)).to.equal(DEFAULT_ADMIN_ROLE);
});
describe('minting', function () {
it('deployer can mint tokens', async function () {
const receipt = await this.token.mint(other, amount, { from: deployer });
expectEvent(receipt, 'Transfer', { from: ZERO_ADDRESS, to: other, value: amount });
expect(await this.token.balanceOf(other)).to.be.bignumber.equal(amount);
});
it('other accounts cannot mint tokens', async function () {
await expectRevert(
this.token.mint(other, amount, { from: other }),
'ERC20PresetMinterPauser: must have minter role to mint',
);
});
});
describe('pausing', function () {
it('deployer can pause', async function () {
const receipt = await this.token.pause({ from: deployer });
expectEvent(receipt, 'Paused', { account: deployer });
expect(await this.token.paused()).to.equal(true);
});
it('deployer can unpause', async function () {
await this.token.pause({ from: deployer });
const receipt = await this.token.unpause({ from: deployer });
expectEvent(receipt, 'Unpaused', { account: deployer });
expect(await this.token.paused()).to.equal(false);
});
it('cannot mint while paused', async function () {
await this.token.pause({ from: deployer });
await expectRevert(
this.token.mint(other, amount, { from: deployer }),
'ERC20Pausable: token transfer while paused',
);
});
it('other accounts cannot pause', async function () {
await expectRevert(
this.token.pause({ from: other }),
'ERC20PresetMinterPauser: must have pauser role to pause',
);
});
it('other accounts cannot unpause', async function () {
await this.token.pause({ from: deployer });
await expectRevert(
this.token.unpause({ from: other }),
'ERC20PresetMinterPauser: must have pauser role to unpause',
);
});
});
describe('burning', function () {
it('holders can burn their tokens', async function () {
await this.token.mint(other, amount, { from: deployer });
const receipt = await this.token.burn(amount.subn(1), { from: other });
expectEvent(receipt, 'Transfer', { from: other, to: ZERO_ADDRESS, value: amount.subn(1) });
expect(await this.token.balanceOf(other)).to.be.bignumber.equal('1');
});
});
});

View File

@ -1,125 +0,0 @@
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { shouldSupportInterfaces } = require('../../../utils/introspection/SupportsInterface.behavior');
const { expect } = require('chai');
const ERC721PresetMinterPauserAutoId = artifacts.require('ERC721PresetMinterPauserAutoId');
contract('ERC721PresetMinterPauserAutoId', function (accounts) {
const [ deployer, other ] = accounts;
const name = 'MinterAutoIDToken';
const symbol = 'MAIT';
const baseURI = 'my.app/';
const DEFAULT_ADMIN_ROLE = '0x0000000000000000000000000000000000000000000000000000000000000000';
const MINTER_ROLE = web3.utils.soliditySha3('MINTER_ROLE');
beforeEach(async function () {
this.token = await ERC721PresetMinterPauserAutoId.new(name, symbol, baseURI, { from: deployer });
});
shouldSupportInterfaces(['ERC721', 'ERC721Enumerable', 'AccessControl', 'AccessControlEnumerable']);
it('token has correct name', async function () {
expect(await this.token.name()).to.equal(name);
});
it('token has correct symbol', async function () {
expect(await this.token.symbol()).to.equal(symbol);
});
it('deployer has the default admin role', async function () {
expect(await this.token.getRoleMemberCount(DEFAULT_ADMIN_ROLE)).to.be.bignumber.equal('1');
expect(await this.token.getRoleMember(DEFAULT_ADMIN_ROLE, 0)).to.equal(deployer);
});
it('deployer has the minter role', async function () {
expect(await this.token.getRoleMemberCount(MINTER_ROLE)).to.be.bignumber.equal('1');
expect(await this.token.getRoleMember(MINTER_ROLE, 0)).to.equal(deployer);
});
it('minter role admin is the default admin', async function () {
expect(await this.token.getRoleAdmin(MINTER_ROLE)).to.equal(DEFAULT_ADMIN_ROLE);
});
describe('minting', function () {
it('deployer can mint tokens', async function () {
const tokenId = new BN('0');
const receipt = await this.token.mint(other, { from: deployer });
expectEvent(receipt, 'Transfer', { from: ZERO_ADDRESS, to: other, tokenId });
expect(await this.token.balanceOf(other)).to.be.bignumber.equal('1');
expect(await this.token.ownerOf(tokenId)).to.equal(other);
expect(await this.token.tokenURI(tokenId)).to.equal(baseURI + tokenId);
});
it('other accounts cannot mint tokens', async function () {
await expectRevert(
this.token.mint(other, { from: other }),
'ERC721PresetMinterPauserAutoId: must have minter role to mint',
);
});
});
describe('pausing', function () {
it('deployer can pause', async function () {
const receipt = await this.token.pause({ from: deployer });
expectEvent(receipt, 'Paused', { account: deployer });
expect(await this.token.paused()).to.equal(true);
});
it('deployer can unpause', async function () {
await this.token.pause({ from: deployer });
const receipt = await this.token.unpause({ from: deployer });
expectEvent(receipt, 'Unpaused', { account: deployer });
expect(await this.token.paused()).to.equal(false);
});
it('cannot mint while paused', async function () {
await this.token.pause({ from: deployer });
await expectRevert(
this.token.mint(other, { from: deployer }),
'ERC721Pausable: token transfer while paused',
);
});
it('other accounts cannot pause', async function () {
await expectRevert(
this.token.pause({ from: other }),
'ERC721PresetMinterPauserAutoId: must have pauser role to pause',
);
});
it('other accounts cannot unpause', async function () {
await this.token.pause({ from: deployer });
await expectRevert(
this.token.unpause({ from: other }),
'ERC721PresetMinterPauserAutoId: must have pauser role to unpause',
);
});
});
describe('burning', function () {
it('holders can burn their tokens', async function () {
const tokenId = new BN('0');
await this.token.mint(other, { from: deployer });
const receipt = await this.token.burn(tokenId, { from: other });
expectEvent(receipt, 'Transfer', { from: other, to: ZERO_ADDRESS, tokenId });
expect(await this.token.balanceOf(other)).to.be.bignumber.equal('0');
expect(await this.token.totalSupply()).to.be.bignumber.equal('0');
});
});
});

View File

@ -1,49 +0,0 @@
const { BN, singletons } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC777PresetFixedSupply = artifacts.require('ERC777PresetFixedSupply');
contract('ERC777PresetFixedSupply', function (accounts) {
const [registryFunder, owner, defaultOperatorA, defaultOperatorB, anyone] = accounts;
const initialSupply = new BN('10000');
const name = 'ERC777Preset';
const symbol = '777P';
const defaultOperators = [defaultOperatorA, defaultOperatorB];
before(async function () {
await singletons.ERC1820Registry(registryFunder);
});
beforeEach(async function () {
this.token = await ERC777PresetFixedSupply.new(name, symbol, defaultOperators, initialSupply, owner);
});
it('returns the name', async function () {
expect(await this.token.name()).to.equal(name);
});
it('returns the symbol', async function () {
expect(await this.token.symbol()).to.equal(symbol);
});
it('returns the default operators', async function () {
expect(await this.token.defaultOperators()).to.deep.equal(defaultOperators);
});
it('default operators are operators for all accounts', async function () {
for (const operator of defaultOperators) {
expect(await this.token.isOperatorFor(operator, anyone)).to.equal(true);
}
});
it('returns the total supply equal to initial supply', async function () {
expect(await this.token.totalSupply()).to.be.bignumber.equal(initialSupply);
});
it('returns the balance of owner equal to initial supply', async function () {
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(initialSupply);
});
});