@getpara/react-sdk 1.10.0 → 1.12.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 +7 -2
- package/dist/modal/components/AddFunds/AddFunds.js +6 -1
- package/dist/modal/components/AddFunds/AddFundsAsset.js +4 -0
- package/dist/modal/components/AddFunds/AddFundsReceive.js +17 -4
- package/dist/modal/components/Body/Body.js +2 -0
- package/dist/modal/hooks/useWalletBalance.js +7 -5
- package/dist/modal/providers/ExternalWalletContext.js +1 -1
- package/dist/provider/actions/createGuestWallets.d.ts +2 -0
- package/dist/provider/actions/createGuestWallets.js +13 -0
- package/dist/provider/actions/getAccount.d.ts +1 -0
- package/dist/provider/actions/getAccount.js +1 -0
- package/dist/provider/hooks/mutations/index.d.ts +1 -0
- package/dist/provider/hooks/mutations/index.js +2 -0
- package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +15 -0
- package/dist/provider/hooks/mutations/useCreateGuestWallets.js +23 -0
- package/dist/provider/hooks/queries/useAccount.d.ts +1 -0
- package/package.json +8 -7
|
@@ -12,15 +12,19 @@ import { useState } from "react";
|
|
|
12
12
|
import { ModalStep } from "../../utils/steps.js";
|
|
13
13
|
import { useWalletBalance } from "../../hooks/useWalletBalance.js";
|
|
14
14
|
import { formatBalanceString } from "../../utils/stringFormatters.js";
|
|
15
|
+
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
15
16
|
const Account = ({ onClose }) => {
|
|
16
17
|
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
17
18
|
const setStep = useModalStore((state) => state.setStep);
|
|
19
|
+
const setFlow = useModalStore((state) => state.setFlow);
|
|
18
20
|
const setOnRampStep = useModalStore((state) => state.setOnRampStep);
|
|
19
21
|
const hideWallets = useThemeStore((state) => state.hideWallets);
|
|
20
22
|
const { disconnectExternalWallet } = useExternalWallets();
|
|
21
23
|
const { balance, isLoading: isBalanceLoading } = useWalletBalance();
|
|
24
|
+
const para = useInternalClient();
|
|
22
25
|
const [isDisconnecting, setIsDisconnecting] = useState(false);
|
|
23
26
|
const isOnRampLoaded = !!onRampConfig;
|
|
27
|
+
const canBuyAndWithdraw = !!para.userId;
|
|
24
28
|
const handleBuyClick = () => {
|
|
25
29
|
setOnRampStep(OnRampStep.SETTINGS);
|
|
26
30
|
setStep(ModalStep.ADD_FUNDS_BUY);
|
|
@@ -37,14 +41,15 @@ const Account = ({ onClose }) => {
|
|
|
37
41
|
yield disconnectExternalWallet();
|
|
38
42
|
onClose();
|
|
39
43
|
setStep(ModalStep.AUTH_MAIN);
|
|
44
|
+
setFlow(void 0);
|
|
40
45
|
setIsDisconnecting(false);
|
|
41
46
|
});
|
|
42
47
|
return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
43
48
|
isBalanceLoading ? /* @__PURE__ */ jsx(BalanceContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, { size: 39 }) }) : balance !== void 0 && /* @__PURE__ */ jsx(BalanceContainer, { children: /* @__PURE__ */ jsx(CpslText, { variant: "headingS", weight: "medium", children: formatBalanceString(balance) }) }),
|
|
44
49
|
/* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
|
-
onRampConfig.isBuyEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Buy Crypto" }) }),
|
|
50
|
+
canBuyAndWithdraw && onRampConfig.isBuyEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Buy Crypto" }) }),
|
|
46
51
|
onRampConfig.isReceiveEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "qrCode02", onClick: handleReceiveClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Receive" }) }),
|
|
47
|
-
onRampConfig.isWithdrawEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) })
|
|
52
|
+
canBuyAndWithdraw && onRampConfig.isWithdrawEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) })
|
|
48
53
|
] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) }),
|
|
49
54
|
/* @__PURE__ */ jsx(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: handleDisconnectClick, disabled: isDisconnecting, children: isDisconnecting ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
50
55
|
hideWallets ? "Logout" : "Disconnect Wallet",
|
|
@@ -15,14 +15,19 @@ import { AddFundsReceive } from "./AddFundsReceive.js";
|
|
|
15
15
|
import { AddFundsContextProvider, TABS } from "./AddFundsContext.js";
|
|
16
16
|
import { AnimatePresence } from "framer-motion";
|
|
17
17
|
import { AddFundsSettings } from "./AddFundsSettings.js";
|
|
18
|
+
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
18
19
|
const AddFunds = () => {
|
|
19
20
|
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
20
21
|
const onRampStep = useModalStore((state) => state.onRampStep);
|
|
21
22
|
const storedTab = useModalStore((state) => state.accountAddFundTab);
|
|
22
23
|
const setModalStep = useModalStore((state) => state.setStep);
|
|
23
24
|
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
25
|
+
const para = useInternalClient();
|
|
24
26
|
const activeWallet = useActiveWallet();
|
|
25
|
-
const
|
|
27
|
+
const canBuyAndWithdraw = !!para.userId;
|
|
28
|
+
const tabs = TABS.filter(
|
|
29
|
+
([, key]) => !!(onRampConfig == null ? void 0 : onRampConfig[key]) && (["isBuyEnabled", "isWithdrawEnabled"].includes(key) && canBuyAndWithdraw || !["isBuyEnabled", "isWithdrawEnabled"].includes(key))
|
|
30
|
+
);
|
|
26
31
|
const tab = storedTab != null ? storedTab : tabs[0][0];
|
|
27
32
|
const isMultiFlow = tabs.length > 1;
|
|
28
33
|
const onSetTab = (event) => {
|
|
@@ -40,10 +40,23 @@ function AddFundsReceive() {
|
|
|
40
40
|
copy(address);
|
|
41
41
|
};
|
|
42
42
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43
|
-
/* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsxs(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
/* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsxs(
|
|
44
|
+
FilledDisabledInput,
|
|
45
|
+
{
|
|
46
|
+
noAutoDisable: true,
|
|
47
|
+
readonly: true,
|
|
48
|
+
placeholder: para.getDisplayAddress(activeWallet.id, {
|
|
49
|
+
truncate: true,
|
|
50
|
+
addressType: activeWallet.type,
|
|
51
|
+
targetLength: 16
|
|
52
|
+
}),
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx(CpslIdenticon, { slot: "start", size: "32px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }),
|
|
55
|
+
/* @__PURE__ */ jsx(CpslButton, { slot: "end", variant: "ghost", onClick: onCopy, children: /* @__PURE__ */ jsx(CpslIcon, { icon: isCopied ? "check" : "copy" }) })
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
address
|
|
59
|
+
) }),
|
|
47
60
|
!isMobile() && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
61
|
/* @__PURE__ */ jsx(CpslDivider, { children: "or" }),
|
|
49
62
|
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
@@ -36,6 +36,7 @@ import { useEffect, useState } from "react";
|
|
|
36
36
|
import { TelegramOAuthStep } from "../OAuth/TelegramOAuthStep.js";
|
|
37
37
|
import { AwaitingPasswordStep } from "../AwaitingPasswordStep/AwaitingPasswordStep.js";
|
|
38
38
|
import { IFrameStep } from "../IFrameStep/IFrameStep.js";
|
|
39
|
+
import { NetworkSpeedBanner } from "@getpara/react-common";
|
|
39
40
|
const MIN_HEIGHT = {
|
|
40
41
|
[ModalStep.ADD_FUNDS_AWAITING]: "680px"
|
|
41
42
|
};
|
|
@@ -211,6 +212,7 @@ const Body = ({ oAuthMethods, twoFactorAuthEnabled, disableEmailLogin, disablePh
|
|
|
211
212
|
$step: currentStep,
|
|
212
213
|
$isIFrameStep: IFrameSteps.includes(currentStep),
|
|
213
214
|
children: [
|
|
215
|
+
/* @__PURE__ */ jsx(NetworkSpeedBanner, { fontSize: "12px", iconSize: "16px" }),
|
|
214
216
|
Content(),
|
|
215
217
|
(onRampConfig == null ? void 0 : onRampConfig.testMode) && [
|
|
216
218
|
ModalStep.ADD_FUNDS_BUY,
|
|
@@ -27,11 +27,13 @@ function useWalletBalance() {
|
|
|
27
27
|
setBalance(externalWalletBalance);
|
|
28
28
|
} else {
|
|
29
29
|
try {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
if (rpcUrl) {
|
|
31
|
+
const balance2 = yield client.getWalletBalance({
|
|
32
|
+
walletId: wallet.id,
|
|
33
|
+
rpcUrl
|
|
34
|
+
});
|
|
35
|
+
setBalance(balance2);
|
|
36
|
+
}
|
|
35
37
|
} catch (err) {
|
|
36
38
|
console.error("Error fetching wallet balance: ", err);
|
|
37
39
|
}
|
|
@@ -283,7 +283,7 @@ function ExternalWalletProvider({
|
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
} else if (address) {
|
|
286
|
-
if (externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes(wallet2.id.toUpperCase())) {
|
|
286
|
+
if (!para.externalWalletConnectionOnly && (externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes(wallet2.id.toUpperCase()))) {
|
|
287
287
|
yield completeFullAuth(address, wallet2.type, userExists, isVerified, bufferAddress);
|
|
288
288
|
} else {
|
|
289
289
|
setStep(ModalStep.LOGIN_DONE);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const createGuestWallets = (para, args) => __async(void 0, null, function* () {
|
|
6
|
+
if (!para) {
|
|
7
|
+
throw new Error("no para instance");
|
|
8
|
+
}
|
|
9
|
+
return yield para.createGuestWallets(args);
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
createGuestWallets
|
|
13
|
+
};
|
|
@@ -6,6 +6,7 @@ const getAccount = (para) => __async(void 0, null, function* () {
|
|
|
6
6
|
const isLoggedIn = yield para == null ? void 0 : para.isFullyLoggedIn();
|
|
7
7
|
const resp = {
|
|
8
8
|
isConnected: !!isLoggedIn,
|
|
9
|
+
isGuestMode: para == null ? void 0 : para.isGuestMode,
|
|
9
10
|
email: void 0,
|
|
10
11
|
phone: void 0,
|
|
11
12
|
wallets: void 0
|
|
@@ -8,3 +8,4 @@ export { useLogout } from './useLogout.js';
|
|
|
8
8
|
export { useKeepSessionAlive } from './useKeepSessionAlive.js';
|
|
9
9
|
export { useSignMessage } from './useSignMessage.js';
|
|
10
10
|
export { useSignTransaction } from './useSignTransaction.js';
|
|
11
|
+
export { useCreateGuestWallets } from './useCreateGuestWallets.js';
|
|
@@ -10,8 +10,10 @@ import { useLogout } from "./useLogout.js";
|
|
|
10
10
|
import { useKeepSessionAlive } from "./useKeepSessionAlive.js";
|
|
11
11
|
import { useSignMessage } from "./useSignMessage.js";
|
|
12
12
|
import { useSignTransaction } from "./useSignTransaction.js";
|
|
13
|
+
import { useCreateGuestWallets } from "./useCreateGuestWallets.js";
|
|
13
14
|
export {
|
|
14
15
|
useCheckIfUserExists,
|
|
16
|
+
useCreateGuestWallets,
|
|
15
17
|
useCreateUser,
|
|
16
18
|
useInitiateLogin,
|
|
17
19
|
useKeepSessionAlive,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
|
|
2
|
+
import { createGuestWallets } from '../../actions/createGuestWallets.js';
|
|
3
|
+
import { Compute } from '../../types/utils.js';
|
|
4
|
+
import { UseMutationReturnType } from '../../types/query.js';
|
|
5
|
+
import { CreateGuestWalletsParams } from '@getpara/web-sdk';
|
|
6
|
+
type Data = Awaited<ReturnType<typeof createGuestWallets>>;
|
|
7
|
+
type UseCreateGuestWalletsReturnType<TData = Data, TError = Error, TVariables = CreateGuestWalletsParams, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
|
|
8
|
+
createGuestWallets: UseMutateFunction<TData, TError, TVariables, TContext>;
|
|
9
|
+
createGuestWalletsAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Hook for creating guest mode wallets
|
|
13
|
+
*/
|
|
14
|
+
export declare const useCreateGuestWallets: () => UseCreateGuestWalletsReturnType<import("@getpara/web-sdk").Wallet[], Error, CreateGuestWalletsParams, unknown>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useMutation } from "@tanstack/react-query";
|
|
6
|
+
import { useClient } from "../index.js";
|
|
7
|
+
import { createGuestWallets } from "../../actions/createGuestWallets.js";
|
|
8
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
9
|
+
const useCreateGuestWallets = () => {
|
|
10
|
+
const client = useClient();
|
|
11
|
+
const mutation = useMutation({
|
|
12
|
+
mutationFn: (args) => __async(void 0, null, function* () {
|
|
13
|
+
return yield createGuestWallets(client, args);
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
return renameMutations(
|
|
17
|
+
mutation,
|
|
18
|
+
"createGuestWallets"
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
useCreateGuestWallets
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"*.css"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@getpara/react-common": "1.
|
|
16
|
-
"@getpara/react-components": "1.
|
|
17
|
-
"@getpara/web-sdk": "1.
|
|
15
|
+
"@getpara/react-common": "1.12.0",
|
|
16
|
+
"@getpara/react-components": "1.12.0",
|
|
17
|
+
"@getpara/web-sdk": "1.12.0",
|
|
18
18
|
"@tanstack/react-query": "^5.0.0",
|
|
19
19
|
"date-fns": "^3.6.0",
|
|
20
20
|
"framer-motion": "11.3.28",
|
|
@@ -30,9 +30,10 @@
|
|
|
30
30
|
"test": "vitest run --coverage"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@testing-library/dom": "^10.
|
|
34
|
-
"@testing-library/react": "^16.
|
|
33
|
+
"@testing-library/dom": "^10.4.0",
|
|
34
|
+
"@testing-library/react": "^16.3.0",
|
|
35
35
|
"@testing-library/react-hooks": "^8.0.1",
|
|
36
|
+
"@testing-library/user-event": "^14.6.1",
|
|
36
37
|
"@types/chrome": "^0.0.237",
|
|
37
38
|
"@types/react": "^18.0.31",
|
|
38
39
|
"@types/react-dom": "^18.2.7",
|
|
@@ -50,5 +51,5 @@
|
|
|
50
51
|
"resolutions": {
|
|
51
52
|
"styled-components": "^6"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "748afcf08c9d307a2d3eaf0716f73132f3eb8529"
|
|
54
55
|
}
|