From a60950c2b025af3416a56acd099f584ee017d3c0 Mon Sep 17 00:00:00 2001 From: Jhonatan Gonzalez Date: Wed, 21 Aug 2024 09:41:47 +0800 Subject: [PATCH] [NO-CHANGELOG][Checkout Widgets] fix: Prevent passing provider as prop to framer motion children (#2101) --- .../components/WalletDrawer/WalletDrawer.tsx | 4 ++-- .../components/WalletDrawer/WalletItem.tsx | 18 ++++++++--------- .../widgets/connect/components/WalletItem.tsx | 20 +++++++++---------- .../widgets/connect/components/WalletList.tsx | 8 ++++---- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/checkout/widgets-lib/src/components/WalletDrawer/WalletDrawer.tsx b/packages/checkout/widgets-lib/src/components/WalletDrawer/WalletDrawer.tsx index b749618a84..b89983c0a0 100644 --- a/packages/checkout/widgets-lib/src/components/WalletDrawer/WalletDrawer.tsx +++ b/packages/checkout/widgets-lib/src/components/WalletDrawer/WalletDrawer.tsx @@ -119,8 +119,8 @@ export function WalletDrawer({ key={providerDetail.info.rdns} testId={testId} loading={walletItemLoading} - providerDetail={providerDetail} - onWalletItemClick={handleWalletItemClick} + providerInfo={providerDetail.info} + onWalletItemClick={() => handleWalletItemClick(providerDetail)} rc={( )} diff --git a/packages/checkout/widgets-lib/src/components/WalletDrawer/WalletItem.tsx b/packages/checkout/widgets-lib/src/components/WalletDrawer/WalletItem.tsx index c95134394a..d6056a015d 100644 --- a/packages/checkout/widgets-lib/src/components/WalletDrawer/WalletItem.tsx +++ b/packages/checkout/widgets-lib/src/components/WalletDrawer/WalletItem.tsx @@ -1,15 +1,15 @@ import { MenuItem } from '@biom3/react'; import { cloneElement, ReactElement, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { EIP6963ProviderDetail } from '@imtbl/checkout-sdk'; +import { EIP6963ProviderInfo } from '@imtbl/checkout-sdk'; import { RawImage } from '../RawImage/RawImage'; export interface WalletItemProps { loading?: boolean; recommended?: boolean; testId: string; - providerDetail: EIP6963ProviderDetail; - onWalletItemClick: (providerDetail: EIP6963ProviderDetail) => Promise; + providerInfo: EIP6963ProviderInfo; + onWalletItemClick: () => void; rc?: RC; } @@ -20,7 +20,7 @@ export function WalletItem< testId, loading = false, recommended = false, - providerDetail, + providerInfo, onWalletItemClick, }: WalletItemProps) { const { t } = useTranslation(); @@ -34,27 +34,27 @@ export function WalletItem< setBusy(true); // let the parent handle errors try { - await onWalletItemClick(providerDetail); + await onWalletItemClick(); } finally { setBusy(false); } }, })} - testId={`${testId}-wallet-list-${providerDetail.info.rdns}`} + testId={`${testId}-wallet-list-${providerInfo.rdns}`} size="medium" emphasized sx={{ position: 'relative' }} > - {providerDetail.info.name} + {providerInfo.name} {((recommended || busy) && ( { loading?: boolean; recommended?: boolean; - onWalletItemClick: (providerDetail: EIP6963ProviderDetail) => void; - providerDetail: EIP6963ProviderDetail; + onWalletItemClick: () => void; + providerInfo: EIP6963ProviderInfo; rc?: RC; } @@ -20,13 +20,13 @@ export function WalletItem< rc = , loading = false, recommended = false, - providerDetail, + providerInfo, onWalletItemClick, }: WalletProps) { const { t } = useTranslation(); const { isSmallScreenMode } = useIsSmallScreen(); const [busy, setBusy] = useState(false); - const providerSlug = getProviderSlugFromRdns(providerDetail.info.rdns); + const providerSlug = getProviderSlugFromRdns(providerInfo.rdns); const isPassport = providerSlug === WalletProviderName.PASSPORT; const isPassportOrMetamask = isPassport || providerSlug === WalletProviderName.METAMASK; const offsetStyles = { marginLeft: '65px' }; @@ -39,13 +39,13 @@ export function WalletItem< setBusy(true); // let the parent handle errors try { - await onWalletItemClick(providerDetail); + await onWalletItemClick(); } finally { setBusy(false); } }, })} - testId={`wallet-list-${providerDetail.info.rdns}`} + testId={`wallet-list-${providerInfo.rdns}`} size="medium" emphasized sx={{ @@ -54,8 +54,8 @@ export function WalletItem< }} > ))} - {providerDetail.info.name} + {providerInfo.name} {(!busy && )} diff --git a/packages/checkout/widgets-lib/src/widgets/connect/components/WalletList.tsx b/packages/checkout/widgets-lib/src/widgets/connect/components/WalletList.tsx index 8ff1b32cc9..6ca219c94e 100644 --- a/packages/checkout/widgets-lib/src/widgets/connect/components/WalletList.tsx +++ b/packages/checkout/widgets-lib/src/widgets/connect/components/WalletList.tsx @@ -372,8 +372,8 @@ export function WalletList(props: WalletListProps) { handleWalletItemClick(passportProviderDetail)} + providerInfo={passportProviderDetail.info} rc={( handleWalletItemClick(filteredProviders[0])} + providerInfo={filteredProviders[0].info} rc={(