Unverified Commit e41ad3f6 authored by YJ's avatar YJ Committed by GitHub
Browse files

UOS Qr Support (rebased on master) (#325)

* feat: wip for adding QR support for UOS

* chore: Squashed old branch

* feat: expose blake2s hash function

* fix: use ui-qr

* fix: add peer dependencies for @polkadot/*

* feat: handle decoding via UOS

* fix: decode substrate payload!

* fix(): network selection

* Update src/components/QrView.js

* fix(): backward compatible

* fix(): Mock for a sparta account, add prefixes for substrate

* fix(): address map for substrate accounts

* fix: Duplicate function names in iOS

* fix(): init with PolaIcon file, types, add ui-shared and react-native-svg

* fix(): add @polkadot/util-crypto

* fix(): add react-native-crypto with override and node-libs-react-native

* fix(): add import 'crypto' in Apps.js

* fix(): add stream-browserify and overrides

* feat: Expose `substrateAddress` in native.js

* fix(): ideenticon visible

* fix: decode from u8a

* fix(): pull in @polkadot/reactnative-identicon

* fix: reformat data for consistency with legacy. temporary placeholdder for native substrateSign

* fix(): remove test files

* fix: update jest config to solve building problem on iOS

* fix(): revert https://github.com/paritytech/parity-signer/pull/300

* fix: qr view

* fix: update npm script for android dev startup

* fix: decoding message and fix the screwed up qr code

* fix: warning when signing payload hash

* fix: remove nodefy and cleanup deps

* fix: re-enable screenshot for debug

* fix: typo

* fix: remove punny dep

* fix: remove polkadot/ui-shared

* fix: remove timers-browsify

* fix: remove string_decoder

* fix: remove buffer

* fix: remove hoist-non-react-statics

* fix: use genesisHash and Address

* fix: make it build

* fix: move parsing logic to store, setup for hadnleing multipart

* fix: store unsignedata

* fix: setData uses scannerstore state unsigned data

* fix: move parse to util

* fix: new account creation with mock

* fix: bring in native blake2s function

* fix: advanced derived path field for new account

* fix: move decores

* fix: use react hooks in AccountIcon

* fix: fix address and nits

* fix: fix genesis in QR

* fix: genesisHash as string

* fix: use real accounts and mnemonic

* fix: refactor

* fix: setup unit tests, vscode debug env

* fix: address encoding

* fix: make tests pass

* fix: multipart unit test

* fix: setup for testing stores

* fix: displaying ascii message to sign, use Kusama adddress in store

* fix: unneeded hexToAscii

* feat: sr25519 signing

* fix: put current account in the state

* fix: decode SCALE

* fix: make tests pass

* feat: Complete SURI derivation

* feat: Expose blake2s proxy function in native.js

* fix: use genesisHash

* fix: use substrateAddress

* fix: recover

* fix: recover derivation

* fix: refactor advanced (derivation path) field

* fix: derivation path validity + refactor

* fix: sign data

* fix: binding for blake2

* fix: display derivation path and link to check pasword

* fix: Added react methods to EthkeyBridge.m

* fix: derivation for new accounts

* fix: merge

* fix: verify derivation pw

* fix: remove dup, reset head

* fix: merge conflicts, handling legacy etehrum txn

* fix: show the hash for oversized message hex

* fix: alert warning signing hash, get network key substrate

* fix: remove log reports

* fix: display decoded extrinsic payload details

* fix: lock when saving accounts

* fix: lock when unmounting backup view

* fix: name wasn't save properly in securestore

* fix: comment out Polkadot and add testnet

* fix: bug ethereum new account and duplicated functions

* fix: stray comment

* fix: derive path

* fix: bump api for payload with spec version

* fix: making it build on android

* fix: link RNSecureStorage

* fix: link for ios

* fix: finalize

* fix: remove logs

* fix: remove console logs

* feat: wip for adding QR support for UOS

* fix: use ui-qr

* fix: add peer dependencies for @polkadot/*

* feat: handle decoding via UOS

* fix: decode substrate payload!

* chore: Squashed old branch

* feat: expose blake2s hash function

* Update src/components/QrView.js

* fix: Duplicate function names in iOS

* feat: Expose `substrateAddress` in native.js

* fix: decode from u8a

* fix: reformat data for consistency with legacy. temporary placeholdder for native substrateSign

* fix(): init with PolaIcon file, types, add ui-shared and react-native-svg

* fix(): add react-native-crypto with override and node-libs-react-native

* fix(): add stream-browserify and overrides

* fix(): ideenticon visible

* fix: qr view

* fix: decoding message and fix the screwed up qr code

* fix: warning when signing payload hash

* fix(): remove test files

* fix(): revert https://github.com/paritytech/parity-signer/pull/300



* fix: remove nodefy and cleanup deps

* fix: re-enable screenshot for debug

* fix: remove punny dep

* fix: remove timers-browsify

* fix: make it build

* fix: move parsing logic to store, setup for hadnleing multipart

* fix: store unsignedata

* fix: setData uses scannerstore state unsigned data

* fix: move parse to util

* fix: bring in native blake2s function

* fix: move decores

* fix(): address map for substrate accounts

* fix: use genesisHash and Address

* fix: refactor

* fix: advanced derived path field for new account

* fix: setup unit tests, vscode debug env

* fix: address encoding

* fix: make tests pass

* fix: multipart unit test

* fix: setup for testing stores

* fix: displaying ascii message to sign, use Kusama adddress in store

* fix: decode SCALE

* fix: make tests pass

* feat: sr25519 signing

* feat: Complete SURI derivation

* fix: use substrateAddress

* fix: recover derivation

* fix: refactor advanced (derivation path) field

* fix: sign data

* feat: Expose blake2s proxy function in native.js

* fix: merge

* fix: display derivation path and link to check pasword

* fix: remove dup, reset head

* fix: merge conflicts, handling legacy etehrum txn

* fix: show the hash for oversized message hex

* fix: verify derivation pw

* fix: rmeove crash reports, qr hex payload

* fix: yarn.lock

* fix: uncorrupt project.pbxproj, resolve merge conflicts

* fix: finalize rebase

* fix: rmeove unused function

* fix: minor gurumbles

* fix: fonts

* fix: add back rn camera

* fix: helper check valid json string

* Update src/screens/MessageDetails.js

Co-Authored-By: default avatarThibaut Sardan <33178835+Tbaut@users.noreply.github.com>

* Update src/screens/MessageDetails.js

Co-Authored-By: default avatarThibaut Sardan <33178835+Tbaut@users.noreply.github.com>

* Update src/screens/MessageDetails.js

Co-Authored-By: default avatarThibaut Sardan <33178835+Tbaut@users.noreply.github.com>

* Update src/screens/About.js

Co-Authored-By: default avatarThibaut Sardan <33178835+Tbaut@users.noreply.github.com>
parent be3edf8b
Pipeline #50151 failed with stage
in 52 seconds
......@@ -168,15 +168,15 @@ android {
}
dependencies {
implementation project(':react-native-svg')
implementation project(':react-native-randombytes')
implementation project(':@react-native-community_netinfo')
implementation project(':react-native-camera')
implementation project(':react-native-secure-storage')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-svg')
implementation project(':@react-native-community_netinfo')
implementation project(':react-native-randombytes')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.facebook.react:react-native:0.60.3'
implementation project(':react-native-gesture-handler')
if (useIntlJsc) {
implementation 'org.webkit:android-jsc-intl:+'
......
......@@ -32,10 +32,9 @@ public class MainActivity extends ReactActivity {
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
......
......@@ -3,17 +3,17 @@ package io.parity.signer;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.reactlibrary.RNSecureStoragePackage;
import org.reactnative.camera.RNCameraPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.horcrux.svg.SvgPackage;
import com.bitgo.randombytes.RandomBytesPackage;
import com.reactnativecommunity.netinfo.NetInfoPackage;
import org.reactnative.camera.RNCameraPackage;
import com.reactlibrary.RNSecureStoragePackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import java.util.Arrays;
import java.util.List;
......@@ -30,11 +30,11 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new SvgPackage(),
new RandomBytesPackage(),
new NetInfoPackage(),
new RNCameraPackage(),
new RNSecureStoragePackage(),
new RNSecureStoragePackage(),
new RNCameraPackage(),
new SvgPackage(),
new NetInfoPackage(),
new RandomBytesPackage(),
new EthkeyBridgePackage(),
new RNGestureHandlerPackage()
);
......
......@@ -47,4 +47,4 @@ subprojects {
}
}
}
}
}
\ No newline at end of file
rootProject.name = 'Parity Signer'
include ':react-native-secure-storage'
project(':react-native-secure-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-secure-storage/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
include ':react-native-randombytes'
project(':react-native-randombytes').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-randombytes/android')
include ':@react-native-community_netinfo'
project(':@react-native-community_netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':react-native-secure-storage'
project(':react-native-secure-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-secure-storage/android')
include ':react-native-randombytes'
project(':react-native-randombytes').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-randombytes/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
This diff is collapsed.
......@@ -83,17 +83,6 @@ class EthkeyBridge: NSObject {
}
}
@objc func blake2s(_ data: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
var error: UInt32 = 0
var data_ptr = data.asPtr()
let hash_rust_str = blake(&error, &data_ptr)
let hash_rust_str_ptr = rust_string_ptr(hash_rust_str)
let hash = String.fromStringPtr(ptr: hash_rust_str_ptr!.pointee)
rust_string_ptr_destroy(hash_rust_str_ptr)
rust_string_destroy(hash_rust_str)
resolve(hash)
}
@objc func ethSign(_ data: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
var error: UInt32 = 0
var data_ptr = data.asPtr()
......
......@@ -19,6 +19,6 @@
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
......@@ -17,14 +17,4 @@
/* global jest */
// import mockCamera from './__mocks__/Camera'
jest.unmock('Image')
jest.mock('react-native-camera', () => 'camera')
jest.mock('Linking', () => {
return {
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
openURL: jest.fn(),
canOpenURL: jest.fn(),
getInitialURL: jest.fn()
}
})
jest.doMock('react-native', () => 'reactNativeMock')
\ No newline at end of file
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
const { defaults } = require('jest-config');
module.exports = {
preset: "react-native",
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],
verbose: true,
roots: ['<rootDir>/src'],
};
roots: [
"<rootDir>/src"
],
setupFiles: [
"<rootDir>/jest-setup.js"
],
testEnvironment: "node",
testPathIgnorePatterns: [
"/node_modules/"
]
}
\ No newline at end of file
process.browser = true;
\ No newline at end of file
process.browser = true;
......@@ -18,6 +18,7 @@
'use strict';
import '../shim';
import React, { Component } from 'react';
import { StatusBar } from 'react-native';
import {
......
......@@ -59,7 +59,6 @@ export default function DerivationPathField(props) {
<TextInput
onChangeText={(text) => {
const derivationPath = keyExtract(text);
console.log('derivationPath',derivationPath)
onChange({
derivationPassword: derivationPath.password || '',
derivationPath: derivationPath.derivePath || ''
......
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
// @flow
import PropTypes from 'prop-types';
import React from 'react';
import { StyleSheet, Text, View, ViewPropTypes } from 'react-native';
import colors from '../colors';
import fonts from '../fonts';
export default class PayloadDetailsCard extends React.PureComponent {
static propTypes = {
description: PropTypes.string.isRequired,
payload: PropTypes.object,
signature: PropTypes.string,
style: ViewPropTypes.style
};
render() {
const { description, payload, signature, style } = this.props;
return (
<View style={[styles.body, style]}>
<Text style={styles.titleText}>{description}</Text>
{
payload && (
<View style={{ padding: 5, paddingVertical: 2 }}>
<ExtrinsicPart label='Block Hash' value={payload.blockHash.toString()} />
<ExtrinsicPart label='Method' value={payload.method.toString()} />
<ExtrinsicPart label='Era' value={payload.era.toString()} />
<ExtrinsicPart label='Nonce' value={payload.nonce.toString()} />
<ExtrinsicPart label='Tip' value={payload.tip.toString()} />
<ExtrinsicPart label='Genesis Hash' value={payload.genesisHash.toString()} />
</View>
)
}
{
signature && (
<View style={{ padding: 5, paddingVertical: 2 }}>
<Text style={styles.label}>Signature</Text>
<Text style={styles.secondaryText}>{signature}</Text>
</View>
)
}
</View>
);
}
}
function ExtrinsicPart({ label, style, value }) {
return (
<View style={[{ justifyContent: 'center', alignItems: 'flex-start' }, style]}>
<View
style={{ padding: 5, paddingVertical: 2 }}
>
<Text style={styles.label}>
{label}
</Text>
<Text style={styles.secondaryText}>{value}</Text>
</View>
</View>
);
}
const styles = StyleSheet.create({
body: {
padding: 20,
paddingTop: 10,
flexDirection: 'column',
backgroundColor: colors.card_bg
},
content: {},
footer: {
backgroundColor: '#977CF6',
flexDirection: 'row-reverse',
padding: 5
},
label: {
backgroundColor: colors.bg,
color: colors.card_bg,
textAlign: 'left',
fontSize: 20,
fontFamily: fonts.bold,
},
icon: {
width: 47,
height: 47
},
titleText: {
textAlign: 'center',
fontFamily: fonts.bold,
fontSize: 14,
color: colors.card_bg_text
},
secondaryText: {
textAlign: 'center',
color: colors.card_bg_text,
fontFamily: fonts.semiBold,
fontSize: 12
},
footerText: {
color: colors.card_bg,
fontFamily: fonts.bold
}
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment