aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/exchange_wrapper.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-01 22:03:09 +0800
committerFabio Berger <me@fabioberger.com>2017-06-01 22:03:09 +0800
commit88a70afa70f84efc866ff53121d05a6d8d77bff8 (patch)
treee90dd32241ac0b50556497cf8761ff2fe6c4c37b /src/contract_wrappers/exchange_wrapper.ts
parenta685d7604fcd0854ad49df762c4ed5a51cc86065 (diff)
downloaddexon-sol-tools-88a70afa70f84efc866ff53121d05a6d8d77bff8.tar
dexon-sol-tools-88a70afa70f84efc866ff53121d05a6d8d77bff8.tar.gz
dexon-sol-tools-88a70afa70f84efc866ff53121d05a6d8d77bff8.tar.bz2
dexon-sol-tools-88a70afa70f84efc866ff53121d05a6d8d77bff8.tar.lz
dexon-sol-tools-88a70afa70f84efc866ff53121d05a6d8d77bff8.tar.xz
dexon-sol-tools-88a70afa70f84efc866ff53121d05a6d8d77bff8.tar.zst
dexon-sol-tools-88a70afa70f84efc866ff53121d05a6d8d77bff8.zip
Add ExchangeContractErrs string enum
Diffstat (limited to 'src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index bf3f10e28..1232b969b 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -4,6 +4,7 @@ import {
ECSignature,
ExchangeContract,
ExchangeContractErrCodes,
+ ExchangeContractErrs,
FillOrderValidationErrs,
OrderValues,
OrderAddresses,
@@ -21,12 +22,12 @@ import {constants} from '../utils/constants';
export class ExchangeWrapper extends ContractWrapper {
private exchangeContractErrCodesToMsg = {
- [ExchangeContractErrCodes.ERROR_FILL_EXPIRED]: 'The order you attempted to fill is expired',
- [ExchangeContractErrCodes.ERROR_CANCEL_EXPIRED]: 'The order you attempted to cancel is expired',
- [ExchangeContractErrCodes.ERROR_FILL_NO_VALUE]: 'This order has already been filled or cancelled',
- [ExchangeContractErrCodes.ERROR_CANCEL_NO_VALUE]: 'This order has already been filled or cancelled',
- [ExchangeContractErrCodes.ERROR_FILL_TRUNCATION]: 'The rounding error was too large when filling this order',
- [ExchangeContractErrCodes.ERROR_FILL_BALANCE_ALLOWANCE]: 'Maker or taker has insufficient balance or allowance',
+ [ExchangeContractErrCodes.ERROR_FILL_EXPIRED]: ExchangeContractErrs.ORDER_EXPIRED,
+ [ExchangeContractErrCodes.ERROR_CANCEL_EXPIRED]: ExchangeContractErrs.ORDER_EXPIRED,
+ [ExchangeContractErrCodes.ERROR_FILL_NO_VALUE]: ExchangeContractErrs.ORDER_REMAINING_FILL_AMOUNT_ZERO,
+ [ExchangeContractErrCodes.ERROR_CANCEL_NO_VALUE]: ExchangeContractErrs.ORDER_REMAINING_FILL_AMOUNT_ZERO,
+ [ExchangeContractErrCodes.ERROR_FILL_TRUNCATION]: ExchangeContractErrs.ORDER_ROUNDING_ERROR,
+ [ExchangeContractErrCodes.ERROR_FILL_BALANCE_ALLOWANCE]: ExchangeContractErrs.ORDER_BALANCE_ALLOWANCE_ERROR,
};
private exchangeContractIfExists?: ExchangeContract;
constructor(web3Wrapper: Web3Wrapper) {
@@ -131,8 +132,8 @@ export class ExchangeWrapper extends ContractWrapper {
const errEvent = _.find(logs, {event: 'LogError'});
if (!_.isUndefined(errEvent)) {
const errCode = errEvent.args.errorId.toNumber();
- const humanReadableErrMessage = this.exchangeContractErrCodesToMsg[errCode];
- throw new Error(humanReadableErrMessage);
+ const errMessage = this.exchangeContractErrCodesToMsg[errCode];
+ throw new Error(errMessage);
}
}
private async getExchangeContractAsync(): Promise<ExchangeContract> {