ghost-keychain/packages/extension-base/src/page/Accounts.ts
Jaco Greeff dec07f6e96
Bump dev (import sorting) (#564)
* Bump dev (import sorting)

* Bump dev
2020-12-08 11:20:57 +01:00

28 lines
854 B
TypeScript

// Copyright 2019-2020 @polkadot/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { InjectedAccount, InjectedAccounts, Unsubcall } from '@polkadot/extension-inject/types';
import type { SendRequest } from './types';
// 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 (): Promise<InjectedAccount[]> {
return sendRequest('pub(accounts.list)');
}
public subscribe (cb: (accounts: InjectedAccount[]) => unknown): Unsubcall {
sendRequest('pub(accounts.subscribe)', null, cb)
.catch((error: Error) => console.error(error));
return (): void => {
// FIXME we need the ability to unsubscribe
};
}
}