@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.
- package/dist/index.js +27 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.js +25 -4
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +25 -4
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -361,7 +361,15 @@ var CHAIN_INFO = {
|
|
|
361
361
|
symbol: "BNB",
|
|
362
362
|
decimals: 18
|
|
363
363
|
},
|
|
364
|
-
rpcUrls: [
|
|
364
|
+
rpcUrls: [
|
|
365
|
+
"https://data-seed-prebsc-2-s1.binance.org:8545",
|
|
366
|
+
"https://data-seed-prebsc-1-s2.binance.org:8545",
|
|
367
|
+
"https://data-seed-prebsc-2-s2.binance.org:8545",
|
|
368
|
+
"https://data-seed-prebsc-1-s3.binance.org:8545",
|
|
369
|
+
"https://data-seed-prebsc-2-s3.binance.org:8545",
|
|
370
|
+
"https://data-seed-prebsc-1-s1.binance.org:8545"
|
|
371
|
+
// 原来的主节点作为最后备选
|
|
372
|
+
],
|
|
365
373
|
blockExplorerUrls: ["https://testnet.bscscan.com"]
|
|
366
374
|
},
|
|
367
375
|
// Polygon
|
|
@@ -562,9 +570,12 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
562
570
|
chain: viemChain,
|
|
563
571
|
transport: viem.custom(provider)
|
|
564
572
|
});
|
|
573
|
+
const chainInfo = getChainInfo(finalChainId);
|
|
574
|
+
const primaryRpcUrl = chainInfo?.rpcUrls[0];
|
|
565
575
|
this.publicClient = viem.createPublicClient({
|
|
566
576
|
chain: viemChain,
|
|
567
|
-
transport: viem.custom(provider)
|
|
577
|
+
transport: primaryRpcUrl ? viem.http(primaryRpcUrl) : viem.custom(provider)
|
|
578
|
+
// 优先使用我们的 RPC,降级到 MetaMask provider
|
|
568
579
|
});
|
|
569
580
|
const address = formatEVMAddress(accounts[0]);
|
|
570
581
|
const account = {
|
|
@@ -641,7 +652,7 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
641
652
|
value: transaction.value ? `0x${BigInt(transaction.value).toString(16)}` : void 0,
|
|
642
653
|
data: transaction.data || "0x",
|
|
643
654
|
gas: transaction.gas ? `0x${BigInt(transaction.gas).toString(16)}` : void 0,
|
|
644
|
-
gasPrice: transaction.gasPrice ? `0x${BigInt(transaction.gasPrice).toString(16)}` : void 0,
|
|
655
|
+
gasPrice: transaction.gasPrice && transaction.gasPrice !== "auto" ? `0x${BigInt(transaction.gasPrice).toString(16)}` : void 0,
|
|
645
656
|
maxFeePerGas: transaction.maxFeePerGas ? `0x${BigInt(transaction.maxFeePerGas).toString(16)}` : void 0,
|
|
646
657
|
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ? `0x${BigInt(transaction.maxPriorityFeePerGas).toString(16)}` : void 0,
|
|
647
658
|
nonce: transaction.nonce !== void 0 ? `0x${transaction.nonce.toString(16)}` : void 0,
|
|
@@ -739,6 +750,16 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
739
750
|
throw new Error("Wallet client not initialized");
|
|
740
751
|
}
|
|
741
752
|
try {
|
|
753
|
+
console.log("\u{1F50D} [MetaMask writeContract] params.gasPrice:", params.gasPrice, "type:", typeof params.gasPrice);
|
|
754
|
+
let processedGasPrice;
|
|
755
|
+
if (!params.gasPrice) {
|
|
756
|
+
processedGasPrice = void 0;
|
|
757
|
+
} else if (params.gasPrice === "auto") {
|
|
758
|
+
processedGasPrice = void 0;
|
|
759
|
+
} else {
|
|
760
|
+
processedGasPrice = BigInt(params.gasPrice);
|
|
761
|
+
}
|
|
762
|
+
console.log("\u{1F50D} [MetaMask writeContract] processedGasPrice:", processedGasPrice);
|
|
742
763
|
const txHash = await this.walletClient.writeContract({
|
|
743
764
|
address: params.address,
|
|
744
765
|
abi: params.abi,
|
|
@@ -746,7 +767,7 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
746
767
|
...params.args ? { args: params.args } : {},
|
|
747
768
|
value: params.value ? BigInt(params.value) : void 0,
|
|
748
769
|
gas: params.gas ? BigInt(params.gas) : void 0,
|
|
749
|
-
gasPrice:
|
|
770
|
+
gasPrice: processedGasPrice
|
|
750
771
|
});
|
|
751
772
|
return txHash;
|
|
752
773
|
} catch (error) {
|
|
@@ -2218,11 +2239,11 @@ var WalletDetector = class {
|
|
|
2218
2239
|
}
|
|
2219
2240
|
}
|
|
2220
2241
|
/**
|
|
2221
|
-
* 检测 MetaMask
|
|
2242
|
+
* 检测 MetaMask(现在支持所有 window.ethereum 钱包)
|
|
2222
2243
|
*/
|
|
2223
2244
|
isMetaMaskAvailable() {
|
|
2224
2245
|
const w = window;
|
|
2225
|
-
return !!
|
|
2246
|
+
return !!w.ethereum;
|
|
2226
2247
|
}
|
|
2227
2248
|
/**
|
|
2228
2249
|
* 检测 TronLink
|