fix compile

This commit is contained in:
Ricardo Guilherme Schmidt 2017-06-28 20:43:54 -03:00
parent 75ab1271d9
commit d01ebfbca6
2 changed files with 19 additions and 24 deletions

View File

@ -35,7 +35,7 @@ contract IssueBank is Controlled, TokenBank {
* @notice deposit ether in bank
**/
function () payable {
deposit();
depositEther(new bytes(0));
}
/**
@ -137,7 +137,7 @@ contract IssueBank is Controlled, TokenBank {
for (uint i = 0; i< len; i++){
ERC20 token = ERC20(_tokens[i]);
amount = token.balanceOf(this);
if(amount > 0) withdraw(token, repoOwner, amount);
if(amount > 0) _withdraw(token, repoOwner, amount, 0x0);
}
}
/**
@ -152,20 +152,18 @@ contract IssueBank is Controlled, TokenBank {
/**
* @dev overwriten to only allow refund in correct state.
**/
function refund(uint depositNonce) returns (bool) {
function refund(address token) returns (bool) {
if(state != State.REFUND) throw;
refundNonce++;
if(refundNonce == nonce) state = State.FINALIZED;
return super.refund(depositNonce);
return super.refund(token);
}
/**
* @dev register the deposit to refundings
**/
function _deposited(address _tokenAddr, address _sender, uint _amount)
internal returns (uint receipt) {
function _deposited(address _sender, uint _amount, address _tokenAddr, bytes _data)
internal {
if(state != State.OPEN) throw;
return super._deposited(_tokenAddr, _sender, _amount);
super._deposited(_sender, _amount, _tokenAddr, _data);
}
function _reward(address[] _tokens) internal {
@ -181,11 +179,11 @@ contract IssueBank is Controlled, TokenBank {
address tokenAddr = _tokens[i];
reward = tokenBalances[tokenAddr];
if (reward > 0) reward = calculeReward(reward, _reward_points);
if (reward > 0) withdraw(tokenAddr, dest, reward);
if (reward > 0) _withdraw(tokenAddr, dest, reward, 0x0);
}
reward = this.balance;
if (reward > 0) reward = (reward / points) * _reward_points;
if (reward > 0) withdraw(dest, reward);
if (reward > 0) _withdraw(0x0, dest, reward, 0x0);
points -= _reward_points;
if(points == 0) state = State.FINALIZED;
}

View File

@ -1,11 +1,11 @@
import "./Token.sol";
import "../token/ERC23.sol";
pragma solidity ^0.4.11;
/**
* @title TokenBank
* @author Ricardo Guilherme Schmidt <3esmit>
* Abstract contract for deposit and withdraw of ETH and ERC20/23 Tokens
* Abstract contract for deposit and withdraw of ETH and ERC20/23 Tokens, with MiniMe token support.
**/
contract TokenBank is ERC23Receiver, ApproveAndCallFallBack {
@ -16,13 +16,7 @@ contract TokenBank is ERC23Receiver, ApproveAndCallFallBack {
mapping (address => uint) public tokenBalances;
address[] public tokens;
uint private nonce;
struct Deposit {
address sender;
address token;
uint amount;
}
uint public nonce;
/**
* @notice deposit ether in bank
@ -76,9 +70,7 @@ contract TokenBank is ERC23Receiver, ApproveAndCallFallBack {
**/
function refund(address _token) returns (bool) {
address _sender = msg.sender;
uint amount = deposits[_sender][_token];
delete deposits[_sender][_token];
withdraw(_token, _sender, amount);
_withdraw(_token, _sender, deposits[_sender][_token], _sender);
return true;
}
@ -109,6 +101,7 @@ contract TokenBank is ERC23Receiver, ApproveAndCallFallBack {
function _deposited(address _sender, uint _amount, address _tokenAddr, bytes _data)
internal {
Deposited(_tokenAddr, _sender, _amount);
nonce++;
if(_tokenAddr != 0x0){
if(tokenBalances[_tokenAddr] == 0){
tokens.push(_tokenAddr);
@ -124,9 +117,13 @@ contract TokenBank is ERC23Receiver, ApproveAndCallFallBack {
/**
* @dev withdraw token amount to dest
**/
function withdraw(address _tokenAddr, address _dest, uint _amount)
function _withdraw(address _tokenAddr, address _dest, uint _amount, address _consumer)
internal returns (bool){
Withdrawn(_tokenAddr, _dest, _amount);
if(_consumer != 0x0) {
require(deposits[_consumer][_tokenAddr] >= _amount);
deposits[_consumer][_tokenAddr] -= _amount;
}
if(_tokenAddr == 0x0){
_dest.transfer(_amount);
return true;