From 8cf9b2182b6ef3951dd08369283b4dff921b5416 Mon Sep 17 00:00:00 2001 From: LukassF Date: Tue, 20 Feb 2024 14:38:50 +0100 Subject: [PATCH 1/2] add: getters selector polkadot --- sdk/packages/selector-base/src/modal.ts | 8 ++++++++ sdk/packages/selector-polkadot/src/adapter.ts | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/sdk/packages/selector-base/src/modal.ts b/sdk/packages/selector-base/src/modal.ts index 636fce3a..71714197 100644 --- a/sdk/packages/selector-base/src/modal.ts +++ b/sdk/packages/selector-base/src/modal.ts @@ -35,6 +35,14 @@ export class NightlyConnectSelectorModal { return this._walletsList } + get relay() { + return this._relay + } + + get chainName() { + return this._modal?.chainName + } + set walletsList(list: IWalletListItem[]) { const filtered = list.filter((w) => isMobileBrowser() ? w.walletType !== 'extension' : w.walletType !== 'mobile' diff --git a/sdk/packages/selector-polkadot/src/adapter.ts b/sdk/packages/selector-polkadot/src/adapter.ts index 72fdf76b..0feb1b8e 100644 --- a/sdk/packages/selector-polkadot/src/adapter.ts +++ b/sdk/packages/selector-polkadot/src/adapter.ts @@ -116,6 +116,22 @@ export class NightlyConnectAdapter implements Injected { } } + get sessionId() { + return this._app?.sessionId + } + + get qrCode() { + if (this._modal && this._modal.chainName && this.sessionId) + return ( + 'nc:' + + this.sessionId + + '?network=' + + this._modal.chainName.replace(/\s/g, '') + + '&relay=' + + this._modal._relay + ) + } + public static initApp = async ( appInitData: AppSelectorInitialize ): Promise<[AppPolkadot, WalletMetadata[]]> => { From 52effa90bb90429716818ab4533b7f287c8a4924 Mon Sep 17 00:00:00 2001 From: LukassF Date: Tue, 20 Feb 2024 14:50:57 +0100 Subject: [PATCH 2/2] fix: export qrcode from modal --- .../components/nightly-selector/nightly-selector.ts | 11 +++++++++++ sdk/packages/selector-base/src/modal.ts | 8 ++------ sdk/packages/selector-polkadot/src/adapter.ts | 10 +--------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/sdk/packages/modal/src/components/nightly-selector/nightly-selector.ts b/sdk/packages/modal/src/components/nightly-selector/nightly-selector.ts index b69fdc42..89830bae 100644 --- a/sdk/packages/modal/src/components/nightly-selector/nightly-selector.ts +++ b/sdk/packages/modal/src/components/nightly-selector/nightly-selector.ts @@ -76,6 +76,17 @@ export class NightlySelector extends LitElement { @state() isMobile = false + get qrCode() { + return ( + 'nc:' + + this.sessionId + + '?network=' + + this.chainName.replace(/\s/g, '') + + '&relay=' + + this.relay + ) + } + // media queries mobileQuery = window.matchMedia('(max-width: 640px)') diff --git a/sdk/packages/selector-base/src/modal.ts b/sdk/packages/selector-base/src/modal.ts index 71714197..44daf443 100644 --- a/sdk/packages/selector-base/src/modal.ts +++ b/sdk/packages/selector-base/src/modal.ts @@ -35,12 +35,8 @@ export class NightlyConnectSelectorModal { return this._walletsList } - get relay() { - return this._relay - } - - get chainName() { - return this._modal?.chainName + get qrCode() { + return this._modal?.qrCode } set walletsList(list: IWalletListItem[]) { diff --git a/sdk/packages/selector-polkadot/src/adapter.ts b/sdk/packages/selector-polkadot/src/adapter.ts index 0feb1b8e..6f84fa96 100644 --- a/sdk/packages/selector-polkadot/src/adapter.ts +++ b/sdk/packages/selector-polkadot/src/adapter.ts @@ -121,15 +121,7 @@ export class NightlyConnectAdapter implements Injected { } get qrCode() { - if (this._modal && this._modal.chainName && this.sessionId) - return ( - 'nc:' + - this.sessionId + - '?network=' + - this._modal.chainName.replace(/\s/g, '') + - '&relay=' + - this._modal._relay - ) + if (this._modal) return this._modal.qrCode } public static initApp = async (