Skip to content

Commit

Permalink
Use io address in ioctl output (#2527)
Browse files Browse the repository at this point in the history
* use io address for output in ioctl

* modify unit test

Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
  • Loading branch information
koseoyoung and CoderZhi authored Nov 30, 2020
1 parent 366588a commit 66cb15f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ioctl/cmd/contract/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestParseOutput(t *testing.T) {
"0000000000000000000000000000000000000000000000000000000000000000",
},
{
"0xc7F43FaB2ca353d29cE0DA04851aB74f45B09593",
"io1cl6rl2ev5dfa988qmgzg2x4hfazmp9vn2g66ng",
"owner",
"000000000000000000000000c7f43fab2ca353d29ce0da04851ab74f45b09593",
},
Expand All @@ -102,7 +102,7 @@ func TestParseOutput(t *testing.T) {
"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b48656c6c6f20576f726c64000000000000000000000000000000000000000000",
},
{
"{i:17 abc:[0x0000000000000000000000000000000000000000 0xc7F43FaB2ca353d29cE0DA04851aB74f45B09593]}",
"{i:17 abc:[io1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqd39ym7 io1cl6rl2ev5dfa988qmgzg2x4hfazmp9vn2g66ng]}",
"testTuple",
"00000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c7f43fab2ca353d29ce0da04851ab74f45b09593",
},
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestParseOutputArgument(t *testing.T) {
common.HexToAddress("c7F43FaB2ca353d29cE0DA04851aB74f45B09593"),
"address",
nil,
"0xc7F43FaB2ca353d29cE0DA04851aB74f45B09593",
"io1cl6rl2ev5dfa988qmgzg2x4hfazmp9vn2g66ng",
},
{
[]byte("test bytes"),
Expand Down
7 changes: 6 additions & 1 deletion ioctl/cmd/contract/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"

"github.com/iotexproject/iotex-address/address"

"github.com/iotexproject/iotex-core/ioctl/output"
"github.com/iotexproject/iotex-core/ioctl/util"
)
Expand Down Expand Up @@ -372,7 +374,10 @@ func parseOutputArgument(v interface{}, t *abi.Type) (string, bool) {
var ethAddr common.Address
ethAddr, ok = v.(common.Address)
if ok {
str = ethAddr.String()
ioAddress, err := address.FromBytes(ethAddr.Bytes())
if err == nil {
str = ioAddress.String()
}
}
}

Expand Down

0 comments on commit 66cb15f

Please sign in to comment.