ghost-portal/packages/react-signer/src/LedgerSigner.ts
Jaco Greeff e1464b85f9
Adjust with API with explicit registry (#1922)
* Update for latest API (explicit registry)

* Edgeware adjusted types

* Bump API
2019-11-21 17:04:54 +01:00

23 lines
828 B
TypeScript

// Copyright 2017-2019 @polkadot/react-signer 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 { Signer, SignerResult } from '@polkadot/api/types';
import { SignerPayloadJSON } from '@polkadot/types/types';
import { getLedger, registry } from '@polkadot/react-api';
import { createType } from '@polkadot/types';
export class LedgerSigner implements Signer {
public async signPayload (payload: SignerPayloadJSON): Promise<SignerResult> {
const raw = createType(registry, 'ExtrinsicPayload', payload, { version: payload.version });
const { signature } = await getLedger().sign(raw.toU8a(true));
return { id: 0, signature };
}
}
const ledgerSigner = new LedgerSigner();
export default ledgerSigner;