@getpara/solana-wallet-connectors 2.0.0-alpha.66 → 2.0.0-alpha.68
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
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
https://www.npmjs.com/package/@getpara/solana-wallet-connectors
|
|
2
|
+
|
|
3
|
+
`@getpara/solana-wallet-connectors` is a package that provides wallet connectors for Solana when using Para's React SDK Lite.
|
|
4
|
+
The package enables integration with popular Solana wallets like Phantom, Backpack, Solflare, and Glow through Para's provider system. After installation, you can configure it in your ParaProvider.
|
|
5
|
+
|
|
6
|
+
###Prerequisites
|
|
7
|
+
|
|
8
|
+
To use Para, you need an API key. This key authenticates your requests to Para services and is essential for integration.
|
|
9
|
+
|
|
10
|
+
Don't have an API key yet? Request access to the [Developer Portal](https://developer.getpara.com/) to create API keys, manage billing, teams, and more.
|
|
11
|
+
|
|
12
|
+
###Learn more
|
|
13
|
+
|
|
14
|
+
For more information on Para’s Solana wallet connector visit the [Para Docs](https://docs.getpara.com/v2/react/guides/external-wallets/solana-lite#solana-wallets-with-react-sdk-lite)
|
|
@@ -48,7 +48,7 @@ function ParaSolanaProvider({ children, config, internalConfig }) {
|
|
|
48
48
|
],
|
|
49
49
|
localStorageKey: "paraSolanaExternal",
|
|
50
50
|
autoConnect: true,
|
|
51
|
-
children: /* @__PURE__ */ jsx(SolanaExternalWalletProvider, __spreadProps(__spreadValues({}, solanaExternalWalletProviderProps), { children }))
|
|
51
|
+
children: /* @__PURE__ */ jsx(SolanaExternalWalletProvider, __spreadProps(__spreadValues({}, solanaExternalWalletProviderProps), { chain, children }))
|
|
52
52
|
}
|
|
53
53
|
) });
|
|
54
54
|
}
|
|
@@ -2,9 +2,12 @@ import { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { CreateWalletFn } from '../types/Wallet.js';
|
|
3
3
|
import { ExternalWalletContextType, ExternalWalletProviderConfig, ExternalWalletProviderConfigBase, FarcasterMiniAppManagement } from '@getpara/react-common';
|
|
4
4
|
import { TExternalHooks } from './externalHooks.js';
|
|
5
|
+
import { Chain } from '@solana-mobile/mobile-wallet-adapter-protocol';
|
|
5
6
|
export type SolanaExternalWalletContextType = ExternalWalletContextType & TExternalHooks & FarcasterMiniAppManagement;
|
|
6
7
|
export declare const SolanaExternalWalletContext: import("react").Context<SolanaExternalWalletContextType>;
|
|
7
8
|
export type SolanaExternalWalletProviderConfig = ExternalWalletProviderConfigBase;
|
|
8
9
|
type SolanaExternalWalletProviderConfigFull = ExternalWalletProviderConfig<CreateWalletFn>;
|
|
9
|
-
export declare function SolanaExternalWalletProvider({ children, wallets: walletFns, onSwitchWallet, para, walletsWithFullAuth, includeWalletVerification, connectionOnly, }: SolanaExternalWalletProviderConfigFull & PropsWithChildren
|
|
10
|
+
export declare function SolanaExternalWalletProvider({ children, wallets: walletFns, onSwitchWallet, para, walletsWithFullAuth, includeWalletVerification, connectionOnly, chain, }: SolanaExternalWalletProviderConfigFull & PropsWithChildren & {
|
|
11
|
+
chain: Chain;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
13
|
export {};
|
|
@@ -58,18 +58,20 @@ function SolanaExternalWalletProvider({
|
|
|
58
58
|
para,
|
|
59
59
|
walletsWithFullAuth,
|
|
60
60
|
includeWalletVerification,
|
|
61
|
-
connectionOnly
|
|
61
|
+
connectionOnly,
|
|
62
|
+
chain
|
|
62
63
|
}) {
|
|
63
64
|
const {
|
|
64
65
|
wallets: adapters,
|
|
65
66
|
select: selectWallet,
|
|
66
67
|
disconnect,
|
|
68
|
+
disconnecting,
|
|
67
69
|
publicKey: solanaAddress,
|
|
68
70
|
wallet,
|
|
69
71
|
connecting,
|
|
70
72
|
signMessage: solanaSignMessage
|
|
71
73
|
} = useWallet();
|
|
72
|
-
const
|
|
74
|
+
const disconnectTypeRef = useRef();
|
|
73
75
|
const solanaSignMessageRef = useRef(solanaSignMessage);
|
|
74
76
|
const solanaAddressRef = useRef(solanaAddress);
|
|
75
77
|
const verificationMessage = useRef();
|
|
@@ -95,7 +97,9 @@ function SolanaExternalWalletProvider({
|
|
|
95
97
|
withFullParaAuth: walletsWithFullAuth === "ALL" || (walletsWithFullAuth == null ? void 0 : walletsWithFullAuth.includes((_b = (_a = getWallet(providerName != null ? providerName : "")) == null ? void 0 : _a.id.toUpperCase()) != null ? _b : "")),
|
|
96
98
|
withVerification: includeWalletVerification,
|
|
97
99
|
isConnectionOnly: connectionOnly
|
|
98
|
-
}
|
|
100
|
+
},
|
|
101
|
+
uri: window == null ? void 0 : window.location.origin,
|
|
102
|
+
chainId: chain
|
|
99
103
|
});
|
|
100
104
|
} catch (err) {
|
|
101
105
|
yield reset();
|
|
@@ -127,7 +131,7 @@ function SolanaExternalWalletProvider({
|
|
|
127
131
|
useEffect(() => {
|
|
128
132
|
var _a;
|
|
129
133
|
const storedExternalWallet = para.externalWallets[(_a = solanaAddress == null ? void 0 : solanaAddress.toString()) != null ? _a : ""];
|
|
130
|
-
if (!!solanaAddress && !storedExternalWallet && !
|
|
134
|
+
if (!!solanaAddress && !storedExternalWallet && !disconnectTypeRef.current) {
|
|
131
135
|
reset();
|
|
132
136
|
}
|
|
133
137
|
}, []);
|
|
@@ -139,7 +143,7 @@ function SolanaExternalWalletProvider({
|
|
|
139
143
|
}, [solanaAddress]);
|
|
140
144
|
useEffect(() => {
|
|
141
145
|
const storedExternalWallet = Object.values(para.externalWallets || {})[0];
|
|
142
|
-
if (!connecting && (!wallet || (wallet == null ? void 0 : wallet.adapter.connected)) && (storedExternalWallet == null ? void 0 : storedExternalWallet.type) === "SOLANA" && (storedExternalWallet == null ? void 0 : storedExternalWallet.address) !== (solanaAddress == null ? void 0 : solanaAddress.toString()) && !
|
|
146
|
+
if (!connecting && (!wallet || (wallet == null ? void 0 : wallet.adapter.connected)) && (storedExternalWallet == null ? void 0 : storedExternalWallet.type) === "SOLANA" && (storedExternalWallet == null ? void 0 : storedExternalWallet.address) !== (solanaAddress == null ? void 0 : solanaAddress.toString()) && !disconnectTypeRef.current) {
|
|
143
147
|
switchWallet(solanaAddress == null ? void 0 : solanaAddress.toString());
|
|
144
148
|
}
|
|
145
149
|
}, [solanaAddress, connecting, wallet]);
|
|
@@ -177,6 +181,11 @@ function SolanaExternalWalletProvider({
|
|
|
177
181
|
if (!adapter) {
|
|
178
182
|
throw new Error("Adapter not found.");
|
|
179
183
|
}
|
|
184
|
+
const wallet2 = getWallet(adapter.name);
|
|
185
|
+
if (wallet2.getQrUri) {
|
|
186
|
+
const qrUri = yield wallet2.getQrUri();
|
|
187
|
+
window.dispatchEvent(new CustomEvent("PARA_WALLETCONNECT_URI_READY", { detail: qrUri }));
|
|
188
|
+
}
|
|
180
189
|
selectWallet(adapter.name);
|
|
181
190
|
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
182
191
|
let address;
|
|
@@ -237,7 +246,8 @@ function SolanaExternalWalletProvider({
|
|
|
237
246
|
switch (err.message) {
|
|
238
247
|
case "User aborted.":
|
|
239
248
|
case "Approval Denied":
|
|
240
|
-
case "You canceled this request.":
|
|
249
|
+
case "You canceled this request.":
|
|
250
|
+
case "Disconnected before connect event": {
|
|
241
251
|
error = "Connection request rejected";
|
|
242
252
|
break;
|
|
243
253
|
}
|
|
@@ -254,7 +264,7 @@ function SolanaExternalWalletProvider({
|
|
|
254
264
|
var _a, _b;
|
|
255
265
|
const wallet2 = wallets.find((w) => w.id === providerId);
|
|
256
266
|
const adapter = getAdapter((_a = wallet2.name) != null ? _a : "");
|
|
257
|
-
|
|
267
|
+
disconnectTypeRef.current = "ACCOUNT_LINKING";
|
|
258
268
|
try {
|
|
259
269
|
const address = yield connectBase(adapter);
|
|
260
270
|
const externalWallet = {
|
|
@@ -270,7 +280,7 @@ function SolanaExternalWalletProvider({
|
|
|
270
280
|
throw new Error((_b = e == null ? void 0 : e.message) != null ? _b : e);
|
|
271
281
|
}
|
|
272
282
|
});
|
|
273
|
-
const disconnectBase = (
|
|
283
|
+
const disconnectBase = (_0, ..._1) => __async(this, [_0, ..._1], function* (providerId, { disconnectType } = {}) {
|
|
274
284
|
var _a;
|
|
275
285
|
const wallet2 = wallets.find((w) => w.id === providerId);
|
|
276
286
|
if (!wallet2) {
|
|
@@ -280,13 +290,15 @@ function SolanaExternalWalletProvider({
|
|
|
280
290
|
if (!(adapter == null ? void 0 : adapter.connected)) {
|
|
281
291
|
return;
|
|
282
292
|
}
|
|
283
|
-
|
|
293
|
+
if (disconnectType) {
|
|
294
|
+
disconnectTypeRef.current = disconnectType;
|
|
295
|
+
}
|
|
284
296
|
try {
|
|
285
297
|
yield adapter.disconnect();
|
|
286
298
|
} catch (e) {
|
|
287
299
|
console.error("Error disconnecting Solana wallet:", e);
|
|
288
300
|
} finally {
|
|
289
|
-
|
|
301
|
+
disconnectTypeRef.current = void 0;
|
|
290
302
|
}
|
|
291
303
|
});
|
|
292
304
|
const getAdapter = (name) => {
|
|
@@ -374,6 +386,7 @@ function SolanaExternalWalletProvider({
|
|
|
374
386
|
() => __spreadValues({
|
|
375
387
|
wallets: walletsWithInjected,
|
|
376
388
|
disconnect,
|
|
389
|
+
disconnectStatus: disconnecting ? "pending" : "idle",
|
|
377
390
|
signMessage,
|
|
378
391
|
signVerificationMessage,
|
|
379
392
|
requestInfo,
|
|
@@ -383,6 +396,7 @@ function SolanaExternalWalletProvider({
|
|
|
383
396
|
[
|
|
384
397
|
walletsWithInjected,
|
|
385
398
|
disconnect,
|
|
399
|
+
disconnecting,
|
|
386
400
|
signMessage,
|
|
387
401
|
signVerificationMessage,
|
|
388
402
|
requestInfo,
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/solana-wallet-connectors",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.68",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/react-common": "2.0.0-alpha.
|
|
6
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
5
|
+
"@getpara/react-common": "2.0.0-alpha.68",
|
|
6
|
+
"@getpara/web-sdk": "2.0.0-alpha.68",
|
|
7
7
|
"bs58": "6.0.0"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dist",
|
|
24
24
|
"package.json"
|
|
25
25
|
],
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "98955203281606201609bb4674f5984acb63d3bf",
|
|
27
27
|
"main": "dist/index.js",
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@farcaster/mini-app-solana": "^1.0.0",
|