Skip to content

Commit 13d8ff9

Browse files
committedFeb 22, 2021
add more checks if a wallet is connected. inform user and return error if a wallet is not connected
1 parent 9ca5dd1 commit 13d8ff9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+26976
-245
lines changed
 

‎example/app/src/App.vue

+10-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<button @click="selectNetwork(42)">Kovan</button>
1313
</div>
1414

15-
<ul v-show="userAddress !== ''">
15+
<!-- <ul v-show="userAddress !== ''">-->
16+
<ul>
1617
<li>
1718
<button @click="disconnect">Disconnect</button>
1819
</li>
@@ -35,7 +36,8 @@
3536
placeholder="amount"
3637
/> </label
3738
><br />
38-
<button v-show="userAddress !== ''" @click="sendTx">send</button>
39+
<!-- <button v-show="userAddress !== ''" @click="sendTx">send</button>-->
40+
<button @click="sendTx">send</button>
3941
<h6>Sends to the connected wallet address</h6>
4042
<h3>Tx Hash:</h3>
4143
{{ txHash }}
@@ -100,7 +102,10 @@
100102
/>
101103
</label>
102104
<br />
103-
<button v-show="userAddress !== ''" @click="sendTxDetailed">
105+
<!-- <button v-show="userAddress !== ''" @click="sendTxDetailed">-->
106+
<!-- send-->
107+
<!-- </button>-->
108+
<button @click="sendTxDetailed">
104109
send
105110
</button>
106111
<h6>Sends to the connected wallet address</h6>
@@ -363,7 +368,7 @@ export default {
363368
this.connect = new mewConnect.Provider({
364369
windowClosedError: true,
365370
chainId: 1,
366-
rpcUrl: 'wss://mainnet.infura.io/ws/v3/7d06294ad2bd432887eada360c5e1986'
371+
rpcUrl: 'https://mainnet.infura.io/v3/859569f6decc4446a5da1bb680e7e9cf' //'wss://mainnet.infura.io/ws/v3/7d06294ad2bd432887eada360c5e1986'
367372
// rpcUrl: 'HTTP://127.0.0.1:7545'
368373
// infuraId:
369374
// '7d06294ad2bd432887eada360c5e1986'
@@ -508,6 +513,7 @@ export default {
508513
this.userAddress = '';
509514
},
510515
getAccount() {
516+
console.log(this.ethereum); // todo remove dev item
511517
this.ethereum.send('eth_requestAccounts').then(accounts => {
512518
console.log(`User's address is ${accounts[0]}`);
513519
});

‎src/connectClient/WebRtcCommunication.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default class WebRtcCommunication extends MewConnectCommon {
6060
this.usingVersion = version;
6161
}
6262

63-
setActiveInitiatorId(id){
63+
setActiveInitiatorId(id) {
6464
this.activeInitiatorId = id;
6565
}
6666

@@ -307,12 +307,16 @@ export default class WebRtcCommunication extends MewConnectCommon {
307307
}
308308
if (this.isJSON(decryptedData)) {
309309
const parsed = JSON.parse(decryptedData);
310-
this.emit('data', { type: parsed.type, data: parsed.data, id: parsed.id });
310+
this.emit('data', {
311+
type: parsed.type,
312+
data: parsed.data,
313+
id: parsed.id
314+
});
311315
} else {
312316
this.emit('data', {
313317
type: decryptedData.type,
314318
data: decryptedData.data,
315-
id: decryptedData.id
319+
id: decryptedData.id
316320
});
317321
}
318322
} catch (e) {
@@ -363,10 +367,9 @@ export default class WebRtcCommunication extends MewConnectCommon {
363367
sendRtcMessage(type, msg, id) {
364368
debug(msg);
365369
debug(`[SEND RTC MESSAGE] type: ${type}, message: ${msg}, id: ${id}`);
366-
this.rtcSend(JSON.stringify({ type, data: msg, id }))
367-
.catch(err =>{
368-
debug(err)
369-
});
370+
this.rtcSend(JSON.stringify({ type, data: msg, id })).catch(err => {
371+
debug(err);
372+
});
370373
}
371374

372375
disconnectRTCClosure() {

0 commit comments

Comments
 (0)
Please sign in to comment.