@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.js CHANGED
@@ -1890,7 +1890,7 @@ var AuthService = class {
1890
1890
  };
1891
1891
 
1892
1892
  // src/core/services/wallet.ts
1893
- import { Wallet, Interface } from "ethers";
1893
+ import { Wallet, Interface, Transaction as EthersTx } from "ethers";
1894
1894
  import { generateMnemonic, mnemonicToSeed } from "bip39";
1895
1895
 
1896
1896
  // src/utils/secrets.ts
@@ -104623,10 +104623,6 @@ var WalletService = class {
104623
104623
  }
104624
104624
  async sendTransaction(params) {
104625
104625
  try {
104626
- const from = await this.getAddress();
104627
- if (!from) {
104628
- throw new SDKError("Wallet not found", "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */);
104629
- }
104630
104626
  const toHexQuantity = (v5) => {
104631
104627
  if (v5 === void 0 || v5 === null) return "0x0";
104632
104628
  const s5 = String(v5).trim();
@@ -104674,6 +104670,31 @@ var WalletService = class {
104674
104670
  }
104675
104671
  const privateKey = await Secrets.combine([share1, share2]);
104676
104672
  const wallet = new Wallet(privateKey);
104673
+ const from = wallet.address;
104674
+ const cachedAddress = await LocalForage.get(
104675
+ STORAGE_KEYS.walletAddress(this.orgHost)
104676
+ );
104677
+ if (cachedAddress && cachedAddress.toLowerCase() !== from.toLowerCase()) {
104678
+ console.warn(
104679
+ "[WalletService] walletAddress mismatch detected. cached=",
104680
+ cachedAddress,
104681
+ "derived=",
104682
+ from
104683
+ );
104684
+ this.walletAddress = from;
104685
+ await LocalForage.save(STORAGE_KEYS.walletAddress(this.orgHost), from);
104686
+ }
104687
+ const nativeBal = await this.rpcClient.sendRpc({
104688
+ chainId: params.chainId,
104689
+ method: "eth_getBalance" /* ETH_GET_BALANCE */,
104690
+ params: [from, "latest"]
104691
+ });
104692
+ if (!nativeBal?.result || BigInt(nativeBal.result) === BigInt(0)) {
104693
+ throw new SDKError(
104694
+ `Insufficient native balance for gas. sender=${from} balance=${nativeBal?.result ?? "0x0"}`,
104695
+ "TRANSACTION_FAILED" /* TRANSACTION_FAILED */
104696
+ );
104697
+ }
104677
104698
  const nonce = params.nonce ?? await this.getTransactionCount(from, params.chainId);
104678
104699
  const gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
104679
104700
  let gasLimit = params.gasLimit;
@@ -104707,6 +104728,19 @@ var WalletService = class {
104707
104728
  gasPrice,
104708
104729
  gasLimit
104709
104730
  });
104731
+ try {
104732
+ const parsed = EthersTx.from(signedTx);
104733
+ const derivedFrom = parsed?.from;
104734
+ if (derivedFrom && String(derivedFrom).toLowerCase() !== from.toLowerCase()) {
104735
+ console.warn(
104736
+ "[WalletService] signedTx sender mismatch. wallet=",
104737
+ from,
104738
+ "txFrom=",
104739
+ derivedFrom
104740
+ );
104741
+ }
104742
+ } catch {
104743
+ }
104710
104744
  const txHash = await this.sendRawTransaction(signedTx, params.chainId);
104711
104745
  await LocalForage.delete(STORAGE_KEYS.share2(this.orgHost));
104712
104746
  return txHash;