Skip to content
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

Refactor WalletPersistence to use Platform Agnostic Storage Provider #337

Merged
merged 10 commits into from
Jul 25, 2021

Conversation

fuxingloh
Copy link
Contributor

@fuxingloh fuxingloh commented Jul 24, 2021

What kind of PR is this?:

/kind refactor

What this PR does / why we need it:

Refactor WalletPersistence with simplified API, with just get/set.

  • WalletData Array is now set with its own index bypassing the 2kb restriction
  • Wallet count is stored to track the number of wallet data.

Started using global __mocks__/* as some component need to be mocked globally. This is mocked automatically.

Moved all storage implementation into api/storage/*

Extended upon @ivan-zynesis IStorage implemented and moved it into api/storage/provider with provider.native.ts for native using SecuredStorage and provider.ts for web using AsyncStorage.

Which issue(s) does this PR fixes?:

Fixes #318
Fixes #319

@codeclimate
Copy link

codeclimate bot commented Jul 24, 2021

Code Climate has analyzed commit d0b120e and detected 0 issues on this pull request.

View more on Code Climate.

@defichain-bot
Copy link
Contributor

Missing Translations Report

The following translations are missing for this pull request.

View Full Report
{
    "zh-Hans": {
        "missingCount": 96,
        "labels": {
            "screens/OceanInterface": [
                "Transaction Sent",
                "title",
                "An error has occurred",
                "OK"
            ],
            "components/BarCodeScanner": [
                "Requesting for camera permission",
                "You have denied the permission request to use your camera"
            ],
            "screens/WalletOnboarding": [
                "No wallets"
            ],
            "screens/WalletNavigator": [
                "Wallets",
                "Create Mnemonic Phrase",
                "Verify Mnemonic Phrase",
                "Restore Mnemonic Wallet"
            ],
            "screens/LoadingScreen": [
                "Loading"
            ],
            "screens/ErrorBoundary": [
                "Something went wrong",
                "The app ran into a problem and could not recover. Please restart your application."
            ],
            "screens/TransactionDetailScreen": [
                "tx.desc)",
                "tx.amount)",
                "`${tx.block}`)",
                "tx.txid"
            ],
            "screens/TransactionsScreen": [
                "desc",
                "block",
                "LOAD MORE",
                "Transactions"
            ],
            "screens/TransactionsDetailScreen": [
                "Transaction"
            ],
            "screens/CommunityScreen": [
                "Connect with the community:",
                "DeFiChain is a community-driven and open project.",
                "The DeFiChain Foundation does not provide direct support.",
                "title",
                "Community"
            ],
            "wallet/settings": [
                "key",
                "EXIT WALLET"
            ],
            "screens/SettingsNavigator": [
                "Settings"
            ],
            "screens/PoolSwapScreen": [
                "From",
                "To",
                "SWAP",
                "Enter an amount",
                "Balance: ",
                "MAX",
                "Price",
                "Estimated to receive",
                "Minimum to receive",
                "Liquidity provider fee",
                "Swapping Token"
            ],
            "app/DexScreen": [
                "section.key"
            ],
            "screens/DexScreen": [
                "SWAP",
                "Decentralized Exchange",
                "Add Liquidity",
                "Remove Liquidity"
            ],
            "screens/RemoveLiquidity": [
                "Amount of liquidity to remove",
                "Removing Liquidity"
            ],
            "screens/AddLiquidity": [
                "Price",
                "`Token ${props.type === 'primary' ? 'A' : 'B'}`",
                "Balance",
                "MAX",
                "per",
                "Share of pool",
                "Pooled "
            ],
            "components/slider": [
                "None"
            ],
            "components": [
                "All"
            ],
            "components/Button": [
                "CONTINUE"
            ],
            "screens/ConfirmAddLiq": [
                "Adding",
                "Fee",
                "Price",
                "Liquidity tokens received",
                "Share of pool",
                "Pooled"
            ],
            "screens/ConfirmLiquidity": [
                "CONFIRM",
                "Adding Liquidity"
            ],
            "screens/SendScreen": [
                "CONTINUE",
                "Sending",
                "Transaction fee",
                "SEND",
                "TO ADDRESS",
                "Enter an address",
                "Enter an amount",
                "Balance: ",
                "MAX",
                "Wallet Send"
            ],
            "screens/TokenDetailScreen": [
                "AMOUNT BALANCE",
                "AVAILABLE OPTIONS",
                "Send to other wallet",
                "Receive",
                "Convert"
            ],
            "screens/ReceiveScreen": [
                "Use this address to receive DFI or any DST",
                "Copy",
                "Wallet Receive"
            ],
            "screens/ConvertScreen": [
                "PREVIEW CONVERSION",
                "\"Tokens vs UTXO",
                "Converting DFI",
                "Convert DFIs",
                "Scan recipient QR"
            ],
            "screens/Convert": [
                "titlePrefix",
                "Balance"
            ],
            "components/max": [
                "MAX"
            ],
            "screens/BalancesScreen": [
                "BALANCE DETAILS",
                "props.title",
                "Wallet Balances"
            ]
        },
        "totalCount": 96
    },
    "zh-Hant": {
        "missingCount": 95,
        "labels": {
            "screens/OceanInterface": [
                "Transaction Sent",
                "title",
                "An error has occurred",
                "OK"
            ],
            "components/BarCodeScanner": [
                "Requesting for camera permission",
                "You have denied the permission request to use your camera"
            ],
            "screens/WalletOnboarding": [
                "No wallets"
            ],
            "screens/WalletNavigator": [
                "Wallets",
                "Create Mnemonic Phrase",
                "Verify Mnemonic Phrase",
                "Restore Mnemonic Wallet"
            ],
            "screens/LoadingScreen": [
                "Loading"
            ],
            "screens/ErrorBoundary": [
                "Something went wrong",
                "The app ran into a problem and could not recover. Please restart your application."
            ],
            "screens/TransactionDetailScreen": [
                "tx.desc)",
                "tx.amount)",
                "`${tx.block}`)",
                "tx.txid"
            ],
            "screens/TransactionsScreen": [
                "desc",
                "block",
                "LOAD MORE"
            ],
            "screens/TransactionsDetailScreen": [
                "Transaction"
            ],
            "screens/CommunityScreen": [
                "Connect with the community:",
                "DeFiChain is a community-driven and open project.",
                "The DeFiChain Foundation does not provide direct support.",
                "title",
                "Community"
            ],
            "wallet/settings": [
                "key",
                "EXIT WALLET"
            ],
            "screens/SettingsNavigator": [
                "Settings"
            ],
            "screens/PoolSwapScreen": [
                "From",
                "To",
                "SWAP",
                "Enter an amount",
                "Balance: ",
                "MAX",
                "Price",
                "Estimated to receive",
                "Minimum to receive",
                "Liquidity provider fee",
                "Swapping Token"
            ],
            "app/DexScreen": [
                "section.key"
            ],
            "screens/DexScreen": [
                "SWAP",
                "Decentralized Exchange",
                "Add Liquidity",
                "Remove Liquidity"
            ],
            "screens/RemoveLiquidity": [
                "Amount of liquidity to remove",
                "Removing Liquidity"
            ],
            "screens/AddLiquidity": [
                "Price",
                "`Token ${props.type === 'primary' ? 'A' : 'B'}`",
                "Balance",
                "MAX",
                "per",
                "Share of pool",
                "Pooled "
            ],
            "components/slider": [
                "None"
            ],
            "components": [
                "All"
            ],
            "components/Button": [
                "CONTINUE"
            ],
            "screens/ConfirmAddLiq": [
                "Adding",
                "Fee",
                "Price",
                "Liquidity tokens received",
                "Share of pool",
                "Pooled"
            ],
            "screens/ConfirmLiquidity": [
                "CONFIRM",
                "Adding Liquidity"
            ],
            "screens/SendScreen": [
                "CONTINUE",
                "Sending",
                "Transaction fee",
                "SEND",
                "TO ADDRESS",
                "Enter an address",
                "Enter an amount",
                "Balance: ",
                "MAX",
                "Wallet Send"
            ],
            "screens/TokenDetailScreen": [
                "AMOUNT BALANCE",
                "AVAILABLE OPTIONS",
                "Send to other wallet",
                "Receive",
                "Convert"
            ],
            "screens/ReceiveScreen": [
                "Use this address to receive DFI or any DST",
                "Copy",
                "Wallet Receive"
            ],
            "screens/ConvertScreen": [
                "PREVIEW CONVERSION",
                "\"Tokens vs UTXO",
                "Converting DFI",
                "Convert DFIs",
                "Scan recipient QR"
            ],
            "screens/Convert": [
                "titlePrefix",
                "Balance"
            ],
            "components/max": [
                "MAX"
            ],
            "screens/BalancesScreen": [
                "BALANCE DETAILS",
                "props.title",
                "Wallet Balances"
            ]
        },
        "totalCount": 96
    },
    "de": {
        "missingCount": 95,
        "labels": {
            "screens/OceanInterface": [
                "Transaction Sent",
                "title",
                "An error has occurred",
                "OK"
            ],
            "components/BarCodeScanner": [
                "Requesting for camera permission",
                "You have denied the permission request to use your camera"
            ],
            "screens/WalletOnboarding": [
                "No wallets"
            ],
            "screens/WalletNavigator": [
                "Wallets",
                "Create Mnemonic Phrase",
                "Verify Mnemonic Phrase",
                "Restore Mnemonic Wallet"
            ],
            "screens/LoadingScreen": [
                "Loading"
            ],
            "screens/ErrorBoundary": [
                "Something went wrong",
                "The app ran into a problem and could not recover. Please restart your application."
            ],
            "screens/TransactionDetailScreen": [
                "tx.desc)",
                "tx.amount)",
                "`${tx.block}`)",
                "tx.txid"
            ],
            "screens/TransactionsScreen": [
                "desc",
                "block",
                "LOAD MORE"
            ],
            "screens/TransactionsDetailScreen": [
                "Transaction"
            ],
            "screens/CommunityScreen": [
                "Connect with the community:",
                "DeFiChain is a community-driven and open project.",
                "The DeFiChain Foundation does not provide direct support.",
                "title",
                "Community"
            ],
            "wallet/settings": [
                "key",
                "EXIT WALLET"
            ],
            "screens/SettingsNavigator": [
                "Settings"
            ],
            "screens/PoolSwapScreen": [
                "From",
                "To",
                "SWAP",
                "Enter an amount",
                "Balance: ",
                "MAX",
                "Price",
                "Estimated to receive",
                "Minimum to receive",
                "Liquidity provider fee",
                "Swapping Token"
            ],
            "app/DexScreen": [
                "section.key"
            ],
            "screens/DexScreen": [
                "SWAP",
                "Decentralized Exchange",
                "Add Liquidity",
                "Remove Liquidity"
            ],
            "screens/RemoveLiquidity": [
                "Amount of liquidity to remove",
                "Removing Liquidity"
            ],
            "screens/AddLiquidity": [
                "Price",
                "`Token ${props.type === 'primary' ? 'A' : 'B'}`",
                "Balance",
                "MAX",
                "per",
                "Share of pool",
                "Pooled "
            ],
            "components/slider": [
                "None"
            ],
            "components": [
                "All"
            ],
            "components/Button": [
                "CONTINUE"
            ],
            "screens/ConfirmAddLiq": [
                "Adding",
                "Fee",
                "Price",
                "Liquidity tokens received",
                "Share of pool",
                "Pooled"
            ],
            "screens/ConfirmLiquidity": [
                "CONFIRM",
                "Adding Liquidity"
            ],
            "screens/SendScreen": [
                "CONTINUE",
                "Sending",
                "Transaction fee",
                "SEND",
                "TO ADDRESS",
                "Enter an address",
                "Enter an amount",
                "Balance: ",
                "MAX",
                "Wallet Send"
            ],
            "screens/TokenDetailScreen": [
                "AMOUNT BALANCE",
                "AVAILABLE OPTIONS",
                "Send to other wallet",
                "Receive",
                "Convert"
            ],
            "screens/ReceiveScreen": [
                "Use this address to receive DFI or any DST",
                "Copy",
                "Wallet Receive"
            ],
            "screens/ConvertScreen": [
                "PREVIEW CONVERSION",
                "\"Tokens vs UTXO",
                "Converting DFI",
                "Convert DFIs",
                "Scan recipient QR"
            ],
            "screens/Convert": [
                "titlePrefix",
                "Balance"
            ],
            "components/max": [
                "MAX"
            ],
            "screens/BalancesScreen": [
                "BALANCE DETAILS",
                "props.title",
                "Wallet Balances"
            ]
        },
        "totalCount": 96
    }
}

@netlify
Copy link

netlify bot commented Jul 24, 2021

✔️ Deploy Preview for defi-wallet ready!

🔨 Explore the source changes: d0b120e

🔍 Inspect the deploy log: https://app.netlify.com/sites/defi-wallet/deploys/60fc2aef87b8430007c8083e

😎 Browse the preview: https://deploy-preview-337--defi-wallet.netlify.app/

@codecov
Copy link

codecov bot commented Jul 24, 2021

Codecov Report

Merging #337 (d0b120e) into main (6038722) will increase coverage by 0.06%.
The diff coverage is 95.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #337      +/-   ##
==========================================
+ Coverage   79.18%   79.24%   +0.06%     
==========================================
  Files          87       90       +3     
  Lines        1321     1330       +9     
  Branches      191      194       +3     
==========================================
+ Hits         1046     1054       +8     
- Misses        274      275       +1     
  Partials        1        1              
Impacted Files Coverage Δ
app/contexts/WalletManagementContext.tsx 100.00% <ø> (ø)
app/contexts/NetworkContext.tsx 65.38% <50.00%> (ø)
app/api/wallet/persistence.ts 94.73% <93.75%> (-5.27%) ⬇️
app/api/storage/index.ts 100.00% <100.00%> (ø)
app/api/storage/provider/index.ts 100.00% <100.00%> (ø)
app/api/storage/provider/provider.native.ts 100.00% <100.00%> (ø)
app/api/storage/provider/provider.ts 100.00% <100.00%> (ø)
app/contexts/PlaygroundContext.tsx 82.50% <100.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6038722...d0b120e. Read the comment docs.

@defichain-bot
Copy link
Contributor

defichain-bot commented Jul 24, 2021

Build preview for DeFi Wallet is ready!

Built with commit e1cf00b

https://expo.io/@defichain/wallet?release-channel=pr-preview-337

@cypress
Copy link

cypress bot commented Jul 24, 2021



Test summary

34 0 3 0


Run details

Project wallet
Status Passed
Commit e1cf00b ℹ️
Started Jul 24, 2021 3:03 PM
Ended Jul 24, 2021 3:10 PM
Duration 07:06 💡
OS Linux Ubuntu - 20.04
Browser Chrome 91

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@fuxingloh fuxingloh marked this pull request as ready for review July 24, 2021 15:12
@thedoublejay thedoublejay merged commit 6acc4de into main Jul 25, 2021
@thedoublejay thedoublejay deleted the fuxingloh/secured-storage branch July 25, 2021 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace AsyncStorage with SecureStore for Wallet
3 participants