@getpara/react-common 2.0.0-alpha.7 → 2.0.0-alpha.71

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 (67) hide show
  1. package/README.md +13 -0
  2. package/dist/{chunk-GOCCUU3Z.js → chunk-MMUBH76A.js} +17 -0
  3. package/dist/classes/ParaInternal.d.ts +26 -7
  4. package/dist/classes/ParaInternal.js +22 -2
  5. package/dist/components/HeroSpinner.d.ts +4 -3
  6. package/dist/components/HeroSpinner.js +29 -15
  7. package/dist/components/KnownDevices.js +6 -7
  8. package/dist/components/MoonPayEmbed.d.ts +4 -2
  9. package/dist/components/MoonPayEmbed.js +57 -84
  10. package/dist/components/NetworkSpeedBanner.js +6 -6
  11. package/dist/components/QRCode.js +8 -8
  12. package/dist/components/RampEmbed.d.ts +2 -2
  13. package/dist/components/RampEmbed.js +17 -29
  14. package/dist/components/UserIdentifier.d.ts +8 -0
  15. package/dist/components/UserIdentifier.js +30 -22
  16. package/dist/components/WalletSelect.d.ts +33 -0
  17. package/dist/components/WalletSelect.js +171 -0
  18. package/dist/components/WalletTypeIcon.d.ts +9 -0
  19. package/dist/components/WalletTypeIcon.js +45 -0
  20. package/dist/components/WarningBanner.d.ts +7 -0
  21. package/dist/components/WarningBanner.js +60 -0
  22. package/dist/components/common.d.ts +3 -3
  23. package/dist/components/common.js +8 -8
  24. package/dist/components/index.d.ts +3 -1
  25. package/dist/components/index.js +3 -1
  26. package/dist/constants/aaguiMetadata.js +1 -1
  27. package/dist/constants/externalWalletDefaults.d.ts +50 -0
  28. package/dist/constants/externalWalletDefaults.js +52 -0
  29. package/dist/constants/index.d.ts +37 -0
  30. package/dist/constants/index.js +152 -0
  31. package/dist/constants/oAuthLogos.d.ts +12 -0
  32. package/dist/constants/oAuthLogos.js +160 -0
  33. package/dist/hooks/index.d.ts +2 -0
  34. package/dist/hooks/index.js +2 -0
  35. package/dist/hooks/useCopyToClipboard.js +1 -1
  36. package/dist/hooks/useDropdownPosition.d.ts +7 -0
  37. package/dist/hooks/useDropdownPosition.js +33 -0
  38. package/dist/hooks/useUserAgent.d.ts +2 -0
  39. package/dist/hooks/useUserAgent.js +10 -0
  40. package/dist/index.d.ts +1 -0
  41. package/dist/index.js +1 -0
  42. package/dist/types/commonTypes.d.ts +15 -0
  43. package/dist/types/commonTypes.js +1 -0
  44. package/dist/types/externalWalletCommon.d.ts +75 -37
  45. package/dist/types/externalWalletCommon.js +0 -31
  46. package/dist/types/index.d.ts +8 -5
  47. package/dist/types/index.js +1 -0
  48. package/dist/utils/formatBiometricHints.d.ts +1 -1
  49. package/dist/utils/formatBiometricHints.js +3 -3
  50. package/dist/utils/getBrowserName.js +1 -1
  51. package/dist/utils/getDeviceLogo.js +1 -1
  52. package/dist/utils/getDeviceModelName.js +1 -1
  53. package/dist/utils/getExternalWalletDisplayName.d.ts +3 -1
  54. package/dist/utils/getExternalWalletDisplayName.js +7 -15
  55. package/dist/utils/getExternalWalletIcon.d.ts +5 -0
  56. package/dist/utils/getExternalWalletIcon.js +17 -0
  57. package/dist/utils/index.d.ts +18 -16
  58. package/dist/utils/index.js +27 -31
  59. package/dist/utils/openMobileUrl.d.ts +1 -0
  60. package/dist/utils/openMobileUrl.js +34 -0
  61. package/dist/utils/safeStyled.d.ts +2 -0
  62. package/dist/utils/safeStyled.js +25 -0
  63. package/package.json +22 -24
  64. package/dist/components/StripeEmbed.d.ts +0 -4
  65. package/dist/components/StripeEmbed.js +0 -138
  66. package/dist/utils/offRampSend.d.ts +0 -7
  67. package/dist/utils/offRampSend.js +0 -75
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ https://www.npmjs.com/package/@getpara/react-common
2
+
3
+ `@getpara/react-common` is a package that contains shared React components and utilities used across Para's React SDK ecosystem
4
+
5
+ ###Prerequisites
6
+
7
+ To use Para, you need an API key. This key authenticates your requests to Para services and is essential for integration.
8
+
9
+ Don't have an API key yet? Request access to the [Developer Portal](https://developer.getpara.com/) to create API keys, manage billing, teams, and more.
10
+
11
+ ###Learn more
12
+
13
+ For more information on Para’s React SDK visit the [Para Docs](https://docs.getpara.com/v2/react/quickstart)
@@ -1,5 +1,7 @@
1
1
  "use client";
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
3
5
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -15,6 +17,19 @@ var __spreadValues = (a, b) => {
15
17
  }
16
18
  return a;
17
19
  };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __objRest = (source, exclude) => {
22
+ var target = {};
23
+ for (var prop in source)
24
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
+ target[prop] = source[prop];
26
+ if (source != null && __getOwnPropSymbols)
27
+ for (var prop of __getOwnPropSymbols(source)) {
28
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
+ target[prop] = source[prop];
30
+ }
31
+ return target;
32
+ };
18
33
  var __async = (__this, __arguments, generator) => {
19
34
  return new Promise((resolve, reject) => {
20
35
  var fulfilled = (value) => {
@@ -38,5 +53,7 @@ var __async = (__this, __arguments, generator) => {
38
53
 
39
54
  export {
40
55
  __spreadValues,
56
+ __spreadProps,
57
+ __objRest,
41
58
  __async
42
59
  };
@@ -1,25 +1,44 @@
1
- import ParaWeb from '@getpara/web-sdk';
2
- export declare class ParaInternal extends ParaWeb {
1
+ import ParaWeb, { InternalInterface } from '@getpara/web-sdk';
2
+ export declare class ParaInternal extends ParaWeb implements InternalInterface {
3
3
  setupAfterLogin: ({ temporaryShares, skipSessionRefresh, }?: {
4
4
  temporaryShares?: any[];
5
5
  skipSessionRefresh?: boolean;
6
6
  }) => Promise<void>;
7
- getSupportedCreateAuthMethods: () => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
8
7
  getTransmissionKeyShares: ({ isForNewDevice }?: {
9
8
  isForNewDevice?: boolean;
10
9
  }) => Promise<any>;
11
- userSetupAfterLogin: () => Promise<import("@getpara/user-management-client").SessionInfo>;
10
+ userSetupAfterLogin: () => Promise<import("@getpara/shared").SessionInfo>;
12
11
  setLoginEncryptionKeyPair: (keyPair?: import("node-forge").pki.rsa.KeyPair) => Promise<void>;
13
12
  getPortalURL: () => Promise<string>;
14
13
  isProviderModalDisabled: () => boolean;
15
- setAuth: (auth: import("@getpara/user-management-client").PrimaryAuth, { extras, userId }?: {
14
+ setAuth: (auth: import("@getpara/shared").PrimaryAuth, { extras, userId }?: {
16
15
  extras?: import("@getpara/web-sdk").AuthExtras;
17
16
  userId?: string;
18
17
  }) => Promise<typeof this.authInfo>;
19
- supportedAuthMethods: (auth: import("@getpara/user-management-client").Auth<import("@getpara/user-management-client").PrimaryAuthType | "userId">) => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
18
+ supportedAuthMethods: (auth: import("@getpara/web-sdk").Auth<import("@getpara/shared").PrimaryAuthType | "userId">) => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
20
19
  constructPortalUrl: (type: import("@getpara/core-sdk/dist/types/types").PortalUrlType, opts?: import("@getpara/core-sdk/dist/types/types").PortalUrlOptions) => Promise<string>;
21
- getNewCredentialAndUrl: ({ authMethod, isForNewDevice, portalTheme, shorten, }?: import("@getpara/core-sdk/dist/types/types").NewCredentialUrlParams) => Promise<{
20
+ getSwitchWalletsUrl: () => Promise<string>;
21
+ getNewCredentialAndUrl: ({ authMethod: optsAuthMethod, isForNewDevice, portalTheme, shorten, }?: import("@getpara/core-sdk/dist/types/types").NewCredentialUrlParams) => Promise<{
22
22
  credentialId: string;
23
23
  url?: string;
24
24
  }>;
25
+ prepareLogin: () => import("@getpara/web-sdk").InternalMethodResponse<"prepareLogin">;
26
+ supportedUserAuthMethods: () => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
27
+ linkAccount: (opts: import("@getpara/web-sdk").InternalMethodParams<"linkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"linkAccount">;
28
+ unlinkAccount: ({ linkedAccountId, }: import("@getpara/web-sdk").InternalMethodParams<"unlinkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"unlinkAccount">;
29
+ verifyEmailOrPhoneLink: ({ verificationCode, }: import("@getpara/web-sdk").InternalMethodParams<"verifyEmailOrPhoneLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyEmailOrPhoneLink">;
30
+ verifyOAuthLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyOAuthLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyOAuthLink">;
31
+ verifyTelegramLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyTelegramLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyTelegramLink">;
32
+ verifyFarcasterLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyFarcasterLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyFarcasterLink">;
33
+ verifyExternalWalletLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyExternalWalletLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyExternalWalletLink">;
34
+ sendLoginCode: () => Promise<void>;
35
+ getProfileBalance: ({ config, refetch }?: {
36
+ config?: import("@getpara/web-sdk").BalancesConfig;
37
+ refetch?: boolean;
38
+ }) => Promise<import("@getpara/web-sdk").ProfileBalance>;
39
+ setModalError: (_error?: string) => void;
40
+ waitForWalletSwitching: (args: import("@getpara/web-sdk").CoreMethodParams<"waitForLogin">) => import("@getpara/web-sdk").CoreMethodResponse<"waitForLogin">;
41
+ displayModalError: (error?: string) => void;
42
+ get partnerLogo(): string;
43
+ get partnerName(): string;
25
44
  }
@@ -1,11 +1,10 @@
1
1
  "use client";
2
- import "../chunk-GOCCUU3Z.js";
2
+ import "../chunk-MMUBH76A.js";
3
3
  import ParaWeb from "@getpara/web-sdk";
4
4
  class ParaInternal extends ParaWeb {
5
5
  constructor() {
6
6
  super(...arguments);
7
7
  this.setupAfterLogin = super.setupAfterLogin;
8
- this.getSupportedCreateAuthMethods = super.getSupportedCreateAuthMethods;
9
8
  this.getTransmissionKeyShares = super.getTransmissionKeyShares;
10
9
  this.userSetupAfterLogin = super.userSetupAfterLogin;
11
10
  this.setLoginEncryptionKeyPair = super.setLoginEncryptionKeyPair;
@@ -14,7 +13,28 @@ class ParaInternal extends ParaWeb {
14
13
  this.setAuth = super.setAuth;
15
14
  this.supportedAuthMethods = super.supportedAuthMethods;
16
15
  this.constructPortalUrl = super.constructPortalUrl;
16
+ this.getSwitchWalletsUrl = super.getSwitchWalletsUrl;
17
17
  this.getNewCredentialAndUrl = super.getNewCredentialAndUrl;
18
+ this.prepareLogin = super.prepareLogin;
19
+ this.supportedUserAuthMethods = super.supportedUserAuthMethods;
20
+ this.linkAccount = super.linkAccount;
21
+ this.unlinkAccount = super.unlinkAccount;
22
+ this.verifyEmailOrPhoneLink = super.verifyEmailOrPhoneLink;
23
+ this.verifyOAuthLink = super.verifyOAuthLink;
24
+ this.verifyTelegramLink = super.verifyTelegramLink;
25
+ this.verifyFarcasterLink = super.verifyFarcasterLink;
26
+ this.verifyExternalWalletLink = super.verifyExternalWalletLink;
27
+ this.sendLoginCode = super.sendLoginCode;
28
+ this.getProfileBalance = super.getProfileBalance;
29
+ this.setModalError = super.setModalError;
30
+ this.waitForWalletSwitching = super.waitForWalletSwitching;
31
+ this.displayModalError = super.displayModalError;
32
+ }
33
+ get partnerLogo() {
34
+ return super.partnerLogo;
35
+ }
36
+ get partnerName() {
37
+ return super.partnerName;
18
38
  }
19
39
  }
20
40
  export {
@@ -1,9 +1,10 @@
1
1
  import { IconType } from '@getpara/react-components';
2
2
  import { PropsWithChildren, ReactNode } from 'react';
3
- type Status = 'loading' | 'error' | 'inactive';
4
- export declare function HeroSpinner({ icon, status, text, }: PropsWithChildren<{
5
- icon?: IconType;
3
+ type Status = 'pending' | 'error' | 'idle' | 'success';
4
+ export declare function HeroSpinner({ icon, status, text, secondaryText, }: PropsWithChildren<{
5
+ icon?: IconType | ReactNode;
6
6
  status?: Status;
7
7
  text?: ReactNode;
8
+ secondaryText?: ReactNode;
8
9
  }>): import("react/jsx-runtime").JSX.Element;
9
10
  export {};
@@ -1,33 +1,43 @@
1
1
  "use client";
2
- import "../chunk-GOCCUU3Z.js";
2
+ import "../chunk-MMUBH76A.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { CpslIcon, CpslSpinner, CpslText } from "@getpara/react-components";
5
- import styled from "styled-components";
5
+ import { safeStyled } from "../utils/index.js";
6
6
  function HeroSpinner({
7
7
  icon,
8
- status = "inactive",
9
- text
8
+ status = "idle",
9
+ text,
10
+ secondaryText
10
11
  }) {
11
12
  return /* @__PURE__ */ jsxs(Root, { children: [
12
13
  /* @__PURE__ */ jsxs(Hero, { children: [
13
- /* @__PURE__ */ jsx(Spinner, { size: 150, barWidth: 9, variant: status === "loading" ? "default" : status }),
14
- icon && /* @__PURE__ */ jsx(CpslIcon, { icon, size: "80px" })
14
+ /* @__PURE__ */ jsx(Spinner, { size: 155, barWidth: 8, variant: status }),
15
+ typeof icon === "string" ? /* @__PURE__ */ jsx(CpslIcon, { icon, size: "80px" }) : icon
15
16
  ] }),
16
17
  /* @__PURE__ */ jsxs(Text, { status, children: [
17
18
  status === "error" && /* @__PURE__ */ jsx(CpslIcon, { icon: "alertCircle", size: "16px", style: { stroke: "currentColor" } }),
18
- /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", weight: "semiBold", color: status === "error" ? "error" : "primary", children: text })
19
- ] })
19
+ status === "success" && /* @__PURE__ */ jsx(CpslIcon, { icon: "checkCircle", size: "16px", style: { stroke: "currentColor" } }),
20
+ /* @__PURE__ */ jsx(
21
+ CpslText,
22
+ {
23
+ variant: "bodyM",
24
+ weight: "semiBold",
25
+ align: "center",
26
+ color: status === "error" ? "error" : status === "success" ? "success" : "primary",
27
+ children: text
28
+ }
29
+ )
30
+ ] }),
31
+ secondaryText && /* @__PURE__ */ jsx(SecondaryText, { align: "center", color: "secondary", variant: "semiBold", children: secondaryText })
20
32
  ] });
21
33
  }
22
- const Root = styled.div`
23
- height: 276px;
34
+ const Root = safeStyled.div`
24
35
  display: flex;
25
36
  flex-direction: column;
26
37
  justify-content: center;
27
38
  align-items: center;
28
- gap: 16px;
29
39
  `;
30
- const Hero = styled.div`
40
+ const Hero = safeStyled.div`
31
41
  width: 150px;
32
42
  height: 150px;
33
43
  margin: 16px 0;
@@ -36,19 +46,23 @@ const Hero = styled.div`
36
46
  align-items: center;
37
47
  position: relative;
38
48
  `;
39
- const Text = styled.div`
49
+ const Text = safeStyled.div`
40
50
  display: flex;
41
51
  gap: 4px;
42
52
  align-items: center;
43
- color: ${({ status }) => status === "error" ? "var(--cpsl-color-utility-red)" : "auto"};
53
+ color: ${({ status }) => status === "error" ? "var(--cpsl-color-utility-red)" : status === "success" ? "var(--cpsl-color-utility-green)" : "auto"};
54
+ `;
55
+ const SecondaryText = safeStyled(CpslText)`
56
+ margin-top: 8px;
44
57
  `;
45
- const Spinner = styled(CpslSpinner)`
58
+ const Spinner = safeStyled(CpslSpinner)`
46
59
  position: absolute;
47
60
  width: 150px;
48
61
  height: 150px;
49
62
  top: 0;
50
63
  left: 0;
51
64
  right: 0;
65
+ transition: 0.2s color;
52
66
  `;
53
67
  export {
54
68
  HeroSpinner
@@ -1,11 +1,10 @@
1
1
  "use client";
2
- import "../chunk-GOCCUU3Z.js";
2
+ import "../chunk-MMUBH76A.js";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
  import { CpslButton, CpslIcon, CpslText } from "@getpara/react-components";
5
- import styled from "styled-components";
6
5
  import { CenteredColumnContainer, FullWidthFilledDisabledInput, CenteredText } from "./common.js";
7
6
  import { QRCode } from "./QRCode.js";
8
- import { getDeviceLogo, getDeviceModelName } from "../utils/index.js";
7
+ import { getDeviceLogo, getDeviceModelName, safeStyled } from "../utils/index.js";
9
8
  import { useCopyToClipboard } from "../hooks/index.js";
10
9
  const KnownDevices = ({ hints, link, showCurrentDevice }) => {
11
10
  const [isCopied, copy] = useCopyToClipboard();
@@ -33,10 +32,10 @@ const KnownDevices = ({ hints, link, showCurrentDevice }) => {
33
32
  ] })
34
33
  ] });
35
34
  };
36
- const Container = styled(CenteredColumnContainer)`
35
+ const Container = safeStyled(CenteredColumnContainer)`
37
36
  gap: 16px;
38
37
  `;
39
- const DevicesContainer = styled.div`
38
+ const DevicesContainer = safeStyled.div`
40
39
  display: flex;
41
40
  flex-direction: column;
42
41
  gap: 8px;
@@ -45,12 +44,12 @@ const DevicesContainer = styled.div`
45
44
  width: 100%;
46
45
  border-radius: 16px;
47
46
  `;
48
- const DeviceListItem = styled.div`
47
+ const DeviceListItem = safeStyled.div`
49
48
  display: flex;
50
49
  gap: 4px;
51
50
  align-items: center;
52
51
  `;
53
- const DeviceLogo = styled(CpslIcon)`
52
+ const DeviceLogo = safeStyled(CpslIcon)`
54
53
  --icon-color: var(--cpsl-color-text-contrast);
55
54
  --height: 16px;
56
55
  --width: 16px;
@@ -1,3 +1,5 @@
1
- import { Props } from '../types/index.js';
2
- export declare const MoonPayEmbed: ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, setOnRampPurchase }: Props) => import("react/jsx-runtime").JSX.Element;
1
+ import { OnRampProps } from '../types/index.js';
2
+ export declare const MoonPayEmbed: ({ email, isDark, isEmbedded, onRampConfig, onRampPurchase, onSuccess, onDepositRequest, onUrlSignatureRequest, }: OnRampProps & {
3
+ onUrlSignatureRequest: (url: string) => Promise<string>;
4
+ }) => import("react/jsx-runtime").JSX.Element;
3
5
  export default MoonPayEmbed;
@@ -1,18 +1,24 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-GOCCUU3Z.js";
4
+ } from "../chunk-MMUBH76A.js";
5
5
  import { jsx } from "react/jsx-runtime";
6
- import { getNetworkPrefix, OnRampProvider, OnRampPurchaseStatus } from "@getpara/web-sdk";
6
+ import { OnRampProvider } from "@getpara/web-sdk";
7
7
  import { lazy, useCallback, useEffect, useMemo, useState } from "react";
8
- import { reverseCurrencyLookup, offRampSend, getCurrencyCode } from "../utils/index.js";
9
- import styled from "styled-components";
8
+ import { reverseCurrencyLookup, getCurrencyCode, safeStyled } from "../utils/index.js";
10
9
  const MOONPAY_PUBLISHABLE_KEY = "pk_live_EQva4LydtNDE0Rwd9X7SG9w58wqOzbux";
11
10
  const MOONPAY_PUBLISHABLE_KEY_TEST = "pk_test_HYobzemmTBXxcSStVA4dSED6jT";
12
- const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, setOnRampPurchase }) => {
13
- const [LazyMoonPayBuyWidget, setLazyMoonPayBuyWidget] = useState(null);
14
- const [LazyMoonPaySellWidget, setLazyMoonPaySellWidget] = useState(null);
15
- const [LazyMoonPayProvider, setLazyMoonPayProvider] = useState(null);
11
+ const MoonPayEmbed = ({
12
+ email,
13
+ isDark,
14
+ isEmbedded,
15
+ onRampConfig,
16
+ onRampPurchase,
17
+ onSuccess,
18
+ onDepositRequest,
19
+ onUrlSignatureRequest
20
+ }) => {
21
+ const [components, setComponents] = useState(null);
16
22
  useEffect(() => {
17
23
  const _LazyMoonPayBuyWidget = lazy(
18
24
  () => import("@moonpay/moonpay-react").then((mod) => ({ default: mod.MoonPayBuyWidget }))
@@ -23,28 +29,13 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
23
29
  const _LazyMoonPayProvider = lazy(
24
30
  () => import("@moonpay/moonpay-react").then((mod) => ({ default: mod.MoonPayProvider }))
25
31
  );
26
- setLazyMoonPayBuyWidget(_LazyMoonPayBuyWidget);
27
- setLazyMoonPaySellWidget(_LazyMoonPaySellWidget);
28
- setLazyMoonPayProvider(_LazyMoonPayProvider);
32
+ setComponents({
33
+ MoonPayBuyWidget: _LazyMoonPayBuyWidget,
34
+ MoonPaySellWidget: _LazyMoonPaySellWidget,
35
+ MoonPayProvider: _LazyMoonPayProvider
36
+ });
29
37
  }, []);
30
38
  const apiKey = onRampPurchase.testMode ? MOONPAY_PUBLISHABLE_KEY_TEST : MOONPAY_PUBLISHABLE_KEY;
31
- const onUrlSignatureRequested = useCallback(
32
- (url) => __async(void 0, null, function* () {
33
- if (!para.getUserId() || !onRampPurchase.walletType) {
34
- throw new Error("missing required fields");
35
- }
36
- const res = yield para.ctx.client.signMoonPayUrl(para.getUserId(), {
37
- url,
38
- type: onRampPurchase.walletType,
39
- cosmosPrefix: getNetworkPrefix(onRampPurchase.network),
40
- testMode: onRampPurchase.testMode,
41
- walletId: onRampPurchase.walletId || void 0,
42
- externalWalletAddress: onRampPurchase.externalWalletAddress || void 0
43
- });
44
- return res.data.signature;
45
- }),
46
- [onRampPurchase.walletId, onRampPurchase.walletType, para.cosmosPrefix, onRampPurchase.testMode, para]
47
- );
48
39
  const onTransactionCompleted = useCallback(
49
40
  (payload) => __async(void 0, null, function* () {
50
41
  try {
@@ -53,57 +44,39 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
53
44
  OnRampProvider.MOONPAY,
54
45
  payload.quoteCurrency.code
55
46
  );
56
- const updated = yield para.ctx.client.updateOnRampPurchase({
57
- userId: para.getUserId(),
58
- walletId: onRampPurchase.walletId,
59
- purchaseId: onRampPurchase.id,
60
- externalWalletAddress: onRampPurchase.externalWalletAddress,
61
- updates: {
62
- fiatQuantity: payload.baseCurrencyAmount.toString(),
63
- fiat: payload.baseCurrency.code,
64
- network,
65
- asset,
66
- assetQuantity: payload.quoteCurrencyAmount.toString(),
67
- status: OnRampPurchaseStatus.FINISHED
68
- }
47
+ onSuccess({
48
+ fiatQuantity: payload.baseCurrencyAmount.toString(),
49
+ fiat: payload.baseCurrency.code,
50
+ network,
51
+ asset,
52
+ assetQuantity: payload.quoteCurrencyAmount.toString()
69
53
  });
70
- setOnRampPurchase(updated);
71
- if (!isEmbedded) {
72
- setTimeout(() => {
73
- if (typeof window !== "undefined") {
74
- window.close();
75
- }
76
- }, 5e3);
77
- }
78
54
  } catch (e) {
79
- console.error(e);
55
+ throw e instanceof Error ? e : new Error(e);
80
56
  }
81
57
  }),
82
- [onRampPurchase.walletId, onRampPurchase.id, onRampPurchase.externalWalletAddress, isEmbedded]
58
+ [onRampConfig]
83
59
  );
84
60
  const onInitiateDeposit = useCallback(
85
61
  (payload) => __async(void 0, null, function* () {
86
- const txHash = yield offRampSend(para, onRampPurchase, setOnRampPurchase, {
87
- assetQuantity: payload.cryptoCurrencyAmount,
88
- fiatQuantity: payload.fiatCurrencyAmount || void 0,
89
- fiat: payload.fiatCurrency.code.toUpperCase(),
90
- destinationAddress: payload.depositWalletAddress,
91
- contractAddress: payload.cryptoCurrency.contractAddress,
92
- chainId: payload.cryptoCurrency.chainId
93
- });
94
- return { depositId: txHash, cancelTransactionOnError: false };
62
+ try {
63
+ const txHash = yield onDepositRequest({
64
+ assetQuantity: payload.cryptoCurrencyAmount,
65
+ fiatQuantity: payload.fiatCurrencyAmount || void 0,
66
+ fiat: payload.fiatCurrency.code.toUpperCase(),
67
+ destinationAddress: payload.depositWalletAddress,
68
+ contractAddress: payload.cryptoCurrency.contractAddress,
69
+ chainId: payload.cryptoCurrency.chainId
70
+ });
71
+ return { depositId: txHash, cancelTransactionOnError: false };
72
+ } catch (e) {
73
+ throw e instanceof Error ? e : new Error(e);
74
+ }
95
75
  }),
96
- [
97
- para,
98
- onRampPurchase.id,
99
- onRampPurchase.testMode,
100
- onRampPurchase.walletId,
101
- onRampPurchase.walletType,
102
- setOnRampPurchase
103
- ]
76
+ []
104
77
  );
105
78
  const embed = useMemo(() => {
106
- if (!LazyMoonPayBuyWidget || !LazyMoonPaySellWidget) {
79
+ if (!components) {
107
80
  return null;
108
81
  }
109
82
  const currencyCode = getCurrencyCode(onRampConfig, {
@@ -111,10 +84,11 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
111
84
  asset: onRampPurchase.asset,
112
85
  provider: OnRampProvider.MOONPAY
113
86
  });
114
- return onRampPurchase.type === "BUY" ? /* @__PURE__ */ jsx(
115
- LazyMoonPayBuyWidget,
87
+ return /* @__PURE__ */ jsx(components.MoonPayProvider, { apiKey, debug: onRampPurchase.testMode, children: onRampPurchase.type === "BUY" ? /* @__PURE__ */ jsx(
88
+ components.MoonPayBuyWidget,
116
89
  {
117
90
  variant: "embedded",
91
+ email,
118
92
  baseCurrencyCode: onRampPurchase.fiat,
119
93
  baseCurrencyAmount: onRampPurchase.fiatQuantity,
120
94
  currencyCode,
@@ -129,10 +103,10 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
129
103
  margin: 0
130
104
  },
131
105
  onTransactionCompleted,
132
- onUrlSignatureRequested
106
+ onUrlSignatureRequested: onUrlSignatureRequest
133
107
  }
134
108
  ) : /* @__PURE__ */ jsx(
135
- LazyMoonPaySellWidget,
109
+ components.MoonPaySellWidget,
136
110
  {
137
111
  variant: "embedded",
138
112
  visible: true,
@@ -144,33 +118,32 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
144
118
  borderRadius: 0,
145
119
  margin: 0
146
120
  },
121
+ email,
147
122
  baseCurrencyCode: currencyCode,
123
+ quoteCurrencyAmount: onRampPurchase.fiatQuantity,
148
124
  refundWalletAddress: onRampPurchase.address,
149
125
  onInitiateDeposit,
150
126
  onTransactionCompleted,
151
- onUrlSignatureRequested
127
+ onUrlSignatureRequested: onUrlSignatureRequest
152
128
  }
153
- );
129
+ ) });
154
130
  }, [
131
+ apiKey,
132
+ email,
155
133
  onRampPurchase.type,
156
134
  onRampPurchase.address,
157
135
  onRampPurchase.walletId,
158
136
  onRampPurchase.walletType,
159
137
  onRampPurchase.asset,
160
- onInitiateDeposit,
138
+ onRampPurchase.testMode,
161
139
  onTransactionCompleted,
162
- onUrlSignatureRequested,
163
140
  isDark,
164
- LazyMoonPayBuyWidget,
165
- LazyMoonPaySellWidget
141
+ components
166
142
  ]);
167
- if (!LazyMoonPayProvider) {
168
- return null;
169
- }
170
- return /* @__PURE__ */ jsx(Container, { isEmbedded, children: /* @__PURE__ */ jsx(LazyMoonPayProvider, { apiKey, debug: onRampPurchase.testMode, children: embed }) });
143
+ return /* @__PURE__ */ jsx(Container, { isEmbedded, children: embed });
171
144
  };
172
145
  var MoonPayEmbed_default = MoonPayEmbed;
173
- const Container = styled.div`
146
+ const Container = safeStyled.div`
174
147
  width: ${({ isEmbedded }) => isEmbedded ? "100%" : "100vw"};
175
148
  height: ${({ isEmbedded }) => isEmbedded ? "640px" : "100vh"};
176
149
 
@@ -1,17 +1,17 @@
1
1
  "use client";
2
- import "../chunk-GOCCUU3Z.js";
2
+ import "../chunk-MMUBH76A.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { useEffect, useState } from "react";
5
- import styled from "styled-components";
6
5
  import { CpslIcon } from "@getpara/react-components";
7
- const BannerContainerWrapper = styled.div`
6
+ import { safeStyled } from "../utils/index.js";
7
+ const BannerContainerWrapper = safeStyled.div`
8
8
  display: flex;
9
9
  justify-content: center;
10
10
  align-items: center;
11
11
  width: 100%;
12
12
  background-color: transparent;
13
13
  `;
14
- const BannerContainer = styled.div`
14
+ const BannerContainer = safeStyled.div`
15
15
  display: flex;
16
16
  justify-content: center;
17
17
  align-items: center;
@@ -27,14 +27,14 @@ const BannerContainer = styled.div`
27
27
  text-overflow: ellipsis;
28
28
  overflow: hidden;
29
29
  `;
30
- const WarningIcon = styled(CpslIcon)`
30
+ const WarningIcon = safeStyled(CpslIcon)`
31
31
  --icon-color: #fbbc04;
32
32
  --width: ${({ $size }) => $size || "24px"};
33
33
  --height: ${({ $size }) => $size || "24px"};
34
34
  margin-right: 6px;
35
35
  flex-shrink: 0;
36
36
  `;
37
- const BannerText = styled.span`
37
+ const BannerText = safeStyled.span`
38
38
  font-family: var(--cpsl-default-font);
39
39
  font-weight: 500;
40
40
  font-size: ${({ $fontSize }) => $fontSize || "14px"};
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import "../chunk-GOCCUU3Z.js";
2
+ import "../chunk-MMUBH76A.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
5
- import styled from "styled-components";
6
5
  import { useCopyToClipboard } from "../hooks/index.js";
7
6
  import { isMobile } from "@getpara/web-sdk";
7
+ import { safeStyled } from "../utils/index.js";
8
8
  const QRCode = ({ link, imageSrc, icon, qrSize = 202, spinnerSize = 60 }) => {
9
9
  const [isCopied, copy] = useCopyToClipboard();
10
10
  const isMobileScreen = isMobile();
@@ -23,7 +23,7 @@ const QRCode = ({ link, imageSrc, icon, qrSize = 202, spinnerSize = 60 }) => {
23
23
  ] })
24
24
  ] });
25
25
  };
26
- const QRContainer = styled.div`
26
+ const QRContainer = safeStyled.div`
27
27
  display: flex;
28
28
  flex-direction: column;
29
29
  justify-content: center;
@@ -36,11 +36,11 @@ const QRContainer = styled.div`
36
36
  padding-bottom: ${({ $isMobile }) => $isMobile ? "0px" : "16px"};
37
37
  padding-top: ${({ $isMobile }) => $isMobile ? "16px" : "0px"};
38
38
  `;
39
- const StyledQRCode = styled(CpslQrCode)`
39
+ const StyledQRCode = safeStyled(CpslQrCode)`
40
40
  --qr-box-shadow: none;
41
41
  --qr-border-radius: 0px;
42
42
  `;
43
- const CopyButton = styled(CpslButton)`
43
+ const CopyButton = safeStyled(CpslButton)`
44
44
  --button-primary-color: var(--cpsl-color-text-contrast);
45
45
  --button-primary-background-color: var(--cpsl-color-background-4);
46
46
 
@@ -57,18 +57,18 @@ const CopyButton = styled(CpslButton)`
57
57
 
58
58
  --button-border-radius: 1000px;
59
59
  `;
60
- const MobileCopyButton = styled(CopyButton)`
60
+ const MobileCopyButton = safeStyled(CopyButton)`
61
61
  --button-padding-top: 4px;
62
62
  --button-padding-bottom: 4px;
63
63
 
64
64
  padding: 0px 12px;
65
65
  `;
66
- const CopyIcon = styled(CpslIcon)`
66
+ const CopyIcon = safeStyled(CpslIcon)`
67
67
  --width: 16px;
68
68
  --height: 16px;
69
69
  --icon-color: var(--cpsl-color-text-contrast);
70
70
  `;
71
- const LoadingContainer = styled.div`
71
+ const LoadingContainer = safeStyled.div`
72
72
  display: flex;
73
73
  justify-content: center;
74
74
  align-items: center;
@@ -1,4 +1,4 @@
1
- import { Props } from '../types/index.js';
2
- export declare const RampEmbed: ({ para, appName, onRampConfig, onRampPurchase, isEmbedded, apiKey, onClose, setOnRampPurchase, }: Props & {
1
+ import { OnRampProps } from '../types/index.js';
2
+ export declare const RampEmbed: ({ appName, email, onRampConfig, onRampPurchase, isEmbedded, apiKey, onClose, onUpdate, onDepositRequest, }: OnRampProps & {
3
3
  apiKey: string;
4
4
  }) => import("react/jsx-runtime").JSX.Element;