Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

[CBR-533] add a new endpoint to calculate the walletid for a given mnemonic #4237

Merged
merged 4 commits into from
Sep 17, 2019

Conversation

cleverca22
Copy link
Contributor

Description

Linked issue

Type of change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🛠 New feature (non-breaking change which adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • 🔨 New or improved tests for existing code
  • ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • CHANGELOG entry has been added and is linked to the correct PR on GitHub.

Testing checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.

QA Steps

Screenshots (if available)

How to merge

Send the message bors r+ to merge this PR. For more information, see
docs/how-to/bors.md.

@tatyanavych
Copy link
Contributor

@cleverca22 Please, add CHANGELOG.md entry under Unreleased in Features section (the section does not exist - needs to be created). Could you also add Fixes section below for the existed entry?
So to have:

Unreleased

Features

  • A new endpoint... (CBR-533 #<PR#>)

Fixes

  • Correct change category...

@tatyanavych tatyanavych requested a review from KtorZ September 13, 2019 14:21
@@ -3,13 +3,15 @@
-- Daedalus client, and aren't useful for wallets, exchanges, and other users.
module Cardano.Wallet.API.Internal where

import Prelude
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation to match import lines below? Also isn't this import already implicit?

Copy link
Contributor

@KtorZ KtorZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, a few remarks though:

  • When read_balance is set, we do a full UTxO scan, can take quite some time, but I suppose it's fine in the context of this endpoint.

  • Using Coin for the balance is somewhat incorrect, especially when summing them as foldl' unsafeAddCoin. This is basically a bomb at runtime, yet unlikely to explode.

  • There's no tests. Even for internal features, it'd be nice to provide evidences of QA.

  • CHANGELOG needs to be updated

@cleverca22
Copy link
Contributor Author

@KtorZ without some chain state to fire up the wallet, i don't know how to test this endpoint fully in an automated manner

all other review comments should be good

@cleverca22 cleverca22 requested a review from KtorZ September 16, 2019 21:38
@KtorZ
Copy link
Contributor

KtorZ commented Sep 17, 2019

@cleverca22 For the testing, have a look at some integration test scenarios (e.g. https://github.com/input-output-hk/cardano-sl/blob/develop/wallet/test/integration/Test/Integration/Scenario/Wallets.hs#L579-L601)

You should be able to do something like:

    scenario "Can query wallet id and balance using only its mnemonic" $
            fixture <- setup $ defaultSetup
                & initialCoins .~ [14]

            successfulRequest $ Client.deleteWallet
                $- (fixture ^. wallet . walletId)

            response <- request $ Client.calculateMnemonic 
                $- (fixture ^. backupPhrase)
                $- (Just True) 

            verify response
                [ expectFieldEqual walletId (fixture ^. wallet . walletId)
                , expectFieldEqual maybeBalance (Just 14)
                ]

+/- the compilation errors and testing with various scenarios (with the query parameter, without, testing on a wallet with no funds etc ..)

@disassembler
Copy link
Contributor

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 17, 2019

👎 Rejected by too few approved reviews

@disassembler
Copy link
Contributor

bors r+

iohk-bors bot added a commit that referenced this pull request Sep 17, 2019
4237: [CBR-533] add a new endpoint to calculate the walletid for a given mnemonic r=disassembler a=cleverca22



## Description

<!--- A brief description of this PR and the problem is trying to solve -->

## Linked issue

<!--- Put here the relevant issue from YouTrack -->



Co-authored-by: Michael Bishop <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 17, 2019

@iohk-bors iohk-bors bot merged commit 8199813 into develop Sep 17, 2019
@iohk-bors iohk-bors bot deleted the add-calculate-mnemonic branch September 17, 2019 16:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants