Skip to content

Commit

Permalink
go/oasis-node/cmd: Improve transaction preview when generating txns
Browse files Browse the repository at this point in the history
Display amounts in tokens and display genesis document's hash when
previewing transactions.
  • Loading branch information
tjanez committed Mar 17, 2021
1 parent 1701467 commit 69d645a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .changelog/3792.feature.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
go/oasis-node/cmd: Improve transaction preview when generating transactions

Display amounts in tokens and display genesis document's hash when previewing
transactions with various `oasis-node * gen_*` CLI commands.
9 changes: 5 additions & 4 deletions go/oasis-node/cmd/governance/governance.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
governance "github.com/oasisprotocol/oasis-core/go/governance/api"
cmdCommon "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common"
cmdConsensus "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/consensus"
cmdContext "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/context"
cmdFlags "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/flags"
cmdGrpc "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/grpc"
cmdSigner "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/signer"
Expand Down Expand Up @@ -100,7 +101,7 @@ func doGenSubmitProposal(cmd *cobra.Command, args []string) {
cmdCommon.EarlyLogAndExit(err)
}

cmdConsensus.InitGenesis()
genesis := cmdConsensus.InitGenesis()
cmdConsensus.AssertTxFileOK()

nonce, fee := cmdConsensus.GetTxNonceAndFee()
Expand Down Expand Up @@ -149,15 +150,15 @@ func doGenSubmitProposal(cmd *cobra.Command, args []string) {
os.Exit(1)
}

cmdConsensus.SignAndSaveTx(context.Background(), tx, nil)
cmdConsensus.SignAndSaveTx(cmdContext.GetCtxWithGenesisInfo(genesis), tx, nil)
}

func doGenCastVote(cmd *cobra.Command, args []string) {
if err := cmdCommon.Init(); err != nil {
cmdCommon.EarlyLogAndExit(err)
}

cmdConsensus.InitGenesis()
genesis := cmdConsensus.InitGenesis()
cmdConsensus.AssertTxFileOK()

id := viper.GetUint64(cfgVoteProposalID)
Expand All @@ -179,7 +180,7 @@ func doGenCastVote(cmd *cobra.Command, args []string) {
ID: id,
Vote: vote,
})
cmdConsensus.SignAndSaveTx(context.Background(), tx, nil)
cmdConsensus.SignAndSaveTx(cmdContext.GetCtxWithGenesisInfo(genesis), tx, nil)
}

func doProposalInfo(cmd *cobra.Command, args []string) {
Expand Down
6 changes: 3 additions & 3 deletions go/oasis-node/cmd/keymanager/keymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keymanager

import (
"bytes"
"context"
"encoding/hex"
"encoding/json"
"errors"
Expand All @@ -25,6 +24,7 @@ import (
kmApi "github.com/oasisprotocol/oasis-core/go/keymanager/api"
cmdCommon "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common"
cmdConsensus "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/consensus"
cmdContext "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/context"
cmdFlags "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/flags"
)

Expand Down Expand Up @@ -391,7 +391,7 @@ func doGenUpdate(cmd *cobra.Command, args []string) {
cmdCommon.EarlyLogAndExit(err)
}

cmdConsensus.InitGenesis()
genesis := cmdConsensus.InitGenesis()
cmdConsensus.AssertTxFileOK()

// Assemble the SignedPolicySGX from the policy document and detached
Expand Down Expand Up @@ -444,7 +444,7 @@ func doGenUpdate(cmd *cobra.Command, args []string) {
// Build, sign, and write the UpdatePolicy transaction.
nonce, fee := cmdConsensus.GetTxNonceAndFee()
tx := kmApi.NewUpdatePolicyTx(nonce, fee, &signedPolicy)
cmdConsensus.SignAndSaveTx(context.Background(), tx, nil)
cmdConsensus.SignAndSaveTx(cmdContext.GetCtxWithGenesisInfo(genesis), tx, nil)
}

func statusFromFlags() (*kmApi.Status, error) {
Expand Down
9 changes: 5 additions & 4 deletions go/oasis-node/cmd/registry/entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
cmdCommon "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common"
cmdConsensus "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/consensus"
cmdContext "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/context"
cmdFlags "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/flags"
cmdGrpc "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/grpc"
cmdSigner "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/signer"
Expand Down Expand Up @@ -279,7 +280,7 @@ func doGenRegister(cmd *cobra.Command, args []string) {
cmdCommon.EarlyLogAndExit(err)
}

cmdConsensus.InitGenesis()
genesis := cmdConsensus.InitGenesis()
cmdConsensus.AssertTxFileOK()

ent, signer, err := cmdCommon.LoadEntitySigner()
Expand All @@ -302,21 +303,21 @@ func doGenRegister(cmd *cobra.Command, args []string) {
nonce, fee := cmdConsensus.GetTxNonceAndFee()
tx := registry.NewRegisterEntityTx(nonce, fee, signed)

cmdConsensus.SignAndSaveTx(context.Background(), tx, signer)
cmdConsensus.SignAndSaveTx(cmdContext.GetCtxWithGenesisInfo(genesis), tx, signer)
}

func doGenDeregister(cmd *cobra.Command, args []string) {
if err := cmdCommon.Init(); err != nil {
cmdCommon.EarlyLogAndExit(err)
}

cmdConsensus.InitGenesis()
genesis := cmdConsensus.InitGenesis()
cmdConsensus.AssertTxFileOK()

nonce, fee := cmdConsensus.GetTxNonceAndFee()
tx := registry.NewDeregisterEntityTx(nonce, fee)

cmdConsensus.SignAndSaveTx(context.Background(), tx, nil)
cmdConsensus.SignAndSaveTx(cmdContext.GetCtxWithGenesisInfo(genesis), tx, nil)
}

func doList(cmd *cobra.Command, args []string) {
Expand Down
5 changes: 3 additions & 2 deletions go/oasis-node/cmd/registry/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
cmdCommon "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common"
cmdConsensus "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/consensus"
cmdContext "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/context"
cmdFlags "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/flags"
cmdGrpc "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/grpc"
cmdSigner "github.com/oasisprotocol/oasis-core/go/oasis-node/cmd/common/signer"
Expand Down Expand Up @@ -206,7 +207,7 @@ func doGenRegister(cmd *cobra.Command, args []string) {
cmdCommon.EarlyLogAndExit(err)
}

cmdConsensus.InitGenesis()
genesis := cmdConsensus.InitGenesis()
cmdConsensus.AssertTxFileOK()

rt, err := runtimeFromFlags()
Expand All @@ -220,7 +221,7 @@ func doGenRegister(cmd *cobra.Command, args []string) {
nonce, fee := cmdConsensus.GetTxNonceAndFee()
tx := registry.NewRegisterRuntimeTx(nonce, fee, rt)

cmdConsensus.SignAndSaveTx(context.Background(), tx, nil)
cmdConsensus.SignAndSaveTx(cmdContext.GetCtxWithGenesisInfo(genesis), tx, nil)
}

func doList(cmd *cobra.Command, args []string) {
Expand Down

0 comments on commit 69d645a

Please sign in to comment.