Skip to content

Commit 14e828a

Browse files
committed
add the protocolVersion in the event
1 parent 0d564ed commit 14e828a

File tree

3 files changed

+67
-22
lines changed

3 files changed

+67
-22
lines changed

contracts/SecurityTokenRegistry.sol

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
104104
address _registrant,
105105
bool _fromAdmin,
106106
uint256 _usdFee,
107-
uint256 _polyFee
107+
uint256 _polyFee,
108+
uint256 _protocolVersion
108109
);
109110
// Emit after ticker registration
110111
event RegisterTicker(
@@ -517,7 +518,16 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
517518
_deployToken(_name, ticker, _tokenDetails, msg.sender, _divisible, protocolVersion);
518519
}
519520

520-
function _deployToken(string memory _name, string memory _ticker, string memory _tokenDetails, address _issuer, bool _divisible, uint256 _protocolVersion) internal {
521+
function _deployToken(
522+
string memory _name,
523+
string memory _ticker,
524+
string memory _tokenDetails,
525+
address _issuer,
526+
bool _divisible,
527+
uint256 _protocolVersion
528+
)
529+
internal
530+
{
521531
(uint256 _usdFee, uint256 _polyFee) = _takeFee(STLAUNCHFEE);
522532
address newSecurityTokenAddress = ISTFactory(getAddressValue(Encoder.getKey("protocolVersionST", _protocolVersion))).deployToken(
523533
_name,
@@ -533,7 +543,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
533543
_storeSecurityTokenData(newSecurityTokenAddress, _ticker, _tokenDetails, now);
534544
set(Encoder.getKey("tickerToSecurityToken", _ticker), newSecurityTokenAddress);
535545
/*solium-disable-next-line security/no-block-members*/
536-
emit NewSecurityToken(_ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, _usdFee, _polyFee);
546+
_emitSecurityTokenEvent(_ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, _usdFee, _polyFee, _protocolVersion);
537547
}
538548

539549
/**
@@ -544,18 +554,20 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
544554
* @param _securityToken is the address of the securityToken
545555
* @param _tokenDetails is the off-chain details of the token
546556
* @param _deployedAt is the timestamp at which the security token is deployed
557+
* @param _protocolVersion Version of securityToken contract
547558
*/
548559
function modifySecurityToken(
549560
string calldata _name,
550561
string calldata _ticker,
551562
address _owner,
552563
address _securityToken,
553564
string calldata _tokenDetails,
554-
uint256 _deployedAt
565+
uint256 _deployedAt,
566+
uint256 _protocolVersion
555567
)
556568
external
557569
onlyOwner
558-
{
570+
{
559571
require(bytes(_name).length > 0 && bytes(_ticker).length > 0, "Bad data");
560572
require(bytes(_ticker).length <= 10, "Bad ticker");
561573
require(_deployedAt != 0 && _owner != address(0), "Bad data");
@@ -571,7 +583,29 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
571583
set(Encoder.getKey("tickerToSecurityToken", ticker), _securityToken);
572584
_modifyTicker(_owner, ticker, _name, registrationTime, expiryTime, true);
573585
_storeSecurityTokenData(_securityToken, ticker, _tokenDetails, _deployedAt);
574-
emit NewSecurityToken(ticker, _name, _securityToken, _owner, _deployedAt, msg.sender, true, uint256(0), uint256(0));
586+
_emitSecurityTokenEvent(
587+
ticker, _name, _securityToken, _owner, _deployedAt, msg.sender, true, uint256(0), uint256(0),
588+
(_protocolVersion == uint256(0) ? getUintValue(Encoder.getKey("latestVersion")) : _protocolVersion)
589+
);
590+
}
591+
592+
function _emitSecurityTokenEvent(
593+
string memory _ticker,
594+
string memory _name,
595+
address _securityToken,
596+
address _owner,
597+
uint256 _addedAt,
598+
address _registrant,
599+
bool _fromAdmin,
600+
uint256 _usdFee,
601+
uint256 _polyFee,
602+
uint256 _protocolVersion
603+
)
604+
internal
605+
{
606+
emit NewSecurityToken(
607+
_ticker, _name, _securityToken, _owner, _addedAt, _registrant, _fromAdmin, _usdFee, _polyFee, _protocolVersion
608+
);
575609
}
576610

577611
/**

contracts/interfaces/ISecurityTokenRegistry.sol

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ pragma solidity ^0.5.0;
55
*/
66
interface ISecurityTokenRegistry {
77
/**
8-
* @notice Creates a new Security Token and saves it to the registry
9-
* @param _name Name of the token
10-
* @param _ticker Ticker ticker of the security token
11-
* @param _tokenDetails Off-chain details of the token
12-
* @param _divisible Whether the token is divisible or not
13-
*/
14-
function generateSecurityToken(string calldata _name, string calldata _ticker, string calldata _tokenDetails, bool _divisible) external;
8+
* @notice Deploys an instance of a new Security Token and records it to the registry
9+
* @param _name is the name of the token
10+
* @param _ticker is the ticker symbol of the security token
11+
* @param _tokenDetails is the off-chain details of the token
12+
* @param _divisible is whether or not the token is divisible
13+
* @param _protocolVersion Version of securityToken contract
14+
* - `_protocolVersion` is the packed value of uin8[3] array (it will be calculated offchain)
15+
* - if _protocolVersion == 0 then latest version of securityToken will be generated
16+
*/
17+
function generateSecurityToken(
18+
string calldata _name,
19+
string calldata _ticker,
20+
string calldata _tokenDetails,
21+
bool _divisible,
22+
uint256 _protocolVersion
23+
) external;
1524

1625
/**
1726
* @notice Adds a new custom Security Token and saves it to the registry. (Token should follow the ISecurityToken interface)
@@ -21,14 +30,16 @@ interface ISecurityTokenRegistry {
2130
* @param _securityToken Address of the securityToken
2231
* @param _tokenDetails Off-chain details of the token
2332
* @param _deployedAt Timestamp at which security token comes deployed on the ethereum blockchain
33+
* @param _protocolVersion Version of the protocol
2434
*/
2535
function modifySecurityToken(
2636
string calldata _name,
2737
string calldata _ticker,
2838
address _owner,
2939
address _securityToken,
3040
string calldata _tokenDetails,
31-
uint256 _deployedAt
41+
uint256 _deployedAt,
42+
uint256 _protocolVersion
3243
)
3344
external;
3445

test/n_security_token_registry.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ contract("SecurityTokenRegistry", async (accounts) => {
755755
describe("Generate custom tokens", async () => {
756756
it("Should fail if msg.sender is not polymath", async () => {
757757
await catchRevert(
758-
I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, {
758+
I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, {
759759
from: account_delegate
760760
}),
761761
"tx revert -> msg.sender is not polymath account"
@@ -764,7 +764,7 @@ contract("SecurityTokenRegistry", async (accounts) => {
764764

765765
it("Should fail to genrate the custom security token -- ticker length is greater than 10 chars", async () => {
766766
await catchRevert(
767-
I_STRProxied.modifySecurityToken("LOGAN", "LOGLOGLOGLOG", account_temp, dummy_token, "I am custom ST", currentTime, {
767+
I_STRProxied.modifySecurityToken("LOGAN", "LOGLOGLOGLOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, {
768768
from: account_polymath
769769
}),
770770
"tx revert -> ticker length is greater than 10 chars"
@@ -773,7 +773,7 @@ contract("SecurityTokenRegistry", async (accounts) => {
773773

774774
it("Should fail to generate the custom security token -- name should not be 0 length ", async () => {
775775
await catchRevert(
776-
I_STRProxied.modifySecurityToken("", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, {
776+
I_STRProxied.modifySecurityToken("", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, {
777777
from: account_polymath
778778
}),
779779
"tx revert -> name should not be 0 length"
@@ -782,7 +782,7 @@ contract("SecurityTokenRegistry", async (accounts) => {
782782

783783
it("Should fail if ST address is 0 address", async () => {
784784
await catchRevert(
785-
I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, address_zero, "I am custom ST", currentTime, {
785+
I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, address_zero, "I am custom ST", currentTime, 0, {
786786
from: account_polymath
787787
}),
788788
"tx revert -> Security token address is 0"
@@ -791,7 +791,7 @@ contract("SecurityTokenRegistry", async (accounts) => {
791791

792792
it("Should fail if symbol length is 0", async () => {
793793
await catchRevert(
794-
I_STRProxied.modifySecurityToken("", "0x0", account_temp, dummy_token, "I am custom ST", currentTime, {
794+
I_STRProxied.modifySecurityToken("", "0x0", account_temp, dummy_token, "I am custom ST", currentTime, 0, {
795795
from: account_polymath
796796
}),
797797
"tx revert -> zero length of the symbol is not allowed"
@@ -800,7 +800,7 @@ contract("SecurityTokenRegistry", async (accounts) => {
800800

801801
it("Should fail to generate the custom ST -- deployedAt param is 0", async () => {
802802
await catchRevert(
803-
I_STRProxied.modifySecurityToken(name2, symbol2, token_owner, dummy_token, "I am custom ST", new BN(0), { from: account_polymath }),
803+
I_STRProxied.modifySecurityToken(name2, symbol2, token_owner, dummy_token, "I am custom ST", new BN(0), 0, { from: account_polymath }),
804804
"tx revert -> because deployedAt param is 0"
805805
);
806806
});
@@ -815,7 +815,7 @@ contract("SecurityTokenRegistry", async (accounts) => {
815815
tickersListArray = await I_Getter.getTickersByOwner.call(account_temp);
816816
console.log(tickersListArray);
817817
// Generating the ST
818-
let tx = await I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, {
818+
let tx = await I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, {
819819
from: account_polymath
820820
});
821821
tickersListArray = await I_Getter.getTickersByOwner.call(account_temp);
@@ -837,7 +837,7 @@ contract("SecurityTokenRegistry", async (accounts) => {
837837
// await catchRevert(I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", await latestTime(), {from: account_polymath}));
838838
// await I_STRProxied.modifyTicker(account_temp, "LOG2", "LOGAN2", await latestTime(), currentTime.add(new BN(duration.days(10))), false, {from: account_polymath});
839839
// await increaseTime(duration.days(1));
840-
let tx = await I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", currentTime, {
840+
let tx = await I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", currentTime, 0, {
841841
from: account_polymath
842842
});
843843
assert.equal(tx.logs[1].args._ticker, "LOG2", "Symbol should match with the registered symbol");

0 commit comments

Comments
 (0)