@getpara/react-sdk-lite 2.0.0-dev.7 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.mjs +26 -1
- package/dist/modal/ParaModal.js +16 -10
- package/dist/modal/components/Account/Account.js +42 -4
- package/dist/modal/components/Account/AccountHeader.js +10 -16
- package/dist/modal/components/Account/AccountProfile.d.ts +1 -1
- package/dist/modal/components/Account/AccountProfile.js +82 -210
- package/dist/modal/components/Account/AccountProfileEntry.d.ts +12 -0
- package/dist/modal/components/Account/AccountProfileEntry.js +220 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.js +15 -4
- package/dist/modal/components/Account/AccountSend/AccountSendAsset.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendAsset.js +94 -0
- package/dist/modal/components/Account/AccountSend/AccountSendForm.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendForm.js +343 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNetwork.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNetwork.js +53 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.js +56 -0
- package/dist/modal/components/Account/AccountSend/AssetNetwork.d.ts +5 -0
- package/dist/modal/components/Account/AccountSend/AssetNetwork.js +36 -0
- package/dist/modal/components/Account/AccountSend/context.d.ts +38 -0
- package/dist/modal/components/Account/AccountSend/context.js +418 -0
- package/dist/modal/components/Account/AccountSend/index.d.ts +4 -0
- package/dist/modal/components/Account/AccountSend/index.js +67 -0
- package/dist/modal/components/Account/AccountWallet.d.ts +1 -0
- package/dist/modal/components/Account/AccountWallet.js +133 -0
- package/dist/modal/components/{WalletSelect/WalletSelect.d.ts → Account/AccountWalletSelect.d.ts} +1 -1
- package/dist/modal/components/{WalletSelect/WalletSelect.js → Account/AccountWalletSelect.js} +20 -6
- package/dist/modal/components/AddFunds/AddFunds.js +3 -2
- package/dist/modal/components/AddFunds/AddFundsAsset.js +7 -6
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +5 -5
- package/dist/modal/components/AddFunds/AddFundsProvider.js +1 -2
- package/dist/modal/components/AddFunds/AddFundsSettings.js +13 -54
- package/dist/modal/components/AddFunds/common.d.ts +0 -14
- package/dist/modal/components/AddFunds/common.js +1 -8
- package/dist/modal/components/AuthInput/AuthInput.js +2 -2
- package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.js +3 -2
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +8 -33
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +5 -2
- package/dist/modal/components/Body/Body.js +81 -48
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +8 -5
- package/dist/modal/components/Controls/ChainSelect.js +1 -2
- package/dist/modal/components/Controls/Controls.js +1 -0
- package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.d.ts +5 -1
- package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js +48 -19
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +5 -2
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +63 -33
- package/dist/modal/components/ExternalWallets/ExternalWallets.d.ts +3 -1
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +22 -12
- package/dist/modal/components/Footer/Footer.js +4 -5
- package/dist/modal/components/Header/Header.js +1 -2
- package/dist/modal/components/Header/hooks/useStepTitle.js +53 -38
- package/dist/modal/components/Hero/Hero.js +5 -3
- package/dist/modal/components/IFrameStep/IFrameStep.js +13 -12
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +4 -1
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -5
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +6 -5
- package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +1 -2
- package/dist/modal/components/QuantityInput.d.ts +9 -0
- package/dist/modal/components/QuantityInput.js +91 -0
- package/dist/modal/components/SearchableButtonList.d.ts +34 -0
- package/dist/modal/components/SearchableButtonList.js +223 -0
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +4 -1
- package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.d.ts +1 -0
- package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.js +10 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +13 -2
- package/dist/modal/components/Waiting/Waiting.d.ts +1 -1
- package/dist/modal/components/Waiting/Waiting.js +7 -2
- package/dist/modal/components/WalletCard/WalletCard.js +2 -3
- package/dist/modal/components/WalletSelectOld/WalletSelectOld.d.ts +7 -1
- package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +33 -12
- package/dist/modal/components/common.d.ts +8 -10
- package/dist/modal/components/common.js +16 -36
- package/dist/modal/hooks/index.d.ts +4 -0
- package/dist/modal/hooks/index.js +5 -0
- package/dist/modal/hooks/useDebounce.d.ts +4 -0
- package/dist/modal/hooks/useDebounce.js +16 -0
- package/dist/modal/hooks/useFarcasterLogin.js +8 -1
- package/dist/modal/hooks/useTelegramLogin.js +4 -0
- package/dist/modal/index.d.ts +1 -1
- package/dist/modal/index.js +1 -1
- package/dist/modal/stores/modal/actions.js +9 -2
- package/dist/modal/stores/modal/useModalStore.d.ts +9 -1
- package/dist/modal/stores/modal/useModalStore.js +6 -2
- package/dist/modal/types/modalProps.d.ts +5 -1
- package/dist/modal/utils/authInputHelpers.js +1 -1
- package/dist/modal/utils/countryCodes.js +50 -1
- package/dist/modal/utils/getWalletDisplayName.js +1 -1
- package/dist/modal/utils/openPopup.d.ts +1 -1
- package/dist/modal/utils/openPopup.js +6 -2
- package/dist/modal/utils/renderTextWithLinks.d.ts +2 -0
- package/dist/modal/utils/renderTextWithLinks.js +34 -0
- package/dist/modal/utils/steps.d.ts +24 -3
- package/dist/modal/utils/steps.js +51 -5
- package/dist/modal/utils/stringFormatters.d.ts +2 -3
- package/dist/modal/utils/stringFormatters.js +11 -7
- package/dist/modal/utils/validatePortalOrigin.d.ts +2 -0
- package/dist/modal/utils/validatePortalOrigin.js +14 -0
- package/dist/provider/ParaProviderMin.js +13 -5
- package/dist/provider/actions/getEmbeddedAccount.d.ts +3 -2
- package/dist/provider/actions/getEmbeddedAccount.js +13 -4
- package/dist/provider/actions/index.d.ts +11 -9
- package/dist/provider/actions/index.js +4 -0
- package/dist/provider/components/CosmosWalletWrapper.js +3 -3
- package/dist/provider/components/EvmWalletWrapper.js +3 -3
- package/dist/provider/components/ExternalWalletWrapper.js +7 -1
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +3 -1
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +3 -1
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +3 -1
- package/dist/provider/hooks/mutations/index.d.ts +2 -0
- package/dist/provider/hooks/mutations/index.js +4 -0
- package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +42 -0
- package/dist/provider/hooks/mutations/useAddAuthMethod.js +59 -0
- package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +5 -5
- package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreateWallet.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +2 -2
- package/dist/provider/hooks/mutations/useEnable2fa.d.ts +2 -2
- package/dist/provider/hooks/mutations/useExportPrivateKey.d.ts +15 -0
- package/dist/provider/hooks/mutations/useExportPrivateKey.js +32 -0
- package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +2 -2
- package/dist/provider/hooks/mutations/useIssueJwt.d.ts +2 -2
- package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +2 -2
- package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +8 -2
- package/dist/provider/hooks/mutations/useLogout.d.ts +2 -2
- package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSetup2fa.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSignMessage.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSignTransaction.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSwitchWallets.d.ts +57 -0
- package/dist/provider/hooks/mutations/useSwitchWallets.js +30 -0
- package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +2 -2
- package/dist/provider/hooks/mutations/useVerify2fa.d.ts +2 -2
- package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +18 -27
- package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +5 -5
- package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +14 -11
- package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +2 -2
- package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +5 -5
- package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +2 -2
- package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +2 -2
- package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +2 -2
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +2 -0
- package/dist/provider/hooks/queries/useAccount.js +58 -24
- package/dist/provider/hooks/queries/useLinkedAccounts.js +4 -2
- package/dist/provider/hooks/queries/useProfileBalance.d.ts +29 -0
- package/dist/provider/hooks/queries/useProfileBalance.js +65 -0
- package/dist/provider/hooks/utils/useAssetInfo.d.ts +3 -0
- package/dist/provider/hooks/utils/useAssetInfo.js +21 -0
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +22 -5
- package/dist/provider/hooks/utils/useModal.js +3 -3
- package/dist/provider/hooks/utils/useWalletState.d.ts +2 -1
- package/dist/provider/hooks/utils/useWalletState.js +2 -1
- package/dist/provider/providers/AccountLinkProvider.js +18 -11
- package/dist/provider/providers/AssetsProvider.d.ts +14 -0
- package/dist/provider/providers/AssetsProvider.js +68 -0
- package/dist/provider/providers/AuthProvider.d.ts +4 -0
- package/dist/provider/providers/AuthProvider.js +187 -43
- package/dist/provider/providers/ExternalWalletProvider.d.ts +19 -5
- package/dist/provider/providers/ExternalWalletProvider.js +363 -44
- package/dist/provider/stores/getters.d.ts +2 -2
- package/dist/provider/stores/slices/modal.js +4 -1
- package/dist/provider/stores/types.d.ts +6 -3
- package/package.json +8 -8
- package/dist/modal/constants/constants.d.ts +0 -35
- package/dist/modal/constants/constants.js +0 -148
- package/dist/modal/utils/routeMobileExternalWallet.d.ts +0 -1
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
|
@@ -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
|
+
};
|
|
@@ -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 {
|
|
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) ||
|
|
32
|
-
|
|
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);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AccountSendAsset(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useMemo, useCallback, memo } from "react";
|
|
5
|
+
import { useWalletState } from "../../../../provider/index.js";
|
|
6
|
+
import { useAssets } from "../../../../provider/providers/AssetsProvider.js";
|
|
7
|
+
import { SearchableButtonList } from "../../SearchableButtonList.js";
|
|
8
|
+
import { useSend } from "./context.js";
|
|
9
|
+
import { CpslIcon } from "@getpara/react-components";
|
|
10
|
+
import { formatAssetQuantity, formatCurrency } from "@getpara/web-sdk";
|
|
11
|
+
import { ModalStep } from "../../../utils/steps.js";
|
|
12
|
+
import { useModalStore } from "../../../stores/index.js";
|
|
13
|
+
import { AssetNetwork } from "./AssetNetwork.js";
|
|
14
|
+
const NetworkIcons = memo(({ networks }) => {
|
|
15
|
+
return /* @__PURE__ */ jsx("div", { style: { position: "relative", height: "12px" }, children: networks.slice(0, 3).map((network, index) => {
|
|
16
|
+
var _a;
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
CpslIcon,
|
|
19
|
+
{
|
|
20
|
+
src: network.metadata.logoUrl,
|
|
21
|
+
size: "16px",
|
|
22
|
+
radius: "full",
|
|
23
|
+
style: {
|
|
24
|
+
borderRadius: "1000px",
|
|
25
|
+
backgroundColor: "var(--cpsl-color-primary)",
|
|
26
|
+
position: "absolute",
|
|
27
|
+
top: 0,
|
|
28
|
+
left: `${index * 8}px`,
|
|
29
|
+
zIndex: 3 - index
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
((_a = network.metadata) == null ? void 0 : _a.logoUrl) || index
|
|
33
|
+
);
|
|
34
|
+
}) });
|
|
35
|
+
});
|
|
36
|
+
NetworkIcons.displayName = "NetworkIcons";
|
|
37
|
+
function AccountSendAsset() {
|
|
38
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
39
|
+
const { profileBalance } = useAssets();
|
|
40
|
+
const { selectedWallet } = useWalletState();
|
|
41
|
+
const { setSendMetadata, setTransferAmount } = useSend();
|
|
42
|
+
const walletAssets = useMemo(() => {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
return (_b = (_a = profileBalance == null ? void 0 : profileBalance.wallets.find((wallet) => wallet.address === (selectedWallet == null ? void 0 : selectedWallet.address))) == null ? void 0 : _a.assets) != null ? _b : [];
|
|
45
|
+
}, [profileBalance, selectedWallet == null ? void 0 : selectedWallet.address]);
|
|
46
|
+
const transformItem = useCallback((item) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const isValued = ((_a = item.value) == null ? void 0 : _a.value) && ((_b = item.value) == null ? void 0 : _b.value) >= 0.01;
|
|
49
|
+
const quantity = formatAssetQuantity({ quantity: item.quantity, symbol: item.metadata.symbol });
|
|
50
|
+
return {
|
|
51
|
+
key: item.metadata.zerionId,
|
|
52
|
+
icon: /* @__PURE__ */ jsx(
|
|
53
|
+
AssetNetwork,
|
|
54
|
+
{
|
|
55
|
+
assetSrc: item.metadata.logoUrl,
|
|
56
|
+
networkSrc: item.networks.length === 1 ? item.networks[0].metadata.logoUrl : void 0,
|
|
57
|
+
size: 48
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
text: item.metadata.symbol,
|
|
61
|
+
textSecondary: item.networks.length > 0 ? item.networks.length === 1 ? item.networks[0].metadata.name : /* @__PURE__ */ jsx(NetworkIcons, { networks: item.networks }) : void 0,
|
|
62
|
+
endText: isValued ? formatCurrency(item.value) : quantity,
|
|
63
|
+
endTextSecondary: isValued ? quantity : void 0
|
|
64
|
+
};
|
|
65
|
+
}, []);
|
|
66
|
+
const searchFilter = useCallback(({ item, searchStr }) => {
|
|
67
|
+
if (!item.metadata) return false;
|
|
68
|
+
const lowerSearchStr = searchStr.toLowerCase();
|
|
69
|
+
return item.metadata.symbol.toLowerCase().includes(lowerSearchStr) || item.metadata.name.toLowerCase().includes(lowerSearchStr);
|
|
70
|
+
}, []);
|
|
71
|
+
const onSelect = useCallback(
|
|
72
|
+
(item) => {
|
|
73
|
+
setTransferAmount(0);
|
|
74
|
+
setSendMetadata({
|
|
75
|
+
asset: item,
|
|
76
|
+
network: item.networks[0]
|
|
77
|
+
});
|
|
78
|
+
setStep(item.networks.length > 1 ? ModalStep.ACCOUNT_SEND_NETWORK : ModalStep.ACCOUNT_SEND);
|
|
79
|
+
},
|
|
80
|
+
[setTransferAmount, setSendMetadata, setStep]
|
|
81
|
+
);
|
|
82
|
+
return /* @__PURE__ */ jsx("div", { style: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
83
|
+
SearchableButtonList,
|
|
84
|
+
{
|
|
85
|
+
items: walletAssets,
|
|
86
|
+
transformItem,
|
|
87
|
+
searchFilter,
|
|
88
|
+
onSelect
|
|
89
|
+
}
|
|
90
|
+
) });
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
AccountSendAsset
|
|
94
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AccountSendForm(): import("react/jsx-runtime").JSX.Element;
|