Skip to content

Commit edf3869

Browse files
authored
Merge pull request #429 from PolymathNetwork/MATM-Fix
Allow 0x transfers for MATM
2 parents 331eb83 + 115c3cb commit edf3869

File tree

2 files changed

+19
-32
lines changed

2 files changed

+19
-32
lines changed

contracts/modules/TransferManager/ManualApprovalTransferManager.sol

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ contract ManualApprovalTransferManager is ITransferManager {
113113
* @param _expiryTime is the time until which the transfer is allowed
114114
*/
115115
function addManualApproval(address _from, address _to, uint256 _allowance, uint256 _expiryTime) public withPerm(TRANSFER_APPROVAL) {
116-
require(_from != address(0), "Invalid from address");
117116
require(_to != address(0), "Invalid to address");
118117
/*solium-disable-next-line security/no-block-members*/
119118
require(_expiryTime > now, "Invalid expiry time");
@@ -129,7 +128,6 @@ contract ManualApprovalTransferManager is ITransferManager {
129128
* @param _expiryTime is the time until which the transfer is blocked
130129
*/
131130
function addManualBlocking(address _from, address _to, uint256 _expiryTime) public withPerm(TRANSFER_APPROVAL) {
132-
require(_from != address(0), "Invalid from address");
133131
require(_to != address(0), "Invalid to address");
134132
/*solium-disable-next-line security/no-block-members*/
135133
require(_expiryTime > now, "Invalid expiry time");
@@ -144,7 +142,6 @@ contract ManualApprovalTransferManager is ITransferManager {
144142
* @param _to is the address to which transfers are approved
145143
*/
146144
function revokeManualApproval(address _from, address _to) public withPerm(TRANSFER_APPROVAL) {
147-
require(_from != address(0), "Invalid from address");
148145
require(_to != address(0), "Invalid to address");
149146
delete manualApprovals[_from][_to];
150147
emit RevokeManualApproval(_from, _to, msg.sender);
@@ -156,7 +153,6 @@ contract ManualApprovalTransferManager is ITransferManager {
156153
* @param _to is the address to which transfers are approved
157154
*/
158155
function revokeManualBlocking(address _from, address _to) public withPerm(TRANSFER_APPROVAL) {
159-
require(_from != address(0), "Invalid from address");
160156
require(_to != address(0), "Invalid to address");
161157
delete manualBlockings[_from][_to];
162158
emit RevokeManualBlocking(_from, _to, msg.sender);

test/j_manual_approval_transfer_manager.js

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,6 @@ contract("ManualApprovalTransferManager", accounts => {
321321
assert.equal((await I_SecurityToken.balanceOf(account_investor1)).toNumber(), web3.utils.toWei("5", "ether"));
322322
});
323323

324-
it("Should fail to add a manual approval because invalid _from address", async () => {
325-
await catchRevert(
326-
I_ManualApprovalTransferManager.addManualApproval(
327-
"",
328-
account_investor4,
329-
web3.utils.toWei("2", "ether"),
330-
latestTime() + duration.days(1),
331-
{ from: token_owner }
332-
)
333-
);
334-
});
335-
336324
it("Should fail to add a manual approval because invalid _to address", async () => {
337325
await catchRevert(
338326
I_ManualApprovalTransferManager.addManualApproval(
@@ -367,6 +355,16 @@ contract("ManualApprovalTransferManager", accounts => {
367355
);
368356
});
369357

358+
it("Add a manual approval for a 5th investor from issuance", async () => {
359+
await I_ManualApprovalTransferManager.addManualApproval(
360+
"",
361+
account_investor5,
362+
web3.utils.toWei("2", "ether"),
363+
latestTime() + duration.days(1),
364+
{ from: token_owner }
365+
);
366+
});
367+
370368
it("Should fail to add a manual approval because allowance is laready exists", async () => {
371369
await catchRevert(
372370
I_ManualApprovalTransferManager.addManualApproval(
@@ -379,10 +377,6 @@ contract("ManualApprovalTransferManager", accounts => {
379377
);
380378
});
381379

382-
it("Should fail to revoke manual approval because invalid _from address", async () => {
383-
await catchRevert(I_ManualApprovalTransferManager.revokeManualApproval("", account_investor4, { from: token_owner }));
384-
});
385-
386380
it("Should fail to revoke manual approval because invalid _to address", async () => {
387381
await catchRevert(I_ManualApprovalTransferManager.revokeManualApproval(account_investor1, "", { from: token_owner }));
388382
});
@@ -409,6 +403,15 @@ contract("ManualApprovalTransferManager", accounts => {
409403
assert.equal((await I_SecurityToken.balanceOf(account_investor4)).toNumber(), web3.utils.toWei("1", "ether"));
410404
});
411405

406+
it("Approval fails with wrong from to address", async () => {
407+
await catchRevert(I_SecurityToken.transfer(account_investor5, web3.utils.toWei("1", "ether"), { from: account_investor1 }));
408+
});
409+
410+
it("Use 100% of issuance approval", async () => {
411+
await I_SecurityToken.mint(account_investor5, web3.utils.toWei("2", "ether"), { from: token_owner });
412+
assert.equal((await I_SecurityToken.balanceOf(account_investor5)).toNumber(), web3.utils.toWei("2", "ether"));
413+
});
414+
412415
it("Check verifyTransfer without actually transferring", async () => {
413416
let verified = await I_SecurityToken.verifyTransfer.call(
414417
account_investor1,
@@ -439,14 +442,6 @@ contract("ManualApprovalTransferManager", accounts => {
439442
await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("1", "ether"), { from: account_investor1 });
440443
});
441444

442-
it("Should fail to add a manual block because invalid _from address", async () => {
443-
await catchRevert(
444-
I_ManualApprovalTransferManager.addManualBlocking("", account_investor2, latestTime() + duration.days(1), {
445-
from: token_owner
446-
})
447-
);
448-
});
449-
450445
it("Should fail to add a manual block because invalid _to address", async () => {
451446
await catchRevert(
452447
I_ManualApprovalTransferManager.addManualBlocking(account_investor1, "", latestTime() + duration.days(1), {
@@ -477,10 +472,6 @@ contract("ManualApprovalTransferManager", accounts => {
477472
await catchRevert(I_SecurityToken.transfer(account_investor2, web3.utils.toWei("1", "ether"), { from: account_investor1 }));
478473
});
479474

480-
it("Should fail to revoke manual block because invalid _from address", async () => {
481-
await catchRevert(I_ManualApprovalTransferManager.revokeManualBlocking("0x0", account_investor2, { from: token_owner }));
482-
});
483-
484475
it("Should fail to revoke manual block because invalid _to address", async () => {
485476
await catchRevert(I_ManualApprovalTransferManager.revokeManualBlocking(account_investor1, "0x0", { from: token_owner }));
486477
});

0 commit comments

Comments
 (0)