coinley-checkout 1.2.9 → 1.3.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.
|
@@ -21673,36 +21673,110 @@ const createSolanaConnection = async () => {
|
|
|
21673
21673
|
const detectTrustWallet = () => {
|
|
21674
21674
|
if (typeof window === "undefined")
|
|
21675
21675
|
return false;
|
|
21676
|
+
console.log("=== TRUST WALLET DETECTION DEBUG ===");
|
|
21677
|
+
if (window.ethereum) {
|
|
21678
|
+
console.log("window.ethereum exists:", {
|
|
21679
|
+
isMetaMask: window.ethereum.isMetaMask,
|
|
21680
|
+
isTrust: window.ethereum.isTrust,
|
|
21681
|
+
isTrustWallet: window.ethereum.isTrustWallet,
|
|
21682
|
+
providers: window.ethereum.providers?.length || 0,
|
|
21683
|
+
chainId: window.ethereum.chainId
|
|
21684
|
+
});
|
|
21685
|
+
if (window.ethereum.providers) {
|
|
21686
|
+
console.log("Multiple providers detected:", window.ethereum.providers.map((p2) => ({
|
|
21687
|
+
isMetaMask: p2.isMetaMask,
|
|
21688
|
+
isTrust: p2.isTrust,
|
|
21689
|
+
isTrustWallet: p2.isTrustWallet
|
|
21690
|
+
})));
|
|
21691
|
+
}
|
|
21692
|
+
}
|
|
21693
|
+
console.log("Trust Wallet globals:", {
|
|
21694
|
+
trustwallet: Boolean(window.trustwallet),
|
|
21695
|
+
trust: Boolean(window.trust),
|
|
21696
|
+
isTrustWallet: Boolean(window.isTrustWallet)
|
|
21697
|
+
});
|
|
21676
21698
|
const trustDetectionMethods = [
|
|
21677
|
-
// Method 1:
|
|
21678
|
-
() =>
|
|
21679
|
-
|
|
21680
|
-
|
|
21681
|
-
|
|
21682
|
-
|
|
21683
|
-
// Method
|
|
21684
|
-
() =>
|
|
21685
|
-
|
|
21686
|
-
|
|
21687
|
-
|
|
21688
|
-
|
|
21689
|
-
// Method
|
|
21690
|
-
() =>
|
|
21691
|
-
|
|
21692
|
-
|
|
21693
|
-
|
|
21694
|
-
|
|
21695
|
-
// Method
|
|
21696
|
-
() =>
|
|
21699
|
+
// Method 1: Direct Trust Wallet identifier
|
|
21700
|
+
() => {
|
|
21701
|
+
const result = window.ethereum && window.ethereum.isTrust === true;
|
|
21702
|
+
console.log("Method 1 (ethereum.isTrust):", result);
|
|
21703
|
+
return result;
|
|
21704
|
+
},
|
|
21705
|
+
// Method 2: TrustWallet global object
|
|
21706
|
+
() => {
|
|
21707
|
+
const result = window.trustwallet !== void 0;
|
|
21708
|
+
console.log("Method 2 (window.trustwallet):", result);
|
|
21709
|
+
return result;
|
|
21710
|
+
},
|
|
21711
|
+
// Method 3: Trust Wallet mobile/extension interface
|
|
21712
|
+
() => {
|
|
21713
|
+
const result = window.ethereum && window.ethereum.isTrustWallet === true;
|
|
21714
|
+
console.log("Method 3 (ethereum.isTrustWallet):", result);
|
|
21715
|
+
return result;
|
|
21716
|
+
},
|
|
21717
|
+
// Method 4: Provider array detection
|
|
21718
|
+
() => {
|
|
21719
|
+
const result = window.ethereum && window.ethereum.providers && window.ethereum.providers.some((p2) => p2.isTrust === true || p2.isTrustWallet === true);
|
|
21720
|
+
console.log("Method 4 (providers array):", result);
|
|
21721
|
+
return result;
|
|
21722
|
+
},
|
|
21723
|
+
// Method 5: Trust Wallet as primary provider when no MetaMask
|
|
21724
|
+
() => {
|
|
21725
|
+
const result = window.ethereum && !window.ethereum.isMetaMask && window.ethereum.request && window.ethereum.isTrust !== false;
|
|
21726
|
+
console.log("Method 5 (primary provider, not MetaMask):", result);
|
|
21727
|
+
return result;
|
|
21728
|
+
},
|
|
21729
|
+
// Method 6: Check for Trust Wallet specific methods/properties
|
|
21730
|
+
() => {
|
|
21731
|
+
const result = window.ethereum && (typeof window.ethereum.isTrust === "boolean" || window.ethereum._trustwallet || window.ethereum.trustWallet);
|
|
21732
|
+
console.log("Method 6 (Trust Wallet specific properties):", result);
|
|
21733
|
+
return result;
|
|
21734
|
+
},
|
|
21735
|
+
// Method 7: User agent detection (for mobile web)
|
|
21736
|
+
() => {
|
|
21737
|
+
const result = /TrustWallet/i.test(navigator.userAgent);
|
|
21738
|
+
console.log("Method 7 (user agent):", result);
|
|
21739
|
+
return result;
|
|
21740
|
+
},
|
|
21741
|
+
// Method 8: DOM element detection
|
|
21742
|
+
() => {
|
|
21743
|
+
const result = document.querySelector('[data-wallet="trustwallet"]') !== null || document.querySelector("#trustwallet-extension") !== null;
|
|
21744
|
+
console.log("Method 8 (DOM elements):", result);
|
|
21745
|
+
return result;
|
|
21746
|
+
},
|
|
21747
|
+
// Method 9: Check for Trust Wallet via window.trust
|
|
21748
|
+
() => {
|
|
21749
|
+
const result = window.trust !== void 0;
|
|
21750
|
+
console.log("Method 9 (window.trust):", result);
|
|
21751
|
+
return result;
|
|
21752
|
+
},
|
|
21753
|
+
// Method 10: Advanced provider detection
|
|
21754
|
+
() => {
|
|
21755
|
+
if (!window.ethereum)
|
|
21756
|
+
return false;
|
|
21757
|
+
const hasTrustFeatures = (
|
|
21758
|
+
// Not MetaMask and not other known wallets
|
|
21759
|
+
!window.ethereum.isMetaMask && !window.ethereum.isPhantom && !window.ethereum.isFrame && // Has ethereum methods but could be Trust Wallet
|
|
21760
|
+
window.ethereum.request && window.ethereum.on && // Check for Trust Wallet specific patterns
|
|
21761
|
+
(window.ethereum.chainId || window.ethereum.networkVersion)
|
|
21762
|
+
);
|
|
21763
|
+
console.log("Method 10 (advanced detection):", hasTrustFeatures);
|
|
21764
|
+
return hasTrustFeatures;
|
|
21765
|
+
}
|
|
21697
21766
|
];
|
|
21698
|
-
|
|
21767
|
+
const detectionResults = trustDetectionMethods.map((method, index) => {
|
|
21699
21768
|
try {
|
|
21700
21769
|
return method();
|
|
21701
21770
|
} catch (error) {
|
|
21702
|
-
console.warn(
|
|
21771
|
+
console.warn(`Trust Wallet detection method ${index + 1} failed:`, error);
|
|
21703
21772
|
return false;
|
|
21704
21773
|
}
|
|
21705
21774
|
});
|
|
21775
|
+
const isDetected = detectionResults.some((result) => result === true);
|
|
21776
|
+
console.log("Detection results:", detectionResults);
|
|
21777
|
+
console.log("Final Trust Wallet detection result:", isDetected);
|
|
21778
|
+
console.log("=== END TRUST WALLET DETECTION DEBUG ===");
|
|
21779
|
+
return isDetected;
|
|
21706
21780
|
};
|
|
21707
21781
|
const detectLuteWallet = () => {
|
|
21708
21782
|
if (typeof window === "undefined")
|
|
@@ -21825,14 +21899,27 @@ const debugWalletEnvironment = () => {
|
|
|
21825
21899
|
console.log("solana:", typeof window !== "undefined" ? Boolean(window.solana) : "Not in browser");
|
|
21826
21900
|
console.log("phantom:", typeof window !== "undefined" ? Boolean(window.phantom) : "Not in browser");
|
|
21827
21901
|
console.log("trustwallet:", typeof window !== "undefined" ? Boolean(window.trustwallet) : "Not in browser");
|
|
21902
|
+
console.log("trust:", typeof window !== "undefined" ? Boolean(window.trust) : "Not in browser");
|
|
21828
21903
|
if (typeof window !== "undefined" && window.ethereum) {
|
|
21829
21904
|
console.log("ethereum details:", {
|
|
21830
21905
|
isMetaMask: window.ethereum.isMetaMask,
|
|
21831
21906
|
isTrust: window.ethereum.isTrust,
|
|
21832
21907
|
isTrustWallet: window.ethereum.isTrustWallet,
|
|
21833
21908
|
chainId: window.ethereum.chainId,
|
|
21834
|
-
providers: window.ethereum.providers?.length || 0
|
|
21909
|
+
providers: window.ethereum.providers?.length || 0,
|
|
21910
|
+
selectedAddress: window.ethereum.selectedAddress
|
|
21835
21911
|
});
|
|
21912
|
+
if (window.ethereum.providers && window.ethereum.providers.length > 0) {
|
|
21913
|
+
console.log("All providers:");
|
|
21914
|
+
window.ethereum.providers.forEach((provider, index) => {
|
|
21915
|
+
console.log(`Provider ${index}:`, {
|
|
21916
|
+
isMetaMask: provider.isMetaMask,
|
|
21917
|
+
isTrust: provider.isTrust,
|
|
21918
|
+
isTrustWallet: provider.isTrustWallet,
|
|
21919
|
+
selectedAddress: provider.selectedAddress
|
|
21920
|
+
});
|
|
21921
|
+
});
|
|
21922
|
+
}
|
|
21836
21923
|
}
|
|
21837
21924
|
if (typeof window !== "undefined" && window.tronWeb) {
|
|
21838
21925
|
console.log("tronWeb details:", {
|
|
@@ -21853,13 +21940,26 @@ const debugWalletEnvironment = () => {
|
|
|
21853
21940
|
if (typeof window !== "undefined") {
|
|
21854
21941
|
console.log("All window wallet properties:");
|
|
21855
21942
|
const walletProps = Object.keys(window).filter(
|
|
21856
|
-
(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")
|
|
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")
|
|
21857
21944
|
);
|
|
21858
21945
|
console.log("Potential wallet properties:", walletProps);
|
|
21946
|
+
console.log("Trust Wallet specific checks:", {
|
|
21947
|
+
"window.trustwallet": Boolean(window.trustwallet),
|
|
21948
|
+
"window.trust": Boolean(window.trust),
|
|
21949
|
+
"window.isTrustWallet": Boolean(window.isTrustWallet),
|
|
21950
|
+
"document trust elements": document.querySelectorAll('[id*="trust"], [class*="trust"]').length
|
|
21951
|
+
});
|
|
21859
21952
|
}
|
|
21953
|
+
console.log("=== DETECTION RESULTS ===");
|
|
21860
21954
|
const wallets = detectWallets();
|
|
21861
|
-
console.log("
|
|
21955
|
+
console.log("Final detection results:", wallets);
|
|
21956
|
+
console.log("Trust Wallet specific detection result:", detectTrustWallet());
|
|
21862
21957
|
console.log("=== END WALLET ENVIRONMENT DEBUG ===");
|
|
21958
|
+
return {
|
|
21959
|
+
wallets,
|
|
21960
|
+
ethereum: typeof window !== "undefined" ? window.ethereum : null,
|
|
21961
|
+
trustWalletDetected: typeof window !== "undefined" ? detectTrustWallet() : false
|
|
21962
|
+
};
|
|
21863
21963
|
};
|
|
21864
21964
|
const connectMetamaskWallet = async () => {
|
|
21865
21965
|
console.log("Connecting to MetaMask wallet...");
|
|
@@ -21901,28 +22001,80 @@ const connectMetamaskWallet = async () => {
|
|
|
21901
22001
|
}
|
|
21902
22002
|
};
|
|
21903
22003
|
const connectTrustWallet = async (targetNetwork = null) => {
|
|
22004
|
+
console.log("=== TRUST WALLET CONNECTION DEBUG ===");
|
|
21904
22005
|
console.log("Connecting to Trust Wallet for network:", targetNetwork);
|
|
22006
|
+
let trustProvider = null;
|
|
21905
22007
|
let networkType = targetNetwork || NETWORK_TYPES.ETHEREUM;
|
|
22008
|
+
if (window.ethereum) {
|
|
22009
|
+
console.log("Available ethereum providers:", {
|
|
22010
|
+
main: {
|
|
22011
|
+
isMetaMask: window.ethereum.isMetaMask,
|
|
22012
|
+
isTrust: window.ethereum.isTrust,
|
|
22013
|
+
isTrustWallet: window.ethereum.isTrustWallet,
|
|
22014
|
+
providers: window.ethereum.providers?.length || 0
|
|
22015
|
+
}
|
|
22016
|
+
});
|
|
22017
|
+
if (window.ethereum.providers) {
|
|
22018
|
+
window.ethereum.providers.forEach((provider, index) => {
|
|
22019
|
+
console.log(`Provider ${index}:`, {
|
|
22020
|
+
isMetaMask: provider.isMetaMask,
|
|
22021
|
+
isTrust: provider.isTrust,
|
|
22022
|
+
isTrustWallet: provider.isTrustWallet
|
|
22023
|
+
});
|
|
22024
|
+
});
|
|
22025
|
+
}
|
|
22026
|
+
}
|
|
21906
22027
|
try {
|
|
21907
22028
|
if (networkType === NETWORK_TYPES.ETHEREUM || networkType === NETWORK_TYPES.BSC) {
|
|
21908
22029
|
if (!window.ethereum) {
|
|
21909
|
-
throw new Error("Ethereum provider
|
|
22030
|
+
throw new Error("No Ethereum provider found. Please install Trust Wallet browser extension.");
|
|
21910
22031
|
}
|
|
21911
|
-
let trustProvider = null;
|
|
21912
22032
|
if (window.ethereum.isTrust === true || window.ethereum.isTrustWallet === true) {
|
|
21913
22033
|
trustProvider = window.ethereum;
|
|
21914
|
-
|
|
21915
|
-
|
|
21916
|
-
|
|
21917
|
-
trustProvider
|
|
22034
|
+
console.log("✅ Found Trust Wallet via direct detection");
|
|
22035
|
+
} else if (window.ethereum.providers && window.ethereum.providers.length > 0) {
|
|
22036
|
+
trustProvider = window.ethereum.providers.find((p2) => p2.isTrust === true || p2.isTrustWallet === true);
|
|
22037
|
+
if (trustProvider) {
|
|
22038
|
+
console.log("✅ Found Trust Wallet in providers array");
|
|
22039
|
+
}
|
|
22040
|
+
} else if (window.trustwallet && window.trustwallet.ethereum) {
|
|
22041
|
+
trustProvider = window.trustwallet.ethereum;
|
|
22042
|
+
console.log("✅ Found Trust Wallet via global trustwallet object");
|
|
22043
|
+
} else if (window.ethereum && !window.ethereum.isMetaMask) {
|
|
22044
|
+
console.log("🔍 Checking if non-MetaMask provider is Trust Wallet...");
|
|
22045
|
+
const couldBeTrustWallet = window.ethereum.request && window.ethereum.on && typeof window.ethereum.isTrust !== "boolean" || window.ethereum.isTrust !== false;
|
|
22046
|
+
if (couldBeTrustWallet) {
|
|
22047
|
+
trustProvider = window.ethereum;
|
|
22048
|
+
console.log("✅ Assuming non-MetaMask provider is Trust Wallet");
|
|
22049
|
+
try {
|
|
22050
|
+
const accounts2 = await window.ethereum.request({ method: "eth_requestAccounts" });
|
|
22051
|
+
if (accounts2 && accounts2.length > 0) {
|
|
22052
|
+
console.log("✅ Connection successful, confirming this is Trust Wallet");
|
|
22053
|
+
}
|
|
22054
|
+
} catch (testError) {
|
|
22055
|
+
console.log("❌ Test connection failed, might not be Trust Wallet");
|
|
22056
|
+
trustProvider = null;
|
|
22057
|
+
}
|
|
22058
|
+
}
|
|
21918
22059
|
}
|
|
21919
22060
|
if (!trustProvider) {
|
|
21920
|
-
|
|
22061
|
+
const detectionResult = detectTrustWallet();
|
|
22062
|
+
if (detectionResult) {
|
|
22063
|
+
throw new Error(`Trust Wallet was detected but couldn't establish connection. Please:
|
|
22064
|
+
1. Make sure Trust Wallet browser extension is enabled
|
|
22065
|
+
2. Refresh the page and try again
|
|
22066
|
+
3. If you have multiple wallets, disable others temporarily
|
|
22067
|
+
4. Check if Trust Wallet is set as the default Web3 provider`);
|
|
22068
|
+
} else {
|
|
22069
|
+
throw new Error("Trust Wallet not detected. Please install the Trust Wallet browser extension from https://trustwallet.com/browser-extension");
|
|
22070
|
+
}
|
|
21921
22071
|
}
|
|
21922
|
-
console.log("
|
|
21923
|
-
const accounts = await trustProvider.request({
|
|
22072
|
+
console.log("🚀 Attempting to connect with Trust Wallet provider...");
|
|
22073
|
+
const accounts = await trustProvider.request({
|
|
22074
|
+
method: "eth_requestAccounts"
|
|
22075
|
+
});
|
|
21924
22076
|
if (!accounts || accounts.length === 0) {
|
|
21925
|
-
throw new Error("No accounts found");
|
|
22077
|
+
throw new Error("No accounts found in Trust Wallet. Please create an account or unlock your wallet.");
|
|
21926
22078
|
}
|
|
21927
22079
|
const address = accounts[0];
|
|
21928
22080
|
const chainIdHex = await trustProvider.request({ method: "eth_chainId" });
|
|
@@ -21938,6 +22090,11 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
21938
22090
|
networkType = `unknown-${chainId}`;
|
|
21939
22091
|
}
|
|
21940
22092
|
const web3Provider = new BrowserProvider(trustProvider);
|
|
22093
|
+
console.log("✅ Trust Wallet connected successfully:", {
|
|
22094
|
+
address,
|
|
22095
|
+
network: networkType,
|
|
22096
|
+
chainId
|
|
22097
|
+
});
|
|
21941
22098
|
return {
|
|
21942
22099
|
walletType: WALLET_TYPES.TRUST_WALLET,
|
|
21943
22100
|
address,
|
|
@@ -21949,7 +22106,7 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
21949
22106
|
};
|
|
21950
22107
|
} else if (networkType === NETWORK_TYPES.TRON) {
|
|
21951
22108
|
if (!window.tronWeb) {
|
|
21952
|
-
throw new Error("TronWeb not found. Please install Trust Wallet with TRON support.");
|
|
22109
|
+
throw new Error("TronWeb not found. Please install Trust Wallet with TRON support or use Trust Wallet mobile app.");
|
|
21953
22110
|
}
|
|
21954
22111
|
if (window.tronWeb.isTrust !== true && !window.trustwallet) {
|
|
21955
22112
|
console.warn("TronWeb detected but may not be from Trust Wallet");
|
|
@@ -21993,7 +22150,7 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
21993
22150
|
solanaProvider = window.solana;
|
|
21994
22151
|
}
|
|
21995
22152
|
if (!solanaProvider) {
|
|
21996
|
-
throw new Error("Trust Wallet Solana provider not found. Please install Trust Wallet with Solana support.");
|
|
22153
|
+
throw new Error("Trust Wallet Solana provider not found. Please install Trust Wallet with Solana support or use Trust Wallet mobile app.");
|
|
21997
22154
|
}
|
|
21998
22155
|
console.log("Found Trust Wallet Solana provider");
|
|
21999
22156
|
const response = await solanaProvider.connect();
|
|
@@ -22015,13 +22172,17 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
22015
22172
|
throw new Error(`Trust Wallet does not support network: ${networkType}`);
|
|
22016
22173
|
}
|
|
22017
22174
|
} catch (error) {
|
|
22018
|
-
console.error("
|
|
22175
|
+
console.error("=== TRUST WALLET CONNECTION ERROR ===");
|
|
22176
|
+
console.error("Error details:", error);
|
|
22177
|
+
console.log("=== END TRUST WALLET CONNECTION DEBUG ===");
|
|
22019
22178
|
if (error.code === 4001 || error.message.includes("rejected")) {
|
|
22020
22179
|
throw new Error("Connection rejected by user. Please approve the connection in Trust Wallet.");
|
|
22021
22180
|
} else if (error.message.includes("locked")) {
|
|
22022
22181
|
throw new Error("Trust Wallet is locked. Please unlock your wallet and try again.");
|
|
22023
|
-
} else {
|
|
22182
|
+
} else if (error.message.includes("install") || error.message.includes("not detected")) {
|
|
22024
22183
|
throw error;
|
|
22184
|
+
} else {
|
|
22185
|
+
throw new Error(`Failed to connect to Trust Wallet: ${error.message}`);
|
|
22025
22186
|
}
|
|
22026
22187
|
}
|
|
22027
22188
|
};
|