feat(contract-wrappers): export ForwarderWrapperError and ContractWrapperError.SignatureRequestDenied

This commit is contained in:
Brandon Millman 2018-10-17 00:49:48 -07:00
parent 1ba207f1fe
commit b75fe10c79
5 changed files with 28 additions and 1 deletions

View File

@ -37,6 +37,14 @@
"note": "note":
"Removed ContractNotFound errors. Checking for this error was somewhat ineffecient. Relevant methods/functions now return the default error from web3-wrapper, which we feel provides enough information.", "Removed ContractNotFound errors. Checking for this error was somewhat ineffecient. Relevant methods/functions now return the default error from web3-wrapper, which we feel provides enough information.",
"pr": 1105 "pr": 1105
},
{
"note": "Add `ForwarderWrapperError` to public interface",
"pr": 1147
},
{
"note": "Add `ContractWrapperError.SignatureRequestDenied` to public interface",
"pr": 1147
} }
], ],
"timestamp": 1539871071 "timestamp": 1539871071

View File

@ -39,6 +39,7 @@ export { TransactionEncoder } from './utils/transaction_encoder';
export { export {
ContractWrappersError, ContractWrappersError,
ForwarderWrapperError,
IndexedFilterValues, IndexedFilterValues,
BlockRange, BlockRange,
ContractWrappersConfig, ContractWrappersConfig,

View File

@ -18,6 +18,10 @@ export enum ExchangeWrapperError {
AssetDataMismatch = 'ASSET_DATA_MISMATCH', AssetDataMismatch = 'ASSET_DATA_MISMATCH',
} }
export enum ForwarderWrapperError {
CompleteFillFailed = 'COMPLETE_FILL_FAILED',
}
export enum ContractWrappersError { export enum ContractWrappersError {
ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK', ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK',
InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER', InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER',
@ -30,6 +34,7 @@ export enum ContractWrappersError {
SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT', SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT',
ERC721OwnerNotFound = 'ERC_721_OWNER_NOT_FOUND', ERC721OwnerNotFound = 'ERC_721_OWNER_NOT_FOUND',
ERC721NoApproval = 'ERC_721_NO_APPROVAL', ERC721NoApproval = 'ERC_721_NO_APPROVAL',
SignatureRequestDenied = 'SIGNATURE_REQUEST_DENIED',
} }
export enum InternalContractWrappersError { export enum InternalContractWrappersError {

View File

@ -14,4 +14,5 @@ export const constants = {
ZERO_AMOUNT: new BigNumber(0), ZERO_AMOUNT: new BigNumber(0),
ONE_AMOUNT: new BigNumber(1), ONE_AMOUNT: new BigNumber(1),
ETHER_TOKEN_DECIMALS: 18, ETHER_TOKEN_DECIMALS: 18,
METAMASK_DENIED_SIGNATURE_PATTERN: 'MetaMask Tx Signature: User denied transaction signature',
}; };

View File

@ -29,6 +29,14 @@ const schemaErrorTransformer = (error: Error) => {
return 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 * Source: https://stackoverflow.com/a/29837695/3546986
*/ */
@ -87,7 +95,11 @@ const syncErrorHandlerFactory = (errorTransformer: ErrorTransformer) => {
}; };
// _.flow(f, g) = f ∘ g // _.flow(f, g) = f ∘ g
const zeroExErrorTransformer = _.flow(schemaErrorTransformer, contractCallErrorTransformer); const zeroExErrorTransformer = _.flow(
schemaErrorTransformer,
contractCallErrorTransformer,
signatureRequestErrorTransformer,
);
export const decorators = { export const decorators = {
asyncZeroExErrorHandler: asyncErrorHandlerFactory(zeroExErrorTransformer), asyncZeroExErrorHandler: asyncErrorHandlerFactory(zeroExErrorTransformer),