@dedot/api 0.0.1-alpha.33 → 0.0.1-alpha.34

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.
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Dedot = void 0;
3
+ exports.LegacyClient = void 0;
4
4
  const codecs_1 = require("@dedot/codecs");
5
5
  const index_js_1 = require("../executor/index.js");
6
6
  const proxychain_js_1 = require("../proxychain.js");
7
7
  const BaseSubstrateClient_js_1 = require("./BaseSubstrateClient.js");
8
8
  const KEEP_ALIVE_INTERVAL = 10_000; // in ms
9
9
  /**
10
- * @name Dedot
10
+ * @name LegacyClient
11
11
  * @description Promised-based API Client for Polkadot & Substrate
12
12
  *
13
13
  * Initialize API instance and interact with substrate-based network
@@ -44,7 +44,7 @@ const KEEP_ALIVE_INTERVAL = 10_000; // in ms
44
44
  * run().catch(console.error);
45
45
  * ```
46
46
  */
47
- class Dedot extends BaseSubstrateClient_js_1.BaseSubstrateClient {
47
+ class LegacyClient extends BaseSubstrateClient_js_1.BaseSubstrateClient {
48
48
  #runtimeSubscriptionUnsub;
49
49
  #healthTimer;
50
50
  #apiAtCache = {};
@@ -62,7 +62,7 @@ class Dedot extends BaseSubstrateClient_js_1.BaseSubstrateClient {
62
62
  * @param options
63
63
  */
64
64
  static async create(options) {
65
- return new Dedot(options).connect();
65
+ return new LegacyClient(options).connect();
66
66
  }
67
67
  /**
68
68
  * Alias for __Dedot.create__
@@ -70,7 +70,7 @@ class Dedot extends BaseSubstrateClient_js_1.BaseSubstrateClient {
70
70
  * @param options
71
71
  */
72
72
  static async new(options) {
73
- return Dedot.create(options);
73
+ return LegacyClient.create(options);
74
74
  }
75
75
  onDisconnected = async () => {
76
76
  await this.#unsubscribeUpdates();
@@ -247,4 +247,4 @@ class Dedot extends BaseSubstrateClient_js_1.BaseSubstrateClient {
247
247
  return api;
248
248
  }
249
249
  }
250
- exports.Dedot = Dedot;
250
+ exports.LegacyClient = LegacyClient;
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Dedot.js"), exports);
17
+ __exportStar(require("./LegacyClient.js"), exports);
18
18
  __exportStar(require("./DedotClient.js"), exports);
@@ -35,13 +35,13 @@ class StorageQueryExecutorV2 extends StorageQueryExecutor_js_1.StorageQueryExecu
35
35
  }, {});
36
36
  }
37
37
  async subscribeStorage(keys, callback) {
38
- let initialHash = await this.chainHead.bestHash();
38
+ let best = await this.chainHead.bestBlock();
39
39
  let eventToListen = 'bestBlock';
40
40
  // TODO subscribe to finalized data source
41
41
  // initialHash = this.chainHead.finalizedHash;
42
42
  // eventToListen = 'finalizedBlock';
43
43
  const latestChanges = {};
44
- const pull = async (hash) => {
44
+ const pull = async ({ hash }) => {
45
45
  const results = await this.queryStorage(keys, hash);
46
46
  let changed = false;
47
47
  keys.forEach((key) => {
@@ -55,7 +55,7 @@ class StorageQueryExecutorV2 extends StorageQueryExecutor_js_1.StorageQueryExecu
55
55
  return;
56
56
  callback(keys.map((key) => latestChanges[key]));
57
57
  };
58
- await pull(initialHash);
58
+ await pull(best);
59
59
  const unsub = this.chainHead.on(eventToListen, pull);
60
60
  return async () => {
61
61
  unsub();
@@ -5,7 +5,7 @@ import type { SubstrateApi } from '../chaintypes/index.js';
5
5
  import type { ApiOptions, ISubstrateClientAt } from '../types.js';
6
6
  import { BaseSubstrateClient } from './BaseSubstrateClient.js';
7
7
  /**
8
- * @name Dedot
8
+ * @name LegacyClient
9
9
  * @description Promised-based API Client for Polkadot & Substrate
10
10
  *
11
11
  * Initialize API instance and interact with substrate-based network
@@ -42,7 +42,7 @@ import { BaseSubstrateClient } from './BaseSubstrateClient.js';
42
42
  * run().catch(console.error);
43
43
  * ```
44
44
  */
45
- export declare class Dedot<ChainApi extends VersionedGenericSubstrateApi = SubstrateApi> extends BaseSubstrateClient<ChainApi> {
45
+ export declare class LegacyClient<ChainApi extends VersionedGenericSubstrateApi = SubstrateApi> extends BaseSubstrateClient<ChainApi> {
46
46
  #private;
47
47
  /**
48
48
  * Use factory methods (`create`, `new`) to create `Dedot` instances.
@@ -55,13 +55,13 @@ export declare class Dedot<ChainApi extends VersionedGenericSubstrateApi = Subst
55
55
  *
56
56
  * @param options
57
57
  */
58
- static create<ChainApi extends VersionedGenericSubstrateApi = SubstrateApi>(options: ApiOptions | JsonRpcProvider): Promise<Dedot<ChainApi>>;
58
+ static create<ChainApi extends VersionedGenericSubstrateApi = SubstrateApi>(options: ApiOptions | JsonRpcProvider): Promise<LegacyClient<ChainApi>>;
59
59
  /**
60
60
  * Alias for __Dedot.create__
61
61
  *
62
62
  * @param options
63
63
  */
64
- static new<ChainApi extends VersionedGenericSubstrateApi = SubstrateApi>(options: ApiOptions | JsonRpcProvider): Promise<Dedot<ChainApi>>;
64
+ static new<ChainApi extends VersionedGenericSubstrateApi = SubstrateApi>(options: ApiOptions | JsonRpcProvider): Promise<LegacyClient<ChainApi>>;
65
65
  protected onDisconnected: () => Promise<void>;
66
66
  protected beforeDisconnect(): Promise<void>;
67
67
  /**
@@ -4,7 +4,7 @@ import { newProxyChain } from '../proxychain.js';
4
4
  import { BaseSubstrateClient } from './BaseSubstrateClient.js';
5
5
  const KEEP_ALIVE_INTERVAL = 10_000; // in ms
6
6
  /**
7
- * @name Dedot
7
+ * @name LegacyClient
8
8
  * @description Promised-based API Client for Polkadot & Substrate
9
9
  *
10
10
  * Initialize API instance and interact with substrate-based network
@@ -41,7 +41,7 @@ const KEEP_ALIVE_INTERVAL = 10_000; // in ms
41
41
  * run().catch(console.error);
42
42
  * ```
43
43
  */
44
- export class Dedot extends BaseSubstrateClient {
44
+ export class LegacyClient extends BaseSubstrateClient {
45
45
  #runtimeSubscriptionUnsub;
46
46
  #healthTimer;
47
47
  #apiAtCache = {};
@@ -59,7 +59,7 @@ export class Dedot extends BaseSubstrateClient {
59
59
  * @param options
60
60
  */
61
61
  static async create(options) {
62
- return new Dedot(options).connect();
62
+ return new LegacyClient(options).connect();
63
63
  }
64
64
  /**
65
65
  * Alias for __Dedot.create__
@@ -67,7 +67,7 @@ export class Dedot extends BaseSubstrateClient {
67
67
  * @param options
68
68
  */
69
69
  static async new(options) {
70
- return Dedot.create(options);
70
+ return LegacyClient.create(options);
71
71
  }
72
72
  onDisconnected = async () => {
73
73
  await this.#unsubscribeUpdates();
package/client/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './Dedot.js';
1
+ export * from './LegacyClient.js';
2
2
  export * from './DedotClient.js';
package/client/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './Dedot.js';
1
+ export * from './LegacyClient.js';
2
2
  export * from './DedotClient.js';
@@ -32,13 +32,13 @@ export class StorageQueryExecutorV2 extends StorageQueryExecutor {
32
32
  }, {});
33
33
  }
34
34
  async subscribeStorage(keys, callback) {
35
- let initialHash = await this.chainHead.bestHash();
35
+ let best = await this.chainHead.bestBlock();
36
36
  let eventToListen = 'bestBlock';
37
37
  // TODO subscribe to finalized data source
38
38
  // initialHash = this.chainHead.finalizedHash;
39
39
  // eventToListen = 'finalizedBlock';
40
40
  const latestChanges = {};
41
- const pull = async (hash) => {
41
+ const pull = async ({ hash }) => {
42
42
  const results = await this.queryStorage(keys, hash);
43
43
  let changed = false;
44
44
  keys.forEach((key) => {
@@ -52,7 +52,7 @@ export class StorageQueryExecutorV2 extends StorageQueryExecutor {
52
52
  return;
53
53
  callback(keys.map((key) => latestChanges[key]));
54
54
  };
55
- await pull(initialHash);
55
+ await pull(best);
56
56
  const unsub = this.chainHead.on(eventToListen, pull);
57
57
  return async () => {
58
58
  unsub();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dedot/api",
3
- "version": "0.0.1-alpha.33",
3
+ "version": "0.0.1-alpha.34",
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.33",
17
- "@dedot/providers": "0.0.1-alpha.33",
18
- "@dedot/runtime-specs": "0.0.1-alpha.33",
19
- "@dedot/shape": "0.0.1-alpha.33",
20
- "@dedot/storage": "0.0.1-alpha.33",
21
- "@dedot/types": "0.0.1-alpha.33",
22
- "@dedot/utils": "0.0.1-alpha.33"
16
+ "@dedot/codecs": "0.0.1-alpha.34",
17
+ "@dedot/providers": "0.0.1-alpha.34",
18
+ "@dedot/runtime-specs": "0.0.1-alpha.34",
19
+ "@dedot/shape": "0.0.1-alpha.34",
20
+ "@dedot/storage": "0.0.1-alpha.34",
21
+ "@dedot/types": "0.0.1-alpha.34",
22
+ "@dedot/utils": "0.0.1-alpha.34"
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": "^11.2.1"
50
50
  },
51
- "gitHead": "36b30a0cec2d8652915e3660329b78f1c6e4221f",
51
+ "gitHead": "053078f3aed79a3044314421967325b9fe0e6f57",
52
52
  "module": "./index.js",
53
53
  "types": "./index.d.ts"
54
54
  }