Expose isValidPresignedSignatureAsync method

This commit is contained in:
Fabio Berger
2018-05-30 17:55:33 -07:00
parent aa997f1be5
commit 0beab9eec4

View File

@@ -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:
@@ -76,6 +74,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`