Skip to content

Commit

Permalink
chore: fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjasiuk committed Aug 29, 2024
1 parent ab70b19 commit 7b11581
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apps/namadillo/src/atoms/proposals/atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const canVoteAtom = atomFamily((proposalStartEpoch: bigint) =>
const api = get(indexerApiAtom);

return {
queryKey: ["can-vote"],
queryKey: ["can-vote", account.data, api],
enabled: account.isSuccess,
queryFn: async () => {
const all_bonds = await api.apiV1PosBondAddressGet(
Expand Down
2 changes: 1 addition & 1 deletion apps/namadillo/src/atoms/validators/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const toMyValidators = (
const addBondToAddress = (
address: Address,
key: "bondItems" | "unbondItems",
bond: IndexerBond | IndexerUnbond
bond: IndexerBond | IndexerMergedBond | IndexerUnbond
): void => {
const { validator: _, ...bondsWithoutValidator } = bond;
myValidators[address]![key].push(bondsWithoutValidator);
Expand Down
20 changes: 3 additions & 17 deletions apps/namadillo/src/hooks/useTransactionCallbacks.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { accountBalanceAtom } from "atoms/accounts";
import { shouldUpdateBalanceAtom, shouldUpdateProposalAtom } from "atoms/etc";
import { proposalFamily, votedProposalIdsAtom } from "atoms/proposals";
import { createStore, useAtomValue, useSetAtom } from "jotai";
import { useAtomValue, useSetAtom } from "jotai";
import { useTransactionEventListener } from "utils";

export const useTransactionCallback = (): void => {
const { refetch: refetchBalances } = useAtomValue(accountBalanceAtom);
const shouldUpdateBalance = useSetAtom(shouldUpdateBalanceAtom);
const shouldUpdateProposal = useSetAtom(shouldUpdateProposalAtom);

const onBalanceUpdate = (): void => {
// TODO: refactor this after event subscription is enabled on indexer
Expand All @@ -22,23 +20,11 @@ export const useTransactionCallback = (): void => {
useTransactionEventListener("Unbond.Success", onBalanceUpdate);
useTransactionEventListener("Withdraw.Success", onBalanceUpdate);

const store = createStore();
const shouldUpdateProposal = useSetAtom(shouldUpdateProposalAtom);

useTransactionEventListener("VoteProposal.Success", (args) => {
// TODO: refactor this after event subscription is enabled on indexer
useTransactionEventListener("VoteProposal.Success", () => {
shouldUpdateProposal(true);

// [0] is fine for time being as we can only vote for one proposal at a time
const proposalId = args.detail.data[0].proposalId;
const { refetch: refetchProposalFamily } = store.get(
proposalFamily(proposalId)
);
refetchProposalFamily();

const { refetch: refetchVotedProposalIds } =
store.get(votedProposalIdsAtom);
refetchVotedProposalIds();

// This does not guarantee that the proposal will be updated,
// but because this is temporary solution(don't quote me on this), it should be fine :)
const timePolling = 12 * 1000;
Expand Down

0 comments on commit 7b11581

Please sign in to comment.