@getpara/react-common 2.0.0-alpha.5 → 2.0.0-alpha.51

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 (48) hide show
  1. package/dist/classes/ParaInternal.d.ts +14 -4
  2. package/dist/classes/ParaInternal.js +15 -1
  3. package/dist/components/HeroSpinner.d.ts +4 -3
  4. package/dist/components/HeroSpinner.js +28 -14
  5. package/dist/components/KnownDevices.js +5 -6
  6. package/dist/components/MoonPayEmbed.d.ts +4 -2
  7. package/dist/components/MoonPayEmbed.js +56 -83
  8. package/dist/components/NetworkSpeedBanner.js +5 -5
  9. package/dist/components/QRCode.js +7 -7
  10. package/dist/components/RampEmbed.d.ts +2 -2
  11. package/dist/components/RampEmbed.js +15 -27
  12. package/dist/components/UserIdentifier.d.ts +8 -0
  13. package/dist/components/UserIdentifier.js +30 -22
  14. package/dist/components/common.d.ts +3 -3
  15. package/dist/components/common.js +7 -7
  16. package/dist/components/index.d.ts +0 -1
  17. package/dist/components/index.js +0 -1
  18. package/dist/constants/externalWalletDefaults.d.ts +47 -0
  19. package/dist/constants/externalWalletDefaults.js +49 -0
  20. package/dist/constants/oAuthLogos.d.ts +12 -0
  21. package/dist/constants/oAuthLogos.js +160 -0
  22. package/dist/hooks/index.d.ts +1 -0
  23. package/dist/hooks/index.js +1 -0
  24. package/dist/hooks/useUserAgent.d.ts +2 -0
  25. package/dist/hooks/useUserAgent.js +10 -0
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.js +2 -0
  28. package/dist/types/commonTypes.d.ts +15 -0
  29. package/dist/types/commonTypes.js +1 -0
  30. package/dist/types/externalWalletCommon.d.ts +69 -37
  31. package/dist/types/externalWalletCommon.js +0 -31
  32. package/dist/types/index.d.ts +8 -5
  33. package/dist/types/index.js +1 -0
  34. package/dist/utils/formatBiometricHints.d.ts +1 -1
  35. package/dist/utils/formatBiometricHints.js +2 -2
  36. package/dist/utils/getExternalWalletDisplayName.d.ts +3 -1
  37. package/dist/utils/getExternalWalletDisplayName.js +6 -14
  38. package/dist/utils/getExternalWalletIcon.d.ts +5 -0
  39. package/dist/utils/getExternalWalletIcon.js +17 -0
  40. package/dist/utils/index.d.ts +2 -1
  41. package/dist/utils/index.js +2 -1
  42. package/dist/utils/safeStyled.d.ts +2 -0
  43. package/dist/utils/safeStyled.js +25 -0
  44. package/package.json +22 -24
  45. package/dist/components/StripeEmbed.d.ts +0 -4
  46. package/dist/components/StripeEmbed.js +0 -138
  47. package/dist/utils/offRampSend.d.ts +0 -7
  48. package/dist/utils/offRampSend.js +0 -75
@@ -1,10 +1,9 @@
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>;
@@ -16,10 +15,21 @@ export declare class ParaInternal extends ParaWeb {
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/user-management-client").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
20
  getNewCredentialAndUrl: ({ authMethod, isForNewDevice, portalTheme, shorten, }?: import("@getpara/core-sdk/dist/types/types").NewCredentialUrlParams) => Promise<{
22
21
  credentialId: string;
23
22
  url?: string;
24
23
  }>;
24
+ prepareLogin: () => import("@getpara/web-sdk").InternalMethodResponse<"prepareLogin">;
25
+ linkAccount: (opts: import("@getpara/web-sdk").InternalMethodParams<"linkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"linkAccount">;
26
+ unlinkAccount: ({ linkedAccountId, }: import("@getpara/web-sdk").InternalMethodParams<"unlinkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"unlinkAccount">;
27
+ verifyEmailOrPhoneLink: ({ verificationCode, }: import("@getpara/web-sdk").InternalMethodParams<"verifyEmailOrPhoneLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyEmailOrPhoneLink">;
28
+ verifyOAuthLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyOAuthLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyOAuthLink">;
29
+ verifyTelegramLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyTelegramLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyTelegramLink">;
30
+ verifyFarcasterLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyFarcasterLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyFarcasterLink">;
31
+ verifyExternalWalletLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyExternalWalletLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyExternalWalletLink">;
32
+ sendLoginCode: () => Promise<void>;
33
+ get partnerLogo(): string;
34
+ get partnerName(): string;
25
35
  }
@@ -5,7 +5,6 @@ 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;
@@ -15,6 +14,21 @@ class ParaInternal extends ParaWeb {
15
14
  this.supportedAuthMethods = super.supportedAuthMethods;
16
15
  this.constructPortalUrl = super.constructPortalUrl;
17
16
  this.getNewCredentialAndUrl = super.getNewCredentialAndUrl;
17
+ this.prepareLogin = super.prepareLogin;
18
+ this.linkAccount = super.linkAccount;
19
+ this.unlinkAccount = super.unlinkAccount;
20
+ this.verifyEmailOrPhoneLink = super.verifyEmailOrPhoneLink;
21
+ this.verifyOAuthLink = super.verifyOAuthLink;
22
+ this.verifyTelegramLink = super.verifyTelegramLink;
23
+ this.verifyFarcasterLink = super.verifyFarcasterLink;
24
+ this.verifyExternalWalletLink = super.verifyExternalWalletLink;
25
+ this.sendLoginCode = super.sendLoginCode;
26
+ }
27
+ get partnerLogo() {
28
+ return super.partnerLogo;
29
+ }
30
+ get partnerName() {
31
+ return super.partnerName;
18
32
  }
19
33
  }
20
34
  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 {};
@@ -2,32 +2,42 @@
2
2
  import "../chunk-GOCCUU3Z.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
@@ -2,10 +2,9 @@
2
2
  import "../chunk-GOCCUU3Z.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;
@@ -3,16 +3,22 @@ import {
3
3
  __async
4
4
  } from "../chunk-GOCCUU3Z.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
 
@@ -2,16 +2,16 @@
2
2
  import "../chunk-GOCCUU3Z.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"};
@@ -2,9 +2,9 @@
2
2
  import "../chunk-GOCCUU3Z.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;
@@ -5,24 +5,19 @@ import {
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { useEffect, useRef } from "react";
7
7
  import { RampInstantSDK } from "@ramp-network/ramp-instant-sdk";
8
- import { Network, OnRampAsset, OnRampProvider, getPortalBaseURL } from "@getpara/web-sdk";
9
- import {
10
- getChainId,
11
- getContractAddressFromAsset,
12
- getCurrencyCodes,
13
- reverseCurrencyLookup,
14
- offRampSend
15
- } from "../utils/index.js";
8
+ import { Network, OnRampAsset, OnRampProvider } from "@getpara/web-sdk";
9
+ import { getChainId, getContractAddressFromAsset, getCurrencyCodes, reverseCurrencyLookup } from "../utils/index.js";
16
10
  const TEST_MODE_FORBIDDEN = ["ETH_ETH", "ETH_USDC"];
17
11
  const RampEmbed = ({
18
- para,
19
12
  appName,
13
+ email,
20
14
  onRampConfig,
21
15
  onRampPurchase,
22
16
  isEmbedded,
23
17
  apiKey,
24
18
  onClose,
25
- setOnRampPurchase
19
+ onUpdate,
20
+ onDepositRequest
26
21
  }) => {
27
22
  const { currencyCodes } = getCurrencyCodes(onRampConfig, {
28
23
  provider: OnRampProvider.RAMP,
@@ -38,10 +33,10 @@ const RampEmbed = ({
38
33
  swapAsset: currencyCodes.filter((code) => !onRampPurchase.testMode || !TEST_MODE_FORBIDDEN.includes(code)).join(","),
39
34
  fiatValue: onRampPurchase.fiatQuantity,
40
35
  fiatCurrency: onRampPurchase.fiat,
41
- hostLogoUrl: `${getPortalBaseURL(para.ctx)}/wordmark_black.svg`,
36
+ hostLogoUrl: `${window.location.hostname}/wordmark_black.svg`,
42
37
  hostApiKey: apiKey,
43
38
  userAddress: onRampPurchase.address,
44
- userEmailAddress: para.getEmail(),
39
+ userEmailAddress: email,
45
40
  url: (onRampPurchase == null ? void 0 : onRampPurchase.testMode) ? "https://app.demo.ramp.network" : "https://app.ramp.network",
46
41
  enabledFlows: [onRampPurchase.type === "BUY" ? "ONRAMP" : "OFFRAMP"],
47
42
  useSendCryptoCallback: true,
@@ -50,21 +45,14 @@ const RampEmbed = ({
50
45
  }).on("PURCHASE_CREATED", (e) => __async(void 0, null, function* () {
51
46
  const p = e.payload.purchase;
52
47
  const [network, asset] = onRampPurchase.testMode ? [Network.ETHEREUM, OnRampAsset.ETHEREUM] : reverseCurrencyLookup(onRampConfig.assetInfo, OnRampProvider.RAMP, p.asset.symbol) || [];
53
- const updated = yield para.ctx.client.updateOnRampPurchase({
54
- userId: para.getUserId(),
55
- walletId: onRampPurchase.walletId,
56
- externalWalletAddress: onRampPurchase.externalWalletAddress,
57
- purchaseId: onRampPurchase.id,
58
- updates: {
59
- providerKey: p.id,
60
- fiatQuantity: p.fiatValue,
61
- fiat: p.fiatCurrency,
62
- assetQuantity: p.cryptoAmount,
63
- asset,
64
- network
65
- }
48
+ onUpdate({
49
+ providerKey: p.id,
50
+ fiatQuantity: p.fiatValue,
51
+ fiat: p.fiatCurrency,
52
+ assetQuantity: p.cryptoAmount,
53
+ asset,
54
+ network
66
55
  });
67
- setOnRampPurchase(updated);
68
56
  })).on("WIDGET_CLOSE", () => __async(void 0, null, function* () {
69
57
  onClose == null ? void 0 : onClose();
70
58
  if (!isEmbedded) {
@@ -77,7 +65,7 @@ const RampEmbed = ({
77
65
  })).onSendCrypto((assetInfo, amount, address) => __async(void 0, null, function* () {
78
66
  try {
79
67
  const [network, asset] = reverseCurrencyLookup(onRampConfig.assetInfo, OnRampProvider.RAMP, assetInfo.symbol);
80
- const txHash = yield offRampSend(para, onRampPurchase, setOnRampPurchase, {
68
+ const txHash = yield onDepositRequest({
81
69
  assetQuantity: amount,
82
70
  destinationAddress: address,
83
71
  contractAddress: getContractAddressFromAsset(network, asset),
@@ -1,4 +1,12 @@
1
+ import { IconType } from '@getpara/react-components';
1
2
  import { CoreAuthInfo } from '@getpara/web-sdk';
3
+ export declare function getAuthDisplay(authInfo: CoreAuthInfo, { withAddress }?: {
4
+ withAddress?: boolean;
5
+ }): {
6
+ name: string | null;
7
+ icon?: IconType;
8
+ src?: string;
9
+ };
2
10
  export declare const UserIdentifier: ({ authInfo }: {
3
11
  authInfo?: CoreAuthInfo;
4
12
  }) => import("react/jsx-runtime").JSX.Element;