forked from sigillabs/mobidex
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
775a336
commit dc857b6
Showing
14 changed files
with
124 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React, { Component } from "react"; | ||
import { View } from "react-native"; | ||
import { Text } from "react-native-elements"; | ||
|
||
export default class AssetItem extends Component { | ||
render() { | ||
let { token, balance } = this.props; | ||
|
||
return ( | ||
<View style={[{ flex: 1, flexDirection: "row", justifyContent: "flex-start", alignItems: "center", }]}> | ||
<Text>{token.symbol.toString()}</Text> | ||
<Text>{balance}</Text> | ||
</View> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import PropTypes from "prop-types"; | ||
import React, { Component } from "react"; | ||
import { View, TouchableOpacity } from "react-native"; | ||
import { List, ListItem } from "react-native-elements"; | ||
import { connect } from "react-redux"; | ||
import AssetItem from "./Item"; | ||
|
||
class AssetList extends Component { | ||
render() { | ||
return ( | ||
<List containerStyle={{ | ||
marginBottom: 20, | ||
flex: 1, | ||
width: this.props.width | ||
}}> | ||
{ | ||
this.props.tokens | ||
.filter(({ address }) => (Boolean(this.props.assets[token.address]))) | ||
.map((token, index) => ( | ||
<TouchableOpacity key={`asset-${index}`} onPress={() => (this.props.onPress(order))}> | ||
<ListItem | ||
title={<AssetItem token={token} balance={this.props.assets[token.address]} />} | ||
leftIcon={{ name: "add" }} | ||
/> | ||
</TouchableOpacity> | ||
)) | ||
} | ||
</List> | ||
); | ||
} | ||
} | ||
|
||
export default connect((state) => ({ ...state.device.layout, ...state.settings, tokens: state.tokens, assets: state.assets }), (dispatch) => ({ dispatch }))(AssetList); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import AssetList from "./List"; | ||
|
||
export default AssetList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React, { Component } from "react"; | ||
import { View, Text, TouchableHighlight } from "react-native"; | ||
import { Card, Header, Icon } from "react-native-elements"; | ||
import { connect } from "react-redux"; | ||
import NormalHeader from "../headers/Normal"; | ||
|
||
class PortfolioScreen extends Component { | ||
render() { | ||
return ( | ||
<AssetList tokens={this.props.tokens} /> | ||
); | ||
} | ||
} | ||
|
||
export default connect(state => ({ address: state.wallet.address, tokens: state.tokens }), dispatch => ({ dispatch }))(PortfolioScreen); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import * as _ from "lodash"; | ||
import { handleActions } from "redux-actions"; | ||
import * as Actions from "../constants/actions"; | ||
|
||
export default handleActions({ | ||
[Actions.SET_BALANCE]: (state, action) => { | ||
return { | ||
...state, | ||
[ action.payload.address ]: action.payload.balance | ||
} | ||
} | ||
}, {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./ethereum"; | ||
export * from "./startup"; | ||
export * from "./trade"; | ||
export * from "./transactions"; | ||
export * from "./tokens"; | ||
export * from "./wallet"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as _ from "lodash"; | ||
import { AsyncStorage } from "react-native"; | ||
import Wallet from "ethereumjs-wallet"; | ||
import { setWallet, setTokens, setQuoteToken, setBaseToken, finishedLoadingTokens, finishedLoadingWallet } from "../actions"; | ||
import { getZeroExClient } from "../utils/ethereum"; | ||
|
||
// Would like to password protect using Ethereum Secret Storage | ||
// `wallet.toV3("nopass")` is very expensive. | ||
export function generateWallet() { | ||
return async (dispatch) => { | ||
let wallet = await Wallet.generate(); | ||
await AsyncStorage.setItem("wallet", wallet.getPrivateKey().toString("hex")); | ||
dispatch(setWallet(wallet)); | ||
}; | ||
} | ||
|
||
export function loadWallet() { | ||
return async (dispatch) => { | ||
let privateKey = await AsyncStorage.getItem("wallet"); | ||
if (privateKey) { | ||
let wallet = Wallet.fromPrivateKey(Buffer.from(privateKey, "hex")); | ||
dispatch(setWallet(wallet)); | ||
dispatch(finishedLoadingWallet()); | ||
return wallet; | ||
} else { | ||
return null; | ||
} | ||
}; | ||
} |