@quirks/core
Version:
35 lines (34 loc) • 1.03 kB
JavaScript
import { Wallet as t } from "./index2.js";
import { assertIsDefined as i } from "./index8.js";
import { getClientFromExtension as s } from "./index7.js";
class d extends t {
constructor(e) {
super(e), this.init(), this.keystoreChange = this.keystoreChange.bind(this);
}
keystoreChange() {
this.events.emit("keystorechange");
}
removeListeners() {
super.removeListeners(), typeof window < "u" && this.options.events && window.removeEventListener(
this.options.events.keystorechange,
this.keystoreChange
);
}
addListeners() {
this.removeListeners(), typeof window < "u" && this.options.events && window.addEventListener(
this.options.events.keystorechange,
this.keystoreChange
);
}
async init() {
i(this.options.windowKey);
try {
return this.client = await s(this.options.windowKey), this.injected = !0, this.client && this.addListeners(), this.client;
} catch (e) {
this.injectionError = e;
}
}
}
export {
d as ExtensionWallet
};