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