@getpara/react-common 2.0.0-fc.2 → 2.0.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.
Files changed (60) 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 +17 -4
  4. package/dist/classes/ParaInternal.js +15 -1
  5. package/dist/components/HeroSpinner.d.ts +2 -1
  6. package/dist/components/HeroSpinner.js +9 -3
  7. package/dist/components/KnownDevices.js +1 -1
  8. package/dist/components/MoonPayEmbed.d.ts +3 -1
  9. package/dist/components/MoonPayEmbed.js +56 -82
  10. package/dist/components/NetworkSpeedBanner.js +2 -4
  11. package/dist/components/QRCode.js +1 -1
  12. package/dist/components/RampEmbed.d.ts +1 -1
  13. package/dist/components/RampEmbed.js +17 -29
  14. package/dist/components/UserIdentifier.d.ts +8 -0
  15. package/dist/components/UserIdentifier.js +25 -16
  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.js +1 -1
  23. package/dist/components/index.d.ts +3 -0
  24. package/dist/components/index.js +3 -0
  25. package/dist/constants/aaguiMetadata.js +1 -1
  26. package/dist/constants/externalWalletDefaults.d.ts +10 -1
  27. package/dist/constants/externalWalletDefaults.js +8 -3
  28. package/dist/constants/index.d.ts +37 -0
  29. package/dist/constants/index.js +152 -0
  30. package/dist/constants/oAuthLogos.d.ts +12 -0
  31. package/dist/constants/oAuthLogos.js +160 -0
  32. package/dist/hooks/index.d.ts +1 -0
  33. package/dist/hooks/index.js +1 -0
  34. package/dist/hooks/useCopyToClipboard.js +1 -1
  35. package/dist/hooks/useDropdownPosition.d.ts +7 -0
  36. package/dist/hooks/useDropdownPosition.js +33 -0
  37. package/dist/hooks/useUserAgent.js +1 -1
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.js +1 -1
  40. package/dist/types/commonTypes.d.ts +15 -0
  41. package/dist/types/commonTypes.js +1 -0
  42. package/dist/types/externalWalletCommon.d.ts +14 -4
  43. package/dist/types/index.d.ts +7 -4
  44. package/dist/types/index.js +1 -0
  45. package/dist/utils/formatBiometricHints.js +1 -1
  46. package/dist/utils/getBrowserName.js +1 -1
  47. package/dist/utils/getDeviceLogo.js +1 -1
  48. package/dist/utils/getDeviceModelName.js +1 -1
  49. package/dist/utils/getExternalWalletDisplayName.d.ts +3 -1
  50. package/dist/utils/getExternalWalletDisplayName.js +7 -15
  51. package/dist/utils/getExternalWalletIcon.d.ts +5 -0
  52. package/dist/utils/getExternalWalletIcon.js +17 -0
  53. package/dist/utils/index.d.ts +17 -16
  54. package/dist/utils/index.js +26 -31
  55. package/dist/utils/openMobileUrl.d.ts +1 -0
  56. package/dist/utils/openMobileUrl.js +34 -0
  57. package/dist/utils/safeStyled.js +1 -1
  58. package/package.json +4 -4
  59. package/dist/utils/offRampSend.d.ts +0 -7
  60. 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
  };
@@ -7,20 +7,23 @@ export declare class ParaInternal extends ParaWeb implements InternalInterface {
7
7
  getTransmissionKeyShares: ({ isForNewDevice }?: {
8
8
  isForNewDevice?: boolean;
9
9
  }) => Promise<any>;
10
- userSetupAfterLogin: () => Promise<import("@getpara/user-management-client").SessionInfo>;
10
+ userSetupAfterLogin: () => Promise<import("@getpara/shared").SessionInfo>;
11
11
  setLoginEncryptionKeyPair: (keyPair?: import("node-forge").pki.rsa.KeyPair) => Promise<void>;
12
12
  getPortalURL: () => Promise<string>;
13
13
  isProviderModalDisabled: () => boolean;
14
- setAuth: (auth: import("@getpara/user-management-client").PrimaryAuth, { extras, userId }?: {
14
+ setAuth: (auth: import("@getpara/shared").PrimaryAuth, { extras, userId }?: {
15
15
  extras?: import("@getpara/web-sdk").AuthExtras;
16
16
  userId?: string;
17
17
  }) => Promise<typeof this.authInfo>;
18
- supportedAuthMethods: (auth: import("@getpara/web-sdk").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>>;
19
19
  constructPortalUrl: (type: import("@getpara/core-sdk/dist/types/types").PortalUrlType, opts?: import("@getpara/core-sdk/dist/types/types").PortalUrlOptions) => Promise<string>;
20
- 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<{
21
22
  credentialId: string;
22
23
  url?: string;
23
24
  }>;
25
+ prepareLogin: () => import("@getpara/web-sdk").InternalMethodResponse<"prepareLogin">;
26
+ supportedUserAuthMethods: () => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
24
27
  linkAccount: (opts: import("@getpara/web-sdk").InternalMethodParams<"linkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"linkAccount">;
25
28
  unlinkAccount: ({ linkedAccountId, }: import("@getpara/web-sdk").InternalMethodParams<"unlinkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"unlinkAccount">;
26
29
  verifyEmailOrPhoneLink: ({ verificationCode, }: import("@getpara/web-sdk").InternalMethodParams<"verifyEmailOrPhoneLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyEmailOrPhoneLink">;
@@ -28,4 +31,14 @@ export declare class ParaInternal extends ParaWeb implements InternalInterface {
28
31
  verifyTelegramLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyTelegramLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyTelegramLink">;
29
32
  verifyFarcasterLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyFarcasterLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyFarcasterLink">;
30
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;
31
44
  }
@@ -1,5 +1,5 @@
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() {
@@ -13,7 +13,10 @@ class ParaInternal extends ParaWeb {
13
13
  this.setAuth = super.setAuth;
14
14
  this.supportedAuthMethods = super.supportedAuthMethods;
15
15
  this.constructPortalUrl = super.constructPortalUrl;
16
+ this.getSwitchWalletsUrl = super.getSwitchWalletsUrl;
16
17
  this.getNewCredentialAndUrl = super.getNewCredentialAndUrl;
18
+ this.prepareLogin = super.prepareLogin;
19
+ this.supportedUserAuthMethods = super.supportedUserAuthMethods;
17
20
  this.linkAccount = super.linkAccount;
18
21
  this.unlinkAccount = super.unlinkAccount;
19
22
  this.verifyEmailOrPhoneLink = super.verifyEmailOrPhoneLink;
@@ -21,6 +24,17 @@ class ParaInternal extends ParaWeb {
21
24
  this.verifyTelegramLink = super.verifyTelegramLink;
22
25
  this.verifyFarcasterLink = super.verifyFarcasterLink;
23
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;
24
38
  }
25
39
  }
26
40
  export {
@@ -1,9 +1,10 @@
1
1
  import { IconType } from '@getpara/react-components';
2
2
  import { PropsWithChildren, ReactNode } from 'react';
3
3
  type Status = 'pending' | 'error' | 'idle' | 'success';
4
- export declare function HeroSpinner({ icon, status, text, }: PropsWithChildren<{
4
+ export declare function HeroSpinner({ icon, status, text, secondaryText, }: PropsWithChildren<{
5
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,12 +1,13 @@
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
5
  import { safeStyled } from "../utils/index.js";
6
6
  function HeroSpinner({
7
7
  icon,
8
8
  status = "idle",
9
- text
9
+ text,
10
+ secondaryText
10
11
  }) {
11
12
  return /* @__PURE__ */ jsxs(Root, { children: [
12
13
  /* @__PURE__ */ jsxs(Hero, { children: [
@@ -21,11 +22,13 @@ function HeroSpinner({
21
22
  {
22
23
  variant: "bodyM",
23
24
  weight: "semiBold",
25
+ align: "center",
24
26
  color: status === "error" ? "error" : status === "success" ? "success" : "primary",
25
27
  children: text
26
28
  }
27
29
  )
28
- ] })
30
+ ] }),
31
+ secondaryText && /* @__PURE__ */ jsx(SecondaryText, { align: "center", color: "secondary", variant: "semiBold", children: secondaryText })
29
32
  ] });
30
33
  }
31
34
  const Root = safeStyled.div`
@@ -49,6 +52,9 @@ const Text = safeStyled.div`
49
52
  align-items: center;
50
53
  color: ${({ status }) => status === "error" ? "var(--cpsl-color-utility-red)" : status === "success" ? "var(--cpsl-color-utility-green)" : "auto"};
51
54
  `;
55
+ const SecondaryText = safeStyled(CpslText)`
56
+ margin-top: 8px;
57
+ `;
52
58
  const Spinner = safeStyled(CpslSpinner)`
53
59
  position: absolute;
54
60
  width: 150px;
@@ -1,5 +1,5 @@
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
5
  import { CenteredColumnContainer, FullWidthFilledDisabledInput, CenteredText } from "./common.js";
@@ -1,3 +1,5 @@
1
1
  import { OnRampProps } from '../types/index.js';
2
- export declare const MoonPayEmbed: ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, setOnRampPurchase }: OnRampProps) => import("react/jsx-runtime").JSX.Element;
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,17 +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, safeStyled } from "../utils/index.js";
8
+ import { reverseCurrencyLookup, getCurrencyCode, safeStyled } from "../utils/index.js";
9
9
  const MOONPAY_PUBLISHABLE_KEY = "pk_live_EQva4LydtNDE0Rwd9X7SG9w58wqOzbux";
10
10
  const MOONPAY_PUBLISHABLE_KEY_TEST = "pk_test_HYobzemmTBXxcSStVA4dSED6jT";
11
- const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, setOnRampPurchase }) => {
12
- const [LazyMoonPayBuyWidget, setLazyMoonPayBuyWidget] = useState(null);
13
- const [LazyMoonPaySellWidget, setLazyMoonPaySellWidget] = useState(null);
14
- 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);
15
22
  useEffect(() => {
16
23
  const _LazyMoonPayBuyWidget = lazy(
17
24
  () => import("@moonpay/moonpay-react").then((mod) => ({ default: mod.MoonPayBuyWidget }))
@@ -22,28 +29,13 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
22
29
  const _LazyMoonPayProvider = lazy(
23
30
  () => import("@moonpay/moonpay-react").then((mod) => ({ default: mod.MoonPayProvider }))
24
31
  );
25
- setLazyMoonPayBuyWidget(_LazyMoonPayBuyWidget);
26
- setLazyMoonPaySellWidget(_LazyMoonPaySellWidget);
27
- setLazyMoonPayProvider(_LazyMoonPayProvider);
32
+ setComponents({
33
+ MoonPayBuyWidget: _LazyMoonPayBuyWidget,
34
+ MoonPaySellWidget: _LazyMoonPaySellWidget,
35
+ MoonPayProvider: _LazyMoonPayProvider
36
+ });
28
37
  }, []);
29
38
  const apiKey = onRampPurchase.testMode ? MOONPAY_PUBLISHABLE_KEY_TEST : MOONPAY_PUBLISHABLE_KEY;
30
- const onUrlSignatureRequested = useCallback(
31
- (url) => __async(void 0, null, function* () {
32
- if (!para.getUserId() || !onRampPurchase.walletType) {
33
- throw new Error("missing required fields");
34
- }
35
- const res = yield para.ctx.client.signMoonPayUrl(para.getUserId(), {
36
- url,
37
- type: onRampPurchase.walletType,
38
- cosmosPrefix: getNetworkPrefix(onRampPurchase.network),
39
- testMode: onRampPurchase.testMode,
40
- walletId: onRampPurchase.walletId || void 0,
41
- externalWalletAddress: onRampPurchase.externalWalletAddress || void 0
42
- });
43
- return res.data.signature;
44
- }),
45
- [onRampPurchase.walletId, onRampPurchase.walletType, para.cosmosPrefix, onRampPurchase.testMode, para]
46
- );
47
39
  const onTransactionCompleted = useCallback(
48
40
  (payload) => __async(void 0, null, function* () {
49
41
  try {
@@ -52,57 +44,39 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
52
44
  OnRampProvider.MOONPAY,
53
45
  payload.quoteCurrency.code
54
46
  );
55
- const updated = yield para.ctx.client.updateOnRampPurchase({
56
- userId: para.getUserId(),
57
- walletId: onRampPurchase.walletId,
58
- purchaseId: onRampPurchase.id,
59
- externalWalletAddress: onRampPurchase.externalWalletAddress,
60
- updates: {
61
- fiatQuantity: payload.baseCurrencyAmount.toString(),
62
- fiat: payload.baseCurrency.code,
63
- network,
64
- asset,
65
- assetQuantity: payload.quoteCurrencyAmount.toString(),
66
- status: OnRampPurchaseStatus.FINISHED
67
- }
47
+ onSuccess({
48
+ fiatQuantity: payload.baseCurrencyAmount.toString(),
49
+ fiat: payload.baseCurrency.code,
50
+ network,
51
+ asset,
52
+ assetQuantity: payload.quoteCurrencyAmount.toString()
68
53
  });
69
- setOnRampPurchase(updated);
70
- if (!isEmbedded) {
71
- setTimeout(() => {
72
- if (typeof window !== "undefined") {
73
- window.close();
74
- }
75
- }, 5e3);
76
- }
77
54
  } catch (e) {
78
- console.error(e);
55
+ throw e instanceof Error ? e : new Error(e);
79
56
  }
80
57
  }),
81
- [onRampPurchase.walletId, onRampPurchase.id, onRampPurchase.externalWalletAddress, isEmbedded]
58
+ [onRampConfig]
82
59
  );
83
60
  const onInitiateDeposit = useCallback(
84
61
  (payload) => __async(void 0, null, function* () {
85
- const txHash = yield offRampSend(para, onRampPurchase, setOnRampPurchase, {
86
- assetQuantity: payload.cryptoCurrencyAmount,
87
- fiatQuantity: payload.fiatCurrencyAmount || void 0,
88
- fiat: payload.fiatCurrency.code.toUpperCase(),
89
- destinationAddress: payload.depositWalletAddress,
90
- contractAddress: payload.cryptoCurrency.contractAddress,
91
- chainId: payload.cryptoCurrency.chainId
92
- });
93
- 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
+ }
94
75
  }),
95
- [
96
- para,
97
- onRampPurchase.id,
98
- onRampPurchase.testMode,
99
- onRampPurchase.walletId,
100
- onRampPurchase.walletType,
101
- setOnRampPurchase
102
- ]
76
+ []
103
77
  );
104
78
  const embed = useMemo(() => {
105
- if (!LazyMoonPayBuyWidget || !LazyMoonPaySellWidget) {
79
+ if (!components) {
106
80
  return null;
107
81
  }
108
82
  const currencyCode = getCurrencyCode(onRampConfig, {
@@ -110,10 +84,11 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
110
84
  asset: onRampPurchase.asset,
111
85
  provider: OnRampProvider.MOONPAY
112
86
  });
113
- return onRampPurchase.type === "BUY" ? /* @__PURE__ */ jsx(
114
- LazyMoonPayBuyWidget,
87
+ return /* @__PURE__ */ jsx(components.MoonPayProvider, { apiKey, debug: onRampPurchase.testMode, children: onRampPurchase.type === "BUY" ? /* @__PURE__ */ jsx(
88
+ components.MoonPayBuyWidget,
115
89
  {
116
90
  variant: "embedded",
91
+ email,
117
92
  baseCurrencyCode: onRampPurchase.fiat,
118
93
  baseCurrencyAmount: onRampPurchase.fiatQuantity,
119
94
  currencyCode,
@@ -128,10 +103,10 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
128
103
  margin: 0
129
104
  },
130
105
  onTransactionCompleted,
131
- onUrlSignatureRequested
106
+ onUrlSignatureRequested: onUrlSignatureRequest
132
107
  }
133
108
  ) : /* @__PURE__ */ jsx(
134
- LazyMoonPaySellWidget,
109
+ components.MoonPaySellWidget,
135
110
  {
136
111
  variant: "embedded",
137
112
  visible: true,
@@ -143,30 +118,29 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
143
118
  borderRadius: 0,
144
119
  margin: 0
145
120
  },
121
+ email,
146
122
  baseCurrencyCode: currencyCode,
123
+ quoteCurrencyAmount: onRampPurchase.fiatQuantity,
147
124
  refundWalletAddress: onRampPurchase.address,
148
125
  onInitiateDeposit,
149
126
  onTransactionCompleted,
150
- onUrlSignatureRequested
127
+ onUrlSignatureRequested: onUrlSignatureRequest
151
128
  }
152
- );
129
+ ) });
153
130
  }, [
131
+ apiKey,
132
+ email,
154
133
  onRampPurchase.type,
155
134
  onRampPurchase.address,
156
135
  onRampPurchase.walletId,
157
136
  onRampPurchase.walletType,
158
137
  onRampPurchase.asset,
159
- onInitiateDeposit,
138
+ onRampPurchase.testMode,
160
139
  onTransactionCompleted,
161
- onUrlSignatureRequested,
162
140
  isDark,
163
- LazyMoonPayBuyWidget,
164
- LazyMoonPaySellWidget
141
+ components
165
142
  ]);
166
- if (!LazyMoonPayProvider) {
167
- return null;
168
- }
169
- return /* @__PURE__ */ jsx(Container, { isEmbedded, children: /* @__PURE__ */ jsx(LazyMoonPayProvider, { apiKey, debug: onRampPurchase.testMode, children: embed }) });
143
+ return /* @__PURE__ */ jsx(Container, { isEmbedded, children: embed });
170
144
  };
171
145
  var MoonPayEmbed_default = MoonPayEmbed;
172
146
  const Container = safeStyled.div`
@@ -1,5 +1,5 @@
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
5
  import { CpslIcon } from "@getpara/react-components";
@@ -23,9 +23,7 @@ const BannerContainer = safeStyled.div`
23
23
  position: relative;
24
24
  z-index: 10;
25
25
  display: inline-flex;
26
- white-space: nowrap;
27
- text-overflow: ellipsis;
28
- overflow: hidden;
26
+ flex-wrap: wrap;
29
27
  `;
30
28
  const WarningIcon = safeStyled(CpslIcon)`
31
29
  --icon-color: #fbbc04;
@@ -1,5 +1,5 @@
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
5
  import { useCopyToClipboard } from "../hooks/index.js";
@@ -1,4 +1,4 @@
1
1
  import { OnRampProps } from '../types/index.js';
2
- export declare const RampEmbed: ({ para, appName, onRampConfig, onRampPurchase, isEmbedded, apiKey, onClose, setOnRampPurchase, }: OnRampProps & {
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;
@@ -1,28 +1,23 @@
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
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 { 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,
@@ -49,22 +44,15 @@ const RampEmbed = ({
49
44
  containerNode: document.getElementById("ramp-container")
50
45
  }).on("PURCHASE_CREATED", (e) => __async(void 0, null, function* () {
51
46
  const p = e.payload.purchase;
52
- 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
- }
47
+ const [network, asset] = onRampPurchase.testMode ? ["ETHEREUM", "ETHEREUM"] : reverseCurrencyLookup(onRampConfig.assetInfo, OnRampProvider.RAMP, p.asset.symbol) || [];
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;
@@ -1,35 +1,43 @@
1
1
  "use client";
2
- import "../chunk-GOCCUU3Z.js";
2
+ import {
3
+ __spreadValues
4
+ } from "../chunk-MMUBH76A.js";
3
5
  import { jsx, jsxs } from "react/jsx-runtime";
4
6
  import { CpslAvatar, CpslIcon, CpslText } from "@getpara/react-components";
5
- import { displayPhoneNumber } from "@getpara/web-sdk";
6
- import { getExternalWalletDisplayName, safeStyled } from "../utils/index.js";
7
- function defaultDisplay(authInfo) {
8
- const { authType, identifier, externalWallet } = authInfo;
7
+ import { displayPhoneNumber, truncateAddress } from "@getpara/web-sdk";
8
+ import { getExternalWalletDisplayName, getExternalWalletIcon, safeStyled } from "../utils/index.js";
9
+ function getAuthDisplay(authInfo, { withAddress = false } = {}) {
10
+ var _a;
11
+ const { authType, displayName, identifier, pfpUrl, externalWallet } = authInfo;
9
12
  switch (authType) {
10
13
  case "email":
11
- return { defaultName: identifier.toLowerCase(), defaultIcon: "mail" };
14
+ return { name: identifier.toLowerCase(), icon: "mail" };
12
15
  case "phone":
13
- return { defaultName: displayPhoneNumber(identifier), defaultIcon: "phone" };
16
+ return { name: displayPhoneNumber(identifier), icon: "phone" };
14
17
  case "farcaster":
15
- return { defaultName: `@${identifier}`, defaultIcon: "farcasterBrand" };
18
+ return __spreadValues({ name: displayName != null ? displayName : `@${identifier}` }, pfpUrl ? { src: pfpUrl } : { icon: "farcasterBrand" });
16
19
  case "telegram":
17
- return { defaultName: `Telegram User @${identifier}`, defaultIcon: "telegramBrand" };
20
+ return __spreadValues({
21
+ name: displayName != null ? displayName : `Telegram User @${identifier}`
22
+ }, pfpUrl ? { src: pfpUrl } : { icon: "telegramBrand" });
18
23
  case "externalWallet":
19
- return { defaultName: getExternalWalletDisplayName(externalWallet), defaultIcon: "wallet" };
24
+ return {
25
+ name: externalWallet ? getExternalWalletDisplayName(externalWallet, { withAddress }) : truncateAddress(identifier, "EVM"),
26
+ icon: (_a = getExternalWalletIcon(externalWallet == null ? void 0 : externalWallet.providerId)) != null ? _a : "wallet02"
27
+ };
20
28
  default:
21
- return { defaultName: null, defaultIcon: null };
29
+ return { name: null, icon: null };
22
30
  }
23
31
  }
24
32
  const UserIdentifier = ({ authInfo }) => {
25
33
  if (!authInfo) {
26
34
  return null;
27
35
  }
28
- const { authType, displayName, pfpUrl } = authInfo;
29
- const { defaultName, defaultIcon } = defaultDisplay(authInfo);
36
+ const { authType } = authInfo;
37
+ const { name, icon, src } = getAuthDisplay(authInfo, { withAddress: true });
30
38
  return /* @__PURE__ */ jsxs(Container, { children: [
31
- /* @__PURE__ */ jsx(IconContainer, { children: pfpUrl ? /* @__PURE__ */ jsx(Avatar, { src: pfpUrl, size: "20px", variant: "round" }) : /* @__PURE__ */ jsx(Icon, { icon: defaultIcon, size: authType === "telegram" ? "20px" : "13px" }) }),
32
- /* @__PURE__ */ jsx(IdentifierText, { variant: "bodyS", weight: "medium", children: displayName || defaultName })
39
+ /* @__PURE__ */ jsx(IconContainer, { children: src ? /* @__PURE__ */ jsx(Avatar, { src, size: "20px", variant: "round" }) : /* @__PURE__ */ jsx(Icon, { icon, size: authType === "telegram" ? "20px" : "13px" }) }),
40
+ /* @__PURE__ */ jsx(IdentifierText, { variant: "bodyS", weight: "medium", children: name })
33
41
  ] });
34
42
  };
35
43
  const Container = safeStyled.div`
@@ -61,5 +69,6 @@ const Avatar = safeStyled(CpslAvatar)`
61
69
  --container-padding: 0;
62
70
  `;
63
71
  export {
64
- UserIdentifier
72
+ UserIdentifier,
73
+ getAuthDisplay
65
74
  };
@@ -0,0 +1,33 @@
1
+ import { AvailableWallet, TWalletType, TExternalWallet } from '@getpara/web-sdk';
2
+ type EntryProps = {
3
+ name?: string;
4
+ type?: TWalletType;
5
+ externalWallet?: TExternalWallet | string;
6
+ withCopy?: boolean;
7
+ withIcon?: boolean;
8
+ copyValue?: string;
9
+ };
10
+ export declare const WalletSelect: ({ isDark, style, className, value, onChange, options, getEntryProps, getSelectValue, helperText, }: {
11
+ isDark: any;
12
+ style?: React.CSSProperties;
13
+ className?: string;
14
+ value: AvailableWallet;
15
+ onChange: (_: AvailableWallet) => void;
16
+ options: AvailableWallet[];
17
+ getEntryProps: (wallet: AvailableWallet) => EntryProps;
18
+ getSelectValue: (wallet: AvailableWallet) => `${string}~${TWalletType}`;
19
+ helperText?: string;
20
+ }) => import("react/jsx-runtime").JSX.Element;
21
+ export declare const Select: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components/dist/types.js").Substitute<Omit<Omit<any, "ref"> & import("react").RefAttributes<any>, "ref"> & {
22
+ ref?: import("react").Ref<any>;
23
+ }, {
24
+ $width: number;
25
+ $top?: number;
26
+ }>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>, keyof import("react").Component<any, {}, any>>;
27
+ export declare const SelectItem: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components/dist/types.js").Substitute<Omit<Omit<any, "ref"> & import("react").RefAttributes<any>, "ref"> & {
28
+ ref?: import("react").Ref<any>;
29
+ }, {
30
+ isMultiOption?: boolean;
31
+ }>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>, keyof import("react").Component<any, {}, any>>;
32
+ export declare const SelectContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
33
+ export {};