From 504badebb894a3f6122508daba3dd841acc01189 Mon Sep 17 00:00:00 2001 From: nabarun Date: Thu, 1 Aug 2024 06:18:02 +0000 Subject: [PATCH] Remove deep link path and prevent re-render from useEffect (#7) Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675) - Remove path config used for deep links Co-authored-by: Shreerang Kale Reviewed-on: https://git.vdb.to/cerc-io/laconic-wallet-web/pulls/7 --- src/index.tsx | 9 +-------- src/screens/ApproveTransaction.tsx | 4 ++-- src/screens/ApproveTransfer.tsx | 10 +++++----- src/screens/SignRequest.tsx | 22 +++++++--------------- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 61d2d7c..087f562 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -15,14 +15,7 @@ import { WalletConnectProvider } from './context/WalletConnectContext'; globalThis.Buffer = Buffer; const linking = { - prefixes: ['https://wallet.laconic.com'], - config: { - screens: { - SignRequest: { - path: 'sign/:namespace/:chaindId/:address/:message', - }, - }, - }, + prefixes: ['https://wallet.laconic.com'] }; const theme = { diff --git a/src/screens/ApproveTransaction.tsx b/src/screens/ApproveTransaction.tsx index f6a0dfe..fd74bb7 100644 --- a/src/screens/ApproveTransaction.tsx +++ b/src/screens/ApproveTransaction.tsx @@ -50,7 +50,7 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => { const [account, setAccount] = useState(); const [cosmosStargateClient, setCosmosStargateClient] = useState(); - const [cosmosGasLimit, setCosmosGasLimit] = useState(); + const [cosmosGasLimit, setCosmosGasLimit] = useState(''); const [fees, setFees] = useState(); const [txError, setTxError] = useState(); const [isTxErrorDialogOpen, setIsTxErrorDialogOpen] = useState(false); @@ -201,7 +201,7 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => { denom: requestedNetwork!.nativeDenom!, }, ], - gas: cosmosGasLimit!, + gas: cosmosGasLimit, }, txMsg: transactionMessage, }; diff --git a/src/screens/ApproveTransfer.tsx b/src/screens/ApproveTransfer.tsx index e12d91b..80f88be 100644 --- a/src/screens/ApproveTransfer.tsx +++ b/src/screens/ApproveTransfer.tsx @@ -70,8 +70,8 @@ const ApproveTransfer = ({ route }: SignRequestProps) => { const [isTxLoading, setIsTxLoading] = useState(false); const [cosmosStargateClient, setCosmosStargateClient] = useState(); - const [fees, setFees] = useState(); - const [cosmosGasLimit, setCosmosGasLimit] = useState(); + const [fees, setFees] = useState(''); + const [cosmosGasLimit, setCosmosGasLimit] = useState(''); const [txError, setTxError] = useState(); const [isTxErrorDialogOpen, setIsTxErrorDialogOpen] = useState(false); const [ethGasPrice, setEthGasPrice] = useState(); @@ -212,7 +212,7 @@ const ApproveTransfer = ({ route }: SignRequestProps) => { // If requested chain is EVM compatible, set loading to false when ethMaxFee and ethPriorityFee have been populated (ethMaxFee !== undefined && ethMaxPriorityFee !== undefined) || // Or if requested chain is a cosmos chain, set loading to false when cosmosGasLimit has been populated - cosmosGasLimit !== undefined + !cosmosGasLimit ) { setIsLoading(false); } @@ -311,11 +311,11 @@ const ApproveTransfer = ({ route }: SignRequestProps) => { // This amount is total fees required for transaction amount: [ { - amount: fees!, + amount: fees, denom: requestedNetwork!.nativeDenom!, }, ], - gas: cosmosGasLimit!, + gas: cosmosGasLimit, }, sendMsg, memo: MEMO, diff --git a/src/screens/SignRequest.tsx b/src/screens/SignRequest.tsx index 2e74c00..3e0839d 100644 --- a/src/screens/SignRequest.tsx +++ b/src/screens/SignRequest.tsx @@ -49,7 +49,7 @@ const SignRequest = ({ route }: SignRequestProps) => { const isCosmosSignDirect = useMemo(() => { const requestParams = route.params.requestEvent; - if (!requestParams) { + if (!requestParams?.id) { return false; } @@ -59,7 +59,7 @@ const SignRequest = ({ route }: SignRequestProps) => { const isEthSendTransaction = useMemo(() => { const requestParams = route.params.requestEvent; - if (!requestParams) { + if (!requestParams?.id) { return false; } @@ -86,21 +86,13 @@ const SignRequest = ({ route }: SignRequestProps) => { return; } - if (requestAccount !== account) { - setAccount(requestAccount); - } - if (requestMessage !== message) { - setMessage(decodeURIComponent(requestMessage)); - } - if (requestNamespace !== namespace) { - setNamespace(requestNamespace); - } - if (requestChainId !== chainId) { - setChainId(requestChainId); - } + setAccount(requestAccount); + setMessage(decodeURIComponent(requestMessage)); + setNamespace(requestNamespace); + setChainId(requestChainId); setIsLoading(false); }, - [account, message, navigation, namespace, chainId], + [navigation], ); const sanitizePath = useCallback(