@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.mjs
CHANGED
|
@@ -353,7 +353,15 @@ var CHAIN_INFO = {
|
|
|
353
353
|
symbol: "BNB",
|
|
354
354
|
decimals: 18
|
|
355
355
|
},
|
|
356
|
-
rpcUrls: [
|
|
356
|
+
rpcUrls: [
|
|
357
|
+
"https://data-seed-prebsc-2-s1.binance.org:8545",
|
|
358
|
+
"https://data-seed-prebsc-1-s2.binance.org:8545",
|
|
359
|
+
"https://data-seed-prebsc-2-s2.binance.org:8545",
|
|
360
|
+
"https://data-seed-prebsc-1-s3.binance.org:8545",
|
|
361
|
+
"https://data-seed-prebsc-2-s3.binance.org:8545",
|
|
362
|
+
"https://data-seed-prebsc-1-s1.binance.org:8545"
|
|
363
|
+
// 原来的主节点作为最后备选
|
|
364
|
+
],
|
|
357
365
|
blockExplorerUrls: ["https://testnet.bscscan.com"]
|
|
358
366
|
},
|
|
359
367
|
// Polygon
|
|
@@ -554,9 +562,12 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
554
562
|
chain: viemChain,
|
|
555
563
|
transport: custom(provider)
|
|
556
564
|
});
|
|
565
|
+
const chainInfo = getChainInfo(finalChainId);
|
|
566
|
+
const primaryRpcUrl = chainInfo?.rpcUrls[0];
|
|
557
567
|
this.publicClient = createPublicClient({
|
|
558
568
|
chain: viemChain,
|
|
559
|
-
transport: custom(provider)
|
|
569
|
+
transport: primaryRpcUrl ? http(primaryRpcUrl) : custom(provider)
|
|
570
|
+
// 优先使用我们的 RPC,降级到 MetaMask provider
|
|
560
571
|
});
|
|
561
572
|
const address = formatEVMAddress(accounts[0]);
|
|
562
573
|
const account = {
|
|
@@ -633,7 +644,7 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
633
644
|
value: transaction.value ? `0x${BigInt(transaction.value).toString(16)}` : void 0,
|
|
634
645
|
data: transaction.data || "0x",
|
|
635
646
|
gas: transaction.gas ? `0x${BigInt(transaction.gas).toString(16)}` : void 0,
|
|
636
|
-
gasPrice: transaction.gasPrice ? `0x${BigInt(transaction.gasPrice).toString(16)}` : void 0,
|
|
647
|
+
gasPrice: transaction.gasPrice && transaction.gasPrice !== "auto" ? `0x${BigInt(transaction.gasPrice).toString(16)}` : void 0,
|
|
637
648
|
maxFeePerGas: transaction.maxFeePerGas ? `0x${BigInt(transaction.maxFeePerGas).toString(16)}` : void 0,
|
|
638
649
|
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ? `0x${BigInt(transaction.maxPriorityFeePerGas).toString(16)}` : void 0,
|
|
639
650
|
nonce: transaction.nonce !== void 0 ? `0x${transaction.nonce.toString(16)}` : void 0,
|
|
@@ -731,6 +742,16 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
731
742
|
throw new Error("Wallet client not initialized");
|
|
732
743
|
}
|
|
733
744
|
try {
|
|
745
|
+
console.log("\u{1F50D} [MetaMask writeContract] params.gasPrice:", params.gasPrice, "type:", typeof params.gasPrice);
|
|
746
|
+
let processedGasPrice;
|
|
747
|
+
if (!params.gasPrice) {
|
|
748
|
+
processedGasPrice = void 0;
|
|
749
|
+
} else if (params.gasPrice === "auto") {
|
|
750
|
+
processedGasPrice = void 0;
|
|
751
|
+
} else {
|
|
752
|
+
processedGasPrice = BigInt(params.gasPrice);
|
|
753
|
+
}
|
|
754
|
+
console.log("\u{1F50D} [MetaMask writeContract] processedGasPrice:", processedGasPrice);
|
|
734
755
|
const txHash = await this.walletClient.writeContract({
|
|
735
756
|
address: params.address,
|
|
736
757
|
abi: params.abi,
|
|
@@ -738,7 +759,7 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
738
759
|
...params.args ? { args: params.args } : {},
|
|
739
760
|
value: params.value ? BigInt(params.value) : void 0,
|
|
740
761
|
gas: params.gas ? BigInt(params.gas) : void 0,
|
|
741
|
-
gasPrice:
|
|
762
|
+
gasPrice: processedGasPrice
|
|
742
763
|
});
|
|
743
764
|
return txHash;
|
|
744
765
|
} catch (error) {
|
|
@@ -2210,11 +2231,11 @@ var WalletDetector = class {
|
|
|
2210
2231
|
}
|
|
2211
2232
|
}
|
|
2212
2233
|
/**
|
|
2213
|
-
* 检测 MetaMask
|
|
2234
|
+
* 检测 MetaMask(现在支持所有 window.ethereum 钱包)
|
|
2214
2235
|
*/
|
|
2215
2236
|
isMetaMaskAvailable() {
|
|
2216
2237
|
const w = window;
|
|
2217
|
-
return !!
|
|
2238
|
+
return !!w.ethereum;
|
|
2218
2239
|
}
|
|
2219
2240
|
/**
|
|
2220
2241
|
* 检测 TronLink
|