-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MetaMask Controller #6
Changes from 1 commit
b929f86
4d93c7c
f4bb286
2a35196
bb757e4
504e90d
3bc9d17
68db65b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
__snapshots__ | ||
android | ||
coverage | ||
app/core | ||
ios | ||
node_modules | ||
package-lock.json | ||
package.json | ||
shim.js | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shim is autogenerated by the rn-nodeify which allows you to use node stuff in react native There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Can we get more specific with the file path? Won't this ignore any There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call! |
||
index.js | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one includes the shim and all that stuff, it's a pretty simple and basic file, so I don't really care about being here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above; can we get more specific with the file path so we don't ignore all Edit: Actually, should this file really be ignored? I didn't see a generated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { createBottomTabNavigator } from 'react-navigation'; | ||
import BrowserScreen from '../BrowserScreen'; | ||
import WalletScreen from '../WalletScreen'; | ||
|
||
/** | ||
* Root application component responsible for configuring the tab navigator | ||
*/ | ||
export default createBottomTabNavigator({ | ||
Home: { | ||
screen: BrowserScreen | ||
}, | ||
Wallet: { | ||
screen: WalletScreen | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { Component } from 'react'; | ||
import { StyleSheet, View, Text, ActivityIndicator } from 'react-native'; | ||
import initBackground from '../../core/scripts/background-react-native'; | ||
import { colors } from '../../styles/common'; | ||
|
||
const styles = StyleSheet.create({ | ||
wrapper: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: colors.slate | ||
} | ||
}); | ||
|
||
export default class Wallet extends Component { | ||
state = { | ||
rate: null | ||
}; | ||
|
||
async componentDidMount() { | ||
this.controller = await initBackground(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how I initialize the "background" process and the only thing it does is to initialize an instance of the MM controller (see https://github.com/bitpshr/MetaMask/pull/6/files#diff-cba5272be8f66ce2d8d371b4507dcd15R434) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, I just realized that we could potentially get rid of the background file and instantiate the MM controller directly |
||
this.init(); | ||
} | ||
|
||
init() { | ||
// Example of how to interact with the MM controller | ||
const API = this.controller.getApi(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Below, this is just a minimal demo of how to access the MM controller |
||
API.setCurrentCurrency('usd', (error, rate) => { | ||
this.setState({ rate: rate.conversionRate }); | ||
}); | ||
} | ||
|
||
renderRate() { | ||
if (this.state.rate) { | ||
return <Text>ETH RATE: ${this.state.rate}</Text>; | ||
} | ||
return <ActivityIndicator size="small" />; | ||
} | ||
|
||
render() { | ||
return <View style={styles.wrapper}>{this.renderRate()}</View>; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import Wallet from './'; | ||
|
||
describe('Wallet', () => { | ||
it('should render correctly', () => { | ||
const wrapper = shallow(<Wallet />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React, { Component } from 'react'; | ||
import Wallet from '../Wallet'; | ||
import Screen from '../Screen'; | ||
|
||
/** | ||
* Main view component for the wallet screen | ||
*/ | ||
export default class WalletScreen extends Component { | ||
render() { | ||
return ( | ||
<Screen> | ||
<Wallet /> | ||
</Screen> | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import WalletScreen from './'; | ||
|
||
describe('WalletScreen', () => { | ||
it('should render correctly', () => { | ||
const wrapper = shallow(<WalletScreen />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything I brought in from the extension is inside that folder. Ideally we would move it to an npm package (or use GABA)