Skip to content

Commit

Permalink
feat: added chainId to actions (#1816)
Browse files Browse the repository at this point in the history
* feat: added chainId to actions

* feat: added chainId to failed txs
  • Loading branch information
JoaquinBattilana authored Oct 19, 2023
1 parent a9529c9 commit 3083862
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/components/TransactionEventHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { useRootStore } from 'src/store/root';
import { selectSuccessfulTransactions } from 'src/store/transactionsSelectors';
import { getNetworkConfig } from 'src/utils/marketsAndNetworksConfig';
import { GENERAL } from 'src/utils/mixPanelEvents';

export const TransactionEventHandler = () => {
Expand All @@ -14,10 +15,10 @@ export const TransactionEventHandler = () => {
useEffect(() => {
Object.keys(successfulTransactions).forEach((chainId) => {
const chainIdNumber = +chainId;
const networkConfig = getNetworkConfig(chainIdNumber);
Object.keys(successfulTransactions[chainIdNumber]).forEach((txHash) => {
if (!postedTransactions[chainIdNumber]?.includes(txHash)) {
const tx = successfulTransactions[chainIdNumber][txHash];

// const event = actionToEvent(tx.action);
trackEvent(GENERAL.TRANSACTION, {
transactionType: tx.action,
Expand All @@ -35,6 +36,8 @@ export const TransactionEventHandler = () => {
outAssetName: tx.outAssetName,
amountUsd: tx.amountUsd,
outAmountUsd: tx.outAmountUsd,
chainId: chainIdNumber,
chainName: networkConfig.displayName || networkConfig.name,
});

// update local state
Expand Down
15 changes: 10 additions & 5 deletions src/components/transactions/Switch/SwitchActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ export const SwitchActions = ({
},
{
chainId,
market: null,
}
);
setMainTxState({
Expand All @@ -158,10 +157,16 @@ export const SwitchActions = ({
txHash: response.hash,
loading: false,
});
addTransaction(response.hash, {
txState: 'failed',
...txData,
});
addTransaction(
response.hash,
{
txState: 'failed',
...txData,
},
{
chainId,
}
);
}
} catch (error) {
const parsedError = getErrorTextFromError(error, TxAction.GAS_ESTIMATION, false);
Expand Down

2 comments on commit 3083862

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

Please sign in to comment.