Add wallet commands to JSON-RPC client #73
Labels
No labels
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
dependencies
Epic
good first issue
hacktoberfest
help wanted
icebox
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbry.go#73
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/wallet"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This adds new wallet_* commands.
refer to the comments for improvements
@ -142,3 +143,4 @@
return response, d.call(response, "account_list", map[string]interface{}{})
}
func (d *Client) AccountListForWallet(walletID string) (*AccountListResponse, error) {
i think we should just add an optional param to the current account functions. just like I did for AccountAdd yesterday
you gotta remember to define the
json
part and add,omitempty
otherwise the SDK will crap outany reasons as to why you'd want to use a structure instead of just passing 3 more params?
to stay consistent with the other calls, unless it's a lot of params we're talking about, I would keep it simple
we followed up in slack. I think we need more opinions here.
Struct pros:
Cons:
@ -142,3 +143,4 @@
return response, d.call(response, "account_list", map[string]interface{}{})
}
func (d *Client) AccountListForWallet(walletID string) (*AccountListResponse, error) {
That's how we ended up with v2 of lbry.go already — introducing backwards incompatible changes way too liberally. I don't think we should do that.
P.S. That's another example where opts would make things easier by not breaking backwards compatibility.
It also makes it easier to omit optional parameters and supply only the ones we want. The second example is much more readable in my opinion.
This also makes sense where we're designing an RPC client, which, in turn, relies on an API that is changing very rapidly. We don't want to bump major version number and/or break, say,
AccountList
for all clients just because there is a newWalletID
parameter now that we need to use.If the structure changes in a non-backwards compatible way, it should be fairly easy to validate in the receiving functions and produce an error at run time.
Bottom line, I think losing some of the compile time validation here is worth it for the ease of readability and use.
Reposting from slack:
to me it makes sense to use arguments for required params and an options struct for optional params
alternatively, if there's an option that's used a lot when calling the method, that can be an arg too
@sayplastic I'm confused what you mean by
How would we break AccountList for all clients? it would not break unless they update to a newer version of lbry.go. And if they are updating, they should be aware that there may be API changes that they'll have to handle. Nothing will break without them taking action.
Not the best wording on my part. What I meant is we’re going to be requiring changes from client code if they stay up to date.
@ -142,3 +143,4 @@
return response, d.call(response, "account_list", map[string]interface{}{})
}
func (d *Client) AccountListForWallet(walletID string) (*AccountListResponse, error) {
I think we shouldn't worry too much about backward compatibility. If one doesn't want to stay up to date with lbry.go/sdk then they can lock themselves into a commit that supports such old versions.
We don't have the time to support multiple versions, only the current one. I still feel like it should not be split out and rather updated
that's the desired outcome in my opinion. If one client updates lbry.go they should expect to update the use of their functions according to the SDK changes. Hiding those updates will fragment usage and possibly make updating a pain as one should either have all sdk functionalities tested (which would be great, but realistically speaking unlikely) or go through all the calls to figure out the changes
I changed the way options are provided, have a look please
I have restored versioning, after this is merged you can tag new versions as
v2.3.1v2.3.2 and higher and import them in client code asgithub.com/lbryio/lbry.go/v2/...
Would strongly suggest tagging your code that is not finalized yet with a
pre
suffix.Added
ChannelImport
method and changedChannelList
signature for wallet ID.@ -27,4 +19,3 @@
github.com/nlopes/slack v0.5.0
github.com/pkg/errors v0.8.1 // indirect
github.com/sebdah/goldie v0.0.0-20180424091453-8784dd1ab561
github.com/sergi/go-diff v1.0.0
something must be still using the wrong stuff
@ -66,6 +66,10 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfM
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c/go.mod h1:muH7wpUqE8hRA3OrYYosw9+Sl681BF9cwcjzE+OCNK8=
nope, we have to use lbry.go for this I think
needs fixes
this needs to be converted to a defined structure like in some other calls, otherwise I believe the SDK might crap out if you pass --wallet_id=null
same here
@ -510,0 +660,4 @@
_, err = d.WalletRemove(id)
if err != nil {
t.Fatal(err)
you should try calling an extra one without walletID to see if it holds up or not
@ -66,6 +66,10 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfM
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c/go.mod h1:muH7wpUqE8hRA3OrYYosw9+Sl681BF9cwcjzE+OCNK8=
Strange since this is not a manual edit
I covered it with a test and seems like the SDK handles it well
@ -142,3 +143,4 @@
return response, d.call(response, "account_list", map[string]interface{}{})
}
func (d *Client) AccountListForWallet(walletID string) (*AccountListResponse, error) {
I spent a few minutes adding a
nil
parameter toAccoutList
in calls around the test code that don't know aboutwallet_id
and it felt quite ugly to me. Barring all the uncertainties of designing an API ahead of client code, I'd hazard a guess the majority of clients will be requiring the argument-less version ofaccount_list
and we should keep it that.