Basic QR tests (+ number encoding fix) (#168)

* Basic QR tests (+ number encoding fix)

* skipEncoding for Address display

* Fixup comments
This commit is contained in:
Jaco Greeff
2019-07-29 17:40:08 +02:00
committed by GitHub
parent 0ad431ba87
commit f7bd11a293
8 changed files with 148 additions and 69 deletions
+3 -9
View File
@@ -5,11 +5,9 @@
import { BaseProps } from './types';
import React from 'react';
import { u8aConcat } from '@polkadot/util';
import { xxhashAsHex } from '@polkadot/util-crypto';
import { ADDRESS_PREFIX } from './constants';
import { encodeString } from './util';
import { createAddressPayload } from './util';
import QrDisplay from './Display';
interface Props extends BaseProps {
@@ -21,8 +19,6 @@ interface State {
dataHash: string | null;
}
const PREFIX = encodeString(ADDRESS_PREFIX);
export default class DisplayExtrinsic extends React.PureComponent<Props, State> {
public state: State = {
data: null,
@@ -30,10 +26,7 @@ export default class DisplayExtrinsic extends React.PureComponent<Props, State>
};
public static getDerivedStateFromProps ({ address }: Props, prevState: State): State | null {
const data = u8aConcat(
PREFIX,
encodeString(address)
);
const data = createAddressPayload(address);
const dataHash = xxhashAsHex(data);
if (dataHash === prevState.dataHash) {
@@ -54,6 +47,7 @@ export default class DisplayExtrinsic extends React.PureComponent<Props, State>
return (
<QrDisplay
className={className}
skipEncoding={true}
style={style}
value={data}
/>