@txnlab/use-wallet 1.2.4 → 1.2.5

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
@@ -1822,6 +1822,7 @@ class WalletConnectClient extends BaseClient {
1822
1822
  const decodedTxns = transactions.map((txn) => {
1823
1823
  return this.algosdk.decodeObj(txn);
1824
1824
  });
1825
+ const signedIndexes = [];
1825
1826
  // Marshal the transactions,
1826
1827
  // and add the signers property if they shouldn't be signed.
1827
1828
  const txnsToSign = decodedTxns.reduce((acc, txn, i) => {
@@ -1829,12 +1830,14 @@ class WalletConnectClient extends BaseClient {
1829
1830
  if (indexesToSign &&
1830
1831
  indexesToSign.length &&
1831
1832
  indexesToSign.includes(i)) {
1833
+ signedIndexes.push(i);
1832
1834
  acc.push({
1833
1835
  txn: Buffer.from(transactions[i]).toString("base64"),
1834
1836
  });
1835
1837
  }
1836
1838
  else if (!isSigned &&
1837
1839
  connectedAccounts.includes(this.algosdk.encodeAddress(txn["snd"]))) {
1840
+ signedIndexes.push(i);
1838
1841
  acc.push({
1839
1842
  txn: Buffer.from(transactions[i]).toString("base64"),
1840
1843
  });
@@ -1858,14 +1861,15 @@ class WalletConnectClient extends BaseClient {
1858
1861
  const result = await this.#client.sendCustomRequest(request);
1859
1862
  this.keepWCAliveStop();
1860
1863
  // Join the newly signed transactions with the original group of transactions.
1861
- const signedTxns = result.reduce((signedTxns, txn, i) => {
1862
- if (txn) {
1863
- signedTxns.push(new Uint8Array(Buffer.from(txn, "base64")));
1864
+ const signedTxns = transactions.reduce((acc, txn, i) => {
1865
+ if (signedIndexes.includes(i)) {
1866
+ const signedByUser = result[i];
1867
+ signedByUser && acc.push(new Uint8Array(Buffer.from(signedByUser, 'base64')));
1864
1868
  }
1865
- if (returnGroup) {
1866
- signedTxns.push(transactions[i]);
1869
+ else if (returnGroup) {
1870
+ acc.push(txn);
1867
1871
  }
1868
- return signedTxns;
1872
+ return acc;
1869
1873
  }, []);
1870
1874
  return signedTxns;
1871
1875
  }