@weblock-wallet/sdk 0.1.60 → 0.1.62

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
@@ -104668,10 +104668,6 @@ var WalletService = class {
104668
104668
  }
104669
104669
  async sendTransaction(params) {
104670
104670
  try {
104671
- const from = await this.getAddress();
104672
- if (!from) {
104673
- throw new SDKError("Wallet not found", "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */);
104674
- }
104675
104671
  const toHexQuantity = (v5) => {
104676
104672
  if (v5 === void 0 || v5 === null) return "0x0";
104677
104673
  const s5 = String(v5).trim();
@@ -104719,6 +104715,31 @@ var WalletService = class {
104719
104715
  }
104720
104716
  const privateKey = await Secrets.combine([share1, share2]);
104721
104717
  const wallet = new import_ethers2.Wallet(privateKey);
104718
+ const from = wallet.address;
104719
+ const cachedAddress = await LocalForage.get(
104720
+ STORAGE_KEYS.walletAddress(this.orgHost)
104721
+ );
104722
+ if (cachedAddress && cachedAddress.toLowerCase() !== from.toLowerCase()) {
104723
+ console.warn(
104724
+ "[WalletService] walletAddress mismatch detected. cached=",
104725
+ cachedAddress,
104726
+ "derived=",
104727
+ from
104728
+ );
104729
+ this.walletAddress = from;
104730
+ await LocalForage.save(STORAGE_KEYS.walletAddress(this.orgHost), from);
104731
+ }
104732
+ const nativeBal = await this.rpcClient.sendRpc({
104733
+ chainId: params.chainId,
104734
+ method: "eth_getBalance" /* ETH_GET_BALANCE */,
104735
+ params: [from, "latest"]
104736
+ });
104737
+ if (!nativeBal?.result || BigInt(nativeBal.result) === BigInt(0)) {
104738
+ throw new SDKError(
104739
+ `Insufficient native balance for gas. sender=${from} balance=${nativeBal?.result ?? "0x0"}`,
104740
+ "TRANSACTION_FAILED" /* TRANSACTION_FAILED */
104741
+ );
104742
+ }
104722
104743
  const nonce = params.nonce ?? await this.getTransactionCount(from, params.chainId);
104723
104744
  const gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
104724
104745
  let gasLimit = params.gasLimit;
@@ -104752,6 +104773,19 @@ var WalletService = class {
104752
104773
  gasPrice,
104753
104774
  gasLimit
104754
104775
  });
104776
+ try {
104777
+ const parsed = import_ethers2.Transaction.from(signedTx);
104778
+ const derivedFrom = parsed?.from;
104779
+ if (derivedFrom && String(derivedFrom).toLowerCase() !== from.toLowerCase()) {
104780
+ console.warn(
104781
+ "[WalletService] signedTx sender mismatch. wallet=",
104782
+ from,
104783
+ "txFrom=",
104784
+ derivedFrom
104785
+ );
104786
+ }
104787
+ } catch {
104788
+ }
104755
104789
  const txHash = await this.sendRawTransaction(signedTx, params.chainId);
104756
104790
  await LocalForage.delete(STORAGE_KEYS.share2(this.orgHost));
104757
104791
  return txHash;