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

Add ListAddresses, PutWallet, PutWalletPassphrase to the Servant API definition. #125

Merged
merged 4 commits into from
Mar 27, 2019

Conversation

jonathanknowles
Copy link
Member

@jonathanknowles jonathanknowles commented Mar 27, 2019

Issue Number

Issue #118

Overview

  • Add ListAddresses operation to the Servant API definition.
  • Add PutWallet operation to the Servant API definition.
  • Add PutWalletPassphrase operation to the Servant API definition.

@jonathanknowles jonathanknowles self-assigned this Mar 27, 2019
@jonathanknowles jonathanknowles changed the title Add PutWallet operation to the Servant API definition. Add PutWallet and PutWalletPassphrase to the Servant API definition. Mar 27, 2019
@KtorZ
Copy link
Member

KtorZ commented Mar 27, 2019

Arg! We agreed on the scope during the last meeting:

  • getWallet
  • listWallet
  • postWallet
  • postTransaction
  • listTransaction

I've put the ticket in QA already; let's get these merged, but we can move on to something else now 👍

Nothing -> error $
"unable to find the definition for " <> show name <> " in the spec"
Just schema ->
return $ NamedSchema (Just name) schema
Copy link
Member

Choose a reason for hiding this comment

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

I think I'd even push it further and make it all "automagic" via a Typeable instance 🤔 ?

@jonathanknowles jonathanknowles changed the title Add PutWallet and PutWalletPassphrase to the Servant API definition. Add ListAddresses, PutWallet, PutWalletPassphrase to the Servant API definition. Mar 27, 2019
@@ -24,8 +42,11 @@ type Api = Wallets
type Wallets =
DeleteWallet
:<|> GetWallet
:<|> ListAddresses
Copy link
Member

@KtorZ KtorZ Mar 27, 2019

Choose a reason for hiding this comment

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

The idea was to have groups matching the groups from the API specification 😅
So I'd suggest to have:

type Wallets =
    DeleteWallet
    :<|> GetWallet
    :<|> ListWallets
    :<|> PostWallet
    :<|> PutWallet
    :<|> PutWalletPassphrase

type Addresses =
    listAddresses

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting! I was under the impression that the listAddresses operation was within the wallets group:

  /wallets/{walletId}/addresses:                                                                                                                                                      
    get:                                                                                                                                                                              
      operationId: listAddresses      

Should we update the specification to move it to another group?

Copy link
Member

Choose a reason for hiding this comment

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

Nope, the spec is correct here. Endpoints are grouped by tags, cf:

https://github.com/input-output-hk/cardano-wallet/blob/master/specifications/api/swagger.yaml#L896

https://github.com/input-output-hk/cardano-wallet/blob/master/specifications/api/swagger.yaml#L844

So, even if, conceptually, the Address resource is a sub-resource of the Wallet resource, operations related to addresses are in a separate group to be easier to identify (same apply for transactions).

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay! I've moved ListAddresses to a separate group.

} deriving (Eq, Generic, Show)

data AddressState = Used | Unused
deriving (Eq, Generic, Show)
Copy link
Member

Choose a reason for hiding this comment

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

That, we want in our Primitive.Model the same way we have other metadata about various core types.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

instance FromJSON (ApiT P.Address) where
parseJSON =
parseJSON >=>
maybe
Copy link
Member

Choose a reason for hiding this comment

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

I'd drop the pointfree here and use a do-notation to makes the reading a bit clearer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough :)

"state": "unused",
"id": "Kgihnukc1UStfMcKxBjRew4jnt7Z53JAUiKZkw3XErXy9NTxZNfmVarXhP9rs99PDFFA"
}
]
Copy link
Member

Choose a reason for hiding this comment

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

I really like we have golden tests for all types. It helps controlling the shape of the JSON objects right away 👌

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

{},
{},
{
"name": "ro8n&(V$]%dJ吚 (v]QSu1𩈾DfZ|*w?\\Iy,X%d9k}[𦴽YFJtW?7ZJv_-jYz_KpB`iE@$*4aV)`𠪚V`Q&0O7=ZmB<KG3Y5$\\>WO$1(/4子tmkNd;Zcte𥗼fay>nqh𨃮wQwW~u:`,pzhSB6|&~p}\"dS6🢓_3#*+f#5𠷓>:-Yq58Q_:𠷒as0/^j7;^BafT3I3y䖜jY0<CiwxqJ.Ofx<\" 1FDU9HrlD$7𨸴cEIq+*>~"
Copy link
Member

Choose a reason for hiding this comment

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

That's the kind of name I imagine @piotr-iohk would use on a wallet yeah 😶

Copy link
Member Author

Choose a reason for hiding this comment

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

Buried deep within this name is the character "䖜", which apparently is "the fighting sound made by two tigers" (https://en.wiktionary.org/wiki/%E4%96%9C)

@jonathanknowles
Copy link
Member Author

Arg! We agreed on the scope during the last meeting:
* getWallet
* listWallet
* postWallet
* postTransaction
* listTransaction

I had interpreted the scope to be everything within issue #53, which states:

Extend the API to support all endpoints.

But now I notice that it also states (later on):

The scope of this ticket has been reduced down to the endpoints discussed during the last iteration
planning meeting

In which case I now understand your comment. :)

In that case, perhaps we should update the the scope of issue #53, so that it no longer states "all endpoints"?

@KtorZ
Copy link
Member

KtorZ commented Mar 27, 2019

@jonathanknowles Yes, let's update the scope. I mean, no big deal, we'll to get them done at some point. But I'd integrate endpoints incrementally and start implementing handlers and CLI commands for those we already have, so that we are able to deliver something already.

@jonathanknowles
Copy link
Member Author

start implementing handlers and CLI commands for those we already have, so that we are able to deliver something already.

Okay!

@jonathanknowles
Copy link
Member Author

Yes, let's update the scope.

Done.

@KtorZ KtorZ force-pushed the jonathanknowles/api-put-wallet branch from 52fd12c to 9776437 Compare March 27, 2019 08:22
Copy link
Member

@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.

LGTM.

I've rebased and squashed on top of latest master 👍

@KtorZ KtorZ force-pushed the jonathanknowles/api-put-wallet branch from 9776437 to b3baaae Compare March 27, 2019 08:58
@jonathanknowles jonathanknowles merged commit baadd43 into master Mar 27, 2019
@jonathanknowles jonathanknowles deleted the jonathanknowles/api-put-wallet branch March 27, 2019 09:16
rvl added a commit that referenced this pull request Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants