mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-06-12 15:31:07 +00:00
Return object in onScan result (#195)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)) });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": [
|
||||
"build",
|
||||
"packages/*/build"
|
||||
],
|
||||
"include": [
|
||||
"packages/**/*.d.ts",
|
||||
"packages/**/*.ts",
|
||||
|
||||
Reference in New Issue
Block a user