@@ -17,7 +17,7 @@ import (
1717)
1818
1919type Resolver interface {
20- ListSupportedCurrencies () []money.CryptoCurrency
20+ ListSupportedCurrencies (withDeprecated bool ) []money.CryptoCurrency
2121 ListBlockchainCurrencies (blockchain money.Blockchain ) []money.CryptoCurrency
2222 GetCurrencyByTicker (ticker string ) (money.CryptoCurrency , error )
2323 GetNativeCoin (blockchain money.Blockchain ) (money.CryptoCurrency , error )
@@ -138,12 +138,16 @@ func (r *CurrencyResolver) GetCurrencyByBlockchainAndContract(bc money.Blockchai
138138 return money.CryptoCurrency {}, ErrCurrencyNotFound
139139}
140140
141- func (r * CurrencyResolver ) ListSupportedCurrencies () []money.CryptoCurrency {
141+ func (r * CurrencyResolver ) ListSupportedCurrencies (withDeprecated bool ) []money.CryptoCurrency {
142142 r .mu .RLock ()
143143 defer r .mu .RUnlock ()
144144
145145 results := make ([]money.CryptoCurrency , 0 )
146146 for i := range r .currencies {
147+ if r .currencies [i ].Deprecated && ! withDeprecated {
148+ continue
149+ }
150+
147151 results = append (results , r .currencies [i ])
148152 }
149153
@@ -181,6 +185,10 @@ func (r *CurrencyResolver) addCurrency(currency money.CryptoCurrency) {
181185
182186 r .ensureIndices (currency .Blockchain , currency .Ticker )
183187
188+ if currency .Deprecated {
189+ return
190+ }
191+
184192 // add currency to "index"
185193 r.blockchainCurrencies [currency.Blockchain ][currency.Ticker ] = struct {}{}
186194
@@ -281,6 +289,11 @@ func DefaultSetup(s *CurrencyResolver) error {
281289 return err
282290 }
283291
292+ deprecated , err := parseBool (c ["deprecated" ])
293+ if err != nil {
294+ return err
295+ }
296+
284297 ticker := c ["ticker" ]
285298
286299 s .addCurrency (money.CryptoCurrency {
@@ -295,6 +308,7 @@ func DefaultSetup(s *CurrencyResolver) error {
295308 TestTokenContractAddress : testTokenAddr ,
296309 Aliases : aliases ,
297310 Decimals : int64 (decimals ),
311+ Deprecated : deprecated ,
298312 })
299313
300314 s .addMinimalWithdrawal (ticker , minimalWithdrawal )
@@ -372,6 +386,14 @@ func parseUSD(raw string) (money.Money, error) {
372386 return money .FiatFromFloat64 (money .USD , f )
373387}
374388
389+ func parseBool (raw string ) (bool , error ) {
390+ if raw == "" {
391+ return false , nil
392+ }
393+
394+ return strconv .ParseBool (raw )
395+ }
396+
375397func parseAliases (raw string ) []string {
376398 if raw == "" {
377399 return nil
0 commit comments