@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.d.mts
CHANGED
|
@@ -75,6 +75,8 @@ interface ContractWriteParams extends ContractReadParams {
|
|
|
75
75
|
value?: string;
|
|
76
76
|
gas?: number;
|
|
77
77
|
gasPrice?: string;
|
|
78
|
+
maxFeePerGas?: string;
|
|
79
|
+
maxPriorityFeePerGas?: string;
|
|
78
80
|
}
|
|
79
81
|
interface EVMTransaction {
|
|
80
82
|
to: string;
|
|
@@ -172,6 +174,8 @@ declare class WalletManager extends TypedEventEmitter<WalletManagerEvents> {
|
|
|
172
174
|
value?: string;
|
|
173
175
|
gas?: number;
|
|
174
176
|
gasPrice?: string;
|
|
177
|
+
maxFeePerGas?: string;
|
|
178
|
+
maxPriorityFeePerGas?: string;
|
|
175
179
|
}, chainType?: ChainType): Promise<string>;
|
|
176
180
|
estimateGas(address: string, abi: any[], functionName: string, args?: any[], chainType?: ChainType): Promise<bigint>;
|
|
177
181
|
waitForTransaction(txHash: string, confirmations?: number, chainType?: ChainType): Promise<TransactionReceipt>;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -75,6 +75,8 @@ interface ContractWriteParams extends ContractReadParams {
|
|
|
75
75
|
value?: string;
|
|
76
76
|
gas?: number;
|
|
77
77
|
gasPrice?: string;
|
|
78
|
+
maxFeePerGas?: string;
|
|
79
|
+
maxPriorityFeePerGas?: string;
|
|
78
80
|
}
|
|
79
81
|
interface EVMTransaction {
|
|
80
82
|
to: string;
|
|
@@ -172,6 +174,8 @@ declare class WalletManager extends TypedEventEmitter<WalletManagerEvents> {
|
|
|
172
174
|
value?: string;
|
|
173
175
|
gas?: number;
|
|
174
176
|
gasPrice?: string;
|
|
177
|
+
maxFeePerGas?: string;
|
|
178
|
+
maxPriorityFeePerGas?: string;
|
|
175
179
|
}, chainType?: ChainType): Promise<string>;
|
|
176
180
|
estimateGas(address: string, abi: any[], functionName: string, args?: any[], chainType?: ChainType): Promise<bigint>;
|
|
177
181
|
waitForTransaction(txHash: string, confirmations?: number, chainType?: ChainType): Promise<TransactionReceipt>;
|
package/dist/react/index.js
CHANGED
|
@@ -668,25 +668,69 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
668
668
|
throw new Error("Wallet client not initialized");
|
|
669
669
|
}
|
|
670
670
|
try {
|
|
671
|
-
console.log("\u{1F50D} [MetaMask writeContract]
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
} else {
|
|
678
|
-
processedGasPrice = BigInt(params.gasPrice);
|
|
679
|
-
}
|
|
680
|
-
console.log("\u{1F50D} [MetaMask writeContract] processedGasPrice:", processedGasPrice);
|
|
681
|
-
const txHash = await this.walletClient.writeContract({
|
|
671
|
+
console.log("\u{1F50D} [MetaMask writeContract] Gas params:", {
|
|
672
|
+
gasPrice: params.gasPrice,
|
|
673
|
+
maxFeePerGas: params.maxFeePerGas,
|
|
674
|
+
maxPriorityFeePerGas: params.maxPriorityFeePerGas
|
|
675
|
+
});
|
|
676
|
+
const txOptions = {
|
|
682
677
|
address: params.address,
|
|
683
678
|
abi: params.abi,
|
|
684
679
|
functionName: params.functionName,
|
|
685
680
|
...params.args ? { args: params.args } : {},
|
|
686
681
|
value: params.value ? BigInt(params.value) : void 0,
|
|
687
|
-
gas: params.gas ? BigInt(params.gas) : void 0
|
|
688
|
-
|
|
689
|
-
|
|
682
|
+
gas: params.gas ? BigInt(params.gas) : void 0
|
|
683
|
+
};
|
|
684
|
+
if (params.maxFeePerGas || params.maxPriorityFeePerGas) {
|
|
685
|
+
if (params.maxFeePerGas) {
|
|
686
|
+
txOptions.maxFeePerGas = BigInt(params.maxFeePerGas);
|
|
687
|
+
}
|
|
688
|
+
if (params.maxPriorityFeePerGas) {
|
|
689
|
+
txOptions.maxPriorityFeePerGas = BigInt(params.maxPriorityFeePerGas);
|
|
690
|
+
}
|
|
691
|
+
console.log("\u{1F50D} [MetaMask writeContract] Using EIP-1559 gas params");
|
|
692
|
+
} else if (params.gasPrice) {
|
|
693
|
+
if (params.gasPrice === "auto") {
|
|
694
|
+
console.log("\u{1F50D} [MetaMask writeContract] Auto gas price - letting viem decide");
|
|
695
|
+
} else {
|
|
696
|
+
txOptions.gasPrice = BigInt(params.gasPrice);
|
|
697
|
+
console.log("\u{1F50D} [MetaMask writeContract] Using legacy gasPrice");
|
|
698
|
+
}
|
|
699
|
+
} else {
|
|
700
|
+
console.log("\u{1F50D} [MetaMask writeContract] No gas params - fetching and setting reasonable gas fees");
|
|
701
|
+
if (this.publicClient) {
|
|
702
|
+
try {
|
|
703
|
+
const feesPerGas = await this.publicClient.estimateFeesPerGas().catch(() => null);
|
|
704
|
+
if (feesPerGas) {
|
|
705
|
+
const minPriorityFeeWei = BigInt(1e8);
|
|
706
|
+
const maxPriorityFeePerGas = feesPerGas.maxPriorityFeePerGas > minPriorityFeeWei ? feesPerGas.maxPriorityFeePerGas : minPriorityFeeWei;
|
|
707
|
+
const adjustedMaxFeePerGas = feesPerGas.maxFeePerGas > maxPriorityFeePerGas ? feesPerGas.maxFeePerGas : maxPriorityFeePerGas + BigInt(1e9);
|
|
708
|
+
txOptions.maxFeePerGas = adjustedMaxFeePerGas;
|
|
709
|
+
txOptions.maxPriorityFeePerGas = maxPriorityFeePerGas;
|
|
710
|
+
const maxFeePerGasGwei = Number(adjustedMaxFeePerGas) / 1e9;
|
|
711
|
+
const maxPriorityFeePerGasGwei = Number(maxPriorityFeePerGas) / 1e9;
|
|
712
|
+
console.log("\u{1F4B0} [MetaMask writeContract] Set gas fees (EIP-1559):", {
|
|
713
|
+
maxFeePerGas: `${maxFeePerGasGwei.toFixed(6)} Gwei`,
|
|
714
|
+
maxPriorityFeePerGas: `${maxPriorityFeePerGasGwei.toFixed(6)} Gwei`,
|
|
715
|
+
maxFeePerGasWei: adjustedMaxFeePerGas.toString(),
|
|
716
|
+
maxPriorityFeePerGasWei: maxPriorityFeePerGas.toString(),
|
|
717
|
+
note: "\u5DF2\u8BBE\u7F6E\u5408\u7406\u7684 gas \u8D39\u7528\uFF0C\u907F\u514D MetaMask \u4F7F\u7528\u9ED8\u8BA4\u503C"
|
|
718
|
+
});
|
|
719
|
+
} else {
|
|
720
|
+
const gasPrice = await this.publicClient.getGasPrice();
|
|
721
|
+
txOptions.gasPrice = gasPrice;
|
|
722
|
+
const gasPriceGwei = Number(gasPrice) / 1e9;
|
|
723
|
+
console.log("\u{1F4B0} [MetaMask writeContract] Set gas price (Legacy):", {
|
|
724
|
+
gasPrice: `${gasPriceGwei.toFixed(6)} Gwei`,
|
|
725
|
+
gasPriceWei: gasPrice.toString()
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
} catch (err) {
|
|
729
|
+
console.warn("\u26A0\uFE0F [MetaMask writeContract] Failed to estimate gas fees, letting viem auto-estimate:", err);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
const txHash = await this.walletClient.writeContract(txOptions);
|
|
690
734
|
return txHash;
|
|
691
735
|
} catch (error) {
|
|
692
736
|
if (error.code === 4001) {
|