@getpara/react-common 2.0.0-fc.3 → 2.1.0
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/README.md +13 -0
- package/dist/{chunk-GOCCUU3Z.js → chunk-MMUBH76A.js} +17 -0
- package/dist/classes/ParaInternal.d.ts +18 -5
- package/dist/classes/ParaInternal.js +15 -1
- package/dist/components/HeroSpinner.d.ts +2 -1
- package/dist/components/HeroSpinner.js +9 -3
- package/dist/components/KnownDevices.js +1 -1
- package/dist/components/MoonPayEmbed.d.ts +3 -1
- package/dist/components/MoonPayEmbed.js +56 -82
- package/dist/components/NetworkSpeedBanner.js +2 -4
- package/dist/components/QRCode.js +1 -1
- package/dist/components/RampEmbed.d.ts +1 -1
- package/dist/components/RampEmbed.js +17 -29
- package/dist/components/UserIdentifier.d.ts +8 -0
- package/dist/components/UserIdentifier.js +25 -16
- package/dist/components/WalletSelect.d.ts +33 -0
- package/dist/components/WalletSelect.js +171 -0
- package/dist/components/WalletTypeIcon.d.ts +9 -0
- package/dist/components/WalletTypeIcon.js +45 -0
- package/dist/components/WarningBanner.d.ts +7 -0
- package/dist/components/WarningBanner.js +60 -0
- package/dist/components/common.js +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/constants/aaguiMetadata.js +1 -1
- package/dist/constants/externalWalletDefaults.d.ts +10 -1
- package/dist/constants/externalWalletDefaults.js +8 -3
- package/dist/constants/index.d.ts +37 -0
- package/dist/constants/index.js +152 -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/useCopyToClipboard.js +1 -1
- package/dist/hooks/useDropdownPosition.d.ts +7 -0
- package/dist/hooks/useDropdownPosition.js +33 -0
- package/dist/hooks/useUserAgent.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types/commonTypes.d.ts +15 -0
- package/dist/types/commonTypes.js +1 -0
- package/dist/types/externalWalletCommon.d.ts +14 -4
- package/dist/types/index.d.ts +7 -4
- package/dist/types/index.js +1 -0
- package/dist/utils/formatBiometricHints.js +1 -1
- package/dist/utils/getBrowserName.js +1 -1
- package/dist/utils/getDeviceLogo.js +1 -1
- package/dist/utils/getDeviceModelName.js +1 -1
- package/dist/utils/getExternalWalletDisplayName.d.ts +3 -1
- package/dist/utils/getExternalWalletDisplayName.js +7 -15
- 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 +26 -31
- package/dist/utils/openMobileUrl.d.ts +1 -0
- package/dist/utils/openMobileUrl.js +34 -0
- package/dist/utils/safeStyled.js +1 -1
- package/package.json +4 -4
- package/dist/utils/offRampSend.d.ts +0 -7
- package/dist/utils/offRampSend.js +0 -75
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-MMUBH76A.js";
|
|
3
|
+
const ACCOUNT_TYPES = {
|
|
4
|
+
"EMAIL": {
|
|
5
|
+
icon: "mail",
|
|
6
|
+
name: "Email",
|
|
7
|
+
inlineText: "email address",
|
|
8
|
+
isPlain: true
|
|
9
|
+
},
|
|
10
|
+
"PHONE": {
|
|
11
|
+
icon: "phone",
|
|
12
|
+
name: "Phone",
|
|
13
|
+
inlineText: "phone number",
|
|
14
|
+
isPlain: true
|
|
15
|
+
},
|
|
16
|
+
"EXTERNAL_WALLET": {
|
|
17
|
+
icon: "wallet",
|
|
18
|
+
name: "External Wallet",
|
|
19
|
+
inlineText: "external wallet",
|
|
20
|
+
isPlain: true
|
|
21
|
+
},
|
|
22
|
+
"GOOGLE": {
|
|
23
|
+
icon: "google",
|
|
24
|
+
iconBranded: "googleBrand",
|
|
25
|
+
name: "Google"
|
|
26
|
+
},
|
|
27
|
+
"TWITTER": {
|
|
28
|
+
icon: "twitter",
|
|
29
|
+
// Not using branded here to ensure the icon looks correct in dark mode
|
|
30
|
+
iconBranded: "twitter",
|
|
31
|
+
name: "X / Twitter",
|
|
32
|
+
inlineText: "X account",
|
|
33
|
+
isDark: true
|
|
34
|
+
},
|
|
35
|
+
"APPLE": {
|
|
36
|
+
icon: "apple",
|
|
37
|
+
// Not using branded here to ensure the icon looks correct in dark mode
|
|
38
|
+
iconBranded: "apple",
|
|
39
|
+
name: "Apple",
|
|
40
|
+
isDark: true
|
|
41
|
+
},
|
|
42
|
+
"DISCORD": {
|
|
43
|
+
icon: "discord",
|
|
44
|
+
iconBranded: "discordBrand",
|
|
45
|
+
name: "Discord"
|
|
46
|
+
},
|
|
47
|
+
"FACEBOOK": {
|
|
48
|
+
icon: "facebook",
|
|
49
|
+
iconBranded: "facebookBrand",
|
|
50
|
+
name: "Facebook"
|
|
51
|
+
},
|
|
52
|
+
"FARCASTER": {
|
|
53
|
+
icon: "farcaster",
|
|
54
|
+
iconBranded: "farcasterBrand",
|
|
55
|
+
name: "Farcaster"
|
|
56
|
+
},
|
|
57
|
+
"TELEGRAM": {
|
|
58
|
+
icon: "telegram",
|
|
59
|
+
iconBranded: "telegramBrand",
|
|
60
|
+
name: "Telegram"
|
|
61
|
+
},
|
|
62
|
+
"MetaMask": {
|
|
63
|
+
icon: "metamask",
|
|
64
|
+
name: "MetaMask",
|
|
65
|
+
isExternalWallet: true
|
|
66
|
+
},
|
|
67
|
+
"Rainbow": {
|
|
68
|
+
icon: "rainbow",
|
|
69
|
+
name: "Rainbow",
|
|
70
|
+
isExternalWallet: true
|
|
71
|
+
},
|
|
72
|
+
"Coinbase Wallet": {
|
|
73
|
+
icon: "coinbase",
|
|
74
|
+
name: "Coinbase Wallet",
|
|
75
|
+
isExternalWallet: true
|
|
76
|
+
},
|
|
77
|
+
"WalletConnect": {
|
|
78
|
+
icon: "walletConnect",
|
|
79
|
+
name: "WalletConnect",
|
|
80
|
+
isExternalWallet: true
|
|
81
|
+
},
|
|
82
|
+
"Zerion": {
|
|
83
|
+
icon: "zerion",
|
|
84
|
+
name: "Zerion",
|
|
85
|
+
isExternalWallet: true
|
|
86
|
+
},
|
|
87
|
+
"Safe": {
|
|
88
|
+
icon: "safe",
|
|
89
|
+
name: "Safe",
|
|
90
|
+
isExternalWallet: true
|
|
91
|
+
},
|
|
92
|
+
"Rabby": {
|
|
93
|
+
icon: "rabby",
|
|
94
|
+
name: "Rabby",
|
|
95
|
+
isExternalWallet: true
|
|
96
|
+
},
|
|
97
|
+
"OKX Wallet": {
|
|
98
|
+
icon: "okx",
|
|
99
|
+
name: "OKX Wallet",
|
|
100
|
+
isExternalWallet: true
|
|
101
|
+
},
|
|
102
|
+
"Phantom": {
|
|
103
|
+
icon: "phantom",
|
|
104
|
+
name: "Phantom",
|
|
105
|
+
isExternalWallet: true
|
|
106
|
+
},
|
|
107
|
+
"Glow": {
|
|
108
|
+
icon: "glow",
|
|
109
|
+
name: "Glow",
|
|
110
|
+
isExternalWallet: true
|
|
111
|
+
},
|
|
112
|
+
"Backpack": {
|
|
113
|
+
icon: "backpack",
|
|
114
|
+
name: "Backpack",
|
|
115
|
+
isExternalWallet: true
|
|
116
|
+
},
|
|
117
|
+
"Keplr": {
|
|
118
|
+
icon: "keplr",
|
|
119
|
+
name: "Keplr",
|
|
120
|
+
isExternalWallet: true
|
|
121
|
+
},
|
|
122
|
+
"Leap": {
|
|
123
|
+
icon: "leap",
|
|
124
|
+
name: "Leap",
|
|
125
|
+
isExternalWallet: true
|
|
126
|
+
},
|
|
127
|
+
"HaHa": {
|
|
128
|
+
icon: "haha",
|
|
129
|
+
name: "HaHa",
|
|
130
|
+
isExternalWallet: true
|
|
131
|
+
},
|
|
132
|
+
"Cosmostation": {
|
|
133
|
+
icon: "cosmostation",
|
|
134
|
+
name: "Cosmostation",
|
|
135
|
+
isExternalWallet: true
|
|
136
|
+
},
|
|
137
|
+
"Solflare": {
|
|
138
|
+
icon: "solflare",
|
|
139
|
+
name: "Solflare",
|
|
140
|
+
isExternalWallet: true
|
|
141
|
+
},
|
|
142
|
+
"Valora": {
|
|
143
|
+
icon: "valora",
|
|
144
|
+
name: "Valora",
|
|
145
|
+
isExternalWallet: true
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
function getAccountTypeName(type, { inline = false } = {}) {
|
|
149
|
+
var _a;
|
|
150
|
+
const data = type ? ACCOUNT_TYPES[type] : void 0;
|
|
151
|
+
return data ? inline ? (_a = data.inlineText) != null ? _a : `${data.name} ${data.isExternalWallet ? "wallet" : "account"}` : data.name : void 0;
|
|
152
|
+
}
|
|
153
|
+
function getAccountTypeLogo(type) {
|
|
154
|
+
return type ? ACCOUNT_TYPES[type].iconBranded || ACCOUNT_TYPES[type].icon : void 0;
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
ACCOUNT_TYPES,
|
|
158
|
+
getAccountTypeLogo,
|
|
159
|
+
getAccountTypeName
|
|
160
|
+
};
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
export declare const useDropdownPosition: (inputRef: MutableRefObject<HTMLCpslInputElement | HTMLDivElement | null>) => {
|
|
3
|
+
dropdownMaxHeight: number;
|
|
4
|
+
dropdownWidth: number;
|
|
5
|
+
mobileAnchor: number;
|
|
6
|
+
resize: () => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-MMUBH76A.js";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
const useDropdownPosition = (inputRef) => {
|
|
5
|
+
const [dropdownMaxHeight, setDropdownMaxHeight] = useState();
|
|
6
|
+
const [dropdownWidth, setDropdownWidth] = useState();
|
|
7
|
+
const [mobileAnchor, setMobileAnchor] = useState();
|
|
8
|
+
const resize = () => {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
if (typeof window !== "undefined") {
|
|
11
|
+
const newMaxHeight = Math.max(
|
|
12
|
+
window.innerHeight - ((_b = (_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.getBoundingClientRect().bottom) != null ? _b : 0) - 20,
|
|
13
|
+
window.innerHeight * 0.25
|
|
14
|
+
);
|
|
15
|
+
setDropdownMaxHeight(newMaxHeight);
|
|
16
|
+
setDropdownWidth((_c = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _c.getBoundingClientRect().width);
|
|
17
|
+
setMobileAnchor((_d = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _d.getBoundingClientRect().height);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
if (inputRef.current && !dropdownMaxHeight) {
|
|
21
|
+
resize();
|
|
22
|
+
}
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
typeof window !== "undefined" && window.addEventListener("resize", resize);
|
|
25
|
+
return () => {
|
|
26
|
+
typeof window !== "undefined" && window.removeEventListener("resize", resize);
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
return { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize };
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
useDropdownPosition
|
|
33
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IconType } from '@getpara/react-components';
|
|
2
|
+
export type Tab<T> = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: T;
|
|
5
|
+
icon: IconType;
|
|
6
|
+
};
|
|
7
|
+
export type DisplayMetadata = {
|
|
8
|
+
name: string;
|
|
9
|
+
inlineText?: string;
|
|
10
|
+
icon: IconType;
|
|
11
|
+
iconBranded?: IconType;
|
|
12
|
+
isDark?: boolean;
|
|
13
|
+
isCircular?: boolean;
|
|
14
|
+
isPlain?: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import ParaWeb, { AuthStateLogin, AuthStateVerify, ExternalWalletInfo, TExternalWallet, TWalletType, Wallet } from '@getpara/web-sdk';
|
|
2
|
+
export type DisconnectType = 'ACCOUNT_LINKING' | 'ACCOUNT_WIDGET';
|
|
3
|
+
export type MutationStatus = 'idle' | 'pending' | 'error' | 'success';
|
|
4
|
+
export type DisconnectBaseOptions = {
|
|
5
|
+
disconnectType?: DisconnectType;
|
|
6
|
+
};
|
|
2
7
|
export type WalletMetadata = {
|
|
3
8
|
id: string;
|
|
4
9
|
internalId: TExternalWallet;
|
|
@@ -77,9 +82,13 @@ export type BalanceManagement<B = string> = {
|
|
|
77
82
|
};
|
|
78
83
|
export type FarcasterMiniAppManagement = {
|
|
79
84
|
farcasterStatus: {
|
|
85
|
+
isPresent: false;
|
|
86
|
+
} | {
|
|
87
|
+
isPresent: true;
|
|
80
88
|
isConnected: false;
|
|
81
89
|
address?: undefined;
|
|
82
90
|
} | {
|
|
91
|
+
isPresent: true;
|
|
83
92
|
isConnected: true;
|
|
84
93
|
address: string;
|
|
85
94
|
} | undefined;
|
|
@@ -89,8 +98,9 @@ export type ExternalWalletContextType<S extends SignResult = SignResult> = {
|
|
|
89
98
|
disconnect: () => Promise<void>;
|
|
90
99
|
signMessage: (_: SignArgs) => Promise<S>;
|
|
91
100
|
signVerificationMessage: () => Promise<S>;
|
|
92
|
-
requestInfo: (_:
|
|
93
|
-
disconnectBase: (_?:
|
|
101
|
+
requestInfo: (_: string) => Promise<ExternalWalletInfo>;
|
|
102
|
+
disconnectBase: (_?: string, __?: DisconnectBaseOptions) => Promise<void>;
|
|
103
|
+
disconnectStatus: MutationStatus;
|
|
94
104
|
};
|
|
95
105
|
export type ExternalWalletProviderConfigBase = {
|
|
96
106
|
onSwitchWallet?: (args: {
|
|
@@ -98,10 +108,10 @@ export type ExternalWalletProviderConfigBase = {
|
|
|
98
108
|
error?: string;
|
|
99
109
|
}) => void;
|
|
100
110
|
para: ParaWeb;
|
|
101
|
-
walletsWithFullAuth: TExternalWallet[];
|
|
111
|
+
walletsWithFullAuth: TExternalWallet[] | 'ALL';
|
|
102
112
|
includeWalletVerification?: boolean;
|
|
103
113
|
connectionOnly?: boolean;
|
|
104
|
-
connectedWallet?:
|
|
114
|
+
connectedWallet?: Pick<Wallet, 'id' | 'type'> | null;
|
|
105
115
|
};
|
|
106
116
|
export type ExternalWalletProviderConfig<W, P = {}> = ExternalWalletProviderConfigBase & {
|
|
107
117
|
wallets: W[];
|
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 * from './commonTypes.js';
|
|
4
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
|
@@ -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
|
-
import "../chunk-
|
|
2
|
+
import "../chunk-MMUBH76A.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-MMUBH76A.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
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TOnRampAsset, OnRampAssetInfo, OnRampProvider, TNetwork, OnRampPurchaseType, OnRampConfig, TWalletType } from '@getpara/user-management-client';
|
|
2
2
|
export declare function getCurrencyCode({ assetInfo }: OnRampConfig, { network, asset, provider }: {
|
|
3
|
-
network:
|
|
4
|
-
asset:
|
|
3
|
+
network: TNetwork;
|
|
4
|
+
asset: TOnRampAsset;
|
|
5
5
|
provider: OnRampProvider;
|
|
6
6
|
}): string | undefined;
|
|
7
7
|
export declare function getCurrencyCodes({ assetInfo, allowedAssets, defaultOnRampNetwork, defaultOnRampAsset }: OnRampConfig, { provider, purchaseType, walletType, }: {
|
|
@@ -12,30 +12,31 @@ export declare function getCurrencyCodes({ assetInfo, allowedAssets, defaultOnRa
|
|
|
12
12
|
currencyCodes: string[];
|
|
13
13
|
defaultCurrencyCode?: string;
|
|
14
14
|
};
|
|
15
|
-
export declare function reverseCurrencyLookup(data: OnRampAssetInfo, provider: OnRampProvider, code: string): [
|
|
15
|
+
export declare function reverseCurrencyLookup(data: OnRampAssetInfo, provider: OnRampProvider, code: string): [TNetwork, TOnRampAsset];
|
|
16
16
|
export declare const TestNetworks: {
|
|
17
|
-
main:
|
|
18
|
-
test:
|
|
17
|
+
main: TNetwork;
|
|
18
|
+
test: TNetwork;
|
|
19
19
|
}[];
|
|
20
|
-
export declare function getNetworkTestEquivalent(network:
|
|
21
|
-
export declare function getNetworkOrMainNetEquivalent(network:
|
|
20
|
+
export declare function getNetworkTestEquivalent(network: TNetwork): TNetwork | undefined;
|
|
21
|
+
export declare function getNetworkOrMainNetEquivalent(network: TNetwork, testMode?: boolean): TNetwork;
|
|
22
22
|
export declare const NetworkChainIds: {
|
|
23
23
|
chainId: string;
|
|
24
|
-
network:
|
|
24
|
+
network: TNetwork;
|
|
25
25
|
}[];
|
|
26
|
-
export declare function getChainId(network:
|
|
27
|
-
export declare function getNetworkFromChainId(chainId?: string | undefined):
|
|
26
|
+
export declare function getChainId(network: TNetwork): string | undefined;
|
|
27
|
+
export declare function getNetworkFromChainId(chainId?: string | undefined): TNetwork | undefined;
|
|
28
28
|
export declare const NetworkAssetAddresses: {
|
|
29
|
-
network:
|
|
30
|
-
asset:
|
|
29
|
+
network: TNetwork;
|
|
30
|
+
asset: TOnRampAsset;
|
|
31
31
|
address: string;
|
|
32
32
|
}[];
|
|
33
|
-
export declare function getAssetFromContractAddress(network:
|
|
34
|
-
export declare function getContractAddressFromAsset(network:
|
|
35
|
-
export * from './offRampSend.js';
|
|
33
|
+
export declare function getAssetFromContractAddress(network: TNetwork, contractAddress: string): TOnRampAsset | undefined;
|
|
34
|
+
export declare function getContractAddressFromAsset(network: TNetwork, asset: TOnRampAsset): string | undefined;
|
|
36
35
|
export * from './getDeviceLogo.js';
|
|
37
36
|
export * from './getDeviceModelName.js';
|
|
38
37
|
export * from './getBrowserName.js';
|
|
39
38
|
export * from './formatBiometricHints.js';
|
|
40
39
|
export * from './getExternalWalletDisplayName.js';
|
|
40
|
+
export * from './getExternalWalletIcon.js';
|
|
41
41
|
export * from './safeStyled.js';
|
|
42
|
+
export * from './openMobileUrl.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
__spreadValues
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import {
|
|
6
|
-
OnRampAsset,
|
|
7
|
-
Network,
|
|
8
|
-
getOnRampNetworks,
|
|
9
|
-
getOnRampAssets,
|
|
10
|
-
toAssetInfoArray
|
|
11
|
-
} from "@getpara/web-sdk";
|
|
4
|
+
} from "../chunk-MMUBH76A.js";
|
|
5
|
+
import { getOnRampNetworks, getOnRampAssets, toAssetInfoArray } from "@getpara/core-sdk";
|
|
12
6
|
function getCurrencyCode({ assetInfo }, { network, asset, provider }) {
|
|
13
7
|
var _a, _b, _c;
|
|
14
8
|
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];
|
|
@@ -44,8 +38,8 @@ function reverseCurrencyLookup(data, provider, code) {
|
|
|
44
38
|
return [row == null ? void 0 : row[1], row == null ? void 0 : row[2]];
|
|
45
39
|
}
|
|
46
40
|
const TestNetworks = [
|
|
47
|
-
{ main:
|
|
48
|
-
{ main:
|
|
41
|
+
{ main: "ETHEREUM", test: "SEPOLIA" },
|
|
42
|
+
{ main: "SOLANA", test: "SOLANA_DEVNET" }
|
|
49
43
|
];
|
|
50
44
|
function getNetworkTestEquivalent(network) {
|
|
51
45
|
var _a;
|
|
@@ -56,13 +50,13 @@ function getNetworkOrMainNetEquivalent(network, testMode) {
|
|
|
56
50
|
return testMode ? (_b = (_a = TestNetworks.find(({ test }) => test === network)) == null ? void 0 : _a.main) != null ? _b : network : network;
|
|
57
51
|
}
|
|
58
52
|
const NetworkChainIds = [
|
|
59
|
-
{ chainId: "11155111", network:
|
|
60
|
-
{ chainId: "1", network:
|
|
61
|
-
{ chainId: "137", network:
|
|
62
|
-
{ chainId: "42220", network:
|
|
63
|
-
{ chainId: "8453", network:
|
|
64
|
-
{ chainId: "42161", network:
|
|
65
|
-
{ chainId: "10", network:
|
|
53
|
+
{ chainId: "11155111", network: "SEPOLIA" },
|
|
54
|
+
{ chainId: "1", network: "ETHEREUM" },
|
|
55
|
+
{ chainId: "137", network: "POLYGON" },
|
|
56
|
+
{ chainId: "42220", network: "CELO" },
|
|
57
|
+
{ chainId: "8453", network: "BASE" },
|
|
58
|
+
{ chainId: "42161", network: "ARBITRUM" },
|
|
59
|
+
{ chainId: "10", network: "OPTIMISM" }
|
|
66
60
|
];
|
|
67
61
|
function getChainId(network) {
|
|
68
62
|
var _a, _b;
|
|
@@ -74,41 +68,42 @@ function getNetworkFromChainId(chainId) {
|
|
|
74
68
|
}
|
|
75
69
|
const ETH_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
76
70
|
const NetworkAssetAddresses = [
|
|
77
|
-
{ network:
|
|
78
|
-
{ network:
|
|
79
|
-
{ network:
|
|
80
|
-
{ network:
|
|
81
|
-
{ network:
|
|
82
|
-
{ network:
|
|
83
|
-
{ network:
|
|
84
|
-
{ network:
|
|
85
|
-
{ network:
|
|
86
|
-
{ network:
|
|
71
|
+
{ network: "ETHEREUM", asset: "USDC", address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" },
|
|
72
|
+
{ network: "POLYGON", asset: "USDC", address: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359" },
|
|
73
|
+
{ network: "CELO", asset: "USDC", address: "0xcebA9300f2b948710d2653dD7B07f33A8B32118C" },
|
|
74
|
+
{ network: "BASE", asset: "USDC", address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" },
|
|
75
|
+
{ network: "ARBITRUM", asset: "USDC", address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831" },
|
|
76
|
+
{ network: "OPTIMISM", asset: "USDC", address: "0x0b2c639c533813f4aa9d7837caf62653d097ff85" },
|
|
77
|
+
{ network: "SOLANA", asset: "USDC", address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
|
|
78
|
+
{ network: "SOLANA_DEVNET", asset: "USDC", address: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU" },
|
|
79
|
+
{ network: "SEPOLIA", asset: "USDC", address: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238" },
|
|
80
|
+
{ network: "SOLANA_DEVNET", asset: "TETHER", address: "EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS" }
|
|
87
81
|
];
|
|
88
82
|
function getAssetFromContractAddress(network, contractAddress) {
|
|
89
83
|
var _a, _b;
|
|
90
84
|
if (contractAddress === ETH_CONTRACT_ADDRESS) {
|
|
91
|
-
return
|
|
85
|
+
return "USDC";
|
|
92
86
|
}
|
|
93
|
-
const checkNetworks = [network, (_a = getNetworkOrMainNetEquivalent(network)) != null ? _a : void 0].filter((n) => !!n).map((n) =>
|
|
87
|
+
const checkNetworks = [network, (_a = getNetworkOrMainNetEquivalent(network)) != null ? _a : void 0].filter((n) => !!n).map((n) => n);
|
|
94
88
|
return (_b = NetworkAssetAddresses.find(
|
|
95
89
|
(row) => checkNetworks.includes(row.network) && row.asset.toLowerCase() === contractAddress.toLowerCase()
|
|
96
90
|
)) == null ? void 0 : _b.asset;
|
|
97
91
|
}
|
|
98
92
|
function getContractAddressFromAsset(network, asset) {
|
|
99
93
|
var _a;
|
|
100
|
-
if (asset ===
|
|
94
|
+
if (asset === "USDC") {
|
|
101
95
|
return ETH_CONTRACT_ADDRESS;
|
|
102
96
|
}
|
|
103
97
|
return (_a = NetworkAssetAddresses.find((row) => row.network === network && row.asset === asset)) == null ? void 0 : _a.address;
|
|
104
98
|
}
|
|
105
|
-
export * from "./offRampSend.js";
|
|
106
99
|
export * from "./getDeviceLogo.js";
|
|
107
100
|
export * from "./getDeviceModelName.js";
|
|
108
101
|
export * from "./getBrowserName.js";
|
|
109
102
|
export * from "./formatBiometricHints.js";
|
|
110
103
|
export * from "./getExternalWalletDisplayName.js";
|
|
104
|
+
export * from "./getExternalWalletIcon.js";
|
|
111
105
|
export * from "./safeStyled.js";
|
|
106
|
+
export * from "./openMobileUrl.js";
|
|
112
107
|
export {
|
|
113
108
|
NetworkAssetAddresses,
|
|
114
109
|
NetworkChainIds,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const openMobileUrl: (url?: string) => void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-MMUBH76A.js";
|
|
3
|
+
import { isAndroid, isMobile, isTelegram } from "@getpara/web-sdk";
|
|
4
|
+
const openMobileUrl = (url) => {
|
|
5
|
+
if (typeof window === "undefined") {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (isMobile()) {
|
|
9
|
+
if (!url) return;
|
|
10
|
+
if (isTelegram()) {
|
|
11
|
+
let href = url;
|
|
12
|
+
if (isAndroid()) {
|
|
13
|
+
try {
|
|
14
|
+
const decoded = decodeURI(url);
|
|
15
|
+
href = decoded === url ? encodeURI(url) : url;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
href = encodeURI(url);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
window.open(href, "_blank", "noreferrer noopener");
|
|
21
|
+
} else if (url.startsWith("http")) {
|
|
22
|
+
const link = document.createElement("a");
|
|
23
|
+
link.href = url;
|
|
24
|
+
link.target = "_blank";
|
|
25
|
+
link.rel = "noreferrer noopener";
|
|
26
|
+
link.click();
|
|
27
|
+
} else {
|
|
28
|
+
window.location.href = url;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
openMobileUrl
|
|
34
|
+
};
|
package/dist/utils/safeStyled.js
CHANGED