Files
pezkuwi-extension/packages/extension-base/src/page/Signer.ts
T
pezkuwichain 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

46 lines
1.4 KiB
TypeScript

// Copyright 2019-2026 @pezkuwi/extension-base authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Signer as SignerInterface, SignerResult } from '@pezkuwi/api/types';
import type { SignerPayloadJSON, SignerPayloadRaw } from '@pezkuwi/types/types';
import type { SendRequest } from './types.js';
// External to class, this.# is not private enough (yet)
let sendRequest: SendRequest;
let nextId = 0;
export default class Signer implements SignerInterface {
constructor (_sendRequest: SendRequest) {
sendRequest = _sendRequest;
}
public async signPayload (payload: SignerPayloadJSON): Promise<SignerResult> {
const id = ++nextId;
const result = await sendRequest('pub(extrinsic.sign)', payload);
// we add an internal id (number) - should have a mapping from the
// extension id (string) -> internal id (number) if we wish to provide
// updated via the update functionality (noop at this point)
return {
...result,
id
};
}
public async signRaw (payload: SignerPayloadRaw): Promise<SignerResult> {
const id = ++nextId;
const result = await sendRequest('pub(bytes.sign)', payload);
return {
...result,
id
};
}
// NOTE We don't listen to updates at all, if we do we can interpret the
// result as provided by the API here
// public update (id: number, status: Hash | SubmittableResult): void {
// // ignore
// }
}