Files
pezkuwi-extension/packages/extension-base/src/page/Accounts.ts
T
Kurdistan Tech MinistryandClaude Opus 4.5 5d54192e6d chore: update copyright years to 2026 and fix lint issues
- 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>
2026-01-09 01:22:46 +03:00

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);
};
}
}