@getpara/react-common 2.0.0-alpha.6 → 2.0.0-alpha.61
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.
- package/dist/classes/ParaInternal.d.ts +21 -6
- package/dist/classes/ParaInternal.js +17 -1
- package/dist/components/HeroSpinner.d.ts +4 -3
- package/dist/components/HeroSpinner.js +28 -14
- package/dist/components/KnownDevices.js +5 -6
- package/dist/components/MoonPayEmbed.d.ts +4 -2
- package/dist/components/MoonPayEmbed.js +56 -83
- package/dist/components/NetworkSpeedBanner.js +5 -5
- package/dist/components/QRCode.js +7 -7
- package/dist/components/RampEmbed.d.ts +2 -2
- package/dist/components/RampEmbed.js +16 -28
- package/dist/components/UserIdentifier.d.ts +8 -0
- package/dist/components/UserIdentifier.js +30 -22
- package/dist/components/WarningBanner.d.ts +7 -0
- package/dist/components/WarningBanner.js +60 -0
- package/dist/components/common.d.ts +3 -3
- package/dist/components/common.js +7 -7
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/constants/externalWalletDefaults.d.ts +47 -0
- package/dist/constants/externalWalletDefaults.js +49 -0
- package/dist/constants/oAuthLogos.d.ts +12 -0
- package/dist/constants/oAuthLogos.js +160 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useUserAgent.d.ts +2 -0
- package/dist/hooks/useUserAgent.js +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/types/commonTypes.d.ts +15 -0
- package/dist/types/commonTypes.js +1 -0
- package/dist/types/externalWalletCommon.d.ts +69 -37
- package/dist/types/externalWalletCommon.js +0 -31
- package/dist/types/index.d.ts +8 -5
- package/dist/types/index.js +1 -0
- package/dist/utils/formatBiometricHints.d.ts +1 -1
- package/dist/utils/formatBiometricHints.js +2 -2
- package/dist/utils/getExternalWalletDisplayName.d.ts +3 -1
- package/dist/utils/getExternalWalletDisplayName.js +6 -14
- package/dist/utils/getExternalWalletIcon.d.ts +5 -0
- package/dist/utils/getExternalWalletIcon.js +17 -0
- package/dist/utils/index.d.ts +17 -16
- package/dist/utils/index.js +25 -30
- package/dist/utils/safeStyled.d.ts +2 -0
- package/dist/utils/safeStyled.js +25 -0
- package/package.json +22 -24
- package/dist/components/StripeEmbed.d.ts +0 -4
- package/dist/components/StripeEmbed.js +0 -138
- package/dist/utils/offRampSend.d.ts +0 -7
- package/dist/utils/offRampSend.js +0 -75
|
@@ -1,25 +1,40 @@
|
|
|
1
|
-
import ParaWeb from '@getpara/web-sdk';
|
|
2
|
-
export declare class ParaInternal extends ParaWeb {
|
|
1
|
+
import ParaWeb, { InternalInterface } from '@getpara/web-sdk';
|
|
2
|
+
export declare class ParaInternal extends ParaWeb implements InternalInterface {
|
|
3
3
|
setupAfterLogin: ({ temporaryShares, skipSessionRefresh, }?: {
|
|
4
4
|
temporaryShares?: any[];
|
|
5
5
|
skipSessionRefresh?: boolean;
|
|
6
6
|
}) => Promise<void>;
|
|
7
|
-
getSupportedCreateAuthMethods: () => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
|
|
8
7
|
getTransmissionKeyShares: ({ isForNewDevice }?: {
|
|
9
8
|
isForNewDevice?: boolean;
|
|
10
9
|
}) => Promise<any>;
|
|
11
|
-
userSetupAfterLogin: () => Promise<import("@getpara/
|
|
10
|
+
userSetupAfterLogin: () => Promise<import("@getpara/shared").SessionInfo>;
|
|
12
11
|
setLoginEncryptionKeyPair: (keyPair?: import("node-forge").pki.rsa.KeyPair) => Promise<void>;
|
|
13
12
|
getPortalURL: () => Promise<string>;
|
|
14
13
|
isProviderModalDisabled: () => boolean;
|
|
15
|
-
setAuth: (auth: import("@getpara/
|
|
14
|
+
setAuth: (auth: import("@getpara/shared").PrimaryAuth, { extras, userId }?: {
|
|
16
15
|
extras?: import("@getpara/web-sdk").AuthExtras;
|
|
17
16
|
userId?: string;
|
|
18
17
|
}) => Promise<typeof this.authInfo>;
|
|
19
|
-
supportedAuthMethods: (auth: import("@getpara/
|
|
18
|
+
supportedAuthMethods: (auth: import("@getpara/web-sdk").Auth<import("@getpara/shared").PrimaryAuthType | "userId">) => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
|
|
20
19
|
constructPortalUrl: (type: import("@getpara/core-sdk/dist/types/types").PortalUrlType, opts?: import("@getpara/core-sdk/dist/types/types").PortalUrlOptions) => Promise<string>;
|
|
21
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
|
+
getProfileBalance: ({ config, refetch }?: {
|
|
34
|
+
config?: import("@getpara/web-sdk").BalancesConfig;
|
|
35
|
+
refetch?: boolean;
|
|
36
|
+
}) => Promise<import("@getpara/web-sdk").ProfileBalance>;
|
|
37
|
+
setModalError: (_error?: string) => void;
|
|
38
|
+
get partnerLogo(): string;
|
|
39
|
+
get partnerName(): string;
|
|
25
40
|
}
|
|
@@ -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,23 @@ 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
|
+
this.getProfileBalance = super.getProfileBalance;
|
|
27
|
+
this.setModalError = super.setModalError;
|
|
28
|
+
}
|
|
29
|
+
get partnerLogo() {
|
|
30
|
+
return super.partnerLogo;
|
|
31
|
+
}
|
|
32
|
+
get partnerName() {
|
|
33
|
+
return super.partnerName;
|
|
18
34
|
}
|
|
19
35
|
}
|
|
20
36
|
export {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { IconType } from '@getpara/react-components';
|
|
2
2
|
import { PropsWithChildren, ReactNode } from 'react';
|
|
3
|
-
type Status = '
|
|
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
|
|
5
|
+
import { safeStyled } from "../utils/index.js";
|
|
6
6
|
function HeroSpinner({
|
|
7
7
|
icon,
|
|
8
|
-
status = "
|
|
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:
|
|
14
|
-
icon
|
|
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(
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
35
|
+
const Container = safeStyled(CenteredColumnContainer)`
|
|
37
36
|
gap: 16px;
|
|
38
37
|
`;
|
|
39
|
-
const DevicesContainer =
|
|
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 =
|
|
47
|
+
const DeviceListItem = safeStyled.div`
|
|
49
48
|
display: flex;
|
|
50
49
|
gap: 4px;
|
|
51
50
|
align-items: center;
|
|
52
51
|
`;
|
|
53
|
-
const DeviceLogo =
|
|
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 {
|
|
2
|
-
export declare const MoonPayEmbed: ({
|
|
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 {
|
|
6
|
+
import { OnRampProvider } from "@getpara/web-sdk";
|
|
7
7
|
import { lazy, useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
-
import { reverseCurrencyLookup,
|
|
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 = ({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
55
|
+
throw e instanceof Error ? e : new Error(e);
|
|
80
56
|
}
|
|
81
57
|
}),
|
|
82
|
-
[
|
|
58
|
+
[onRampConfig]
|
|
83
59
|
);
|
|
84
60
|
const onInitiateDeposit = useCallback(
|
|
85
61
|
(payload) => __async(void 0, null, function* () {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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 (!
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
138
|
+
onRampPurchase.testMode,
|
|
161
139
|
onTransactionCompleted,
|
|
162
|
-
onUrlSignatureRequested,
|
|
163
140
|
isDark,
|
|
164
|
-
|
|
165
|
-
LazyMoonPaySellWidget
|
|
141
|
+
components
|
|
166
142
|
]);
|
|
167
|
-
|
|
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 =
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
39
|
+
const StyledQRCode = safeStyled(CpslQrCode)`
|
|
40
40
|
--qr-box-shadow: none;
|
|
41
41
|
--qr-border-radius: 0px;
|
|
42
42
|
`;
|
|
43
|
-
const CopyButton =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 {
|
|
2
|
-
export declare const RampEmbed: ({
|
|
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 {
|
|
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
|
-
|
|
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: `${
|
|
36
|
+
hostLogoUrl: `${window.location.hostname}/wordmark_black.svg`,
|
|
42
37
|
hostApiKey: apiKey,
|
|
43
38
|
userAddress: onRampPurchase.address,
|
|
44
|
-
userEmailAddress:
|
|
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 ? [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
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;
|