From 256744317f768e60f8f47a51fc0747bf3426be6c Mon Sep 17 00:00:00 2001
From: Bogdan Fazakas <bogdan.fazakas@gmail.com>
Date: Wed, 22 Jun 2022 06:58:29 +0300
Subject: [PATCH] fix provider fee approve for free assets

---
 src/@utils/order.ts | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/@utils/order.ts b/src/@utils/order.ts
index 464521f65..cd2c456a3 100644
--- a/src/@utils/order.ts
+++ b/src/@utils/order.ts
@@ -186,12 +186,16 @@ export async function handleComputeOrder(
     initializeData.providerFee &&
     initializeData.providerFee.providerFeeAmount !== '0'
   ) {
+    const baseToken =
+      asset?.accessDetails?.type === 'free'
+        ? getOceanConfig(asset.chainId).oceanTokenAddress
+        : asset?.accessDetails?.baseToken?.address
     const txApproveWei = await approveWei(
       web3,
       accountId,
-      asset.accessDetails.baseToken.address,
-      asset.accessDetails.datatoken.address,
-      initializeData.providerFee.providerFeeAmount
+      baseToken,
+      asset?.accessDetails?.datatoken?.address,
+      initializeData?.providerFee?.providerFeeAmount
     )
     if (!txApproveWei) {
       toast.error('Failed to approve provider fees!')