@bze/bze-ui-kit 1.0.15 → 1.0.16

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.mjs CHANGED
@@ -4242,18 +4242,19 @@ var useTx = (chainName) => {
4242
4242
  }
4243
4243
  }, [simulateFee]);
4244
4244
  const tx = useCallback11(async (msgs, options) => {
4245
- var _a2;
4245
+ var _a2, _b2;
4246
4246
  if (!address) {
4247
4247
  toast.error("Transaction Failed" /* Failed */, "Please connect the wallet");
4248
- return;
4248
+ return false;
4249
4249
  }
4250
4250
  if (!await canUseClient()) {
4251
4251
  toast.error("Transaction Failed" /* Failed */, "Can not find suitable signing client. Make sure your wallet is installed, connected and unlocked.");
4252
4252
  disconnect();
4253
- return;
4253
+ return false;
4254
4254
  }
4255
4255
  setProgressTrack("Getting fee");
4256
4256
  const broadcastToastId = toast.loading("Transaction Pending" /* Broadcasting */, "Waiting for transaction to be signed and included in block");
4257
+ let success = false;
4257
4258
  if (signingClient) {
4258
4259
  try {
4259
4260
  const fee = await getFee(msgs, options);
@@ -4263,6 +4264,7 @@ var useTx = (chainName) => {
4263
4264
  const resp = await broadcastResult.wait();
4264
4265
  const txHash = (resp == null ? void 0 : resp.txhash) || broadcastResult.transactionHash;
4265
4266
  if ((resp == null ? void 0 : resp.code) === 0) {
4267
+ success = true;
4266
4268
  setProgressTrack("Transaction sent");
4267
4269
  toast.clickableSuccess("Transaction Successful" /* Successful */, () => {
4268
4270
  openExternalLink(`${getChainExplorerURL(chainName != null ? chainName : defaultChainName)}/tx/${txHash}`);
@@ -4279,12 +4281,19 @@ var useTx = (chainName) => {
4279
4281
  }
4280
4282
  } catch (e) {
4281
4283
  console.error(e);
4282
- if (e.message.includes("Failed to retrieve account from signer")) {
4284
+ const errMsg = (_b2 = e == null ? void 0 : e.message) != null ? _b2 : "";
4285
+ const isSignerError = [
4286
+ "Failed to retrieve account from signer",
4287
+ "Signer address does not match",
4288
+ "signers mismatch",
4289
+ "Signer mismatched"
4290
+ ].some((pattern) => errMsg.includes(pattern));
4291
+ if (isSignerError) {
4283
4292
  disconnect();
4284
4293
  }
4285
- toast.error("Transaction Failed" /* Failed */, prettyError(e == null ? void 0 : e.message));
4294
+ toast.error("Transaction Failed" /* Failed */, prettyError(errMsg));
4286
4295
  if (options == null ? void 0 : options.onFailure) {
4287
- options.onFailure(prettyError(e == null ? void 0 : e.message) || "Unknown error");
4296
+ options.onFailure(prettyError(errMsg) || "Unknown error");
4288
4297
  }
4289
4298
  }
4290
4299
  }
@@ -4292,6 +4301,7 @@ var useTx = (chainName) => {
4292
4301
  setTimeout(() => {
4293
4302
  setProgressTrack("");
4294
4303
  }, (options == null ? void 0 : options.progressTrackerTimeout) || 5e3);
4304
+ return success;
4295
4305
  }, [address, canUseClient, toast, signingClient, disconnect, getFee, chainName, defaultChainName]);
4296
4306
  return {
4297
4307
  tx,