Skip to content

Commit

Permalink
Fix/donkeys empty balance (#2611)
Browse files Browse the repository at this point in the history
* Merge into main (#2603)

* Fix missing arrival when sending lords & donkeys (#2594)

* contracts: fix share points check

* contracts: fix share points check

* Add resource filter for contributions (#2596)

* Add resource filter for contributions

* Change % for specific resource contribution

* Fix missing donkeys in bridge step 2 (#2598)

* Fix missing donkeys in bridge step 2

* fix rerenders

* Remove filter

* Fix registration delay (#2602)

* Fix registration delay

* styling

* Open popup on load

* Add burned donkeys back (#2601)

---------

Co-authored-by: Credence <[email protected]>
Co-authored-by: Loaf <[email protected]>

* merge into main (#2605)

* Fix missing arrival when sending lords & donkeys (#2594)

* contracts: fix share points check

* contracts: fix share points check

* Add resource filter for contributions (#2596)

* Add resource filter for contributions

* Change % for specific resource contribution

* Fix missing donkeys in bridge step 2 (#2598)

* Fix missing donkeys in bridge step 2

* fix rerenders

* Remove filter

* Fix registration delay (#2602)

* Fix registration delay

* styling

* Open popup on load

* Add burned donkeys back (#2601)

* im (#2604)

---------

Co-authored-by: Credence <[email protected]>
Co-authored-by: Loaf <[email protected]>

* Fix build (#2610)

* filter out donkeys w/ empty balance

---------

Co-authored-by: Credence <[email protected]>
Co-authored-by: Loaf <[email protected]>
  • Loading branch information
3 people authored Dec 27, 2024
1 parent a890d42 commit 2185bcb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
37 changes: 17 additions & 20 deletions landing/src/components/modules/bridge-out-step-2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,23 @@ export const BridgeOutStep2 = () => {
const [selectedDonkeys, setSelectedDonkeys] = useState<Set<bigint>>(new Set());
const [isTableOpen, setIsTableOpen] = useState(false);

const updateResourcesFromSelectedDonkeys = useMemo(
() => (selectedDonkeyIds: Set<bigint>) => {
const allResources = Array.from(selectedDonkeyIds).flatMap(
(id) =>
donkeyInfos?.find((d) => d?.donkeyEntityId && BigInt(d.donkeyEntityId) === id)?.donkeyResourceBalances || [],
);
const updateResourcesFromSelectedDonkeys = (selectedDonkeyIds: Set<bigint>) => {
const allResources = Array.from(selectedDonkeyIds).flatMap(
(id) =>
donkeyInfos?.find((d) => d?.donkeyEntityId && BigInt(d.donkeyEntityId) === id)?.donkeyResourceBalances || [],
);

setSelectedResourceIds(allResources.map((r) => r.resourceId as never));
setSelectedResourceAmounts(
allResources.reduce(
(acc, r) => ({
...acc,
[r.resourceId]: (acc[r.resourceId] || 0) + r.amount / RESOURCE_PRECISION,
}),
{},
),
);
},
[donkeyInfos, selectedDonkeys],
);
setSelectedResourceIds(allResources.map((r) => r.resourceId as never));
setSelectedResourceAmounts(
allResources.reduce(
(acc, r) => ({
...acc,
[r.resourceId]: (acc[r.resourceId] || 0) + r.amount / RESOURCE_PRECISION,
}),
{},
),
);
};

useEffect(() => {
const newSelected = new Set<bigint>();
Expand All @@ -115,7 +112,7 @@ export const BridgeOutStep2 = () => {
newSelected.add(BigInt(donkey?.donkeyEntityId || 0));
}
});
}, [donkeyInfos, selectedDonkeys]);
}, [donkeyInfos]);

const handleRefresh = () => {
setIsRefreshing(true);
Expand Down
7 changes: 4 additions & 3 deletions landing/src/hooks/helpers/useDonkeyArrivals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export function useDonkeyArrivals(realmEntityIds: ID[]) {
queryKey: ["donkeyEntityIds", realmId],
queryFn: () => execute(GET_ETERNUM_ENTITY_OWNERS, { entityOwnerIds: [realmId] }),
enabled: !!realmId,
refetchInterval: 10_000,
staleTime: 5000,
refetchInterval: 100_000,
})),
});

Expand Down Expand Up @@ -110,7 +109,9 @@ export function useDonkeyArrivals(realmEntityIds: ID[]) {
};

const donkeyInfos = useMemo(() => {
return donkeysAtBank?.map((donkey) => donkey && getDonkeyInfo(donkey));
return donkeysAtBank
?.map((donkey) => donkey && getDonkeyInfo(donkey))
.filter((info) => info?.donkeyResourceBalances.some((balance) => Number(balance.amount) > 0));
}, [donkeysAtBank, donkeyResources]);

return {
Expand Down

0 comments on commit 2185bcb

Please sign in to comment.