aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-31 08:55:33 +0800
committerFabio Berger <me@fabioberger.com>2018-05-31 08:55:33 +0800
commit0beab9eec45508fb6163bd6c0fd3970f0b61a91d (patch)
tree0cdbd0aaef26ade3382612044c0a152fea9e620d
parentaa997f1be516f15e103cb9a3de9090764d6c5f1c (diff)
downloaddexon-sol-tools-0beab9eec45508fb6163bd6c0fd3970f0b61a91d.tar
dexon-sol-tools-0beab9eec45508fb6163bd6c0fd3970f0b61a91d.tar.gz
dexon-sol-tools-0beab9eec45508fb6163bd6c0fd3970f0b61a91d.tar.bz2
dexon-sol-tools-0beab9eec45508fb6163bd6c0fd3970f0b61a91d.tar.lz
dexon-sol-tools-0beab9eec45508fb6163bd6c0fd3970f0b61a91d.tar.xz
dexon-sol-tools-0beab9eec45508fb6163bd6c0fd3970f0b61a91d.tar.zst
dexon-sol-tools-0beab9eec45508fb6163bd6c0fd3970f0b61a91d.zip
Expose isValidPresignedSignatureAsync method
-rw-r--r--packages/order-utils/src/signature_utils.ts22
1 files changed, 19 insertions, 3 deletions
diff --git a/packages/order-utils/src/signature_utils.ts b/packages/order-utils/src/signature_utils.ts
index 70637e2ac..f1466973c 100644
--- a/packages/order-utils/src/signature_utils.ts
+++ b/packages/order-utils/src/signature_utils.ts
@@ -66,9 +66,7 @@ export async function isValidSignatureAsync(
}
case SignatureType.PreSigned: {
- const exchangeContract = new ExchangeContract(artifacts.Exchange.abi, signerAddress, provider);
- const isValid = await exchangeContract.preSigned.callAsync(data, signerAddress);
- return true;
+ return isValidPresignedSignatureAsync(provider, data, signature, signerAddress);
}
default:
@@ -77,6 +75,24 @@ export async function isValidSignatureAsync(
}
/**
+ * Verifies that the provided presigned signature is valid according to the 0x Protocol smart contracts
+ * @param data The hex encoded data signed by the supplied signature.
+ * @param signature A hex encoded presigned 0x Protocol signature made up of: [SignatureType.Presigned]
+ * @param signerAddress The hex encoded address that signed the data, producing the supplied signature.
+ * @return Whether the data was preSigned by the supplied signerAddress.
+ */
+export async function isValidPresignedSignatureAsync(
+ provider: Provider,
+ data: string,
+ signature: string,
+ signerAddress: string,
+): Promise<boolean> {
+ const exchangeContract = new ExchangeContract(artifacts.Exchange.abi, signerAddress, provider);
+ const isValid = await exchangeContract.preSigned.callAsync(data, signerAddress);
+ return isValid;
+}
+
+/**
* Checks if the supplied elliptic curve signature corresponds to signing `data` with
* the private key corresponding to `signerAddress`
* @param data The hex encoded data signed by the supplied signature.