-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added any erc20 support to payments #37
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ contract Escapable { | |
function escapeHatch() onlyEscapeHatchCaller { | ||
uint total = getBalance(); | ||
// Send the total balance of this contract to the `escapeHatchDestination` | ||
transfer(escapeHatchDestination, total); | ||
transfer(baseToken, escapeHatchDestination, total); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has it's own function, see |
||
EscapeHatchCalled(total); | ||
} | ||
/// @notice Changes the address assigned to call `escapeHatch()` | ||
|
@@ -67,13 +67,14 @@ contract Escapable { | |
return this.balance; | ||
} | ||
} | ||
/// @notice Sends an `_amount` of `baseToken` to `_to` from this contract, | ||
/// @notice Sends an `_amount` of `_token` to `_to` from this contract, | ||
/// and it can only be called by the contract itself | ||
/// @param _token to deposit, 0x0 to send ether. | ||
/// @param _to The address of the recipient | ||
/// @param _amount The amount of `baseToken to be sent | ||
function transfer(address _to, uint _amount) internal { | ||
if (address(baseToken) != 0) { | ||
if (!baseToken.transfer(_to, _amount)) throw; | ||
function transfer(address _token, address _to, uint _amount) internal { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will have to ask jordi but i think the better design is to have a second function for this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has it's own function, see claimTokens which may need to be renamed... Honestly i dont think this contract needs changes |
||
if (_token != 0) { | ||
if (!Token(_token).transfer(_to, _amount)) throw; | ||
} else { | ||
if (! _to.send(_amount)) throw; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ contract Vault is Escapable, Owned { | |
struct Payment { | ||
string name; // What is the purpose of this payment | ||
bytes32 reference; // Reference of the payment. | ||
address token; // if 0 payment of ether, else the token being sent | ||
address spender; // Who is sending the funds | ||
uint earliestPayTime; // The earliest a payment can be made (Unix Time) | ||
bool canceled; // If True then the payment has been canceled | ||
|
@@ -196,6 +197,7 @@ contract Vault is Escapable, Owned { | |
/// @param _name Brief description of the payment that is authorized | ||
/// @param _reference Reference hash of the payment shared with the contract | ||
/// requesting the payment. | ||
/// @param _token The token being sent | ||
/// @param _recipient Destination of the payment | ||
/// @param _amount Amount to be paid in wei | ||
/// @param _paymentDelay Number of seconds the payment is to be delayed, if | ||
|
@@ -204,6 +206,7 @@ contract Vault is Escapable, Owned { | |
function authorizePayment( | ||
string _name, | ||
bytes32 _reference, | ||
address _token, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is a better strategy to create a second function for non-baseToken transfers... but we need to hear from jordi... it might be a few days |
||
address _recipient, | ||
uint _amount, | ||
uint _paymentDelay | ||
|
@@ -233,13 +236,14 @@ contract Vault is Escapable, Owned { | |
p.amount = _amount; | ||
p.name = _name; | ||
p.reference = _reference; | ||
p.token = (_token == 0) ? baseToken : _token; | ||
|
||
totalAuthorizedToBeSpent += p.amount; | ||
PaymentAuthorized(idPayment, p.recipient, p.amount); | ||
|
||
if ((now >= p.earliestPayTime) && (getBalance() >= p.amount)) { | ||
p.paid = true; // Set the payment to being paid | ||
transfer(p.recipient, p.amount); // Make the payment | ||
transfer(p.token, p.recipient, p.amount); // Make the payment | ||
|
||
totalAuthorizedToBeSpent -= p.amount; | ||
totalSpent += p.amount; // Accounting | ||
|
@@ -271,7 +275,7 @@ contract Vault is Escapable, Owned { | |
if (getBalance() < p.amount) throw; | ||
|
||
p.paid = true; // Set the payment to being paid | ||
transfer(p.recipient, p.amount);// Make the payment | ||
transfer(p.token, p.recipient, p.amount);// Make the payment | ||
|
||
totalAuthorizedToBeSpent -= p.amount; | ||
totalSpent += p.amount; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has it's own function and should not be added to the constructor