Commit fe3d5ee2 authored by Marek Kotewicz's avatar Marek Kotewicz
Browse files

fixing bugs

parent 6233df97
...@@ -59,7 +59,7 @@ pub unsafe extern fn ethkey_keypair_address(keypair: *mut KeyPair) -> *mut Strin ...@@ -59,7 +59,7 @@ pub unsafe extern fn ethkey_keypair_address(keypair: *mut KeyPair) -> *mut Strin
pub unsafe extern fn ethkey_keypair_sign(keypair: *mut KeyPair, message: *mut StringPtr) -> *mut String { pub unsafe extern fn ethkey_keypair_sign(keypair: *mut KeyPair, message: *mut StringPtr) -> *mut String {
let secret = (*keypair).secret(); let secret = (*keypair).secret();
let message: Message = (*message).as_str().parse().unwrap(); let message: Message = (*message).as_str().parse().unwrap();
let signature = format!("{:?}", sign(secret, &message).unwrap()); let signature = format!("{}", sign(secret, &message).unwrap());
Box::into_raw(Box::new(signature)) Box::into_raw(Box::new(signature))
} }
......
...@@ -5,7 +5,6 @@ import { View, Text, StyleSheet, AppState } from 'react-native' ...@@ -5,7 +5,6 @@ import { View, Text, StyleSheet, AppState } from 'react-native'
import { Provider, connect } from 'react-redux' import { Provider, connect } from 'react-redux'
import { createStore } from 'redux' import { createStore } from 'redux'
import { Actions, ActionConst, Router, Scene } from 'react-native-router-flux' import { Actions, ActionConst, Router, Scene } from 'react-native-router-flux'
import reducers from '../reducers'
import TabIcon from './TabIcon' import TabIcon from './TabIcon'
import QrScanner from '../containers/QrScanner' import QrScanner from '../containers/QrScanner'
import Accounts from '../containers/Accounts' import Accounts from '../containers/Accounts'
...@@ -18,9 +17,9 @@ import { EnterPin, SetPin, ConfirmPin } from '../containers/Pin' ...@@ -18,9 +17,9 @@ import { EnterPin, SetPin, ConfirmPin } from '../containers/Pin'
import { QrViewTransaction, QrViewAddress } from '../containers/QrView' import { QrViewTransaction, QrViewAddress } from '../containers/QrView'
import { loadAccounts, saveAccounts } from '../util/db' import { loadAccounts, saveAccounts } from '../util/db'
import { setAccounts } from '../actions/accounts' import { setAccounts } from '../actions/accounts'
import store from '../util/store'
const ConnectedRouter = connect()(Router) const ConnectedRouter = connect()(Router)
const store = createStore(reducers)
loadAccounts().then(accounts => { loadAccounts().then(accounts => {
store.dispatch(setAccounts(accounts)) store.dispatch(setAccounts(accounts))
......
...@@ -6,6 +6,7 @@ import { connect } from 'react-redux' ...@@ -6,6 +6,7 @@ import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux' import { Actions } from 'react-native-router-flux'
import AccountDetails from '../components/AccountDetails' import AccountDetails from '../components/AccountDetails'
import { deleteAccount } from '../actions/accounts' import { deleteAccount } from '../actions/accounts'
import { deleteAccount as dbDeleteAccount } from '../util/db'
const mapDispatchToProps = (dispatch, ownProps) => ({ const mapDispatchToProps = (dispatch, ownProps) => ({
onDisplayAddressPressed: () => { onDisplayAddressPressed: () => {
...@@ -15,6 +16,7 @@ const mapDispatchToProps = (dispatch, ownProps) => ({ ...@@ -15,6 +16,7 @@ const mapDispatchToProps = (dispatch, ownProps) => ({
Alert.alert('Do you want to delete the account?', undefined, [ Alert.alert('Do you want to delete the account?', undefined, [
{ text: 'Yes', onPress: () => { { text: 'Yes', onPress: () => {
dispatch(deleteAccount(account)) dispatch(deleteAccount(account))
dbDeleteAccount(account)
Actions.pop() Actions.pop()
}}, }},
{ text: 'No' } { text: 'No' }
......
...@@ -8,6 +8,7 @@ import Pin from '../components/Pin' ...@@ -8,6 +8,7 @@ import Pin from '../components/Pin'
import { addAccount, setPin } from '../actions/accounts' import { addAccount, setPin } from '../actions/accounts'
import { signedTx } from '../actions/transactions' import { signedTx } from '../actions/transactions'
import { keccak, brainWalletSign } from '../util/native' import { keccak, brainWalletSign } from '../util/native'
import { saveAccount } from '../util/db'
const mapStateToPropsEnterPin = (state, ownProps) => ({ const mapStateToPropsEnterPin = (state, ownProps) => ({
account: state.accounts.selected, account: state.accounts.selected,
...@@ -50,6 +51,7 @@ const mapDispatchToPropsConfirmPin = (dispatch, ownProps) => ({ ...@@ -50,6 +51,7 @@ const mapDispatchToPropsConfirmPin = (dispatch, ownProps) => ({
onNextPressed: (pin, account) => { onNextPressed: (pin, account) => {
if (pin === account.pin) { if (pin === account.pin) {
dispatch(addAccount(account)) dispatch(addAccount(account))
saveAccount(account)
Actions.popTo('accounts') Actions.popTo('accounts')
} else { } else {
Alert.alert('Invalid pin') Alert.alert('Invalid pin')
......
...@@ -5,8 +5,10 @@ import { Vibration, Alert } from 'react-native' ...@@ -5,8 +5,10 @@ import { Vibration, Alert } from 'react-native'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux' import { Actions } from 'react-native-router-flux'
import Scanner from '../components/Scanner' import Scanner from '../components/Scanner'
import { selectAccount } from '../actions/accounts'
import { scannedTx } from '../actions/transactions' import { scannedTx } from '../actions/transactions'
import transaction from '../util/transaction' import transaction from '../util/transaction'
import store from '../util/store'
var scanning = false var scanning = false
...@@ -16,10 +18,22 @@ async function onScannedTransaction(data, dispatch) { ...@@ -16,10 +18,22 @@ async function onScannedTransaction(data, dispatch) {
return return
} }
scanning = true scanning = true
let tx = await transaction(data); let tx_request = JSON.parse(data);
dispatch(scannedTx(data, tx)) let from = tx_request.from.toLowerCase()
let account = store.getState().accounts.all.find(account => {
return account.address.toLowerCase() == from
})
if (!account) {
Alert.alert('Invalid sender address ' + tx_request.from, undefined, [
{ text: 'OK', onPress: () => { scanning = false }}
])
return
}
let tx = await transaction(tx_request.rlp);
dispatch(selectAccount(account))
dispatch(scannedTx(data.rlp, tx))
Vibration.vibrate() Vibration.vibrate()
Actions.confirm() Actions.enterPin()
scanning = false scanning = false
} catch (e) { } catch (e) {
console.log(e) console.log(e)
......
...@@ -5,7 +5,7 @@ import { connect } from 'react-redux' ...@@ -5,7 +5,7 @@ import { connect } from 'react-redux'
import QrView from '../components/QrView' import QrView from '../components/QrView'
const mapStateToPropsTransaction = (state, ownProps) => ({ const mapStateToPropsTransaction = (state, ownProps) => ({
text: state.transactions.signedTx, text: state.transactions.signedTransaction.signature,
}) })
export const QrViewTransaction = connect(mapStateToPropsTransaction)(QrView) export const QrViewTransaction = connect(mapStateToPropsTransaction)(QrView)
......
...@@ -23,7 +23,9 @@ export default function transactions(state = initialState, action) { ...@@ -23,7 +23,9 @@ export default function transactions(state = initialState, action) {
}) })
case SIGNED_TX: case SIGNED_TX:
return Object.assign({}, state, { return Object.assign({}, state, {
signedTransaction: action.signature, signedTransaction: {
signature: action.signature,
}
}) })
default: default:
return state return state
......
'use strict'
import React from 'react'
import { createStore } from 'redux'
import reducers from '../reducers'
export default createStore(reducers)
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