Skip to content

Commit 66cb15f

Browse files
koseoyoungCoderZhi
andauthored
Use io address in ioctl output (#2527)
* use io address for output in ioctl * modify unit test Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
1 parent 366588a commit 66cb15f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

ioctl/cmd/contract/contract_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestParseOutput(t *testing.T) {
9292
"0000000000000000000000000000000000000000000000000000000000000000",
9393
},
9494
{
95-
"0xc7F43FaB2ca353d29cE0DA04851aB74f45B09593",
95+
"io1cl6rl2ev5dfa988qmgzg2x4hfazmp9vn2g66ng",
9696
"owner",
9797
"000000000000000000000000c7f43fab2ca353d29ce0da04851ab74f45b09593",
9898
},
@@ -102,7 +102,7 @@ func TestParseOutput(t *testing.T) {
102102
"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b48656c6c6f20576f726c64000000000000000000000000000000000000000000",
103103
},
104104
{
105-
"{i:17 abc:[0x0000000000000000000000000000000000000000 0xc7F43FaB2ca353d29cE0DA04851aB74f45B09593]}",
105+
"{i:17 abc:[io1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqd39ym7 io1cl6rl2ev5dfa988qmgzg2x4hfazmp9vn2g66ng]}",
106106
"testTuple",
107107
"00000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c7f43fab2ca353d29ce0da04851ab74f45b09593",
108108
},
@@ -152,7 +152,7 @@ func TestParseOutputArgument(t *testing.T) {
152152
common.HexToAddress("c7F43FaB2ca353d29cE0DA04851aB74f45B09593"),
153153
"address",
154154
nil,
155-
"0xc7F43FaB2ca353d29cE0DA04851aB74f45B09593",
155+
"io1cl6rl2ev5dfa988qmgzg2x4hfazmp9vn2g66ng",
156156
},
157157
{
158158
[]byte("test bytes"),

ioctl/cmd/contract/parse.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"github.com/ethereum/go-ethereum/accounts/abi"
2020
"github.com/ethereum/go-ethereum/common"
2121

22+
"github.com/iotexproject/iotex-address/address"
23+
2224
"github.com/iotexproject/iotex-core/ioctl/output"
2325
"github.com/iotexproject/iotex-core/ioctl/util"
2426
)
@@ -372,7 +374,10 @@ func parseOutputArgument(v interface{}, t *abi.Type) (string, bool) {
372374
var ethAddr common.Address
373375
ethAddr, ok = v.(common.Address)
374376
if ok {
375-
str = ethAddr.String()
377+
ioAddress, err := address.FromBytes(ethAddr.Bytes())
378+
if err == nil {
379+
str = ioAddress.String()
380+
}
376381
}
377382
}
378383

0 commit comments

Comments
 (0)