Skip to content

Commit

Permalink
feat: wc tx info while transaction (#88)
Browse files Browse the repository at this point in the history
* feat: display loader while waiting for tx to complete

* fix: rejection handler
  • Loading branch information
anukulpandey authored Jun 10, 2024
1 parent 94bcc50 commit f78d920
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ const App = (): JSX.Element => {
window.addEventListener("unhandledrejection", (event) => {
const errorMessage = event.reason?.message || event.reason;
if (errorMessage === "_canceled") {
// disable wallet connect loader if exists
setWcPreloader({
value:false,message:""
})
setErrorToast({
message:"You rejected the transaction",
type:"danger"
Expand Down
17 changes: 17 additions & 0 deletions src/pages/dashboard/TokenBalances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { isReefswapUI, useDexConfig } from '../../environment';
import {network as nw} from '@reef-chain/util-lib';
import PoolContext from '../../context/PoolContext';
import HideBalance from '../../context/HideBalance';
import useConnectedWallet from '../../hooks/useConnectedWallet';
import { extension as reefExt } from '@reef-chain/util-lib';
import useWcPreloader from '../../hooks/useWcPreloader';

const {Skeleton,TokenCard} = Components;

Expand Down Expand Up @@ -41,6 +44,18 @@ export const TokenBalances = ({ tokens }: TokenBalances): JSX.Element => {
const { selectedSigner, network,accounts,provider } = useContext(ReefSigners);
const pools = useContext(PoolContext);
const hidebalance = useContext(HideBalance)
const {selExtensionName} = useConnectedWallet();
const {setLoading:setWcPreloader} = useWcPreloader();
const { walletSelectorOptions } = Components;

const isWalletConnect = selExtensionName == walletSelectorOptions[reefExt.REEF_WALLET_CONNECT_IDENT].name

const handleWalletConnectModal = (hasStarted:boolean)=>{
setWcPreloader({
value:hasStarted,
message:"waiting for transaction approval"
})
}

const isReefBalanceZero = selectedSigner?.balance._hex === '0x00';

Expand Down Expand Up @@ -85,6 +100,8 @@ export const TokenBalances = ({ tokens }: TokenBalances): JSX.Element => {
selectedSigner={selectedSigner}
signer={selectedSigner}
tokenPrices={tokenPrices}
isWalletConnect={isWalletConnect}
handleWalletConnectModal={handleWalletConnectModal}
/>
</div>
));
Expand Down

0 comments on commit f78d920

Please sign in to comment.