@dedot/api 0.0.1-next.9c1d51fe.10 → 0.0.1-next.a5b1d2fb.22
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/chaintypes/substrate/consts.js +1 -0
- package/chaintypes/substrate/errors.js +1 -0
- package/chaintypes/substrate/events.js +1 -0
- package/chaintypes/substrate/index.js +1 -0
- package/chaintypes/substrate/json-rpc.d.ts +1 -1
- package/chaintypes/substrate/json-rpc.js +1 -0
- package/chaintypes/substrate/query.js +1 -0
- package/chaintypes/substrate/runtime.js +1 -0
- package/chaintypes/substrate/tx.js +1 -0
- package/chaintypes/substrate/types.js +1 -0
- package/cjs/chaintypes/substrate/consts.js +1 -0
- package/cjs/chaintypes/substrate/errors.js +1 -0
- package/cjs/chaintypes/substrate/events.js +1 -0
- package/cjs/chaintypes/substrate/index.js +1 -0
- package/cjs/chaintypes/substrate/json-rpc.js +1 -0
- package/cjs/chaintypes/substrate/query.js +1 -0
- package/cjs/chaintypes/substrate/runtime.js +1 -0
- package/cjs/chaintypes/substrate/tx.js +1 -0
- package/cjs/chaintypes/substrate/types.js +1 -0
- package/cjs/client/BaseSubstrateClient.js +2 -2
- package/cjs/client/{Dedot.js → LegacyClient.js} +8 -8
- package/cjs/client/index.js +1 -1
- package/cjs/executor/v2/StorageQueryExecutorV2.js +3 -3
- package/cjs/extrinsic/extensions/known/CheckMetadataHash.js +31 -0
- package/cjs/extrinsic/extensions/known/StorageWeightReclaim.js +10 -0
- package/cjs/extrinsic/extensions/known/index.js +4 -0
- package/cjs/extrinsic/submittable/utils.js +2 -3
- package/client/{Dedot.d.ts → LegacyClient.d.ts} +6 -6
- package/client/{Dedot.js → LegacyClient.js} +6 -6
- package/client/index.d.ts +1 -1
- package/client/index.js +1 -1
- package/executor/v2/StorageQueryExecutorV2.js +3 -3
- package/extrinsic/extensions/known/CheckMetadataHash.d.ts +13 -0
- package/extrinsic/extensions/known/CheckMetadataHash.js +27 -0
- package/extrinsic/extensions/known/StorageWeightReclaim.d.ts +6 -0
- package/extrinsic/extensions/known/StorageWeightReclaim.js +6 -0
- package/extrinsic/extensions/known/index.js +4 -0
- package/package.json +10 -10
- package/proxychain.d.ts +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { GenericJsonRpcApis, RpcVersion } from '@dedot/types';
|
|
2
2
|
import type { JsonRpcApis } from '@dedot/types/json-rpc';
|
|
3
|
-
export type ChainJsonRpcApis<Rv extends RpcVersion> = Pick<JsonRpcApis, 'author_hasKey' | 'author_hasSessionKeys' | 'author_insertKey' | 'author_pendingExtrinsics' | 'author_removeExtrinsic' | 'author_rotateKeys' | 'author_submitAndWatchExtrinsic' | 'author_submitExtrinsic' | 'babe_epochAuthorship' | 'beefy_getFinalizedHead' | 'beefy_subscribeJustifications' | '
|
|
3
|
+
export type ChainJsonRpcApis<Rv extends RpcVersion> = Pick<JsonRpcApis, 'author_hasKey' | 'author_hasSessionKeys' | 'author_insertKey' | 'author_pendingExtrinsics' | 'author_removeExtrinsic' | 'author_rotateKeys' | 'author_submitAndWatchExtrinsic' | 'author_submitExtrinsic' | 'babe_epochAuthorship' | 'beefy_getFinalizedHead' | 'beefy_subscribeJustifications' | 'chainHead_v1_body' | 'chainHead_v1_call' | 'chainHead_v1_continue' | 'chainHead_v1_follow' | 'chainHead_v1_header' | 'chainHead_v1_stopOperation' | 'chainHead_v1_storage' | 'chainHead_v1_unpin' | 'chainSpec_v1_chainName' | 'chainSpec_v1_genesisHash' | 'chainSpec_v1_properties' | 'chain_getBlock' | 'chain_getBlockHash' | 'chain_getFinalizedHead' | 'chain_getHeader' | 'chain_subscribeAllHeads' | 'chain_subscribeFinalizedHeads' | 'chain_subscribeNewHeads' | 'childstate_getKeys' | 'childstate_getKeysPaged' | 'childstate_getStorage' | 'childstate_getStorageEntries' | 'childstate_getStorageHash' | 'childstate_getStorageSize' | 'dev_getBlockStats' | 'grandpa_proveFinality' | 'grandpa_roundState' | 'grandpa_subscribeJustifications' | 'mmr_generateProof' | 'mmr_root' | 'mmr_verifyProof' | 'mmr_verifyProofStateless' | 'offchain_localStorageGet' | 'offchain_localStorageSet' | 'payment_queryFeeDetails' | 'payment_queryInfo' | 'rpc_methods' | 'state_call' | 'state_getChildReadProof' | 'state_getKeys' | 'state_getKeysPaged' | 'state_getMetadata' | 'state_getPairs' | 'state_getReadProof' | 'state_getRuntimeVersion' | 'state_getStorage' | 'state_getStorageHash' | 'state_getStorageSize' | 'state_queryStorage' | 'state_queryStorageAt' | 'state_subscribeRuntimeVersion' | 'state_subscribeStorage' | 'state_traceBlock' | 'state_trieMigrationStatus' | 'statement_broadcasts' | 'statement_dump' | 'statement_posted' | 'statement_postedClear' | 'statement_remove' | 'statement_submit' | 'sync_state_genSyncSpec' | 'system_accountNextIndex' | 'system_addLogFilter' | 'system_addReservedPeer' | 'system_chain' | 'system_chainType' | 'system_dryRun' | 'system_health' | 'system_localListenAddresses' | 'system_localPeerId' | 'system_name' | 'system_nodeRoles' | 'system_peers' | 'system_properties' | 'system_removeReservedPeer' | 'system_reservedPeers' | 'system_resetLogFilter' | 'system_syncState' | 'system_unstable_networkState' | 'system_version' | 'transactionWatch_v1_submitAndWatch' | 'transaction_v1_broadcast' | 'transaction_v1_stop'> & GenericJsonRpcApis<Rv>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseSubstrateClient =
|
|
3
|
+
exports.BaseSubstrateClient = void 0;
|
|
4
|
+
exports.ensurePresence = ensurePresence;
|
|
4
5
|
const codecs_1 = require("@dedot/codecs");
|
|
5
6
|
const storage_1 = require("@dedot/storage");
|
|
6
7
|
const utils_1 = require("@dedot/utils");
|
|
@@ -13,7 +14,6 @@ const MESSAGE = 'Make sure to call `.connect()` method first before using the AP
|
|
|
13
14
|
function ensurePresence(value) {
|
|
14
15
|
return (0, utils_1.ensurePresence)(value, MESSAGE);
|
|
15
16
|
}
|
|
16
|
-
exports.ensurePresence = ensurePresence;
|
|
17
17
|
/**
|
|
18
18
|
* @name BaseSubstrateClient
|
|
19
19
|
* @description Base & shared abstraction for Substrate API Clients
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
|
|
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
|
|
@@ -16,7 +16,7 @@ const KEEP_ALIVE_INTERVAL = 10_000; // in ms
|
|
|
16
16
|
* import type { PolkadotApi } from '@dedot/chaintypes/polkadot';
|
|
17
17
|
*
|
|
18
18
|
* const run = async () => {
|
|
19
|
-
* const api = await
|
|
19
|
+
* const api = await LegacyClient.new<PolkadotApi>('wss://rpc.polkadot.io');
|
|
20
20
|
*
|
|
21
21
|
* // Call rpc `state_getMetadata` to fetch raw scale-encoded metadata and decode it.
|
|
22
22
|
* const metadata = await api.rpc.state.getMetadata();
|
|
@@ -44,7 +44,7 @@ const KEEP_ALIVE_INTERVAL = 10_000; // in ms
|
|
|
44
44
|
* run().catch(console.error);
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
|
-
class
|
|
47
|
+
class LegacyClient extends BaseSubstrateClient_js_1.BaseSubstrateClient {
|
|
48
48
|
#runtimeSubscriptionUnsub;
|
|
49
49
|
#healthTimer;
|
|
50
50
|
#apiAtCache = {};
|
|
@@ -62,15 +62,15 @@ class Dedot extends BaseSubstrateClient_js_1.BaseSubstrateClient {
|
|
|
62
62
|
* @param options
|
|
63
63
|
*/
|
|
64
64
|
static async create(options) {
|
|
65
|
-
return new
|
|
65
|
+
return new LegacyClient(options).connect();
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* Alias for
|
|
68
|
+
* Alias for __LegacyClient.create__
|
|
69
69
|
*
|
|
70
70
|
* @param options
|
|
71
71
|
*/
|
|
72
72
|
static async new(options) {
|
|
73
|
-
return
|
|
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.
|
|
250
|
+
exports.LegacyClient = LegacyClient;
|
package/cjs/client/index.js
CHANGED
|
@@ -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("./
|
|
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
|
|
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(
|
|
58
|
+
await pull(best);
|
|
59
59
|
const unsub = this.chainHead.on(eventToListen, pull);
|
|
60
60
|
return async () => {
|
|
61
61
|
unsub();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CheckMetadataHash = void 0;
|
|
4
|
+
const utils_1 = require("@dedot/utils");
|
|
5
|
+
const SignedExtension_js_1 = require("../SignedExtension.js");
|
|
6
|
+
/**
|
|
7
|
+
* @description Genesis hash check to provide replay protection between different networks.
|
|
8
|
+
*/
|
|
9
|
+
class CheckMetadataHash extends SignedExtension_js_1.SignedExtension {
|
|
10
|
+
async init() {
|
|
11
|
+
let metadataHash = this.payloadOptions.metadataHash;
|
|
12
|
+
if (metadataHash) {
|
|
13
|
+
(0, utils_1.assert)((0, utils_1.isHex)(metadataHash), 'Metadata hash is not a valid hex string');
|
|
14
|
+
this.data = { mode: 'Enabled' };
|
|
15
|
+
this.additionalSigned = metadataHash;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.data = { mode: 'Disabled' };
|
|
19
|
+
this.additionalSigned = undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
toPayload() {
|
|
23
|
+
// Ref: https://github.com/paritytech/polkadot-sdk/blob/8dbe4ee80734bba6644c7e5f879a363ce7c0a19f/substrate/frame/metadata-hash-extension/src/lib.rs#L55-L58
|
|
24
|
+
let enabled = this.data.mode === 'Enabled';
|
|
25
|
+
return {
|
|
26
|
+
mode: enabled ? 1 : 0, // 0 -> disabled, 1 -> enabled
|
|
27
|
+
metadataHash: this.additionalSigned,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.CheckMetadataHash = CheckMetadataHash;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StorageWeightReclaim = void 0;
|
|
4
|
+
const SignedExtension_js_1 = require("../SignedExtension.js");
|
|
5
|
+
/**
|
|
6
|
+
* @description Storage weight reclaim mechanism.
|
|
7
|
+
*/
|
|
8
|
+
class StorageWeightReclaim extends SignedExtension_js_1.SignedExtension {
|
|
9
|
+
}
|
|
10
|
+
exports.StorageWeightReclaim = StorageWeightReclaim;
|
|
@@ -4,6 +4,7 @@ exports.knownSignedExtensions = void 0;
|
|
|
4
4
|
const ChargeAssetTxPayment_js_1 = require("./ChargeAssetTxPayment.js");
|
|
5
5
|
const ChargeTransactionPayment_js_1 = require("./ChargeTransactionPayment.js");
|
|
6
6
|
const CheckGenesis_js_1 = require("./CheckGenesis.js");
|
|
7
|
+
const CheckMetadataHash_js_1 = require("./CheckMetadataHash.js");
|
|
7
8
|
const CheckMortality_js_1 = require("./CheckMortality.js");
|
|
8
9
|
const CheckNonZeroSender_js_1 = require("./CheckNonZeroSender.js");
|
|
9
10
|
const CheckNonce_js_1 = require("./CheckNonce.js");
|
|
@@ -11,6 +12,7 @@ const CheckSpecVersion_js_1 = require("./CheckSpecVersion.js");
|
|
|
11
12
|
const CheckTxVersion_js_1 = require("./CheckTxVersion.js");
|
|
12
13
|
const CheckWeight_js_1 = require("./CheckWeight.js");
|
|
13
14
|
const PrevalidateAttests_js_1 = require("./PrevalidateAttests.js");
|
|
15
|
+
const StorageWeightReclaim_js_1 = require("./StorageWeightReclaim.js");
|
|
14
16
|
exports.knownSignedExtensions = {
|
|
15
17
|
CheckNonZeroSender: CheckNonZeroSender_js_1.CheckNonZeroSender,
|
|
16
18
|
CheckSpecVersion: CheckSpecVersion_js_1.CheckSpecVersion,
|
|
@@ -22,4 +24,6 @@ exports.knownSignedExtensions = {
|
|
|
22
24
|
ChargeTransactionPayment: ChargeTransactionPayment_js_1.ChargeTransactionPayment,
|
|
23
25
|
PrevalidateAttests: PrevalidateAttests_js_1.PrevalidateAttests,
|
|
24
26
|
ChargeAssetTxPayment: ChargeAssetTxPayment_js_1.ChargeAssetTxPayment,
|
|
27
|
+
CheckMetadataHash: CheckMetadataHash_js_1.CheckMetadataHash,
|
|
28
|
+
StorageWeightReclaim: StorageWeightReclaim_js_1.StorageWeightReclaim,
|
|
25
29
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isKeyringPair = isKeyringPair;
|
|
4
|
+
exports.signRaw = signRaw;
|
|
4
5
|
const utils_1 = require("@dedot/utils");
|
|
5
6
|
function isKeyringPair(account) {
|
|
6
7
|
return (0, utils_1.isFunction)(account.sign);
|
|
7
8
|
}
|
|
8
|
-
exports.isKeyringPair = isKeyringPair;
|
|
9
9
|
/**
|
|
10
10
|
* Sign a raw message
|
|
11
11
|
* @param signerPair
|
|
@@ -17,4 +17,3 @@ function signRaw(signerPair, raw) {
|
|
|
17
17
|
const toSignRaw = u8a.length > 256 ? (0, utils_1.blake2AsU8a)(u8a, 256) : u8a;
|
|
18
18
|
return signerPair.sign(toSignRaw, { withType: true });
|
|
19
19
|
}
|
|
20
|
-
exports.signRaw = signRaw;
|
|
@@ -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
|
|
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
|
|
@@ -14,7 +14,7 @@ import { BaseSubstrateClient } from './BaseSubstrateClient.js';
|
|
|
14
14
|
* import type { PolkadotApi } from '@dedot/chaintypes/polkadot';
|
|
15
15
|
*
|
|
16
16
|
* const run = async () => {
|
|
17
|
-
* const api = await
|
|
17
|
+
* const api = await LegacyClient.new<PolkadotApi>('wss://rpc.polkadot.io');
|
|
18
18
|
*
|
|
19
19
|
* // Call rpc `state_getMetadata` to fetch raw scale-encoded metadata and decode it.
|
|
20
20
|
* const metadata = await api.rpc.state.getMetadata();
|
|
@@ -42,7 +42,7 @@ import { BaseSubstrateClient } from './BaseSubstrateClient.js';
|
|
|
42
42
|
* run().catch(console.error);
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
export declare class
|
|
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<
|
|
58
|
+
static create<ChainApi extends VersionedGenericSubstrateApi = SubstrateApi>(options: ApiOptions | JsonRpcProvider): Promise<LegacyClient<ChainApi>>;
|
|
59
59
|
/**
|
|
60
|
-
* Alias for
|
|
60
|
+
* Alias for __LegacyClient.create__
|
|
61
61
|
*
|
|
62
62
|
* @param options
|
|
63
63
|
*/
|
|
64
|
-
static new<ChainApi extends VersionedGenericSubstrateApi = SubstrateApi>(options: ApiOptions | JsonRpcProvider): Promise<
|
|
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
|
|
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
|
|
@@ -13,7 +13,7 @@ const KEEP_ALIVE_INTERVAL = 10_000; // in ms
|
|
|
13
13
|
* import type { PolkadotApi } from '@dedot/chaintypes/polkadot';
|
|
14
14
|
*
|
|
15
15
|
* const run = async () => {
|
|
16
|
-
* const api = await
|
|
16
|
+
* const api = await LegacyClient.new<PolkadotApi>('wss://rpc.polkadot.io');
|
|
17
17
|
*
|
|
18
18
|
* // Call rpc `state_getMetadata` to fetch raw scale-encoded metadata and decode it.
|
|
19
19
|
* const metadata = await api.rpc.state.getMetadata();
|
|
@@ -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
|
|
44
|
+
export class LegacyClient extends BaseSubstrateClient {
|
|
45
45
|
#runtimeSubscriptionUnsub;
|
|
46
46
|
#healthTimer;
|
|
47
47
|
#apiAtCache = {};
|
|
@@ -59,15 +59,15 @@ export class Dedot extends BaseSubstrateClient {
|
|
|
59
59
|
* @param options
|
|
60
60
|
*/
|
|
61
61
|
static async create(options) {
|
|
62
|
-
return new
|
|
62
|
+
return new LegacyClient(options).connect();
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Alias for
|
|
65
|
+
* Alias for __LegacyClient.create__
|
|
66
66
|
*
|
|
67
67
|
* @param options
|
|
68
68
|
*/
|
|
69
69
|
static async new(options) {
|
|
70
|
-
return
|
|
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 './
|
|
1
|
+
export * from './LegacyClient.js';
|
|
2
2
|
export * from './DedotClient.js';
|
package/client/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
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
|
|
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(
|
|
55
|
+
await pull(best);
|
|
56
56
|
const unsub = this.chainHead.on(eventToListen, pull);
|
|
57
57
|
return async () => {
|
|
58
58
|
unsub();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SignerPayloadJSON } from '@polkadot/types/types';
|
|
2
|
+
import { Hash } from '@dedot/codecs';
|
|
3
|
+
import { SignedExtension } from '../SignedExtension.js';
|
|
4
|
+
export type CheckMetadataHashMode = 'Disabled' | 'Enabled';
|
|
5
|
+
/**
|
|
6
|
+
* @description Genesis hash check to provide replay protection between different networks.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CheckMetadataHash extends SignedExtension<{
|
|
9
|
+
mode: CheckMetadataHashMode;
|
|
10
|
+
}, Hash | undefined> {
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
toPayload(): Partial<SignerPayloadJSON>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { assert, isHex } from '@dedot/utils';
|
|
2
|
+
import { SignedExtension } from '../SignedExtension.js';
|
|
3
|
+
/**
|
|
4
|
+
* @description Genesis hash check to provide replay protection between different networks.
|
|
5
|
+
*/
|
|
6
|
+
export class CheckMetadataHash extends SignedExtension {
|
|
7
|
+
async init() {
|
|
8
|
+
let metadataHash = this.payloadOptions.metadataHash;
|
|
9
|
+
if (metadataHash) {
|
|
10
|
+
assert(isHex(metadataHash), 'Metadata hash is not a valid hex string');
|
|
11
|
+
this.data = { mode: 'Enabled' };
|
|
12
|
+
this.additionalSigned = metadataHash;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
this.data = { mode: 'Disabled' };
|
|
16
|
+
this.additionalSigned = undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
toPayload() {
|
|
20
|
+
// Ref: https://github.com/paritytech/polkadot-sdk/blob/8dbe4ee80734bba6644c7e5f879a363ce7c0a19f/substrate/frame/metadata-hash-extension/src/lib.rs#L55-L58
|
|
21
|
+
let enabled = this.data.mode === 'Enabled';
|
|
22
|
+
return {
|
|
23
|
+
mode: enabled ? 1 : 0, // 0 -> disabled, 1 -> enabled
|
|
24
|
+
metadataHash: this.additionalSigned,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChargeAssetTxPayment } from './ChargeAssetTxPayment.js';
|
|
2
2
|
import { ChargeTransactionPayment } from './ChargeTransactionPayment.js';
|
|
3
3
|
import { CheckGenesis } from './CheckGenesis.js';
|
|
4
|
+
import { CheckMetadataHash } from './CheckMetadataHash.js';
|
|
4
5
|
import { CheckMortality } from './CheckMortality.js';
|
|
5
6
|
import { CheckNonZeroSender } from './CheckNonZeroSender.js';
|
|
6
7
|
import { CheckNonce } from './CheckNonce.js';
|
|
@@ -8,6 +9,7 @@ import { CheckSpecVersion } from './CheckSpecVersion.js';
|
|
|
8
9
|
import { CheckTxVersion } from './CheckTxVersion.js';
|
|
9
10
|
import { CheckWeight } from './CheckWeight.js';
|
|
10
11
|
import { PrevalidateAttests } from './PrevalidateAttests.js';
|
|
12
|
+
import { StorageWeightReclaim } from './StorageWeightReclaim.js';
|
|
11
13
|
export const knownSignedExtensions = {
|
|
12
14
|
CheckNonZeroSender,
|
|
13
15
|
CheckSpecVersion,
|
|
@@ -19,4 +21,6 @@ export const knownSignedExtensions = {
|
|
|
19
21
|
ChargeTransactionPayment,
|
|
20
22
|
PrevalidateAttests,
|
|
21
23
|
ChargeAssetTxPayment,
|
|
24
|
+
CheckMetadataHash,
|
|
25
|
+
StorageWeightReclaim,
|
|
22
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/api",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.a5b1d2fb.22+a5b1d2f",
|
|
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-next.
|
|
17
|
-
"@dedot/providers": "0.0.1-next.
|
|
18
|
-
"@dedot/runtime-specs": "0.0.1-next.
|
|
19
|
-
"@dedot/shape": "0.0.1-next.
|
|
20
|
-
"@dedot/storage": "0.0.1-next.
|
|
21
|
-
"@dedot/types": "0.0.1-next.
|
|
22
|
-
"@dedot/utils": "0.0.1-next.
|
|
16
|
+
"@dedot/codecs": "0.0.1-next.a5b1d2fb.22+a5b1d2f",
|
|
17
|
+
"@dedot/providers": "0.0.1-next.a5b1d2fb.22+a5b1d2f",
|
|
18
|
+
"@dedot/runtime-specs": "0.0.1-next.a5b1d2fb.22+a5b1d2f",
|
|
19
|
+
"@dedot/shape": "0.0.1-next.a5b1d2fb.22+a5b1d2f",
|
|
20
|
+
"@dedot/storage": "0.0.1-next.a5b1d2fb.22+a5b1d2f",
|
|
21
|
+
"@dedot/types": "0.0.1-next.a5b1d2fb.22+a5b1d2f",
|
|
22
|
+
"@dedot/utils": "0.0.1-next.a5b1d2fb.22+a5b1d2f"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsc --project tsconfig.build.json && tsc --project tsconfig.build.cjs.json",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
},
|
|
47
47
|
"license": "Apache-2.0",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@polkadot/types": "^11.
|
|
49
|
+
"@polkadot/types": "^11.3.1"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "a5b1d2fbb14107e2e5bb9de229b2707d814a02e5",
|
|
52
52
|
"module": "./index.js",
|
|
53
53
|
"types": "./index.d.ts"
|
|
54
54
|
}
|
package/proxychain.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export interface Carrier<ChainApi extends GenericSubstrateApi> {
|
|
|
11
11
|
* @param currentLevel
|
|
12
12
|
* @param maxLevel
|
|
13
13
|
*/
|
|
14
|
-
export declare const newProxyChain: <ChainApi extends GenericSubstrateApi
|
|
14
|
+
export declare const newProxyChain: <ChainApi extends GenericSubstrateApi>(carrier: Carrier<ChainApi>, currentLevel?: number, maxLevel?: number) => unknown;
|