Skip to content

Commit

Permalink
feat: add address to str function (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code authored and github-actions[bot] committed Feb 28, 2024
1 parent fecc1a8 commit 4482ee7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions types/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/bech32"
"github.com/ethereum/go-ethereum/common"
tronaddress "github.com/fbsobreira/gotron-sdk/pkg/address"
)

func ParseAddress(addr string) (accAddr sdk.AccAddress, isEvmAddr bool, err error) {
Expand All @@ -19,3 +20,11 @@ func ParseAddress(addr string) (accAddr sdk.AccAddress, isEvmAddr bool, err erro
}
return nil, false, errors.Join(decodeErr, ethAddrError)
}

func AddressToStr(bt []byte, module string) string {
if module == "tron" {
return tronaddress.Address(bt).String()
} else {
return common.BytesToAddress(bt).String()
}
}

0 comments on commit 4482ee7

Please sign in to comment.