Skip to content

Commit

Permalink
Quick fix for transaction window pop-up
Browse files Browse the repository at this point in the history
When we connected the account from the landing page the etherum account was not set up. Therefore, the deposit transaction window did not run because the eth account is still required in several places in the code.This is a quick fix to solve the issue but it is not a solution to the problem.
  • Loading branch information
kkosiorowska committed May 28, 2024
1 parent 34d8350 commit 91df679
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dapp/src/hooks/useTransactionModal.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ActionFlowType, MODAL_TYPES } from "#/types"
import { useCallback, useEffect } from "react"
import { logPromiseFailure } from "#/utils"
import { ZeroAddress } from "ethers"
import { useModal } from "./useModal"
import { useWalletContext } from "./useWalletContext"
import { useRequestBitcoinAccount } from "./useRequestBitcoinAccount"

export function useTransactionModal(type: ActionFlowType) {
const { btcAccount } = useWalletContext()
const { btcAccount, setEthAccount } = useWalletContext()
const { account, requestAccount } = useRequestBitcoinAccount()
const { openModal } = useModal()

Expand All @@ -24,11 +25,18 @@ export function useTransactionModal(type: ActionFlowType) {
}
}, [account, handleOpenModal])

const handleRequestAccount = useCallback(async () => {
await requestAccount()
// TODO: Temporary solution - we do not need the eth account and we
// want to create the Acre SDK w/o passing the Ethereum Account.
setEthAccount(ZeroAddress)
}, [requestAccount, setEthAccount])

return useCallback(() => {
if (btcAccount) {
handleOpenModal()
} else {
logPromiseFailure(requestAccount())
logPromiseFailure(handleRequestAccount())
}
}, [btcAccount, handleOpenModal, requestAccount])
}, [btcAccount, handleOpenModal, handleRequestAccount])
}

0 comments on commit 91df679

Please sign in to comment.