Skip to content

Commit dcea2c4

Browse files
satyamakgecmaxsam4
authored andcommitted
Fix setProtocolFactory() (#689)
1 parent 045ccc1 commit dcea2c4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

contracts/SecurityTokenRegistry.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
872872
function _setProtocolFactory(address _STFactoryAddress, uint8 _major, uint8 _minor, uint8 _patch) internal {
873873
require(_STFactoryAddress != address(0), "Bad address");
874874
uint24 _packedVersion = VersionUtils.pack(_major, _minor, _patch);
875+
address stFactoryAddress = getAddressValue(Encoder.getKey("protocolVersionST", uint256(_packedVersion)));
876+
require(stFactoryAddress == address(0), "Already exists");
875877
set(Encoder.getKey("protocolVersionST", uint256(_packedVersion)), _STFactoryAddress);
876878
emit ProtocolFactorySet(_STFactoryAddress, _major, _minor, _patch);
877879
}

test/n_security_token_registry.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,10 @@ contract("SecurityTokenRegistry", async (accounts) => {
683683
assert.equal(_protocol[0], 2);
684684
assert.equal(_protocol[1], 2);
685685
assert.equal(_protocol[2], 0);
686-
await I_STRProxied.setProtocolFactory(I_STFactory.address, new BN(3), new BN(0), new BN(0), { from: account_polymath});
686+
await catchRevert(
687+
I_STRProxied.setProtocolFactory(I_STFactory.address, new BN(3), new BN(0), new BN(0), { from: account_polymath})
688+
);
689+
await I_STRProxied.setProtocolFactory(I_STFactory.address, new BN(3), new BN(0), new BN(1), { from: account_polymath});
687690
await I_STRProxied.setLatestVersion(new BN(3), new BN(0), new BN(0), { from: account_polymath});
688691
_protocol = await I_Getter.getLatestProtocolVersion.call();
689692
assert.equal(_protocol[0], 3);

0 commit comments

Comments
 (0)