dedot 0.2.0 → 0.3.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.
- package/README.md +11 -13
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ A delightful JavaScript/TypeScript client for [Polkadot](https://polkadot.networ
|
|
|
12
12
|
_Note: The project is still in active development phase, the information on this page might be outdated. Feel free to raise an [issue](https://github.com/dedotdev/dedot/issues/new) if you run into any problems or want to share any ideas._
|
|
13
13
|
|
|
14
14
|
---
|
|
15
|
+
|
|
15
16
|
### Features
|
|
16
17
|
- ✅ Small bundle size, tree-shakable (no more bn.js or wasm-blob tight dependencies)
|
|
17
18
|
- ✅ Built-in metadata caching mechanism
|
|
@@ -32,19 +33,19 @@ Try `dedot` now on [CodeSandbox Playground](https://codesandbox.io/p/devbox/tryd
|
|
|
32
33
|
- Install `dedot` package
|
|
33
34
|
```shell
|
|
34
35
|
# via yarn
|
|
35
|
-
yarn add dedot
|
|
36
|
+
yarn add dedot
|
|
36
37
|
|
|
37
38
|
# via npm
|
|
38
|
-
npm i dedot
|
|
39
|
+
npm i dedot
|
|
39
40
|
```
|
|
40
41
|
|
|
41
42
|
- Install `@dedot/chaintypes` package for chain types & APIs suggestion. Skip this step if you don't use TypeScript.
|
|
42
43
|
```shell
|
|
43
44
|
# via yarn
|
|
44
|
-
yarn add -D @dedot/chaintypes
|
|
45
|
+
yarn add -D @dedot/chaintypes
|
|
45
46
|
|
|
46
47
|
# via npm
|
|
47
|
-
npm i -D @dedot/chaintypes
|
|
48
|
+
npm i -D @dedot/chaintypes
|
|
48
49
|
```
|
|
49
50
|
|
|
50
51
|
- Initialize the API client and start interacting with Polkadot network
|
|
@@ -104,7 +105,6 @@ const api = await LegacyClient.new(provider);
|
|
|
104
105
|
```
|
|
105
106
|
|
|
106
107
|
### Table of contents
|
|
107
|
-
- [Status](#status)
|
|
108
108
|
- [Chain Types & APIs](#chain-types--apis)
|
|
109
109
|
- [Execute RPC Methods](#execute-rpc-methods)
|
|
110
110
|
- [Query On-chain Storage](#query-on-chain-storage)
|
|
@@ -123,10 +123,10 @@ Each Substrate-based blockchain has their own set of data types & APIs to intera
|
|
|
123
123
|
Types & APIs for each Substrate-based blockchains are defined in package [`@dedot/chaintypes`](https://github.com/dedotdev/chaintypes):
|
|
124
124
|
```shell
|
|
125
125
|
# via yarn
|
|
126
|
-
yarn add -D @dedot/chaintypes
|
|
126
|
+
yarn add -D @dedot/chaintypes
|
|
127
127
|
|
|
128
128
|
# via npm
|
|
129
|
-
npm i -D @dedot/chaintypes
|
|
129
|
+
npm i -D @dedot/chaintypes
|
|
130
130
|
```
|
|
131
131
|
|
|
132
132
|
Initialize a `DedotClient` instance using the `ChainApi` interface for a target chain to enable types & APIs suggestion/autocompletion for that particular chain:
|
|
@@ -253,7 +253,7 @@ const unsub = await api.tx.balances
|
|
|
253
253
|
.signAndSend(alice, async ({ status }) => {
|
|
254
254
|
console.log('Transaction status', status.type);
|
|
255
255
|
if (status.type === 'BestChainBlockIncluded') { // or status.type === 'Finalized'
|
|
256
|
-
console.log(`Transaction completed at block hash ${status.value}`);
|
|
256
|
+
console.log(`Transaction completed at block hash ${status.value.blockHash}`);
|
|
257
257
|
await unsub();
|
|
258
258
|
}
|
|
259
259
|
});
|
|
@@ -270,7 +270,7 @@ const unsub = await api.tx.balances
|
|
|
270
270
|
.signAndSend(account.address, { signer }, async ({ status }) => {
|
|
271
271
|
console.log('Transaction status', status.type);
|
|
272
272
|
if (status.type === 'BestChainBlockIncluded') { // or status.type === 'Finalized'
|
|
273
|
-
console.log(`Transaction completed at block hash ${status.value}`);
|
|
273
|
+
console.log(`Transaction completed at block hash ${status.value.blockHash}`);
|
|
274
274
|
await unsub();
|
|
275
275
|
}
|
|
276
276
|
});
|
|
@@ -299,7 +299,7 @@ const unsub = api.tx.utility.batch([transferTx.call, remarkCall])
|
|
|
299
299
|
.signAndSend(account.address, { signer }, async ({ status }) => {
|
|
300
300
|
console.log('Transaction status', status.type);
|
|
301
301
|
if (status.type === 'BestChainBlockIncluded') { // or status.type === 'Finalized'
|
|
302
|
-
console.log(`Transaction completed at block hash ${status.value}`);
|
|
302
|
+
console.log(`Transaction completed at block hash ${status.value.blockHash}`);
|
|
303
303
|
await unsub();
|
|
304
304
|
}
|
|
305
305
|
});
|
|
@@ -377,9 +377,7 @@ Example to list new accounts created in each block:
|
|
|
377
377
|
// ...
|
|
378
378
|
const ss58Prefix = api.consts.system.ss58Prefix;
|
|
379
379
|
await api.query.system.events(async (eventRecords) => {
|
|
380
|
-
const newAccountEvents = eventRecords
|
|
381
|
-
.map(({ event }) => api.events.system.NewAccount.as(event))
|
|
382
|
-
.filter((one) => one);
|
|
380
|
+
const newAccountEvents = api.events.system.NewAccount.filter(eventRecords);
|
|
383
381
|
|
|
384
382
|
console.log(newAccountEvents.length, 'account(s) was created in block', await api.query.system.number());
|
|
385
383
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dedot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"clean": "rm -rf ./dist && rm -rf ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dedot/api": "0.
|
|
25
|
-
"@dedot/cli": "0.
|
|
26
|
-
"@dedot/codecs": "0.
|
|
27
|
-
"@dedot/contracts": "0.
|
|
28
|
-
"@dedot/providers": "0.
|
|
29
|
-
"@dedot/runtime-specs": "0.
|
|
30
|
-
"@dedot/shape": "0.
|
|
31
|
-
"@dedot/types": "0.
|
|
32
|
-
"@dedot/utils": "0.
|
|
24
|
+
"@dedot/api": "0.3.0",
|
|
25
|
+
"@dedot/cli": "0.3.0",
|
|
26
|
+
"@dedot/codecs": "0.3.0",
|
|
27
|
+
"@dedot/contracts": "0.3.0",
|
|
28
|
+
"@dedot/providers": "0.3.0",
|
|
29
|
+
"@dedot/runtime-specs": "0.3.0",
|
|
30
|
+
"@dedot/shape": "0.3.0",
|
|
31
|
+
"@dedot/types": "0.3.0",
|
|
32
|
+
"@dedot/utils": "0.3.0"
|
|
33
33
|
},
|
|
34
34
|
"exports": {
|
|
35
35
|
".": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"directory": "dist"
|
|
93
93
|
},
|
|
94
94
|
"license": "Apache-2.0",
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "40d0f3c7eee292b7615649e6a5d54887bee75fe2",
|
|
96
96
|
"module": "./index.js",
|
|
97
97
|
"types": "./index.d.ts"
|
|
98
98
|
}
|