@getpara/react-common 2.0.0-dev.0 → 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 +23 -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 -1241
- package/dist/package.json +6 -0
- package/dist/types/externalWalletCommon.d.ts +69 -10
- 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 -0
- package/dist/utils/getExternalWalletDisplayName.js +22 -0
- package/dist/utils/index.d.ts +9 -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
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import ParaWeb, { AuthStateLogin, AuthStateVerify, ExternalWalletInfo, TExternalWallet, TWalletType, Wallet } from '@getpara/web-sdk';
|
|
2
2
|
export type WalletMetadata = {
|
|
3
3
|
id: string;
|
|
4
|
+
internalId: TExternalWallet;
|
|
4
5
|
name: string;
|
|
5
6
|
iconUrl: string;
|
|
6
7
|
rdns?: string;
|
|
@@ -26,25 +27,83 @@ export type WalletMetadata = {
|
|
|
26
27
|
linux?: string;
|
|
27
28
|
desktop?: string;
|
|
28
29
|
};
|
|
30
|
+
hasIosSafariExtension?: boolean;
|
|
29
31
|
};
|
|
30
32
|
export type CommonWallet = {
|
|
31
|
-
connect: () => Promise<{
|
|
33
|
+
connect: (isConnectionOnly?: boolean) => Promise<{
|
|
32
34
|
address?: string;
|
|
33
|
-
|
|
35
|
+
ethAddress?: string;
|
|
34
36
|
error?: string;
|
|
35
|
-
|
|
36
|
-
isVerified: boolean;
|
|
37
|
+
authState?: AuthStateLogin | AuthStateVerify;
|
|
37
38
|
}>;
|
|
38
|
-
connectMobile: (isManualWalletConnect?: boolean) => Promise<{
|
|
39
|
+
connectMobile: (isManualWalletConnect?: boolean, isConnectionOnly?: boolean) => Promise<{
|
|
39
40
|
address?: string;
|
|
40
|
-
|
|
41
|
+
ethAddress?: string;
|
|
41
42
|
error?: string;
|
|
42
|
-
|
|
43
|
-
isVerified: boolean;
|
|
43
|
+
authState?: AuthStateLogin | AuthStateVerify;
|
|
44
44
|
}>;
|
|
45
|
-
type:
|
|
45
|
+
type: TWalletType;
|
|
46
46
|
} & WalletMetadata;
|
|
47
47
|
export type CommonChain = {
|
|
48
48
|
id: string | number;
|
|
49
49
|
name: string;
|
|
50
50
|
};
|
|
51
|
+
export type SignArgs = {
|
|
52
|
+
message: string;
|
|
53
|
+
externalWallet?: ExternalWalletInfo;
|
|
54
|
+
};
|
|
55
|
+
export type SignResult = {
|
|
56
|
+
address?: string;
|
|
57
|
+
signature?: string;
|
|
58
|
+
error?: string;
|
|
59
|
+
};
|
|
60
|
+
export type SwitchChainResult = {
|
|
61
|
+
error: string[];
|
|
62
|
+
} | void;
|
|
63
|
+
export type ConnectParaEmbedded = {
|
|
64
|
+
connectParaEmbedded: () => Promise<{
|
|
65
|
+
result?: unknown;
|
|
66
|
+
error?: string;
|
|
67
|
+
}>;
|
|
68
|
+
};
|
|
69
|
+
export type ChainManagement<ChainId, R extends SwitchChainResult = SwitchChainResult> = {
|
|
70
|
+
chains: CommonChain[];
|
|
71
|
+
chainId?: ChainId;
|
|
72
|
+
switchChain: (_: ChainId) => Promise<R>;
|
|
73
|
+
};
|
|
74
|
+
export type BalanceManagement<B = string> = {
|
|
75
|
+
balance?: B;
|
|
76
|
+
getWalletBalance: () => Promise<B | undefined>;
|
|
77
|
+
};
|
|
78
|
+
export type FarcasterMiniAppManagement = {
|
|
79
|
+
farcasterStatus: {
|
|
80
|
+
isConnected: false;
|
|
81
|
+
address?: undefined;
|
|
82
|
+
} | {
|
|
83
|
+
isConnected: true;
|
|
84
|
+
address: string;
|
|
85
|
+
} | undefined;
|
|
86
|
+
};
|
|
87
|
+
export type ExternalWalletContextType<S extends SignResult = SignResult> = {
|
|
88
|
+
wallets: CommonWallet[];
|
|
89
|
+
disconnect: () => Promise<void>;
|
|
90
|
+
signMessage: (_: SignArgs) => Promise<S>;
|
|
91
|
+
signVerificationMessage: () => Promise<S>;
|
|
92
|
+
requestInfo: (_: TExternalWallet) => Promise<ExternalWalletInfo>;
|
|
93
|
+
disconnectBase: (_?: TExternalWallet) => Promise<void>;
|
|
94
|
+
};
|
|
95
|
+
export type ExternalWalletProviderConfigBase = {
|
|
96
|
+
onSwitchWallet?: (args: {
|
|
97
|
+
address?: string;
|
|
98
|
+
error?: string;
|
|
99
|
+
}) => void;
|
|
100
|
+
para: ParaWeb;
|
|
101
|
+
walletsWithFullAuth: TExternalWallet[];
|
|
102
|
+
includeWalletVerification?: boolean;
|
|
103
|
+
connectionOnly?: boolean;
|
|
104
|
+
connectedWallet?: Omit<Wallet, 'signer'> | null;
|
|
105
|
+
};
|
|
106
|
+
export type ExternalWalletProviderConfig<W, P = {}> = ExternalWalletProviderConfigBase & {
|
|
107
|
+
wallets: W[];
|
|
108
|
+
} & P;
|
|
109
|
+
export { type TExternalWallet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AuthInfo } from '@getpara/user-management-client';
|
|
2
2
|
import ParaWeb, { type OnRampConfig, type OnRampPurchase } from '@getpara/web-sdk';
|
|
3
3
|
export * from './externalWalletCommon.js';
|
|
4
|
-
export type
|
|
4
|
+
export type OnRampProps = {
|
|
5
5
|
appName?: string;
|
|
6
6
|
para: ParaWeb;
|
|
7
7
|
isDark?: boolean;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../chunk-GOCCUU3Z.js";
|
|
5
|
+
import { UAParser } from "ua-parser-js";
|
|
6
|
+
import { aaguidMetadata } from "../constants/aaguiMetadata.js";
|
|
7
|
+
const formatStringToUUID = (str) => {
|
|
8
|
+
if (str.length !== 32) {
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
return `${str.slice(0, 8)}-${str.slice(8, 12)}-${str.slice(12, 16)}-${str.slice(16, 20)}-${str.slice(20)}`;
|
|
12
|
+
};
|
|
13
|
+
const formatBiometricHints = (hints, isPasskeySupported = false) => {
|
|
14
|
+
let hasMobileDevice = false, isOnKnownDevice = false;
|
|
15
|
+
const deviceParsedUA = UAParser();
|
|
16
|
+
const formattedHintsByKey = {};
|
|
17
|
+
hints == null ? void 0 : hints.forEach((hint) => {
|
|
18
|
+
var _a;
|
|
19
|
+
let isMobile = false, isKnownDevice = false, passwordManager, parsedUA, key = "";
|
|
20
|
+
if (hint.useragent) {
|
|
21
|
+
parsedUA = new UAParser(hint.useragent).getResult();
|
|
22
|
+
if (parsedUA.device.type === "mobile" || parsedUA.device.type === "tablet") {
|
|
23
|
+
isMobile = true;
|
|
24
|
+
hasMobileDevice = true;
|
|
25
|
+
}
|
|
26
|
+
if (deviceParsedUA) {
|
|
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
|
+
isOnKnownDevice = true;
|
|
29
|
+
isKnownDevice = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
key = `${parsedUA == null ? void 0 : parsedUA.browser.name}-${parsedUA == null ? void 0 : parsedUA.device.type}-${parsedUA == null ? void 0 : parsedUA.device.vendor}-${parsedUA == null ? void 0 : parsedUA.device.model}`;
|
|
33
|
+
}
|
|
34
|
+
if (hint.aaguid) {
|
|
35
|
+
const formattedAaguid = formatStringToUUID(hint.aaguid);
|
|
36
|
+
if (formattedAaguid) {
|
|
37
|
+
passwordManager = (_a = aaguidMetadata[formattedAaguid]) == null ? void 0 : _a.name;
|
|
38
|
+
}
|
|
39
|
+
key = `${key}${key ? "-" : ""}${passwordManager}`;
|
|
40
|
+
}
|
|
41
|
+
formattedHintsByKey[key] = __spreadValues({ passwordManager, isMobile, isKnownDevice, key }, parsedUA);
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
hasMobileDevice,
|
|
45
|
+
isOnKnownDevice,
|
|
46
|
+
formattedHints: Object.values(formattedHintsByKey)
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
formatBiometricHints
|
|
51
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-GOCCUU3Z.js";
|
|
3
|
+
const getDeviceLogo = (vendor, isMobile) => {
|
|
4
|
+
switch (vendor == null ? void 0 : vendor.toLowerCase()) {
|
|
5
|
+
case "apple": {
|
|
6
|
+
return "apple";
|
|
7
|
+
}
|
|
8
|
+
case "samsung": {
|
|
9
|
+
return "samsung";
|
|
10
|
+
}
|
|
11
|
+
case "lenovo": {
|
|
12
|
+
return "lenovo";
|
|
13
|
+
}
|
|
14
|
+
case "lg": {
|
|
15
|
+
return "lg";
|
|
16
|
+
}
|
|
17
|
+
case "motorola": {
|
|
18
|
+
return "motorola";
|
|
19
|
+
}
|
|
20
|
+
case "dell": {
|
|
21
|
+
return "dell";
|
|
22
|
+
}
|
|
23
|
+
case "hp": {
|
|
24
|
+
return "hp";
|
|
25
|
+
}
|
|
26
|
+
default: {
|
|
27
|
+
if (isMobile) {
|
|
28
|
+
return "phone";
|
|
29
|
+
}
|
|
30
|
+
return "laptop";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
getDeviceLogo
|
|
36
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-GOCCUU3Z.js";
|
|
3
|
+
const getDeviceModelName = (model) => {
|
|
4
|
+
if (!model) {
|
|
5
|
+
return void 0;
|
|
6
|
+
}
|
|
7
|
+
switch (model.toLowerCase()) {
|
|
8
|
+
case "macintosh": {
|
|
9
|
+
return "Mac";
|
|
10
|
+
}
|
|
11
|
+
case "k": {
|
|
12
|
+
return "Android";
|
|
13
|
+
}
|
|
14
|
+
default: {
|
|
15
|
+
return model;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
getDeviceModelName
|
|
21
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-GOCCUU3Z.js";
|
|
3
|
+
import { truncateAddress } from "@getpara/web-sdk";
|
|
4
|
+
const getExternalWalletDisplayName = ({ address, type, addressBech32 }) => {
|
|
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)}`;
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
getExternalWalletDisplayName
|
|
22
|
+
};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { OnRampAsset, OnRampAssetInfo, OnRampProvider, Network, OnRampPurchaseType, OnRampConfig,
|
|
1
|
+
import { OnRampAsset, OnRampAssetInfo, OnRampProvider, Network, OnRampPurchaseType, OnRampConfig, TWalletType } from '@getpara/web-sdk';
|
|
2
|
+
export declare function getCurrencyCode({ assetInfo }: OnRampConfig, { network, asset, provider }: {
|
|
3
|
+
network: Network;
|
|
4
|
+
asset: OnRampAsset;
|
|
5
|
+
provider: OnRampProvider;
|
|
6
|
+
}): string | undefined;
|
|
2
7
|
export declare function getCurrencyCodes({ assetInfo, allowedAssets, defaultOnRampNetwork, defaultOnRampAsset }: OnRampConfig, { provider, purchaseType, walletType, }: {
|
|
3
8
|
provider: OnRampProvider;
|
|
4
9
|
purchaseType: OnRampPurchaseType;
|
|
5
|
-
walletType:
|
|
10
|
+
walletType: TWalletType;
|
|
6
11
|
}): {
|
|
7
12
|
currencyCodes: string[];
|
|
8
13
|
defaultCurrencyCode?: string;
|
|
@@ -32,3 +37,5 @@ export * from './getDeviceLogo.js';
|
|
|
32
37
|
export * from './getDeviceModelName.js';
|
|
33
38
|
export * from './getBrowserName.js';
|
|
34
39
|
export * from './formatBiometricHints.js';
|
|
40
|
+
export * from './getExternalWalletDisplayName.js';
|
|
41
|
+
export * from './safeStyled.js';
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../chunk-GOCCUU3Z.js";
|
|
5
|
+
import {
|
|
6
|
+
OnRampAsset,
|
|
7
|
+
Network,
|
|
8
|
+
getOnRampNetworks,
|
|
9
|
+
getOnRampAssets,
|
|
10
|
+
toAssetInfoArray
|
|
11
|
+
} from "@getpara/web-sdk";
|
|
12
|
+
function getCurrencyCode({ assetInfo }, { network, asset, provider }) {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
return (_c = (_b = (_a = Object.values(assetInfo).reduce((acc, record) => __spreadValues(__spreadValues({}, acc), record), {})[network]) == null ? void 0 : _a[asset]) == null ? void 0 : _b[provider]) == null ? void 0 : _c[0];
|
|
15
|
+
}
|
|
16
|
+
function getCurrencyCodes({ assetInfo, allowedAssets, defaultOnRampNetwork, defaultOnRampAsset }, {
|
|
17
|
+
provider,
|
|
18
|
+
purchaseType,
|
|
19
|
+
walletType
|
|
20
|
+
}) {
|
|
21
|
+
let defaultCurrencyCode;
|
|
22
|
+
const currencyCodes = getOnRampNetworks(assetInfo, {
|
|
23
|
+
walletType,
|
|
24
|
+
allowed: allowedAssets ? Object.keys(allowedAssets) : void 0
|
|
25
|
+
}).sort((a, b) => a === defaultOnRampNetwork ? -1 : b === defaultOnRampNetwork ? 1 : 0).reduce((acc, network) => {
|
|
26
|
+
const allowed = Array.isArray(allowedAssets == null ? void 0 : allowedAssets[network]) ? allowedAssets[network] : void 0;
|
|
27
|
+
return [
|
|
28
|
+
...acc,
|
|
29
|
+
...getOnRampAssets(assetInfo, { walletType, network, allowed }).sort((a, b) => a === defaultOnRampAsset ? -1 : b === defaultOnRampAsset ? 1 : 0).map((asset) => {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f;
|
|
31
|
+
if (network === defaultOnRampNetwork && asset === defaultOnRampAsset) {
|
|
32
|
+
defaultCurrencyCode = (_c = (_b = (_a = assetInfo[walletType]) == null ? void 0 : _a[network]) == null ? void 0 : _b[asset]) == null ? void 0 : _c[provider][0];
|
|
33
|
+
}
|
|
34
|
+
return (_f = (_e = (_d = assetInfo[walletType]) == null ? void 0 : _d[network]) == null ? void 0 : _e[asset]) == null ? void 0 : _f[provider];
|
|
35
|
+
}).filter((entry) => !!entry && !!entry[1][purchaseType]).map(([code]) => code)
|
|
36
|
+
];
|
|
37
|
+
}, []).filter((code) => !!code);
|
|
38
|
+
return { currencyCodes, defaultCurrencyCode: defaultCurrencyCode || currencyCodes[0] };
|
|
39
|
+
}
|
|
40
|
+
function reverseCurrencyLookup(data, provider, code) {
|
|
41
|
+
const row = toAssetInfoArray(data).find(
|
|
42
|
+
([_, __, ___, providers]) => [code.toUpperCase(), code.toLowerCase()].includes(providers[provider][0])
|
|
43
|
+
);
|
|
44
|
+
return [row == null ? void 0 : row[1], row == null ? void 0 : row[2]];
|
|
45
|
+
}
|
|
46
|
+
const TestNetworks = [
|
|
47
|
+
{ main: Network.ETHEREUM, test: Network.SEPOLIA },
|
|
48
|
+
{ main: Network.SOLANA, test: Network.SOLANA_DEVNET }
|
|
49
|
+
];
|
|
50
|
+
function getNetworkTestEquivalent(network) {
|
|
51
|
+
var _a;
|
|
52
|
+
return (_a = TestNetworks.find(({ main }) => main === network)) == null ? void 0 : _a.test;
|
|
53
|
+
}
|
|
54
|
+
function getNetworkOrMainNetEquivalent(network, testMode) {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
return testMode ? (_b = (_a = TestNetworks.find(({ test }) => test === network)) == null ? void 0 : _a.main) != null ? _b : network : network;
|
|
57
|
+
}
|
|
58
|
+
const NetworkChainIds = [
|
|
59
|
+
{ chainId: "11155111", network: Network.SEPOLIA },
|
|
60
|
+
{ chainId: "1", network: Network.ETHEREUM },
|
|
61
|
+
{ chainId: "137", network: Network.POLYGON },
|
|
62
|
+
{ chainId: "42220", network: Network.CELO },
|
|
63
|
+
{ chainId: "8453", network: Network.BASE },
|
|
64
|
+
{ chainId: "42161", network: Network.ARBITRUM },
|
|
65
|
+
{ chainId: "10", network: Network.OPTIMISM }
|
|
66
|
+
];
|
|
67
|
+
function getChainId(network) {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
return (_b = (_a = NetworkChainIds.find(({ network: n }) => n === network)) == null ? void 0 : _a.chainId) != null ? _b : void 0;
|
|
70
|
+
}
|
|
71
|
+
function getNetworkFromChainId(chainId) {
|
|
72
|
+
var _a;
|
|
73
|
+
return chainId ? (_a = NetworkChainIds.find(({ chainId: c }) => c === chainId)) == null ? void 0 : _a.network : void 0;
|
|
74
|
+
}
|
|
75
|
+
const ETH_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
76
|
+
const NetworkAssetAddresses = [
|
|
77
|
+
{ network: Network.ETHEREUM, asset: OnRampAsset.USDC, address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" },
|
|
78
|
+
{ network: Network.POLYGON, asset: OnRampAsset.USDC, address: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359" },
|
|
79
|
+
{ network: Network.CELO, asset: OnRampAsset.USDC, address: "0xcebA9300f2b948710d2653dD7B07f33A8B32118C" },
|
|
80
|
+
{ network: Network.BASE, asset: OnRampAsset.USDC, address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" },
|
|
81
|
+
{ network: Network.ARBITRUM, asset: OnRampAsset.USDC, address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831" },
|
|
82
|
+
{ network: Network.OPTIMISM, asset: OnRampAsset.USDC, address: "0x0b2c639c533813f4aa9d7837caf62653d097ff85" },
|
|
83
|
+
{ network: Network.SOLANA, asset: OnRampAsset.USDC, address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
|
|
84
|
+
{ network: Network.SOLANA_DEVNET, asset: OnRampAsset.USDC, address: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU" },
|
|
85
|
+
{ network: Network.SEPOLIA, asset: OnRampAsset.USDC, address: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238" },
|
|
86
|
+
{ network: Network.SOLANA_DEVNET, asset: OnRampAsset.TETHER, address: "EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS" }
|
|
87
|
+
];
|
|
88
|
+
function getAssetFromContractAddress(network, contractAddress) {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
if (contractAddress === ETH_CONTRACT_ADDRESS) {
|
|
91
|
+
return OnRampAsset.ETHEREUM;
|
|
92
|
+
}
|
|
93
|
+
const checkNetworks = [network, (_a = getNetworkOrMainNetEquivalent(network)) != null ? _a : void 0].filter((n) => !!n).map((n) => Network[n]);
|
|
94
|
+
return (_b = NetworkAssetAddresses.find(
|
|
95
|
+
(row) => checkNetworks.includes(row.network) && row.asset.toLowerCase() === contractAddress.toLowerCase()
|
|
96
|
+
)) == null ? void 0 : _b.asset;
|
|
97
|
+
}
|
|
98
|
+
function getContractAddressFromAsset(network, asset) {
|
|
99
|
+
var _a;
|
|
100
|
+
if (asset === OnRampAsset.ETHEREUM) {
|
|
101
|
+
return ETH_CONTRACT_ADDRESS;
|
|
102
|
+
}
|
|
103
|
+
return (_a = NetworkAssetAddresses.find((row) => row.network === network && row.asset === asset)) == null ? void 0 : _a.address;
|
|
104
|
+
}
|
|
105
|
+
export * from "./offRampSend.js";
|
|
106
|
+
export * from "./getDeviceLogo.js";
|
|
107
|
+
export * from "./getDeviceModelName.js";
|
|
108
|
+
export * from "./getBrowserName.js";
|
|
109
|
+
export * from "./formatBiometricHints.js";
|
|
110
|
+
export * from "./getExternalWalletDisplayName.js";
|
|
111
|
+
export * from "./safeStyled.js";
|
|
112
|
+
export {
|
|
113
|
+
NetworkAssetAddresses,
|
|
114
|
+
NetworkChainIds,
|
|
115
|
+
TestNetworks,
|
|
116
|
+
getAssetFromContractAddress,
|
|
117
|
+
getChainId,
|
|
118
|
+
getContractAddressFromAsset,
|
|
119
|
+
getCurrencyCode,
|
|
120
|
+
getCurrencyCodes,
|
|
121
|
+
getNetworkFromChainId,
|
|
122
|
+
getNetworkOrMainNetEquivalent,
|
|
123
|
+
getNetworkTestEquivalent,
|
|
124
|
+
reverseCurrencyLookup
|
|
125
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
};
|
|
@@ -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-dev.
|
|
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-dev.2",
|
|
13
4
|
"dependencies": {
|
|
14
|
-
"@getpara/react-components": "2.0.0-dev.
|
|
15
|
-
"@getpara/web-sdk": "2.0.0-dev.
|
|
5
|
+
"@getpara/react-components": "2.0.0-dev.2",
|
|
6
|
+
"@getpara/web-sdk": "2.0.0-dev.2",
|
|
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": "77d818539daa181c839a40f0ad5362af4058844e"
|
|
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_51Q2z5k2epVn9Kq0ZSbUzuetKb4azH6E6UPcvWmjRxvHmxLAJbIK0pwDbPQo63W9OyDng337ntNu3ZXx3AJ7MhFmR00XgfRmPgP";
|
|
4
|
-
export declare const StripeEmbed: ({ para, isDark, isEmbedded, onRampPurchase, setOnRampPurchase }: Props) => import("react/jsx-runtime").JSX.Element;
|
package/dist/index.js.br
DELETED
|
Binary file
|
package/dist/index.js.gz
DELETED
|
Binary file
|