@getpara/react-common 2.0.0-alpha.5 → 2.0.0-alpha.50
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 +14 -4
- package/dist/classes/ParaInternal.js +15 -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 +15 -27
- package/dist/components/UserIdentifier.d.ts +8 -0
- package/dist/components/UserIdentifier.js +30 -22
- package/dist/components/common.d.ts +3 -3
- package/dist/components/common.js +7 -7
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -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 +2 -1
- package/dist/utils/index.js +2 -1
- 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
package/dist/types/index.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { AuthInfo } from '@getpara/user-management-client';
|
|
2
|
-
import
|
|
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
|
|
4
|
+
export * from './commonTypes.js';
|
|
5
|
+
export type OnRampProps = {
|
|
5
6
|
appName?: string;
|
|
6
|
-
|
|
7
|
+
email?: string;
|
|
7
8
|
isDark?: boolean;
|
|
8
9
|
isEmbedded?: boolean;
|
|
9
10
|
onClose?: () => void;
|
|
10
11
|
onRampConfig: OnRampConfig;
|
|
11
12
|
onRampPurchase: OnRampPurchase;
|
|
12
|
-
|
|
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;
|
package/dist/types/index.js
CHANGED
|
@@ -10,5 +10,5 @@ export type BiometricHints = {
|
|
|
10
10
|
isOnKnownDevice: boolean;
|
|
11
11
|
formattedHints: FormattedBiometricHint[];
|
|
12
12
|
};
|
|
13
|
-
export declare const formatBiometricHints: (hints: BiometricLocationHint[]) => BiometricHints;
|
|
13
|
+
export declare const formatBiometricHints: (hints: BiometricLocationHint[], isPasskeySupported?: boolean) => BiometricHints;
|
|
14
14
|
export {};
|
|
@@ -10,7 +10,7 @@ const formatStringToUUID = (str) => {
|
|
|
10
10
|
}
|
|
11
11
|
return `${str.slice(0, 8)}-${str.slice(8, 12)}-${str.slice(12, 16)}-${str.slice(16, 20)}-${str.slice(20)}`;
|
|
12
12
|
};
|
|
13
|
-
const formatBiometricHints = (hints) => {
|
|
13
|
+
const formatBiometricHints = (hints, isPasskeySupported = false) => {
|
|
14
14
|
let hasMobileDevice = false, isOnKnownDevice = false;
|
|
15
15
|
const deviceParsedUA = UAParser();
|
|
16
16
|
const formattedHintsByKey = {};
|
|
@@ -24,7 +24,7 @@ const formatBiometricHints = (hints) => {
|
|
|
24
24
|
hasMobileDevice = true;
|
|
25
25
|
}
|
|
26
26
|
if (deviceParsedUA) {
|
|
27
|
-
if (deviceParsedUA.browser.name === parsedUA.browser.name && deviceParsedUA.device.type === parsedUA.device.type && deviceParsedUA.device.vendor === parsedUA.device.vendor && deviceParsedUA.device.model === parsedUA.device.model) {
|
|
27
|
+
if (isPasskeySupported && deviceParsedUA.browser.name === parsedUA.browser.name && deviceParsedUA.device.type === parsedUA.device.type && deviceParsedUA.device.vendor === parsedUA.device.vendor && deviceParsedUA.device.model === parsedUA.device.model) {
|
|
28
28
|
isOnKnownDevice = true;
|
|
29
29
|
isKnownDevice = true;
|
|
30
30
|
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { ExternalWalletInfo } from '@getpara/user-management-client';
|
|
2
|
-
export declare const getExternalWalletDisplayName: ({ address, type, addressBech32 }: ExternalWalletInfo
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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,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
|
+
};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -32,9 +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
|
+
export * from './safeStyled.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -102,12 +102,13 @@ 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
|
+
export * from "./safeStyled.js";
|
|
111
112
|
export {
|
|
112
113
|
NetworkAssetAddresses,
|
|
113
114
|
NetworkChainIds,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-GOCCUU3Z.js";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
const createStubComponent = () => {
|
|
5
|
+
const StubComponent = () => null;
|
|
6
|
+
StubComponent.attrs = () => createStubComponent();
|
|
7
|
+
StubComponent.withConfig = () => createStubComponent();
|
|
8
|
+
return StubComponent;
|
|
9
|
+
};
|
|
10
|
+
const createStubStyled = () => {
|
|
11
|
+
const styledStub = () => createStubComponent();
|
|
12
|
+
const handler = {
|
|
13
|
+
get: (_target, _prop) => {
|
|
14
|
+
return createStubComponent;
|
|
15
|
+
},
|
|
16
|
+
apply: () => {
|
|
17
|
+
return createStubComponent();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return new Proxy(styledStub, handler);
|
|
21
|
+
};
|
|
22
|
+
const safeStyled = typeof window !== "undefined" ? styled : createStubStyled();
|
|
23
|
+
export {
|
|
24
|
+
safeStyled
|
|
25
|
+
};
|
package/package.json
CHANGED
|
@@ -1,46 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-common",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": "./dist/index.js"
|
|
9
|
-
},
|
|
10
|
-
"sideEffects": [
|
|
11
|
-
"*.css"
|
|
12
|
-
],
|
|
3
|
+
"version": "2.0.0-alpha.50",
|
|
13
4
|
"dependencies": {
|
|
14
|
-
"@getpara/react-components": "2.0.0-alpha.
|
|
15
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
5
|
+
"@getpara/react-components": "2.0.0-alpha.50",
|
|
6
|
+
"@getpara/web-sdk": "2.0.0-alpha.50",
|
|
16
7
|
"@moonpay/moonpay-react": "^1.8.3",
|
|
17
8
|
"@ramp-network/ramp-instant-sdk": "^4.0.5",
|
|
18
|
-
"
|
|
19
|
-
"@stripe/stripe-js": "^3.4.0",
|
|
20
|
-
"libphonenumber-js": "^1.11.1",
|
|
9
|
+
"libphonenumber-js": "^1.11.7",
|
|
21
10
|
"styled-components": "^6.1.8",
|
|
22
11
|
"ua-parser-js": "^2.0.2"
|
|
23
12
|
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs",
|
|
26
|
-
"typegen": "tsc --emitDeclarationOnly"
|
|
27
|
-
},
|
|
28
13
|
"devDependencies": {
|
|
29
14
|
"@types/react": "^18.0.31",
|
|
30
15
|
"@types/react-dom": "^18.2.7",
|
|
31
|
-
"typescript": "^5.
|
|
16
|
+
"typescript": "^5.8.3"
|
|
32
17
|
},
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"react-dom": "*"
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./dist/index.js"
|
|
36
20
|
},
|
|
37
21
|
"files": [
|
|
38
22
|
"dist",
|
|
39
23
|
"package.json",
|
|
40
24
|
"styles.css"
|
|
41
25
|
],
|
|
26
|
+
"main": "dist/index.js",
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": "*",
|
|
29
|
+
"react-dom": "*"
|
|
30
|
+
},
|
|
42
31
|
"resolutions": {
|
|
43
32
|
"styled-components": "^6"
|
|
44
33
|
},
|
|
45
|
-
"
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs",
|
|
36
|
+
"typegen": "tsc --emitDeclarationOnly"
|
|
37
|
+
},
|
|
38
|
+
"sideEffects": [
|
|
39
|
+
"*.css"
|
|
40
|
+
],
|
|
41
|
+
"type": "module",
|
|
42
|
+
"types": "dist/index.d.ts",
|
|
43
|
+
"gitHead": "688b92a7ca207593a4a3be09cb5cc580092614fc"
|
|
46
44
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Props } from '../types/index.js';
|
|
2
|
-
export declare const STRIPE_PUBLISHABLE_KEY = "pk_live_51MvquNGrzDeP5yP9EgVSMBPQbrbg0oHDjPIIXypePd0jzOFjbadyfO7wBKLHhUtbKIUiEUVC3YYcTJyAmJ8xA7JE00T2UDfYKz";
|
|
3
|
-
export declare const STRIPE_PUBLISHABLE_KEY_TEST = "pk_test_51MvquNGrzDeP5yP98WgPaAUgQ50I3OpfPhVfiLO47FBHepJnZRPO62IzZY2uxT5ovhSS10RwcTcnaVil1mcJOzIi00dHapODdS";
|
|
4
|
-
export declare const StripeEmbed: ({ para, isDark, isEmbedded, onRampPurchase, setOnRampPurchase }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../chunk-GOCCUU3Z.js";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
|
-
import { loadStripeOnramp } from "@stripe/crypto";
|
|
8
|
-
import { Network, OnRampAsset, OnRampProvider, OnRampPurchaseStatus } from "@getpara/web-sdk";
|
|
9
|
-
import { CpslSpinner } from "@getpara/react-components";
|
|
10
|
-
import { SpinnerContainer } from "./common.js";
|
|
11
|
-
import styled from "styled-components";
|
|
12
|
-
const STRIPE_PUBLISHABLE_KEY = "pk_live_51MvquNGrzDeP5yP9EgVSMBPQbrbg0oHDjPIIXypePd0jzOFjbadyfO7wBKLHhUtbKIUiEUVC3YYcTJyAmJ8xA7JE00T2UDfYKz";
|
|
13
|
-
const STRIPE_PUBLISHABLE_KEY_TEST = "pk_test_51MvquNGrzDeP5yP98WgPaAUgQ50I3OpfPhVfiLO47FBHepJnZRPO62IzZY2uxT5ovhSS10RwcTcnaVil1mcJOzIi00dHapODdS";
|
|
14
|
-
const AssetCodes = {
|
|
15
|
-
eth: OnRampAsset.ETHEREUM,
|
|
16
|
-
matic: OnRampAsset.POLYGON,
|
|
17
|
-
sol: OnRampAsset.SOLANA,
|
|
18
|
-
usdc: OnRampAsset.USDC
|
|
19
|
-
};
|
|
20
|
-
const NetworkCodes = {
|
|
21
|
-
base: Network.BASE,
|
|
22
|
-
ethereum: Network.ETHEREUM,
|
|
23
|
-
polygon: Network.POLYGON,
|
|
24
|
-
solana: Network.SOLANA
|
|
25
|
-
};
|
|
26
|
-
const CryptoElementsContext = React.createContext(null);
|
|
27
|
-
CryptoElementsContext.displayName = "CryptoElementsContext";
|
|
28
|
-
const useOnrampSessionListener = (type, session, callback) => {
|
|
29
|
-
React.useEffect(() => {
|
|
30
|
-
if (session && callback) {
|
|
31
|
-
const listener = (e) => callback(e.payload);
|
|
32
|
-
session.addEventListener(type, listener);
|
|
33
|
-
return () => {
|
|
34
|
-
session.removeEventListener(type, listener);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return () => {
|
|
38
|
-
};
|
|
39
|
-
}, [session, callback, type]);
|
|
40
|
-
};
|
|
41
|
-
const StripeEmbed = ({ para, isDark, isEmbedded, onRampPurchase, setOnRampPurchase }) => {
|
|
42
|
-
const [isReady, setIsReady] = useState(false);
|
|
43
|
-
const isStripeEmbed = useMemo(() => onRampPurchase.provider === OnRampProvider.STRIPE, [onRampPurchase]);
|
|
44
|
-
const clientSecret = useMemo(
|
|
45
|
-
() => (onRampPurchase == null ? void 0 : onRampPurchase.provider) === OnRampProvider.STRIPE ? onRampPurchase == null ? void 0 : onRampPurchase.providerKey : void 0,
|
|
46
|
-
[onRampPurchase == null ? void 0 : onRampPurchase.provider, onRampPurchase == null ? void 0 : onRampPurchase.providerKey]
|
|
47
|
-
);
|
|
48
|
-
const [stripeOnRamp, setStripeOnRamp] = useState();
|
|
49
|
-
const onrampElementRef = React.useRef(null);
|
|
50
|
-
const [session, setSession] = React.useState();
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
const containerRef = onrampElementRef.current;
|
|
53
|
-
if (containerRef) {
|
|
54
|
-
containerRef.innerHTML = "";
|
|
55
|
-
if (clientSecret && stripeOnRamp) {
|
|
56
|
-
setSession(
|
|
57
|
-
stripeOnRamp.createSession({
|
|
58
|
-
clientSecret,
|
|
59
|
-
appearance: { theme: isDark ? "dark" : "light" }
|
|
60
|
-
}).mount(containerRef)
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}, [clientSecret, stripeOnRamp]);
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
loadStripeOnramp((onRampPurchase == null ? void 0 : onRampPurchase.testMode) ? STRIPE_PUBLISHABLE_KEY_TEST : STRIPE_PUBLISHABLE_KEY).then(setStripeOnRamp);
|
|
67
|
-
}, []);
|
|
68
|
-
const onReady = useCallback(() => {
|
|
69
|
-
setIsReady(true);
|
|
70
|
-
}, []);
|
|
71
|
-
const onSessionChange = useCallback(
|
|
72
|
-
(_0) => __async(void 0, [_0], function* ({ session: session2 }) {
|
|
73
|
-
if (!isStripeEmbed) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
switch (session2.status) {
|
|
77
|
-
case "fulfillment_processing":
|
|
78
|
-
case "fulfillment_complete":
|
|
79
|
-
const updatedPurchase = yield para.ctx.client.updateOnRampPurchase({
|
|
80
|
-
userId: para.getUserId(),
|
|
81
|
-
walletId: onRampPurchase.walletId,
|
|
82
|
-
externalWalletAddress: onRampPurchase.externalWalletAddress,
|
|
83
|
-
purchaseId: onRampPurchase.id,
|
|
84
|
-
updates: {
|
|
85
|
-
status: OnRampPurchaseStatus.FINISHED,
|
|
86
|
-
fiatQuantity: session2.quote.source_amount,
|
|
87
|
-
fiat: session2.quote.source_currency.asset_code,
|
|
88
|
-
network: NetworkCodes[session2.quote.destination_currency.currency_network],
|
|
89
|
-
asset: AssetCodes[session2.quote.destination_currency.asset_code],
|
|
90
|
-
assetQuantity: session2.quote.destination_amount,
|
|
91
|
-
providerKey: null
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
setOnRampPurchase(updatedPurchase);
|
|
95
|
-
if (!isEmbedded) {
|
|
96
|
-
setTimeout(() => {
|
|
97
|
-
if (typeof window !== "undefined") {
|
|
98
|
-
window.close();
|
|
99
|
-
}
|
|
100
|
-
}, 5e3);
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
default:
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}),
|
|
107
|
-
[isStripeEmbed]
|
|
108
|
-
);
|
|
109
|
-
useOnrampSessionListener("onramp_ui_loaded", session, onReady);
|
|
110
|
-
useOnrampSessionListener("onramp_session_updated", session, onSessionChange);
|
|
111
|
-
return /* @__PURE__ */ jsxs(OuterContainer, { children: [
|
|
112
|
-
/* @__PURE__ */ jsx(Container, { isReady, ref: onrampElementRef }),
|
|
113
|
-
!isReady && /* @__PURE__ */ jsx(SpinnerContainer, { style: { width: "100%", height: "100%", flex: 1 }, children: /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) })
|
|
114
|
-
] });
|
|
115
|
-
};
|
|
116
|
-
const OuterContainer = styled.div`
|
|
117
|
-
height: 100%;
|
|
118
|
-
width: 100%;
|
|
119
|
-
display: flex;
|
|
120
|
-
flex: 1;
|
|
121
|
-
align-items: center;
|
|
122
|
-
justify-content: center;
|
|
123
|
-
`;
|
|
124
|
-
const Container = styled.div`
|
|
125
|
-
height: 100%;
|
|
126
|
-
width: 100%;
|
|
127
|
-
display: ${({ isReady }) => isReady ? "flex" : "none"};
|
|
128
|
-
justify-content: center;
|
|
129
|
-
|
|
130
|
-
& > iframe {
|
|
131
|
-
height: 100%;
|
|
132
|
-
}
|
|
133
|
-
`;
|
|
134
|
-
export {
|
|
135
|
-
STRIPE_PUBLISHABLE_KEY,
|
|
136
|
-
STRIPE_PUBLISHABLE_KEY_TEST,
|
|
137
|
-
StripeEmbed
|
|
138
|
-
};
|
|
@@ -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
|
-
};
|