Skip to content

Commit 0e8c7cd

Browse files
maxsam4adamdossa
authored andcommitted
updated transfer manager results (#693)
1 parent 99cf720 commit 0e8c7cd

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

contracts/libraries/TokenLib.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,9 @@ library TokenLib {
432432
bool isValid = false;
433433
bool isForceValid = false;
434434
// Use the local variables to avoid the stack too deep error
435-
transfersFrozen = false; // bool unarchived = false;
436435
bytes32 appCode;
437436
for (uint256 i = 0; i < modules.length; i++) {
438437
if (!modulesToData[modules[i]].isArchived) {
439-
transfersFrozen = true;
440438
(ITransferManager.Result valid, bytes32 reason) = ITransferManager(modules[i]).verifyTransfer(from, to, value, data);
441439
if (valid == ITransferManager.Result.INVALID) {
442440
isInvalid = true;
@@ -448,9 +446,8 @@ library TokenLib {
448446
}
449447
}
450448
}
451-
// If no unarchived modules, return true by default
452449
// Use the local variables to avoid the stack too deep error
453-
isValid = transfersFrozen ? (isForceValid ? true : (isInvalid ? false : isValid)) : true;
450+
isValid = isForceValid ? true : (isInvalid ? false : isValid);
454451
return (isValid, isValid ? bytes32(StatusCodes.code(StatusCodes.Status.TransferSuccess)): appCode);
455452
}
456453
return (false, bytes32(StatusCodes.code(StatusCodes.Status.TransfersHalted)));

contracts/tokens/SecurityToken.sol

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,13 +668,13 @@ contract SecurityToken is ERC20, ReentrancyGuard, SecurityTokenStorage, IERC1594
668668
bool isInvalid;
669669
bool isValid;
670670
bool isForceValid;
671-
bool unarchived;
672671
address module;
673672
uint256 tmLength = modules[TRANSFER_KEY].length;
674673
for (uint256 i = 0; i < tmLength; i++) {
675674
module = modules[TRANSFER_KEY][i];
676675
if (!modulesToData[module].isArchived) {
677-
unarchived = true;
676+
// refer to https://github.com/PolymathNetwork/polymath-core/wiki/Transfer-manager-results
677+
// for understanding what these results mean
678678
ITransferManager.Result valid = ITransferManager(module).executeTransfer(_from, _to, _value, _data);
679679
if (valid == ITransferManager.Result.INVALID) {
680680
isInvalid = true;
@@ -685,8 +685,7 @@ contract SecurityToken is ERC20, ReentrancyGuard, SecurityTokenStorage, IERC1594
685685
}
686686
}
687687
}
688-
// If no unarchived modules, return true by default
689-
return unarchived ? (isForceValid ? true : (isInvalid ? false : isValid)) : true;
688+
return isForceValid ? true : (isInvalid ? false : isValid);
690689
}
691690
return false;
692691
}

test/o_security_token.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -525,16 +525,6 @@ contract("SecurityToken", async (accounts) => {
525525
let tx = await I_SecurityToken.removeModule(I_GeneralTransferManager.address, { from: token_owner });
526526
assert.equal(tx.logs[0].args._types[0], transferManagerKey);
527527
assert.equal(tx.logs[0].args._module, I_GeneralTransferManager.address);
528-
await I_SecurityToken.issue(account_investor1, new BN(web3.utils.toWei("500")), "0x0", { from: token_owner });
529-
let _canTransfer = await I_SecurityToken.canTransfer.call(account_investor2, new BN(web3.utils.toWei("200")), "0x0", {from: account_investor1});
530-
531-
assert.isTrue(_canTransfer[0]);
532-
assert.equal(_canTransfer[1], 0x51);
533-
assert.equal(_canTransfer[2], empty_hash);
534-
535-
await I_SecurityToken.transfer(account_investor2, new BN(web3.utils.toWei("200")), { from: account_investor1 });
536-
537-
assert.equal((await I_SecurityToken.balanceOf(account_investor2)).div(new BN(10).pow(new BN(18))).toNumber(), 200);
538528
await revertToSnapshot(key);
539529
});
540530

@@ -587,12 +577,8 @@ contract("SecurityToken", async (accounts) => {
587577
assert.equal(moduleData[3], true);
588578
});
589579

590-
it("Should successfully issue tokens while GTM archived", async () => {
591-
let key = await takeSnapshot();
592-
await I_SecurityToken.issue(one_address, new BN(100).mul(new BN(10).pow(new BN(18))), "0x0", { from: token_owner, gas: 500000 });
593-
let balance = await I_SecurityToken.balanceOf(one_address);
594-
assert.equal(balance.div(new BN(10).pow(new BN(18))).toNumber(), 100);
595-
await revertToSnapshot(key);
580+
it("Should fail to issue (or transfer) tokens while all TM are archived archived", async () => {
581+
await catchRevert(I_SecurityToken.issue(one_address, new BN(100).mul(new BN(10).pow(new BN(18))), "0x0", { from: token_owner }));
596582
});
597583

598584
it("Should successfully unarchive the general transfer manager module from the securityToken", async () => {

0 commit comments

Comments
 (0)