Skip to content

Commit 6dafbf3

Browse files
committed
refactor + fees
1 parent e229cff commit 6dafbf3

15 files changed

+665
-755
lines changed

contracts/ERC721Factory.sol

+34-27
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import "./interfaces/IERC721Template.sol";
99
import "./interfaces/IFactory.sol";
1010
import "@openzeppelin/contracts/access/Ownable.sol";
1111
import "./interfaces/IERC20Template.sol";
12-
12+
import "hardhat/console.sol";
1313
/**
1414
* @title DTFactory contract
1515
* @author Ocean Protocol Team
@@ -276,29 +276,35 @@ contract ERC721Factory is Deployer, Ownable {
276276
* @dev Deploys new DataToken proxy contract.
277277
* This function is not called directly from here. It's called from the NFT contract.
278278
An NFT contract can deploy multiple ERC20 tokens.
279-
280-
* @param name token name
281-
* @param symbol token symbol
282-
* @param cap the maximum total supply
283279
* @param _templateIndex ERC20Template index
284-
* @param minter account who can mint datatokens (can have multiple minters)
285-
280+
* @param strings refers to an array of strings
281+
* [0] = name
282+
* [1] = symbol
283+
* @param addresses refers to an array of addresses
284+
* [0] = minter account who can mint datatokens (can have multiple minters)
285+
* [1] = feeManager initial feeManager for this DT
286+
* [2] = publishing Market Address
287+
* [3] = publishing Market Fee Token
288+
* @param uints refers to an array of uints
289+
* [0] = cap_ the total ERC20 cap
290+
* [1] = publishing Market Fee Amount
291+
* @param bytess refers to an array of bytes
292+
* Currently not used, usefull for future templates
286293
* @return token address of a new proxy DataToken contract
287294
*/
288295
function createToken(
289-
string memory name,
290-
string memory symbol,
291-
uint256 cap,
292296
uint256 _templateIndex,
293-
address minter,
294-
address feeManager
297+
string[] memory strings,
298+
address[] memory addresses,
299+
uint256[] memory uints,
300+
bytes[] calldata bytess
295301
) public returns (address token) {
296302
require(
297303
erc721List[msg.sender] == msg.sender,
298304
"ERC721Factory: ONLY ERC721 INSTANCE FROM ERC721FACTORY"
299305
);
300306

301-
require(cap != 0, "ERC20Factory: zero cap is not allowed");
307+
require(uints[0] != 0, "ERC20Factory: zero cap is not allowed");
302308
require(
303309
_templateIndex <= templateCount && _templateIndex != 0,
304310
"ERC20Factory: Template index doesnt exist"
@@ -311,7 +317,7 @@ contract ERC721Factory is Deployer, Ownable {
311317
);
312318

313319
token = deploy(tokenTemplate.templateAddress);
314-
320+
315321
erc20List[token] = true;
316322

317323
require(
@@ -320,24 +326,25 @@ contract ERC721Factory is Deployer, Ownable {
320326
);
321327

322328
IERC20Template tokenInstance = IERC20Template(token);
323-
324-
325-
329+
address[] memory factoryAddresses = new address[](3);
330+
factoryAddresses[0] = msg.sender;
331+
332+
factoryAddresses[1] = communityFeeCollector;
333+
334+
factoryAddresses[2] = router;
335+
326336
require(
327337
tokenInstance.initialize(
328-
name,
329-
symbol,
330-
msg.sender,
331-
cap,
332-
communityFeeCollector,
333-
minter,
334-
router,
335-
feeManager
338+
strings,
339+
addresses,
340+
factoryAddresses,
341+
uints,
342+
bytess
336343
),
337344
"ERC20Factory: Unable to initialize token instance"
338345
);
339-
emit TokenCreated(token, tokenTemplate.templateAddress, name);
340-
emit TokenRegistered(token, name, symbol, cap, msg.sender);
346+
emit TokenCreated(token, tokenTemplate.templateAddress, strings[0]);
347+
emit TokenRegistered(token, strings[0], strings[1], uints[0], msg.sender);
341348

342349
currentTokenCount += 1;
343350
}

contracts/interfaces/IERC20Template.sol

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@ interface IERC20Template {
66
bool minter;
77
bool feeManager;
88
}
9-
109
function initialize(
11-
string calldata name_,
12-
string calldata symbol_,
13-
address erc721Address,
14-
uint256 cap_,
15-
address communityFeeCollector,
16-
address minter,
17-
address router,
18-
address feeManager
10+
string[] calldata strings_,
11+
address[] calldata addresses_,
12+
address[] calldata factoryAddresses_,
13+
uint256[] calldata uints_,
14+
bytes[] calldata bytes_
1915
) external returns (bool);
20-
16+
2117
function name() external pure returns (string memory);
2218

2319
function symbol() external pure returns (string memory);
@@ -88,4 +84,8 @@ interface IERC20Template {
8884
uint256 marketFee,
8985
address marketFeeCollector
9086
) external returns (bytes32 exchangeId);
87+
88+
function getPublishingMarketFee() external view returns (address , address, uint256);
89+
function setPublishingMarketFee(address _publishMarketFeeAddress, address _publishMarketFeeToken, uint256 _publishMarketFeeAmount) external;
90+
9191
}

contracts/interfaces/IFactory.sol

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pragma solidity >=0.5.7;
2-
2+
pragma experimental ABIEncoderV2;
33
interface IFactory {
44
function initialize(
55
string calldata _name,
@@ -46,14 +46,13 @@ interface IFactory {
4646
function approveMinter() external;
4747

4848
function createToken(
49-
string calldata name,
50-
string calldata symbol,
51-
uint256 cap,
52-
// address erc721address,
5349
uint256 _templateIndex,
54-
address minter,
55-
address feeManager
50+
string[] calldata strings,
51+
address[] calldata addresses,
52+
uint256[] calldata uints,
53+
bytes[] calldata bytess
5654
) external returns (address token);
55+
5756

5857
function addToERC721Registry(address ERC721address) external;
5958

0 commit comments

Comments
 (0)