Skip to content

Commit

Permalink
chore: filter delegations
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor committed Feb 27, 2024
1 parent 35a454a commit 8c445c4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const useProxy = false;
const useProxy = true;

const nextConfig = {
eslint: {
Expand Down
16 changes: 14 additions & 2 deletions src/features/staking/context/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,19 @@ const getUniqueValidators = (
// @TODO
const getUniqueDelegations = (
delegations: NonNullable<StakingState["delegations"]>["items"],
) => delegations;
) => {
const validatorIds = new Set<string>();

return delegations.filter((delegation) => {
if (validatorIds.has(delegation.validatorAddress)) {
return false;
}

validatorIds.add(delegation.validatorAddress);

return true;
});
};

export const reducer = (state: StakingState, action: StakingAction) => {
switch (action.type) {
Expand Down Expand Up @@ -92,7 +104,7 @@ export const reducer = (state: StakingState, action: StakingAction) => {
currentDelegations.currentPage += 1;

currentDelegations.items = getUniqueDelegations(
currentDelegations.items.concat(action.content.items),
action.content.items.concat(currentDelegations.items),
);

return {
Expand Down
1 change: 1 addition & 0 deletions src/features/staking/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export const dashboardUrl =
// : `${window.location.origin}/rpc`;

export const rpcEndpoint = "https://rpc.xion-testnet-1.burnt.com:443";
// export const rpcEndpoint = "https://rpc.xion-testnet.forbole.com";

0 comments on commit 8c445c4

Please sign in to comment.