@enclave-hq/wallet-sdk 1.0.1 → 1.1.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.
@@ -271,7 +271,15 @@ var CHAIN_INFO = {
271
271
  symbol: "BNB",
272
272
  decimals: 18
273
273
  },
274
- rpcUrls: ["https://data-seed-prebsc-1-s1.binance.org:8545"],
274
+ rpcUrls: [
275
+ "https://data-seed-prebsc-2-s1.binance.org:8545",
276
+ "https://data-seed-prebsc-1-s2.binance.org:8545",
277
+ "https://data-seed-prebsc-2-s2.binance.org:8545",
278
+ "https://data-seed-prebsc-1-s3.binance.org:8545",
279
+ "https://data-seed-prebsc-2-s3.binance.org:8545",
280
+ "https://data-seed-prebsc-1-s1.binance.org:8545"
281
+ // 原来的主节点作为最后备选
282
+ ],
275
283
  blockExplorerUrls: ["https://testnet.bscscan.com"]
276
284
  },
277
285
  // Polygon
@@ -463,9 +471,12 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
463
471
  chain: viemChain,
464
472
  transport: custom(provider)
465
473
  });
474
+ const chainInfo = getChainInfo(finalChainId);
475
+ const primaryRpcUrl = chainInfo?.rpcUrls[0];
466
476
  this.publicClient = createPublicClient({
467
477
  chain: viemChain,
468
- transport: custom(provider)
478
+ transport: primaryRpcUrl ? http(primaryRpcUrl) : custom(provider)
479
+ // 优先使用我们的 RPC,降级到 MetaMask provider
469
480
  });
470
481
  const address = formatEVMAddress(accounts[0]);
471
482
  const account = {
@@ -542,7 +553,7 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
542
553
  value: transaction.value ? `0x${BigInt(transaction.value).toString(16)}` : void 0,
543
554
  data: transaction.data || "0x",
544
555
  gas: transaction.gas ? `0x${BigInt(transaction.gas).toString(16)}` : void 0,
545
- gasPrice: transaction.gasPrice ? `0x${BigInt(transaction.gasPrice).toString(16)}` : void 0,
556
+ gasPrice: transaction.gasPrice && transaction.gasPrice !== "auto" ? `0x${BigInt(transaction.gasPrice).toString(16)}` : void 0,
546
557
  maxFeePerGas: transaction.maxFeePerGas ? `0x${BigInt(transaction.maxFeePerGas).toString(16)}` : void 0,
547
558
  maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ? `0x${BigInt(transaction.maxPriorityFeePerGas).toString(16)}` : void 0,
548
559
  nonce: transaction.nonce !== void 0 ? `0x${transaction.nonce.toString(16)}` : void 0,
@@ -640,6 +651,16 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
640
651
  throw new Error("Wallet client not initialized");
641
652
  }
642
653
  try {
654
+ console.log("\u{1F50D} [MetaMask writeContract] params.gasPrice:", params.gasPrice, "type:", typeof params.gasPrice);
655
+ let processedGasPrice;
656
+ if (!params.gasPrice) {
657
+ processedGasPrice = void 0;
658
+ } else if (params.gasPrice === "auto") {
659
+ processedGasPrice = void 0;
660
+ } else {
661
+ processedGasPrice = BigInt(params.gasPrice);
662
+ }
663
+ console.log("\u{1F50D} [MetaMask writeContract] processedGasPrice:", processedGasPrice);
643
664
  const txHash = await this.walletClient.writeContract({
644
665
  address: params.address,
645
666
  abi: params.abi,
@@ -647,7 +668,7 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
647
668
  ...params.args ? { args: params.args } : {},
648
669
  value: params.value ? BigInt(params.value) : void 0,
649
670
  gas: params.gas ? BigInt(params.gas) : void 0,
650
- gasPrice: params.gasPrice ? BigInt(params.gasPrice) : void 0
671
+ gasPrice: processedGasPrice
651
672
  });
652
673
  return txHash;
653
674
  } catch (error) {