Skip to content
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

[ioctl] display chainID and encoding #2820

Merged
merged 2 commits into from
Oct 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions ioctl/cmd/action/actionhash.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ import (
var (
hashCmdShorts = map[config.Language]string{
config.English: "Get action by hash",
config.Chinese: "依据哈希值,获取行动",
config.Chinese: "依据哈希值,获取交易",
}
hashCmdUses = map[config.Language]string{
config.English: "hash ACTION_HASH",
config.Chinese: "hash 行动_哈希", // this translation
config.Chinese: "hash 交易哈希",
}
)

Expand Down Expand Up @@ -169,21 +169,22 @@ func printActionProto(action *iotextypes.Action) (string, error) {
return "", output.NewError(output.ConvertError, "failed to convert bytes into address", nil)
}
//ioctl action should display IOTX unit instead Raul
gasPriceUnitIOTX, err := util.StringToIOTX(action.Core.GasPrice)
core := action.Core
gasPriceUnitIOTX, err := util.StringToIOTX(core.GasPrice)
if err != nil {
return "", output.NewError(output.ConfigError, "failed to convert string to IOTX", err)
}
result := fmt.Sprintf("\nversion: %d ", action.Core.GetVersion()) +
fmt.Sprintf("nonce: %d ", action.Core.GetNonce()) +
fmt.Sprintf("gasLimit: %d ", action.Core.GasLimit) +
fmt.Sprintf("gasPrice: %s IOTX\n", gasPriceUnitIOTX) +
result := fmt.Sprintf("\nversion: %d ", core.GetVersion()) +
fmt.Sprintf("nonce: %d ", core.GetNonce()) +
fmt.Sprintf("gasLimit: %d ", core.GasLimit) +
fmt.Sprintf("gasPrice: %s IOTX ", gasPriceUnitIOTX) +
fmt.Sprintf("chainID: %d ", core.GetChainID()) +
fmt.Sprintf("encoding: %d\n", action.GetEncoding()) +
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

display chainID and encoding

fmt.Sprintf("senderAddress: %s %s\n", senderAddress.String(),
Match(senderAddress.String(), "address"))
switch {
default:
result += protoV1.MarshalTextString(action.Core)
case action.Core.GetTransfer() != nil:
transfer := action.Core.GetTransfer()
case core.GetTransfer() != nil:
transfer := core.GetTransfer()
amount, err := util.StringToIOTX(transfer.Amount)
if err != nil {
return "", output.NewError(output.ConvertError, "failed to convert string into IOTX amount", err)
Expand All @@ -196,8 +197,8 @@ func printActionProto(action *iotextypes.Action) (string, error) {
result += fmt.Sprintf(" payload: %s\n", transfer.Payload)
}
result += ">\n"
case action.Core.GetExecution() != nil:
execution := action.Core.GetExecution()
case core.GetExecution() != nil:
execution := core.GetExecution()
result += "execution: <\n" +
fmt.Sprintf(" contract: %s %s\n", execution.Contract,
Match(execution.Contract, "address"))
Expand All @@ -209,8 +210,8 @@ func printActionProto(action *iotextypes.Action) (string, error) {
result += fmt.Sprintf(" amount: %s IOTX\n", amount)
}
result += fmt.Sprintf(" data: %x\n", execution.Data) + ">\n"
case action.Core.GetPutPollResult() != nil:
putPollResult := action.Core.GetPutPollResult()
case core.GetPutPollResult() != nil:
putPollResult := core.GetPutPollResult()
result += "putPollResult: <\n" +
fmt.Sprintf(" height: %d\n", putPollResult.Height) +
" candidates: <\n"
Expand All @@ -224,6 +225,8 @@ func printActionProto(action *iotextypes.Action) (string, error) {
}
result += " >\n" +
">\n"
default:
result += protoV1.MarshalTextString(core)
}
result += fmt.Sprintf("senderPubKey: %x\n", action.SenderPubKey) +
fmt.Sprintf("signature: %x\n", action.Signature)
Expand Down