ghost-keychain/packages/extension-base/src/background/RequestBytesSign.ts
Jaco Greeff 98d6c66de5
Allow for variable signed extensions, as supplied (#328)
* Allow for variable signed extensions, as supplied

* Small text updates
2020-05-14 10:01:29 +02:00

28 lines
841 B
TypeScript

// Copyright 2019-2020 @polkadot/extension authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { KeyringPair } from '@polkadot/keyring/types';
import { RequestSign } from './types';
import { SignerPayloadRaw } from '@polkadot/types/types';
import { u8aToHex, hexToU8a } from '@polkadot/util';
import { TypeRegistry } from '@polkadot/types';
export default class RequestBytesSign implements RequestSign {
public readonly payload: SignerPayloadRaw;
constructor (payload: SignerPayloadRaw) {
this.payload = payload;
}
sign (_registry: TypeRegistry, pair: KeyringPair): { signature: string } {
return {
signature: u8aToHex(
pair.sign(
hexToU8a(this.payload.data)
)
)
};
}
}