dedot 0.18.8 → 1.0.0

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.
Files changed (2) hide show
  1. package/README.md +13 -9
  2. package/package.json +14 -14
package/README.md CHANGED
@@ -28,6 +28,7 @@ Delightful JavaScript/TypeScript client for [Polkadot](https://polkadot.com/) &
28
28
 
29
29
  ### Features
30
30
 
31
+ - ✅ Fully support [light clients](https://docs.dedot.dev/getting-started/connect-to-network#smoldot) (e.g: [smoldot](https://www.npmjs.com/package/smoldot))
31
32
  - ✅ Small bundle size, tree-shakable (no more bn.js or wasm-blob tight dependencies)
32
33
  - ✅ Types & APIs suggestions for each individual Polkadot SDK-based blockchain
33
34
  network ([@dedot/chaintypes](https://github.com/dedotdev/chaintypes))
@@ -38,7 +39,6 @@ Delightful JavaScript/TypeScript client for [Polkadot](https://polkadot.com/) &
38
39
  - ✅ Built-in metadata optimization ([caching](https://docs.dedot.dev/getting-started/connect-to-network#caching-metadata))
39
40
  - ✅ Build on top of both the [new](https://paritytech.github.io/json-rpc-interface-spec/introduction.html) & [legacy](https://github.com/w3f/PSPs/blob/master/PSPs/drafts/psp-6.md) (
40
41
  deprecated soon) JSON-RPC APIs
41
- - ✅ Support [light clients](https://docs.dedot.dev/getting-started/connect-to-network#initializing-dedotclient-and-interact-with-polkadot-network) (e.g: [smoldot](https://www.npmjs.com/package/smoldot))
42
42
  - ✅ [Unified Typesafe Contract APIs](https://docs.dedot.dev/smart-contracts/intro) for ink! v5 (WASM, pallet-contracts), ink! v6 and solidity contracts (PVM, pallet-revive)
43
43
  - ✅ Fully-typed low-level [JSON-RPC client](https://docs.dedot.dev/clients-and-providers/clients#jsonrpcclient)
44
44
 
@@ -63,19 +63,19 @@ npm i -D @dedot/chaintypes
63
63
  ```
64
64
  2. Connect to the network
65
65
  ```typescript
66
- import { DedotClient, WsProvider, PinnedBlock } from 'dedot';
66
+ import { DedotClient, WsProvider } from 'dedot';
67
67
  import type { PolkadotApi } from '@dedot/chaintypes';
68
68
 
69
69
  const provider = new WsProvider('wss://rpc.polkadot.io');
70
70
  const client = await DedotClient.new<PolkadotApi>(provider);
71
71
 
72
- // Call rpc `state_getMetadata` to fetch raw scale-encoded metadata and decode it.
73
- const metadata = await client.rpc.state_getMetadata();
74
- console.log('Metadata:', metadata);
72
+ // Get current best block
73
+ const bestBlock = await client.block.best();
74
+ console.log('Best block:', bestBlock.number, bestBlock.hash);
75
75
 
76
- // Listen to best blocks
77
- client.on('bestBlock', (block: PinnedBlock) => { // or 'finalizedBlock'
78
- console.log(`Current best block number: ${block.number}, hash: ${block.hash}`);
76
+ // Subscribe to finalized blocks
77
+ const unsub = client.block.finalized((block) => {
78
+ console.log('Finalized block:', block.number);
79
79
  });
80
80
 
81
81
  // Query on-chain storage
@@ -87,9 +87,13 @@ const ss58Prefix = client.consts.system.ss58Prefix;
87
87
  console.log('Polkadot ss58Prefix:', ss58Prefix);
88
88
 
89
89
  // Call runtime api
90
- const pendingRewards = await client.call.nominationPoolsApi.pendingRewards(<address>)
90
+ const pendingRewards = await client.call.nominationPoolsApi.pendingRewards(<address>);
91
91
  console.log('Pending rewards:', pendingRewards);
92
92
 
93
+ // Sign and send transaction
94
+ const result = await client.tx.balances.transferKeepAlive(<dest>, 1_000_000_000_000n)
95
+ .signAndSend(signer).untilFinalized();
96
+
93
97
  // Disconnect
94
98
  await client.disconnect();
95
99
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dedot",
3
- "version": "0.18.8",
3
+ "version": "1.0.0",
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",
@@ -21,18 +21,18 @@
21
21
  "clean": "rm -rf ./dist && rm -rf ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo"
22
22
  },
23
23
  "dependencies": {
24
- "@dedot/api": "0.18.8",
25
- "@dedot/cli": "0.18.8",
26
- "@dedot/codecs": "0.18.8",
27
- "@dedot/contracts": "0.18.8",
28
- "@dedot/merkleized-metadata": "0.18.8",
29
- "@dedot/providers": "0.18.8",
30
- "@dedot/runtime-specs": "0.18.8",
31
- "@dedot/shape": "0.18.8",
32
- "@dedot/smoldot": "0.18.8",
33
- "@dedot/types": "0.18.8",
34
- "@dedot/utils": "0.18.8",
35
- "smoldot": "^2.0.39"
24
+ "@dedot/api": "1.0.0",
25
+ "@dedot/cli": "1.0.0",
26
+ "@dedot/codecs": "1.0.0",
27
+ "@dedot/contracts": "1.0.0",
28
+ "@dedot/merkleized-metadata": "1.0.0",
29
+ "@dedot/providers": "1.0.0",
30
+ "@dedot/runtime-specs": "1.0.0",
31
+ "@dedot/shape": "1.0.0",
32
+ "@dedot/smoldot": "1.0.0",
33
+ "@dedot/types": "1.0.0",
34
+ "@dedot/utils": "1.0.0",
35
+ "smoldot": "^2.0.40"
36
36
  },
37
37
  "exports": {
38
38
  ".": {
@@ -122,7 +122,7 @@
122
122
  "node": ">=18"
123
123
  },
124
124
  "license": "Apache-2.0",
125
- "gitHead": "5f87f515d4ce4183038681dd02b20bb682a5fdce",
125
+ "gitHead": "7767062a2188b4ac90561c5ad3cc3f06ac608a24",
126
126
  "module": "./index.js",
127
127
  "types": "./index.d.ts"
128
128
  }