Usar id correcta en OpenSea para evitar colisiones
All checks were successful
continuous-integration/woodpecker the build was successful

This commit is contained in:
Cat /dev/Nulo 2021-11-10 11:05:45 -03:00
parent 31d7775c21
commit b3f6b48d70
2 changed files with 5 additions and 2 deletions

View file

@ -88,7 +88,7 @@ func getRandomOpenSeaAsset() (Asset, error) {
if len(a.ImageUrl) == 0 { if len(a.ImageUrl) == 0 {
continue continue
} }
id := getOpenSeaId(a.TokenId) id := getOpenSeaId(a.Id)
file, err := os.Open(filepath.Join(NFTS_DIR, id)) file, err := os.Open(filepath.Join(NFTS_DIR, id))
defer file.Close() defer file.Close()
if errors.Is(err, fs.ErrNotExist) { if errors.Is(err, fs.ErrNotExist) {
@ -114,7 +114,7 @@ func (d downloadedOpenSeaAsset) IsVideo() bool {
} }
func downloadOpenSeaAsset(asset Asset, transaction Transaction) (string, error) { func downloadOpenSeaAsset(asset Asset, transaction Transaction) (string, error) {
id := getOpenSeaId(asset.TokenId) id := getOpenSeaId(asset.Id)
u, err := url.Parse(asset.ImageUrl) u, err := url.Parse(asset.ImageUrl)
if err != nil { if err != nil {

View file

@ -8,6 +8,7 @@ import (
// https://docs.opensea.io/reference/asset-object // https://docs.opensea.io/reference/asset-object
type Asset struct { type Asset struct {
Id string
TokenId string TokenId string
Permalink string Permalink string
ImageUrl string ImageUrl string
@ -26,6 +27,7 @@ type Assets []Asset
func GetAssets() (Assets, error) { func GetAssets() (Assets, error) {
parsed := struct { parsed := struct {
Assets []struct { Assets []struct {
Id uint64 `json:"id"`
TokenId string `json:"token_id"` TokenId string `json:"token_id"`
Permalink string `json:"permalink"` Permalink string `json:"permalink"`
ImageUrl string `json:"image_url"` ImageUrl string `json:"image_url"`
@ -59,6 +61,7 @@ func GetAssets() (Assets, error) {
return assets, err return assets, err
} }
assets = append(assets, Asset{ assets = append(assets, Asset{
Id: strconv.FormatUint(a.Id, 10),
TokenId: a.TokenId, TokenId: a.TokenId,
Permalink: a.Permalink, Permalink: a.Permalink,
ImageUrl: a.ImageUrl, ImageUrl: a.ImageUrl,