diff --git a/package.json b/package.json index d21edec..c585bfd 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "typecheck": "turbo run typecheck", "size": "pnpm build && size-limit", "prepare": "husky", + "check:circular-deps": "turbo run check:circular-deps", "changeset": "changeset", "version:packages": "changeset version", "publish-packages": "changeset publish --filter @solana/client --filter @solana/react-hooks --filter @solana/web3-compat" diff --git a/packages/client/package.json b/packages/client/package.json index f1fc73f..a80ff89 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -49,9 +49,10 @@ "compile:typedefs": "tsc -p ./tsconfig.declarations.json", "format": "biome check --write src", "lint": "biome check src", - "test:typecheck": "tsc --noEmit", + "test:typecheck": "tsc --noEmit -p tsconfig.test.json", "test": "vitest run --config ./vitest.config.ts", - "typecheck": "pnpm test:typecheck" + "typecheck": "tsc --noEmit", + "check:circular-deps": "madge --circular $(find ./src -name '*.ts' -o -name '*.tsx')" }, "author": "Solana Maintainers ", "repository": { diff --git a/packages/client/src/client/actions.test.ts b/packages/client/src/client/actions.test.ts index 5f2bc39..ec9aec4 100644 --- a/packages/client/src/client/actions.test.ts +++ b/packages/client/src/client/actions.test.ts @@ -2,7 +2,9 @@ import type { Address, Lamports, SendableTransaction, Signature, Transaction } f import type { TransactionWithLastValidBlockHeight } from '@solana/transaction-confirmation'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { ClientActions, SolanaClientRuntime, WalletConnector, WalletRegistry } from '../types'; +import type { SolanaClientRuntime } from '../rpc/types'; +import type { ClientActions } from '../types'; +import type { WalletConnector, WalletRegistry } from '../wallet/types'; import { createActions } from './actions'; import { createDefaultClientStore } from './createClientStore'; diff --git a/packages/client/src/client/actions.ts b/packages/client/src/client/actions.ts index 5065b34..d7c5098 100644 --- a/packages/client/src/client/actions.ts +++ b/packages/client/src/client/actions.ts @@ -19,16 +19,10 @@ import { fetchNonce } from '@solana-program/system'; import { createLogger, formatError } from '../logging/logger'; import { createSolanaRpcClient } from '../rpc/createSolanaRpcClient'; -import type { - AddressLookupTableData, - ClientActions, - ClientState, - ClientStore, - NonceAccountData, - SolanaClientRuntime, - WalletRegistry, -} from '../types'; +import type { SolanaClientRuntime } from '../rpc/types'; +import type { AddressLookupTableData, ClientActions, ClientState, ClientStore, NonceAccountData } from '../types'; import { now } from '../utils'; +import type { WalletRegistry, WalletSession } from '../wallet/types'; type MutableRuntime = SolanaClientRuntime; @@ -162,12 +156,12 @@ export function createActions({ connectors, logger: inputLogger, runtime, store * Initiates a wallet connection using a registered connector. * * @param connectorId - Identifier for the desired wallet connector. - * @returns Promise that resolves once the connection attempt has completed. + * @returns Promise that resolves to the wallet session once the connection attempt has completed. */ async function connectWallet( connectorId: string, options: Readonly<{ autoConnect?: boolean }> = {}, - ): Promise { + ): Promise { walletEventsCleanup?.(); walletEventsCleanup = undefined; const connector = connectors.get(connectorId); @@ -206,6 +200,7 @@ export function createActions({ connectors, logger: inputLogger, runtime, store level: 'info', message: 'wallet connected', }); + return session; } catch (error) { store.setState((state) => ({ ...state, diff --git a/packages/client/src/client/createClient.ts b/packages/client/src/client/createClient.ts index 44b9ff5..cd73459 100644 --- a/packages/client/src/client/createClient.ts +++ b/packages/client/src/client/createClient.ts @@ -1,7 +1,8 @@ import { createLogger, formatError } from '../logging/logger'; import { createSolanaRpcClient } from '../rpc/createSolanaRpcClient'; +import type { SolanaClientRuntime } from '../rpc/types'; import { applySerializableState } from '../serialization/state'; -import type { ClientStore, SolanaClient, SolanaClientConfig, SolanaClientRuntime } from '../types'; +import type { ClientStore, SolanaClient, SolanaClientConfig } from '../types'; import { now } from '../utils'; import { resolveCluster } from '../utils/cluster'; import { createWalletRegistry } from '../wallet/registry'; diff --git a/packages/client/src/client/createClientHelpers.ts b/packages/client/src/client/createClientHelpers.ts index 1a212a3..40f6969 100644 --- a/packages/client/src/client/createClientHelpers.ts +++ b/packages/client/src/client/createClientHelpers.ts @@ -4,12 +4,13 @@ import { createSolTransferHelper, type SolTransferHelper } from '../features/sol import { createSplTokenHelper, type SplTokenHelper, type SplTokenHelperConfig } from '../features/spl'; import { createStakeHelper, type StakeHelper } from '../features/stake'; import { createTransactionHelper, type TransactionHelper } from '../features/transactions'; +import type { SolanaClientRuntime } from '../rpc/types'; import { type PrepareTransactionMessage, type PrepareTransactionOptions, prepareTransaction as prepareTransactionUtility, } from '../transactions/prepareTransaction'; -import type { ClientHelpers, ClientStore, SolanaClientRuntime } from '../types'; +import type { ClientHelpers, ClientStore } from '../types'; type SplTokenCacheEntry = Readonly<{ baseCommitment?: Commitment; diff --git a/packages/client/src/client/defaultClient.ts b/packages/client/src/client/defaultClient.ts index 93f1d9c..c03bd7e 100644 --- a/packages/client/src/client/defaultClient.ts +++ b/packages/client/src/client/defaultClient.ts @@ -1,8 +1,9 @@ import type { ClusterUrl, Commitment } from '@solana/kit'; -import type { SolanaClient, SolanaClientConfig, WalletConnector } from '../types'; +import type { SolanaClient, SolanaClientConfig } from '../types'; import { type ClusterMoniker, resolveCluster } from '../utils/cluster'; import { autoDiscover, backpack, phantom, solflare } from '../wallet/connectors'; +import type { WalletConnector } from '../wallet/types'; import { createClient } from './createClient'; type BasePassthrough = Omit; diff --git a/packages/client/src/client/watchers.test.ts b/packages/client/src/client/watchers.test.ts index de09fcd..a035b68 100644 --- a/packages/client/src/client/watchers.test.ts +++ b/packages/client/src/client/watchers.test.ts @@ -1,7 +1,8 @@ import type { Address, Signature } from '@solana/kit'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { ClientStore, SolanaClientRuntime } from '../types'; +import type { SolanaClientRuntime } from '../rpc/types'; +import type { ClientStore } from '../types'; import { createDefaultClientStore } from './createClientStore'; import { createWatchers } from './watchers'; diff --git a/packages/client/src/client/watchers.ts b/packages/client/src/client/watchers.ts index 44dc94a..dea554c 100644 --- a/packages/client/src/client/watchers.ts +++ b/packages/client/src/client/watchers.ts @@ -1,6 +1,7 @@ import type { Lamports, SolanaRpcSubscriptionsApi } from '@solana/kit'; import { createLogger, formatError } from '../logging/logger'; +import type { SolanaClientRuntime } from '../rpc/types'; import type { AccountCacheEntry, AccountWatcherConfig, @@ -8,7 +9,6 @@ import type { ClientStore, ClientWatchers, SignatureWatcherConfig, - SolanaClientRuntime, SubscriptionStatus, } from '../types'; import { now } from '../utils'; diff --git a/packages/client/src/features/sol.test.ts b/packages/client/src/features/sol.test.ts index d1f1cdf..63455e5 100644 --- a/packages/client/src/features/sol.test.ts +++ b/packages/client/src/features/sol.test.ts @@ -1,6 +1,6 @@ import type { TransactionSigner } from '@solana/kit'; import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; -import type { WalletSession } from '../types'; +import type { WalletSession } from '../wallet/types'; type MutableMessage = { instructions: unknown[]; diff --git a/packages/client/src/features/sol.ts b/packages/client/src/features/sol.ts index 92ac64a..3b29858 100644 --- a/packages/client/src/features/sol.ts +++ b/packages/client/src/features/sol.ts @@ -24,8 +24,9 @@ import { import { getTransferSolInstruction } from '@solana-program/system'; import { lamportsMath } from '../numeric/lamports'; +import type { SolanaClientRuntime } from '../rpc/types'; import { createWalletTransactionSigner, isWalletSession, resolveSignerMode } from '../signers/walletTransactionSigner'; -import type { SolanaClientRuntime, WalletSession } from '../types'; +import type { WalletSession } from '../wallet/types'; type BlockhashLifetime = Readonly<{ blockhash: Blockhash; diff --git a/packages/client/src/features/spl.ts b/packages/client/src/features/spl.ts index 62e36fb..3e78212 100644 --- a/packages/client/src/features/spl.ts +++ b/packages/client/src/features/spl.ts @@ -31,8 +31,9 @@ import { } from '@solana-program/token'; import { createTokenAmount, type TokenAmountMath } from '../numeric/amounts'; +import type { SolanaClientRuntime } from '../rpc/types'; import { createWalletTransactionSigner, isWalletSession, resolveSignerMode } from '../signers/walletTransactionSigner'; -import type { SolanaClientRuntime, WalletSession } from '../types'; +import type { WalletSession } from '../wallet/types'; import type { SolTransferSendOptions } from './sol'; type BlockhashLifetime = Readonly<{ diff --git a/packages/client/src/features/stake.ts b/packages/client/src/features/stake.ts index 39aedab..d66ce7d 100644 --- a/packages/client/src/features/stake.ts +++ b/packages/client/src/features/stake.ts @@ -32,8 +32,9 @@ import { import { getCreateAccountInstruction } from '@solana-program/system'; import { lamportsMath } from '../numeric/lamports'; +import type { SolanaClientRuntime } from '../rpc/types'; import { createWalletTransactionSigner, isWalletSession, resolveSignerMode } from '../signers/walletTransactionSigner'; -import type { SolanaClientRuntime, WalletSession } from '../types'; +import type { WalletSession } from '../wallet/types'; type BlockhashLifetime = Readonly<{ blockhash: Blockhash; diff --git a/packages/client/src/features/transactions.ts b/packages/client/src/features/transactions.ts index 31a7fe7..725feb1 100644 --- a/packages/client/src/features/transactions.ts +++ b/packages/client/src/features/transactions.ts @@ -37,14 +37,14 @@ import { getSetComputeUnitLimitInstruction, getSetComputeUnitPriceInstruction, } from '@solana-program/compute-budget'; - +import type { SolanaClientRuntime } from '../rpc/types'; import { createWalletTransactionSigner, isWalletSession, resolveSignerMode } from '../signers/walletTransactionSigner'; import { type PrepareTransactionMessage, type PrepareTransactionOptions, prepareTransaction as prepareTransactionUtility, } from '../transactions/prepareTransaction'; -import type { SolanaClientRuntime, WalletSession } from '../types'; +import type { WalletSession } from '../wallet/types'; type BlockhashLifetime = Readonly<{ blockhash: Blockhash; diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index 7b88a8f..ced7eed 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -101,6 +101,7 @@ export { type SimulateTransactionOptions, type SolanaRpcClient, } from './rpc/createSolanaRpcClient'; +export type { SolanaClientRuntime } from './rpc/types'; export { bigintFromJson, bigintToJson, lamportsFromJson, lamportsToJson } from './serialization/json'; export { applySerializableState, @@ -178,11 +179,6 @@ export type { SetClusterReturnType, SolanaClient, SolanaClientConfig, - WalletConnector, - WalletConnectorMetadata, - WalletRegistry, - WalletSession, - WalletStatus, } from './types'; export { type AddressLike, toAddress, toAddressString } from './utils/addressLike'; export { type ClusterMoniker, resolveCluster } from './utils/cluster'; @@ -194,3 +190,10 @@ export { getWalletStandardConnectors, watchWalletStandardConnectors, } from './wallet/standard'; +export type { + WalletConnector, + WalletConnectorMetadata, + WalletRegistry, + WalletSession, + WalletStatus, +} from './wallet/types'; diff --git a/packages/client/src/rpc/types.ts b/packages/client/src/rpc/types.ts new file mode 100644 index 0000000..f8d8478 --- /dev/null +++ b/packages/client/src/rpc/types.ts @@ -0,0 +1,7 @@ +type SolanaRpcInstance = ReturnType; +type SolanaSubscriptionsInstance = ReturnType; + +export type SolanaClientRuntime = { + rpc: SolanaRpcInstance; + rpcSubscriptions: SolanaSubscriptionsInstance; +}; diff --git a/packages/client/src/signers/walletTransactionSigner.test.ts b/packages/client/src/signers/walletTransactionSigner.test.ts index 9d46260..6b098a9 100644 --- a/packages/client/src/signers/walletTransactionSigner.test.ts +++ b/packages/client/src/signers/walletTransactionSigner.test.ts @@ -2,7 +2,7 @@ import { getBase58Decoder } from '@solana/codecs-strings'; import type { TransactionSigner } from '@solana/kit'; import { describe, expect, it, vi } from 'vitest'; -import type { WalletSession } from '../types'; +import type { WalletSession } from '../wallet/types'; import { createWalletTransactionSigner, isWalletSession, resolveSignerMode } from './walletTransactionSigner'; type SessionTransaction = Parameters>[0]; diff --git a/packages/client/src/signers/walletTransactionSigner.ts b/packages/client/src/signers/walletTransactionSigner.ts index 037c52a..d9ab56a 100644 --- a/packages/client/src/signers/walletTransactionSigner.ts +++ b/packages/client/src/signers/walletTransactionSigner.ts @@ -15,8 +15,7 @@ import { type TransactionWithinSizeLimit, type TransactionWithLifetime, } from '@solana/kit'; - -import type { WalletSession } from '../types'; +import type { WalletSession } from '../wallet/types'; type WalletTransactionSignerMode = 'partial' | 'send'; diff --git a/packages/client/src/types.ts b/packages/client/src/types.ts index 9a6d75b..3bbd452 100644 --- a/packages/client/src/types.ts +++ b/packages/client/src/types.ts @@ -15,80 +15,15 @@ import type { SplTokenHelper, SplTokenHelperConfig } from './features/spl'; import type { StakeHelper } from './features/stake'; import type { TransactionHelper } from './features/transactions'; import type { SolanaRpcClient } from './rpc/createSolanaRpcClient'; +import type { SolanaClientRuntime } from './rpc/types'; import type { PrepareTransactionMessage, PrepareTransactionOptions } from './transactions/prepareTransaction'; import type { ClusterMoniker } from './utils/cluster'; - -type SolanaRpcInstance = ReturnType; -type SolanaSubscriptionsInstance = ReturnType; +import type { WalletConnector, WalletRegistry, WalletSession, WalletStatus } from './wallet/types'; export type LogLevel = 'debug' | 'error' | 'info' | 'warn'; export type ClientLogger = (event: { data?: Record; level: LogLevel; message: string }) => void; -export type WalletConnectorMetadata = Readonly<{ - canAutoConnect?: boolean; - icon?: string; - id: string; - kind?: string; - name: string; - ready?: boolean; -}>; - -export type WalletAccount = Readonly<{ - address: Address; - label?: string; - publicKey: Uint8Array; -}>; - -export type WalletSession = Readonly<{ - account: WalletAccount; - connector: WalletConnectorMetadata; - disconnect(): Promise; - onAccountsChanged?: (listener: (accounts: WalletAccount[]) => void) => () => void; - sendTransaction?( - transaction: SendableTransaction & Transaction, - config?: Readonly<{ commitment?: Commitment }>, - ): Promise; - signMessage?(message: Uint8Array): Promise; - signTransaction?(transaction: SendableTransaction & Transaction): Promise; -}>; - -export type WalletConnector = WalletConnectorMetadata & { - connect(opts?: Readonly<{ autoConnect?: boolean; allowInteractiveFallback?: boolean }>): Promise; - disconnect(): Promise; - isSupported(): boolean; -}; - -type WalletStatusConnected = Readonly<{ - autoConnect?: boolean; - connectorId: string; - session: WalletSession; - status: 'connected'; -}>; - -type WalletStatusConnecting = Readonly<{ - autoConnect?: boolean; - connectorId: string; - status: 'connecting'; -}>; - -type WalletStatusDisconnected = Readonly<{ - status: 'disconnected'; -}>; - -type WalletStatusError = Readonly<{ - autoConnect?: boolean; - connectorId?: string; - error: unknown; - status: 'error'; -}>; - -export type WalletStatus = - | WalletStatusConnected - | WalletStatusConnecting - | WalletStatusDisconnected - | WalletStatusError; - type ClusterStatusConnecting = Readonly<{ status: 'connecting' }>; type ClusterStatusError = Readonly<{ @@ -202,11 +137,6 @@ export type SerializableSolanaState = Readonly<{ websocketEndpoint?: ClusterUrl; }>; -export type SolanaClientRuntime = { - rpc: SolanaRpcInstance; - rpcSubscriptions: SolanaSubscriptionsInstance; -}; - export type BalanceWatcherConfig = Readonly<{ address: Address; commitment?: Commitment; @@ -232,7 +162,7 @@ export type ConnectWalletParameters = Readonly<{ options?: Readonly<{ autoConnect?: boolean; allowInteractiveFallback?: boolean }>; }>; -export type ConnectWalletReturnType = Promise; +export type ConnectWalletReturnType = Promise; export type DisconnectWalletParameters = undefined; @@ -350,11 +280,6 @@ export type ClientHelpers = Readonly<{ ): Promise; }>; -export type WalletRegistry = Readonly<{ - all: readonly WalletConnector[]; - get(id: string): WalletConnector | undefined; -}>; - export type SolanaClient = Readonly<{ actions: ClientActions; config: SolanaClientConfig; diff --git a/packages/client/src/wallet/connectors.ts b/packages/client/src/wallet/connectors.ts index ef34cba..f47f657 100644 --- a/packages/client/src/wallet/connectors.ts +++ b/packages/client/src/wallet/connectors.ts @@ -1,8 +1,8 @@ import { getWallets } from '@wallet-standard/app'; import type { Wallet } from '@wallet-standard/base'; import { StandardConnect } from '@wallet-standard/features'; -import type { WalletConnector } from '../types'; import { createWalletStandardConnector } from './standard'; +import type { WalletConnector } from './types'; type DiscoveryOptions = Readonly<{ overrides?: (wallet: Wallet) => Parameters[1]; diff --git a/packages/client/src/wallet/registry.test.ts b/packages/client/src/wallet/registry.test.ts index d22f76c..77a5add 100644 --- a/packages/client/src/wallet/registry.test.ts +++ b/packages/client/src/wallet/registry.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it } from 'vitest'; - -import type { WalletConnector } from '../types'; import { createWalletRegistry } from './registry'; +import type { WalletConnector } from './types'; describe('wallet registry', () => { const connector = (id: string): WalletConnector => ({ diff --git a/packages/client/src/wallet/registry.ts b/packages/client/src/wallet/registry.ts index 5be15c9..7de5b0c 100644 --- a/packages/client/src/wallet/registry.ts +++ b/packages/client/src/wallet/registry.ts @@ -1,4 +1,4 @@ -import type { WalletConnector, WalletRegistry } from '../types'; +import type { WalletConnector, WalletRegistry } from './types'; /** * Creates an in-memory wallet registry from the provided connectors. diff --git a/packages/client/src/wallet/standard.ts b/packages/client/src/wallet/standard.ts index fb12b14..564559d 100644 --- a/packages/client/src/wallet/standard.ts +++ b/packages/client/src/wallet/standard.ts @@ -21,7 +21,7 @@ import type { } from '@wallet-standard/features'; import { StandardConnect, StandardDisconnect, StandardEvents } from '@wallet-standard/features'; -import type { WalletAccount, WalletConnector, WalletConnectorMetadata, WalletSession } from '../types'; +import type { WalletAccount, WalletConnector, WalletConnectorMetadata, WalletSession } from './types'; export type WalletStandardConnectorMetadata = Readonly<{ canAutoConnect?: boolean; diff --git a/packages/client/src/wallet/types.ts b/packages/client/src/wallet/types.ts new file mode 100644 index 0000000..5b2f637 --- /dev/null +++ b/packages/client/src/wallet/types.ts @@ -0,0 +1,70 @@ +import type { Address, Commitment, SendableTransaction, Signature, Transaction } from '@solana/kit'; + +export type WalletConnectorMetadata = Readonly<{ + canAutoConnect?: boolean; + icon?: string; + id: string; + kind?: string; + name: string; + ready?: boolean; +}>; + +export type WalletAccount = Readonly<{ + address: Address; + label?: string; + publicKey: Uint8Array; +}>; + +export type WalletSession = Readonly<{ + account: WalletAccount; + connector: WalletConnectorMetadata; + disconnect(): Promise; + onAccountsChanged?: (listener: (accounts: WalletAccount[]) => void) => () => void; + sendTransaction?( + transaction: SendableTransaction & Transaction, + config?: Readonly<{ commitment?: Commitment }>, + ): Promise; + signMessage?(message: Uint8Array): Promise; + signTransaction?(transaction: SendableTransaction & Transaction): Promise; +}>; + +export type WalletConnector = WalletConnectorMetadata & { + connect(opts?: Readonly<{ autoConnect?: boolean; allowInteractiveFallback?: boolean }>): Promise; + disconnect(): Promise; + isSupported(): boolean; +}; + +type WalletStatusConnected = Readonly<{ + autoConnect?: boolean; + connectorId: string; + session: WalletSession; + status: 'connected'; +}>; + +type WalletStatusConnecting = Readonly<{ + autoConnect?: boolean; + connectorId: string; + status: 'connecting'; +}>; + +type WalletStatusDisconnected = Readonly<{ + status: 'disconnected'; +}>; + +type WalletStatusError = Readonly<{ + autoConnect?: boolean; + connectorId?: string; + error: unknown; + status: 'error'; +}>; + +export type WalletStatus = + | WalletStatusConnected + | WalletStatusConnecting + | WalletStatusDisconnected + | WalletStatusError; + +export type WalletRegistry = Readonly<{ + all: readonly WalletConnector[]; + get(id: string): WalletConnector | undefined; +}>; diff --git a/packages/client/tsconfig.test.json b/packages/client/tsconfig.test.json new file mode 100644 index 0000000..227211b --- /dev/null +++ b/packages/client/tsconfig.test.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "ESNext" + }, + "include": ["src/**/*.test.ts", "src/**/*.test.tsx"], + "exclude": [] +} diff --git a/packages/react-hooks/package.json b/packages/react-hooks/package.json index 1903926..cc83a79 100644 --- a/packages/react-hooks/package.json +++ b/packages/react-hooks/package.json @@ -34,7 +34,8 @@ "lint": "biome check src", "test:typecheck": "tsc --noEmit", "test": "vitest run --config ../../vitest.config.ts", - "typecheck": "pnpm test:typecheck" + "typecheck": "pnpm test:typecheck", + "check:circular-deps": "madge --circular $(find ./src -name '*.ts' -o -name '*.tsx')" }, "author": "Solana Maintainers ", "repository": { diff --git a/packages/react-hooks/src/context.tsx b/packages/react-hooks/src/context.tsx index c7103ee..3f777d0 100644 --- a/packages/react-hooks/src/context.tsx +++ b/packages/react-hooks/src/context.tsx @@ -8,7 +8,7 @@ import { import type { ReactNode } from 'react'; import { createContext, useContext, useEffect, useMemo } from 'react'; -const SolanaClientContext = createContext(null); +export const SolanaClientContext = createContext(null); type ProviderProps = Readonly<{ children: ReactNode; diff --git a/packages/react-hooks/src/hooks.ts b/packages/react-hooks/src/hooks.ts index 4567c16..3020400 100644 --- a/packages/react-hooks/src/hooks.ts +++ b/packages/react-hooks/src/hooks.ts @@ -237,7 +237,7 @@ export function useWalletActions() { export function useConnectWallet(): ( connectorId: string, options?: Readonly<{ autoConnect?: boolean; allowInteractiveFallback?: boolean }>, -) => Promise { +) => Promise { const client = useSolanaClient(); return useCallback( (connectorId: string, options?: Readonly<{ autoConnect?: boolean; allowInteractiveFallback?: boolean }>) => diff --git a/packages/react-hooks/src/index.ts b/packages/react-hooks/src/index.ts index c3e0e35..95ea9a4 100644 --- a/packages/react-hooks/src/index.ts +++ b/packages/react-hooks/src/index.ts @@ -6,7 +6,7 @@ export type { UseSolanaClientParameters, UseSolanaClientReturnType, } from './context'; -export { SolanaClientProvider, useSolanaClient } from './context'; +export { SolanaClientContext, SolanaClientProvider, useSolanaClient } from './context'; export type { SignatureWaitStatus, UseAccountParameters, diff --git a/packages/react-hooks/src/ui.tsx b/packages/react-hooks/src/ui.tsx index 3f8dc87..f2e0804 100644 --- a/packages/react-hooks/src/ui.tsx +++ b/packages/react-hooks/src/ui.tsx @@ -9,7 +9,7 @@ type WalletConnectionState = Readonly<{ connect( connectorId: string, options?: Readonly<{ autoConnect?: boolean; allowInteractiveFallback?: boolean }>, - ): Promise; + ): Promise; connected: boolean; connecting: boolean; connectors: readonly WalletConnector[]; @@ -154,11 +154,12 @@ export function useWalletModalState(options: WalletModalStateOptions = {}): Wall const connect = useCallback( async (connectorId: string, connectOptions?: Readonly<{ autoConnect?: boolean }>) => { - await connection.connect(connectorId, connectOptions); + const session = await connection.connect(connectorId, connectOptions); setSelectedConnector(connectorId); if (closeOnConnect) { setIsOpen(false); } + return session; }, [closeOnConnect, connection], ); diff --git a/turbo.json b/turbo.json index b81c668..7c976fb 100644 --- a/turbo.json +++ b/turbo.json @@ -22,6 +22,9 @@ "typecheck": { "dependsOn": ["^build"], "outputs": [] + }, + "check:circular-deps": { + "outputs": [] } } }