Skip to content

Commit e019ccf

Browse files
committed
refactor: add logs to he shared worker functions
1 parent 2968088 commit e019ccf

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

packages/extension-polkagate/src/util/workers/shared-helpers/getAssetOnAssetHub.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export async function getAssetOnAssetHub (addresses, assetsToBeFetched, chainNam
1818

1919
const { metadata } = metadataFromApi(api);
2020

21+
console.info('Shared worker, metadata fetched and sent for chain:', chainName);
2122
port.postMessage(JSON.stringify({ functionName: 'getAssetOnAssetHub', metadata }));
2223

2324
const results = await toGetNativeToken(addresses, api, chainName);
@@ -38,6 +39,7 @@ export async function getAssetOnAssetHub (addresses, assetsToBeFetched, chainNam
3839

3940
await getAssets(addresses, api, nonNativeAssets, chainName, results);
4041

42+
console.info('Shared worker, account assets fetched and send on chain:', chainName);
4143
port.postMessage(JSON.stringify({ functionName: 'getAssetOnAssetHub', results }));
4244
closeWebsockets(connections);
4345
}

packages/extension-polkagate/src/util/workers/shared-helpers/getAssetOnMultiAssetChain.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export async function getAssetOnMultiAssetChain (assetsToBeFetched, addresses, c
1919

2020
const { metadata } = metadataFromApi(api);
2121

22+
console.info('Shared worker, metadata fetched and sent for chain:', chainName);
2223
port.postMessage(JSON.stringify({ functionName: 'getAssetOnMultiAssetChain', metadata }));
2324

2425
const results = await toGetNativeToken(addresses, api, chainName);
@@ -68,6 +69,7 @@ export async function getAssetOnMultiAssetChain (assetsToBeFetched, addresses, c
6869
}
6970
});
7071

72+
console.info('Shared worker, account assets fetched and send on chain:', chainName);
7173
port.postMessage(JSON.stringify({ functionName: 'getAssetOnMultiAssetChain', results }));
7274
closeWebsockets(connections);
7375
}

packages/extension-polkagate/src/util/workers/shared-helpers/getAssetOnRelayChain.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export async function getAssetOnRelayChain (addresses, chainName, userAddedEndpo
4747
} catch (error) {
4848
console.error(`getAssetOnRelayChain: Error fetching balances for ${chainName}:`, error);
4949
} finally {
50+
console.info('Shared worker, account assets fetched and send on chain:', chainName);
5051
Object.keys(results).length
5152
? port.postMessage(JSON.stringify({ functionName: 'getAssetOnRelayChain', results }))
5253
: port.postMessage(JSON.stringify({ functionName: 'getAssetOnRelayChain' }));

packages/extension-polkagate/src/util/workers/shared-helpers/getBalances.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export async function getBalances (chainName, addresses, userAddedEndpoints, por
2121
if (api.isConnected && api.derive.balances) {
2222
const { metadata } = metadataFromApi(api);
2323

24+
console.info('Shared worker, metadata fetched and sent for chain:', chainName);
2425
port.postMessage(JSON.stringify({ functionName: 'getAssetOnRelayChain', metadata }));
2526

2627
const requests = addresses.map(async (address) => {
@@ -40,7 +41,8 @@ export async function getBalances (chainName, addresses, userAddedEndpoints, por
4041
if (api.query['staking']?.['ledger']) {
4142
const ledger = await api.query['staking']['ledger'](address);
4243

43-
if (!ledger.isEmpty) {
44+
// @ts-ignore
45+
if (ledger.isSome) {
4446
// @ts-ignore
4547
soloTotal = ledger?.unwrap()?.total?.toString();
4648
}

0 commit comments

Comments
 (0)