@weblock-wallet/sdk 0.1.57 → 0.1.58
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.cjs +22 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -104692,21 +104692,27 @@ var WalletService = class {
|
|
|
104692
104692
|
const gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
|
|
104693
104693
|
let gasLimit = params.gasLimit;
|
|
104694
104694
|
if (!gasLimit) {
|
|
104695
|
-
|
|
104696
|
-
|
|
104697
|
-
|
|
104698
|
-
|
|
104699
|
-
|
|
104700
|
-
|
|
104701
|
-
|
|
104702
|
-
|
|
104703
|
-
|
|
104704
|
-
|
|
104705
|
-
|
|
104695
|
+
try {
|
|
104696
|
+
const est = await this.estimateGas(
|
|
104697
|
+
{
|
|
104698
|
+
from,
|
|
104699
|
+
to: params.to,
|
|
104700
|
+
value: toHexQuantity(params.value),
|
|
104701
|
+
data: params.data || "0x"
|
|
104702
|
+
},
|
|
104703
|
+
params.chainId
|
|
104704
|
+
);
|
|
104705
|
+
const buffered = Math.max(21e3, Math.ceil(est * 1.2));
|
|
104706
|
+
gasLimit = "0x" + buffered.toString(16);
|
|
104707
|
+
} catch (e7) {
|
|
104708
|
+
const data = (params.data || "").toLowerCase();
|
|
104709
|
+
const fallback = data.startsWith("0x095ea7b3") ? 12e4 : data && data !== "0x" ? 8e5 : 21e3;
|
|
104710
|
+
gasLimit = "0x" + fallback.toString(16);
|
|
104711
|
+
}
|
|
104706
104712
|
}
|
|
104707
104713
|
const signedTx = await wallet.signTransaction({
|
|
104708
104714
|
to: params.to,
|
|
104709
|
-
value: params.value,
|
|
104715
|
+
value: params.value ?? "0x0",
|
|
104710
104716
|
data: params.data || "0x",
|
|
104711
104717
|
chainId: params.chainId,
|
|
104712
104718
|
nonce,
|
|
@@ -104715,8 +104721,11 @@ var WalletService = class {
|
|
|
104715
104721
|
});
|
|
104716
104722
|
return this.sendRawTransaction(signedTx, params.chainId);
|
|
104717
104723
|
} catch (error) {
|
|
104724
|
+
const detail = String(
|
|
104725
|
+
error?.shortMessage ?? error?.reason ?? error?.message ?? ""
|
|
104726
|
+
).trim();
|
|
104718
104727
|
throw new SDKError(
|
|
104719
|
-
"Transaction failed",
|
|
104728
|
+
detail ? `Transaction failed: ${detail}` : "Transaction failed",
|
|
104720
104729
|
"TRANSACTION_FAILED" /* TRANSACTION_FAILED */,
|
|
104721
104730
|
error
|
|
104722
104731
|
);
|