@dedot/api 0.0.1-alpha.32 → 0.0.1-alpha.33
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 +0 -1
- package/chaintypes/substrate/errors.js +0 -1
- package/chaintypes/substrate/events.js +0 -1
- package/chaintypes/substrate/index.js +0 -1
- package/chaintypes/substrate/json-rpc.js +0 -1
- package/chaintypes/substrate/query.js +0 -1
- package/chaintypes/substrate/runtime.js +0 -1
- package/chaintypes/substrate/tx.js +0 -1
- package/chaintypes/substrate/types.js +0 -1
- package/cjs/chaintypes/substrate/consts.js +0 -1
- package/cjs/chaintypes/substrate/errors.js +0 -1
- package/cjs/chaintypes/substrate/events.js +0 -1
- package/cjs/chaintypes/substrate/index.js +0 -1
- package/cjs/chaintypes/substrate/json-rpc.js +0 -1
- package/cjs/chaintypes/substrate/query.js +0 -1
- package/cjs/chaintypes/substrate/runtime.js +0 -1
- package/cjs/chaintypes/substrate/tx.js +0 -1
- package/cjs/chaintypes/substrate/types.js +0 -1
- package/cjs/extrinsic/extensions/known/CheckMetadataHash.js +31 -0
- package/cjs/extrinsic/extensions/known/index.js +2 -0
- package/extrinsic/extensions/known/CheckMetadataHash.d.ts +13 -0
- package/extrinsic/extensions/known/CheckMetadataHash.js +27 -0
- package/extrinsic/extensions/known/index.js +2 -0
- package/package.json +10 -10
|
@@ -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;
|
|
@@ -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");
|
|
@@ -22,4 +23,5 @@ exports.knownSignedExtensions = {
|
|
|
22
23
|
ChargeTransactionPayment: ChargeTransactionPayment_js_1.ChargeTransactionPayment,
|
|
23
24
|
PrevalidateAttests: PrevalidateAttests_js_1.PrevalidateAttests,
|
|
24
25
|
ChargeAssetTxPayment: ChargeAssetTxPayment_js_1.ChargeAssetTxPayment,
|
|
26
|
+
CheckMetadataHash: CheckMetadataHash_js_1.CheckMetadataHash,
|
|
25
27
|
};
|
|
@@ -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';
|
|
@@ -19,4 +20,5 @@ export const knownSignedExtensions = {
|
|
|
19
20
|
ChargeTransactionPayment,
|
|
20
21
|
PrevalidateAttests,
|
|
21
22
|
ChargeAssetTxPayment,
|
|
23
|
+
CheckMetadataHash,
|
|
22
24
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/api",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.33",
|
|
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-alpha.
|
|
17
|
-
"@dedot/providers": "0.0.1-alpha.
|
|
18
|
-
"@dedot/runtime-specs": "0.0.1-alpha.
|
|
19
|
-
"@dedot/shape": "0.0.1-alpha.
|
|
20
|
-
"@dedot/storage": "0.0.1-alpha.
|
|
21
|
-
"@dedot/types": "0.0.1-alpha.
|
|
22
|
-
"@dedot/utils": "0.0.1-alpha.
|
|
16
|
+
"@dedot/codecs": "0.0.1-alpha.33",
|
|
17
|
+
"@dedot/providers": "0.0.1-alpha.33",
|
|
18
|
+
"@dedot/runtime-specs": "0.0.1-alpha.33",
|
|
19
|
+
"@dedot/shape": "0.0.1-alpha.33",
|
|
20
|
+
"@dedot/storage": "0.0.1-alpha.33",
|
|
21
|
+
"@dedot/types": "0.0.1-alpha.33",
|
|
22
|
+
"@dedot/utils": "0.0.1-alpha.33"
|
|
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.2.1"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "36b30a0cec2d8652915e3660329b78f1c6e4221f",
|
|
52
52
|
"module": "./index.js",
|
|
53
53
|
"types": "./index.d.ts"
|
|
54
54
|
}
|