-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add WrappedToken.sol #1095
Draft
quantumagi
wants to merge
67
commits into
stratisproject:feature/1.5.0.0-interflux
Choose a base branch
from
quantumagi:wrappedcoin
base: feature/1.5.0.0-interflux
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+863
−0
Draft
Add WrappedToken.sol #1095
Changes from 21 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
2d3e00a
Merge remote-tracking branch 'origin/release/1.3.0.0' into release/1.…
fassadlr 96da7d1
Merge remote-tracking branch 'origin/release/1.3.2.1' into release/1.…
fassadlr 729e92c
Merge remote-tracking branch 'origin/release/1.3.2.2' into release/1.…
fassadlr 248646d
Merge remote-tracking branch 'origin/release/1.3.3.0' into release/1.…
fassadlr a12874d
Bump all versions to 1.3.4.0
fassadlr 6f65bf6
Merge remote-tracking branch 'origin/release/1.3.3.0' into release/1.…
fassadlr 9968ba1
Merge remote-tracking branch 'origin/release/1.3.4.0' into release/1.…
fassadlr 309391d
Bump all versions to 1.4.0.0
fassadlr 0c93dd2
Merge branch 'feature/dotnet6' into release/1.4.0.0
fassadlr be5ccd6
Set version to RC
fassadlr 8fcacb6
Always publish mining statistics
fassadlr c14acd9
Add activation height for multisig fee sorting
fassadlr 24ab542
Fix GateWayPairStarts pair
fassadlr 58fc318
Merge pull request #1092 from stratisproject/interflux-ms-fees-ort
fassadlr 341746c
Update release 1.4 activation height
fassadlr 0606287
Bump build version to 1.4.0.1
fassadlr 2958d64
Fix multisig fee sort
fassadlr d62930c
Bump build revision to 1.4.0.2
fassadlr fa722c2
Set release 1.4 activation height
fassadlr 1b6c10a
Add WrappedToken.sol
quantumagi d4a265e
Add WrappedToken.cs
quantumagi 470db60
Changes based on feedback
quantumagi 0032aa6
Rename
quantumagi 333a033
Add burnId
quantumagi 6afb5fe
Add blacklisting
quantumagi 814a3ac
Fix names
quantumagi 2027682
Use external
quantumagi 75a0487
Fix compilation issues
quantumagi 0113b7e
Update ABI
quantumagi 991cd53
Update bytecode
quantumagi 19abd6c
Update WrappedTokenDeployment
quantumagi 721fd34
Fix
quantumagi 344638f
Add helper classes
quantumagi e7d3278
Bump all versions to 1.3.4.0
fassadlr 577aa63
Bump all versions to 1.4.0.0
fassadlr f9dfd51
Set version to RC
fassadlr 84d7f40
Bump build version to 1.4.0.1
fassadlr 149a154
Bump build revision to 1.4.0.2
fassadlr 309aed9
Add WrappedToken.sol
quantumagi efb0ebb
Add WrappedToken.cs
quantumagi fb747f5
Changes based on feedback
quantumagi b2f731b
Rename
quantumagi 485edaa
Add burnId
quantumagi c7c4232
Add blacklisting
quantumagi 6887246
Fix names
quantumagi 9ee754c
Use external
quantumagi 9c8529e
Fix compilation issues
quantumagi 61fe516
Update ABI
quantumagi 407bed3
Update bytecode
quantumagi 320e1c8
Update WrappedTokenDeployment
quantumagi 1c39f6f
Fix
quantumagi 938cdb0
Add helper classes
quantumagi aa8ed8d
Merge branch 'wrappedcoin' of https://github.com/quantumagi/StratisFu…
quantumagi 2a69ad0
Move contract to correct folder
quantumagi cff1217
Fix rebase
quantumagi 2521d06
Add require and comments
quantumagi 6314e73
Add TODO
quantumagi b86f39d
The user signature is not required in the contract
quantumagi 0f6355a
Implement replay check
quantumagi c649116
Add fee log
quantumagi 7032879
Calculate decimalsFactor
quantumagi 70dd28b
Cast amounts
quantumagi e58bb5e
Refactor decimalsFactor
quantumagi dcc237d
Remove fee and toaddr
quantumagi f97e1ae
Add transferForNetwork method
quantumagi 49b02dc
Fix compile errors and add constants and private methods
quantumagi feb9812
Refactor
quantumagi 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
60 changes: 60 additions & 0 deletions
60
src/Stratis.Bitcoin.Features.Interop/ETHClient/ContractSource/WrappedToken.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,60 @@ | ||
// contracts/WrappedToken.sol | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.6.0; | ||
|
||
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/access/Ownable.sol"; | ||
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract WrappedToken is ERC20, Ownable { | ||
mapping (address => string) public withdrawalAddresses; | ||
|
||
constructor(string tokenName, string tokenSymbol, uint256 initialSupply) public ERC20(tokenName, tokenSymbol) { | ||
_mint(msg.sender, initialSupply); | ||
} | ||
|
||
/** | ||
* @dev Creates `amount` new tokens and assigns them to `account`. | ||
* | ||
* See {ERC20-_mint}. | ||
*/ | ||
function mint(address account, uint256 amount) public onlyOwner { | ||
_mint(account, amount); | ||
} | ||
|
||
/** | ||
* @dev Destroys `amount` tokens from the caller. | ||
* | ||
* See {ERC20-_burn}. | ||
*/ | ||
function burn(uint256 amount, string memory address) public { | ||
_burn(_msgSender(), amount); | ||
|
||
// When the tokens are burnt we need to know where to credit the equivalent value on the Stratis chain. | ||
// Currently it is only possible to assign a single address here, so if multiple recipients are required | ||
// the burner will have to wait until each burn is processed before proceeding with the next. | ||
withdrawalAddresses[msg.sender] = address; | ||
} | ||
|
||
/** | ||
* @dev Destroys `amount` tokens from `account`, deducting from the caller's | ||
* allowance. | ||
* | ||
* See {ERC20-_burn} and {ERC20-allowance}. | ||
* | ||
* Requirements: | ||
* | ||
* - the caller must have allowance for ``accounts``'s tokens of at least | ||
* `amount`. | ||
*/ | ||
function burnFrom(address account, uint256 amount, string memory address) public { | ||
uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); | ||
|
||
_approve(account, _msgSender(), decreasedAllowance); | ||
_burn(account, amount); | ||
|
||
// When the tokens are burnt we need to know where to credit the equivalent value on the Stratis chain. | ||
// Currently it is only possible to assign a single address here, so if multiple recipients are required | ||
// the burner will have to wait until each burn is processed before proceeding with the next. | ||
withdrawalAddresses[msg.sender] = address; | ||
} | ||
} |
656 changes: 656 additions & 0 deletions
656
src/Stratis.Bitcoin.Features.Interop/ETHClient/WrappedToken.cs
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 1 addition & 4 deletions
5
src/Stratis.Bitcoin.Features.PoA/Events/MiningStatisticsEvent.cs
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
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
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.
maybe add additional method with onlyOwner modifier that removes value withdrawalAddresses[address].
And in burn method if address is set- revert.
That will prevent users sending requests with multiple recepients in a row before prev requests are processed and subsequently loosing money
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.
@noescape00 , I've made the following change:
Trying to clean-up the dictionary may not be worth the additional costs for each multisig node.