input-output-hk / cardano-wallet-legacy

Official Wallet Backend & API for Cardano-SL
https://input-output-hk.github.io/cardano-wallet/
MIT License
21 stars 12 forks source link

WalletNotFound error in listEosWallets handler #354

Closed denisshevchenko closed 5 years ago

denisshevchenko commented 5 years ago
Release Operating System Cause
next Windows & OSX & Linux) Code v Configuration v Environment v Human v Unknown

Context

`GET`-request to `/api/v1/wallets/externally-owned` endpoint should return the list of available EOS-wallets. However currently it _always_ returns `WalletNotFound` error. # Steps to Reproduce
  1. Just send GET-request to /api/v1/wallets/externally-owned endpoint with any parameters.

Expected behavior

Endpoint returns a list of available EOS-wallets.

Actual behavior

Endpoint always returns WalletNotFound error.


Resolution Plan

So, look at listEosWallets definition:

:<|> "wallets"
        :> "externally-owned"
        :> Summary "Returns a list of the available wallets."
        ...
        :> Get '[ValidJSON] (APIResponse [EosWallet])

This tells us that if the path is /api/v1/wallets/externally-owned and the HTTP verb GET, the server should route the request to the listEosWallets handler. However, before that, we have another endpoint defined as:

:<|> "wallets" :> CaptureWalletId
               :> Summary "Returns the Wallet identified by the given walletId."
               :> Get '[ValidJSON] (APIResponse Wallet)

Which tells us that, if a request is made to /api/v1/wallets/{walletId} and the HTTP verb is GET, then we should the request through the getWallet handler, capturing whatever {walletId} is provided in the path.

So, externally-owned in the path is interpreted as-if it was the {walletId} from the getWallet endpoint. But this isn't a valid wallet id, hence the WalletNotFound error.

PR

Number Base
#355 develop

QA

KtorZ commented 5 years ago

Note: the doc has been successfully updated on develop :wink:

https://input-output-hk.github.io/cardano-wallet/#tag/Externally-Owned-Wallets

piotr-iohk commented 5 years ago

lgtm :+1: I'll be adding more integration tests for listEosWallets in #331.