This commit is contained in:
aozhiwei 2024-06-16 18:28:38 +08:00
parent 38460a1465
commit 9742748b9c

View File

@ -89,11 +89,14 @@ func (this *cacheMgr) batchGetNfts(nfts []*common.NftDto) {
rspObj := struct {
ErrCode interface{} `json:"errcode"`
ErrMsg string `json:"errmsg"`
Nfts []map[string]interface{} `json:"nfts"`
/*
Nfts [] struct {
NetId interface{} `json:"errmsg"`
ContractAddress string `json:"contract_address"`
TokenId interface{} `json:"token_id"`
} `json:"nfts"`
*/
}{}
params := struct {
Nfts []struct {
@ -118,17 +121,32 @@ func (this *cacheMgr) batchGetNfts(nfts []*common.NftDto) {
}
if rsp.JsonParseOk() {
for _, val := range rspObj.Nfts {
netId := q5.SafeToInt32(val.NetId)
contractAddress := q5.ToString(val.ContractAddress)
tokenId := q5.SafeToString(val.TokenId)
for _, val2 := range nfts {
if val2.NetId == netId &&
val2.ContractAddress == contractAddress &&
val2.TokenId == tokenId {
}
var netId int32
var contractAddress string
var tokenId string
if p, ok := val["net_id"]; ok {
netId = q5.SafeToInt32(p)
} else {
continue
}
if p, ok := val["contract_address"]; ok {
contractAddress = q5.SafeToString(p)
} else {
continue
}
if p, ok := val["token_id"]; ok {
tokenId = q5.SafeToString(p)
} else {
continue
}
this.addNft(netId, contractAddress, tokenId)
}
}
})
}
func (this *cacheMgr) addNft(netId int32, contractAddress string, tokenId string) {
dto := new(common.NftDto)
p := newNft()
this.nftHash.Store(dto.GetKey(), p)
}