@weblock-wallet/sdk 0.1.62 → 0.1.63

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 CHANGED
@@ -104740,8 +104740,22 @@ var WalletService = class {
104740
104740
  "TRANSACTION_FAILED" /* TRANSACTION_FAILED */
104741
104741
  );
104742
104742
  }
104743
- const nonce = params.nonce ?? await this.getTransactionCount(from, params.chainId);
104744
- const gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
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
- "Transaction failed",
104819
+ `Transaction failed: ${msg}`,
104795
104820
  "TRANSACTION_FAILED" /* TRANSACTION_FAILED */,
104796
104821
  error
104797
104822
  );