@acala-network/chopsticks-testing 1.0.2-1 → 1.0.2-2

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.
@@ -1,38 +1,110 @@
1
1
  import { ApiPromise } from '@polkadot/api';
2
2
  import { Codec } from '@polkadot/types/types';
3
+ /**
4
+ * Defines a filter for blockchain events
5
+ * Can be either a string (section name) or an object with method and section
6
+ */
3
7
  export type EventFilter = string | {
4
8
  method: string;
5
9
  section: string;
6
10
  };
11
+ /**
12
+ * Configuration options for data redaction
13
+ */
7
14
  export type RedactOptions = {
15
+ /** Redact numbers with optional precision */
8
16
  number?: boolean | number;
17
+ /** Redact 32-byte hex values */
9
18
  hash?: boolean;
19
+ /** Redact any hex values with 0x prefix */
10
20
  hex?: boolean;
21
+ /** Redact base58 addresses */
11
22
  address?: boolean;
23
+ /** Regex pattern for keys whose values should be redacted */
12
24
  redactKeys?: RegExp;
25
+ /** Regex pattern for keys that should be removed */
13
26
  removeKeys?: RegExp;
14
27
  };
28
+ /**
29
+ * Function type for test assertions
30
+ */
15
31
  export type ExpectFn = (value: any) => {
16
32
  toMatchSnapshot: (msg?: string) => void;
17
33
  toMatch(value: any, msg?: string): void;
18
34
  toMatchObject(value: any, msg?: string): void;
19
35
  };
36
+ /**
37
+ * Main class for checking and validating blockchain data
38
+ * Provides a fluent interface for data transformation, filtering, and assertion
39
+ */
20
40
  export declare class Checker {
21
41
  #private;
42
+ /**
43
+ * Creates a new Checker instance
44
+ * @param expectFn - Function for making test assertions
45
+ * @param value - Value to check
46
+ * @param message - Optional message for assertions
47
+ */
22
48
  constructor(expectFn: ExpectFn, value: any, message?: string);
49
+ /** Convert the checked value to human-readable format */
23
50
  toHuman(): this;
51
+ /** Convert the checked value to hexadecimal format */
24
52
  toHex(): this;
53
+ /** Convert the checked value to JSON format */
25
54
  toJson(): this;
55
+ /**
56
+ * Set a message for test assertions
57
+ * @param message - Message to use in assertions
58
+ */
26
59
  message(message: string): this;
60
+ /**
61
+ * Filter blockchain events based on provided filters
62
+ * @param filters - Event filters to apply
63
+ */
27
64
  filterEvents(...filters: EventFilter[]): this;
65
+ /**
66
+ * Apply redaction rules to the checked value
67
+ * @param options - Redaction options
68
+ */
28
69
  redact(options?: RedactOptions): this;
70
+ /**
71
+ * Add a transformation function to the processing pipeline
72
+ * @param fn - Transformation function
73
+ */
29
74
  map(fn: (value: any) => any): this;
75
+ /**
76
+ * Apply a function to the current Checker instance
77
+ * @param fn - Function to apply
78
+ */
30
79
  pipe(fn?: (value: Checker) => Checker): Checker;
80
+ /**
81
+ * Get the final processed value
82
+ * @returns Processed value after applying all transformations
83
+ */
31
84
  value(): Promise<any>;
85
+ /**
86
+ * Assert that the value matches a snapshot
87
+ * @param msg - Optional message for the assertion
88
+ */
32
89
  toMatchSnapshot(msg?: string): Promise<void>;
90
+ /**
91
+ * Assert that the value matches an expected value
92
+ * @param value - Expected value
93
+ * @param msg - Optional message for the assertion
94
+ */
33
95
  toMatch(value: any, msg?: string): Promise<void>;
96
+ /**
97
+ * Assert that the value matches an expected object structure
98
+ * @param value - Expected object structure
99
+ * @param msg - Optional message for the assertion
100
+ */
34
101
  toMatchObject(value: any, msg?: string): Promise<void>;
35
102
  }
103
+ /**
104
+ * Creates a set of checking utilities with a provided assertion function
105
+ * @param expectFn - Function for making test assertions
106
+ * @returns Object containing various checking utilities
107
+ */
36
108
  export declare const withExpect: (expectFn: ExpectFn) => {
37
109
  check: (value: any, msg?: string) => Checker;
38
110
  checkEvents: ({ events }: {
package/dist/cjs/check.js CHANGED
@@ -66,29 +66,49 @@ function _class_private_method_init(obj, privateSet) {
66
66
  _check_private_redeclaration(obj, privateSet);
67
67
  privateSet.add(obj);
68
68
  }
69
- const processCodecOrArray = (codec, fn)=>Array.isArray(codec) ? codec.map(fn) : fn(codec);
70
- const toHuman = (codec)=>processCodecOrArray(codec, (c)=>c?.toHuman?.() ?? c);
71
- const toHex = (codec)=>processCodecOrArray(codec, (c)=>c?.toHex?.() ?? c);
72
- const toJson = (codec)=>processCodecOrArray(codec, (c)=>c?.toJSON?.() ?? c);
69
+ /**
70
+ * Processes a Codec or array of Codecs with a given transformation function
71
+ * @param codec - Single Codec or array of Codecs to process
72
+ * @param fn - Transformation function to apply to each Codec
73
+ * @returns Processed value(s)
74
+ */ const processCodecOrArray = (codec, fn)=>Array.isArray(codec) ? codec.map(fn) : fn(codec);
75
+ /**
76
+ * Converts Codec data to human-readable format
77
+ * @param codec - Codec data to convert
78
+ */ const toHuman = (codec)=>processCodecOrArray(codec, (c)=>c?.toHuman?.() ?? c);
79
+ /**
80
+ * Converts Codec data to hexadecimal format
81
+ * @param codec - Codec data to convert
82
+ */ const toHex = (codec)=>processCodecOrArray(codec, (c)=>c?.toHex?.() ?? c);
83
+ /**
84
+ * Converts Codec data to JSON format
85
+ * @param codec - Codec data to convert
86
+ */ const toJson = (codec)=>processCodecOrArray(codec, (c)=>c?.toJSON?.() ?? c);
73
87
  var _expectFn = /*#__PURE__*/ new WeakMap(), _value = /*#__PURE__*/ new WeakMap(), _pipeline = /*#__PURE__*/ new WeakMap(), _format = /*#__PURE__*/ new WeakMap(), _message = /*#__PURE__*/ new WeakMap(), _redactOptions = /*#__PURE__*/ new WeakMap(), _redact = /*#__PURE__*/ new WeakSet();
74
88
  class Checker {
75
- toHuman() {
89
+ /** Convert the checked value to human-readable format */ toHuman() {
76
90
  _class_private_field_set(this, _format, 'human');
77
91
  return this;
78
92
  }
79
- toHex() {
93
+ /** Convert the checked value to hexadecimal format */ toHex() {
80
94
  _class_private_field_set(this, _format, 'hex');
81
95
  return this;
82
96
  }
83
- toJson() {
97
+ /** Convert the checked value to JSON format */ toJson() {
84
98
  _class_private_field_set(this, _format, 'json');
85
99
  return this;
86
100
  }
87
- message(message) {
101
+ /**
102
+ * Set a message for test assertions
103
+ * @param message - Message to use in assertions
104
+ */ message(message) {
88
105
  _class_private_field_set(this, _message, message);
89
106
  return this;
90
107
  }
91
- filterEvents(...filters) {
108
+ /**
109
+ * Filter blockchain events based on provided filters
110
+ * @param filters - Event filters to apply
111
+ */ filterEvents(...filters) {
92
112
  this.toHuman();
93
113
  _class_private_field_get(this, _pipeline).push((value)=>{
94
114
  let data = value.map(({ event: { index: _, ...event } })=>event);
@@ -108,7 +128,10 @@ class Checker {
108
128
  });
109
129
  return this;
110
130
  }
111
- redact(options = {
131
+ /**
132
+ * Apply redaction rules to the checked value
133
+ * @param options - Redaction options
134
+ */ redact(options = {
112
135
  number: 2,
113
136
  hash: true
114
137
  }) {
@@ -118,14 +141,23 @@ class Checker {
118
141
  });
119
142
  return this;
120
143
  }
121
- map(fn) {
144
+ /**
145
+ * Add a transformation function to the processing pipeline
146
+ * @param fn - Transformation function
147
+ */ map(fn) {
122
148
  _class_private_field_get(this, _pipeline).push(fn);
123
149
  return this;
124
150
  }
125
- pipe(fn) {
151
+ /**
152
+ * Apply a function to the current Checker instance
153
+ * @param fn - Function to apply
154
+ */ pipe(fn) {
126
155
  return fn ? fn(this) : this;
127
156
  }
128
- async value() {
157
+ /**
158
+ * Get the final processed value
159
+ * @returns Processed value after applying all transformations
160
+ */ async value() {
129
161
  let value = await _class_private_field_get(this, _value);
130
162
  switch(_class_private_field_get(this, _format)){
131
163
  case 'human':
@@ -144,16 +176,32 @@ class Checker {
144
176
  value = _class_private_method_get(this, _redact, redact).call(this, value);
145
177
  return value;
146
178
  }
147
- async toMatchSnapshot(msg) {
179
+ /**
180
+ * Assert that the value matches a snapshot
181
+ * @param msg - Optional message for the assertion
182
+ */ async toMatchSnapshot(msg) {
148
183
  return _class_private_field_get(this, _expectFn).call(this, await this.value()).toMatchSnapshot(msg ?? _class_private_field_get(this, _message));
149
184
  }
150
- async toMatch(value, msg) {
185
+ /**
186
+ * Assert that the value matches an expected value
187
+ * @param value - Expected value
188
+ * @param msg - Optional message for the assertion
189
+ */ async toMatch(value, msg) {
151
190
  return _class_private_field_get(this, _expectFn).call(this, await this.value()).toMatch(value, msg ?? _class_private_field_get(this, _message));
152
191
  }
153
- async toMatchObject(value, msg) {
192
+ /**
193
+ * Assert that the value matches an expected object structure
194
+ * @param value - Expected object structure
195
+ * @param msg - Optional message for the assertion
196
+ */ async toMatchObject(value, msg) {
154
197
  return _class_private_field_get(this, _expectFn).call(this, await this.value()).toMatchObject(value, msg ?? _class_private_field_get(this, _message));
155
198
  }
156
- constructor(expectFn, value, message){
199
+ /**
200
+ * Creates a new Checker instance
201
+ * @param expectFn - Function for making test assertions
202
+ * @param value - Value to check
203
+ * @param message - Optional message for assertions
204
+ */ constructor(expectFn, value, message){
157
205
  _class_private_method_init(this, _redact);
158
206
  _class_private_field_init(this, _expectFn, {
159
207
  writable: true,
@@ -258,7 +306,11 @@ function redact(value) {
258
306
  return process(value);
259
307
  }
260
308
  const withExpect = (expectFn)=>{
261
- const check = (value, msg)=>{
309
+ /**
310
+ * Create a new Checker instance
311
+ * @param value - Value to check
312
+ * @param msg - Optional message for assertions
313
+ */ const check = (value, msg)=>{
262
314
  if (value instanceof Checker) {
263
315
  if (msg) {
264
316
  return value.message(msg);
@@ -267,14 +319,32 @@ const withExpect = (expectFn)=>{
267
319
  }
268
320
  return new Checker(expectFn, value, msg);
269
321
  };
270
- const checkEvents = ({ events }, ...filters)=>check(events, 'events').filterEvents(...filters).redact();
271
- const checkSystemEvents = ({ api }, ...filters)=>check(api.query.system.events(), 'system events').filterEvents(...filters).redact();
272
- const checkUmp = ({ api })=>check(api.query.parachainSystem.upwardMessages(), 'ump').map((value)=>api.createType('Vec<XcmVersionedXcm>', value).toJSON());
273
- const checkHrmp = ({ api })=>check(api.query.parachainSystem.hrmpOutboundMessages(), 'hrmp').map((value)=>value.map(({ recipient, data })=>({
322
+ /**
323
+ * Check blockchain events with filtering and redaction
324
+ * @param events - Events to check
325
+ * @param filters - Event filters to apply
326
+ */ const checkEvents = ({ events }, ...filters)=>check(events, 'events').filterEvents(...filters).redact();
327
+ /**
328
+ * Check system events with filtering and redaction
329
+ * @param api - Polkadot API instance
330
+ * @param filters - Event filters to apply
331
+ */ const checkSystemEvents = ({ api }, ...filters)=>check(api.query.system.events(), 'system events').filterEvents(...filters).redact();
332
+ /**
333
+ * Check Upward Message Passing (UMP) messages
334
+ * @param api - Polkadot API instance
335
+ */ const checkUmp = ({ api })=>check(api.query.parachainSystem.upwardMessages(), 'ump').map((value)=>api.createType('Vec<XcmVersionedXcm>', value).toJSON());
336
+ /**
337
+ * Check HRMP (Horizontal Relay-routed Message Passing) messages
338
+ * @param api - Polkadot API instance
339
+ */ const checkHrmp = ({ api })=>check(api.query.parachainSystem.hrmpOutboundMessages(), 'hrmp').map((value)=>value.map(({ recipient, data })=>({
274
340
  data: api.createType('(XcmpMessageFormat, XcmVersionedXcm)', data).toJSON(),
275
341
  recipient
276
342
  })));
277
- const checkHex = (value, msg)=>check(value, msg).toHex();
343
+ /**
344
+ * Check a value in hexadecimal format
345
+ * @param value - Value to check
346
+ * @param msg - Optional message for assertions
347
+ */ const checkHex = (value, msg)=>check(value, msg).toHex();
278
348
  return {
279
349
  check,
280
350
  checkEvents,
@@ -1,38 +1,110 @@
1
1
  import { ApiPromise } from '@polkadot/api';
2
2
  import { Codec } from '@polkadot/types/types';
3
+ /**
4
+ * Defines a filter for blockchain events
5
+ * Can be either a string (section name) or an object with method and section
6
+ */
3
7
  export type EventFilter = string | {
4
8
  method: string;
5
9
  section: string;
6
10
  };
11
+ /**
12
+ * Configuration options for data redaction
13
+ */
7
14
  export type RedactOptions = {
15
+ /** Redact numbers with optional precision */
8
16
  number?: boolean | number;
17
+ /** Redact 32-byte hex values */
9
18
  hash?: boolean;
19
+ /** Redact any hex values with 0x prefix */
10
20
  hex?: boolean;
21
+ /** Redact base58 addresses */
11
22
  address?: boolean;
23
+ /** Regex pattern for keys whose values should be redacted */
12
24
  redactKeys?: RegExp;
25
+ /** Regex pattern for keys that should be removed */
13
26
  removeKeys?: RegExp;
14
27
  };
28
+ /**
29
+ * Function type for test assertions
30
+ */
15
31
  export type ExpectFn = (value: any) => {
16
32
  toMatchSnapshot: (msg?: string) => void;
17
33
  toMatch(value: any, msg?: string): void;
18
34
  toMatchObject(value: any, msg?: string): void;
19
35
  };
36
+ /**
37
+ * Main class for checking and validating blockchain data
38
+ * Provides a fluent interface for data transformation, filtering, and assertion
39
+ */
20
40
  export declare class Checker {
21
41
  #private;
42
+ /**
43
+ * Creates a new Checker instance
44
+ * @param expectFn - Function for making test assertions
45
+ * @param value - Value to check
46
+ * @param message - Optional message for assertions
47
+ */
22
48
  constructor(expectFn: ExpectFn, value: any, message?: string);
49
+ /** Convert the checked value to human-readable format */
23
50
  toHuman(): this;
51
+ /** Convert the checked value to hexadecimal format */
24
52
  toHex(): this;
53
+ /** Convert the checked value to JSON format */
25
54
  toJson(): this;
55
+ /**
56
+ * Set a message for test assertions
57
+ * @param message - Message to use in assertions
58
+ */
26
59
  message(message: string): this;
60
+ /**
61
+ * Filter blockchain events based on provided filters
62
+ * @param filters - Event filters to apply
63
+ */
27
64
  filterEvents(...filters: EventFilter[]): this;
65
+ /**
66
+ * Apply redaction rules to the checked value
67
+ * @param options - Redaction options
68
+ */
28
69
  redact(options?: RedactOptions): this;
70
+ /**
71
+ * Add a transformation function to the processing pipeline
72
+ * @param fn - Transformation function
73
+ */
29
74
  map(fn: (value: any) => any): this;
75
+ /**
76
+ * Apply a function to the current Checker instance
77
+ * @param fn - Function to apply
78
+ */
30
79
  pipe(fn?: (value: Checker) => Checker): Checker;
80
+ /**
81
+ * Get the final processed value
82
+ * @returns Processed value after applying all transformations
83
+ */
31
84
  value(): Promise<any>;
85
+ /**
86
+ * Assert that the value matches a snapshot
87
+ * @param msg - Optional message for the assertion
88
+ */
32
89
  toMatchSnapshot(msg?: string): Promise<void>;
90
+ /**
91
+ * Assert that the value matches an expected value
92
+ * @param value - Expected value
93
+ * @param msg - Optional message for the assertion
94
+ */
33
95
  toMatch(value: any, msg?: string): Promise<void>;
96
+ /**
97
+ * Assert that the value matches an expected object structure
98
+ * @param value - Expected object structure
99
+ * @param msg - Optional message for the assertion
100
+ */
34
101
  toMatchObject(value: any, msg?: string): Promise<void>;
35
102
  }
103
+ /**
104
+ * Creates a set of checking utilities with a provided assertion function
105
+ * @param expectFn - Function for making test assertions
106
+ * @returns Object containing various checking utilities
107
+ */
36
108
  export declare const withExpect: (expectFn: ExpectFn) => {
37
109
  check: (value: any, msg?: string) => Checker;
38
110
  checkEvents: ({ events }: {
package/dist/esm/check.js CHANGED
@@ -1,36 +1,64 @@
1
- const processCodecOrArray = (codec, fn)=>Array.isArray(codec) ? codec.map(fn) : fn(codec);
2
- const toHuman = (codec)=>processCodecOrArray(codec, (c)=>c?.toHuman?.() ?? c);
3
- const toHex = (codec)=>processCodecOrArray(codec, (c)=>c?.toHex?.() ?? c);
4
- const toJson = (codec)=>processCodecOrArray(codec, (c)=>c?.toJSON?.() ?? c);
5
- export class Checker {
1
+ /**
2
+ * Processes a Codec or array of Codecs with a given transformation function
3
+ * @param codec - Single Codec or array of Codecs to process
4
+ * @param fn - Transformation function to apply to each Codec
5
+ * @returns Processed value(s)
6
+ */ const processCodecOrArray = (codec, fn)=>Array.isArray(codec) ? codec.map(fn) : fn(codec);
7
+ /**
8
+ * Converts Codec data to human-readable format
9
+ * @param codec - Codec data to convert
10
+ */ const toHuman = (codec)=>processCodecOrArray(codec, (c)=>c?.toHuman?.() ?? c);
11
+ /**
12
+ * Converts Codec data to hexadecimal format
13
+ * @param codec - Codec data to convert
14
+ */ const toHex = (codec)=>processCodecOrArray(codec, (c)=>c?.toHex?.() ?? c);
15
+ /**
16
+ * Converts Codec data to JSON format
17
+ * @param codec - Codec data to convert
18
+ */ const toJson = (codec)=>processCodecOrArray(codec, (c)=>c?.toJSON?.() ?? c);
19
+ /**
20
+ * Main class for checking and validating blockchain data
21
+ * Provides a fluent interface for data transformation, filtering, and assertion
22
+ */ export class Checker {
6
23
  #expectFn;
7
24
  #value;
8
25
  #pipeline = [];
9
26
  #format = 'json';
10
27
  #message;
11
28
  #redactOptions;
12
- constructor(expectFn, value, message){
29
+ /**
30
+ * Creates a new Checker instance
31
+ * @param expectFn - Function for making test assertions
32
+ * @param value - Value to check
33
+ * @param message - Optional message for assertions
34
+ */ constructor(expectFn, value, message){
13
35
  this.#expectFn = expectFn;
14
36
  this.#value = value;
15
37
  this.#message = message;
16
38
  }
17
- toHuman() {
39
+ /** Convert the checked value to human-readable format */ toHuman() {
18
40
  this.#format = 'human';
19
41
  return this;
20
42
  }
21
- toHex() {
43
+ /** Convert the checked value to hexadecimal format */ toHex() {
22
44
  this.#format = 'hex';
23
45
  return this;
24
46
  }
25
- toJson() {
47
+ /** Convert the checked value to JSON format */ toJson() {
26
48
  this.#format = 'json';
27
49
  return this;
28
50
  }
29
- message(message) {
51
+ /**
52
+ * Set a message for test assertions
53
+ * @param message - Message to use in assertions
54
+ */ message(message) {
30
55
  this.#message = message;
31
56
  return this;
32
57
  }
33
- filterEvents(...filters) {
58
+ /**
59
+ * Filter blockchain events based on provided filters
60
+ * @param filters - Event filters to apply
61
+ */ filterEvents(...filters) {
34
62
  this.toHuman();
35
63
  this.#pipeline.push((value)=>{
36
64
  let data = value.map(({ event: { index: _, ...event } })=>event);
@@ -50,7 +78,10 @@ export class Checker {
50
78
  });
51
79
  return this;
52
80
  }
53
- redact(options = {
81
+ /**
82
+ * Apply redaction rules to the checked value
83
+ * @param options - Redaction options
84
+ */ redact(options = {
54
85
  number: 2,
55
86
  hash: true
56
87
  }) {
@@ -133,14 +164,23 @@ export class Checker {
133
164
  };
134
165
  return process(value);
135
166
  }
136
- map(fn) {
167
+ /**
168
+ * Add a transformation function to the processing pipeline
169
+ * @param fn - Transformation function
170
+ */ map(fn) {
137
171
  this.#pipeline.push(fn);
138
172
  return this;
139
173
  }
140
- pipe(fn) {
174
+ /**
175
+ * Apply a function to the current Checker instance
176
+ * @param fn - Function to apply
177
+ */ pipe(fn) {
141
178
  return fn ? fn(this) : this;
142
179
  }
143
- async value() {
180
+ /**
181
+ * Get the final processed value
182
+ * @returns Processed value after applying all transformations
183
+ */ async value() {
144
184
  let value = await this.#value;
145
185
  switch(this.#format){
146
186
  case 'human':
@@ -159,18 +199,37 @@ export class Checker {
159
199
  value = this.#redact(value);
160
200
  return value;
161
201
  }
162
- async toMatchSnapshot(msg) {
202
+ /**
203
+ * Assert that the value matches a snapshot
204
+ * @param msg - Optional message for the assertion
205
+ */ async toMatchSnapshot(msg) {
163
206
  return this.#expectFn(await this.value()).toMatchSnapshot(msg ?? this.#message);
164
207
  }
165
- async toMatch(value, msg) {
208
+ /**
209
+ * Assert that the value matches an expected value
210
+ * @param value - Expected value
211
+ * @param msg - Optional message for the assertion
212
+ */ async toMatch(value, msg) {
166
213
  return this.#expectFn(await this.value()).toMatch(value, msg ?? this.#message);
167
214
  }
168
- async toMatchObject(value, msg) {
215
+ /**
216
+ * Assert that the value matches an expected object structure
217
+ * @param value - Expected object structure
218
+ * @param msg - Optional message for the assertion
219
+ */ async toMatchObject(value, msg) {
169
220
  return this.#expectFn(await this.value()).toMatchObject(value, msg ?? this.#message);
170
221
  }
171
222
  }
172
- export const withExpect = (expectFn)=>{
173
- const check = (value, msg)=>{
223
+ /**
224
+ * Creates a set of checking utilities with a provided assertion function
225
+ * @param expectFn - Function for making test assertions
226
+ * @returns Object containing various checking utilities
227
+ */ export const withExpect = (expectFn)=>{
228
+ /**
229
+ * Create a new Checker instance
230
+ * @param value - Value to check
231
+ * @param msg - Optional message for assertions
232
+ */ const check = (value, msg)=>{
174
233
  if (value instanceof Checker) {
175
234
  if (msg) {
176
235
  return value.message(msg);
@@ -179,14 +238,32 @@ export const withExpect = (expectFn)=>{
179
238
  }
180
239
  return new Checker(expectFn, value, msg);
181
240
  };
182
- const checkEvents = ({ events }, ...filters)=>check(events, 'events').filterEvents(...filters).redact();
183
- const checkSystemEvents = ({ api }, ...filters)=>check(api.query.system.events(), 'system events').filterEvents(...filters).redact();
184
- const checkUmp = ({ api })=>check(api.query.parachainSystem.upwardMessages(), 'ump').map((value)=>api.createType('Vec<XcmVersionedXcm>', value).toJSON());
185
- const checkHrmp = ({ api })=>check(api.query.parachainSystem.hrmpOutboundMessages(), 'hrmp').map((value)=>value.map(({ recipient, data })=>({
241
+ /**
242
+ * Check blockchain events with filtering and redaction
243
+ * @param events - Events to check
244
+ * @param filters - Event filters to apply
245
+ */ const checkEvents = ({ events }, ...filters)=>check(events, 'events').filterEvents(...filters).redact();
246
+ /**
247
+ * Check system events with filtering and redaction
248
+ * @param api - Polkadot API instance
249
+ * @param filters - Event filters to apply
250
+ */ const checkSystemEvents = ({ api }, ...filters)=>check(api.query.system.events(), 'system events').filterEvents(...filters).redact();
251
+ /**
252
+ * Check Upward Message Passing (UMP) messages
253
+ * @param api - Polkadot API instance
254
+ */ const checkUmp = ({ api })=>check(api.query.parachainSystem.upwardMessages(), 'ump').map((value)=>api.createType('Vec<XcmVersionedXcm>', value).toJSON());
255
+ /**
256
+ * Check HRMP (Horizontal Relay-routed Message Passing) messages
257
+ * @param api - Polkadot API instance
258
+ */ const checkHrmp = ({ api })=>check(api.query.parachainSystem.hrmpOutboundMessages(), 'hrmp').map((value)=>value.map(({ recipient, data })=>({
186
259
  data: api.createType('(XcmpMessageFormat, XcmVersionedXcm)', data).toJSON(),
187
260
  recipient
188
261
  })));
189
- const checkHex = (value, msg)=>check(value, msg).toHex();
262
+ /**
263
+ * Check a value in hexadecimal format
264
+ * @param value - Value to check
265
+ * @param msg - Optional message for assertions
266
+ */ const checkHex = (value, msg)=>check(value, msg).toHex();
190
267
  return {
191
268
  check,
192
269
  checkEvents,
package/package.json CHANGED
@@ -1,23 +1,26 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks-testing",
3
- "version": "1.0.2-1",
3
+ "version": "1.0.2-2",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
+ "engines": {
8
+ "node": ">=v20"
9
+ },
7
10
  "scripts": {
8
11
  "clean": "rm -rf dist tsconfig.tsbuildinfo",
9
12
  "build": "yarn clean && ../../package-build.sh",
10
13
  "depcheck": "npx depcheck"
11
14
  },
12
15
  "dependencies": {
13
- "@acala-network/chopsticks-utils": "1.0.2-1",
14
- "@polkadot/api": "^14.0.1",
15
- "@polkadot/types": "^14.0.1"
16
+ "@acala-network/chopsticks-utils": "1.0.2-2",
17
+ "@polkadot/api": "^15.0",
18
+ "@polkadot/types": "^15.0"
16
19
  },
17
20
  "devDependencies": {
18
- "@swc/cli": "0.5.0",
19
- "@swc/core": "^1.7.40",
20
- "typescript": "^5.6.3"
21
+ "@swc/cli": "0.5.2",
22
+ "@swc/core": "^1.10.1",
23
+ "typescript": "^5.7.2"
21
24
  },
22
25
  "files": [
23
26
  "dist/esm/**",