aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2018-10-09 17:58:30 +0800
committerJacob Evans <jacob@dekz.net>2018-10-09 17:58:30 +0800
commit75b9e639194e98febf8e378619afef2d578cbc7e (patch)
treea46866ab1aa613f21c8ecdd5b1e1b117364a1cb2
parent7f554303b4333b083102eb17cd9acb6f6b73cc75 (diff)
downloaddexon-sol-tools-75b9e639194e98febf8e378619afef2d578cbc7e.tar.gz
dexon-sol-tools-75b9e639194e98febf8e378619afef2d578cbc7e.tar.zst
dexon-sol-tools-75b9e639194e98febf8e378619afef2d578cbc7e.zip
Move Metamask Error to OrderErrors
-rw-r--r--packages/order-utils/CHANGELOG.json7
-rw-r--r--packages/order-utils/src/signature_utils.ts11
-rw-r--r--packages/order-utils/src/types.ts1
3 files changed, 9 insertions, 10 deletions
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json
index 2555ad350..5a0c0db47 100644
--- a/packages/order-utils/CHANGELOG.json
+++ b/packages/order-utils/CHANGELOG.json
@@ -3,15 +3,16 @@
"version": "2.0.0",
"changes": [
{
- "note": "Added `ecSignOrderAsync` to first sign an order as EIP712 and fallback to EthSign",
+ "note":
+ "Added `ecSignOrderAsync` to first sign an order using `eth_signTypedData` and fallback to `eth_sign`.",
"pr": 1102
},
{
- "note": "Added `ecSignTypedDataOrderAsync` to sign an order exclusively as EIP712",
+ "note": "Added `ecSignTypedDataOrderAsync` to sign an order exclusively using `eth_signTypedData`.",
"pr": 1102
},
{
- "note": "Rename `ecSignOrderHashAsync` to `ecSignHashAsync` removing `SignerType` parameter",
+ "note": "Rename `ecSignOrderHashAsync` to `ecSignHashAsync` removing `SignerType` parameter.",
"pr": 1102
}
]
diff --git a/packages/order-utils/src/signature_utils.ts b/packages/order-utils/src/signature_utils.ts
index 2605ccd32..372d210d0 100644
--- a/packages/order-utils/src/signature_utils.ts
+++ b/packages/order-utils/src/signature_utils.ts
@@ -210,7 +210,8 @@ export const signatureUtils = {
// HACK: We are unable to handle specific errors thrown since provider is not an object
// under our control. It could be Metamask Web3, Ethers, or any general RPC provider.
// We check for a user denying the signature request in a way that supports Metamask and
- // Coinbase Wallet
+ // Coinbase Wallet. Unfortunately for signers with a different error message,
+ // they will receive two signature requests.
if (err.message.includes('User denied message signature')) {
throw err;
}
@@ -255,9 +256,7 @@ export const signatureUtils = {
} catch (err) {
// Detect if Metamask to transition users to the MetamaskSubprovider
if ((provider as any).isMetaMask) {
- throw new Error(
- `MetaMask provider must be wrapped in a MetamaskSubprovider (from the '@0xproject/subproviders' package) in order to work with this method.`,
- );
+ throw new Error(OrderError.InvalidMetamaskSigner);
} else {
throw err;
}
@@ -313,9 +312,7 @@ export const signatureUtils = {
}
// Detect if Metamask to transition users to the MetamaskSubprovider
if ((provider as any).isMetaMask) {
- throw new Error(
- `MetaMask provider must be wrapped in a MetamaskSubprovider (from the '@0xproject/subproviders' package) in order to work with this method.`,
- );
+ throw new Error(OrderError.InvalidMetamaskSigner);
} else {
throw new Error(OrderError.InvalidSignature);
}
diff --git a/packages/order-utils/src/types.ts b/packages/order-utils/src/types.ts
index 80075270e..5b13dd754 100644
--- a/packages/order-utils/src/types.ts
+++ b/packages/order-utils/src/types.ts
@@ -2,6 +2,7 @@ import { BigNumber } from '@0xproject/utils';
export enum OrderError {
InvalidSignature = 'INVALID_SIGNATURE',
+ InvalidMetamaskSigner = "MetaMask provider must be wrapped in a MetamaskSubprovider (from the '@0xproject/subproviders' package) in order to work with this method.",
}
export enum TradeSide {