@txnlab/use-wallet 1.2.3 → 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 =
|
|
1862
|
-
if (
|
|
1863
|
-
|
|
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
|
-
|
|
1869
|
+
else if (returnGroup) {
|
|
1870
|
+
acc.push(txn);
|
|
1867
1871
|
}
|
|
1868
|
-
return
|
|
1872
|
+
return acc;
|
|
1869
1873
|
}, []);
|
|
1870
1874
|
return signedTxns;
|
|
1871
1875
|
}
|
|
@@ -2401,12 +2405,25 @@ const initializeProviders = (providers, nodeConfig, algosdkStatic) => {
|
|
|
2401
2405
|
return initializedProviders;
|
|
2402
2406
|
};
|
|
2403
2407
|
|
|
2408
|
+
const getActiveProviders = () => {
|
|
2409
|
+
const accounts = useWalletStore.getState().accounts;
|
|
2410
|
+
return [...new Set(accounts.map((acct) => acct.providerId))];
|
|
2411
|
+
};
|
|
2412
|
+
const isActiveProvider = (id) => {
|
|
2413
|
+
const activeProviders = getActiveProviders();
|
|
2414
|
+
return activeProviders.includes(id);
|
|
2415
|
+
};
|
|
2416
|
+
|
|
2404
2417
|
const reconnectProviders = async (providers) => {
|
|
2405
2418
|
try {
|
|
2406
2419
|
const clients = Object.values(providers);
|
|
2407
2420
|
for (const client of clients) {
|
|
2408
2421
|
const c = await client;
|
|
2409
|
-
|
|
2422
|
+
const id = c?.metadata.id;
|
|
2423
|
+
// Only reconnect to active providers
|
|
2424
|
+
if (id && isActiveProvider(id)) {
|
|
2425
|
+
c.reconnect(() => clearAccounts(id));
|
|
2426
|
+
}
|
|
2410
2427
|
}
|
|
2411
2428
|
}
|
|
2412
2429
|
catch (e) {
|