Skip to content

Commit ebf83fa

Browse files
author
jagdeep sidhu
committed
cleanup islocked logic
1 parent 7e80682 commit ebf83fa

File tree

6 files changed

+28
-53
lines changed

6 files changed

+28
-53
lines changed

src/wizard/Step1FastSwap.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,6 @@ class Step1FS extends Component {
138138
this.setState({buttonVal1: false, buttonValMsg1: this.props.t("step2InstallPali")});
139139
return;
140140
}
141-
try {
142-
if(await window.ConnectionsController.isLocked()) {
143-
this.setState({buttonVal1: false, buttonValMsg1: this.props.t("step2UnlockPali")});
144-
return;
145-
}
146-
} catch(e) {
147-
this.setState({buttonVal1: false, buttonValMsg1: e.message || e});
148-
return;
149-
}
150141
let connectedAccount;
151142
try {
152143
connectedAccount = await window.ConnectionsController.getConnectedAccount()
@@ -158,7 +149,11 @@ class Step1FS extends Component {
158149
this.setState({buttonVal1: false, buttonValMsg1: e.message || e});
159150
return;
160151
}
161-
if (!connectedAccount) {
152+
const locked = await window.ConnectionsController.isLocked()
153+
if(locked) {
154+
this.setState({buttonVal1: true, buttonValMsg1: this.props.t("step2UnlockPali")});
155+
}
156+
if (!connectedAccount || locked) {
162157
await window.ConnectionsController.connectWallet()
163158
}
164159
let xpub;

src/wizard/Step1SysToEth.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,6 @@ class Step1 extends Component {
8888
this.setState({buttonVal: false, buttonValMsg: this.props.t("step2InstallPali")});
8989
return;
9090
}
91-
try {
92-
if(await window.ConnectionsController.isLocked()) {
93-
this.setState({buttonVal: false, buttonValMsg: this.props.t("step2UnlockPali")});
94-
return;
95-
}
96-
} catch(e) {
97-
this.setState({buttonVal: false, buttonValMsg: e.message || e});
98-
return;
99-
}
10091
let connectedAccount;
10192
try {
10293
connectedAccount = await window.ConnectionsController.getConnectedAccount()
@@ -108,7 +99,11 @@ class Step1 extends Component {
10899
this.setState({buttonVal: false, buttonValMsg: e.message || e});
109100
return;
110101
}
111-
if (!connectedAccount) {
102+
const locked = await window.ConnectionsController.isLocked()
103+
if(locked) {
104+
this.setState({buttonVal: true, buttonValMsg: this.props.t("step2UnlockPali")});
105+
}
106+
if (!connectedAccount || locked) {
112107
await window.ConnectionsController.connectWallet()
113108
}
114109
let xpub;

src/wizard/Step1SysToSysx.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,6 @@ class Step1SX extends Component {
8383
this.setState({buttonVal: false, buttonValMsg: this.props.t("step2InstallPali")});
8484
return;
8585
}
86-
try {
87-
if(await window.ConnectionsController.isLocked()) {
88-
this.setState({buttonVal: false, buttonValMsg: this.props.t("step2UnlockPali")});
89-
return;
90-
}
91-
} catch(e) {
92-
this.setState({buttonVal: false, buttonValMsg: e.message || e});
93-
return;
94-
}
9586
let connectedAccount;
9687
try {
9788
connectedAccount = await window.ConnectionsController.getConnectedAccount()
@@ -103,7 +94,11 @@ class Step1SX extends Component {
10394
this.setState({buttonVal: false, buttonValMsg: e.message || e});
10495
return;
10596
}
106-
if (!connectedAccount) {
97+
const locked = await window.ConnectionsController.isLocked()
98+
if(locked) {
99+
this.setState({buttonVal: true, buttonValMsg: this.props.t("step2UnlockPali")});
100+
}
101+
if (!connectedAccount || locked) {
107102
await window.ConnectionsController.connectWallet()
108103
}
109104
let xpub;

src/wizard/Step1SysxToSys.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,6 @@ class Step1XS extends Component {
8484
this.setState({buttonVal: false, buttonValMsg: this.props.t("step2InstallPali")});
8585
return;
8686
}
87-
try {
88-
if(await window.ConnectionsController.isLocked()) {
89-
this.setState({buttonVal: false, buttonValMsg: this.props.t("step2UnlockPali")});
90-
return;
91-
}
92-
} catch(e) {
93-
this.setState({buttonVal: false, buttonValMsg: e.message || e});
94-
return;
95-
}
9687
let connectedAccount;
9788
try {
9889
connectedAccount = await window.ConnectionsController.getConnectedAccount()
@@ -104,7 +95,11 @@ class Step1XS extends Component {
10495
this.setState({buttonVal: false, buttonValMsg: e.message || e});
10596
return;
10697
}
107-
if (!connectedAccount) {
98+
const locked = await window.ConnectionsController.isLocked()
99+
if(locked) {
100+
this.setState({buttonVal: true, buttonValMsg: this.props.t("step2UnlockPali")});
101+
}
102+
if (!connectedAccount || locked) {
108103
await window.ConnectionsController.connectWallet()
109104
}
110105
let xpub;

src/wizard/Step2EthToSys.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ class Step2ES extends Component {
8080
this.setState({buttonVal: false, buttonValMsg: this.props.t("step2InstallPali")});
8181
return;
8282
}
83-
try {
84-
if(await window.ConnectionsController.isLocked()) {
85-
this.setState({buttonVal: false, buttonValMsg: this.props.t("step2UnlockPali")});
86-
return;
87-
}
88-
} catch(e) {
89-
this.setState({buttonVal: false, buttonValMsg: e.message || e});
90-
return;
91-
}
9283
let connectedAccount;
9384
try {
9485
connectedAccount = await window.ConnectionsController.getConnectedAccount()
@@ -100,7 +91,11 @@ class Step2ES extends Component {
10091
this.setState({buttonVal: false, buttonValMsg: e.message || e});
10192
return;
10293
}
103-
if (!connectedAccount) {
94+
const locked = await window.ConnectionsController.isLocked()
95+
if(locked) {
96+
this.setState({buttonVal: true, buttonValMsg: this.props.t("step2UnlockPali")});
97+
}
98+
if (!connectedAccount || locked) {
10499
await window.ConnectionsController.connectWallet()
105100
}
106101
let xpub;

src/wizard/i18n.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ i18n.use(LanguageDetector).init({
100100
'step2EnterEthAddress': 'NEVM address of recipient...',
101101
'step1Button': "Burn",
102102
'step2InstallPali': 'Please install Pali to submit SPV proof to Syscoin...',
103-
'step2UnlockPali': 'Please unlock your Pali wallet...',
103+
'step2UnlockPali': 'Please unlock your Pali wallet and try again...',
104104
'step2SelectPaliAccount': 'Please select an account in Pali to use for submitting an SPV proof to Syscoin...',
105105
'step2EnterTx': 'Enter Syscoin Burn TXID...',
106106
'step2Head': '<em className="step">Step 2:</em> Complete!',
@@ -237,7 +237,7 @@ i18n.use(LanguageDetector).init({
237237
'step2EnterEthAddress': 'NEVM address of recipient...',
238238
'step1Button': "Burn",
239239
'step2InstallPali': 'Please install Pali to submit SPV proof to Syscoin...',
240-
'step2UnlockPali': 'Please unlock your Pali wallet...',
240+
'step2UnlockPali': 'Please unlock your Pali wallet and try again...',
241241
'step2SelectPaliAccount': 'Please select an account in Pali to use for submitting an SPV proof to Syscoin...',
242242
'step2EnterTx': 'Enter Syscoin Burn TXID...',
243243
'step2Head': '<em className="step">Step 2:</em> Complete!',
@@ -374,7 +374,7 @@ i18n.use(LanguageDetector).init({
374374
'step2EnterEthAddress': 'NEVM address of recipient...',
375375
'step1Button': "Burn",
376376
'step2InstallPali': 'Please install Pali to submit SPV proof to Syscoin...',
377-
'step2UnlockPali': 'Please unlock your Pali wallet...',
377+
'step2UnlockPali': 'Please unlock your Pali wallet and try again...',
378378
'step2SelectPaliAccount': 'Please select an account in Pali to use for submitting an SPV proof to Syscoin...',
379379
'step2EnterTx': 'Enter Syscoin Burn TXID...',
380380
'step2Head': '<em className="step">Step 2:</em> Complete!',

0 commit comments

Comments
 (0)