@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.js CHANGED
@@ -104695,8 +104695,22 @@ var WalletService = class {
104695
104695
  "TRANSACTION_FAILED" /* TRANSACTION_FAILED */
104696
104696
  );
104697
104697
  }
104698
- const nonce = params.nonce ?? await this.getTransactionCount(from, params.chainId);
104699
- const gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
104698
+ const pendingNonceHex = await this.rpcClient.sendRpc({
104699
+ chainId: params.chainId,
104700
+ method: "eth_getTransactionCount" /* ETH_GET_TRANSACTION_COUNT */,
104701
+ params: [from, "pending"]
104702
+ });
104703
+ const pendingNonce = parseInt(
104704
+ pendingNonceHex?.result ?? "0x0",
104705
+ 16
104706
+ );
104707
+ const nonce = params.nonce ?? pendingNonce;
104708
+ let gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
104709
+ try {
104710
+ const bumped = BigInt(gasPrice) * 12n / 10n;
104711
+ gasPrice = "0x" + bumped.toString(16);
104712
+ } catch {
104713
+ }
104700
104714
  let gasLimit = params.gasLimit;
104701
104715
  if (!gasLimit) {
104702
104716
  try {
@@ -104745,8 +104759,19 @@ var WalletService = class {
104745
104759
  await LocalForage.delete(STORAGE_KEYS.share2(this.orgHost));
104746
104760
  return txHash;
104747
104761
  } catch (error) {
104762
+ if (error instanceof SDKError) {
104763
+ throw error;
104764
+ }
104765
+ const msg = (() => {
104766
+ try {
104767
+ const anyErr = error;
104768
+ return anyErr?.shortMessage || anyErr?.reason || anyErr?.message || String(error);
104769
+ } catch {
104770
+ return "Unknown error";
104771
+ }
104772
+ })();
104748
104773
  throw new SDKError(
104749
- "Transaction failed",
104774
+ `Transaction failed: ${msg}`,
104750
104775
  "TRANSACTION_FAILED" /* TRANSACTION_FAILED */,
104751
104776
  error
104752
104777
  );