Refactoring and documentation
Status
Assign
type
effort points
10
Start Date
Jun 14, 2022
End Date
priority
tags
Github PR
As we are moving towards more mature and stable product. Some parts of theme-extenion-app needs significant refactor e.g. : token ABI, global variables, etc. Also, adding some robust documentation to make it more readable and easy to understand.
This will also get rid of some duplicated lines of code and help with enforcing better error handling. In addition to this, it will make unit testing easier.
connectWallet
- Make global variables for provider, signer, and user address to be easily accessible.
processTransaction
- Get rid of accessing wallet variables from provider and use global variable
- Refactor nested verification for network
- Implement generic method to lead email screen and verification.
performTransaction
- Create generic ABI for all three tokens (all ERC-20 tokens)
- Refactor repeated
transfer
call - Refactor nested
if - else
getShopAddr
- Updatethen
withasync await
getCartData
- Updatethen
withasync await
loadEmailScreen
- Implement a generic function and can load the email screen. It is a big chunk of code repeated insideredeem
andprocessTransaction
as state management and email validation was time consuming and had some blockers when NFT redemption was initially shipped.
validateEmail
- Regular expression to validate email is repeated and nested inside email screen logic. It needs to be a generic pure function for a cleaner implementation.
redeem
- Get rid of repeated wallet verification
- Implemented generic function to load and validate email screen.