ghost-extension-wallet/src/background/chains.ts
Uncle Stretch d79bbfe668
update extension to be compatible with PAPI
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2026-11-05 21:56:26 +03:00

25 lines
699 B
TypeScript

import { networks } from "../constants"
import * as storage from "./storage"
const CHAIN_KEY_PREIFX = "selected_chain_id"
export const createChainStorage = () => {
const getActiveChainId = async (): Promise<String> => {
let activeChainId = await storage.get(CHAIN_KEY_PREIFX)
if (!activeChainId) {
activeChainId = networks.at(0)?.chainId;
await setActiveChainId(activeChainId)
}
return activeChainId
}
const setActiveChainId = async (activeChainId: String | undefined): Promise<void> => {
await storage.set(CHAIN_KEY_PREIFX, activeChainId)
}
return {
getActiveChainId,
setActiveChainId,
}
}