-
Notifications
You must be signed in to change notification settings - Fork 20
Add eHMND ERC20 precompile #746
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
Merged
Merged
Changes from 25 commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
20f7188
Add basic implementation for total_supply and balance_of calls
dmitrylavrenov 95481c1
Integrate initial precompile-evm-balances-erc20 implementation into h…
dmitrylavrenov abd9a18
Add metadata erc20 methods
dmitrylavrenov a24707d
Add approvals related logic
dmitrylavrenov 5d3fa58
Add transfer related method
dmitrylavrenov d53e157
Add transferFrom related method
dmitrylavrenov 34325d7
Add event logs
dmitrylavrenov 440d8d0
Add docs to interface actions
dmitrylavrenov 448bd57
Fix some clippy
dmitrylavrenov 7c1e371
Add docs for approves logic
dmitrylavrenov b06c562
Fix typos
dmitrylavrenov 5faec0f
Remove unnecesary docs
dmitrylavrenov 64a9610
Introduce helper functions to simplify code
dmitrylavrenov 70d0b08
Some refactoring
dmitrylavrenov 5f81c84
Update features snapshot
dmitrylavrenov 0d5b4d6
Fix docs
dmitrylavrenov 41be202
Add ERC20 solidity interface
dmitrylavrenov 6785a6e
Rename erc20 metadata at frontier precompiles
dmitrylavrenov c055a1a
Add mocked environment
dmitrylavrenov 68de669
Add metadata related tests
dmitrylavrenov c7c1c34
Add balance_of_works and total_supply_works tests
dmitrylavrenov 115acc3
Add approve_works test
dmitrylavrenov 88b2356
Rename some tests
dmitrylavrenov 8147024
Add transfer_works test
dmitrylavrenov e6a33ea
Add transfer_from_works test
dmitrylavrenov 890f6a7
Rename symbol
dmitrylavrenov 2992d29
Edit name erc20 metadata
dmitrylavrenov 99d30dc
Introduce pallet-erc20 to store approvals data
dmitrylavrenov f0a31c8
Use approvals logic from pallet-erc20 at precompile
dmitrylavrenov 9736378
Use currency config instead of pallet-evm-balances config
dmitrylavrenov 350d670
Add erc20 related logic into pallet-erc20
dmitrylavrenov be70bdd
Add utility aliases
dmitrylavrenov aadf8b2
Integrate pallet-erc20 logic into precompile
dmitrylavrenov 60f43cc
Fix mock at pallet-erc20
dmitrylavrenov c7421e3
Fix mock at precompile
dmitrylavrenov 1fdbb26
Remove redundant dependency
dmitrylavrenov 4b9a3e1
Rename pallet-erc20 to pallet-token-wrapper
dmitrylavrenov 3aa99bd
Rename precompile-evm-balances-erc20 into precompile-token-wrapper
dmitrylavrenov 9e5460e
Integrate introduced changes into humanode-runtime
dmitrylavrenov 922f15f
Use wrapped-token instead for token-wrapper
dmitrylavrenov 14883e3
Merge branch 'master' into precompile-balances-erc20
dmitrylavrenov 9275197
Rename EvmBalancesErc20 into WrappedEvmBalances
dmitrylavrenov c52f822
Add total_supply_works test to pallet-wrapped-token
dmitrylavrenov 9af708f
Improve approvals related test at pallet-wrapped-token
dmitrylavrenov 03d9703
Add transfer_works test
dmitrylavrenov 2a547f0
Add transfer_from_works test
dmitrylavrenov 85a6c63
Add fails tests for transfer from logic
dmitrylavrenov 2c1e87a
Add with_storage_layer usage at pallet-wrapped-token
dmitrylavrenov 2a4ee15
Fix features
dmitrylavrenov 654dc65
Use approvals aliases
dmitrylavrenov 0f21930
Merge branch 'master' into precompile-balances-erc20
dmitrylavrenov cec5068
Rename pallet-wrapped-token into pallet-erc20-support
dmitrylavrenov 87d81ff
Merge branch 'master' into precompile-balances-erc20
dmitrylavrenov 38f68c2
Some renaming and docs improvements
dmitrylavrenov 93be731
Update features snapshot
dmitrylavrenov 0fdc379
Add comments for tests at pallet-erc20-support
dmitrylavrenov 6e9c7db
Improve dispatch error handling
dmitrylavrenov 7a6f1b5
Add more tests at precompile-erc20-support
dmitrylavrenov ad08491
Merge branch 'master' into precompile-balances-erc20
dmitrylavrenov 38966f0
Merge branch 'master' into precompile-balances-erc20
dmitrylavrenov d66cddf
Rename precompile-erc20-support into precompile-native-currency
dmitrylavrenov 78b3097
Rename Erc20EvmBalancesMetadata into EvmBalancesErc20Metadata
dmitrylavrenov 974d188
Rename Erc20EvmBalances into EvmBalancesErc20Support
dmitrylavrenov 66f9c50
Revert "Use approvals aliases"
dmitrylavrenov b293aad
Merge branch 'master' into precompile-balances-erc20
dmitrylavrenov 276d52f
Properly handle transferFrom logic
dmitrylavrenov e600842
Improve dispatch error handling
dmitrylavrenov 1354e9e
Add approve_overwrite_works test
dmitrylavrenov a7944d6
Fix transfer
dmitrylavrenov ebed3b0
Add tests to check approve logic with sending full approved balance
dmitrylavrenov 00e1d79
Add approve_approval_value_more_than_balance_works test
dmitrylavrenov 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,47 @@ | ||
| [package] | ||
| name = "precompile-evm-balances-erc20" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| publish = false | ||
|
|
||
| [dependencies] | ||
| precompile-utils = { path = "../precompile-utils", default-features = false } | ||
| primitives-currency-swap = { path = "../primitives-currency-swap", default-features = false } | ||
|
|
||
| codec = { workspace = true, package = "parity-scale-codec", features = ["derive"] } | ||
| fp-evm = { workspace = true } | ||
| frame-support = { workspace = true } | ||
| num_enum = { workspace = true } | ||
| pallet-evm = { workspace = true } | ||
| pallet-evm-balances = { workspace = true } | ||
| scale-info = { workspace = true, features = ["derive"] } | ||
| sp-core = { workspace = true } | ||
|
|
||
| [dev-dependencies] | ||
| precompile-utils = { path = "../precompile-utils", features = ["testing"] } | ||
|
|
||
| frame-system = { workspace = true } | ||
| hex-literal = { workspace = true } | ||
| pallet-balances = { workspace = true, features = ["default"] } | ||
| pallet-evm = { workspace = true } | ||
| pallet-evm-system = { workspace = true, features = ["default"] } | ||
| pallet-timestamp = { workspace = true, features = ["default"] } | ||
|
|
||
| [features] | ||
| default = ["std"] | ||
| std = [ | ||
| "codec/std", | ||
| "fp-evm/std", | ||
| "frame-support/std", | ||
| "frame-system/std", | ||
| "num_enum/std", | ||
| "pallet-balances/std", | ||
| "pallet-evm-balances/std", | ||
| "pallet-evm-system/std", | ||
| "pallet-evm/std", | ||
| "pallet-timestamp/std", | ||
| "precompile-utils/std", | ||
| "primitives-currency-swap/std", | ||
| "scale-info/std", | ||
| "sp-core/std", | ||
| ] |
This file contains hidden or 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,117 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
|
|
||
| pragma solidity >=0.7.0 <0.9.0; | ||
|
|
||
| /** | ||
| * @title ERC20 Interface | ||
| * | ||
| * An interface exposing native eHMND tokens as ERC20 tokens. | ||
| * | ||
| * Address: 0x0000000000000000000000000000000000000802 | ||
MOZGIII marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
| interface IERC20 { | ||
| /** | ||
| * Returns the name of the token. | ||
| * Selector: 06fdde03 | ||
| */ | ||
| function name() external view returns (string memory); | ||
|
|
||
| /** | ||
| * Returns the symbol of the token. | ||
| * Selector: 95d89b41 | ||
| */ | ||
| function symbol() external view returns (string memory); | ||
|
|
||
| /** | ||
| * Returns the decimals places of the token. | ||
| * Selector: 313ce567 | ||
| */ | ||
| function decimals() external view returns (uint8); | ||
|
|
||
| /** | ||
| * Total number of tokens in existence. | ||
| * Selector: 18160ddd | ||
| */ | ||
| function totalSupply() external view returns (uint256); | ||
|
|
||
| /** | ||
| * Gets the balance of the specified address. | ||
| * Selector: 70a08231 | ||
| * | ||
| * @param owner The address to query the balance of. | ||
| * @return uint256 The amount owned by the passed address. | ||
| */ | ||
| function balanceOf(address owner) external view returns (uint256); | ||
|
|
||
| /** | ||
| * Function to check the amount of tokens that an owner allowed to a spender. | ||
| * Selector: dd62ed3e | ||
| * | ||
| * @param owner The address which owns the funds. | ||
| * @param spender The address which will spend the funds. | ||
| * @return uint256 The amount of tokens still available for the spender. | ||
| */ | ||
| function allowance( | ||
| address owner, | ||
| address spender | ||
| ) external view returns (uint256); | ||
|
|
||
| /** | ||
| * Transfer token for a specified address. | ||
| * Selector: a9059cbb | ||
| * | ||
| * @param to The address to transfer tokens to. | ||
| * @param value The amount to be transferred. | ||
| * @return true if the transfer was succesful, revert otherwise. | ||
| */ | ||
| function transfer(address to, uint256 value) external returns (bool); | ||
|
|
||
| /** | ||
| * Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. | ||
| * Selector: 095ea7b3 | ||
| * | ||
| * @param spender The address which will spend the funds. | ||
| * @param value The amount of tokens to be spent. | ||
| * @return true, this cannot fail. | ||
| */ | ||
| function approve(address spender, uint256 value) external returns (bool); | ||
|
|
||
| /** | ||
| * Transfer tokens from one address to another. | ||
| * Selector: 23b872dd | ||
| * | ||
| * @param from The address which you want to send tokens from. | ||
| * @param to The address which you want to transfer to. | ||
| * @param value The amount of tokens to be transferred. | ||
| * @return true if the transfer was succesful, revert otherwise. | ||
| */ | ||
| function transferFrom( | ||
| address from, | ||
| address to, | ||
| uint256 value | ||
| ) external returns (bool); | ||
|
|
||
| /** | ||
| * Event emited when a transfer has been performed. | ||
| * Selector: ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef | ||
| * | ||
| * @param from The address sending the tokens | ||
| * @param to The address receiving the tokens. | ||
| * @param value The amount of tokens transfered. | ||
| */ | ||
| event Transfer(address indexed from, address indexed to, uint256 value); | ||
|
|
||
| /** | ||
| * Event emited when an approval has been registered. | ||
| * Selector: 8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925 | ||
| * | ||
| * @param owner The owner address of the tokens. | ||
| * @param spender The allowed spender address. | ||
| * @param value The amount of tokens approved. | ||
| */ | ||
| event Approval( | ||
| address indexed owner, | ||
| address indexed spender, | ||
| uint256 value | ||
| ); | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.