Commit 9f416173 authored by Marek Kotewicz's avatar Marek Kotewicz
Browse files

Merge branch 'master' of github.com:paritytech/native-signer

parents d48bce8f 60100c19
......@@ -69,6 +69,11 @@ public class EthkeyBridge extends ReactContextBaseJavaModule {
promise.resolve(ethkeyKeccak(data));
}
@ReactMethod
public void ethSign(String data, Promise promise) {
promise.resolve(ethkeyEthSign(data));
}
@ReactMethod
public void blockiesIcon(String seed, Promise promise) {
promise.resolve(ethkeyBlockiesIcon(seed));
......@@ -98,6 +103,7 @@ public class EthkeyBridge extends ReactContextBaseJavaModule {
private static native String ethkeyBrainwalletSign(String seed, String message);
private static native String ethkeyRlpItem(String data, int position);
private static native String ethkeyKeccak(String data);
private static native String ethkeyEthSign(String data);
private static native String ethkeyBlockiesIcon(String seed);
private static native String ethkeyRandomPhrase(int words);
private static native String ethkeyEncryptData(String data, String password);
......
......@@ -73,6 +73,16 @@ class EthkeyBridge: NSObject {
resolve(hash)
}
@objc func ethSign(_ data: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
var data_ptr = data.asPtr()
let hash_rust_str = eth_sign(&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 blockiesIcon(_ seed: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
var seed_ptr = seed.asPtr()
let icon_rust_str = blockies_icon(&seed_ptr)
......
......@@ -30,6 +30,7 @@ RCT_EXTERN_METHOD(brainWalletSecret:(NSString*)seed resolve:(RCTPromiseResolveBl
RCT_EXTERN_METHOD(brainWalletSign:(NSString*)seed message:(NSString*)message resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(rlpItem:(NSString*)rlp position:(NSUInteger)position resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(keccak:(NSString*)data resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(ethSign:(NSString*)data resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(blockiesIcon:(NSString*)seed resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(randomPhrase:(NSUInteger)words resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(encryptData:(NSString*)data password:(NSString*)password resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
......
......@@ -8,7 +8,7 @@ dependencies = [
"jni 0.3.1 (git+https://github.com/prevoty/jni-rs)",
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-wordlist 1.0.0 (git+https://github.com/paritytech/wordlist)",
"rlp 0.1.0 (git+https://github.com/paritytech/parity)",
"rlp 0.2.0 (git+https://github.com/paritytech/parity)",
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny-keccak 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -34,13 +34,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bigint"
version = "1.0.1"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -96,8 +97,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "elastic-array"
version = "0.6.0"
source = "git+https://github.com/paritytech/elastic-array#346f1ba5982576dab9d0b8fa178b50e1db0a21cd"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -129,10 +130,10 @@ dependencies = [
[[package]]
name = "ethcore-bigint"
version = "0.1.2"
source = "git+https://github.com/paritytech/parity#1df30ee83e20a39baa3b416518f3b01f6c56e8ff"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bigint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bigint 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -142,10 +143,10 @@ dependencies = [
[[package]]
name = "ethcrypto"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity#1df30ee83e20a39baa3b416518f3b01f6c56e8ff"
source = "git+https://github.com/paritytech/parity#38ed39ebe051ce7ee38b177c560f5cf674651ddf"
dependencies = [
"eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)",
"ethcore-bigint 0.1.2 (git+https://github.com/paritytech/parity)",
"ethcore-bigint 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethkey 0.2.0 (git+https://github.com/paritytech/parity)",
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny-keccak 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -154,11 +155,11 @@ dependencies = [
[[package]]
name = "ethkey"
version = "0.2.0"
source = "git+https://github.com/paritytech/parity#1df30ee83e20a39baa3b416518f3b01f6c56e8ff"
source = "git+https://github.com/paritytech/parity#38ed39ebe051ce7ee38b177c560f5cf674651ddf"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)",
"ethcore-bigint 0.1.2 (git+https://github.com/paritytech/parity)",
"ethcore-bigint 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -169,9 +170,9 @@ dependencies = [
[[package]]
name = "ethstore"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity#1df30ee83e20a39baa3b416518f3b01f6c56e8ff"
source = "git+https://github.com/paritytech/parity#38ed39ebe051ce7ee38b177c560f5cf674651ddf"
dependencies = [
"ethcore-bigint 0.1.2 (git+https://github.com/paritytech/parity)",
"ethcore-bigint 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcrypto 0.1.0 (git+https://github.com/paritytech/parity)",
"ethkey 0.2.0 (git+https://github.com/paritytech/parity)",
"itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -412,12 +413,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rlp"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity#1df30ee83e20a39baa3b416518f3b01f6c56e8ff"
version = "0.2.0"
source = "git+https://github.com/paritytech/parity#38ed39ebe051ce7ee38b177c560f5cf674651ddf"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.6.0 (git+https://github.com/paritytech/elastic-array)",
"ethcore-bigint 0.1.2 (git+https://github.com/paritytech/parity)",
"elastic-array 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-bigint 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -447,15 +448,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc_version"
version = "0.1.7"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver"
version = "0.1.20"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
......@@ -572,7 +581,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum adler32 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff33fe13a08dbce05bcefa2c68eea4844941437e33d6f808240b54d7157b9cd"
"checksum arrayvec 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d89f1b0e242270b5b797778af0c8d182a1a2ccac5d8d6fadf414223cc0fab096"
"checksum ascii 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae7d751998c189c1d4468cf0a39bb2eae052a9c58d50ebb3b9591ee3813ad50"
"checksum bigint 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4987c855cbe118271721d21f16cacdfedfe7dbeb7ea5970e4ae33db06602e3f2"
"checksum bigint 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4865ae66523e00114a17935fc03865323c668381e9e37fa96c525a8bbcc4e04f"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum blockies 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88f848260161ae4410b5133744d5f47b7b126cf1bb4a08a552f2de328022f1d3"
"checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
......@@ -581,11 +590,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum deflate 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebb02aaf4b775afc96684b8402510a338086974e38570a1f65bea8c202eb77a7"
"checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90"
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
"checksum elastic-array 0.6.0 (git+https://github.com/paritytech/elastic-array)" = "<none>"
"checksum elastic-array 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71a64decd4b8cd06654a4e643c45cb558ad554abbffd82a7e16e34f45f51b605"
"checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180"
"checksum error-chain 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e92ecf0a508c8e074c0e6fa8fe0fa38414848ad4dfc4db6f74c5e9753330b248"
"checksum eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)" = "<none>"
"checksum ethcore-bigint 0.1.2 (git+https://github.com/paritytech/parity)" = "<none>"
"checksum ethcore-bigint 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5d237300af825a8d78f4c0dc835b0eab76a207e9df4aa088d91e162a173e0ca0"
"checksum ethcrypto 0.1.0 (git+https://github.com/paritytech/parity)" = "<none>"
"checksum ethkey 0.2.0 (git+https://github.com/paritytech/parity)" = "<none>"
"checksum ethstore 0.1.0 (git+https://github.com/paritytech/parity)" = "<none>"
......@@ -618,12 +627,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
"checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d"
"checksum redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd35cc9a8bdec562c757e3d43c1526b5c6d2653e23e2315065bc25556550753"
"checksum rlp 0.1.0 (git+https://github.com/paritytech/parity)" = "<none>"
"checksum rlp 0.2.0 (git+https://github.com/paritytech/parity)" = "<none>"
"checksum rust-crypto 0.2.36 (git+https://github.com/debris/rust-crypto)" = "<none>"
"checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a"
"checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b"
"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084"
"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac"
"checksum rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9743a7670d88d5d52950408ecdb7c71d8986251ab604d4689dd2ca25c9bca69"
"checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)" = "231dfd55909400769e437326cfb4af8bec97c3dd56ab3d02df8ef5c7e00f179b"
"checksum serde_codegen_internals 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bc888bd283bd2420b16ad0d860e35ad8acb21941180a83a189bb2046f9d00400"
"checksum serde_derive 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)" = "d75c72ef4dd193d89eb652b73890fe2489996c9ead8b37980f57a1078f96ed50"
......
......@@ -67,6 +67,8 @@ struct rust_string* rlp_item(const struct rust_string_ptr* rlp, const unsigned p
struct rust_string* keccak256(const struct rust_string_ptr* data);
struct rust_string* eth_sign(const struct rust_string_ptr* data);
// blockies ffi
struct rust_string* blockies_icon(const struct rust_string_ptr* blockies_seed);
......
......@@ -136,6 +136,19 @@ pub unsafe extern fn keccak256(data: *mut StringPtr) -> *mut String {
Box::into_raw(Box::new(res.to_hex()))
}
#[no_mangle]
pub unsafe extern fn eth_sign(data: *mut StringPtr) -> *mut String {
let data = (*data).as_str();
let hex = data.from_hex().unwrap();
let message = format!("\x19Ethereum Signed Message:\n{}", hex.len()).into_bytes();
let mut res: [u8; 32] = [0; 32];
let mut keccak = Keccak::new_keccak256();
keccak.update(&message);
keccak.update(&hex);
keccak.finalize(&mut res);
Box::into_raw(Box::new(res.to_hex()))
}
// blockies ffi
#[no_mangle]
......@@ -246,6 +259,18 @@ pub mod android {
env.new_string(res.to_hex()).expect("Could not create java string").into_inner()
}
#[no_mangle]
pub unsafe extern fn Java_com_nativesigner_EthkeyBridge_ethkeyEthSign(env: JNIEnv, _: JClass, data: JString) -> jstring {
let data: String = env.get_string(data).expect("Invalid seed").into();
let hex = data.from_hex().unwrap();
let message = format!("\x19Ethereum Signed Message:\n{}", hex.len()).into_bytes();
let mut res: [u8; 32] = [0; 32];
let mut keccak = Keccak::new_keccak256();
keccak.update(&hex);
keccak.finalize(&mut res);
env.new_string(res.to_hex()).expect("Could not create java string").into_inner()
}
#[no_mangle]
pub unsafe extern fn Java_com_nativesigner_EthkeyBridge_ethkeyBlockiesIcon(env: JNIEnv, _: JClass, seed: JString) -> jstring {
let seed: String = env.get_string(seed).expect("Invalid seed").into();
......
......@@ -20,9 +20,9 @@ import { Alert } from 'react-native'
import { Actions } from 'react-native-router-flux'
import { ENABLE_SCANNER, DISABLE_SCANNER, DISABLE_SCANNER_WARNINGS, RESET_SCANNER } from '../constants/ScannerActions'
import { selectAccount } from './accounts'
import { scannedTx } from './transactions'
import { scannedTx, scannedData } from './signer'
import transaction from '../util/transaction'
import { keccak } from '../util/native'
import { keccak, ethSign } from '../util/native'
export function enableScanner () {
return {
......@@ -90,18 +90,28 @@ export function scannerDispatch (data) {
let hash = await keccak(txRequest.data.rlp)
dispatch(selectAccount(account))
dispatch(scannedTx(hash, tx))
Actions.txDetails()
dispatch(resetScanner())
} else if (txRequest.action === 'signTransactionHash') {
var details = txRequest.data.details
details.isSafe = false
let hash = txRequest.data.hash
dispatch(selectAccount(account))
dispatch(scannedTx(hash, details))
Actions.txDetails()
dispatch(resetScanner())
} else if (txRequest.action === 'signData') {
let data = txRequest.data.data
let hash = await ethSign(txRequest.data.data)
dispatch(selectAccount(account))
dispatch(scannedData(hash, data))
Actions.dataDetails()
dispatch(resetScanner())
} else {
dispatch(displayScannerWarning('Invalid request'))
dispatch(resetScanner())
return
}
Actions.txDetails()
dispatch(resetScanner())
} catch (e) {
console.error(e)
dispatch(displayScannerWarning('Invalid transaction' + e))
......
......@@ -18,26 +18,34 @@
import { Alert } from 'react-native'
import { Actions } from 'react-native-router-flux'
import { NEW_SCANNED_TX, SIGN_TX } from '../constants/TransactionActions'
import { NEW_SCANNED_TX, NEW_SCANNED_DATA, SIGN_HASH } from '../constants/SignerActions'
import { brainWalletSign, decryptData } from '../util/native'
export function scannedTx (rlpHash, transaction) {
export function scannedTx (hash, transaction) {
return {
type: NEW_SCANNED_TX,
rlpHash,
hash,
transaction
}
}
export function signTx (pin) {
export function scannedData (hash, data) {
return {
type: NEW_SCANNED_DATA,
hash,
data
}
}
export function signHash (pin) {
return async function (dispatch, getState) {
try {
let account = getState().accounts.selected
let hash = getState().transactions.pendingTransaction.rlpHash
let hash = getState().signer.hashToSign
let seed = await decryptData(account.encryptedSeed, pin)
let signature = await brainWalletSign(seed, hash)
dispatch({
type: SIGN_TX,
type: SIGN_HASH,
signature: signature
})
Actions.qrViewTx()
......
......@@ -29,6 +29,7 @@ import AccountDetails from '../containers/AccountDetails'
import TxDetails from '../containers/TxDetails'
import { AccountEnterPin, AccountChangePin, AccountSetPin, AccountConfirmPin } from '../containers/AccountPin'
import { QrViewTransaction, QrViewAddress } from '../containers/QrView'
import DataDetails from '../containers/DataDetails'
import { loadAccounts, saveAccounts } from '../util/db'
import { setAccounts } from '../actions/accounts'
import store from '../util/store'
......@@ -64,6 +65,11 @@ const scenes = Actions.create(
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='dataDetails' component={DataDetails} title='Sign Data'
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='accountEnterPin' title='Enter PIN' component={AccountEnterPin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
......
// Copyright 2015-2017 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/>.
'use strict'
import React, { Component, PropTypes } from 'react'
import { View, Button, Text } from 'react-native'
import AppStyles from '../styles'
function isAscii (data) {
for (var i = 2; i < data.length; i += 2) {
let n = parseInt(data.substr(i, 2), 16)
if (n < 32 || n >= 128) {
return false
}
}
return true
}
function hexToAscii (hexx) {
var hex = hexx.toString()
var str = ''
for (var i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16))
}
return str
}
export default class DataDetails extends Component {
static propTypes = {
data: PropTypes.string.isRequired,
onNextButtonPressed: PropTypes.func.isRequired
}
render () {
return (
<View style={AppStyles.view}>
<Text style={AppStyles.hintText}>Data to sign</Text>
<Text style={AppStyles.valueText}>{ isAscii(this.props.data) ? hexToAscii(this.props.data) : this.props.data }</Text>
<Button
onPress={this.props.onNextButtonPressed}
title='Next'
color='gree'
accessibilityLabel='Enter Pin'
/>
</View>
)
}
}
......@@ -37,6 +37,12 @@ export default class Scanner extends Component {
)
}
let data = {
data: '{"action":"signData","data":{"data":"12","account":"006E27B6A72E1f34C626762F3C4761547Aff1421"}}'
}
this.props.onBarCodeRead(data)
return (
<Camera onBarCodeRead={this.props.onBarCodeRead} style={AppStyles.view}>
<StatusBar barStyle='light-content' />
......
......@@ -16,5 +16,6 @@
'use strict'
export const NEW_SCANNED_TX = 'TRANSACTION_ACTION_NEW_SCANNED_TX'
export const SIGN_TX = 'TRANSACTION_ACTION_SIGNED_TX'
export const NEW_SCANNED_TX = 'SIGNER_ACTION_NEW_SCANNED_TX'
export const NEW_SCANNED_DATA = 'SIGNER_ACTION_NEW_SCANNED_DATA'
export const SIGN_HASH = 'SIGNER_ACTION_SIGNED_HASH'
......@@ -20,7 +20,7 @@ import { Keyboard } from 'react-native'
import { connect } from 'react-redux'
import AccountPin from '../components/AccountPin'
import { addAccount, setNewPin, setOldPin, changePin } from '../actions/accounts'
import { signTx } from '../actions/transactions'
import { signHash } from '../actions/signer'
export const AccountEnterPin = connect(
(state) => ({
......@@ -29,7 +29,7 @@ export const AccountEnterPin = connect(
(dispatch) => ({
onNextPressed: (pin) => {
Keyboard.dismiss()
dispatch(signTx(pin))
dispatch(signHash(pin))
}
})
)(AccountPin)
......
// Copyright 2015-2017 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/>.
'use strict'
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import DataDetails from '../components/DataDetails'
const DataDetailsContainer = connect(state => ({
data: state.signer.data
}), dispatch => ({
onNextButtonPressed: () => {
Actions.accountEnterPin()
}
}))(DataDetails)
export default DataDetailsContainer
......@@ -20,7 +20,7 @@ import { connect } from 'react-redux'
import QrView from '../components/QrView'
const mapStateToPropsTransaction = (state, ownProps) => ({
text: state.transactions.signedTransaction.signature,
text: state.signer.signedHash,
view: true
})
......
......@@ -30,17 +30,17 @@ const fetchAccountName = (state, address = '') => {
const mapStateToProps = (state, ownProps) => ({
nextButtonTitle: 'Next',
nextButtonDescription: 'Enter Pin',
txRlpHash: state.transactions.pendingTransaction.rlpHash,
txRlpHash: state.signer.pendingTransaction.rlpHash,
txSenderAddress: state.accounts.selected.address,
txRecipientAddress: state.transactions.pendingTransaction.transaction.action,
txValue: state.transactions.pendingTransaction.transaction.value,
txNonce: state.transactions.pendingTransaction.transaction.nonce,
txGas: state.transactions.pendingTransaction.transaction.gas,
txGasPrice: state.transactions.pendingTransaction.transaction.gasPrice,
txData: state.transactions.pendingTransaction.transaction.data,
isSafe: state.transactions.pendingTransaction.transaction.isSafe,
txRecipientAddress: state.signer.transactionDetails.action,
txValue: state.signer.transactionDetails.value,
txNonce: state.signer.transactionDetails.nonce,
txGas: state.signer.transactionDetails.gas,
txGasPrice: state.signer.transactionDetails.gasPrice,
txData: state.signer.transactionDetails.data,
isSafe: state.signer.transactionDetails.isSafe,
txSenderName: fetchAccountName(state, state.accounts.selected.address),
txRecipientName: fetchAccountName(state, state.transactions.pendingTransaction.transaction.action)
txRecipientName: fetchAccountName(state, state.signer.transactionDetails.action)
})
const mapDispatchToProps = (dispatch, ownProps) => ({
......
......@@ -20,11 +20,11 @@ import { combineReducers } from 'redux'
import accounts from './accounts'
import routes from './routes'
import scanner from './scanner'
import transactions from './transactions'
import signer from './signer'
export default combineReducers({
accounts,
routes,
scanner,
transactions
signer
})
......@@ -16,32 +16,30 @@
'use strict'
import { NEW_SCANNED_TX, SIGN_TX } from '../constants/TransactionActions'
import { NEW_SCANNED_TX, NEW_SCANNED_DATA, SIGN_HASH } from '../constants/SignerActions'
const initialState = {
pendingTransaction: {
transaction: {},
rlpHash: ''
},
signedTransaction: {
signature: ''
}
transactionDetails: {},
data: '',
hashToSign: '',
signedHash: ''
}
export default function transactions (state = initialState, action) {
export default function signer (state = initialState, action) {
switch (action.type) {
case NEW_SCANNED_TX:
return Object.assign({}, state, {
pendingTransaction: {
rlpHash: action.rlpHash,
transaction: action.transaction
}
transactionDetails: action.transaction,
hashToSign: action.hash
})
case NEW_SCANNED_DATA:
return Object.assign({}, state, {
data: action.data,
hashToSign: action.hash
})
case SIGN_TX:
case SIGN_HASH:
return Object.assign({}, state, {