@phantom/react-sdk 1.0.0-beta.13 → 1.0.0-beta.15
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 +24 -11
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -5
- package/dist/index.mjs +1 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -136,26 +136,39 @@ function WalletExample() {
|
|
|
136
136
|
|
|
137
137
|
### Connection Options
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
The `connect()` method automatically switches between providers based on the authentication method you specify:
|
|
140
140
|
|
|
141
141
|
```tsx
|
|
142
142
|
const { connect } = useConnect();
|
|
143
143
|
|
|
144
|
-
//
|
|
144
|
+
// Connect with current provider (no switching)
|
|
145
145
|
await connect();
|
|
146
146
|
|
|
147
|
-
//
|
|
147
|
+
// Connect with injected provider (Phantom extension)
|
|
148
|
+
// Automatically switches to injected provider if not already using it
|
|
148
149
|
await connect({
|
|
149
|
-
|
|
150
|
-
provider: "google",
|
|
151
|
-
},
|
|
150
|
+
provider: "injected",
|
|
152
151
|
});
|
|
153
152
|
|
|
154
|
-
//
|
|
153
|
+
// Connect with Google authentication (embedded provider)
|
|
154
|
+
// Automatically switches to embedded provider if not already using it
|
|
155
155
|
await connect({
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
provider: "google",
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Connect with Apple authentication (embedded provider)
|
|
160
|
+
// Automatically switches to embedded provider if not already using it
|
|
161
|
+
await connect({
|
|
162
|
+
provider: "apple",
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
// Connect with Phantom authentication (embedded provider)
|
|
168
|
+
// Uses Phantom extension or mobile app for authentication
|
|
169
|
+
// Automatically switches to embedded provider if not already using it
|
|
170
|
+
await connect({
|
|
171
|
+
provider: "phantom",
|
|
159
172
|
});
|
|
160
173
|
```
|
|
161
174
|
|
|
@@ -215,7 +228,7 @@ function ConnectButton() {
|
|
|
215
228
|
|
|
216
229
|
const handleConnect = async () => {
|
|
217
230
|
try {
|
|
218
|
-
const {
|
|
231
|
+
const { addresses } = await connect();
|
|
219
232
|
console.log("Connected addresses:", addresses);
|
|
220
233
|
} catch (err) {
|
|
221
234
|
console.error("Failed to connect:", err);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -59,7 +59,6 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
59
59
|
const [isConnecting, setIsConnecting] = (0, import_react.useState)(false);
|
|
60
60
|
const [connectError, setConnectError] = (0, import_react.useState)(null);
|
|
61
61
|
const [addresses, setAddresses] = (0, import_react.useState)([]);
|
|
62
|
-
const [walletId, setWalletId] = (0, import_react.useState)(null);
|
|
63
62
|
const [currentProviderType, setCurrentProviderType] = (0, import_react.useState)(
|
|
64
63
|
memoizedConfig.providerType || null
|
|
65
64
|
);
|
|
@@ -88,7 +87,6 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
88
87
|
setCurrentProviderType(providerInfo?.type || null);
|
|
89
88
|
const addrs = await sdk.getAddresses();
|
|
90
89
|
setAddresses(addrs);
|
|
91
|
-
setWalletId(sdk.getWalletId());
|
|
92
90
|
} catch (err) {
|
|
93
91
|
console.error("Error connecting:", err);
|
|
94
92
|
try {
|
|
@@ -108,7 +106,6 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
108
106
|
setIsConnecting(false);
|
|
109
107
|
setConnectError(null);
|
|
110
108
|
setAddresses([]);
|
|
111
|
-
setWalletId(null);
|
|
112
109
|
};
|
|
113
110
|
sdk.on("connect_start", handleConnectStart);
|
|
114
111
|
sdk.on("connect", handleConnect);
|
|
@@ -151,12 +148,11 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
151
148
|
isConnecting,
|
|
152
149
|
connectError,
|
|
153
150
|
addresses,
|
|
154
|
-
walletId,
|
|
155
151
|
currentProviderType,
|
|
156
152
|
isPhantomAvailable,
|
|
157
153
|
isClient
|
|
158
154
|
}),
|
|
159
|
-
[sdk, isConnected, isConnecting, connectError, addresses,
|
|
155
|
+
[sdk, isConnected, isConnecting, connectError, addresses, currentProviderType, isPhantomAvailable, isClient]
|
|
160
156
|
);
|
|
161
157
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PhantomContext.Provider, { value, children });
|
|
162
158
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,6 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
11
11
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
12
12
|
const [connectError, setConnectError] = useState(null);
|
|
13
13
|
const [addresses, setAddresses] = useState([]);
|
|
14
|
-
const [walletId, setWalletId] = useState(null);
|
|
15
14
|
const [currentProviderType, setCurrentProviderType] = useState(
|
|
16
15
|
memoizedConfig.providerType || null
|
|
17
16
|
);
|
|
@@ -40,7 +39,6 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
40
39
|
setCurrentProviderType(providerInfo?.type || null);
|
|
41
40
|
const addrs = await sdk.getAddresses();
|
|
42
41
|
setAddresses(addrs);
|
|
43
|
-
setWalletId(sdk.getWalletId());
|
|
44
42
|
} catch (err) {
|
|
45
43
|
console.error("Error connecting:", err);
|
|
46
44
|
try {
|
|
@@ -60,7 +58,6 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
60
58
|
setIsConnecting(false);
|
|
61
59
|
setConnectError(null);
|
|
62
60
|
setAddresses([]);
|
|
63
|
-
setWalletId(null);
|
|
64
61
|
};
|
|
65
62
|
sdk.on("connect_start", handleConnectStart);
|
|
66
63
|
sdk.on("connect", handleConnect);
|
|
@@ -103,12 +100,11 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
103
100
|
isConnecting,
|
|
104
101
|
connectError,
|
|
105
102
|
addresses,
|
|
106
|
-
walletId,
|
|
107
103
|
currentProviderType,
|
|
108
104
|
isPhantomAvailable,
|
|
109
105
|
isClient
|
|
110
106
|
}),
|
|
111
|
-
[sdk, isConnected, isConnecting, connectError, addresses,
|
|
107
|
+
[sdk, isConnected, isConnecting, connectError, addresses, currentProviderType, isPhantomAvailable, isClient]
|
|
112
108
|
);
|
|
113
109
|
return /* @__PURE__ */ jsx(PhantomContext.Provider, { value, children });
|
|
114
110
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/react-sdk",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.15",
|
|
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": "^1.0.0-beta.
|
|
29
|
+
"@phantom/browser-sdk": "^1.0.0-beta.15",
|
|
30
30
|
"@phantom/chain-interfaces": "^1.0.0-beta.7",
|
|
31
31
|
"@phantom/constants": "^1.0.0-beta.7"
|
|
32
32
|
},
|