Skip to content

Commit ee2a748

Browse files
authored
Merge pull request #223 from AElfProject/fix/mobile-login
Discover login required app
2 parents 234f78f + 16633d9 commit ee2a748

File tree

3 files changed

+32
-29
lines changed

3 files changed

+32
-29
lines changed

packages/base/src/errors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const ERR_CODE = {
2525
GET_LOGIN_STATUS_FAIL: 10022,
2626
IN_FINISH_BUT_STATUS_IS_NOT_SUCCESS: 10023,
2727
UNKNOWN: 10024,
28+
DISCOVER_LOGIN_REQUIRED_APP: 10025,
2829
};
2930

3031
export const ERR_CODE_MSG: {
@@ -57,6 +58,7 @@ export const ERR_CODE_MSG: {
5758
10022: 'Call getLoginStatus but the result is not pass',
5859
10023: 'Login completed, but the isLoginStatus is not success. Please log in again',
5960
10024: 'Unknown error',
61+
10025: 'Please use the FairyVault app or the FairyVault browser extension on your computer.',
6062
};
6163

6264
export function makeError(code: number, nativeError?: any): TWalletError {

packages/wallets/fairy-vault-discover/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ export class FairyVaultDiscoverWallet extends BaseWalletAdapter {
169169

170170
async login(): Promise<TWalletInfo> {
171171
if (isMobileDevices() && !isFairyVaultApp()) {
172-
openPageInDiscover(undefined, undefined);
172+
// TODO: open in FairyVault App
173+
// openPageInDiscover(undefined, undefined);
174+
this.emit('error', makeError(ERR_CODE.DISCOVER_LOGIN_REQUIRED_APP));
173175
return;
174176
}
175177
try {

packages/wallets/fairy-vault-discover/src/utils.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,31 @@ export function zeroFill(str: string | BN) {
66
}
77

88
export function openPageInDiscover(url?: string, version?: 'v1') {
9-
console.info('TODO List', url, version);
10-
// TODO: change link to fairy vault
11-
// try {
12-
// window.location.href = scheme.formatScheme({
13-
// action: 'linkDapp',
14-
// version,
15-
// domain: window.location.host,
16-
// custom: {
17-
// url: url || window.location.href,
18-
// },
19-
// });
20-
// const downloadUrl = 'https://portkey.finance/';
21-
// setTimeout(() => {
22-
// const hidden =
23-
// window.document.hidden ||
24-
// (window.document as any).mozHidden ||
25-
// (window.document as any).msHidden ||
26-
// (window.document as any).webkitHidden;
27-
// if (typeof hidden !== 'undefined' && hidden === true) {
28-
// return;
29-
// }
30-
// window.location.href = downloadUrl;
31-
// }, 2000);
32-
// } catch (error) {
33-
// // can‘t open app cannot go into this logic
34-
// console.error(error);
35-
// window.open('https://portkey.finance', '_blank');
36-
// }
9+
try {
10+
window.location.href = scheme.formatScheme({
11+
scheme: 'portkey.fairyvault',
12+
action: 'linkDapp',
13+
version,
14+
domain: window.location.host,
15+
custom: {
16+
url: url || window.location.href,
17+
},
18+
});
19+
const downloadUrl = 'https://fairyvault.com/';
20+
setTimeout(() => {
21+
const hidden =
22+
window.document.hidden ||
23+
(window.document as any).mozHidden ||
24+
(window.document as any).msHidden ||
25+
(window.document as any).webkitHidden;
26+
if (typeof hidden !== 'undefined' && hidden === true) {
27+
return;
28+
}
29+
window.location.href = downloadUrl;
30+
}, 2000);
31+
} catch (error) {
32+
// can‘t open app cannot go into this logic
33+
console.error(error);
34+
window.open('https://fairyvault.com', '_blank');
35+
}
3736
}

0 commit comments

Comments
 (0)