diff --git a/sdk/bindings/WalletMetadata.ts b/sdk/bindings/WalletMetadata.ts index 06106435..78889c7c 100644 --- a/sdk/bindings/WalletMetadata.ts +++ b/sdk/bindings/WalletMetadata.ts @@ -1,9 +1,23 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Deeplink } from "./Deeplink"; -import type { Images } from "./Images"; -import type { Network } from "./Network"; -import type { Platform } from "./Platform"; -import type { Version } from "./Version"; -import type { WalletType } from "./WalletType"; +import type { Deeplink } from './Deeplink' +import type { Images } from './Images' +import type { Network } from './Network' +import type { Platform } from './Platform' +import type { Version } from './Version' +import type { WalletType } from './WalletType' -export interface WalletMetadata { slug: string, name: string, description: string, homepage: string, chains: Array, version: Version, walletType: WalletType, mobile: Deeplink | null, desktop: Deeplink | null, image: Images, app: Record, injectPath: Record, lastUpdatedTimestamp: bigint, } \ No newline at end of file +export interface WalletMetadata { + slug: string + name: string + description?: string + homepage?: string + chains?: Array + version?: Version + walletType: WalletType + mobile: Deeplink | null + desktop: Deeplink | null + image: Images + app?: Record + injectPath?: Record + lastUpdatedTimestamp?: bigint +} diff --git a/sdk/packages/selector-base/src/types.ts b/sdk/packages/selector-base/src/types.ts index 55ecbbbb..ccba4694 100644 --- a/sdk/packages/selector-base/src/types.ts +++ b/sdk/packages/selector-base/src/types.ts @@ -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 } from '../../../bindings/WalletMetadata' +export { type WalletMetadata } from '../../../bindings/WalletMetadata' export interface Adapter { connect: () => Promise @@ -17,48 +19,6 @@ export interface MetadataWallet { walletType: WalletType } -interface Images { - default: string - sm: string - md: string - lg: string -} - -type Network = string - -type Platform = - | 'browser' - | 'ios' - | 'android' - | 'macos' - | 'windows' - | 'linux' - | 'chrome' - | 'firefox' - | 'opera' - | 'edge' - | 'brave' - | 'safari' - | 'other' - -type Version = string - -export interface WalletMetadata { - slug: string - name: string - description?: string - homepage?: string - chains?: Array - version?: Version - walletType: WalletType - mobile: Deeplink | null - desktop: Deeplink | null - image: Images - app?: Record - injectPath?: Record - lastUpdatedTimestamp?: bigint -} - export interface IWalletListItem extends WalletMetadata { recent?: boolean detected?: boolean diff --git a/sdk/packages/selector-polkadot/src/adapter.ts b/sdk/packages/selector-polkadot/src/adapter.ts index 468a527a..4fbb1ed9 100644 --- a/sdk/packages/selector-polkadot/src/adapter.ts +++ b/sdk/packages/selector-polkadot/src/adapter.ts @@ -113,7 +113,7 @@ export class NightlyConnectAdapter implements Injected { set walletsList(list: IPolkadotWalletListItem[]) { this._walletsList = list if (this._modal) { - this._modal.walletsList = list as IWalletListItem[] + this._modal.walletsList = list } } diff --git a/sdk/packages/selector-polkadot/src/detection.ts b/sdk/packages/selector-polkadot/src/detection.ts index 649a19a7..8395fd11 100644 --- a/sdk/packages/selector-polkadot/src/detection.ts +++ b/sdk/packages/selector-polkadot/src/detection.ts @@ -42,7 +42,10 @@ export const getPolkadotWalletsList = (presetList: WalletMetadata[], recentWalle const walletsData: Record = {} presetList.forEach((wallet) => { - walletsData[wallet.slug.toLocaleLowerCase()] = wallet + walletsData[wallet.slug.toLocaleLowerCase()] = { + ...wallet, + recent: recentWalletName === wallet.name + } }) for (const wallet of windowWallets) { // Check if wallet is already in the list @@ -94,7 +97,6 @@ export const getPolkadotWalletsList = (presetList: WalletMetadata[], recentWalle recent: recentWalletName === wallet.name, detected: true, injectedWallet: wallet, - homepage: '', walletType: 'hybrid' } } diff --git a/sdk/packages/selector-solana/src/adapter.ts b/sdk/packages/selector-solana/src/adapter.ts index e5f53fac..1b33ef3b 100644 --- a/sdk/packages/selector-solana/src/adapter.ts +++ b/sdk/packages/selector-solana/src/adapter.ts @@ -22,6 +22,7 @@ import { BaseMessageSignerWalletAdapter, WalletAdapterCompatibleStandardWallet, WalletAdapterEvents, + WalletError, WalletName, WalletNotConnectedError, WalletNotReadyError, @@ -36,14 +37,6 @@ import { PublicKey, Transaction, TransactionVersion, VersionedTransaction } from import { solanaWalletsFilter } from './detection' import { StandardEventsChangeProperties } from '@wallet-standard/core' -type ArgumentMap = { - [K in keyof T]: T[K] extends (...args: any[]) => void - ? Parameters - : T[K] extends any[] - ? T[K] - : any[] -} - type NightlyConnectAdapterEvents = WalletAdapterEvents & { change(properties: StandardEventsChangeProperties): void } @@ -154,16 +147,28 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter { on( event: T, - fn: (...args: ArgumentMap[T]) => void, + fn: NightlyConnectAdapterEvents[T] extends (...args: infer Args) => void + ? (...args: Args) => void + : never, context?: any ): this { - return this + if (event === 'change') { + // TODO implement on change listener + return this + } else { + return super.on(event, fn, context) + } } emit( event: T, - ...args: ArgumentMap[Extract] + ...args: [publicKey: PublicKey] | [] | [error: WalletError] | [readyState: WalletReadyState] ): boolean { + if (event === 'change') { + // TODO implement change event emitter + } else { + super.emit(event, ...args) + } return true } @@ -244,7 +249,7 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter { adapter._metadataWallets = metadataWallets adapter.walletsList = getWalletsList( - [], + metadataWallets, solanaWalletsFilter, getRecentWalletForNetwork(SOLANA_NETWORK)?.walletName ?? undefined )