diff options
-rw-r--r-- | packages/order-utils/src/signature_utils.ts | 22 |
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. |