aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/utils
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-10-17 15:49:48 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-10-23 13:44:13 +0800
commitb75fe10c790a60c875914a2a79ae8c4761b78bb9 (patch)
treec0ee1119fd31951b625aadb67fde085d040a4baf /packages/contract-wrappers/src/utils
parent1ba207f1fef4338682b4cc7e45af8c073e63d263 (diff)
downloaddexon-sol-tools-b75fe10c790a60c875914a2a79ae8c4761b78bb9.tar
dexon-sol-tools-b75fe10c790a60c875914a2a79ae8c4761b78bb9.tar.gz
dexon-sol-tools-b75fe10c790a60c875914a2a79ae8c4761b78bb9.tar.bz2
dexon-sol-tools-b75fe10c790a60c875914a2a79ae8c4761b78bb9.tar.lz
dexon-sol-tools-b75fe10c790a60c875914a2a79ae8c4761b78bb9.tar.xz
dexon-sol-tools-b75fe10c790a60c875914a2a79ae8c4761b78bb9.tar.zst
dexon-sol-tools-b75fe10c790a60c875914a2a79ae8c4761b78bb9.zip
feat(contract-wrappers): export ForwarderWrapperError and ContractWrapperError.SignatureRequestDenied
Diffstat (limited to 'packages/contract-wrappers/src/utils')
-rw-r--r--packages/contract-wrappers/src/utils/constants.ts1
-rw-r--r--packages/contract-wrappers/src/utils/decorators.ts14
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..b89438592 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,
+ METAMASK_DENIED_SIGNATURE_PATTERN: 'MetaMask Tx Signature: User denied transaction signature',
};
diff --git a/packages/contract-wrappers/src/utils/decorators.ts b/packages/contract-wrappers/src/utils/decorators.ts
index e17246015..932b11785 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.METAMASK_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),