Skip to content
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
14 changes: 14 additions & 0 deletions .changeset/purple-readers-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@solana/react': patch
'@solana/kit': minor
---

Migrate `@solana/react` to depend on `@solana/kit` as a peer dependency (replacing its individual workspace sub-package deps) and re-export `@solana/subscribable` from `@solana/kit` so React consumers have a single import root. `@solana/promises` remains as a direct dep — it's a small utility that isn't part of Kit's public surface.

For `@solana/react` users:
- `@solana/kit` must now be installed alongside `@solana/react`.
- Apps that already use both get a single deduplicated `@solana/kit` instance — important for anything relying on shared types or `instanceof SolanaError` checks.
- Kit can be bumped independently of React within the peer range.

For `@solana/kit` users:
- `ReactiveStreamSource`, `ReactiveStreamStore`, `ReactiveActionSource`, `ReactiveActionStore`, `ReactiveState`, `createReactiveActionStore`, `createReactiveStoreFromDataPublisherFactory`, `DataPublisher` and the rest of `@solana/subscribable`'s surface are now reachable directly through `@solana/kit`.
1 change: 1 addition & 0 deletions packages/kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export * from '@solana/rpc-parsed-types';
export * from '@solana/rpc-subscriptions';
export * from '@solana/rpc-types';
export * from '@solana/signers';
export * from '@solana/subscribable';
export * from '@solana/transaction-messages';
export * from '@solana/transactions';
export * from './create-async-generator-with-initial-value-and-slot-tracking';
Expand Down
12 changes: 2 additions & 10 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,7 @@
"maintained node versions"
],
"dependencies": {
"@solana/addresses": "workspace:*",
"@solana/errors": "workspace:*",
"@solana/keys": "workspace:*",
"@solana/plugin-core": "workspace:*",
"@solana/promises": "workspace:*",
"@solana/signers": "workspace:*",
"@solana/subscribable": "workspace:*",
"@solana/transaction-messages": "workspace:*",
"@solana/transactions": "workspace:*",
"@solana/wallet-standard-features": "^1.3.0",
"@wallet-standard/base": "^1.1.0",
"@wallet-standard/errors": "^0.1.1",
Expand All @@ -91,9 +83,8 @@
"@wallet-standard/ui-registry": "^1.0.1"
},
"devDependencies": {
"@solana/codecs-core": "workspace:*",
"@solana/eslint-config": "workspace:*",
"@solana/rpc-types": "workspace:*",
"@solana/kit": "workspace:*",
"@testing-library/react": "^16.3.2",
"@types/react": "^19.2.15",
"@types/react-dom": "^19.2.3",
Expand All @@ -104,6 +95,7 @@
"react-test-renderer": "^19.2.6"
},
"peerDependencies": {
"@solana/kit": "workspace:*",
"react": ">=18"
},
"peerDependenciesMeta": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ClientProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Client } from '@solana/plugin-core';
import type { Client } from '@solana/kit';
import React from 'react';

import { usePromise } from './usePromise';
Expand Down
7 changes: 3 additions & 4 deletions packages/react/src/__tests__/ClientProvider-test.browser.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { isSolanaError, SOLANA_ERROR__REACT__MISSING_PROVIDER } from '@solana/errors';
import { Client, createClient } from '@solana/plugin-core';
import { Client, createClient, isSolanaError, SOLANA_ERROR__REACT__MISSING_PROVIDER } from '@solana/kit';
import { act } from '@testing-library/react';
import React, { Suspense } from 'react';
import { ErrorBoundary } from 'react-error-boundary';

import { render, renderHook } from '../__test-utils__/render';
import { ClientProvider } from '../ClientProvider';
import { useClient } from '../useClient';
import { render, renderHook } from '../__test-utils__/render';

describe('ClientProvider + useClient', () => {
it('publishes the client to descendants and returns the same reference across renders', () => {
Expand Down Expand Up @@ -110,7 +109,7 @@ describe('ClientProvider + useClient', () => {
const clientPromise = Promise.reject<Client<object>>(boom);
// Pre-attach a catch so the rejection isn't flagged as unhandled before React's
// error-boundary subscription runs.
clientPromise.catch(() => {});
clientPromise.catch(() => { });
const onError = jest.fn();
function Probe() {
useClient();
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/__tests__/useAction-test.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React from 'react';
import { renderToString } from 'react-dom/server';

import { renderHook } from '../__test-utils__/render';

import { useAction } from '../useAction';

describe('useAction', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
createClient,
isSolanaError,
SOLANA_ERROR__REACT__MISSING_CAPABILITY,
SOLANA_ERROR__REACT__MISSING_PROVIDER,
} from '@solana/errors';
import { createClient } from '@solana/plugin-core';
} from '@solana/kit';
import React from 'react';

import { renderHook } from '../__test-utils__/render';
import { ClientProvider } from '../ClientProvider';
import { useClient } from '../useClient';
import { useClientCapability } from '../useClientCapability';
import { renderHook } from '../__test-utils__/render';

type ClientWithFoo = { foo: { hello(): string } };

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/__tests__/useRequest-test.browser.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createReactiveActionStore, ReactiveActionSource } from '@solana/subscribable';
import { createReactiveActionStore, ReactiveActionSource } from '@solana/kit';
import { act } from '@testing-library/react';
import React from 'react';
import { renderToString } from 'react-dom/server';
Expand Down
8 changes: 6 additions & 2 deletions packages/react/src/__tests__/useSubscription-test.browser.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { SolanaRpcResponse } from '@solana/rpc-types';
import { createReactiveStoreFromDataPublisherFactory, DataPublisher, ReactiveStreamSource } from '@solana/subscribable';
import {
createReactiveStoreFromDataPublisherFactory,
DataPublisher,
ReactiveStreamSource,
SolanaRpcResponse,
} from '@solana/kit';
import { act } from '@testing-library/react';
import React from 'react';
import { renderToString } from 'react-dom/server';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED, SolanaError } from '@solana/errors';
import { SignatureBytes } from '@solana/keys';
import { SignatureBytes, SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED, SolanaError } from '@solana/kit';
import type { UiWalletAccount } from '@wallet-standard/ui';

import { renderHook } from '../test-renderer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { Address } from '@solana/addresses';
import type { VariableSizeEncoder } from '@solana/codecs-core';
import { SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED, SolanaError } from '@solana/errors';
import { SignatureBytes } from '@solana/keys';
import { Transaction, TransactionMessageBytes } from '@solana/transactions';
import { getTransactionEncoder } from '@solana/transactions';
import {
Address,
getTransactionEncoder,
SignatureBytes,
SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,
SolanaError,
Transaction,
TransactionMessageBytes,
type VariableSizeEncoder,
} from '@solana/kit';
import type { UiWalletAccount } from '@wallet-standard/ui';

import { renderHook } from '../test-renderer';
import { useSignAndSendTransaction } from '../useSignAndSendTransaction';
import { useWalletAccountTransactionSendingSigner } from '../useWalletAccountTransactionSendingSigner';

jest.mock('@solana/transactions');
jest.mock('@solana/kit', () => ({
...jest.requireActual('@solana/kit'),
getTransactionEncoder: jest.fn(),
}));
jest.mock('../useSignAndSendTransaction');

describe('useWalletAccountTransactionSendingSigner', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
import { Address } from '@solana/addresses';
import type { VariableSizeCodec, VariableSizeDecoder } from '@solana/codecs-core';
import {
SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,
SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE,
SolanaError,
} from '@solana/errors';
import { SignatureBytes } from '@solana/keys';
import { Blockhash } from '@solana/rpc-types';
import {
Address,
Blockhash,
CompiledTransactionMessage,
CompiledTransactionMessageWithLifetime,
getCompiledTransactionMessageDecoder,
} from '@solana/transaction-messages';
import {
getTransactionCodec,
getTransactionLifetimeConstraintFromCompiledTransactionMessage,
SignatureBytes,
SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,
SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE,
SolanaError,
Transaction,
TransactionMessageBytes,
} from '@solana/transactions';
import { getTransactionCodec } from '@solana/transactions';
type VariableSizeCodec,
type VariableSizeDecoder,
} from '@solana/kit';
import type { UiWalletAccount } from '@wallet-standard/ui';

import { renderHook } from '../test-renderer';
import { useSignTransaction } from '../useSignTransaction';
import { useWalletAccountTransactionSigner } from '../useWalletAccountTransactionSigner';

jest.mock('@solana/transaction-messages');
jest.mock('@solana/transactions');
jest.mock('@solana/kit', () => ({
...jest.requireActual('@solana/kit'),
assertIsTransactionWithinSizeLimit: jest.fn(),
getCompiledTransactionMessageDecoder: jest.fn(),
getTransactionCodec: jest.fn(),
getTransactionLifetimeConstraintFromCompiledTransactionMessage: jest.fn(),
}));
jest.mock('../useSignTransaction');

describe('useWalletAccountTransactionSigner', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/__typetests__/useClient-typetest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/rules-of-hooks */

import type { Client } from '@solana/plugin-core';
import type { Client } from '@solana/kit';

import { useClient } from '../useClient';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/rules-of-hooks */

import type { Client } from '@solana/plugin-core';
import type { Client } from '@solana/kit';

import { useClientCapability } from '../useClientCapability';

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/__typetests__/useRequest-typetest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/rules-of-hooks */

import { ReactiveActionSource } from '@solana/subscribable';
import { ReactiveActionSource } from '@solana/kit';

import { RequestResult, useRequest } from '../useRequest';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/rules-of-hooks */

import { address } from '@solana/addresses';
import { address } from '@solana/kit';
import { UiWalletAccount } from '@wallet-standard/ui';

import { useSignAndSendTransaction, useSignAndSendTransactions } from '../useSignAndSendTransaction';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/__typetests__/useSignIn-typetest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
/* eslint-disable react-hooks/rules-of-hooks */

import { address } from '@solana/addresses';
import { address } from '@solana/kit';
import { WalletVersion } from '@wallet-standard/base';
import { UiWalletAccount } from '@wallet-standard/ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/rules-of-hooks */

import { address } from '@solana/addresses';
import { address } from '@solana/kit';
import { UiWalletAccount } from '@wallet-standard/ui';

import { useSignTransaction, useSignTransactions } from '../useSignTransaction';
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/__typetests__/useSubscription-typetest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable react-hooks/rules-of-hooks */

import { SolanaRpcResponse } from '@solana/rpc-types';
import { ReactiveStreamSource } from '@solana/subscribable';
import { ReactiveStreamSource, SolanaRpcResponse } from '@solana/kit';

import { SubscriptionResult, useSubscription } from '../useSubscription';

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/staticStores.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactiveActionStore, ReactiveState, ReactiveStreamStore } from '@solana/subscribable';
import { ReactiveActionStore, ReactiveState, ReactiveStreamStore } from '@solana/kit';

const DISABLED_ACTION_STATE = Object.freeze({
data: undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/useAction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createReactiveActionStore } from '@solana/subscribable';
import { createReactiveActionStore } from '@solana/kit';
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';

import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/useClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SOLANA_ERROR__REACT__MISSING_PROVIDER, SolanaError } from '@solana/errors';
import type { Client } from '@solana/plugin-core';
import { type Client, SOLANA_ERROR__REACT__MISSING_PROVIDER, SolanaError } from '@solana/kit';
import React from 'react';

import { ClientContext } from './ClientProvider';
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/useClientCapability.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SOLANA_ERROR__REACT__MISSING_CAPABILITY, SolanaError } from '@solana/errors';
import type { Client } from '@solana/plugin-core';
import { type Client, SOLANA_ERROR__REACT__MISSING_CAPABILITY, SolanaError } from '@solana/kit';

import { useClient } from './useClient';

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/useRequest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createReactiveActionStore, ReactiveActionSource } from '@solana/subscribable';
import { createReactiveActionStore, ReactiveActionSource } from '@solana/kit';
import { useCallback, useEffect, useMemo, useRef } from 'react';

import { disabledActionStore } from './staticStores';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/useRequestResult.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactiveActionStore } from '@solana/subscribable';
import { ReactiveActionStore } from '@solana/kit';
import { useMemo, useSyncExternalStore } from 'react';

import { RequestResult } from './useRequest';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/useSignIn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address } from '@solana/addresses';
import { Address } from '@solana/kit';
import {
SolanaSignIn,
SolanaSignInFeature,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/useSubscription.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactiveStreamSource } from '@solana/subscribable';
import { ReactiveStreamSource } from '@solana/kit';
import { useCallback, useEffect, useMemo, useRef } from 'react';

import { disabledStreamStore } from './staticStores';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/useSubscriptionResult.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactiveStreamStore } from '@solana/subscribable';
import { ReactiveStreamStore } from '@solana/kit';
import { useMemo, useSyncExternalStore } from 'react';

import { SubscriptionResult } from './useSubscription';
Expand Down
17 changes: 11 additions & 6 deletions packages/react/src/useWalletAccountMessageSigner.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { Address, address } from '@solana/addresses';
import { bytesEqual } from '@solana/codecs-core';
import { SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED, SolanaError } from '@solana/errors';
import { SignatureBytes } from '@solana/keys';
import {
Address,
address,
bytesEqual,
MessageModifyingSigner,
SignableMessage,
SignatureBytes,
SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,
SolanaError,
} from '@solana/kit';
import { getAbortablePromise } from '@solana/promises';
import { MessageModifyingSigner, SignableMessage } from '@solana/signers';
import type { UiWalletAccount } from '@wallet-standard/ui';
import { useMemo } from 'react';

Expand All @@ -21,7 +26,7 @@ import { useSignMessage } from './useSignMessage';
* @example
* ```tsx
* import { useWalletAccountMessageSigner } from '@solana/react';
* import { createSignableMessage } from '@solana/signers';
* import { createSignableMessage } from '@solana/kit';
*
* function SignMessageButton({ account, text }) {
* const messageSigner = useWalletAccountMessageSigner(account);
Expand Down
13 changes: 8 additions & 5 deletions packages/react/src/useWalletAccountTransactionSendingSigner.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { address } from '@solana/addresses';
import { SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED, SolanaError } from '@solana/errors';
import { SignatureBytes } from '@solana/keys';
import {
address,
getTransactionEncoder,
SignatureBytes,
SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,
SolanaError,
TransactionSendingSigner,
} from '@solana/kit';
import { getAbortablePromise } from '@solana/promises';
import { TransactionSendingSigner } from '@solana/signers';
import { getTransactionEncoder } from '@solana/transactions';
import { UiWalletAccount } from '@wallet-standard/ui';
import { useMemo, useRef } from 'react';

Expand Down
Loading
Loading