Skip to content

Commit

Permalink
Merge pull request #15 from XPRNetwork/protondex
Browse files Browse the repository at this point in the history
improve logging in createorder
  • Loading branch information
pbatmetal authored Dec 6, 2023
2 parents 67e0ff2 + 55af66b commit f0c460f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ts/src/protondex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Exchange from './abstract/protondex.js';
import { TICK_SIZE } from './base/functions/number.js';
import { ExchangeError, ArgumentsRequired, InsufficientFunds, OrderNotFound } from './base/errors.js';
import { ExchangeError, ArgumentsRequired, InsufficientFunds, OrderNotFound, BadRequest } from './base/errors.js';
import { Precise } from './base/Precise.js';
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
import { ripemd160 } from './static_dependencies/noble-hashes/ripemd160.js';
Expand Down Expand Up @@ -1539,18 +1539,21 @@ export default class protondex extends Exchange {
orderDetails['price'] = (orderDetails['price'] / Math.pow (10, askTokenPrecision));
retries = 0;
} catch (e) {
if (this.last_json_response.error.details[0]) {
if (this.last_json_response) {
if (JSON.stringify (this.last_json_response.error) === '{}' || JSON.stringify (this.last_json_response.error.details) === '{}') {
throw this.last_json_response;
}
const message = this.safeString (this.last_json_response.error.details[0], 'message');
if (message === 'is_canonical( c ): signature is not canonical') {
--retries;
} else {
if (message === 'assertion failure with message: overdrawn balance') {
throw new InsufficientFunds ('- Add funds to the account');
}
retries = 0;
throw new BadRequest (message);
}
} else {
throw e;
retries = 0;
}
if (!retries) {
throw e;
Expand Down

0 comments on commit f0c460f

Please sign in to comment.