ghost-keychain/packages/extension-base/src/background/RequestBytesSign.ts
Jaco 1783054288
Bump deps (#878)
* Bump deps

* linting type fixes
2021-11-06 20:51:57 +02:00

30 lines
880 B
TypeScript

// Copyright 2019-2021 @polkadot/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { KeyringPair } from '@polkadot/keyring/types';
import type { SignerPayloadRaw } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import type { RequestSign } from './types';
import { wrapBytes } from '@polkadot/extension-dapp/wrapBytes';
import { TypeRegistry } from '@polkadot/types';
import { u8aToHex } from '@polkadot/util';
export default class RequestBytesSign implements RequestSign {
public readonly payload: SignerPayloadRaw;
constructor (payload: SignerPayloadRaw) {
this.payload = payload;
}
sign (_registry: TypeRegistry, pair: KeyringPair): { signature: HexString } {
return {
signature: u8aToHex(
pair.sign(
wrapBytes(this.payload.data)
)
)
};
}
}