@phantom/react-sdk 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -239,7 +239,12 @@ function ExtensionStatus() {
239
239
  {isInstalled ? (
240
240
  <p>✅ Phantom extension is installed!</p>
241
241
  ) : (
242
- <p>❌ Phantom extension not found. <a href="https://phantom.app/download" target="_blank">Install here</a></p>
242
+ <p>
243
+ ❌ Phantom extension not found.{" "}
244
+ <a href="https://phantom.app/download" target="_blank">
245
+ Install here
246
+ </a>
247
+ </p>
243
248
  )}
244
249
  </div>
245
250
  );
@@ -247,12 +252,14 @@ function ExtensionStatus() {
247
252
  ```
248
253
 
249
254
  **Features:**
255
+
250
256
  - **Session-based caching**: Result is cached during the browser session to avoid redundant checks
251
257
  - **Automatic detection**: Runs automatically when the hook is first used
252
258
  - **Loading states**: Provides `isLoading` during the initial check
253
259
  - **Performance optimized**: Subsequent calls return cached result instantly
254
260
 
255
261
  **Use cases:**
262
+
256
263
  - Show installation prompts for users without the extension
257
264
  - Conditionally render UI based on extension availability
258
265
  - Provide fallback options when extension is not installed
@@ -287,7 +294,10 @@ function SignMessage() {
287
294
 
288
295
  const handleSign = async () => {
289
296
  try {
290
- const signature = await signMessage("Hello from Phantom!", NetworkId.SOLANA_MAINNET);
297
+ const signature = await signMessage({
298
+ message: "Hello from Phantom!",
299
+ networkId: NetworkId.SOLANA_MAINNET,
300
+ });
291
301
  console.log("Signature:", signature);
292
302
  } catch (err) {
293
303
  console.error("Failed to sign:", err);
@@ -572,16 +582,16 @@ function MultiChainWallet() {
572
582
 
573
583
  Quick reference of all available hooks:
574
584
 
575
- | Hook | Purpose | Returns |
576
- |------|---------|---------|
577
- | `useConnect` | Connect to wallet | `{ connect, isConnecting, error }` |
578
- | `useAccounts` | Get wallet addresses | `WalletAddress[]` or `null` |
579
- | `useIsExtensionInstalled` | Check extension status | `{ isLoading, isInstalled }` |
580
- | `useDisconnect` | Disconnect from wallet | `{ disconnect, isDisconnecting }` |
581
- | `useSignMessage` | Sign text messages | `{ signMessage, isSigning, error }` |
582
- | `useSignAndSendTransaction` | Sign and send transactions | `{ signAndSendTransaction, isSigning, error }` |
585
+ | Hook | Purpose | Returns |
586
+ | --------------------------- | ----------------------------------- | ----------------------------------------------- |
587
+ | `useConnect` | Connect to wallet | `{ connect, isConnecting, error }` |
588
+ | `useAccounts` | Get wallet addresses | `WalletAddress[]` or `null` |
589
+ | `useIsExtensionInstalled` | Check extension status | `{ isLoading, isInstalled }` |
590
+ | `useDisconnect` | Disconnect from wallet | `{ disconnect, isDisconnecting }` |
591
+ | `useSignMessage` | Sign text messages | `{ signMessage, isSigning, error }` |
592
+ | `useSignAndSendTransaction` | Sign and send transactions | `{ signAndSendTransaction, isSigning, error }` |
583
593
  | `useCreateUserOrganization` | Create user organization (embedded) | `{ createUserOrganization, isCreating, error }` |
584
- | `usePhantom` | Get provider context | `{ isConnected, isReady, currentProviderType }` |
594
+ | `usePhantom` | Get provider context | `{ isConnected, isReady, currentProviderType }` |
585
595
 
586
596
  ## Configuration Reference
587
597
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
  import * as _phantom_browser_sdk from '@phantom/browser-sdk';
4
- import { BrowserSDKConfig, BrowserSDK, WalletAddress, NetworkId, SignAndSendTransactionParams, SignedTransaction, CreateUserOrganizationParams, CreateUserOrganizationResult } from '@phantom/browser-sdk';
4
+ import { BrowserSDKConfig, BrowserSDK, WalletAddress, SignMessageParams, SignAndSendTransactionParams, SignedTransaction, CreateUserOrganizationParams, CreateUserOrganizationResult } from '@phantom/browser-sdk';
5
5
  export { AddressType, CreateUserOrganizationParams, CreateUserOrganizationResult, NetworkId, SignAndSendTransactionParams, SignMessageParams, SignedTransaction, WalletAddress } from '@phantom/browser-sdk';
6
6
 
7
7
  interface PhantomSDKConfig extends BrowserSDKConfig {
@@ -46,7 +46,7 @@ declare function useDisconnect(): {
46
46
  };
47
47
 
48
48
  declare function useSignMessage(): {
49
- signMessage: (message: string, networkId: NetworkId) => Promise<string>;
49
+ signMessage: (params: SignMessageParams) => Promise<string>;
50
50
  isSigning: boolean;
51
51
  error: Error | null;
52
52
  };
package/dist/index.js CHANGED
@@ -216,7 +216,7 @@ function useSignMessage() {
216
216
  const [isSigning, setIsSigning] = (0, import_react4.useState)(false);
217
217
  const [error, setError] = (0, import_react4.useState)(null);
218
218
  const signMessage = (0, import_react4.useCallback)(
219
- async (message, networkId) => {
219
+ async (params) => {
220
220
  if (!sdk) {
221
221
  throw new Error("SDK not initialized");
222
222
  }
@@ -226,7 +226,7 @@ function useSignMessage() {
226
226
  setIsSigning(true);
227
227
  setError(null);
228
228
  try {
229
- const signature = await sdk.signMessage(message, networkId);
229
+ const signature = await sdk.signMessage(params);
230
230
  return signature;
231
231
  } catch (err) {
232
232
  setError(err);
package/dist/index.mjs CHANGED
@@ -170,7 +170,7 @@ function useSignMessage() {
170
170
  const [isSigning, setIsSigning] = useState4(false);
171
171
  const [error, setError] = useState4(null);
172
172
  const signMessage = useCallback4(
173
- async (message, networkId) => {
173
+ async (params) => {
174
174
  if (!sdk) {
175
175
  throw new Error("SDK not initialized");
176
176
  }
@@ -180,7 +180,7 @@ function useSignMessage() {
180
180
  setIsSigning(true);
181
181
  setError(null);
182
182
  try {
183
- const signature = await sdk.signMessage(message, networkId);
183
+ const signature = await sdk.signMessage(params);
184
184
  return signature;
185
185
  } catch (err) {
186
186
  setError(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phantom/react-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "prettier": "prettier --write \"src/**/*.{ts,tsx}\""
26
26
  },
27
27
  "dependencies": {
28
- "@phantom/browser-sdk": "^0.1.0"
28
+ "@phantom/browser-sdk": "^0.2.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@testing-library/dom": "^10.4.0",