diff --git a/contracts/libraries/TokenLib.sol b/contracts/libraries/TokenLib.sol index aecdac0d4..e2eedff05 100644 --- a/contracts/libraries/TokenLib.sol +++ b/contracts/libraries/TokenLib.sol @@ -432,11 +432,9 @@ library TokenLib { bool isValid = false; bool isForceValid = false; // Use the local variables to avoid the stack too deep error - transfersFrozen = false; // bool unarchived = false; bytes32 appCode; for (uint256 i = 0; i < modules.length; i++) { if (!modulesToData[modules[i]].isArchived) { - transfersFrozen = true; (ITransferManager.Result valid, bytes32 reason) = ITransferManager(modules[i]).verifyTransfer(from, to, value, data); if (valid == ITransferManager.Result.INVALID) { isInvalid = true; @@ -448,9 +446,8 @@ library TokenLib { } } } - // If no unarchived modules, return true by default // Use the local variables to avoid the stack too deep error - isValid = transfersFrozen ? (isForceValid ? true : (isInvalid ? false : isValid)) : true; + isValid = isForceValid ? true : (isInvalid ? false : isValid); return (isValid, isValid ? bytes32(StatusCodes.code(StatusCodes.Status.TransferSuccess)): appCode); } return (false, bytes32(StatusCodes.code(StatusCodes.Status.TransfersHalted))); diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index fa915e5e1..f3dd30365 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -671,13 +671,13 @@ contract SecurityToken is ERC20, ReentrancyGuard, SecurityTokenStorage, IERC1594 bool isInvalid; bool isValid; bool isForceValid; - bool unarchived; address module; uint256 tmLength = modules[TRANSFER_KEY].length; for (uint256 i = 0; i < tmLength; i++) { module = modules[TRANSFER_KEY][i]; if (!modulesToData[module].isArchived) { - unarchived = true; + // refer to https://github.com/PolymathNetwork/polymath-core/wiki/Transfer-manager-results + // for understanding what these results mean ITransferManager.Result valid = ITransferManager(module).executeTransfer(_from, _to, _value, _data); if (valid == ITransferManager.Result.INVALID) { isInvalid = true; @@ -688,8 +688,7 @@ contract SecurityToken is ERC20, ReentrancyGuard, SecurityTokenStorage, IERC1594 } } } - // If no unarchived modules, return true by default - return unarchived ? (isForceValid ? true : (isInvalid ? false : isValid)) : true; + return isForceValid ? true : (isInvalid ? false : isValid); } return false; } diff --git a/test/o_security_token.js b/test/o_security_token.js index 71afe9be5..85a70ad02 100644 --- a/test/o_security_token.js +++ b/test/o_security_token.js @@ -519,16 +519,6 @@ contract("SecurityToken", async (accounts) => { let tx = await I_SecurityToken.removeModule(I_GeneralTransferManager.address, { from: token_owner }); assert.equal(tx.logs[0].args._types[0], transferManagerKey); assert.equal(tx.logs[0].args._module, I_GeneralTransferManager.address); - await I_SecurityToken.issue(account_investor1, new BN(web3.utils.toWei("500")), "0x0", { from: token_owner }); - let _canTransfer = await I_SecurityToken.canTransfer.call(account_investor2, new BN(web3.utils.toWei("200")), "0x0", {from: account_investor1}); - - assert.isTrue(_canTransfer[0]); - assert.equal(_canTransfer[1], 0x51); - assert.equal(_canTransfer[2], empty_hash); - - await I_SecurityToken.transfer(account_investor2, new BN(web3.utils.toWei("200")), { from: account_investor1 }); - - assert.equal((await I_SecurityToken.balanceOf(account_investor2)).div(new BN(10).pow(new BN(18))).toNumber(), 200); await revertToSnapshot(key); }); @@ -581,12 +571,8 @@ contract("SecurityToken", async (accounts) => { assert.equal(moduleData[3], true); }); - it("Should successfully issue tokens while GTM archived", async () => { - let key = await takeSnapshot(); - await I_SecurityToken.issue(one_address, new BN(100).mul(new BN(10).pow(new BN(18))), "0x0", { from: token_owner, gas: 500000 }); - let balance = await I_SecurityToken.balanceOf(one_address); - assert.equal(balance.div(new BN(10).pow(new BN(18))).toNumber(), 100); - await revertToSnapshot(key); + it("Should fail to issue (or transfer) tokens while all TM are archived archived", async () => { + await catchRevert(I_SecurityToken.issue(one_address, new BN(100).mul(new BN(10).pow(new BN(18))), "0x0", { from: token_owner })); }); it("Should successfully unarchive the general transfer manager module from the securityToken", async () => {