Skip to content

Commit

Permalink
feat: added generate explorer link
Browse files Browse the repository at this point in the history
  • Loading branch information
Argeare5 committed Feb 8, 2023
1 parent 78b5876 commit 3b21f6e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/hooks/useTxStatuses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const useTxStatuses = <T extends BaseTx>({
const txPending = tx && tx.pending;
const txSuccess = tx && tx.status === 1;
const txChainId = tx && tx.chainId;
const txWalletType = tx && tx.walletType;

useEffect(() => {
if (txPending || !!error) {
Expand All @@ -44,5 +45,6 @@ export const useTxStatuses = <T extends BaseTx>({
txPending,
txSuccess,
txChainId,
txWalletType,
};
};
20 changes: 20 additions & 0 deletions src/utils/generateExplorerLink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { WalletType } from '../web3/connectors';

export function generateExplorerLink(
blockExplorerUrls: string,
txWalletType: WalletType,
txChainId: number,
txHash: string,
activeWallet?: string
) {
const gnosisSafeLinksHelper: Record<number, string> = {
1: 'https://app.safe.global/eth:',
5: 'https://app.safe.global/gor:',
};

if (txWalletType !== 'GnosisSafe') {
return `${blockExplorerUrls}/tx/${txHash}`;
} else {
return `${gnosisSafeLinksHelper[txChainId]}${activeWallet}/transactions/tx?id=multisig_${activeWallet}_${txHash}`;
}
}

0 comments on commit 3b21f6e

Please sign in to comment.