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

[3.20] Don't ask for name when registering ticker #706

Merged
merged 5 commits into from Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion contracts/STRGetter.sol
Expand Up @@ -171,12 +171,14 @@ contract STRGetter is EternalStorage {
uint256 expiryDate = getUintValue(Encoder.getKey("registeredTickers_expiryDate", ticker));
/*solium-disable-next-line security/no-block-members*/
if ((tickerStatus == true) || (expiryDate > now)) {
address stAddress = getAddressValue(Encoder.getKey("tickerToSecurityToken", ticker));
string memory tokenName = stAddress == address(0) ? "" : ISecurityToken(stAddress).name();
return
(
getTickerOwner(ticker),
getUintValue(Encoder.getKey("registeredTickers_registrationDate", ticker)),
expiryDate,
getStringValue(Encoder.getKey("registeredTickers_tokenName", ticker)),
tokenName,
tickerStatus
);
} else {
Expand Down
94 changes: 67 additions & 27 deletions contracts/SecurityTokenRegistry.sol
Expand Up @@ -53,7 +53,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
address owner;
uint256 registrationDate;
uint256 expiryDate;
string tokenName;
string tokenName; //Not stored since 3.0.0
bool status;
}

Expand Down Expand Up @@ -126,8 +126,16 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
uint256 _registrationFee
);
// Emit after ticker registration
// _registrationFee is in poly
// fee in usd is not being emitted to maintain backwards compatibility
event RegisterTicker(
address indexed _owner,
string _ticker,
uint256 indexed _registrationDate,
uint256 indexed _expiryDate,
bool _fromAdmin,
uint256 _registrationFeePoly,
uint256 _registrationFeeUsd
);
// For backwards compatibility
event RegisterTicker(
address indexed _owner,
string _ticker,
Expand Down Expand Up @@ -307,13 +315,12 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
* @notice its ownership. If the ticker expires and its issuer hasn't used it, then someone else can take it.
* @param _owner is address of the owner of the token
* @param _ticker is unique token ticker
* @param _tokenName is the name of the token
*/
function registerTicker(address _owner, string memory _ticker, string memory _tokenName) public whenNotPausedOrOwner {
function registerNewTicker(address _owner, string memory _ticker) public whenNotPausedOrOwner {
require(_owner != address(0), "Bad address");
require(bytes(_ticker).length > 0 && bytes(_ticker).length <= 10, "Bad ticker");
// Attempt to charge the reg fee if it is > 0 USD
(, uint256 _polyFee) = _takeFee(TICKERREGFEE);
(uint256 usdFee, uint256 polyFee) = _takeFee(TICKERREGFEE);
string memory ticker = Util.upper(_ticker);
require(_tickerAvailable(ticker), "Ticker reserved");
// Check whether ticker was previously registered (and expired)
Expand All @@ -322,7 +329,16 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
_deleteTickerOwnership(previousOwner, ticker);
}
/*solium-disable-next-line security/no-block-members*/
_addTicker(_owner, ticker, _tokenName, now, now.add(getUintValue(EXPIRYLIMIT)), false, false, _polyFee);
_addTicker(_owner, ticker, now, now.add(getUintValue(EXPIRYLIMIT)), false, false, polyFee, usdFee);
}

/**
* @dev This function is just for backwards compatibility
*/
function registerTicker(address _owner, string calldata _ticker, string calldata _tokenName) external {
registerNewTicker(_owner, _ticker);
(, uint256 polyFee) = getFees(TICKERREGFEE);
emit RegisterTicker(_owner, _ticker, _tokenName, now, now.add(getUintValue(EXPIRYLIMIT)), false, polyFee);
}

/**
Expand All @@ -331,34 +347,32 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
function _addTicker(
address _owner,
string memory _ticker,
string memory _tokenName,
uint256 _registrationDate,
uint256 _expiryDate,
bool _status,
bool _fromAdmin,
uint256 _polyFee
uint256 _polyFee,
uint256 _usdFee
)
internal
{
_setTickerOwnership(_owner, _ticker);
_storeTickerDetails(_ticker, _owner, _registrationDate, _expiryDate, _tokenName, _status);
emit RegisterTicker(_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _fromAdmin, _polyFee);
_storeTickerDetails(_ticker, _owner, _registrationDate, _expiryDate, _status);
emit RegisterTicker(_owner, _ticker, _registrationDate, _expiryDate, _fromAdmin, _polyFee, _usdFee);
}

/**
* @notice Modifies the ticker details. Only Polymath has the ability to do so.
* @notice Only allowed to modify the tickers which are not yet deployed.
* @param _owner is the owner of the token
* @param _ticker is the token ticker
* @param _tokenName is the name of the token
* @param _registrationDate is the date at which ticker is registered
* @param _expiryDate is the expiry date for the ticker
* @param _status is the token deployment status
*/
function modifyTicker(
function modifyExistingTicker(
address _owner,
string memory _ticker,
string memory _tokenName,
uint256 _registrationDate,
uint256 _expiryDate,
bool _status
Expand All @@ -371,7 +385,24 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
require(_registrationDate <= _expiryDate, "Bad dates");
require(_owner != address(0), "Bad address");
string memory ticker = Util.upper(_ticker);
_modifyTicker(_owner, ticker, _tokenName, _registrationDate, _expiryDate, _status);
_modifyTicker(_owner, ticker, _registrationDate, _expiryDate, _status);
}

/**
* @dev This function is just for backwards compatibility
*/
function modifyTicker(
address _owner,
string calldata _ticker,
string calldata _tokenName,
uint256 _registrationDate,
uint256 _expiryDate,
bool _status
)
external
{
modifyExistingTicker(_owner, _ticker, _registrationDate, _expiryDate, _status);
emit RegisterTicker(_owner, _ticker, _tokenName, now, now.add(getUintValue(EXPIRYLIMIT)), false, 0);
}

/**
Expand All @@ -380,7 +411,6 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
function _modifyTicker(
address _owner,
string memory _ticker,
string memory _tokenName,
uint256 _registrationDate,
uint256 _expiryDate,
bool _status
Expand All @@ -398,7 +428,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
if (_status) {
require(getAddressValue(Encoder.getKey("tickerToSecurityToken", _ticker)) != address(0), "Not registered");
}
_addTicker(_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _status, true, uint256(0));
_addTicker(_owner, _ticker, _registrationDate, _expiryDate, _status, true, uint256(0), uint256(0));
}

function _tickerOwner(string memory _ticker) internal view returns(address) {
Expand All @@ -415,7 +445,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
require(owner != address(0), "Bad ticker");
_deleteTickerOwnership(owner, ticker);
set(Encoder.getKey("tickerToSecurityToken", ticker), address(0));
_storeTickerDetails(ticker, address(0), 0, 0, "", false);
_storeTickerDetails(ticker, address(0), 0, 0, false);
/*solium-disable-next-line security/no-block-members*/
emit TickerRemoved(ticker, msg.sender);
}
Expand Down Expand Up @@ -464,7 +494,6 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
address _owner,
uint256 _registrationDate,
uint256 _expiryDate,
string memory _tokenName,
bool _status
)
internal
Expand All @@ -475,8 +504,6 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
set(key, _registrationDate);
key = Encoder.getKey("registeredTickers_expiryDate", _ticker);
set(key, _expiryDate);
key = Encoder.getKey("registeredTickers_tokenName", _ticker);
set(key, _tokenName);
key = Encoder.getKey("registeredTickers_status", _ticker);
set(key, _status);
}
Expand Down Expand Up @@ -664,15 +691,13 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {

/**
* @notice Adds a new custom Security Token and saves it to the registry. (Token should follow the ISecurityToken interface)
* @param _name is the name of the token
* @param _ticker is the ticker symbol of the security token
* @param _owner is the owner of the token
* @param _securityToken is the address of the securityToken
* @param _tokenDetails is the off-chain details of the token
* @param _deployedAt is the timestamp at which the security token is deployed
*/
function modifySecurityToken(
string memory _name,
function modifyExistingSecurityToken(
string memory _ticker,
address _owner,
address _securityToken,
Expand All @@ -682,7 +707,6 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
public
onlyOwner
{
require(bytes(_name).length > 0 && bytes(_ticker).length > 0, "Bad data");
require(bytes(_ticker).length <= 10, "Bad ticker");
require(_deployedAt != 0 && _owner != address(0), "Bad data");
string memory ticker = Util.upper(_ticker);
Expand All @@ -695,13 +719,29 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
expiryTime = registrationTime.add(getUintValue(EXPIRYLIMIT));
}
set(Encoder.getKey("tickerToSecurityToken", ticker), _securityToken);
_modifyTicker(_owner, ticker, _name, registrationTime, expiryTime, true);
_modifyTicker(_owner, ticker, registrationTime, expiryTime, true);
_storeSecurityTokenData(_securityToken, ticker, _tokenDetails, _deployedAt);
emit NewSecurityTokenCreated(
ticker, _name, _securityToken, _owner, _deployedAt, msg.sender, true, uint256(0), uint256(0), 0
ticker, ISecurityToken(_securityToken).name(), _securityToken, _owner, _deployedAt, msg.sender, true, uint256(0), uint256(0), 0
);
}

/**
* @dev This function is just for backwards compatibility
*/
function modifySecurityToken(
string calldata /* */,
string calldata _ticker,
address _owner,
address _securityToken,
string calldata _tokenDetails,
uint256 _deployedAt
)
external
{
modifyExistingSecurityToken(_ticker, _owner, _securityToken, _tokenDetails, _deployedAt);
}

/**
* @notice Internal - Stores the security token details
*/
Expand Down
6 changes: 4 additions & 2 deletions contracts/interfaces/ISecurityToken.sol
Expand Up @@ -17,6 +17,8 @@ interface ISecurityToken {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);

function name() external view returns(string memory);

/**
* @notice Transfers of securities may fail for a number of reasons. So this function will used to understand the
* cause of failure by getting the byte value. Which will be the ESC that follows the EIP 1066. ESC can be mapped
Expand Down Expand Up @@ -571,7 +573,7 @@ interface ISecurityToken {
* but it doesn't mean we operator is allowed to transfer the LOCKED partition values.
* Logic for this restriction is written in `operatorTransferByPartition()` function.
* @param _operator An address which is being authorised.
*/
*/
function authorizeOperator(address _operator) external;

/**
Expand Down Expand Up @@ -614,7 +616,7 @@ interface ISecurityToken {
uint256 _value,
bytes calldata _data,
bytes calldata _operatorData
)
)
external
returns (bytes32);

Expand Down
4 changes: 2 additions & 2 deletions test/b_capped_sto.js
Expand Up @@ -171,7 +171,7 @@ contract("CappedSTO", async (accounts) => {
describe("Generate the SecurityToken", async () => {
it("Should register the ticker before the generation of the security token", async () => {
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx = await I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner });
let tx = await I_STRProxied.registerNewTicker(token_owner, symbol, { from: token_owner });
assert.equal(tx.logs[0].args._owner, token_owner);
assert.equal(tx.logs[0].args._ticker, symbol);
});
Expand Down Expand Up @@ -624,7 +624,7 @@ contract("CappedSTO", async (accounts) => {
describe("Launch a new SecurityToken", async () => {
it("POLY: Should register the ticker before the generation of the security token", async () => {
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx = await I_STRProxied.registerTicker(token_owner, P_symbol, P_name, { from: token_owner });
let tx = await I_STRProxied.registerNewTicker(token_owner, P_symbol, { from: token_owner });
assert.equal(tx.logs[0].args._owner, token_owner);
assert.equal(tx.logs[0].args._ticker, P_symbol);
});
Expand Down
2 changes: 1 addition & 1 deletion test/c_checkpoints.js
Expand Up @@ -119,7 +119,7 @@ contract("Checkpoints", async function(accounts) {
describe("Generate the SecurityToken", async () => {
it("Should register the ticker before the generation of the security token", async () => {
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx = await I_STRProxied.registerTicker(token_owner, symbol, contact, { from: token_owner });
let tx = await I_STRProxied.registerNewTicker(token_owner, symbol, { from: token_owner });
assert.equal(tx.logs[0].args._owner, token_owner);
assert.equal(tx.logs[0].args._ticker, symbol.toUpperCase());
});
Expand Down
4 changes: 2 additions & 2 deletions test/d_count_transfer_manager.js
Expand Up @@ -135,7 +135,7 @@ contract("CountTransferManager", async (accounts) => {
describe("Generate the SecurityToken", async () => {
it("Should register the ticker before the generation of the security token", async () => {
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx = await I_STRProxied.registerTicker(token_owner, symbol, contact, { from: token_owner });
let tx = await I_STRProxied.registerNewTicker(token_owner, symbol, { from: token_owner });
assert.equal(tx.logs[0].args._owner, token_owner);
assert.equal(tx.logs[0].args._ticker, symbol.toUpperCase());
});
Expand Down Expand Up @@ -361,7 +361,7 @@ contract("CountTransferManager", async (accounts) => {
it("deploy a new token & auto attach modules", async () => {
//register ticker and deploy token
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx = await I_STRProxied.registerTicker(token_owner, symbol2, contact, { from: token_owner });
let tx = await I_STRProxied.registerNewTicker(token_owner, symbol2, { from: token_owner });

await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });

Expand Down
2 changes: 1 addition & 1 deletion test/e_erc20_dividends.js
Expand Up @@ -143,7 +143,7 @@ contract("ERC20DividendCheckpoint", async (accounts) => {
describe("Generate the SecurityToken", async () => {
it("Should register the ticker before the generation of the security token", async () => {
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx = await I_STRProxied.registerTicker(token_owner, symbol, contact, { from: token_owner });
let tx = await I_STRProxied.registerNewTicker(token_owner, symbol, { from: token_owner });
assert.equal(tx.logs[0].args._owner, token_owner);
assert.equal(tx.logs[0].args._ticker, symbol.toUpperCase());
});
Expand Down
2 changes: 1 addition & 1 deletion test/f_ether_dividends.js
Expand Up @@ -136,7 +136,7 @@ contract("EtherDividendCheckpoint", async (accounts) => {
describe("Generate the SecurityToken", async () => {
it("Should register the ticker before the generation of the security token", async () => {
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx = await I_STRProxied.registerTicker(token_owner, symbol, contact, { from: token_owner });
let tx = await I_STRProxied.registerNewTicker(token_owner, symbol, { from: token_owner });
assert.equal(tx.logs[0].args._owner, token_owner);
assert.equal(tx.logs[0].args._ticker, symbol.toUpperCase());
});
Expand Down
4 changes: 2 additions & 2 deletions test/g_general_permission_manager.js
Expand Up @@ -134,7 +134,7 @@ contract("GeneralPermissionManager", async (accounts) => {
describe("Generate the SecurityToken", async () => {
it("Should register the ticker before the generation of the security token", async () => {
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx = await I_STRProxied.registerTicker(token_owner, symbol, contact, { from: token_owner });
let tx = await I_STRProxied.registerNewTicker(token_owner, symbol, { from: token_owner });
assert.equal(tx.logs[0].args._owner, token_owner);
assert.equal(tx.logs[0].args._ticker, symbol.toUpperCase());
});
Expand Down Expand Up @@ -324,7 +324,7 @@ contract("GeneralPermissionManager", async (accounts) => {
it("Should create a new token and add some more delegates, then get them", async() => {
await I_PolyToken.getTokens(web3.utils.toWei("500", "ether"), token_owner);
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx1 = await I_STRProxied.registerTicker(token_owner, "DEL", contact, { from: token_owner });
let tx1 = await I_STRProxied.registerNewTicker(token_owner, "DEL", { from: token_owner });
assert.equal(tx1.logs[0].args._owner, token_owner);
assert.equal(tx1.logs[0].args._ticker, "DEL");

Expand Down
2 changes: 1 addition & 1 deletion test/h_general_transfer_manager.js
Expand Up @@ -165,7 +165,7 @@ contract("GeneralTransferManager", async (accounts) => {
describe("Generate the SecurityToken", async () => {
it("Should register the ticker before the generation of the security token", async () => {
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx = await I_STRProxied.registerTicker(token_owner, symbol, contact, { from: token_owner });
let tx = await I_STRProxied.registerNewTicker(token_owner, symbol, { from: token_owner });
assert.equal(tx.logs[0].args._owner, token_owner);
assert.equal(tx.logs[0].args._ticker, symbol.toUpperCase());
});
Expand Down
2 changes: 1 addition & 1 deletion test/i_Issuance.js
Expand Up @@ -147,7 +147,7 @@ contract("Issuance", async (accounts) => {
it("POLYMATH: Should register the ticker before the generation of the security token", async () => {
await I_PolyToken.getTokens(new BN(10000).mul(new BN(10).pow(new BN(18))), account_polymath);
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: account_polymath });
let tx = await I_STRProxied.registerTicker(account_polymath, symbol, name, { from: account_polymath });
let tx = await I_STRProxied.registerNewTicker(account_polymath, symbol, { from: account_polymath });
assert.equal(tx.logs[0].args._owner, account_polymath);
assert.equal(tx.logs[0].args._ticker, symbol);
});
Expand Down
2 changes: 1 addition & 1 deletion test/j_manual_approval_transfer_manager.js
Expand Up @@ -144,7 +144,7 @@ contract("ManualApprovalTransferManager", accounts => {
describe("Generate the SecurityToken", async () => {
it("Should register the ticker before the generation of the security token", async () => {
await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner });
let tx = await I_STRProxied.registerTicker(token_owner, symbol, contact, { from: token_owner });
let tx = await I_STRProxied.registerNewTicker(token_owner, symbol, { from: token_owner });
assert.equal(tx.logs[0].args._owner, token_owner);
assert.equal(tx.logs[0].args._ticker, symbol.toUpperCase());
});
Expand Down