]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/commitdiff
Handle poloniex ip restriction.
authorjloup <jeanloup.jamet@gmail.com>
Mon, 26 Mar 2018 08:54:48 +0000 (10:54 +0200)
committerjloup <jeanloup.jamet@gmail.com>
Mon, 26 Mar 2018 08:55:40 +0000 (10:55 +0200)
api/const.go
api/const_string.go
cmd/web/js/poloniex.jsx
markets/poloniex.go

index 1b22355d23d213e01e11d2db9ccb663ee73fd5d4..d3e5f42a485a27ced0feff2a89611686e1a23f59 100644 (file)
@@ -19,6 +19,7 @@ const (
        InvalidCredentials
        InvalidEmail
        InvalidMarketCredentials
+       IPRestrictedApiKey
        InvalidOtp
        InvalidPassword
        NeedOtpValidation
@@ -35,7 +36,7 @@ func StatusToHttpCode(status Status, code ErrorCode) int {
        }
 
        switch code {
-       case BadRequest, InvalidPassword, InvalidEmail, InvalidMarketCredentials:
+       case BadRequest, InvalidPassword, InvalidEmail, InvalidMarketCredentials, IPRestrictedApiKey:
                return http.StatusBadRequest
 
        case InvalidCredentials, InvalidOtp:
index e4b9e507421d386728072c2ff9e84e3b9390d009..58ed230aeb47795c1896c199fac582eeb922fe1f 100644 (file)
@@ -15,9 +15,9 @@ func (i Status) String() string {
        return _Status_name[_Status_index[i]:_Status_index[i+1]]
 }
 
-const _ErrorCode_name = "BadRequestEmailExistsExternalServiceTimeoutInternalErrorInvalidCredentialsInvalidEmailInvalidMarketCredentialsInvalidOtpInvalidPasswordNeedOtpValidationNotAuthorizedNotFoundOtpAlreadySetupOtpNotSetupUserNotConfirmed"
+const _ErrorCode_name = "BadRequestEmailExistsExternalServiceTimeoutInternalErrorInvalidCredentialsInvalidEmailInvalidMarketCredentialsIPRestrictedApiKeyInvalidOtpInvalidPasswordNeedOtpValidationNotAuthorizedNotFoundOtpAlreadySetupOtpNotSetupUserNotConfirmed"
 
-var _ErrorCode_index = [...]uint8{0, 10, 21, 43, 56, 74, 86, 110, 120, 135, 152, 165, 173, 188, 199, 215}
+var _ErrorCode_index = [...]uint8{0, 10, 21, 43, 56, 74, 86, 110, 128, 138, 153, 170, 183, 191, 206, 217, 233}
 
 func (i ErrorCode) String() string {
        i -= 3
index 482dbb6c9b437ca2f0bf2af7e93ed2378810ff55..813a506a60d9af3e7a03426b4a1cd3577c32c08f 100644 (file)
@@ -32,6 +32,8 @@ class PoloniexController extends React.Component {
         console.error(err, data);
         if (err.code === 'invalid_market_credentials') {
           this.setState({'flag': 'invalidCredentials', 'valueCurrency': null, 'balanceValue': null, 'balance': null});
+        } else if (err.code === 'ip_restricted_api_key') {
+          this.setState({'flag': 'ipRestricted', 'valueCurrency': null, 'balanceValue': null, 'balance': null});
         }
         return;
       }
@@ -68,6 +70,9 @@ class PoloniexController extends React.Component {
       case 'invalidCredentials':
         displayText = 'Invalid poloniex credentials';
         break;
+      case 'ipRestricted':
+        displayText = 'Your API key is IP restricted. Please whitelist us.';
+        break;
       case 'emptyCredentials':
         displayText = 'Please provide poloniex credentials';
         break;
index 5e1ec6473f3eb6ce3adfef00e69cbda1c269bb4d..34ebb7eaf5e296bd9d550118d18428b18ccd4155 100644 (file)
@@ -13,6 +13,7 @@ var (
        ErrorFlagCounter        utils.Counter = 0
        CurrencyPairNotInTicker               = utils.InitFlag(&ErrorFlagCounter, "CurrencyPairNotInTicker")
        InvalidCredentials                    = utils.InitFlag(&ErrorFlagCounter, "InvalidCredentials")
+       IPRestricted                          = utils.InitFlag(&ErrorFlagCounter, "IPRestricted")
 )
 
 func poloniexInvalidCredentialsError(err error) bool {
@@ -22,6 +23,13 @@ func poloniexInvalidCredentialsError(err error) bool {
        return strings.Contains(err.Error(), "Invalid API key/secret pair")
 }
 
+func poloniexRestrictedIPError(err error) bool {
+       if err == nil {
+               return false
+       }
+       return strings.Contains(err.Error(), "Permission denied")
+}
+
 type CurrencyPair struct {
        Name string
        Rate decimal.Decimal