Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
parity-signer
Commits
fe3d5ee2
Commit
fe3d5ee2
authored
Feb 28, 2017
by
Marek Kotewicz
Browse files
fixing bugs
parent
6233df97
Changes
8
Hide whitespace changes
Inline
Side-by-side
rust/signer/src/lib.rs
View file @
fe3d5ee2
...
...
@@ -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
))
}
...
...
src/components/App.js
View file @
fe3d5ee2
...
...
@@ -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
))
...
...
src/containers/Account.js
View file @
fe3d5ee2
...
...
@@ -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
'
}
...
...
src/containers/Pin.js
View file @
fe3d5ee2
...
...
@@ -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
'
)
...
...
src/containers/QrScanner.js
View file @
fe3d5ee2
...
...
@@ -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
)
...
...
src/containers/QrView.js
View file @
fe3d5ee2
...
...
@@ -5,7 +5,7 @@ import { connect } from 'react-redux'
import
QrView
from
'
../components/QrView
'
const
mapStateToPropsTransaction
=
(
state
,
ownProps
)
=>
({
text
:
state
.
transactions
.
signedT
x
,
text
:
state
.
transactions
.
signedT
ransaction
.
signature
,
})
export
const
QrViewTransaction
=
connect
(
mapStateToPropsTransaction
)(
QrView
)
...
...
src/reducers/transactions.js
View file @
fe3d5ee2
...
...
@@ -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
...
...
src/util/store.js
0 → 100644
View file @
fe3d5ee2
'
use strict
'
import
React
from
'
react
'
import
{
createStore
}
from
'
redux
'
import
reducers
from
'
../reducers
'
export
default
createStore
(
reducers
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment