@polkadot/types-codec 10.12.4 → 10.13.1

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.
@@ -58,7 +58,7 @@ export declare abstract class AbstractArray<T extends Codec> extends Array<T> im
58
58
  /**
59
59
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
60
60
  */
61
- toHuman(isExtended?: boolean): AnyJson;
61
+ toHuman(isExtended?: boolean, disableAscii?: boolean): AnyJson;
62
62
  /**
63
63
  * @description Converts the Object to JSON, typically used for RPC transfers
64
64
  */
@@ -66,7 +66,7 @@ export declare abstract class AbstractArray<T extends Codec> extends Array<T> im
66
66
  /**
67
67
  * @description Converts the value in a best-fit primitive form
68
68
  */
69
- toPrimitive(): AnyJson;
69
+ toPrimitive(disableAscii?: boolean): AnyJson;
70
70
  /**
71
71
  * @description Returns the base runtime type name for this instance
72
72
  */
package/abstract/Array.js CHANGED
@@ -97,11 +97,11 @@ export class AbstractArray extends Array {
97
97
  /**
98
98
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
99
99
  */
100
- toHuman(isExtended) {
100
+ toHuman(isExtended, disableAscii) {
101
101
  const count = this.length;
102
102
  const result = new Array(count);
103
103
  for (let i = 0; i < count; i++) {
104
- result[i] = this[i] && this[i].toHuman(isExtended);
104
+ result[i] = this[i] && this[i].toHuman(isExtended, disableAscii);
105
105
  }
106
106
  return result;
107
107
  }
@@ -121,11 +121,11 @@ export class AbstractArray extends Array {
121
121
  /**
122
122
  * @description Converts the value in a best-fit primitive form
123
123
  */
124
- toPrimitive() {
124
+ toPrimitive(disableAscii) {
125
125
  const count = this.length;
126
126
  const result = new Array(count);
127
127
  for (let i = 0; i < count; i++) {
128
- result[i] = this[i] && this[i].toPrimitive();
128
+ result[i] = this[i] && this[i].toPrimitive(disableAscii);
129
129
  }
130
130
  return result;
131
131
  }
@@ -42,7 +42,7 @@ export declare abstract class AbstractBase<T extends Codec> implements Codec {
42
42
  /**
43
43
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
44
44
  */
45
- toHuman(isExtended?: boolean): AnyJson;
45
+ toHuman(isExtended?: boolean, disableAscii?: boolean): AnyJson;
46
46
  /**
47
47
  * @description Converts the Object to JSON, typically used for RPC transfers
48
48
  */
@@ -50,7 +50,7 @@ export declare abstract class AbstractBase<T extends Codec> implements Codec {
50
50
  /**
51
51
  * @description Converts the value in a best-fit primitive form
52
52
  */
53
- toPrimitive(): AnyJson;
53
+ toPrimitive(disableAscii?: boolean): AnyJson;
54
54
  /**
55
55
  * @description Returns the string representation of the value
56
56
  */
package/abstract/Base.js CHANGED
@@ -58,8 +58,8 @@ export class AbstractBase {
58
58
  /**
59
59
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
60
60
  */
61
- toHuman(isExtended) {
62
- return this.__internal__raw.toHuman(isExtended);
61
+ toHuman(isExtended, disableAscii) {
62
+ return this.__internal__raw.toHuman(isExtended, disableAscii);
63
63
  }
64
64
  /**
65
65
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -70,8 +70,8 @@ export class AbstractBase {
70
70
  /**
71
71
  * @description Converts the value in a best-fit primitive form
72
72
  */
73
- toPrimitive() {
74
- return this.__internal__raw.toPrimitive();
73
+ toPrimitive(disableAscii) {
74
+ return this.__internal__raw.toPrimitive(disableAscii);
75
75
  }
76
76
  /**
77
77
  * @description Returns the string representation of the value
@@ -38,7 +38,7 @@ export declare abstract class AbstractObject<T extends ToString> implements Code
38
38
  /**
39
39
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
40
40
  */
41
- abstract toHuman(isExtended?: boolean): AnyJson;
41
+ abstract toHuman(isExtended?: boolean, disableAscii?: boolean): AnyJson;
42
42
  /**
43
43
  * @description Converts the Object to JSON, typically used for RPC transfers
44
44
  */
@@ -46,7 +46,7 @@ export declare abstract class AbstractObject<T extends ToString> implements Code
46
46
  /**
47
47
  * @description Converts the value in a best-fit primitive form
48
48
  */
49
- abstract toPrimitive(): AnyJson;
49
+ abstract toPrimitive(disableAscii?: boolean): AnyJson;
50
50
  /**
51
51
  * @description Returns the string representation of the value
52
52
  */
package/base/Compact.d.ts CHANGED
@@ -57,7 +57,7 @@ export declare class Compact<T extends INumber> implements ICompact<T> {
57
57
  /**
58
58
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
59
59
  */
60
- toHuman(isExtended?: boolean): AnyJson;
60
+ toHuman(isExtended?: boolean, disableAscii?: boolean): AnyJson;
61
61
  /**
62
62
  * @description Converts the Object to JSON, typically used for RPC transfers
63
63
  */
@@ -69,7 +69,7 @@ export declare class Compact<T extends INumber> implements ICompact<T> {
69
69
  /**
70
70
  * @description Converts the value in a best-fit primitive form
71
71
  */
72
- toPrimitive(): string | number;
72
+ toPrimitive(disableAscii?: boolean): string | number;
73
73
  /**
74
74
  * @description Returns the base runtime type name for this instance
75
75
  */
package/base/Compact.js CHANGED
@@ -111,8 +111,8 @@ export class Compact {
111
111
  /**
112
112
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
113
113
  */
114
- toHuman(isExtended) {
115
- return this.__internal__raw.toHuman(isExtended);
114
+ toHuman(isExtended, disableAscii) {
115
+ return this.__internal__raw.toHuman(isExtended, disableAscii);
116
116
  }
117
117
  /**
118
118
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -129,8 +129,8 @@ export class Compact {
129
129
  /**
130
130
  * @description Converts the value in a best-fit primitive form
131
131
  */
132
- toPrimitive() {
133
- return this.__internal__raw.toPrimitive();
132
+ toPrimitive(disableAscii) {
133
+ return this.__internal__raw.toPrimitive(disableAscii);
134
134
  }
135
135
  /**
136
136
  * @description Returns the base runtime type name for this instance
package/base/Enum.d.ts CHANGED
@@ -84,7 +84,7 @@ export declare class Enum implements IEnum {
84
84
  /**
85
85
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
86
86
  */
87
- toHuman(isExtended?: boolean): AnyJson;
87
+ toHuman(isExtended?: boolean, disableAscii?: boolean): AnyJson;
88
88
  /**
89
89
  * @description Converts the Object to JSON, typically used for RPC transfers
90
90
  */
@@ -96,7 +96,7 @@ export declare class Enum implements IEnum {
96
96
  /**
97
97
  * @description Converts the value in a best-fit primitive form
98
98
  */
99
- toPrimitive(): AnyJson;
99
+ toPrimitive(disableAscii?: boolean): AnyJson;
100
100
  /**
101
101
  * @description Returns a raw struct representation of the enum types
102
102
  */
package/base/Enum.js CHANGED
@@ -294,10 +294,10 @@ export class Enum {
294
294
  /**
295
295
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
296
296
  */
297
- toHuman(isExtended) {
297
+ toHuman(isExtended, disableAscii) {
298
298
  return this.__internal__isBasic || this.isNone
299
299
  ? this.type
300
- : { [this.type]: this.__internal__raw.toHuman(isExtended) };
300
+ : { [this.type]: this.__internal__raw.toHuman(isExtended, disableAscii) };
301
301
  }
302
302
  /**
303
303
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -316,10 +316,10 @@ export class Enum {
316
316
  /**
317
317
  * @description Converts the value in a best-fit primitive form
318
318
  */
319
- toPrimitive() {
319
+ toPrimitive(disableAscii) {
320
320
  return this.__internal__isBasic
321
321
  ? this.type
322
- : { [stringCamelCase(this.type)]: this.__internal__raw.toPrimitive() };
322
+ : { [stringCamelCase(this.type)]: this.__internal__raw.toPrimitive(disableAscii) };
323
323
  }
324
324
  /**
325
325
  * @description Returns a raw struct representation of the enum types
package/base/Option.d.ts CHANGED
@@ -55,7 +55,7 @@ export declare class Option<T extends Codec> implements IOption<T> {
55
55
  /**
56
56
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
57
57
  */
58
- toHuman(isExtended?: boolean): AnyJson;
58
+ toHuman(isExtended?: boolean, disableAscii?: boolean): AnyJson;
59
59
  /**
60
60
  * @description Converts the Object to JSON, typically used for RPC transfers
61
61
  */
@@ -63,7 +63,7 @@ export declare class Option<T extends Codec> implements IOption<T> {
63
63
  /**
64
64
  * @description Converts the value in a best-fit primitive form
65
65
  */
66
- toPrimitive(): AnyJson;
66
+ toPrimitive(disableAscii?: boolean): AnyJson;
67
67
  /**
68
68
  * @description Returns the base runtime type name for this instance
69
69
  */
package/base/Option.js CHANGED
@@ -153,8 +153,8 @@ export class Option {
153
153
  /**
154
154
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
155
155
  */
156
- toHuman(isExtended) {
157
- return this.__internal__raw.toHuman(isExtended);
156
+ toHuman(isExtended, disableAscii) {
157
+ return this.__internal__raw.toHuman(isExtended, disableAscii);
158
158
  }
159
159
  /**
160
160
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -167,10 +167,10 @@ export class Option {
167
167
  /**
168
168
  * @description Converts the value in a best-fit primitive form
169
169
  */
170
- toPrimitive() {
170
+ toPrimitive(disableAscii) {
171
171
  return this.isNone
172
172
  ? null
173
- : this.__internal__raw.toPrimitive();
173
+ : this.__internal__raw.toPrimitive(disableAscii);
174
174
  }
175
175
  /**
176
176
  * @description Returns the base runtime type name for this instance
@@ -100,11 +100,11 @@ class AbstractArray extends Array {
100
100
  /**
101
101
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
102
102
  */
103
- toHuman(isExtended) {
103
+ toHuman(isExtended, disableAscii) {
104
104
  const count = this.length;
105
105
  const result = new Array(count);
106
106
  for (let i = 0; i < count; i++) {
107
- result[i] = this[i] && this[i].toHuman(isExtended);
107
+ result[i] = this[i] && this[i].toHuman(isExtended, disableAscii);
108
108
  }
109
109
  return result;
110
110
  }
@@ -124,11 +124,11 @@ class AbstractArray extends Array {
124
124
  /**
125
125
  * @description Converts the value in a best-fit primitive form
126
126
  */
127
- toPrimitive() {
127
+ toPrimitive(disableAscii) {
128
128
  const count = this.length;
129
129
  const result = new Array(count);
130
130
  for (let i = 0; i < count; i++) {
131
- result[i] = this[i] && this[i].toPrimitive();
131
+ result[i] = this[i] && this[i].toPrimitive(disableAscii);
132
132
  }
133
133
  return result;
134
134
  }
@@ -61,8 +61,8 @@ class AbstractBase {
61
61
  /**
62
62
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
63
63
  */
64
- toHuman(isExtended) {
65
- return this.__internal__raw.toHuman(isExtended);
64
+ toHuman(isExtended, disableAscii) {
65
+ return this.__internal__raw.toHuman(isExtended, disableAscii);
66
66
  }
67
67
  /**
68
68
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -73,8 +73,8 @@ class AbstractBase {
73
73
  /**
74
74
  * @description Converts the value in a best-fit primitive form
75
75
  */
76
- toPrimitive() {
77
- return this.__internal__raw.toPrimitive();
76
+ toPrimitive(disableAscii) {
77
+ return this.__internal__raw.toPrimitive(disableAscii);
78
78
  }
79
79
  /**
80
80
  * @description Returns the string representation of the value
@@ -114,8 +114,8 @@ class Compact {
114
114
  /**
115
115
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
116
116
  */
117
- toHuman(isExtended) {
118
- return this.__internal__raw.toHuman(isExtended);
117
+ toHuman(isExtended, disableAscii) {
118
+ return this.__internal__raw.toHuman(isExtended, disableAscii);
119
119
  }
120
120
  /**
121
121
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -132,8 +132,8 @@ class Compact {
132
132
  /**
133
133
  * @description Converts the value in a best-fit primitive form
134
134
  */
135
- toPrimitive() {
136
- return this.__internal__raw.toPrimitive();
135
+ toPrimitive(disableAscii) {
136
+ return this.__internal__raw.toPrimitive(disableAscii);
137
137
  }
138
138
  /**
139
139
  * @description Returns the base runtime type name for this instance
package/cjs/base/Enum.js CHANGED
@@ -297,10 +297,10 @@ class Enum {
297
297
  /**
298
298
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
299
299
  */
300
- toHuman(isExtended) {
300
+ toHuman(isExtended, disableAscii) {
301
301
  return this.__internal__isBasic || this.isNone
302
302
  ? this.type
303
- : { [this.type]: this.__internal__raw.toHuman(isExtended) };
303
+ : { [this.type]: this.__internal__raw.toHuman(isExtended, disableAscii) };
304
304
  }
305
305
  /**
306
306
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -319,10 +319,10 @@ class Enum {
319
319
  /**
320
320
  * @description Converts the value in a best-fit primitive form
321
321
  */
322
- toPrimitive() {
322
+ toPrimitive(disableAscii) {
323
323
  return this.__internal__isBasic
324
324
  ? this.type
325
- : { [(0, util_1.stringCamelCase)(this.type)]: this.__internal__raw.toPrimitive() };
325
+ : { [(0, util_1.stringCamelCase)(this.type)]: this.__internal__raw.toPrimitive(disableAscii) };
326
326
  }
327
327
  /**
328
328
  * @description Returns a raw struct representation of the enum types
@@ -156,8 +156,8 @@ class Option {
156
156
  /**
157
157
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
158
158
  */
159
- toHuman(isExtended) {
160
- return this.__internal__raw.toHuman(isExtended);
159
+ toHuman(isExtended, disableAscii) {
160
+ return this.__internal__raw.toHuman(isExtended, disableAscii);
161
161
  }
162
162
  /**
163
163
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -170,10 +170,10 @@ class Option {
170
170
  /**
171
171
  * @description Converts the value in a best-fit primitive form
172
172
  */
173
- toPrimitive() {
173
+ toPrimitive(disableAscii) {
174
174
  return this.isNone
175
175
  ? null
176
- : this.__internal__raw.toPrimitive();
176
+ : this.__internal__raw.toPrimitive(disableAscii);
177
177
  }
178
178
  /**
179
179
  * @description Returns the base runtime type name for this instance
@@ -132,10 +132,10 @@ class BTreeSet extends Set {
132
132
  /**
133
133
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
134
134
  */
135
- toHuman(isExtended) {
135
+ toHuman(isExtended, disableAscii) {
136
136
  const json = [];
137
137
  for (const v of this.values()) {
138
- json.push(v.toHuman(isExtended));
138
+ json.push(v.toHuman(isExtended, disableAscii));
139
139
  }
140
140
  return json;
141
141
  }
@@ -158,10 +158,10 @@ class BTreeSet extends Set {
158
158
  /**
159
159
  * @description Converts the value in a best-fit primitive form
160
160
  */
161
- toPrimitive() {
161
+ toPrimitive(disableAscii) {
162
162
  const json = [];
163
163
  for (const v of this.values()) {
164
- json.push(v.toPrimitive());
164
+ json.push(v.toPrimitive(disableAscii));
165
165
  }
166
166
  return json;
167
167
  }
@@ -143,12 +143,12 @@ class CodecMap extends Map {
143
143
  /**
144
144
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
145
145
  */
146
- toHuman(isExtended) {
146
+ toHuman(isExtended, disableAscii) {
147
147
  const json = {};
148
148
  for (const [k, v] of this.entries()) {
149
- json[k instanceof Raw_js_1.Raw && k.isAscii
149
+ json[k instanceof Raw_js_1.Raw && !disableAscii && k.isAscii
150
150
  ? k.toUtf8()
151
- : k.toString()] = v.toHuman(isExtended);
151
+ : k.toString()] = v.toHuman(isExtended, disableAscii);
152
152
  }
153
153
  return json;
154
154
  }
@@ -165,12 +165,12 @@ class CodecMap extends Map {
165
165
  /**
166
166
  * @description Converts the value in a best-fit primitive form
167
167
  */
168
- toPrimitive() {
168
+ toPrimitive(disableAscii) {
169
169
  const json = {};
170
170
  for (const [k, v] of this.entries()) {
171
- json[k instanceof Raw_js_1.Raw && k.isAscii
171
+ json[k instanceof Raw_js_1.Raw && !disableAscii && k.isAscii
172
172
  ? k.toUtf8()
173
- : k.toString()] = v.toPrimitive();
173
+ : k.toString()] = v.toPrimitive(disableAscii);
174
174
  }
175
175
  return json;
176
176
  }
@@ -63,18 +63,18 @@ class WrapperKeepOpaque extends Bytes_js_1.Bytes {
63
63
  /**
64
64
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
65
65
  */
66
- toHuman(isExtended) {
66
+ toHuman(isExtended, disableAscii) {
67
67
  return this.__internal__decoded
68
- ? this.__internal__decoded.toHuman(isExtended)
69
- : super.toHuman();
68
+ ? this.__internal__decoded.toHuman(isExtended, disableAscii)
69
+ : super.toHuman(isExtended, disableAscii);
70
70
  }
71
71
  /**
72
72
  * @description Converts the value in a best-fit primitive form
73
73
  */
74
- toPrimitive() {
74
+ toPrimitive(disableAscii) {
75
75
  return this.__internal__decoded
76
- ? this.__internal__decoded.toPrimitive()
77
- : super.toPrimitive();
76
+ ? this.__internal__decoded.toPrimitive(disableAscii)
77
+ : super.toPrimitive(disableAscii);
78
78
  }
79
79
  /**
80
80
  * @description Returns the base runtime type name for this instance
@@ -91,10 +91,10 @@ class Json extends Map {
91
91
  /**
92
92
  * @description Converts the value in a best-fit primitive form
93
93
  */
94
- toPrimitive() {
94
+ toPrimitive(disableAscii) {
95
95
  return [...this.entries()].reduce((json, [key, value]) => {
96
96
  json[key] = (0, util_1.isFunction)(value.toPrimitive)
97
- ? value.toPrimitive()
97
+ ? value.toPrimitive(disableAscii)
98
98
  : value;
99
99
  return json;
100
100
  }, {});
package/cjs/native/Raw.js CHANGED
@@ -91,8 +91,8 @@ class Raw extends Uint8Array {
91
91
  /**
92
92
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
93
93
  */
94
- toHuman() {
95
- return this.toPrimitive();
94
+ toHuman(_isExtended, disableAscii) {
95
+ return this.toPrimitive(disableAscii);
96
96
  }
97
97
  /**
98
98
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -103,8 +103,8 @@ class Raw extends Uint8Array {
103
103
  /**
104
104
  * @description Converts the value in a best-fit primitive form
105
105
  */
106
- toPrimitive() {
107
- if (this.isAscii) {
106
+ toPrimitive(disableAscii) {
107
+ if (!disableAscii && this.isAscii) {
108
108
  const text = this.toUtf8();
109
109
  // ensure we didn't end up with multibyte codepoints
110
110
  if ((0, util_1.isAscii)(text)) {
@@ -209,10 +209,10 @@ class Struct extends Map {
209
209
  /**
210
210
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
211
211
  */
212
- toHuman(isExtended) {
212
+ toHuman(isExtended, disableAscii) {
213
213
  const json = {};
214
214
  for (const [k, v] of this.entries()) {
215
- json[k] = v.toHuman(isExtended);
215
+ json[k] = v.toHuman(isExtended, disableAscii);
216
216
  }
217
217
  return json;
218
218
  }
@@ -231,10 +231,10 @@ class Struct extends Map {
231
231
  /**
232
232
  * @description Converts the value in a best-fit primitive form
233
233
  */
234
- toPrimitive() {
234
+ toPrimitive(disableAscii) {
235
235
  const json = {};
236
236
  for (const [k, v] of this.entries()) {
237
- json[k] = v.toPrimitive();
237
+ json[k] = v.toPrimitive(disableAscii);
238
238
  }
239
239
  return json;
240
240
  }
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageInfo = void 0;
4
- exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.12.4' };
4
+ exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.13.1' };
@@ -39,7 +39,7 @@ export declare class BTreeSet<V extends Codec = Codec> extends Set<V> implements
39
39
  /**
40
40
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
41
41
  */
42
- toHuman(isExtended?: boolean): AnyJson;
42
+ toHuman(isExtended?: boolean, disableAscii?: boolean): AnyJson;
43
43
  /**
44
44
  * @description Converts the Object to JSON, typically used for RPC transfers
45
45
  */
@@ -51,7 +51,7 @@ export declare class BTreeSet<V extends Codec = Codec> extends Set<V> implements
51
51
  /**
52
52
  * @description Converts the value in a best-fit primitive form
53
53
  */
54
- toPrimitive(): AnyJson;
54
+ toPrimitive(disableAscii?: boolean): AnyJson;
55
55
  /**
56
56
  * @description Returns the string representation of the value
57
57
  */
@@ -129,10 +129,10 @@ export class BTreeSet extends Set {
129
129
  /**
130
130
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
131
131
  */
132
- toHuman(isExtended) {
132
+ toHuman(isExtended, disableAscii) {
133
133
  const json = [];
134
134
  for (const v of this.values()) {
135
- json.push(v.toHuman(isExtended));
135
+ json.push(v.toHuman(isExtended, disableAscii));
136
136
  }
137
137
  return json;
138
138
  }
@@ -155,10 +155,10 @@ export class BTreeSet extends Set {
155
155
  /**
156
156
  * @description Converts the value in a best-fit primitive form
157
157
  */
158
- toPrimitive() {
158
+ toPrimitive(disableAscii) {
159
159
  const json = [];
160
160
  for (const v of this.values()) {
161
- json.push(v.toPrimitive());
161
+ json.push(v.toPrimitive(disableAscii));
162
162
  }
163
163
  return json;
164
164
  }
package/extended/Map.d.ts CHANGED
@@ -34,7 +34,7 @@ export declare class CodecMap<K extends Codec = Codec, V extends Codec = Codec>
34
34
  /**
35
35
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
36
36
  */
37
- toHuman(isExtended?: boolean): Record<string, AnyJson>;
37
+ toHuman(isExtended?: boolean, disableAscii?: boolean): Record<string, AnyJson>;
38
38
  /**
39
39
  * @description Converts the Object to JSON, typically used for RPC transfers
40
40
  */
@@ -42,7 +42,7 @@ export declare class CodecMap<K extends Codec = Codec, V extends Codec = Codec>
42
42
  /**
43
43
  * @description Converts the value in a best-fit primitive form
44
44
  */
45
- toPrimitive(): AnyJson;
45
+ toPrimitive(disableAscii?: boolean): AnyJson;
46
46
  /**
47
47
  * @description Returns the base runtime type name for this instance
48
48
  */
package/extended/Map.js CHANGED
@@ -140,12 +140,12 @@ export class CodecMap extends Map {
140
140
  /**
141
141
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
142
142
  */
143
- toHuman(isExtended) {
143
+ toHuman(isExtended, disableAscii) {
144
144
  const json = {};
145
145
  for (const [k, v] of this.entries()) {
146
- json[k instanceof Raw && k.isAscii
146
+ json[k instanceof Raw && !disableAscii && k.isAscii
147
147
  ? k.toUtf8()
148
- : k.toString()] = v.toHuman(isExtended);
148
+ : k.toString()] = v.toHuman(isExtended, disableAscii);
149
149
  }
150
150
  return json;
151
151
  }
@@ -162,12 +162,12 @@ export class CodecMap extends Map {
162
162
  /**
163
163
  * @description Converts the value in a best-fit primitive form
164
164
  */
165
- toPrimitive() {
165
+ toPrimitive(disableAscii) {
166
166
  const json = {};
167
167
  for (const [k, v] of this.entries()) {
168
- json[k instanceof Raw && k.isAscii
168
+ json[k instanceof Raw && !disableAscii && k.isAscii
169
169
  ? k.toUtf8()
170
- : k.toString()] = v.toPrimitive();
170
+ : k.toString()] = v.toPrimitive(disableAscii);
171
171
  }
172
172
  return json;
173
173
  }
@@ -19,11 +19,11 @@ export declare class WrapperKeepOpaque<T extends Codec> extends Bytes {
19
19
  /**
20
20
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
21
21
  */
22
- toHuman(isExtended?: boolean): AnyJson;
22
+ toHuman(isExtended?: boolean, disableAscii?: boolean): AnyJson;
23
23
  /**
24
24
  * @description Converts the value in a best-fit primitive form
25
25
  */
26
- toPrimitive(): any;
26
+ toPrimitive(disableAscii?: boolean): any;
27
27
  /**
28
28
  * @description Returns the base runtime type name for this instance
29
29
  */
@@ -60,18 +60,18 @@ export class WrapperKeepOpaque extends Bytes {
60
60
  /**
61
61
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
62
62
  */
63
- toHuman(isExtended) {
63
+ toHuman(isExtended, disableAscii) {
64
64
  return this.__internal__decoded
65
- ? this.__internal__decoded.toHuman(isExtended)
66
- : super.toHuman();
65
+ ? this.__internal__decoded.toHuman(isExtended, disableAscii)
66
+ : super.toHuman(isExtended, disableAscii);
67
67
  }
68
68
  /**
69
69
  * @description Converts the value in a best-fit primitive form
70
70
  */
71
- toPrimitive() {
71
+ toPrimitive(disableAscii) {
72
72
  return this.__internal__decoded
73
- ? this.__internal__decoded.toPrimitive()
74
- : super.toPrimitive();
73
+ ? this.__internal__decoded.toPrimitive(disableAscii)
74
+ : super.toPrimitive(disableAscii);
75
75
  }
76
76
  /**
77
77
  * @description Returns the base runtime type name for this instance
package/native/Json.d.ts CHANGED
@@ -53,7 +53,7 @@ export declare class Json extends Map<string, any> implements Codec {
53
53
  /**
54
54
  * @description Converts the value in a best-fit primitive form
55
55
  */
56
- toPrimitive(): Record<string, AnyJson>;
56
+ toPrimitive(disableAscii?: boolean): Record<string, AnyJson>;
57
57
  /**
58
58
  * @description Returns the base runtime type name for this instance
59
59
  */
package/native/Json.js CHANGED
@@ -88,10 +88,10 @@ export class Json extends Map {
88
88
  /**
89
89
  * @description Converts the value in a best-fit primitive form
90
90
  */
91
- toPrimitive() {
91
+ toPrimitive(disableAscii) {
92
92
  return [...this.entries()].reduce((json, [key, value]) => {
93
93
  json[key] = isFunction(value.toPrimitive)
94
- ? value.toPrimitive()
94
+ ? value.toPrimitive(disableAscii)
95
95
  : value;
96
96
  return json;
97
97
  }, {});
package/native/Raw.d.ts CHANGED
@@ -59,7 +59,7 @@ export declare class Raw extends Uint8Array implements IU8a {
59
59
  /**
60
60
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
61
61
  */
62
- toHuman(): AnyJson;
62
+ toHuman(_isExtended?: boolean, disableAscii?: boolean): AnyJson;
63
63
  /**
64
64
  * @description Converts the Object to JSON, typically used for RPC transfers
65
65
  */
@@ -67,7 +67,7 @@ export declare class Raw extends Uint8Array implements IU8a {
67
67
  /**
68
68
  * @description Converts the value in a best-fit primitive form
69
69
  */
70
- toPrimitive(): AnyJson;
70
+ toPrimitive(disableAscii?: boolean): AnyJson;
71
71
  /**
72
72
  * @description Returns the base runtime type name for this instance
73
73
  */
package/native/Raw.js CHANGED
@@ -88,8 +88,8 @@ export class Raw extends Uint8Array {
88
88
  /**
89
89
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
90
90
  */
91
- toHuman() {
92
- return this.toPrimitive();
91
+ toHuman(_isExtended, disableAscii) {
92
+ return this.toPrimitive(disableAscii);
93
93
  }
94
94
  /**
95
95
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -100,8 +100,8 @@ export class Raw extends Uint8Array {
100
100
  /**
101
101
  * @description Converts the value in a best-fit primitive form
102
102
  */
103
- toPrimitive() {
104
- if (this.isAscii) {
103
+ toPrimitive(disableAscii) {
104
+ if (!disableAscii && this.isAscii) {
105
105
  const text = this.toUtf8();
106
106
  // ensure we didn't end up with multibyte codepoints
107
107
  if (isAscii(text)) {
@@ -80,7 +80,7 @@ export declare class Struct<S extends TypesDef = TypesDef, V extends {
80
80
  /**
81
81
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
82
82
  */
83
- toHuman(isExtended?: boolean): Record<string, AnyJson>;
83
+ toHuman(isExtended?: boolean, disableAscii?: boolean): Record<string, AnyJson>;
84
84
  /**
85
85
  * @description Converts the Object to JSON, typically used for RPC transfers
86
86
  */
@@ -88,7 +88,7 @@ export declare class Struct<S extends TypesDef = TypesDef, V extends {
88
88
  /**
89
89
  * @description Converts the value in a best-fit primitive form
90
90
  */
91
- toPrimitive(): Record<string, AnyJson>;
91
+ toPrimitive(disableAscii?: boolean): Record<string, AnyJson>;
92
92
  /**
93
93
  * @description Returns the base runtime type name for this instance
94
94
  */
package/native/Struct.js CHANGED
@@ -206,10 +206,10 @@ export class Struct extends Map {
206
206
  /**
207
207
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
208
208
  */
209
- toHuman(isExtended) {
209
+ toHuman(isExtended, disableAscii) {
210
210
  const json = {};
211
211
  for (const [k, v] of this.entries()) {
212
- json[k] = v.toHuman(isExtended);
212
+ json[k] = v.toHuman(isExtended, disableAscii);
213
213
  }
214
214
  return json;
215
215
  }
@@ -228,10 +228,10 @@ export class Struct extends Map {
228
228
  /**
229
229
  * @description Converts the value in a best-fit primitive form
230
230
  */
231
- toPrimitive() {
231
+ toPrimitive(disableAscii) {
232
232
  const json = {};
233
233
  for (const [k, v] of this.entries()) {
234
- json[k] = v.toPrimitive();
234
+ json[k] = v.toPrimitive(disableAscii);
235
235
  }
236
236
  return json;
237
237
  }
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "./cjs/packageDetect.js"
19
19
  ],
20
20
  "type": "module",
21
- "version": "10.12.4",
21
+ "version": "10.13.1",
22
22
  "main": "./cjs/index.js",
23
23
  "module": "./index.js",
24
24
  "types": "./index.d.ts",
package/packageInfo.js CHANGED
@@ -1 +1 @@
1
- export const packageInfo = { name: '@polkadot/types-codec', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '10.12.4' };
1
+ export const packageInfo = { name: '@polkadot/types-codec', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '10.13.1' };
package/types/codec.d.ts CHANGED
@@ -70,16 +70,19 @@ export interface Codec {
70
70
  toHex(isLe?: boolean): HexString;
71
71
  /**
72
72
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
73
+ * @param isExtended When set, for some (e.g. call) it can add more info, e.g. metadata documentation. (Generally not needed in all cases, but can be useful in Events, Calls, ...)
74
+ * @param disableAscii When set, for some (e.g. `Raw` types) it will disable converting the value to ascii.
73
75
  */
74
- toHuman(isExtended?: boolean): AnyJson;
76
+ toHuman(isExtended?: boolean, disableAscii?: boolean): AnyJson;
75
77
  /**
76
78
  * @description Converts the Object to JSON, typically used for RPC transfers
77
79
  */
78
80
  toJSON(): AnyJson;
79
81
  /**
80
82
  * @description Converts the value in a best-fit primitive form
83
+ * @param disableAscii
81
84
  */
82
- toPrimitive(): AnyJson;
85
+ toPrimitive(disableAscii?: boolean): AnyJson;
83
86
  /**
84
87
  * @description Returns the base runtime type name for this instance
85
88
  */
@@ -24,7 +24,7 @@ export interface INumber extends Codec {
24
24
  toBigInt(): bigint;
25
25
  toBn(): BN;
26
26
  toNumber(): number;
27
- toPrimitive(): string | number;
27
+ toPrimitive(disableAscii?: boolean): string | number;
28
28
  }
29
29
  export interface IFloat extends Codec {
30
30
  toNumber(): number;
@@ -58,7 +58,7 @@ export interface IU8a extends Uint8Array, Codec {
58
58
  readonly isAscii: boolean;
59
59
  readonly isUtf8: boolean;
60
60
  bitLength(): number;
61
- toHuman(isExtended?: boolean): any;
61
+ toHuman(isExtended?: boolean, disableAscii?: boolean): any;
62
62
  toJSON(): any;
63
63
  toUtf8(): string;
64
64
  }