Skip to content

Commit

Permalink
Eslint config: fix no-misused-promises rule
Browse files Browse the repository at this point in the history
  • Loading branch information
ioay committed Jan 16, 2024
1 parent ac3de29 commit 2eabd86
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 22 deletions.
12 changes: 0 additions & 12 deletions dapp/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion dapp/src/components/Header/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ function ConnectButton({
}: ConnectButtonsProps) {
const colorScheme = !account ? "error" : undefined

const handleClick = () => {
requestAccount().catch((error) => {
throw error
})
}

return (
<Button
variant="card"
colorScheme={colorScheme}
leftIcon={<Icon as={leftIcon} boxSize={6} />}
onClick={requestAccount}
onClick={handleClick}
>
{account ? truncateAddress(account.address) : "Not connected"}
</Button>
Expand Down
8 changes: 7 additions & 1 deletion dapp/src/components/Modals/Staking/SignMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ export default function SignMessage() {
const { goNext } = useModalFlowContext()
const { signMessage } = useSignMessage(goNext)

const handleClick = () => {
signMessage().catch((error) => {
throw error
})
}

return (
<StakingSteps buttonText="Continue" activeStep={0} onClick={signMessage}>
<StakingSteps buttonText="Continue" activeStep={0} onClick={handleClick}>
{/* TODO: Add the correct action after click */}
<Alert withActionIcon onclick={() => {}}>
<TextMd>
Expand Down
14 changes: 7 additions & 7 deletions dapp/src/components/Modals/Support/MissingAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export default function MissingAccount({
}: MissingAccountProps) {
const { name, symbol } = getCurrencyByType(currency)

const handleClick = () => {
requestAccount().catch((error) => {
throw error
})
}

return (
<>
<ModalHeader>{name} account not installed</ModalHeader>
Expand All @@ -44,13 +50,7 @@ export default function MissingAccount({
</Alert>
</ModalBody>
<ModalFooter mt={4}>
<Button
size="lg"
width="100%"
onClick={async () => {
await requestAccount()
}}
>
<Button size="lg" width="100%" onClick={handleClick}>
Connect wallet
</Button>
</ModalFooter>
Expand Down
8 changes: 7 additions & 1 deletion dapp/src/components/shared/Form/FormTokenBalanceInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<TokenBalanceInput
{...restProps}
{...field}
amount={meta.value as bigint}
setAmount={helpers.setValue}
setAmount={setAmount}
hasError={Boolean(meta.touched && meta.error)}
errorMsgText={meta.error}
/>
Expand Down
2 changes: 2 additions & 0 deletions dapp/src/hooks/useDepositBTCTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 2eabd86

Please sign in to comment.