@getpara/react-common 2.0.0-dev.1 → 2.0.0-dev.2
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/chunk-GOCCUU3Z.js +42 -0
- package/dist/classes/ParaInternal.d.ts +19 -10
- package/dist/classes/ParaInternal.js +28 -0
- package/dist/classes/index.js +2 -0
- package/dist/components/HeroSpinner.d.ts +2 -2
- package/dist/components/HeroSpinner.js +63 -0
- package/dist/components/KnownDevices.js +59 -0
- package/dist/components/MoonPayEmbed.d.ts +2 -2
- package/dist/components/MoonPayEmbed.js +183 -0
- package/dist/components/NetworkSpeedBanner.d.ts +5 -0
- package/dist/components/NetworkSpeedBanner.js +80 -0
- package/dist/components/QRCode.js +80 -0
- package/dist/components/RampEmbed.d.ts +2 -2
- package/dist/components/RampEmbed.js +103 -0
- package/dist/components/UserIdentifier.d.ts +4 -2
- package/dist/components/UserIdentifier.js +65 -0
- package/dist/components/common.d.ts +5 -5
- package/dist/components/common.js +54 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +9 -0
- package/dist/constants/aaguiMetadata.js +145 -0
- package/dist/constants/externalWalletDefaults.d.ts +41 -0
- package/dist/constants/externalWalletDefaults.js +47 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/useCopyToClipboard.js +36 -0
- package/dist/hooks/useUserAgent.d.ts +2 -0
- package/dist/hooks/useUserAgent.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -1290
- package/dist/package.json +6 -0
- package/dist/types/externalWalletCommon.d.ts +68 -40
- package/dist/types/externalWalletCommon.js +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +2 -0
- package/dist/utils/formatBiometricHints.d.ts +1 -1
- package/dist/utils/formatBiometricHints.js +51 -0
- package/dist/utils/getBrowserName.js +7 -0
- package/dist/utils/getDeviceLogo.js +36 -0
- package/dist/utils/getDeviceModelName.js +21 -0
- package/dist/utils/getExternalWalletDisplayName.d.ts +2 -5
- package/dist/utils/getExternalWalletDisplayName.js +22 -0
- package/dist/utils/index.d.ts +8 -2
- package/dist/utils/index.js +125 -0
- package/dist/utils/offRampSend.js +75 -0
- 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/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../chunk-GOCCUU3Z.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { useEffect, useRef } from "react";
|
|
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";
|
|
16
|
+
const TEST_MODE_FORBIDDEN = ["ETH_ETH", "ETH_USDC"];
|
|
17
|
+
const RampEmbed = ({
|
|
18
|
+
para,
|
|
19
|
+
appName,
|
|
20
|
+
onRampConfig,
|
|
21
|
+
onRampPurchase,
|
|
22
|
+
isEmbedded,
|
|
23
|
+
apiKey,
|
|
24
|
+
onClose,
|
|
25
|
+
setOnRampPurchase
|
|
26
|
+
}) => {
|
|
27
|
+
const { currencyCodes } = getCurrencyCodes(onRampConfig, {
|
|
28
|
+
provider: OnRampProvider.RAMP,
|
|
29
|
+
purchaseType: onRampPurchase.type,
|
|
30
|
+
walletType: onRampPurchase.walletType
|
|
31
|
+
});
|
|
32
|
+
const isMounted = useRef(false);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!isMounted.current) {
|
|
35
|
+
try {
|
|
36
|
+
const widget = new RampInstantSDK({
|
|
37
|
+
hostAppName: appName,
|
|
38
|
+
swapAsset: currencyCodes.filter((code) => !onRampPurchase.testMode || !TEST_MODE_FORBIDDEN.includes(code)).join(","),
|
|
39
|
+
fiatValue: onRampPurchase.fiatQuantity,
|
|
40
|
+
fiatCurrency: onRampPurchase.fiat,
|
|
41
|
+
hostLogoUrl: `${getPortalBaseURL(para.ctx)}/wordmark_black.svg`,
|
|
42
|
+
hostApiKey: apiKey,
|
|
43
|
+
userAddress: onRampPurchase.address,
|
|
44
|
+
userEmailAddress: para.getEmail(),
|
|
45
|
+
url: (onRampPurchase == null ? void 0 : onRampPurchase.testMode) ? "https://app.demo.ramp.network" : "https://app.ramp.network",
|
|
46
|
+
enabledFlows: [onRampPurchase.type === "BUY" ? "ONRAMP" : "OFFRAMP"],
|
|
47
|
+
useSendCryptoCallback: true,
|
|
48
|
+
variant: "embedded-mobile",
|
|
49
|
+
containerNode: document.getElementById("ramp-container")
|
|
50
|
+
}).on("PURCHASE_CREATED", (e) => __async(void 0, null, function* () {
|
|
51
|
+
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
|
+
}
|
|
66
|
+
});
|
|
67
|
+
setOnRampPurchase(updated);
|
|
68
|
+
})).on("WIDGET_CLOSE", () => __async(void 0, null, function* () {
|
|
69
|
+
onClose == null ? void 0 : onClose();
|
|
70
|
+
if (!isEmbedded) {
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
if (typeof window !== "undefined") {
|
|
73
|
+
window.close();
|
|
74
|
+
}
|
|
75
|
+
}, 5e3);
|
|
76
|
+
}
|
|
77
|
+
})).onSendCrypto((assetInfo, amount, address) => __async(void 0, null, function* () {
|
|
78
|
+
try {
|
|
79
|
+
const [network, asset] = reverseCurrencyLookup(onRampConfig.assetInfo, OnRampProvider.RAMP, assetInfo.symbol);
|
|
80
|
+
const txHash = yield offRampSend(para, onRampPurchase, setOnRampPurchase, {
|
|
81
|
+
assetQuantity: amount,
|
|
82
|
+
destinationAddress: address,
|
|
83
|
+
contractAddress: getContractAddressFromAsset(network, asset),
|
|
84
|
+
chainId: getChainId(network),
|
|
85
|
+
testMode: onRampPurchase.testMode
|
|
86
|
+
});
|
|
87
|
+
return { txHash };
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error(e);
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
widget.show();
|
|
93
|
+
isMounted.current = true;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.error(e);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}, []);
|
|
99
|
+
return /* @__PURE__ */ jsx("div", { id: "ramp-container", style: { minWidth: "320px", width: "100%", height: "767px" } });
|
|
100
|
+
};
|
|
101
|
+
export {
|
|
102
|
+
RampEmbed
|
|
103
|
+
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const UserIdentifier: ({
|
|
1
|
+
import { CoreAuthInfo } from '@getpara/web-sdk';
|
|
2
|
+
export declare const UserIdentifier: ({ authInfo }: {
|
|
3
|
+
authInfo?: CoreAuthInfo;
|
|
4
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-GOCCUU3Z.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
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;
|
|
9
|
+
switch (authType) {
|
|
10
|
+
case "email":
|
|
11
|
+
return { defaultName: identifier.toLowerCase(), defaultIcon: "mail" };
|
|
12
|
+
case "phone":
|
|
13
|
+
return { defaultName: displayPhoneNumber(identifier), defaultIcon: "phone" };
|
|
14
|
+
case "farcaster":
|
|
15
|
+
return { defaultName: `@${identifier}`, defaultIcon: "farcasterBrand" };
|
|
16
|
+
case "telegram":
|
|
17
|
+
return { defaultName: `Telegram User @${identifier}`, defaultIcon: "telegramBrand" };
|
|
18
|
+
case "externalWallet":
|
|
19
|
+
return { defaultName: getExternalWalletDisplayName(externalWallet), defaultIcon: "wallet" };
|
|
20
|
+
default:
|
|
21
|
+
return { defaultName: null, defaultIcon: null };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const UserIdentifier = ({ authInfo }) => {
|
|
25
|
+
if (!authInfo) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const { authType, displayName, pfpUrl } = authInfo;
|
|
29
|
+
const { defaultName, defaultIcon } = defaultDisplay(authInfo);
|
|
30
|
+
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 })
|
|
33
|
+
] });
|
|
34
|
+
};
|
|
35
|
+
const Container = safeStyled.div`
|
|
36
|
+
padding: 8px 12px 8px 8px;
|
|
37
|
+
border-radius: 1000px;
|
|
38
|
+
background-color: var(--cpsl-color-background-4);
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: flex-start;
|
|
42
|
+
gap: 4px;
|
|
43
|
+
`;
|
|
44
|
+
const IdentifierText = safeStyled(CpslText)`
|
|
45
|
+
--color-override: var(--cpsl-color-background-96);
|
|
46
|
+
`;
|
|
47
|
+
const IconContainer = safeStyled.div`
|
|
48
|
+
display: flex;
|
|
49
|
+
background: var(--cpsl-color-background-0);
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
border-radius: 1000px;
|
|
53
|
+
width: 20px;
|
|
54
|
+
height: 20px;
|
|
55
|
+
`;
|
|
56
|
+
const Icon = safeStyled(CpslIcon)`
|
|
57
|
+
--icon-color: var(--cpsl-color-text-primary);
|
|
58
|
+
`;
|
|
59
|
+
const Avatar = safeStyled(CpslAvatar)`
|
|
60
|
+
--container-border-width: 0;
|
|
61
|
+
--container-padding: 0;
|
|
62
|
+
`;
|
|
63
|
+
export {
|
|
64
|
+
UserIdentifier
|
|
65
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CpslInput, CpslText } from '@getpara/react-components';
|
|
2
|
-
export declare const SpinnerContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
-
export declare const CenteredColumnContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
2
|
+
export declare const SpinnerContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
+
export declare const CenteredColumnContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
4
|
export declare const FilledDisabledInput: typeof CpslInput;
|
|
5
5
|
export declare const FullWidthFilledDisabledInput: typeof CpslInput;
|
|
6
6
|
export declare const CenteredText: typeof CpslText;
|
|
7
|
-
export declare const HeaderButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<
|
|
8
|
-
ref?: import("react").Ref<
|
|
9
|
-
}, never>> & string & Omit<import("react").ForwardRefExoticComponent<
|
|
7
|
+
export declare const HeaderButton: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<any, "ref"> & import("react").RefAttributes<any>, "ref"> & {
|
|
8
|
+
ref?: import("react").Ref<any>;
|
|
9
|
+
}, never>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>, keyof import("react").Component<any, {}, any>>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-GOCCUU3Z.js";
|
|
3
|
+
import { CpslButton, CpslInput, CpslText } from "@getpara/react-components";
|
|
4
|
+
import { safeStyled } from "../utils/index.js";
|
|
5
|
+
const SpinnerContainer = safeStyled.div`
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
`;
|
|
10
|
+
const CenteredColumnContainer = safeStyled.div`
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
align-self: center;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: 8px;
|
|
18
|
+
`;
|
|
19
|
+
const FilledDisabledInput = safeStyled(CpslInput)`
|
|
20
|
+
--container-border-color: var(--cpsl-color-input-border-placeholder);
|
|
21
|
+
--container-background-color: var(--cpsl-color-background-0);
|
|
22
|
+
--input-background-color: transparent;
|
|
23
|
+
--input-font-weight: 500;
|
|
24
|
+
--input-color: var(--cpsl-color-text-secondary) !important;
|
|
25
|
+
`;
|
|
26
|
+
const FullWidthFilledDisabledInput = safeStyled(FilledDisabledInput)`
|
|
27
|
+
width: 100%;
|
|
28
|
+
`;
|
|
29
|
+
const CenteredText = safeStyled(CpslText)`
|
|
30
|
+
width: 100%;
|
|
31
|
+
text-align: center;
|
|
32
|
+
`;
|
|
33
|
+
const HeaderButton = safeStyled(CpslButton)`
|
|
34
|
+
flex: 0;
|
|
35
|
+
--button-padding-top: 2px;
|
|
36
|
+
--button-padding-bottom: 2px;
|
|
37
|
+
--button-padding-start: 2px;
|
|
38
|
+
--button-padding-end: 2px;
|
|
39
|
+
--button-border-radius: 1000px;
|
|
40
|
+
--button-background-color: var(--cpsl-color-background-4);
|
|
41
|
+
|
|
42
|
+
cpsl-icon {
|
|
43
|
+
--height: 20px;
|
|
44
|
+
--width: 20px;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
export {
|
|
48
|
+
CenteredColumnContainer,
|
|
49
|
+
CenteredText,
|
|
50
|
+
FilledDisabledInput,
|
|
51
|
+
FullWidthFilledDisabledInput,
|
|
52
|
+
HeaderButton,
|
|
53
|
+
SpinnerContainer
|
|
54
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from './MoonPayEmbed.js';
|
|
2
2
|
export * from './RampEmbed.js';
|
|
3
|
-
export * from './StripeEmbed.js';
|
|
4
3
|
export * from './common.js';
|
|
5
4
|
export * from './HeroSpinner.js';
|
|
6
5
|
export * from './KnownDevices.js';
|
|
7
6
|
export * from './QRCode.js';
|
|
8
7
|
export * from './UserIdentifier.js';
|
|
8
|
+
export * from './NetworkSpeedBanner.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export * from "./MoonPayEmbed.js";
|
|
3
|
+
export * from "./RampEmbed.js";
|
|
4
|
+
export * from "./common.js";
|
|
5
|
+
export * from "./HeroSpinner.js";
|
|
6
|
+
export * from "./KnownDevices.js";
|
|
7
|
+
export * from "./QRCode.js";
|
|
8
|
+
export * from "./UserIdentifier.js";
|
|
9
|
+
export * from "./NetworkSpeedBanner.js";
|