UNPKG

@turnkey/core

Version:

A core JavaScript web and React Native package for interfacing with Turnkey's infrastructure.

34 lines (31 loc) 1.23 kB
import { WebWalletManager } from './web/manager.mjs'; import { isReactNative, isWeb } from '../utils.mjs'; import { MobileWalletManager } from './mobile/manager.mjs'; /** * Creates and initializes a wallet manager instance based on the runtime environment. * * - If the environment is React Native, it creates and initializes a `MobileWalletManager`. * - If the environment is Web, it creates and initializes a `WebWalletManager`. * - Throws an error if the environment is neither supported. * * @param cfg - Configuration object used to initialize the wallet manager. * @returns A promise that resolves to an initialized `WalletManagerBase` instance. * @throws {Error} If the environment is not supported (neither React Native nor Web). */ async function createWalletManager(cfg) { if (isReactNative()) { const manager = new MobileWalletManager(cfg); await manager.init(cfg); return manager; } else if (isWeb()) { const manager = new WebWalletManager(cfg); await manager.init(cfg); return manager; } else { throw new Error("Unsupported environment for wallet manager"); } } export { createWalletManager }; //# sourceMappingURL=base.mjs.map