@dedot/api 0.0.1-alpha.35 → 0.0.1-alpha.36

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.
@@ -40,20 +40,20 @@ class StorageQueryExecutorV2 extends StorageQueryExecutor_js_1.StorageQueryExecu
40
40
  // TODO subscribe to finalized data source
41
41
  // initialHash = this.chainHead.finalizedHash;
42
42
  // eventToListen = 'finalizedBlock';
43
- const latestChanges = {};
43
+ const latestChanges = new Map();
44
44
  const pull = async ({ hash }) => {
45
45
  const results = await this.queryStorage(keys, hash);
46
46
  let changed = false;
47
47
  keys.forEach((key) => {
48
48
  const newValue = results[key];
49
- if (latestChanges[key] === newValue)
49
+ if (latestChanges.size > 0 && latestChanges.get(key) === newValue)
50
50
  return;
51
51
  changed = true;
52
- latestChanges[key] = newValue;
52
+ latestChanges.set(key, newValue);
53
53
  });
54
54
  if (!changed)
55
55
  return;
56
- callback(keys.map((key) => latestChanges[key]));
56
+ callback(keys.map((key) => latestChanges.get(key)));
57
57
  };
58
58
  await pull(best);
59
59
  const unsub = this.chainHead.on(eventToListen, pull);
@@ -37,20 +37,20 @@ export class StorageQueryExecutorV2 extends StorageQueryExecutor {
37
37
  // TODO subscribe to finalized data source
38
38
  // initialHash = this.chainHead.finalizedHash;
39
39
  // eventToListen = 'finalizedBlock';
40
- const latestChanges = {};
40
+ const latestChanges = new Map();
41
41
  const pull = async ({ hash }) => {
42
42
  const results = await this.queryStorage(keys, hash);
43
43
  let changed = false;
44
44
  keys.forEach((key) => {
45
45
  const newValue = results[key];
46
- if (latestChanges[key] === newValue)
46
+ if (latestChanges.size > 0 && latestChanges.get(key) === newValue)
47
47
  return;
48
48
  changed = true;
49
- latestChanges[key] = newValue;
49
+ latestChanges.set(key, newValue);
50
50
  });
51
51
  if (!changed)
52
52
  return;
53
- callback(keys.map((key) => latestChanges[key]));
53
+ callback(keys.map((key) => latestChanges.get(key)));
54
54
  };
55
55
  await pull(best);
56
56
  const unsub = this.chainHead.on(eventToListen, pull);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dedot/api",
3
- "version": "0.0.1-alpha.35",
3
+ "version": "0.0.1-alpha.36",
4
4
  "description": "A delightful JavaScript/TypeScript client for Polkadot & Substrate",
5
5
  "author": "Thang X. Vu <thang@coongcrafts.io>",
6
6
  "homepage": "https://github.com/dedotdev/dedot",
@@ -13,13 +13,13 @@
13
13
  "type": "module",
14
14
  "sideEffects": false,
15
15
  "dependencies": {
16
- "@dedot/codecs": "0.0.1-alpha.35",
17
- "@dedot/providers": "0.0.1-alpha.35",
18
- "@dedot/runtime-specs": "0.0.1-alpha.35",
19
- "@dedot/shape": "0.0.1-alpha.35",
20
- "@dedot/storage": "0.0.1-alpha.35",
21
- "@dedot/types": "0.0.1-alpha.35",
22
- "@dedot/utils": "0.0.1-alpha.35"
16
+ "@dedot/codecs": "0.0.1-alpha.36",
17
+ "@dedot/providers": "0.0.1-alpha.36",
18
+ "@dedot/runtime-specs": "0.0.1-alpha.36",
19
+ "@dedot/shape": "0.0.1-alpha.36",
20
+ "@dedot/storage": "0.0.1-alpha.36",
21
+ "@dedot/types": "0.0.1-alpha.36",
22
+ "@dedot/utils": "0.0.1-alpha.36"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsc --project tsconfig.build.json && tsc --project tsconfig.build.cjs.json",
@@ -48,7 +48,7 @@
48
48
  "devDependencies": {
49
49
  "@polkadot/types": "^12.0.1"
50
50
  },
51
- "gitHead": "bf954b82ac4c8a8e1d989c0c708a099269eb4262",
51
+ "gitHead": "798f0b8ce218baf212b8853e4e6eb0cf45157f6e",
52
52
  "module": "./index.js",
53
53
  "types": "./index.d.ts"
54
54
  }