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 1 commit
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
Prev Previous commit
Next Next commit
refactor: code cleanup activity node creation logic
  • Loading branch information
AbbasAliLokhandwala committed Sep 13, 2024
commit e1ed273813f49edc7819a45d674e76dbf8dc68b7
45 changes: 18 additions & 27 deletions packages/stores/src/account/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import deepmerge from "deepmerge";
import { Buffer } from "buffer/";
import { MakeTxResponse, ProtoMsgsOrWithAminoMsgs } from "./types";
import {
getActivityNode,
getEip712TypedDataBasedOnChainId,
getNodes,
getProposalNode,
Expand Down Expand Up @@ -450,29 +451,6 @@ export class CosmosAccountImpl {

const { nodes, balanceOffset, signerAddress } = getNodes(msgs, type);

const newNode: Node = {
balanceOffset,
type,
block: {
timestamp: new Date().toJSON(),
__typename: "Block",
},
id: txId,
transaction: {
fees: JSON.stringify(signDoc.fee.amount),
chainId: signDoc.chain_id,
gasUsed: fee.gas,
id: txId,
memo: memo,
signerAddress,
status: "Pending",
timeoutHeight: "0",
messages: {
nodes,
},
},
};

if (type === "govVote") {
proposalNode = getProposalNode({
txId,
Expand All @@ -483,8 +461,19 @@ export class CosmosAccountImpl {
nodes,
});
this.activityStore.addProposalNode(proposalNode);
} else {
const newNode: Node = getActivityNode({
balanceOffset,
signerAddress,
txId,
signDoc,
type,
fee,
memo,
nodes,
});
this.activityStore.addNode(newNode);
}
this.activityStore.addNode(newNode);
this.activityStore.addPendingTxn({ id: txId, type });
} catch (e: any) {
this.base.setTxTypeInProgress("");
Expand Down Expand Up @@ -549,9 +538,10 @@ export class CosmosAccountImpl {
proposalNode.id,
this.activityStore
);
} else {
//update node's gas, amount and status on completed
updateNodeOnTxnCompleted(type, tx, txId, this.activityStore);
}
//update node's gas, amount and status on completed
updateNodeOnTxnCompleted(type, tx, txId, this.activityStore);
this.activityStore.removePendingTxn(txId);

this.base.setTxTypeInProgress("");
Expand Down Expand Up @@ -584,12 +574,13 @@ export class CosmosAccountImpl {
})
.catch(() => {
this.activityStore.removePendingTxn(txId);
this.activityStore.setTxnStatus(txId, "Unconfirmed");
if (type === "govVote") {
this.activityStore.setProposalTxnStatus(
proposalNode.id,
"Unconfirmed"
);
} else {
this.activityStore.setTxnStatus(txId, "Unconfirmed");
}
this.base.setTxTypeInProgress("");
this.activityStore.setIsNodeUpdated(true);
Expand Down
54 changes: 53 additions & 1 deletion packages/stores/src/account/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { EthermintChainIdHelper } from "@keplr-wallet/cosmos";
import { ProtoMsgsOrWithAminoMsgs } from "./types";
import { ProposalNode } from "./cosmos";
import { Node } from "./cosmos";
import { ActivityStore } from "src/activity";

export function txEventsWithPreOnFulfill(
Expand Down Expand Up @@ -327,7 +328,7 @@ export const getProposalNode = ({
fee: any;
memo: string;
nodes: Array<any>;
}): ProposalNode => {
}) => {
const option = Number(signDoc.msgs[0].value.option);
const optionText = (() => {
switch (option) {
Expand Down Expand Up @@ -367,3 +368,54 @@ export const getProposalNode = ({

return proposalNode;
};

export const getActivityNode = ({
balanceOffset,
signerAddress,
txId,
signDoc,
type,
fee,
memo,
nodes,
}: {
balanceOffset: string;
signerAddress: string;
txId: string;
signDoc: any;
type: string;
fee: any;
memo: string;
nodes: [
{
json: string;
typeUrl: string;
__typename: string;
}
];
}) => {
const newNode: Node = {
balanceOffset,
type,
block: {
timestamp: new Date().toJSON(),
__typename: "Block",
},
id: txId,
transaction: {
fees: JSON.stringify(signDoc.fee.amount),
chainId: signDoc.chain_id,
gasUsed: fee.gas,
id: txId,
memo: memo,
signerAddress,
status: "Pending",
timeoutHeight: "0",
messages: {
nodes,
},
},
};

return newNode;
};