Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const checkOrderSignature = async (order, provider, errors) => {
// Check signature is valid
const isValid = signatures.isSignatureValid(order)
if (!isValid) {
errors.push('Signature invalid')
}
// Check signer authorized signatory
if (order['signature']['signatory'] !== order['signer']['wallet']) {
const swapContract = new ethers.Contract(
order['signature']['validator'],
Swap.abi,
provider
)
await swapContract
.signerAuthorizations(
order['signer']['wallet'],
order['signature']['signatory']
)
.then(isAuthorized => {
if (!isAuthorized) {
errors.push(`Signatory not authorized`)
}
})
}
return errors
}