Skip to content

Commit

Permalink
allow using approveHandler even if 2612 supported
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Oct 30, 2024
1 parent 830f705 commit a7914aa
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/iden3comm/handlers/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,13 +658,11 @@ export class PaymentHandler
paymentHandler: (data: Iden3PaymentRailsERC20RequestV1) => Promise<string>,
approveHandler?: (data: Iden3PaymentRailsERC20RequestV1) => Promise<string>
): Promise<Iden3PaymentRailsERC20V1> {
if (!data.features?.includes(PaymentFeatures.EIP_2612)) {
if (!approveHandler) {
throw new Error(
`please provide erc20TokenApproveHandler in context for ERC-20 payment type`
);
}
if (!data.features?.includes(PaymentFeatures.EIP_2612) && !approveHandler) {
throw new Error(`please provide erc20TokenApproveHandler in context for ERC-20 payment type`);
}

if (approveHandler) {
await approveHandler(data);
}

Expand Down

0 comments on commit a7914aa

Please sign in to comment.