@getpara/react-common 2.0.0-dev.3 → 2.0.0-dev.6

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.
@@ -21,6 +21,7 @@ export declare class ParaInternal extends ParaWeb implements InternalInterface {
21
21
  credentialId: string;
22
22
  url?: string;
23
23
  }>;
24
+ prepareLogin: () => import("@getpara/web-sdk").InternalMethodResponse<"prepareLogin">;
24
25
  linkAccount: (opts: import("@getpara/web-sdk").InternalMethodParams<"linkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"linkAccount">;
25
26
  unlinkAccount: ({ linkedAccountId, }: import("@getpara/web-sdk").InternalMethodParams<"unlinkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"unlinkAccount">;
26
27
  verifyEmailOrPhoneLink: ({ verificationCode, }: import("@getpara/web-sdk").InternalMethodParams<"verifyEmailOrPhoneLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyEmailOrPhoneLink">;
@@ -28,4 +29,7 @@ export declare class ParaInternal extends ParaWeb implements InternalInterface {
28
29
  verifyTelegramLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyTelegramLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyTelegramLink">;
29
30
  verifyFarcasterLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyFarcasterLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyFarcasterLink">;
30
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;
31
35
  }
@@ -14,6 +14,7 @@ class ParaInternal extends ParaWeb {
14
14
  this.supportedAuthMethods = super.supportedAuthMethods;
15
15
  this.constructPortalUrl = super.constructPortalUrl;
16
16
  this.getNewCredentialAndUrl = super.getNewCredentialAndUrl;
17
+ this.prepareLogin = super.prepareLogin;
17
18
  this.linkAccount = super.linkAccount;
18
19
  this.unlinkAccount = super.unlinkAccount;
19
20
  this.verifyEmailOrPhoneLink = super.verifyEmailOrPhoneLink;
@@ -21,6 +22,13 @@ class ParaInternal extends ParaWeb {
21
22
  this.verifyTelegramLink = super.verifyTelegramLink;
22
23
  this.verifyFarcasterLink = super.verifyFarcasterLink;
23
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;
24
32
  }
25
33
  }
26
34
  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 {};
@@ -6,7 +6,8 @@ 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,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;
@@ -3,15 +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, 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,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;
@@ -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;
@@ -1,35 +1,43 @@
1
1
  "use client";
2
- import "../chunk-GOCCUU3Z.js";
2
+ import {
3
+ __spreadValues
4
+ } from "../chunk-GOCCUU3Z.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
  };
@@ -28,7 +28,10 @@ export declare const defaultEvmExternalWallet: {
28
28
  requestInfo: () => Promise<ExternalWalletInfo>;
29
29
  disconnectBase: () => Promise<void>;
30
30
  useAccount: () => any;
31
- farcasterStatus: any;
31
+ farcasterStatus: {
32
+ isPresent: false;
33
+ };
34
+ verificationStage: any;
32
35
  };
33
36
  export declare const defaultSolanaExternalWallet: {
34
37
  wallets: any[];
@@ -38,4 +41,7 @@ export declare const defaultSolanaExternalWallet: {
38
41
  requestInfo: () => Promise<ExternalWalletInfo>;
39
42
  disconnectBase: () => Promise<void>;
40
43
  useWallet: () => any;
44
+ farcasterStatus: {
45
+ isPresent: false;
46
+ };
41
47
  };
@@ -29,7 +29,8 @@ const defaultEvmExternalWallet = {
29
29
  requestInfo: () => Promise.resolve({}),
30
30
  disconnectBase: () => Promise.resolve(),
31
31
  useAccount: () => void 0,
32
- farcasterStatus: void 0
32
+ farcasterStatus: { isPresent: false },
33
+ verificationStage: void 0
33
34
  };
34
35
  const defaultSolanaExternalWallet = {
35
36
  wallets: [],
@@ -38,7 +39,8 @@ const defaultSolanaExternalWallet = {
38
39
  signVerificationMessage: () => Promise.resolve({}),
39
40
  requestInfo: () => Promise.resolve({}),
40
41
  disconnectBase: () => Promise.resolve(),
41
- useWallet: () => void 0
42
+ useWallet: () => void 0,
43
+ farcasterStatus: { isPresent: false }
42
44
  };
43
45
  export {
44
46
  defaultCosmosExternalWallet,
@@ -0,0 +1,12 @@
1
+ import { IconType } from '@getpara/react-components';
2
+ import { TLinkedAccountType } from '@getpara/web-sdk';
3
+ import { DisplayMetadata } from '../types/commonTypes.js';
4
+ export declare const ACCOUNT_TYPES: {
5
+ [key in TLinkedAccountType | string]: DisplayMetadata & {
6
+ isExternalWallet?: boolean;
7
+ };
8
+ };
9
+ export declare function getAccountTypeName(type: TLinkedAccountType | string | undefined, { inline }?: {
10
+ inline?: boolean;
11
+ }): string | undefined;
12
+ export declare function getAccountTypeLogo(type: TLinkedAccountType | undefined): IconType | undefined;
@@ -0,0 +1,160 @@
1
+ "use client";
2
+ import "../chunk-GOCCUU3Z.js";
3
+ const ACCOUNT_TYPES = {
4
+ "EMAIL": {
5
+ icon: "mail",
6
+ name: "Email",
7
+ inlineText: "email address",
8
+ isPlain: true
9
+ },
10
+ "PHONE": {
11
+ icon: "phone",
12
+ name: "Phone",
13
+ inlineText: "phone number",
14
+ isPlain: true
15
+ },
16
+ "EXTERNAL_WALLET": {
17
+ icon: "wallet",
18
+ name: "External Wallet",
19
+ inlineText: "external wallet",
20
+ isPlain: true
21
+ },
22
+ "GOOGLE": {
23
+ icon: "google",
24
+ iconBranded: "googleBrand",
25
+ name: "Google"
26
+ },
27
+ "TWITTER": {
28
+ icon: "twitter",
29
+ // Not using branded here to ensure the icon looks correct in dark mode
30
+ iconBranded: "twitter",
31
+ name: "X / Twitter",
32
+ inlineText: "X account",
33
+ isDark: true
34
+ },
35
+ "APPLE": {
36
+ icon: "apple",
37
+ // Not using branded here to ensure the icon looks correct in dark mode
38
+ iconBranded: "apple",
39
+ name: "Apple",
40
+ isDark: true
41
+ },
42
+ "DISCORD": {
43
+ icon: "discord",
44
+ iconBranded: "discordBrand",
45
+ name: "Discord"
46
+ },
47
+ "FACEBOOK": {
48
+ icon: "facebook",
49
+ iconBranded: "facebookBrand",
50
+ name: "Facebook"
51
+ },
52
+ "FARCASTER": {
53
+ icon: "farcaster",
54
+ iconBranded: "farcasterBrand",
55
+ name: "Farcaster"
56
+ },
57
+ "TELEGRAM": {
58
+ icon: "telegram",
59
+ iconBranded: "telegramBrand",
60
+ name: "Telegram"
61
+ },
62
+ "MetaMask": {
63
+ icon: "metamask",
64
+ name: "MetaMask",
65
+ isExternalWallet: true
66
+ },
67
+ "Rainbow": {
68
+ icon: "rainbow",
69
+ name: "Rainbow",
70
+ isExternalWallet: true
71
+ },
72
+ "Coinbase Wallet": {
73
+ icon: "coinbase",
74
+ name: "Coinbase Wallet",
75
+ isExternalWallet: true
76
+ },
77
+ "WalletConnect": {
78
+ icon: "walletConnect",
79
+ name: "WalletConnect",
80
+ isExternalWallet: true
81
+ },
82
+ "Zerion": {
83
+ icon: "zerion",
84
+ name: "Zerion",
85
+ isExternalWallet: true
86
+ },
87
+ "Safe": {
88
+ icon: "safe",
89
+ name: "Safe",
90
+ isExternalWallet: true
91
+ },
92
+ "Rabby": {
93
+ icon: "rabby",
94
+ name: "Rabby",
95
+ isExternalWallet: true
96
+ },
97
+ "OKX Wallet": {
98
+ icon: "okx",
99
+ name: "OKX Wallet",
100
+ isExternalWallet: true
101
+ },
102
+ "Phantom": {
103
+ icon: "phantom",
104
+ name: "Phantom",
105
+ isExternalWallet: true
106
+ },
107
+ "Glow": {
108
+ icon: "glow",
109
+ name: "Glow",
110
+ isExternalWallet: true
111
+ },
112
+ "Backpack": {
113
+ icon: "backpack",
114
+ name: "Backpack",
115
+ isExternalWallet: true
116
+ },
117
+ "Keplr": {
118
+ icon: "keplr",
119
+ name: "Keplr",
120
+ isExternalWallet: true
121
+ },
122
+ "Leap": {
123
+ icon: "leap",
124
+ name: "Leap",
125
+ isExternalWallet: true
126
+ },
127
+ "HaHa": {
128
+ icon: "haha",
129
+ name: "HaHa",
130
+ isExternalWallet: true
131
+ },
132
+ "Cosmostation": {
133
+ icon: "cosmostation",
134
+ name: "Cosmostation",
135
+ isExternalWallet: true
136
+ },
137
+ "Solflare": {
138
+ icon: "solflare",
139
+ name: "Solflare",
140
+ isExternalWallet: true
141
+ },
142
+ "Valora": {
143
+ icon: "valora",
144
+ name: "Valora",
145
+ isExternalWallet: true
146
+ }
147
+ };
148
+ function getAccountTypeName(type, { inline = false } = {}) {
149
+ var _a;
150
+ const data = type ? ACCOUNT_TYPES[type] : void 0;
151
+ return data ? inline ? (_a = data.inlineText) != null ? _a : `${data.name} ${data.isExternalWallet ? "wallet" : "account"}` : data.name : void 0;
152
+ }
153
+ function getAccountTypeLogo(type) {
154
+ return type ? ACCOUNT_TYPES[type].iconBranded || ACCOUNT_TYPES[type].icon : void 0;
155
+ }
156
+ export {
157
+ ACCOUNT_TYPES,
158
+ getAccountTypeLogo,
159
+ getAccountTypeName
160
+ };
package/dist/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from './utils/index.js';
4
4
  export * from './hooks/index.js';
5
5
  export * from './types/index.js';
6
6
  export * from './constants/externalWalletDefaults.js';
7
+ export * from './constants/oAuthLogos.js';
package/dist/index.js CHANGED
@@ -5,3 +5,4 @@ export * from "./utils/index.js";
5
5
  export * from "./hooks/index.js";
6
6
  export * from "./types/index.js";
7
7
  export * from "./constants/externalWalletDefaults.js";
8
+ export * from "./constants/oAuthLogos.js";
@@ -0,0 +1,15 @@
1
+ import { IconType } from '@getpara/react-components';
2
+ export type Tab<T> = {
3
+ label: string;
4
+ value: T;
5
+ icon: IconType;
6
+ };
7
+ export type DisplayMetadata = {
8
+ name: string;
9
+ inlineText?: string;
10
+ icon: IconType;
11
+ iconBranded?: IconType;
12
+ isDark?: boolean;
13
+ isCircular?: boolean;
14
+ isPlain?: boolean;
15
+ };
@@ -0,0 +1 @@
1
+ "use client";
@@ -77,9 +77,13 @@ export type BalanceManagement<B = string> = {
77
77
  };
78
78
  export type FarcasterMiniAppManagement = {
79
79
  farcasterStatus: {
80
+ isPresent: false;
81
+ } | {
82
+ isPresent: true;
80
83
  isConnected: false;
81
84
  address?: undefined;
82
85
  } | {
86
+ isPresent: true;
83
87
  isConnected: true;
84
88
  address: string;
85
89
  } | undefined;
@@ -89,8 +93,8 @@ export type ExternalWalletContextType<S extends SignResult = SignResult> = {
89
93
  disconnect: () => Promise<void>;
90
94
  signMessage: (_: SignArgs) => Promise<S>;
91
95
  signVerificationMessage: () => Promise<S>;
92
- requestInfo: (_: TExternalWallet) => Promise<ExternalWalletInfo>;
93
- disconnectBase: (_?: TExternalWallet) => Promise<void>;
96
+ requestInfo: (_: string) => Promise<ExternalWalletInfo>;
97
+ disconnectBase: (_?: string) => Promise<void>;
94
98
  };
95
99
  export type ExternalWalletProviderConfigBase = {
96
100
  onSwitchWallet?: (args: {
@@ -1,15 +1,18 @@
1
- import { AuthInfo } from '@getpara/user-management-client';
2
- import ParaWeb, { type OnRampConfig, type OnRampPurchase } from '@getpara/web-sdk';
1
+ import { AuthInfo, OnRampPurchaseUpdateParams } from '@getpara/user-management-client';
2
+ import { OfframpDepositRequest, type OnRampConfig, type OnRampPurchase } from '@getpara/web-sdk';
3
3
  export * from './externalWalletCommon.js';
4
+ export * from './commonTypes.js';
4
5
  export type OnRampProps = {
5
6
  appName?: string;
6
- para: ParaWeb;
7
+ email?: string;
7
8
  isDark?: boolean;
8
9
  isEmbedded?: boolean;
9
10
  onClose?: () => void;
10
11
  onRampConfig: OnRampConfig;
11
12
  onRampPurchase: OnRampPurchase;
12
- setOnRampPurchase?: (_: OnRampPurchase) => void;
13
+ onDepositRequest: (_: OfframpDepositRequest) => Promise<string>;
14
+ onUpdate: (_: OnRampPurchaseUpdateParams) => Promise<void>;
15
+ onSuccess: (_: OnRampPurchaseUpdateParams) => Promise<void>;
13
16
  };
14
17
  export type ModalAuthInfo = AuthInfo & Partial<{
15
18
  pfpUrl: string | null;
@@ -1,2 +1,3 @@
1
1
  "use client";
2
2
  export * from "./externalWalletCommon.js";
3
+ export * from "./commonTypes.js";
@@ -1,2 +1,4 @@
1
1
  import { ExternalWalletInfo } from '@getpara/user-management-client';
2
- export declare const getExternalWalletDisplayName: ({ address, type, addressBech32 }: ExternalWalletInfo) => string;
2
+ export declare const getExternalWalletDisplayName: ({ address, type, providerId, addressBech32 }: ExternalWalletInfo, { withAddress }?: {
3
+ withAddress?: boolean;
4
+ }) => string;
@@ -1,21 +1,13 @@
1
1
  "use client";
2
2
  import "../chunk-GOCCUU3Z.js";
3
3
  import { truncateAddress } from "@getpara/web-sdk";
4
- const getExternalWalletDisplayName = ({ address, type, addressBech32 }) => {
4
+ const getExternalWalletDisplayName = ({ address, type, providerId, addressBech32 }, { withAddress = false } = {}) => {
5
5
  const walletType = type;
6
- let walletTypeDisplay;
7
- switch (walletType) {
8
- case "EVM":
9
- walletTypeDisplay = "EVM";
10
- break;
11
- case "SOLANA":
12
- walletTypeDisplay = "Solana";
13
- break;
14
- case "COSMOS":
15
- walletTypeDisplay = "Cosmos";
16
- break;
17
- }
18
- return `${walletTypeDisplay} ${truncateAddress(addressBech32 != null ? addressBech32 : address, walletType)}`;
6
+ return `${providerId != null ? providerId : {
7
+ EVM: "EVM",
8
+ SOLANA: "Solana",
9
+ COSMOS: "Cosmos"
10
+ }[type]}${withAddress ? ` ${truncateAddress(addressBech32 != null ? addressBech32 : address, walletType)}` : ""}`;
19
11
  };
20
12
  export {
21
13
  getExternalWalletDisplayName
@@ -0,0 +1,5 @@
1
+ import { TExternalWallet } from '@getpara/web-sdk';
2
+ import { IconType } from '@getpara/react-components';
3
+ export declare function getExternalWalletIcon(internalId: TExternalWallet | string | undefined, { branded }?: {
4
+ branded?: boolean;
5
+ }): IconType | undefined;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import "../chunk-GOCCUU3Z.js";
3
+ import { ACCOUNT_TYPES } from "../constants/oAuthLogos.js";
4
+ function getExternalWalletIcon(internalId, { branded = false } = {}) {
5
+ var _a;
6
+ if (!internalId) {
7
+ return "wallet02";
8
+ }
9
+ const data = (_a = ACCOUNT_TYPES) == null ? void 0 : _a[internalId];
10
+ if (!data) {
11
+ return "wallet02";
12
+ }
13
+ return branded ? data.iconBranded || data.icon : data.icon;
14
+ }
15
+ export {
16
+ getExternalWalletIcon
17
+ };
@@ -32,10 +32,10 @@ export declare const NetworkAssetAddresses: {
32
32
  }[];
33
33
  export declare function getAssetFromContractAddress(network: Network, contractAddress: string): OnRampAsset | undefined;
34
34
  export declare function getContractAddressFromAsset(network: Network, asset: OnRampAsset): string | undefined;
35
- export * from './offRampSend.js';
36
35
  export * from './getDeviceLogo.js';
37
36
  export * from './getDeviceModelName.js';
38
37
  export * from './getBrowserName.js';
39
38
  export * from './formatBiometricHints.js';
40
39
  export * from './getExternalWalletDisplayName.js';
40
+ export * from './getExternalWalletIcon.js';
41
41
  export * from './safeStyled.js';
@@ -102,12 +102,12 @@ function getContractAddressFromAsset(network, asset) {
102
102
  }
103
103
  return (_a = NetworkAssetAddresses.find((row) => row.network === network && row.asset === asset)) == null ? void 0 : _a.address;
104
104
  }
105
- export * from "./offRampSend.js";
106
105
  export * from "./getDeviceLogo.js";
107
106
  export * from "./getDeviceModelName.js";
108
107
  export * from "./getBrowserName.js";
109
108
  export * from "./formatBiometricHints.js";
110
109
  export * from "./getExternalWalletDisplayName.js";
110
+ export * from "./getExternalWalletIcon.js";
111
111
  export * from "./safeStyled.js";
112
112
  export {
113
113
  NetworkAssetAddresses,
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@getpara/react-common",
3
- "version": "2.0.0-dev.3",
3
+ "version": "2.0.0-dev.6",
4
4
  "dependencies": {
5
- "@getpara/react-components": "2.0.0-dev.3",
6
- "@getpara/web-sdk": "2.0.0-dev.3",
5
+ "@getpara/react-components": "2.0.0-dev.6",
6
+ "@getpara/web-sdk": "2.0.0-dev.6",
7
7
  "@moonpay/moonpay-react": "^1.8.3",
8
8
  "@ramp-network/ramp-instant-sdk": "^4.0.5",
9
9
  "libphonenumber-js": "^1.11.7",
@@ -40,5 +40,5 @@
40
40
  ],
41
41
  "type": "module",
42
42
  "types": "dist/index.d.ts",
43
- "gitHead": "ffe34f7d8df2dd3c2327ca1f35bcc9764e0a68a2"
43
+ "gitHead": "c2125e37c73a19f11978031f5aa2eab39b978c56"
44
44
  }
@@ -1,7 +0,0 @@
1
- import { OnRampPurchaseUpdateParams } from '@getpara/user-management-client';
2
- import Para, { OnRampPurchase } from '@getpara/web-sdk';
3
- export declare function offRampSend(para: Para, { id: purchaseId, provider, walletId, walletType, address, testMode }: Partial<OnRampPurchase>, setOnRampPurchase: (_: OnRampPurchase) => void, { assetQuantity, fiat, fiatQuantity, chainId, destinationAddress, contractAddress, }: OnRampPurchaseUpdateParams & {
4
- chainId?: string;
5
- destinationAddress: string;
6
- contractAddress?: string | null;
7
- }): Promise<string | undefined>;
@@ -1,75 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../chunk-GOCCUU3Z.js";
5
- import { hexStringToBase64 } from "@getpara/web-sdk";
6
- function offRampSend(_0, _1, _2, _3) {
7
- return __async(this, arguments, function* (para, { id: purchaseId, provider, walletId, walletType, address, testMode = false }, setOnRampPurchase, {
8
- assetQuantity,
9
- fiat,
10
- fiatQuantity,
11
- chainId,
12
- destinationAddress,
13
- contractAddress
14
- }) {
15
- var _a, _b, _c;
16
- if (!purchaseId || !walletId || !walletType || !provider) {
17
- throw new Error("Missing required fields");
18
- }
19
- try {
20
- const { tx, message, network, asset } = yield para.ctx.client.generateOffRampTx(para.getUserId(), {
21
- walletId,
22
- walletType,
23
- provider,
24
- chainId,
25
- destinationAddress,
26
- sourceAddress: address,
27
- contractAddress,
28
- testMode,
29
- assetQuantity
30
- });
31
- let signature;
32
- switch (walletType) {
33
- case "EVM":
34
- signature = (_a = yield para.signTransaction({
35
- walletId,
36
- rlpEncodedTxBase64: hexStringToBase64(tx),
37
- chainId
38
- })) == null ? void 0 : _a.signature;
39
- break;
40
- case "SOLANA":
41
- signature = (_b = yield para.signMessage({ walletId, messageBase64: message })) == null ? void 0 : _b.signature;
42
- break;
43
- default:
44
- throw new Error(`Unsupported wallet type: ${walletType}`);
45
- }
46
- const { txHash } = yield para.ctx.client.sendOffRampTx(para.getUserId(), {
47
- tx,
48
- signature: walletType === "EVM" ? `0x${signature}` : signature,
49
- sourceAddress: address,
50
- network,
51
- walletId,
52
- walletType
53
- });
54
- const updated = yield para.ctx.client.updateOnRampPurchase({
55
- userId: para.getUserId(),
56
- walletId,
57
- purchaseId,
58
- updates: {
59
- fiat,
60
- fiatQuantity,
61
- assetQuantity,
62
- network,
63
- asset
64
- }
65
- });
66
- setOnRampPurchase(updated);
67
- return txHash;
68
- } catch (e) {
69
- throw new Error(((_c = e.response) == null ? void 0 : _c.data) || e.message);
70
- }
71
- });
72
- }
73
- export {
74
- offRampSend
75
- };