-
Notifications
You must be signed in to change notification settings - Fork 35
/
index.js
87 lines (75 loc) · 2.28 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import {EventEmitter} from 'events';
import 'node-libs-react-native/globals';
import {I18nManager, YellowBox} from 'react-native';
import {Navigation} from 'react-native-navigation';
import RNRestart from 'react-native-restart';
import {setTabsRoot, setOnboardingRoot} from './navigation';
import {registerHeaders} from './navigation/headers';
import {registerModals} from './navigation/modals';
import {registerScreens} from './navigation/screens';
import {setStore as setStoreForAssetService} from './services/AssetService';
import {GasService} from './services/GasService';
import {TransactionService} from './services/TransactionService';
import {UniswapService} from './services/UniswapService';
import {WalletService} from './services/WalletService';
import {initialize as initializeStore} from './store';
import {loadWalletAddress} from './thunks';
import {setExceptionHandlers} from './error-handlers';
if (I18nManager.isRTL) {
I18nManager.allowRTL(false);
RNRestart.Restart();
}
EventEmitter.defaultMaxListeners = 32000;
EventEmitter.prototype.defaultMaxListeners = 32000;
EventEmitter.prototype._maxListeners = 32000;
if (__DEV__) {
YellowBox.ignoreWarnings([
'Setting a timer',
'Class RCTCxxModule',
'Warning:',
'Method',
'Module',
'MOBIDEX:',
]);
} else {
setExceptionHandlers();
}
const initializeApp = (function initialize() {
let _store = null;
let _count = 0;
return async store => {
if (store) _store = store;
if (++_count < 2) return;
setStoreForAssetService(_store);
new GasService(_store);
new WalletService(_store);
new UniswapService(_store);
new TransactionService(_store);
await WalletService.instance.initialize();
await _store.dispatch(loadWalletAddress());
const {
wallet: {address},
} = _store.getState();
registerScreens(_store);
registerHeaders(_store);
registerModals(_store);
Navigation.setDefaultOptions({
statusBar: {
visible: true,
style: 'dark',
},
topBar: {
visible: false,
drawBehind: true,
animate: true,
},
});
if (address) {
setTabsRoot();
} else {
setOnboardingRoot();
}
};
})();
initializeStore(initializeApp);
Navigation.events().registerAppLaunchedListener(initializeApp);