@getpara/react-sdk-lite 2.0.0-alpha.66 → 2.0.0-alpha.67

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.
Files changed (50) hide show
  1. package/dist/modal/components/Account/AccountProfile.js +12 -172
  2. package/dist/modal/components/Account/AccountProfileEntry.d.ts +12 -0
  3. package/dist/modal/components/Account/AccountProfileEntry.js +220 -0
  4. package/dist/modal/components/Account/AccountWallet.d.ts +1 -0
  5. package/dist/modal/components/Account/AccountWallet.js +133 -0
  6. package/dist/modal/components/Body/Body.js +4 -0
  7. package/dist/modal/components/Header/hooks/useStepTitle.js +50 -45
  8. package/dist/modal/stores/modal/actions.js +2 -1
  9. package/dist/modal/stores/modal/useModalStore.d.ts +3 -0
  10. package/dist/modal/stores/modal/useModalStore.js +2 -1
  11. package/dist/modal/utils/steps.d.ts +3 -1
  12. package/dist/modal/utils/steps.js +4 -0
  13. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +3 -1
  14. package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +3 -1
  15. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +3 -1
  16. package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +2 -2
  17. package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +2 -2
  18. package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +2 -2
  19. package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +2 -2
  20. package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +2 -2
  21. package/dist/provider/hooks/mutations/useCreateWallet.d.ts +2 -2
  22. package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +2 -2
  23. package/dist/provider/hooks/mutations/useEnable2fa.d.ts +2 -2
  24. package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +2 -2
  25. package/dist/provider/hooks/mutations/useIssueJwt.d.ts +2 -2
  26. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +2 -2
  27. package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +2 -2
  28. package/dist/provider/hooks/mutations/useLogout.d.ts +2 -2
  29. package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +2 -2
  30. package/dist/provider/hooks/mutations/useSetup2fa.d.ts +2 -2
  31. package/dist/provider/hooks/mutations/useSignMessage.d.ts +2 -2
  32. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +2 -2
  33. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +2 -2
  34. package/dist/provider/hooks/mutations/useSwitchWallets.d.ts +2 -2
  35. package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +2 -2
  36. package/dist/provider/hooks/mutations/useVerify2fa.d.ts +2 -2
  37. package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +2 -2
  38. package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +2 -2
  39. package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +8 -8
  40. package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +2 -2
  41. package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +2 -2
  42. package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +2 -2
  43. package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +2 -2
  44. package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +2 -2
  45. package/dist/provider/hooks/utils/useWalletState.d.ts +1 -1
  46. package/dist/provider/providers/AccountLinkProvider.js +3 -2
  47. package/dist/provider/providers/ExternalWalletProvider.d.ts +10 -4
  48. package/dist/provider/providers/ExternalWalletProvider.js +35 -11
  49. package/dist/provider/stores/getters.d.ts +1 -1
  50. package/package.json +8 -8
@@ -4,78 +4,20 @@ import {
4
4
  __spreadValues
5
5
  } from "../../../chunk-MMUBH76A.js";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- import { AccountTypeIcon, GradientScroll, StepContainer } from "../common.js";
7
+ import { GradientScroll, StepContainer } from "../common.js";
8
8
  import { CpslButton, CpslIcon, CpslText } from "@getpara/react-components";
9
9
  import { useAccount } from "../../../provider/index.js";
10
10
  import { useLinkedAccounts } from "../../../provider/hooks/index.js";
11
- import {
12
- formatAssetQuantity,
13
- formatCurrency,
14
- truncateAddress
15
- } from "@getpara/web-sdk";
16
11
  import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
17
12
  import { useEffect, useMemo } from "react";
18
- import { ACCOUNT_TYPES, safeStyled, useCopyToClipboard, WalletTypeIcon } from "@getpara/react-common";
19
- import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
13
+ import { safeStyled } from "@getpara/react-common";
20
14
  import { useStore } from "../../../provider/stores/useStore.js";
21
- import { useAssets } from "../../../provider/providers/AssetsProvider.js";
22
15
  import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
23
16
  import { useModalStore } from "../../stores/index.js";
24
17
  import { ModalStep } from "../../utils/steps.js";
25
18
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
26
19
  import { Waiting } from "../Waiting/Waiting.js";
27
- const Entry = ({
28
- identifier,
29
- icon,
30
- name,
31
- address,
32
- addressShort,
33
- balance: walletBalance,
34
- onUnlink
35
- }) => {
36
- const balancesConfig = useStore((state) => {
37
- var _a;
38
- return (_a = state.modalConfig) == null ? void 0 : _a.balances;
39
- });
40
- const [isCopied, copy] = useCopyToClipboard();
41
- const balance = useMemo(() => {
42
- var _a;
43
- switch (true) {
44
- case !balancesConfig:
45
- case (balancesConfig == null ? void 0 : balancesConfig.displayType) === "AGGREGATED":
46
- return formatCurrency(walletBalance == null ? void 0 : walletBalance.value);
47
- default:
48
- return formatAssetQuantity({
49
- quantity: (_a = walletBalance == null ? void 0 : walletBalance.assets.find(
50
- ({ metadata }) => !!metadata && metadata.symbol === balancesConfig.asset.symbol
51
- )) == null ? void 0 : _a.quantity,
52
- symbol: balancesConfig.asset.symbol
53
- });
54
- }
55
- }, [balancesConfig, walletBalance]);
56
- return /* @__PURE__ */ jsxs(EntryContainer, { children: [
57
- icon,
58
- /* @__PURE__ */ jsx(EntryDisplayName, { variant: "bodyM", color: "contrast", children: name }),
59
- /* @__PURE__ */ jsx(EntryFlex, { children: address ? /* @__PURE__ */ jsxs(EntryAddress, { children: [
60
- /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "secondary", children: addressShort != null ? addressShort : address }),
61
- /* @__PURE__ */ jsx(
62
- CpslButton,
63
- {
64
- size: "small",
65
- variant: "ghost",
66
- onClick: (e) => {
67
- e.stopPropagation();
68
- e.preventDefault();
69
- copy(address);
70
- },
71
- children: /* @__PURE__ */ jsx(CopyIcon, { id: "ignore-click", slot: "start", isCopied, icon: isCopied ? "check" : "copy" })
72
- }
73
- )
74
- ] }) : null }),
75
- typeof balance === "string" && balance !== "" && /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "contrast", children: balance }),
76
- onUnlink && /* @__PURE__ */ jsx(EntryUnlink, { href: "#", onClick: onUnlink, children: "Unlink" })
77
- ] }, address != null ? address : identifier);
78
- };
20
+ import { AccountLinkEntry, WalletEntry } from "./AccountProfileEntry.js";
79
21
  const AccountProfile = ({
80
22
  isDisconnecting,
81
23
  onDisconnect
@@ -83,13 +25,11 @@ const AccountProfile = ({
83
25
  const para = useInternalClient();
84
26
  const { embedded } = useAccount();
85
27
  const { data: linkedAccounts } = useLinkedAccounts();
86
- const { wallets } = useExternalWallets();
87
- const { isEnabled: isAccountLinkingEnabled, linkAccount, unlinkAccount } = useAccountLinking();
28
+ const { isEnabled: isAccountLinkingEnabled, linkAccount } = useAccountLinking();
88
29
  const hideWallets = useStore((state) => {
89
30
  var _a;
90
31
  return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
91
32
  });
92
- const { profileBalance } = useAssets();
93
33
  const { switchWallets, switchWalletsUrl, setSwitchWalletsUrl, isSwitchWalletsPending } = useAuthActions();
94
34
  const setStep = useModalStore((state) => state.setStep);
95
35
  const partnerGroups = useMemo(() => {
@@ -117,21 +57,13 @@ const AccountProfile = ({
117
57
  }
118
58
  return /* @__PURE__ */ jsxs(StepContainer, { children: [
119
59
  partnerGroups && partnerGroups.length > 0 && /* @__PURE__ */ jsxs(Section, { children: [
120
- partnerGroups.map(({ partner, wallets: wallets2 }) => {
60
+ partnerGroups.map(({ partner, wallets }) => {
121
61
  return /* @__PURE__ */ jsxs(Section, { children: [
122
62
  /* @__PURE__ */ jsxs(Title, { variant: "bodyS", color: "secondary", children: [
123
63
  partner.displayName,
124
64
  " Wallets"
125
65
  ] }),
126
- /* @__PURE__ */ jsx(Content, { children: wallets2.map((wallet) => /* @__PURE__ */ jsx(
127
- Entry,
128
- {
129
- icon: /* @__PURE__ */ jsx(WalletTypeIcon, { walletType: wallet.type, externalWallet: wallet.externalProviderId, size: "24px" }),
130
- name: truncateAddress(wallet.address, wallet.type),
131
- balance: profileBalance == null ? void 0 : profileBalance.wallets.find((w) => w.address === wallet.address)
132
- },
133
- `${wallet.address}-${wallet.type}`
134
- )) })
66
+ /* @__PURE__ */ jsx(Content, { children: wallets.map((wallet) => /* @__PURE__ */ jsx(WalletEntry, { wallet, isSelectable: true }, `${wallet.address}-${wallet.type}`)) })
135
67
  ] }, partner.id);
136
68
  }),
137
69
  !embedded.isGuestMode && /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: switchWallets, disabled: isSwitchWalletsPending, children: isSwitchWalletsPending ? "Please Wait..." : /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -142,30 +74,8 @@ const AccountProfile = ({
142
74
  !embedded.isGuestMode && /* @__PURE__ */ jsxs(Section, { children: [
143
75
  /* @__PURE__ */ jsx(Title, { variant: "bodyS", color: "secondary", children: "Connected Wallets" }),
144
76
  /* @__PURE__ */ jsxs(Content, { children: [
145
- Object.values((para == null ? void 0 : para.externalWallets) || {}).map((wallet) => {
146
- var _a, _b;
147
- const externalWallet = wallets.find((w) => w.name === wallet.name);
148
- return /* @__PURE__ */ jsx(
149
- Entry,
150
- {
151
- icon: /* @__PURE__ */ jsx(
152
- WalletTypeIcon,
153
- {
154
- walletType: wallet.type,
155
- externalWallet: externalWallet != null ? externalWallet : wallet.externalProviderId,
156
- size: "24px",
157
- inset: "0"
158
- }
159
- ),
160
- name: (_b = (_a = wallet.ensName) != null ? _a : wallet.name) != null ? _b : "",
161
- address: wallet.address,
162
- addressShort: wallet.address ? truncateAddress(wallet.address, wallet.type, {
163
- prefix: para.cosmosPrefix
164
- }) : "",
165
- balance: profileBalance == null ? void 0 : profileBalance.wallets.find((w) => w.address === wallet.address)
166
- },
167
- wallet.address
168
- );
77
+ para.availableWallets.filter(({ isExternal }) => isExternal).map((wallet) => {
78
+ return /* @__PURE__ */ jsx(WalletEntry, { wallet, isSelectable: true }, wallet.address);
169
79
  }),
170
80
  /* @__PURE__ */ jsxs(
171
81
  CpslButton,
@@ -189,43 +99,13 @@ const AccountProfile = ({
189
99
  /* @__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 }) => {
190
100
  return !externalWallet || externalWallet.address !== (embedded == null ? void 0 : embedded.externalWalletAddress);
191
101
  }).map((linkedAccount) => {
192
- var _a, _b, _c, _d, _e;
193
- const { identifier, displayName, type, isPrimary = false, externalWallet } = linkedAccount;
194
- const externalWalletConnector = wallets.find(
195
- (wallet) => {
196
- var _a2, _b2;
197
- return wallet.id === (externalWallet == null ? void 0 : externalWallet.providerId) || wallet.id.toLowerCase() === ((_a2 = externalWallet == null ? void 0 : externalWallet.providerId) == null ? void 0 : _a2.toLowerCase()) || wallet.name.toLowerCase() === ((_b2 = externalWallet == null ? void 0 : externalWallet.providerId) == null ? void 0 : _b2.toLowerCase());
198
- }
199
- );
200
- let accountType = type;
201
- let src = void 0;
202
- if (externalWallet) {
203
- if (externalWalletConnector) {
204
- accountType = void 0;
205
- src = externalWalletConnector.iconUrl;
206
- } else if (externalWallet.providerId && ACCOUNT_TYPES[externalWallet.providerId]) {
207
- accountType = externalWallet.providerId;
208
- src = void 0;
209
- } else {
210
- accountType = "EXTERNAL_WALLET";
211
- src = void 0;
212
- }
213
- }
214
102
  return /* @__PURE__ */ jsx(
215
- Entry,
103
+ AccountLinkEntry,
216
104
  {
217
- icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType, src, size: "24px" }),
218
- name: externalWallet ? (_c = (_b = (_a = externalWallet.ensName) != null ? _a : externalWalletConnector == null ? void 0 : externalWalletConnector.name) != null ? _b : externalWallet.provider) != null ? _c : "" : displayName != null ? displayName : identifier,
219
- address: (_d = externalWallet == null ? void 0 : externalWallet.addressBech32) != null ? _d : externalWallet == null ? void 0 : externalWallet.address,
220
- addressShort: externalWallet ? truncateAddress((_e = externalWallet.addressBech32) != null ? _e : externalWallet.address, externalWallet.type, {
221
- prefix: para.cosmosPrefix
222
- }) : void 0,
223
- onUnlink: isPrimary ? void 0 : (e) => {
224
- e.preventDefault();
225
- unlinkAccount(linkedAccount);
226
- }
105
+ accountLink: linkedAccount,
106
+ isPrimary: linkedAccount.isPrimary
227
107
  },
228
- identifier
108
+ linkedAccount.id
229
109
  );
230
110
  }) }),
231
111
  /* @__PURE__ */ jsxs(CpslButton, { fullWidth: true, variant: "tertiary", onClick: () => linkAccount(void 0), children: [
@@ -254,50 +134,10 @@ const Content = safeStyled(Section)`
254
134
  const Title = safeStyled(CpslText)`
255
135
  font-weight: 600;
256
136
  `;
257
- const EntryContainer = safeStyled.div`
258
- overflow: hidden;
259
- position: relative;
260
- width: 100%;
261
- display: flex;
262
- gap: 8px;
263
- align-items: center;
264
- `;
265
- const EntryDisplayName = safeStyled(CpslText)``;
266
- const EntryFlex = safeStyled.div`
267
- flex: 1;
268
- `;
269
- const EntryAddress = safeStyled.div`
270
- display: flex;
271
- gap: 8px;
272
- align-items: center;
273
- `;
274
- const CopyIcon = safeStyled(CpslIcon)`
275
- --width: 16px;
276
- --height: 16px;
277
- --icon-color: ${({ isCopied }) => isCopied ? "var(--cpsl-color-utility-green) !important" : "var(--cpsl-color-text-secondary)"};
278
-
279
- &:hover {
280
- --icon-color: var(--cpsl-color-text-contrast);
281
- }
282
- `;
283
- const EntryUnlink = safeStyled.a`
284
- color: var(--cpsl-color-utility-red);
285
- position: absolute;
286
- right: 0;
287
- text-decoration: none;
288
- font-size: 14px;
289
- font-weight: 500;
290
- font-family: var(--cpsl-font-family);
291
-
292
- &:hover {
293
- text-decoration: underline;
294
- }
295
- `;
296
137
  const DisconnectButton = safeStyled(CpslButton)`
297
138
  --button-border-width: 0px;
298
139
  --button-destructive-hover-background-color: rgba(255, 0, 0, 0.2);
299
140
  --button-destructive-active-background-color: rgba(255, 0, 0, 0.1);
300
-
301
141
  `;
302
142
  export {
303
143
  AccountProfile
@@ -0,0 +1,12 @@
1
+ import { CSSProperties } from 'react';
2
+ import { AvailableWallet, LinkedAccount } from '@getpara/web-sdk';
3
+ export declare const WalletEntry: ({ wallet, isSelectable, style, className, }: {
4
+ wallet: AvailableWallet;
5
+ isSelectable?: boolean;
6
+ style?: CSSProperties;
7
+ className?: string;
8
+ }) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const AccountLinkEntry: ({ accountLink, isPrimary, }: {
10
+ accountLink: LinkedAccount;
11
+ isPrimary?: boolean;
12
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,220 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { useMemo } from "react";
5
+ import { ACCOUNT_TYPES, safeStyled, useCopyToClipboard, WalletTypeIcon } from "@getpara/react-common";
6
+ import { CpslButton, CpslIcon, CpslText } from "@getpara/react-components";
7
+ import {
8
+ formatAssetQuantity,
9
+ formatCurrency,
10
+ truncateAddress
11
+ } from "@getpara/web-sdk";
12
+ import { useStore } from "../../../provider/stores/useStore.js";
13
+ import { useModalStore } from "../../stores/index.js";
14
+ import { useAssets } from "../../../provider/providers/AssetsProvider.js";
15
+ import { ModalStep } from "../../utils/steps.js";
16
+ import { AccountTypeIcon } from "../common.js";
17
+ import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
18
+ import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
19
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
20
+ const AccountProfileEntry = ({
21
+ icon,
22
+ key,
23
+ text,
24
+ textSecondary,
25
+ textTertiary,
26
+ copyString,
27
+ accessory,
28
+ style,
29
+ className,
30
+ onSelect
31
+ }) => {
32
+ const [isCopied, copy] = useCopyToClipboard();
33
+ const Copy = copyString ? /* @__PURE__ */ jsx(
34
+ CpslButton,
35
+ {
36
+ size: "small",
37
+ variant: "ghost",
38
+ onClick: (e) => {
39
+ e.stopPropagation();
40
+ e.preventDefault();
41
+ copy(copyString);
42
+ },
43
+ children: /* @__PURE__ */ jsx(CopyIcon, { id: "ignore-click", slot: "start", isCopied, icon: isCopied ? "check" : "copy" })
44
+ }
45
+ ) : null;
46
+ return /* @__PURE__ */ jsxs(EntryContainer, { onClick: onSelect, className, style, children: [
47
+ icon,
48
+ /* @__PURE__ */ jsx(EntryDisplayName, { variant: "bodyM", color: "contrast", children: text }),
49
+ /* @__PURE__ */ jsx(EntryFlex, { children: textSecondary ? /* @__PURE__ */ jsxs(Fragment, { children: [
50
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "secondary", children: textSecondary }),
51
+ Copy
52
+ ] }) : Copy }),
53
+ textTertiary && /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "contrast", children: textTertiary }),
54
+ accessory,
55
+ onSelect && /* @__PURE__ */ jsx(CpslIcon, { color: "var(--cpsl-color-foreground-32)", icon: "chevronRight", size: "16px" })
56
+ ] }, key);
57
+ };
58
+ const WalletEntry = ({
59
+ wallet,
60
+ isSelectable = false,
61
+ style,
62
+ className
63
+ }) => {
64
+ var _a, _b;
65
+ const { wallets } = useExternalWallets();
66
+ const { profileBalance } = useAssets();
67
+ const balancesConfig = useStore((state) => {
68
+ var _a2;
69
+ return (_a2 = state.modalConfig) == null ? void 0 : _a2.balances;
70
+ });
71
+ const setProfileWallet = useModalStore((state) => state.setProfileWallet);
72
+ const setStep = useModalStore((state) => state.setStep);
73
+ const walletBalance = useMemo(() => {
74
+ return profileBalance == null ? void 0 : profileBalance.wallets.find((w) => w.address === wallet.address);
75
+ }, [profileBalance, wallet.address]);
76
+ const externalWallet = useMemo(
77
+ () => wallets.find((w) => w.id === wallet.externalProviderId),
78
+ [wallets, wallet.externalProviderId]
79
+ );
80
+ const withAddressShort = wallet.ensName || !!wallet.externalProviderId;
81
+ const balance = useMemo(() => {
82
+ var _a2;
83
+ switch (true) {
84
+ case !balancesConfig:
85
+ case (balancesConfig == null ? void 0 : balancesConfig.displayType) === "AGGREGATED":
86
+ return formatCurrency(walletBalance == null ? void 0 : walletBalance.value);
87
+ default:
88
+ return formatAssetQuantity({
89
+ quantity: (_a2 = walletBalance == null ? void 0 : walletBalance.assets.find(
90
+ ({ metadata }) => !!metadata && metadata.symbol === balancesConfig.asset.symbol
91
+ )) == null ? void 0 : _a2.quantity,
92
+ symbol: balancesConfig.asset.symbol
93
+ });
94
+ }
95
+ }, [balancesConfig, walletBalance]);
96
+ return /* @__PURE__ */ jsx(
97
+ AccountProfileEntry,
98
+ {
99
+ icon: /* @__PURE__ */ jsx(
100
+ WalletTypeIcon,
101
+ {
102
+ walletType: wallet.type,
103
+ externalWallet: externalWallet != null ? externalWallet : wallet.externalProviderId,
104
+ size: "24px",
105
+ inset: "0"
106
+ }
107
+ ),
108
+ text: (_b = (_a = wallet.ensName) != null ? _a : wallet.externalProviderId) != null ? _b : wallet.addressShort,
109
+ textSecondary: withAddressShort ? wallet.addressShort : void 0,
110
+ textTertiary: balance,
111
+ copyString: wallet.address,
112
+ style,
113
+ className,
114
+ onSelect: isSelectable ? () => {
115
+ setProfileWallet(wallet);
116
+ setStep(ModalStep.ACCOUNT_WALLET);
117
+ } : void 0
118
+ },
119
+ wallet.address
120
+ );
121
+ };
122
+ const AccountLinkEntry = ({
123
+ accountLink,
124
+ isPrimary = false
125
+ }) => {
126
+ var _a, _b, _c, _d;
127
+ const para = useInternalClient();
128
+ const { wallets } = useExternalWallets();
129
+ const { unlinkAccount } = useAccountLinking();
130
+ const { identifier, displayName, type, externalWallet } = accountLink;
131
+ const externalWalletConnector = wallets.find(
132
+ (wallet) => {
133
+ var _a2, _b2;
134
+ return wallet.id === (externalWallet == null ? void 0 : externalWallet.providerId) || wallet.id.toLowerCase() === ((_a2 = externalWallet == null ? void 0 : externalWallet.providerId) == null ? void 0 : _a2.toLowerCase()) || wallet.name.toLowerCase() === ((_b2 = externalWallet == null ? void 0 : externalWallet.providerId) == null ? void 0 : _b2.toLowerCase());
135
+ }
136
+ );
137
+ let accountType = type;
138
+ let src = void 0;
139
+ let address = void 0;
140
+ let addressShort = void 0;
141
+ if (externalWallet) {
142
+ address = (_a = externalWallet.addressBech32) != null ? _a : externalWallet.address;
143
+ addressShort = truncateAddress(address, externalWallet.type, {
144
+ prefix: para.cosmosPrefix
145
+ });
146
+ if (externalWalletConnector) {
147
+ accountType = void 0;
148
+ src = externalWalletConnector.iconUrl;
149
+ } else if (externalWallet.providerId && ACCOUNT_TYPES[externalWallet.providerId]) {
150
+ accountType = externalWallet.providerId;
151
+ src = void 0;
152
+ } else {
153
+ accountType = "EXTERNAL_WALLET";
154
+ src = void 0;
155
+ }
156
+ }
157
+ return /* @__PURE__ */ jsx(
158
+ AccountProfileEntry,
159
+ {
160
+ icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType, src, size: "24px" }),
161
+ text: externalWallet ? (_d = (_c = (_b = externalWallet.ensName) != null ? _b : externalWalletConnector == null ? void 0 : externalWalletConnector.name) != null ? _c : externalWallet.provider) != null ? _d : "" : displayName != null ? displayName : identifier,
162
+ textSecondary: addressShort,
163
+ copyString: address,
164
+ accessory: isPrimary ? void 0 : /* @__PURE__ */ jsx(
165
+ EntryUnlink,
166
+ {
167
+ href: "#",
168
+ onClick: isPrimary ? void 0 : (e) => {
169
+ e.preventDefault();
170
+ unlinkAccount(accountLink);
171
+ },
172
+ children: "Unlink"
173
+ }
174
+ )
175
+ },
176
+ identifier
177
+ );
178
+ };
179
+ const EntryContainer = safeStyled.div`
180
+ overflow: hidden;
181
+ position: relative;
182
+ width: 100%;
183
+ display: flex;
184
+ gap: 8px;
185
+ align-items: center;
186
+ ${({ onClick }) => onClick ? "cursor: pointer;" : ""}
187
+ `;
188
+ const EntryDisplayName = safeStyled(CpslText)``;
189
+ const EntryFlex = safeStyled.div`
190
+ display: flex;
191
+ gap: 8px;
192
+ align-items: center;
193
+ flex: 1;
194
+ `;
195
+ const CopyIcon = safeStyled(CpslIcon)`
196
+ --width: 16px;
197
+ --height: 16px;
198
+ --icon-color: ${({ isCopied }) => isCopied ? "var(--cpsl-color-utility-green) !important" : "var(--cpsl-color-text-secondary)"};
199
+
200
+ &:hover {
201
+ --icon-color: var(--cpsl-color-text-contrast);
202
+ }
203
+ `;
204
+ const EntryUnlink = safeStyled.a`
205
+ color: var(--cpsl-color-utility-red);
206
+ position: absolute;
207
+ right: 0;
208
+ text-decoration: none;
209
+ font-size: 14px;
210
+ font-weight: 500;
211
+ font-family: var(--cpsl-font-family);
212
+
213
+ &:hover {
214
+ text-decoration: underline;
215
+ }
216
+ `;
217
+ export {
218
+ AccountLinkEntry,
219
+ WalletEntry
220
+ };
@@ -0,0 +1 @@
1
+ export declare const AccountWallet: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,133 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { safeStyled, SpinnerContainer } from "@getpara/react-common";
7
+ import { CpslButton, CpslIcon, CpslSpinner } from "@getpara/react-components";
8
+ import { useModalStore } from "../../stores/modal/useModalStore.js";
9
+ import { WalletEntry } from "./AccountProfileEntry.js";
10
+ import { useEffect, useMemo } from "react";
11
+ import { useAccount, useExportPrivateKey } from "../../../provider/index.js";
12
+ import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
13
+ import { ModalStep } from "../../utils/steps.js";
14
+ const EXPLORERS = {
15
+ EVM: {
16
+ name: "Etherscan",
17
+ url: (address) => `https://etherscan.io/address/${address}`
18
+ },
19
+ SOLANA: {
20
+ name: "Solana Explorer",
21
+ url: (address) => `https://explorer.solana.com/address/${address}`
22
+ },
23
+ COSMOS: {
24
+ name: "Atomscan",
25
+ url: (address) => `https://atomscan.com/accounts/${address}`
26
+ }
27
+ };
28
+ const AccountWallet = () => {
29
+ const profileWallet = useModalStore((state) => state.profileWallet);
30
+ const setProfileWallet = useModalStore((state) => state.setProfileWallet);
31
+ const setStep = useModalStore((state) => state.setStep);
32
+ const { connectionType } = useAccount();
33
+ const { mutate: exportPrivateKey } = useExportPrivateKey();
34
+ const { disconnectBase, evmDisconnectStatus, solanaDisconnectStatus, cosmosDisconnectStatus } = useExternalWallets();
35
+ const disconnectStatus = useMemo(() => {
36
+ if (!(profileWallet == null ? void 0 : profileWallet.isExternal)) {
37
+ return "idle";
38
+ }
39
+ switch (profileWallet.type) {
40
+ case "EVM":
41
+ return evmDisconnectStatus;
42
+ case "SOLANA":
43
+ return solanaDisconnectStatus;
44
+ case "COSMOS":
45
+ default:
46
+ return cosmosDisconnectStatus;
47
+ }
48
+ }, [profileWallet == null ? void 0 : profileWallet.isExternal, profileWallet == null ? void 0 : profileWallet.type, evmDisconnectStatus, solanaDisconnectStatus, cosmosDisconnectStatus]);
49
+ const Content = useMemo(() => {
50
+ if (!profileWallet) {
51
+ return null;
52
+ }
53
+ if (disconnectStatus === "pending") {
54
+ return /* @__PURE__ */ jsx(SpinnerContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, {}) });
55
+ }
56
+ const { name, url } = EXPLORERS[profileWallet.type];
57
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
58
+ /* @__PURE__ */ jsx(
59
+ WalletEntry,
60
+ {
61
+ wallet: profileWallet,
62
+ style: { marginBottom: "16px" }
63
+ },
64
+ `${profileWallet.address}-${profileWallet.type}`
65
+ ),
66
+ typeof window !== "undefined" && /* @__PURE__ */ jsxs(
67
+ CpslButton,
68
+ {
69
+ variant: "tertiary",
70
+ fullWidth: true,
71
+ onClick: () => {
72
+ window.open(url(profileWallet.address), "_blank");
73
+ },
74
+ children: [
75
+ "View wallet on ",
76
+ name,
77
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "linkExternal", slot: "end" })
78
+ ]
79
+ }
80
+ ),
81
+ !profileWallet.isExternal && ["EVM", "COSMOS"].includes(profileWallet.type) && /* @__PURE__ */ jsxs(
82
+ DestructiveButton,
83
+ {
84
+ variant: "destructive",
85
+ fullWidth: true,
86
+ onClick: () => exportPrivateKey({ walletId: profileWallet.id, shouldOpenPopup: true }),
87
+ children: [
88
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "key", slot: "start" }),
89
+ "Export private key"
90
+ ]
91
+ }
92
+ ),
93
+ profileWallet.isExternal && connectionType === "both" && /* @__PURE__ */ jsxs(
94
+ DestructiveButton,
95
+ {
96
+ variant: "destructive",
97
+ fullWidth: true,
98
+ onClick: () => __async(void 0, null, function* () {
99
+ yield disconnectBase(profileWallet.externalProviderId, profileWallet.type, {
100
+ disconnectType: "ACCOUNT_WIDGET"
101
+ });
102
+ setProfileWallet(void 0);
103
+ setStep(ModalStep.ACCOUNT_PROFILE);
104
+ }),
105
+ children: [
106
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "key", slot: "start" }),
107
+ "Disconnect"
108
+ ]
109
+ }
110
+ )
111
+ ] });
112
+ }, [profileWallet, connectionType, disconnectStatus]);
113
+ useEffect(() => {
114
+ return () => {
115
+ setProfileWallet(void 0);
116
+ };
117
+ }, []);
118
+ return /* @__PURE__ */ jsx(Container, { children: Content });
119
+ };
120
+ const Container = safeStyled.div`
121
+ display: flex;
122
+ width: 100%;
123
+ flex-direction: column;
124
+ gap: 12px;
125
+ align-items: flex-start;
126
+ `;
127
+ const DestructiveButton = safeStyled(CpslButton)`
128
+ --button-destructive-hover-background-color: rgba(255, 0, 0, 0.2);
129
+ --button-destructive-active-background-color: rgba(255, 0, 0, 0.1);
130
+ `;
131
+ export {
132
+ AccountWallet
133
+ };
@@ -45,6 +45,7 @@ import { AwaitingAccountStep } from "../AwaitingAccountStep/AwaitingAccountStep.
45
45
  import { SwitchWalletsStep } from "../SwitchWalletsStep/SwitchWalletsStep.js";
46
46
  import { Footer } from "../Footer/Footer.js";
47
47
  import { renderTextWithLinks } from "../../utils/renderTextWithLinks.js";
48
+ import { AccountWallet } from "../Account/AccountWallet.js";
48
49
  const MIN_HEIGHT = {
49
50
  [ModalStep.ADD_FUNDS_AWAITING]: "680px"
50
51
  };
@@ -183,6 +184,9 @@ const Body = ({
183
184
  case ModalStep.ACCOUNT_PROFILE_REMOVE: {
184
185
  return /* @__PURE__ */ jsx(AccountProfileUnlink, {});
185
186
  }
187
+ case ModalStep.ACCOUNT_WALLET: {
188
+ return /* @__PURE__ */ jsx(AccountWallet, {});
189
+ }
186
190
  case ModalStep.EX_WALLET_SELECTED: {
187
191
  return /* @__PURE__ */ jsx(ExternalWalletStep, {});
188
192
  }