-
-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b929f86
MetaMask Controller working
brunobar79 4d93c7c
fix
brunobar79 f4bb286
fix conflicts
brunobar79 2a35196
npm baby
brunobar79 bb757e4
update prettierignore
brunobar79 504e90d
more clean up
brunobar79 3bc9d17
Slight reorganization
bitpshr 68db65b
Clean up package.json
bitpshr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -47,3 +47,6 @@ buck-out/ | |
|
||
# testing | ||
coverage | ||
|
||
# app-specific | ||
shim.js |
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ ios | |
node_modules | ||
package-lock.json | ||
package.json | ||
/shim.js |
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 |
---|---|---|
@@ -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 | ||
} | ||
}); |
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,43 @@ | ||
import React, { Component } from 'react'; | ||
import initBackground from 'metamask-core'; | ||
import { ActivityIndicator, StyleSheet, Text, View } from 'react-native'; | ||
import { colors } from '../../styles/common'; | ||
|
||
const styles = StyleSheet.create({ | ||
wrapper: { | ||
alignItems: 'center', | ||
backgroundColor: colors.slate, | ||
flex: 1, | ||
justifyContent: 'center' | ||
} | ||
}); | ||
|
||
export default class Wallet extends Component { | ||
state = { | ||
rate: null | ||
}; | ||
|
||
async componentDidMount() { | ||
this.controller = await initBackground(); | ||
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>; | ||
} | ||
} |
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,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(); | ||
}); | ||
}); |
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 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> | ||
); | ||
} | ||
} |
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,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(); | ||
}); | ||
}); |
File renamed without changes.
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,9 +1,12 @@ | ||
/** | ||
* Common styles and variables | ||
*/ | ||
import './shim.js'; | ||
import crypto from 'crypto'; // eslint-disable-line import/no-nodejs-modules, no-unused-vars | ||
require('react-native-browser-polyfill'); // eslint-disable-line import/no-commonjs | ||
|
||
import App from './app/components/App'; | ||
import { AppRegistry } from 'react-native'; | ||
import App from './app/components/App'; | ||
import { name } from './app.json'; | ||
|
||
AppRegistry.registerComponent(name, () => App); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 comment
The 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