Skip to content

Commit

Permalink
fix: useTxStatuses
Browse files Browse the repository at this point in the history
  • Loading branch information
Argeare5 committed Feb 7, 2023
1 parent 66df781 commit be67b3b
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/hooks/useTxStatuses.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
import { useEffect, useState } from 'react';
import { StoreApi, UseBoundStore } from 'zustand';

import { selectLastTxByTypeAndPayload } from '../web3/store/transactionsSelectors';
import { BaseTx, ITransactionsState } from '../web3/store/transactionsSlice';

interface TxStatusesParams<T extends BaseTx> {
useStore: UseBoundStore<
StoreApi<{
getActiveAddress: () => string | undefined;
}>
>;
state: ITransactionsState<T>;
activeAddress: string;
type: T['type'];
payload: T['payload'];
}

export const useTxStatuses = <T extends BaseTx>({
useStore,
state,
activeAddress,
type,
payload,
}: TxStatusesParams<T>) => {
const getActiveAddress = useStore((state) => state.getActiveAddress);
const activeAddress = getActiveAddress();

const tx = selectLastTxByTypeAndPayload(
state,
activeAddress || '',
type,
payload
);
const tx = selectLastTxByTypeAndPayload(state, activeAddress, type, payload);

const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
Expand Down

0 comments on commit be67b3b

Please sign in to comment.