Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #545 from vegaprotocol/feature/544-display-tx-hash…
Browse files Browse the repository at this point in the history
…-sent

feat: now displaying transaction hash after sending
  • Loading branch information
jeremyletang authored Apr 22, 2022
2 parents 981344d + b53d8a8 commit 436a70b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/) -
Expand Down
3 changes: 3 additions & 0 deletions cmd/tx_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 4 additions & 0 deletions service/mocks/policies_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ func (p *MockConsentPolicy) Ask(tx *v1.SubmitTransactionRequest) (bool, error) {
}
return true, nil
}

func (p *MockConsentPolicy) NeedsInteractiveOutput() bool {
return true
}
9 changes: 9 additions & 0 deletions service/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (r *ConsentRequest) GetTxID() string {

type Policy interface {
Ask(tx *v1.SubmitTransactionRequest) (bool, error)
NeedsInteractiveOutput() bool
}

type AutomaticConsentPolicy struct{}
Expand All @@ -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
}
Expand All @@ -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
}
6 changes: 6 additions & 0 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"`
Expand Down

0 comments on commit 436a70b

Please sign in to comment.