From a7914aad883653ac58dd62eee13369306a6722d2 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Wed, 30 Oct 2024 17:40:48 +0200 Subject: [PATCH] allow using approveHandler even if 2612 supported --- src/iden3comm/handlers/payment.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/iden3comm/handlers/payment.ts b/src/iden3comm/handlers/payment.ts index d2954159..b2db3d54 100644 --- a/src/iden3comm/handlers/payment.ts +++ b/src/iden3comm/handlers/payment.ts @@ -658,13 +658,11 @@ export class PaymentHandler paymentHandler: (data: Iden3PaymentRailsERC20RequestV1) => Promise, approveHandler?: (data: Iden3PaymentRailsERC20RequestV1) => Promise ): Promise { - 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); }