Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contracts/DecentralizedAutonomousTrust.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "./Whitelist.sol";
import "hardlydifficult-ethereum-contracts/contracts/math/BigDiv.sol";
import "hardlydifficult-ethereum-contracts/contracts/math/Sqrt.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Detailed.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";
Expand All @@ -23,6 +24,7 @@ contract DecentralizedAutonomousTrust
is ERC20, ERC20Detailed
{
using SafeMath for uint;
using SafeERC20 for IERC20;

/**
* Events
Expand Down Expand Up @@ -324,8 +326,7 @@ contract DecentralizedAutonomousTrust
// currency is ERC20
require(_msgValue == 0, "DO_NOT_SEND_ETH");

bool success = currency.transferFrom(_from, address(this), _quantityToInvest);
require(success, "ERC20_TRANSFER_FAILED");
currency.safeTransferFrom(_from, address(this), _quantityToInvest);
}
}

Expand All @@ -345,8 +346,7 @@ contract DecentralizedAutonomousTrust
}
else
{
bool success = currency.transfer(_to, _amount);
require(success, "ERC20_TRANSFER_FAILED");
currency.safeTransfer(_to, _amount);
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions test/dat/collectInvestment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Tests the ability to buy dat tokens
*/

const { approveAll, deployDat } = require("../helpers");
const { tokens } = require("hardlydifficult-ethereum-contracts");
const { constants, shouldFail } = require("../helpers");

contract("dat / collectInvestment", accounts => {
it("shouldFail with DO_NOT_SEND_ETH", async () => {
const token = await tokens.dai.deploy(web3, accounts[0]);
const contracts = await deployDat(accounts, { currency: token.address });
await approveAll(contracts, accounts);
await token.mint(accounts[1], constants.MAX_UINT, {
from: accounts[0]
});
await token.approve(contracts.dat.address, constants.MAX_UINT, {
from: accounts[1]
});
await shouldFail(
contracts.dat.buy(accounts[1], "100000000000000000000", 1, {
from: accounts[1],
value: 1
}),
"DO_NOT_SEND_ETH"
);
});
});