@tezos-x/octez.connect-dapp
Version:
Use this package on your dApp to instanciate a DAppClient object and communicate to wallets.
24 lines • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDAppClientInstance = void 0;
const octez_connect_core_1 = require("@tezos-x/octez.connect-core");
const DAppClient_1 = require("../dapp-client/DAppClient");
const logger = new octez_connect_core_1.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 */
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_1.DAppClient(config);
}
return _instance;
};
exports.getDAppClientInstance = getDAppClientInstance;
//# sourceMappingURL=get-instance.js.map