Skip to content

Commit 675ac4c

Browse files
author
jagdeep sidhu
committed
connect wallet on site start to avoid getConnectedAccount bug
1 parent ebf83fa commit 675ac4c

File tree

6 files changed

+40
-8
lines changed

6 files changed

+40
-8
lines changed

src/pali.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
class PALICONNECT {
3+
constructor() {
4+
this.connect()
5+
}
6+
async connect() {
7+
if (window.ConnectionsController) {
8+
var connectedAccount
9+
try {
10+
connectedAccount = await window.ConnectionsController.getConnectedAccount()
11+
.catch(function(rejected){
12+
console.log("paliConnect error: " + rejected)
13+
});
14+
if(!connectedAccount) {
15+
await window.ConnectionsController.connectWallet()
16+
.catch(function(rejected){
17+
console.log("paliConnect error: " + rejected)
18+
});
19+
}
20+
} catch(e) {
21+
console.log("paliConnect error: " + e)
22+
}
23+
}
24+
25+
}
26+
}
27+
export default new PALICONNECT();

src/wizard/Step1FastSwap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class Step1FS extends Component {
152152
const locked = await window.ConnectionsController.isLocked()
153153
if(locked) {
154154
this.setState({buttonVal1: true, buttonValMsg1: this.props.t("step2UnlockPali")});
155+
return
155156
}
156157
if (!connectedAccount || locked) {
157158
await window.ConnectionsController.connectWallet()

src/wizard/Step1SysToEth.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Step1 extends Component {
9292
try {
9393
connectedAccount = await window.ConnectionsController.getConnectedAccount()
9494
.catch(function(rejected){
95-
this.setState({buttonValMsg: false, buttonValMsg: rejected});
95+
this.setState({buttonVal: false, buttonValMsg: rejected});
9696
return;
9797
});
9898
} catch(e) {
@@ -102,6 +102,7 @@ class Step1 extends Component {
102102
const locked = await window.ConnectionsController.isLocked()
103103
if(locked) {
104104
this.setState({buttonVal: true, buttonValMsg: this.props.t("step2UnlockPali")});
105+
return;
105106
}
106107
if (!connectedAccount || locked) {
107108
await window.ConnectionsController.connectWallet()
@@ -110,7 +111,7 @@ class Step1 extends Component {
110111
try {
111112
xpub = await window.ConnectionsController.getConnectedAccountXpub()
112113
.catch(function(rejected){
113-
this.setState({buttonValMsg: false, buttonValMsg: rejected});
114+
this.setState({buttonVal: false, buttonValMsg: rejected});
114115
return;
115116
});
116117
} catch(e) {

src/wizard/Step1SysToSysx.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Step1SX extends Component {
8787
try {
8888
connectedAccount = await window.ConnectionsController.getConnectedAccount()
8989
.catch(function(rejected){
90-
this.setState({buttonValMsg: false, buttonValMsg: rejected});
90+
this.setState({buttonVal: false, buttonValMsg: rejected});
9191
return;
9292
});
9393
} catch(e) {
@@ -97,6 +97,7 @@ class Step1SX extends Component {
9797
const locked = await window.ConnectionsController.isLocked()
9898
if(locked) {
9999
this.setState({buttonVal: true, buttonValMsg: this.props.t("step2UnlockPali")});
100+
return;
100101
}
101102
if (!connectedAccount || locked) {
102103
await window.ConnectionsController.connectWallet()
@@ -105,7 +106,7 @@ class Step1SX extends Component {
105106
try {
106107
xpub = await window.ConnectionsController.getConnectedAccountXpub()
107108
.catch(function(rejected){
108-
this.setState({buttonValMsg: false, buttonValMsg: rejected});
109+
this.setState({buttonVal: false, buttonValMsg: rejected});
109110
return;
110111
});
111112
} catch(e) {

src/wizard/Step1SysxToSys.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Step1XS extends Component {
8888
try {
8989
connectedAccount = await window.ConnectionsController.getConnectedAccount()
9090
.catch(function(rejected){
91-
this.setState({buttonValMsg: false, buttonValMsg: rejected});
91+
this.setState({buttonVal: false, buttonValMsg: rejected});
9292
return;
9393
});
9494
} catch(e) {
@@ -98,6 +98,7 @@ class Step1XS extends Component {
9898
const locked = await window.ConnectionsController.isLocked()
9999
if(locked) {
100100
this.setState({buttonVal: true, buttonValMsg: this.props.t("step2UnlockPali")});
101+
return;
101102
}
102103
if (!connectedAccount || locked) {
103104
await window.ConnectionsController.connectWallet()
@@ -106,7 +107,7 @@ class Step1XS extends Component {
106107
try {
107108
xpub = await window.ConnectionsController.getConnectedAccountXpub()
108109
.catch(function(rejected){
109-
this.setState({buttonValMsg: false, buttonValMsg: rejected});
110+
this.setState({buttonVal: false, buttonValMsg: rejected});
110111
return;
111112
});
112113
} catch(e) {

src/wizard/Step2EthToSys.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Step2ES extends Component {
8484
try {
8585
connectedAccount = await window.ConnectionsController.getConnectedAccount()
8686
.catch(function(rejected){
87-
this.setState({buttonValMsg: false, buttonValMsg: rejected});
87+
this.setState({buttonVal: false, buttonValMsg: rejected});
8888
return;
8989
});
9090
} catch(e) {
@@ -94,6 +94,7 @@ class Step2ES extends Component {
9494
const locked = await window.ConnectionsController.isLocked()
9595
if(locked) {
9696
this.setState({buttonVal: true, buttonValMsg: this.props.t("step2UnlockPali")});
97+
return;
9798
}
9899
if (!connectedAccount || locked) {
99100
await window.ConnectionsController.connectWallet()
@@ -102,7 +103,7 @@ class Step2ES extends Component {
102103
try {
103104
xpub = await window.ConnectionsController.getConnectedAccountXpub()
104105
.catch(function(rejected){
105-
this.setState({buttonValMsg: false, buttonValMsg: rejected});
106+
this.setState({buttonVal: false, buttonValMsg: rejected});
106107
return;
107108
});
108109
} catch(e){

0 commit comments

Comments
 (0)