Skip to content

Commit

Permalink
gctcli: remove all exchange name client-side validation (thrasher-cor…
Browse files Browse the repository at this point in the history
…p#758)

* gctcli: remove all exchange name client-side validation

Since now exchange names can be user-assigned we can no longer have
client-side validation, all exchange name validation must now occur
on the server (it was already doing that).

* engine: add server side exchange name check on some RPCs
  • Loading branch information
lrascao authored Aug 23, 2021
1 parent a15cbf6 commit 9bb4348
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 206 deletions.
126 changes: 0 additions & 126 deletions cmd/gctcli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@ func enableExchange(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

conn, err := setupClient()
if err != nil {
return err
Expand Down Expand Up @@ -341,10 +337,6 @@ func disableExchange(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

conn, err := setupClient()
if err != nil {
return err
Expand Down Expand Up @@ -391,10 +383,6 @@ func getExchangeOTPCode(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

conn, err := setupClient()
if err != nil {
return err
Expand Down Expand Up @@ -466,10 +454,6 @@ func getExchangeInfo(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

conn, err := setupClient()
if err != nil {
return err
Expand Down Expand Up @@ -527,10 +511,6 @@ func getTicker(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("pair") {
currencyPair = c.String("pair")
} else {
Expand Down Expand Up @@ -643,10 +623,6 @@ func getOrderbook(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("pair") {
currencyPair = c.String("pair")
} else {
Expand Down Expand Up @@ -758,10 +734,6 @@ func getAccountInfo(c *cli.Context) error {
assetType = c.Args().Get(1)
}

if !validExchange(exchange) {
return errInvalidExchange
}

if !validAsset(assetType) {
return errInvalidAsset
}
Expand Down Expand Up @@ -824,10 +796,6 @@ func getAccountInfoStream(c *cli.Context) error {
assetType = c.Args().Get(1)
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if !validAsset(assetType) {
return errInvalidAsset
}
Expand Down Expand Up @@ -898,10 +866,6 @@ func updateAccountInfo(c *cli.Context) error {
assetType = c.Args().Get(1)
}

if !validExchange(exchange) {
return errInvalidExchange
}

if !validAsset(assetType) {
return errInvalidAsset
}
Expand Down Expand Up @@ -1274,10 +1238,6 @@ func getOrders(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("asset") {
assetType = c.String("asset")
} else {
Expand Down Expand Up @@ -1392,10 +1352,6 @@ func getManagedOrders(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("asset") {
assetType = c.String("asset")
} else {
Expand Down Expand Up @@ -1487,10 +1443,6 @@ func getOrder(c *cli.Context) error {
} else {
exchangeName = c.Args().First()
}
if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("asset") {
assetType = c.String("asset")
} else {
Expand Down Expand Up @@ -1607,10 +1559,6 @@ func submitOrder(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("pair") {
currencyPair = c.String("pair")
} else {
Expand Down Expand Up @@ -1758,10 +1706,6 @@ func simulateOrder(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("pair") {
currencyPair = c.String("pair")
} else {
Expand Down Expand Up @@ -1867,10 +1811,6 @@ func whaleBomb(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("pair") {
currencyPair = c.String("pair")
} else {
Expand Down Expand Up @@ -1987,10 +1927,6 @@ func cancelOrder(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("account_id") {
accountID = c.String("account_id")
} else {
Expand Down Expand Up @@ -2133,10 +2069,6 @@ func cancelBatchOrders(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("account_id") {
accountID = c.String("account_id")
} else {
Expand Down Expand Up @@ -2277,13 +2209,6 @@ func cancelAllOrders(c *cli.Context) error {
exchangeName = c.Args().First()
}

// exchange name is an optional param
if exchangeName != "" {
if !validExchange(exchangeName) {
return errInvalidExchange
}
}

conn, err := setupClient()
if err != nil {
return err
Expand Down Expand Up @@ -2318,9 +2243,6 @@ func modifyOrder(c *cli.Context) error {
} else {
exchangeName = c.Args().First()
}
if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("asset") {
assetType = c.String("asset")
Expand Down Expand Up @@ -2488,10 +2410,6 @@ func addEvent(c *cli.Context) error {
return fmt.Errorf("exchange name is required")
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("item") {
item = c.String("item")
} else {
Expand Down Expand Up @@ -2658,10 +2576,6 @@ func getCryptocurrencyDepositAddresses(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

conn, err := setupClient()
if err != nil {
return err
Expand Down Expand Up @@ -2710,10 +2624,6 @@ func getCryptocurrencyDepositAddress(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("cryptocurrency") {
cryptocurrency = c.String("cryptocurrency")
} else if c.Args().Get(1) != "" {
Expand Down Expand Up @@ -2796,10 +2706,6 @@ func withdrawCryptocurrencyFunds(c *cli.Context) error {
exchange = c.Args().Get(0)
}

if !validExchange(exchange) {
return errInvalidExchange
}

if c.IsSet("currency") {
cur = c.String("currency")
} else if c.Args().Get(1) != "" {
Expand Down Expand Up @@ -2911,10 +2817,6 @@ func withdrawFiatFunds(c *cli.Context) error {
exchange = c.Args().Get(0)
}

if !validExchange(exchange) {
return errInvalidExchange
}

if c.IsSet("currency") {
cur = c.String("currency")
} else if c.Args().Get(1) != "" {
Expand Down Expand Up @@ -3380,10 +3282,6 @@ func getOrderbookStream(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("pair") {
pair = c.String("pair")
} else {
Expand Down Expand Up @@ -3516,10 +3414,6 @@ func getExchangeOrderbookStream(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

conn, err := setupClient()
if err != nil {
return err
Expand Down Expand Up @@ -3589,10 +3483,6 @@ func getTickerStream(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

if c.IsSet("pair") {
pair = c.String("pair")
} else {
Expand Down Expand Up @@ -3695,10 +3585,6 @@ func getExchangeTickerStream(c *cli.Context) error {
exchangeName = c.Args().First()
}

if !validExchange(exchangeName) {
return errInvalidExchange
}

conn, err := setupClient()
if err != nil {
return err
Expand Down Expand Up @@ -4330,10 +4216,6 @@ func getHistoricCandles(c *cli.Context) error {
} else {
exchangeName = c.Args().First()
}
if !validExchange(exchangeName) {
return errInvalidExchange
}

var currencyPair string
if c.IsSet("pair") {
currencyPair = c.String("pair")
Expand Down Expand Up @@ -4489,10 +4371,6 @@ func getHistoricCandlesExtended(c *cli.Context) error {
} else {
exchangeName = c.Args().First()
}
if !validExchange(exchangeName) {
return errInvalidExchange
}

var currencyPair string
if c.IsSet("pair") {
currencyPair = c.String("pair")
Expand Down Expand Up @@ -4668,10 +4546,6 @@ func findMissingSavedCandleIntervals(c *cli.Context) error {
} else {
exchangeName = c.Args().First()
}
if !validExchange(exchangeName) {
return errInvalidExchange
}

var currencyPair string
if c.IsSet("pair") {
currencyPair = c.String("pair")
Expand Down
3 changes: 0 additions & 3 deletions cmd/gctcli/data_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,6 @@ func upsertDataHistoryJob(c *cli.Context) error {
if c.IsSet("exchange") {
exchange = c.String("exchange")
}
if !validExchange(exchange) {
return errInvalidExchange
}

if c.IsSet("asset") {
assetType = c.String("asset")
Expand Down
Loading

0 comments on commit 9bb4348

Please sign in to comment.