forked from haqq-network/haqq-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
91 lines (77 loc) · 2.22 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
88
89
90
91
/**
* @format
*/
import '@ethersproject/shims';
import '@walletconnect/react-native-compat'
import {AppRegistry} from 'react-native';
import {ENVIRONMENT, SENTRY_DSN} from '@env';
import {JsonRpcProvider} from '@ethersproject/providers';
import * as Sentry from '@sentry/react-native';
import {name as appName} from './app.json';
import {App} from './src/app';
import './src/event-actions';
import {Overview} from './src/overview';
import {Jailbreak} from './src/jailbreak';
if(!global.BigInt){
const BigInt = require('big-integer');
Object.assign(global, {
BigInt: BigInt,
});
}
import './src/event-actions';
import {DEBUG_VARS} from '@app/debug-vars';
if (SENTRY_DSN && DEBUG_VARS.enableSentry) {
try {
Sentry.init({
dsn: SENTRY_DSN,
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production.
tracesSampleRate: 1.0,
environment: ENVIRONMENT ?? 'development',
enableWatchdogTerminationTracking: false
});
} catch (e) {
console.log('sentry init failed');
}
}
function getResult(payload) {
if (payload.error) {
const error = new Error(payload.error.message);
error.code = payload.error.code;
error.data = payload.error.data;
throw error;
}
return payload.result;
}
JsonRpcProvider.prototype.send = async function (method, params) {
const request = {
method: method,
params: params,
id: this._nextId++,
jsonrpc: '2.0',
};
const cache = ['eth_chainId', 'eth_blockNumber'].indexOf(method) >= 0;
if (cache && this._cache[method]) {
return this._cache[method];
}
const req = await fetch(`${this.connection.url}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(request),
});
const resp = await req.json();
const result = getResult(resp);
if (cache) {
this._cache[method] = result;
setTimeout(() => {
this._cache[method] = null;
}, 0);
}
return result;
};
const Wrapped = Sentry.wrap(App);
AppRegistry.registerComponent(appName, () => Wrapped);
AppRegistry.registerComponent('overview', () => Overview);
AppRegistry.registerComponent('jailbreak', () => Jailbreak);