UNPKG

@tezos-x/octez.connect-dapp

Version:

Use this package on your dApp to instanciate a DAppClient object and communicate to wallets.

20 lines • 849 B
import { Logger } from '@tezos-x/octez.connect-core'; import { DAppClient } from '../dapp-client/DAppClient'; const logger = new Logger('get-instance'); let _instance; /** Get a DAppClient instance. Will make sure only one dAppClient exists. After the first instance has been created, the config will be ignored, unless "reset" is set */ export const getDAppClientInstance = (config, reset) => { if (_instance && reset) { // sync API — kick off cleanup but surface failures rather than swallow. _instance.disconnect().catch((error) => logger.error('[DAppClient] disconnect on reset failed', error)); _instance = undefined; } if (_instance) { return _instance; } if (!_instance) { _instance = new DAppClient(config); } return _instance; }; //# sourceMappingURL=get-instance.js.map