Skip to content

Commit f0abc4e

Browse files
committed
Migrate @solana/react to import from @solana/kit
Switch the `@solana/react` package to take a single `@solana/kit` workspace dep instead of pinning each consumed sub-package individually. The kit barrel already re-exports `@solana/addresses`, `@solana/errors`, `@solana/keys`, `@solana/plugin-core`, `@solana/signers`, `@solana/transaction-messages`, `@solana/transactions`, `@solana/rpc-types`, and (transitively via `@solana/codecs`) `@solana/codecs-core` — so the granular deps are redundant. `@solana/subscribable` and `@solana/promises` stay as direct deps because they aren't re-exported by Kit. The migration is mechanical — every `import { … } from '@solana/<sub-package>'` in `src/` becomes `import { … } from '@solana/kit'`. No behavior change; consumers' transitive dep tree is unchanged because `@solana/kit` itself depends on the same sub-packages. Two wallet-signer tests switched from full-module auto-mocks (`jest.mock('@solana/transactions')` / `jest.mock('@solana/transaction-messages')`) to factory-style mocks (`jest.mock('@solana/kit', () => ({ ...jest.requireActual('@solana/kit'), getTransactionCodec: jest.fn(), … }))`). The bundled `@solana/kit` output doesn't propagate jest's auto-mock through its `export *` re-exports, so listing the specific functions to stub keeps everything else (notably `SolanaError`, error constants, and `bytesEqual`) as the real implementation. Positions `@solana/react` symmetrically with how a third-party `@solana/vue` / `@solana/svelte` / etc. binding would depend on Kit: one umbrella dep, one place to import from.
1 parent 624e92f commit f0abc4e

25 files changed

Lines changed: 87 additions & 99 deletions

.changeset/purple-readers-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@solana/react': patch
3+
---
4+
5+
Migrate `@solana/react` to import from `@solana/kit` instead of pinning each consumed sub-package individually. `@solana/subscribable` and `@solana/promises` remain as direct deps because they aren't re-exported by `@solana/kit`.

packages/react/package.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,9 @@
7474
"maintained node versions"
7575
],
7676
"dependencies": {
77-
"@solana/addresses": "workspace:*",
78-
"@solana/errors": "workspace:*",
79-
"@solana/keys": "workspace:*",
80-
"@solana/plugin-core": "workspace:*",
77+
"@solana/kit": "workspace:*",
8178
"@solana/promises": "workspace:*",
82-
"@solana/signers": "workspace:*",
8379
"@solana/subscribable": "workspace:*",
84-
"@solana/transaction-messages": "workspace:*",
85-
"@solana/transactions": "workspace:*",
8680
"@solana/wallet-standard-features": "^1.3.0",
8781
"@wallet-standard/base": "^1.1.0",
8882
"@wallet-standard/errors": "^0.1.1",
@@ -91,9 +85,7 @@
9185
"@wallet-standard/ui-registry": "^1.0.1"
9286
},
9387
"devDependencies": {
94-
"@solana/codecs-core": "workspace:*",
9588
"@solana/eslint-config": "workspace:*",
96-
"@solana/rpc-types": "workspace:*",
9789
"@testing-library/react": "^16.3.2",
9890
"@types/react": "^19.2.15",
9991
"@types/react-dom": "^19.2.3",

packages/react/src/ClientProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '@solana/plugin-core';
1+
import type { Client } from '@solana/kit';
22
import React from 'react';
33

44
import { usePromise } from './usePromise';

packages/react/src/__tests__/ClientProvider-test.browser.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { isSolanaError, SOLANA_ERROR__REACT__MISSING_PROVIDER } from '@solana/errors';
2-
import { Client, createClient } from '@solana/plugin-core';
1+
import { isSolanaError, SOLANA_ERROR__REACT__MISSING_PROVIDER } from '@solana/kit';
2+
import { Client, createClient } from '@solana/kit';
33
import { act } from '@testing-library/react';
44
import React, { Suspense } from 'react';
55
import { ErrorBoundary } from 'react-error-boundary';
66

7+
import { render, renderHook } from '../__test-utils__/render';
78
import { ClientProvider } from '../ClientProvider';
89
import { useClient } from '../useClient';
9-
import { render, renderHook } from '../__test-utils__/render';
1010

1111
describe('ClientProvider + useClient', () => {
1212
it('publishes the client to descendants and returns the same reference across renders', () => {

packages/react/src/__tests__/useAction-test.browser.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import React from 'react';
44
import { renderToString } from 'react-dom/server';
55

66
import { renderHook } from '../__test-utils__/render';
7-
87
import { useAction } from '../useAction';
98

109
describe('useAction', () => {

packages/react/src/__tests__/useClientCapability-test.browser.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import {
22
isSolanaError,
33
SOLANA_ERROR__REACT__MISSING_CAPABILITY,
44
SOLANA_ERROR__REACT__MISSING_PROVIDER,
5-
} from '@solana/errors';
6-
import { createClient } from '@solana/plugin-core';
5+
} from '@solana/kit';
6+
import { createClient } from '@solana/kit';
77
import React from 'react';
88

9+
import { renderHook } from '../__test-utils__/render';
910
import { ClientProvider } from '../ClientProvider';
1011
import { useClient } from '../useClient';
1112
import { useClientCapability } from '../useClientCapability';
12-
import { renderHook } from '../__test-utils__/render';
1313

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

packages/react/src/__tests__/useSubscription-test.browser.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SolanaRpcResponse } from '@solana/rpc-types';
1+
import { SolanaRpcResponse } from '@solana/kit';
22
import { createReactiveStoreFromDataPublisherFactory, DataPublisher, ReactiveStreamSource } from '@solana/subscribable';
33
import { act } from '@testing-library/react';
44
import React from 'react';

packages/react/src/__tests__/useWalletAccountMessageSigner-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED, SolanaError } from '@solana/errors';
2-
import { SignatureBytes } from '@solana/keys';
1+
import { SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED, SolanaError } from '@solana/kit';
2+
import { SignatureBytes } from '@solana/kit';
33
import type { UiWalletAccount } from '@wallet-standard/ui';
44

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

packages/react/src/__tests__/useWalletAccountTransactionSendingSigner-test.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
import { Address } from '@solana/addresses';
2-
import type { VariableSizeEncoder } from '@solana/codecs-core';
3-
import { SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED, SolanaError } from '@solana/errors';
4-
import { SignatureBytes } from '@solana/keys';
5-
import { Transaction, TransactionMessageBytes } from '@solana/transactions';
6-
import { getTransactionEncoder } from '@solana/transactions';
1+
import {
2+
Address,
3+
getTransactionEncoder,
4+
SignatureBytes,
5+
SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,
6+
SolanaError,
7+
Transaction,
8+
TransactionMessageBytes,
9+
type VariableSizeEncoder,
10+
} from '@solana/kit';
711
import type { UiWalletAccount } from '@wallet-standard/ui';
812

913
import { renderHook } from '../test-renderer';
1014
import { useSignAndSendTransaction } from '../useSignAndSendTransaction';
1115
import { useWalletAccountTransactionSendingSigner } from '../useWalletAccountTransactionSendingSigner';
1216

13-
jest.mock('@solana/transactions');
17+
jest.mock('@solana/kit', () => ({
18+
...jest.requireActual('@solana/kit'),
19+
getTransactionEncoder: jest.fn(),
20+
}));
1421
jest.mock('../useSignAndSendTransaction');
1522

1623
describe('useWalletAccountTransactionSendingSigner', () => {

packages/react/src/__tests__/useWalletAccountTransactionSigner-test.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
import { Address } from '@solana/addresses';
2-
import type { VariableSizeCodec, VariableSizeDecoder } from '@solana/codecs-core';
3-
import {
4-
SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,
5-
SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE,
6-
SolanaError,
7-
} from '@solana/errors';
8-
import { SignatureBytes } from '@solana/keys';
9-
import { Blockhash } from '@solana/rpc-types';
101
import {
2+
Address,
3+
Blockhash,
114
CompiledTransactionMessage,
125
CompiledTransactionMessageWithLifetime,
136
getCompiledTransactionMessageDecoder,
14-
} from '@solana/transaction-messages';
15-
import {
7+
getTransactionCodec,
168
getTransactionLifetimeConstraintFromCompiledTransactionMessage,
9+
SignatureBytes,
10+
SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED,
11+
SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE,
12+
SolanaError,
1713
Transaction,
1814
TransactionMessageBytes,
19-
} from '@solana/transactions';
20-
import { getTransactionCodec } from '@solana/transactions';
15+
type VariableSizeCodec,
16+
type VariableSizeDecoder,
17+
} from '@solana/kit';
2118
import type { UiWalletAccount } from '@wallet-standard/ui';
2219

2320
import { renderHook } from '../test-renderer';
2421
import { useSignTransaction } from '../useSignTransaction';
2522
import { useWalletAccountTransactionSigner } from '../useWalletAccountTransactionSigner';
2623

27-
jest.mock('@solana/transaction-messages');
28-
jest.mock('@solana/transactions');
24+
jest.mock('@solana/kit', () => ({
25+
...jest.requireActual('@solana/kit'),
26+
assertIsTransactionWithinSizeLimit: jest.fn(),
27+
getCompiledTransactionMessageDecoder: jest.fn(),
28+
getTransactionCodec: jest.fn(),
29+
getTransactionLifetimeConstraintFromCompiledTransactionMessage: jest.fn(),
30+
}));
2931
jest.mock('../useSignTransaction');
3032

3133
describe('useWalletAccountTransactionSigner', () => {

0 commit comments

Comments
 (0)