Skip to content
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

Remove param address _facilitator from GatewayRedeemInterface.redeem and EIP20CoGateway.redeem #517

Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
50d7894
Removed facilitator address
gulshanvasnani Dec 4, 2018
3ea2f6d
Merge branch 'develop' into gulshan/gh_475_remove_facilitator_redeem
0xsarvesh Dec 5, 2018
f2326fd
Merge branch 'Remove_gateway_linking' into gulshan/gh_475_remove_faci…
gulshanvasnani Dec 5, 2018
3225318
Merged PR's
gulshanvasnani Dec 5, 2018
7331ba9
Test cases for redeem method
gulshanvasnani Dec 5, 2018
470bdea
Merge remote-tracking branch 'remotes/upstream/develop' into gulshan/…
gulshanvasnani Dec 6, 2018
c06ac66
Travis build fix and moved redeem.js to eip20_cogateway
gulshanvasnani Dec 6, 2018
b92b94b
Changed dependency for bignumber to bn.js
gulshanvasnani Dec 6, 2018
9c9e9ea
Verification of event
gulshanvasnani Dec 6, 2018
a6d7011
Merge branch 'develop' into gulshan/gh_475_remove_facilitator_redeem
Dec 6, 2018
c6f9588
PR feedback changes
gulshanvasnani Dec 7, 2018
9b7b4dc
Merge branch 'gulshan/gh_475_remove_facilitator_redeem' of https://gi…
gulshanvasnani Dec 7, 2018
2742e06
Merge branch 'Remove_gateway_linking' into gulshan/gh_475_remove_faci…
gulshanvasnani Dec 7, 2018
830dec0
Merge remote-tracking branch 'remotes/upstream/develop' into gulshan/…
gulshanvasnani Dec 10, 2018
27a2c94
PR feedback changes
gulshanvasnani Dec 11, 2018
0802e1e
Merge branch 'develop' into gulshan/gh_475_remove_facilitator_redeem
0xsarvesh Dec 11, 2018
c70cff2
Merge branch 'develop' into gulshan/gh_475_remove_facilitator_redeem
0xsarvesh Dec 11, 2018
90c06db
Merge remote-tracking branch 'remotes/upstream/develop' into gulshan/…
gulshanvasnani Dec 11, 2018
470df85
Merge branch 'gulshan/gh_475_remove_facilitator_redeem' of https://gi…
gulshanvasnani Dec 11, 2018
c1d467c
Updated and added new test cases
gulshanvasnani Dec 12, 2018
90261c0
Fixed indentation
gulshanvasnani Dec 12, 2018
7e8f4b3
Removed hard coding of approval amount and fixed test-case
gulshanvasnani Dec 12, 2018
6394012
Indentation changes for expectRevert method
gulshanvasnani Dec 12, 2018
2da6509
Corrected the error message and updated the test case messages
gulshanvasnani Dec 12, 2018
d44013f
Added test case when redeemer sends less base token value than requir…
gulshanvasnani Dec 12, 2018
68ae9ff
Added TestEIP20CoGateway
gulshanvasnani Dec 12, 2018
57c961d
Merge branch 'develop' into gulshan/gh_475_remove_facilitator_redeem
Dec 12, 2018
12d605e
Modified test case as per the PR feedback
gulshanvasnani Dec 13, 2018
0c56943
Merge branch 'gulshan/gh_475_remove_facilitator_redeem' of https://gi…
gulshanvasnani Dec 13, 2018
44c2c6c
Added unit test case to verify that the message status at outbox is u…
gulshanvasnani Dec 13, 2018
0625c5a
Merge remote-tracking branch 'upstream/develop' into gulshan/gh_475_r…
gulshanvasnani Dec 13, 2018
d1eb483
Added burner address for eip20cogateway constructor
gulshanvasnani Dec 13, 2018
9fe9391
Merge remote-tracking branch 'upstream/develop' into gulshan/gh_475_r…
gulshanvasnani Dec 13, 2018
cc94151
Styling changes
gulshanvasnani Dec 13, 2018
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
43 changes: 17 additions & 26 deletions contracts/gateway/EIP20CoGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ contract EIP20CoGateway is GatewayBase {
*/
address beneficiary;

/** Address of the facilitator that initiates the stake process. */
address facilitator; //todo need to discuss revocation process
/** bounty amount kept by facilitator for transferring redeem messages*/
uint256 bounty;
}
Expand Down Expand Up @@ -865,49 +863,43 @@ contract EIP20CoGateway is GatewayBase {
* @dev In order to redeem the redeemer needs to approve CoGateway contract
* for redeem amount. Redeem amount is transferred from redeemer
* address to CoGateway contract.
* This is a payable function. The bounty is transferred in base token
* Redeemer is always msg.sender
* This is a payable function. The bounty is transferred in base token.
* Redeemer is always msg.sender.
*
* @param _amount Redeem amount that will be transferred from redeemer
* account.
* @param _beneficiary The address in the origin chain where the value
* tok ens will be released.
* @param _facilitator Facilitator address.
* @param _gasPrice Gas price that redeemer is ready to pay to get the
* redeem process done.
* @param _gasLimit Gas limit that redeemer is ready to pay
* @param _gasLimit Gas limit that redeemer is ready to pay.
* @param _nonce Nonce of the redeemer address.
* @param _hashLock Hash Lock provided by the facilitator.
*
* @return messageHash_ which is unique for each request.
* @return messageHash_ Unique for each request.
*/
function redeem(
gulshanvasnani marked this conversation as resolved.
Show resolved Hide resolved
uint256 _amount,
address _beneficiary,
address _facilitator,
uint256 _gasPrice,
uint256 _gasLimit,
uint256 _nonce,
bytes32 _hashLock
)
public
external
payable
returns (bytes32 messageHash_)
{
require(
msg.value == bounty,
"msg.value must match the bounty amount"
"Payable amount should be equal to the bounty amount."
);
require(
_amount > uint256(0),
"Redeem amount must not be zero"
"Redeem amount must not be zero."
);

require(
_facilitator != address(0),
"Facilitator address must not be zero"
);
// Get the redeem intent hash
// Get the redeem intent hash.
bytes32 intentHash = GatewayLib.hashRedeemIntent(
_amount,
_beneficiary,
Expand All @@ -918,7 +910,7 @@ contract EIP20CoGateway is GatewayBase {
valueToken
);

// Get the messageHash
// Get the messageHash.
messageHash_ = MessageBus.messageDigest(
REDEEM_TYPEHASH,
intentHash,
Expand All @@ -927,24 +919,23 @@ contract EIP20CoGateway is GatewayBase {
_gasLimit
);

// Get previousMessageHash
// Get previousMessageHash.
bytes32 previousMessageHash = registerOutboxProcess(
msg.sender,
_nonce,
messageHash_
);

// Delete the previous progressed/revoked redeem data
// Delete the previous progressed/revoked redeem data.
delete redeems[previousMessageHash];

redeems[messageHash_] = Redeem({
amount : _amount,
beneficiary : _beneficiary,
facilitator : _facilitator,
bounty : bounty
});
});

// create message object
// Create message object.
messages[messageHash_] = getMessage(
msg.sender,
_nonce,
Expand All @@ -957,19 +948,19 @@ contract EIP20CoGateway is GatewayBase {
require(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't test this condition.
Please recommend how to test it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that moving this condition to line 920 makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved it at 920 line number.

messageBox.outbox[messageHash_] ==
MessageBus.MessageStatus.Undeclared,
"Message status must be Undeclared"
"Message status must be Undeclared."
);
// Update the message outbox status to declared.
messageBox.outbox[messageHash_] = MessageBus.MessageStatus.Declared;

//transfer redeem amount to Co-Gateway
// Transfer redeem amount to Co-Gateway.
EIP20Interface(utilityToken).transferFrom(
msg.sender,
address(this),
_amount
);

// Emit RedeemIntentDeclared event
// Emit RedeemIntentDeclared event.
emit RedeemIntentDeclared(
messageHash_,
msg.sender,
Expand Down Expand Up @@ -1162,7 +1153,7 @@ contract EIP20CoGateway is GatewayBase {
redeemer_ = message.sender;
redeemAmount_ = redeems[_messageHash].amount;
// Burn the redeem amount.
UtilityTokenInterface(utilityToken).burn(address(this), redeemAmount_);
UtilityTokenInterface(utilityToken).burn(redeemAmount_);

// Transfer the bounty amount to the facilitator
msg.sender.transfer(redeems[_messageHash].bounty);
Expand Down
2 changes: 0 additions & 2 deletions contracts/gateway/GatewayRedeemInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ contract GatewayRedeemInterface {
* account.
* @param _beneficiary The address in the origin chain where the value
* tok ens will be released.
* @param _facilitator Facilitator address.
* @param _gasPrice Gas price that redeemer is ready to pay to get the
* redeem process done.
* @param _gasLimit Gas limit that redeemer is ready to pay
Expand All @@ -69,7 +68,6 @@ contract GatewayRedeemInterface {
function redeem(
uint256 _amount,
gulshanvasnani marked this conversation as resolved.
Show resolved Hide resolved
address _beneficiary,
address _facilitator,
uint256 _gasPrice,
uint256 _gasLimit,
uint256 _nonce,
Expand Down
2 changes: 0 additions & 2 deletions contracts/gateway/UtilityTokenInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ contract UtilityTokenInterface {
* @dev only burns the amount from CoGateway address, So to burn
* transfer the amount to CoGateway.
*
* @param _burner Burner address.
* @param _amount Amount of tokens to burn.
*
* @return bool `true` if burn is successful, false otherwise.
*/
function burn(
address _burner,
uint256 _amount
)
external
Expand Down
2 changes: 1 addition & 1 deletion migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = function (deployer) {
deployer.deploy(MockGatewayLib);
deployer.deploy(MetaBlock);
deployer.link(GatewayLib, [GatewayBase, EIP20Gateway, TestEIP20Gateway, EIP20CoGateway]);
deployer.link(MessageBus, [EIP20CoGateway,TestEIP20Gateway, EIP20Gateway]);
deployer.link(MessageBus, [EIP20CoGateway, TestEIP20Gateway, EIP20Gateway] );
deployer.link(MockGatewayLib, [MockGatewayBase, TestEIP20Gateway]);
deployer.link(MetaBlock, [BlockStore, AuxiliaryBlockStore]);

Expand Down
Loading