diff --git a/src/connectors/injected/index.ts b/src/connectors/injected/index.ts index 968c152..e117fab 100644 --- a/src/connectors/injected/index.ts +++ b/src/connectors/injected/index.ts @@ -171,6 +171,9 @@ export class InjectedConnector extends Connector { const [account] = accounts const chainId = await this.chainId() + /** + * @dev This emit ensures compatibility with starknet-react + */ this.emit("connect", { account, chainId }) return { @@ -187,6 +190,9 @@ export class InjectedConnector extends Connector { throw new ConnectorNotFoundError() } + /** + * @dev This emit ensures compatibility with starknet-react + */ this.emit("disconnect") } @@ -229,14 +235,23 @@ export class InjectedConnector extends Connector { private async onAccountsChanged(accounts?: string[]): Promise { if (!accounts) { + /** + * @dev This emit ensures compatibility with starknet-react + */ this.emit("disconnect") } else { const [account] = accounts if (account) { const chainId = await this.chainId() + /** + * @dev This emit ensures compatibility with starknet-react + */ this.emit("change", { account, chainId }) } else { + /** + * @dev This emit ensures compatibility with starknet-react + */ this.emit("disconnect") } } @@ -246,8 +261,14 @@ export class InjectedConnector extends Connector { if (chainIdHex) { const chainId = BigInt(chainIdHex) const [account] = accounts || [] + /** + * @dev This emit ensures compatibility with starknet-react + */ this.emit("change", { chainId, account }) } else { + /** + * @dev This emit ensures compatibility with starknet-react + */ this.emit("change", {}) } }