Closed vuon9 closed 3 years ago
I didn't even know about this openlink functionality! (though miguel referred to it, when we were talking about right-mouse buttons once).
Rather than adding slug to Coin, couldn't we pass the whole Coin to the api method, and let it use whatever it wants?
Rather than adding slug to Coin, couldn't we pass the whole Coin to the api method, and let it use whatever it wants?
Sorry, which api method?
I was suggesting that the interface method could be
CoinLink(coin Coin) string
Then the implementations could use whichever attribute(s) of Coin they felt like, and not have to pre-emptively squash it into a string called Slug.
coingecko.go: func (s *Service) CoinLink(coin Coin) string { return fmt.Sprintf("https://www.coingecko.com/en/coins/%s", coin.ID) }
coinmarketcap.go: func (s *Service) CoinLink(coin Coin) string { return fmt.Sprintf("https://www.coingecko.com/en/coins/%s", coin.ID) // ID? slug? }
(cmc currently uses v.Name for coin.ID which seems possibly wrong?)
Understood your point now. Actually, I came with it previously, but I have changed to the string for a simple & enough type as current. If we need more than 1 parameter for CoinLink, can switch to use the whole Coin pointer later. For now, I think that's fine to keep as string. In any way, we still have to store Slug value for at least Coinmarketcap, so I think a separated field is better than reuse ID field of Coin struct.
(cmc currently uses v.Name for coin.ID which seems possibly wrong?)
I don't have a conclusion because Coingecko and Coinmarketcap has different type for id field, so may be Coin struct can be free to define its own ID, as long as it still works well. I mean it could be change if we found the limitation.
(cmc currently uses v.Name for coin.ID which seems possibly wrong?)
I don't have a conclusion because Coingecko and Coinmarketcap has different type for id field, so may be Coin struct can be free to define its own ID, as long as it still works well. I mean it could be change if we found the limitation.
This just looks wrong to me:
ret = append(ret, apitypes.Coin{
ID: util.FormatID(v.Name),
Name: util.FormatName(v.Name),
...
Especially when v.Name is not guaranteed to be unique?
I agree. I think this PR is tiny PR for just open link problem. The ID, I worry it relates to so many flows to be fixing. I created another issue for it https://github.com/cointop-sh/cointop/issues/279
FWIW on Coingecko it opens https://www.coingecko.com/en/coins/concierge-io which redirects to https://www.coingecko.com/en/coins/travala but I don't think we can do any better there
Currently, some links couldn't be open correctly on one (or both) Coingecko, Coinmarketcap websites:
Dogecoin
) is similar to the symbol of the Buff Doge Coin (symbol:DOGECOIN
).CoinLink
method is using a regex to replace non Alpha numeric chars to dash. So the original name is "Travala.com" and the converted name is "travala-com" -> unable to use. https://github.com/cointop-sh/cointop/blob/8b8db3bd13c366a9657434af71b61400e6b01ad9/pkg/api/util/util.go#L12-L15 shouldn't change the regex because it will impact to yearn.finance coin (it only works with "yearn-finance" slug on Coingecko).Seems both Coingecko and Coinmarketcap supported slug, please see the below. This PR is about switching to use slug instead of name.
Coingecko supports
id
it is equivalent to
API id
on the UICoinmarketcap supports
slug