@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.js
CHANGED
|
@@ -104647,21 +104647,27 @@ var WalletService = class {
|
|
|
104647
104647
|
const gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
|
|
104648
104648
|
let gasLimit = params.gasLimit;
|
|
104649
104649
|
if (!gasLimit) {
|
|
104650
|
-
|
|
104651
|
-
|
|
104652
|
-
|
|
104653
|
-
|
|
104654
|
-
|
|
104655
|
-
|
|
104656
|
-
|
|
104657
|
-
|
|
104658
|
-
|
|
104659
|
-
|
|
104660
|
-
|
|
104650
|
+
try {
|
|
104651
|
+
const est = await this.estimateGas(
|
|
104652
|
+
{
|
|
104653
|
+
from,
|
|
104654
|
+
to: params.to,
|
|
104655
|
+
value: toHexQuantity(params.value),
|
|
104656
|
+
data: params.data || "0x"
|
|
104657
|
+
},
|
|
104658
|
+
params.chainId
|
|
104659
|
+
);
|
|
104660
|
+
const buffered = Math.max(21e3, Math.ceil(est * 1.2));
|
|
104661
|
+
gasLimit = "0x" + buffered.toString(16);
|
|
104662
|
+
} catch (e7) {
|
|
104663
|
+
const data = (params.data || "").toLowerCase();
|
|
104664
|
+
const fallback = data.startsWith("0x095ea7b3") ? 12e4 : data && data !== "0x" ? 8e5 : 21e3;
|
|
104665
|
+
gasLimit = "0x" + fallback.toString(16);
|
|
104666
|
+
}
|
|
104661
104667
|
}
|
|
104662
104668
|
const signedTx = await wallet.signTransaction({
|
|
104663
104669
|
to: params.to,
|
|
104664
|
-
value: params.value,
|
|
104670
|
+
value: params.value ?? "0x0",
|
|
104665
104671
|
data: params.data || "0x",
|
|
104666
104672
|
chainId: params.chainId,
|
|
104667
104673
|
nonce,
|
|
@@ -104670,8 +104676,11 @@ var WalletService = class {
|
|
|
104670
104676
|
});
|
|
104671
104677
|
return this.sendRawTransaction(signedTx, params.chainId);
|
|
104672
104678
|
} catch (error) {
|
|
104679
|
+
const detail = String(
|
|
104680
|
+
error?.shortMessage ?? error?.reason ?? error?.message ?? ""
|
|
104681
|
+
).trim();
|
|
104673
104682
|
throw new SDKError(
|
|
104674
|
-
"Transaction failed",
|
|
104683
|
+
detail ? `Transaction failed: ${detail}` : "Transaction failed",
|
|
104675
104684
|
"TRANSACTION_FAILED" /* TRANSACTION_FAILED */,
|
|
104676
104685
|
error
|
|
104677
104686
|
);
|