23 lines
794 B
TypeScript
23 lines
794 B
TypeScript
// Copyright 2019-2024 @polkadot/extension-base authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { KeyringPair } from '@polkadot/keyring/types';
|
|
import type { TypeRegistry } from '@polkadot/types';
|
|
import type { SignerPayloadJSON } from '@polkadot/types/types';
|
|
import type { HexString } from '@polkadot/util/types';
|
|
import type { RequestSign } from './types.js';
|
|
|
|
export default class RequestExtrinsicSign implements RequestSign {
|
|
public readonly payload: SignerPayloadJSON;
|
|
|
|
constructor (payload: SignerPayloadJSON) {
|
|
this.payload = payload;
|
|
}
|
|
|
|
sign (registry: TypeRegistry, pair: KeyringPair): { signature: HexString } {
|
|
return registry
|
|
.createType('ExtrinsicPayload', this.payload, { version: this.payload.version })
|
|
.sign(pair);
|
|
}
|
|
}
|