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
3c1b9305
Commit
3c1b9305
authored
Feb 09, 2017
by
Marek Kotewicz
Browse files
add account view
parent
1d3adc87
Changes
8
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
3c1b9305
...
...
@@ -7,6 +7,9 @@
"test"
:
"jest"
},
"dependencies"
:
{
"
debounce
"
:
"
^1.0.0
"
,
"
elliptic
"
:
"
^6.3.2
"
,
"
js-sha3
"
:
"
^0.5.7
"
,
"
react
"
:
"
^15.4.2
"
,
"
react-native
"
:
"
0.40.0
"
,
"
react-native-camera
"
:
"
^0.5.1
"
,
...
...
src/actions/crypto.js
0 → 100644
View file @
3c1b9305
import
{
ec
}
from
'
elliptic
'
import
{
keccak_256
}
from
'
js-sha3
'
var
secp
=
new
ec
(
'
secp256k1
'
)
export
function
keypairFromPhrase
(
phrase
)
{
var
seed
=
keccak_256
.
array
(
phrase
);
var
kp
;
for
(
var
i
=
0
;
i
<=
16384
||
!
toAddress
(
kp
=
secp
.
keyFromPrivate
(
seed
)).
startsWith
(
'
00
'
);
++
i
)
seed
=
keccak_256
.
array
(
seed
)
return
kp
}
export
function
toAddress
(
kp
)
{
return
keccak_256
(
kp
.
getPublic
(
'
buffer
'
).
slice
(
1
)).
substr
(
24
);
}
src/actions/index.js
deleted
100644 → 0
View file @
1d3adc87
src/components/NewAccountInput.js
View file @
3c1b9305
...
...
@@ -31,7 +31,7 @@ export default class NewAccountInput extends Component {
this
.
props
.
onChangeText
(
text
)
}}
value
=
{
this
.
state
.
text
}
maxLength
=
{
10
0
}
maxLength
=
{
24
0
}
/
>
)
}
...
...
src/constants/AccountActions.js
0 → 100644
View file @
3c1b9305
export
const
ADD_ACCOUNT
=
'
ACCOUNT_ACTION_ADD_ACCOUNT
'
src/containers/Accounts.js
View file @
3c1b9305
...
...
@@ -3,7 +3,7 @@ import { connect } from 'react-redux'
import
AccountsList
from
'
../components/AccountsList
'
const
Accounts
=
connect
(
state
=>
({
accounts
:
state
.
accounts
accounts
:
state
.
accounts
.
map
(
account
=>
account
.
address
)
}))(
AccountsList
)
export
default
Accounts
src/containers/NewAccount.js
View file @
3c1b9305
import
React
,
{
Component
}
from
'
react
'
import
{
View
,
Text
,
StyleSheet
}
from
'
react-native
'
import
{
View
,
Text
,
Button
,
StyleSheet
}
from
'
react-native
'
import
debounce
from
'
debounce
'
import
NewAccountInput
from
'
../components/NewAccountInput
'
import
{
words
}
from
'
../actions/random
'
import
{
keypairFromPhrase
,
toAddress
}
from
'
../actions/crypto
'
//const addAccount = (dispatch) => {
//return {
//onAddAccount: (keypair) => {
//}
//}
//}
export
default
class
NewAccount
extends
Component
{
constructor
(
props
)
{
super
(
props
)
const
seed
=
words
()
this
.
state
=
{
seed
:
seed
,
keypair
:
keypairFromPhrase
(
seed
),
}
}
render
()
{
var
self
=
this
;
return
(
<
View
style
=
{
styles
.
view
}
>
<
NewAccountInput
seed
=
{
words
()}
onChangeText
=
{()
=>
{}}
/
>
<
NewAccountInput
seed
=
{
this
.
state
.
seed
}
onChangeText
=
{
debounce
((
text
)
=>
self
.
setState
({
keypair
:
keypairFromPhrase
(
text
)}),
100
)
}
/
>
<
Text
>
0
x
{
toAddress
(
this
.
state
.
keypair
)}
<
/Text
>
<
Button
onPress
=
{()
=>
{}}
title
=
"
Add Account
"
color
=
"
#841584
"
accessibilityLabel
=
"
Press to add new account
"
/>
<
/View
>
)
}
...
...
src/reducers/accounts.js
View file @
3c1b9305
const
initialAccounts
=
[
'
0xb794f5ea0ba39494ce839613fffba74279579268
'
,
'
0xe853c56864a2ebe4576a807d26fdc4a0ada51919
'
,
'
0x53d284357ec70ce289d6d64134dfac8e511c8a3d
'
,
'
0xd56d423cdc0e437babbdff79c4fa38904ff8d128
'
]
import
{
ADD_ACCOUNT
}
from
'
../constants/AccountActions
'
const
initialAccounts
=
[{
address
:
'
0xb794f5ea0ba39494ce839613fffba74279579268
'
,
},
{
address
:
'
0xe853c56864a2ebe4576a807d26fdc4a0ada51919
'
,
},
{
address
:
'
0x53d284357ec70ce289d6d64134dfac8e511c8a3d
'
,
},
{
address
:
'
0xd56d423cdc0e437babbdff79c4fa38904ff8d128
'
}]
export
default
function
accounts
(
state
=
initialAccounts
,
action
)
{
return
state
switch
(
action
.
type
)
{
case
ADD_ACCOUNT
:
return
[
...
state
,
{
address
:
action
.
address
}
]
default
:
return
state
}
}
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