diff --git a/CHANGELOG.md b/CHANGELOG.md index 4619a40e..30e141be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ - [](https://github.com/vegaprotocol/vegawallet/pull/) - ### 🛠 Improvements -- [](https://github.com/vegaprotocol/vegawallet/pull/) - +- [544](https://github.com/vegaprotocol/vegawallet/issues/544) - Display transaction hash after sending transaction ### 🔥 Removal - [](https://github.com/vegaprotocol/vegawallet/pull/) - diff --git a/cmd/tx_send.go b/cmd/tx_send.go index eee328ec..e505c082 100644 --- a/cmd/tx_send.go +++ b/cmd/tx_send.go @@ -204,6 +204,9 @@ func SendTx(w io.Writer, rf *RootFlags, req *SendTxRequest) error { } log.Info("transaction successfully sent", zap.String("hash", txHash)) + if rf.Output == flags.InteractiveOutput { + p.CheckMark().InfoText("Transaction sent:").SuccessText(txHash).NextLine() + } return nil } diff --git a/go.sum b/go.sum index c1028bc4..5b202ec5 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,6 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -code.vegaprotocol.io/protos v0.50.1-0.20220412212930-5d74f8a446c0 h1:qy9Kk53fpfsZU7HXL95ZE7yDKVPBv0EtIwdKr/zKvMs= -code.vegaprotocol.io/protos v0.50.1-0.20220412212930-5d74f8a446c0/go.mod h1:4BqwDw6jhc/mnwbXq8ZFUtYBFCnk8tBW6zuPsBt8OrQ= code.vegaprotocol.io/protos v0.50.1 h1:/DQ57iSPMR6Uk+TVGw/GcBfNcTqSCd3Bk/nia11o/+c= code.vegaprotocol.io/protos v0.50.1/go.mod h1:4BqwDw6jhc/mnwbXq8ZFUtYBFCnk8tBW6zuPsBt8OrQ= code.vegaprotocol.io/shared v0.0.0-20220321185018-3b5684b00533 h1:IxTWvyF0i0AgUAS+FTgQKIpbsS6Ki/Y9Ug0GSlgChJw= diff --git a/service/mocks/policies_mock.go b/service/mocks/policies_mock.go index 4a680426..924e988c 100644 --- a/service/mocks/policies_mock.go +++ b/service/mocks/policies_mock.go @@ -21,3 +21,7 @@ func (p *MockConsentPolicy) Ask(tx *v1.SubmitTransactionRequest) (bool, error) { } return true, nil } + +func (p *MockConsentPolicy) NeedsInteractiveOutput() bool { + return true +} diff --git a/service/policies.go b/service/policies.go index a5545eb9..5a47d7ab 100644 --- a/service/policies.go +++ b/service/policies.go @@ -36,6 +36,7 @@ func (r *ConsentRequest) GetTxID() string { type Policy interface { Ask(tx *v1.SubmitTransactionRequest) (bool, error) + NeedsInteractiveOutput() bool } type AutomaticConsentPolicy struct{} @@ -48,6 +49,10 @@ func (p *AutomaticConsentPolicy) Ask(_ *v1.SubmitTransactionRequest) (bool, erro return true, nil } +func (p *AutomaticConsentPolicy) NeedsInteractiveOutput() bool { + return false +} + type ExplicitConsentPolicy struct { pendingEvents chan ConsentRequest } @@ -67,3 +72,7 @@ func (p *ExplicitConsentPolicy) Ask(tx *v1.SubmitTransactionRequest) (bool, erro c := <-confirmations return c.Decision, nil } + +func (p *ExplicitConsentPolicy) NeedsInteractiveOutput() bool { + return true +} diff --git a/service/service.go b/service/service.go index fba26ab8..45ff7fc3 100644 --- a/service/service.go +++ b/service/service.go @@ -16,6 +16,7 @@ import ( commandspb "code.vegaprotocol.io/protos/vega/commands/v1" walletpb "code.vegaprotocol.io/protos/vega/wallet/v1" vgcrypto "code.vegaprotocol.io/shared/libs/crypto" + "code.vegaprotocol.io/vegawallet/cmd/printer" wcommands "code.vegaprotocol.io/vegawallet/commands" "code.vegaprotocol.io/vegawallet/network" "code.vegaprotocol.io/vegawallet/version" @@ -793,6 +794,11 @@ func (s *Service) signTx(token string, w http.ResponseWriter, r *http.Request, _ return } + if s.policy.NeedsInteractiveOutput() { + p := printer.NewInteractivePrinter(w) + p.CheckMark().InfoText("Transaction sent:").SuccessText(txHash).NextLine() + } + s.writeSuccess(w, struct { TxHash string `json:"txHash"` Tx *commandspb.Transaction `json:"tx"`