Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add setFeeCollector #776

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions contracts/templates/ERC20Template3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,14 @@ contract ERC20Template3 is
address exchangeContract,
address indexed baseToken
);
event NewDispenser(address dispenserContract);


event NewPaymentCollector(
address indexed caller,
address indexed _newPaymentCollector,
uint256 timestamp,
uint256 blockNumber
);


modifier onlyNotInitialized() {
require(
!initialized,
Expand Down Expand Up @@ -338,12 +336,6 @@ contract ERC20Template3 is
initialized = true;
// set payment collector to this contract, so we can get the $$$
_setPaymentCollector(address(this));
emit NewPaymentCollector(
msg.sender,
address(this),
block.timestamp,
block.number
);
publishMarketFeeAddress = addresses_[2];
publishMarketFeeToken = addresses_[3];
publishMarketFeeAmount = uints_[1];
Expand Down Expand Up @@ -521,18 +513,6 @@ contract ERC20Template3 is
_removeMinter(_minter);
}

/**
* @dev setData
* Only ERC20Deployer (at 721 level) can call it.
* This function allows to store data with a preset key (keccak256(ERC20Address)) into NFT 725 Store
* @param _value data to be set with this key
*/

function setData(bytes calldata _value) external onlyERC20Deployer {
bytes32 key = keccak256(abi.encodePacked(address(this)));
IERC721Template(_erc721Address).setDataERC20(key, _value);
}

/**
* @dev cleanPermissions()
* Only NFT Owner (at 721 level) can call it.
Expand Down Expand Up @@ -627,8 +607,28 @@ contract ERC20Template3 is

function _setPaymentCollector(address _newPaymentCollector) internal {
paymentCollector = _newPaymentCollector;
emit NewPaymentCollector(
msg.sender,
paymentCollector,
block.timestamp,
block.number
);
}

/**
* @dev setFeeCollector
* Only feeManager can call it
* This function allows to set a newFeeCollector
* (will get FRE fees, slashes stakes, revenue per epoch if no predictoors)
* @param _newFeeCollector new fee collector
*/

function setFeeCollector(address _newFeeCollector) external onlyERC20Deployer{
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions

Parameter ERC20Template3.setFeeCollector(address)._newFeeCollector (contracts/templates/ERC20Template3.sol#626) is not in mixedCase
feeCollector = _newFeeCollector;
}



/**
* @dev getPublishingMarketFee
* Get publishingMarket Fee
Expand Down
27 changes: 6 additions & 21 deletions test/unit/datatokens/ERC20Template3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,27 +353,6 @@ describe("ERC20Template3", () => {
assert(address, "Not able to get the parent ERC721 address")
});

it("#setData - should fail to setData if NOT erc20Deployer", async () => {
const key = web3.utils.keccak256(erc20Token.address);
const value = web3.utils.asciiToHex("SomeData");

await expectRevert(
erc20Token.connect(user2).setData(value),
"ERC20Template: NOT DEPLOYER ROLE"
);

assert((await tokenERC721.getData(key)) == "0x");
});

it("#setData - should succeed to setData if erc20Deployer", async () => {
const key = web3.utils.keccak256(erc20Token.address);
const value = web3.utils.asciiToHex("SomeData");

await erc20Token.connect(user3).setData(value);

assert((await tokenERC721.getData(key)) == value);
});

it("#cleanPermissions - should fail to call cleanPermissions if NOT NFTOwner", async () => {
await expectRevert(
erc20Token.connect(user2).cleanPermissions(),
Expand Down Expand Up @@ -749,6 +728,12 @@ describe("ERC20Template3", () => {
assert(publishFee[1] = erc20Token.address)
assert(publishFee[2] = web3.utils.toWei('10'))
});
it("#setFeeCollector - user should not be able to set new fee collector", async () => {
await expectRevert(
erc20TokenWithPublishFee.connect(user2).setFeeCollector(user2.address),
"ERC20Template: NOT DEPLOYER ROLE"
);
});
it("#getId - should return templateId", async () => {
const templateId = 3;
assert((await erc20Token.getId()) == templateId);
Expand Down