-
Notifications
You must be signed in to change notification settings - Fork 30
Conversation
ae21d46
to
c0597d5
Compare
4669cd4
to
865d40c
Compare
c0597d5
to
abc9bdf
Compare
abc9bdf
to
492729b
Compare
package.json
Outdated
@@ -57,7 +57,8 @@ | |||
"@oclif/plugin-help" | |||
], | |||
"topics": { | |||
"config": { "description": "Manages Lisk Commander configuration." } | |||
"config": { "description": "Manages Lisk Commander configuration." }, | |||
"account": { "description": "Manages account." } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Manages Lisk accounts."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking ahead that it should be able to create non-lisk accounts too, but i guess it's too ahead now
package.json
Outdated
@@ -57,7 +57,8 @@ | |||
"@oclif/plugin-help" | |||
], | |||
"topics": { | |||
"config": { "description": "Manages Lisk Commander configuration." } | |||
"config": { "description": "Manages Lisk Commander configuration." }, | |||
"account": { "description": "Manages account." } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are formatted differently to the message for the help
command (try ./bin/run
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, maybe something like
"config": { "description": "manage configuration for lisk" },
"account": { "description": "manage account for lisk" }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather change the help message to conform to the pattern we have here.
src/commands/account/create.js
Outdated
}; | ||
|
||
CreateCommand.description = ` | ||
Returns a randomly-generated mnemonic passphrase with its corresponding public key and address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its corresponding public/private key pair and Lisk address
src/commands/account/get.js
Outdated
name: 'addresses', | ||
required: true, | ||
description: | ||
'Comma separated address(es) which you want to get the information of.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comma-separated address(es) to get information about.
?
src/commands/account/get.js
Outdated
address, | ||
})); | ||
const client = getAPIClient(this.userConfig.api); | ||
const results = await query(client, 'accounts', req); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I try an address which has a balance and one which doesn't I just get the error No accounts found using specified parameters.
This is pretty unhelpful, but shouldn't I get information about the existing addresses without having to try again anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can think of three way of solving this, but it's not really good UX either...
- Ignore errors, unless all error
- create another
key
in the response like { data: [], errors: []} - print error and returned value
1 will be hard to tell what went wrong to the user, and
considering it will be used in script, 2 and 3 will be harder to use.
any other idea to solve this? 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the case where an address is valid but not in the blockchain is a different case to other errors. We could wrap that specific error and return an object that has no public key and no balance (therefore clear that it's never been used). With other errors it's more complicated. I guess it's more acceptable in that case to return an error if anything failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of empty response, we are creating the error on the commander side.
but im not sure it's a good idea to return an object that has no public key and no balance
.
Any API change will affect this command to break, while currently it's pretty flexible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did we do for list
before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no public key and no balance
I just meant an empty string and 0s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current behavior is the same as before.
if we need to initialize them, we need to be fixed on those field.
maybe what we can do is to define empty object from key
?
for example, we call query
with object created with key. In account case, it would be
{account: '123L'}
and in cause of empty response, return this
src/commands/account/show.js
Outdated
import BaseCommand from '../../base'; | ||
import getInputsFromSources from '../../utils/input'; | ||
import cryptography from '../../utils/cryptography'; | ||
import commonOptions from '../../utils/options'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to rename this commonFlags
and utils/flags
to be more herouku-consistent?
test/commands/account/get.test.js
Outdated
}); | ||
|
||
describe('account:get account', () => { | ||
const account = '3520445367460290306L'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address
]); | ||
return expect(printMethodStub).to.be.calledWithExactly(queryResult); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error case? Is there a maximum number of addresses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently there is no maximum (each request is separated)
test/commands/account/get.test.js
Outdated
const queryResult = { | ||
address: account, | ||
name: 'i am owner', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I have to know whether I'm calling this command with one address or more than one in order to process it properly (or do some format check). If I'm using this command as part of a script that generates a variable number of addresses, that might not be obvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm maybe it will have better UX by always returning the array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so.
test/commands/account/show.test.js
Outdated
...defaultAddress, | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about warning if the passphrase is not a valid mnemonic? Beyond the scope of this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think #337 is the issue
package.json
Outdated
@@ -57,8 +57,11 @@ | |||
"@oclif/plugin-help" | |||
], | |||
"topics": { | |||
"help": { "description": "Displays help for Lisk Commander." }, | |||
"warranty": { "description": "Displays warranty notice for Lisk Commander." }, | |||
"copyright": { "description": "Displays copyright notice for Lisk Commander." }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these for Lisk Commander
s seem a bit redundant.
src/commands/account/get.js
Outdated
address, | ||
})); | ||
const client = getAPIClient(this.userConfig.api); | ||
const results = await query(client, 'accounts', req); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the case where an address is valid but not in the blockchain is a different case to other errors. We could wrap that specific error and return an object that has no public key and no balance (therefore clear that it's never been used). With other errors it's more complicated. I guess it's more acceptable in that case to return an error if anything failed.
test/commands/account/get.test.js
Outdated
@@ -44,53 +44,57 @@ describe('account:get command', () => { | |||
}); | |||
|
|||
describe('account:get account', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
account:get address
package.json
Outdated
"config": { "description": "Manages Lisk Commander configuration." }, | ||
"account": { "description": "Manages account." } | ||
"account": { "description": "Manages Lisk accounts." } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer alphabetical order (to match order displayed by oclif).
328ff60
to
c5ba1c4
Compare
c5ba1c4
to
9dbe2e3
Compare
src/commands/account/get.js
Outdated
}, | ||
placeholder: { | ||
address, | ||
message: 'No data was returned.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest "Address not found."
9dbe2e3
to
bcf4416
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, would just be nice to align the import style of lisk-elements/cryptography
in config:set
.
Description
Migration from
npm t
./bin/run account:create
./bin/run account:show
./bin/run account:get
Review checklist