Expose isValidPresignedSignatureAsync method
This commit is contained in:
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user