@dedot/api 1.0.0-next.a0f8d41e.25 → 1.0.1

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.
@@ -7,7 +7,7 @@ import { ChainJsonRpcApis } from './json-rpc.js';
7
7
  import { ChainStorage } from './query.js';
8
8
  import { RuntimeApis } from './runtime.js';
9
9
  import { ChainTx } from './tx.js';
10
- import type { FrameMetadataHashExtensionCheckMetadataHash, FrameSupportTokensFungibleUnionOfNativeOrWithId, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckMortality, FrameSystemExtensionsCheckNonZeroSender, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckTxVersion, FrameSystemExtensionsCheckWeight, FrameSystemExtensionsWeightReclaim, KitchensinkRuntimeRuntimeCall, PalletAssetConversionTxPaymentChargeAssetTxPayment, SpRuntimeMultiSignature } from './types.js';
10
+ import type { FrameMetadataHashExtensionCheckMetadataHash, FrameSupportTokensFungibleUnionOfNativeOrWithId, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckMortality, FrameSystemExtensionsCheckNonZeroSender, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckTxVersion, FrameSystemExtensionsCheckWeight, FrameSystemExtensionsWeightReclaim, KitchensinkRuntimeRuntimeCall, PalletAssetConversionTxPaymentChargeAssetTxPayment, SpRuntimeMultiSignature } from './types.js';
11
11
  import { ChainViewFunctions } from './view-functions.js';
12
12
  export * from './types.js';
13
13
  interface ChainKnownTypes extends GenericChainKnownTypes {
@@ -27,6 +27,7 @@ interface ChainKnownTypes extends GenericChainKnownTypes {
27
27
  FrameSystemExtensionsWeightReclaim
28
28
  ];
29
29
  AssetId: FrameSupportTokensFungibleUnionOfNativeOrWithId;
30
+ EventRecord: FrameSystemEventRecord;
30
31
  }
31
32
  /**
32
33
  * @name: SubstrateApi
@@ -29,10 +29,10 @@ class StorageQueryExecutorV2 extends StorageQueryExecutor_js_1.StorageQueryExecu
29
29
  ]);
30
30
  };
31
31
  const pagedKeys = () => {
32
- throw new utils_1.DedotError('The pagedKeys method is not yet available via the new JSON-RPC specification. Please use the LegacyClient instead.');
32
+ throw new utils_1.DedotError('The pagedKeys method is not yet available via the new JSON-RPC (v2) specification. Please use the legacy client instead.');
33
33
  };
34
34
  const pagedEntries = () => {
35
- throw new utils_1.DedotError('The pagedEntries method is not yet available via the new JSON-RPC specification. Please use the LegacyClient instead.');
35
+ throw new utils_1.DedotError('The pagedEntries method is not yet available via the new JSON-RPC (v2) specification. Please use the legacy client instead.');
36
36
  };
37
37
  return { entries, pagedKeys, pagedEntries };
38
38
  }
@@ -883,7 +883,7 @@ class ChainHead extends JsonRpcGroup_js_1.JsonRpcGroup {
883
883
  let queryItems = items;
884
884
  while (queryItems.length > 0) {
885
885
  const [newBatch, newDiscardedItems] = await this.#getStorage(queryItems, childTrie ?? null, hash);
886
- results.push(...newBatch);
886
+ results = results.concat(newBatch);
887
887
  queryItems = newDiscardedItems;
888
888
  }
889
889
  }
@@ -1,7 +1,7 @@
1
1
  import { BlockHash, Extrinsic, Hash, Metadata, PortableRegistry, RuntimeVersion } from '@dedot/codecs';
2
2
  import { type JsonRpcProvider } from '@dedot/providers';
3
3
  import { type IStorage } from '@dedot/storage';
4
- import { Callback, GenericStorageQuery, GenericSubstrateApi, InjectedSigner, Query, QueryFnResult, RpcVersion, TxUnsub, Unsub } from '@dedot/types';
4
+ import { Callback, GenericStorageQuery, GenericSubstrateApi, InjectedSigner, ISubmittableResult, Query, QueryFnResult, RpcVersion, TxUnsub, Unsub } from '@dedot/types';
5
5
  import { Deferred, HexString, LRUCache } from '@dedot/utils';
6
6
  import type { SubstrateApi } from '../chaintypes/index.js';
7
7
  import { JsonRpcClient } from '../json-rpc/index.js';
@@ -132,7 +132,7 @@ export declare abstract class BaseSubstrateClient<ChainApi extends GenericSubstr
132
132
  [K in keyof Fns]: QueryFnResult<Fns[K]>;
133
133
  }>): Promise<Unsub>;
134
134
  protected getStorageQuery(): BaseStorageQuery;
135
- sendTx(tx: HexString | Extrinsic, callback?: Callback): TxUnsub;
135
+ sendTx(tx: HexString | Extrinsic, callback?: Callback<ISubmittableResult<ChainApi['types']['EventRecord']>>): TxUnsub;
136
136
  get chainSpec(): IChainSpec;
137
137
  on<Event extends Events = Events>(event: Event, handler: EventHandlerFn<Event>): () => void;
138
138
  }
@@ -1,6 +1,6 @@
1
1
  import { type Extrinsic, Metadata, PortableRegistry } from '@dedot/codecs';
2
2
  import { ConnectionStatus, JsonRpcProvider } from '@dedot/providers';
3
- import { Callback, GenericStorageQuery, GenericSubstrateApi, InjectedSigner, Query, QueryFnResult, RpcVersion, TxUnsub, Unsub } from '@dedot/types';
3
+ import { Callback, GenericStorageQuery, GenericSubstrateApi, InjectedSigner, ISubmittableResult, Query, QueryFnResult, RpcVersion, TxUnsub, Unsub } from '@dedot/types';
4
4
  import { HexString } from '@dedot/utils';
5
5
  import { SubstrateApi } from '../chaintypes/index.js';
6
6
  import { ApiEvent, ApiOptions, BlockExplorer, ISubstrateClient, ISubstrateClientAt, SubstrateRuntimeVersion, IChainSpec, type EventHandlerFn } from '../types.js';
@@ -269,7 +269,7 @@ export declare class DedotClient<ChainApi extends GenericSubstrateApi = Substrat
269
269
  * @param handler - The handler function to remove (optional, removes all handlers if not provided)
270
270
  * @returns This client instance for method chaining
271
271
  */
272
- off(event: ApiEvent, handler?: ((...args: any[]) => void) | undefined): this;
272
+ off<Event extends ApiEvent = ApiEvent>(event: Event, handler?: EventHandlerFn<Event>): this;
273
273
  /**
274
274
  * Get a client instance at a specific block hash.
275
275
  *
@@ -358,7 +358,7 @@ export declare class DedotClient<ChainApi extends GenericSubstrateApi = Substrat
358
358
  * });
359
359
  * ```
360
360
  */
361
- sendTx(tx: HexString | Extrinsic, callback?: Callback): TxUnsub;
361
+ sendTx(tx: HexString | Extrinsic, callback?: Callback<ISubmittableResult<ChainApi['types']['EventRecord']>>): TxUnsub;
362
362
  /**
363
363
  * Clear internal caches.
364
364
  *
@@ -1,6 +1,6 @@
1
1
  import { BlockHash, type Extrinsic, Metadata } from '@dedot/codecs';
2
2
  import type { JsonRpcProvider } from '@dedot/providers';
3
- import { Callback, GenericSubstrateApi, TxUnsub } from '@dedot/types';
3
+ import { Callback, GenericSubstrateApi, ISubmittableResult, TxUnsub } from '@dedot/types';
4
4
  import { HexString } from '@dedot/utils';
5
5
  import type { SubstrateApi } from '../chaintypes/index.js';
6
6
  import { BaseStorageQuery } from '../storage/index.js';
@@ -136,5 +136,5 @@ export declare class LegacyClient<ChainApi extends GenericSubstrateApi = Substra
136
136
  */
137
137
  at<ChainApiAt extends GenericSubstrateApi = ChainApi>(hash: BlockHash): Promise<ISubstrateClientAt<ChainApiAt>>;
138
138
  protected getStorageQuery(): BaseStorageQuery;
139
- sendTx(tx: HexString | Extrinsic, callback?: Callback): TxUnsub;
139
+ sendTx(tx: HexString | Extrinsic, callback?: Callback<ISubmittableResult<ChainApi['types']['EventRecord']>>): TxUnsub;
140
140
  }
@@ -1,6 +1,6 @@
1
1
  import { BlockHash, type Extrinsic, Metadata } from '@dedot/codecs';
2
2
  import type { JsonRpcProvider } from '@dedot/providers';
3
- import { Callback, GenericSubstrateApi, TxUnsub } from '@dedot/types';
3
+ import { Callback, GenericSubstrateApi, ISubmittableResult, TxUnsub } from '@dedot/types';
4
4
  import { HexString } from '@dedot/utils';
5
5
  import type { SubstrateApi } from '../chaintypes/index.js';
6
6
  import { Archive, ChainHead, ChainSpec, PinnedBlock } from '../json-rpc/index.js';
@@ -71,5 +71,5 @@ export declare class V2Client<ChainApi extends GenericSubstrateApi = SubstrateAp
71
71
  */
72
72
  at<ChainApiAt extends GenericSubstrateApi = ChainApi>(hash: BlockHash): Promise<ISubstrateClientAt<ChainApiAt>>;
73
73
  protected getStorageQuery(): BaseStorageQuery;
74
- sendTx(tx: HexString | Extrinsic, callback?: Callback): TxUnsub;
74
+ sendTx(tx: HexString | Extrinsic, callback?: Callback<ISubmittableResult<ChainApi['types']['EventRecord']>>): TxUnsub;
75
75
  }
@@ -26,10 +26,10 @@ export class StorageQueryExecutorV2 extends StorageQueryExecutor {
26
26
  ]);
27
27
  };
28
28
  const pagedKeys = () => {
29
- throw new DedotError('The pagedKeys method is not yet available via the new JSON-RPC specification. Please use the LegacyClient instead.');
29
+ throw new DedotError('The pagedKeys method is not yet available via the new JSON-RPC (v2) specification. Please use the legacy client instead.');
30
30
  };
31
31
  const pagedEntries = () => {
32
- throw new DedotError('The pagedEntries method is not yet available via the new JSON-RPC specification. Please use the LegacyClient instead.');
32
+ throw new DedotError('The pagedEntries method is not yet available via the new JSON-RPC (v2) specification. Please use the legacy client instead.');
33
33
  };
34
34
  return { entries, pagedKeys, pagedEntries };
35
35
  }
@@ -1,5 +1,5 @@
1
1
  import { Extrinsic, Preamble } from '@dedot/codecs';
2
- import { Callback, IRuntimeTxCall, TxHash, TxUnsub } from '@dedot/types';
2
+ import { Callback, IRuntimeTxCall, ISubmittableResult, TxHash, TxUnsub } from '@dedot/types';
3
3
  import { HexString } from '@dedot/utils';
4
4
  import { V2Client } from '../../client/V2Client.js';
5
5
  import { BaseSubmittableExtrinsic } from './BaseSubmittableExtrinsic.js';
@@ -13,5 +13,5 @@ export declare class SubmittableExtrinsicV2 extends BaseSubmittableExtrinsic {
13
13
  constructor(client: V2Client<any>, call: IRuntimeTxCall, preamble?: Preamble);
14
14
  static fromTx(client: V2Client<any>, tx: HexString | Extrinsic): SubmittableExtrinsicV2;
15
15
  send(): TxHash;
16
- send(callback: Callback): TxUnsub;
16
+ send(callback: Callback<ISubmittableResult>): TxUnsub;
17
17
  }
@@ -880,7 +880,7 @@ export class ChainHead extends JsonRpcGroup {
880
880
  let queryItems = items;
881
881
  while (queryItems.length > 0) {
882
882
  const [newBatch, newDiscardedItems] = await this.#getStorage(queryItems, childTrie ?? null, hash);
883
- results.push(...newBatch);
883
+ results = results.concat(newBatch);
884
884
  queryItems = newDiscardedItems;
885
885
  }
886
886
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dedot/api",
3
- "version": "1.0.0-next.a0f8d41e.25+a0f8d41e",
3
+ "version": "1.0.1",
4
4
  "description": "A delightful JavaScript/TypeScript client for Polkadot & Substrate",
5
5
  "author": "Thang X. Vu <thang@dedot.dev>",
6
6
  "homepage": "https://dedot.dev",
@@ -13,13 +13,13 @@
13
13
  "type": "module",
14
14
  "sideEffects": false,
15
15
  "dependencies": {
16
- "@dedot/codecs": "1.0.0-next.a0f8d41e.25+a0f8d41e",
17
- "@dedot/providers": "1.0.0-next.a0f8d41e.25+a0f8d41e",
18
- "@dedot/runtime-specs": "1.0.0-next.a0f8d41e.25+a0f8d41e",
19
- "@dedot/shape": "1.0.0-next.a0f8d41e.25+a0f8d41e",
20
- "@dedot/storage": "1.0.0-next.a0f8d41e.25+a0f8d41e",
21
- "@dedot/types": "1.0.0-next.a0f8d41e.25+a0f8d41e",
22
- "@dedot/utils": "1.0.0-next.a0f8d41e.25+a0f8d41e"
16
+ "@dedot/codecs": "1.0.1",
17
+ "@dedot/providers": "1.0.1",
18
+ "@dedot/runtime-specs": "1.0.1",
19
+ "@dedot/shape": "1.0.1",
20
+ "@dedot/storage": "1.0.1",
21
+ "@dedot/types": "1.0.1",
22
+ "@dedot/utils": "1.0.1"
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
  "node": ">=18"
49
49
  },
50
50
  "license": "Apache-2.0",
51
- "gitHead": "a0f8d41e632a44c03ccc31ee77bcb7d19df936e9",
51
+ "gitHead": "f9f1bd894a76672675008e1f94d4f98422e9655e",
52
52
  "module": "./index.js",
53
53
  "types": "./index.d.ts"
54
54
  }
package/types.d.ts CHANGED
@@ -2,7 +2,7 @@ import { BlockHash, Extrinsic, Hash, Header, Metadata, PortableRegistry } from '
2
2
  import type { ConnectionStatus, JsonRpcProvider, ProviderEvent } from '@dedot/providers';
3
3
  import type { AnyShape } from '@dedot/shape';
4
4
  import type { IStorage } from '@dedot/storage';
5
- import { Callback, GenericStorageQuery, GenericSubstrateApi, InjectedSigner, Query, QueryFnResult, RpcVersion, RuntimeApiName, RuntimeApiSpec, TxUnsub, Unsub } from '@dedot/types';
5
+ import { Callback, GenericStorageQuery, GenericSubstrateApi, InjectedSigner, ISubmittableResult, Query, QueryFnResult, RpcVersion, RuntimeApiName, RuntimeApiSpec, TxUnsub, Unsub } from '@dedot/types';
6
6
  import { Properties } from '@dedot/types/json-rpc';
7
7
  import type { HashFn, HexString, IEventEmitter } from '@dedot/utils';
8
8
  import type { SubstrateApi } from './chaintypes/index.js';
@@ -224,7 +224,7 @@ Events extends string = ApiEvent> extends IJsonRpcClient<ChainApi, Events>, IGen
224
224
  * const result = await client.sendTx(rawTxHex).untilFinalized();
225
225
  * console.log('Transaction finalized:', result);
226
226
  */
227
- sendTx(tx: HexString | Extrinsic, callback?: Callback): TxUnsub;
227
+ sendTx(tx: HexString | Extrinsic, callback?: Callback<ISubmittableResult<ChainApi['types']['EventRecord']>>): TxUnsub;
228
228
  /**
229
229
  * Query multiple storage items in a single call or subscribe to multiple storage items
230
230
  *