Skip to content

Commit

Permalink
fix native token match failed
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqiang.fan committed May 6, 2024
1 parent bd63489 commit c731f49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions server/tokenlogoinfo/Client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (

const (
endpointGetLogoInfos = "/priapi/v1/oc/web-common/coin/getLogoInfoBatch"
ChainNativeTokenAddr = "0x0000000000000000000000000000000000000000"
EmptyStr = ""
)

type Client struct {
Expand Down Expand Up @@ -117,5 +119,8 @@ func (c *Client) GetTokenLogoInfos(tokenAddArr []*tokenlogo.QueryLogoParam) (map
}

func GetTokenLogoMapKey(tokenAddr string, chainId uint32) string {
if tokenAddr == ChainNativeTokenAddr {
tokenAddr = EmptyStr
}
return fmt.Sprintf("%s_%d", strings.ToLower(tokenAddr), chainId)
}
6 changes: 5 additions & 1 deletion server/tokenlogoinfo/logohelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ func buildQueryLogoParams(noCacheTokenMap map[uint32][]string) []*tokenlogo.Quer
var logoParams []*tokenlogo.QueryLogoParam
for k, v := range noCacheTokenMap {
for _, addr := range v {
finalAddr := addr
if addr == ChainNativeTokenAddr {
finalAddr = EmptyStr
}
logoParams = append(logoParams, &tokenlogo.QueryLogoParam{
ChainId: k,
TokenContractAddress: addr,
TokenContractAddress: finalAddr,
})
}
}
Expand Down

0 comments on commit c731f49

Please sign in to comment.