@txnlab/use-wallet 2.7.0 → 2.8.0

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/cjs/index.js CHANGED
@@ -2392,7 +2392,7 @@ class LuteClient extends BaseClient {
2392
2392
  return acc;
2393
2393
  }, []);
2394
2394
  // Sign them with the client.
2395
- const result = (await this.#client.signTxns(txnsToSign));
2395
+ const result = await this.#client.signTxns(txnsToSign);
2396
2396
  const signedTxns = transactions.reduce((acc, txn, i) => {
2397
2397
  if (signedIndexes.includes(i)) {
2398
2398
  const signedByUser = result.shift();
@@ -3361,12 +3361,15 @@ class KibisisClient extends BaseClient {
3361
3361
  providerId: ARC_0027_PROVIDER_ID
3362
3362
  });
3363
3363
  }, timeout || DEFAULT_REQUEST_TIMEOUT);
3364
- // broadcast the request
3365
- channel.postMessage({
3366
- id: requestId,
3367
- params,
3368
- reference
3369
- });
3364
+ // broadcast the request on the next tick
3365
+ // this allows the channel to be ready before the request is sent
3366
+ window.setTimeout(() => {
3367
+ channel.postMessage({
3368
+ id: requestId,
3369
+ params,
3370
+ reference
3371
+ });
3372
+ }, 0);
3370
3373
  });
3371
3374
  }
3372
3375
  /**
@@ -3724,7 +3727,8 @@ function useWallet() {
3724
3727
  accounts: getAccountsByProvider(id),
3725
3728
  isActive: activeAccount?.providerId === id,
3726
3729
  isConnected: connectedAccounts.some((accounts) => accounts.providerId === id),
3727
- connect: (arg) => connect(id, arg),
3730
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3731
+ connect: (arg, throws) => connect(id, arg, throws),
3728
3732
  disconnect: () => disconnect(id),
3729
3733
  reconnect: () => reconnect(id),
3730
3734
  setActiveProvider: () => setActive(id),
@@ -3764,7 +3768,7 @@ function useWallet() {
3764
3768
  }, [status]);
3765
3769
  const selectActiveAccount = (providerId, address) => {
3766
3770
  try {
3767
- const account = connectedActiveAccounts.find((acct) => acct.address === address && acct.providerId === providerId);
3771
+ const account = connectedAccounts.find((acct) => acct.address === address && acct.providerId === providerId);
3768
3772
  if (!account) {
3769
3773
  throw new Error(`No accounts with address ${address} found.`);
3770
3774
  }
@@ -3775,7 +3779,7 @@ function useWallet() {
3775
3779
  }
3776
3780
  };
3777
3781
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3778
- const connect = async (id, arg) => {
3782
+ const connect = async (id, arg, throws = false) => {
3779
3783
  try {
3780
3784
  const walletClient = getClient(id);
3781
3785
  const walletInfo = await walletClient?.connect(() => clearAccounts(id), arg);
@@ -3784,6 +3788,9 @@ function useWallet() {
3784
3788
  }
3785
3789
  catch (e) {
3786
3790
  console.error(e);
3791
+ if (throws) {
3792
+ throw e;
3793
+ }
3787
3794
  }
3788
3795
  };
3789
3796
  const reconnect = async (id) => {