coinley-checkout 1.2.9 → 1.3.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.
|
@@ -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,32 +22001,110 @@ 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
|
+
} else {
|
|
22040
|
+
const nonMetaMaskProvider = window.ethereum.providers.find((p2) => !p2.isMetaMask);
|
|
22041
|
+
if (nonMetaMaskProvider) {
|
|
22042
|
+
trustProvider = nonMetaMaskProvider;
|
|
22043
|
+
console.log("✅ Found non-MetaMask provider, assuming it's Trust Wallet");
|
|
22044
|
+
}
|
|
22045
|
+
}
|
|
22046
|
+
} else if (window.trustwallet && window.trustwallet.ethereum) {
|
|
22047
|
+
trustProvider = window.trustwallet.ethereum;
|
|
22048
|
+
console.log("✅ Found Trust Wallet via global trustwallet object");
|
|
22049
|
+
} else if (window.ethereum && !window.ethereum.isMetaMask && !window.ethereum.isPhantom) {
|
|
22050
|
+
console.log("🔍 Single provider detected, not MetaMask or Phantom - assuming Trust Wallet");
|
|
22051
|
+
trustProvider = window.ethereum;
|
|
22052
|
+
} else if (window.ethereum) {
|
|
22053
|
+
console.log("🔍 Fallback strategy - testing main ethereum provider as Trust Wallet");
|
|
22054
|
+
trustProvider = window.ethereum;
|
|
21918
22055
|
}
|
|
21919
22056
|
if (!trustProvider) {
|
|
21920
|
-
throw new Error(
|
|
22057
|
+
throw new Error(`Trust Wallet provider not found. Available providers: ${window.ethereum.providers?.length || 1}. Please ensure Trust Wallet is properly installed and enabled.`);
|
|
22058
|
+
}
|
|
22059
|
+
console.log("🚀 Attempting to connect with Trust Wallet provider...");
|
|
22060
|
+
let accounts;
|
|
22061
|
+
try {
|
|
22062
|
+
accounts = await trustProvider.request({
|
|
22063
|
+
method: "eth_requestAccounts"
|
|
22064
|
+
});
|
|
22065
|
+
} catch (requestError) {
|
|
22066
|
+
console.log("❌ Connection attempt failed:", requestError);
|
|
22067
|
+
if (window.ethereum.providers && window.ethereum.providers.length > 1) {
|
|
22068
|
+
console.log("🔄 Trying alternative providers...");
|
|
22069
|
+
for (let i = 0; i < window.ethereum.providers.length; i++) {
|
|
22070
|
+
const altProvider = window.ethereum.providers[i];
|
|
22071
|
+
if (altProvider !== trustProvider) {
|
|
22072
|
+
try {
|
|
22073
|
+
console.log(`🔍 Testing provider ${i}...`);
|
|
22074
|
+
const altAccounts = await altProvider.request({ method: "eth_requestAccounts" });
|
|
22075
|
+
if (altAccounts && altAccounts.length > 0) {
|
|
22076
|
+
trustProvider = altProvider;
|
|
22077
|
+
accounts = altAccounts;
|
|
22078
|
+
console.log(`✅ Alternative provider ${i} worked!`);
|
|
22079
|
+
break;
|
|
22080
|
+
}
|
|
22081
|
+
} catch (altError) {
|
|
22082
|
+
console.log(`❌ Alternative provider ${i} failed:`, altError.message);
|
|
22083
|
+
continue;
|
|
22084
|
+
}
|
|
22085
|
+
}
|
|
22086
|
+
}
|
|
22087
|
+
}
|
|
22088
|
+
if (!accounts) {
|
|
22089
|
+
if (requestError.code === 4001) {
|
|
22090
|
+
throw new Error("Connection rejected by user. Please approve the connection in Trust Wallet.");
|
|
22091
|
+
} else {
|
|
22092
|
+
throw new Error(`Failed to connect to Trust Wallet: ${requestError.message}. Please make sure Trust Wallet is unlocked and try again.`);
|
|
22093
|
+
}
|
|
22094
|
+
}
|
|
21921
22095
|
}
|
|
21922
|
-
console.log("Found Trust Wallet Ethereum provider");
|
|
21923
|
-
const accounts = await trustProvider.request({ method: "eth_requestAccounts" });
|
|
21924
22096
|
if (!accounts || accounts.length === 0) {
|
|
21925
|
-
throw new Error("No accounts found");
|
|
22097
|
+
throw new Error("No accounts found in Trust Wallet. Please create an account or unlock your wallet.");
|
|
21926
22098
|
}
|
|
21927
22099
|
const address = accounts[0];
|
|
21928
|
-
|
|
21929
|
-
|
|
22100
|
+
let chainIdHex, chainId;
|
|
22101
|
+
try {
|
|
22102
|
+
chainIdHex = await trustProvider.request({ method: "eth_chainId" });
|
|
22103
|
+
chainId = parseInt(chainIdHex, 16);
|
|
22104
|
+
} catch (chainError) {
|
|
22105
|
+
console.warn("Could not get chain ID:", chainError);
|
|
22106
|
+
chainId = 1;
|
|
22107
|
+
}
|
|
21930
22108
|
switch (chainId) {
|
|
21931
22109
|
case 1:
|
|
21932
22110
|
networkType = NETWORK_TYPES.ETHEREUM;
|
|
@@ -21938,6 +22116,12 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
21938
22116
|
networkType = `unknown-${chainId}`;
|
|
21939
22117
|
}
|
|
21940
22118
|
const web3Provider = new BrowserProvider(trustProvider);
|
|
22119
|
+
console.log("✅ Trust Wallet connected successfully:", {
|
|
22120
|
+
address,
|
|
22121
|
+
network: networkType,
|
|
22122
|
+
chainId
|
|
22123
|
+
});
|
|
22124
|
+
console.log("=== END TRUST WALLET CONNECTION DEBUG ===");
|
|
21941
22125
|
return {
|
|
21942
22126
|
walletType: WALLET_TYPES.TRUST_WALLET,
|
|
21943
22127
|
address,
|
|
@@ -21949,7 +22133,7 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
21949
22133
|
};
|
|
21950
22134
|
} else if (networkType === NETWORK_TYPES.TRON) {
|
|
21951
22135
|
if (!window.tronWeb) {
|
|
21952
|
-
throw new Error("TronWeb not found. Please install Trust Wallet with TRON support.");
|
|
22136
|
+
throw new Error("TronWeb not found. Please install Trust Wallet with TRON support or use Trust Wallet mobile app.");
|
|
21953
22137
|
}
|
|
21954
22138
|
if (window.tronWeb.isTrust !== true && !window.trustwallet) {
|
|
21955
22139
|
console.warn("TronWeb detected but may not be from Trust Wallet");
|
|
@@ -21993,7 +22177,7 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
21993
22177
|
solanaProvider = window.solana;
|
|
21994
22178
|
}
|
|
21995
22179
|
if (!solanaProvider) {
|
|
21996
|
-
throw new Error("Trust Wallet Solana provider not found. Please install Trust Wallet with Solana support.");
|
|
22180
|
+
throw new Error("Trust Wallet Solana provider not found. Please install Trust Wallet with Solana support or use Trust Wallet mobile app.");
|
|
21997
22181
|
}
|
|
21998
22182
|
console.log("Found Trust Wallet Solana provider");
|
|
21999
22183
|
const response = await solanaProvider.connect();
|
|
@@ -22015,13 +22199,17 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
22015
22199
|
throw new Error(`Trust Wallet does not support network: ${networkType}`);
|
|
22016
22200
|
}
|
|
22017
22201
|
} catch (error) {
|
|
22018
|
-
console.error("
|
|
22202
|
+
console.error("=== TRUST WALLET CONNECTION ERROR ===");
|
|
22203
|
+
console.error("Error details:", error);
|
|
22204
|
+
console.log("=== END TRUST WALLET CONNECTION DEBUG ===");
|
|
22019
22205
|
if (error.code === 4001 || error.message.includes("rejected")) {
|
|
22020
22206
|
throw new Error("Connection rejected by user. Please approve the connection in Trust Wallet.");
|
|
22021
22207
|
} else if (error.message.includes("locked")) {
|
|
22022
22208
|
throw new Error("Trust Wallet is locked. Please unlock your wallet and try again.");
|
|
22023
|
-
} else {
|
|
22209
|
+
} else if (error.message.includes("install") || error.message.includes("not detected") || error.message.includes("not found")) {
|
|
22024
22210
|
throw error;
|
|
22211
|
+
} else {
|
|
22212
|
+
throw new Error(`Failed to connect to Trust Wallet: ${error.message}`);
|
|
22025
22213
|
}
|
|
22026
22214
|
}
|
|
22027
22215
|
};
|