@getpara/react-sdk-lite 2.1.0 → 2.3.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/modal/components/Account/Account.js +1 -1
- package/dist/modal/components/Account/AccountProfileEntry.js +1 -2
- package/dist/modal/components/Account/AccountSend/AccountSendForm.js +13 -10
- package/dist/modal/components/Account/AccountSend/context.js +11 -2
- package/dist/modal/components/Header/Header.js +2 -2
- package/dist/modal/stores/modal/useModalStore.d.ts +2 -2
- package/dist/modal/stores/modal/useModalStore.js +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +1 -1
- package/package.json +8 -8
|
@@ -95,7 +95,7 @@ const Account = () => {
|
|
|
95
95
|
] }),
|
|
96
96
|
/* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
97
97
|
(onRampConfig.isBuyEnabled || onRampConfig.isReceiveEnabled) && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "plusCircle", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Add Funds" }) }),
|
|
98
|
-
/* @__PURE__ */ jsx(OptionButton, { icon: "send", onClick: handleSendClick, disabled: !profileBalance, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Send" }) }),
|
|
98
|
+
embedded.authType !== "externalWallet" && /* @__PURE__ */ jsx(OptionButton, { icon: "send", onClick: handleSendClick, disabled: !profileBalance, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Send" }) }),
|
|
99
99
|
onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleDown", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) }),
|
|
100
100
|
/* @__PURE__ */ jsx(OptionButton, { icon: "user01", onClick: handleProfileClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: isEnabled ? "Profile" : "Settings" }) })
|
|
101
101
|
] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) })
|
|
@@ -22,7 +22,6 @@ import { useAccountLinking } from "../../../provider/providers/AccountLinkProvid
|
|
|
22
22
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
23
23
|
const AccountProfileEntry = ({
|
|
24
24
|
icon,
|
|
25
|
-
key,
|
|
26
25
|
text,
|
|
27
26
|
textSecondary,
|
|
28
27
|
textTertiary,
|
|
@@ -57,7 +56,7 @@ const AccountProfileEntry = ({
|
|
|
57
56
|
textTertiary && /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "contrast", children: textTertiary }),
|
|
58
57
|
accessory,
|
|
59
58
|
onSelect && /* @__PURE__ */ jsx(CpslIcon, { color: "var(--cpsl-color-foreground-32)", icon: "chevronRight", size: "16px" })
|
|
60
|
-
] }
|
|
59
|
+
] });
|
|
61
60
|
};
|
|
62
61
|
const WalletEntry = ({
|
|
63
62
|
wallet,
|
|
@@ -13,7 +13,7 @@ import { useDebounce } from "../../../hooks/useDebounce.js";
|
|
|
13
13
|
import { AssetNetwork } from "./AssetNetwork.js";
|
|
14
14
|
import { useWalletState } from "../../../../provider/index.js";
|
|
15
15
|
function AccountSendForm() {
|
|
16
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
17
17
|
const { selectedWallet } = useWalletState();
|
|
18
18
|
const setStep = useModalStore((state) => state.setStep);
|
|
19
19
|
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
@@ -48,21 +48,22 @@ function AccountSendForm() {
|
|
|
48
48
|
const dbInputValue = useDebounce(inputValue, 500);
|
|
49
49
|
const isEditing = useRef(false);
|
|
50
50
|
const error = useMemo(() => {
|
|
51
|
-
var _a2;
|
|
51
|
+
var _a2, _b2, _c2;
|
|
52
52
|
const errorRef = (estimate == null ? void 0 : estimate.error) || (broadcast == null ? void 0 : broadcast.error);
|
|
53
53
|
if (!errorRef || estimateIsPending || broadcastIsPending) {
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
56
|
switch (errorRef == null ? void 0 : errorRef.code) {
|
|
57
57
|
case "INSUFFICIENT_NATIVE_BALANCE": {
|
|
58
|
-
const nativeSymbol = (selectedWallet == null ? void 0 : selectedWallet.type) === "EVM" ? "ETH" : "SOL";
|
|
58
|
+
const nativeSymbol = ((_b2 = (_a2 = sendMetadata == null ? void 0 : sendMetadata.network) == null ? void 0 : _a2.metadata) == null ? void 0 : _b2.nativeTokenSymbol) || ((selectedWallet == null ? void 0 : selectedWallet.type) === "EVM" ? "ETH" : "SOL");
|
|
59
|
+
const shouldShowBuyButton = (onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled) && ((selectedWallet == null ? void 0 : selectedWallet.type) === "SOLANA" || (selectedWallet == null ? void 0 : selectedWallet.type) === "EVM" && nativeSymbol === "ETH");
|
|
59
60
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
61
|
/* @__PURE__ */ jsxs(CpslText, { variant: "bodyXS", color: "error", style: { textAlign: (onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled) ? "left" : "center" }, children: [
|
|
61
62
|
"You need ",
|
|
62
|
-
(
|
|
63
|
+
(_c2 = estimate == null ? void 0 : estimate.transferAmount) != null ? _c2 : nativeSymbol,
|
|
63
64
|
" to conduct this transaction"
|
|
64
65
|
] }),
|
|
65
|
-
|
|
66
|
+
shouldShowBuyButton && /* @__PURE__ */ jsxs(
|
|
66
67
|
"button",
|
|
67
68
|
{
|
|
68
69
|
style: {
|
|
@@ -99,14 +100,16 @@ function AccountSendForm() {
|
|
|
99
100
|
selectedWallet == null ? void 0 : selectedWallet.type,
|
|
100
101
|
estimateIsPending,
|
|
101
102
|
broadcastIsPending,
|
|
102
|
-
onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled
|
|
103
|
+
onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled,
|
|
104
|
+
(_d = (_c = sendMetadata == null ? void 0 : sendMetadata.network) == null ? void 0 : _c.metadata) == null ? void 0 : _d.nativeTokenSymbol,
|
|
105
|
+
estimate == null ? void 0 : estimate.transferAmount
|
|
103
106
|
]);
|
|
104
107
|
useEffect(() => {
|
|
105
108
|
var _a2, _b2;
|
|
106
109
|
const isTestnet2 = (_b2 = (_a2 = sendMetadata == null ? void 0 : sendMetadata.network) == null ? void 0 : _a2.metadata) == null ? void 0 : _b2.isTestnet;
|
|
107
110
|
const shouldUseAmountMode2 = !assetPrice || !!assetPrice && isTestnet2;
|
|
108
111
|
setInputMode(shouldUseAmountMode2 ? "AMOUNT" : "VALUE");
|
|
109
|
-
}, [assetPrice, (
|
|
112
|
+
}, [assetPrice, (_f = (_e = sendMetadata == null ? void 0 : sendMetadata.network) == null ? void 0 : _e.metadata) == null ? void 0 : _f.isTestnet]);
|
|
110
113
|
useEffect(() => {
|
|
111
114
|
if (inputMode === "AMOUNT") {
|
|
112
115
|
setTransferAmount(Number(dbInputValue));
|
|
@@ -190,7 +193,7 @@ function AccountSendForm() {
|
|
|
190
193
|
children: [
|
|
191
194
|
/* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "secondary", children: inputMode === "VALUE" ? formatAssetQuantity({
|
|
192
195
|
quantity: isMax && assetAmountOnNetwork ? assetAmountOnNetwork : transferAmount,
|
|
193
|
-
symbol: (
|
|
196
|
+
symbol: (_g = sendMetadata.asset.metadata) == null ? void 0 : _g.symbol
|
|
194
197
|
}) : formatCurrency({
|
|
195
198
|
value: isMax && assetValueOnNetwork ? assetValueOnNetwork.value : Number(transferValue),
|
|
196
199
|
currency: "USD"
|
|
@@ -322,7 +325,7 @@ function AccountSendForm() {
|
|
|
322
325
|
),
|
|
323
326
|
((estimate == null ? void 0 : estimate.feeValue) || (estimate == null ? void 0 : estimate.feeAmount) || estimateIsPending) && /* @__PURE__ */ jsxs("div", { style: { display: "flex", width: "100%", gap: "4px", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
324
327
|
/* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", children: "Network Fee" }),
|
|
325
|
-
/* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "contrast", children: estimateIsPending ? "Estimating..." : (
|
|
328
|
+
/* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "contrast", children: estimateIsPending ? "Estimating..." : (_k = (_j = ((_i = (_h = sendMetadata == null ? void 0 : sendMetadata.network) == null ? void 0 : _h.metadata) == null ? void 0 : _i.isTestnet) ? estimate == null ? void 0 : estimate.feeAmount : estimate == null ? void 0 : estimate.feeValue) != null ? _j : estimate == null ? void 0 : estimate.feeAmount) != null ? _k : "0" })
|
|
326
329
|
] }),
|
|
327
330
|
error && /* @__PURE__ */ jsx("div", { style: { display: "flex", width: "100%", gap: "4px", alignItems: "center", justifyContent: "space-between" }, children: error }),
|
|
328
331
|
/* @__PURE__ */ jsx(
|
|
@@ -331,7 +334,7 @@ function AccountSendForm() {
|
|
|
331
334
|
variant: "primary",
|
|
332
335
|
fullWidth: true,
|
|
333
336
|
pending: estimateIsPending || broadcastIsPending,
|
|
334
|
-
disabled: estimateIsPending || broadcastIsPending || !((
|
|
337
|
+
disabled: estimateIsPending || broadcastIsPending || !((_l = estimate == null ? void 0 : estimate.result) == null ? void 0 : _l.txSerialized) || !!(estimate == null ? void 0 : estimate.error),
|
|
335
338
|
onClick: onSubmit,
|
|
336
339
|
children: "Confirm Send"
|
|
337
340
|
}
|
|
@@ -26,12 +26,15 @@ const getDefaultSendMetadata = (balances, wallet) => {
|
|
|
26
26
|
return { asset: null, network: null };
|
|
27
27
|
}
|
|
28
28
|
const walletBalance = balances.wallets.find(({ address }) => address === (wallet == null ? void 0 : wallet.address));
|
|
29
|
-
if (!walletBalance) {
|
|
29
|
+
if (!walletBalance || walletBalance.assets.length === 0) {
|
|
30
30
|
return { asset: null, network: null };
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
let defaultAsset = walletBalance.assets.find(
|
|
33
33
|
({ metadata }) => (metadata == null ? void 0 : metadata.symbol) === ((wallet == null ? void 0 : wallet.type) === "EVM" ? "ETH" : "SOL")
|
|
34
34
|
);
|
|
35
|
+
if (!defaultAsset) {
|
|
36
|
+
defaultAsset = walletBalance.assets[0];
|
|
37
|
+
}
|
|
35
38
|
if (!defaultAsset) {
|
|
36
39
|
return { asset: null, network: null };
|
|
37
40
|
}
|
|
@@ -58,6 +61,10 @@ const AccountSendContext = createContext({});
|
|
|
58
61
|
function AccountSendProvider({ children, step }) {
|
|
59
62
|
var _a, _b, _c, _d, _e, _f;
|
|
60
63
|
const para = useInternalClient();
|
|
64
|
+
const balancesConfig = useStore((state) => {
|
|
65
|
+
var _a2;
|
|
66
|
+
return (_a2 = state.modalConfig) == null ? void 0 : _a2.balances;
|
|
67
|
+
});
|
|
61
68
|
const setStep = useModalStore((state) => state.setStep);
|
|
62
69
|
const setSendTx = useModalStore((state) => state.setSendTx);
|
|
63
70
|
const { data: balances } = useProfileBalance({ isComprehensive: true });
|
|
@@ -338,6 +345,7 @@ function AccountSendProvider({ children, step }) {
|
|
|
338
345
|
userId: para.userId,
|
|
339
346
|
opts: {
|
|
340
347
|
type: selectedWallet.type === "COSMOS" ? "EVM" : selectedWallet.type,
|
|
348
|
+
config: balancesConfig,
|
|
341
349
|
sourceAddress: selectedWallet.address,
|
|
342
350
|
destinationAddress,
|
|
343
351
|
contractAddress: (_a2 = sendMetadata == null ? void 0 : sendMetadata.network) == null ? void 0 : _a2.contractAddress,
|
|
@@ -349,6 +357,7 @@ function AccountSendProvider({ children, step }) {
|
|
|
349
357
|
});
|
|
350
358
|
}, [
|
|
351
359
|
transferAmount,
|
|
360
|
+
balancesConfig,
|
|
352
361
|
destinationAddress,
|
|
353
362
|
selectedWallet.address,
|
|
354
363
|
selectedWallet.type,
|
|
@@ -38,7 +38,7 @@ const Header = () => {
|
|
|
38
38
|
return /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", initial: false, custom: stepDirection, children: /* @__PURE__ */ jsx(
|
|
39
39
|
Container,
|
|
40
40
|
{
|
|
41
|
-
isVisible: !isControls,
|
|
41
|
+
$isVisible: !isControls,
|
|
42
42
|
custom: stepDirection,
|
|
43
43
|
variants: BODY_MOTION_VARIANTS,
|
|
44
44
|
initial: "enter",
|
|
@@ -61,7 +61,7 @@ const Container = safeStyled(motion.div)`
|
|
|
61
61
|
gap: 8px;
|
|
62
62
|
flex-wrap: wrap;
|
|
63
63
|
height: 24px;
|
|
64
|
-
visibility: ${({ isVisible }) => isVisible ? "visible" : "hidden"};
|
|
64
|
+
visibility: ${({ $isVisible }) => $isVisible ? "visible" : "hidden"};
|
|
65
65
|
`;
|
|
66
66
|
const AuthDisplay = safeStyled.div`
|
|
67
67
|
display: flex;
|
|
@@ -61,7 +61,7 @@ interface ModalState {
|
|
|
61
61
|
isPasskeySupported: boolean;
|
|
62
62
|
accountLinkOptions: SupportedAccountLinks;
|
|
63
63
|
profileWallet?: AvailableWallet;
|
|
64
|
-
sendTx
|
|
64
|
+
sendTx: BroadcastTransactionResult | null;
|
|
65
65
|
}
|
|
66
66
|
export interface ModalActions {
|
|
67
67
|
resetState: () => void;
|
|
@@ -101,7 +101,7 @@ export interface ModalActions {
|
|
|
101
101
|
setIsPasskeySupported: (_: boolean) => void;
|
|
102
102
|
setAccountLinkOptions: (_: SupportedAccountLinks) => void;
|
|
103
103
|
setProfileWallet: (_?: AvailableWallet) => void;
|
|
104
|
-
setSendTx: (_
|
|
104
|
+
setSendTx: (_: BroadcastTransactionResult | null) => void;
|
|
105
105
|
}
|
|
106
106
|
export type ModalStore = ModalState & ModalActions;
|
|
107
107
|
export declare const DEFAULT_MODAL_STATE: Omit<ModalState, 'step' | 'onRampConfig'>;
|
|
@@ -63,7 +63,7 @@ const useEventListeners = ({
|
|
|
63
63
|
queryClient.invalidateQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
|
|
64
64
|
queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
65
65
|
clearSelectedWallet();
|
|
66
|
-
setSendTx(
|
|
66
|
+
setSendTx(null);
|
|
67
67
|
onLogout == null ? void 0 : onLogout(event);
|
|
68
68
|
},
|
|
69
69
|
[queryClient, clearSelectedWallet, setSendTx, onLogout]
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk-lite",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"setup-para": "dist/cli/cli.mjs"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@getpara/react-common": "2.
|
|
9
|
-
"@getpara/react-components": "2.
|
|
10
|
-
"@getpara/web-sdk": "2.
|
|
8
|
+
"@getpara/react-common": "2.3.0",
|
|
9
|
+
"@getpara/react-components": "2.3.0",
|
|
10
|
+
"@getpara/web-sdk": "2.3.0",
|
|
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.
|
|
20
|
-
"@getpara/evm-wallet-connectors": "2.
|
|
21
|
-
"@getpara/solana-wallet-connectors": "2.
|
|
19
|
+
"@getpara/cosmos-wallet-connectors": "2.3.0",
|
|
20
|
+
"@getpara/evm-wallet-connectors": "2.3.0",
|
|
21
|
+
"@getpara/solana-wallet-connectors": "2.3.0",
|
|
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": "
|
|
41
|
+
"gitHead": "c2ecd83fd7b4ede9b5365904a299564df9c79c18",
|
|
42
42
|
"main": "dist/index.js",
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@tanstack/react-query": ">=5.0.0",
|