@enclave-hq/wallet-sdk 1.2.1 → 1.2.2
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.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +58 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -14
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +4 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.js +58 -14
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +58 -14
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -661,25 +661,69 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
661
661
|
throw new Error("Wallet client not initialized");
|
|
662
662
|
}
|
|
663
663
|
try {
|
|
664
|
-
console.log("\u{1F50D} [MetaMask writeContract]
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
} else {
|
|
671
|
-
processedGasPrice = BigInt(params.gasPrice);
|
|
672
|
-
}
|
|
673
|
-
console.log("\u{1F50D} [MetaMask writeContract] processedGasPrice:", processedGasPrice);
|
|
674
|
-
const txHash = await this.walletClient.writeContract({
|
|
664
|
+
console.log("\u{1F50D} [MetaMask writeContract] Gas params:", {
|
|
665
|
+
gasPrice: params.gasPrice,
|
|
666
|
+
maxFeePerGas: params.maxFeePerGas,
|
|
667
|
+
maxPriorityFeePerGas: params.maxPriorityFeePerGas
|
|
668
|
+
});
|
|
669
|
+
const txOptions = {
|
|
675
670
|
address: params.address,
|
|
676
671
|
abi: params.abi,
|
|
677
672
|
functionName: params.functionName,
|
|
678
673
|
...params.args ? { args: params.args } : {},
|
|
679
674
|
value: params.value ? BigInt(params.value) : void 0,
|
|
680
|
-
gas: params.gas ? BigInt(params.gas) : void 0
|
|
681
|
-
|
|
682
|
-
|
|
675
|
+
gas: params.gas ? BigInt(params.gas) : void 0
|
|
676
|
+
};
|
|
677
|
+
if (params.maxFeePerGas || params.maxPriorityFeePerGas) {
|
|
678
|
+
if (params.maxFeePerGas) {
|
|
679
|
+
txOptions.maxFeePerGas = BigInt(params.maxFeePerGas);
|
|
680
|
+
}
|
|
681
|
+
if (params.maxPriorityFeePerGas) {
|
|
682
|
+
txOptions.maxPriorityFeePerGas = BigInt(params.maxPriorityFeePerGas);
|
|
683
|
+
}
|
|
684
|
+
console.log("\u{1F50D} [MetaMask writeContract] Using EIP-1559 gas params");
|
|
685
|
+
} else if (params.gasPrice) {
|
|
686
|
+
if (params.gasPrice === "auto") {
|
|
687
|
+
console.log("\u{1F50D} [MetaMask writeContract] Auto gas price - letting viem decide");
|
|
688
|
+
} else {
|
|
689
|
+
txOptions.gasPrice = BigInt(params.gasPrice);
|
|
690
|
+
console.log("\u{1F50D} [MetaMask writeContract] Using legacy gasPrice");
|
|
691
|
+
}
|
|
692
|
+
} else {
|
|
693
|
+
console.log("\u{1F50D} [MetaMask writeContract] No gas params - fetching and setting reasonable gas fees");
|
|
694
|
+
if (this.publicClient) {
|
|
695
|
+
try {
|
|
696
|
+
const feesPerGas = await this.publicClient.estimateFeesPerGas().catch(() => null);
|
|
697
|
+
if (feesPerGas) {
|
|
698
|
+
const minPriorityFeeWei = BigInt(1e8);
|
|
699
|
+
const maxPriorityFeePerGas = feesPerGas.maxPriorityFeePerGas > minPriorityFeeWei ? feesPerGas.maxPriorityFeePerGas : minPriorityFeeWei;
|
|
700
|
+
const adjustedMaxFeePerGas = feesPerGas.maxFeePerGas > maxPriorityFeePerGas ? feesPerGas.maxFeePerGas : maxPriorityFeePerGas + BigInt(1e9);
|
|
701
|
+
txOptions.maxFeePerGas = adjustedMaxFeePerGas;
|
|
702
|
+
txOptions.maxPriorityFeePerGas = maxPriorityFeePerGas;
|
|
703
|
+
const maxFeePerGasGwei = Number(adjustedMaxFeePerGas) / 1e9;
|
|
704
|
+
const maxPriorityFeePerGasGwei = Number(maxPriorityFeePerGas) / 1e9;
|
|
705
|
+
console.log("\u{1F4B0} [MetaMask writeContract] Set gas fees (EIP-1559):", {
|
|
706
|
+
maxFeePerGas: `${maxFeePerGasGwei.toFixed(6)} Gwei`,
|
|
707
|
+
maxPriorityFeePerGas: `${maxPriorityFeePerGasGwei.toFixed(6)} Gwei`,
|
|
708
|
+
maxFeePerGasWei: adjustedMaxFeePerGas.toString(),
|
|
709
|
+
maxPriorityFeePerGasWei: maxPriorityFeePerGas.toString(),
|
|
710
|
+
note: "\u5DF2\u8BBE\u7F6E\u5408\u7406\u7684 gas \u8D39\u7528\uFF0C\u907F\u514D MetaMask \u4F7F\u7528\u9ED8\u8BA4\u503C"
|
|
711
|
+
});
|
|
712
|
+
} else {
|
|
713
|
+
const gasPrice = await this.publicClient.getGasPrice();
|
|
714
|
+
txOptions.gasPrice = gasPrice;
|
|
715
|
+
const gasPriceGwei = Number(gasPrice) / 1e9;
|
|
716
|
+
console.log("\u{1F4B0} [MetaMask writeContract] Set gas price (Legacy):", {
|
|
717
|
+
gasPrice: `${gasPriceGwei.toFixed(6)} Gwei`,
|
|
718
|
+
gasPriceWei: gasPrice.toString()
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
} catch (err) {
|
|
722
|
+
console.warn("\u26A0\uFE0F [MetaMask writeContract] Failed to estimate gas fees, letting viem auto-estimate:", err);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
const txHash = await this.walletClient.writeContract(txOptions);
|
|
683
727
|
return txHash;
|
|
684
728
|
} catch (error) {
|
|
685
729
|
if (error.code === 4001) {
|