https://github.com/dcnick3/soramitsu-test
Polkaswap test task for Soramitsu
https://github.com/dcnick3/soramitsu-test
Last synced: 11 months ago
JSON representation
Polkaswap test task for Soramitsu
- Host: GitHub
- URL: https://github.com/dcnick3/soramitsu-test
- Owner: DCNick3
- License: unlicense
- Created: 2022-04-15T22:23:38.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-15T22:24:19.000Z (over 4 years ago)
- Last Synced: 2025-01-28T03:29:50.731Z (over 1 year ago)
- Language: Rust
- Size: 46.1 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Polkaswap test task for Soramitsu
This project is based on `substrate-node-template` and contains a pallet implementing functionality resembling [ERC20](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol) smart contract.
The pallet implementation is located in `pallets/erc20`

## Feature mapping
The mapping of ERC20 functions are as follows:
- `name`, `symbol` and `decimals` are available as metadata entries of the pallet
- `totalSupply`, `balanceOf` and `allowance` are available as storage getters
- `transfer`, `approve` and `transferFrom` are implemented as dispatchable functions
- `_mint` and `_burn` are implemented as public, but non-dispatchable functions and can be run only with other pallets
Instead of returning bools like the original functions, I decided to return rust errors, which is the way to go for dispatchable functions.
Otherwise, I believe, the implementation matches closely what happens in `ERC20`
Even though it was allowed, I did not use `pallet-balances`, as its concepts do not seem to match to what `ERC20` expects (with stuff like locked funds). Also, it allowed me to expose nice storage getters.
## Testing
I wrote some amount of unit tests for the pallet (can be found `pallets/erc20/tests.rs`).
Test cases include basic ones (using functions as intended) along with all possible error conditions and (some) corner-cases.
## Documentation
There are doc-strings for all public items exposed from the pallet