Skip to content

Commit 31fbee0

Browse files
crypto error fixed
1 parent 61c2c6d commit 31fbee0

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/util/web3/index.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ const startWeb3 = (/* tcall */) => {
224224
tinyCrypto.isUnlocked = () => window.ethereum && window.ethereum._isUnlocked;
225225

226226
// Emitter
227-
class MyEmitter extends EventEmitter {}
227+
class MyEmitter extends EventEmitter { }
228228
const myEmitter = new MyEmitter();
229229
myEmitter.setMaxListeners(Infinity);
230230

@@ -267,7 +267,7 @@ const startWeb3 = (/* tcall */) => {
267267
})
268268
.catch(reject);
269269
})
270-
.catch(reject);
270+
.catch(err => { console.error(err); resolve(null); });
271271
} else {
272272
reject(tinyCrypto.errors.noProvider());
273273
}
@@ -281,7 +281,7 @@ const startWeb3 = (/* tcall */) => {
281281
tinyCrypto
282282
.checkConnection()
283283
.then((cryptoData) => {
284-
if (tinyCrypto.validateMatrixAddress()) {
284+
if (cryptoData && tinyCrypto.validateMatrixAddress()) {
285285
// Address
286286
const tinyAddress = address.toLowerCase();
287287

@@ -440,16 +440,18 @@ const startWeb3 = (/* tcall */) => {
440440

441441
tinyCrypto
442442
.checkConnection(true)
443-
.then(() => {
444-
web3
445-
.getNetwork()
446-
.then((network) => {
447-
tinyCrypto.chainId = network.chainId;
448-
tinyCrypto.connected = true;
449-
// tcall();
450-
myEmitter.emit('readyProvider');
451-
})
452-
.catch(tinyConnectionError);
443+
.then((data) => {
444+
if (data) {
445+
web3
446+
.getNetwork()
447+
.then((network) => {
448+
tinyCrypto.chainId = network.chainId;
449+
tinyCrypto.connected = true;
450+
// tcall();
451+
myEmitter.emit('readyProvider');
452+
})
453+
.catch(tinyConnectionError);
454+
}
453455
})
454456
.catch(tinyConnectionError);
455457
}

src/util/web3/status.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export function setEthereumStatusButton(newHeader) {
77
}
88
export default function startStatus() {
99
// Detect Meta to Update Icon
10-
const checkConnection = function () {
11-
if (header) {
10+
const checkConnection = function (data) {
11+
if (data && header) {
1212
if (!tinyCrypto.existEthereum()) {
1313
if (!__ENV_APP__.ELECTRON_MODE)
1414
toast("You don't have a ethereum Wallet installed in your browser!", 'Ethereum Wallet');

0 commit comments

Comments
 (0)