@polkadot/types-codec 8.5.2-2 → 8.5.2-5
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/cjs/packageInfo.js +1 -1
- package/cjs/utils/sanitize.js +12 -6
- package/native/Text.d.ts +2 -2
- package/package.json +1 -1
- package/packageInfo.js +1 -1
- package/utils/sanitize.d.ts +1 -0
- package/utils/sanitize.js +10 -6
package/cjs/packageInfo.js
CHANGED
package/cjs/utils/sanitize.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.removePairOf = removePairOf;
|
|
|
14
14
|
exports.removeTraits = removeTraits;
|
|
15
15
|
exports.removeWrap = removeWrap;
|
|
16
16
|
exports.sanitize = sanitize;
|
|
17
|
+
exports.trim = trim;
|
|
17
18
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
18
19
|
// SPDX-License-Identifier: Apache-2.0
|
|
19
20
|
const BOUNDED = ['BTreeMap', 'BTreeSet', 'HashMap', 'Vec'];
|
|
@@ -35,7 +36,13 @@ alias('RawAddress', 'Address'), // lookups, mapped to Address/AccountId as appro
|
|
|
35
36
|
alias('Lookup::Source', 'LookupSource'), alias('Lookup::Target', 'LookupTarget'), // HACK duplication between contracts & primitives, however contracts prefixed with exec
|
|
36
37
|
alias('exec::StorageKey', 'ContractStorageKey'), // flattens tuples with one value, `(AccountId)` -> `AccountId`
|
|
37
38
|
flattenSingleTuple(), // converts ::Type to Type, <T as Trait<I>>::Proposal -> Proposal
|
|
38
|
-
removeColons()
|
|
39
|
+
removeColons(), // remove all trailing spaces - this should always be the last
|
|
40
|
+
trim()]; // given a string, trim it
|
|
41
|
+
|
|
42
|
+
function trim() {
|
|
43
|
+
return value => value.trim();
|
|
44
|
+
} // given a starting index, find the closing >
|
|
45
|
+
|
|
39
46
|
|
|
40
47
|
function findClosing(value, start) {
|
|
41
48
|
let depth = 0;
|
|
@@ -218,10 +225,11 @@ function removeWrap(check) {
|
|
|
218
225
|
const sanitizeMap = new Map(); // eslint-disable-next-line @typescript-eslint/ban-types
|
|
219
226
|
|
|
220
227
|
function sanitize(value, options) {
|
|
221
|
-
|
|
228
|
+
const startValue = value.toString();
|
|
229
|
+
let result = startValue;
|
|
222
230
|
|
|
223
231
|
if (!options) {
|
|
224
|
-
const memoized = sanitizeMap.get(
|
|
232
|
+
const memoized = sanitizeMap.get(startValue);
|
|
225
233
|
|
|
226
234
|
if (memoized) {
|
|
227
235
|
return memoized;
|
|
@@ -232,10 +240,8 @@ function sanitize(value, options) {
|
|
|
232
240
|
result = mappings[i](result, options);
|
|
233
241
|
}
|
|
234
242
|
|
|
235
|
-
result = result.trim();
|
|
236
|
-
|
|
237
243
|
if (!options) {
|
|
238
|
-
sanitizeMap.set(
|
|
244
|
+
sanitizeMap.set(startValue, result);
|
|
239
245
|
}
|
|
240
246
|
|
|
241
247
|
return result;
|
package/native/Text.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HexString } from '@polkadot/util/types';
|
|
2
|
-
import type { AnyU8a, Inspect, IText, IU8a, Registry } from '../types';
|
|
2
|
+
import type { AnyString, AnyU8a, Inspect, IText, IU8a, Registry } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* @name Text
|
|
5
5
|
* @description
|
|
@@ -12,7 +12,7 @@ export declare class Text extends String implements IText {
|
|
|
12
12
|
#private;
|
|
13
13
|
readonly registry: Registry;
|
|
14
14
|
createdAtHash?: IU8a;
|
|
15
|
-
constructor(registry: Registry, value?: null |
|
|
15
|
+
constructor(registry: Registry, value?: null | AnyString | AnyU8a | {
|
|
16
16
|
toString: () => string;
|
|
17
17
|
});
|
|
18
18
|
/**
|
package/package.json
CHANGED
package/packageInfo.js
CHANGED
|
@@ -5,5 +5,5 @@ export const packageInfo = {
|
|
|
5
5
|
name: '@polkadot/types-codec',
|
|
6
6
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
7
7
|
type: 'esm',
|
|
8
|
-
version: '8.5.2-
|
|
8
|
+
version: '8.5.2-5'
|
|
9
9
|
};
|
package/utils/sanitize.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ interface SanitizeOptions {
|
|
|
2
2
|
allowNamespaces?: boolean;
|
|
3
3
|
}
|
|
4
4
|
declare type Mapper = (value: string, options?: SanitizeOptions) => string;
|
|
5
|
+
export declare function trim(): Mapper;
|
|
5
6
|
export declare function findClosing(value: string, start: number): number;
|
|
6
7
|
export declare function alias(src: string, dest: string, withChecks?: boolean): Mapper;
|
|
7
8
|
export declare function cleanupCompact(): Mapper;
|
package/utils/sanitize.js
CHANGED
|
@@ -19,7 +19,12 @@ alias('RawAddress', 'Address'), // lookups, mapped to Address/AccountId as appro
|
|
|
19
19
|
alias('Lookup::Source', 'LookupSource'), alias('Lookup::Target', 'LookupTarget'), // HACK duplication between contracts & primitives, however contracts prefixed with exec
|
|
20
20
|
alias('exec::StorageKey', 'ContractStorageKey'), // flattens tuples with one value, `(AccountId)` -> `AccountId`
|
|
21
21
|
flattenSingleTuple(), // converts ::Type to Type, <T as Trait<I>>::Proposal -> Proposal
|
|
22
|
-
removeColons()
|
|
22
|
+
removeColons(), // remove all trailing spaces - this should always be the last
|
|
23
|
+
trim()]; // given a string, trim it
|
|
24
|
+
|
|
25
|
+
export function trim() {
|
|
26
|
+
return value => value.trim();
|
|
27
|
+
} // given a starting index, find the closing >
|
|
23
28
|
|
|
24
29
|
export function findClosing(value, start) {
|
|
25
30
|
let depth = 0;
|
|
@@ -191,10 +196,11 @@ export function removeWrap(check) {
|
|
|
191
196
|
const sanitizeMap = new Map(); // eslint-disable-next-line @typescript-eslint/ban-types
|
|
192
197
|
|
|
193
198
|
export function sanitize(value, options) {
|
|
194
|
-
|
|
199
|
+
const startValue = value.toString();
|
|
200
|
+
let result = startValue;
|
|
195
201
|
|
|
196
202
|
if (!options) {
|
|
197
|
-
const memoized = sanitizeMap.get(
|
|
203
|
+
const memoized = sanitizeMap.get(startValue);
|
|
198
204
|
|
|
199
205
|
if (memoized) {
|
|
200
206
|
return memoized;
|
|
@@ -205,10 +211,8 @@ export function sanitize(value, options) {
|
|
|
205
211
|
result = mappings[i](result, options);
|
|
206
212
|
}
|
|
207
213
|
|
|
208
|
-
result = result.trim();
|
|
209
|
-
|
|
210
214
|
if (!options) {
|
|
211
|
-
sanitizeMap.set(
|
|
215
|
+
sanitizeMap.set(startValue, result);
|
|
212
216
|
}
|
|
213
217
|
|
|
214
218
|
return result;
|