@w3ux/utils 0.9.1 → 0.10.1-alpha.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.
package/base.cjs CHANGED
@@ -25,8 +25,6 @@ __export(base_exports, {
25
25
  ellipsisFn: () => ellipsisFn,
26
26
  eqSet: () => eqSet,
27
27
  formatAccountSs58: () => formatAccountSs58,
28
- greaterThanZero: () => greaterThanZero,
29
- isNotZero: () => isNotZero,
30
28
  isSuperset: () => isSuperset,
31
29
  minDecimalPlaces: () => minDecimalPlaces,
32
30
  pageFromUri: () => pageFromUri,
@@ -36,8 +34,7 @@ __export(base_exports, {
36
34
  withTimeout: () => withTimeout
37
35
  });
38
36
  module.exports = __toCommonJS(base_exports);
39
- var import_bignumber = require("bignumber.js");
40
- var import_util_crypto = require("@polkadot/util-crypto");
37
+ var import_substrate_bindings = require("@polkadot-api/substrate-bindings");
41
38
  var camelize = (str) => {
42
39
  const convertToString = (string) => {
43
40
  if (string) {
@@ -92,15 +89,15 @@ var ellipsisFn = (str, amount = 6, position = "center") => {
92
89
  return "..." + str.slice(amount);
93
90
  }
94
91
  };
95
- var greaterThanZero = (val) => val.isGreaterThan(0);
96
- var isNotZero = (val) => !val.isZero();
97
92
  var minDecimalPlaces = (val, minDecimals) => {
98
- const whole = new import_bignumber.BigNumber(rmCommas(val).split(".")[0] || 0);
99
- const decimals = val.split(".")[1] || "";
100
- const missingDecimals = new import_bignumber.BigNumber(minDecimals).minus(decimals.length);
101
- return missingDecimals.isGreaterThan(0) ? `${whole.toFormat(0)}.${decimals.toString()}${"0".repeat(
102
- missingDecimals.toNumber()
103
- )}` : val;
93
+ try {
94
+ const whole = BigInt(rmCommas(val).split(".")[0] || "0");
95
+ const decimals = val.split(".")[1] || "";
96
+ const missingDecimals = minDecimals - decimals.length;
97
+ return missingDecimals > 0 ? `${whole.toString()}.${decimals}${"0".repeat(missingDecimals)}` : val;
98
+ } catch (e) {
99
+ return "0";
100
+ }
104
101
  };
105
102
  var pageFromUri = (pathname, fallback) => {
106
103
  const lastUriItem = pathname.substring(pathname.lastIndexOf("/") + 1);
@@ -136,9 +133,8 @@ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
136
133
  var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
137
134
  var formatAccountSs58 = (address, ss58Prefix) => {
138
135
  try {
139
- const decodedAddress = (0, import_util_crypto.decodeAddress)(address);
140
- const formattedAddress = (0, import_util_crypto.encodeAddress)(decodedAddress, ss58Prefix);
141
- return formattedAddress;
136
+ const codec = (0, import_substrate_bindings.AccountId)(ss58Prefix);
137
+ return codec.dec(codec.enc(address));
142
138
  } catch (e) {
143
139
  return null;
144
140
  }
@@ -161,8 +157,6 @@ var isSuperset = (set, subset) => {
161
157
  ellipsisFn,
162
158
  eqSet,
163
159
  formatAccountSs58,
164
- greaterThanZero,
165
- isNotZero,
166
160
  isSuperset,
167
161
  minDecimalPlaces,
168
162
  pageFromUri,
package/base.d.cts CHANGED
@@ -1,4 +1,3 @@
1
- import { BigNumber } from 'bignumber.js';
2
1
  import { AnyFunction } from '@w3ux/types';
3
2
 
4
3
  /**
@@ -15,16 +14,6 @@ declare const camelize: (str: string) => string;
15
14
  * same for beginning and end; if "start" or "end" then its only once the amount; defaults to "start"
16
15
  */
17
16
  declare const ellipsisFn: (str: string, amount?: number, position?: "start" | "end" | "center") => string;
18
- /**
19
- * @name greaterThanZero
20
- * @summary Returns whether a BigNumber is greater than zero.
21
- */
22
- declare const greaterThanZero: (val: BigNumber) => boolean;
23
- /**
24
- * @name isNotZero
25
- * @summary Returns whether a BigNumber is zero.
26
- */
27
- declare const isNotZero: (val: BigNumber) => boolean;
28
17
  /**
29
18
  * @name minDecimalPlaces
30
19
  * @summary Forces a number to have at least the provided decimal places.
@@ -76,4 +65,4 @@ declare const removeHexPrefix: (str: string) => string;
76
65
  declare const eqSet: (xs: Set<any>, ys: Set<any>) => boolean;
77
66
  declare const isSuperset: (set: Set<any>, subset: Set<any>) => boolean;
78
67
 
79
- export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, greaterThanZero, isNotZero, isSuperset, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout };
68
+ export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout };
package/base.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { BigNumber } from 'bignumber.js';
2
1
  import { AnyFunction } from '@w3ux/types';
3
2
 
4
3
  /**
@@ -15,16 +14,6 @@ declare const camelize: (str: string) => string;
15
14
  * same for beginning and end; if "start" or "end" then its only once the amount; defaults to "start"
16
15
  */
17
16
  declare const ellipsisFn: (str: string, amount?: number, position?: "start" | "end" | "center") => string;
18
- /**
19
- * @name greaterThanZero
20
- * @summary Returns whether a BigNumber is greater than zero.
21
- */
22
- declare const greaterThanZero: (val: BigNumber) => boolean;
23
- /**
24
- * @name isNotZero
25
- * @summary Returns whether a BigNumber is zero.
26
- */
27
- declare const isNotZero: (val: BigNumber) => boolean;
28
17
  /**
29
18
  * @name minDecimalPlaces
30
19
  * @summary Forces a number to have at least the provided decimal places.
@@ -76,4 +65,4 @@ declare const removeHexPrefix: (str: string) => string;
76
65
  declare const eqSet: (xs: Set<any>, ys: Set<any>) => boolean;
77
66
  declare const isSuperset: (set: Set<any>, subset: Set<any>) => boolean;
78
67
 
79
- export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, greaterThanZero, isNotZero, isSuperset, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout };
68
+ export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout };
package/base.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // src/base.ts
2
- import { BigNumber } from "bignumber.js";
3
- import { decodeAddress, encodeAddress } from "@polkadot/util-crypto";
2
+ import { AccountId } from "@polkadot-api/substrate-bindings";
4
3
  var camelize = (str) => {
5
4
  const convertToString = (string) => {
6
5
  if (string) {
@@ -55,15 +54,15 @@ var ellipsisFn = (str, amount = 6, position = "center") => {
55
54
  return "..." + str.slice(amount);
56
55
  }
57
56
  };
58
- var greaterThanZero = (val) => val.isGreaterThan(0);
59
- var isNotZero = (val) => !val.isZero();
60
57
  var minDecimalPlaces = (val, minDecimals) => {
61
- const whole = new BigNumber(rmCommas(val).split(".")[0] || 0);
62
- const decimals = val.split(".")[1] || "";
63
- const missingDecimals = new BigNumber(minDecimals).minus(decimals.length);
64
- return missingDecimals.isGreaterThan(0) ? `${whole.toFormat(0)}.${decimals.toString()}${"0".repeat(
65
- missingDecimals.toNumber()
66
- )}` : val;
58
+ try {
59
+ const whole = BigInt(rmCommas(val).split(".")[0] || "0");
60
+ const decimals = val.split(".")[1] || "";
61
+ const missingDecimals = minDecimals - decimals.length;
62
+ return missingDecimals > 0 ? `${whole.toString()}.${decimals}${"0".repeat(missingDecimals)}` : val;
63
+ } catch (e) {
64
+ return "0";
65
+ }
67
66
  };
68
67
  var pageFromUri = (pathname, fallback) => {
69
68
  const lastUriItem = pathname.substring(pathname.lastIndexOf("/") + 1);
@@ -99,9 +98,8 @@ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
99
98
  var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
100
99
  var formatAccountSs58 = (address, ss58Prefix) => {
101
100
  try {
102
- const decodedAddress = decodeAddress(address);
103
- const formattedAddress = encodeAddress(decodedAddress, ss58Prefix);
104
- return formattedAddress;
101
+ const codec = AccountId(ss58Prefix);
102
+ return codec.dec(codec.enc(address));
105
103
  } catch (e) {
106
104
  return null;
107
105
  }
@@ -123,8 +121,6 @@ export {
123
121
  ellipsisFn,
124
122
  eqSet,
125
123
  formatAccountSs58,
126
- greaterThanZero,
127
- isNotZero,
128
124
  isSuperset,
129
125
  minDecimalPlaces,
130
126
  pageFromUri,
package/index.cjs CHANGED
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
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
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/index.ts
@@ -31,9 +41,7 @@ __export(src_exports, {
31
41
  evalUnits: () => evalUnits,
32
42
  extractUrlValue: () => extractUrlValue,
33
43
  formatAccountSs58: () => formatAccountSs58,
34
- greaterThanZero: () => greaterThanZero,
35
44
  inChrome: () => inChrome,
36
- isNotZero: () => isNotZero,
37
45
  isSuperset: () => isSuperset,
38
46
  isValidAddress: () => isValidAddress,
39
47
  isValidHttpUrl: () => isValidHttpUrl,
@@ -64,8 +72,7 @@ __export(src_exports, {
64
72
  module.exports = __toCommonJS(src_exports);
65
73
 
66
74
  // src/base.ts
67
- var import_bignumber = require("bignumber.js");
68
- var import_util_crypto = require("@polkadot/util-crypto");
75
+ var import_substrate_bindings = require("@polkadot-api/substrate-bindings");
69
76
  var camelize = (str) => {
70
77
  const convertToString = (string) => {
71
78
  if (string) {
@@ -120,15 +127,15 @@ var ellipsisFn = (str, amount = 6, position = "center") => {
120
127
  return "..." + str.slice(amount);
121
128
  }
122
129
  };
123
- var greaterThanZero = (val) => val.isGreaterThan(0);
124
- var isNotZero = (val) => !val.isZero();
125
130
  var minDecimalPlaces = (val, minDecimals) => {
126
- const whole = new import_bignumber.BigNumber(rmCommas(val).split(".")[0] || 0);
127
- const decimals = val.split(".")[1] || "";
128
- const missingDecimals = new import_bignumber.BigNumber(minDecimals).minus(decimals.length);
129
- return missingDecimals.isGreaterThan(0) ? `${whole.toFormat(0)}.${decimals.toString()}${"0".repeat(
130
- missingDecimals.toNumber()
131
- )}` : val;
131
+ try {
132
+ const whole = BigInt(rmCommas(val).split(".")[0] || "0");
133
+ const decimals = val.split(".")[1] || "";
134
+ const missingDecimals = minDecimals - decimals.length;
135
+ return missingDecimals > 0 ? `${whole.toString()}.${decimals}${"0".repeat(missingDecimals)}` : val;
136
+ } catch (e) {
137
+ return "0";
138
+ }
132
139
  };
133
140
  var pageFromUri = (pathname, fallback) => {
134
141
  const lastUriItem = pathname.substring(pathname.lastIndexOf("/") + 1);
@@ -164,9 +171,8 @@ var appendOrEmpty = (condition, value) => condition ? ` ${value}` : "";
164
171
  var appendOr = (condition, value, fallback) => condition ? ` ${value}` : ` ${fallback}`;
165
172
  var formatAccountSs58 = (address, ss58Prefix) => {
166
173
  try {
167
- const decodedAddress = (0, import_util_crypto.decodeAddress)(address);
168
- const formattedAddress = (0, import_util_crypto.encodeAddress)(decodedAddress, ss58Prefix);
169
- return formattedAddress;
174
+ const codec = (0, import_substrate_bindings.AccountId)(ss58Prefix);
175
+ return codec.dec(codec.enc(address));
170
176
  } catch (e) {
171
177
  return null;
172
178
  }
@@ -182,17 +188,162 @@ var isSuperset = (set, subset) => {
182
188
  return true;
183
189
  };
184
190
 
191
+ // ../../node_modules/@polkadot/x-textdecoder/node.js
192
+ var import_node_util = __toESM(require("util"), 1);
193
+
194
+ // ../../node_modules/@polkadot/x-global/index.js
195
+ function evaluateThis(fn) {
196
+ return fn("return this");
197
+ }
198
+ var xglobal = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : evaluateThis(Function);
199
+ function extractGlobal(name, fallback) {
200
+ return typeof xglobal[name] === "undefined" ? fallback : xglobal[name];
201
+ }
202
+
203
+ // ../../node_modules/@polkadot/x-textdecoder/node.js
204
+ var TextDecoder = /* @__PURE__ */ extractGlobal("TextDecoder", import_node_util.default.TextDecoder);
205
+
206
+ // ../../node_modules/@polkadot/x-textencoder/node.js
207
+ var import_node_util2 = __toESM(require("util"), 1);
208
+ var Fallback = class {
209
+ __internal__encoder;
210
+ constructor() {
211
+ this.__internal__encoder = new import_node_util2.default.TextEncoder();
212
+ }
213
+ // For a Jest 26.0.1 environment, Buffer !== Uint8Array
214
+ encode(value) {
215
+ return Uint8Array.from(this.__internal__encoder.encode(value));
216
+ }
217
+ };
218
+ var TextEncoder = /* @__PURE__ */ extractGlobal("TextEncoder", Fallback);
219
+
220
+ // ../../node_modules/@polkadot/util/is/function.js
221
+ function isFunction(value) {
222
+ return typeof value === "function";
223
+ }
224
+
225
+ // ../../node_modules/@polkadot/x-bigint/index.js
226
+ function invalidFallback() {
227
+ return Number.NaN;
228
+ }
229
+ var BigInt2 = /* @__PURE__ */ extractGlobal("BigInt", invalidFallback);
230
+
231
+ // ../../node_modules/@polkadot/util/hex/toU8a.js
232
+ var CHR = "0123456789abcdef";
233
+ var U8 = new Uint8Array(256);
234
+ var U16 = new Uint8Array(256 * 256);
235
+ for (let i = 0, count = CHR.length; i < count; i++) {
236
+ U8[CHR[i].charCodeAt(0) | 0] = i | 0;
237
+ if (i > 9) {
238
+ U8[CHR[i].toUpperCase().charCodeAt(0) | 0] = i | 0;
239
+ }
240
+ }
241
+ for (let i = 0; i < 256; i++) {
242
+ const s = i << 8;
243
+ for (let j = 0; j < 256; j++) {
244
+ U16[s | j] = U8[i] << 4 | U8[j];
245
+ }
246
+ }
247
+ function hexToU8a(value, bitLength = -1) {
248
+ if (!value) {
249
+ return new Uint8Array();
250
+ }
251
+ let s = value.startsWith("0x") ? 2 : 0;
252
+ const decLength = Math.ceil((value.length - s) / 2);
253
+ const endLength = Math.ceil(bitLength === -1 ? decLength : bitLength / 8);
254
+ const result = new Uint8Array(endLength);
255
+ const offset = endLength > decLength ? endLength - decLength : 0;
256
+ for (let i = offset; i < endLength; i++, s += 2) {
257
+ result[i] = U16[value.charCodeAt(s) << 8 | value.charCodeAt(s + 1)];
258
+ }
259
+ return result;
260
+ }
261
+
262
+ // ../../node_modules/@polkadot/util/is/hex.js
263
+ var REGEX_HEX_PREFIXED = /^0x[\da-fA-F]+$/;
264
+ function isHex(value, bitLength = -1, ignoreLength) {
265
+ 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));
266
+ }
267
+
268
+ // ../../node_modules/@polkadot/util/has.js
269
+ var hasBigInt = typeof BigInt2 === "function" && typeof BigInt2.asIntN === "function";
270
+ var hasBuffer = typeof xglobal.Buffer === "function" && typeof xglobal.Buffer.isBuffer === "function";
271
+ var hasProcess = typeof xglobal.process === "object";
272
+
273
+ // ../../node_modules/@polkadot/util/is/buffer.js
274
+ function isBuffer(value) {
275
+ return hasBuffer && !!value && isFunction(value.readDoubleLE) && xglobal.Buffer.isBuffer(value);
276
+ }
277
+
278
+ // ../../node_modules/@polkadot/util/is/u8a.js
279
+ function isU8a(value) {
280
+ return (value && value.constructor) === Uint8Array || value instanceof Uint8Array;
281
+ }
282
+
283
+ // ../../node_modules/@polkadot/util/string/toU8a.js
284
+ var encoder = new TextEncoder();
285
+ function stringToU8a(value) {
286
+ return value ? encoder.encode(value.toString()) : new Uint8Array();
287
+ }
288
+
289
+ // ../../node_modules/@polkadot/util/u8a/toU8a.js
290
+ function u8aToU8a(value) {
291
+ return isU8a(value) ? isBuffer(value) ? new Uint8Array(value) : value : isHex(value) ? hexToU8a(value) : Array.isArray(value) ? new Uint8Array(value) : stringToU8a(value);
292
+ }
293
+
294
+ // ../../node_modules/@polkadot/util/u8a/eq.js
295
+ function u8aEq(a, b) {
296
+ const u8aa = u8aToU8a(a);
297
+ const u8ab = u8aToU8a(b);
298
+ if (u8aa.length === u8ab.length) {
299
+ const dvA = new DataView(u8aa.buffer, u8aa.byteOffset);
300
+ const dvB = new DataView(u8ab.buffer, u8ab.byteOffset);
301
+ const mod = u8aa.length % 4 | 0;
302
+ const length = u8aa.length - mod | 0;
303
+ for (let i = 0; i < length; i += 4) {
304
+ if (dvA.getUint32(i) !== dvB.getUint32(i)) {
305
+ return false;
306
+ }
307
+ }
308
+ for (let i = length, count = u8aa.length; i < count; i++) {
309
+ if (u8aa[i] !== u8ab[i]) {
310
+ return false;
311
+ }
312
+ }
313
+ return true;
314
+ }
315
+ return false;
316
+ }
317
+
318
+ // ../../node_modules/@polkadot/util/u8a/toString.js
319
+ var decoder = new TextDecoder("utf-8");
320
+ function u8aToString(value) {
321
+ return value ? decoder.decode(value) : "";
322
+ }
323
+
324
+ // ../../node_modules/@polkadot/util/u8a/wrap.js
325
+ var U8A_WRAP_ETHEREUM = /* @__PURE__ */ u8aToU8a("Ethereum Signed Message:\n");
326
+ var U8A_WRAP_PREFIX = /* @__PURE__ */ u8aToU8a("<Bytes>");
327
+ var U8A_WRAP_POSTFIX = /* @__PURE__ */ u8aToU8a("</Bytes>");
328
+ var WRAP_LEN = U8A_WRAP_PREFIX.length + U8A_WRAP_POSTFIX.length;
329
+ function u8aIsWrapped(u8a, withEthereum) {
330
+ 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);
331
+ }
332
+ function u8aUnwrapBytes(bytes) {
333
+ const u8a = u8aToU8a(bytes);
334
+ return u8aIsWrapped(u8a, false) ? u8a.subarray(U8A_WRAP_PREFIX.length, u8a.length - U8A_WRAP_POSTFIX.length) : u8a;
335
+ }
336
+
185
337
  // src/unit.ts
186
- var import_util_crypto2 = require("@polkadot/util-crypto");
187
- var import_util = require("@polkadot/util");
188
- var import_bignumber2 = require("bignumber.js");
338
+ var import_bignumber = require("bignumber.js");
339
+ var import_substrate_bindings2 = require("@polkadot-api/substrate-bindings");
189
340
  var remToUnit = (rem) => Number(rem.slice(0, rem.length - 3)) * parseFloat(getComputedStyle(document.documentElement).fontSize);
190
- var planckToUnit = (val, units) => new import_bignumber2.BigNumber(
191
- val.dividedBy(new import_bignumber2.BigNumber(10).exponentiatedBy(units)).toFixed(units)
341
+ var planckToUnit = (val, units) => new import_bignumber.BigNumber(
342
+ val.dividedBy(new import_bignumber.BigNumber(10).exponentiatedBy(units)).toFixed(units)
192
343
  );
193
344
  var unitToPlanck = (val, units) => {
194
- const init = new import_bignumber2.BigNumber(!val.length || !val ? "0" : val);
195
- return (!init.isNaN() ? init : new import_bignumber2.BigNumber(0)).multipliedBy(new import_bignumber2.BigNumber(10).exponentiatedBy(units)).integerValue();
345
+ const init = new import_bignumber.BigNumber(!val.length || !val ? "0" : val);
346
+ return (!init.isNaN() ? init : new import_bignumber.BigNumber(0)).multipliedBy(new import_bignumber.BigNumber(10).exponentiatedBy(units)).integerValue();
196
347
  };
197
348
  var capitalizeFirstLetter = (string) => string.charAt(0).toUpperCase() + string.slice(1);
198
349
  var snakeToCamel = (str) => str.toLowerCase().replace(
@@ -215,10 +366,8 @@ var localStorageOrDefault = (key, _default, parse = false) => {
215
366
  };
216
367
  var isValidAddress = (address) => {
217
368
  try {
218
- if ((0, import_util.isHex)(address)) {
219
- return true;
220
- }
221
- (0, import_util_crypto2.decodeAddress)(address);
369
+ const codec = (0, import_substrate_bindings2.AccountId)();
370
+ codec.dec(codec.enc(address));
222
371
  return true;
223
372
  } catch (e) {
224
373
  return false;
@@ -227,7 +376,7 @@ var isValidAddress = (address) => {
227
376
  var determinePoolDisplay = (address, batchItem) => {
228
377
  const defaultDisplay = ellipsisFn(address, 6);
229
378
  let display = batchItem ?? defaultDisplay;
230
- const displayAsBytes = (0, import_util.u8aToString)((0, import_util.u8aUnwrapBytes)(display));
379
+ const displayAsBytes = u8aToString(u8aUnwrapBytes(display));
231
380
  if (displayAsBytes !== "") {
232
381
  display = displayAsBytes;
233
382
  }
@@ -346,7 +495,7 @@ var makeCancelable = (promise) => {
346
495
  }
347
496
  };
348
497
  };
349
- var getSiValue = (si2) => new import_bignumber2.BigNumber(10).pow(new import_bignumber2.BigNumber(si2));
498
+ var getSiValue = (si2) => new import_bignumber.BigNumber(10).pow(new import_bignumber.BigNumber(si2));
350
499
  var si = [
351
500
  { value: getSiValue(24), symbol: "y", isMil: true },
352
501
  { value: getSiValue(21), symbol: "z", isMil: true },
@@ -356,7 +505,7 @@ var si = [
356
505
  { value: getSiValue(9), symbol: "n", isMil: true },
357
506
  { value: getSiValue(6), symbol: "\u03BC", isMil: true },
358
507
  { value: getSiValue(3), symbol: "m", isMil: true },
359
- { value: new import_bignumber2.BigNumber(1), symbol: "" },
508
+ { value: new import_bignumber.BigNumber(1), symbol: "" },
360
509
  { value: getSiValue(3), symbol: "k" },
361
510
  { value: getSiValue(6), symbol: "M" },
362
511
  { value: getSiValue(9), symbol: "G" },
@@ -381,25 +530,25 @@ var evalUnits = (input, chainDecimals) => {
381
530
  const symbol = input.replace(/[0-9.,]/g, "");
382
531
  const siVal = si.find((s) => s.symbol === symbol);
383
532
  const numberStr = input.replace(symbol, "").replace(",", ".");
384
- let numeric = new import_bignumber2.BigNumber(0);
533
+ let numeric = new import_bignumber.BigNumber(0);
385
534
  if (!siVal) {
386
535
  return [null, "Provided symbol is not correct" /* SYMBOL_ERROR */];
387
536
  }
388
- const decimalsBn = new import_bignumber2.BigNumber(10).pow(new import_bignumber2.BigNumber(chainDecimals));
537
+ const decimalsBn = new import_bignumber.BigNumber(10).pow(new import_bignumber.BigNumber(chainDecimals));
389
538
  const containDecimal = numberStr.includes(".");
390
539
  const [decPart, fracPart] = numberStr.split(".");
391
540
  const fracDecimals = fracPart?.length || 0;
392
- const fracExp = new import_bignumber2.BigNumber(10).pow(new import_bignumber2.BigNumber(fracDecimals));
393
- numeric = containDecimal ? new import_bignumber2.BigNumber(
394
- new import_bignumber2.BigNumber(decPart).multipliedBy(fracExp).plus(new import_bignumber2.BigNumber(fracPart))
395
- ) : new import_bignumber2.BigNumber(new import_bignumber2.BigNumber(numberStr));
541
+ const fracExp = new import_bignumber.BigNumber(10).pow(new import_bignumber.BigNumber(fracDecimals));
542
+ numeric = containDecimal ? new import_bignumber.BigNumber(
543
+ new import_bignumber.BigNumber(decPart).multipliedBy(fracExp).plus(new import_bignumber.BigNumber(fracPart))
544
+ ) : new import_bignumber.BigNumber(new import_bignumber.BigNumber(numberStr));
396
545
  numeric = numeric.multipliedBy(decimalsBn);
397
546
  if (containDecimal) {
398
547
  numeric = siVal.isMil ? numeric.dividedBy(siVal.value).dividedBy(fracExp) : numeric.multipliedBy(siVal.value).dividedBy(fracExp);
399
548
  } else {
400
549
  numeric = siVal.isMil ? numeric.dividedBy(siVal.value) : numeric.multipliedBy(siVal.value);
401
550
  }
402
- if (numeric.eq(new import_bignumber2.BigNumber(0))) {
551
+ if (numeric.eq(new import_bignumber.BigNumber(0))) {
403
552
  return [null, "You cannot send 0 funds" /* ZERO */];
404
553
  }
405
554
  return [numeric, "" /* SUCCESS */];
@@ -446,7 +595,7 @@ var mergeDeep = (target, ...sources) => {
446
595
  }
447
596
  return mergeDeep(target, ...sources);
448
597
  };
449
- var stringToBigNumber = (value) => new import_bignumber2.BigNumber(rmCommas(value));
598
+ var stringToBigNumber = (value) => new import_bignumber.BigNumber(rmCommas(value));
450
599
  // Annotate the CommonJS export names for ESM import in node:
451
600
  0 && (module.exports = {
452
601
  addedTo,
@@ -461,9 +610,7 @@ var stringToBigNumber = (value) => new import_bignumber2.BigNumber(rmCommas(valu
461
610
  evalUnits,
462
611
  extractUrlValue,
463
612
  formatAccountSs58,
464
- greaterThanZero,
465
613
  inChrome,
466
- isNotZero,
467
614
  isSuperset,
468
615
  isValidAddress,
469
616
  isValidHttpUrl,
package/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, greaterThanZero, isNotZero, isSuperset, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.cjs';
1
+ export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.cjs';
2
2
  export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, evalUnits, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, stringToBigNumber, transformToBaseUnit, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.cjs';
3
- import 'bignumber.js';
4
3
  import '@w3ux/types';
4
+ import 'bignumber.js';
5
5
  import 'react';
6
6
  import './types.cjs';
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, greaterThanZero, isNotZero, isSuperset, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.js';
1
+ export { appendOr, appendOrEmpty, camelize, ellipsisFn, eqSet, formatAccountSs58, isSuperset, minDecimalPlaces, pageFromUri, removeHexPrefix, rmCommas, shuffle, withTimeout } from './base.js';
2
2
  export { addedTo, applyWidthAsPadding, capitalizeFirstLetter, determinePoolDisplay, evalUnits, extractUrlValue, inChrome, isValidAddress, isValidHttpUrl, localStorageOrDefault, makeCancelable, matchedProperties, mergeDeep, planckToUnit, remToUnit, removeVarFromUrlHash, removedFrom, setStateWithRef, snakeToCamel, sortWithNull, stringToBigNumber, transformToBaseUnit, unescape, unimplemented, unitToPlanck, varToUrlHash } from './unit.js';
3
- import 'bignumber.js';
4
3
  import '@w3ux/types';
4
+ import 'bignumber.js';
5
5
  import 'react';
6
6
  import './types.js';