From 2eabd86d1679b11c32f217802ee58d87ce8f34b6 Mon Sep 17 00:00:00 2001 From: ioay Date: Tue, 16 Jan 2024 17:44:45 +0100 Subject: [PATCH] Eslint config: fix no-misused-promises rule --- dapp/.eslintrc | 12 ------------ dapp/src/components/Header/ConnectWallet.tsx | 8 +++++++- dapp/src/components/Modals/Staking/SignMessage.tsx | 8 +++++++- .../components/Modals/Support/MissingAccount.tsx | 14 +++++++------- .../shared/Form/FormTokenBalanceInput.tsx | 8 +++++++- dapp/src/hooks/useDepositBTCTransaction.ts | 2 ++ 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/dapp/.eslintrc b/dapp/.eslintrc index 091b6b126..e0ec22303 100644 --- a/dapp/.eslintrc +++ b/dapp/.eslintrc @@ -21,18 +21,6 @@ // This is temporary solution after changes of the eslint-config version: @thesis-co/eslint-config: "github:thesis/eslint-config#7b9bc8c" // Overrides rules should be fixed file by file. "overrides": [ - { - "files": [ - "src/components/Header/ConnectWallet.tsx", - "src/components/Modals/Support/MissingAccount.tsx", - "src/components/Modals/Staking/SignMessage.tsx", - "src/hooks/useDepositBTCTransaction.ts", - "src/components/shared/Form/FormTokenBalanceInput.tsx" - ], - "rules": { - "@typescript-eslint/no-misused-promises": "off" - } - }, { "files": [ "src/hooks/useSignMessage.ts" diff --git a/dapp/src/components/Header/ConnectWallet.tsx b/dapp/src/components/Header/ConnectWallet.tsx index 5319a04ca..41be77ac0 100644 --- a/dapp/src/components/Header/ConnectWallet.tsx +++ b/dapp/src/components/Header/ConnectWallet.tsx @@ -24,12 +24,18 @@ function ConnectButton({ }: ConnectButtonsProps) { const colorScheme = !account ? "error" : undefined + const handleClick = () => { + requestAccount().catch((error) => { + throw error + }) + } + return ( diff --git a/dapp/src/components/Modals/Staking/SignMessage.tsx b/dapp/src/components/Modals/Staking/SignMessage.tsx index e3cda7886..4bc8f7554 100644 --- a/dapp/src/components/Modals/Staking/SignMessage.tsx +++ b/dapp/src/components/Modals/Staking/SignMessage.tsx @@ -9,8 +9,14 @@ export default function SignMessage() { const { goNext } = useModalFlowContext() const { signMessage } = useSignMessage(goNext) + const handleClick = () => { + signMessage().catch((error) => { + throw error + }) + } + return ( - + {/* TODO: Add the correct action after click */} {}}> diff --git a/dapp/src/components/Modals/Support/MissingAccount.tsx b/dapp/src/components/Modals/Support/MissingAccount.tsx index 89ca3effd..b859f3cc8 100644 --- a/dapp/src/components/Modals/Support/MissingAccount.tsx +++ b/dapp/src/components/Modals/Support/MissingAccount.tsx @@ -25,6 +25,12 @@ export default function MissingAccount({ }: MissingAccountProps) { const { name, symbol } = getCurrencyByType(currency) + const handleClick = () => { + requestAccount().catch((error) => { + throw error + }) + } + return ( <> {name} account not installed @@ -44,13 +50,7 @@ export default function MissingAccount({ - diff --git a/dapp/src/components/shared/Form/FormTokenBalanceInput.tsx b/dapp/src/components/shared/Form/FormTokenBalanceInput.tsx index 8571ed27e..817f840d0 100644 --- a/dapp/src/components/shared/Form/FormTokenBalanceInput.tsx +++ b/dapp/src/components/shared/Form/FormTokenBalanceInput.tsx @@ -11,12 +11,18 @@ export function FormTokenBalanceInput({ }: FormTokenBalanceInputProps) { const [field, meta, helpers] = useField(name) + const setAmount = (value?: bigint) => { + helpers.setValue(value).catch((error) => { + throw error + }) + } + return ( diff --git a/dapp/src/hooks/useDepositBTCTransaction.ts b/dapp/src/hooks/useDepositBTCTransaction.ts index 0bef0c4be..a3feb0507 100644 --- a/dapp/src/hooks/useDepositBTCTransaction.ts +++ b/dapp/src/hooks/useDepositBTCTransaction.ts @@ -5,6 +5,8 @@ export function useDepositBTCTransaction(onSuccess?: OnSuccessCallback) { // TODO: sending transactions using the SDK const depositBTC = useCallback(() => { if (onSuccess) { + // FIXME: enable eslint rule when SDK ready + // eslint-disable-next-line @typescript-eslint/no-misused-promises setTimeout(onSuccess, 1000) } }, [onSuccess])