@weblock-wallet/sdk 0.1.62 → 0.1.64
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 +38 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -104740,8 +104740,22 @@ var WalletService = class {
|
|
|
104740
104740
|
"TRANSACTION_FAILED" /* TRANSACTION_FAILED */
|
|
104741
104741
|
);
|
|
104742
104742
|
}
|
|
104743
|
-
const
|
|
104744
|
-
|
|
104743
|
+
const pendingNonceHex = await this.rpcClient.sendRpc({
|
|
104744
|
+
chainId: params.chainId,
|
|
104745
|
+
method: "eth_getTransactionCount" /* ETH_GET_TRANSACTION_COUNT */,
|
|
104746
|
+
params: [from, "pending"]
|
|
104747
|
+
});
|
|
104748
|
+
const pendingNonce = parseInt(
|
|
104749
|
+
pendingNonceHex?.result ?? "0x0",
|
|
104750
|
+
16
|
|
104751
|
+
);
|
|
104752
|
+
const nonce = params.nonce ?? pendingNonce;
|
|
104753
|
+
let gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
|
|
104754
|
+
try {
|
|
104755
|
+
const bumped = BigInt(gasPrice) * 12n / 10n;
|
|
104756
|
+
gasPrice = "0x" + bumped.toString(16);
|
|
104757
|
+
} catch {
|
|
104758
|
+
}
|
|
104745
104759
|
let gasLimit = params.gasLimit;
|
|
104746
104760
|
if (!gasLimit) {
|
|
104747
104761
|
try {
|
|
@@ -104790,8 +104804,19 @@ var WalletService = class {
|
|
|
104790
104804
|
await LocalForage.delete(STORAGE_KEYS.share2(this.orgHost));
|
|
104791
104805
|
return txHash;
|
|
104792
104806
|
} catch (error) {
|
|
104807
|
+
if (error instanceof SDKError) {
|
|
104808
|
+
throw error;
|
|
104809
|
+
}
|
|
104810
|
+
const msg = (() => {
|
|
104811
|
+
try {
|
|
104812
|
+
const anyErr = error;
|
|
104813
|
+
return anyErr?.shortMessage || anyErr?.reason || anyErr?.message || String(error);
|
|
104814
|
+
} catch {
|
|
104815
|
+
return "Unknown error";
|
|
104816
|
+
}
|
|
104817
|
+
})();
|
|
104793
104818
|
throw new SDKError(
|
|
104794
|
-
|
|
104819
|
+
`Transaction failed: ${msg}`,
|
|
104795
104820
|
"TRANSACTION_FAILED" /* TRANSACTION_FAILED */,
|
|
104796
104821
|
error
|
|
104797
104822
|
);
|
|
@@ -105262,17 +105287,17 @@ var RpcClient = class {
|
|
|
105262
105287
|
method: request.method,
|
|
105263
105288
|
params: request.params
|
|
105264
105289
|
};
|
|
105265
|
-
const res = await this.client.post(
|
|
105266
|
-
|
|
105267
|
-
|
|
105268
|
-
|
|
105269
|
-
|
|
105290
|
+
const res = await this.client.post(this.baseUrl, rpcRequest, {
|
|
105291
|
+
needsAccessToken: true
|
|
105292
|
+
});
|
|
105293
|
+
if (res && typeof res.result === "string") {
|
|
105294
|
+
const t5 = res.result.trim();
|
|
105295
|
+
if (t5.startsWith("{") && t5.endsWith("}") || t5.startsWith("[") && t5.endsWith("]")) {
|
|
105296
|
+
try {
|
|
105297
|
+
res.result = JSON.parse(t5);
|
|
105298
|
+
} catch {
|
|
105299
|
+
}
|
|
105270
105300
|
}
|
|
105271
|
-
);
|
|
105272
|
-
if (res?.error) {
|
|
105273
|
-
const err = res.error;
|
|
105274
|
-
const msg = err?.message || "RPC error";
|
|
105275
|
-
throw new SDKError(msg, "REQUEST_FAILED" /* REQUEST_FAILED */, err);
|
|
105276
105301
|
}
|
|
105277
105302
|
return res;
|
|
105278
105303
|
}
|