@phantom/react-sdk 1.0.0-beta.21 → 1.0.0-beta.22
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 +300 -48
- package/dist/index.d.ts +39 -17
- package/dist/index.js +582 -182
- package/dist/index.mjs +578 -178
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ function App() {
|
|
|
41
41
|
return (
|
|
42
42
|
<PhantomProvider
|
|
43
43
|
config={{
|
|
44
|
-
|
|
44
|
+
providers: ["injected"], // Only allow Phantom browser extension
|
|
45
45
|
addressTypes: [AddressType.solana, AddressType.ethereum],
|
|
46
46
|
}}
|
|
47
47
|
>
|
|
@@ -83,7 +83,7 @@ function WalletComponent() {
|
|
|
83
83
|
}
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
###
|
|
86
|
+
### Multiple Authentication Methods
|
|
87
87
|
|
|
88
88
|
```tsx
|
|
89
89
|
import { PhantomProvider } from "@phantom/react-sdk";
|
|
@@ -93,8 +93,8 @@ function App() {
|
|
|
93
93
|
return (
|
|
94
94
|
<PhantomProvider
|
|
95
95
|
config={{
|
|
96
|
-
|
|
97
|
-
appId: "your-app-id", // Get your app ID from phantom.com/portal
|
|
96
|
+
providers: ["google", "apple", "phantom", "injected"], // Allow all auth methods
|
|
97
|
+
appId: "your-app-id", // Get your app ID from phantom.com/portal (required for embedded providers)
|
|
98
98
|
addressTypes: [AddressType.solana, AddressType.ethereum],
|
|
99
99
|
}}
|
|
100
100
|
>
|
|
@@ -104,6 +104,195 @@ function App() {
|
|
|
104
104
|
}
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
+
## Connection Modal
|
|
108
|
+
|
|
109
|
+
The SDK includes a built-in connection modal UI that provides a user-friendly interface for connecting to Phantom. The modal supports multiple connection methods (Google, Apple, Phantom Login, browser extension) and handles all connection logic automatically.
|
|
110
|
+
|
|
111
|
+
### Using the Modal
|
|
112
|
+
|
|
113
|
+
To use the modal, pass a `theme` prop to `PhantomProvider` and use the `useModal()` hook to control visibility:
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import { PhantomProvider, useModal, darkTheme, usePhantom } from "@phantom/react-sdk";
|
|
117
|
+
import { AddressType } from "@phantom/browser-sdk";
|
|
118
|
+
|
|
119
|
+
function App() {
|
|
120
|
+
return (
|
|
121
|
+
<PhantomProvider
|
|
122
|
+
config={{
|
|
123
|
+
providers: ["google", "apple", "phantom", "injected"],
|
|
124
|
+
appId: "your-app-id",
|
|
125
|
+
addressTypes: [AddressType.solana, AddressType.ethereum],
|
|
126
|
+
}}
|
|
127
|
+
theme={darkTheme}
|
|
128
|
+
appIcon="https://your-app.com/icon.png"
|
|
129
|
+
appName="Your App Name"
|
|
130
|
+
>
|
|
131
|
+
<WalletComponent />
|
|
132
|
+
</PhantomProvider>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function WalletComponent() {
|
|
137
|
+
const { open, close, isOpened } = useModal();
|
|
138
|
+
const { isConnected, user } = usePhantom();
|
|
139
|
+
|
|
140
|
+
if (isConnected) {
|
|
141
|
+
return (
|
|
142
|
+
<div>
|
|
143
|
+
<p>Connected as {user?.email || "Unknown"}</p>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return <button onClick={open}>Connect Wallet</button>;
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Modal Features:**
|
|
153
|
+
|
|
154
|
+
- **Multiple Auth Providers**: Google, Apple, Phantom Login, browser extension
|
|
155
|
+
- **Automatic Provider Detection**: Shows browser extension option when Phantom is installed
|
|
156
|
+
- **Mobile Support**: Displays deeplink option for Phantom mobile app on mobile devices
|
|
157
|
+
- **Error Handling**: Clear error messages displayed in the modal
|
|
158
|
+
- **Loading States**: Visual feedback during connection attempts
|
|
159
|
+
- **Responsive Design**: Optimized for both mobile and desktop
|
|
160
|
+
|
|
161
|
+
### useModal Hook
|
|
162
|
+
|
|
163
|
+
Control the connection modal visibility:
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import { useModal } from "@phantom/react-sdk";
|
|
167
|
+
|
|
168
|
+
function ConnectButton() {
|
|
169
|
+
const { open, close, isOpened } = useModal();
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<div>
|
|
173
|
+
<button onClick={open}>Open Modal</button>
|
|
174
|
+
<button onClick={close}>Close Modal</button>
|
|
175
|
+
<p>Modal is {isOpened ? "open" : "closed"}</p>
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Returns:**
|
|
182
|
+
|
|
183
|
+
- `open()` - Function to open the modal
|
|
184
|
+
- `close()` - Function to close the modal
|
|
185
|
+
- `isOpened` - Boolean indicating if modal is currently visible
|
|
186
|
+
|
|
187
|
+
### ConnectButton Component
|
|
188
|
+
|
|
189
|
+
A ready-to-use button component that handles the complete connection flow. When disconnected, it shows a "Connect Wallet" button that opens the connection modal. When connected, it displays the truncated wallet address and opens the wallet management modal on click.
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { ConnectButton, AddressType } from "@phantom/react-sdk";
|
|
193
|
+
|
|
194
|
+
function Header() {
|
|
195
|
+
return (
|
|
196
|
+
<div>
|
|
197
|
+
{/* Default: Shows first available address */}
|
|
198
|
+
<ConnectButton />
|
|
199
|
+
|
|
200
|
+
{/* Show specific address type */}
|
|
201
|
+
<ConnectButton addressType={AddressType.solana} />
|
|
202
|
+
<ConnectButton addressType={AddressType.ethereum} />
|
|
203
|
+
|
|
204
|
+
{/* Full width button */}
|
|
205
|
+
<ConnectButton fullWidth />
|
|
206
|
+
</div>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Props:**
|
|
212
|
+
|
|
213
|
+
- `addressType?: AddressType` - Specify which address type to display when connected (e.g., `AddressType.solana`, `AddressType.ethereum`). If not specified, shows the first available address.
|
|
214
|
+
- `fullWidth?: boolean` - Whether the button should take full width of its container. Default: `false`
|
|
215
|
+
|
|
216
|
+
**Features:**
|
|
217
|
+
|
|
218
|
+
- **When disconnected**: Opens connection modal with auth provider options (Google, Apple, Phantom Login, browser extension)
|
|
219
|
+
- **When connected**: Displays truncated address (e.g., "5Gv8r2...k3Hn") and opens wallet management modal on click
|
|
220
|
+
- **Wallet modal**: Shows all connected addresses and provides a disconnect button
|
|
221
|
+
- Uses theme styling for consistent appearance
|
|
222
|
+
- Fully clickable in both states
|
|
223
|
+
|
|
224
|
+
## Theming
|
|
225
|
+
|
|
226
|
+
Customize the modal appearance by passing a theme object to the `PhantomProvider`. The SDK includes two built-in themes: `darkTheme` (default) and `lightTheme`.
|
|
227
|
+
|
|
228
|
+
### Using Built-in Themes
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
import { PhantomProvider, darkTheme, lightTheme } from "@phantom/react-sdk";
|
|
232
|
+
|
|
233
|
+
// Use dark theme (default)
|
|
234
|
+
<PhantomProvider config={config} theme={darkTheme}>
|
|
235
|
+
<App />
|
|
236
|
+
</PhantomProvider>
|
|
237
|
+
|
|
238
|
+
// Use light theme
|
|
239
|
+
<PhantomProvider config={config} theme={lightTheme}>
|
|
240
|
+
<App />
|
|
241
|
+
</PhantomProvider>
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Custom Theme
|
|
245
|
+
|
|
246
|
+
You can pass a partial theme object to customize specific properties:
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
import { PhantomProvider } from "@phantom/react-sdk";
|
|
250
|
+
|
|
251
|
+
const customTheme = {
|
|
252
|
+
background: "#1a1a1a",
|
|
253
|
+
text: "#ffffff",
|
|
254
|
+
secondary: "#98979C",
|
|
255
|
+
brand: "#ab9ff2",
|
|
256
|
+
error: "#ff4444",
|
|
257
|
+
success: "#00ff00",
|
|
258
|
+
borderRadius: "16px",
|
|
259
|
+
overlay: "rgba(0, 0, 0, 0.8)",
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
<PhantomProvider config={config} theme={customTheme} appIcon="https://your-app.com/icon.png" appName="Your App">
|
|
263
|
+
<App />
|
|
264
|
+
</PhantomProvider>;
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Theme Properties
|
|
268
|
+
|
|
269
|
+
| Property | Type | Description |
|
|
270
|
+
| -------------- | -------- | --------------------------------------------------------- |
|
|
271
|
+
| `background` | `string` | Background color for modal |
|
|
272
|
+
| `text` | `string` | Primary text color |
|
|
273
|
+
| `secondary` | `string` | Secondary color for text, borders, dividers (must be hex) |
|
|
274
|
+
| `brand` | `string` | Brand/primary action color |
|
|
275
|
+
| `error` | `string` | Error state color |
|
|
276
|
+
| `success` | `string` | Success state color |
|
|
277
|
+
| `borderRadius` | `string` | Border radius for buttons and modal |
|
|
278
|
+
| `overlay` | `string` | Overlay background color (with opacity) |
|
|
279
|
+
|
|
280
|
+
**Note:** The `secondary` color must be a hex color value (e.g., `#98979C`) as it's used to derive auxiliary colors with opacity.
|
|
281
|
+
|
|
282
|
+
### Accessing Theme in Custom Components
|
|
283
|
+
|
|
284
|
+
If you need to access the current theme in your own components, use the `useTheme()` hook:
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
import { useTheme } from "@phantom/react-sdk";
|
|
288
|
+
|
|
289
|
+
function CustomComponent() {
|
|
290
|
+
const theme = useTheme();
|
|
291
|
+
|
|
292
|
+
return <div style={{ backgroundColor: theme.background, color: theme.text }}>Themed content</div>;
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
107
296
|
## Connection Flow
|
|
108
297
|
|
|
109
298
|
The React SDK follows a clear connection pattern:
|
|
@@ -173,16 +362,58 @@ await connect({
|
|
|
173
362
|
});
|
|
174
363
|
```
|
|
175
364
|
|
|
176
|
-
##
|
|
365
|
+
## SDK Initialization
|
|
177
366
|
|
|
178
|
-
|
|
367
|
+
The SDK provides an `isLoading` state to track when initialization and autoconnect are in progress. This is useful for showing loading states before your app is ready.
|
|
179
368
|
|
|
180
|
-
|
|
369
|
+
```tsx
|
|
370
|
+
import { useConnect, usePhantom } from "@phantom/react-sdk";
|
|
371
|
+
|
|
372
|
+
function App() {
|
|
373
|
+
const { isLoading } = usePhantom();
|
|
374
|
+
const { connect } = useConnect();
|
|
375
|
+
|
|
376
|
+
// Show loading state while SDK initializes
|
|
377
|
+
if (isLoading) {
|
|
378
|
+
return (
|
|
379
|
+
<div>
|
|
380
|
+
<h1>Initializing Phantom SDK...</h1>
|
|
381
|
+
<p>Please wait...</p>
|
|
382
|
+
</div>
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// SDK is ready
|
|
387
|
+
return (
|
|
388
|
+
<div>
|
|
389
|
+
<h1>Welcome!</h1>
|
|
390
|
+
<button onClick={() => connect({ provider: "injected" })}>Connect Wallet</button>
|
|
391
|
+
</div>
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Authentication Providers
|
|
397
|
+
|
|
398
|
+
The SDK supports multiple authentication providers that you configure via the `providers` array:
|
|
399
|
+
|
|
400
|
+
### Available Providers
|
|
401
|
+
|
|
402
|
+
- **`"injected"`** - Phantom browser extension (no `appId` required)
|
|
403
|
+
- **`"google"`** - Google OAuth (requires `appId`)
|
|
404
|
+
- **`"apple"`** - Apple ID (requires `appId`)
|
|
405
|
+
- **`"phantom"`** - Phantom Login (requires `appId`)
|
|
406
|
+
- **`"x"`** - X/Twitter (requires `appId`)
|
|
407
|
+
- **`"tiktok"`** - TikTok (requires `appId`)
|
|
408
|
+
|
|
409
|
+
### Configuration Examples
|
|
410
|
+
|
|
411
|
+
**Browser Extension Only**
|
|
181
412
|
|
|
182
413
|
```tsx
|
|
183
414
|
<PhantomProvider
|
|
184
415
|
config={{
|
|
185
|
-
|
|
416
|
+
providers: ["injected"], // Only allow browser extension
|
|
186
417
|
addressTypes: [AddressType.solana, AddressType.ethereum],
|
|
187
418
|
}}
|
|
188
419
|
>
|
|
@@ -190,11 +421,23 @@ Uses the Phantom browser extension installed by the user.
|
|
|
190
421
|
</PhantomProvider>
|
|
191
422
|
```
|
|
192
423
|
|
|
193
|
-
|
|
424
|
+
**Multiple Authentication Methods**
|
|
194
425
|
|
|
195
|
-
|
|
426
|
+
```tsx
|
|
427
|
+
<PhantomProvider
|
|
428
|
+
config={{
|
|
429
|
+
providers: ["google", "apple", "phantom", "injected"], // Allow all methods
|
|
430
|
+
appId: "your-app-id", // Required for embedded providers
|
|
431
|
+
addressTypes: [AddressType.solana, AddressType.ethereum],
|
|
432
|
+
}}
|
|
433
|
+
>
|
|
434
|
+
<YourApp />
|
|
435
|
+
</PhantomProvider>
|
|
436
|
+
```
|
|
196
437
|
|
|
197
|
-
|
|
438
|
+
### Embedded Wallet Type
|
|
439
|
+
|
|
440
|
+
When using embedded providers (google, apple, phantom, etc.), you can specify the wallet type using `embeddedWalletType`. The default is `"user-wallet"`:
|
|
198
441
|
|
|
199
442
|
- **Uses Phantom authentication** - user logs in with existing account
|
|
200
443
|
- **Potentially funded** - brings existing wallet balance
|
|
@@ -203,16 +446,16 @@ Creates non-custodial wallets embedded in your application.
|
|
|
203
446
|
```tsx
|
|
204
447
|
<PhantomProvider
|
|
205
448
|
config={{
|
|
206
|
-
|
|
449
|
+
providers: ["google", "apple", "phantom"],
|
|
207
450
|
appId: "your-app-id",
|
|
208
451
|
addressTypes: [AddressType.solana, AddressType.ethereum],
|
|
452
|
+
embeddedWalletType: "user-wallet", // default, can be omitted
|
|
209
453
|
}}
|
|
210
454
|
>
|
|
211
455
|
<YourApp />
|
|
212
456
|
</PhantomProvider>
|
|
213
457
|
```
|
|
214
458
|
|
|
215
|
-
|
|
216
459
|
## Available Hooks
|
|
217
460
|
|
|
218
461
|
### Core Connection Hooks
|
|
@@ -225,7 +468,7 @@ Connect to wallet:
|
|
|
225
468
|
import { useConnect } from "@phantom/react-sdk";
|
|
226
469
|
|
|
227
470
|
function ConnectButton() {
|
|
228
|
-
const { connect, isConnecting, error } = useConnect();
|
|
471
|
+
const { connect, isConnecting, isLoading, error } = useConnect();
|
|
229
472
|
|
|
230
473
|
const handleConnect = async () => {
|
|
231
474
|
try {
|
|
@@ -236,6 +479,11 @@ function ConnectButton() {
|
|
|
236
479
|
}
|
|
237
480
|
};
|
|
238
481
|
|
|
482
|
+
// Wait for SDK to finish initializing before showing connect button
|
|
483
|
+
if (isLoading) {
|
|
484
|
+
return <div>Loading...</div>;
|
|
485
|
+
}
|
|
486
|
+
|
|
239
487
|
return (
|
|
240
488
|
<button onClick={handleConnect} disabled={isConnecting}>
|
|
241
489
|
{isConnecting ? "Connecting..." : "Connect Wallet"}
|
|
@@ -338,11 +586,7 @@ function PhantomLoginButton() {
|
|
|
338
586
|
return null; // Don't show button if Phantom Login is not available
|
|
339
587
|
}
|
|
340
588
|
|
|
341
|
-
return (
|
|
342
|
-
<button onClick={() => connect({ provider: "phantom" })}>
|
|
343
|
-
Login with Phantom
|
|
344
|
-
</button>
|
|
345
|
-
);
|
|
589
|
+
return <button onClick={() => connect({ provider: "phantom" })}>Login with Phantom</button>;
|
|
346
590
|
}
|
|
347
591
|
```
|
|
348
592
|
|
|
@@ -515,18 +759,18 @@ function EthereumOperations() {
|
|
|
515
759
|
|
|
516
760
|
**Supported EVM Networks:**
|
|
517
761
|
|
|
518
|
-
| Network
|
|
519
|
-
|
|
520
|
-
| Ethereum Mainnet | `1`
|
|
762
|
+
| Network | Chain ID | Usage |
|
|
763
|
+
| ---------------- | ---------- | -------------------------------- |
|
|
764
|
+
| Ethereum Mainnet | `1` | `ethereum.switchChain(1)` |
|
|
521
765
|
| Ethereum Sepolia | `11155111` | `ethereum.switchChain(11155111)` |
|
|
522
|
-
| Polygon Mainnet
|
|
523
|
-
| Polygon Amoy
|
|
524
|
-
| Base Mainnet
|
|
525
|
-
| Base Sepolia
|
|
526
|
-
| Arbitrum One
|
|
527
|
-
| Arbitrum Sepolia | `421614`
|
|
528
|
-
| Monad Mainnet
|
|
529
|
-
| Monad Testnet
|
|
766
|
+
| Polygon Mainnet | `137` | `ethereum.switchChain(137)` |
|
|
767
|
+
| Polygon Amoy | `80002` | `ethereum.switchChain(80002)` |
|
|
768
|
+
| Base Mainnet | `8453` | `ethereum.switchChain(8453)` |
|
|
769
|
+
| Base Sepolia | `84532` | `ethereum.switchChain(84532)` |
|
|
770
|
+
| Arbitrum One | `42161` | `ethereum.switchChain(42161)` |
|
|
771
|
+
| Arbitrum Sepolia | `421614` | `ethereum.switchChain(421614)` |
|
|
772
|
+
| Monad Mainnet | `143` | `ethereum.switchChain(143)` |
|
|
773
|
+
| Monad Testnet | `10143` | `ethereum.switchChain(10143)` |
|
|
530
774
|
|
|
531
775
|
### Auto-Confirm Hook (Injected Provider Only)
|
|
532
776
|
|
|
@@ -789,37 +1033,44 @@ function EthereumExample() {
|
|
|
789
1033
|
|
|
790
1034
|
Quick reference of all available hooks:
|
|
791
1035
|
|
|
792
|
-
| Hook
|
|
793
|
-
|
|
|
794
|
-
| `useConnect`
|
|
795
|
-
| `
|
|
796
|
-
| `
|
|
797
|
-
| `
|
|
798
|
-
| `
|
|
799
|
-
| `
|
|
800
|
-
| `
|
|
801
|
-
| `
|
|
802
|
-
| `
|
|
1036
|
+
| Hook | Purpose | Returns |
|
|
1037
|
+
| ---------------------------- | --------------------------------------- | --------------------------------------------------- |
|
|
1038
|
+
| `useConnect` | Connect to wallet | `{ connect, isConnecting, error }` |
|
|
1039
|
+
| `useModal` | Control connection modal | `{ open, close, isOpened }` |
|
|
1040
|
+
| `useAccounts` | Get wallet addresses | `WalletAddress[]` or `null` |
|
|
1041
|
+
| `useIsExtensionInstalled` | Check extension status | `{ isLoading, isInstalled }` |
|
|
1042
|
+
| `useIsPhantomLoginAvailable` | Check Phantom Login availability | `{ isLoading, isAvailable }` |
|
|
1043
|
+
| `useDisconnect` | Disconnect from wallet | `{ disconnect, isDisconnecting }` |
|
|
1044
|
+
| `useAutoConfirm` | Auto-confirm management (injected only) | `{ enable, disable, status, supportedChains, ... }` |
|
|
1045
|
+
| `useSolana` | Solana chain operations | `{ signMessage, signAndSendTransaction, ... }` |
|
|
1046
|
+
| `useEthereum` | Ethereum chain operations | `{ signPersonalMessage, sendTransaction, ... }` |
|
|
1047
|
+
| `useTheme` | Access current theme | `CompletePhantomTheme` |
|
|
1048
|
+
| `usePhantom` | Get provider context | `{ isConnected, isReady }` |
|
|
803
1049
|
|
|
804
1050
|
## Configuration Reference
|
|
805
1051
|
|
|
806
1052
|
```typescript
|
|
807
1053
|
interface PhantomSDKConfig {
|
|
808
|
-
|
|
1054
|
+
// List of allowed authentication providers (REQUIRED)
|
|
1055
|
+
providers: AuthProviderType[]; // e.g., ["google", "apple", "phantom", "injected"]
|
|
1056
|
+
|
|
809
1057
|
addressTypes?: [AddressType, ...AddressType[]]; // Networks to enable (e.g., [AddressType.solana])
|
|
810
1058
|
|
|
811
|
-
// Required
|
|
812
|
-
appId
|
|
813
|
-
|
|
1059
|
+
// Required when using embedded providers (google, apple, phantom, x, tiktok)
|
|
1060
|
+
appId?: string; // Your app ID from phantom.com/portal
|
|
1061
|
+
|
|
814
1062
|
// Optional configuration
|
|
815
1063
|
apiBaseUrl?: string; // Phantom API base URL (optional, has default)
|
|
816
1064
|
authOptions?: {
|
|
817
1065
|
authUrl?: string; // Custom auth URL (optional, defaults to "https://connect.phantom.app/login")
|
|
818
1066
|
redirectUrl?: string; // Custom redirect URL after authentication (optional)
|
|
819
1067
|
};
|
|
820
|
-
embeddedWalletType?: "user-wallet"; // Wallet type (optional, defaults to "user-wallet"
|
|
821
|
-
autoConnect?: boolean; // Auto-connect to existing session
|
|
1068
|
+
embeddedWalletType?: "user-wallet"; // Wallet type (optional, defaults to "user-wallet")
|
|
1069
|
+
autoConnect?: boolean; // Auto-connect to existing session (default: true when embedded providers used)
|
|
822
1070
|
}
|
|
1071
|
+
|
|
1072
|
+
// Valid provider types
|
|
1073
|
+
type AuthProviderType = "google" | "apple" | "phantom" | "x" | "tiktok" | "injected";
|
|
823
1074
|
```
|
|
824
1075
|
|
|
825
1076
|
## Debug Configuration
|
|
@@ -849,8 +1100,9 @@ function App() {
|
|
|
849
1100
|
|
|
850
1101
|
// SDK configuration - static, won't change when debug settings change
|
|
851
1102
|
const config: PhantomSDKConfig = {
|
|
852
|
-
|
|
1103
|
+
providers: ["google", "apple", "phantom"],
|
|
853
1104
|
appId: "your-app-id",
|
|
1105
|
+
addressTypes: [AddressType.solana, AddressType.ethereum],
|
|
854
1106
|
// ... other config
|
|
855
1107
|
};
|
|
856
1108
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,44 +1,50 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import * as _phantom_browser_sdk from '@phantom/browser-sdk';
|
|
4
|
+
import { BrowserSDKConfig, DebugConfig, AuthOptions, BrowserSDK, WalletAddress, ConnectResult, AuthProviderType, AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult, AddressType } from '@phantom/browser-sdk';
|
|
5
|
+
export { AddressType, AuthOptions, AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult, ConnectErrorEventData, ConnectEventData, ConnectStartEventData, DebugLevel, DebugMessage, DisconnectEventData, EmbeddedProviderEvent, EmbeddedProviderEventMap, EventCallback, NetworkId, SignedTransaction, WalletAddress, debug, isMobileDevice } from '@phantom/browser-sdk';
|
|
6
|
+
import { PhantomTheme, CompletePhantomTheme } from '@phantom/wallet-sdk-ui';
|
|
7
|
+
export { CompletePhantomTheme, HexColor, PhantomTheme, darkTheme, lightTheme, mergeTheme, useTheme } from '@phantom/wallet-sdk-ui';
|
|
6
8
|
import { ISolanaChain, IEthereumChain } from '@phantom/chain-interfaces';
|
|
7
9
|
export { EthTransactionRequest, IEthereumChain, ISolanaChain } from '@phantom/chain-interfaces';
|
|
10
|
+
import * as _phantom_embedded_provider_core from '@phantom/embedded-provider-core';
|
|
8
11
|
|
|
9
12
|
type PhantomSDKConfig = BrowserSDKConfig;
|
|
10
13
|
interface PhantomDebugConfig extends DebugConfig {
|
|
11
14
|
}
|
|
12
15
|
interface ConnectOptions {
|
|
13
|
-
providerType?: "injected" | "embedded";
|
|
14
16
|
embeddedWalletType?: "app-wallet" | "user-wallet";
|
|
15
17
|
authOptions?: AuthOptions;
|
|
16
18
|
}
|
|
19
|
+
interface PhantomProviderProps {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
config: PhantomSDKConfig;
|
|
22
|
+
debugConfig?: PhantomDebugConfig;
|
|
23
|
+
theme?: Partial<PhantomTheme>;
|
|
24
|
+
appIcon?: string;
|
|
25
|
+
appName?: string;
|
|
26
|
+
}
|
|
27
|
+
declare function PhantomProvider({ children, config, debugConfig, theme, appIcon, appName }: PhantomProviderProps): react_jsx_runtime.JSX.Element;
|
|
28
|
+
|
|
17
29
|
interface PhantomContextValue {
|
|
18
30
|
sdk: BrowserSDK | null;
|
|
19
31
|
isConnected: boolean;
|
|
20
32
|
isConnecting: boolean;
|
|
33
|
+
isLoading: boolean;
|
|
21
34
|
connectError: Error | null;
|
|
22
35
|
addresses: WalletAddress[];
|
|
23
|
-
currentProviderType: "injected" | "embedded" | null;
|
|
24
|
-
isPhantomAvailable: boolean;
|
|
25
36
|
isClient: boolean;
|
|
26
37
|
user: ConnectResult | null;
|
|
38
|
+
theme: CompletePhantomTheme;
|
|
39
|
+
allowedProviders: AuthProviderType[];
|
|
27
40
|
}
|
|
28
|
-
interface PhantomProviderProps {
|
|
29
|
-
children: ReactNode;
|
|
30
|
-
config: PhantomSDKConfig;
|
|
31
|
-
debugConfig?: PhantomDebugConfig;
|
|
32
|
-
}
|
|
33
|
-
declare function PhantomProvider({ children, config, debugConfig }: PhantomProviderProps): react_jsx_runtime.JSX.Element;
|
|
34
41
|
declare function usePhantom(): PhantomContextValue;
|
|
35
42
|
|
|
36
43
|
declare function useConnect(): {
|
|
37
|
-
connect: (options: AuthOptions) => Promise<
|
|
44
|
+
connect: (options: AuthOptions) => Promise<_phantom_browser_sdk.ConnectResult>;
|
|
38
45
|
isConnecting: boolean;
|
|
46
|
+
isLoading: boolean;
|
|
39
47
|
error: Error | null;
|
|
40
|
-
currentProviderType: "injected" | "embedded" | null;
|
|
41
|
-
isPhantomAvailable: boolean;
|
|
42
48
|
};
|
|
43
49
|
|
|
44
50
|
declare function useDisconnect(): {
|
|
@@ -47,6 +53,12 @@ declare function useDisconnect(): {
|
|
|
47
53
|
error: Error | null;
|
|
48
54
|
};
|
|
49
55
|
|
|
56
|
+
declare function useModal(): {
|
|
57
|
+
open: () => void;
|
|
58
|
+
close: () => void;
|
|
59
|
+
isOpened: boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
50
62
|
declare function useAccounts(): _phantom_embedded_provider_core.WalletAddress[] | null;
|
|
51
63
|
|
|
52
64
|
/**
|
|
@@ -98,6 +110,16 @@ declare function useEthereum(): {
|
|
|
98
110
|
isAvailable: boolean;
|
|
99
111
|
};
|
|
100
112
|
|
|
101
|
-
|
|
113
|
+
interface UseModalResult {
|
|
114
|
+
open: () => void;
|
|
115
|
+
close: () => void;
|
|
116
|
+
isOpened: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface ConnectButtonProps {
|
|
120
|
+
addressType?: AddressType;
|
|
121
|
+
fullWidth?: boolean;
|
|
122
|
+
}
|
|
123
|
+
declare function ConnectButton({ addressType, fullWidth }: ConnectButtonProps): react_jsx_runtime.JSX.Element;
|
|
102
124
|
|
|
103
|
-
export { ConnectOptions, PhantomDebugConfig, PhantomProvider, PhantomProviderProps, PhantomSDKConfig,
|
|
125
|
+
export { ConnectButton, ConnectButtonProps, ConnectOptions, PhantomDebugConfig, PhantomProvider, PhantomProviderProps, PhantomSDKConfig, UseModalResult, useAccounts, useAutoConfirm, useConnect, useDisconnect, useEthereum, useIsExtensionInstalled, useIsPhantomLoginAvailable, useModal, usePhantom, useSolana };
|