Skip to content

Commit

Permalink
Fix claimAllSuccess bug and switch to remote host
Browse files Browse the repository at this point in the history
  • Loading branch information
shibatales committed Feb 3, 2024
1 parent 9a83c23 commit cfa3c3d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/routes/staking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,16 @@ const Staking = () => {

setTotalUnclaimed(new BigNumber(0));
setUnclaimedEras({ cores: [], total: 0 });
setClaimAllSuccess(result);
setClaimAllSuccess(true);
refreshQuery();
};

const refreshQuery = () => {
const refreshQuery = useCallback(() => {
if (!claimAllSuccess) return;
reexecuteQuery({ requestPolicy: 'network-only' });
reexecuteCoreQuery({ requestPolicy: 'network-only' });
setClaimAllSuccess(false);
};
}, [claimAllSuccess, reexecuteQuery, reexecuteCoreQuery]);

const disableClaiming = useMemo(() => {
return isWaiting || unclaimedEras.total === 0 && totalUnclaimed.toNumber() === 0;
Expand Down Expand Up @@ -525,7 +525,7 @@ const Staking = () => {
if (initialUnclaimed.current === null) {
initialUnclaimed.current = totalUnclaimed;
}
}, [selectedAccount, rewardsUserClaimedQuery.fetching, rewardsUserClaimedQuery.data, claimAllSuccess]);
}, [selectedAccount, rewardsUserClaimedQuery.fetching, rewardsUserClaimedQuery.data, claimAllSuccess, refreshQuery]);

useEffect(() => {
if (rewardsCoreClaimedQuery.fetching || !rewardsCoreClaimedQuery.data?.cores?.length || !selectedAccount) return;
Expand Down
4 changes: 2 additions & 2 deletions src/stores/rpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type RPCState = {
};

const useRPC = createWithEqualityFn<RPCState>()((set, get) => ({
// host: host.REMOTE,
host: host.LOCAL,
host: host.REMOTE,
// host: host.LOCAL,
setHost: (host: Host) => set(() => ({ host })),
error: null,
createApi: async (options) => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/restakeClaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const restakeClaim = async ({
uniqueCores.forEach(core => {
if (!core?.earliestEra) return;
const restakeUnclaimedAmount = handleRestakingLogic(undefined, uniqueCores.length);
if (restakeUnclaimedAmount && !restakeUnclaimedAmount.isZero()) {
if (restakeUnclaimedAmount && restakeUnclaimedAmount.isGreaterThan(0)) {
const restakeAmountInteger = restakeUnclaimedAmount.integerValue().toString();
batch.push(api.tx.ocifStaking.stake(core.coreId, restakeAmountInteger));
}
Expand Down Expand Up @@ -110,7 +110,7 @@ export const restakeClaim = async ({
// Send the transaction batch
// Casting batch to the correct type to satisfy the linting error
const castedBatch = rebuildBatch as Vec<Call>;

// FIX: Changed the batchAll to batch to solve the claim issues.
// Issue is caused by batchAll failing when trying to claim an era where stake == 0, prob due to stake being moved to another core.
// TODO: Proper solution is to still use batchAll but not attempt to claim eras where stake == 0
Expand Down

0 comments on commit cfa3c3d

Please sign in to comment.