@phantom/react-sdk 0.3.1 → 0.3.2
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 +23 -12
- package/dist/index.d.ts +3 -9
- package/dist/index.js +8 -33
- package/dist/index.mjs +8 -33
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -624,30 +624,41 @@ function MultiChainWallet() {
|
|
|
624
624
|
|
|
625
625
|
Quick reference of all available hooks:
|
|
626
626
|
|
|
627
|
-
| Hook | Purpose
|
|
628
|
-
| --------------------------- |
|
|
629
|
-
| `useConnect` | Connect to wallet
|
|
630
|
-
| `useAccounts` | Get wallet addresses
|
|
631
|
-
| `useIsExtensionInstalled` | Check extension status
|
|
632
|
-
| `useDisconnect` | Disconnect from wallet
|
|
633
|
-
| `useSignMessage` | Sign text messages
|
|
634
|
-
| `useSignAndSendTransaction` | Sign and send transactions
|
|
635
|
-
| `
|
|
636
|
-
| `usePhantom` | Get provider context | `{ isConnected, isReady }` |
|
|
627
|
+
| Hook | Purpose | Returns |
|
|
628
|
+
| --------------------------- | -------------------------- | ---------------------------------------------- |
|
|
629
|
+
| `useConnect` | Connect to wallet | `{ connect, isConnecting, error }` |
|
|
630
|
+
| `useAccounts` | Get wallet addresses | `WalletAddress[]` or `null` |
|
|
631
|
+
| `useIsExtensionInstalled` | Check extension status | `{ isLoading, isInstalled }` |
|
|
632
|
+
| `useDisconnect` | Disconnect from wallet | `{ disconnect, isDisconnecting }` |
|
|
633
|
+
| `useSignMessage` | Sign text messages | `{ signMessage, isSigning, error }` |
|
|
634
|
+
| `useSignAndSendTransaction` | Sign and send transactions | `{ signAndSendTransaction, isSigning, error }` |
|
|
635
|
+
| `usePhantom` | Get provider context | `{ isConnected, isReady }` |
|
|
637
636
|
|
|
638
637
|
## Configuration Reference
|
|
639
638
|
|
|
640
639
|
```typescript
|
|
641
640
|
interface PhantomSDKConfig {
|
|
642
641
|
providerType: "injected" | "embedded";
|
|
642
|
+
appName?: string; // Optional app name for branding
|
|
643
|
+
appLogo?: string; // Optional app logo URL for branding
|
|
644
|
+
addressTypes?: AddressType[]; // Networks to enable (e.g., [AddressType.solana])
|
|
643
645
|
|
|
644
646
|
// Required for embedded provider only
|
|
645
|
-
addressTypes?: AddressType[]; // Networks to enable
|
|
646
647
|
apiBaseUrl?: string; // Phantom API base URL
|
|
647
648
|
organizationId?: string; // Your organization ID
|
|
648
|
-
|
|
649
|
+
authOptions?: {
|
|
650
|
+
authUrl?: string; // Custom auth URL (optional)
|
|
651
|
+
redirectUrl?: string; // Custom redirect URL (optional)
|
|
652
|
+
};
|
|
649
653
|
embeddedWalletType?: "app-wallet" | "user-wallet"; // Wallet type
|
|
650
654
|
solanaProvider?: "web3js" | "kit"; // Solana library choice (default: 'web3js')
|
|
655
|
+
|
|
656
|
+
// Debug options
|
|
657
|
+
debug?: {
|
|
658
|
+
enabled?: boolean; // Enable debug logging
|
|
659
|
+
level?: "info" | "warn" | "error"; // Debug level
|
|
660
|
+
callback?: (level: string, message: string, data?: any) => void; // Custom debug callback
|
|
661
|
+
};
|
|
651
662
|
}
|
|
652
663
|
```
|
|
653
664
|
|
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
|
-
import { BrowserSDKConfig, AuthOptions, BrowserSDK, WalletAddress, SignMessageParams, SignMessageResult, SignAndSendTransactionParams, SignedTransaction
|
|
4
|
-
export { AddressType,
|
|
3
|
+
import { BrowserSDKConfig, AuthOptions, BrowserSDK, WalletAddress, SignMessageParams, SignMessageResult, SignAndSendTransactionParams, SignedTransaction } from '@phantom/browser-sdk';
|
|
4
|
+
export { AddressType, DebugLevel, DebugMessage, NetworkId, SignAndSendTransactionParams, SignMessageParams, SignMessageResult, SignedTransaction, WalletAddress, debug } from '@phantom/browser-sdk';
|
|
5
5
|
import * as _phantom_embedded_provider_core from '@phantom/embedded-provider-core';
|
|
6
6
|
|
|
7
7
|
interface PhantomSDKConfig extends BrowserSDKConfig {
|
|
@@ -56,12 +56,6 @@ declare function useSignAndSendTransaction(): {
|
|
|
56
56
|
|
|
57
57
|
declare function useAccounts(): _phantom_embedded_provider_core.WalletAddress[] | null;
|
|
58
58
|
|
|
59
|
-
declare function useCreateUserOrganization(): {
|
|
60
|
-
createUserOrganization: (params: CreateUserOrganizationParams) => Promise<CreateUserOrganizationResult>;
|
|
61
|
-
isCreating: boolean;
|
|
62
|
-
error: Error | null;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
59
|
declare function useIsExtensionInstalled(): {
|
|
66
60
|
isLoading: boolean;
|
|
67
61
|
isInstalled: boolean;
|
|
@@ -69,4 +63,4 @@ declare function useIsExtensionInstalled(): {
|
|
|
69
63
|
|
|
70
64
|
type ProviderType = "injected" | "embedded";
|
|
71
65
|
|
|
72
|
-
export { ConnectOptions, PhantomProvider, PhantomProviderProps, PhantomSDKConfig, ProviderType, useAccounts, useConnect,
|
|
66
|
+
export { ConnectOptions, PhantomProvider, PhantomProviderProps, PhantomSDKConfig, ProviderType, useAccounts, useConnect, useDisconnect, useIsExtensionInstalled, usePhantom, useSignAndSendTransaction, useSignMessage };
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,6 @@ __export(src_exports, {
|
|
|
37
37
|
debug: () => import_browser_sdk2.debug,
|
|
38
38
|
useAccounts: () => useAccounts,
|
|
39
39
|
useConnect: () => useConnect,
|
|
40
|
-
useCreateUserOrganization: () => useCreateUserOrganization,
|
|
41
40
|
useDisconnect: () => useDisconnect,
|
|
42
41
|
useIsExtensionInstalled: () => useIsExtensionInstalled,
|
|
43
42
|
usePhantom: () => usePhantom,
|
|
@@ -83,6 +82,14 @@ function PhantomProvider({ children, config }) {
|
|
|
83
82
|
} catch (err) {
|
|
84
83
|
console.error("Error updating connection state:", err);
|
|
85
84
|
setError(err);
|
|
85
|
+
try {
|
|
86
|
+
await sdk.disconnect();
|
|
87
|
+
setIsConnected(false);
|
|
88
|
+
setAddresses([]);
|
|
89
|
+
setWalletId(null);
|
|
90
|
+
} catch (err2) {
|
|
91
|
+
console.error("Error disconnecting:", err2);
|
|
92
|
+
}
|
|
86
93
|
}
|
|
87
94
|
}, [sdk]);
|
|
88
95
|
(0, import_react.useEffect)(() => {
|
|
@@ -262,38 +269,6 @@ function useAccounts() {
|
|
|
262
269
|
return isConnected ? addresses : null;
|
|
263
270
|
}
|
|
264
271
|
|
|
265
|
-
// src/hooks/useCreateUserOrganization.ts
|
|
266
|
-
var import_react6 = require("react");
|
|
267
|
-
function useCreateUserOrganization() {
|
|
268
|
-
const { sdk } = usePhantom();
|
|
269
|
-
const [isCreating, setIsCreating] = (0, import_react6.useState)(false);
|
|
270
|
-
const [error, setError] = (0, import_react6.useState)(null);
|
|
271
|
-
const createUserOrganization = (0, import_react6.useCallback)(
|
|
272
|
-
async (params) => {
|
|
273
|
-
if (!sdk) {
|
|
274
|
-
throw new Error("SDK not initialized");
|
|
275
|
-
}
|
|
276
|
-
setIsCreating(true);
|
|
277
|
-
setError(null);
|
|
278
|
-
try {
|
|
279
|
-
const result = await sdk.createUserOrganization(params);
|
|
280
|
-
return result;
|
|
281
|
-
} catch (err) {
|
|
282
|
-
setError(err);
|
|
283
|
-
throw err;
|
|
284
|
-
} finally {
|
|
285
|
-
setIsCreating(false);
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
[sdk]
|
|
289
|
-
);
|
|
290
|
-
return {
|
|
291
|
-
createUserOrganization,
|
|
292
|
-
isCreating,
|
|
293
|
-
error
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
272
|
// src/hooks/useIsExtensionInstalled.ts
|
|
298
273
|
var React = __toESM(require("react"));
|
|
299
274
|
var cachedIsInstalled = null;
|
package/dist/index.mjs
CHANGED
|
@@ -35,6 +35,14 @@ function PhantomProvider({ children, config }) {
|
|
|
35
35
|
} catch (err) {
|
|
36
36
|
console.error("Error updating connection state:", err);
|
|
37
37
|
setError(err);
|
|
38
|
+
try {
|
|
39
|
+
await sdk.disconnect();
|
|
40
|
+
setIsConnected(false);
|
|
41
|
+
setAddresses([]);
|
|
42
|
+
setWalletId(null);
|
|
43
|
+
} catch (err2) {
|
|
44
|
+
console.error("Error disconnecting:", err2);
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
}, [sdk]);
|
|
40
48
|
useEffect(() => {
|
|
@@ -214,38 +222,6 @@ function useAccounts() {
|
|
|
214
222
|
return isConnected ? addresses : null;
|
|
215
223
|
}
|
|
216
224
|
|
|
217
|
-
// src/hooks/useCreateUserOrganization.ts
|
|
218
|
-
import { useCallback as useCallback6, useState as useState6 } from "react";
|
|
219
|
-
function useCreateUserOrganization() {
|
|
220
|
-
const { sdk } = usePhantom();
|
|
221
|
-
const [isCreating, setIsCreating] = useState6(false);
|
|
222
|
-
const [error, setError] = useState6(null);
|
|
223
|
-
const createUserOrganization = useCallback6(
|
|
224
|
-
async (params) => {
|
|
225
|
-
if (!sdk) {
|
|
226
|
-
throw new Error("SDK not initialized");
|
|
227
|
-
}
|
|
228
|
-
setIsCreating(true);
|
|
229
|
-
setError(null);
|
|
230
|
-
try {
|
|
231
|
-
const result = await sdk.createUserOrganization(params);
|
|
232
|
-
return result;
|
|
233
|
-
} catch (err) {
|
|
234
|
-
setError(err);
|
|
235
|
-
throw err;
|
|
236
|
-
} finally {
|
|
237
|
-
setIsCreating(false);
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
[sdk]
|
|
241
|
-
);
|
|
242
|
-
return {
|
|
243
|
-
createUserOrganization,
|
|
244
|
-
isCreating,
|
|
245
|
-
error
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
225
|
// src/hooks/useIsExtensionInstalled.ts
|
|
250
226
|
import * as React from "react";
|
|
251
227
|
var cachedIsInstalled = null;
|
|
@@ -291,7 +267,6 @@ export {
|
|
|
291
267
|
debug,
|
|
292
268
|
useAccounts,
|
|
293
269
|
useConnect,
|
|
294
|
-
useCreateUserOrganization,
|
|
295
270
|
useDisconnect,
|
|
296
271
|
useIsExtensionInstalled,
|
|
297
272
|
usePhantom,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/react-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"prettier": "prettier --write \"src/**/*.{ts,tsx}\""
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@phantom/browser-sdk": "^0.3.
|
|
29
|
+
"@phantom/browser-sdk": "^0.3.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@testing-library/dom": "^10.4.0",
|