Files
pwap/pezkuwi-sdk-ui/packages/page-staking2/src/useCache.ts
T
pezkuwichain 971df8edba Rebrand: Remove 3rd party chains, update domains to PezkuwiChain
- Remove all 3rd party parachain configurations from endpoints:
  - productionRelayPolkadot.ts: Keep only system parachains
  - productionRelayDicle.ts: Keep only system parachains
  - testingRelayZagros.ts: Keep only system parachains
  - testingRelayTeyrChain.ts: Keep only system parachains

- Update domain references:
  - polkadot.js.org → pezkuwichain.app
  - wiki.polkadot.network → wiki.pezkuwichain.io
  - dotapps.io → pezkuwichain.app
  - statement.polkadot.network → docs.pezkuwichain.io/statement
  - support.polkadot.network → docs.pezkuwichain.io

- Update repository references:
  - github.com/pezkuwi-js/apps → github.com/pezkuwichain/pwap

- Rename system parachains to Pezkuwi ecosystem:
  - PolkadotAssetHub → PezkuwiAssetHub
  - polkadotBridgeHub → pezkuwiBridgeHub
  - polkadotCollectives → pezkuwiCollectives
  - polkadotCoretime → pezkuwiCoretime
  - polkadotPeople → pezkuwiPeople

- Update network name in claims utility:
  - Polkadot → Pezkuwi
2026-01-09 03:08:11 +03:00

58 lines
1.5 KiB
TypeScript

// Copyright 2017-2026 @pezkuwi/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { useEffect } from 'react';
export interface CacheValue<T> {
value?: T;
}
type CacheMapKey = `use${'Exposure' | 'Heartbeat'}`;
type CacheValKey = `use${'ElectedValidators' | 'Points' | 'ValidatorsActive' | 'ValidatorsAll' | 'ValidatorsWaiting'}`;
const cacheMap: Record<CacheMapKey, Record<string, CacheValue<any>>> = {
useExposure: {},
useHeartbeat: {}
};
const cacheVal: Record<CacheValKey, CacheValue<any>> = {
useElectedValidators: {},
usePoints: {},
useValidatorsActive: {},
useValidatorsAll: {},
useValidatorsWaiting: {}
};
export function clearCache (): void {
for (const k of Object.keys(cacheMap)) {
cacheMap[k as CacheMapKey] = {};
}
for (const k of Object.keys(cacheVal)) {
cacheVal[k as CacheValKey] = {};
}
}
export function useCacheMap <T> (section: CacheMapKey, id: string, value?: T): T | undefined {
// update the cached result on value changes
useEffect((): void => {
if (value) {
cacheMap[section][id] = { value };
}
}, [id, section, value]);
return value || (cacheMap[section][id] as CacheValue<T>)?.value;
}
export function useCacheValue <T> (section: CacheValKey, value?: T): T | undefined {
// update the cached result on value changes
useEffect((): void => {
if (value) {
cacheVal[section] = { value };
}
}, [section, value]);
return value || (cacheVal[section] as CacheValue<T>)?.value;
}