Skip to content
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

fix: refreshing when connected to multiple namespaces only reconnects active namespace #3440

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion packages/appkit-new/src/adapters/ChainAdapterBlueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import {
} from '@reown/appkit-common'
import type { ChainAdapterConnector } from './ChainAdapterConnector.js'
import {
AccountController,
OptionsController,
ThemeController,
type AccountType,
type AccountControllerState,
type Connector as AppKitConnector,
type AuthConnector,
type Metadata,
Expand All @@ -18,7 +21,7 @@ import type { W3mFrameProvider } from '@reown/appkit-wallet'
import { ConstantsUtil, PresetsUtil } from '@reown/appkit-utils'
import type { AppKitOptions } from '../utils/index.js'
import type { AppKit } from '../client.js'
import { snapshot } from 'valtio'
import { snapshot } from 'valtio/vanilla'

type EventName = 'disconnect' | 'accountChanged' | 'switchNetwork'
type EventData = {
Expand Down Expand Up @@ -152,6 +155,10 @@ export abstract class AdapterBlueprint<
})
}

protected setStatus(status: AccountControllerState['status'], chainNamespace?: ChainNamespace) {
AccountController.setStatus(status, chainNamespace)
}

/**
* Adds an event listener for a specific event.
* @template T
Expand Down Expand Up @@ -211,6 +218,15 @@ export abstract class AdapterBlueprint<
params: AdapterBlueprint.ConnectParams
): Promise<AdapterBlueprint.ConnectResult>

/**
* Gets the accounts for the connected wallet.
* @returns {Promise<AccountType[]>} An array of account objects with their associated type and namespace
*/

public abstract getAccounts(
params: AdapterBlueprint.GetAccountsParams
): Promise<AdapterBlueprint.GetAccountsResult>

/**
* Switches the network.
* @param {AdapterBlueprint.SwitchNetworkParams} params - Network switching parameters
Expand Down Expand Up @@ -507,4 +523,10 @@ export namespace AdapterBlueprint {
chainId: number | string
address: string
}

export type GetAccountsResult = { accounts: AccountType[] }
export type GetAccountsParams = {
id: AppKitConnector['id']
namespace?: ChainNamespace
}
}
Loading
Loading