@getpara/react-sdk 2.0.0-alpha.16 → 2.0.0-alpha.17

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.
@@ -31,7 +31,7 @@ const Account = ({ onClose }) => {
31
31
  const { data: balance, isLoading: isBalanceLoading } = useWalletBalance();
32
32
  const [isDisconnecting, setIsDisconnecting] = useState(false);
33
33
  const isGuestMode = (account == null ? void 0 : account.isConnected) && account.isGuestMode;
34
- const cantBuyAndWithdraw = para.externalWalletConnectionType === "CONNECTION_ONLY" && !para.userId;
34
+ const cantBuyAndWithdraw = (para.externalWalletConnectionType === "CONNECTION_ONLY" || para.externalWalletConnectionType === "VERIFICATION") && !para.userId;
35
35
  const isOnRampLoaded = !!onRampConfig;
36
36
  const handleBuyClick = () => {
37
37
  if (isGuestMode) {
@@ -34,7 +34,7 @@ const LoginDoneStep = ({ onClose }) => {
34
34
  return /* @__PURE__ */ jsxs(StepContainer, { children: [
35
35
  /* @__PURE__ */ jsx(HeroIcon, { icon: "checkCircleFilled" }),
36
36
  /* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: "Connected" }),
37
- !hideWallets && /* @__PURE__ */ jsx(WalletCards, { children: para.externalWalletConnectionType === "CONNECTION_ONLY" ? /* @__PURE__ */ jsx(ExternalWalletCard, { address: (_b = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.address) != null ? _b : "" }) : para.currentWalletIdsArray.map(([id, type]) => {
37
+ !hideWallets && /* @__PURE__ */ jsx(WalletCards, { children: para.externalWalletConnectionType === "CONNECTION_ONLY" || para.externalWalletConnectionType === "VERIFICATION" ? /* @__PURE__ */ jsx(ExternalWalletCard, { address: (_b = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.address) != null ? _b : "" }) : para.currentWalletIdsArray.map(([id, type]) => {
38
38
  return /* @__PURE__ */ jsx(WalletCard, { id, type }, `${id}-${type}`);
39
39
  }) })
40
40
  ] });
@@ -119,7 +119,7 @@ const BODY_MOTION_VARIANTS = {
119
119
  const BODY_TRANSITION = {
120
120
  duration: 0.2
121
121
  };
122
- const SDK_VERSION = "2.0.0-alpha.16";
122
+ const SDK_VERSION = "2.0.0-alpha.17";
123
123
  export {
124
124
  BODY_MOTION_VARIANTS,
125
125
  BODY_TRANSITION,
@@ -23,6 +23,10 @@ const ParaProvider = forwardRef(({ children, paraClientConfig, callbacks, config
23
23
  const externalWallets = useStore((state) => state.externalWallets);
24
24
  const setExternalWalletsWithFullAuth = useStore((state) => state.setExternalWalletsWithFullAuth);
25
25
  const externalWalletsWithFullAuth = useStore((state) => state.externalWalletsWithFullAuth);
26
+ const setIncludeWalletVerification = useStore((state) => state.setIncludeWalletVerification);
27
+ const includeWalletVerification = useStore((state) => state.includeWalletVerification);
28
+ const setConnectionOnly = useStore((state) => state.setConnectionOnly);
29
+ const connectionOnly = useStore((state) => state.connectionOnly);
26
30
  const setModalConfig = useStore((state) => state.setModalConfig);
27
31
  const modalConfig = useStore((state) => state.modalConfig);
28
32
  const setAppName = useStore((state) => state.setAppName);
@@ -45,6 +49,23 @@ const ParaProvider = forwardRef(({ children, paraClientConfig, callbacks, config
45
49
  useEffect(() => {
46
50
  if (modalConfig !== paraModalConfig) setModalConfig(paraModalConfig);
47
51
  }, [paraModalConfig]);
52
+ useEffect(() => {
53
+ var _a;
54
+ if (connectionOnly !== (externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly)) {
55
+ setConnectionOnly((_a = externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) != null ? _a : false);
56
+ }
57
+ }, [externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly]);
58
+ useEffect(() => {
59
+ var _a, _b;
60
+ if (includeWalletVerification !== (externalWalletConfig == null ? void 0 : externalWalletConfig.includeWalletVerification)) {
61
+ if ((externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) || (isConfigType(paraClientConfig) ? (_a = paraClientConfig.opts) == null ? void 0 : _a.externalWalletConnectionOnly : paraClientConfig.externalWalletConnectionOnly)) {
62
+ console.warn("includeWalletVerification has no effect when using connection only external wallets");
63
+ setIncludeWalletVerification(false);
64
+ } else {
65
+ setIncludeWalletVerification((_b = externalWalletConfig == null ? void 0 : externalWalletConfig.includeWalletVerification) != null ? _b : false);
66
+ }
67
+ }
68
+ }, [externalWalletConfig == null ? void 0 : externalWalletConfig.includeWalletVerification]);
48
69
  useEffect(() => {
49
70
  var _a;
50
71
  if (externalWallets !== (externalWalletConfig == null ? void 0 : externalWalletConfig.wallets)) {
@@ -54,8 +75,8 @@ const ParaProvider = forwardRef(({ children, paraClientConfig, callbacks, config
54
75
  useEffect(() => {
55
76
  var _a, _b;
56
77
  if (externalWalletsWithFullAuth !== (externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets)) {
57
- if (isConfigType(paraClientConfig) ? (_a = paraClientConfig.opts) == null ? void 0 : _a.externalWalletConnectionOnly : paraClientConfig.externalWalletConnectionOnly) {
58
- console.warn("createLinkedEmbeddedForExternalWallets has no effect when using externalWalletConnectionOnly");
78
+ if ((externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) || (isConfigType(paraClientConfig) ? (_a = paraClientConfig.opts) == null ? void 0 : _a.externalWalletConnectionOnly : paraClientConfig.externalWalletConnectionOnly)) {
79
+ console.warn("createLinkedEmbeddedForExternalWallets has no effect when using connection only external wallets");
59
80
  setExternalWalletsWithFullAuth([]);
60
81
  } else {
61
82
  setExternalWalletsWithFullAuth(
@@ -17,11 +17,20 @@ const CosmosWalletWrapper = ({
17
17
  const externalWalletsWithFullAuth = useStore((state) => state.externalWalletsWithFullAuth);
18
18
  const wallets = useStore((state) => state.externalWallets);
19
19
  const isUsing = wallets.some((w) => w in CosmosWallet);
20
+ const connectionOnly = useStore((state) => state.connectionOnly);
21
+ const includeWalletVerification = useStore((state) => state.includeWalletVerification);
20
22
  return /* @__PURE__ */ jsx(
21
23
  CosmosExternalWalletProvider,
22
24
  {
23
25
  config: cosmosConnectorConfig,
24
- internalConfig: { onSwitchWallet, para, walletsWithFullAuth: externalWalletsWithFullAuth, connectedWallet: wallet },
26
+ internalConfig: {
27
+ onSwitchWallet,
28
+ para,
29
+ walletsWithFullAuth: externalWalletsWithFullAuth,
30
+ connectedWallet: wallet,
31
+ connectionOnly,
32
+ includeWalletVerification
33
+ },
25
34
  grazProviderProps,
26
35
  isUsing,
27
36
  wallets,
@@ -16,12 +16,21 @@ const EvmWalletWrapper = ({
16
16
  const { data: wallet } = useWallet();
17
17
  const externalWalletsWithFullAuth = useStore((state) => state.externalWalletsWithFullAuth);
18
18
  const wallets = useStore((state) => state.externalWallets);
19
+ const connectionOnly = useStore((state) => state.connectionOnly);
20
+ const includeWalletVerification = useStore((state) => state.includeWalletVerification);
19
21
  const isUsing = wallets.some((w) => w in EvmWallet);
20
22
  return /* @__PURE__ */ jsx(
21
23
  EvmExternalWalletProvider,
22
24
  {
23
25
  config: evmProviderConfig,
24
- internalConfig: { onSwitchWallet, para, walletsWithFullAuth: externalWalletsWithFullAuth, connectedWallet: wallet },
26
+ internalConfig: {
27
+ onSwitchWallet,
28
+ para,
29
+ walletsWithFullAuth: externalWalletsWithFullAuth,
30
+ connectedWallet: wallet,
31
+ connectionOnly,
32
+ includeWalletVerification
33
+ },
25
34
  wagmiProviderProps,
26
35
  isUsing,
27
36
  wallets,
@@ -13,6 +13,8 @@ const SolanaWalletWrapper = ({
13
13
  const externalWalletsWithFullAuth = useStore((state) => state.externalWalletsWithFullAuth);
14
14
  const para = useInternalClient();
15
15
  const wallets = useStore((state) => state.externalWallets);
16
+ const connectionOnly = useStore((state) => state.connectionOnly);
17
+ const includeWalletVerification = useStore((state) => state.includeWalletVerification);
16
18
  const isUsing = wallets.some((w) => w in SolanaWallet);
17
19
  if (!solanaProviderConfig) {
18
20
  if (isUsing) {
@@ -24,7 +26,13 @@ const SolanaWalletWrapper = ({
24
26
  SolanaExternalWalletProvider,
25
27
  {
26
28
  config: solanaProviderConfig,
27
- internalConfig: { onSwitchWallet, para, walletsWithFullAuth: externalWalletsWithFullAuth },
29
+ internalConfig: {
30
+ onSwitchWallet,
31
+ para,
32
+ walletsWithFullAuth: externalWalletsWithFullAuth,
33
+ connectionOnly,
34
+ includeWalletVerification
35
+ },
28
36
  isUsing,
29
37
  wallets,
30
38
  children
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import {
3
- __async
3
+ __async,
4
+ __spreadValues
4
5
  } from "../../chunk-MMUBH76A.js";
5
6
  import { jsx } from "react/jsx-runtime";
6
7
  import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
@@ -38,6 +39,8 @@ function ExternalWalletProvider({ children }) {
38
39
  const solanaContext = useStore((state) => state.solanaContext);
39
40
  const externalWallets = useStore((state) => state.externalWallets);
40
41
  const externalWalletsWithFullAuth = useStore((state) => state.externalWalletsWithFullAuth);
42
+ const includeWalletVerification = useStore((state) => state.includeWalletVerification);
43
+ const connectionOnly = useStore((state) => state.connectionOnly);
41
44
  const {
42
45
  wallets: evmWallets,
43
46
  disconnect: evmDisconnect,
@@ -177,23 +180,34 @@ function ExternalWalletProvider({ children }) {
177
180
  [evmSwitchChain, cosmosSwitchChain]
178
181
  );
179
182
  const verifyWalletSignature = useCallback(() => __async(this, null, function* () {
180
- var _a;
181
183
  setExternalWalletError();
182
184
  setIsExternalWalletVerifying(true);
183
- const walletType = (_a = Object.values(para.externalWallets)[0]) == null ? void 0 : _a.type;
185
+ const wallet2 = Object.values(para.externalWallets)[0];
186
+ const walletType = wallet2 == null ? void 0 : wallet2.type;
184
187
  let verifyExternalWalletParams;
188
+ const withVerification = includeWalletVerification;
189
+ const isConnectionOnly = connectionOnly;
190
+ const withFullParaAuth = (wallet2 == null ? void 0 : wallet2.name) ? externalWalletsWithFullAuth.includes(wallet2.name.toUpperCase()) : false;
191
+ const defaultWalletInfo = {
192
+ withVerification,
193
+ isConnectionOnly,
194
+ withFullParaAuth,
195
+ provider: wallet2.name,
196
+ isExternal: true
197
+ };
185
198
  switch (walletType) {
186
199
  case "COSMOS":
187
200
  {
188
- const { address, signature, error, cosmosPublicKeyHex, cosmosSigner } = yield cosmosSignVerificationMessage();
201
+ const { address, signature, error, cosmosPublicKeyHex, cosmosSigner, addressBech32 } = yield cosmosSignVerificationMessage();
189
202
  if (error) {
190
203
  setExternalWalletError([error]);
191
204
  } else if (signature && address) {
192
205
  verifyExternalWalletParams = {
193
- externalWallet: {
206
+ externalWallet: __spreadValues({
194
207
  type: "COSMOS",
195
- address
196
- },
208
+ address,
209
+ addressBech32
210
+ }, defaultWalletInfo),
197
211
  signedMessage: signature,
198
212
  cosmosPublicKeyHex,
199
213
  cosmosSigner
@@ -208,10 +222,10 @@ function ExternalWalletProvider({ children }) {
208
222
  setExternalWalletError([error]);
209
223
  } else if (signature && address) {
210
224
  verifyExternalWalletParams = {
211
- externalWallet: {
225
+ externalWallet: __spreadValues({
212
226
  type: "EVM",
213
227
  address
214
- },
228
+ }, defaultWalletInfo),
215
229
  signedMessage: signature
216
230
  };
217
231
  }
@@ -224,10 +238,10 @@ function ExternalWalletProvider({ children }) {
224
238
  setExternalWalletError([error]);
225
239
  } else if (signature && address) {
226
240
  verifyExternalWalletParams = {
227
- externalWallet: {
241
+ externalWallet: __spreadValues({
228
242
  type: "SOLANA",
229
243
  address
230
- },
244
+ }, defaultWalletInfo),
231
245
  signedMessage: signature
232
246
  };
233
247
  }
@@ -242,7 +256,14 @@ function ExternalWalletProvider({ children }) {
242
256
  return;
243
257
  }
244
258
  verifyExternalWallet(verifyExternalWalletParams, {
245
- onSuccess: onNewAuthState,
259
+ onSuccess: (d) => {
260
+ var _a;
261
+ if (wallet2 && (externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes((_a = wallet2.name) == null ? void 0 : _a.toUpperCase()))) {
262
+ onNewAuthState(d);
263
+ } else {
264
+ setStep(ModalStep.LOGIN_DONE);
265
+ }
266
+ },
246
267
  onError: (e) => {
247
268
  console.error("Error verifying signature:", e);
248
269
  setExternalWalletError(["Signature verification failed."]);
@@ -255,7 +276,7 @@ function ExternalWalletProvider({ children }) {
255
276
  }
256
277
  setIsExternalWalletVerifying(false);
257
278
  return void 0;
258
- }), [cosmosSignVerificationMessage, evmSignVerificationMessage, solanaSignVerificationMessage]);
279
+ }), [cosmosSignVerificationMessage, evmSignVerificationMessage, solanaSignVerificationMessage, wallet]);
259
280
  const connectExternalWallet = useCallback(
260
281
  (wallet2, isMobileConnect, isManualWalletConnect, isResetAfterManualWalletConnect) => __async(this, null, function* () {
261
282
  if (isExternalWalletConnecting && isManualWalletConnect) {
@@ -269,7 +290,7 @@ function ExternalWalletProvider({ children }) {
269
290
  setExternalWalletError();
270
291
  setIsExternalWalletConnecting(true);
271
292
  setIsUsingMobileConnector(isMobileConnect);
272
- const { address, error, authState } = yield isMobileConnect ? wallet2.connectMobile(isManualWalletConnect) : wallet2.connect();
293
+ const { address, error, authState } = yield isMobileConnect ? wallet2.connectMobile(isManualWalletConnect, connectionOnly) : wallet2.connect(connectionOnly);
273
294
  if (error) {
274
295
  setExternalWalletError([error]);
275
296
  setIsUsingMobileConnector();
@@ -280,7 +301,7 @@ function ExternalWalletProvider({ children }) {
280
301
  return;
281
302
  }
282
303
  } else if (address) {
283
- if (!!authState && (externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes(wallet2.id.toUpperCase()))) {
304
+ if (!!authState && ((externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes(wallet2.name.toUpperCase())) || includeWalletVerification)) {
284
305
  onNewAuthState(authState);
285
306
  } else {
286
307
  setStep(ModalStep.LOGIN_DONE);
@@ -289,7 +310,7 @@ function ExternalWalletProvider({ children }) {
289
310
  setIsExternalWalletConnecting(false);
290
311
  }
291
312
  }),
292
- [isExternalWalletConnecting, externalWalletsWithFullAuth]
313
+ [isExternalWalletConnecting, externalWalletsWithFullAuth, connectionOnly, includeWalletVerification]
293
314
  );
294
315
  const disconnectExternalWallet = () => __async(this, null, function* () {
295
316
  yield para.logout();
@@ -9,6 +9,10 @@ const createExternalWalletsSlice = (set) => ({
9
9
  setExternalWallets: (externalWallets) => set({ externalWallets }),
10
10
  externalWalletsWithFullAuth: [],
11
11
  setExternalWalletsWithFullAuth: (externalWalletsWithFullAuth) => set({ externalWalletsWithFullAuth }),
12
+ includeWalletVerification: false,
13
+ setIncludeWalletVerification: (includeWalletVerification) => set({ includeWalletVerification }),
14
+ connectionOnly: false,
15
+ setConnectionOnly: (connectionOnly) => set({ connectionOnly }),
12
16
  evmContext: EvmExternalWalletContext,
13
17
  setEvmContext: (evmContext) => set({ evmContext }),
14
18
  EvmProvider: void 0,
@@ -37,6 +37,10 @@ export interface WalletSlice {
37
37
  export interface ExternalWalletsSlice {
38
38
  externalWallets: TExternalWallet[];
39
39
  setExternalWallets: (_: TExternalWallet[]) => void;
40
+ connectionOnly: boolean;
41
+ setConnectionOnly: (_: boolean) => void;
42
+ includeWalletVerification: boolean;
43
+ setIncludeWalletVerification: (_: boolean) => void;
40
44
  externalWalletsWithFullAuth: TExternalWallet[];
41
45
  setExternalWalletsWithFullAuth: (_: TExternalWallet[]) => void;
42
46
  evmContext: Context<EvmExternalWalletContextType>;
@@ -107,11 +107,23 @@ export type ExternalWalletConfig<chains extends readonly [Chain, ...Chain[]], tr
107
107
  */
108
108
  wallets?: TExternalWallet[];
109
109
  /**
110
- * Array of external wallets that will also include linked embedded wallets.
110
+ * Array of external wallets that will also include linked embedded wallets. Also includes a wallet verification step.
111
111
  *
112
112
  * You can also pass `ALL` to include linked embedded wallets for all external wallets.
113
113
  */
114
114
  createLinkedEmbeddedForExternalWallets?: TExternalWallet[] | 'ALL';
115
+ /**
116
+ * Whether or not to validate a signature from the connected external wallet and create a Para session.
117
+ *
118
+ * All wallets using createLinkedEmbeddedForExternalWallets automatically include wallet verification.
119
+ */
120
+ includeWalletVerification?: boolean;
121
+ /**
122
+ * Whether or not to treat external wallets as connections only, skipping all Para functionality.
123
+ *
124
+ * This prop will override the createLinkedEmbeddedForExternalWallets and includeWalletVerification props
125
+ */
126
+ connectionOnly?: boolean;
115
127
  };
116
128
  export interface ParaProviderProps<chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>> extends PropsWithChildren {
117
129
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk",
3
- "version": "2.0.0-alpha.16",
3
+ "version": "2.0.0-alpha.17",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,9 +15,9 @@
15
15
  "*.css"
16
16
  ],
17
17
  "dependencies": {
18
- "@getpara/react-common": "2.0.0-alpha.16",
19
- "@getpara/react-components": "2.0.0-alpha.16",
20
- "@getpara/web-sdk": "2.0.0-alpha.16",
18
+ "@getpara/react-common": "2.0.0-alpha.17",
19
+ "@getpara/react-components": "2.0.0-alpha.17",
20
+ "@getpara/web-sdk": "2.0.0-alpha.17",
21
21
  "date-fns": "^3.6.0",
22
22
  "framer-motion": "11.3.28",
23
23
  "libphonenumber-js": "^1.11.1",
@@ -33,9 +33,9 @@
33
33
  "cli": "node ./dist/cli/cli.mjs"
34
34
  },
35
35
  "devDependencies": {
36
- "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.16",
37
- "@getpara/evm-wallet-connectors": "2.0.0-alpha.16",
38
- "@getpara/solana-wallet-connectors": "2.0.0-alpha.16",
36
+ "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.17",
37
+ "@getpara/evm-wallet-connectors": "2.0.0-alpha.17",
38
+ "@getpara/solana-wallet-connectors": "2.0.0-alpha.17",
39
39
  "@testing-library/dom": "^10.4.0",
40
40
  "@testing-library/react": "^16.3.0",
41
41
  "@testing-library/react-hooks": "^8.0.1",
@@ -63,5 +63,5 @@
63
63
  "resolutions": {
64
64
  "styled-components": "^6"
65
65
  },
66
- "gitHead": "84eb1a14fa8918c449ae4b163fe173d34688cdcd"
66
+ "gitHead": "5cb0f3dee5564995c465ead160ed817ba2ba37a7"
67
67
  }