Return object in onScan result (#195)

This commit is contained in:
Jaco Greeff
2019-09-01 16:00:13 +02:00
committed by GitHub
parent 1e58e6f5cf
commit f30a94b2bc
3 changed files with 18 additions and 4 deletions
+7 -2
View File
@@ -11,9 +11,14 @@ import { ADDRESS_PREFIX } from './constants';
import QrScan from './Scan';
import { decodeAddress } from '@polkadot/util-crypto';
interface ScanType {
address: string;
genesisHash: string;
}
interface Props extends BaseProps {
onError?: (error: Error) => void;
onScan?: (aqddress: string, genesisHash: string) => void;
onScan?: (scanned: ScanType) => void;
}
export default class ScanAddress extends React.PureComponent<Props> {
@@ -44,7 +49,7 @@ export default class ScanAddress extends React.PureComponent<Props> {
assert(prefix === ADDRESS_PREFIX, `Invalid address received, expected '${ADDRESS_PREFIX}', found '${prefix}'`);
decodeAddress(address);
onScan(address, genesisHash);
onScan({ address, genesisHash });
} catch (error) {
console.error('@polkadot/react-qr:QrScanAddress', error.message, data);
}
+7 -2
View File
@@ -5,13 +5,18 @@
import { BaseProps } from './types';
import React from 'react';
import { u8aToHex } from '@polkadot/util';
import QrScan from './Scan';
import { encodeString } from './util';
interface ScanType {
signature: string;
}
interface Props extends BaseProps {
onError?: (error: Error) => void;
onScan?: (data: Uint8Array) => void;
onScan?: (scanned: ScanType) => void;
}
export default class ScanSignature extends React.PureComponent<Props> {
@@ -36,6 +41,6 @@ export default class ScanSignature extends React.PureComponent<Props> {
return;
}
onScan(encodeString(data));
onScan({ signature: u8aToHex(encodeString(data)) });
}
}
+4
View File
@@ -1,5 +1,9 @@
{
"extends": "./tsconfig.json",
"exclude": [
"build",
"packages/*/build"
],
"include": [
"packages/**/*.d.ts",
"packages/**/*.ts",