From 375dc087a39d9a48f392edd09421572f0a958e23 Mon Sep 17 00:00:00 2001 From: Markeljan Sokoli Date: Tue, 11 Mar 2025 15:28:56 -0400 Subject: [PATCH] track bitte-wallet transaction hash from url --- .../chat/transactions/ReviewTransaction.tsx | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/components/chat/transactions/ReviewTransaction.tsx b/src/components/chat/transactions/ReviewTransaction.tsx index b52c9b1..df8fe6a 100644 --- a/src/components/chat/transactions/ReviewTransaction.tsx +++ b/src/components/chat/transactions/ReviewTransaction.tsx @@ -1,7 +1,7 @@ import { Transaction } from "@near-wallet-selector/core"; import BN from "bn.js"; import { SafeEncodedSignRequest } from "near-safe"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useAccountBalance } from "../../../hooks/useAccountBalance"; import { SuccessInfo, useTransaction } from "../../../hooks/useTransaction"; import { useTxnFees } from "../../../hooks/useTxnFees"; @@ -70,6 +70,37 @@ export const ReviewTransaction = ({ const { width } = useWindowSize(); const isMobile = !!width && width < 640; + useEffect(() => { + if (!result) { + const searchParams = new URLSearchParams(window.location.search); + const txHash = searchParams.get("transactionHashes"); + + if (txHash) { + // Create a success info object from the transaction hash + const successInfo = { + near: { + receipts: [ + { + transaction: { + hash: txHash, + }, + }, + ], + }, + }; + setResult(successInfo); + + // Clear the URL parameters + searchParams.delete("transactionHashes"); + searchParams.delete("account_id"); + const newUrl = `${window.location.pathname}${ + searchParams.toString() ? "?" + searchParams.toString() : "" + }`; + window.history.replaceState({}, "", newUrl); + } + } + }, [result]); + if (!transactions || transactions.length === 0) { return (