Skip to content

Commit

Permalink
fix deeplinks on eager connect (#223)
Browse files Browse the repository at this point in the history
* fix deeplinks on eager connect

* fix comment
  • Loading branch information
LukassF authored Nov 25, 2024
1 parent 5fd0111 commit e9b8100
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 12 deletions.
8 changes: 4 additions & 4 deletions sdk/apps/modal-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"@nightlylabs/nightly-connect-polkadot": "0.0.16",
"@nightlylabs/nightly-connect-solana": "0.0.30",
"@nightlylabs/nightly-connect-sui": "0.1.0",
"@nightlylabs/wallet-selector-aptos": "^0.1.14",
"@nightlylabs/wallet-selector-aptos": "^0.1.15",
"@nightlylabs/wallet-selector-base": "^0.4.3",
"@nightlylabs/wallet-selector-polkadot": "0.2.8",
"@nightlylabs/wallet-selector-solana": "0.3.10",
"@nightlylabs/wallet-selector-sui": "0.4.1",
"@nightlylabs/wallet-selector-polkadot": "0.2.9",
"@nightlylabs/wallet-selector-solana": "0.3.11",
"@nightlylabs/wallet-selector-sui": "0.4.2",
"@polkadot/api": "^10.10.1",
"@polkadot/extension-inject": "^0.46.5",
"@solana/web3.js": "^1.77.2",
Expand Down
2 changes: 1 addition & 1 deletion sdk/packages/selector-aptos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nightlylabs/wallet-selector-aptos",
"version": "0.1.14",
"version": "0.1.15",
"description": "",
"type": "module",
"exports": {
Expand Down
20 changes: 20 additions & 0 deletions sdk/packages/selector-aptos/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,26 @@ export class NightlyConnectAptosAdapter extends EventEmitter<AptosAdapterEvents>
this._connected = true
this._connecting = false
this._connectionType = ConnectionType.Nightly
// we only run it to reassign deeplinks on eager connect mobile browser (not on qr connection)
if (isMobileBrowser()) {
const wallet = this.walletsList.find((w) => w.name === 'Nightly')
if (wallet?.mobile) {
// If we have a native deeplink, we should use it
if (wallet.mobile?.native !== null) {
this._app.connectDeeplink({
walletName: wallet.name,
url: wallet.mobile.native
})
}
// If we have a universal deeplink, we should use it
else if (wallet.mobile?.universal !== null) {
this._app.connectDeeplink({
walletName: wallet.name,
url: wallet.mobile.universal
})
}
}
}
this.emit('connect', this._accountInfo)
resolve(
Promise.resolve({
Expand Down
2 changes: 1 addition & 1 deletion sdk/packages/selector-polkadot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nightlylabs/wallet-selector-polkadot",
"version": "0.2.8",
"version": "0.2.9",
"description": "",
"type": "module",
"exports": {
Expand Down
20 changes: 20 additions & 0 deletions sdk/packages/selector-polkadot/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,26 @@ export class NightlyConnectAdapter
this.setSelectedWallet({ isRemote: true })
this._connected = true
this._connecting = false
// we only run it to reassign deeplinks on eager connect mobile browser (not on qr connection)
if (isMobileBrowser()) {
const wallet = this.walletsList.find((w) => w.name === 'Nightly')
if (wallet?.mobile) {
// If we have a native deeplink, we should use it
if (wallet.mobile?.native !== null) {
this._app.connectDeeplink({
walletName: wallet.name,
url: wallet.mobile.native
})
}
// If we have a universal deeplink, we should use it
else if (wallet.mobile?.universal !== null) {
this._app.connectDeeplink({
walletName: wallet.name,
url: wallet.mobile.universal
})
}
}
}
this.emit('connect', await this.accounts.get())
resolve()
return
Expand Down
2 changes: 1 addition & 1 deletion sdk/packages/selector-solana/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nightlylabs/wallet-selector-solana",
"version": "0.3.10",
"version": "0.3.11",
"description": "",
"type": "module",
"exports": {
Expand Down
20 changes: 20 additions & 0 deletions sdk/packages/selector-solana/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,26 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter {
this._connecting = false
this._connectionType = ConnectionType.Nightly
this.setSelectedWallet({ isRemote: true })
// we only run it to reassign deeplinks on eager connect mobile browser (not on qr connection)
if (isMobileBrowser()) {
const wallet = this.walletsList.find((w) => w.name === 'Nightly')
if (wallet?.mobile) {
// If we have a native deeplink, we should use it
if (wallet.mobile?.native !== null) {
this._app.connectDeeplink({
walletName: wallet.name,
url: wallet.mobile.native
})
}
// If we have a universal deeplink, we should use it
else if (wallet.mobile?.universal !== null) {
this._app.connectDeeplink({
walletName: wallet.name,
url: wallet.mobile.universal
})
}
}
}
this.emit('connect', this._publicKey)
resolve()
return
Expand Down
2 changes: 1 addition & 1 deletion sdk/packages/selector-sui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nightlylabs/wallet-selector-sui",
"version": "0.4.1",
"version": "0.4.2",
"description": "",
"type": "module",
"exports": {
Expand Down
20 changes: 20 additions & 0 deletions sdk/packages/selector-sui/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,26 @@ export class NightlyConnectSuiAdapter extends EventEmitter<SuiAdapterEvents> {
this.connecting = false
this._connectionType = ConnectionType.Nightly
this.setSelectedWallet({ isRemote: true })
// we only run it to reassign deeplinks on eager connect mobile browser (not on qr connection)
if (isMobileBrowser()) {
const wallet = this.walletsList.find((w) => w.name === 'Nightly')
if (wallet?.mobile) {
// If we have a native deeplink, we should use it
if (wallet.mobile?.native !== null) {
this._app.connectDeeplink({
walletName: wallet.name,
url: wallet.mobile.native
})
}
// If we have a universal deeplink, we should use it
else if (wallet.mobile?.universal !== null) {
this._app.connectDeeplink({
walletName: wallet.name,
url: wallet.mobile.universal
})
}
}
}
this.emit('connect', this._accounts)
resolve()
return
Expand Down
8 changes: 4 additions & 4 deletions sdk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e9b8100

Please sign in to comment.