Skip to content

Commit

Permalink
fix(wallet): don't require to be subscribed to request addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jul 23, 2023
1 parent e2ffc25 commit 36920b4
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/AeSdkWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ export default class AeSdkWallet extends AeSdk {
_pushAccountsToApps(): void {
if (this._clients == null) return;
Array.from(this._clients.keys())
.filter((clientId) => this._isRpcClientSubscribed(clientId))
.map((clientId) => this._getClient(clientId).rpc)
.forEach((client) => client.notify(METHODS.updateAddress, this.getAccounts()));
.filter((clientId) => this._isRpcClientConnected(clientId))
.map((clientId) => this._getClient(clientId))
.filter((client) => client.addressSubscription.size !== 0)
.forEach((client) => client.rpc.notify(METHODS.updateAddress, this.getAccounts()));
}

override selectAccount(address: Encoded.AccountAddress): void {
Expand Down Expand Up @@ -149,11 +150,6 @@ export default class AeSdkWallet extends AeSdk {
return client;
}

_isRpcClientSubscribed(clientId: string): boolean {
return this._isRpcClientConnected(clientId)
&& this._getClient(clientId).addressSubscription.size !== 0;
}

_isRpcClientConnected(clientId: string): boolean {
return RPC_STATUS.CONNECTED === this._getClient(clientId).status
&& this._getClient(clientId).rpc.connection.isConnected();
Expand Down Expand Up @@ -238,7 +234,7 @@ export default class AeSdkWallet extends AeSdk {
};
},
[METHODS.address]: async (params, origin) => {
if (!this._isRpcClientSubscribed(id)) throw new RpcNotAuthorizeError();
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
await this.onAskAccounts(id, params, origin);
return this.addresses();
},
Expand Down

0 comments on commit 36920b4

Please sign in to comment.