mirror of
https://github.com/pezkuwichain/pezkuwi-extension.git
synced 2026-11-21 05:20:01 +00:00
- Update all copyright headers from 2025 to 2026 - Fix @polkadot references to @pezkuwi in config files - Fix eslint.config.js import path Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
34 lines
1002 B
TypeScript
34 lines
1002 B
TypeScript
// Copyright 2019-2026 @pezkuwi/extension-base authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { InjectedAccount, InjectedAccounts, Unsubcall } from '@pezkuwi/extension-inject/types';
|
|
import type { SendRequest } from './types.js';
|
|
|
|
// External to class, this.# is not private enough (yet)
|
|
let sendRequest: SendRequest;
|
|
|
|
export default class Accounts implements InjectedAccounts {
|
|
constructor (_sendRequest: SendRequest) {
|
|
sendRequest = _sendRequest;
|
|
}
|
|
|
|
public get (anyType?: boolean): Promise<InjectedAccount[]> {
|
|
return sendRequest('pub(accounts.list)', { anyType });
|
|
}
|
|
|
|
public subscribe (cb: (accounts: InjectedAccount[]) => unknown): Unsubcall {
|
|
let id: string | null = null;
|
|
|
|
sendRequest('pub(accounts.subscribe)', null, cb)
|
|
.then((subId): void => {
|
|
id = subId;
|
|
})
|
|
.catch(console.error);
|
|
|
|
return (): void => {
|
|
id && sendRequest('pub(accounts.unsubscribe)', { id })
|
|
.catch(console.error);
|
|
};
|
|
}
|
|
}
|