Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Fix reading undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 committed Sep 20, 2024
1 parent 8293cb7 commit d5bd1f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/hooks/use-collator-power.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ export const useCollatorPower = (
let sub$$: Subscription | undefined;

if (polkadotApi) {
sub$$ = from(polkadotApi.query.darwiniaStaking.exposureCacheStates())
sub$$ = from(
polkadotApi.query.darwiniaStaking.exposureCacheStates
? polkadotApi.query.darwiniaStaking.exposureCacheStates()
: polkadotApi.query.darwiniaStaking.cacheStates()
)
.pipe(
switchMap((cacheStates) => {
const index = (cacheStates.toJSON() as ExposureCacheState[]).findIndex((cs) => cs === "Current");
Expand Down
2 changes: 1 addition & 1 deletion src/providers/staking-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function StakingProvider({ children }: PropsWithChildren<unknown>) {
const calcExtraPower = useCallback((stakingRing: bigint, stakingKton: bigint) => stakingRing + stakingKton, []);

useEffect(() => {
setMinimumDeposit(BigInt(polkadotApi?.consts.deposit.minLockingAmount.toString() || 0));
setMinimumDeposit(BigInt(polkadotApi?.consts.deposit.minLockingAmount?.toString() || 0));
setMaxCommission(Number(polkadotApi?.consts.darwiniaStaking.maxCommission?.toJSON() || 1000000000) / 10000000);
}, [polkadotApi]);

Expand Down

0 comments on commit d5bd1f5

Please sign in to comment.