Giter VIP home page Giter VIP logo

soramitsu-test's Introduction

Polkaswap test task for Soramitsu

This project is based on substrate-node-template and contains a pallet implementing functionality resembling ERC20 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

soramitsu-test's People

Contributors

al3mart avatar amirabrams avatar anderssorby avatar apopiak avatar athei avatar bkchr avatar boozook avatar c410-f3r avatar cab404 avatar chenzongxiong avatar danforbes avatar dcnick3 avatar dcompoze avatar disconnect3d avatar erasmus avatar hamidra avatar jba-khalifa avatar jeluard avatar jimmychu0807 avatar joshorndorff avatar kaichaosun avatar nukemandan avatar riusricardo avatar sacha-l avatar shawntabrizi avatar tripleight avatar vyorkin avatar wheresaddie avatar xlc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.