diff --git a/src/features/transactions/helpers/getOrdersFromLogs.ts b/src/features/transactions/helpers/getOrdersFromLogs.ts index 0e212627..844146b9 100644 --- a/src/features/transactions/helpers/getOrdersFromLogs.ts +++ b/src/features/transactions/helpers/getOrdersFromLogs.ts @@ -1,7 +1,6 @@ import { Pool } from "@airswap/libraries"; import { FullSwapERC20, - getFullSwapERC20, OrderERC20, protocolFeeReceiverAddresses, } from "@airswap/utils"; @@ -9,6 +8,7 @@ import { import { BigNumber, Event } from "ethers"; import { transformFullSwapERC20ToOrderERC20 } from "../../../entities/OrderERC20/OrderERC20Transformers"; +import { getFullSwapERC20 } from "../../../helpers/getFullSwapERC20"; export interface FullSwapErc20Log { hash: string; @@ -54,6 +54,8 @@ export const getOrdersFromLogs = async ( receipt.logs ); + if (!swap) return; + const order = transformFullSwapERC20ToOrderERC20(swap, nonce.toString()); return { diff --git a/src/features/transactions/hooks/useLatestSwapFromEvents.ts b/src/features/transactions/hooks/useLatestSwapFromEvents.ts index 32e6d256..fbd3c3d4 100644 --- a/src/features/transactions/hooks/useLatestSwapFromEvents.ts +++ b/src/features/transactions/hooks/useLatestSwapFromEvents.ts @@ -1,13 +1,12 @@ import { useEffect, useState } from "react"; -import { SwapERC20 } from "@airswap/libraries"; -import { getFullSwapERC20 } from "@airswap/utils"; import { useWeb3React } from "@web3-react/core"; import { BigNumber, Event } from "ethers"; import { FullSwapERC20Event } from "../../../entities/FullSwapERC20Event/FullSwapERC20Event"; import { transformToFullSwapERC20Event } from "../../../entities/FullSwapERC20Event/FullSwapERC20EventTransformers"; +import { getFullSwapERC20 } from "../../../helpers/getFullSwapERC20"; import { compareAddresses } from "../../../helpers/string"; import { getSwapErc20Contract } from "../../../helpers/swapErc20"; import useNetworkSupported from "../../../hooks/useNetworkSupported"; @@ -45,6 +44,8 @@ const useLatestSwapFromEvents = ( receipt.logs ); + if (!swap) return; + if ( !compareAddresses(swap.signerWallet, account) && !compareAddresses(swap.senderWallet, account) && diff --git a/src/helpers/getFullSwapERC20.ts b/src/helpers/getFullSwapERC20.ts new file mode 100644 index 00000000..086e972e --- /dev/null +++ b/src/helpers/getFullSwapERC20.ts @@ -0,0 +1,29 @@ +import { getFullSwapERC20 as airswapGetFullSwapERC20 } from "@airswap/utils"; +import { FullSwapERC20 } from "@airswap/utils/build/src/swap-erc20"; + +import { ethers } from "ethers"; + +// TODO: Remove this function when this issue is resolved: +// https://github.com/airswap/airswap-protocols/issues/1319 + +export const getFullSwapERC20 = async ( + nonce: string, + signerWallet: string, + feeReceiver: string, + logs: ethers.providers.Log[] +): Promise => { + try { + return await airswapGetFullSwapERC20( + nonce, + signerWallet, + feeReceiver, + logs + ); + } catch (error) { + console.error( + `[getFullSwapERC20]: Error for transaction with nonce ${nonce}: ${error}` + ); + + return undefined; + } +};