@getpara/react-common 1.9.0 → 1.11.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.
@@ -1,7 +1,5 @@
1
1
  "use client";
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
3
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -17,7 +15,6 @@ var __spreadValues = (a, b) => {
17
15
  }
18
16
  return a;
19
17
  };
20
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
18
  var __async = (__this, __arguments, generator) => {
22
19
  return new Promise((resolve, reject) => {
23
20
  var fulfilled = (value) => {
@@ -41,6 +38,5 @@ var __async = (__this, __arguments, generator) => {
41
38
 
42
39
  export {
43
40
  __spreadValues,
44
- __spreadProps,
45
41
  __async
46
42
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
2
+ import "../chunk-GOCCUU3Z.js";
3
3
  import ParaWeb from "@getpara/web-sdk";
4
4
  class ParaInternal extends ParaWeb {
5
5
  constructor() {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
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
5
  import styled from "styled-components";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
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
5
  import styled from "styled-components";
@@ -1,13 +1,11 @@
1
1
  "use client";
2
2
  import {
3
- __async,
4
- __spreadProps,
5
- __spreadValues
6
- } from "../chunk-IV3L3JVM.js";
3
+ __async
4
+ } from "../chunk-GOCCUU3Z.js";
7
5
  import { jsx } from "react/jsx-runtime";
8
- import { OnRampProvider, OnRampPurchaseStatus } from "@getpara/web-sdk";
6
+ import { getNetworkPrefix, OnRampProvider, OnRampPurchaseStatus } from "@getpara/web-sdk";
9
7
  import { lazy, useCallback, useEffect, useMemo, useState } from "react";
10
- import { getCurrencyCodes, reverseCurrencyLookup, offRampSend } from "../utils/index.js";
8
+ import { reverseCurrencyLookup, offRampSend, getCurrencyCode } from "../utils/index.js";
11
9
  import styled from "styled-components";
12
10
  const MOONPAY_PUBLISHABLE_KEY = "pk_live_EQva4LydtNDE0Rwd9X7SG9w58wqOzbux";
13
11
  const MOONPAY_PUBLISHABLE_KEY_TEST = "pk_test_HYobzemmTBXxcSStVA4dSED6jT";
@@ -38,7 +36,7 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
38
36
  const res = yield para.ctx.client.signMoonPayUrl(para.getUserId(), {
39
37
  url,
40
38
  type: onRampPurchase.walletType,
41
- cosmosPrefix: para.cosmosPrefix,
39
+ cosmosPrefix: getNetworkPrefix(onRampPurchase.network),
42
40
  testMode: onRampPurchase.testMode,
43
41
  walletId: onRampPurchase.walletId || void 0,
44
42
  externalWalletAddress: onRampPurchase.externalWalletAddress || void 0
@@ -47,14 +45,6 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
47
45
  }),
48
46
  [onRampPurchase.walletId, onRampPurchase.walletType, para.cosmosPrefix, onRampPurchase.testMode, para]
49
47
  );
50
- const { currencyCodes, defaultCurrencyCode } = useMemo(
51
- () => getCurrencyCodes(onRampConfig, {
52
- provider: OnRampProvider.MOONPAY,
53
- walletType: onRampPurchase.walletType,
54
- purchaseType: onRampPurchase.type
55
- }),
56
- [onRampPurchase.walletType, onRampPurchase.type, onRampConfig.assetInfo, onRampConfig == null ? void 0 : onRampConfig.allowedAssets]
57
- );
58
48
  const onTransactionCompleted = useCallback(
59
49
  (payload) => __async(void 0, null, function* () {
60
50
  try {
@@ -116,18 +106,19 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
116
106
  if (!LazyMoonPayBuyWidget || !LazyMoonPaySellWidget) {
117
107
  return null;
118
108
  }
119
- const walletAddresses = currencyCodes.reduce((acc, code) => {
120
- return __spreadProps(__spreadValues({}, acc), { [code.toLowerCase()]: onRampPurchase.address });
121
- }, {});
109
+ const currencyCode = getCurrencyCode(onRampConfig, {
110
+ network: onRampPurchase.network,
111
+ asset: onRampPurchase.asset,
112
+ provider: OnRampProvider.MOONPAY
113
+ });
122
114
  return onRampPurchase.type === "BUY" ? /* @__PURE__ */ jsx(
123
115
  LazyMoonPayBuyWidget,
124
116
  {
125
117
  variant: "embedded",
126
118
  baseCurrencyCode: onRampPurchase.fiat,
127
119
  baseCurrencyAmount: onRampPurchase.fiatQuantity,
128
- showOnlyCurrencies: currencyCodes.join(","),
129
- defaultCurrencyCode,
130
- walletAddresses: JSON.stringify(walletAddresses),
120
+ currencyCode,
121
+ walletAddress: onRampPurchase.address,
131
122
  visible: true,
132
123
  theme: isDark ? "dark" : "light",
133
124
  style: {
@@ -144,7 +135,6 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
144
135
  LazyMoonPaySellWidget,
145
136
  {
146
137
  variant: "embedded",
147
- refundWalletAddresses: JSON.stringify(walletAddresses),
148
138
  visible: true,
149
139
  theme: isDark ? "dark" : "light",
150
140
  style: {
@@ -154,7 +144,8 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
154
144
  borderRadius: 0,
155
145
  margin: 0
156
146
  },
157
- defaultBaseCurrencyCode: currencyCodes[0],
147
+ baseCurrencyCode: currencyCode,
148
+ refundWalletAddress: onRampPurchase.address,
158
149
  onInitiateDeposit,
159
150
  onTransactionCompleted,
160
151
  onUrlSignatureRequested
@@ -165,8 +156,7 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
165
156
  onRampPurchase.address,
166
157
  onRampPurchase.walletId,
167
158
  onRampPurchase.walletType,
168
- defaultCurrencyCode,
169
- currencyCodes,
159
+ onRampPurchase.asset,
170
160
  onInitiateDeposit,
171
161
  onTransactionCompleted,
172
162
  onUrlSignatureRequested,
@@ -0,0 +1,5 @@
1
+ export declare const NetworkSpeedBanner: ({ fontSize, iconSize, maxWidth, }: {
2
+ fontSize?: string;
3
+ iconSize?: string;
4
+ maxWidth?: string;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ import "../chunk-GOCCUU3Z.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { useEffect, useState } from "react";
5
+ import styled from "styled-components";
6
+ import { CpslIcon } from "@getpara/react-components";
7
+ const BannerContainerWrapper = styled.div`
8
+ display: flex;
9
+ justify-content: center;
10
+ align-items: center;
11
+ width: 100%;
12
+ background-color: transparent;
13
+ `;
14
+ const BannerContainer = styled.div`
15
+ display: flex;
16
+ justify-content: center;
17
+ align-items: center;
18
+ max-width: ${({ $maxWidth }) => $maxWidth || "100%"};
19
+ box-sizing: border-box;
20
+ padding: 6px;
21
+ border-radius: 12px;
22
+ background-color: transparent;
23
+ position: relative;
24
+ z-index: 10;
25
+ display: inline-flex;
26
+ white-space: nowrap;
27
+ text-overflow: ellipsis;
28
+ overflow: hidden;
29
+ `;
30
+ const WarningIcon = styled(CpslIcon)`
31
+ --icon-color: #fbbc04;
32
+ --width: ${({ $size }) => $size || "24px"};
33
+ --height: ${({ $size }) => $size || "24px"};
34
+ margin-right: 6px;
35
+ flex-shrink: 0;
36
+ `;
37
+ const BannerText = styled.span`
38
+ font-family: var(--cpsl-default-font);
39
+ font-weight: 500;
40
+ font-size: ${({ $fontSize }) => $fontSize || "14px"};
41
+ color: var(--cpsl-color-black);
42
+ flex: 1;
43
+ `;
44
+ const NetworkSpeedBanner = ({
45
+ fontSize,
46
+ iconSize,
47
+ maxWidth
48
+ }) => {
49
+ const [isSlowNetwork, setIsSlowNetwork] = useState(false);
50
+ useEffect(() => {
51
+ var _a;
52
+ const connection = navigator == null ? void 0 : navigator.connection;
53
+ const checkNetworkSpeed = () => {
54
+ if (connection) {
55
+ const isSlow = connection.effectiveType === "2g" || connection.effectiveType === "slow-2g" || connection.downlink && connection.downlink < 0.5;
56
+ setIsSlowNetwork(isSlow);
57
+ } else {
58
+ setIsSlowNetwork(false);
59
+ }
60
+ };
61
+ checkNetworkSpeed();
62
+ (_a = connection == null ? void 0 : connection.addEventListener) == null ? void 0 : _a.call(connection, "change", checkNetworkSpeed);
63
+ const intervalId = setInterval(checkNetworkSpeed, 15e3);
64
+ return () => {
65
+ var _a2;
66
+ clearInterval(intervalId);
67
+ (_a2 = connection == null ? void 0 : connection.removeEventListener) == null ? void 0 : _a2.call(connection, "change", checkNetworkSpeed);
68
+ };
69
+ }, []);
70
+ if (!isSlowNetwork) {
71
+ return null;
72
+ }
73
+ return /* @__PURE__ */ jsx(BannerContainerWrapper, { children: /* @__PURE__ */ jsxs(BannerContainer, { $maxWidth: maxWidth, children: [
74
+ /* @__PURE__ */ jsx(WarningIcon, { $size: iconSize, icon: "alertTriangle" }),
75
+ /* @__PURE__ */ jsx(BannerText, { $fontSize: fontSize, children: "Your network is slow. This may impact your experience." })
76
+ ] }) });
77
+ };
78
+ export {
79
+ NetworkSpeedBanner
80
+ };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
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
5
  import styled from "styled-components";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-IV3L3JVM.js";
4
+ } from "../chunk-GOCCUU3Z.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";
@@ -1,4 +1,4 @@
1
1
  import { Props } from '../types/index.js';
2
2
  export declare const STRIPE_PUBLISHABLE_KEY = "pk_live_51MvquNGrzDeP5yP9EgVSMBPQbrbg0oHDjPIIXypePd0jzOFjbadyfO7wBKLHhUtbKIUiEUVC3YYcTJyAmJ8xA7JE00T2UDfYKz";
3
- export declare const STRIPE_PUBLISHABLE_KEY_TEST = "pk_test_51Q2z5k2epVn9Kq0ZSbUzuetKb4azH6E6UPcvWmjRxvHmxLAJbIK0pwDbPQo63W9OyDng337ntNu3ZXx3AJ7MhFmR00XgfRmPgP";
3
+ export declare const STRIPE_PUBLISHABLE_KEY_TEST = "pk_test_51MvquNGrzDeP5yP98WgPaAUgQ50I3OpfPhVfiLO47FBHepJnZRPO62IzZY2uxT5ovhSS10RwcTcnaVil1mcJOzIi00dHapODdS";
4
4
  export declare const StripeEmbed: ({ para, isDark, isEmbedded, onRampPurchase, setOnRampPurchase }: Props) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-IV3L3JVM.js";
4
+ } from "../chunk-GOCCUU3Z.js";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import React, { useCallback, useEffect, useMemo, useState } from "react";
7
7
  import { loadStripeOnramp } from "@stripe/crypto";
@@ -10,7 +10,7 @@ import { CpslSpinner } from "@getpara/react-components";
10
10
  import { SpinnerContainer } from "./common.js";
11
11
  import styled from "styled-components";
12
12
  const STRIPE_PUBLISHABLE_KEY = "pk_live_51MvquNGrzDeP5yP9EgVSMBPQbrbg0oHDjPIIXypePd0jzOFjbadyfO7wBKLHhUtbKIUiEUVC3YYcTJyAmJ8xA7JE00T2UDfYKz";
13
- const STRIPE_PUBLISHABLE_KEY_TEST = "pk_test_51Q2z5k2epVn9Kq0ZSbUzuetKb4azH6E6UPcvWmjRxvHmxLAJbIK0pwDbPQo63W9OyDng337ntNu3ZXx3AJ7MhFmR00XgfRmPgP";
13
+ const STRIPE_PUBLISHABLE_KEY_TEST = "pk_test_51MvquNGrzDeP5yP98WgPaAUgQ50I3OpfPhVfiLO47FBHepJnZRPO62IzZY2uxT5ovhSS10RwcTcnaVil1mcJOzIi00dHapODdS";
14
14
  const AssetCodes = {
15
15
  eth: OnRampAsset.ETHEREUM,
16
16
  matic: OnRampAsset.POLYGON,
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
2
+ import "../chunk-GOCCUU3Z.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { CpslAvatar, CpslIcon, CpslText } from "@getpara/react-components";
5
5
  import styled from "styled-components";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
2
+ import "../chunk-GOCCUU3Z.js";
3
3
  import { CpslButton, CpslInput, CpslText } from "@getpara/react-components";
4
4
  import styled from "styled-components";
5
5
  const SpinnerContainer = styled.div`
@@ -6,3 +6,4 @@ export * from './HeroSpinner.js';
6
6
  export * from './KnownDevices.js';
7
7
  export * from './QRCode.js';
8
8
  export * from './UserIdentifier.js';
9
+ export * from './NetworkSpeedBanner.js';
@@ -7,3 +7,4 @@ export * from "./HeroSpinner.js";
7
7
  export * from "./KnownDevices.js";
8
8
  export * from "./QRCode.js";
9
9
  export * from "./UserIdentifier.js";
10
+ export * from "./NetworkSpeedBanner.js";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
2
+ import "../chunk-GOCCUU3Z.js";
3
3
  const aaguidMetadata = {
4
4
  "ea9b8d66-4d01-1d21-3ce4-b6b48cb575d4": {
5
5
  name: "Google Password Manager",
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-IV3L3JVM.js";
4
+ } from "../chunk-GOCCUU3Z.js";
5
5
  import { useCallback, useState } from "react";
6
6
  function useCopyToClipboard() {
7
7
  const [copied, setCopied] = useState(false);
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __spreadValues
4
- } from "../chunk-IV3L3JVM.js";
4
+ } from "../chunk-GOCCUU3Z.js";
5
5
  import { UAParser } from "ua-parser-js";
6
6
  import { aaguidMetadata } from "../constants/aaguiMetadata.js";
7
7
  const formatStringToUUID = (str) => {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
2
+ import "../chunk-GOCCUU3Z.js";
3
3
  import parsePhoneNumberFromString from "libphonenumber-js";
4
4
  const formatPhoneNumber = (phone, countryCode) => {
5
5
  phone = phone.toString();
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
2
+ import "../chunk-GOCCUU3Z.js";
3
3
  import { UAParser } from "ua-parser-js";
4
4
  const getBrowserName = () => new UAParser().getBrowser().name;
5
5
  export {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
2
+ import "../chunk-GOCCUU3Z.js";
3
3
  const getDeviceLogo = (vendor, isMobile) => {
4
4
  switch (vendor == null ? void 0 : vendor.toLowerCase()) {
5
5
  case "apple": {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
2
+ import "../chunk-GOCCUU3Z.js";
3
3
  const getDeviceModelName = (model) => {
4
4
  if (!model) {
5
5
  return void 0;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
2
+ import "../chunk-GOCCUU3Z.js";
3
3
  import { truncateAddress, WalletType } from "@getpara/web-sdk";
4
4
  const getExternalWalletDisplayName = ({ address, type }) => {
5
5
  const walletType = type;
@@ -1,4 +1,9 @@
1
1
  import { OnRampAsset, OnRampAssetInfo, OnRampProvider, Network, OnRampPurchaseType, OnRampConfig, WalletType } from '@getpara/web-sdk';
2
+ export declare function getCurrencyCode({ assetInfo }: OnRampConfig, { network, asset, provider }: {
3
+ network: Network;
4
+ asset: OnRampAsset;
5
+ provider: OnRampProvider;
6
+ }): string | undefined;
2
7
  export declare function getCurrencyCodes({ assetInfo, allowedAssets, defaultOnRampNetwork, defaultOnRampAsset }: OnRampConfig, { provider, purchaseType, walletType, }: {
3
8
  provider: OnRampProvider;
4
9
  purchaseType: OnRampPurchaseType;
@@ -1,5 +1,7 @@
1
1
  "use client";
2
- import "../chunk-IV3L3JVM.js";
2
+ import {
3
+ __spreadValues
4
+ } from "../chunk-GOCCUU3Z.js";
3
5
  import {
4
6
  OnRampAsset,
5
7
  Network,
@@ -7,6 +9,10 @@ import {
7
9
  getOnRampAssets,
8
10
  toAssetInfoArray
9
11
  } from "@getpara/web-sdk";
12
+ function getCurrencyCode({ assetInfo }, { network, asset, provider }) {
13
+ var _a, _b, _c;
14
+ return (_c = (_b = (_a = Object.values(assetInfo).reduce((acc, record) => __spreadValues(__spreadValues({}, acc), record), {})[network]) == null ? void 0 : _a[asset]) == null ? void 0 : _b[provider]) == null ? void 0 : _c[0];
15
+ }
10
16
  function getCurrencyCodes({ assetInfo, allowedAssets, defaultOnRampNetwork, defaultOnRampAsset }, {
11
17
  provider,
12
18
  purchaseType,
@@ -110,6 +116,7 @@ export {
110
116
  getAssetFromContractAddress,
111
117
  getChainId,
112
118
  getContractAddressFromAsset,
119
+ getCurrencyCode,
113
120
  getCurrencyCodes,
114
121
  getNetworkFromChainId,
115
122
  getNetworkOrMainNetEquivalent,
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-IV3L3JVM.js";
4
+ } from "../chunk-GOCCUU3Z.js";
5
5
  import { hexStringToBase64, WalletType } from "@getpara/web-sdk";
6
6
  function offRampSend(_0, _1, _2, _3) {
7
7
  return __async(this, arguments, function* (para, { id: purchaseId, provider, walletId, walletType, address, testMode = false }, setOnRampPurchase, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-common",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,8 +11,8 @@
11
11
  "*.css"
12
12
  ],
13
13
  "dependencies": {
14
- "@getpara/react-components": "1.9.0",
15
- "@getpara/web-sdk": "1.9.0",
14
+ "@getpara/react-components": "1.11.0",
15
+ "@getpara/web-sdk": "1.11.0",
16
16
  "@moonpay/moonpay-react": "^1.8.3",
17
17
  "@ramp-network/ramp-instant-sdk": "^4.0.5",
18
18
  "@stripe/crypto": "^0.0.4",
@@ -43,5 +43,5 @@
43
43
  "resolutions": {
44
44
  "styled-components": "^6"
45
45
  },
46
- "gitHead": "3d749844bf071e2c8de2769dd16e17c026951109"
46
+ "gitHead": "91b68e4ead22e2104307c934f2a582245b176619"
47
47
  }