@funkit/connect 1.5.0-next.0 → 2.0.1
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/CHANGELOG.md +28 -0
- package/dist/components/FunkitProvider/FunkitCheckoutContext.d.ts +2 -1
- package/dist/config/getDefaultConfig.d.ts +33 -0
- package/dist/dydx-G2CHDMSF.js +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +93 -51
- package/dist/utils/checkout.d.ts +1 -1
- package/dist/utils/flags/config.d.ts +8 -2
- package/dist/utils/flags/index.d.ts +2 -0
- package/dist/utils/isDydxAddress.d.ts +6 -0
- package/dist/utils/privyHelper.d.ts +1 -1
- package/dist/wallets/walletConnectors/index.js +69 -69
- package/package.json +5 -4
- package/dist/wallets/walletConnectors/chunk-32KBKKGT.js +0 -182
- package/dist/wallets/walletConnectors/chunk-37MVF2BB.js +0 -94
- package/dist/wallets/walletConnectors/chunk-3CLNL7LR.js +0 -73
- package/dist/wallets/walletConnectors/chunk-7GGRZNT3.js +0 -96
- package/dist/wallets/walletConnectors/chunk-7YDZTPO4.js +0 -100
- package/dist/wallets/walletConnectors/chunk-AJKRYTH2.js +0 -92
- package/dist/wallets/walletConnectors/chunk-BAFQ33Z6.js +0 -71
- package/dist/wallets/walletConnectors/chunk-CMXZK5RR.js +0 -94
- package/dist/wallets/walletConnectors/chunk-CVGDYGHA.js +0 -60
- package/dist/wallets/walletConnectors/chunk-F4EJ42XO.js +0 -105
- package/dist/wallets/walletConnectors/chunk-FGBCIE4L.js +0 -182
- package/dist/wallets/walletConnectors/chunk-FL2VIO76.js +0 -71
- package/dist/wallets/walletConnectors/chunk-GJ4TYHDI.js +0 -102
- package/dist/wallets/walletConnectors/chunk-I5GSQUQN.js +0 -98
- package/dist/wallets/walletConnectors/chunk-IIJOJ6AD.js +0 -102
- package/dist/wallets/walletConnectors/chunk-KZFAL4RZ.js +0 -27
- package/dist/wallets/walletConnectors/chunk-LJRV5JY7.js +0 -95
- package/dist/wallets/walletConnectors/chunk-MSRKKVDE.js +0 -98
- package/dist/wallets/walletConnectors/chunk-OKZSWAPF.js +0 -60
- package/dist/wallets/walletConnectors/chunk-OYKWP3N3.js +0 -60
- package/dist/wallets/walletConnectors/chunk-OYW4TIA3.js +0 -81
- package/dist/wallets/walletConnectors/chunk-PK46LOWC.js +0 -95
- package/dist/wallets/walletConnectors/chunk-QYK7UAJQ.js +0 -96
- package/dist/wallets/walletConnectors/chunk-THEL4ZSX.js +0 -105
- package/dist/wallets/walletConnectors/chunk-XC7OMZSO.js +0 -73
- package/dist/wallets/walletConnectors/chunk-Z4YUZ33O.js +0 -100
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @funkit/connect
|
|
2
2
|
|
|
3
|
+
## 2.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 212d32f: feat: conditionally disable zksync source assets for dydx & mantle checkouts
|
|
8
|
+
- 10c3f9e: refactor(connect): web2 login redirects should persist existing query params
|
|
9
|
+
- 116235a: feat: enable bech32 decoding check on dydx addresses
|
|
10
|
+
|
|
11
|
+
## 2.0.0
|
|
12
|
+
|
|
13
|
+
### Major Changes
|
|
14
|
+
|
|
15
|
+
- 4c467f2: feat: update minimum node version to v18, use native fetch
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- d50a369: feat: dydx chain and usdc checkout compatibility
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- d50a369: feat: checkout history safeguard across versions
|
|
24
|
+
- Updated dependencies [d50a369]
|
|
25
|
+
- Updated dependencies [d50a369]
|
|
26
|
+
- Updated dependencies [4c467f2]
|
|
27
|
+
- @funkit/core@2.0.0
|
|
28
|
+
- @funkit/api-base@1.0.0
|
|
29
|
+
- @funkit/wagmi-tools@3.0.0
|
|
30
|
+
|
|
3
31
|
## 1.5.0-next.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
|
@@ -11,6 +11,7 @@ export interface FunkitCheckoutActionParams {
|
|
|
11
11
|
functionArgs: any[];
|
|
12
12
|
value?: bigint;
|
|
13
13
|
}
|
|
14
|
+
export type DydxAddress = `dydx${string}`;
|
|
14
15
|
export interface FunkitCheckoutConfig {
|
|
15
16
|
/** ****************************
|
|
16
17
|
* Api-related configurations *
|
|
@@ -28,7 +29,7 @@ export interface FunkitCheckoutConfig {
|
|
|
28
29
|
/** Timestamp (in milliseconds) after which the checkout should not be performed, and the funds will become rescuable. Min: 300000 (5 mins), Max: 3600000 (1 hour). **/
|
|
29
30
|
expirationTimestampMs: number;
|
|
30
31
|
/** Custom recipient address of the checkout. If specified, a different checkout flow will be executed. It is not recommended to set this unless the Fun.xyz team advises it. **/
|
|
31
|
-
customRecipient?: Address;
|
|
32
|
+
customRecipient?: Address | DydxAddress;
|
|
32
33
|
/** ****************************************
|
|
33
34
|
* Checkout ModalUI-related configurations *
|
|
34
35
|
*******************************************/
|
|
@@ -3761,6 +3761,39 @@ export declare const getDefaultChains: () => ({
|
|
|
3761
3761
|
formatters?: undefined;
|
|
3762
3762
|
serializers?: import("viem").ChainSerializers<undefined> | undefined;
|
|
3763
3763
|
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
3764
|
+
} | {
|
|
3765
|
+
id: number;
|
|
3766
|
+
name: string;
|
|
3767
|
+
nativeCurrency: {
|
|
3768
|
+
symbol: string;
|
|
3769
|
+
decimals: number;
|
|
3770
|
+
name: string;
|
|
3771
|
+
};
|
|
3772
|
+
rpcUrls: {
|
|
3773
|
+
default: {
|
|
3774
|
+
http: string[];
|
|
3775
|
+
};
|
|
3776
|
+
};
|
|
3777
|
+
blockExplorers: {
|
|
3778
|
+
default: {
|
|
3779
|
+
name: string;
|
|
3780
|
+
url: string;
|
|
3781
|
+
apiUrl: string;
|
|
3782
|
+
};
|
|
3783
|
+
};
|
|
3784
|
+
contracts: {
|
|
3785
|
+
ensRegistry: {
|
|
3786
|
+
address: `0x${string}`;
|
|
3787
|
+
};
|
|
3788
|
+
ensUniversalResolver: {
|
|
3789
|
+
address: `0x${string}`;
|
|
3790
|
+
blockCreated: number;
|
|
3791
|
+
};
|
|
3792
|
+
multicall3: {
|
|
3793
|
+
address: `0x${string}`;
|
|
3794
|
+
blockCreated: number;
|
|
3795
|
+
};
|
|
3796
|
+
};
|
|
3764
3797
|
} | {
|
|
3765
3798
|
blockExplorers: {
|
|
3766
3799
|
readonly default: {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/components/FunkitProvider/chainIcons/dydx.svg
|
|
3
|
+
var dydx_default = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgzIiBoZWlnaHQ9IjE4MyIgdmlld0JveD0iMCAwIDE4MyAxODMiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSIxODEiIGhlaWdodD0iMTgxIiByeD0iMzciIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcikiLz4KPHBhdGggZD0iTTExNS4zMTYgNDNMNDUgMTQxLjk5Mkg2Ni41ODg1TDEzNy4yNjkgNDNIMTE1LjMxNloiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik02OC44Mzc1IDQzTDg5LjUyNjUgNzIuMTY5Nkw3OC43MzIyIDg4LjA4MDRMNDYuNzk5MiA0M0g2OC44Mzc1WiIgZmlsbD0idXJsKCNwYWludDFfbGluZWFyKSIvPgo8cGF0aCBkPSJNMTE3LjQxMSAxNDJMOTQuNDczNyAxMDkuNzM3TDEwNS4yNjggOTQuMjY3OUwxMzkgMTQySDExNy40MTFaIiBmaWxsPSJ1cmwoI3BhaW50Ml9saW5lYXIpIi8+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSIxODEiIGhlaWdodD0iMTgxIiByeD0iMzciIHN0cm9rZT0iIzJEMkQzRCIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXIiIHgxPSIxNDcuNSIgeTE9Ii0yNC41IiB4Mj0iMTAzIiB5Mj0iMTYwLjUiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iIzJDMkMzRCIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMxYTFhMjciLz4KPC9saW5lYXJHcmFkaWVudD4KPGxpbmVhckdyYWRpZW50IGlkPSJwYWludDFfbGluZWFyIiB4MT0iNjMuODkwMSIgeTE9IjQ5LjE4NzUiIHgyPSI5Mi44OTUxIiB5Mj0iODQuODIwNSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSJ3aGl0ZSIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IndoaXRlIiBzdG9wLW9wYWNpdHk9IjAuNTUiLz4KPC9saW5lYXJHcmFkaWVudD4KPGxpbmVhckdyYWRpZW50IGlkPSJwYWludDJfbGluZWFyIiB4MT0iMTIyLjM1OSIgeTE9IjEzNC40ODciIHgyPSI4Ni43ODczIiB5Mj0iODUuNjg2MyIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjNjk2NkZGIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzY5NjZGRiIgc3RvcC1vcGFjaXR5PSIwLjM2Ii8+CjwvbGluZWFyR3JhZGllbnQ+CjwvZGVmcz4KPC9zdmc+Cg==";
|
|
4
|
+
export {
|
|
5
|
+
dydx_default as default
|
|
6
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,6 @@ export { cssStringFromTheme } from './css/cssStringFromTheme';
|
|
|
22
22
|
export type { Locale } from './locales/';
|
|
23
23
|
export { darkTheme } from './themes/darkTheme';
|
|
24
24
|
export { lightTheme } from './themes/lightTheme';
|
|
25
|
-
export { useAddRecentTransaction } from './transactions/useAddRecentTransaction';
|
|
26
25
|
export type { FunkitConnectWalletConnectParameters, Wallet, WalletDetailsParams, WalletList, } from './wallets/Wallet';
|
|
27
26
|
export { useFunkitAccount, useFunkitDisconnect, useFunkitSwitchChains, } from './components/FunkitProvider/GeneralWalletProvider';
|
|
27
|
+
export { isDydxAddress } from './utils/isDydxAddress';
|
package/dist/index.js
CHANGED
|
@@ -321,9 +321,11 @@ var validateEmailString = (emailInput) => {
|
|
|
321
321
|
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
322
322
|
return emailRegex.test(emailInput);
|
|
323
323
|
};
|
|
324
|
-
var
|
|
324
|
+
var removeSpecificURLParameters = (paramsToRemove) => {
|
|
325
325
|
if (window.history.pushState) {
|
|
326
|
-
const
|
|
326
|
+
const url = new URL(window.location.href);
|
|
327
|
+
paramsToRemove.forEach((param) => url.searchParams.delete(param));
|
|
328
|
+
const cleanUrl = url.protocol + "//" + url.host + url.pathname + url.search;
|
|
327
329
|
window.history.pushState({ path: cleanUrl }, "", cleanUrl);
|
|
328
330
|
}
|
|
329
331
|
};
|
|
@@ -420,6 +422,14 @@ var flagConfig = {
|
|
|
420
422
|
["disable_mantle_source_assets" /* DisableMantleSourceAssets */]: {
|
|
421
423
|
type: "boolean",
|
|
422
424
|
default_value: true
|
|
425
|
+
},
|
|
426
|
+
["disable_zksync_source_assets_for_mantle_checkouts" /* DisableZkSyncSourceAssetsForMantleCheckouts */]: {
|
|
427
|
+
type: "boolean",
|
|
428
|
+
default_value: true
|
|
429
|
+
},
|
|
430
|
+
["disable_zksync_source_assets_for_dydx_checkouts" /* DisableZkSyncSourceAssetsForDydxCheckouts */]: {
|
|
431
|
+
type: "boolean",
|
|
432
|
+
default_value: true
|
|
423
433
|
}
|
|
424
434
|
};
|
|
425
435
|
|
|
@@ -944,6 +954,7 @@ function useFunkitConfig() {
|
|
|
944
954
|
}
|
|
945
955
|
|
|
946
956
|
// src/components/FunkitProvider/provideFunkitConnectChains.ts
|
|
957
|
+
import { DYDX_MAINNET_CHAIN_ID } from "@funkit/core";
|
|
947
958
|
var arbitrumIcon = {
|
|
948
959
|
iconBackground: "#96bedc",
|
|
949
960
|
iconUrl: async () => (await import("./arbitrum-U5YFKKLG.js")).default
|
|
@@ -968,6 +979,10 @@ var cronosIcon = {
|
|
|
968
979
|
iconBackground: "#002D74",
|
|
969
980
|
iconUrl: async () => (await import("./cronos-2XRBT4RE.js")).default
|
|
970
981
|
};
|
|
982
|
+
var dydxIcon = {
|
|
983
|
+
iconBackground: "#2C2C3D",
|
|
984
|
+
iconUrl: async () => (await import("./dydx-G2CHDMSF.js")).default
|
|
985
|
+
};
|
|
971
986
|
var ethereumIcon = {
|
|
972
987
|
iconBackground: "#484c50",
|
|
973
988
|
iconUrl: async () => (await import("./ethereum-H5XMTX4V.js")).default
|
|
@@ -1031,6 +1046,7 @@ var chainMetadataByName = {
|
|
|
1031
1046
|
bscTestnet: { chainId: 97, ...bscIcon },
|
|
1032
1047
|
cronos: { chainId: 25, ...cronosIcon },
|
|
1033
1048
|
cronosTestnet: { chainId: 338, ...cronosIcon },
|
|
1049
|
+
dydxMainnet: { chainId: DYDX_MAINNET_CHAIN_ID, ...dydxIcon },
|
|
1034
1050
|
goerli: { chainId: 5, ...ethereumIcon },
|
|
1035
1051
|
hardhat: { chainId: 31337, ...hardhatIcon },
|
|
1036
1052
|
holesky: { chainId: 17e3, ...ethereumIcon },
|
|
@@ -1733,9 +1749,9 @@ function useSymbolRefresh() {
|
|
|
1733
1749
|
var useSymbolRefresh_default = useSymbolRefresh;
|
|
1734
1750
|
|
|
1735
1751
|
// src/utils/assets.ts
|
|
1736
|
-
import { FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO } from "@funkit/core";
|
|
1752
|
+
import { dydxChain, FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO } from "@funkit/core";
|
|
1737
1753
|
import { formatUnits } from "viem";
|
|
1738
|
-
import { mantle } from "viem/chains";
|
|
1754
|
+
import { mantle, zkSync } from "viem/chains";
|
|
1739
1755
|
|
|
1740
1756
|
// src/hooks/useCheckoutType.ts
|
|
1741
1757
|
function getCheckoutType(checkoutItem) {
|
|
@@ -1773,14 +1789,23 @@ var getNormalizedTokenBalance = (tokenBalance, decimals) => {
|
|
|
1773
1789
|
return Number(formatUnits(BigInt(tokenBalance), decimals));
|
|
1774
1790
|
};
|
|
1775
1791
|
var isAssetUsableToPayForCheckout = (checkoutItem, paymentMethod, assetChainId, assetTokenAddress, isWeb2Login, isWeb3Login) => {
|
|
1792
|
+
const targetChainId = checkoutItem.initSettings.config.targetChain;
|
|
1776
1793
|
const { isCheckoutPostActionRequired } = getCheckoutType(checkoutItem);
|
|
1777
|
-
const isSameAsPurchasingToken = !isCheckoutPostActionRequired && paymentMethod === "balance" /* ACCOUNT_BALANCE */ &&
|
|
1794
|
+
const isSameAsPurchasingToken = !isCheckoutPostActionRequired && paymentMethod === "balance" /* ACCOUNT_BALANCE */ && targetChainId === assetChainId && checkoutItem.initSettings.config.targetAsset.toLowerCase() === assetTokenAddress.toLowerCase();
|
|
1778
1795
|
const isConnectedAccountSupported = isWeb2Login && FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO[assetChainId].isFunWalletSupported || isWeb3Login || !isWeb2Login && !isWeb3Login;
|
|
1796
|
+
const isZkSyncAssetsDisabledForMantleCheckouts = flags.getBool(
|
|
1797
|
+
"disable_zksync_source_assets_for_mantle_checkouts" /* DisableZkSyncSourceAssetsForMantleCheckouts */,
|
|
1798
|
+
true
|
|
1799
|
+
);
|
|
1800
|
+
const isZkSyncAssetsDisabledForDydxCheckouts = flags.getBool(
|
|
1801
|
+
"disable_zksync_source_assets_for_dydx_checkouts" /* DisableZkSyncSourceAssetsForDydxCheckouts */,
|
|
1802
|
+
true
|
|
1803
|
+
);
|
|
1779
1804
|
const isMantleAssetsDisabled = flags.getBool(
|
|
1780
1805
|
"disable_mantle_source_assets" /* DisableMantleSourceAssets */,
|
|
1781
1806
|
true
|
|
1782
1807
|
);
|
|
1783
|
-
const isAssetDisabled = isMantleAssetsDisabled && assetChainId === mantle.id.toString();
|
|
1808
|
+
const isAssetDisabled = isMantleAssetsDisabled && assetChainId === mantle.id.toString() || isZkSyncAssetsDisabledForMantleCheckouts && assetChainId === zkSync.id.toString() && targetChainId === mantle.id.toString() || isZkSyncAssetsDisabledForDydxCheckouts && assetChainId === zkSync.id.toString() && targetChainId === dydxChain.id.toString();
|
|
1784
1809
|
const isPickedChainSupportedForCheckout = isConnectedAccountSupported && FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO[assetChainId].isCheckoutSupported && !isAssetDisabled;
|
|
1785
1810
|
const isUsable = !isSameAsPurchasingToken && isPickedChainSupportedForCheckout;
|
|
1786
1811
|
return {
|
|
@@ -2225,7 +2250,7 @@ import {
|
|
|
2225
2250
|
formatEther,
|
|
2226
2251
|
pad
|
|
2227
2252
|
} from "viem";
|
|
2228
|
-
import { zkSync } from "viem/zksync";
|
|
2253
|
+
import { zkSync as zkSync2 } from "viem/zksync";
|
|
2229
2254
|
import { useAccount as useAccount3, useConfig as useConfig2 } from "wagmi";
|
|
2230
2255
|
|
|
2231
2256
|
// src/consts/checkout.ts
|
|
@@ -2558,6 +2583,20 @@ function normalizeSmallUsdNumber(usdNumber) {
|
|
|
2558
2583
|
return parsedNumber;
|
|
2559
2584
|
}
|
|
2560
2585
|
|
|
2586
|
+
// src/utils/isDydxAddress.ts
|
|
2587
|
+
import { bech32 } from "bech32";
|
|
2588
|
+
function verifyIsBech32(address) {
|
|
2589
|
+
try {
|
|
2590
|
+
bech32.decode(address);
|
|
2591
|
+
} catch (error) {
|
|
2592
|
+
return error;
|
|
2593
|
+
}
|
|
2594
|
+
return void 0;
|
|
2595
|
+
}
|
|
2596
|
+
function isDydxAddress(address) {
|
|
2597
|
+
return address.startsWith("dydx1") && verifyIsBech32(address) === void 0;
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2561
2600
|
// src/utils/checkout.ts
|
|
2562
2601
|
var CHECKOUT_EXPIRATION_TIMESTAMP_UPPERBOUND = 36e5;
|
|
2563
2602
|
var CHECKOUT_EXPIRATION_TIMESTAMP_LOWERBOUND = 3e5;
|
|
@@ -2567,7 +2606,7 @@ var DUMMY_TRANSFER_PARAMS = {
|
|
|
2567
2606
|
toAddress: "0x000000000000000000000000000000000000dEaD",
|
|
2568
2607
|
tokenAmount: 5
|
|
2569
2608
|
};
|
|
2570
|
-
function validateCheckoutConfig(config
|
|
2609
|
+
function validateCheckoutConfig(config) {
|
|
2571
2610
|
var _a, _b;
|
|
2572
2611
|
logger.log("validateCheckoutConfig_input", config);
|
|
2573
2612
|
if (!config.checkoutItemTitle) {
|
|
@@ -2619,7 +2658,19 @@ function validateCheckoutConfig(config, isUserLoggedIn) {
|
|
|
2619
2658
|
message: `Invalid targetChain configuration: Unsupported chain id ${config.targetChain} for checkout.`
|
|
2620
2659
|
};
|
|
2621
2660
|
}
|
|
2622
|
-
|
|
2661
|
+
const chainCheckoutAssetWhitelist = FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO3[config.targetChain].checkoutAssetWhitelist || [];
|
|
2662
|
+
if ((chainCheckoutAssetWhitelist == null ? void 0 : chainCheckoutAssetWhitelist[0]) !== "*" && !chainCheckoutAssetWhitelist.some(
|
|
2663
|
+
(asset) => {
|
|
2664
|
+
var _a2;
|
|
2665
|
+
return asset.toLowerCase() === ((_a2 = config.targetAsset) == null ? void 0 : _a2.toLowerCase());
|
|
2666
|
+
}
|
|
2667
|
+
)) {
|
|
2668
|
+
return {
|
|
2669
|
+
isValid: false,
|
|
2670
|
+
message: `Invalid targetAsset ${config.targetAsset} for targetChain ${config.targetChain}.`
|
|
2671
|
+
};
|
|
2672
|
+
}
|
|
2673
|
+
if (config.customRecipient && !isAddress(config.customRecipient) && !isDydxAddress(config.customRecipient)) {
|
|
2623
2674
|
return {
|
|
2624
2675
|
isValid: false,
|
|
2625
2676
|
message: `Invalid customRecipient configuration: Has to be a valid address.`
|
|
@@ -2918,7 +2969,12 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
2918
2969
|
newCheckoutHistoryList = singleCheckoutHistory ? [singleCheckoutHistory] : [];
|
|
2919
2970
|
}
|
|
2920
2971
|
setCheckoutHistoryList(
|
|
2921
|
-
newCheckoutHistoryList.filter(
|
|
2972
|
+
newCheckoutHistoryList.filter(
|
|
2973
|
+
(item) => {
|
|
2974
|
+
var _a, _b;
|
|
2975
|
+
return item.state !== CheckoutState3.CANCELLED && !!((_a = FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO5) == null ? void 0 : _a[item.fromChainId]) && !!((_b = FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO5) == null ? void 0 : _b[item.toChainId]);
|
|
2976
|
+
}
|
|
2977
|
+
).sort((a, b) => b.createdTimeMs - a.createdTimeMs)
|
|
2922
2978
|
);
|
|
2923
2979
|
setIsCheckoutHistoryInited(true);
|
|
2924
2980
|
} catch (err) {
|
|
@@ -3233,7 +3289,7 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
3233
3289
|
};
|
|
3234
3290
|
let additionalFeesTokenAmount = 0;
|
|
3235
3291
|
let additionalTimeMs = 0;
|
|
3236
|
-
if (newPaymentMethodInfo.paymentMethod === "balance" /* ACCOUNT_BALANCE */ && isWeb3Login && checkoutItem.selectedSourceAssetInfo.chainId !==
|
|
3292
|
+
if (newPaymentMethodInfo.paymentMethod === "balance" /* ACCOUNT_BALANCE */ && isWeb3Login && checkoutItem.selectedSourceAssetInfo.chainId !== zkSync2.id.toString()) {
|
|
3237
3293
|
let gasEstimateResult = BigInt(0);
|
|
3238
3294
|
const isNativeTokenTransfer = checkoutItem.selectedSourceAssetInfo.address === NATIVE_TOKEN;
|
|
3239
3295
|
logger.log("gasEstimateResult:before", { gasEstimateResult });
|
|
@@ -3599,13 +3655,15 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
3599
3655
|
[
|
|
3600
3656
|
funkitConfig.apiKey,
|
|
3601
3657
|
_getAndValidateCheckoutItemByCheckoutId,
|
|
3602
|
-
isWeb3Login,
|
|
3603
3658
|
isWeb2Login,
|
|
3659
|
+
isWeb3Login,
|
|
3604
3660
|
walletAddress,
|
|
3605
3661
|
_generateClientMetadataForBackend,
|
|
3606
3662
|
activeCheckouts,
|
|
3607
3663
|
triggerRefreshSymbol,
|
|
3608
|
-
|
|
3664
|
+
connector,
|
|
3665
|
+
_generateSignedBatchOperation,
|
|
3666
|
+
switchChainAsync
|
|
3609
3667
|
]
|
|
3610
3668
|
);
|
|
3611
3669
|
const contextValue = {
|
|
@@ -3781,10 +3839,7 @@ var useFunkitCheckout = (props) => {
|
|
|
3781
3839
|
...propsConfig || {},
|
|
3782
3840
|
...inputConfig || {}
|
|
3783
3841
|
};
|
|
3784
|
-
const validationResult = validateCheckoutConfig(
|
|
3785
|
-
combinedConfig,
|
|
3786
|
-
isUserLoggedIn
|
|
3787
|
-
);
|
|
3842
|
+
const validationResult = validateCheckoutConfig(combinedConfig);
|
|
3788
3843
|
onValidation == null ? void 0 : onValidation(validationResult);
|
|
3789
3844
|
if (validationResult.isValid) {
|
|
3790
3845
|
const finalConfig = combinedConfig;
|
|
@@ -3794,15 +3849,13 @@ var useFunkitCheckout = (props) => {
|
|
|
3794
3849
|
);
|
|
3795
3850
|
if (isUserLoggedIn || !!finalConfig.customRecipient) {
|
|
3796
3851
|
setPendingCheckoutConfig(void 0);
|
|
3797
|
-
if (isUserLoggedIn) {
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
return;
|
|
3805
|
-
}
|
|
3852
|
+
if (isUserLoggedIn && !((_b = (_a = FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO5) == null ? void 0 : _a[finalConfig.targetChain]) == null ? void 0 : _b.isMainnet)) {
|
|
3853
|
+
onErrorWrapper == null ? void 0 : onErrorWrapper({
|
|
3854
|
+
type: "error",
|
|
3855
|
+
message: "Unable to begin a new checkout: Insufficient funds on testnet account",
|
|
3856
|
+
metadata: {}
|
|
3857
|
+
});
|
|
3858
|
+
return;
|
|
3806
3859
|
}
|
|
3807
3860
|
onOpenWrapper == null ? void 0 : onOpenWrapper(newId);
|
|
3808
3861
|
} else {
|
|
@@ -4657,11 +4710,12 @@ var EditIcon = ({ size = "24" }) => /* @__PURE__ */ React32.createElement("svg",
|
|
|
4657
4710
|
|
|
4658
4711
|
// src/components/FunCheckoutModal/FunCheckoutModal.tsx
|
|
4659
4712
|
import {
|
|
4713
|
+
dydxChain as dydxChain2,
|
|
4660
4714
|
FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO as FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO8,
|
|
4661
4715
|
getTokenInfo as getTokenInfo2
|
|
4662
4716
|
} from "@funkit/core";
|
|
4663
4717
|
import React83, { useCallback as useCallback20, useEffect as useEffect20, useMemo as useMemo22, useState as useState23 } from "react";
|
|
4664
|
-
import { arbitrum, mainnet as mainnet3, mantle as mantle2, zkSync as
|
|
4718
|
+
import { arbitrum, mainnet as mainnet3, mantle as mantle2, zkSync as zkSync3 } from "viem/chains";
|
|
4665
4719
|
|
|
4666
4720
|
// src/hooks/useCheckoutAccountBalanceTransfer.ts
|
|
4667
4721
|
import { useCallback as useCallback9 } from "react";
|
|
@@ -9665,8 +9719,9 @@ function FunCheckoutModal({
|
|
|
9665
9719
|
const isCanada = userIpInfo ? userIpInfo.alpha2 === "CA" : false;
|
|
9666
9720
|
const originalTargetChainId = checkoutItem == null ? void 0 : checkoutItem.initSettings.config.targetChain.toString();
|
|
9667
9721
|
const moonpayChainId = [
|
|
9668
|
-
|
|
9669
|
-
mantle2.id.toString()
|
|
9722
|
+
zkSync3.id.toString(),
|
|
9723
|
+
mantle2.id.toString(),
|
|
9724
|
+
dydxChain2.id.toString()
|
|
9670
9725
|
].includes(originalTargetChainId) ? arbitrum.id.toString() : originalTargetChainId;
|
|
9671
9726
|
const wethAddrOnTargetChain = (await getTokenInfo2("weth", moonpayChainId)).toLowerCase();
|
|
9672
9727
|
const isTargetAssetEthOrWeth = [NATIVE_TOKEN, wethAddrOnTargetChain].includes(
|
|
@@ -14095,6 +14150,7 @@ var PRIVY_AUTH_URL = "https://auth.privy.io";
|
|
|
14095
14150
|
var PRIVY_IFRAME_ID = "privy-funkit-iframe";
|
|
14096
14151
|
var PRIVY_OAUTH_CODE_URL_PARAM = "privy_oauth_code";
|
|
14097
14152
|
var PRIVY_OAUTH_STATE_URL_PARAM = "privy_oauth_state";
|
|
14153
|
+
var PRIVY_OAUTH_PROVIDER_URL_PARAM = "privy_oauth_provider";
|
|
14098
14154
|
var RESEND_EMAIL_TIMEOUT_MS = 3e3;
|
|
14099
14155
|
var getLoginMethodFromCache = () => {
|
|
14100
14156
|
try {
|
|
@@ -14330,7 +14386,11 @@ var FunkitWeb2Provider = ({
|
|
|
14330
14386
|
secondLoginCode: oauthState,
|
|
14331
14387
|
inputLoginMethod: loginMethod
|
|
14332
14388
|
});
|
|
14333
|
-
|
|
14389
|
+
removeSpecificURLParameters([
|
|
14390
|
+
PRIVY_OAUTH_CODE_URL_PARAM,
|
|
14391
|
+
PRIVY_OAUTH_STATE_URL_PARAM,
|
|
14392
|
+
PRIVY_OAUTH_PROVIDER_URL_PARAM
|
|
14393
|
+
]);
|
|
14334
14394
|
} else {
|
|
14335
14395
|
await handleFunkitWeb2Login({ chainId: initChainId });
|
|
14336
14396
|
}
|
|
@@ -14359,7 +14419,7 @@ var FunkitWeb2Provider = ({
|
|
|
14359
14419
|
if (!privy)
|
|
14360
14420
|
throw new Error(ERROR_MESSAGES.PRIVY_NOT_INITIALIZED);
|
|
14361
14421
|
try {
|
|
14362
|
-
const redirectURI = window.location.
|
|
14422
|
+
const redirectURI = window.location.href;
|
|
14363
14423
|
const resp = await privy.auth.oauth.generateURL(
|
|
14364
14424
|
authProvider,
|
|
14365
14425
|
redirectURI
|
|
@@ -15984,7 +16044,7 @@ function setFunkitConnectVersion({ version }) {
|
|
|
15984
16044
|
localStorage.setItem(storageKey6, version);
|
|
15985
16045
|
}
|
|
15986
16046
|
function getCurrentSdkVersion() {
|
|
15987
|
-
return "
|
|
16047
|
+
return "2.0.1";
|
|
15988
16048
|
}
|
|
15989
16049
|
function useFingerprint() {
|
|
15990
16050
|
const fingerprint = useCallback33(() => {
|
|
@@ -16604,24 +16664,6 @@ function FunkitPaymentsIconLine({
|
|
|
16604
16664
|
size
|
|
16605
16665
|
}));
|
|
16606
16666
|
}
|
|
16607
|
-
|
|
16608
|
-
// src/transactions/useAddRecentTransaction.ts
|
|
16609
|
-
import { useCallback as useCallback35 } from "react";
|
|
16610
|
-
import { useAccount as useAccount18 } from "wagmi";
|
|
16611
|
-
function useAddRecentTransaction() {
|
|
16612
|
-
const store = useTransactionStore();
|
|
16613
|
-
const { address } = useAccount18();
|
|
16614
|
-
const chainId = useChainId();
|
|
16615
|
-
return useCallback35(
|
|
16616
|
-
(transaction) => {
|
|
16617
|
-
if (!address || !chainId) {
|
|
16618
|
-
throw new Error("No address or chain ID found");
|
|
16619
|
-
}
|
|
16620
|
-
store.addTransaction(address, chainId, transaction);
|
|
16621
|
-
},
|
|
16622
|
-
[store, address, chainId]
|
|
16623
|
-
);
|
|
16624
|
-
}
|
|
16625
16667
|
export {
|
|
16626
16668
|
ConnectButton,
|
|
16627
16669
|
FunkitConnectAuthenticationProvider,
|
|
@@ -16640,10 +16682,10 @@ export {
|
|
|
16640
16682
|
getDefaultChains,
|
|
16641
16683
|
getDefaultTransports,
|
|
16642
16684
|
getDefaultWallets,
|
|
16685
|
+
isDydxAddress,
|
|
16643
16686
|
lightTheme,
|
|
16644
16687
|
useAccountModal,
|
|
16645
16688
|
useActiveTheme,
|
|
16646
|
-
useAddRecentTransaction,
|
|
16647
16689
|
useChainModal,
|
|
16648
16690
|
useConnectModal,
|
|
16649
16691
|
useFunkitAccount,
|
package/dist/utils/checkout.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare const DUMMY_TRANSFER_PARAMS: {
|
|
|
13
13
|
* @param config - The checkout configuration to validate.
|
|
14
14
|
* @returns An object indicating whether the configuration is valid and a message if it is not.
|
|
15
15
|
*/
|
|
16
|
-
export declare function validateCheckoutConfig(config: Partial<FunkitCheckoutConfig
|
|
16
|
+
export declare function validateCheckoutConfig(config: Partial<FunkitCheckoutConfig>): {
|
|
17
17
|
isValid: boolean;
|
|
18
18
|
message: string;
|
|
19
19
|
};
|
|
@@ -16,12 +16,18 @@ export declare enum FlagKey {
|
|
|
16
16
|
* - “Brokerage or Exchange” → Exchange
|
|
17
17
|
*/
|
|
18
18
|
PaymentMethodCopyV1 = "payment_method_copy_v1",
|
|
19
|
-
/** Whether mantle assets can be used as source asset for payment
|
|
20
|
-
DisableMantleSourceAssets = "disable_mantle_source_assets"
|
|
19
|
+
/** Whether mantle assets can be used as source asset for payment for any checkout */
|
|
20
|
+
DisableMantleSourceAssets = "disable_mantle_source_assets",
|
|
21
|
+
/** Whether zksync assets can be used as source asset for payment in a mantle checkout */
|
|
22
|
+
DisableZkSyncSourceAssetsForMantleCheckouts = "disable_zksync_source_assets_for_mantle_checkouts",
|
|
23
|
+
/** Whether zksync assets can be used as source asset for payment in a dydx checkout */
|
|
24
|
+
DisableZkSyncSourceAssetsForDydxCheckouts = "disable_zksync_source_assets_for_dydx_checkouts"
|
|
21
25
|
}
|
|
22
26
|
export declare const flagConfig: {
|
|
23
27
|
[FlagKey.ConnectSignInShowSocialLabel]: BooleanFlagConfig;
|
|
24
28
|
[FlagKey.SelectPaymentMethodText]: StringFlagConfig;
|
|
25
29
|
[FlagKey.PaymentMethodCopyV1]: BooleanFlagConfig;
|
|
26
30
|
[FlagKey.DisableMantleSourceAssets]: BooleanFlagConfig;
|
|
31
|
+
[FlagKey.DisableZkSyncSourceAssetsForMantleCheckouts]: BooleanFlagConfig;
|
|
32
|
+
[FlagKey.DisableZkSyncSourceAssetsForDydxCheckouts]: BooleanFlagConfig;
|
|
27
33
|
};
|
|
@@ -6,5 +6,7 @@ declare const singleton: FeatureFlag<{
|
|
|
6
6
|
select_payment_method_text: import("./types").StringFlagConfig;
|
|
7
7
|
payment_method_copy_v1: import("./types").BooleanFlagConfig;
|
|
8
8
|
disable_mantle_source_assets: import("./types").BooleanFlagConfig;
|
|
9
|
+
disable_zksync_source_assets_for_mantle_checkouts: import("./types").BooleanFlagConfig;
|
|
10
|
+
disable_zksync_source_assets_for_dydx_checkouts: import("./types").BooleanFlagConfig;
|
|
9
11
|
}>;
|
|
10
12
|
export declare const flags: Pick<typeof singleton, "init" | "getBool" | "getNumber" | "getString">;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replicated from @dydxprotocol/v4-client-js https://github.com/dydxprotocol/v4-clients/blob/main/v4-client-js/src/lib/validation.ts#L145C1-L158
|
|
3
|
+
* Not importing the sdk in the interest of space.
|
|
4
|
+
*/
|
|
5
|
+
export declare function verifyIsBech32(address: string): Error | undefined;
|
|
6
|
+
export declare function isDydxAddress(address: string): boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const validateEmailString: (emailInput: string) => boolean;
|
|
2
2
|
export declare const validatePhoneString: (phoneInput: string) => boolean;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const removeSpecificURLParameters: (paramsToRemove: string[]) => void;
|