From 5fc634db754f8abc1d371c5a4e45fc2a74187748 Mon Sep 17 00:00:00 2001 From: Vitalii Vozniak Date: Thu, 5 Oct 2023 21:04:31 +0300 Subject: [PATCH] chore(cip-1694-ui): improve logging, get rid of tip dependency in fetch receipt effect --- ui/cip-1694/.env.example | 2 +- ui/cip-1694/src/common/utils/voteUtils.ts | 5 ++++- .../ConnectWalletModal/ConnectWalletModal.tsx | 2 +- .../src/components/common/Content/Content.tsx | 3 ++- ui/cip-1694/src/pages/Vote/Vote.tsx | 20 ++++--------------- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/ui/cip-1694/.env.example b/ui/cip-1694/.env.example index 19eeb9868..d89b060e3 100644 --- a/ui/cip-1694/.env.example +++ b/ui/cip-1694/.env.example @@ -6,4 +6,4 @@ REACT_APP_TARGET_NETWORK=PREPROD REACT_APP_EVENT_ID=CIP-1694_Pre_Ratification_4619 -REACT_APP_SUPPORTED_WALLETS=flint,eternl,nami,typhoncip30,yoroi,nufi,gerowallet,lace +REACT_APP_SUPPORTED_WALLETS=flint,eternl,nami,typhoncip30,yoroi,nufi,gerowallet,lace,begin,cardwallet diff --git a/ui/cip-1694/src/common/utils/voteUtils.ts b/ui/cip-1694/src/common/utils/voteUtils.ts index 37b1c3a33..cd008f26f 100644 --- a/ui/cip-1694/src/common/utils/voteUtils.ts +++ b/ui/cip-1694/src/common/utils/voteUtils.ts @@ -47,7 +47,10 @@ export const getSignedMessagePromise = (signMessage: ReturnType resolve({ coseSignature: signature, cosePublicKey: key || '' }), - (error: Error) => reject(error) + (error: Error) => { + console.log(error); + return reject(error); + } ); }); }; diff --git a/ui/cip-1694/src/components/ConnectWalletModal/ConnectWalletModal.tsx b/ui/cip-1694/src/components/ConnectWalletModal/ConnectWalletModal.tsx index 79706f847..2ad8ce3c1 100644 --- a/ui/cip-1694/src/components/ConnectWalletModal/ConnectWalletModal.tsx +++ b/ui/cip-1694/src/components/ConnectWalletModal/ConnectWalletModal.tsx @@ -19,7 +19,7 @@ type ConnectWalletModalProps = { title: string; description: string; onConnectWallet: () => void; - onConnectWalletError: () => void; + onConnectWalletError: (walletName: string, error: Error) => void; onCloseFn: () => void; }; diff --git a/ui/cip-1694/src/components/common/Content/Content.tsx b/ui/cip-1694/src/components/common/Content/Content.tsx index 0cd5900dc..445e68669 100644 --- a/ui/cip-1694/src/components/common/Content/Content.tsx +++ b/ui/cip-1694/src/components/common/Content/Content.tsx @@ -26,7 +26,8 @@ export const Content = () => { debouncedToast(); }, [dispatch, debouncedToast]); - const onConnectWalletError = useCallback(() => { + const onConnectWalletError = useCallback((walletName: string, error: Error) => { + console.log(walletName, error); toast( { useEffect(() => { const session = getUserInSession(); - if ( - tip?.absoluteSlot && - stakeAddress && - event?.notStarted === false && - ((session && tokenIsExpired(session.expiresAt)) || !session) - ) { + if (stakeAddress && event?.notStarted === false && ((session && tokenIsExpired(session.expiresAt)) || !session)) { setIsConfirmWithWalletSignatureModalVisible(true); } - }, [event?.notStarted, tip?.absoluteSlot, stakeAddress]); + }, [event?.notStarted, stakeAddress]); const items: OptionItem[] = event?.categories ?.find(({ id }) => id === activeCategoryId) @@ -200,17 +195,10 @@ export const VotePage = () => { useEffect(() => { const session = getUserInSession(); - if ( - isConnected && - tip?.absoluteSlot && - stakeAddress && - session && - !tokenIsExpired(session.expiresAt) && - activeCategoryId - ) { + if (isConnected && stakeAddress && session && !tokenIsExpired(session.expiresAt) && activeCategoryId) { fetchReceipt({}); } - }, [fetchReceipt, isConnected, stakeAddress, tip?.absoluteSlot, activeCategoryId]); + }, [fetchReceipt, isConnected, stakeAddress, activeCategoryId]); const openReceiptDrawer = async () => { setIsReceiptDrawerInitializing(true);