-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: not possible to cancel SendToEthereum transactions (fixes #389…
…) (#532)
- Loading branch information
1 parent
c90f4f5
commit 2ae1533
Showing
17 changed files
with
1,323 additions
and
95 deletions.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pragma solidity ^0.6.8; | ||
|
||
import "./ModuleCRC20.sol"; | ||
|
||
contract ModuleCRC21 is ModuleCRC20 { | ||
|
||
event __CronosSendToChain(address sender, address recipient, uint256 amount, uint256 bridge_fee, uint256 chain_id); | ||
event __CronosCancelSendToChain(address sender, uint256 id); | ||
|
||
constructor(string memory denom_, uint8 decimals_) ModuleCRC20(denom_, decimals_) public { | ||
decimals = decimals_; | ||
denom = denom_; | ||
} | ||
|
||
// make unsafe_burn internal | ||
function unsafe_burn_internal(address addr, uint amount) internal { | ||
// Deduct user's balance without approval | ||
require(balanceOf[addr] >= amount, "ds-token-insufficient-balance"); | ||
balanceOf[addr] = sub(balanceOf[addr], amount); | ||
totalSupply = sub(totalSupply, amount); | ||
emit Burn(addr, amount); | ||
} | ||
|
||
// send to another chain through gravity bridge | ||
function send_to_chain(address recipient, uint amount, uint bridge_fee, uint chain_id) external { | ||
unsafe_burn_internal(msg.sender, add(amount, bridge_fee)); | ||
emit __CronosSendToChain(msg.sender, recipient, amount, bridge_fee, chain_id); | ||
} | ||
|
||
// cancel a send to chain transaction considering if it hasnt been batched yet. | ||
function cancel_send_to_chain(uint256 id) external { | ||
emit __CronosCancelSendToChain(msg.sender, id); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
integration_tests/contracts/contracts/CronosGravityCancellation.sol
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pragma solidity ^0.6.6; | ||
|
||
contract CronosGravityCancellation { | ||
|
||
event __CronosCancelSendToChain(address sender, uint256 id); | ||
|
||
// Cancel a send to chain transaction considering if it hasnt been batched yet. | ||
function cancelTransaction(uint256 id) public { | ||
emit __CronosCancelSendToChain(msg.sender, id); | ||
} | ||
} |
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
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.