@w3ux/utils 1.1.1-beta.0 → 1.1.1-beta.10
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/base.cjs +3 -9
- package/base.d.cts +6 -9
- package/base.d.ts +6 -9
- package/base.js +2 -8
- package/convert.cjs +39 -0
- package/convert.d.cts +9 -0
- package/convert.d.ts +9 -0
- package/convert.js +15 -0
- package/index.cjs +15 -176
- package/index.d.cts +3 -2
- package/index.d.ts +3 -2
- package/index.js +13 -164
- package/package.json +1 -1
- package/unit.cjs +0 -196
- package/unit.d.cts +1 -6
- package/unit.d.ts +1 -6
- package/unit.js +0 -185
package/base.cjs
CHANGED
|
@@ -32,8 +32,8 @@ __export(base_exports, {
|
|
|
32
32
|
pageFromUri: () => pageFromUri,
|
|
33
33
|
removeHexPrefix: () => removeHexPrefix,
|
|
34
34
|
rmCommas: () => rmCommas,
|
|
35
|
+
rmDecimals: () => rmDecimals,
|
|
35
36
|
shuffle: () => shuffle,
|
|
36
|
-
stringToU8a: () => stringToU8a,
|
|
37
37
|
withTimeout: () => withTimeout
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(base_exports);
|
|
@@ -111,6 +111,7 @@ var pageFromUri = (pathname, fallback) => {
|
|
|
111
111
|
return page.trim();
|
|
112
112
|
};
|
|
113
113
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
114
|
+
var rmDecimals = (str) => str.split(".")[0];
|
|
114
115
|
var shuffle = (array) => {
|
|
115
116
|
let currentIndex = array.length;
|
|
116
117
|
let randomIndex;
|
|
@@ -157,13 +158,6 @@ var isSuperset = (set, subset) => {
|
|
|
157
158
|
};
|
|
158
159
|
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
159
160
|
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
160
|
-
var stringToU8a = (input) => {
|
|
161
|
-
const u8a = new Uint8Array(input.length);
|
|
162
|
-
for (let i = 0; i < input.length; i++) {
|
|
163
|
-
u8a[i] = input.charCodeAt(i);
|
|
164
|
-
}
|
|
165
|
-
return u8a;
|
|
166
|
-
};
|
|
167
161
|
// Annotate the CommonJS export names for ESM import in node:
|
|
168
162
|
0 && (module.exports = {
|
|
169
163
|
appendOr,
|
|
@@ -179,8 +173,8 @@ var stringToU8a = (input) => {
|
|
|
179
173
|
pageFromUri,
|
|
180
174
|
removeHexPrefix,
|
|
181
175
|
rmCommas,
|
|
176
|
+
rmDecimals,
|
|
182
177
|
shuffle,
|
|
183
|
-
stringToU8a,
|
|
184
178
|
withTimeout
|
|
185
179
|
});
|
|
186
180
|
/* @license Copyright 2024 w3ux authors & contributors
|
package/base.d.cts
CHANGED
|
@@ -43,6 +43,11 @@ declare const pageFromUri: (pathname: string, fallback: string) => string;
|
|
|
43
43
|
* @summary Removes the commas from a string.
|
|
44
44
|
*/
|
|
45
45
|
declare const rmCommas: (val: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* @name rmCommas
|
|
48
|
+
* @summary Removes the decimal point and decimals from a string.
|
|
49
|
+
*/
|
|
50
|
+
declare const rmDecimals: (str: any) => any;
|
|
46
51
|
/**
|
|
47
52
|
* @name shuffle
|
|
48
53
|
* @summary Shuffle a set of objects.
|
|
@@ -100,13 +105,5 @@ declare const maxBigInt: (...values: bigint[]) => bigint;
|
|
|
100
105
|
* minBigInt(10n, 50n, 30n, 100n, 20n); // 10n
|
|
101
106
|
*/
|
|
102
107
|
declare const minBigInt: (...values: bigint[]) => bigint;
|
|
103
|
-
/**
|
|
104
|
-
* Converts a string to a Uint8Array.
|
|
105
|
-
*
|
|
106
|
-
* @function stringToU8a
|
|
107
|
-
* @param {string} input - The string to convert.
|
|
108
|
-
* @returns {Uint8Array} The resulting Uint8Array.
|
|
109
|
-
*/
|
|
110
|
-
declare const stringToU8a: (input: string) => Uint8Array;
|
|
111
108
|
|
|
112
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas,
|
|
109
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout };
|
package/base.d.ts
CHANGED
|
@@ -43,6 +43,11 @@ declare const pageFromUri: (pathname: string, fallback: string) => string;
|
|
|
43
43
|
* @summary Removes the commas from a string.
|
|
44
44
|
*/
|
|
45
45
|
declare const rmCommas: (val: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* @name rmCommas
|
|
48
|
+
* @summary Removes the decimal point and decimals from a string.
|
|
49
|
+
*/
|
|
50
|
+
declare const rmDecimals: (str: any) => any;
|
|
46
51
|
/**
|
|
47
52
|
* @name shuffle
|
|
48
53
|
* @summary Shuffle a set of objects.
|
|
@@ -100,13 +105,5 @@ declare const maxBigInt: (...values: bigint[]) => bigint;
|
|
|
100
105
|
* minBigInt(10n, 50n, 30n, 100n, 20n); // 10n
|
|
101
106
|
*/
|
|
102
107
|
declare const minBigInt: (...values: bigint[]) => bigint;
|
|
103
|
-
/**
|
|
104
|
-
* Converts a string to a Uint8Array.
|
|
105
|
-
*
|
|
106
|
-
* @function stringToU8a
|
|
107
|
-
* @param {string} input - The string to convert.
|
|
108
|
-
* @returns {Uint8Array} The resulting Uint8Array.
|
|
109
|
-
*/
|
|
110
|
-
declare const stringToU8a: (input: string) => Uint8Array;
|
|
111
108
|
|
|
112
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas,
|
|
109
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout };
|
package/base.js
CHANGED
|
@@ -73,6 +73,7 @@ var pageFromUri = (pathname, fallback) => {
|
|
|
73
73
|
return page.trim();
|
|
74
74
|
};
|
|
75
75
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
76
|
+
var rmDecimals = (str) => str.split(".")[0];
|
|
76
77
|
var shuffle = (array) => {
|
|
77
78
|
let currentIndex = array.length;
|
|
78
79
|
let randomIndex;
|
|
@@ -119,13 +120,6 @@ var isSuperset = (set, subset) => {
|
|
|
119
120
|
};
|
|
120
121
|
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
121
122
|
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
122
|
-
var stringToU8a = (input) => {
|
|
123
|
-
const u8a = new Uint8Array(input.length);
|
|
124
|
-
for (let i = 0; i < input.length; i++) {
|
|
125
|
-
u8a[i] = input.charCodeAt(i);
|
|
126
|
-
}
|
|
127
|
-
return u8a;
|
|
128
|
-
};
|
|
129
123
|
export {
|
|
130
124
|
appendOr,
|
|
131
125
|
appendOrEmpty,
|
|
@@ -140,8 +134,8 @@ export {
|
|
|
140
134
|
pageFromUri,
|
|
141
135
|
removeHexPrefix,
|
|
142
136
|
rmCommas,
|
|
137
|
+
rmDecimals,
|
|
143
138
|
shuffle,
|
|
144
|
-
stringToU8a,
|
|
145
139
|
withTimeout
|
|
146
140
|
};
|
|
147
141
|
/* @license Copyright 2024 w3ux authors & contributors
|
package/convert.cjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/convert.ts
|
|
20
|
+
var convert_exports = {};
|
|
21
|
+
__export(convert_exports, {
|
|
22
|
+
u8aConcat: () => u8aConcat
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(convert_exports);
|
|
25
|
+
var u8aConcat = (...u8as) => {
|
|
26
|
+
const totalLength = u8as.reduce((sum, u8a) => sum + u8a.length, 0);
|
|
27
|
+
const result = new Uint8Array(totalLength);
|
|
28
|
+
let offset = 0;
|
|
29
|
+
for (const u8a of u8as) {
|
|
30
|
+
result.set(u8a, offset);
|
|
31
|
+
offset += u8a.length;
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
u8aConcat
|
|
38
|
+
});
|
|
39
|
+
// /* @license Copyright 2024 w3ux authors & contributors
|
package/convert.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concatenates multiple Uint8Array instances into a single Uint8Array.
|
|
3
|
+
*
|
|
4
|
+
* @param {Uint8Array[]} u8as - An array of Uint8Array instances to concatenate.
|
|
5
|
+
* @returns {Uint8Array} A new Uint8Array containing all the input arrays concatenated.
|
|
6
|
+
*/
|
|
7
|
+
declare const u8aConcat: (...u8as: Uint8Array[]) => Uint8Array;
|
|
8
|
+
|
|
9
|
+
export { u8aConcat };
|
package/convert.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concatenates multiple Uint8Array instances into a single Uint8Array.
|
|
3
|
+
*
|
|
4
|
+
* @param {Uint8Array[]} u8as - An array of Uint8Array instances to concatenate.
|
|
5
|
+
* @returns {Uint8Array} A new Uint8Array containing all the input arrays concatenated.
|
|
6
|
+
*/
|
|
7
|
+
declare const u8aConcat: (...u8as: Uint8Array[]) => Uint8Array;
|
|
8
|
+
|
|
9
|
+
export { u8aConcat };
|
package/convert.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/convert.ts
|
|
2
|
+
var u8aConcat = (...u8as) => {
|
|
3
|
+
const totalLength = u8as.reduce((sum, u8a) => sum + u8a.length, 0);
|
|
4
|
+
const result = new Uint8Array(totalLength);
|
|
5
|
+
let offset = 0;
|
|
6
|
+
for (const u8a of u8as) {
|
|
7
|
+
result.set(u8a, offset);
|
|
8
|
+
offset += u8a.length;
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
u8aConcat
|
|
14
|
+
};
|
|
15
|
+
// /* @license Copyright 2024 w3ux authors & contributors
|
package/index.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// src/index.ts
|
|
@@ -35,7 +25,6 @@ __export(src_exports, {
|
|
|
35
25
|
applyWidthAsPadding: () => applyWidthAsPadding,
|
|
36
26
|
camelize: () => camelize,
|
|
37
27
|
capitalizeFirstLetter: () => capitalizeFirstLetter,
|
|
38
|
-
determinePoolDisplay: () => determinePoolDisplay,
|
|
39
28
|
ellipsisFn: () => ellipsisFn,
|
|
40
29
|
eqSet: () => eqSet,
|
|
41
30
|
extractUrlValue: () => extractUrlValue,
|
|
@@ -58,11 +47,12 @@ __export(src_exports, {
|
|
|
58
47
|
removeVarFromUrlHash: () => removeVarFromUrlHash,
|
|
59
48
|
removedFrom: () => removedFrom,
|
|
60
49
|
rmCommas: () => rmCommas,
|
|
50
|
+
rmDecimals: () => rmDecimals,
|
|
61
51
|
setStateWithRef: () => setStateWithRef,
|
|
62
52
|
shuffle: () => shuffle,
|
|
63
53
|
snakeToCamel: () => snakeToCamel,
|
|
64
54
|
sortWithNull: () => sortWithNull,
|
|
65
|
-
|
|
55
|
+
u8aConcat: () => u8aConcat,
|
|
66
56
|
unescape: () => unescape,
|
|
67
57
|
unimplemented: () => unimplemented,
|
|
68
58
|
unitToPlanck: () => unitToPlanck,
|
|
@@ -146,6 +136,7 @@ var pageFromUri = (pathname, fallback) => {
|
|
|
146
136
|
return page.trim();
|
|
147
137
|
};
|
|
148
138
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
139
|
+
var rmDecimals = (str) => str.split(".")[0];
|
|
149
140
|
var shuffle = (array) => {
|
|
150
141
|
let currentIndex = array.length;
|
|
151
142
|
let randomIndex;
|
|
@@ -192,159 +183,18 @@ var isSuperset = (set, subset) => {
|
|
|
192
183
|
};
|
|
193
184
|
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
194
185
|
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
195
|
-
var stringToU8a = (input) => {
|
|
196
|
-
const u8a = new Uint8Array(input.length);
|
|
197
|
-
for (let i = 0; i < input.length; i++) {
|
|
198
|
-
u8a[i] = input.charCodeAt(i);
|
|
199
|
-
}
|
|
200
|
-
return u8a;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
204
|
-
var import_node_util = __toESM(require("util"), 1);
|
|
205
|
-
|
|
206
|
-
// ../../node_modules/@polkadot/x-global/index.js
|
|
207
|
-
function evaluateThis(fn) {
|
|
208
|
-
return fn("return this");
|
|
209
|
-
}
|
|
210
|
-
var xglobal = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : evaluateThis(Function);
|
|
211
|
-
function extractGlobal(name, fallback) {
|
|
212
|
-
return typeof xglobal[name] === "undefined" ? fallback : xglobal[name];
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
216
|
-
var TextDecoder = /* @__PURE__ */ extractGlobal("TextDecoder", import_node_util.default.TextDecoder);
|
|
217
186
|
|
|
218
|
-
//
|
|
219
|
-
var
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
encode(value) {
|
|
227
|
-
return Uint8Array.from(this.__internal__encoder.encode(value));
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
var TextEncoder = /* @__PURE__ */ extractGlobal("TextEncoder", Fallback);
|
|
231
|
-
|
|
232
|
-
// ../../node_modules/@polkadot/util/is/function.js
|
|
233
|
-
function isFunction(value) {
|
|
234
|
-
return typeof value === "function";
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// ../../node_modules/@polkadot/x-bigint/index.js
|
|
238
|
-
function invalidFallback() {
|
|
239
|
-
return Number.NaN;
|
|
240
|
-
}
|
|
241
|
-
var BigInt2 = /* @__PURE__ */ extractGlobal("BigInt", invalidFallback);
|
|
242
|
-
|
|
243
|
-
// ../../node_modules/@polkadot/util/hex/toU8a.js
|
|
244
|
-
var CHR = "0123456789abcdef";
|
|
245
|
-
var U8 = new Uint8Array(256);
|
|
246
|
-
var U16 = new Uint8Array(256 * 256);
|
|
247
|
-
for (let i = 0, count = CHR.length; i < count; i++) {
|
|
248
|
-
U8[CHR[i].charCodeAt(0) | 0] = i | 0;
|
|
249
|
-
if (i > 9) {
|
|
250
|
-
U8[CHR[i].toUpperCase().charCodeAt(0) | 0] = i | 0;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
for (let i = 0; i < 256; i++) {
|
|
254
|
-
const s = i << 8;
|
|
255
|
-
for (let j = 0; j < 256; j++) {
|
|
256
|
-
U16[s | j] = U8[i] << 4 | U8[j];
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
function hexToU8a(value, bitLength = -1) {
|
|
260
|
-
if (!value) {
|
|
261
|
-
return new Uint8Array();
|
|
262
|
-
}
|
|
263
|
-
let s = value.startsWith("0x") ? 2 : 0;
|
|
264
|
-
const decLength = Math.ceil((value.length - s) / 2);
|
|
265
|
-
const endLength = Math.ceil(bitLength === -1 ? decLength : bitLength / 8);
|
|
266
|
-
const result = new Uint8Array(endLength);
|
|
267
|
-
const offset = endLength > decLength ? endLength - decLength : 0;
|
|
268
|
-
for (let i = offset; i < endLength; i++, s += 2) {
|
|
269
|
-
result[i] = U16[value.charCodeAt(s) << 8 | value.charCodeAt(s + 1)];
|
|
187
|
+
// src/convert.ts
|
|
188
|
+
var u8aConcat = (...u8as) => {
|
|
189
|
+
const totalLength = u8as.reduce((sum, u8a) => sum + u8a.length, 0);
|
|
190
|
+
const result = new Uint8Array(totalLength);
|
|
191
|
+
let offset = 0;
|
|
192
|
+
for (const u8a of u8as) {
|
|
193
|
+
result.set(u8a, offset);
|
|
194
|
+
offset += u8a.length;
|
|
270
195
|
}
|
|
271
196
|
return result;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// ../../node_modules/@polkadot/util/is/hex.js
|
|
275
|
-
var REGEX_HEX_PREFIXED = /^0x[\da-fA-F]+$/;
|
|
276
|
-
function isHex(value, bitLength = -1, ignoreLength) {
|
|
277
|
-
return typeof value === "string" && (value === "0x" || REGEX_HEX_PREFIXED.test(value)) && (bitLength === -1 ? ignoreLength || value.length % 2 === 0 : value.length === 2 + Math.ceil(bitLength / 4));
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// ../../node_modules/@polkadot/util/has.js
|
|
281
|
-
var hasBigInt = typeof BigInt2 === "function" && typeof BigInt2.asIntN === "function";
|
|
282
|
-
var hasBuffer = typeof xglobal.Buffer === "function" && typeof xglobal.Buffer.isBuffer === "function";
|
|
283
|
-
var hasProcess = typeof xglobal.process === "object";
|
|
284
|
-
|
|
285
|
-
// ../../node_modules/@polkadot/util/is/buffer.js
|
|
286
|
-
function isBuffer(value) {
|
|
287
|
-
return hasBuffer && !!value && isFunction(value.readDoubleLE) && xglobal.Buffer.isBuffer(value);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// ../../node_modules/@polkadot/util/is/u8a.js
|
|
291
|
-
function isU8a(value) {
|
|
292
|
-
return (value && value.constructor) === Uint8Array || value instanceof Uint8Array;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// ../../node_modules/@polkadot/util/string/toU8a.js
|
|
296
|
-
var encoder = new TextEncoder();
|
|
297
|
-
function stringToU8a2(value) {
|
|
298
|
-
return value ? encoder.encode(value.toString()) : new Uint8Array();
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// ../../node_modules/@polkadot/util/u8a/toU8a.js
|
|
302
|
-
function u8aToU8a(value) {
|
|
303
|
-
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) : stringToU8a2(value);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// ../../node_modules/@polkadot/util/u8a/eq.js
|
|
307
|
-
function u8aEq(a, b) {
|
|
308
|
-
const u8aa = u8aToU8a(a);
|
|
309
|
-
const u8ab = u8aToU8a(b);
|
|
310
|
-
if (u8aa.length === u8ab.length) {
|
|
311
|
-
const dvA = new DataView(u8aa.buffer, u8aa.byteOffset);
|
|
312
|
-
const dvB = new DataView(u8ab.buffer, u8ab.byteOffset);
|
|
313
|
-
const mod = u8aa.length % 4 | 0;
|
|
314
|
-
const length = u8aa.length - mod | 0;
|
|
315
|
-
for (let i = 0; i < length; i += 4) {
|
|
316
|
-
if (dvA.getUint32(i) !== dvB.getUint32(i)) {
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
for (let i = length, count = u8aa.length; i < count; i++) {
|
|
321
|
-
if (u8aa[i] !== u8ab[i]) {
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return true;
|
|
326
|
-
}
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// ../../node_modules/@polkadot/util/u8a/toString.js
|
|
331
|
-
var decoder = new TextDecoder("utf-8");
|
|
332
|
-
function u8aToString(value) {
|
|
333
|
-
return value ? decoder.decode(value) : "";
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// ../../node_modules/@polkadot/util/u8a/wrap.js
|
|
337
|
-
var U8A_WRAP_ETHEREUM = /* @__PURE__ */ u8aToU8a("Ethereum Signed Message:\n");
|
|
338
|
-
var U8A_WRAP_PREFIX = /* @__PURE__ */ u8aToU8a("<Bytes>");
|
|
339
|
-
var U8A_WRAP_POSTFIX = /* @__PURE__ */ u8aToU8a("</Bytes>");
|
|
340
|
-
var WRAP_LEN = U8A_WRAP_PREFIX.length + U8A_WRAP_POSTFIX.length;
|
|
341
|
-
function u8aIsWrapped(u8a, withEthereum) {
|
|
342
|
-
return u8a.length >= WRAP_LEN && u8aEq(u8a.subarray(0, U8A_WRAP_PREFIX.length), U8A_WRAP_PREFIX) && u8aEq(u8a.slice(-U8A_WRAP_POSTFIX.length), U8A_WRAP_POSTFIX) || withEthereum && u8a.length >= U8A_WRAP_ETHEREUM.length && u8aEq(u8a.subarray(0, U8A_WRAP_ETHEREUM.length), U8A_WRAP_ETHEREUM);
|
|
343
|
-
}
|
|
344
|
-
function u8aUnwrapBytes(bytes) {
|
|
345
|
-
const u8a = u8aToU8a(bytes);
|
|
346
|
-
return u8aIsWrapped(u8a, false) ? u8a.subarray(U8A_WRAP_PREFIX.length, u8a.length - U8A_WRAP_POSTFIX.length) : u8a;
|
|
347
|
-
}
|
|
197
|
+
};
|
|
348
198
|
|
|
349
199
|
// src/unit.ts
|
|
350
200
|
var import_substrate_bindings2 = require("@polkadot-api/substrate-bindings");
|
|
@@ -412,18 +262,6 @@ var isValidAddress = (address) => {
|
|
|
412
262
|
return false;
|
|
413
263
|
}
|
|
414
264
|
};
|
|
415
|
-
var determinePoolDisplay = (address, batchItem) => {
|
|
416
|
-
const defaultDisplay = ellipsisFn(address, 6);
|
|
417
|
-
let display = batchItem ?? defaultDisplay;
|
|
418
|
-
const displayAsBytes = u8aToString(u8aUnwrapBytes(display));
|
|
419
|
-
if (displayAsBytes !== "") {
|
|
420
|
-
display = displayAsBytes;
|
|
421
|
-
}
|
|
422
|
-
if (display === "") {
|
|
423
|
-
display = defaultDisplay;
|
|
424
|
-
}
|
|
425
|
-
return display;
|
|
426
|
-
};
|
|
427
265
|
var extractUrlValue = (key, url) => {
|
|
428
266
|
if (typeof url === "undefined") {
|
|
429
267
|
url = window.location.href;
|
|
@@ -564,7 +402,6 @@ var mergeDeep = (target, ...sources) => {
|
|
|
564
402
|
applyWidthAsPadding,
|
|
565
403
|
camelize,
|
|
566
404
|
capitalizeFirstLetter,
|
|
567
|
-
determinePoolDisplay,
|
|
568
405
|
ellipsisFn,
|
|
569
406
|
eqSet,
|
|
570
407
|
extractUrlValue,
|
|
@@ -587,11 +424,12 @@ var mergeDeep = (target, ...sources) => {
|
|
|
587
424
|
removeVarFromUrlHash,
|
|
588
425
|
removedFrom,
|
|
589
426
|
rmCommas,
|
|
427
|
+
rmDecimals,
|
|
590
428
|
setStateWithRef,
|
|
591
429
|
shuffle,
|
|
592
430
|
snakeToCamel,
|
|
593
431
|
sortWithNull,
|
|
594
|
-
|
|
432
|
+
u8aConcat,
|
|
595
433
|
unescape,
|
|
596
434
|
unimplemented,
|
|
597
435
|
unitToPlanck,
|
|
@@ -600,3 +438,4 @@ var mergeDeep = (target, ...sources) => {
|
|
|
600
438
|
});
|
|
601
439
|
/* @license Copyright 2024 w3ux authors & contributors
|
|
602
440
|
SPDX-License-Identifier: GPL-3.0-only */
|
|
441
|
+
// /* @license Copyright 2024 w3ux authors & contributors
|
package/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas,
|
|
2
|
-
export {
|
|
1
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout } from './base.cjs';
|
|
2
|
+
export { u8aConcat } from './convert.cjs';
|
|
3
|
+
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.cjs';
|
|
3
4
|
import '@w3ux/types';
|
|
4
5
|
import 'react';
|
|
5
6
|
import './types.cjs';
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas,
|
|
2
|
-
export {
|
|
1
|
+
export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, maxBigInt, minBigInt, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, rmDecimals, shuffle, withTimeout } from './base.js';
|
|
2
|
+
export { u8aConcat } from './convert.js';
|
|
3
|
+
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.js';
|
|
3
4
|
import '@w3ux/types';
|
|
4
5
|
import 'react';
|
|
5
6
|
import './types.js';
|
package/index.js
CHANGED
|
@@ -73,6 +73,7 @@ var pageFromUri = (pathname, fallback) => {
|
|
|
73
73
|
return page.trim();
|
|
74
74
|
};
|
|
75
75
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
76
|
+
var rmDecimals = (str) => str.split(".")[0];
|
|
76
77
|
var shuffle = (array) => {
|
|
77
78
|
let currentIndex = array.length;
|
|
78
79
|
let randomIndex;
|
|
@@ -119,159 +120,18 @@ var isSuperset = (set, subset) => {
|
|
|
119
120
|
};
|
|
120
121
|
var maxBigInt = (...values) => values.reduce((max, current) => current > max ? current : max);
|
|
121
122
|
var minBigInt = (...values) => values.reduce((min, current) => current < min ? current : min);
|
|
122
|
-
var stringToU8a = (input) => {
|
|
123
|
-
const u8a = new Uint8Array(input.length);
|
|
124
|
-
for (let i = 0; i < input.length; i++) {
|
|
125
|
-
u8a[i] = input.charCodeAt(i);
|
|
126
|
-
}
|
|
127
|
-
return u8a;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
131
|
-
import util from "node:util";
|
|
132
|
-
|
|
133
|
-
// ../../node_modules/@polkadot/x-global/index.js
|
|
134
|
-
function evaluateThis(fn) {
|
|
135
|
-
return fn("return this");
|
|
136
|
-
}
|
|
137
|
-
var xglobal = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : evaluateThis(Function);
|
|
138
|
-
function extractGlobal(name, fallback) {
|
|
139
|
-
return typeof xglobal[name] === "undefined" ? fallback : xglobal[name];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
143
|
-
var TextDecoder = /* @__PURE__ */ extractGlobal("TextDecoder", util.TextDecoder);
|
|
144
123
|
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
encode(value) {
|
|
154
|
-
return Uint8Array.from(this.__internal__encoder.encode(value));
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
var TextEncoder = /* @__PURE__ */ extractGlobal("TextEncoder", Fallback);
|
|
158
|
-
|
|
159
|
-
// ../../node_modules/@polkadot/util/is/function.js
|
|
160
|
-
function isFunction(value) {
|
|
161
|
-
return typeof value === "function";
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// ../../node_modules/@polkadot/x-bigint/index.js
|
|
165
|
-
function invalidFallback() {
|
|
166
|
-
return Number.NaN;
|
|
167
|
-
}
|
|
168
|
-
var BigInt2 = /* @__PURE__ */ extractGlobal("BigInt", invalidFallback);
|
|
169
|
-
|
|
170
|
-
// ../../node_modules/@polkadot/util/hex/toU8a.js
|
|
171
|
-
var CHR = "0123456789abcdef";
|
|
172
|
-
var U8 = new Uint8Array(256);
|
|
173
|
-
var U16 = new Uint8Array(256 * 256);
|
|
174
|
-
for (let i = 0, count = CHR.length; i < count; i++) {
|
|
175
|
-
U8[CHR[i].charCodeAt(0) | 0] = i | 0;
|
|
176
|
-
if (i > 9) {
|
|
177
|
-
U8[CHR[i].toUpperCase().charCodeAt(0) | 0] = i | 0;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
for (let i = 0; i < 256; i++) {
|
|
181
|
-
const s = i << 8;
|
|
182
|
-
for (let j = 0; j < 256; j++) {
|
|
183
|
-
U16[s | j] = U8[i] << 4 | U8[j];
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function hexToU8a(value, bitLength = -1) {
|
|
187
|
-
if (!value) {
|
|
188
|
-
return new Uint8Array();
|
|
189
|
-
}
|
|
190
|
-
let s = value.startsWith("0x") ? 2 : 0;
|
|
191
|
-
const decLength = Math.ceil((value.length - s) / 2);
|
|
192
|
-
const endLength = Math.ceil(bitLength === -1 ? decLength : bitLength / 8);
|
|
193
|
-
const result = new Uint8Array(endLength);
|
|
194
|
-
const offset = endLength > decLength ? endLength - decLength : 0;
|
|
195
|
-
for (let i = offset; i < endLength; i++, s += 2) {
|
|
196
|
-
result[i] = U16[value.charCodeAt(s) << 8 | value.charCodeAt(s + 1)];
|
|
124
|
+
// src/convert.ts
|
|
125
|
+
var u8aConcat = (...u8as) => {
|
|
126
|
+
const totalLength = u8as.reduce((sum, u8a) => sum + u8a.length, 0);
|
|
127
|
+
const result = new Uint8Array(totalLength);
|
|
128
|
+
let offset = 0;
|
|
129
|
+
for (const u8a of u8as) {
|
|
130
|
+
result.set(u8a, offset);
|
|
131
|
+
offset += u8a.length;
|
|
197
132
|
}
|
|
198
133
|
return result;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// ../../node_modules/@polkadot/util/is/hex.js
|
|
202
|
-
var REGEX_HEX_PREFIXED = /^0x[\da-fA-F]+$/;
|
|
203
|
-
function isHex(value, bitLength = -1, ignoreLength) {
|
|
204
|
-
return typeof value === "string" && (value === "0x" || REGEX_HEX_PREFIXED.test(value)) && (bitLength === -1 ? ignoreLength || value.length % 2 === 0 : value.length === 2 + Math.ceil(bitLength / 4));
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// ../../node_modules/@polkadot/util/has.js
|
|
208
|
-
var hasBigInt = typeof BigInt2 === "function" && typeof BigInt2.asIntN === "function";
|
|
209
|
-
var hasBuffer = typeof xglobal.Buffer === "function" && typeof xglobal.Buffer.isBuffer === "function";
|
|
210
|
-
var hasProcess = typeof xglobal.process === "object";
|
|
211
|
-
|
|
212
|
-
// ../../node_modules/@polkadot/util/is/buffer.js
|
|
213
|
-
function isBuffer(value) {
|
|
214
|
-
return hasBuffer && !!value && isFunction(value.readDoubleLE) && xglobal.Buffer.isBuffer(value);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// ../../node_modules/@polkadot/util/is/u8a.js
|
|
218
|
-
function isU8a(value) {
|
|
219
|
-
return (value && value.constructor) === Uint8Array || value instanceof Uint8Array;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// ../../node_modules/@polkadot/util/string/toU8a.js
|
|
223
|
-
var encoder = new TextEncoder();
|
|
224
|
-
function stringToU8a2(value) {
|
|
225
|
-
return value ? encoder.encode(value.toString()) : new Uint8Array();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// ../../node_modules/@polkadot/util/u8a/toU8a.js
|
|
229
|
-
function u8aToU8a(value) {
|
|
230
|
-
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) : stringToU8a2(value);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// ../../node_modules/@polkadot/util/u8a/eq.js
|
|
234
|
-
function u8aEq(a, b) {
|
|
235
|
-
const u8aa = u8aToU8a(a);
|
|
236
|
-
const u8ab = u8aToU8a(b);
|
|
237
|
-
if (u8aa.length === u8ab.length) {
|
|
238
|
-
const dvA = new DataView(u8aa.buffer, u8aa.byteOffset);
|
|
239
|
-
const dvB = new DataView(u8ab.buffer, u8ab.byteOffset);
|
|
240
|
-
const mod = u8aa.length % 4 | 0;
|
|
241
|
-
const length = u8aa.length - mod | 0;
|
|
242
|
-
for (let i = 0; i < length; i += 4) {
|
|
243
|
-
if (dvA.getUint32(i) !== dvB.getUint32(i)) {
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
for (let i = length, count = u8aa.length; i < count; i++) {
|
|
248
|
-
if (u8aa[i] !== u8ab[i]) {
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return true;
|
|
253
|
-
}
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// ../../node_modules/@polkadot/util/u8a/toString.js
|
|
258
|
-
var decoder = new TextDecoder("utf-8");
|
|
259
|
-
function u8aToString(value) {
|
|
260
|
-
return value ? decoder.decode(value) : "";
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// ../../node_modules/@polkadot/util/u8a/wrap.js
|
|
264
|
-
var U8A_WRAP_ETHEREUM = /* @__PURE__ */ u8aToU8a("Ethereum Signed Message:\n");
|
|
265
|
-
var U8A_WRAP_PREFIX = /* @__PURE__ */ u8aToU8a("<Bytes>");
|
|
266
|
-
var U8A_WRAP_POSTFIX = /* @__PURE__ */ u8aToU8a("</Bytes>");
|
|
267
|
-
var WRAP_LEN = U8A_WRAP_PREFIX.length + U8A_WRAP_POSTFIX.length;
|
|
268
|
-
function u8aIsWrapped(u8a, withEthereum) {
|
|
269
|
-
return u8a.length >= WRAP_LEN && u8aEq(u8a.subarray(0, U8A_WRAP_PREFIX.length), U8A_WRAP_PREFIX) && u8aEq(u8a.slice(-U8A_WRAP_POSTFIX.length), U8A_WRAP_POSTFIX) || withEthereum && u8a.length >= U8A_WRAP_ETHEREUM.length && u8aEq(u8a.subarray(0, U8A_WRAP_ETHEREUM.length), U8A_WRAP_ETHEREUM);
|
|
270
|
-
}
|
|
271
|
-
function u8aUnwrapBytes(bytes) {
|
|
272
|
-
const u8a = u8aToU8a(bytes);
|
|
273
|
-
return u8aIsWrapped(u8a, false) ? u8a.subarray(U8A_WRAP_PREFIX.length, u8a.length - U8A_WRAP_POSTFIX.length) : u8a;
|
|
274
|
-
}
|
|
134
|
+
};
|
|
275
135
|
|
|
276
136
|
// src/unit.ts
|
|
277
137
|
import { AccountId as AccountId2 } from "@polkadot-api/substrate-bindings";
|
|
@@ -339,18 +199,6 @@ var isValidAddress = (address) => {
|
|
|
339
199
|
return false;
|
|
340
200
|
}
|
|
341
201
|
};
|
|
342
|
-
var determinePoolDisplay = (address, batchItem) => {
|
|
343
|
-
const defaultDisplay = ellipsisFn(address, 6);
|
|
344
|
-
let display = batchItem ?? defaultDisplay;
|
|
345
|
-
const displayAsBytes = u8aToString(u8aUnwrapBytes(display));
|
|
346
|
-
if (displayAsBytes !== "") {
|
|
347
|
-
display = displayAsBytes;
|
|
348
|
-
}
|
|
349
|
-
if (display === "") {
|
|
350
|
-
display = defaultDisplay;
|
|
351
|
-
}
|
|
352
|
-
return display;
|
|
353
|
-
};
|
|
354
202
|
var extractUrlValue = (key, url) => {
|
|
355
203
|
if (typeof url === "undefined") {
|
|
356
204
|
url = window.location.href;
|
|
@@ -490,7 +338,6 @@ export {
|
|
|
490
338
|
applyWidthAsPadding,
|
|
491
339
|
camelize,
|
|
492
340
|
capitalizeFirstLetter,
|
|
493
|
-
determinePoolDisplay,
|
|
494
341
|
ellipsisFn,
|
|
495
342
|
eqSet,
|
|
496
343
|
extractUrlValue,
|
|
@@ -513,11 +360,12 @@ export {
|
|
|
513
360
|
removeVarFromUrlHash,
|
|
514
361
|
removedFrom,
|
|
515
362
|
rmCommas,
|
|
363
|
+
rmDecimals,
|
|
516
364
|
setStateWithRef,
|
|
517
365
|
shuffle,
|
|
518
366
|
snakeToCamel,
|
|
519
367
|
sortWithNull,
|
|
520
|
-
|
|
368
|
+
u8aConcat,
|
|
521
369
|
unescape,
|
|
522
370
|
unimplemented,
|
|
523
371
|
unitToPlanck,
|
|
@@ -526,3 +374,4 @@ export {
|
|
|
526
374
|
};
|
|
527
375
|
/* @license Copyright 2024 w3ux authors & contributors
|
|
528
376
|
SPDX-License-Identifier: GPL-3.0-only */
|
|
377
|
+
// /* @license Copyright 2024 w3ux authors & contributors
|
package/package.json
CHANGED
package/unit.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// src/unit.ts
|
|
@@ -32,7 +22,6 @@ __export(unit_exports, {
|
|
|
32
22
|
addedTo: () => addedTo,
|
|
33
23
|
applyWidthAsPadding: () => applyWidthAsPadding,
|
|
34
24
|
capitalizeFirstLetter: () => capitalizeFirstLetter,
|
|
35
|
-
determinePoolDisplay: () => determinePoolDisplay,
|
|
36
25
|
extractUrlValue: () => extractUrlValue,
|
|
37
26
|
inChrome: () => inChrome,
|
|
38
27
|
isValidAddress: () => isValidAddress,
|
|
@@ -55,180 +44,8 @@ __export(unit_exports, {
|
|
|
55
44
|
});
|
|
56
45
|
module.exports = __toCommonJS(unit_exports);
|
|
57
46
|
|
|
58
|
-
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
59
|
-
var import_node_util = __toESM(require("util"), 1);
|
|
60
|
-
|
|
61
|
-
// ../../node_modules/@polkadot/x-global/index.js
|
|
62
|
-
function evaluateThis(fn) {
|
|
63
|
-
return fn("return this");
|
|
64
|
-
}
|
|
65
|
-
var xglobal = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : evaluateThis(Function);
|
|
66
|
-
function extractGlobal(name, fallback) {
|
|
67
|
-
return typeof xglobal[name] === "undefined" ? fallback : xglobal[name];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
71
|
-
var TextDecoder = /* @__PURE__ */ extractGlobal("TextDecoder", import_node_util.default.TextDecoder);
|
|
72
|
-
|
|
73
|
-
// ../../node_modules/@polkadot/x-textencoder/node.js
|
|
74
|
-
var import_node_util2 = __toESM(require("util"), 1);
|
|
75
|
-
var Fallback = class {
|
|
76
|
-
__internal__encoder;
|
|
77
|
-
constructor() {
|
|
78
|
-
this.__internal__encoder = new import_node_util2.default.TextEncoder();
|
|
79
|
-
}
|
|
80
|
-
// For a Jest 26.0.1 environment, Buffer !== Uint8Array
|
|
81
|
-
encode(value) {
|
|
82
|
-
return Uint8Array.from(this.__internal__encoder.encode(value));
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
var TextEncoder = /* @__PURE__ */ extractGlobal("TextEncoder", Fallback);
|
|
86
|
-
|
|
87
|
-
// ../../node_modules/@polkadot/util/is/function.js
|
|
88
|
-
function isFunction(value) {
|
|
89
|
-
return typeof value === "function";
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// ../../node_modules/@polkadot/x-bigint/index.js
|
|
93
|
-
function invalidFallback() {
|
|
94
|
-
return Number.NaN;
|
|
95
|
-
}
|
|
96
|
-
var BigInt2 = /* @__PURE__ */ extractGlobal("BigInt", invalidFallback);
|
|
97
|
-
|
|
98
|
-
// ../../node_modules/@polkadot/util/hex/toU8a.js
|
|
99
|
-
var CHR = "0123456789abcdef";
|
|
100
|
-
var U8 = new Uint8Array(256);
|
|
101
|
-
var U16 = new Uint8Array(256 * 256);
|
|
102
|
-
for (let i = 0, count = CHR.length; i < count; i++) {
|
|
103
|
-
U8[CHR[i].charCodeAt(0) | 0] = i | 0;
|
|
104
|
-
if (i > 9) {
|
|
105
|
-
U8[CHR[i].toUpperCase().charCodeAt(0) | 0] = i | 0;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
for (let i = 0; i < 256; i++) {
|
|
109
|
-
const s = i << 8;
|
|
110
|
-
for (let j = 0; j < 256; j++) {
|
|
111
|
-
U16[s | j] = U8[i] << 4 | U8[j];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function hexToU8a(value, bitLength = -1) {
|
|
115
|
-
if (!value) {
|
|
116
|
-
return new Uint8Array();
|
|
117
|
-
}
|
|
118
|
-
let s = value.startsWith("0x") ? 2 : 0;
|
|
119
|
-
const decLength = Math.ceil((value.length - s) / 2);
|
|
120
|
-
const endLength = Math.ceil(bitLength === -1 ? decLength : bitLength / 8);
|
|
121
|
-
const result = new Uint8Array(endLength);
|
|
122
|
-
const offset = endLength > decLength ? endLength - decLength : 0;
|
|
123
|
-
for (let i = offset; i < endLength; i++, s += 2) {
|
|
124
|
-
result[i] = U16[value.charCodeAt(s) << 8 | value.charCodeAt(s + 1)];
|
|
125
|
-
}
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// ../../node_modules/@polkadot/util/is/hex.js
|
|
130
|
-
var REGEX_HEX_PREFIXED = /^0x[\da-fA-F]+$/;
|
|
131
|
-
function isHex(value, bitLength = -1, ignoreLength) {
|
|
132
|
-
return typeof value === "string" && (value === "0x" || REGEX_HEX_PREFIXED.test(value)) && (bitLength === -1 ? ignoreLength || value.length % 2 === 0 : value.length === 2 + Math.ceil(bitLength / 4));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// ../../node_modules/@polkadot/util/has.js
|
|
136
|
-
var hasBigInt = typeof BigInt2 === "function" && typeof BigInt2.asIntN === "function";
|
|
137
|
-
var hasBuffer = typeof xglobal.Buffer === "function" && typeof xglobal.Buffer.isBuffer === "function";
|
|
138
|
-
var hasProcess = typeof xglobal.process === "object";
|
|
139
|
-
|
|
140
|
-
// ../../node_modules/@polkadot/util/is/buffer.js
|
|
141
|
-
function isBuffer(value) {
|
|
142
|
-
return hasBuffer && !!value && isFunction(value.readDoubleLE) && xglobal.Buffer.isBuffer(value);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// ../../node_modules/@polkadot/util/is/u8a.js
|
|
146
|
-
function isU8a(value) {
|
|
147
|
-
return (value && value.constructor) === Uint8Array || value instanceof Uint8Array;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// ../../node_modules/@polkadot/util/string/toU8a.js
|
|
151
|
-
var encoder = new TextEncoder();
|
|
152
|
-
function stringToU8a(value) {
|
|
153
|
-
return value ? encoder.encode(value.toString()) : new Uint8Array();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// ../../node_modules/@polkadot/util/u8a/toU8a.js
|
|
157
|
-
function u8aToU8a(value) {
|
|
158
|
-
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) : stringToU8a(value);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// ../../node_modules/@polkadot/util/u8a/eq.js
|
|
162
|
-
function u8aEq(a, b) {
|
|
163
|
-
const u8aa = u8aToU8a(a);
|
|
164
|
-
const u8ab = u8aToU8a(b);
|
|
165
|
-
if (u8aa.length === u8ab.length) {
|
|
166
|
-
const dvA = new DataView(u8aa.buffer, u8aa.byteOffset);
|
|
167
|
-
const dvB = new DataView(u8ab.buffer, u8ab.byteOffset);
|
|
168
|
-
const mod = u8aa.length % 4 | 0;
|
|
169
|
-
const length = u8aa.length - mod | 0;
|
|
170
|
-
for (let i = 0; i < length; i += 4) {
|
|
171
|
-
if (dvA.getUint32(i) !== dvB.getUint32(i)) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
for (let i = length, count = u8aa.length; i < count; i++) {
|
|
176
|
-
if (u8aa[i] !== u8ab[i]) {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// ../../node_modules/@polkadot/util/u8a/toString.js
|
|
186
|
-
var decoder = new TextDecoder("utf-8");
|
|
187
|
-
function u8aToString(value) {
|
|
188
|
-
return value ? decoder.decode(value) : "";
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// ../../node_modules/@polkadot/util/u8a/wrap.js
|
|
192
|
-
var U8A_WRAP_ETHEREUM = /* @__PURE__ */ u8aToU8a("Ethereum Signed Message:\n");
|
|
193
|
-
var U8A_WRAP_PREFIX = /* @__PURE__ */ u8aToU8a("<Bytes>");
|
|
194
|
-
var U8A_WRAP_POSTFIX = /* @__PURE__ */ u8aToU8a("</Bytes>");
|
|
195
|
-
var WRAP_LEN = U8A_WRAP_PREFIX.length + U8A_WRAP_POSTFIX.length;
|
|
196
|
-
function u8aIsWrapped(u8a, withEthereum) {
|
|
197
|
-
return u8a.length >= WRAP_LEN && u8aEq(u8a.subarray(0, U8A_WRAP_PREFIX.length), U8A_WRAP_PREFIX) && u8aEq(u8a.slice(-U8A_WRAP_POSTFIX.length), U8A_WRAP_POSTFIX) || withEthereum && u8a.length >= U8A_WRAP_ETHEREUM.length && u8aEq(u8a.subarray(0, U8A_WRAP_ETHEREUM.length), U8A_WRAP_ETHEREUM);
|
|
198
|
-
}
|
|
199
|
-
function u8aUnwrapBytes(bytes) {
|
|
200
|
-
const u8a = u8aToU8a(bytes);
|
|
201
|
-
return u8aIsWrapped(u8a, false) ? u8a.subarray(U8A_WRAP_PREFIX.length, u8a.length - U8A_WRAP_POSTFIX.length) : u8a;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
47
|
// src/base.ts
|
|
205
48
|
var import_substrate_bindings = require("@polkadot-api/substrate-bindings");
|
|
206
|
-
var ellipsisFn = (str, amount = 6, position = "center") => {
|
|
207
|
-
const half = str.length / 2;
|
|
208
|
-
if (amount <= 4) {
|
|
209
|
-
if (position === "center") {
|
|
210
|
-
return str.slice(0, 4) + "..." + str.slice(-4);
|
|
211
|
-
}
|
|
212
|
-
if (position === "end") {
|
|
213
|
-
return str.slice(0, 4) + "...";
|
|
214
|
-
}
|
|
215
|
-
return "..." + str.slice(-4);
|
|
216
|
-
}
|
|
217
|
-
if (position === "center") {
|
|
218
|
-
return amount >= (str.length - 2) / 2 ? str.slice(0, half - 3) + "..." + str.slice(-(half - 3)) : str.slice(0, amount) + "..." + str.slice(-amount);
|
|
219
|
-
}
|
|
220
|
-
if (amount >= str.length) {
|
|
221
|
-
if (position === "end") {
|
|
222
|
-
return str.slice(0, str.length - 3) + "...";
|
|
223
|
-
}
|
|
224
|
-
return "..." + str.slice(-(str.length - 3));
|
|
225
|
-
} else {
|
|
226
|
-
if (position === "end") {
|
|
227
|
-
return str.slice(0, amount) + "...";
|
|
228
|
-
}
|
|
229
|
-
return "..." + str.slice(amount);
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
49
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
233
50
|
|
|
234
51
|
// src/unit.ts
|
|
@@ -297,18 +114,6 @@ var isValidAddress = (address) => {
|
|
|
297
114
|
return false;
|
|
298
115
|
}
|
|
299
116
|
};
|
|
300
|
-
var determinePoolDisplay = (address, batchItem) => {
|
|
301
|
-
const defaultDisplay = ellipsisFn(address, 6);
|
|
302
|
-
let display = batchItem ?? defaultDisplay;
|
|
303
|
-
const displayAsBytes = u8aToString(u8aUnwrapBytes(display));
|
|
304
|
-
if (displayAsBytes !== "") {
|
|
305
|
-
display = displayAsBytes;
|
|
306
|
-
}
|
|
307
|
-
if (display === "") {
|
|
308
|
-
display = defaultDisplay;
|
|
309
|
-
}
|
|
310
|
-
return display;
|
|
311
|
-
};
|
|
312
117
|
var extractUrlValue = (key, url) => {
|
|
313
118
|
if (typeof url === "undefined") {
|
|
314
119
|
url = window.location.href;
|
|
@@ -446,7 +251,6 @@ var mergeDeep = (target, ...sources) => {
|
|
|
446
251
|
addedTo,
|
|
447
252
|
applyWidthAsPadding,
|
|
448
253
|
capitalizeFirstLetter,
|
|
449
|
-
determinePoolDisplay,
|
|
450
254
|
extractUrlValue,
|
|
451
255
|
inChrome,
|
|
452
256
|
isValidAddress,
|
package/unit.d.cts
CHANGED
|
@@ -57,11 +57,6 @@ declare const localStorageOrDefault: <T>(key: string, _default: T, parse?: boole
|
|
|
57
57
|
* @summary Return whether an address is valid Substrate address.
|
|
58
58
|
*/
|
|
59
59
|
declare const isValidAddress: (address: string) => boolean;
|
|
60
|
-
/**
|
|
61
|
-
* @name determinePoolDisplay
|
|
62
|
-
* @summary A pool will be displayed with either its set metadata or its address.
|
|
63
|
-
*/
|
|
64
|
-
declare const determinePoolDisplay: (address: string, batchItem: AnyJson) => any;
|
|
65
60
|
/**
|
|
66
61
|
* @name extractUrlValue
|
|
67
62
|
* @summary Extracts a URL value from a URL string.
|
|
@@ -150,4 +145,4 @@ declare const unimplemented: ({ ...props }: {
|
|
|
150
145
|
*/
|
|
151
146
|
declare const mergeDeep: (target: AnyObject, ...sources: AnyObject[]) => AnyObject;
|
|
152
147
|
|
|
153
|
-
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter,
|
|
148
|
+
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash };
|
package/unit.d.ts
CHANGED
|
@@ -57,11 +57,6 @@ declare const localStorageOrDefault: <T>(key: string, _default: T, parse?: boole
|
|
|
57
57
|
* @summary Return whether an address is valid Substrate address.
|
|
58
58
|
*/
|
|
59
59
|
declare const isValidAddress: (address: string) => boolean;
|
|
60
|
-
/**
|
|
61
|
-
* @name determinePoolDisplay
|
|
62
|
-
* @summary A pool will be displayed with either its set metadata or its address.
|
|
63
|
-
*/
|
|
64
|
-
declare const determinePoolDisplay: (address: string, batchItem: AnyJson) => any;
|
|
65
60
|
/**
|
|
66
61
|
* @name extractUrlValue
|
|
67
62
|
* @summary Extracts a URL value from a URL string.
|
|
@@ -150,4 +145,4 @@ declare const unimplemented: ({ ...props }: {
|
|
|
150
145
|
*/
|
|
151
146
|
declare const mergeDeep: (target: AnyObject, ...sources: AnyObject[]) => AnyObject;
|
|
152
147
|
|
|
153
|
-
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter,
|
|
148
|
+
export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, unescape, unimplemented, unitToPlanck, varToUrlHash };
|
package/unit.js
CHANGED
|
@@ -1,177 +1,5 @@
|
|
|
1
|
-
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
2
|
-
import util from "node:util";
|
|
3
|
-
|
|
4
|
-
// ../../node_modules/@polkadot/x-global/index.js
|
|
5
|
-
function evaluateThis(fn) {
|
|
6
|
-
return fn("return this");
|
|
7
|
-
}
|
|
8
|
-
var xglobal = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : evaluateThis(Function);
|
|
9
|
-
function extractGlobal(name, fallback) {
|
|
10
|
-
return typeof xglobal[name] === "undefined" ? fallback : xglobal[name];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// ../../node_modules/@polkadot/x-textdecoder/node.js
|
|
14
|
-
var TextDecoder = /* @__PURE__ */ extractGlobal("TextDecoder", util.TextDecoder);
|
|
15
|
-
|
|
16
|
-
// ../../node_modules/@polkadot/x-textencoder/node.js
|
|
17
|
-
import util2 from "node:util";
|
|
18
|
-
var Fallback = class {
|
|
19
|
-
__internal__encoder;
|
|
20
|
-
constructor() {
|
|
21
|
-
this.__internal__encoder = new util2.TextEncoder();
|
|
22
|
-
}
|
|
23
|
-
// For a Jest 26.0.1 environment, Buffer !== Uint8Array
|
|
24
|
-
encode(value) {
|
|
25
|
-
return Uint8Array.from(this.__internal__encoder.encode(value));
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var TextEncoder = /* @__PURE__ */ extractGlobal("TextEncoder", Fallback);
|
|
29
|
-
|
|
30
|
-
// ../../node_modules/@polkadot/util/is/function.js
|
|
31
|
-
function isFunction(value) {
|
|
32
|
-
return typeof value === "function";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// ../../node_modules/@polkadot/x-bigint/index.js
|
|
36
|
-
function invalidFallback() {
|
|
37
|
-
return Number.NaN;
|
|
38
|
-
}
|
|
39
|
-
var BigInt2 = /* @__PURE__ */ extractGlobal("BigInt", invalidFallback);
|
|
40
|
-
|
|
41
|
-
// ../../node_modules/@polkadot/util/hex/toU8a.js
|
|
42
|
-
var CHR = "0123456789abcdef";
|
|
43
|
-
var U8 = new Uint8Array(256);
|
|
44
|
-
var U16 = new Uint8Array(256 * 256);
|
|
45
|
-
for (let i = 0, count = CHR.length; i < count; i++) {
|
|
46
|
-
U8[CHR[i].charCodeAt(0) | 0] = i | 0;
|
|
47
|
-
if (i > 9) {
|
|
48
|
-
U8[CHR[i].toUpperCase().charCodeAt(0) | 0] = i | 0;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
for (let i = 0; i < 256; i++) {
|
|
52
|
-
const s = i << 8;
|
|
53
|
-
for (let j = 0; j < 256; j++) {
|
|
54
|
-
U16[s | j] = U8[i] << 4 | U8[j];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function hexToU8a(value, bitLength = -1) {
|
|
58
|
-
if (!value) {
|
|
59
|
-
return new Uint8Array();
|
|
60
|
-
}
|
|
61
|
-
let s = value.startsWith("0x") ? 2 : 0;
|
|
62
|
-
const decLength = Math.ceil((value.length - s) / 2);
|
|
63
|
-
const endLength = Math.ceil(bitLength === -1 ? decLength : bitLength / 8);
|
|
64
|
-
const result = new Uint8Array(endLength);
|
|
65
|
-
const offset = endLength > decLength ? endLength - decLength : 0;
|
|
66
|
-
for (let i = offset; i < endLength; i++, s += 2) {
|
|
67
|
-
result[i] = U16[value.charCodeAt(s) << 8 | value.charCodeAt(s + 1)];
|
|
68
|
-
}
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// ../../node_modules/@polkadot/util/is/hex.js
|
|
73
|
-
var REGEX_HEX_PREFIXED = /^0x[\da-fA-F]+$/;
|
|
74
|
-
function isHex(value, bitLength = -1, ignoreLength) {
|
|
75
|
-
return typeof value === "string" && (value === "0x" || REGEX_HEX_PREFIXED.test(value)) && (bitLength === -1 ? ignoreLength || value.length % 2 === 0 : value.length === 2 + Math.ceil(bitLength / 4));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// ../../node_modules/@polkadot/util/has.js
|
|
79
|
-
var hasBigInt = typeof BigInt2 === "function" && typeof BigInt2.asIntN === "function";
|
|
80
|
-
var hasBuffer = typeof xglobal.Buffer === "function" && typeof xglobal.Buffer.isBuffer === "function";
|
|
81
|
-
var hasProcess = typeof xglobal.process === "object";
|
|
82
|
-
|
|
83
|
-
// ../../node_modules/@polkadot/util/is/buffer.js
|
|
84
|
-
function isBuffer(value) {
|
|
85
|
-
return hasBuffer && !!value && isFunction(value.readDoubleLE) && xglobal.Buffer.isBuffer(value);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// ../../node_modules/@polkadot/util/is/u8a.js
|
|
89
|
-
function isU8a(value) {
|
|
90
|
-
return (value && value.constructor) === Uint8Array || value instanceof Uint8Array;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ../../node_modules/@polkadot/util/string/toU8a.js
|
|
94
|
-
var encoder = new TextEncoder();
|
|
95
|
-
function stringToU8a(value) {
|
|
96
|
-
return value ? encoder.encode(value.toString()) : new Uint8Array();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// ../../node_modules/@polkadot/util/u8a/toU8a.js
|
|
100
|
-
function u8aToU8a(value) {
|
|
101
|
-
return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) : stringToU8a(value);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// ../../node_modules/@polkadot/util/u8a/eq.js
|
|
105
|
-
function u8aEq(a, b) {
|
|
106
|
-
const u8aa = u8aToU8a(a);
|
|
107
|
-
const u8ab = u8aToU8a(b);
|
|
108
|
-
if (u8aa.length === u8ab.length) {
|
|
109
|
-
const dvA = new DataView(u8aa.buffer, u8aa.byteOffset);
|
|
110
|
-
const dvB = new DataView(u8ab.buffer, u8ab.byteOffset);
|
|
111
|
-
const mod = u8aa.length % 4 | 0;
|
|
112
|
-
const length = u8aa.length - mod | 0;
|
|
113
|
-
for (let i = 0; i < length; i += 4) {
|
|
114
|
-
if (dvA.getUint32(i) !== dvB.getUint32(i)) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
for (let i = length, count = u8aa.length; i < count; i++) {
|
|
119
|
-
if (u8aa[i] !== u8ab[i]) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// ../../node_modules/@polkadot/util/u8a/toString.js
|
|
129
|
-
var decoder = new TextDecoder("utf-8");
|
|
130
|
-
function u8aToString(value) {
|
|
131
|
-
return value ? decoder.decode(value) : "";
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// ../../node_modules/@polkadot/util/u8a/wrap.js
|
|
135
|
-
var U8A_WRAP_ETHEREUM = /* @__PURE__ */ u8aToU8a("Ethereum Signed Message:\n");
|
|
136
|
-
var U8A_WRAP_PREFIX = /* @__PURE__ */ u8aToU8a("<Bytes>");
|
|
137
|
-
var U8A_WRAP_POSTFIX = /* @__PURE__ */ u8aToU8a("</Bytes>");
|
|
138
|
-
var WRAP_LEN = U8A_WRAP_PREFIX.length + U8A_WRAP_POSTFIX.length;
|
|
139
|
-
function u8aIsWrapped(u8a, withEthereum) {
|
|
140
|
-
return u8a.length >= WRAP_LEN && u8aEq(u8a.subarray(0, U8A_WRAP_PREFIX.length), U8A_WRAP_PREFIX) && u8aEq(u8a.slice(-U8A_WRAP_POSTFIX.length), U8A_WRAP_POSTFIX) || withEthereum && u8a.length >= U8A_WRAP_ETHEREUM.length && u8aEq(u8a.subarray(0, U8A_WRAP_ETHEREUM.length), U8A_WRAP_ETHEREUM);
|
|
141
|
-
}
|
|
142
|
-
function u8aUnwrapBytes(bytes) {
|
|
143
|
-
const u8a = u8aToU8a(bytes);
|
|
144
|
-
return u8aIsWrapped(u8a, false) ? u8a.subarray(U8A_WRAP_PREFIX.length, u8a.length - U8A_WRAP_POSTFIX.length) : u8a;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
1
|
// src/base.ts
|
|
148
2
|
import { AccountId } from "@polkadot-api/substrate-bindings";
|
|
149
|
-
var ellipsisFn = (str, amount = 6, position = "center") => {
|
|
150
|
-
const half = str.length / 2;
|
|
151
|
-
if (amount <= 4) {
|
|
152
|
-
if (position === "center") {
|
|
153
|
-
return str.slice(0, 4) + "..." + str.slice(-4);
|
|
154
|
-
}
|
|
155
|
-
if (position === "end") {
|
|
156
|
-
return str.slice(0, 4) + "...";
|
|
157
|
-
}
|
|
158
|
-
return "..." + str.slice(-4);
|
|
159
|
-
}
|
|
160
|
-
if (position === "center") {
|
|
161
|
-
return amount >= (str.length - 2) / 2 ? str.slice(0, half - 3) + "..." + str.slice(-(half - 3)) : str.slice(0, amount) + "..." + str.slice(-amount);
|
|
162
|
-
}
|
|
163
|
-
if (amount >= str.length) {
|
|
164
|
-
if (position === "end") {
|
|
165
|
-
return str.slice(0, str.length - 3) + "...";
|
|
166
|
-
}
|
|
167
|
-
return "..." + str.slice(-(str.length - 3));
|
|
168
|
-
} else {
|
|
169
|
-
if (position === "end") {
|
|
170
|
-
return str.slice(0, amount) + "...";
|
|
171
|
-
}
|
|
172
|
-
return "..." + str.slice(amount);
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
3
|
var rmCommas = (val) => val.replace(/,/g, "");
|
|
176
4
|
|
|
177
5
|
// src/unit.ts
|
|
@@ -240,18 +68,6 @@ var isValidAddress = (address) => {
|
|
|
240
68
|
return false;
|
|
241
69
|
}
|
|
242
70
|
};
|
|
243
|
-
var determinePoolDisplay = (address, batchItem) => {
|
|
244
|
-
const defaultDisplay = ellipsisFn(address, 6);
|
|
245
|
-
let display = batchItem ?? defaultDisplay;
|
|
246
|
-
const displayAsBytes = u8aToString(u8aUnwrapBytes(display));
|
|
247
|
-
if (displayAsBytes !== "") {
|
|
248
|
-
display = displayAsBytes;
|
|
249
|
-
}
|
|
250
|
-
if (display === "") {
|
|
251
|
-
display = defaultDisplay;
|
|
252
|
-
}
|
|
253
|
-
return display;
|
|
254
|
-
};
|
|
255
71
|
var extractUrlValue = (key, url) => {
|
|
256
72
|
if (typeof url === "undefined") {
|
|
257
73
|
url = window.location.href;
|
|
@@ -388,7 +204,6 @@ export {
|
|
|
388
204
|
addedTo,
|
|
389
205
|
applyWidthAsPadding,
|
|
390
206
|
capitalizeFirstLetter,
|
|
391
|
-
determinePoolDisplay,
|
|
392
207
|
extractUrlValue,
|
|
393
208
|
inChrome,
|
|
394
209
|
isValidAddress,
|