coinley-checkout 1.3.0 → 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.
|
@@ -22036,49 +22036,75 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
22036
22036
|
trustProvider = window.ethereum.providers.find((p2) => p2.isTrust === true || p2.isTrustWallet === true);
|
|
22037
22037
|
if (trustProvider) {
|
|
22038
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
|
+
}
|
|
22039
22045
|
}
|
|
22040
22046
|
} else if (window.trustwallet && window.trustwallet.ethereum) {
|
|
22041
22047
|
trustProvider = window.trustwallet.ethereum;
|
|
22042
22048
|
console.log("✅ Found Trust Wallet via global trustwallet object");
|
|
22043
|
-
} else if (window.ethereum && !window.ethereum.isMetaMask) {
|
|
22044
|
-
console.log("🔍
|
|
22045
|
-
|
|
22046
|
-
|
|
22047
|
-
|
|
22048
|
-
|
|
22049
|
-
|
|
22050
|
-
|
|
22051
|
-
|
|
22052
|
-
|
|
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;
|
|
22055
|
+
}
|
|
22056
|
+
if (!trustProvider) {
|
|
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
|
+
}
|
|
22053
22085
|
}
|
|
22054
|
-
} catch (testError) {
|
|
22055
|
-
console.log("❌ Test connection failed, might not be Trust Wallet");
|
|
22056
|
-
trustProvider = null;
|
|
22057
22086
|
}
|
|
22058
22087
|
}
|
|
22059
|
-
|
|
22060
|
-
|
|
22061
|
-
|
|
22062
|
-
|
|
22063
|
-
|
|
22064
|
-
|
|
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");
|
|
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
|
+
}
|
|
22070
22094
|
}
|
|
22071
22095
|
}
|
|
22072
|
-
console.log("🚀 Attempting to connect with Trust Wallet provider...");
|
|
22073
|
-
const accounts = await trustProvider.request({
|
|
22074
|
-
method: "eth_requestAccounts"
|
|
22075
|
-
});
|
|
22076
22096
|
if (!accounts || accounts.length === 0) {
|
|
22077
22097
|
throw new Error("No accounts found in Trust Wallet. Please create an account or unlock your wallet.");
|
|
22078
22098
|
}
|
|
22079
22099
|
const address = accounts[0];
|
|
22080
|
-
|
|
22081
|
-
|
|
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
|
+
}
|
|
22082
22108
|
switch (chainId) {
|
|
22083
22109
|
case 1:
|
|
22084
22110
|
networkType = NETWORK_TYPES.ETHEREUM;
|
|
@@ -22095,6 +22121,7 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
22095
22121
|
network: networkType,
|
|
22096
22122
|
chainId
|
|
22097
22123
|
});
|
|
22124
|
+
console.log("=== END TRUST WALLET CONNECTION DEBUG ===");
|
|
22098
22125
|
return {
|
|
22099
22126
|
walletType: WALLET_TYPES.TRUST_WALLET,
|
|
22100
22127
|
address,
|
|
@@ -22179,7 +22206,7 @@ const connectTrustWallet = async (targetNetwork = null) => {
|
|
|
22179
22206
|
throw new Error("Connection rejected by user. Please approve the connection in Trust Wallet.");
|
|
22180
22207
|
} else if (error.message.includes("locked")) {
|
|
22181
22208
|
throw new Error("Trust Wallet is locked. Please unlock your wallet and try again.");
|
|
22182
|
-
} else if (error.message.includes("install") || error.message.includes("not detected")) {
|
|
22209
|
+
} else if (error.message.includes("install") || error.message.includes("not detected") || error.message.includes("not found")) {
|
|
22183
22210
|
throw error;
|
|
22184
22211
|
} else {
|
|
22185
22212
|
throw new Error(`Failed to connect to Trust Wallet: ${error.message}`);
|