@acala-network/chopsticks-core 0.9.1-2 → 0.9.1-4
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 +149 -91
- package/dist/cjs/blockchain/block-builder.js +192 -118
- package/dist/cjs/blockchain/block.js +245 -182
- package/dist/cjs/blockchain/head-state.js +115 -51
- package/dist/cjs/blockchain/index.js +283 -218
- package/dist/cjs/blockchain/inherent/index.js +99 -39
- package/dist/cjs/blockchain/inherent/para-enter.js +16 -10
- package/dist/cjs/blockchain/inherent/parachain/babe-randomness.js +13 -6
- package/dist/cjs/blockchain/inherent/parachain/nimbus-author-inherent.js +13 -6
- package/dist/cjs/blockchain/inherent/parachain/validation-data.js +106 -74
- package/dist/cjs/blockchain/storage-layer.js +245 -135
- package/dist/cjs/blockchain/txpool.js +267 -140
- package/dist/cjs/chopsticks-provider.js +183 -106
- package/dist/cjs/database.js +3 -1
- package/dist/cjs/genesis-provider.js +165 -111
- package/dist/cjs/index.js +36 -36
- package/dist/cjs/logger.js +49 -36
- package/dist/cjs/offchain.js +44 -16
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/rpc/index.js +35 -16
- package/dist/cjs/rpc/shared.js +41 -11
- package/dist/cjs/rpc/substrate/author.js +57 -58
- package/dist/cjs/rpc/substrate/chain.js +75 -60
- package/dist/cjs/rpc/substrate/index.js +79 -39
- package/dist/cjs/rpc/substrate/payment.js +27 -26
- package/dist/cjs/rpc/substrate/state.js +110 -127
- package/dist/cjs/rpc/substrate/system.js +63 -38
- package/dist/cjs/schema/index.js +28 -11
- package/dist/cjs/setup.js +37 -33
- package/dist/cjs/utils/decoder.js +77 -50
- package/dist/cjs/utils/index.js +99 -66
- package/dist/cjs/utils/key-cache.js +71 -37
- package/dist/cjs/utils/proof.js +40 -18
- package/dist/cjs/utils/set-storage.js +46 -32
- package/dist/cjs/utils/time-travel.js +50 -36
- package/dist/cjs/utils/well-known-keys.js +37 -27
- package/dist/cjs/wasm-executor/browser-wasm-executor.js +76 -0
- package/dist/cjs/wasm-executor/browser-worker.js +16 -12
- package/dist/cjs/wasm-executor/index.js +164 -106
- package/dist/cjs/wasm-executor/node-wasm-executor.js +78 -0
- package/dist/cjs/wasm-executor/node-worker.js +22 -46
- package/dist/cjs/xcm/downward.js +32 -21
- package/dist/cjs/xcm/horizontal.js +30 -18
- package/dist/cjs/xcm/index.js +37 -19
- package/dist/cjs/xcm/upward.js +21 -15
- package/dist/esm/api.js +71 -74
- package/dist/esm/blockchain/block-builder.js +147 -90
- package/dist/esm/blockchain/block.js +121 -136
- package/dist/esm/blockchain/head-state.js +39 -41
- package/dist/esm/blockchain/index.js +166 -174
- package/dist/esm/blockchain/inherent/index.js +19 -27
- package/dist/esm/blockchain/inherent/para-enter.js +6 -6
- package/dist/esm/blockchain/inherent/parachain/babe-randomness.js +3 -1
- package/dist/esm/blockchain/inherent/parachain/nimbus-author-inherent.js +3 -1
- package/dist/esm/blockchain/inherent/parachain/validation-data.js +76 -52
- package/dist/esm/blockchain/storage-layer.js +102 -106
- package/dist/esm/blockchain/txpool.js +150 -140
- package/dist/esm/chopsticks-provider.js +92 -82
- package/dist/esm/database.js +1 -1
- package/dist/esm/genesis-provider.js +95 -111
- package/dist/esm/index.js +19 -20
- package/dist/esm/logger.js +33 -31
- package/dist/esm/offchain.js +17 -10
- package/dist/esm/rpc/index.js +9 -7
- package/dist/esm/rpc/shared.js +7 -4
- package/dist/esm/rpc/substrate/author.js +30 -30
- package/dist/esm/rpc/substrate/chain.js +25 -26
- package/dist/esm/rpc/substrate/index.js +6 -6
- package/dist/esm/rpc/substrate/payment.js +5 -7
- package/dist/esm/rpc/substrate/state.js +57 -51
- package/dist/esm/rpc/substrate/system.js +17 -15
- package/dist/esm/schema/index.js +13 -3
- package/dist/esm/setup.js +19 -21
- package/dist/esm/utils/decoder.js +41 -28
- package/dist/esm/utils/index.js +35 -30
- package/dist/esm/utils/key-cache.js +25 -21
- package/dist/esm/utils/proof.js +7 -7
- package/dist/esm/utils/set-storage.js +31 -23
- package/dist/esm/utils/time-travel.js +20 -23
- package/dist/esm/utils/well-known-keys.js +24 -20
- package/dist/esm/wasm-executor/browser-wasm-executor.js +31 -0
- package/dist/esm/wasm-executor/browser-worker.js +5 -7
- package/dist/esm/wasm-executor/index.js +67 -58
- package/dist/esm/wasm-executor/node-wasm-executor.js +28 -0
- package/dist/esm/wasm-executor/node-worker.js +5 -37
- package/dist/esm/xcm/downward.js +19 -14
- package/dist/esm/xcm/horizontal.js +19 -13
- package/dist/esm/xcm/index.js +11 -9
- package/dist/esm/xcm/upward.js +8 -8
- package/dist/types/blockchain/block-builder.d.ts +2 -2
- package/dist/types/blockchain/block.d.ts +3 -3
- package/dist/types/blockchain/head-state.d.ts +1 -1
- package/dist/types/blockchain/index.d.ts +7 -7
- package/dist/types/blockchain/inherent/index.d.ts +6 -6
- package/dist/types/blockchain/inherent/para-enter.d.ts +3 -3
- package/dist/types/blockchain/inherent/parachain/babe-randomness.d.ts +3 -3
- package/dist/types/blockchain/inherent/parachain/nimbus-author-inherent.d.ts +3 -3
- package/dist/types/blockchain/inherent/parachain/validation-data.d.ts +3 -3
- package/dist/types/blockchain/storage-layer.d.ts +2 -2
- package/dist/types/blockchain/txpool.d.ts +3 -3
- package/dist/types/chopsticks-provider.d.ts +2 -2
- package/dist/types/genesis-provider.d.ts +2 -2
- package/dist/types/index.d.ts +19 -19
- package/dist/types/offchain.d.ts +1 -1
- package/dist/types/rpc/index.d.ts +4 -4
- package/dist/types/rpc/shared.d.ts +1 -1
- package/dist/types/rpc/substrate/author.d.ts +1 -1
- package/dist/types/rpc/substrate/chain.d.ts +1 -1
- package/dist/types/rpc/substrate/index.d.ts +41 -41
- package/dist/types/rpc/substrate/payment.d.ts +1 -1
- package/dist/types/rpc/substrate/state.d.ts +2 -2
- package/dist/types/rpc/substrate/system.d.ts +2 -2
- package/dist/types/setup.d.ts +4 -4
- package/dist/types/utils/decoder.d.ts +1 -1
- package/dist/types/utils/index.d.ts +5 -5
- package/dist/types/utils/set-storage.d.ts +1 -1
- package/dist/types/utils/time-travel.d.ts +1 -1
- package/dist/types/wasm-executor/index.d.ts +1 -1
- package/dist/types/xcm/downward.d.ts +1 -1
- package/dist/types/xcm/horizontal.d.ts +1 -1
- package/dist/types/xcm/index.d.ts +1 -1
- package/dist/types/xcm/upward.d.ts +1 -1
- package/package.json +14 -9
- package/dist/cjs/wasm-executor/browser-wasm-executor.mjs +0 -32
- package/dist/esm/package.json +0 -1
- package/dist/esm/wasm-executor/browser-wasm-executor.mjs +0 -32
package/dist/cjs/api.js
CHANGED
|
@@ -1,141 +1,199 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.signedExtensions = signedExtensions || {};
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Api", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Api;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _index = require("./utils/index.js");
|
|
12
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
13
|
+
if (privateCollection.has(obj)) {
|
|
14
|
+
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
18
|
+
if (descriptor.get) {
|
|
19
|
+
return descriptor.get.call(receiver);
|
|
20
|
+
}
|
|
21
|
+
return descriptor.value;
|
|
22
|
+
}
|
|
23
|
+
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
24
|
+
if (descriptor.set) {
|
|
25
|
+
descriptor.set.call(receiver, value);
|
|
26
|
+
} else {
|
|
27
|
+
if (!descriptor.writable) {
|
|
28
|
+
throw new TypeError("attempted to set read only private field");
|
|
29
|
+
}
|
|
30
|
+
descriptor.value = value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
34
|
+
if (!privateMap.has(receiver)) {
|
|
35
|
+
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
37
36
|
}
|
|
37
|
+
return privateMap.get(receiver);
|
|
38
|
+
}
|
|
39
|
+
function _class_private_field_get(receiver, privateMap) {
|
|
40
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
41
|
+
return _class_apply_descriptor_get(receiver, descriptor);
|
|
42
|
+
}
|
|
43
|
+
function _class_private_field_init(obj, privateMap, value) {
|
|
44
|
+
_check_private_redeclaration(obj, privateMap);
|
|
45
|
+
privateMap.set(obj, value);
|
|
46
|
+
}
|
|
47
|
+
function _class_private_field_set(receiver, privateMap, value) {
|
|
48
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
49
|
+
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
function _define_property(obj, key, value) {
|
|
53
|
+
if (key in obj) {
|
|
54
|
+
Object.defineProperty(obj, key, {
|
|
55
|
+
value: value,
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
obj[key] = value;
|
|
62
|
+
}
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
var _provider = /*#__PURE__*/ new WeakMap(), _ready = /*#__PURE__*/ new WeakMap(), _chain = /*#__PURE__*/ new WeakMap(), _chainProperties = /*#__PURE__*/ new WeakMap();
|
|
66
|
+
class Api {
|
|
38
67
|
async disconnect() {
|
|
39
|
-
return
|
|
68
|
+
return _class_private_field_get(this, _provider).disconnect();
|
|
40
69
|
}
|
|
41
70
|
get isReady() {
|
|
42
|
-
if (!
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
71
|
+
if (!_class_private_field_get(this, _ready)) {
|
|
72
|
+
if (_class_private_field_get(this, _provider)['isReady']) {
|
|
73
|
+
_class_private_field_set(this, _ready, _class_private_field_get(this, _provider)['isReady']);
|
|
74
|
+
} else {
|
|
75
|
+
_class_private_field_set(this, _ready, new Promise((resolve)=>{
|
|
76
|
+
if (_class_private_field_get(this, _provider).hasSubscriptions) {
|
|
77
|
+
_class_private_field_get(this, _provider).on('connected', resolve);
|
|
78
|
+
_class_private_field_get(this, _provider).connect();
|
|
79
|
+
} else {
|
|
53
80
|
resolve();
|
|
54
81
|
}
|
|
55
|
-
})
|
|
82
|
+
}));
|
|
56
83
|
}
|
|
57
84
|
}
|
|
58
|
-
return
|
|
85
|
+
return _class_private_field_get(this, _ready);
|
|
59
86
|
}
|
|
60
87
|
get chain() {
|
|
61
|
-
if (!
|
|
62
|
-
|
|
88
|
+
if (!_class_private_field_get(this, _chain)) {
|
|
89
|
+
_class_private_field_set(this, _chain, this.getSystemChain());
|
|
63
90
|
}
|
|
64
|
-
return
|
|
91
|
+
return _class_private_field_get(this, _chain);
|
|
65
92
|
}
|
|
66
93
|
get chainProperties() {
|
|
67
|
-
if (!
|
|
68
|
-
|
|
94
|
+
if (!_class_private_field_get(this, _chainProperties)) {
|
|
95
|
+
_class_private_field_set(this, _chainProperties, this.getSystemProperties());
|
|
69
96
|
}
|
|
70
|
-
return
|
|
97
|
+
return _class_private_field_get(this, _chainProperties);
|
|
71
98
|
}
|
|
72
99
|
async getSystemName() {
|
|
73
|
-
return
|
|
100
|
+
return _class_private_field_get(this, _provider).send('system_name', []);
|
|
74
101
|
}
|
|
75
102
|
async getSystemProperties() {
|
|
76
|
-
return
|
|
103
|
+
return _class_private_field_get(this, _provider).send('system_properties', []);
|
|
77
104
|
}
|
|
78
105
|
async getSystemChain() {
|
|
79
|
-
return
|
|
106
|
+
return _class_private_field_get(this, _provider).send('system_chain', []);
|
|
80
107
|
}
|
|
81
108
|
async getBlockHash(blockNumber) {
|
|
82
|
-
return
|
|
109
|
+
return _class_private_field_get(this, _provider).send('chain_getBlockHash', Number.isInteger(blockNumber) ? [
|
|
110
|
+
blockNumber
|
|
111
|
+
] : [], !!blockNumber);
|
|
83
112
|
}
|
|
84
113
|
async getHeader(hash) {
|
|
85
|
-
return
|
|
114
|
+
return _class_private_field_get(this, _provider).send('chain_getHeader', hash ? [
|
|
115
|
+
hash
|
|
116
|
+
] : [], !!hash);
|
|
86
117
|
}
|
|
87
118
|
async getBlock(hash) {
|
|
88
|
-
return
|
|
119
|
+
return _class_private_field_get(this, _provider).send('chain_getBlock', hash ? [
|
|
120
|
+
hash
|
|
121
|
+
] : [], !!hash);
|
|
89
122
|
}
|
|
90
123
|
async getStorage(key, hash) {
|
|
91
|
-
const [child, storageKey] = (0,
|
|
124
|
+
const [child, storageKey] = (0, _index.splitChildKey)(key);
|
|
92
125
|
if (child) {
|
|
93
126
|
// child storage key, use childstate_getStorage
|
|
94
|
-
const params = [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
127
|
+
const params = [
|
|
128
|
+
child,
|
|
129
|
+
storageKey
|
|
130
|
+
];
|
|
131
|
+
if (hash) params.push(hash);
|
|
132
|
+
return _class_private_field_get(this, _provider).send('childstate_getStorage', params, !!hash);
|
|
133
|
+
} else {
|
|
100
134
|
// main storage key, use state_getStorage
|
|
101
|
-
const params = [
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
135
|
+
const params = [
|
|
136
|
+
key
|
|
137
|
+
];
|
|
138
|
+
if (hash) params.push(hash);
|
|
139
|
+
return _class_private_field_get(this, _provider).send('state_getStorage', params, !!hash);
|
|
105
140
|
}
|
|
106
141
|
}
|
|
107
142
|
async getKeysPaged(prefix, pageSize, startKey, hash) {
|
|
108
|
-
const [child, storageKey] = (0,
|
|
143
|
+
const [child, storageKey] = (0, _index.splitChildKey)(prefix);
|
|
109
144
|
if (child) {
|
|
110
145
|
// child storage key, use childstate_getKeysPaged
|
|
111
146
|
// strip child prefix from startKey
|
|
112
|
-
const params = [
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
147
|
+
const params = [
|
|
148
|
+
child,
|
|
149
|
+
storageKey,
|
|
150
|
+
pageSize,
|
|
151
|
+
(0, _index.stripChildPrefix)(startKey)
|
|
152
|
+
];
|
|
153
|
+
if (hash) params.push(hash);
|
|
154
|
+
return _class_private_field_get(this, _provider).send('childstate_getKeysPaged', params, !!hash).then((keys)=>keys.map((key)=>(0, _index.prefixedChildKey)(child, key)));
|
|
155
|
+
} else {
|
|
120
156
|
// main storage key, use state_getKeysPaged
|
|
121
|
-
const params = [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
157
|
+
const params = [
|
|
158
|
+
prefix,
|
|
159
|
+
pageSize,
|
|
160
|
+
startKey
|
|
161
|
+
];
|
|
162
|
+
if (hash) params.push(hash);
|
|
163
|
+
return _class_private_field_get(this, _provider).send('state_getKeysPaged', params, !!hash);
|
|
125
164
|
}
|
|
126
165
|
}
|
|
127
166
|
async subscribeRemoteNewHeads(cb) {
|
|
128
|
-
if (!
|
|
167
|
+
if (!_class_private_field_get(this, _provider).hasSubscriptions) {
|
|
129
168
|
throw new Error('subscribeRemoteNewHeads only works with subscriptions');
|
|
130
169
|
}
|
|
131
|
-
return
|
|
170
|
+
return _class_private_field_get(this, _provider).subscribe('chain_newHead', 'chain_subscribeNewHeads', [], cb);
|
|
132
171
|
}
|
|
133
172
|
async subscribeRemoteFinalizedHeads(cb) {
|
|
134
|
-
if (!
|
|
173
|
+
if (!_class_private_field_get(this, _provider).hasSubscriptions) {
|
|
135
174
|
throw new Error('subscribeRemoteFinalizedHeads only works with subscriptions');
|
|
136
175
|
}
|
|
137
|
-
return
|
|
176
|
+
return _class_private_field_get(this, _provider).subscribe('chain_finalizedHead', 'chain_subscribeFinalizedHeads', [], cb);
|
|
177
|
+
}
|
|
178
|
+
constructor(provider, signedExtensions){
|
|
179
|
+
_class_private_field_init(this, _provider, {
|
|
180
|
+
writable: true,
|
|
181
|
+
value: void 0
|
|
182
|
+
});
|
|
183
|
+
_class_private_field_init(this, _ready, {
|
|
184
|
+
writable: true,
|
|
185
|
+
value: void 0
|
|
186
|
+
});
|
|
187
|
+
_class_private_field_init(this, _chain, {
|
|
188
|
+
writable: true,
|
|
189
|
+
value: void 0
|
|
190
|
+
});
|
|
191
|
+
_class_private_field_init(this, _chainProperties, {
|
|
192
|
+
writable: true,
|
|
193
|
+
value: void 0
|
|
194
|
+
});
|
|
195
|
+
_define_property(this, "signedExtensions", void 0);
|
|
196
|
+
_class_private_field_set(this, _provider, provider);
|
|
197
|
+
this.signedExtensions = signedExtensions || {};
|
|
138
198
|
}
|
|
139
199
|
}
|
|
140
|
-
exports.Api = Api;
|
|
141
|
-
_Api_provider = new WeakMap(), _Api_ready = new WeakMap(), _Api_chain = new WeakMap(), _Api_chainProperties = new WeakMap();
|