Skip to content

Commit

Permalink
Merge pull request #54 from nightly-labs/remove-query-network-enum
Browse files Browse the repository at this point in the history
Selectors: remove QueryNetwork enum
  • Loading branch information
awojciak authored Aug 9, 2023
2 parents 65c8231 + 4dea82e commit a9e47c0
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const meta = {
.chainIcon=${args.chainIcon}
.chainName=${args.chainName}
.sessionId=${args.sessionId}
.network=${args.network}
.relay=${args.relay}
></nightly-modal>`
}
Expand All @@ -45,7 +44,6 @@ interface NightlyModalArgs {
chainIcon: string
chainName: string
sessionId: string
network: string
relay: string
}
type Story = StoryObj<NightlyModalArgs>
Expand Down Expand Up @@ -89,7 +87,6 @@ export const Default: Story = {
chainIcon: ChainIcon,
chainName: 'Solana',
sessionId: '6a82dc5a-c013-4c17-b6ff-45fe0f45bddb',
network: 'SOLANA',
relay: 'https://nc2.nightly.app'
}
}
17 changes: 12 additions & 5 deletions sdk/packages/modal/src/components/nightly-modal/nightly-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ export class NightlyModal extends LitElement {
@property({ type: String })
sessionId = ''

@property({ type: String })
network = ''

@property({ type: String })
relay = ''

Expand All @@ -41,7 +38,12 @@ export class NightlyModal extends LitElement {

onCopy = () => {
navigator.clipboard.writeText(
'nc:' + this.sessionId + '?network=' + this.network + '&relay=' + this.relay
'nc:' +
this.sessionId +
'?network=' +
this.chainName.replace(/\s/g, '') +
'&relay=' +
this.relay
)
this.copyMessage = 'Copied!'
clearTimeout(this.timeoutRef)
Expand All @@ -68,7 +70,12 @@ export class NightlyModal extends LitElement {
class="code"
src=${svgToBase64(
generateQrCodeXml(
'nc:' + this.sessionId + '?network=' + this.network + '&relay=' + this.relay,
'nc:' +
this.sessionId +
'?network=' +
this.chainName.replace(/\s/g, '') +
'&relay=' +
this.relay,
{
width: 400,
height: 400,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Binance from '../../static/svg/BinanceIcon.svg'
import Sollet from '../../static/svg/SolletIcon.svg'
import NightlyIcon from '../../static/svg/NightlyIcon.svg'
import ChainIcon from '../../static/svg/ChainIcon.svg'
import { QueryNetwork, WalletSelectorItem } from '../../utils/types'
import { WalletSelectorItem } from '../../utils/types'

const meta = {
title: 'nightly-selector',
Expand All @@ -36,7 +36,6 @@ interface NightlyModalArgs {
chainIcon: string
chainName: string
sessionId: string
network: QueryNetwork
connecting: boolean
relay: string
}
Expand All @@ -59,7 +58,6 @@ export const Default: Story = (args: NightlyModalArgs) => {
.chainIcon=${args.chainIcon}
.chainName=${args.chainName}
.sessionId=${args.sessionId}
.network=${args.network}
?connecting=${args.connecting}
.relay=${args.relay}
></nightly-selector>
Expand Down Expand Up @@ -114,7 +112,6 @@ Default.args = {
chainName: 'Solana',
sessionId:
'fsdhfdzfsdhgfzghggdfhbgchgbdfnvfbxhncvfjhzxdhgbhghfgfvzhfgjhgszdhgzxdfhgfzxdjfuhdfhgd',
network: QueryNetwork.SOLANA,
connecting: true,
relay: 'https://nc2.nightly.app',
open: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { customElement, property, state } from 'lit/decorators.js'
import { tailwindElement } from '../../shared/tailwind.element'
import style from './nightly-selector.css'
import '../pages/nightly-main-page'
import { QueryNetwork, WalletSelectorItem } from '../../utils/types'
import { WalletSelectorItem } from '../../utils/types'

@customElement('nightly-selector')
export class NightlySelector extends LitElement {
Expand All @@ -29,9 +29,6 @@ export class NightlySelector extends LitElement {
@property({ type: String })
sessionId = ''

@property({ type: String })
network: QueryNetwork = QueryNetwork.SOLANA

@property({ type: String })
relay = ''

Expand Down Expand Up @@ -78,7 +75,6 @@ export class NightlySelector extends LitElement {
.chainIcon=${this.chainIcon}
.chainName=${this.chainName}
.sessionId=${this.sessionId}
.network=${this.network}
?connecting=${this.connecting}
.relay=${this.relay}
?fireClosingAnimation=${this.fireClosingAnimation}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export class NightlyQrCode extends LitElement {
sessionId = ''

@property({ type: String })
network = ''
relay = ''

@property({ type: String })
relay = ''
chainName = ''

@property({ type: Function })
showAllWallets!: () => void
Expand All @@ -39,7 +39,12 @@ export class NightlyQrCode extends LitElement {
class="code"
src=${svgToBase64(
generateQrCodeXml(
'nc:' + this.sessionId + '?network=' + this.network + '&relay=' + this.relay,
'nc:' +
this.sessionId +
'?network=' +
this.chainName.replace(/\s/g, '') +
'&relay=' +
this.relay,
{
width: 432,
height: 432,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface NightlyWalletSelectorListArgs {
walletSelectorItems: WalletSelectorItem[]
onWalletClick: (name: string) => void
sessionId: string
network: string
chainName: string
relay: string
onClose: () => void
}
Expand All @@ -39,7 +39,7 @@ export const Default = (args: NightlyWalletSelectorListArgs) => {
.selectorItems=${args.walletSelectorItems}
.onWalletClick=${args.onWalletClick}
.sessionId=${args.sessionId}
.network=${args.network}
.chainName=${args.chainName}
.onClose=${args.onClose}
.relay=${args.relay}
></nightly-wallet-selector-small-page>
Expand Down Expand Up @@ -90,6 +90,6 @@ Default.args = {
},
sessionId:
'fsdhfdzfsdhgfzghggdfhbgchgbdfnvfbxhncvfjhzxdhgbhghfgfvzhfgjhgszdhgzxdfhgfzxdjfuhdfhgd',
network: 'SOLANA',
chainName: 'SOLANA',
relay: 'https://nc2.nightly.app'
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class NightlyWalletSelectorSmallPage extends LitElement {
sessionId = ''

@property({ type: String })
network = ''
chainName = ''

@property({ type: String })
relay = ''
Expand Down Expand Up @@ -70,7 +70,6 @@ export class NightlyWalletSelectorSmallPage extends LitElement {
return html`
<nightly-wallet-wrapper
class="selectorView"
.network=${this.network}
.sessionId=${this.sessionId}
.showAllWallets=${this.showAllWallets.bind(this)}
.onWalletClick=${this.onWalletClick.bind(this)}
Expand Down Expand Up @@ -127,7 +126,7 @@ export class NightlyWalletSelectorSmallPage extends LitElement {
return html`
<nightly-qr-code
class="selectorView"
.network=${this.network}
.chainName=${this.chainName}
.sessionId=${this.sessionId}
.relay=${this.relay}
.showAllWallets=${this.showAllWallets.bind(this)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const meta = {
.chainIcon=${args.chainIcon}
.chainName=${args.chainName}
.sessionId=${args.sessionId}
.network=${args.network}
?connecting=${args.connecting}
.relay=${args.relay}
></nightly-main-page>
Expand All @@ -50,7 +49,6 @@ interface NightlyModalArgs {
chainIcon: string
chainName: string
sessionId: string
network: string
connecting: boolean
relay: string
}
Expand Down Expand Up @@ -106,7 +104,6 @@ export const Default: Story = {
chainName: 'Solana',
sessionId:
'fsdhfdzfsdhgfzghggdfhbgchgbdfnvfbxhncvfjhzxdhgbhghfgfvzhfgjhgszdhgzxdfhgfzxdjfuhdfhgd',
network: 'SOLANA',
connecting: true,
relay: 'https://nc2.nightly.app'
}
Expand Down
6 changes: 1 addition & 5 deletions sdk/packages/modal/src/components/pages/nightly-main-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ export class NightlyMainPage extends LitElement {
@property({ type: String })
sessionId = ''

@property({ type: String })
network = ''

@property({ type: String })
relay = ''

Expand Down Expand Up @@ -166,10 +163,10 @@ export class NightlyMainPage extends LitElement {
return html`<div id="modalSelect">
<nightly-wallet-selector-small-page
class="modalMobile"
.network=${this.network}
.onWalletClick=${this.onSelectWallet}
.selectorItems=${this.selectorItems}
.sessionId=${this.sessionId}
.chainName=${this.chainName}
.relay=${this.relay}
${animate({
properties: ['opacity'],
Expand All @@ -194,7 +191,6 @@ export class NightlyMainPage extends LitElement {
class="modalDesktop"
.chainIcon=${this.chainIcon}
.chainName=${this.chainName}
.network=${this.network}
.onWalletClick=${this.onSelectWallet}
.selectorItems=${this.selectorItems}
.sessionId=${this.sessionId}
Expand Down
2 changes: 1 addition & 1 deletion sdk/packages/modal/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './components/nightly-selector/nightly-selector'
import './shared/tailwind.global.css'
export { type NightlySelector } from './components/nightly-selector/nightly-selector'
export { QueryNetwork, type WalletSelectorItem } from './utils/types'
export { type WalletSelectorItem } from './utils/types'

export const getNightlySelectorElement = () => {
const style = document.createElement('style')
Expand Down
1 change: 0 additions & 1 deletion sdk/packages/selector-base/src/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class NightlyConnectSelectorModal {
this._modal = getNightlySelectorElement()
this._modal.onClose = this.onCloseModal

this._modal.network = this._networkData.network
this._modal.relay = this._relay
this._modal.chainIcon = this._networkData.icon
this._modal.chainName = this._networkData.name
Expand Down
6 changes: 1 addition & 5 deletions sdk/packages/selector-base/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { type Wallet } from '@wallet-standard/core'
export interface Adapter {
connect: () => Promise<void>
}
export enum QueryNetwork {
SOLANA = 'SOLANA',
SUI = 'SUI'
}

export type AppInitData = Omit<AppBaseInitialize, 'network'>

export interface MetadataWallet {
Expand All @@ -25,7 +22,6 @@ export interface IWalletListItem extends MetadataWallet {
}

export interface NetworkData {
network: QueryNetwork
name: string
icon: string
}
Expand Down
3 changes: 0 additions & 3 deletions sdk/packages/selector-solana/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
persistRecentStandardWalletForNetwork,
persistStandardConnectForNetwork,
isStandardConnectedForNetwork,
QueryNetwork,
triggerConnect,
persistStandardDisconnectForNetwork,
sleep
Expand Down Expand Up @@ -123,7 +122,6 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter {
adapter.walletsList,
appInitData.url ?? 'https://nc2.nightly.app',
{
network: QueryNetwork.SOLANA,
name: SOLANA_NETWORK,
icon: 'https://assets.coingecko.com/coins/images/4128/small/solana.png'
},
Expand Down Expand Up @@ -177,7 +175,6 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter {
adapter.walletsList,
appInitData.url ?? 'https://nc2.nightly.app',
{
network: QueryNetwork.SOLANA,
name: SOLANA_NETWORK,
icon: 'https://assets.coingecko.com/coins/images/4128/small/solana.png'
},
Expand Down
3 changes: 0 additions & 3 deletions sdk/packages/selector-sui/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
IWalletListItem,
MetadataWallet,
NightlyConnectSelectorModal,
QueryNetwork,
clearRecentStandardWalletForNetwork,
clearSessionIdForNetwork,
getRecentStandardWalletForNetwork,
Expand Down Expand Up @@ -106,7 +105,6 @@ export class NightlyConnectSuiAdapter implements WalletAdapter {
adapter.walletsList,
appInitData.url ?? 'https://nc2.nightly.app',
{
network: QueryNetwork.SUI,
name: SUI_NETWORK,
icon: 'https://registry.connect.nightly.app/networks/sui.png'
},
Expand Down Expand Up @@ -154,7 +152,6 @@ export class NightlyConnectSuiAdapter implements WalletAdapter {
adapter.walletsList,
appInitData.url ?? 'https://nc2.nightly.app',
{
network: QueryNetwork.SUI,
name: SUI_NETWORK,
icon: 'https://registry.connect.nightly.app/networks/sui.png'
},
Expand Down

0 comments on commit a9e47c0

Please sign in to comment.