-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add: lazy loading modal solana selector #98
Changes from 8 commits
9395c69
5678d3c
5bab9f5
bb51fc0
bba5a77
f26cbb6
bd6a67e
de1f563
11fce53
e012fc4
ae9b42a
7cff49a
cdd47df
6f25b32
dad6ed4
492aeb3
d7ecc4c
01004bd
532d76c
3024c96
0790def
cf5764e
3bb97c4
44295fb
262958d
d4c6d5b
8953340
299798c
64474f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,4 @@ | |
"tslib": "^2.5.3", | ||
"typescript": "^5.1.3" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ import { type AppBaseInitialize } from '@nightlylabs/nightly-connect-base' | |
import { type Deeplink } from '@nightlylabs/nightly-connect-base/dist/types/bindings/Deeplink' | ||
import { type Wallet } from '@wallet-standard/core' | ||
import { type WalletType } from '../../../bindings/WalletType' | ||
import { type WalletMetadata as WalletMetadataOriginal } from '../../../bindings/WalletMetadata' | ||
import { Images } from '../../../bindings/Images' | ||
|
||
export interface Adapter { | ||
connect: () => Promise<void> | ||
|
@@ -17,7 +19,16 @@ export interface MetadataWallet { | |
walletType: WalletType | ||
} | ||
|
||
export interface IWalletListItem extends MetadataWallet { | ||
export interface WalletMetadata extends Partial<WalletMetadataOriginal> { | ||
slug: string | ||
name: string | ||
walletType: WalletType | ||
mobile: Deeplink | null | ||
desktop: Deeplink | null | ||
image: Images | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WHAT ? remove this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But wouldnt it then force me to pass all of the fields such as homepage, version, app etc. in for example polkadot selector detection file? |
||
export interface IWalletListItem extends WalletMetadata { | ||
recent?: boolean | ||
detected?: boolean | ||
standardWallet?: Wallet | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,4 @@ | |
"tslib": "^2.5.3", | ||
"typescript": "^5.1.3" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { | |
import { | ||
ConnectionOptions, | ||
ConnectionType, | ||
IWalletListItem, | ||
NightlyConnectSelectorModal, | ||
XMLOptions, | ||
clearRecentWalletForNetwork, | ||
|
@@ -163,7 +164,7 @@ export class NightlyConnectAdapter implements Injected { | |
) | ||
if (!adapter._connectionOptions.disableModal) { | ||
adapter._modal = new NightlyConnectSelectorModal( | ||
adapter.walletsList, | ||
adapter.walletsList as IWalletListItem[], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need as also |
||
appInitData.url ?? 'https://nc2.nightly.app', | ||
networkToData(adapter.network), | ||
anchorRef, | ||
|
@@ -212,7 +213,7 @@ export class NightlyConnectAdapter implements Injected { | |
|
||
if (!adapter._connectionOptions.disableModal) { | ||
adapter._modal = new NightlyConnectSelectorModal( | ||
adapter.walletsList, | ||
adapter.walletsList as IWalletListItem[], | ||
appInitData.url ?? 'https://nc2.nightly.app', | ||
networkToData(adapter.network), | ||
anchorRef, | ||
|
@@ -309,47 +310,47 @@ export class NightlyConnectAdapter implements Injected { | |
throw new Error('Wallet not found') | ||
} | ||
|
||
if (wallet.deeplink === null) { | ||
if (wallet.mobile === null) { | ||
throw new Error('Deeplink not found') | ||
} | ||
|
||
// If we have a native deeplink, we should use it | ||
if (wallet.deeplink.native !== null) { | ||
if (wallet.mobile.native !== null) { | ||
this._app.connectDeeplink({ | ||
walletName: wallet.name, | ||
url: wallet.deeplink.native | ||
url: wallet.mobile.native | ||
}) | ||
|
||
this._chosenMobileWalletName = walletName | ||
|
||
triggerConnect( | ||
wallet.deeplink.native, | ||
wallet.mobile.native, | ||
this._app.sessionId, | ||
this._appInitData.url ?? 'https://nc2.nightly.app' | ||
) | ||
return | ||
} | ||
|
||
// If we have a universal deeplink, we should use it | ||
if (wallet.deeplink.universal !== null) { | ||
if (wallet.mobile.universal !== null) { | ||
this._app.connectDeeplink({ | ||
walletName: wallet.name, | ||
url: wallet.deeplink.universal | ||
url: wallet.mobile.universal | ||
}) | ||
|
||
this._chosenMobileWalletName = walletName | ||
|
||
triggerConnect( | ||
wallet.deeplink.universal, | ||
wallet.mobile.universal, | ||
this._app.sessionId, | ||
this._appInitData.url ?? 'https://nc2.nightly.app' | ||
) | ||
return | ||
} | ||
// Fallback to redirecting to app browser | ||
// aka browser inside the app | ||
if (!wallet.deeplink.redirectToAppBrowser) { | ||
const redirectToAppBrowser = wallet.deeplink.redirectToAppBrowser | ||
if (!wallet.mobile.redirectToAppBrowser) { | ||
const redirectToAppBrowser = wallet.mobile.redirectToAppBrowser | ||
if (redirectToAppBrowser !== null && redirectToAppBrowser.indexOf('{{url}}') > -1) { | ||
const url = redirectToAppBrowser.replace( | ||
'{{url}}', | ||
|
@@ -599,7 +600,7 @@ export class NightlyConnectAdapter implements Injected { | |
getRecentWalletForNetwork(this.network)?.walletName ?? undefined | ||
) | ||
if (this._modal) { | ||
this._modal.walletsList = this.walletsList | ||
this._modal.walletsList = this.walletsList as IWalletListItem[] | ||
} | ||
this._connected = false | ||
} finally { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import { type Injected, type InjectedExtension } from '@polkadot/extension-inject/types' | ||
import { type WalletIcon } from '@wallet-standard/core' | ||
import { appToIcon } from './tempIcons' | ||
import { IWalletListItem } from '@nightlylabs/wallet-selector-base' | ||
import { WalletMetadata } from '@nightlylabs/nightly-connect-polkadot' | ||
export interface PolkadotWalletInjected { | ||
// Default Polkadot standard | ||
|
@@ -32,7 +31,9 @@ export const getPolkadotWallets = (): PolkadotWalletInjected[] => { | |
} | ||
} | ||
|
||
export interface IPolkadotWalletListItem extends Omit<IWalletListItem, 'standardWallet'> { | ||
export interface IPolkadotWalletListItem extends WalletMetadata { | ||
recent?: boolean | ||
detected?: boolean | ||
injectedWallet?: PolkadotWalletInjected | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WalletMetadata should be one from bindings |
||
|
||
|
@@ -43,12 +44,7 @@ export const getPolkadotWalletsList = (presetList: WalletMetadata[], recentWalle | |
|
||
presetList.forEach((wallet) => { | ||
walletsData[wallet.slug.toLocaleLowerCase()] = { | ||
slug: wallet.slug, | ||
name: wallet.name, | ||
icon: wallet.image.default, | ||
deeplink: wallet.mobile, | ||
link: wallet.homepage, | ||
walletType: wallet.walletType, | ||
...wallet, | ||
recent: recentWalletName === wallet.name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is recent part of api ? |
||
} | ||
}) | ||
|
@@ -91,9 +87,14 @@ export const getPolkadotWalletsList = (presetList: WalletMetadata[], recentWalle | |
walletsData[wallet.name.toLocaleLowerCase()] = { | ||
slug: wallet.name, | ||
name: wallet.name, | ||
icon: wallet.icon as string, | ||
link: '', | ||
deeplink: null, | ||
image: { | ||
default: wallet.icon as string, | ||
sm: wallet.icon as string, | ||
md: wallet.icon as string, | ||
lg: wallet.icon as string | ||
}, | ||
desktop: null, | ||
mobile: null, | ||
recent: recentWalletName === wallet.name, | ||
detected: true, | ||
injectedWallet: wallet, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just export this