dedot 0.0.1-alpha.34 → 0.0.1-alpha.35
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 +24 -24
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -20,8 +20,8 @@ _Note: The project is still in active development phase, the information on this
|
|
|
20
20
|
- ✅ Compatible with `@polkadot/extension`-based wallets
|
|
21
21
|
- ✅ Support Metadata V14, V15 (latest)
|
|
22
22
|
- ✅ Build on top of both the [new](https://paritytech.github.io/json-rpc-interface-spec/introduction.html) & legacy (deprecated soon) JSON-RPC APIs
|
|
23
|
-
- ✅ Support light clients (e.g: [smoldot](https://www.npmjs.com/package/smoldot))
|
|
24
|
-
-
|
|
23
|
+
- ✅ Support light clients (e.g: [smoldot](https://www.npmjs.com/package/smoldot)) (_docs coming soon_)
|
|
24
|
+
- ✅ Typed Contract APIs (_docs coming soon_)
|
|
25
25
|
|
|
26
26
|
### Have a quick taste
|
|
27
27
|
|
|
@@ -124,7 +124,7 @@ const api = await LegacyClient.new(provider);
|
|
|
124
124
|
| Transaction APIs (`api.tx`) | ✅ |
|
|
125
125
|
| Events (`api.events`) | ✅ |
|
|
126
126
|
| Errors (`api.errors`) | ✅ |
|
|
127
|
-
| Contract APIs |
|
|
127
|
+
| Contract APIs | ✅ |
|
|
128
128
|
| Metadata v14 | ✅ |
|
|
129
129
|
| Metadata v15 | ✅ |
|
|
130
130
|
| [RPC v2](https://github.com/dedotdev/dedot/issues/20) | ✅ |
|
|
@@ -265,8 +265,8 @@ const alice = keyring.addFromUri('//Alice');
|
|
|
265
265
|
const unsub = await api.tx.balances
|
|
266
266
|
.transferKeepAlive(<destAddress>, 2_000_000_000_000n)
|
|
267
267
|
.signAndSend(alice, async ({ status }) => {
|
|
268
|
-
console.log('Transaction status', status.
|
|
269
|
-
if (status.
|
|
268
|
+
console.log('Transaction status', status.type);
|
|
269
|
+
if (status.type === 'InBlock') {
|
|
270
270
|
console.log(`Transaction completed at block hash ${status.value}`);
|
|
271
271
|
await unsub();
|
|
272
272
|
}
|
|
@@ -282,8 +282,8 @@ const signer = injected.signer;
|
|
|
282
282
|
const unsub = await api.tx.balances
|
|
283
283
|
.transferKeepAlive(<destAddress>, 2_000_000_000_000n)
|
|
284
284
|
.signAndSend(account.address, { signer }, async ({ status }) => {
|
|
285
|
-
console.log('Transaction status', status.
|
|
286
|
-
if (status.
|
|
285
|
+
console.log('Transaction status', status.type);
|
|
286
|
+
if (status.type === 'InBlock') {
|
|
287
287
|
console.log(`Transaction completed at block hash ${status.value}`);
|
|
288
288
|
await unsub();
|
|
289
289
|
}
|
|
@@ -311,8 +311,8 @@ const remarkCall: PolkadotRuntimeRuntimeCallLike = {
|
|
|
311
311
|
|
|
312
312
|
const unsub = api.tx.utility.batch([transferTx.call, remarkCall])
|
|
313
313
|
.signAndSend(account.address, { signer }, async ({ status }) => {
|
|
314
|
-
console.log('Transaction status', status.
|
|
315
|
-
if (status.
|
|
314
|
+
console.log('Transaction status', status.type);
|
|
315
|
+
if (status.type === 'InBlock') {
|
|
316
316
|
console.log(`Transaction completed at block hash ${status.value}`);
|
|
317
317
|
await unsub();
|
|
318
318
|
}
|
|
@@ -329,21 +329,21 @@ import { AccountId32 } from 'dedot/codecs';
|
|
|
329
329
|
const TWO_TOKENS = 2_000_000_000_000n;
|
|
330
330
|
const destAddress = <bobAddress>;
|
|
331
331
|
|
|
332
|
-
const api = await
|
|
332
|
+
const api = await DedotClient.new<WestendAssetHubApi>('...westend-assethub-rpc...');
|
|
333
333
|
|
|
334
334
|
const dest: XcmVersionedLocation = {
|
|
335
|
-
|
|
336
|
-
value: { parents: 1, interior: {
|
|
335
|
+
type: 'V3',
|
|
336
|
+
value: { parents: 1, interior: { type: 'Here' } },
|
|
337
337
|
};
|
|
338
338
|
|
|
339
339
|
const beneficiary: XcmVersionedLocation = {
|
|
340
|
-
|
|
340
|
+
type: 'V3',
|
|
341
341
|
value: {
|
|
342
342
|
parents: 0,
|
|
343
343
|
interior: {
|
|
344
|
-
|
|
344
|
+
type: 'X1',
|
|
345
345
|
value: {
|
|
346
|
-
|
|
346
|
+
type: 'AccountId32',
|
|
347
347
|
value: { id: new AccountId32(destAddress).raw },
|
|
348
348
|
},
|
|
349
349
|
},
|
|
@@ -351,25 +351,25 @@ const beneficiary: XcmVersionedLocation = {
|
|
|
351
351
|
};
|
|
352
352
|
|
|
353
353
|
const assets: XcmVersionedAssets = {
|
|
354
|
-
|
|
354
|
+
type: 'V3',
|
|
355
355
|
value: [
|
|
356
356
|
{
|
|
357
357
|
id: {
|
|
358
|
-
|
|
358
|
+
type: 'Concrete',
|
|
359
359
|
value: {
|
|
360
360
|
parents: 1,
|
|
361
|
-
interior: {
|
|
361
|
+
interior: { type: 'Here' },
|
|
362
362
|
},
|
|
363
363
|
},
|
|
364
364
|
fun: {
|
|
365
|
-
|
|
365
|
+
type: 'Fungible',
|
|
366
366
|
value: TWO_TOKENS,
|
|
367
367
|
},
|
|
368
368
|
},
|
|
369
369
|
],
|
|
370
370
|
};
|
|
371
371
|
|
|
372
|
-
const weight: XcmV3WeightLimit = {
|
|
372
|
+
const weight: XcmV3WeightLimit = { type: 'Unlimited' };
|
|
373
373
|
|
|
374
374
|
api.tx.polkadotXcm
|
|
375
375
|
.limitedTeleportAssets(dest, beneficiary, assets, 0, weight)
|
|
@@ -417,7 +417,7 @@ await api.query.system.events(async (eventRecords) => {
|
|
|
417
417
|
for (const tx of eventRecords) {
|
|
418
418
|
if (api.events.system.ExtrinsicFailed.is(tx.event)) {
|
|
419
419
|
const { dispatchError } = tx.event.palletEvent.data;
|
|
420
|
-
if (dispatchError.
|
|
420
|
+
if (dispatchError.type === 'Module' && api.errors.assets.AlreadyExists.is(dispatchError.value)) {
|
|
421
421
|
console.log('Assets.AlreadyExists error occurred!');
|
|
422
422
|
} else {
|
|
423
423
|
console.log('Other error occurred', dispatchError);
|
|
@@ -446,10 +446,10 @@ const api = await ApiPromise.create({ provider: new WsProvider('wss://rpc.polkad
|
|
|
446
446
|
import { DedotClient, WsProvider } from 'dedot';
|
|
447
447
|
import type { PolkadotApi } from '@dedot/chaintypes';
|
|
448
448
|
|
|
449
|
-
const api = await DedotClient.new<PolkadotApi>(new WsProvider('wss://rpc.polkadot.io')); // or
|
|
449
|
+
const api = await DedotClient.new<PolkadotApi>(new WsProvider('wss://rpc.polkadot.io')); // or DedotClient.create(...) if you prefer
|
|
450
450
|
|
|
451
451
|
// OR
|
|
452
|
-
const api = await DedotClient.new<PolkadotApi>({provider: new WsProvider('wss://rpc.polkadot.io')});
|
|
452
|
+
const api = await DedotClient.new<PolkadotApi>({ provider: new WsProvider('wss://rpc.polkadot.io') });
|
|
453
453
|
```
|
|
454
454
|
|
|
455
455
|
- Notes:
|
|
@@ -472,7 +472,7 @@ Unlike `@polkadot/api` where data are wrapped inside a [codec types](https://pol
|
|
|
472
472
|
| `str` | `string` |
|
|
473
473
|
| Tuple: `(A, B)`, `()` | `[A, B]`, `[]` |
|
|
474
474
|
| Struct: `struct { field_1: u8, field_2: str }` | `{ field_1: number, field_2: string}` |
|
|
475
|
-
| Enum: `enum { Variant1(u8), Variant2(bool), Variant3 }` | `{
|
|
475
|
+
| Enum: `enum { Variant1(u8), Variant2(bool), Variant3 }` | `{ type: 'Variant1', value: number } \| { type: 'Variant2', value: boolean } \| { type: 'Variant2' }` |
|
|
476
476
|
| FlatEnum: `enum { Variant1, Variant2 }` | `'Variant1' \| 'Variant2'` |
|
|
477
477
|
|
|
478
478
|
E.g 1:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dedot",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.35",
|
|
4
4
|
"description": "A delightful JavaScript/TypeScript client for Polkadot & Substrate",
|
|
5
5
|
"author": "Thang X. Vu <thang@coongcrafts.io>",
|
|
6
6
|
"main": "./cjs/index.js",
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"clean": "rm -rf ./dist && rm -rf ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@dedot/api": "0.0.1-alpha.
|
|
19
|
-
"@dedot/cli": "0.0.1-alpha.
|
|
20
|
-
"@dedot/codecs": "0.0.1-alpha.
|
|
21
|
-
"@dedot/contracts": "0.0.1-alpha.
|
|
22
|
-
"@dedot/providers": "0.0.1-alpha.
|
|
23
|
-
"@dedot/runtime-specs": "0.0.1-alpha.
|
|
24
|
-
"@dedot/shape": "0.0.1-alpha.
|
|
25
|
-
"@dedot/types": "0.0.1-alpha.
|
|
26
|
-
"@dedot/utils": "0.0.1-alpha.
|
|
18
|
+
"@dedot/api": "0.0.1-alpha.35",
|
|
19
|
+
"@dedot/cli": "0.0.1-alpha.35",
|
|
20
|
+
"@dedot/codecs": "0.0.1-alpha.35",
|
|
21
|
+
"@dedot/contracts": "0.0.1-alpha.35",
|
|
22
|
+
"@dedot/providers": "0.0.1-alpha.35",
|
|
23
|
+
"@dedot/runtime-specs": "0.0.1-alpha.35",
|
|
24
|
+
"@dedot/shape": "0.0.1-alpha.35",
|
|
25
|
+
"@dedot/types": "0.0.1-alpha.35",
|
|
26
|
+
"@dedot/utils": "0.0.1-alpha.35"
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"directory": "dist"
|
|
87
87
|
},
|
|
88
88
|
"license": "Apache-2.0",
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "bf954b82ac4c8a8e1d989c0c708a099269eb4262",
|
|
90
90
|
"module": "./index.js",
|
|
91
91
|
"types": "./index.d.ts"
|
|
92
92
|
}
|