-
Notifications
You must be signed in to change notification settings - Fork 31
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
Beneficiary Support For Redeem and UnstaKe #101
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b76adc9
adding .travis.yml file
53c324e
Develop Rebase Changes
7a1fc83
Beneficiary Support for redeem and unstake
5b13eb0
Integration Test: Beneficiary Support for redeem and unstake
6495e52
Rebased branch abhay/benefeciary with 'remotes/origin/develop' branch
929ce3e
Resolved conflict with travis.yml file
cea5fe5
Pull Request Changes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ pragma solidity ^0.4.17; | |
import "./SafeMath.sol"; | ||
import "./Hasher.sol"; | ||
import "./OpsManaged.sol"; | ||
// import "./CoreInterface.sol"; | ||
|
||
// utility chain contracts | ||
import "./STPrime.sol"; | ||
|
@@ -58,6 +57,7 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
struct Redemption { | ||
bytes32 uuid; | ||
address redeemer; | ||
address beneficiary; | ||
uint256 amountUT; | ||
uint256 unlockHeight; | ||
} | ||
|
@@ -81,14 +81,14 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
address _beneficiary, uint256 _amountUT); | ||
|
||
event RedemptionIntentDeclared(bytes32 indexed _uuid, bytes32 indexed _redemptionIntentHash, | ||
address _token, address _redeemer, uint256 _nonce, uint256 _amount, uint256 _unlockHeight, | ||
address _token, address _redeemer, address _beneficiary, uint256 _nonce, uint256 _amount, uint256 _unlockHeight, | ||
uint256 _chainIdValue); | ||
|
||
event ProcessedRedemption(bytes32 indexed _uuid, bytes32 indexed _redemptionIntentHash, address _token, | ||
address _redeemer, uint256 _amount); | ||
address _redeemer, address _beneficiary, uint256 _amount); | ||
|
||
event RevertedRedemption(bytes32 indexed _uuid, bytes32 indexed _redemptionIntentHash, | ||
address _redeemer, uint256 _amountUT); | ||
address _redeemer, address _beneficiary, uint256 _amountUT); | ||
|
||
/* | ||
* Constants | ||
|
@@ -114,7 +114,7 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
/// chainId of the current utility chain | ||
uint256 public chainIdUtility; | ||
address public registrar; | ||
/// registered branded tokens | ||
/// registered branded tokens | ||
mapping(bytes32 /* uuid */ => RegisteredToken) internal registeredTokens; | ||
/// name reservation is first come, first serve | ||
mapping(bytes32 /* hashName */ => address /* requester */) public nameReservation; | ||
|
@@ -299,17 +299,20 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
/// as the spender so that the branded token can be taken into escrow by OpenSTUtility | ||
/// note: for STPrime, call OpenSTUtility.redeemSTPrime as a payable function | ||
/// note: nonce must be queried from OpenSTValue contract | ||
/// note: Redemption will be done to beneficiary address | ||
function redeem( | ||
bytes32 _uuid, | ||
uint256 _amountBT, | ||
uint256 _nonce) | ||
uint256 _nonce, | ||
address _beneficiary) | ||
external | ||
returns ( | ||
uint256 unlockHeight, | ||
bytes32 redemptionIntentHash) | ||
{ | ||
require(_uuid != ""); | ||
require(_amountBT > 0); | ||
require(_beneficiary != address(0)); | ||
// on redemption allow the nonce to be re-used to cover for an unsuccessful | ||
// previous redemption previously; as the nonce is strictly increasing plus | ||
// one on the value chain; there is no gain on redeeming with the same nonce, | ||
|
@@ -332,27 +335,31 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
_uuid, | ||
msg.sender, | ||
_nonce, | ||
_beneficiary, | ||
_amountBT, | ||
unlockHeight | ||
); | ||
|
||
redemptions[redemptionIntentHash] = Redemption({ | ||
uuid: _uuid, | ||
redeemer: msg.sender, | ||
beneficiary: _beneficiary, | ||
amountUT: _amountBT, | ||
unlockHeight: unlockHeight | ||
}); | ||
|
||
RedemptionIntentDeclared(_uuid, redemptionIntentHash, address(token), | ||
msg.sender, _nonce, _amountBT, unlockHeight, chainIdValue); | ||
msg.sender, _beneficiary, _nonce, _amountBT, unlockHeight, chainIdValue); | ||
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. then the order here is aligned with the function signature |
||
|
||
return (unlockHeight, redemptionIntentHash); | ||
} | ||
|
||
/// @dev redeemer must send as value the amount STP to redeem | ||
/// note: nonce must be queried from OpenSTValue contract | ||
/// note: redemption will be done to beneficiary address | ||
function redeemSTPrime( | ||
uint256 _nonce) | ||
uint256 _nonce, | ||
address _beneficiary) | ||
external | ||
payable | ||
returns ( | ||
|
@@ -361,6 +368,7 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
bytes32 redemptionIntentHash) | ||
{ | ||
require(msg.value > 0); | ||
require(_beneficiary != address(0)); | ||
// on redemption allow the nonce to be re-used to cover for an unsuccessful | ||
// previous redemption previously; as the nonce is strictly increasing plus | ||
// one on the value chain; there is no gain on redeeming with the same nonce, | ||
|
@@ -375,19 +383,21 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
uuidSTPrime, | ||
msg.sender, | ||
_nonce, | ||
_beneficiary, | ||
amountSTP, | ||
unlockHeight | ||
); | ||
|
||
redemptions[redemptionIntentHash] = Redemption({ | ||
uuid: uuidSTPrime, | ||
redeemer: msg.sender, | ||
beneficiary: _beneficiary, | ||
amountUT: amountSTP, | ||
unlockHeight: unlockHeight | ||
}); | ||
|
||
RedemptionIntentDeclared(uuidSTPrime, redemptionIntentHash, simpleTokenPrime, | ||
msg.sender, _nonce, amountSTP, unlockHeight, chainIdValue); | ||
msg.sender, _beneficiary, _nonce, amountSTP, unlockHeight, chainIdValue); | ||
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. again order would change here |
||
|
||
return (amountSTP, unlockHeight, redemptionIntentHash); | ||
} | ||
|
@@ -424,7 +434,7 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
require(token.burn.value(value)(redemption.redeemer, redemption.amountUT)); | ||
|
||
ProcessedRedemption(redemption.uuid, _redemptionIntentHash, token, | ||
redemption.redeemer, redemption.amountUT); | ||
redemption.redeemer, redemption.beneficiary, redemption.amountUT); | ||
|
||
delete redemptions[_redemptionIntentHash]; | ||
|
||
|
@@ -437,6 +447,7 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
returns ( | ||
bytes32 uuid, | ||
address redeemer, | ||
address beneficiary, | ||
uint256 amountUT) | ||
{ | ||
require(_redemptionIntentHash != ""); | ||
|
@@ -450,6 +461,7 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
uuid = redemption.uuid; | ||
amountUT = redemption.amountUT; | ||
redeemer = redemption.redeemer; | ||
beneficiary = redemption.beneficiary; | ||
|
||
if (redemption.uuid == uuidSTPrime) { | ||
// transfer throws if insufficient funds | ||
|
@@ -463,9 +475,9 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
delete redemptions[_redemptionIntentHash]; | ||
|
||
// fire event | ||
RevertedRedemption(uuid, _redemptionIntentHash, redeemer, amountUT); | ||
RevertedRedemption(uuid, _redemptionIntentHash, redeemer, beneficiary, amountUT); | ||
|
||
return (uuid, redeemer, amountUT); | ||
return (uuid, redeemer, beneficiary, amountUT); | ||
} | ||
|
||
/* | ||
|
@@ -551,7 +563,7 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
// in which case must come from same address | ||
// otherwise proposals are first come, first serve | ||
// under opt-in discretion of registrar | ||
address requester = nameReservation[_hashName]; | ||
address requester = nameReservation[_hashName]; | ||
if ((requester == address(0) || | ||
requester == _requester)) { | ||
return true; | ||
|
@@ -616,8 +628,8 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
require(registeredUuid == _checkUuid); | ||
require(_brandedToken.uuid() == _checkUuid); | ||
|
||
assert(address(registeredTokens[registeredUuid].token) == address(0)); | ||
assert(address(registeredTokens[registeredUuid].token) == address(0)); | ||
|
||
registeredTokens[registeredUuid] = RegisteredToken({ | ||
token: _brandedToken, | ||
registrar: registrar | ||
|
@@ -630,7 +642,7 @@ contract OpenSTUtility is Hasher, OpsManaged { | |
|
||
RegisteredBrandedToken(registrar, _brandedToken, registeredUuid, _symbol, _name, | ||
_conversionRate, _requester); | ||
|
||
return registeredUuid; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
to keep in line with the function signatures for redeem; can we make the order
_nonce
,_beneficiary
?