@getpara/react-sdk-lite 2.0.0-alpha.59 → 2.0.0-alpha.60

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.
@@ -7,21 +7,21 @@ import { useMemo } from "react";
7
7
  import { truncateAddress } from "@getpara/web-sdk";
8
8
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
9
9
  import { useAssets } from "../../../provider/providers/AssetsProvider.js";
10
- import { useAccount } from "../../../provider/index.js";
10
+ import { useAccount, useWallet } from "../../../provider/index.js";
11
11
  import { WalletSelect } from "../WalletSelect/WalletSelect.js";
12
12
  const AccountHeader = ({ withBalance = false } = {}) => {
13
13
  const para = useInternalClient();
14
14
  const { connectionType } = useAccount();
15
15
  const { profileBalance, totalBalance } = useAssets();
16
- const externalWallet = Object.keys(para == null ? void 0 : para.externalWallets).length > 0 ? Object.values(para.externalWallets)[0] : void 0;
16
+ const { data: activeWallet } = useWallet();
17
17
  const { name, icon, src } = useMemo(() => {
18
18
  var _a;
19
19
  let name2, icon2, src2;
20
20
  switch (true) {
21
- case !!externalWallet:
22
- name2 = (_a = externalWallet.ensName) != null ? _a : truncateAddress(externalWallet.address, externalWallet.type, { prefix: para.cosmosPrefix });
23
- src2 = externalWallet.ensAvatar;
24
- icon2 = getExternalWalletIcon(externalWallet.externalProviderId);
21
+ case (activeWallet == null ? void 0 : activeWallet.isExternal):
22
+ name2 = (_a = activeWallet.ensName) != null ? _a : truncateAddress(activeWallet.address, activeWallet.type, { prefix: para.cosmosPrefix });
23
+ src2 = activeWallet.ensAvatar;
24
+ icon2 = getExternalWalletIcon(activeWallet.externalProviderId);
25
25
  break;
26
26
  default:
27
27
  name2 = `${para.partnerName} Wallet`;
@@ -30,7 +30,7 @@ const AccountHeader = ({ withBalance = false } = {}) => {
30
30
  break;
31
31
  }
32
32
  return { name: name2, icon: icon2, src: src2 };
33
- }, [para.partnerName, para.partnerLogo, externalWallet]);
33
+ }, [para.partnerName, para.partnerLogo, activeWallet]);
34
34
  return /* @__PURE__ */ jsxs(AccountContainer, { children: [
35
35
  /* @__PURE__ */ jsx(
36
36
  CpslIcon,
@@ -6,7 +6,7 @@ import {
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { AccountTypeIcon, GradientScroll, StepContainer, WalletTypeIcon } from "../common.js";
8
8
  import { CpslButton, CpslIcon, CpslText } from "@getpara/react-components";
9
- import { useAccount, useClient } from "../../../provider/index.js";
9
+ import { useAccount } from "../../../provider/index.js";
10
10
  import { useLinkedAccounts } from "../../../provider/hooks/index.js";
11
11
  import { getWalletDisplayName } from "../../utils/getWalletDisplayName.js";
12
12
  import {
@@ -19,8 +19,10 @@ import { useMemo } from "react";
19
19
  import { ACCOUNT_TYPES, safeStyled, useCopyToClipboard } from "@getpara/react-common";
20
20
  import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
21
21
  import { useStore } from "../../../provider/stores/useStore.js";
22
- import { AccountHeader } from "./AccountHeader.js";
23
22
  import { useAssets } from "../../../provider/providers/AssetsProvider.js";
23
+ import { useModalStore } from "../../stores/index.js";
24
+ import { ModalStep } from "../../utils/steps.js";
25
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
24
26
  const Entry = ({
25
27
  identifier,
26
28
  icon,
@@ -77,9 +79,9 @@ const AccountProfile = ({
77
79
  isDisconnecting,
78
80
  onDisconnect
79
81
  }) => {
80
- var _a, _b, _c, _d, _e, _f;
81
- const para = useClient();
82
- const { connectionType, embedded } = useAccount();
82
+ var _a;
83
+ const para = useInternalClient();
84
+ const { embedded } = useAccount();
83
85
  const { data: linkedAccounts } = useLinkedAccounts();
84
86
  const { wallets } = useExternalWallets();
85
87
  const { isEnabled, linkAccount, unlinkAccount } = useAccountLinking();
@@ -88,47 +90,18 @@ const AccountProfile = ({
88
90
  return (_a2 = state.modalConfig) == null ? void 0 : _a2.hideWallets;
89
91
  });
90
92
  const { profileBalance } = useAssets();
93
+ const setStep = useModalStore((state) => state.setStep);
91
94
  if (!para) {
92
95
  return null;
93
96
  }
94
- const externalWallet = (_a = para.authInfo) == null ? void 0 : _a.externalWallet;
97
+ const embeddedWallets = (_a = para == null ? void 0 : para.availableWallets) == null ? void 0 : _a.filter((wallet) => !wallet.isExternal);
95
98
  return /* @__PURE__ */ jsxs(StepContainer, { children: [
96
- /* @__PURE__ */ jsx(AccountHeader, { withBalance: true }),
97
- connectionType !== "external" && /* @__PURE__ */ jsxs(ParaConnect, { target: "_blank", href: "https://connect.getpara.com", rel: "noreferrer noopener", children: [
98
- /* @__PURE__ */ jsx(ParaIcon, { icon: "paraIconBrand", size: "40px", inset: "8px", background: "white" }),
99
- /* @__PURE__ */ jsxs("div", { children: [
100
- "Do even more with your wallet",
101
- /* @__PURE__ */ jsx("br", {}),
102
- "at ",
103
- /* @__PURE__ */ jsx("span", { style: { fontWeight: "600" }, children: "Para Connect" })
99
+ embeddedWallets.length > 0 && /* @__PURE__ */ jsxs(Section, { children: [
100
+ /* @__PURE__ */ jsxs(Title, { variant: "bodyS", color: "secondary", children: [
101
+ para.partnerName,
102
+ " Wallets"
104
103
  ] }),
105
- /* @__PURE__ */ jsxs(Dots, { children: [
106
- new Array(6).fill(0).map((_, index) => /* @__PURE__ */ jsx(DotsIcon, { index, icon: "dotsSquare", size: "27.5px" }, index)),
107
- /* @__PURE__ */ jsx(ParaArrow, { icon: "paraArrow", size: "31px", color: "white" })
108
- ] })
109
- ] }),
110
- /* @__PURE__ */ jsxs(Section, { children: [
111
- /* @__PURE__ */ jsx(Title, { variant: "bodyS", color: "secondary", children: "Connected Wallets" }),
112
- /* @__PURE__ */ jsx(Content, { children: externalWallet && connectionType === "external" ? /* @__PURE__ */ jsx(
113
- Entry,
114
- {
115
- icon: /* @__PURE__ */ jsx(
116
- WalletTypeIcon,
117
- {
118
- walletType: externalWallet.type,
119
- externalWallet: externalWallet.providerId,
120
- size: "24px",
121
- inset: "0"
122
- }
123
- ),
124
- name: (_c = (_b = externalWallet.ensName) != null ? _b : externalWallet.provider) != null ? _c : "",
125
- address: (_d = externalWallet.addressBech32) != null ? _d : externalWallet.address,
126
- addressShort: truncateAddress((_e = externalWallet.addressBech32) != null ? _e : externalWallet.address, externalWallet.type, {
127
- prefix: para.cosmosPrefix
128
- })
129
- },
130
- externalWallet.address
131
- ) : (_f = para == null ? void 0 : para.availableWallets) == null ? void 0 : _f.map((wallet) => /* @__PURE__ */ jsx(
104
+ /* @__PURE__ */ jsx(Content, { children: embeddedWallets.map((wallet) => /* @__PURE__ */ jsx(
132
105
  Entry,
133
106
  {
134
107
  icon: /* @__PURE__ */ jsx(WalletTypeIcon, { walletType: wallet.type, externalWallet: wallet.externalProviderId, size: "24px" }),
@@ -140,23 +113,72 @@ const AccountProfile = ({
140
113
  wallet.address
141
114
  )) })
142
115
  ] }),
116
+ /* @__PURE__ */ jsxs(Section, { children: [
117
+ /* @__PURE__ */ jsx(Title, { variant: "bodyS", color: "secondary", children: "External Wallets" }),
118
+ /* @__PURE__ */ jsxs(Content, { children: [
119
+ Object.values((para == null ? void 0 : para.externalWallets) || {}).map((wallet) => {
120
+ var _a2, _b;
121
+ const externalWallet = wallets.find((w) => w.name === wallet.name);
122
+ return /* @__PURE__ */ jsx(
123
+ Entry,
124
+ {
125
+ icon: /* @__PURE__ */ jsx(
126
+ WalletTypeIcon,
127
+ {
128
+ walletType: wallet.type,
129
+ externalWallet: externalWallet != null ? externalWallet : wallet.externalProviderId,
130
+ size: "24px",
131
+ inset: "0"
132
+ }
133
+ ),
134
+ name: (_b = (_a2 = wallet.ensName) != null ? _a2 : wallet.name) != null ? _b : "",
135
+ address: wallet.address,
136
+ addressShort: wallet.address ? truncateAddress(wallet.address, wallet.type, {
137
+ prefix: para.cosmosPrefix
138
+ }) : "",
139
+ balance: profileBalance == null ? void 0 : profileBalance.wallets.find((w) => w.address === wallet.address)
140
+ },
141
+ wallet.address
142
+ );
143
+ }),
144
+ /* @__PURE__ */ jsxs(
145
+ CpslButton,
146
+ {
147
+ fullWidth: true,
148
+ variant: "tertiary",
149
+ onClick: () => {
150
+ setStep(ModalStep.ADD_EX_WALLET_MORE);
151
+ },
152
+ children: [
153
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "plus", slot: "start" }),
154
+ "Add Wallet"
155
+ ]
156
+ }
157
+ )
158
+ ] })
159
+ ] }),
143
160
  isEnabled && /* @__PURE__ */ jsxs(Section, { children: [
144
161
  /* @__PURE__ */ jsx(Title, { variant: "bodyS", color: "secondary", children: "Linked Accounts" }),
145
162
  /* @__PURE__ */ jsxs(Content, { children: [
146
- /* @__PURE__ */ jsx(GradientScroll, { gap: "12px", height: "360px", children: [...((linkedAccounts == null ? void 0 : linkedAccounts.primary) || []).map((p) => __spreadProps(__spreadValues({}, p), { isPrimary: true })), ...(linkedAccounts == null ? void 0 : linkedAccounts.linked) || []].filter(({ externalWallet: externalWallet2 }) => {
147
- return !externalWallet2 || externalWallet2.address !== (embedded == null ? void 0 : embedded.externalWalletAddress);
163
+ /* @__PURE__ */ jsx(GradientScroll, { gap: "12px", height: "360px", children: [...((linkedAccounts == null ? void 0 : linkedAccounts.primary) || []).map((p) => __spreadProps(__spreadValues({}, p), { isPrimary: true })), ...(linkedAccounts == null ? void 0 : linkedAccounts.linked) || []].filter(({ externalWallet }) => {
164
+ return !externalWallet || externalWallet.address !== (embedded == null ? void 0 : embedded.externalWalletAddress);
148
165
  }).map((linkedAccount) => {
149
- var _a2, _b2, _c2, _d2, _e2;
150
- const { identifier, displayName, type, isPrimary = false, externalWallet: externalWallet2 } = linkedAccount;
151
- const externalWalletConnector = wallets.find((wallet) => wallet.id === (externalWallet2 == null ? void 0 : externalWallet2.providerId));
166
+ var _a2, _b, _c, _d, _e;
167
+ const { identifier, displayName, type, isPrimary = false, externalWallet } = linkedAccount;
168
+ const externalWalletConnector = wallets.find(
169
+ (wallet) => {
170
+ var _a3, _b2;
171
+ return wallet.id === (externalWallet == null ? void 0 : externalWallet.providerId) || wallet.id.toLowerCase() === ((_a3 = externalWallet == null ? void 0 : externalWallet.providerId) == null ? void 0 : _a3.toLowerCase()) || wallet.name.toLowerCase() === ((_b2 = externalWallet == null ? void 0 : externalWallet.providerId) == null ? void 0 : _b2.toLowerCase());
172
+ }
173
+ );
152
174
  let accountType = type;
153
175
  let src = void 0;
154
- if (externalWallet2) {
176
+ if (externalWallet) {
155
177
  if (externalWalletConnector) {
156
178
  accountType = void 0;
157
179
  src = externalWalletConnector.iconUrl;
158
- } else if (externalWallet2.providerId && ACCOUNT_TYPES[externalWallet2.providerId]) {
159
- accountType = externalWallet2.providerId;
180
+ } else if (externalWallet.providerId && ACCOUNT_TYPES[externalWallet.providerId]) {
181
+ accountType = externalWallet.providerId;
160
182
  src = void 0;
161
183
  } else {
162
184
  accountType = "EXTERNAL_WALLET";
@@ -167,9 +189,9 @@ const AccountProfile = ({
167
189
  Entry,
168
190
  {
169
191
  icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType, src, size: "24px" }),
170
- name: externalWallet2 ? (_c2 = (_b2 = (_a2 = externalWallet2.ensName) != null ? _a2 : externalWalletConnector == null ? void 0 : externalWalletConnector.name) != null ? _b2 : externalWallet2.provider) != null ? _c2 : "" : displayName != null ? displayName : identifier,
171
- address: (_d2 = externalWallet2 == null ? void 0 : externalWallet2.addressBech32) != null ? _d2 : externalWallet2 == null ? void 0 : externalWallet2.address,
172
- addressShort: externalWallet2 ? truncateAddress((_e2 = externalWallet2.addressBech32) != null ? _e2 : externalWallet2.address, externalWallet2.type, {
192
+ name: externalWallet ? (_c = (_b = (_a2 = externalWallet.ensName) != null ? _a2 : externalWalletConnector == null ? void 0 : externalWalletConnector.name) != null ? _b : externalWallet.provider) != null ? _c : "" : displayName != null ? displayName : identifier,
193
+ address: (_d = externalWallet == null ? void 0 : externalWallet.addressBech32) != null ? _d : externalWallet == null ? void 0 : externalWallet.address,
194
+ addressShort: externalWallet ? truncateAddress((_e = externalWallet.addressBech32) != null ? _e : externalWallet.address, externalWallet.type, {
173
195
  prefix: para.cosmosPrefix
174
196
  }) : void 0,
175
197
  onUnlink: isPrimary ? void 0 : (e) => {
@@ -251,51 +273,6 @@ const DisconnectButton = safeStyled(CpslButton)`
251
273
  --button-destructive-active-background-color: rgba(255, 0, 0, 0.1);
252
274
 
253
275
  `;
254
- const ParaConnect = safeStyled.a`
255
- position: relative;
256
- box-sizing: border-box;
257
- width: 100%;
258
- text-decoration: none;
259
- color: white !important;
260
- font-family: 'PP Mori', sans-serif;
261
- font-weight: 500;
262
- font-size: 15px;
263
- padding: 16px;
264
- height: 69px;
265
- display: flex;
266
- align-items: center;
267
- justify-content: flex-start;
268
- gap: 8px;
269
- border-radius: 8px;
270
- border: 1px solid #FF4E00;
271
- background: #FF4E00;
272
- box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.05), 0 0 20px 8px rgba(251, 188, 4, 0.20) inset;
273
-
274
- &:hover, &:active {
275
- background: #FF6A2B;
276
- border: 1px solid #FF6A2B;
277
- }
278
-
279
- `;
280
- const ParaIcon = safeStyled(CpslIcon)`
281
- --icon-border-radius: 4px;
282
- `;
283
- const Dots = safeStyled.div`
284
- width: 75px;
285
- position: absolute;
286
- right: 14px;
287
- top: 7px;
288
- `;
289
- const DotsIcon = safeStyled(CpslIcon)`
290
- position: absolute;
291
- left: ${({ index }) => `${index % 3 * 27.5}px`};
292
- top: ${({ index }) => `${Math.floor(index / 3) * 27.5}px`};
293
- `;
294
- const ParaArrow = safeStyled(CpslIcon)`
295
- position: absolute;
296
- top: 12px;
297
- right: 4px;
298
- `;
299
276
  export {
300
277
  AccountProfile
301
278
  };
@@ -6,13 +6,15 @@ import { AccountTypeIcon, GradientScroll, StepContainer } from "../common.js";
6
6
  import { CpslButton, CpslDivider, CpslText } from "@getpara/react-components";
7
7
  import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
8
8
  import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
9
+ import { useLinkedAccounts } from "../../../provider/hooks/index.js";
9
10
  import { useEffect, useMemo } from "react";
10
11
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
11
12
  import { getAccountTypeName, safeStyled } from "@getpara/react-common";
12
13
  function AccountProfileLinkOptions() {
13
14
  const para = useInternalClient();
14
15
  const { accountLinkOptions, linkAccount, isLinkAccountPending, linkAccountError, setLinkAccountError, resetMutations } = useAccountLinking();
15
- const { wallet: connectedWallet, wallets } = useExternalWallets();
16
+ const { wallets } = useExternalWallets();
17
+ const { data: linkedAccounts } = useLinkedAccounts();
16
18
  const [isEmail, isPhone, externalWalletIndex, isOptions] = [
17
19
  accountLinkOptions.includes("EMAIL"),
18
20
  accountLinkOptions.includes("PHONE"),
@@ -28,8 +30,17 @@ function AccountProfileLinkOptions() {
28
30
  return Array.from(
29
31
  new Set(
30
32
  baseOptions.filter((option) => {
31
- if (!wallets.some((wallet) => wallet.id === option) || (connectedWallet == null ? void 0 : connectedWallet.id) !== option && wallets.some(({ type, id, installed, isMobile }) => {
32
- return (installed || isMobile) && (para == null ? void 0 : para.supportedWalletTypes.some((obj) => obj.type === type)) && id === option;
33
+ if (!wallets.some((wallet) => wallet.id === option) || wallets.some(({ type, id, installed, isMobile }) => {
34
+ if (!(installed || isMobile) || !(para == null ? void 0 : para.supportedWalletTypes.some((obj) => obj.type === type)) || id !== option) {
35
+ return false;
36
+ }
37
+ const isAlreadyLinked = [...(linkedAccounts == null ? void 0 : linkedAccounts.primary) || [], ...(linkedAccounts == null ? void 0 : linkedAccounts.linked) || []].some(
38
+ (linkedAccount) => {
39
+ var _a, _b;
40
+ return ((_a = linkedAccount.externalWallet) == null ? void 0 : _a.providerId) === id && ((_b = linkedAccount.externalWallet) == null ? void 0 : _b.type) === type;
41
+ }
42
+ );
43
+ return !isAlreadyLinked;
33
44
  })) {
34
45
  return true;
35
46
  }
@@ -37,7 +48,7 @@ function AccountProfileLinkOptions() {
37
48
  })
38
49
  )
39
50
  );
40
- }, [accountLinkOptions, externalWalletIndex, wallets]);
51
+ }, [accountLinkOptions, externalWalletIndex, wallets, linkedAccounts, para == null ? void 0 : para.supportedWalletTypes]);
41
52
  useEffect(() => {
42
53
  resetMutations();
43
54
  setLinkAccountError(null);
@@ -190,7 +190,22 @@ const Body = ({
190
190
  return /* @__PURE__ */ jsx(ChainSwitch, {});
191
191
  }
192
192
  case ModalStep.EX_WALLET_NETWORK_SELECT: {
193
- return /* @__PURE__ */ jsx(ExternalWalletNetworkSelectStep, {});
193
+ return /* @__PURE__ */ jsx(ExternalWalletNetworkSelectStep, { type: "CONNECT" });
194
+ }
195
+ case ModalStep.ADD_EX_WALLET_NETWORK_SELECT: {
196
+ return /* @__PURE__ */ jsx(ExternalWalletNetworkSelectStep, { type: "ADD_EXTERNAL" });
197
+ }
198
+ case ModalStep.LINK_EX_WALLET_NETWORK_SELECT: {
199
+ return /* @__PURE__ */ jsx(ExternalWalletNetworkSelectStep, { type: "ACCOUNT_LINKING" });
200
+ }
201
+ case ModalStep.ADD_EX_WALLET_MORE: {
202
+ return /* @__PURE__ */ jsx(ExternalWallets, { isAddingWallets: true });
203
+ }
204
+ case ModalStep.ADD_EX_WALLET_SELECTED: {
205
+ return /* @__PURE__ */ jsx(ExternalWalletStep, { isAddingWallets: true });
206
+ }
207
+ case ModalStep.ADD_EX_WALLET_NETWORK_SELECT: {
208
+ return /* @__PURE__ */ jsx(ExternalWalletNetworkSelectStep, { type: "ADD_EXTERNAL" });
194
209
  }
195
210
  case ModalStep.AWAITING_ACCOUNT: {
196
211
  return /* @__PURE__ */ jsx(AwaitingAccountStep, {});
@@ -1 +1,5 @@
1
- export declare const ExternalWalletNetworkSelectStep: () => import("react/jsx-runtime").JSX.Element | null;
1
+ type ExternalWalletNetworkSelectStepType = 'CONNECT' | 'ADD_EXTERNAL' | 'ACCOUNT_LINKING';
2
+ export declare const ExternalWalletNetworkSelectStep: ({ type }: {
3
+ type?: ExternalWalletNetworkSelectStepType;
4
+ }) => import("react/jsx-runtime").JSX.Element | null;
5
+ export {};
@@ -1,5 +1,7 @@
1
1
  "use client";
2
- import "../../../chunk-MMUBH76A.js";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
3
5
  import { jsx, jsxs } from "react/jsx-runtime";
4
6
  import { safeStyled } from "@getpara/react-common";
5
7
  import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
@@ -8,35 +10,62 @@ import { ModalStep } from "../../utils/steps.js";
8
10
  import { CpslButton, CpslIcon, CpslText } from "@getpara/react-components";
9
11
  import { WALLET_TYPE_CONFIG } from "../../constants/walletTypeConfig.js";
10
12
  import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
11
- const ExternalWalletNetworkSelectStep = () => {
12
- var _a, _b;
13
+ const ExternalWalletNetworkSelectStep = ({ type = "CONNECT" }) => {
14
+ var _a, _b, _c;
13
15
  const setStep = useModalStore((state) => state.setStep);
14
16
  const selectedExternalWallet = useModalStore((state) => state.selectedExternalWallet);
15
17
  const setSelectedExternalWallet = useModalStore((state) => state.setSelectedExternalWallet);
16
- const { wallets, connectExternalWallet } = useExternalWallets();
18
+ const { wallets, connectExternalWallet, addAdditionalExternalWallet } = useExternalWallets();
17
19
  const { accountLinkInProgress, linkAccount } = useAccountLinking();
18
- const externalWalletProvider = (_b = accountLinkInProgress == null ? void 0 : accountLinkInProgress.pendingWalletProvider) != null ? _b : (_a = accountLinkInProgress == null ? void 0 : accountLinkInProgress.externalWallet) == null ? void 0 : _a.providerId;
19
- if (!accountLinkInProgress && !selectedExternalWallet) {
20
- setStep(ModalStep.ACCOUNT_MAIN);
20
+ const externalWalletProvider = (_c = (_b = accountLinkInProgress == null ? void 0 : accountLinkInProgress.pendingWalletProvider) != null ? _b : (_a = accountLinkInProgress == null ? void 0 : accountLinkInProgress.externalWallet) == null ? void 0 : _a.providerId) != null ? _c : selectedExternalWallet == null ? void 0 : selectedExternalWallet.id;
21
+ if (!externalWalletProvider) {
21
22
  return null;
22
23
  }
23
- const availableWallets = wallets.filter((w) => w.id === (externalWalletProvider != null ? externalWalletProvider : selectedExternalWallet == null ? void 0 : selectedExternalWallet.id));
24
+ const availableWallets = wallets.filter((w) => w.id === externalWalletProvider);
24
25
  const firstWallet = availableWallets[0];
25
- const handleWalletClick = (wallet) => () => {
26
- if (accountLinkInProgress) {
27
- linkAccount({ externalWallet: { provider: wallet.id, type: wallet.type } });
28
- return;
26
+ const handleWalletClick = (wallet) => () => __async(void 0, null, function* () {
27
+ switch (type) {
28
+ case "ACCOUNT_LINKING":
29
+ linkAccount({ externalWallet: { provider: wallet.id, type: wallet.type } });
30
+ break;
31
+ case "ADD_EXTERNAL":
32
+ setSelectedExternalWallet({ id: wallet.id, type: wallet.type });
33
+ setStep(ModalStep.ADD_EX_WALLET_SELECTED);
34
+ try {
35
+ yield addAdditionalExternalWallet(wallet);
36
+ } catch (error) {
37
+ console.error("Failed to add additional wallet:", error);
38
+ }
39
+ break;
40
+ case "CONNECT":
41
+ default:
42
+ setSelectedExternalWallet({ id: wallet.id, type: wallet.type });
43
+ setStep(ModalStep.EX_WALLET_SELECTED);
44
+ if (wallet.installed || wallet.internalId === "FARCASTER") {
45
+ connectExternalWallet(wallet);
46
+ } else if (wallet.isMobile) {
47
+ connectExternalWallet(wallet, true);
48
+ }
49
+ break;
29
50
  }
30
- setSelectedExternalWallet({ id: wallet.id, type: wallet.type });
31
- setStep(ModalStep.EX_WALLET_SELECTED);
32
- if (wallet.installed || wallet.internalId === "FARCASTER") {
33
- connectExternalWallet(wallet);
34
- } else if (wallet.isMobile) {
35
- connectExternalWallet(wallet, true);
51
+ });
52
+ const getIconSource = () => {
53
+ var _a2, _b2, _c2;
54
+ switch (type) {
55
+ case "ACCOUNT_LINKING":
56
+ return ((_a2 = accountLinkInProgress == null ? void 0 : accountLinkInProgress.externalWallet) == null ? void 0 : _a2.providerId) ? (_b2 = wallets.find((w) => {
57
+ var _a3;
58
+ return w.id === ((_a3 = accountLinkInProgress.externalWallet) == null ? void 0 : _a3.providerId);
59
+ })) == null ? void 0 : _b2.iconUrl : firstWallet == null ? void 0 : firstWallet.iconUrl;
60
+ case "ADD_EXTERNAL":
61
+ return (selectedExternalWallet == null ? void 0 : selectedExternalWallet.id) ? (_c2 = wallets.find((w) => w.id === selectedExternalWallet.id)) == null ? void 0 : _c2.iconUrl : firstWallet == null ? void 0 : firstWallet.iconUrl;
62
+ case "CONNECT":
63
+ default:
64
+ return firstWallet == null ? void 0 : firstWallet.iconUrl;
36
65
  }
37
66
  };
38
67
  return /* @__PURE__ */ jsxs(Container, { children: [
39
- /* @__PURE__ */ jsx(Avatar, { slot: "image", src: firstWallet == null ? void 0 : firstWallet.iconUrl }),
68
+ /* @__PURE__ */ jsx(Avatar, { slot: "image", src: getIconSource() }),
40
69
  /* @__PURE__ */ jsx(ButtonContainer, { children: availableWallets.map((wallet) => {
41
70
  const config = WALLET_TYPE_CONFIG[wallet.type];
42
71
  return /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: handleWalletClick(wallet), children: /* @__PURE__ */ jsxs(ButtonInnerContainer, { children: [
@@ -5,4 +5,6 @@ export declare const ExternalWalletMobileConnect: ({ wallet, qrUri: propsQrUri,
5
5
  onConnectWc: (_: CommonWallet) => Promise<void>;
6
6
  isSelfFetching?: boolean;
7
7
  }) => import("react/jsx-runtime").JSX.Element;
8
- export declare const ExternalWalletStep: () => import("react/jsx-runtime").JSX.Element | null;
8
+ export declare const ExternalWalletStep: ({ isAddingWallets }: {
9
+ isAddingWallets?: boolean;
10
+ }) => import("react/jsx-runtime").JSX.Element | null;
@@ -5,7 +5,7 @@ import {
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
7
7
  import { CenteredText, HeroAccountTypeIcon, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
8
- import { useEffect, useMemo, useState } from "react";
8
+ import { useCallback, useEffect, useMemo, useState } from "react";
9
9
  import { useModalStore } from "../../stores/index.js";
10
10
  import { HeroSpinner, safeStyled } from "@getpara/react-common";
11
11
  import { useCopyToClipboard } from "@getpara/react-common";
@@ -90,16 +90,27 @@ const ExternalWalletMobileConnect = ({
90
90
  /* @__PURE__ */ jsx(InnerStepContainer, { children: isWalletConnect ? /* @__PURE__ */ jsx(Fragment, { children: GetWalletButton }) : /* @__PURE__ */ jsx(Link, { href: (_b = wallet.downloadUrl) != null ? _b : "", target: "_blank", children: GetWalletButton }) })
91
91
  ] });
92
92
  };
93
- const ExternalWalletStep = () => {
93
+ const ExternalWalletStep = ({ isAddingWallets = false }) => {
94
94
  const externalWalletError = useModalStore((state) => state.externalWalletError);
95
+ const step = useModalStore((state) => state.step);
95
96
  const setStep = useModalStore((state) => state.setStep);
96
- const { connectExternalWallet, wallet, qrUri, walletDisplayHelpers } = useExternalWallets();
97
+ const { connectExternalWallet, addAdditionalExternalWallet, wallet, qrUri, walletDisplayHelpers } = useExternalWallets();
98
+ const handleConnect = useCallback(
99
+ (wallet2, isWc = false) => __async(void 0, null, function* () {
100
+ if (isAddingWallets) {
101
+ yield addAdditionalExternalWallet(wallet2);
102
+ } else {
103
+ yield isWc ? connectExternalWallet(wallet2, true, true) : connectExternalWallet(wallet2);
104
+ }
105
+ }),
106
+ [isAddingWallets, addAdditionalExternalWallet, connectExternalWallet]
107
+ );
97
108
  useEffect(() => {
98
109
  routeMobileExternalWallet(qrUri);
99
110
  }, [qrUri]);
100
111
  const handleTryAgainClick = () => __async(void 0, null, function* () {
101
112
  if (wallet) {
102
- yield connectExternalWallet(wallet);
113
+ yield handleConnect(wallet);
103
114
  }
104
115
  });
105
116
  const Content = useMemo(() => {
@@ -153,17 +164,29 @@ Please choose another wallet or continue on desktop.` }) });
153
164
  wallet,
154
165
  qrUri,
155
166
  onConnectWc: (w) => __async(void 0, null, function* () {
156
- yield connectExternalWallet(w, true, true);
167
+ yield handleConnect(w, true);
157
168
  })
158
169
  }
159
170
  );
160
171
  }
161
- }, [wallet, walletDisplayHelpers, externalWalletError, qrUri]);
172
+ }, [
173
+ wallet,
174
+ walletDisplayHelpers,
175
+ externalWalletError,
176
+ qrUri,
177
+ isAddingWallets,
178
+ addAdditionalExternalWallet,
179
+ connectExternalWallet
180
+ ]);
162
181
  useEffect(() => {
163
182
  if (!wallet) {
164
- setStep(ModalStep.AUTH_MAIN);
183
+ if (step === ModalStep.ADD_EX_WALLET_SELECTED) {
184
+ setStep(ModalStep.ADD_EX_WALLET_MORE);
185
+ } else {
186
+ setStep(ModalStep.AUTH_MAIN);
187
+ }
165
188
  }
166
- }, [wallet]);
189
+ }, [wallet, step]);
167
190
  if (!wallet) {
168
191
  return null;
169
192
  }
@@ -1 +1,3 @@
1
- export declare const ExternalWallets: () => import("react/jsx-runtime").JSX.Element;
1
+ export declare const ExternalWallets: ({ isAddingWallets }: {
2
+ isAddingWallets?: boolean;
3
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -12,11 +12,13 @@ import { useState } from "react";
12
12
  import { hasEmbeddedAuth } from "../../utils/authLayoutHelpers.js";
13
13
  import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
14
14
  const HAS_MORE_LENGTH = 3;
15
- const ExternalWallets = () => {
16
- const { wallets: allWallets, connectExternalWallet } = useExternalWallets();
15
+ const ExternalWallets = ({ isAddingWallets = false }) => {
16
+ const { wallets: allWallets, connectExternalWallet, addAdditionalExternalWallet } = useExternalWallets();
17
17
  const setSelectedExternalWallet = useModalStore((state) => state.setSelectedExternalWallet);
18
18
  const setStep = useModalStore((state) => state.setStep);
19
- const showAll = useModalStore((state) => state.step === ModalStep.EX_WALLET_MORE);
19
+ const showAll = useModalStore(
20
+ (state) => state.step === ModalStep.EX_WALLET_MORE || state.step === ModalStep.ADD_EX_WALLET_MORE
21
+ );
20
22
  const authLayout = useModalStore((state) => state.authLayout);
21
23
  const [search, setSearch] = useState("");
22
24
  const dedupedWallets = Array.from(new Set(allWallets.map((wallet) => wallet.id))).map((id) => {
@@ -31,21 +33,29 @@ const ExternalWallets = () => {
31
33
  const handleParaClick = () => {
32
34
  setStep(ModalStep.AUTH_MORE);
33
35
  };
34
- const handleWalletClick = (wallet) => () => {
36
+ const handleWalletClick = (wallet) => () => __async(void 0, null, function* () {
35
37
  const shouldShowNetworkSelection = allWallets.filter((w) => w.id === wallet.id).length > 1;
36
38
  if (shouldShowNetworkSelection) {
37
39
  setSelectedExternalWallet({ id: wallet.id, type: wallet.type });
38
- setStep(ModalStep.EX_WALLET_NETWORK_SELECT);
40
+ setStep(isAddingWallets ? ModalStep.ADD_EX_WALLET_NETWORK_SELECT : ModalStep.EX_WALLET_NETWORK_SELECT);
39
41
  return;
40
42
  }
41
43
  setSelectedExternalWallet({ id: wallet.id, type: wallet.type });
42
- setStep(ModalStep.EX_WALLET_SELECTED);
43
- if (wallet.installed) {
44
- connectExternalWallet(wallet);
45
- } else if (wallet.isMobile) {
46
- connectExternalWallet(wallet, true);
44
+ setStep(isAddingWallets ? ModalStep.ADD_EX_WALLET_SELECTED : ModalStep.EX_WALLET_SELECTED);
45
+ if (isAddingWallets) {
46
+ try {
47
+ yield addAdditionalExternalWallet(wallet);
48
+ } catch (error) {
49
+ console.error("Failed to add additional wallet:", error);
50
+ }
51
+ } else {
52
+ if (wallet.installed) {
53
+ connectExternalWallet(wallet);
54
+ } else if (wallet.isMobile) {
55
+ connectExternalWallet(wallet, true);
56
+ }
47
57
  }
48
- };
58
+ });
49
59
  return /* @__PURE__ */ jsxs(Container, { $maxHeight: showAll, children: [
50
60
  showAll && /* @__PURE__ */ jsxs(Fragment, { children: [
51
61
  /* @__PURE__ */ jsx(SearchInputWrapper, { children: /* @__PURE__ */ jsx(
@@ -61,7 +71,7 @@ const ExternalWallets = () => {
61
71
  children: /* @__PURE__ */ jsx(SearchIcon, { slot: "start", icon: "search" })
62
72
  }
63
73
  ) }),
64
- hasEmbeddedAuth(authLayout != null ? authLayout : []) && /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: handleParaClick, children: /* @__PURE__ */ jsxs(WalletButtonOuterContainer, { children: [
74
+ hasEmbeddedAuth(authLayout != null ? authLayout : []) && !isAddingWallets && /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: handleParaClick, children: /* @__PURE__ */ jsxs(WalletButtonOuterContainer, { children: [
65
75
  /* @__PURE__ */ jsxs(WalletButtonInnerContainer, { children: [
66
76
  /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "paraIcon" }),
67
77
  /* @__PURE__ */ jsx(CpslText, { weight: "medium", children: "Para" })
@@ -39,6 +39,7 @@ const useStepTitle = () => {
39
39
  [ModalStep.AUTH_MORE]: signUpOrLogInTitle,
40
40
  [ModalStep.AUTH_GUEST_SIGNUP]: "Complete Account Setup",
41
41
  [ModalStep.EX_WALLET_MORE]: connectWalletTitle,
42
+ [ModalStep.ADD_EX_WALLET_MORE]: "Add Wallet",
42
43
  [ModalStep.VERIFICATIONS]: "Sign Up",
43
44
  [ModalStep.AWAITING_OAUTH]: signUpOrLogInTitle,
44
45
  [ModalStep.FARCASTER_OAUTH]: signUpOrLogInTitle,
@@ -70,6 +71,12 @@ const useStepTitle = () => {
70
71
  [ModalStep.ACCOUNT_PROFILE_LIST]: "Link Account",
71
72
  [ModalStep.ACCOUNT_PROFILE_ADD]: "Link Account",
72
73
  [ModalStep.ACCOUNT_PROFILE_REMOVE]: "Unlink Account",
74
+ [ModalStep.EX_WALLET_SELECTED]: "Connect Wallet",
75
+ [ModalStep.EX_WALLET_NETWORK_SELECT]: "Select Network",
76
+ [ModalStep.ADD_EX_WALLET_NETWORK_SELECT]: "Select Network",
77
+ [ModalStep.LINK_EX_WALLET_NETWORK_SELECT]: "Select Network",
78
+ [ModalStep.ADD_EX_WALLET_SELECTED]: "Add Wallet",
79
+ [ModalStep.EXTERNAL_WALLET_VERIFICATION]: "Verify Wallet",
73
80
  [ModalStep.AWAITING_ACCOUNT]: isLogin ? "Login" : "Sign Up"
74
81
  }),
75
82
  [isLogin, chainId, hideWallets, authStepTitle]
@@ -1,4 +1,5 @@
1
1
  import { CpslIcon, CpslInput, CpslText, CpslTileButton } from '@getpara/react-components';
2
+ import { CommonWallet } from '@getpara/react-common';
2
3
  import { TExternalWallet, TLinkedAccountType, TNetwork, TOnRampAsset, TWalletType } from '@getpara/web-sdk';
3
4
  import { ComponentProps, PropsWithChildren } from 'react';
4
5
  export declare const SpinnerContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -40,7 +41,7 @@ export declare function NetworkIcon({ network, size }: {
40
41
  export declare function WalletTypeIcon({ className, walletType, externalWallet, ...props }: {
41
42
  className?: string;
42
43
  walletType: TWalletType;
43
- externalWallet?: TExternalWallet | string;
44
+ externalWallet?: TExternalWallet | CommonWallet | string;
44
45
  } & Parameters<typeof CpslIcon>[0]): import("react/jsx-runtime").JSX.Element;
45
46
  export declare const ErrorContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
46
47
  export declare const ErrorIcon: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<any, "ref"> & import("react").RefAttributes<any>, "ref"> & {
@@ -177,11 +177,14 @@ function WalletTypeIcon(_c) {
177
177
  "walletType",
178
178
  "externalWallet"
179
179
  ]);
180
- var _a;
180
+ var _a, _b;
181
181
  const isDark = useStore((state) => {
182
- var _a2, _b;
183
- return ((_b = (_a2 = state.modalConfig) == null ? void 0 : _a2.theme) == null ? void 0 : _b.mode) === "dark";
182
+ var _a2, _b2;
183
+ return ((_b2 = (_a2 = state.modalConfig) == null ? void 0 : _a2.theme) == null ? void 0 : _b2.mode) === "dark";
184
184
  });
185
+ if (typeof externalWallet === "object" && "iconUrl" in externalWallet) {
186
+ return /* @__PURE__ */ jsx(CpslIcon, __spreadProps(__spreadValues({ className, src: externalWallet.iconUrl }, props), { inset: (_a = props.inset) != null ? _a : "10%" }));
187
+ }
185
188
  const data = (externalWallet ? ACCOUNT_TYPES[externalWallet] : WALLET_TYPES_METADATA[walletType]) || {
186
189
  icon: "wallet02",
187
190
  isDark: true
@@ -194,7 +197,7 @@ function WalletTypeIcon(_c) {
194
197
  icon: data.icon,
195
198
  invert: isDark && data.isDark
196
199
  }, props), {
197
- inset: (_a = props.inset) != null ? _a : "10%"
200
+ inset: (_b = props.inset) != null ? _b : "10%"
198
201
  })
199
202
  );
200
203
  }
@@ -22,6 +22,7 @@ const getActions = (set, get) => ({
22
22
  const previousStep = get().step;
23
23
  const refs = get().refs;
24
24
  set({ step });
25
+ refs.currentStep.current = step;
25
26
  onModalStepChange == null ? void 0 : onModalStepChange({ previousStep, currentStep: step, canGoBack: get().hasPreviousStep() });
26
27
  if (step === ModalStep.ACCOUNT_MAIN) {
27
28
  refs.wasSignedIn.current = true;
@@ -57,6 +58,7 @@ const getActions = (set, get) => ({
57
58
  step: prevStep,
58
59
  stepDirection: -1
59
60
  }, prevStep === ModalStep.AUTH_MAIN && { flow: void 0 }));
61
+ refs.currentStep.current = prevStep;
60
62
  onModalStepChange == null ? void 0 : onModalStepChange({ previousStep: currentStep, currentStep: prevStep, canGoBack: get().hasPreviousStep() });
61
63
  }
62
64
  (_a = refs.popupWindow.current) == null ? void 0 : _a.close();
@@ -71,7 +73,9 @@ const getActions = (set, get) => ({
71
73
  }
72
74
  return !!getPreviousStep(flow, currentStep);
73
75
  },
74
- setFlow: (flow) => set({ flow }),
76
+ setFlow: (flow) => {
77
+ set({ flow });
78
+ },
75
79
  isLogin: () => get().flow === "login",
76
80
  isAccount: () => get().flow === "account",
77
81
  setAuthState: (authState) => {
@@ -40,7 +40,11 @@ export declare enum ModalStep {
40
40
  ACCOUNT_PROFILE_LIST = "ACCOUNT_PROFILE_LIST",
41
41
  ACCOUNT_PROFILE_REMOVE = "ACCOUNT_PROFILE_REMOVE",
42
42
  AWAITING_ACCOUNT = "AWAITING_ACCOUNT",
43
- OTP = "OTP"
43
+ OTP = "OTP",
44
+ ADD_EX_WALLET_MORE = "ADD_EX_WALLET_MORE",
45
+ ADD_EX_WALLET_SELECTED = "ADD_EX_WALLET_SELECTED",
46
+ ADD_EX_WALLET_NETWORK_SELECT = "ADD_EX_WALLET_NETWORK_SELECT",
47
+ LINK_EX_WALLET_NETWORK_SELECT = "LINK_EX_WALLET_NETWORK_SELECT"
44
48
  }
45
49
  export type ModalStepPropU = keyof typeof ModalStep | ModalStep;
46
50
  export type ModalStepPropL = Lowercase<ModalStepPropU>;
@@ -58,7 +62,11 @@ declare enum AccountStep {
58
62
  ACCOUNT_PROFILE = "ACCOUNT_PROFILE",
59
63
  ACCOUNT_PROFILE_ADD = "ACCOUNT_PROFILE_ADD",
60
64
  ACCOUNT_PROFILE_LIST = "ACCOUNT_PROFILE_LIST",
61
- ACCOUNT_PROFILE_REMOVE = "ACCOUNT_PROFILE_REMOVE"
65
+ ACCOUNT_PROFILE_REMOVE = "ACCOUNT_PROFILE_REMOVE",
66
+ EXTERNAL_WALLET_VERIFICATION = "EXTERNAL_WALLET_VERIFICATION",
67
+ ADD_EX_WALLET_MORE = "ADD_EX_WALLET_MORE",
68
+ ADD_EX_WALLET_SELECTED = "ADD_EX_WALLET_SELECTED",
69
+ ADD_EX_WALLET_NETWORK_SELECT = "ADD_EX_WALLET_NETWORK_SELECT"
62
70
  }
63
71
  export declare const RESET_TO_AUTH_STEPS: ModalStep[];
64
72
  export declare const RESET_TO_ACCOUNT_STEPS: ModalStep[];
@@ -42,6 +42,10 @@ var ModalStep = /* @__PURE__ */ ((ModalStep2) => {
42
42
  ModalStep2["ACCOUNT_PROFILE_REMOVE"] = "ACCOUNT_PROFILE_REMOVE";
43
43
  ModalStep2["AWAITING_ACCOUNT"] = "AWAITING_ACCOUNT";
44
44
  ModalStep2["OTP"] = "OTP";
45
+ ModalStep2["ADD_EX_WALLET_MORE"] = "ADD_EX_WALLET_MORE";
46
+ ModalStep2["ADD_EX_WALLET_SELECTED"] = "ADD_EX_WALLET_SELECTED";
47
+ ModalStep2["ADD_EX_WALLET_NETWORK_SELECT"] = "ADD_EX_WALLET_NETWORK_SELECT";
48
+ ModalStep2["LINK_EX_WALLET_NETWORK_SELECT"] = "LINK_EX_WALLET_NETWORK_SELECT";
45
49
  return ModalStep2;
46
50
  })(ModalStep || {});
47
51
  var AccountStep = /* @__PURE__ */ ((AccountStep2) => {
@@ -58,10 +62,13 @@ var AccountStep = /* @__PURE__ */ ((AccountStep2) => {
58
62
  AccountStep2["ACCOUNT_PROFILE_ADD"] = "ACCOUNT_PROFILE_ADD";
59
63
  AccountStep2["ACCOUNT_PROFILE_LIST"] = "ACCOUNT_PROFILE_LIST";
60
64
  AccountStep2["ACCOUNT_PROFILE_REMOVE"] = "ACCOUNT_PROFILE_REMOVE";
65
+ AccountStep2["EXTERNAL_WALLET_VERIFICATION"] = "EXTERNAL_WALLET_VERIFICATION";
66
+ AccountStep2["ADD_EX_WALLET_MORE"] = "ADD_EX_WALLET_MORE";
67
+ AccountStep2["ADD_EX_WALLET_SELECTED"] = "ADD_EX_WALLET_SELECTED";
68
+ AccountStep2["ADD_EX_WALLET_NETWORK_SELECT"] = "ADD_EX_WALLET_NETWORK_SELECT";
61
69
  return AccountStep2;
62
70
  })(AccountStep || {});
63
71
  const RESET_TO_AUTH_STEPS = [
64
- "EX_WALLET_MORE" /* EX_WALLET_MORE */,
65
72
  "EX_WALLET_SELECTED" /* EX_WALLET_SELECTED */,
66
73
  "EX_WALLET_NETWORK_SELECT" /* EX_WALLET_NETWORK_SELECT */,
67
74
  "VERIFICATIONS" /* VERIFICATIONS */,
@@ -84,7 +91,6 @@ const RESET_TO_AUTH_STEPS = [
84
91
  "SETUP_2FA" /* SETUP_2FA */,
85
92
  "VERIFY_2FA" /* VERIFY_2FA */,
86
93
  "TWO_FACTOR_DONE" /* TWO_FACTOR_DONE */,
87
- "LOGIN_DONE" /* LOGIN_DONE */,
88
94
  "OTP" /* OTP */
89
95
  ];
90
96
  const RESET_TO_ACCOUNT_STEPS = [
@@ -99,7 +105,12 @@ const RESET_TO_ACCOUNT_STEPS = [
99
105
  "ACCOUNT_PROFILE" /* ACCOUNT_PROFILE */,
100
106
  "ACCOUNT_PROFILE_ADD" /* ACCOUNT_PROFILE_ADD */,
101
107
  "ACCOUNT_PROFILE_LIST" /* ACCOUNT_PROFILE_LIST */,
102
- "ACCOUNT_PROFILE_REMOVE" /* ACCOUNT_PROFILE_REMOVE */
108
+ "ACCOUNT_PROFILE_REMOVE" /* ACCOUNT_PROFILE_REMOVE */,
109
+ "ADD_EX_WALLET_MORE" /* ADD_EX_WALLET_MORE */,
110
+ "ADD_EX_WALLET_SELECTED" /* ADD_EX_WALLET_SELECTED */,
111
+ "ADD_EX_WALLET_NETWORK_SELECT" /* ADD_EX_WALLET_NETWORK_SELECT */,
112
+ "LINK_EX_WALLET_NETWORK_SELECT" /* LINK_EX_WALLET_NETWORK_SELECT */,
113
+ "EXTERNAL_WALLET_VERIFICATION" /* EXTERNAL_WALLET_VERIFICATION */
103
114
  ];
104
115
  const AccountPreviousStep = {
105
116
  ["ACCOUNT_MAIN" /* ACCOUNT_MAIN */]: void 0,
@@ -114,7 +125,11 @@ const AccountPreviousStep = {
114
125
  ["ACCOUNT_PROFILE" /* ACCOUNT_PROFILE */]: "ACCOUNT_MAIN" /* ACCOUNT_MAIN */,
115
126
  ["ACCOUNT_PROFILE_LIST" /* ACCOUNT_PROFILE_LIST */]: "ACCOUNT_PROFILE" /* ACCOUNT_PROFILE */,
116
127
  ["ACCOUNT_PROFILE_ADD" /* ACCOUNT_PROFILE_ADD */]: "ACCOUNT_PROFILE_LIST" /* ACCOUNT_PROFILE_LIST */,
117
- ["ACCOUNT_PROFILE_REMOVE" /* ACCOUNT_PROFILE_REMOVE */]: "ACCOUNT_PROFILE" /* ACCOUNT_PROFILE */
128
+ ["ACCOUNT_PROFILE_REMOVE" /* ACCOUNT_PROFILE_REMOVE */]: "ACCOUNT_PROFILE" /* ACCOUNT_PROFILE */,
129
+ ["EXTERNAL_WALLET_VERIFICATION" /* EXTERNAL_WALLET_VERIFICATION */]: "EX_WALLET_SELECTED" /* EX_WALLET_SELECTED */,
130
+ ["ADD_EX_WALLET_MORE" /* ADD_EX_WALLET_MORE */]: "ACCOUNT_PROFILE" /* ACCOUNT_PROFILE */,
131
+ ["ADD_EX_WALLET_SELECTED" /* ADD_EX_WALLET_SELECTED */]: "ADD_EX_WALLET_MORE" /* ADD_EX_WALLET_MORE */,
132
+ ["ADD_EX_WALLET_NETWORK_SELECT" /* ADD_EX_WALLET_NETWORK_SELECT */]: "ADD_EX_WALLET_MORE" /* ADD_EX_WALLET_MORE */
118
133
  };
119
134
  var SignUpModalStep = /* @__PURE__ */ ((SignUpModalStep2) => {
120
135
  SignUpModalStep2["AUTH_MAIN"] = "AUTH_MAIN";
@@ -5,7 +5,7 @@ import { CosmosExternalWalletProvider } from "../providers/CosmosExternalWalletP
5
5
  import { useInternalClient } from "../hooks/utils/useInternalClient.js";
6
6
  import { useStore } from "../stores/useStore.js";
7
7
  import { COSMOS_WALLETS } from "@getpara/web-sdk";
8
- import { useWallet } from "../hooks/index.js";
8
+ import { useWalletState } from "../hooks/index.js";
9
9
  const CosmosWalletWrapper = ({
10
10
  children,
11
11
  cosmosConnectorConfig,
@@ -13,7 +13,7 @@ const CosmosWalletWrapper = ({
13
13
  onSwitchWallet
14
14
  }) => {
15
15
  const para = useInternalClient();
16
- const { data: wallet } = useWallet();
16
+ const { selectedWallet } = useWalletState();
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 COSMOS_WALLETS);
@@ -27,7 +27,7 @@ const CosmosWalletWrapper = ({
27
27
  onSwitchWallet,
28
28
  para,
29
29
  walletsWithFullAuth: externalWalletsWithFullAuth,
30
- connectedWallet: wallet,
30
+ connectedWallet: (selectedWallet == null ? void 0 : selectedWallet.id) ? { id: selectedWallet.id, type: selectedWallet.type } : null,
31
31
  connectionOnly,
32
32
  includeWalletVerification
33
33
  },
@@ -5,7 +5,7 @@ import { EvmExternalWalletProvider } from "../providers/EvmExternalWalletProvide
5
5
  import { useInternalClient } from "../hooks/utils/useInternalClient.js";
6
6
  import { useStore } from "../stores/useStore.js";
7
7
  import { EVM_WALLETS } from "@getpara/web-sdk";
8
- import { useWallet } from "../hooks/index.js";
8
+ import { useWalletState } from "../hooks/index.js";
9
9
  const EvmWalletWrapper = ({
10
10
  children,
11
11
  evmProviderConfig,
@@ -13,7 +13,7 @@ const EvmWalletWrapper = ({
13
13
  onSwitchWallet
14
14
  }) => {
15
15
  const para = useInternalClient();
16
- const { data: wallet } = useWallet();
16
+ const { selectedWallet } = useWalletState();
17
17
  const externalWalletsWithFullAuth = useStore((state) => state.externalWalletsWithFullAuth);
18
18
  const wallets = useStore((state) => state.externalWallets);
19
19
  const connectionOnly = useStore((state) => state.connectionOnly);
@@ -27,7 +27,7 @@ const EvmWalletWrapper = ({
27
27
  onSwitchWallet,
28
28
  para,
29
29
  walletsWithFullAuth: externalWalletsWithFullAuth,
30
- connectedWallet: wallet,
30
+ connectedWallet: (selectedWallet == null ? void 0 : selectedWallet.id) ? { id: selectedWallet.id, type: selectedWallet.type } : null,
31
31
  connectionOnly,
32
32
  includeWalletVerification
33
33
  },
@@ -73,7 +73,6 @@ const AccountLinkProvider = ({ children }) => {
73
73
  const account = useAccount();
74
74
  const { data: coreAccountLinkInProgress } = useAccountLinkInProgress();
75
75
  const {
76
- wallet: connectedWallet,
77
76
  wallets,
78
77
  signMessage,
79
78
  isSigningMessage,
@@ -152,9 +151,6 @@ const AccountLinkProvider = ({ children }) => {
152
151
  }
153
152
  const providerId = supportedWalletId != null ? supportedWalletId : args.externalWallet.provider;
154
153
  const type = args.externalWallet.type;
155
- if (providerId === (connectedWallet == null ? void 0 : connectedWallet.id)) {
156
- throw new Error(`Cannot link the currently connected external wallet: ${providerId}`);
157
- }
158
154
  setAccountLinkInProgress({
159
155
  type: "EXTERNAL_WALLET",
160
156
  pendingWalletProvider: providerId,
@@ -164,7 +160,7 @@ const AccountLinkProvider = ({ children }) => {
164
160
  if (!linkWallet) {
165
161
  throw new Error(`wallet not installed: ${providerId}`);
166
162
  }
167
- openModal({ step: !type ? ModalStep.EX_WALLET_NETWORK_SELECT : ModalStep.ACCOUNT_PROFILE_ADD });
163
+ openModal({ step: !type ? ModalStep.LINK_EX_WALLET_NETWORK_SELECT : ModalStep.ACCOUNT_PROFILE_ADD });
168
164
  if (!type) {
169
165
  return;
170
166
  }
@@ -316,15 +312,26 @@ const AccountLinkProvider = ({ children }) => {
316
312
  break;
317
313
  }
318
314
  };
319
- const onAccountLinkVerified = (updatedAccounts) => {
315
+ const onAccountLinkVerified = (updatedAccounts) => __async(void 0, null, function* () {
320
316
  queryClient.invalidateQueries({ queryKey: [LINKED_ACCOUNTS_BASE_KEY] });
321
317
  queryClient.setQueryData(["getLinkedAccounts"], () => updatedAccounts);
318
+ if ((accountLinkInProgress == null ? void 0 : accountLinkInProgress.type) === "EXTERNAL_WALLET" && accountLinkInProgress.externalWallet) {
319
+ try {
320
+ yield disconnectBase(
321
+ accountLinkInProgress.externalWallet.providerId,
322
+ accountLinkInProgress.externalWallet.type
323
+ );
324
+ } catch (error) {
325
+ }
326
+ }
322
327
  setTimeout(() => {
323
328
  setStep(ModalStep.ACCOUNT_PROFILE);
329
+ setAccountLinkInProgress(void 0);
324
330
  }, 2e3);
325
- };
331
+ });
326
332
  const onAccountLinkError = (e) => {
327
333
  setLinkAccountError(e instanceof Error ? e.message : e);
334
+ setAccountLinkInProgress(void 0);
328
335
  };
329
336
  const unlinkAccount = (linkedAccount) => {
330
337
  setUnlinkingAccount(linkedAccount);
@@ -23,6 +23,7 @@ export declare const defaultExternalWallet: {
23
23
  username: undefined;
24
24
  avatar: undefined;
25
25
  connectExternalWallet: () => Promise<void>;
26
+ addAdditionalExternalWallet: () => Promise<void>;
26
27
  disconnectExternalWallet: () => Promise<void>;
27
28
  switchChain: () => Promise<void>;
28
29
  setChainIdSwitchingTo: () => void;
@@ -48,6 +49,7 @@ type Value = Omit<ExternalWalletContextType<CosmosSignResult>, 'disconnect' | 's
48
49
  username?: string;
49
50
  avatar?: string;
50
51
  connectExternalWallet: (wallet: CommonWallet, isMobile?: boolean, isManualWalletConnect?: boolean) => Promise<void>;
52
+ addAdditionalExternalWallet: (wallet: CommonWallet) => Promise<void>;
51
53
  disconnectExternalWallet: () => Promise<void>;
52
54
  setChainIdSwitchingTo: (chainId?: string) => void;
53
55
  connectEmbeddedToExternalConnectors: () => Promise<void>;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async,
4
+ __spreadProps,
4
5
  __spreadValues
5
6
  } from "../../chunk-MMUBH76A.js";
6
7
  import { jsx } from "react/jsx-runtime";
@@ -11,6 +12,7 @@ import { useStore } from "../stores/useStore.js";
11
12
  import { ModalStep } from "../../modal/index.js";
12
13
  import { useModalStore } from "../../modal/stores/index.js";
13
14
  import { useAccount, useModal, useParaStatus, useVerifyExternalWallet, useWalletState } from "../hooks/index.js";
15
+ import { ParaEvent, dispatchEvent } from "@getpara/web-sdk";
14
16
  import { useAuthActions } from "./AuthProvider.js";
15
17
  import { IS_FULLY_LOGGED_IN_BASE_KEY } from "../hooks/queries/useIsFullyLoggedIn.js";
16
18
  import { useQueryClient } from "@tanstack/react-query";
@@ -36,6 +38,7 @@ const defaultExternalWallet = {
36
38
  username: void 0,
37
39
  avatar: void 0,
38
40
  connectExternalWallet: () => Promise.resolve(),
41
+ addAdditionalExternalWallet: () => Promise.resolve(),
39
42
  disconnectExternalWallet: () => Promise.resolve(),
40
43
  switchChain: () => Promise.resolve(),
41
44
  setChainIdSwitchingTo: () => {
@@ -396,6 +399,71 @@ function ExternalWalletProvider({ children }) {
396
399
  }),
397
400
  [cosmosSignMessage, evmSignMessage, solanaSignMessage]
398
401
  );
402
+ const addAdditionalExternalWallet = useCallback(
403
+ (wallet2) => __async(this, null, function* () {
404
+ try {
405
+ const walletInfo = yield requestInfo(wallet2.id, wallet2.type);
406
+ const walletAddress = wallet2.type === "COSMOS" && walletInfo.addressBech32 ? walletInfo.addressBech32 : walletInfo.address;
407
+ const walletKey = walletInfo.address;
408
+ const newWallet = __spreadProps(__spreadValues({}, walletInfo), {
409
+ id: walletKey,
410
+ // Use EVM-style address as the key/ID
411
+ address: walletAddress,
412
+ // Use bech32 address for Cosmos, regular for others
413
+ name: wallet2.name,
414
+ // Ensure the name is set from the wallet object
415
+ isExternal: true,
416
+ isExternalWithParaAuth: false,
417
+ externalProviderId: walletInfo.provider || wallet2.name,
418
+ signer: "",
419
+ isExternalConnectionOnly: true,
420
+ isExternalWithVerification: includeWalletVerification
421
+ });
422
+ yield para.setExternalWallets((currentWallets) => {
423
+ const updatedWallets = __spreadProps(__spreadValues({}, currentWallets), {
424
+ [walletKey]: newWallet
425
+ });
426
+ return updatedWallets;
427
+ });
428
+ dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
429
+ try {
430
+ const externalWalletInfo = __spreadProps(__spreadValues({
431
+ partnerId: para.partnerId,
432
+ address: walletInfo.address
433
+ }, wallet2.type === "COSMOS" && walletInfo.addressBech32 && {
434
+ addressBech32: walletInfo.addressBech32
435
+ // Include bech32 address for Cosmos
436
+ }), {
437
+ type: wallet2.type,
438
+ provider: walletInfo.provider,
439
+ providerId: walletInfo.providerId
440
+ // Use the providerId from requestInfo
441
+ });
442
+ const linkResult = yield para.linkAccount({ externalWallet: externalWalletInfo });
443
+ if (linkResult && linkResult.externalWallet && "signatureVerificationMessage" in linkResult.externalWallet) {
444
+ const verificationMessage = linkResult.externalWallet.signatureVerificationMessage;
445
+ const signResult = yield signMessage({
446
+ message: verificationMessage,
447
+ externalWallet: externalWalletInfo
448
+ });
449
+ if (!signResult || !signResult.signature) {
450
+ throw new Error(`Failed to sign ${wallet2.type} message: No signature returned`);
451
+ }
452
+ const { signature: signedMessage, cosmosPublicKeyHex, cosmosSigner } = signResult;
453
+ yield para.verifyExternalWalletLink({ signedMessage, cosmosPublicKeyHex, cosmosSigner });
454
+ } else {
455
+ throw new Error("Unknown error linking external wallet");
456
+ }
457
+ } catch (linkError) {
458
+ }
459
+ yield connectEmbeddedToExternalConnectors();
460
+ setStep(ModalStep.ACCOUNT_PROFILE);
461
+ } catch (error) {
462
+ setExternalWalletError(["Failed to add wallet. Please try again."]);
463
+ }
464
+ }),
465
+ [para, connectionOnly, includeWalletVerification, setStep, setExternalWalletError]
466
+ );
399
467
  const connectExternalWallet = useCallback(
400
468
  (wallet2, isMobileConnect, isManualWalletConnect, isResetAfterManualWalletConnect) => __async(this, null, function* () {
401
469
  if (isExternalWalletConnecting && isManualWalletConnect) {
@@ -486,6 +554,9 @@ function ExternalWalletProvider({ children }) {
486
554
  const externalWallet = yield cosmosRequestInfo(providerId);
487
555
  return externalWallet;
488
556
  }
557
+ default: {
558
+ throw new Error(`Unsupported wallet type: ${type}`);
559
+ }
489
560
  }
490
561
  });
491
562
  const disconnectBase = (providerId, type) => __async(this, null, function* () {
@@ -600,6 +671,7 @@ function ExternalWalletProvider({ children }) {
600
671
  username,
601
672
  avatar,
602
673
  connectExternalWallet,
674
+ addAdditionalExternalWallet,
603
675
  disconnectExternalWallet,
604
676
  switchChain,
605
677
  setChainIdSwitchingTo,
@@ -625,6 +697,7 @@ function ExternalWalletProvider({ children }) {
625
697
  avatar,
626
698
  disconnectExternalWallet,
627
699
  connectExternalWallet,
700
+ addAdditionalExternalWallet,
628
701
  switchChain,
629
702
  setChainIdSwitchingTo,
630
703
  connectEmbeddedToExternalConnectors,
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk-lite",
3
- "version": "2.0.0-alpha.59",
3
+ "version": "2.0.0-alpha.60",
4
4
  "bin": {
5
5
  "setup-para": "dist/cli/cli.mjs"
6
6
  },
7
7
  "dependencies": {
8
- "@getpara/react-common": "2.0.0-alpha.59",
9
- "@getpara/react-components": "2.0.0-alpha.59",
10
- "@getpara/web-sdk": "2.0.0-alpha.59",
8
+ "@getpara/react-common": "2.0.0-alpha.60",
9
+ "@getpara/react-components": "2.0.0-alpha.60",
10
+ "@getpara/web-sdk": "2.0.0-alpha.60",
11
11
  "date-fns": "^3.6.0",
12
12
  "framer-motion": "^11.3.31",
13
13
  "libphonenumber-js": "^1.11.7",
@@ -16,9 +16,9 @@
16
16
  "zustand-sync-tabs": "^0.2.2"
17
17
  },
18
18
  "devDependencies": {
19
- "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.59",
20
- "@getpara/evm-wallet-connectors": "2.0.0-alpha.59",
21
- "@getpara/solana-wallet-connectors": "2.0.0-alpha.59",
19
+ "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.60",
20
+ "@getpara/evm-wallet-connectors": "2.0.0-alpha.60",
21
+ "@getpara/solana-wallet-connectors": "2.0.0-alpha.60",
22
22
  "@tanstack/react-query": "^5.74.0",
23
23
  "@testing-library/dom": "^10.4.0",
24
24
  "@testing-library/react": "^16.3.0",
@@ -38,7 +38,7 @@
38
38
  "package.json",
39
39
  "styles.css"
40
40
  ],
41
- "gitHead": "e15908ac8eafff6f3b264fffa43742870b14b275",
41
+ "gitHead": "b445d9dcf909a9bfa72d4f21b825fcf7c643be0c",
42
42
  "main": "dist/index.js",
43
43
  "peerDependencies": {
44
44
  "@tanstack/react-query": ">=5.0.0",