-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
modules/coin/rest: implemented doCreateRole #208
Conversation
Alright, now CLI tests remaining. |
Cool, added functionality. Two main points, I could add them to code, but easier here:
|
Thanks for the notes @ethanfrey. In regards to:
|
Alright, I've updated the PR, PTAL. |
After this PR is merged into unstable, there is another coming up on branch https://github.com/orijtech/basecoin/tree/query_role and that should conclude #200 or at least for the listed tasks. |
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.
Looks good, but the create role handler belongs in modules/roles/rest
Thanks @ethanfrey, yeah that's a brain fart on my part, I'll move that code. |
Updated @ethanfrey, PTAL! |
modules/roles/rest/handlers.go
Outdated
"github.com/tendermint/tmlibs/common" | ||
) | ||
|
||
type RoleInput struct { |
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.
Can we get a comment for the public struct?
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.
Good plan, thanks for letting me know. I'll update this in a second.
modules/roles/rest/handlers.go
Outdated
|
||
// mux.Router registrars | ||
|
||
// RegisterQueryAccount is a mux.Router handler that exposes GET |
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.
This comment appears stale. Should be RegisterCreateRole
and route is /build/create_role
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.
Ah, thank you, updating it.
tx = roles.NewCreateRoleTx(parsedRole, ri.MinimumSigners, ri.Signers) | ||
|
||
// 3. ChainTx | ||
tx = base.NewChainTx(commands.GetChainID(), 0, tx) |
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.
Not thrilled about calls to commands
package all over. Think we need to revisit approach. It's certainly convenient and not that bad, just somewhat striking.
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.
Yes I agree, perhaps we need a refactor in a few rounds. I think we had coupled all the functionality with the CLI(for which all these libraries had been built for) and in order to spin up the rest server (a quick job) we haven't been able to dissect and change it up.
@@ -24,11 +24,17 @@ Route | Method | Completed | Description | |||
/sign|POST|✔️|Sign a transaction | |||
/tx|POST|✖️|Post a transaction to the blockchain | |||
/seeds/status|GET|✖️|Returns the information on the last seed | |||
/build/create_role|POST|✔️|Creates a role. Please note that the role MUST be valid hex for example instead of sending "role", send its hex encoded equivalent "726f6c65" |
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.
Not surprised to see this, but it doesn't make the best experience. Can we do something about it or is this a deep 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.
So we changed this up in tendermint/basecoin@f2adf36 and the rational is that using hex makes sending content "more secure"/obfuscated as opposed to just sending a string, cc @ethanfrey.
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.
Hmm ok. I'll wait to here from frey on this one. Thanks.
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.
Yeah, we use hex identifiers everywhere and there was confusion writing tests with it not being hex. Then in a discussion, someone mentioned it was not good to use strings ("cosmos-devs") but rather force hex bytes which would generally be chosen with no human significance, and not leak information.
Seems easier and no need to use human-readable strings in the API, although one could build that on top, if so desired.
Thank you @ebuchman for the review, I've updated the feedback in tendermint/basecoin@d5b63ab, PTAL! |
Great! |
* Note: Role must be a hex string, as enforced in tests/rest/cli.sh ```shell $ curl -X POST http://localhost:8998/build/create_role --data \ '{ "role":"DEADBEEF", "seq": 1, "min_sigs": 1, "signers": [{ "addr": "4FF759D47C81754D8F553DCCAC8651D0AF74C7F9", "app": "role" }] }' ``` ```HTTP HTTP/1.1 200 OK Content-Type: application/json Date: Tue, 08 Aug 2017 19:15:13 GMT Content-Length: 387 { "type": "chain/tx", "data": { "chain_id": "test_chain_id", "expires_at": 0, "tx": { "type": "role/create", "data": { "role": "DEADBEEF", "min_sigs": 1, "signers": [ { "chain": "", "app": "role", "addr": "4FF759D47C81754D8F553DCCAC8651D0AF74C7F9" } ] } } } } ``` Updates #200
Implements doCreateRole
Updates #200