coinley-checkout 1.3.7 → 1.3.8
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.
|
@@ -21490,7 +21490,8 @@ const WALLET_TYPES = {
|
|
|
21490
21490
|
TRONLINK: "tronlink",
|
|
21491
21491
|
TRUST_WALLET: "trustwallet",
|
|
21492
21492
|
LUTE: "lute",
|
|
21493
|
-
PHANTOM: "phantom"
|
|
21493
|
+
PHANTOM: "phantom",
|
|
21494
|
+
BITGET: "bitget"
|
|
21494
21495
|
};
|
|
21495
21496
|
const NETWORK_TYPES = {
|
|
21496
21497
|
ETHEREUM: "ethereum",
|
|
@@ -21635,13 +21636,11 @@ const TOKEN_CONFIG = {
|
|
|
21635
21636
|
}
|
|
21636
21637
|
};
|
|
21637
21638
|
const NETWORK_WALLET_MAP = {
|
|
21638
|
-
[NETWORK_TYPES.ETHEREUM]: [WALLET_TYPES.METAMASK, WALLET_TYPES.TRUST_WALLET],
|
|
21639
|
-
[NETWORK_TYPES.BSC]: [WALLET_TYPES.METAMASK, WALLET_TYPES.TRUST_WALLET],
|
|
21640
|
-
[NETWORK_TYPES.TRON]: [WALLET_TYPES.TRONLINK, WALLET_TYPES.TRUST_WALLET],
|
|
21641
|
-
// Trust Wallet supports TRON
|
|
21639
|
+
[NETWORK_TYPES.ETHEREUM]: [WALLET_TYPES.METAMASK, WALLET_TYPES.TRUST_WALLET, WALLET_TYPES.BITGET],
|
|
21640
|
+
[NETWORK_TYPES.BSC]: [WALLET_TYPES.METAMASK, WALLET_TYPES.TRUST_WALLET, WALLET_TYPES.BITGET],
|
|
21641
|
+
[NETWORK_TYPES.TRON]: [WALLET_TYPES.TRONLINK, WALLET_TYPES.TRUST_WALLET, WALLET_TYPES.BITGET],
|
|
21642
21642
|
[NETWORK_TYPES.ALGORAND]: [WALLET_TYPES.LUTE],
|
|
21643
|
-
[NETWORK_TYPES.SOLANA]: [WALLET_TYPES.PHANTOM, WALLET_TYPES.TRUST_WALLET]
|
|
21644
|
-
// Trust Wallet supports Solana
|
|
21643
|
+
[NETWORK_TYPES.SOLANA]: [WALLET_TYPES.PHANTOM, WALLET_TYPES.TRUST_WALLET, WALLET_TYPES.BITGET]
|
|
21645
21644
|
};
|
|
21646
21645
|
const getWalletInstallUrl = (walletType) => {
|
|
21647
21646
|
const urls = {
|
|
@@ -21649,7 +21648,8 @@ const getWalletInstallUrl = (walletType) => {
|
|
|
21649
21648
|
[WALLET_TYPES.TRONLINK]: "https://www.tronlink.org/download/",
|
|
21650
21649
|
[WALLET_TYPES.TRUST_WALLET]: "https://trustwallet.com/download/",
|
|
21651
21650
|
[WALLET_TYPES.LUTE]: "https://lute.app/download/",
|
|
21652
|
-
[WALLET_TYPES.PHANTOM]: "https://phantom.app/download"
|
|
21651
|
+
[WALLET_TYPES.PHANTOM]: "https://phantom.app/download",
|
|
21652
|
+
[WALLET_TYPES.BITGET]: "https://web3.bitget.com/wallet-download"
|
|
21653
21653
|
};
|
|
21654
21654
|
return urls[walletType] || "";
|
|
21655
21655
|
};
|
|
@@ -21670,6 +21670,118 @@ const createSolanaConnection = async () => {
|
|
|
21670
21670
|
}
|
|
21671
21671
|
throw new Error("Failed to connect to any Solana RPC endpoint. Please try again later.");
|
|
21672
21672
|
};
|
|
21673
|
+
const detectBitgetWallet = () => {
|
|
21674
|
+
if (typeof window === "undefined")
|
|
21675
|
+
return false;
|
|
21676
|
+
console.log("=== BITGET WALLET DETECTION DEBUG ===");
|
|
21677
|
+
if (window.ethereum) {
|
|
21678
|
+
console.log("window.ethereum exists:", {
|
|
21679
|
+
isMetaMask: window.ethereum.isMetaMask,
|
|
21680
|
+
isTrust: window.ethereum.isTrust,
|
|
21681
|
+
isBitget: window.ethereum.isBitget,
|
|
21682
|
+
isBitKeep: window.ethereum.isBitKeep,
|
|
21683
|
+
providers: window.ethereum.providers?.length || 0,
|
|
21684
|
+
chainId: window.ethereum.chainId
|
|
21685
|
+
});
|
|
21686
|
+
if (window.ethereum.providers) {
|
|
21687
|
+
console.log("Multiple providers detected:", window.ethereum.providers.map((p2) => ({
|
|
21688
|
+
isMetaMask: p2.isMetaMask,
|
|
21689
|
+
isTrust: p2.isTrust,
|
|
21690
|
+
isBitget: p2.isBitget,
|
|
21691
|
+
isBitKeep: p2.isBitKeep
|
|
21692
|
+
})));
|
|
21693
|
+
}
|
|
21694
|
+
}
|
|
21695
|
+
console.log("Bitget Wallet globals:", {
|
|
21696
|
+
bitkeep: Boolean(window.bitkeep),
|
|
21697
|
+
bitget: Boolean(window.bitget),
|
|
21698
|
+
isBitget: Boolean(window.isBitget),
|
|
21699
|
+
BitKeep: Boolean(window.BitKeep)
|
|
21700
|
+
});
|
|
21701
|
+
const bitgetDetectionMethods = [
|
|
21702
|
+
// Method 1: Direct Bitget Wallet identifier
|
|
21703
|
+
() => {
|
|
21704
|
+
const result = window.ethereum && window.ethereum.isBitget === true;
|
|
21705
|
+
console.log("Method 1 (ethereum.isBitget):", result);
|
|
21706
|
+
return result;
|
|
21707
|
+
},
|
|
21708
|
+
// Method 2: BitKeep (former name) identifier
|
|
21709
|
+
() => {
|
|
21710
|
+
const result = window.ethereum && window.ethereum.isBitKeep === true;
|
|
21711
|
+
console.log("Method 2 (ethereum.isBitKeep):", result);
|
|
21712
|
+
return result;
|
|
21713
|
+
},
|
|
21714
|
+
// Method 3: Bitget global object
|
|
21715
|
+
() => {
|
|
21716
|
+
const result = window.bitget !== void 0;
|
|
21717
|
+
console.log("Method 3 (window.bitget):", result);
|
|
21718
|
+
return result;
|
|
21719
|
+
},
|
|
21720
|
+
// Method 4: BitKeep global object
|
|
21721
|
+
() => {
|
|
21722
|
+
const result = window.bitkeep !== void 0 || window.BitKeep !== void 0;
|
|
21723
|
+
console.log("Method 4 (window.bitkeep/BitKeep):", result);
|
|
21724
|
+
return result;
|
|
21725
|
+
},
|
|
21726
|
+
// Method 5: Provider array detection
|
|
21727
|
+
() => {
|
|
21728
|
+
const result = window.ethereum && window.ethereum.providers && window.ethereum.providers.some((p2) => p2.isBitget === true || p2.isBitKeep === true);
|
|
21729
|
+
console.log("Method 5 (providers array):", result);
|
|
21730
|
+
return result;
|
|
21731
|
+
},
|
|
21732
|
+
// Method 6: Bitget Wallet ethereum provider specific check
|
|
21733
|
+
() => {
|
|
21734
|
+
const result = window.ethereum && (typeof window.ethereum.isBitget === "boolean" || typeof window.ethereum.isBitKeep === "boolean" || window.ethereum._bitget || window.ethereum.bitget);
|
|
21735
|
+
console.log("Method 6 (Bitget specific properties):", result);
|
|
21736
|
+
return result;
|
|
21737
|
+
},
|
|
21738
|
+
// Method 7: User agent detection (for mobile web)
|
|
21739
|
+
() => {
|
|
21740
|
+
const result = /BitKeep|Bitget/i.test(navigator.userAgent);
|
|
21741
|
+
console.log("Method 7 (user agent):", result);
|
|
21742
|
+
return result;
|
|
21743
|
+
},
|
|
21744
|
+
// Method 8: DOM element detection
|
|
21745
|
+
() => {
|
|
21746
|
+
const result = document.querySelector('[data-wallet="bitget"]') !== null || document.querySelector('[data-wallet="bitkeep"]') !== null || document.querySelector("#bitget-extension") !== null || document.querySelector("#bitkeep-extension") !== null;
|
|
21747
|
+
console.log("Method 8 (DOM elements):", result);
|
|
21748
|
+
return result;
|
|
21749
|
+
},
|
|
21750
|
+
// Method 9: Check for Bitget via window.bitget or window.bitkeep
|
|
21751
|
+
() => {
|
|
21752
|
+
const result = window.bitget !== void 0 || window.bitkeep !== void 0;
|
|
21753
|
+
console.log("Method 9 (window.bitget/bitkeep):", result);
|
|
21754
|
+
return result;
|
|
21755
|
+
},
|
|
21756
|
+
// Method 10: Advanced provider detection for Bitget
|
|
21757
|
+
() => {
|
|
21758
|
+
if (!window.ethereum)
|
|
21759
|
+
return false;
|
|
21760
|
+
const hasBitgetFeatures = (
|
|
21761
|
+
// Not other known wallets
|
|
21762
|
+
!window.ethereum.isMetaMask && !window.ethereum.isTrust && !window.ethereum.isPhantom && !window.ethereum.isFrame && // Has ethereum methods but could be Bitget
|
|
21763
|
+
window.ethereum.request && window.ethereum.on && // Check for potential Bitget patterns
|
|
21764
|
+
(window.ethereum.chainId || window.ethereum.networkVersion) && // Additional checks for Bitget-specific features
|
|
21765
|
+
(window.ethereum._bitget || window.bitget || window.bitkeep)
|
|
21766
|
+
);
|
|
21767
|
+
console.log("Method 10 (advanced detection):", hasBitgetFeatures);
|
|
21768
|
+
return hasBitgetFeatures;
|
|
21769
|
+
}
|
|
21770
|
+
];
|
|
21771
|
+
const detectionResults = bitgetDetectionMethods.map((method, index) => {
|
|
21772
|
+
try {
|
|
21773
|
+
return method();
|
|
21774
|
+
} catch (error) {
|
|
21775
|
+
console.warn(`Bitget Wallet detection method ${index + 1} failed:`, error);
|
|
21776
|
+
return false;
|
|
21777
|
+
}
|
|
21778
|
+
});
|
|
21779
|
+
const isDetected = detectionResults.some((result) => result === true);
|
|
21780
|
+
console.log("Detection results:", detectionResults);
|
|
21781
|
+
console.log("Final Bitget Wallet detection result:", isDetected);
|
|
21782
|
+
console.log("=== END BITGET WALLET DETECTION DEBUG ===");
|
|
21783
|
+
return isDetected;
|
|
21784
|
+
};
|
|
21673
21785
|
const detectTrustWallet = () => {
|
|
21674
21786
|
if (typeof window === "undefined")
|
|
21675
21787
|
return false;
|
|
@@ -21820,7 +21932,7 @@ const detectMetamaskWallet = () => {
|
|
|
21820
21932
|
if (typeof window === "undefined")
|
|
21821
21933
|
return false;
|
|
21822
21934
|
try {
|
|
21823
|
-
return window.ethereum !== void 0 && window.ethereum.isMetaMask === true && window.ethereum.isTrust !== true && window.ethereum.isTrustWallet !== true;
|
|
21935
|
+
return window.ethereum !== void 0 && window.ethereum.isMetaMask === true && window.ethereum.isTrust !== true && window.ethereum.isTrustWallet !== true && window.ethereum.isBitget !== true && window.ethereum.isBitKeep !== true;
|
|
21824
21936
|
} catch (error) {
|
|
21825
21937
|
console.warn("MetaMask detection failed:", error);
|
|
21826
21938
|
return false;
|
|
@@ -21832,7 +21944,8 @@ const detectWallets = () => {
|
|
|
21832
21944
|
[WALLET_TYPES.TRONLINK]: typeof window !== "undefined" && window.tronWeb !== void 0,
|
|
21833
21945
|
[WALLET_TYPES.TRUST_WALLET]: detectTrustWallet(),
|
|
21834
21946
|
[WALLET_TYPES.LUTE]: detectLuteWallet(),
|
|
21835
|
-
[WALLET_TYPES.PHANTOM]: detectPhantomWallet()
|
|
21947
|
+
[WALLET_TYPES.PHANTOM]: detectPhantomWallet(),
|
|
21948
|
+
[WALLET_TYPES.BITGET]: detectBitgetWallet()
|
|
21836
21949
|
};
|
|
21837
21950
|
if (typeof window !== "undefined") {
|
|
21838
21951
|
console.log("=== WALLET DETECTION DEBUG ===");
|
|
@@ -21841,11 +21954,14 @@ const detectWallets = () => {
|
|
|
21841
21954
|
console.log("Trust Wallet:", availableWallets[WALLET_TYPES.TRUST_WALLET]);
|
|
21842
21955
|
console.log("Lute:", availableWallets[WALLET_TYPES.LUTE]);
|
|
21843
21956
|
console.log("Phantom:", availableWallets[WALLET_TYPES.PHANTOM]);
|
|
21957
|
+
console.log("Bitget Wallet:", availableWallets[WALLET_TYPES.BITGET]);
|
|
21844
21958
|
if (window.ethereum) {
|
|
21845
21959
|
console.log("Ethereum provider details:", {
|
|
21846
21960
|
isMetaMask: window.ethereum.isMetaMask,
|
|
21847
21961
|
isTrust: window.ethereum.isTrust,
|
|
21848
21962
|
isTrustWallet: window.ethereum.isTrustWallet,
|
|
21963
|
+
isBitget: window.ethereum.isBitget,
|
|
21964
|
+
isBitKeep: window.ethereum.isBitKeep,
|
|
21849
21965
|
providers: window.ethereum.providers?.length || 0
|
|
21850
21966
|
});
|
|
21851
21967
|
}
|
|
@@ -21867,20 +21983,22 @@ const detectWalletsWithRetry = async (maxRetries = 5, delay = 1e3) => {
|
|
|
21867
21983
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
21868
21984
|
retries++;
|
|
21869
21985
|
}
|
|
21870
|
-
if (!wallets[WALLET_TYPES.TRUST_WALLET] || !wallets[WALLET_TYPES.LUTE] || !wallets[WALLET_TYPES.PHANTOM]) {
|
|
21986
|
+
if (!wallets[WALLET_TYPES.TRUST_WALLET] || !wallets[WALLET_TYPES.LUTE] || !wallets[WALLET_TYPES.PHANTOM] || !wallets[WALLET_TYPES.BITGET]) {
|
|
21871
21987
|
console.log("Performing extended wallet detection...");
|
|
21872
21988
|
if (typeof window !== "undefined") {
|
|
21873
21989
|
try {
|
|
21874
21990
|
const events = [
|
|
21875
21991
|
new CustomEvent("trust-wallet-detect", { detail: { source: "coinley-sdk" } }),
|
|
21876
21992
|
new CustomEvent("lute-wallet-detect", { detail: { source: "coinley-sdk" } }),
|
|
21877
|
-
new CustomEvent("phantom-wallet-detect", { detail: { source: "coinley-sdk" } })
|
|
21993
|
+
new CustomEvent("phantom-wallet-detect", { detail: { source: "coinley-sdk" } }),
|
|
21994
|
+
new CustomEvent("bitget-wallet-detect", { detail: { source: "coinley-sdk" } })
|
|
21878
21995
|
];
|
|
21879
21996
|
events.forEach((event) => window.dispatchEvent(event));
|
|
21880
21997
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
21881
21998
|
wallets[WALLET_TYPES.TRUST_WALLET] = detectTrustWallet();
|
|
21882
21999
|
wallets[WALLET_TYPES.LUTE] = detectLuteWallet();
|
|
21883
22000
|
wallets[WALLET_TYPES.PHANTOM] = detectPhantomWallet();
|
|
22001
|
+
wallets[WALLET_TYPES.BITGET] = detectBitgetWallet();
|
|
21884
22002
|
} catch (error) {
|
|
21885
22003
|
console.warn("Extended wallet detection failed:", error);
|
|
21886
22004
|
}
|
|
@@ -21900,11 +22018,16 @@ const debugWalletEnvironment = () => {
|
|
|
21900
22018
|
console.log("phantom:", typeof window !== "undefined" ? Boolean(window.phantom) : "Not in browser");
|
|
21901
22019
|
console.log("trustwallet:", typeof window !== "undefined" ? Boolean(window.trustwallet) : "Not in browser");
|
|
21902
22020
|
console.log("trust:", typeof window !== "undefined" ? Boolean(window.trust) : "Not in browser");
|
|
22021
|
+
console.log("bitget:", typeof window !== "undefined" ? Boolean(window.bitget) : "Not in browser");
|
|
22022
|
+
console.log("bitkeep:", typeof window !== "undefined" ? Boolean(window.bitkeep) : "Not in browser");
|
|
22023
|
+
console.log("BitKeep:", typeof window !== "undefined" ? Boolean(window.BitKeep) : "Not in browser");
|
|
21903
22024
|
if (typeof window !== "undefined" && window.ethereum) {
|
|
21904
22025
|
console.log("ethereum details:", {
|
|
21905
22026
|
isMetaMask: window.ethereum.isMetaMask,
|
|
21906
22027
|
isTrust: window.ethereum.isTrust,
|
|
21907
22028
|
isTrustWallet: window.ethereum.isTrustWallet,
|
|
22029
|
+
isBitget: window.ethereum.isBitget,
|
|
22030
|
+
isBitKeep: window.ethereum.isBitKeep,
|
|
21908
22031
|
chainId: window.ethereum.chainId,
|
|
21909
22032
|
providers: window.ethereum.providers?.length || 0,
|
|
21910
22033
|
selectedAddress: window.ethereum.selectedAddress
|
|
@@ -21916,6 +22039,8 @@ const debugWalletEnvironment = () => {
|
|
|
21916
22039
|
isMetaMask: provider.isMetaMask,
|
|
21917
22040
|
isTrust: provider.isTrust,
|
|
21918
22041
|
isTrustWallet: provider.isTrustWallet,
|
|
22042
|
+
isBitget: provider.isBitget,
|
|
22043
|
+
isBitKeep: provider.isBitKeep,
|
|
21919
22044
|
selectedAddress: provider.selectedAddress
|
|
21920
22045
|
});
|
|
21921
22046
|
});
|
|
@@ -21926,13 +22051,15 @@ const debugWalletEnvironment = () => {
|
|
|
21926
22051
|
ready: window.tronWeb.ready,
|
|
21927
22052
|
fullNode: window.tronWeb.fullNode?.host,
|
|
21928
22053
|
defaultAddress: window.tronWeb.defaultAddress,
|
|
21929
|
-
isTrust: window.tronWeb.isTrust
|
|
22054
|
+
isTrust: window.tronWeb.isTrust,
|
|
22055
|
+
isBitget: window.tronWeb.isBitget
|
|
21930
22056
|
});
|
|
21931
22057
|
}
|
|
21932
22058
|
if (typeof window !== "undefined" && window.solana) {
|
|
21933
22059
|
console.log("solana details:", {
|
|
21934
22060
|
isPhantom: window.solana.isPhantom,
|
|
21935
22061
|
isTrust: window.solana.isTrust,
|
|
22062
|
+
isBitget: window.solana.isBitget,
|
|
21936
22063
|
publicKey: window.solana.publicKey?.toString(),
|
|
21937
22064
|
isConnected: window.solana.isConnected
|
|
21938
22065
|
});
|
|
@@ -21940,31 +22067,34 @@ const debugWalletEnvironment = () => {
|
|
|
21940
22067
|
if (typeof window !== "undefined") {
|
|
21941
22068
|
console.log("All window wallet properties:");
|
|
21942
22069
|
const walletProps = Object.keys(window).filter(
|
|
21943
|
-
(key) => key.toLowerCase().includes("lute") || key.toLowerCase().includes("algo") || key.toLowerCase().includes("wallet") || key.toLowerCase().includes("phantom") || key.toLowerCase().includes("solana") || key.toLowerCase().includes("trust") || key.toLowerCase().includes("metamask")
|
|
22070
|
+
(key) => key.toLowerCase().includes("lute") || key.toLowerCase().includes("algo") || key.toLowerCase().includes("wallet") || key.toLowerCase().includes("phantom") || key.toLowerCase().includes("solana") || key.toLowerCase().includes("trust") || key.toLowerCase().includes("metamask") || key.toLowerCase().includes("bitget") || key.toLowerCase().includes("bitkeep")
|
|
21944
22071
|
);
|
|
21945
22072
|
console.log("Potential wallet properties:", walletProps);
|
|
21946
|
-
console.log("
|
|
21947
|
-
"window.
|
|
21948
|
-
"window.
|
|
21949
|
-
"window.
|
|
21950
|
-
"
|
|
22073
|
+
console.log("Bitget Wallet specific checks:", {
|
|
22074
|
+
"window.bitget": Boolean(window.bitget),
|
|
22075
|
+
"window.bitkeep": Boolean(window.bitkeep),
|
|
22076
|
+
"window.BitKeep": Boolean(window.BitKeep),
|
|
22077
|
+
"window.isBitget": Boolean(window.isBitget),
|
|
22078
|
+
"document bitget elements": document.querySelectorAll('[id*="bitget"], [class*="bitget"], [id*="bitkeep"], [class*="bitkeep"]').length
|
|
21951
22079
|
});
|
|
21952
22080
|
}
|
|
21953
22081
|
console.log("=== DETECTION RESULTS ===");
|
|
21954
22082
|
const wallets = detectWallets();
|
|
21955
22083
|
console.log("Final detection results:", wallets);
|
|
21956
22084
|
console.log("Trust Wallet specific detection result:", detectTrustWallet());
|
|
22085
|
+
console.log("Bitget Wallet specific detection result:", detectBitgetWallet());
|
|
21957
22086
|
console.log("=== END WALLET ENVIRONMENT DEBUG ===");
|
|
21958
22087
|
return {
|
|
21959
22088
|
wallets,
|
|
21960
22089
|
ethereum: typeof window !== "undefined" ? window.ethereum : null,
|
|
21961
|
-
trustWalletDetected: typeof window !== "undefined" ? detectTrustWallet() : false
|
|
22090
|
+
trustWalletDetected: typeof window !== "undefined" ? detectTrustWallet() : false,
|
|
22091
|
+
bitgetWalletDetected: typeof window !== "undefined" ? detectBitgetWallet() : false
|
|
21962
22092
|
};
|
|
21963
22093
|
};
|
|
21964
22094
|
const connectMetamaskWallet = async () => {
|
|
21965
22095
|
console.log("Connecting to MetaMask wallet...");
|
|
21966
|
-
if (!window.ethereum || !window.ethereum.isMetaMask || window.ethereum.isTrust === true) {
|
|
21967
|
-
console.error("MetaMask not found or
|
|
22096
|
+
if (!window.ethereum || !window.ethereum.isMetaMask || window.ethereum.isTrust === true || window.ethereum.isBitget === true) {
|
|
22097
|
+
console.error("MetaMask not found or another wallet detected instead.");
|
|
21968
22098
|
throw new Error("MetaMask not detected. Please install MetaMask extension.");
|
|
21969
22099
|
}
|
|
21970
22100
|
try {
|
|
@@ -22000,6 +22130,186 @@ const connectMetamaskWallet = async () => {
|
|
|
22000
22130
|
throw error;
|
|
22001
22131
|
}
|
|
22002
22132
|
};
|
|
22133
|
+
const connectBitgetWallet = async (targetNetwork = null) => {
|
|
22134
|
+
console.log("=== BITGET WALLET CONNECTION DEBUG ===");
|
|
22135
|
+
console.log("Connecting to Bitget Wallet for network:", targetNetwork);
|
|
22136
|
+
let networkType = targetNetwork || NETWORK_TYPES.ETHEREUM;
|
|
22137
|
+
try {
|
|
22138
|
+
if (networkType === NETWORK_TYPES.ETHEREUM || networkType === NETWORK_TYPES.BSC || networkType === NETWORK_TYPES.SOLANA) {
|
|
22139
|
+
if (!window.ethereum) {
|
|
22140
|
+
throw new Error("No Ethereum provider found. Please install Bitget Wallet browser extension.");
|
|
22141
|
+
}
|
|
22142
|
+
console.log("Available ethereum details:", {
|
|
22143
|
+
isMetaMask: window.ethereum.isMetaMask,
|
|
22144
|
+
isTrust: window.ethereum.isTrust,
|
|
22145
|
+
isBitget: window.ethereum.isBitget,
|
|
22146
|
+
isBitKeep: window.ethereum.isBitKeep,
|
|
22147
|
+
providers: window.ethereum.providers?.length || 0,
|
|
22148
|
+
selectedAddress: window.ethereum.selectedAddress
|
|
22149
|
+
});
|
|
22150
|
+
const providersToTry = [];
|
|
22151
|
+
if (window.ethereum.providers && window.ethereum.providers.length > 0) {
|
|
22152
|
+
providersToTry.push(...window.ethereum.providers);
|
|
22153
|
+
console.log(`Found ${window.ethereum.providers.length} providers in array`);
|
|
22154
|
+
} else {
|
|
22155
|
+
providersToTry.push(window.ethereum);
|
|
22156
|
+
console.log("Using main ethereum provider");
|
|
22157
|
+
}
|
|
22158
|
+
if (window.bitget?.ethereum) {
|
|
22159
|
+
providersToTry.push(window.bitget.ethereum);
|
|
22160
|
+
console.log("Added bitget.ethereum provider");
|
|
22161
|
+
}
|
|
22162
|
+
if (window.bitkeep?.ethereum) {
|
|
22163
|
+
providersToTry.push(window.bitkeep.ethereum);
|
|
22164
|
+
console.log("Added bitkeep.ethereum provider");
|
|
22165
|
+
}
|
|
22166
|
+
console.log(`Total providers to try: ${providersToTry.length}`);
|
|
22167
|
+
let successfulProvider = null;
|
|
22168
|
+
let accounts = null;
|
|
22169
|
+
let lastError = null;
|
|
22170
|
+
for (let i = 0; i < providersToTry.length; i++) {
|
|
22171
|
+
const provider = providersToTry[i];
|
|
22172
|
+
console.log(`
|
|
22173
|
+
🔍 Trying provider ${i + 1}/${providersToTry.length}:`, {
|
|
22174
|
+
isMetaMask: provider.isMetaMask,
|
|
22175
|
+
isTrust: provider.isTrust,
|
|
22176
|
+
isBitget: provider.isBitget,
|
|
22177
|
+
isBitKeep: provider.isBitKeep,
|
|
22178
|
+
selectedAddress: provider.selectedAddress
|
|
22179
|
+
});
|
|
22180
|
+
try {
|
|
22181
|
+
console.log(`📞 Requesting accounts from provider ${i + 1}...`);
|
|
22182
|
+
const testAccounts = await provider.request({
|
|
22183
|
+
method: "eth_requestAccounts"
|
|
22184
|
+
});
|
|
22185
|
+
if (testAccounts && testAccounts.length > 0) {
|
|
22186
|
+
console.log(`✅ Provider ${i + 1} worked! Got ${testAccounts.length} accounts`);
|
|
22187
|
+
console.log(`📝 First account: ${testAccounts[0]}`);
|
|
22188
|
+
successfulProvider = provider;
|
|
22189
|
+
accounts = testAccounts;
|
|
22190
|
+
if (provider.isBitget || provider.isBitKeep) {
|
|
22191
|
+
console.log(`🎯 Provider ${i + 1} is Bitget Wallet - using this one!`);
|
|
22192
|
+
break;
|
|
22193
|
+
} else {
|
|
22194
|
+
console.log(`⚠️ Provider ${i + 1} is not Bitget - will use it if no Bitget found`);
|
|
22195
|
+
}
|
|
22196
|
+
} else {
|
|
22197
|
+
console.log(`❌ Provider ${i + 1} returned no accounts`);
|
|
22198
|
+
}
|
|
22199
|
+
} catch (providerError) {
|
|
22200
|
+
console.log(`❌ Provider ${i + 1} failed:`, providerError.message);
|
|
22201
|
+
lastError = providerError;
|
|
22202
|
+
if (providerError.code === 4001) {
|
|
22203
|
+
console.log("🛑 User rejected connection - stopping attempts");
|
|
22204
|
+
throw new Error("Connection rejected by user. Please approve the connection in your wallet.");
|
|
22205
|
+
}
|
|
22206
|
+
continue;
|
|
22207
|
+
}
|
|
22208
|
+
}
|
|
22209
|
+
if (!successfulProvider || !accounts || accounts.length === 0) {
|
|
22210
|
+
console.error("❌ All providers failed");
|
|
22211
|
+
if (lastError) {
|
|
22212
|
+
if (lastError.code === 4001) {
|
|
22213
|
+
throw new Error("Connection rejected by user. Please approve the connection in your wallet.");
|
|
22214
|
+
} else {
|
|
22215
|
+
throw new Error(`Connection failed: ${lastError.message}. Please make sure your wallet is unlocked and try again.`);
|
|
22216
|
+
}
|
|
22217
|
+
} else {
|
|
22218
|
+
throw new Error("No wallet accounts found. Please make sure Bitget Wallet is unlocked and has at least one account.");
|
|
22219
|
+
}
|
|
22220
|
+
}
|
|
22221
|
+
console.log("\n🎉 Successfully connected!");
|
|
22222
|
+
console.log("Using provider:", {
|
|
22223
|
+
isMetaMask: successfulProvider.isMetaMask,
|
|
22224
|
+
isTrust: successfulProvider.isTrust,
|
|
22225
|
+
isBitget: successfulProvider.isBitget,
|
|
22226
|
+
isBitKeep: successfulProvider.isBitKeep
|
|
22227
|
+
});
|
|
22228
|
+
const address = accounts[0];
|
|
22229
|
+
let chainIdHex, chainId;
|
|
22230
|
+
try {
|
|
22231
|
+
chainIdHex = await successfulProvider.request({ method: "eth_chainId" });
|
|
22232
|
+
chainId = parseInt(chainIdHex, 16);
|
|
22233
|
+
console.log("Chain ID:", chainId);
|
|
22234
|
+
} catch (chainError) {
|
|
22235
|
+
console.warn("Could not get chain ID:", chainError);
|
|
22236
|
+
chainId = 1;
|
|
22237
|
+
}
|
|
22238
|
+
switch (chainId) {
|
|
22239
|
+
case 1:
|
|
22240
|
+
networkType = NETWORK_TYPES.ETHEREUM;
|
|
22241
|
+
break;
|
|
22242
|
+
case 56:
|
|
22243
|
+
networkType = NETWORK_TYPES.BSC;
|
|
22244
|
+
break;
|
|
22245
|
+
default:
|
|
22246
|
+
networkType = `unknown-${chainId}`;
|
|
22247
|
+
}
|
|
22248
|
+
const web3Provider = new BrowserProvider(successfulProvider);
|
|
22249
|
+
console.log("✅ Bitget Wallet connected successfully:", {
|
|
22250
|
+
address,
|
|
22251
|
+
network: networkType,
|
|
22252
|
+
chainId
|
|
22253
|
+
});
|
|
22254
|
+
console.log("=== END BITGET WALLET CONNECTION DEBUG ===");
|
|
22255
|
+
return {
|
|
22256
|
+
walletType: WALLET_TYPES.BITGET,
|
|
22257
|
+
address,
|
|
22258
|
+
provider: web3Provider,
|
|
22259
|
+
network: networkType,
|
|
22260
|
+
isConnected: true,
|
|
22261
|
+
chainId,
|
|
22262
|
+
nativeProvider: successfulProvider
|
|
22263
|
+
};
|
|
22264
|
+
} else if (networkType === NETWORK_TYPES.TRON) {
|
|
22265
|
+
if (!window.tronWeb) {
|
|
22266
|
+
throw new Error("TronWeb not found. Please install Bitget Wallet with TRON support or use Bitget Wallet mobile app.");
|
|
22267
|
+
}
|
|
22268
|
+
const waitForTronWeb = async (maxAttempts = 10, interval = 500) => {
|
|
22269
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
22270
|
+
if (window.tronWeb && window.tronWeb.ready) {
|
|
22271
|
+
return window.tronWeb;
|
|
22272
|
+
}
|
|
22273
|
+
console.log(`Waiting for TronWeb to be ready... Attempt ${attempt + 1}/${maxAttempts}`);
|
|
22274
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
22275
|
+
}
|
|
22276
|
+
throw new Error("TronWeb took too long to be ready");
|
|
22277
|
+
};
|
|
22278
|
+
const tronWeb = await waitForTronWeb();
|
|
22279
|
+
if (!tronWeb.defaultAddress || !tronWeb.defaultAddress.base58) {
|
|
22280
|
+
try {
|
|
22281
|
+
await window.tronWeb.request({ method: "tron_requestAccounts" });
|
|
22282
|
+
} catch (permissionError) {
|
|
22283
|
+
console.error("Failed to get permission from Bitget Wallet TRON:", permissionError);
|
|
22284
|
+
throw new Error("Please unlock Bitget Wallet and approve TRON connection");
|
|
22285
|
+
}
|
|
22286
|
+
}
|
|
22287
|
+
const address = tronWeb.defaultAddress.base58;
|
|
22288
|
+
console.log("Connected to Bitget Wallet TRON:", address);
|
|
22289
|
+
return {
|
|
22290
|
+
walletType: WALLET_TYPES.BITGET,
|
|
22291
|
+
address,
|
|
22292
|
+
provider: tronWeb,
|
|
22293
|
+
network: NETWORK_TYPES.TRON,
|
|
22294
|
+
isConnected: true,
|
|
22295
|
+
nativeProvider: tronWeb
|
|
22296
|
+
};
|
|
22297
|
+
} else {
|
|
22298
|
+
throw new Error(`Bitget Wallet does not support network: ${networkType}`);
|
|
22299
|
+
}
|
|
22300
|
+
} catch (error) {
|
|
22301
|
+
console.error("=== BITGET WALLET CONNECTION ERROR ===");
|
|
22302
|
+
console.error("Error details:", error);
|
|
22303
|
+
console.log("=== END BITGET WALLET CONNECTION DEBUG ===");
|
|
22304
|
+
if (error.code === 4001 || error.message.includes("rejected by user")) {
|
|
22305
|
+
throw error;
|
|
22306
|
+
} else if (error.message.includes("locked")) {
|
|
22307
|
+
throw new Error("Bitget Wallet is locked. Please unlock your wallet and try again.");
|
|
22308
|
+
} else {
|
|
22309
|
+
throw error;
|
|
22310
|
+
}
|
|
22311
|
+
}
|
|
22312
|
+
};
|
|
22003
22313
|
const connectTrustWallet = async (targetNetwork = null) => {
|
|
22004
22314
|
console.log("=== TRUST WALLET CONNECTION DEBUG ===");
|
|
22005
22315
|
console.log("Connecting to Trust Wallet for network:", targetNetwork);
|
|
@@ -22210,6 +22520,9 @@ const connectTronlinkWallet = async () => {
|
|
|
22210
22520
|
if (window.tronWeb.isTrust === true) {
|
|
22211
22521
|
throw new Error("Trust Wallet TRON detected instead of TronLink. Please switch to TronLink or use Trust Wallet option.");
|
|
22212
22522
|
}
|
|
22523
|
+
if (window.tronWeb.isBitget === true) {
|
|
22524
|
+
throw new Error("Bitget Wallet TRON detected instead of TronLink. Please switch to TronLink or use Bitget Wallet option.");
|
|
22525
|
+
}
|
|
22213
22526
|
const waitForTronWeb = async (maxAttempts = 10, interval = 500) => {
|
|
22214
22527
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
22215
22528
|
if (window.tronWeb && window.tronWeb.ready) {
|
|
@@ -22332,6 +22645,9 @@ const connectPhantomWallet = async () => {
|
|
|
22332
22645
|
if (phantomProvider.isTrust === true) {
|
|
22333
22646
|
throw new Error("Trust Wallet Solana detected instead of Phantom. Please switch to Phantom or use Trust Wallet option.");
|
|
22334
22647
|
}
|
|
22648
|
+
if (phantomProvider.isBitget === true) {
|
|
22649
|
+
throw new Error("Bitget Wallet Solana detected instead of Phantom. Please switch to Phantom or use Bitget Wallet option.");
|
|
22650
|
+
}
|
|
22335
22651
|
console.log("Found Phantom wallet provider:", phantomProvider);
|
|
22336
22652
|
try {
|
|
22337
22653
|
const response = await phantomProvider.connect();
|
|
@@ -22372,6 +22688,8 @@ const connectWallet = async (walletType, targetNetwork = null) => {
|
|
|
22372
22688
|
return connectLuteWallet();
|
|
22373
22689
|
case WALLET_TYPES.PHANTOM:
|
|
22374
22690
|
return connectPhantomWallet();
|
|
22691
|
+
case WALLET_TYPES.BITGET:
|
|
22692
|
+
return connectBitgetWallet(targetNetwork);
|
|
22375
22693
|
default:
|
|
22376
22694
|
throw new Error(`Unsupported wallet type: ${walletType}`);
|
|
22377
22695
|
}
|
|
@@ -22395,6 +22713,7 @@ const sendNativeTransaction = async (walletConnection, toAddress, amount) => {
|
|
|
22395
22713
|
switch (walletConnection.walletType) {
|
|
22396
22714
|
case WALLET_TYPES.METAMASK:
|
|
22397
22715
|
case WALLET_TYPES.TRUST_WALLET:
|
|
22716
|
+
case WALLET_TYPES.BITGET:
|
|
22398
22717
|
const provider = walletConnection.provider;
|
|
22399
22718
|
const signer = await provider.getSigner();
|
|
22400
22719
|
const amountInEther = amount.toString();
|
|
@@ -22522,10 +22841,10 @@ const validateTransactionAmount = (amount, currency, network) => {
|
|
|
22522
22841
|
console.log("Network:", network);
|
|
22523
22842
|
if (currency === "SOL" && amountFloat > 1) {
|
|
22524
22843
|
const estimatedUSDValue = amountFloat * 100;
|
|
22525
|
-
console.warn(`⚠️ Large SOL transaction: ${amountFloat} SOL (
|
|
22844
|
+
console.warn(`⚠️ Large SOL transaction: ${amountFloat} SOL (~${estimatedUSDValue})`);
|
|
22526
22845
|
return {
|
|
22527
22846
|
isLarge: true,
|
|
22528
|
-
warning: `You are about to send ${amountFloat} SOL (approximately
|
|
22847
|
+
warning: `You are about to send ${amountFloat} SOL (approximately ${estimatedUSDValue}). Please confirm this is correct.`
|
|
22529
22848
|
};
|
|
22530
22849
|
}
|
|
22531
22850
|
if (["USDC", "USDT"].includes(currency) && amountFloat > 100) {
|
|
@@ -22603,6 +22922,14 @@ const sendTokenTransaction = async (walletConnection, tokenConfig, toAddress, am
|
|
|
22603
22922
|
} else {
|
|
22604
22923
|
return sendERC20Transaction(walletConnection, tokenConfig, toAddress, amount);
|
|
22605
22924
|
}
|
|
22925
|
+
case WALLET_TYPES.BITGET:
|
|
22926
|
+
if (walletConnection.network === NETWORK_TYPES.SOLANA) {
|
|
22927
|
+
return sendSolanaTokenTransaction(walletConnection, tokenConfig, toAddress, amount);
|
|
22928
|
+
} else if (walletConnection.network === NETWORK_TYPES.TRON) {
|
|
22929
|
+
return sendTRC20Transaction(walletConnection, tokenConfig, toAddress, amount);
|
|
22930
|
+
} else {
|
|
22931
|
+
return sendERC20Transaction(walletConnection, tokenConfig, toAddress, amount);
|
|
22932
|
+
}
|
|
22606
22933
|
default:
|
|
22607
22934
|
return sendERC20Transaction(walletConnection, tokenConfig, toAddress, amount);
|
|
22608
22935
|
}
|
|
@@ -22752,7 +23079,15 @@ const sendERC20Transaction = async (walletConnection, tokenConfig, toAddress, am
|
|
|
22752
23079
|
const gasEstimate = await tokenContract.transfer.estimateGas(toAddress, tokenUnits);
|
|
22753
23080
|
console.log("Gas estimate:", gasEstimate.toString());
|
|
22754
23081
|
let gasMultiplier;
|
|
22755
|
-
if (walletConnection.walletType === WALLET_TYPES.
|
|
23082
|
+
if (walletConnection.walletType === WALLET_TYPES.BITGET) {
|
|
23083
|
+
if (symbol === "USDC") {
|
|
23084
|
+
gasMultiplier = BigInt(160);
|
|
23085
|
+
} else if (symbol === "USDT") {
|
|
23086
|
+
gasMultiplier = BigInt(140);
|
|
23087
|
+
} else {
|
|
23088
|
+
gasMultiplier = BigInt(130);
|
|
23089
|
+
}
|
|
23090
|
+
} else if (walletConnection.walletType === WALLET_TYPES.TRUST_WALLET) {
|
|
22756
23091
|
if (symbol === "USDC") {
|
|
22757
23092
|
gasMultiplier = BigInt(160);
|
|
22758
23093
|
} else if (symbol === "USDT") {
|
|
@@ -22779,7 +23114,15 @@ const sendERC20Transaction = async (walletConnection, tokenConfig, toAddress, am
|
|
|
22779
23114
|
} catch (gasError) {
|
|
22780
23115
|
console.error("Gas estimation failed:", gasError);
|
|
22781
23116
|
let fixedGasLimit;
|
|
22782
|
-
if (walletConnection.walletType === WALLET_TYPES.
|
|
23117
|
+
if (walletConnection.walletType === WALLET_TYPES.BITGET) {
|
|
23118
|
+
if (symbol === "USDC") {
|
|
23119
|
+
fixedGasLimit = BigInt(22e4);
|
|
23120
|
+
} else if (symbol === "USDT") {
|
|
23121
|
+
fixedGasLimit = BigInt(2e5);
|
|
23122
|
+
} else {
|
|
23123
|
+
fixedGasLimit = BigInt(18e4);
|
|
23124
|
+
}
|
|
23125
|
+
} else if (walletConnection.walletType === WALLET_TYPES.TRUST_WALLET) {
|
|
22783
23126
|
if (symbol === "USDC") {
|
|
22784
23127
|
fixedGasLimit = BigInt(22e4);
|
|
22785
23128
|
} else if (symbol === "USDT") {
|
|
@@ -22921,8 +23264,8 @@ let apiConfig = {
|
|
|
22921
23264
|
apiKey: null,
|
|
22922
23265
|
apiSecret: null,
|
|
22923
23266
|
// apiUrl: 'https://coinleyserver-production.up.railway.app',
|
|
22924
|
-
apiUrl:
|
|
22925
|
-
|
|
23267
|
+
// apiUrl: 'https://hub.coinley.io',
|
|
23268
|
+
apiUrl: "http://localhost:9000",
|
|
22926
23269
|
merchantWalletAddresses: {},
|
|
22927
23270
|
authToken: null,
|
|
22928
23271
|
merchantFeePercentage: null,
|
|
@@ -24694,15 +25037,15 @@ const QRCode = ({
|
|
|
24694
25037
|
};
|
|
24695
25038
|
const getWalletSuggestions = (network2) => {
|
|
24696
25039
|
const suggestions = {
|
|
24697
|
-
ethereum: ["MetaMask", "Trust Wallet", "Coinbase Wallet"],
|
|
24698
|
-
bsc: ["MetaMask", "Trust Wallet", "SafePal"],
|
|
24699
|
-
tron: ["TronLink", "Trust Wallet"],
|
|
24700
|
-
//
|
|
25040
|
+
ethereum: ["MetaMask", "Trust Wallet", "Bitget Wallet", "Coinbase Wallet"],
|
|
25041
|
+
bsc: ["MetaMask", "Trust Wallet", "Bitget Wallet", "SafePal"],
|
|
25042
|
+
tron: ["TronLink", "Trust Wallet", "Bitget Wallet"],
|
|
25043
|
+
// Bitget Wallet supports TRON
|
|
24701
25044
|
algorand: ["Pera Wallet", "MyAlgo Wallet"],
|
|
24702
|
-
solana: ["Phantom", "Trust Wallet", "Solflare"]
|
|
24703
|
-
//
|
|
25045
|
+
solana: ["Phantom", "Trust Wallet", "Bitget Wallet", "Solflare"]
|
|
25046
|
+
// Bitget Wallet supports Solana
|
|
24704
25047
|
};
|
|
24705
|
-
return suggestions[network2.toLowerCase()] || ["MetaMask", "Trust Wallet"];
|
|
25048
|
+
return suggestions[network2.toLowerCase()] || ["MetaMask", "Trust Wallet", "Bitget Wallet"];
|
|
24706
25049
|
};
|
|
24707
25050
|
const copyToClipboard = async (text) => {
|
|
24708
25051
|
try {
|
|
@@ -24807,6 +25150,14 @@ const QRCode = ({
|
|
|
24807
25150
|
getNetworkDisplayName(network),
|
|
24808
25151
|
") and using the exact amount shown above."
|
|
24809
25152
|
] }) }),
|
|
25153
|
+
getWalletSuggestions(network).includes("Bitget Wallet") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 p-2 bg-green-50 border border-green-200 rounded", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-green-800", children: [
|
|
25154
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: "Bitget Wallet users:" }),
|
|
25155
|
+
" Bitget Wallet supports ",
|
|
25156
|
+
getNetworkDisplayName(network),
|
|
25157
|
+
" payments. Make sure you have the correct network selected in your Bitget Wallet app.",
|
|
25158
|
+
network.toLowerCase() === "solana" && " For Solana payments, use the built-in QR scanner or Solana Pay feature.",
|
|
25159
|
+
network.toLowerCase() === "tron" && " For TRON payments, the QR code will open directly in Bitget Wallet."
|
|
25160
|
+
] }) }),
|
|
24810
25161
|
getWalletSuggestions(network).includes("Trust Wallet") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 p-2 bg-green-50 border border-green-200 rounded", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-green-800", children: [
|
|
24811
25162
|
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: "Trust Wallet users:" }),
|
|
24812
25163
|
" Trust Wallet supports ",
|
|
@@ -25729,7 +26080,8 @@ const CoinleyModal = ({
|
|
|
25729
26080
|
[WALLET_TYPES.TRONLINK]: "TronLink",
|
|
25730
26081
|
[WALLET_TYPES.TRUST_WALLET]: "Trust Wallet",
|
|
25731
26082
|
[WALLET_TYPES.LUTE]: "Lute Wallet",
|
|
25732
|
-
[WALLET_TYPES.PHANTOM]: "Phantom"
|
|
26083
|
+
[WALLET_TYPES.PHANTOM]: "Phantom",
|
|
26084
|
+
[WALLET_TYPES.BITGET]: "Bitget Wallet"
|
|
25733
26085
|
};
|
|
25734
26086
|
return names2[walletType] || walletType;
|
|
25735
26087
|
};
|
|
@@ -25739,7 +26091,8 @@ const CoinleyModal = ({
|
|
|
25739
26091
|
[WALLET_TYPES.TRONLINK]: "https://www.tronlink.org/images/logo.png",
|
|
25740
26092
|
[WALLET_TYPES.TRUST_WALLET]: "https://trustwallet.com/assets/images/media/trust_platform.svg",
|
|
25741
26093
|
[WALLET_TYPES.LUTE]: "https://lute.app/logo.png",
|
|
25742
|
-
[WALLET_TYPES.PHANTOM]: "https://phantom.app/img/phantom-logo.png"
|
|
26094
|
+
[WALLET_TYPES.PHANTOM]: "https://phantom.app/img/phantom-logo.png",
|
|
26095
|
+
[WALLET_TYPES.BITGET]: "https://img.bitgetimg.com/multiplatform/web/web3/bitget-wallet-logo.png"
|
|
25743
26096
|
};
|
|
25744
26097
|
return icons[walletType] || "";
|
|
25745
26098
|
};
|