Skip to content

Commit

Permalink
Merge branch 'main' of github.com:thesis/acre into validate-deposit-a…
Browse files Browse the repository at this point in the history
…ddress
  • Loading branch information
kkosiorowska committed Feb 26, 2024
2 parents 3135d99 + e23ae29 commit 26de39d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dapp/src/acre-react/hooks/useStakeFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type UseStakeFlowReturn = {
depositReceipt?: DepositReceipt
signMessage: () => Promise<void>
stake: () => Promise<void>
depositReceipt?: DepositReceipt
}

export function useStakeFlow(): UseStakeFlowReturn {
Expand All @@ -29,6 +30,10 @@ export function useStakeFlow(): UseStakeFlowReturn {
DepositReceipt | undefined
>(undefined)

const [depositReceipt, setDepositReceipt] = useState<

Check failure on line 33 in dapp/src/acre-react/hooks/useStakeFlow.ts

View workflow job for this annotation

GitHub Actions / dapp-format

'depositReceipt' is already defined

Check failure on line 33 in dapp/src/acre-react/hooks/useStakeFlow.ts

View workflow job for this annotation

GitHub Actions / dapp-format

'setDepositReceipt' is already defined
DepositReceipt | undefined
>(undefined)

const initStake = useCallback(
async (
bitcoinRecoveryAddress: string,
Expand Down Expand Up @@ -73,5 +78,6 @@ export function useStakeFlow(): UseStakeFlowReturn {
depositReceipt,
signMessage,
stake,
depositReceipt,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
useModalFlowContext,
useStakeFlowContext,
useTransactionContext,
useWalletContext,
} from "#/hooks"
import Alert from "#/components/shared/Alert"
import { TextMd } from "#/components/shared/Typography"
Expand All @@ -14,6 +15,7 @@ import { PROCESS_STATUSES } from "#/types"
import StakingStepsModalContent from "./StakingStepsModalContent"

export default function DepositBTCModal() {
const { ethAccount } = useWalletContext()
const { tokenAmount } = useTransactionContext()
const { setStatus } = useModalFlowContext()
const { btcAddress, depositReceipt, stake } = useStakeFlowContext()
Expand Down Expand Up @@ -48,14 +50,18 @@ export default function DepositBTCModal() {
useDepositBTCTransaction(onDepositBTCSuccess)

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

asyncWrapper(depositTelemetry(depositReceipt, btcAddress))
asyncWrapper(
depositTelemetry(depositReceipt, btcAddress, ethAccount?.address),
)
asyncWrapper(sendBitcoinTransaction(tokenAmount?.amount, btcAddress))
}, [
btcAddress,
depositReceipt,
depositTelemetry,
ethAccount,
sendBitcoinTransaction,
tokenAmount?.amount,
])
Expand Down
9 changes: 8 additions & 1 deletion dapp/src/hooks/useDepositTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ export function useDepositTelemetry() {
const captureMessage = useCaptureMessage()

return useCallback(
async (deposit: DepositReceipt, depositAddress: string) => {
async (
deposit: DepositReceipt,
depositAddress: string,
ethAddress: string,
) => {
const { status, response } = await verifyDepositAddress(
deposit,
depositAddress,
Expand All @@ -21,6 +25,7 @@ export function useDepositTelemetry() {
walletPublicKeyHash,
refundPublicKeyHash,
refundLocktime,
extraData,
} = deposit

captureMessage(
Expand All @@ -31,10 +36,12 @@ export function useDepositTelemetry() {
walletPublicKeyHash: walletPublicKeyHash.toString(),
refundPublicKeyHash: refundPublicKeyHash.toString(),
refundLocktime: refundLocktime.toString(),
extraData: extraData?.toString(),
verificationStatus: status,
verificationResponse: response,
},
{
ethAddress,
"verification.status": status,
},
)
Expand Down

0 comments on commit 26de39d

Please sign in to comment.