@talismn/balances 0.0.0-pr2092-20250715131755 → 0.0.0-pr2094-20250715164740
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.
@@ -1502,8 +1502,23 @@ const getRpcQueryPack$ = (connector, networkId, queries, timeout = false) => {
|
|
1502
1502
|
decodeResult
|
1503
1503
|
}) => decodeResult(stateKeys.map(() => null))));
|
1504
1504
|
return new rxjs.Observable(subscriber => {
|
1505
|
+
// first subscription callback includes results for all state keys, but further callbacks will only include the ones that changed
|
1506
|
+
// => we need to keep all results in memory and update them after each callback, so we can emit the full result set each time
|
1507
|
+
const dicChangesCache = {};
|
1505
1508
|
const promUnsub = connector.subscribe(networkId, "state_subscribeStorage", "state_storage", [allStateKeys], (error, result) => {
|
1506
|
-
if (error) subscriber.error(error);else
|
1509
|
+
if (error) subscriber.error(error);else if (result) {
|
1510
|
+
// update the cache
|
1511
|
+
for (const [stateKey, encodedResult] of result.changes) dicChangesCache[stateKey] = encodedResult;
|
1512
|
+
|
1513
|
+
// regenerate the full changes array
|
1514
|
+
const changes = lodashEs.toPairs(dicChangesCache);
|
1515
|
+
|
1516
|
+
// decode and emit results for all queries
|
1517
|
+
subscriber.next(decodeRpcQueryPack(queries, {
|
1518
|
+
block: result.block,
|
1519
|
+
changes
|
1520
|
+
}));
|
1521
|
+
}
|
1507
1522
|
}, timeout);
|
1508
1523
|
return () => {
|
1509
1524
|
promUnsub.then(unsub => unsub("state_unsubscribeStorage"));
|
@@ -1502,8 +1502,23 @@ const getRpcQueryPack$ = (connector, networkId, queries, timeout = false) => {
|
|
1502
1502
|
decodeResult
|
1503
1503
|
}) => decodeResult(stateKeys.map(() => null))));
|
1504
1504
|
return new rxjs.Observable(subscriber => {
|
1505
|
+
// first subscription callback includes results for all state keys, but further callbacks will only include the ones that changed
|
1506
|
+
// => we need to keep all results in memory and update them after each callback, so we can emit the full result set each time
|
1507
|
+
const dicChangesCache = {};
|
1505
1508
|
const promUnsub = connector.subscribe(networkId, "state_subscribeStorage", "state_storage", [allStateKeys], (error, result) => {
|
1506
|
-
if (error) subscriber.error(error);else
|
1509
|
+
if (error) subscriber.error(error);else if (result) {
|
1510
|
+
// update the cache
|
1511
|
+
for (const [stateKey, encodedResult] of result.changes) dicChangesCache[stateKey] = encodedResult;
|
1512
|
+
|
1513
|
+
// regenerate the full changes array
|
1514
|
+
const changes = lodashEs.toPairs(dicChangesCache);
|
1515
|
+
|
1516
|
+
// decode and emit results for all queries
|
1517
|
+
subscriber.next(decodeRpcQueryPack(queries, {
|
1518
|
+
block: result.block,
|
1519
|
+
changes
|
1520
|
+
}));
|
1521
|
+
}
|
1507
1522
|
}, timeout);
|
1508
1523
|
return () => {
|
1509
1524
|
promUnsub.then(unsub => unsub("state_unsubscribeStorage"));
|
@@ -2,7 +2,7 @@ import { EvmErc20TokenSchema, parseTokenId, parseEvmErc20TokenId, evmErc20TokenI
|
|
2
2
|
export { MINIMETADATA_VERSION } from '@talismn/chaindata-provider';
|
3
3
|
import { isEthereumAddress, isNotNil, BigMath, isArrayOf, isBigInt, planckToTokens, isAbortError, getSharedObservable, keepAlive, isTruthy, normalizeAddress } from '@talismn/util';
|
4
4
|
import { parseAbi, erc20Abi, getContract, ContractFunctionExecutionError, hexToString, erc20Abi_bytes32, encodeFunctionData, withRetry } from 'viem';
|
5
|
-
import { assign, omit, isEqual, uniq, keyBy, keys, fromPairs, values
|
5
|
+
import { assign, omit, isEqual, uniq, keyBy, toPairs, keys, fromPairs, values } from 'lodash-es';
|
6
6
|
import z from 'zod/v4';
|
7
7
|
import anylogger from 'anylogger';
|
8
8
|
import { of, Observable, distinctUntilChanged, map, timer, switchMap, from, firstValueFrom, combineLatest, BehaviorSubject, shareReplay, startWith, filter, defer, catchError, EMPTY, tap } from 'rxjs';
|
@@ -1493,8 +1493,23 @@ const getRpcQueryPack$ = (connector, networkId, queries, timeout = false) => {
|
|
1493
1493
|
decodeResult
|
1494
1494
|
}) => decodeResult(stateKeys.map(() => null))));
|
1495
1495
|
return new Observable(subscriber => {
|
1496
|
+
// first subscription callback includes results for all state keys, but further callbacks will only include the ones that changed
|
1497
|
+
// => we need to keep all results in memory and update them after each callback, so we can emit the full result set each time
|
1498
|
+
const dicChangesCache = {};
|
1496
1499
|
const promUnsub = connector.subscribe(networkId, "state_subscribeStorage", "state_storage", [allStateKeys], (error, result) => {
|
1497
|
-
if (error) subscriber.error(error);else
|
1500
|
+
if (error) subscriber.error(error);else if (result) {
|
1501
|
+
// update the cache
|
1502
|
+
for (const [stateKey, encodedResult] of result.changes) dicChangesCache[stateKey] = encodedResult;
|
1503
|
+
|
1504
|
+
// regenerate the full changes array
|
1505
|
+
const changes = toPairs(dicChangesCache);
|
1506
|
+
|
1507
|
+
// decode and emit results for all queries
|
1508
|
+
subscriber.next(decodeRpcQueryPack(queries, {
|
1509
|
+
block: result.block,
|
1510
|
+
changes
|
1511
|
+
}));
|
1512
|
+
}
|
1498
1513
|
}, timeout);
|
1499
1514
|
return () => {
|
1500
1515
|
promUnsub.then(unsub => unsub("state_unsubscribeStorage"));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/balances",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-pr2094-20250715164740",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "GPL-3.0-or-later",
|
@@ -34,13 +34,13 @@
|
|
34
34
|
"scale-ts": "^1.6.1",
|
35
35
|
"viem": "^2.27.3",
|
36
36
|
"zod": "^3.25.62",
|
37
|
-
"@talismn/chain-connector": "0.0.0-
|
38
|
-
"@talismn/chain-connector-evm": "0.0.0-
|
39
|
-
"@talismn/chaindata-provider": "0.0.0-
|
40
|
-
"@talismn/sapi": "0.0.0-
|
41
|
-
"@talismn/
|
42
|
-
"@talismn/
|
43
|
-
"@talismn/scale": "0.0.0-
|
37
|
+
"@talismn/chain-connector": "0.0.0-pr2094-20250715164740",
|
38
|
+
"@talismn/chain-connector-evm": "0.0.0-pr2094-20250715164740",
|
39
|
+
"@talismn/chaindata-provider": "0.0.0-pr2094-20250715164740",
|
40
|
+
"@talismn/sapi": "0.0.0-pr2094-20250715164740",
|
41
|
+
"@talismn/util": "0.0.0-pr2094-20250715164740",
|
42
|
+
"@talismn/token-rates": "0.0.0-pr2094-20250715164740",
|
43
|
+
"@talismn/scale": "0.0.0-pr2094-20250715164740"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|
46
46
|
"@polkadot/api-contract": "16.1.2",
|
@@ -55,8 +55,8 @@
|
|
55
55
|
"jest": "^29.7.0",
|
56
56
|
"ts-jest": "^29.2.5",
|
57
57
|
"typescript": "^5.6.3",
|
58
|
-
"@talismn/
|
59
|
-
"@talismn/
|
58
|
+
"@talismn/eslint-config": "0.0.3",
|
59
|
+
"@talismn/tsconfig": "0.0.2"
|
60
60
|
},
|
61
61
|
"peerDependencies": {
|
62
62
|
"@polkadot/api-contract": "*",
|