Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dApp: Remove an unnecessary condition for ethAccount in the deposit flow #434

Merged
merged 4 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
useFetchDeposits,
useStakeFlowContext,
useToast,
useWalletContext,
} from "#/hooks"
import { logPromiseFailure } from "#/utils"
import { PROCESS_STATUSES } from "#/types"
Expand All @@ -25,7 +24,6 @@ const TOAST_ID = TOAST_IDS.DEPOSIT_TRANSACTION_ERROR
const TOAST = TOASTS[TOAST_ID]

export default function DepositBTCModal() {
const { ethAccount } = useWalletContext()
const tokenAmount = useActionFlowTokenAmount()
const { btcAddress, depositReceipt, stake } = useStakeFlowContext()
const depositTelemetry = useDepositTelemetry()
Expand Down Expand Up @@ -76,14 +74,9 @@ export default function DepositBTCModal() {
}, [dispatch, transactionHash])

const handledDepositBTC = useCallback(async () => {
if (!tokenAmount?.amount || !btcAddress || !depositReceipt || !ethAccount)
return
if (!tokenAmount?.amount || !btcAddress || !depositReceipt) return

const response = await depositTelemetry(
depositReceipt,
btcAddress,
ethAccount,
)
const response = await depositTelemetry(depositReceipt, btcAddress)

if (response.verificationStatus === "valid") {
logPromiseFailure(sendBitcoinTransaction(tokenAmount?.amount, btcAddress))
Expand All @@ -94,7 +87,6 @@ export default function DepositBTCModal() {
btcAddress,
depositReceipt,
depositTelemetry,
ethAccount,
sendBitcoinTransaction,
showError,
tokenAmount?.amount,
Expand Down
7 changes: 1 addition & 6 deletions dapp/src/hooks/useDepositTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ export function useDepositTelemetry() {
const captureMessage = useCaptureMessage()

return useCallback(
async (
deposit: DepositReceipt,
depositAddress: string,
ethAddress: string,
) => {
async (deposit: DepositReceipt, depositAddress: string) => {
const { status, response } = await verifyDepositAddress(
deposit,
depositAddress,
Expand Down Expand Up @@ -43,7 +39,6 @@ export function useDepositTelemetry() {
verificationResponse: response,
},
{
ethAddress,
...verificationStatus,
},
)
Expand Down
8 changes: 2 additions & 6 deletions dapp/src/hooks/useWallet.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useMemo } from "react"
import { ZeroAddress } from "ethers"
import { useWalletContext } from "./useWalletContext"
import { useRequestBitcoinAccount } from "./useRequestBitcoinAccount"

export function useWallet() {
const { btcAccount, ethAccount, setEthAccount } = useWalletContext()
const { btcAccount, ethAccount } = useWalletContext()
const { requestAccount: requestBitcoinAccount } = useRequestBitcoinAccount()

return useMemo(
Expand All @@ -13,13 +12,10 @@ export function useWallet() {
account: btcAccount,
requestAccount: async () => {
await requestBitcoinAccount()
// 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)
},
},
ethereum: { account: ethAccount },
}),
[btcAccount, requestBitcoinAccount, ethAccount, setEthAccount],
[btcAccount, ethAccount, requestBitcoinAccount],
)
}
Loading