-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(account): Move node-unregister from entity to account
- Loading branch information
Showing
3 changed files
with
61 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package account | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/oasisprotocol/oasis-core/go/common/crypto/signature" | ||
registry "github.com/oasisprotocol/oasis-core/go/registry/api" | ||
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/connection" | ||
|
||
"github.com/oasisprotocol/cli/cmd/common" | ||
cliConfig "github.com/oasisprotocol/cli/config" | ||
) | ||
|
||
var nodeUnfreezeCmd = &cobra.Command{ | ||
Use: "node-unfreeze <node-id>", | ||
Short: "Unfreeze a frozen validator node", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cfg := cliConfig.Global() | ||
npa := common.GetNPASelection(cfg) | ||
txCfg := common.GetTransactionConfig() | ||
rawNodeID := args[0] | ||
|
||
if npa.Account == nil { | ||
cobra.CheckErr("no accounts configured in your wallet") | ||
} | ||
|
||
// When not in offline mode, connect to the given network endpoint. | ||
ctx := context.Background() | ||
var conn connection.Connection | ||
if !txCfg.Offline { | ||
var err error | ||
conn, err = connection.Connect(ctx, npa.Network) | ||
cobra.CheckErr(err) | ||
} | ||
|
||
// Parse node identifier. | ||
var nodeID signature.PublicKey | ||
err := nodeID.UnmarshalText([]byte(rawNodeID)) | ||
cobra.CheckErr(err) | ||
|
||
// Prepare transaction. | ||
tx := registry.NewUnfreezeNodeTx(0, nil, ®istry.UnfreezeNode{ | ||
NodeID: nodeID, | ||
}) | ||
|
||
acc := common.LoadAccount(cfg, npa.AccountName) | ||
sigTx, err := common.SignConsensusTransaction(ctx, npa, acc, conn, tx) | ||
cobra.CheckErr(err) | ||
|
||
common.BroadcastOrExportTransaction(ctx, npa.ParaTime, conn, sigTx, nil, nil) | ||
}, | ||
} | ||
|
||
func init() { | ||
nodeUnfreezeCmd.Flags().AddFlagSet(common.SelectorNAFlags) | ||
nodeUnfreezeCmd.Flags().AddFlagSet(common.TransactionFlags) | ||
} |