diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-24 08:15:23 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-24 08:15:23 +0800 |
commit | 3cd9f40e63d82c983ce10963c62432c87808f993 (patch) | |
tree | 471b1aa39da8ee36f27e6d21978a8cd1c52cf048 /packages/contract-wrappers/src/utils | |
parent | a766d78706cb45336263388360584390fe0e62f2 (diff) | |
parent | 4a72dc6c6f0825232d61e470f5b7975aec2e5c0e (diff) | |
download | dexon-sol-tools-3cd9f40e63d82c983ce10963c62432c87808f993.tar dexon-sol-tools-3cd9f40e63d82c983ce10963c62432c87808f993.tar.gz dexon-sol-tools-3cd9f40e63d82c983ce10963c62432c87808f993.tar.bz2 dexon-sol-tools-3cd9f40e63d82c983ce10963c62432c87808f993.tar.lz dexon-sol-tools-3cd9f40e63d82c983ce10963c62432c87808f993.tar.xz dexon-sol-tools-3cd9f40e63d82c983ce10963c62432c87808f993.tar.zst dexon-sol-tools-3cd9f40e63d82c983ce10963c62432c87808f993.zip |
Merge branch 'development' into feature/instant/failure-state
Diffstat (limited to 'packages/contract-wrappers/src/utils')
-rw-r--r-- | packages/contract-wrappers/src/utils/constants.ts | 1 | ||||
-rw-r--r-- | packages/contract-wrappers/src/utils/decorators.ts | 14 |
2 files changed, 14 insertions, 1 deletions
diff --git a/packages/contract-wrappers/src/utils/constants.ts b/packages/contract-wrappers/src/utils/constants.ts index 9ff61f62a..c587ba526 100644 --- a/packages/contract-wrappers/src/utils/constants.ts +++ b/packages/contract-wrappers/src/utils/constants.ts @@ -14,4 +14,5 @@ export const constants = { ZERO_AMOUNT: new BigNumber(0), ONE_AMOUNT: new BigNumber(1), ETHER_TOKEN_DECIMALS: 18, + USER_DENIED_SIGNATURE_PATTERN: 'User denied transaction signature', }; diff --git a/packages/contract-wrappers/src/utils/decorators.ts b/packages/contract-wrappers/src/utils/decorators.ts index e17246015..a4207ae4c 100644 --- a/packages/contract-wrappers/src/utils/decorators.ts +++ b/packages/contract-wrappers/src/utils/decorators.ts @@ -29,6 +29,14 @@ const schemaErrorTransformer = (error: Error) => { return error; }; +const signatureRequestErrorTransformer = (error: Error) => { + if (_.includes(error.message, constants.USER_DENIED_SIGNATURE_PATTERN)) { + const errMsg = ContractWrappersError.SignatureRequestDenied; + return new Error(errMsg); + } + return error; +}; + /** * Source: https://stackoverflow.com/a/29837695/3546986 */ @@ -87,7 +95,11 @@ const syncErrorHandlerFactory = (errorTransformer: ErrorTransformer) => { }; // _.flow(f, g) = f ∘ g -const zeroExErrorTransformer = _.flow(schemaErrorTransformer, contractCallErrorTransformer); +const zeroExErrorTransformer = _.flow( + schemaErrorTransformer, + contractCallErrorTransformer, + signatureRequestErrorTransformer, +); export const decorators = { asyncZeroExErrorHandler: asyncErrorHandlerFactory(zeroExErrorTransformer), |