From 33b0cc3a4894689b88e27ee6f11f40ce50788fe3 Mon Sep 17 00:00:00 2001 From: Jhonatan Gonzalez Date: Fri, 23 Feb 2024 13:50:02 +1100 Subject: [PATCH] fix: [GPR-415][Sale Widget] Fix transak integration after breaking changes (#1522) --- .../src/components/Transak/TransakIframe.tsx | 33 +++++--- .../components/Transak/useTransakIframe.ts | 23 +++--- .../src/widgets/sale/SaleWidget.tsx | 11 ++- .../src/widgets/sale/components/WithCard.tsx | 11 ++- .../sale/context/SaleContextProvider.tsx | 20 +++-- .../src/widgets/sale/hooks/useClientConfig.ts | 82 +++++++++++++++++++ .../src/widgets/sale/hooks/useCurrency.ts | 57 ------------- .../src/widgets/sale/hooks/useSignOrder.ts | 6 +- .../widgets-lib/src/widgets/sale/types.ts | 13 ++- .../src/widgets/sale/utils/config.ts | 2 - 10 files changed, 158 insertions(+), 100 deletions(-) create mode 100644 packages/checkout/widgets-lib/src/widgets/sale/hooks/useClientConfig.ts delete mode 100644 packages/checkout/widgets-lib/src/widgets/sale/hooks/useCurrency.ts diff --git a/packages/checkout/widgets-lib/src/components/Transak/TransakIframe.tsx b/packages/checkout/widgets-lib/src/components/Transak/TransakIframe.tsx index ce9f747517..bc9317a18d 100644 --- a/packages/checkout/widgets-lib/src/components/Transak/TransakIframe.tsx +++ b/packages/checkout/widgets-lib/src/components/Transak/TransakIframe.tsx @@ -1,4 +1,5 @@ import { useRef } from 'react'; +import { Environment } from '@imtbl/config'; import { TransakEventHandlers, useTransakEvents } from './useTransakEvents'; import { @@ -10,17 +11,19 @@ import { UserJourney } from '../../context/analytics-provider/SegmentAnalyticsPr import { CenteredBoxContent } from '../CenteredBoxContent/CenteredBoxContent'; import { LoadingBox } from '../../views/loading/LoadingBox'; -export type TransactionIframeProps = { +export type TransakIframeProps = { id: string; type: TransakWidgetType; email: string; + contractId: string; + environment: Environment; walletAddress: string; isPassportWallet: boolean; loadingText: string; } & TransakEventHandlers & TransakNFTCheckoutParams; -export function TransakIframe(props: TransactionIframeProps) { +export function TransakIframe(props: TransakIframeProps) { const { id, type, @@ -32,7 +35,6 @@ export function TransakIframe(props: TransactionIframeProps) { cryptoCurrencyCode, estimatedGasLimit, exchangeScreenTitle, - smartContractAddress, partnerOrderId, onOpen, onInit, @@ -43,6 +45,8 @@ export function TransakIframe(props: TransactionIframeProps) { onFailedToLoad, failedToLoadTimeoutInMs, loadingText, + environment, + contractId, } = props; const iframeRef = useRef(null); @@ -64,15 +68,18 @@ export function TransakIframe(props: TransactionIframeProps) { const { iframeSrc } = useTransakIframe({ type, - nftData, - calldata, - cryptoCurrencyCode, - estimatedGasLimit, - exchangeScreenTitle, - smartContractAddress, - email, - walletAddress, - partnerOrderId, + contractId, + environment, + transakParams: { + nftData, + calldata, + cryptoCurrencyCode, + estimatedGasLimit, + exchangeScreenTitle, + email, + walletAddress, + partnerOrderId, + }, }); return ( @@ -83,8 +90,8 @@ export function TransakIframe(props: TransactionIframeProps) { )}