coinley-test 0.0.53 → 0.0.54

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.
package/dist/index.esm.js CHANGED
@@ -2601,60 +2601,7 @@ const WalletSelector = ({
2601
2601
  const getAvailableWallets = () => {
2602
2602
  var _a;
2603
2603
  if (!selectedNetwork) return [];
2604
- const wallets = [];
2605
- const networkType = (_a = selectedNetwork.shortName) == null ? void 0 : _a.toLowerCase();
2606
- if (["ethereum", "bsc", "polygon", "arbitrum", "optimism", "avalanche"].includes(networkType)) {
2607
- wallets.push({
2608
- type: "metamask",
2609
- name: "MetaMask",
2610
- icon: "🦊",
2611
- description: "Recommended for Ethereum-based networks",
2612
- isInstalled: !!window.ethereum,
2613
- networks: ["ethereum", "bsc", "polygon", "arbitrum", "optimism", "avalanche"],
2614
- isPrimary: true
2615
- });
2616
- wallets.push({
2617
- type: "phantom",
2618
- name: "Phantom",
2619
- icon: "👻",
2620
- description: "Multi-chain wallet (also supports EVM)",
2621
- isInstalled: !!window.solana,
2622
- networks: ["ethereum", "bsc", "polygon", "solana"],
2623
- isAlternative: true
2624
- });
2625
- }
2626
- if (networkType === "solana") {
2627
- wallets.push({
2628
- type: "phantom",
2629
- name: "Phantom",
2630
- icon: "👻",
2631
- description: "Recommended for Solana network",
2632
- isInstalled: !!window.solana,
2633
- networks: ["solana"],
2634
- isPrimary: true
2635
- });
2636
- }
2637
- if (!["ethereum", "bsc", "polygon", "arbitrum", "optimism", "avalanche", "solana"].includes(networkType)) {
2638
- wallets.push({
2639
- type: "metamask",
2640
- name: "MetaMask",
2641
- icon: "🦊",
2642
- description: "Popular wallet for various networks",
2643
- isInstalled: !!window.ethereum,
2644
- networks: ["multiple"],
2645
- isAlternative: true
2646
- });
2647
- wallets.push({
2648
- type: "phantom",
2649
- name: "Phantom",
2650
- icon: "👻",
2651
- description: "Multi-chain wallet option",
2652
- isInstalled: !!window.solana,
2653
- networks: ["multiple"],
2654
- isAlternative: true
2655
- });
2656
- }
2657
- return wallets;
2604
+ (_a = selectedNetwork.shortName) == null ? void 0 : _a.toLowerCase();
2658
2605
  };
2659
2606
  const availableWallets = getAvailableWallets();
2660
2607
  const handleWalletClick = async (walletType) => {
@@ -3223,70 +3170,28 @@ const EnhancedSimpleCoinleyPayment = ({
3223
3170
  console.log(`🔄 Preparing ${selectedWalletType} transaction to:`, recipientAddress);
3224
3171
  let txParams;
3225
3172
  let txHash;
3226
- if (selectedWalletType === "phantom") {
3227
- if (selectedNetwork.shortName === "solana") {
3228
- console.log("🔄 Preparing Solana transaction with Phantom...");
3229
- const amount = selectedToken.contractAddress ? Math.floor(paymentData.totalAmount * Math.pow(10, selectedToken.decimals || 6)) : Math.floor(paymentData.totalAmount * Math.pow(10, 9));
3230
- txParams = {
3231
- type: "solana",
3232
- recipientAddress,
3233
- amount,
3234
- currency: selectedToken.symbol,
3235
- tokenMintAddress: selectedToken.contractAddress || null,
3236
- decimals: selectedToken.decimals || (selectedToken.contractAddress ? 6 : 9),
3237
- network: "solana"
3238
- };
3239
- console.log("🔄 Solana Transaction Params:", {
3240
- token: selectedToken.symbol,
3241
- amount: paymentData.totalAmount,
3242
- amountWithDecimals: amount,
3243
- to: recipientAddress,
3244
- isToken: !!selectedToken.contractAddress,
3245
- tokenMint: selectedToken.contractAddress
3246
- });
3247
- } else {
3248
- console.log("🔄 Preparing EVM transaction with Phantom...");
3249
- if (selectedToken.contractAddress) {
3250
- const decimals = selectedToken.decimals || 6;
3251
- const amount = Math.floor(paymentData.totalAmount * Math.pow(10, decimals));
3252
- const methodId = "0xa9059cbb";
3253
- const recipientPadded = recipientAddress.slice(2).toLowerCase().padStart(64, "0");
3254
- const amountPadded = amount.toString(16).padStart(64, "0");
3255
- const data = `${methodId}${recipientPadded}${amountPadded}`;
3256
- txParams = {
3257
- type: "evm",
3258
- to: selectedToken.contractAddress,
3259
- data,
3260
- value: "0x0",
3261
- network: selectedNetwork.shortName
3262
- };
3263
- console.log("🔄 ERC-20 Transaction via Phantom:", {
3264
- token: selectedToken.symbol,
3265
- amount: paymentData.totalAmount,
3266
- amountWithDecimals: amount,
3267
- to: selectedToken.contractAddress,
3268
- recipient: recipientAddress
3269
- });
3270
- } else {
3271
- const value = Math.floor(paymentData.totalAmount * Math.pow(10, 18));
3272
- txParams = {
3273
- type: "evm",
3274
- to: recipientAddress,
3275
- value: `0x${value.toString(16)}`,
3276
- network: selectedNetwork.shortName
3277
- };
3278
- console.log("🔄 Native EVM Transaction via Phantom:", {
3279
- amount: paymentData.totalAmount,
3280
- to: recipientAddress,
3281
- network: selectedNetwork.shortName
3282
- });
3283
- }
3284
- }
3285
- } else if (selectedWalletType === "metamask") {
3173
+ if (selectedNetwork.shortName === "solana" && selectedWalletType === "phantom") {
3174
+ console.log("🔄 Preparing Solana transaction with Phantom...");
3175
+ const amount = selectedToken.contractAddress ? Math.floor(paymentData.totalAmount * Math.pow(10, selectedToken.decimals || 6)) : Math.floor(paymentData.totalAmount * Math.pow(10, 9));
3176
+ txParams = {
3177
+ type: "solana",
3178
+ recipientAddress,
3179
+ amount,
3180
+ currency: selectedToken.symbol,
3181
+ tokenMintAddress: selectedToken.contractAddress || null,
3182
+ decimals: selectedToken.decimals || (selectedToken.contractAddress ? 6 : 9),
3183
+ network: "solana"
3184
+ };
3185
+ console.log("🔄 Solana Transaction Params:", {
3186
+ token: selectedToken.symbol,
3187
+ amount: paymentData.totalAmount,
3188
+ amountWithDecimals: amount,
3189
+ to: recipientAddress,
3190
+ isToken: !!selectedToken.contractAddress,
3191
+ tokenMint: selectedToken.contractAddress
3192
+ });
3193
+ } else if (["ethereum", "bsc", "polygon", "arbitrum", "optimism", "avalanche"].includes(selectedNetwork.shortName) && selectedWalletType === "metamask") {
3286
3194
  console.log("🔄 Preparing EVM transaction with MetaMask...");
3287
- if (selectedNetwork.shortName === "solana") {
3288
- throw new Error("MetaMask does not support Solana network. Please use Phantom wallet for Solana transactions.");
3289
- }
3290
3195
  if (selectedToken.contractAddress) {
3291
3196
  const decimals = selectedToken.decimals || 6;
3292
3197
  const amount = Math.floor(paymentData.totalAmount * Math.pow(10, decimals));
@@ -3314,11 +3219,18 @@ const EnhancedSimpleCoinleyPayment = ({
3314
3219
  };
3315
3220
  console.log("🔄 Native EVM Transaction via MetaMask:", {
3316
3221
  amount: paymentData.totalAmount,
3317
- to: recipientAddress
3222
+ to: recipientAddress,
3223
+ network: selectedNetwork.shortName
3318
3224
  });
3319
3225
  }
3320
3226
  } else {
3321
- throw new Error(`Unsupported wallet type: ${selectedWalletType}`);
3227
+ if (selectedNetwork.shortName === "solana" && selectedWalletType === "metamask") {
3228
+ throw new Error("MetaMask does not support Solana network. Please use Phantom wallet for Solana transactions.");
3229
+ } else if (["ethereum", "bsc", "polygon", "arbitrum", "optimism", "avalanche"].includes(selectedNetwork.shortName) && selectedWalletType === "phantom") {
3230
+ throw new Error("For EVM networks, please use MetaMask wallet. Phantom is only available for Solana network.");
3231
+ } else {
3232
+ throw new Error(`Invalid wallet-network combination: ${selectedWalletType} with ${selectedNetwork.shortName}`);
3233
+ }
3322
3234
  }
3323
3235
  setCurrentStep("processing");
3324
3236
  if (!txParams) {
@@ -3335,7 +3247,6 @@ const EnhancedSimpleCoinleyPayment = ({
3335
3247
  amount: paymentData.totalAmount,
3336
3248
  method: paymentMethod,
3337
3249
  walletType: selectedWalletType
3338
- // NEW: Include wallet type in callback
3339
3250
  });
3340
3251
  }, 2e3);
3341
3252
  } catch (err) {