-
Notifications
You must be signed in to change notification settings - Fork 375
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
chore: In gnoclient, separate out SignTx and BroadcastTxCommit #2641
chore: In gnoclient, separate out SignTx and BroadcastTxCommit #2641
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2641 +/- ##
==========================================
+ Coverage 60.19% 60.24% +0.04%
==========================================
Files 562 562
Lines 75007 75038 +31
==========================================
+ Hits 45154 45210 +56
+ Misses 26476 26457 -19
+ Partials 3377 3371 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…d BroadcastTxCommit Also add MakeCallTx, MakeRunTx, MakeSendTx and MakeAddPackageTx to support signing separately. Signed-off-by: Jeff Thompson <jeff@thefirst.org>
795277a
to
10550df
Compare
…use temporary replace for gno PR 2641 (#161) PR gnolang/gno#2641 updates the `gnoclient` API to add `MakeCallTx`, etc. and `SignTx` and `BroadcastTxCommit`. We want to support these in the gnonative API. * In go.mod, add a replace for github.com/gnolang/gno to the branch of PR gnolang/gno#2641 * In gnonativetypes.go, add field `CallerAddress` to `CallRequest`, `SendRequest` and `RunRequest`. Add `MakeTxResponse` and request/response for `SignTx` and `BroadcastTxCommitResponse`. * In rpc.proto, add `MakeCallTx`, etc., `SignTx` and `BroadcastTxCommit`. * Run `make regenerate` . * In api.go, split out helper function `convertCallRequest` from `Call`. Do the same for `convertSendRequest` and `convertRunRequest`. Add `MakeCallTx` which also uses `convertCallRequest`. Do the same for `MakeSendTx` and `MakeRunTx`. Add `SignTx` and `BroadcastTxCommit`. * Note that `MakeCallTx` converts the tx structure to JSON using `amino.MarshalJSON(tx)` . This is the same thing as done by the command-line `gnokey maketx call` . Signed-off-by: Jeff Thompson <jeff@thefirst.org>
…it-MakeCallTx-etc
…unSigningSeparately Signed-off-by: Jeff Thompson <jeff@thefirst.org>
Signed-off-by: Jeff Thompson <jeff@thefirst.org>
…it-MakeCallTx-etc
…it-MakeCallTx-etc
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 this is a huge step for the gnoclient, one we should've made for v1 of it 💯
I'm sorry for making you fix legacy code here, but I think we can fix this signing insanity once and for all. The changes look solid 🚀
…it-MakeCallTx-etc
…it-MakeCallTx-etc
Signed-off-by: Jeff Thompson <jeff@thefirst.org>
…lTx, etc. Signed-off-by: Jeff Thompson <jeff@thefirst.org>
Signed-off-by: Jeff Thompson <jeff@thefirst.org>
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.
Thank you for the cleanup 🙏
Pinging @gfanton for a second review 🙏 |
…it-MakeCallTx-etc
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!
Would it make sense to expose SignAndBroadcastTx?
Thanks for the review. No, I don't think we need to expose SignAndBroadcastTx. The use case for separating out SignTx is for airgap signing (or signing with a different app like Gnokey Mobile). In this use case, sign and broadcast are done on different devices or apps. |
Gno PR gnolang/gno#2641 has been merged, so we don't need the go.mod replace which was introduced in PR #161 . * In go.mod, remove the replace and use the latest gnolang/gno. * The final gnoclient API which was merged in PR gnolang/gno#2641 is different. It uses `vm.MsgCall`, etc. instead of `gnoclient.MsgCall`, and uses `NewCallTx`, etc. instead of `MakeCallTx`. Therefore, this PR updates api.go to use the new API. * Change the helper functions `convertCallRequest`, etc. to maybe return an error if there is no active account, or if the `send` amount like "1000ugnot" can't be parsed. Signed-off-by: Jeff Thompson <jeff@thefirst.org>
We can use
gnokey maketx call
,gnokey sign
andgnokey broadcast
to make a transaction and sign it separately before broadcast. We want to support the same thing in thegnoclient
API. (And we want to expose this API in Gno Native Kit.)NewCallTx
fromCall
NewRunTx
fromRun
NewSendTx
fromSend
NewAddPackageTx
fromAddPackage
SignTx
andBroadcastTxCommit
fromsignAndBroadcastTxCommit
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description