Skip to content

Commit

Permalink
refactor(wallet-rpc)!: remove meta, condition unused by known wallets
Browse files Browse the repository at this point in the history
BREAKING CHANGE: wallet can't selectively notify aepps about selecting/adding account
If you need this feature, create a custom wallet implementation.

BREAKING CHANGE: wallet can't provide metadata for accounts
If you need this feature, create a custom wallet implementation.
  • Loading branch information
davidyuk committed Jun 7, 2022
1 parent 7155ed3 commit 4630643
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/utils/aepp-wallet-communication/rpc/wallet-rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,11 @@ export default Ae.compose(AccountMultiple, {
const _addAccount = this.addAccount.bind(this)
const _selectNode = this.selectNode.bind(this)

// Overwrite AE methods
this.selectAccount = (address, { condition = () => true } = {}) => {
this.selectAccount = (address) => {
_selectAccount(address)
Object.values(this.rpcClients)
.filter(client => client.isConnected() && client.isSubscribed() &&
client.hasAccessToAccount(address) && condition(client))
client.hasAccessToAccount(address))
.forEach(client => client.setAccounts({
current: { [address]: {} },
connected: {
Expand All @@ -145,23 +144,21 @@ export default Ae.compose(AccountMultiple, {
}
}))
}
this.addAccount = async (account, { select, meta = {}, condition = () => true } = {}) => {
this.addAccount = async (account, { select } = {}) => {
await _addAccount(account, { select })
const address = await account.address()
// Send notification 'update.address' to all Aepp which are subscribed for connected accounts
Object.values(this.rpcClients)
.filter(client => client.isConnected() && client.isSubscribed() && condition(client))
.filter(client => client.isConnected() && client.isSubscribed())
.forEach(client => client.setAccounts({
current: { ...select ? { [address]: meta } : client.accounts.current },
current: { ...select ? { [address]: {} } : client.accounts.current },
connected: {
...select ? client.accounts.current : { [address]: meta },
...select ? client.accounts.current : { [address]: {} },
...client.accounts.connected
}
}))
}
this.selectNode = (name) => {
_selectNode(name)
// Send notification 'update.network' to all Aepp which connected
Object.values(this.rpcClients)
.filter(client => client.isConnected())
.forEach(client => {
Expand Down

0 comments on commit 4630643

Please sign in to comment.