@acala-network/chopsticks-core 1.5.2 → 1.6.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/dist/cjs/api.js +6 -15
- package/dist/cjs/blockchain/block-builder.js +3 -1
- package/dist/cjs/blockchain/block.js +5 -12
- package/dist/cjs/blockchain/head-state.js +4 -9
- package/dist/cjs/blockchain/index.js +6 -15
- package/dist/cjs/blockchain/storage-layer.js +5 -12
- package/dist/cjs/blockchain/txpool.js +17 -17
- package/dist/cjs/chopsticks-provider.js +5 -12
- package/dist/cjs/env.d.ts +25 -47
- package/dist/cjs/env.js +8 -19
- package/dist/cjs/genesis-provider.js +5 -12
- package/dist/cjs/logger.d.ts +3 -2
- package/dist/cjs/offchain.js +1 -3
- package/dist/cjs/rpc/dev/new-block.d.ts +9 -53
- package/dist/cjs/rpc/dev/set-head.d.ts +1 -1
- package/dist/cjs/rpc/index.d.ts +1 -1
- package/dist/cjs/rpc/rpc-spec/chainHead_v1.js +33 -7
- package/dist/cjs/rpc/rpc-spec/index.d.ts +1 -1
- package/dist/cjs/rpc/rpc-spec/index.js +8 -19
- package/dist/cjs/rpc/shared.d.ts +2 -2
- package/dist/cjs/rpc/shared.js +1 -3
- package/dist/cjs/rpc/substrate/index.d.ts +1 -6
- package/dist/cjs/rpc/substrate/index.js +8 -19
- package/dist/cjs/rpc/substrate/payment.js +7 -4
- package/dist/cjs/schema/index.d.ts +6 -52
- package/dist/cjs/schema/index.js +1 -1
- package/dist/cjs/utils/index.d.ts +5 -0
- package/dist/cjs/utils/index.js +9 -0
- package/dist/cjs/utils/key-cache.js +1 -3
- package/dist/cjs/wasm-executor/browser-wasm-executor.js +8 -19
- package/dist/cjs/wasm-executor/index.js +8 -19
- package/dist/cjs/wasm-executor/node-wasm-executor.js +8 -19
- package/dist/esm/blockchain/block-builder.js +4 -2
- package/dist/esm/blockchain/txpool.js +12 -3
- package/dist/esm/env.d.ts +25 -47
- package/dist/esm/logger.d.ts +3 -2
- package/dist/esm/rpc/dev/new-block.d.ts +9 -53
- package/dist/esm/rpc/dev/set-head.d.ts +1 -1
- package/dist/esm/rpc/index.d.ts +1 -1
- package/dist/esm/rpc/index.js +1 -1
- package/dist/esm/rpc/rpc-spec/chainHead_v1.js +33 -7
- package/dist/esm/rpc/rpc-spec/index.d.ts +1 -1
- package/dist/esm/rpc/rpc-spec/index.js +1 -1
- package/dist/esm/rpc/shared.d.ts +2 -2
- package/dist/esm/rpc/substrate/index.d.ts +1 -6
- package/dist/esm/rpc/substrate/index.js +1 -6
- package/dist/esm/rpc/substrate/payment.js +8 -5
- package/dist/esm/schema/index.d.ts +6 -52
- package/dist/esm/schema/index.js +1 -1
- package/dist/esm/utils/index.d.ts +5 -0
- package/dist/esm/utils/index.js +10 -1
- package/package.json +65 -61
|
@@ -45,18 +45,44 @@ const logger = _logger.defaultLogger.child({
|
|
|
45
45
|
name: 'rpc-chainHead_v1'
|
|
46
46
|
});
|
|
47
47
|
const following = new Map();
|
|
48
|
+
const runtimeSpec = (runtime)=>({
|
|
49
|
+
type: 'valid',
|
|
50
|
+
spec: {
|
|
51
|
+
specName: runtime.specName,
|
|
52
|
+
implName: runtime.implName,
|
|
53
|
+
specVersion: runtime.specVersion,
|
|
54
|
+
implVersion: runtime.implVersion,
|
|
55
|
+
transactionVersion: runtime.transactionVersion,
|
|
56
|
+
apis: Object.fromEntries(runtime.apis)
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const invalidRuntimeSpec = (error)=>({
|
|
60
|
+
type: 'invalid',
|
|
61
|
+
error: error instanceof Error ? error.message : String(error)
|
|
62
|
+
});
|
|
63
|
+
const getRuntimeSpec = async (runtime)=>{
|
|
64
|
+
try {
|
|
65
|
+
return runtimeSpec(await runtime);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return invalidRuntimeSpec(error);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
48
70
|
const chainHead_v1_follow = async (context, [withRuntime], { subscribe })=>{
|
|
49
71
|
const update = async (block)=>{
|
|
50
72
|
logger.trace({
|
|
51
73
|
hash: block.hash
|
|
52
74
|
}, 'chainHead_v1_follow');
|
|
53
75
|
const getNewRuntime = async ()=>{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
76
|
+
try {
|
|
77
|
+
const [runtime, previousRuntime] = await Promise.all([
|
|
78
|
+
block.runtimeVersion,
|
|
79
|
+
block.parentBlock.then((b)=>b?.runtimeVersion)
|
|
80
|
+
]);
|
|
81
|
+
const hasNewRuntime = runtime.implVersion !== previousRuntime?.implVersion || runtime.specVersion !== previousRuntime.specVersion;
|
|
82
|
+
return hasNewRuntime ? runtimeSpec(runtime) : null;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return invalidRuntimeSpec(error);
|
|
85
|
+
}
|
|
60
86
|
};
|
|
61
87
|
const newRuntime = withRuntime ? await getNewRuntime() : null;
|
|
62
88
|
callback({
|
|
@@ -104,7 +130,7 @@ const chainHead_v1_follow = async (context, [withRuntime], { subscribe })=>{
|
|
|
104
130
|
finalizedBlockHashes: [
|
|
105
131
|
context.chain.head.hash
|
|
106
132
|
],
|
|
107
|
-
finalizedBlockRuntime: withRuntime ? await context.chain.head.runtimeVersion : null
|
|
133
|
+
finalizedBlockRuntime: withRuntime ? await getRuntimeSpec(context.chain.head.runtimeVersion) : null
|
|
108
134
|
});
|
|
109
135
|
callback({
|
|
110
136
|
event: 'bestBlockChanged',
|
|
@@ -2,7 +2,7 @@ import * as ArchiveV1RPC from './archive_v1.js';
|
|
|
2
2
|
import * as ChainHeadV1RPC from './chainHead_v1.js';
|
|
3
3
|
import * as ChainSpecV1RPC from './chainSpec_v1.js';
|
|
4
4
|
import * as TransactionV1RPC from './transaction_v1.js';
|
|
5
|
-
export { ChainHeadV1RPC,
|
|
5
|
+
export { ChainHeadV1RPC, ChainSpecV1RPC, TransactionV1RPC };
|
|
6
6
|
declare const handlers: {
|
|
7
7
|
chainSpec_v1_chainName: import("../shared.js").Handler<[], string>;
|
|
8
8
|
chainSpec_v1_genesisHash: import("../shared.js").Handler<[], import("@polkadot/util/types").HexString>;
|
|
@@ -35,18 +35,12 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
35
35
|
})(nodeInterop);
|
|
36
36
|
}
|
|
37
37
|
function _interop_require_wildcard(obj, nodeInterop) {
|
|
38
|
-
if (!nodeInterop && obj && obj.__esModule)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
default: obj
|
|
44
|
-
};
|
|
45
|
-
}
|
|
38
|
+
if (!nodeInterop && obj && obj.__esModule) return obj;
|
|
39
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
|
|
40
|
+
default: obj
|
|
41
|
+
};
|
|
46
42
|
var cache = _getRequireWildcardCache(nodeInterop);
|
|
47
|
-
if (cache && cache.has(obj))
|
|
48
|
-
return cache.get(obj);
|
|
49
|
-
}
|
|
43
|
+
if (cache && cache.has(obj)) return cache.get(obj);
|
|
50
44
|
var newObj = {
|
|
51
45
|
__proto__: null
|
|
52
46
|
};
|
|
@@ -54,17 +48,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
54
48
|
for(var key in obj){
|
|
55
49
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
56
50
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
57
|
-
if (desc && (desc.get || desc.set))
|
|
58
|
-
|
|
59
|
-
} else {
|
|
60
|
-
newObj[key] = obj[key];
|
|
61
|
-
}
|
|
51
|
+
if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
|
|
52
|
+
else newObj[key] = obj[key];
|
|
62
53
|
}
|
|
63
54
|
}
|
|
64
55
|
newObj.default = obj;
|
|
65
|
-
if (cache)
|
|
66
|
-
cache.set(obj, newObj);
|
|
67
|
-
}
|
|
56
|
+
if (cache) cache.set(obj, newObj);
|
|
68
57
|
return newObj;
|
|
69
58
|
}
|
|
70
59
|
const handlers = {
|
package/dist/cjs/rpc/shared.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { Blockchain } from '../blockchain/index.js';
|
|
3
3
|
export declare const logger: import("pino").Logger<never, boolean>;
|
|
4
|
-
export declare const zHex: z.
|
|
5
|
-
export declare const zHash: z.ZodIntersection<z.ZodString, z.
|
|
4
|
+
export declare const zHex: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
5
|
+
export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
6
6
|
export declare class ResponseError extends Error {
|
|
7
7
|
code: number;
|
|
8
8
|
constructor(code: number, message: string);
|
package/dist/cjs/rpc/shared.js
CHANGED
|
@@ -4,12 +4,7 @@ import * as ChainRPC from './chain.js';
|
|
|
4
4
|
import * as PaymentRPC from './payment.js';
|
|
5
5
|
import * as StateRPC from './state.js';
|
|
6
6
|
import * as SystemRPC from './system.js';
|
|
7
|
-
export { ArchiveRPC };
|
|
8
|
-
export { AuthorRPC };
|
|
9
|
-
export { ChainRPC };
|
|
10
|
-
export { PaymentRPC };
|
|
11
|
-
export { StateRPC };
|
|
12
|
-
export { SystemRPC };
|
|
7
|
+
export { ArchiveRPC, AuthorRPC, ChainRPC, PaymentRPC, StateRPC, SystemRPC };
|
|
13
8
|
declare const handlers: {
|
|
14
9
|
system_localPeerId: () => Promise<string>;
|
|
15
10
|
system_nodeRoles: () => Promise<string[]>;
|
|
@@ -46,18 +46,12 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
46
46
|
})(nodeInterop);
|
|
47
47
|
}
|
|
48
48
|
function _interop_require_wildcard(obj, nodeInterop) {
|
|
49
|
-
if (!nodeInterop && obj && obj.__esModule)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
default: obj
|
|
55
|
-
};
|
|
56
|
-
}
|
|
49
|
+
if (!nodeInterop && obj && obj.__esModule) return obj;
|
|
50
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
|
|
51
|
+
default: obj
|
|
52
|
+
};
|
|
57
53
|
var cache = _getRequireWildcardCache(nodeInterop);
|
|
58
|
-
if (cache && cache.has(obj))
|
|
59
|
-
return cache.get(obj);
|
|
60
|
-
}
|
|
54
|
+
if (cache && cache.has(obj)) return cache.get(obj);
|
|
61
55
|
var newObj = {
|
|
62
56
|
__proto__: null
|
|
63
57
|
};
|
|
@@ -65,17 +59,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
65
59
|
for(var key in obj){
|
|
66
60
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
67
61
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
68
|
-
if (desc && (desc.get || desc.set))
|
|
69
|
-
|
|
70
|
-
} else {
|
|
71
|
-
newObj[key] = obj[key];
|
|
72
|
-
}
|
|
62
|
+
if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
|
|
63
|
+
else newObj[key] = obj[key];
|
|
73
64
|
}
|
|
74
65
|
}
|
|
75
66
|
newObj.default = obj;
|
|
76
|
-
if (cache)
|
|
77
|
-
cache.set(obj, newObj);
|
|
78
|
-
}
|
|
67
|
+
if (cache) cache.set(obj, newObj);
|
|
79
68
|
return newObj;
|
|
80
69
|
}
|
|
81
70
|
const handlers = {
|
|
@@ -17,6 +17,7 @@ _export(exports, {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const _util = require("@polkadot/util");
|
|
20
|
+
const _index = require("../../utils/index.js");
|
|
20
21
|
const _shared = require("../shared.js");
|
|
21
22
|
const payment_queryFeeDetails = async (context, [extrinsic, hash])=>{
|
|
22
23
|
const block = await context.chain.getBlock(hash);
|
|
@@ -26,8 +27,9 @@ const payment_queryFeeDetails = async (context, [extrinsic, hash])=>{
|
|
|
26
27
|
const registry = await block.registry;
|
|
27
28
|
const tx = (0, _util.hexToU8a)(extrinsic);
|
|
28
29
|
const resp = await block.call('TransactionPaymentApi_query_fee_details', [
|
|
29
|
-
|
|
30
|
-
registry.createType('
|
|
30
|
+
// polkadot.js cannot always decode a general (v5) extrinsic; the runtime takes its bytes as they are
|
|
31
|
+
(0, _index.isGeneralExtrinsic)(tx) ? extrinsic : registry.createType('Extrinsic', tx).toHex(),
|
|
32
|
+
(0, _util.u8aToHex)(registry.createType('u32', tx.byteLength).toU8a())
|
|
31
33
|
]);
|
|
32
34
|
return resp.result;
|
|
33
35
|
};
|
|
@@ -39,8 +41,9 @@ const payment_queryInfo = async (context, [extrinsic, hash])=>{
|
|
|
39
41
|
const registry = await block.registry;
|
|
40
42
|
const tx = (0, _util.hexToU8a)(extrinsic);
|
|
41
43
|
const resp = await block.call('TransactionPaymentApi_query_info', [
|
|
42
|
-
|
|
43
|
-
registry.createType('
|
|
44
|
+
// polkadot.js cannot always decode a general (v5) extrinsic; the runtime takes its bytes as they are
|
|
45
|
+
(0, _index.isGeneralExtrinsic)(tx) ? extrinsic : registry.createType('Extrinsic', tx).toHex(),
|
|
46
|
+
(0, _util.u8aToHex)(registry.createType('u32', tx.byteLength).toU8a())
|
|
44
47
|
]);
|
|
45
48
|
return resp.result;
|
|
46
49
|
};
|
|
@@ -4,59 +4,13 @@ export declare const genesisSchema: z.ZodObject<{
|
|
|
4
4
|
name: z.ZodString;
|
|
5
5
|
properties: z.ZodObject<{
|
|
6
6
|
ss58Format: z.ZodOptional<z.ZodNumber>;
|
|
7
|
-
tokenDecimals: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber
|
|
8
|
-
tokenSymbol: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
9
|
-
},
|
|
10
|
-
ss58Format?: number | undefined;
|
|
11
|
-
tokenDecimals?: number | number[] | undefined;
|
|
12
|
-
tokenSymbol?: string | string[] | undefined;
|
|
13
|
-
}, {
|
|
14
|
-
ss58Format?: number | undefined;
|
|
15
|
-
tokenDecimals?: number | number[] | undefined;
|
|
16
|
-
tokenSymbol?: string | string[] | undefined;
|
|
17
|
-
}>;
|
|
7
|
+
tokenDecimals: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>]>>;
|
|
8
|
+
tokenSymbol: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
9
|
+
}, z.core.$strip>;
|
|
18
10
|
genesis: z.ZodObject<{
|
|
19
11
|
raw: z.ZodObject<{
|
|
20
12
|
top: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
top: Record<string, string>;
|
|
25
|
-
}>;
|
|
26
|
-
}, "strip", z.ZodTypeAny, {
|
|
27
|
-
raw: {
|
|
28
|
-
top: Record<string, string>;
|
|
29
|
-
};
|
|
30
|
-
}, {
|
|
31
|
-
raw: {
|
|
32
|
-
top: Record<string, string>;
|
|
33
|
-
};
|
|
34
|
-
}>;
|
|
35
|
-
}, "strip", z.ZodTypeAny, {
|
|
36
|
-
name: string;
|
|
37
|
-
id: string;
|
|
38
|
-
properties: {
|
|
39
|
-
ss58Format?: number | undefined;
|
|
40
|
-
tokenDecimals?: number | number[] | undefined;
|
|
41
|
-
tokenSymbol?: string | string[] | undefined;
|
|
42
|
-
};
|
|
43
|
-
genesis: {
|
|
44
|
-
raw: {
|
|
45
|
-
top: Record<string, string>;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
}, {
|
|
49
|
-
name: string;
|
|
50
|
-
id: string;
|
|
51
|
-
properties: {
|
|
52
|
-
ss58Format?: number | undefined;
|
|
53
|
-
tokenDecimals?: number | number[] | undefined;
|
|
54
|
-
tokenSymbol?: string | string[] | undefined;
|
|
55
|
-
};
|
|
56
|
-
genesis: {
|
|
57
|
-
raw: {
|
|
58
|
-
top: Record<string, string>;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
}>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
}, z.core.$strip>;
|
|
62
16
|
export type Genesis = z.infer<typeof genesisSchema>;
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -10,6 +10,11 @@ export type ProcessKey = (key: StorageKey<any>) => any;
|
|
|
10
10
|
export declare function fetchKeys(getKeys: GetKeys, processKey: ProcessKey): Promise<void>;
|
|
11
11
|
export declare function fetchKeysToArray(getKeys: GetKeys): Promise<StorageKey<any>[]>;
|
|
12
12
|
export declare const compactHex: (value: Uint8Array) => HexString;
|
|
13
|
+
/**
|
|
14
|
+
* Whether `extrinsic` is a general (v5) extrinsic, read from its preamble byte. polkadot.js cannot always decode one: it
|
|
15
|
+
* skips the payload of a transaction extension it does not know, such as VerifySignature.
|
|
16
|
+
*/
|
|
17
|
+
export declare const isGeneralExtrinsic: (extrinsic: HexString | Uint8Array) => boolean;
|
|
13
18
|
export declare const getParaId: (chain: Blockchain) => Promise<import("@polkadot/types").U32>;
|
|
14
19
|
export declare const isUrl: (url: string) => boolean;
|
|
15
20
|
export type Deferred<T> = {
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -39,6 +39,9 @@ _export(exports, {
|
|
|
39
39
|
get getSlotDuration () {
|
|
40
40
|
return getSlotDuration;
|
|
41
41
|
},
|
|
42
|
+
get isGeneralExtrinsic () {
|
|
43
|
+
return isGeneralExtrinsic;
|
|
44
|
+
},
|
|
42
45
|
get isPrefixedChildKey () {
|
|
43
46
|
return isPrefixedChildKey;
|
|
44
47
|
},
|
|
@@ -55,6 +58,7 @@ _export(exports, {
|
|
|
55
58
|
return stripChildPrefix;
|
|
56
59
|
}
|
|
57
60
|
});
|
|
61
|
+
const _constants = require("@polkadot/types/extrinsic/constants");
|
|
58
62
|
const _util = require("@polkadot/util");
|
|
59
63
|
const _hex = require("@polkadot/util/hex");
|
|
60
64
|
const _index = require("../wasm-executor/index.js");
|
|
@@ -99,6 +103,11 @@ async function fetchKeysToArray(getKeys) {
|
|
|
99
103
|
const compactHex = (value)=>{
|
|
100
104
|
return (0, _util.u8aToHex)((0, _util.compactStripLength)(value)[1]);
|
|
101
105
|
};
|
|
106
|
+
const isGeneralExtrinsic = (extrinsic)=>{
|
|
107
|
+
const u8a = (0, _util.u8aToU8a)(extrinsic);
|
|
108
|
+
const [offset] = (0, _util.compactFromU8a)(u8a);
|
|
109
|
+
return (u8a[offset] & _constants.TYPE_MASK) === _constants.GENERAL_EXTRINSIC;
|
|
110
|
+
};
|
|
102
111
|
const getParaId = async (chain)=>{
|
|
103
112
|
const meta = await chain.head.meta;
|
|
104
113
|
const id = await chain.head.read('u32', meta.query.parachainInfo.parachainId);
|
|
@@ -13,18 +13,12 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
13
13
|
})(nodeInterop);
|
|
14
14
|
}
|
|
15
15
|
function _interop_require_wildcard(obj, nodeInterop) {
|
|
16
|
-
if (!nodeInterop && obj && obj.__esModule)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
default: obj
|
|
22
|
-
};
|
|
23
|
-
}
|
|
16
|
+
if (!nodeInterop && obj && obj.__esModule) return obj;
|
|
17
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
24
20
|
var cache = _getRequireWildcardCache(nodeInterop);
|
|
25
|
-
if (cache && cache.has(obj))
|
|
26
|
-
return cache.get(obj);
|
|
27
|
-
}
|
|
21
|
+
if (cache && cache.has(obj)) return cache.get(obj);
|
|
28
22
|
var newObj = {
|
|
29
23
|
__proto__: null
|
|
30
24
|
};
|
|
@@ -32,17 +26,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
32
26
|
for(var key in obj){
|
|
33
27
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
34
28
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
35
|
-
if (desc && (desc.get || desc.set))
|
|
36
|
-
|
|
37
|
-
} else {
|
|
38
|
-
newObj[key] = obj[key];
|
|
39
|
-
}
|
|
29
|
+
if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
|
|
30
|
+
else newObj[key] = obj[key];
|
|
40
31
|
}
|
|
41
32
|
}
|
|
42
33
|
newObj.default = obj;
|
|
43
|
-
if (cache)
|
|
44
|
-
cache.set(obj, newObj);
|
|
45
|
-
}
|
|
34
|
+
if (cache) cache.set(obj, newObj);
|
|
46
35
|
return newObj;
|
|
47
36
|
}
|
|
48
37
|
const getRuntimeVersion = async (code)=>{
|
|
@@ -60,18 +60,12 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
60
60
|
})(nodeInterop);
|
|
61
61
|
}
|
|
62
62
|
function _interop_require_wildcard(obj, nodeInterop) {
|
|
63
|
-
if (!nodeInterop && obj && obj.__esModule)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
default: obj
|
|
69
|
-
};
|
|
70
|
-
}
|
|
63
|
+
if (!nodeInterop && obj && obj.__esModule) return obj;
|
|
64
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
|
|
65
|
+
default: obj
|
|
66
|
+
};
|
|
71
67
|
var cache = _getRequireWildcardCache(nodeInterop);
|
|
72
|
-
if (cache && cache.has(obj))
|
|
73
|
-
return cache.get(obj);
|
|
74
|
-
}
|
|
68
|
+
if (cache && cache.has(obj)) return cache.get(obj);
|
|
75
69
|
var newObj = {
|
|
76
70
|
__proto__: null
|
|
77
71
|
};
|
|
@@ -79,17 +73,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
79
73
|
for(var key in obj){
|
|
80
74
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
81
75
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
82
|
-
if (desc && (desc.get || desc.set))
|
|
83
|
-
|
|
84
|
-
} else {
|
|
85
|
-
newObj[key] = obj[key];
|
|
86
|
-
}
|
|
76
|
+
if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
|
|
77
|
+
else newObj[key] = obj[key];
|
|
87
78
|
}
|
|
88
79
|
}
|
|
89
80
|
newObj.default = obj;
|
|
90
|
-
if (cache)
|
|
91
|
-
cache.set(obj, newObj);
|
|
92
|
-
}
|
|
81
|
+
if (cache) cache.set(obj, newObj);
|
|
93
82
|
return newObj;
|
|
94
83
|
}
|
|
95
84
|
const logger = _logger.defaultLogger.child({
|
|
@@ -20,18 +20,12 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
20
20
|
})(nodeInterop);
|
|
21
21
|
}
|
|
22
22
|
function _interop_require_wildcard(obj, nodeInterop) {
|
|
23
|
-
if (!nodeInterop && obj && obj.__esModule)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
default: obj
|
|
29
|
-
};
|
|
30
|
-
}
|
|
23
|
+
if (!nodeInterop && obj && obj.__esModule) return obj;
|
|
24
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
|
|
25
|
+
default: obj
|
|
26
|
+
};
|
|
31
27
|
var cache = _getRequireWildcardCache(nodeInterop);
|
|
32
|
-
if (cache && cache.has(obj))
|
|
33
|
-
return cache.get(obj);
|
|
34
|
-
}
|
|
28
|
+
if (cache && cache.has(obj)) return cache.get(obj);
|
|
35
29
|
var newObj = {
|
|
36
30
|
__proto__: null
|
|
37
31
|
};
|
|
@@ -39,17 +33,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
39
33
|
for(var key in obj){
|
|
40
34
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
35
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
42
|
-
if (desc && (desc.get || desc.set))
|
|
43
|
-
|
|
44
|
-
} else {
|
|
45
|
-
newObj[key] = obj[key];
|
|
46
|
-
}
|
|
36
|
+
if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
|
|
37
|
+
else newObj[key] = obj[key];
|
|
47
38
|
}
|
|
48
39
|
}
|
|
49
40
|
newObj.default = obj;
|
|
50
|
-
if (cache)
|
|
51
|
-
cache.set(obj, newObj);
|
|
52
|
-
}
|
|
41
|
+
if (cache) cache.set(obj, newObj);
|
|
53
42
|
return newObj;
|
|
54
43
|
}
|
|
55
44
|
const getRuntimeVersion = async (code)=>{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { compactAddLength, hexToU8a, stringToHex, u8aConcat, u8aToHex } from '@polkadot/util';
|
|
2
2
|
import { blake2AsU8a } from '@polkadot/util-crypto';
|
|
3
3
|
import { defaultLogger, truncate } from '../logger.js';
|
|
4
|
-
import { compactHex, getCurrentSlot } from '../utils/index.js';
|
|
4
|
+
import { compactHex, getCurrentSlot, isGeneralExtrinsic } from '../utils/index.js';
|
|
5
5
|
import { Block } from './block.js';
|
|
6
6
|
import { StorageLayer, StorageValueKind } from './storage-layer.js';
|
|
7
7
|
const logger = defaultLogger.child({
|
|
@@ -417,7 +417,9 @@ export const dryRunExtrinsic = async (head, inherentProviders, extrinsic, params
|
|
|
417
417
|
generic.toHex()
|
|
418
418
|
]);
|
|
419
419
|
}
|
|
420
|
-
logger.debug({
|
|
420
|
+
logger.debug(isGeneralExtrinsic(extrinsic) ? {
|
|
421
|
+
extrinsic: truncate(extrinsic)
|
|
422
|
+
} : {
|
|
421
423
|
call: registry.createType('GenericExtrinsic', hexToU8a(extrinsic)).toJSON()
|
|
422
424
|
}, 'dry_run_extrinsic');
|
|
423
425
|
return newBlock.call('BlockBuilder_apply_extrinsic', [
|
|
@@ -2,7 +2,7 @@ import { hexToU8a } from '@polkadot/util/hex/toU8a';
|
|
|
2
2
|
import { EventEmitter } from 'eventemitter3';
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import { defaultLogger, truncate } from '../logger.js';
|
|
5
|
-
import { defer } from '../utils/index.js';
|
|
5
|
+
import { defer, isGeneralExtrinsic } from '../utils/index.js';
|
|
6
6
|
import { buildBlock } from './block-builder.js';
|
|
7
7
|
const logger = defaultLogger.child({
|
|
8
8
|
name: 'txpool'
|
|
@@ -73,8 +73,17 @@ export class TxPool {
|
|
|
73
73
|
}
|
|
74
74
|
async #getSigner(extrinsic) {
|
|
75
75
|
const registry = await this.#chain.head.registry;
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
if (!isGeneralExtrinsic(extrinsic)) {
|
|
77
|
+
return registry.createType('GenericExtrinsic', extrinsic).signer.toString();
|
|
78
|
+
}
|
|
79
|
+
// A general (v5) extrinsic has no signer field, and `signer` throws for it. Its account, if any, is the one
|
|
80
|
+
// frame_system's CheckNonce tags it with: `provides: [(account, nonce)]`.
|
|
81
|
+
const validity = await this.#chain.validateExtrinsic(extrinsic);
|
|
82
|
+
if (!validity.isOk) return undefined;
|
|
83
|
+
const length = registry.createType('AccountId').encodedLength + registry.createType('Index').encodedLength;
|
|
84
|
+
const tags = validity.asOk.provides.filter((tag)=>tag.length === length);
|
|
85
|
+
if (tags.length !== 1) return undefined;
|
|
86
|
+
return registry.createType('(AccountId, Index)', tags[0].toU8a(true))[0].toString();
|
|
78
87
|
}
|
|
79
88
|
submitUpwardMessages(id, ump) {
|
|
80
89
|
logger.debug({
|
package/dist/esm/env.d.ts
CHANGED
|
@@ -1,57 +1,35 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
export declare const environmentSchema: z.ZodObject<{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Set port for Chopsticks to listen on, default is `8000`.
|
|
9
|
-
*/
|
|
3
|
+
DISABLE_AUTO_HRMP: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
|
|
4
|
+
true: "true";
|
|
5
|
+
false: "false";
|
|
6
|
+
}>>, z.ZodTransform<boolean, "true" | "false">>;
|
|
10
7
|
PORT: z.ZodOptional<z.ZodString>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
DISABLE_PLUGINS: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
|
|
9
|
+
true: "true";
|
|
10
|
+
false: "false";
|
|
11
|
+
}>>, z.ZodTransform<boolean, "true" | "false">>;
|
|
15
12
|
HTTP_PROXY: z.ZodOptional<z.ZodString>;
|
|
16
13
|
http_proxy: z.ZodOptional<z.ZodString>;
|
|
17
14
|
HTTPS_PROXY: z.ZodOptional<z.ZodString>;
|
|
18
15
|
https_proxy: z.ZodOptional<z.ZodString>;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
VERBOSE_LOG: z.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
LOG_COMPACT: z.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
VERBOSE_LOG: boolean;
|
|
37
|
-
LOG_COMPACT: boolean;
|
|
38
|
-
PORT?: string | undefined;
|
|
39
|
-
HTTP_PROXY?: string | undefined;
|
|
40
|
-
http_proxy?: string | undefined;
|
|
41
|
-
HTTPS_PROXY?: string | undefined;
|
|
42
|
-
https_proxy?: string | undefined;
|
|
43
|
-
}, {
|
|
44
|
-
DISABLE_AUTO_HRMP?: "true" | "false" | undefined;
|
|
45
|
-
PORT?: string | undefined;
|
|
46
|
-
DISABLE_PLUGINS?: "true" | "false" | undefined;
|
|
47
|
-
HTTP_PROXY?: string | undefined;
|
|
48
|
-
http_proxy?: string | undefined;
|
|
49
|
-
HTTPS_PROXY?: string | undefined;
|
|
50
|
-
https_proxy?: string | undefined;
|
|
51
|
-
LOG_LEVEL?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | undefined;
|
|
52
|
-
VERBOSE_LOG?: "true" | "false" | undefined;
|
|
53
|
-
LOG_COMPACT?: "true" | "false" | undefined;
|
|
54
|
-
}>;
|
|
16
|
+
LOG_LEVEL: z.ZodDefault<z.ZodEnum<{
|
|
17
|
+
fatal: "fatal";
|
|
18
|
+
error: "error";
|
|
19
|
+
warn: "warn";
|
|
20
|
+
info: "info";
|
|
21
|
+
debug: "debug";
|
|
22
|
+
trace: "trace";
|
|
23
|
+
}>>;
|
|
24
|
+
VERBOSE_LOG: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
|
|
25
|
+
true: "true";
|
|
26
|
+
false: "false";
|
|
27
|
+
}>>, z.ZodTransform<boolean, "true" | "false">>;
|
|
28
|
+
LOG_COMPACT: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
|
|
29
|
+
true: "true";
|
|
30
|
+
false: "false";
|
|
31
|
+
}>>, z.ZodTransform<boolean, "true" | "false">>;
|
|
32
|
+
}, z.core.$strip>;
|
|
55
33
|
/**
|
|
56
34
|
* Environment variables available for users
|
|
57
35
|
*/
|
package/dist/esm/logger.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
import { pino } from 'pino';
|
|
2
|
+
export declare const pinoLogger: pino.Logger<never, boolean>;
|
|
3
|
+
export declare const defaultLogger: pino.Logger<never, boolean>;
|
|
3
4
|
export declare const truncate: (val: any) => any;
|