Skip to content

Commit

Permalink
Improve hash cmd for ioctl (#836)
Browse files Browse the repository at this point in the history
* Improve hash cmd for ioctl

* update
  • Loading branch information
Frankonly authored and raullenchai committed Mar 25, 2019
1 parent 6b4621e commit 49350d0
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions cli/ioctl/cmd/action/actionhash.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func getActionByHash(args []string) string {
if err != nil {
return err.Error()
}

return output + "\n#This action has been written on blockchain\n" +
printReceiptProto(responseReceipt.Receipt)
}
Expand All @@ -101,35 +100,43 @@ func printActionProto(action *iotextypes.Action) (string, error) {
switch {
case action.Core.GetTransfer() != nil:
transfer := action.Core.GetTransfer()
return fmt.Sprintf("senderAddress: %s %s\n", senderAddress.String(),
match(senderAddress.String(), "address")) +
return 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 Rau\n", action.Core.GasPrice) +
fmt.Sprintf("senderAddress: %s %s\n", senderAddress.String(),
match(senderAddress.String(), "address")) +
"transfer: <\n" +
fmt.Sprintf(" recipient: %s %s\n", transfer.Recipient,
match(transfer.Recipient, "address")) +
fmt.Sprintf(" amount: %s\n", transfer.Amount) +
fmt.Sprintf(" amount: %s Rau\n", transfer.Amount) +
fmt.Sprintf(" payload: %s\n", transfer.Payload) +
">\n" +
fmt.Sprintf("senderPubKey: %x\n", action.SenderPubKey) +
fmt.Sprintf("signature: %x\n", action.Signature), nil
case action.Core.GetExecution() != nil:
execution := action.Core.GetExecution()
return fmt.Sprintf("senderAddress: %s %s\n", senderAddress.String(),
match(senderAddress.String(), "address")) +
fmt.Sprintf("version: %d\n", action.Core.GetVersion()) +
fmt.Sprintf("nonce: %d\n", action.Core.GetNonce()) +
fmt.Sprintf("gasLimit: %d\n", action.Core.GasLimit) +
fmt.Sprintf("gasPrice: %s\n", action.Core.GasPrice) +
return 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 Rau\n", action.Core.GasPrice) +
fmt.Sprintf("senderAddress: %s %s\n", senderAddress.String(),
match(senderAddress.String(), "address")) +
"execution: <\n" +
fmt.Sprintf(" contract: %s %s\n", execution.Contract,
match(execution.Contract, "address")) +
fmt.Sprintf(" amount: %s\n", execution.Amount) +
fmt.Sprintf(" amount: %s Rau\n", execution.Amount) +
fmt.Sprintf(" data: %x\n", execution.Data) +
">\n" +
fmt.Sprintf("senderPubKey: %x\n", action.SenderPubKey) +
fmt.Sprintf("signature: %x\n", action.Signature), nil
case action.Core.GetClaimFromRewardingFund() != nil:
return fmt.Sprintf("senderAddress: %s %s\n", senderAddress.String(),
match(senderAddress.String(), "address")) +
return 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 Rau\n", action.Core.GasPrice) +
fmt.Sprintf("senderAddress: %s %s\n", senderAddress.String(),
match(senderAddress.String(), "address")) +
proto.MarshalTextString(action.Core) +
fmt.Sprintf("senderPubKey: %x\n", action.SenderPubKey) +
fmt.Sprintf("signature: %x\n", action.Signature), nil
Expand All @@ -151,6 +158,7 @@ func printReceiptProto(receipt *iotextypes.Receipt) string {
fmt.Sprintf("status: %d %s\n", receipt.Status,
match(strconv.Itoa(int(receipt.Status)), "status")) +
fmt.Sprintf("actHash: %x\n", receipt.ActHash) +
// TODO: blkHash
fmt.Sprintf("gasConsumed: %d\n", receipt.GasConsumed) +
fmt.Sprintf("contractAddress: %s %s\n", receipt.ContractAddress,
match(receipt.ContractAddress, "address")) +
Expand Down

0 comments on commit 49350d0

Please sign in to comment.