Skip to content

Commit 2df78e9

Browse files
coderbradleezjshen14
authored andcommitted
ioctl action transfer uses IOTX for amount rather than Rau #1215 (#1216)
1 parent 2ffdb38 commit 2df78e9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cli/ioctl/cmd/action/actionhash.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,14 @@ func printActionProto(action *iotextypes.Action) (string, error) {
137137
output += proto.MarshalTextString(action.Core)
138138
case action.Core.GetTransfer() != nil:
139139
transfer := action.Core.GetTransfer()
140+
amount, err := util.StringToIOTX(transfer.Amount)
141+
if err != nil {
142+
return "", err
143+
}
140144
output += "transfer: <\n" +
141145
fmt.Sprintf(" recipient: %s %s\n", transfer.Recipient,
142146
Match(transfer.Recipient, "address")) +
143-
fmt.Sprintf(" amount: %s Rau\n", transfer.Amount)
147+
fmt.Sprintf(" amount: %s IOTX\n", amount)
144148
if len(transfer.Payload) != 0 {
145149
output += fmt.Sprintf(" payload: %s\n", transfer.Payload)
146150
}

cli/ioctl/util/util.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,13 @@ func IoAddrToEvmAddr(ioAddr string) (common.Address, error) {
9999
}
100100
return common.BytesToAddress(address.Bytes()), nil
101101
}
102+
103+
// StringToIOTX converts Rau string to Iotx string
104+
func StringToIOTX(amount string) (iotx string, err error) {
105+
amountInt, err := StringToRau(amount, 0)
106+
if err != nil {
107+
return "", err
108+
}
109+
iotx = RauToString(amountInt, 18)
110+
return
111+
}

0 commit comments

Comments
 (0)