mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
* Config: Move config versions to separate pacakges * Config: Move version tests to blackbox texts * Config: Protect registerVersion from overflow * Config: Protect against version already registered
30 lines
914 B
Go
30 lines
914 B
Go
package v2
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/buger/jsonparser"
|
|
)
|
|
|
|
// Version is an ExchangeVersion to change the name of GDAX to CoinbasePro
|
|
type Version struct{}
|
|
|
|
// Exchanges returns just GDAX and CoinbasePro
|
|
func (*Version) Exchanges() []string { return []string{"GDAX", "CoinbasePro"} }
|
|
|
|
// UpgradeExchange will change the exchange name from GDAX to CoinbasePro
|
|
func (*Version) UpgradeExchange(_ context.Context, e []byte) ([]byte, error) {
|
|
if n, err := jsonparser.GetString(e, "name"); err == nil && n == "GDAX" {
|
|
return jsonparser.Set(e, []byte(`"CoinbasePro"`), "name")
|
|
}
|
|
return e, nil
|
|
}
|
|
|
|
// DowngradeExchange will change the exchange name from CoinbasePro to GDAX
|
|
func (*Version) DowngradeExchange(_ context.Context, e []byte) ([]byte, error) {
|
|
if n, err := jsonparser.GetString(e, "name"); err == nil && n == "CoinbasePro" {
|
|
return jsonparser.Set(e, []byte(`"GDAX"`), "name")
|
|
}
|
|
return e, nil
|
|
}
|