Skip to content

Commit 421c0ed

Browse files
committed
Initial Commit
0 parents  commit 421c0ed

25 files changed

+8172
-0
lines changed

.babelrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": ["babel-preset-expo", "babel-preset-react-native-web3"],
3+
"env": {
4+
"development": {
5+
"plugins": ["transform-react-jsx-source"]
6+
}
7+
}
8+
}

.eslintrc.js

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
module.exports = {
2+
parser: require.resolve('babel-eslint'),
3+
4+
env: {
5+
es6: true,
6+
},
7+
parserOptions: {
8+
sourceType: 'module',
9+
ecmaFeatures: {
10+
jsx: true,
11+
},
12+
},
13+
plugins: ['import', 'react'],
14+
15+
rules: {
16+
'constructor-super': 'error',
17+
'no-case-declarations': 'error',
18+
'no-class-assign': 'error',
19+
'no-cond-assign': 'error',
20+
'no-const-assign': 'error',
21+
'no-constant-condition': 'error',
22+
'no-control-regex': 'error',
23+
'no-delete-var': 'error',
24+
'no-dupe-args': 'error',
25+
'no-dupe-class-members': 'error',
26+
'no-dupe-keys': 'error',
27+
'no-duplicate-case': 'error',
28+
'no-empty': 'error',
29+
'no-empty-character-class': 'error',
30+
'no-empty-pattern': 'error',
31+
'no-ex-assign': 'error',
32+
'no-extra-boolean-cast': 'error',
33+
'no-extra-semi': 'error',
34+
'no-fallthrough': 'error',
35+
'no-func-assign': 'error',
36+
'no-inner-declarations': 'error',
37+
'no-invalid-regexp': 'error',
38+
'no-new-symbol': 'error',
39+
'no-obj-calls': 'error',
40+
'no-octal': 'error',
41+
'no-redeclare': 'error',
42+
'no-regex-spaces': 'error',
43+
'no-self-assign': 'error',
44+
'no-sparse-arrays': 'error',
45+
'no-this-before-super': 'error',
46+
'no-unexpected-multiline': 'error',
47+
'no-unreachable': 'error',
48+
'no-unsafe-finally': 'error',
49+
'no-unused-labels': 'error',
50+
'no-unused-vars': 'warn',
51+
'require-yield': 'error',
52+
'use-isnan': 'error',
53+
'valid-typeof': 'error',
54+
55+
'import/no-unresolved': 'warn',
56+
'import/named': 'error',
57+
'import/default': 'off',
58+
'import/namespace': 'off',
59+
'import/export': 'error',
60+
'import/no-named-as-default': 'off',
61+
'import/no-named-as-default-member': 'off',
62+
'import/no-deprecated': 'off',
63+
'import/no-extraneous-dependencies': 'off',
64+
'import/no-commonjs': 'warn',
65+
'import/no-amd': 'error',
66+
'import/no-nodejs-modules': 'off',
67+
'import/imports-first': 'error',
68+
'import/no-duplicates': 'error',
69+
'import/no-namespace': 'off',
70+
'import/extensions': ['error', { js: 'never', json: 'always' }],
71+
'import/order': 'off',
72+
73+
'react/display-name': 'off',
74+
'react/forbid-prop-types': 'off',
75+
'react/no-danger': 'error',
76+
'react/no-deprecated': 'error',
77+
'react/no-did-mount-set-state': 'error',
78+
'react/no-did-update-set-state': 'error',
79+
'react/no-direct-mutation-state': 'error',
80+
'react/no-is-mounted': 'error',
81+
'react/no-multi-comp': 'off',
82+
'react/no-set-state': 'off',
83+
'react/no-string-refs': 'error',
84+
'react/no-unknown-property': 'error',
85+
'react/prefer-es6-class': 'error',
86+
'react/prop-types': 'off',
87+
'react/react-in-jsx-scope': 'error',
88+
'react/require-render-return': 'error',
89+
'react/self-closing-comp': 'error',
90+
'react/sort-comp': 'error',
91+
'react/sort-prop-types': 'off',
92+
'react/jsx-boolean-value': ['error', 'never'],
93+
'react/jsx-handler-names': 'off',
94+
'react/jsx-key': 'error',
95+
'react/jsx-no-bind': 'off',
96+
'react/jsx-no-duplicate-props': 'error',
97+
'react/jsx-no-literals': 'off',
98+
'react/jsx-no-undef': 'error',
99+
'react/jsx-pascal-case': 'error',
100+
'react/jsx-sort-props': 'off',
101+
'react/jsx-uses-react': 'error',
102+
'react/jsx-uses-vars': 'error',
103+
'react/prefer-stateless-function': 'off',
104+
},
105+
settings: {
106+
'import/resolver': {
107+
node: {
108+
extensions: ['.js', '.native.js', 'json'],
109+
},
110+
},
111+
},
112+
};

.flowconfig

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[ignore]
2+
<PROJECT_ROOT>/node_modules
3+
.*/*[.]android.js
4+
[include]
5+
6+
[libs]
7+
./libdefs.js
8+
9+
[lints]
10+
11+
[options]
12+
emoji=true
13+
module.system=haste
14+
module.file_ext=.js
15+
module.file_ext=.native.js
16+
module.file_ext=.json
17+
18+
suppress_type=$FlowIssue
19+
suppress_type=$FlowFixMe
20+
suppress_type=$FixMe
21+
22+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-8]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
23+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-8]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
24+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
25+
suppress_comment=\\(.\\|\n\\)*\\$FlowIgnore
26+

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/**/*
2+
.expo/*
3+
npm-debug.*
4+

.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

App.js

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* @flow */
2+
import * as React from 'react';
3+
// $FlowFixMe
4+
import 'babel-preset-react-native-web3/globals';
5+
6+
import HDWalletProvider from 'truffle-hdwallet-provider';
7+
8+
import { TabNavigator } from 'react-navigation';
9+
10+
import Web3 from 'web3';
11+
12+
import Main from './src/Candidates/Main';
13+
import Container from './src/Container';
14+
import Stats from './src/Stats';
15+
16+
import truffleConfig from './truffle';
17+
18+
const network = truffleConfig.networks.ropsten;
19+
const TESTRPC_ADDRESS = `${network.protocol}://${network.host}/`;
20+
21+
const mnemonic = 'YOUR_MNEMONIC_HERE'; // 12 word mnemonic
22+
23+
const web3Provider = new HDWalletProvider(mnemonic, TESTRPC_ADDRESS);
24+
25+
const web3 = new Web3(web3Provider);
26+
27+
class MainScreen extends React.PureComponent<{}> {
28+
static navigationOptions = {
29+
tabBarVisible: false,
30+
};
31+
render() {
32+
return <Main web3={web3} />;
33+
}
34+
}
35+
36+
class SetupScreen extends React.PureComponent<{}> {
37+
static navigationOptions = {
38+
tabBarVisible: false,
39+
};
40+
render() {
41+
return <Stats web3={web3} />;
42+
}
43+
}
44+
45+
export default class App extends React.PureComponent<{}> {
46+
render() {
47+
return (
48+
<Container>
49+
<AppNavigation />
50+
</Container>
51+
);
52+
}
53+
}
54+
const AppNavigation = TabNavigator(
55+
{
56+
Main: { screen: MainScreen },
57+
Setup: { screen: SetupScreen },
58+
},
59+
{
60+
animationEnabled: true,
61+
swipeEnabled: true,
62+
}
63+
);

README.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# react-native-blockchain-poll
2+
3+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
4+
5+
> This is just in an early stage and can fail.
6+
7+
A simple mobile decentralized app ( dApp ) done as a prototype for [React Native](https://facebook.github.io/react-native/) and [expo](https://expo.io) to handle cryptopunks ranking on the ethereum blockchain.
8+
9+
## Overview
10+
11+
* It's basically a mobile dapp for iOS and android done using `react-native` and `web3`.
12+
13+
* It uses [flow](https://flow.org/) as a javascript typechecker and [babel-preset-react-native-web3](https://github.com/agrcrobles/babel-preset-react-native-web3) to polyfill crypto
14+
15+
## Getting started in localhost
16+
17+
Configure `Ropsten Testnet Network` mnemonic key in `App.js`
18+
19+
```bash
20+
# Install dependencies
21+
yarn
22+
23+
# and from a separate shell Run the mobile app
24+
exp start
25+
```
26+
27+
For more information about configuring the cross platform app look into the [React Native](https://facebook.github.io/react-native/docs/getting-started.html) and [expo](https://docs.expo.io/versions/latest/index.html) getting started guides.
28+
29+
### React Native dependencies
30+
31+
* [victory-native](https://formidable.com/open-source/victory/docs/victory-pie/) Victory bar Charts
32+
* [react-navigation](https://github.com/react-community/react-navigation) to navigate among scenes
33+
* among other cool ones such as `react-native-pull-to-refresh` and `react-native-star-rating`
34+
35+
### Ethereum dependencies
36+
37+
* [web3](https://github.com/ethereum/web3.js) as the Etherum Javascript API
38+
* [truffle-contract](https://github.com/trufflesuite/truffle-contract) to parse the abstraction of the smart contract
39+
* [truffle-hdwallet-provider](https://github.com/trufflesuite/truffle-hdwallet-provider) to sign transactions via a deterministic wallet provider
40+
41+
## Expo
42+
43+
![expo](https://raw.githubusercontent.com/agrcrobles/react-native-blockchain-poll/master/assets/expo.png)
44+
45+
## Sample
46+
47+
![playing with the app](https://raw.githubusercontent.com/agrcrobles/react-native-blockchain-poll/master/assets/sample.gif)
48+
49+
## Ropsten
50+
51+
* Smart Contract - https://ropsten.etherscan.io/address/0x25cee65ac493a0c965f12a2d0c46fe82e09d6d44
52+
* Coinbase - https://ropsten.etherscan.io/address/0x712f06642990a90f151a89990594365c4b32dec5
53+
54+
## More info
55+
56+
* For more info about the ethereum configuration, see the following [gist](https://gist.github.com/agrcrobles/e03151b27ad4753827de227929677db3)
57+
58+
## Contributing
59+
60+
Intended for personal purposes stars ✭ and issue reporting, welcome!
61+
62+
## License
63+
64+
MIT @ zetta

app.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"expo": {
3+
"name": "react-native-blockchain-poll",
4+
"description": "A mobile dapp to rank cryptopunks",
5+
"slug": "react-native-blockchain-poll",
6+
"privacy": "public",
7+
"sdkVersion": "25.0.0",
8+
"platforms": ["ios", "android"],
9+
"version": "1.0.0",
10+
"orientation": "portrait",
11+
"icon": "./assets/icon.png",
12+
"splash": {
13+
"image": "./assets/splash.png",
14+
"resizeMode": "contain",
15+
"backgroundColor": "#ffffff"
16+
},
17+
"ios": {
18+
"supportsTablet": true
19+
}
20+
}
21+
}

assets/expo.png

2.88 KB
Loading

assets/icon.png

26 KB
Loading

assets/sample.gif

1.1 MB
Loading

assets/splash.png

7.01 KB
Loading

0 commit comments

Comments
 (0)