coinley-checkout 1.2.4 → 1.2.5
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.
|
@@ -17967,6 +17967,23 @@ _providerInfo = new WeakMap();
|
|
|
17967
17967
|
let BrowserProvider = _BrowserProvider;
|
|
17968
17968
|
let Connection, PublicKey, Transaction, SystemProgram, LAMPORTS_PER_SOL;
|
|
17969
17969
|
let createTransferInstruction, getAssociatedTokenAddress, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID;
|
|
17970
|
+
const createSolanaConnection = async () => {
|
|
17971
|
+
const config = NETWORK_CONFIG[NETWORK_TYPES.SOLANA];
|
|
17972
|
+
const urls = [config.rpcUrl, ...config.fallbackRpcUrls || []];
|
|
17973
|
+
for (const url of urls) {
|
|
17974
|
+
try {
|
|
17975
|
+
console.log(`Trying Solana RPC: ${url}`);
|
|
17976
|
+
const connection = new Connection(url, "confirmed");
|
|
17977
|
+
await connection.getLatestBlockhash();
|
|
17978
|
+
console.log(`✅ Successfully connected to Solana RPC: ${url}`);
|
|
17979
|
+
return connection;
|
|
17980
|
+
} catch (error) {
|
|
17981
|
+
console.warn(`❌ Failed to connect to ${url}:`, error.message);
|
|
17982
|
+
continue;
|
|
17983
|
+
}
|
|
17984
|
+
}
|
|
17985
|
+
throw new Error("Failed to connect to any Solana RPC endpoint. Please try again later.");
|
|
17986
|
+
};
|
|
17970
17987
|
const initializeSolanaLibraries = async () => {
|
|
17971
17988
|
try {
|
|
17972
17989
|
if (!Connection) {
|
|
@@ -18041,7 +18058,12 @@ const NETWORK_CONFIG = {
|
|
|
18041
18058
|
name: "Solana Mainnet",
|
|
18042
18059
|
symbol: "SOL",
|
|
18043
18060
|
decimals: 9,
|
|
18044
|
-
rpcUrl: "https://
|
|
18061
|
+
rpcUrl: "https://rpc.ankr.com/solana",
|
|
18062
|
+
fallbackRpcUrls: [
|
|
18063
|
+
"https://solana-api.projectserum.com",
|
|
18064
|
+
"https://api.mainnet-beta.solana.com",
|
|
18065
|
+
"https://solana-mainnet.g.alchemy.com/v2/demo"
|
|
18066
|
+
],
|
|
18045
18067
|
blockExplorerUrl: "https://explorer.solana.com"
|
|
18046
18068
|
}
|
|
18047
18069
|
};
|
|
@@ -18645,7 +18667,7 @@ const sendNativeTransaction = async (walletConnection, toAddress, amount) => {
|
|
|
18645
18667
|
walletType: "Phantom Native SOL"
|
|
18646
18668
|
});
|
|
18647
18669
|
try {
|
|
18648
|
-
const connection =
|
|
18670
|
+
const connection = await createSolanaConnection();
|
|
18649
18671
|
const fromPubkey = walletConnection.publicKey;
|
|
18650
18672
|
const toPubkey = new PublicKey(toAddress);
|
|
18651
18673
|
const lamports = Math.floor(amountFloat * LAMPORTS_PER_SOL);
|
|
@@ -18774,7 +18796,7 @@ const sendSolanaTokenTransaction = async (walletConnection, tokenConfig, toAddre
|
|
|
18774
18796
|
throw new Error(`Amount too small: ${tokenAmount} ${symbol} is smaller than the minimum unit`);
|
|
18775
18797
|
}
|
|
18776
18798
|
try {
|
|
18777
|
-
const connection =
|
|
18799
|
+
const connection = await createSolanaConnection();
|
|
18778
18800
|
const fromPubkey = walletConnection.publicKey;
|
|
18779
18801
|
const toPubkey = new PublicKey(toAddress);
|
|
18780
18802
|
const mintPubkey = new PublicKey(contractAddress);
|