Skip to content

Commit

Permalink
better method
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Damer committed Oct 11, 2023
1 parent e037fb2 commit c752133
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/controllers/verify-ketl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,21 @@ export default class VerifyKetlController {
async multipleBalanceAttestationSimplified(
@Ctx() ctx: Context,
@Body({ required: true })
{
message,
ownerAddress,
signature,
types,
}: OwnerAddress & Signature & AttestationTypeList
body: OwnerAddress & Signature & AttestationTypeList
) {
const signerAddress = ethers.utils
.verifyMessage(message, signature)
.toLowerCase()
const { message, ownerAddress, signature, types } = body
let signerAddress: string

if (signerAddress.toLowerCase() !== ownerAddress.toLowerCase()) {
try {
signerAddress = ethers.utils
.verifyMessage(message, signature)
.toLowerCase()

if (signerAddress.toLowerCase() !== ownerAddress.toLowerCase()) {
return ctx.throw(badRequest('Invalid ownerAddress'))
}
} catch (e) {
console.error(e)
return ctx.throw(badRequest('Invalid ownerAddress'))
}

Expand All @@ -202,12 +205,14 @@ export default class VerifyKetlController {
const hasInvite = await checkInvite(type, attestationHash)
if (hasInvite) attestations.push(record)
} catch (e) {
console.log(e)
console.error(e)
}
}
}

if (!attestations.length)
return ctx.throw(notFound(handleInvitationError('wallet')))

return Promise.all(attestations)
}

Expand Down

0 comments on commit c752133

Please sign in to comment.