Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tx broadcast fix #395

Merged
merged 16 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
529006f
chore: replaced api data with proposal store data in gov. proposals tab
AbbasAliLokhandwala Aug 20, 2024
9e331ca
Currency sync (#390)
AbbasAliLokhandwala Aug 26, 2024
7288265
fix: error handling and checks for tx node update methods in activity…
AbbasAliLokhandwala Aug 28, 2024
378769a
fix: update methods proposal txn logs and gas in activity store
AbbasAliLokhandwala Aug 28, 2024
6dd798b
chore: added state in base store for broadcast progress
AbbasAliLokhandwala Aug 29, 2024
7094e16
fix: disabling signpage approve button while broadcast in progress
AbbasAliLokhandwala Aug 29, 2024
e1ed273
refactor: code cleanup activity node creation logic
AbbasAliLokhandwala Aug 29, 2024
fe5701f
fix: signpage approve button text
AbbasAliLokhandwala Aug 29, 2024
88d8fd3
fix: activity store updateTxnBalance check
AbbasAliLokhandwala Aug 30, 2024
d0a08c7
chore: added txInProgress state in base store
AbbasAliLokhandwala Sep 3, 2024
410b162
chore: added util function for pathname and navigateOnTxnEvents
AbbasAliLokhandwala Sep 3, 2024
a6d620c
fix: txn redirect UX fixes for delegate, unstake, withdraw, redelegate
AbbasAliLokhandwala Sep 3, 2024
9db9100
fix: txn redirect UX fixes for ibc transfer, send, proposals, native …
AbbasAliLokhandwala Sep 3, 2024
e5b6389
Allow eridanus chain id in proposals
AbbasAliLokhandwala Sep 12, 2024
e70a450
fix: chain switch activity issue
AbbasAliLokhandwala Sep 17, 2024
128cdd6
fix: saving proposals from graphql api in proposal store
AbbasAliLokhandwala Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { observer } from "mobx-react-lite";
import React, { FunctionComponent, useEffect, useState } from "react";
import { CHAIN_ID_DORADO, CHAIN_ID_FETCHHUB } from "../../../config.ui.var";
import { useStore } from "../../../stores";
import { FilterDropdown, FilterActivities } from "../filter";
import { ActivityRow } from "./activity-row";
import { FilterActivities, FilterDropdown } from "../filter";
import { NoActivity } from "../no-activity";
import { govOptions } from "../utils";
import { CHAIN_ID_DORADO, CHAIN_ID_FETCHHUB } from "../../../config.ui.var";
import { UnsupportedNetwork } from "../unsupported-network";
import { observer } from "mobx-react-lite";
import { govOptions } from "../utils";
import { ActivityRow } from "./activity-row";

export const GovProposalsTab: FunctionComponent<{ latestBlock: any }> =
observer(({}) => {
Expand All @@ -22,7 +22,6 @@ export const GovProposalsTab: FunctionComponent<{ latestBlock: any }> =
const [isSaveChangesButtonDisabled, setIsSaveChangesButtonDisabled] =
useState(true);
const proposalNodes = activityStore.sortedNodesProposals;

const accountOrChainChanged =
activityStore.getAddress !== accountInfo.bech32Address ||
activityStore.getChainId !== current.chainId;
Expand Down
5 changes: 5 additions & 0 deletions packages/fetch-extension/src/pages-new/activity/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ export const fetchProposalNodes = async (
if (fetchedData) {
parsedNodes = fetchedData.nodes.map((node: any) => ({
...node,
transaction: {
...node.transaction,
chainId,
signerAddress: bech32Address,
},
proposalId: getProposalIdFromLogs(node.transaction.log),
}));
return parsedNodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ButtonV2 } from "@components-v2/buttons/button";
import { Card } from "@components-v2/card";
import { TXNTYPE } from "../../config";
import { FeeButtons } from "@components-v2/form/fee-buttons-v2";
import { navigateOnTxnEvents } from "@utils/navigate-txn-event";

export const FetchhubBridge: FunctionComponent<{
limit: string;
Expand Down Expand Up @@ -105,7 +106,14 @@ export const FetchhubBridge: FunctionComponent<{
},
{
onBroadcasted() {
navigate("/bridge");
const txnNavigationOptions = {
redirect: () => {
navigate("/bridge");
},
txInProgress: accountInfo.txInProgress,
txType: TXNTYPE.nativeBridgeSend,
};
navigateOnTxnEvents(txnNavigationOptions);
analyticsStore.logEvent("Bridge token tx broadcasted", {
chainId: chainStore.current.chainId,
chainName: chainStore.current.chainName,
Expand Down Expand Up @@ -135,12 +143,26 @@ export const FetchhubBridge: FunctionComponent<{
},
});
}
navigate("/");
const txnNavigationOptions = {
redirect: () => {
navigate("/");
},
txInProgress: accountInfo.txInProgress,
txType: TXNTYPE.nativeBridgeSend,
};
navigateOnTxnEvents(txnNavigationOptions);
},
}
);
} catch (e) {
navigate("/", { replace: true });
const txnNavigationOptions = {
redirect: () => {
navigate("/");
},
txInProgress: accountInfo.txInProgress,
txType: TXNTYPE.nativeBridgeSend,
};
navigateOnTxnEvents(txnNavigationOptions);
notification.push({
type: "warning",
placement: "top-center",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Card } from "@components-v2/card";
import { Dropdown } from "@components-v2/dropdown";
import { SetKeyRingPage } from "../../keyring-dev";
import { TXNTYPE } from "../../../config";
import { navigateOnTxnEvents } from "@utils/navigate-txn-event";

export const IBCTransferPage: FunctionComponent = observer(() => {
const navigate = useNavigate();
Expand Down Expand Up @@ -169,7 +170,14 @@ export const IBCTransferPage: FunctionComponent = observer(() => {
}
);

navigate("/");
const txnNavigationOptions = {
redirect: () => {
navigate("/");
},
txInProgress: accountInfo.txInProgress,
txType: TXNTYPE.ibcTransfer,
};
navigateOnTxnEvents(txnNavigationOptions);
} catch (e) {
analyticsStore.logEvent("ibc_txn_broadcasted_fail", {
chainId: chainStore.current.chainId,
Expand All @@ -179,7 +187,14 @@ export const IBCTransferPage: FunctionComponent = observer(() => {
toChainName,
message: e?.message ?? "",
});
navigate("/", { replace: true });
const txnNavigationOptions = {
redirect: () => {
navigate("/", { replace: true });
},
txInProgress: accountInfo.txInProgress,
txType: TXNTYPE.ibcTransfer,
};
navigateOnTxnEvents(txnNavigationOptions);
notification.push({
type: "warning",
placement: "top-center",
Expand Down
21 changes: 16 additions & 5 deletions packages/fetch-extension/src/pages-new/more/proposals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { getFilteredProposals } from "@utils/filters";
import { observer } from "mobx-react-lite";
import { useNavigate } from "react-router";
import { ProposalType } from "src/@types/proposal-type";
import { CHAIN_ID_DORADO, CHAIN_ID_FETCHHUB } from "../../../config.ui.var";
import {
CHAIN_ID_DORADO,
CHAIN_ID_ERIDANUS,
CHAIN_ID_FETCHHUB,
} from "../../../config.ui.var";
import { ErrorActivity } from "../../activity/error-activity";
import { NoActivity } from "../../activity/no-activity";
import { UnsupportedNetwork } from "../../activity/unsupported-network";
Expand Down Expand Up @@ -152,10 +156,7 @@ export const Proposals = observer(() => {
</div>
}
>
{current.chainId === CHAIN_ID_FETCHHUB ||
current.chainId === CHAIN_ID_DORADO ||
current.chainId === "test" ||
current.chainId === "test-local" ? (
{isChainIdSupported(current.chainId) ? (
isError ? (
<ErrorActivity />
) : proposals && Object.keys(proposals).length > 0 ? (
Expand Down Expand Up @@ -303,3 +304,13 @@ const GovtProposalFilterDropdown = ({
</Dropdown>
);
};

const isChainIdSupported = (chainId: string) => {
return (
chainId === CHAIN_ID_FETCHHUB ||
chainId === CHAIN_ID_DORADO ||
chainId === CHAIN_ID_ERIDANUS ||
chainId === "test" ||
chainId === "test-local"
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import React, { useState } from "react";
import { useNavigate } from "react-router";
import { useStore } from "../../../../stores";
import { ButtonV2 } from "@components-v2/buttons/button";
import { TXNTYPE } from "../../../../config";
import { navigateOnTxnEvents } from "@utils/navigate-txn-event";

interface VoteDropdownProps {
proposal: ObservableQueryProposal | undefined;
Expand Down Expand Up @@ -66,8 +68,6 @@ export const VoteDropdown = ({ proposal }: VoteDropdownProps) => {
},
}
);

navigate(`/activity?tab=Proposals`, { replace: true });
} catch (e: any) {
analyticsStore.logEvent("vote_txn_broadcasted_fail", {
chainId: chainStore.current.chainId,
Expand Down Expand Up @@ -99,10 +99,16 @@ export const VoteDropdown = ({ proposal }: VoteDropdownProps) => {
duration: 0.25,
},
});
navigate(-2);
navigate(`/activity?tab=Proposals`, { replace: true });
} finally {
setIsSendingTx(false);
const txnNavigationOptions = {
redirect: () => {
navigate(`/activity?tab=Proposals`, { replace: true });
},
txType: TXNTYPE.govVote,
txInProgress: accountInfo.txInProgress,
};
navigateOnTxnEvents(txnNavigationOptions);
}
}
};
Expand Down
117 changes: 99 additions & 18 deletions packages/fetch-extension/src/pages-new/send/send-phase-2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import { TransxStatus } from "@components-v2/transx-status";
import { useLocation } from "react-router";
import { TXNTYPE } from "../../config";
import { FeeButtons } from "@components-v2/form/fee-buttons-v2";
import { getPathname } from "@utils/pathname";
import { useNotification } from "@components/notification";
import { navigateOnTxnEvents } from "@utils/navigate-txn-event";

interface SendPhase2Props {
sendConfigs?: any;
setIsNext?: any;
Expand Down Expand Up @@ -43,6 +47,7 @@ export const SendPhase2: React.FC<SendPhase2Props> = observer(
} = useStore();
const accountInfo = accountStore.getAccount(chainStore.current.chainId);
const navigate = useNavigate();
const notification = useNotification();
const location = useLocation();
const { isFromPhase1 } = location.state || {};
const language = useLanguage();
Expand Down Expand Up @@ -264,38 +269,103 @@ export const SendPhase2: React.FC<SendPhase2Props> = observer(
{
onBroadcastFailed: (e: any) => {
console.log(e);
navigate("/send", {
replace: true,
state: { trnsxStatus: "failed", isNext: true },
});
const txnNavigationOptions = {
redirect: () => {
navigate("/send", {
replace: true,
state: { trnsxStatus: "failed", isNext: true },
});
},
txType: TXNTYPE.send,
txInProgress: accountInfo.txInProgress,
toastNotification: () => {
notification.push({
type: "warning",
placement: "top-center",
duration: 5,
content: `Transaction Failed`,
canDelete: true,
transition: {
duration: 0.25,
},
});
},
};
navigateOnTxnEvents(txnNavigationOptions);
},
onBroadcasted: () => {
analyticsStore.logEvent("Send token tx broadcasted", {
chainId: chainStore.current.chainId,
chainName: chainStore.current.chainName,
feeType: sendConfigs.feeConfig.feeType,
});
navigate("/send", {
replace: true,
state: { trnsxStatus: "pending", isNext: true },
});
const txnNavigationOptions = {
redirect: () => {
navigate("/send", {
replace: true,
state: { trnsxStatus: "pending", isNext: true },
});
},
txType: TXNTYPE.send,
txInProgress: accountInfo.txInProgress,
toastNotification: () => {
notification.push({
type: "primary",
placement: "top-center",
duration: 2,
content: `Transaction broadcasted`,
canDelete: true,
transition: {
duration: 0.25,
},
});
},
};
navigateOnTxnEvents(txnNavigationOptions);
},
onFulfill: () => {
navigate("/send", {
replace: true,
state: { trnsxStatus: "success", isNext: true },
});
onFulfill: (tx: any) => {
const istxnSuccess = tx.code ? false : true;
const txnNavigationOptions = {
redirect: () => {
navigate("/send", {
replace: true,
state: { trnsxStatus: "success", isNext: true },
});
},
pagePathname: "send",
txType: TXNTYPE.send,
txInProgress: accountInfo.txInProgress,
toastNotification: () => {
notification.push({
type: istxnSuccess ? "success" : "danger",
placement: "top-center",
duration: 5,
content: istxnSuccess
? `Transaction Completed`
: `Transaction Failed`,
canDelete: true,
transition: {
duration: 0.25,
},
});
},
};
navigateOnTxnEvents(txnNavigationOptions);
},
}
);
if (!isDetachedPage) {
navigate("/send", {
replace: true,
state: { trnsxStatus: "pending", isNext: true },
});
const currentPathName = getPathname();
if (currentPathName === "send") {
navigate("/send", {
replace: true,
state: { trnsxStatus: "pending", isNext: true },
});
}
}
} catch (e) {
if (!isDetachedPage) {
const currentPathName = getPathname();
if (!isDetachedPage && currentPathName === "send") {
navigate("/send", {
replace: true,
state: {
Expand All @@ -309,6 +379,17 @@ export const SendPhase2: React.FC<SendPhase2Props> = observer(
},
},
});
} else {
notification.push({
type: "warning",
placement: "top-center",
duration: 5,
content: `Transaction Failed`,
canDelete: true,
transition: {
duration: 0.25,
},
});
}
} finally {
// XXX: If the page is in detached state,
Expand Down
Loading
Loading