@coin-voyage/paykit 2.3.6-beta.2 → 2.4.0-beta.1

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 (45) hide show
  1. package/dist/components/Pages/CardPayment/index.js +1 -1
  2. package/dist/components/Pages/Confirmation/index.js +1 -1
  3. package/dist/components/Pages/PayToAddress/copyable-info.js +1 -1
  4. package/dist/components/Pages/PayWithToken/index.js +2 -1
  5. package/dist/components/Pages/SelectPayToAddressChain/index.js +1 -5
  6. package/dist/components/contexts/pay/index.d.ts +2 -2
  7. package/dist/components/pay-modal/ConnectWithInjector/index.js +5 -5
  8. package/dist/components/pay-modal/index.js +1 -1
  9. package/dist/components/ui/BrowserIcon/index.js +1 -1
  10. package/dist/components/ui/ChainSelectList/index.js +1 -1
  11. package/dist/components/ui/ConnectorList/index.js +2 -2
  12. package/dist/components/ui/CountDownTimer/index.js +1 -1
  13. package/dist/components/ui/Modal/index.js +2 -1
  14. package/dist/components/ui/OrderHeader/index.js +1 -1
  15. package/dist/config/route-config.js +1 -6
  16. package/dist/hooks/useChainOptions.js +1 -1
  17. package/dist/hooks/useDepositAddressQuery.js +1 -1
  18. package/dist/hooks/useMethodOptions.js +3 -3
  19. package/dist/hooks/usePayToAddress.js +1 -1
  20. package/dist/hooks/usePayToAddressChainOptions.d.ts +1 -6
  21. package/dist/hooks/usePayToAddressChainOptions.js +4 -7
  22. package/dist/hooks/usePayToAddressTokens.js +1 -1
  23. package/dist/hooks/usePayWithCard.js +1 -1
  24. package/dist/hooks/usePayWithToken.js +2 -1
  25. package/dist/hooks/usePaymentState.d.ts +2 -2
  26. package/dist/hooks/usePaymentState.js +1 -1
  27. package/dist/hooks/useTokenOptions.js +1 -1
  28. package/dist/hooks/useWalletConnectModal.js +2 -2
  29. package/dist/hooks/useWallets.d.ts +1 -1
  30. package/dist/hooks/useWallets.js +8 -6
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.js +1 -1
  33. package/dist/lib/api/payment-details.js +1 -1
  34. package/dist/lib/config/wallet.d.ts +1 -1
  35. package/dist/lib/config/wallet.js +1 -1
  36. package/dist/providers/paykit-provider.js +2 -2
  37. package/dist/types/payment-details.d.ts +1 -1
  38. package/dist/types/routes.d.ts +1 -2
  39. package/dist/types/routes.js +0 -1
  40. package/dist/types.d.ts +1 -1
  41. package/package.json +3 -3
  42. package/dist/components/Pages/SwitchNetworks/index.d.ts +0 -2
  43. package/dist/components/Pages/SwitchNetworks/index.js +0 -24
  44. package/dist/hooks/useChainIsSupported.d.ts +0 -2
  45. package/dist/hooks/useChainIsSupported.js +0 -19
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getFiatPaymentData } from "@coin-voyage/shared/common";
2
+ import { getFiatPaymentData } from "@coin-voyage/shared/payment";
3
3
  import { PayOrderMode, PayOrderStatus } from "@coin-voyage/shared/types";
4
4
  import { loadStripeOnramp } from "@stripe/crypto/pure";
5
5
  import { useQuery } from "@tanstack/react-query";
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { getChainExplorerTxUrl } from "@coin-voyage/shared/common";
2
+ import { getChainExplorerTxUrl } from "@coin-voyage/shared/chain";
3
3
  import { PayOrderMode, PayOrderStatus } from "@coin-voyage/shared/types";
4
4
  import { useEffect, useMemo } from "react";
5
5
  import { ExternalLinkIcon } from "../../../assets/icons";
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { truncateAddress } from "@coin-voyage/shared/common";
2
+ import { truncateAddress } from "@coin-voyage/shared/utils";
3
3
  import useLocales from "../../../hooks/useLocales";
4
4
  import { CopyRowOrThrobber } from "../../ui/CopyableInfo";
5
5
  import { CountdownTimer } from "../../ui/CountDownTimer";
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useAccount } from "@coin-voyage/crypto/hooks";
3
- import { assert, getChainTypeByChainId } from "@coin-voyage/shared/common";
3
+ import { getChainTypeByChainId } from "@coin-voyage/shared/chain";
4
4
  import { ChainType, PayOrderMode, PayOrderStatus } from "@coin-voyage/shared/types";
5
+ import { assert } from "@coin-voyage/shared/utils";
5
6
  import { AnimatePresence, motion } from "framer-motion";
6
7
  import { useCallback, useEffect, useMemo, useState } from "react";
7
8
  import { useChainId, useSwitchChain } from "wagmi";
@@ -1,14 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import usePayContext from "../../contexts/pay";
3
2
  import { PageContent } from "../../ui/Modal/styles";
4
3
  import { OrderHeader } from "../../ui/OrderHeader";
5
4
  import OptionsList from "../../ui/OptionsList";
6
5
  import PoweredByFooter from "../../ui/PoweredByFooter";
7
6
  import { usePayToAddressChainOptions } from "../../../hooks/usePayToAddressChainOptions";
8
7
  export default function SelectPayToAddressChain() {
9
- const { paymentState } = usePayContext();
10
- const { payOrder } = paymentState;
11
- const fiatAmount = payOrder?.fulfillment.amount.value_usd;
12
- const { options, isLoading } = usePayToAddressChainOptions({ fiatAmount });
8
+ const { options, isLoading } = usePayToAddressChainOptions();
13
9
  return (_jsxs(PageContent, { children: [_jsx(OrderHeader, { minified: true }), _jsx(OptionsList, { isLoading: isLoading, requiredSkeletons: 4, options: options }), _jsx(PoweredByFooter, {})] }));
14
10
  }
@@ -1,5 +1,5 @@
1
- import { useConnectCallbackProps } from "@coin-voyage/crypto/hooks/use-connect-callback";
2
- import { WalletPermission } from "@coin-voyage/crypto/types/wallet";
1
+ import { useConnectCallbackProps } from "@coin-voyage/crypto/hooks";
2
+ import { WalletPermission } from "@coin-voyage/crypto/types";
3
3
  import React from "react";
4
4
  import type { PaymentState } from "../../../hooks/usePaymentState";
5
5
  import type { CustomTheme, Languages, Mode, PayKitOptions, PayModalOptions, Theme } from "../../../types";
@@ -4,12 +4,12 @@ import { useCallback, useEffect, useRef, useState } from "react";
4
4
  import { ConnectingContainer, Container, Content, RetryButton, RetryIconContainer } from "./styles";
5
5
  import Alert from "../../ui/Alert";
6
6
  import Button from "../../ui/Button";
7
- import { ModalBody, ModalContent, ModalContentContainer, ModalH1, ModalHeading, PageContent, } from "../../ui/Modal/styles";
7
+ import { ModalBody, ModalContent, ModalContentContainer, ModalH1, PageContent } from "../../ui/Modal/styles";
8
8
  import Tooltip from "../../ui/Tooltip";
9
9
  import SquircleSpinner from "../../spinners/SquircleSpinner";
10
10
  import { useUniversalConnect } from "@coin-voyage/crypto/hooks";
11
- import { getConnectorId } from "@coin-voyage/crypto/lib/utils/connector";
12
- import { detectBrowser } from "@coin-voyage/shared/common";
11
+ import { getConnectorId } from "@coin-voyage/crypto/utils";
12
+ import { detectBrowser } from "@coin-voyage/shared/utils";
13
13
  import { AlertIcon, RetryIconCircle, TickIcon } from "../../../assets/icons";
14
14
  import useLocales from "../../../hooks/useLocales";
15
15
  import { ROUTE } from "../../../types/routes";
@@ -153,14 +153,14 @@ export default function ConnectWithInjector({ forceState }) {
153
153
  return () => clearTimeout(timeoutId);
154
154
  }, [status, runConnect]);
155
155
  if (!wallet) {
156
- return (_jsx(PageContent, { children: _jsxs(Container, { children: [_jsx(ModalHeading, { children: "Invalid State" }), _jsx(ModalContent, { children: _jsx(Alert, { children: "No connectors match the id given. This state should never happen." }) })] }) }));
156
+ return (_jsx(PageContent, { children: _jsx(Container, { children: _jsxs(ModalContent, { children: [_jsx(ModalH1, { "$error": true, children: "Invalid State" }), _jsx(Alert, { children: "No connectors match the id given. This state should never happen." })] }) }) }));
157
157
  }
158
158
  const connectorId = getConnectorId(wallet.connectors[0].connector);
159
159
  const isWalletConnect = isWalletConnectConnector(connectorId);
160
160
  const isInjected = isInjectedConnector(connectorId);
161
161
  // TODO: Make this more generic
162
162
  if (isWalletConnect) {
163
- return (_jsx(PageContent, { children: _jsxs(Container, { children: [_jsx(ModalHeading, { children: "Invalid State" }), _jsx(ModalContent, { children: _jsx(Alert, { children: "WalletConnect does not have an injection flow. This state should never happen." }) })] }) }));
163
+ return (_jsx(PageContent, { children: _jsx(Container, { children: _jsxs(ModalContent, { children: [_jsx(ModalH1, { "$error": true, children: "Invalid State" }), _jsx(Alert, { children: "WalletConnect does not have an injection flow. This state should never happen." })] }) }) }));
164
164
  }
165
165
  return (_jsx(PageContent, { children: _jsxs(Container, { children: [_jsx(ConnectingContainer, { children: _jsxs(AnimationContainer, { "$shake": status === states.FAILED || status === states.REJECTED, "$circle": walletInfo.iconShape === "circle", children: [_jsx(AnimatePresence, { children: (status === states.FAILED || status === states.REJECTED) && (_jsx(RetryButton, { "aria-label": "Retry", initial: { opacity: 0, scale: 0.8 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.8 }, whileTap: { scale: 0.9 }, transition: { duration: 0.1 }, onClick: runConnect, children: _jsx(RetryIconContainer, { children: _jsx(Tooltip, { open: showTryAgainTooltip && (status === states.FAILED || status === states.REJECTED), message: locales.tryAgainQuestion, xOffset: -6, children: _jsx(RetryIconCircle, {}) }) }) })) }), walletInfo.iconShape === "circle" ? (_jsx(CircleSpinner, { logo: status === states.UNAVAILABLE ? (_jsx("div", { style: {
166
166
  transform: "scale(1.14)",
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getChainTypeName } from "@coin-voyage/shared/common";
2
+ import { getChainTypeName } from "@coin-voyage/shared/chain";
3
3
  import { useCallback, useMemo } from "react";
4
4
  import { routeConfig } from "../../config/route-config";
5
5
  import useLocales from "../../hooks/useLocales";
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from "react";
3
- import { detectBrowser } from "@coin-voyage/shared/common";
3
+ import { detectBrowser } from "@coin-voyage/shared/utils";
4
4
  import { BrowserIconContainer } from "./styles";
5
5
  import browsers from "../../../assets/browsers";
6
6
  const BrowserIcon = React.forwardRef(({ browser }, _ref) => {
@@ -5,7 +5,7 @@ import Alert from "../Alert";
5
5
  import { ChainButton, ChainButtonBg, ChainButtonContainer, ChainButtonStatus, ChainButtons, ChainIcon, ChainLogoContainer, ChainLogoSpinner, SwitchNetworksContainer, } from "./styles";
6
6
  import { AnimatePresence, motion } from "framer-motion";
7
7
  import { isCoinbaseWalletConnector } from "../../../utils";
8
- import { isMobile } from "@coin-voyage/shared/common";
8
+ import { isMobile } from "@coin-voyage/shared/utils";
9
9
  import ChainIcons from "../../../assets/chains";
10
10
  import useLocales from "../../../hooks/useLocales";
11
11
  import { chainConfigs } from "../../../lib/config/chain";
@@ -4,8 +4,8 @@ import { ConnectorButton, ConnectorIcon, ConnectorLabel, ConnectorsContainer, Re
4
4
  import Alert from "../Alert";
5
5
  import { ScrollArea } from "../ScrollArea";
6
6
  import { useLastConnector, useUniversalConnect } from "@coin-voyage/crypto/hooks";
7
- import { isWalletInstalled } from "@coin-voyage/crypto/lib/utils/is-wallet-installed";
8
- import { detectBrowser } from "@coin-voyage/shared/common";
7
+ import { isWalletInstalled } from "@coin-voyage/crypto/utils";
8
+ import { detectBrowser } from "@coin-voyage/shared/utils";
9
9
  import { useIsMobile } from "@coin-voyage/shared/hooks";
10
10
  import { useCallback, useMemo } from "react";
11
11
  import useLocales from "../../../hooks/useLocales";
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { formatTime } from "@coin-voyage/shared/common";
2
+ import { formatTime } from "@coin-voyage/shared/utils";
3
3
  import useLocales from "../../../hooks/useLocales";
4
4
  import CircleTimer from "../CircleTimer";
5
5
  import { ModalBody } from "../Modal/styles";
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getChainTypeName, isMobile } from "@coin-voyage/shared/common";
2
+ import { getChainTypeName } from "@coin-voyage/shared/chain";
3
3
  import { FocusTrap, usePrevious } from "@coin-voyage/shared/hooks";
4
+ import { isMobile } from "@coin-voyage/shared/utils";
4
5
  import useLocales from "../../../hooks/useLocales";
5
6
  import { useThemeContext } from "../../../providers/theme/provider";
6
7
  import { ResetContainer } from "../../../styles";
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useAccount } from "@coin-voyage/crypto/hooks";
3
- import { truncateAddress } from "@coin-voyage/shared/common";
3
+ import { truncateAddress } from "@coin-voyage/shared/utils";
4
4
  import { motion } from "framer-motion";
5
5
  import { Arbitrum, Bitcoin, Ethereum, Optimism, Solana, Sui } from "../../../assets/chains";
6
6
  import { USDC } from "../../../assets/coins";
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getChainName } from "@coin-voyage/shared/common";
2
+ import { getChainName } from "@coin-voyage/shared/chain";
3
3
  import About from "../components/Pages/About";
4
4
  import CardPayment from "../components/Pages/CardPayment";
5
5
  import Confirmation from "../components/Pages/Confirmation";
@@ -14,7 +14,6 @@ import SelectMethod from "../components/Pages/SelectMethod";
14
14
  import SelectPayToAddressChain from "../components/Pages/SelectPayToAddressChain";
15
15
  import SelectPayToAddressToken from "../components/Pages/SelectPayToAddressToken";
16
16
  import SelectToken from "../components/Pages/SelectToken";
17
- import SwitchNetworks from "../components/Pages/SwitchNetworks";
18
17
  import ConnectUsing from "../components/pay-modal/ConnectUsing";
19
18
  import { ROUTE } from "../types/routes";
20
19
  export const routeConfig = {
@@ -126,8 +125,4 @@ export const routeConfig = {
126
125
  depth: 2,
127
126
  onBack: ROUTE.CONNECT,
128
127
  },
129
- [ROUTE.SWITCHNETWORKS]: {
130
- component: _jsx(SwitchNetworks, {}),
131
- heading: (ctx) => ctx.locales.switchNetworkScreen_heading,
132
- },
133
128
  };
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useConfig as useBigmiConfig } from "@bigmi/react";
3
- import { truncateAddress, truncateENSName } from "@coin-voyage/shared/common";
3
+ import { truncateAddress, truncateENSName } from "@coin-voyage/shared/utils";
4
4
  import { ChainType, PayOrderMode } from "@coin-voyage/shared/types";
5
5
  import { useWallets } from "@mysten/dapp-kit";
6
6
  import { useWallet } from "@solana/wallet-adapter-react";
@@ -1,4 +1,4 @@
1
- import { getDepositAddress } from "@coin-voyage/shared/common";
1
+ import { getDepositAddress } from "@coin-voyage/shared/payment";
2
2
  import { useQuery } from "@tanstack/react-query";
3
3
  import usePayContext from "../components/contexts/pay";
4
4
  export function useDepositAddressQuery({ enabled }) {
@@ -39,7 +39,7 @@ export function useMethodOptions({ mode, onClick }) {
39
39
  id: PaymentMethod.WALLET,
40
40
  title: getTitle("with Wallet", isDeposit),
41
41
  iconShape: "squircle",
42
- icons: [_jsx(Logos.MetaMask, {}, "metamask"), _jsx(Logos.Rainbow, {}, "rainbow"), _jsx(Logos.Phantom, {}, "phantom")],
42
+ icons: [_jsx(Logos.MetaMask, {}, "metamask"), _jsx(Logos.Phantom, {}, "phantom"), _jsx(Logos.Slush, { style: { backgroundColor: "#000" } }, "slush")],
43
43
  onClick: () => {
44
44
  setPaymentMethod(PaymentMethod.WALLET);
45
45
  setRoute(ROUTE.WALLET_CHAIN_SELECT);
@@ -52,8 +52,8 @@ export function useMethodOptions({ mode, onClick }) {
52
52
  iconShape: "circle",
53
53
  icons: [
54
54
  _jsx(ChainLogos.Ethereum, {}, "ethereum"),
55
- _jsx(ChainLogos.Base, {}, "base"),
56
- _jsx(ChainLogos.Arbitrum, {}, "arbitrum"),
55
+ _jsx(ChainLogos.Solana, {}, "solana"),
56
+ _jsx(ChainLogos.Sui, {}, "sui"),
57
57
  ],
58
58
  onClick: () => {
59
59
  setPaymentMethod(PaymentMethod.DEPOSIT_ADDRESS);
@@ -1,4 +1,4 @@
1
- import { assert } from "@coin-voyage/shared/common";
1
+ import { assert } from "@coin-voyage/shared/utils";
2
2
  import { fetchPaymentDetails } from "../lib/api/payment-details";
3
3
  import { useBackendApi } from "../components/contexts/api";
4
4
  export function usePayToAddress({ payOrder, setPayOrder, log }) {
@@ -1,14 +1,9 @@
1
- interface UsePayToAddressChainOptionsProps {
2
- fiatAmount: number | undefined;
3
- }
4
- export declare function usePayToAddressChainOptions({ fiatAmount }: UsePayToAddressChainOptionsProps): {
1
+ export declare function usePayToAddressChainOptions(): {
5
2
  options: {
6
3
  id: string;
7
4
  title: string;
8
5
  icons: import("react/jsx-runtime").JSX.Element[];
9
6
  onClick: () => void;
10
- disabled: boolean;
11
7
  }[];
12
8
  isLoading: boolean;
13
9
  };
14
- export {};
@@ -1,20 +1,18 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { fetchTokenList, getChains } from "@coin-voyage/shared/common";
3
- import { ChainId } from "@coin-voyage/shared/types";
2
+ import { fetchTokenList, getChains } from "@coin-voyage/shared/currency";
4
3
  import { useQuery } from "@tanstack/react-query";
5
4
  import { useMemo } from "react";
6
5
  import usePayContext from "../components/contexts/pay";
7
6
  import { SquircleIcon } from "../components/ui/Icon";
8
7
  import { ROUTE } from "../types/routes";
9
- const BTC_MIN_USD_AMOUNT = 15;
10
8
  const TOKEN_LIST_QUERY_KEY = ["token-list"];
11
- export function usePayToAddressChainOptions({ fiatAmount }) {
9
+ export function usePayToAddressChainOptions() {
12
10
  const { setRoute, paymentState } = usePayContext();
13
11
  const { setPayToAddressChainId: setPayToAddressChain } = paymentState;
14
12
  const { data: tokenList, isLoading } = useQuery({
15
13
  queryKey: TOKEN_LIST_QUERY_KEY,
16
14
  queryFn: fetchTokenList,
17
- staleTime: 1000 * 60 * 5,
15
+ staleTime: 1000 * 60 * 15,
18
16
  });
19
17
  const chains = useMemo(() => getChains(tokenList?.chains ?? []), [tokenList]);
20
18
  const options = useMemo(() => chains.map((chain) => ({
@@ -25,7 +23,6 @@ export function usePayToAddressChainOptions({ fiatAmount }) {
25
23
  setPayToAddressChain(chain.chainId);
26
24
  setRoute(ROUTE.ADDRESS_TOKEN_SELECT);
27
25
  },
28
- disabled: chain.chainId === ChainId.BTC && typeof fiatAmount === "number" && fiatAmount < BTC_MIN_USD_AMOUNT,
29
- })), [chains, fiatAmount, setPayToAddressChain, setRoute]);
26
+ })), [chains, setPayToAddressChain, setRoute]);
30
27
  return { options, isLoading };
31
28
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { fetchTokenList, tokensByChainId, tokenToCurrency } from "@coin-voyage/shared/common";
2
+ import { fetchTokenList, tokensByChainId, tokenToCurrency } from "@coin-voyage/shared/currency";
3
3
  import { useQuery } from "@tanstack/react-query";
4
4
  import { useMemo } from "react";
5
5
  import usePayContext from "../components/contexts/pay";
@@ -1,4 +1,4 @@
1
- import { assert } from "@coin-voyage/shared/common";
1
+ import { assert } from "@coin-voyage/shared/utils";
2
2
  import { PaymentRail } from "@coin-voyage/shared/types";
3
3
  import { useBackendApi } from "../components/contexts/api";
4
4
  import { fetchPaymentDetails } from "../lib/api/payment-details";
@@ -1,5 +1,6 @@
1
1
  import { usePrepareTransaction } from "@coin-voyage/crypto/hooks";
2
- import { assert, getDepositAddress, getWalletPaymentData } from "@coin-voyage/shared/common";
2
+ import { getDepositAddress, getWalletPaymentData } from "@coin-voyage/shared/payment";
3
+ import { assert } from "@coin-voyage/shared/utils";
3
4
  import { useBackendApi } from "../components/contexts/api";
4
5
  import { fetchPaymentDetails } from "../lib/api/payment-details";
5
6
  export function usePayFromWallet({ senderAddr, payOrder, setPayOrder, chainType, log }) {
@@ -1,6 +1,6 @@
1
- import { WalletProps } from "@coin-voyage/crypto/types/wallet";
1
+ import { WalletProps } from "@coin-voyage/crypto/types";
2
2
  import { ChainId, ChainType, Currency, CurrencyBase, PaymentMethod, type PayOrder } from "@coin-voyage/shared/types";
3
- import { PaymentDetails, PayOrderParams } from "@coin-voyage/shared/types/api";
3
+ import { PaymentDetails, PayOrderParams } from "@coin-voyage/shared/types";
4
4
  import { ROUTE } from "../types/routes";
5
5
  import { CurrencyAndQuoteID } from "../types/state";
6
6
  import { usePayOrderQuotes } from "./usePayOrderQuotes";
@@ -1,5 +1,5 @@
1
1
  import { useAccount } from "@coin-voyage/crypto/hooks";
2
- import { zPayOrder } from "@coin-voyage/shared/common";
2
+ import { zPayOrder } from "@coin-voyage/shared/schemas";
3
3
  import { ChainType, PayOrderMode } from "@coin-voyage/shared/types";
4
4
  import { useResolveSuiNSName } from "@mysten/dapp-kit";
5
5
  import { useCallback, useState } from "react";
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getChainName } from "@coin-voyage/shared/common";
2
+ import { getChainName } from "@coin-voyage/shared/chain";
3
3
  import usePayContext from "../components/contexts/pay";
4
4
  import TokenChainLogo from "../components/ui/TokenChainLogo";
5
5
  import { ROUTE } from "../types/routes";
@@ -1,6 +1,6 @@
1
1
  import { useUniversalConnect } from "@coin-voyage/crypto/hooks";
2
- import { createWalletConnectConnector } from "@coin-voyage/crypto/lib/connectors/walletConnect";
3
- import { extendsWalletAdapter } from "@coin-voyage/crypto/solana/utils";
2
+ import { createWalletConnectConnector } from "@coin-voyage/crypto/connectors";
3
+ import { extendsWalletAdapter } from "@coin-voyage/crypto/solana";
4
4
  import { ChainType } from "@coin-voyage/shared/types";
5
5
  import { useWallet } from "@solana/wallet-adapter-react";
6
6
  import { useState } from "react";
@@ -1,2 +1,2 @@
1
- import type { WalletProps } from "@coin-voyage/crypto/types/wallet";
1
+ import type { WalletProps } from "@coin-voyage/crypto/types";
2
2
  export declare const useWallets: () => WalletProps[];
@@ -7,13 +7,15 @@ export const useWallets = () => {
7
7
  const { paymentState } = usePayContext();
8
8
  const installedWallets = useInstalledWallets(paymentState.connectorChainType);
9
9
  const wallets = installedWallets.map((wallet) => {
10
- // use overrides
11
- const walletId = Object.keys(walletConfigs).find(
12
- // where id is comma seperated list
13
- (id) => id
10
+ // Match config overrides against canonicalized wallet ids without losing chain-specific variants.
11
+ const matchingWalletIds = Object.keys(walletConfigs).filter((id) => id
14
12
  .split(",")
15
- .map((i) => i.trim())
16
- .indexOf(wallet.id) !== -1);
13
+ .map((i) => i.trim().toLowerCase())
14
+ .includes(wallet.id.toLowerCase()));
15
+ const walletId = matchingWalletIds.find((id) => {
16
+ const chainTypes = walletConfigs[id].chainTypes;
17
+ return !chainTypes || wallet.connectors.some((connector) => chainTypes.includes(connector.chainType));
18
+ }) ?? matchingWalletIds[0];
17
19
  const c = {
18
20
  id: wallet.id,
19
21
  name: wallet.name ?? wallet.id,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { WalletProvider } from "@coin-voyage/crypto/wallets/wallet-provider";
1
+ export { WalletProvider } from "@coin-voyage/crypto/wallets";
2
2
  export { PayButton } from "./components/pay-button";
3
3
  export { PayKitProvider } from "./providers/paykit-provider";
4
4
  export { usePayStatus } from "./hooks/usePayStatus";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { WalletProvider } from "@coin-voyage/crypto/wallets/wallet-provider";
1
+ export { WalletProvider } from "@coin-voyage/crypto/wallets";
2
2
  export { PayButton } from "./components/pay-button";
3
3
  export { PayKitProvider } from "./providers/paykit-provider";
4
4
  export { usePayStatus } from "./hooks/usePayStatus";
@@ -1,4 +1,4 @@
1
- import { assert } from "@coin-voyage/shared/common";
1
+ import { assert } from "@coin-voyage/shared/utils";
2
2
  export async function fetchPaymentDetails(api, params, payOrder) {
3
3
  assert(payOrder != undefined, "PayOrder is required for payment");
4
4
  const { data: paymentDetails, error } = await api.payOrderPaymentDetails(params);
@@ -1,4 +1,4 @@
1
- import { WalletConfigProps } from "@coin-voyage/crypto/types/wallet";
1
+ import { WalletConfigProps } from "@coin-voyage/crypto/types";
2
2
  export declare const walletConfigs: {
3
3
  [rdns: string]: WalletConfigProps;
4
4
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { isAndroid } from "@coin-voyage/shared/common";
2
+ import { isAndroid } from "@coin-voyage/shared/utils";
3
3
  import { ChainType } from "@coin-voyage/shared/types";
4
4
  import Logos from "../../assets/logos";
5
5
  import MobileWithLogos from "../../assets/mobile-with-logos";
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getDepositAddress, getFiatPaymentStep, getWalletPaymentStep } from "@coin-voyage/shared/common";
3
- import { useInWagmiContext } from "@coin-voyage/crypto/evm/provider/provider";
2
+ import { getDepositAddress, getFiatPaymentStep, getWalletPaymentStep } from "@coin-voyage/shared/payment";
3
+ import { useInWagmiContext } from "@coin-voyage/crypto/evm";
4
4
  import { useAccount, useConnectCallback } from "@coin-voyage/crypto/hooks";
5
5
  import { PaymentMethod, PayOrderMode, PayOrderStatus } from "@coin-voyage/shared/types";
6
6
  import { Buffer } from "buffer";
@@ -1,4 +1,4 @@
1
- import type { Token } from "@coin-voyage/shared/common";
1
+ import type { Token } from "@coin-voyage/shared/currency";
2
2
  export interface PaymentDetails extends Token {
3
3
  depositAddress: string;
4
4
  expirationS?: number;
@@ -13,6 +13,5 @@ export declare enum ROUTE {
13
13
  CONFIRMATION = 11,
14
14
  ONBOARDING = 12,
15
15
  ABOUT = 13,
16
- DOWNLOAD = 14,
17
- SWITCHNETWORKS = 15
16
+ DOWNLOAD = 14
18
17
  }
@@ -16,5 +16,4 @@ export var ROUTE;
16
16
  ROUTE[ROUTE["ONBOARDING"] = 12] = "ONBOARDING";
17
17
  ROUTE[ROUTE["ABOUT"] = 13] = "ABOUT";
18
18
  ROUTE[ROUTE["DOWNLOAD"] = 14] = "DOWNLOAD";
19
- ROUTE[ROUTE["SWITCHNETWORKS"] = 15] = "SWITCHNETWORKS";
20
19
  })(ROUTE || (ROUTE = {}));
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useConnectCallbackProps } from "@coin-voyage/crypto/hooks";
2
- import type { WalletConfiguration as WalletConfigurationImport } from "@coin-voyage/crypto/types/wallet";
2
+ import type { WalletConfiguration as WalletConfigurationImport } from "@coin-voyage/crypto/types";
3
3
  import { APIEnvironment as APIEnvironmentShared } from "@coin-voyage/shared/api";
4
4
  import type { ReactNode } from "react";
5
5
  import type { Languages as Lang } from "./lib/localizations";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coin-voyage/paykit",
3
3
  "description": "Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.",
4
- "version": "2.3.6-beta.2",
4
+ "version": "2.4.0-beta.1",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "author": "Lars <lars@coinvoyage.io>",
@@ -63,8 +63,8 @@
63
63
  "@stripe/crypto": "0.0.4",
64
64
  "styled-components": "^5.3.11",
65
65
  "uuid": "13.0.0",
66
- "@coin-voyage/crypto": "2.3.1-beta.0",
67
- "@coin-voyage/shared": "2.3.5-beta.3"
66
+ "@coin-voyage/crypto": "2.4.0-beta.0",
67
+ "@coin-voyage/shared": "2.4.0-beta.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/qrcode": "1.5.5",
@@ -1,2 +0,0 @@
1
- declare const SwitchNetworks: () => import("react/jsx-runtime").JSX.Element;
2
- export default SwitchNetworks;
@@ -1,24 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { ChainType } from "@coin-voyage/shared/types";
3
- import { useAccount, useConnect, useDisconnect } from "wagmi";
4
- import { DisconnectIcon } from "../../../assets/icons";
5
- import { useChainIsSupported } from "../../../hooks/useChainIsSupported";
6
- import useLocales from "../../../hooks/useLocales";
7
- import { isSafeConnector } from "../../../utils";
8
- import Button from "../../ui/Button";
9
- import ChainSelectList from "../../ui/ChainSelectList";
10
- import { OrDivider } from "../../ui/Divider/OrDivider";
11
- import { ModalBody, ModalContent, PageContent } from "../../ui/Modal/styles";
12
- const SwitchNetworks = () => {
13
- const { reset } = useConnect();
14
- const { disconnect } = useDisconnect();
15
- const { connector, chain } = useAccount();
16
- const isChainSupported = useChainIsSupported(ChainType.EVM, chain?.id);
17
- const locales = useLocales();
18
- const onDisconnect = () => {
19
- disconnect();
20
- reset();
21
- };
22
- return (_jsx(PageContent, { style: { width: 278 }, children: _jsxs(ModalContent, { style: { padding: 0, marginTop: -10 }, children: [!isChainSupported && (_jsxs(ModalBody, { children: [locales.warnings_chainUnsupported, " ", locales.warnings_chainUnsupportedResolve] })), _jsx("div", { style: { padding: "6px 8px" }, children: _jsx(ChainSelectList, { variant: "secondary" }) }), !isChainSupported && !isSafeConnector(connector?.id) && (_jsxs("div", { style: { paddingTop: 12 }, children: [_jsx(OrDivider, {}), _jsx(Button, { icon: _jsx(DisconnectIcon, {}), variant: "secondary", onClick: onDisconnect, children: locales.disconnect })] }))] }) }));
23
- };
24
- export default SwitchNetworks;
@@ -1,2 +0,0 @@
1
- import { ChainType } from "@coin-voyage/shared/types";
2
- export declare function useChainIsSupported(chainType: ChainType, chainId?: number): boolean | null;
@@ -1,19 +0,0 @@
1
- import { useAccount, useConfig as useBigmiConfig } from "@bigmi/react";
2
- import { isBitcoinAddress } from "@coin-voyage/shared/common";
3
- import { ChainType } from "@coin-voyage/shared/types";
4
- import { useConfig } from "wagmi";
5
- export function useChainIsSupported(chainType, chainId) {
6
- const { chains } = useConfig();
7
- const config = useBigmiConfig();
8
- const { account } = useAccount({ config });
9
- if (!chainId) {
10
- return false;
11
- }
12
- if (chainType === ChainType.UTXO) {
13
- return Boolean(account?.address && isBitcoinAddress(account.address));
14
- }
15
- if (chainType === ChainType.EVM) {
16
- return chains.some((x) => x.id === chainId);
17
- }
18
- return true;
19
- }