diff --git a/src/lib/wayfinder.ts b/src/lib/wayfinder.ts index e246d449..6e6cb5f7 100644 --- a/src/lib/wayfinder.ts +++ b/src/lib/wayfinder.ts @@ -27,8 +27,18 @@ const pingUpdater = async ( data: GatewayAddressRegistryItem[], onUpdate: any ) => { - const newData = structuredClone(data); - const pingPromises = data.map((item, index) => async () => { + const CLabs = "CDoilQgKg6Pmp4Q0LJ4d84VXRgB3Ay9pIJ_SA617cVk"; + const CLabsGateway = data.find((item) => item.id === CLabs); + + let newData = structuredClone(data) + .sort((a, b) => b.operatorStake - a.operatorStake) + .slice(0, 5); + + if (CLabsGateway && !newData.some((item) => item.id === CLabsGateway)) { + newData.push(CLabsGateway); + } + + const pingPromises = newData.map((item, index) => async () => { const delayMs = pingStaggerDelayMs * index; await new Promise((resolve) => setTimeout(resolve, delayMs)); diff --git a/src/tokens/aoTokens/ao.ts b/src/tokens/aoTokens/ao.ts index 6beb1f82..df53afa3 100644 --- a/src/tokens/aoTokens/ao.ts +++ b/src/tokens/aoTokens/ao.ts @@ -98,10 +98,13 @@ export function useAoTokens(): [TokenInfoWithBalance[], boolean] { instance: ExtensionStorage }); - const [aoTokens] = useStorage({ - key: "ao_tokens", - instance: ExtensionStorage - }); + const [aoTokens] = useStorage( + { + key: "ao_tokens", + instance: ExtensionStorage + }, + [] + ); // fetch token infos useEffect(() => { @@ -183,10 +186,13 @@ export function useAoTokensCache(): [TokenInfoWithBalance[], boolean] { instance: ExtensionStorage }); - const [aoTokens] = useStorage<(TokenInfo & { processId: string })[]>({ - key: "ao_tokens", - instance: ExtensionStorage - }); + const [aoTokens] = useStorage<(TokenInfo & { processId: string })[]>( + { + key: "ao_tokens", + instance: ExtensionStorage + }, + [] + ); const [aoTokensCache] = useStorage<(TokenInfo & { processId: string })[]>( { key: "ao_tokens_cache", instance: ExtensionStorage },