@talismn/util 0.0.0-pr677-20230418101345 → 0.0.0-pr708-20230419032011

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/CHANGELOG.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # @talismn/util
2
2
 
3
- ## 0.0.0-pr677-20230418101345
3
+ ## 0.0.0-pr708-20230419032011
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 71b68602: feat: crowdloan and nom pool balances
8
- - c3f58851: fix: packages publishing with incorrect interdependency versions
7
+ - 8e63a8cf: eslint rules
9
8
 
10
9
  ## 0.1.8
11
10
 
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export declare const BigMath: {
6
6
  abs(x: bigint): bigint;
7
- sign(x: bigint): 0n | 1n | -1n;
7
+ sign(x: bigint): bigint;
8
8
  min(value: bigint, ...values: bigint[]): bigint;
9
9
  max(value: bigint, ...values: bigint[]): bigint;
10
10
  };
@@ -9,7 +9,6 @@ export * from "./formatDecimals";
9
9
  export * from "./getBase64ImageUrl";
10
10
  export * from "./hasOwnProperty";
11
11
  export * from "./isArrayOf";
12
- export * from "./isEthereumAddress";
13
12
  export * from "./planckToTokens";
14
13
  export * from "./sleep";
15
14
  export * from "./throwAfter";
@@ -17,11 +17,11 @@ var BigNumber__default = /*#__PURE__*/_interopDefault(BigNumber);
17
17
  */
18
18
  const BigMath = {
19
19
  abs(x) {
20
- return x < 0n ? -x : x;
20
+ return x < BigInt("0") ? -x : x;
21
21
  },
22
22
  sign(x) {
23
- if (x === 0n) return 0n;
24
- return x < 0n ? -1n : 1n;
23
+ if (x === BigInt("0")) return BigInt("0");
24
+ return x < BigInt("0") ? BigInt("-1") : BigInt("1");
25
25
  },
26
26
  // TODO: Improve our babel/tsc config to let us use the `**` operator on bigint values.
27
27
  // Error thrown: Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later. ts(2791)
@@ -66,6 +66,7 @@ function decodeAnyAddress(encoded, ignoreChecksum, ss58Format) {
66
66
  */
67
67
  function Deferred() {
68
68
  let resolve;
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
70
  let reject;
70
71
  let isPending = true;
71
72
  let isResolved = false;
@@ -169,8 +170,6 @@ function isArrayOf(array, func) {
169
170
  return false;
170
171
  }
171
172
 
172
- const isEthereumAddress = address => address.startsWith("0x") && address.length === 42;
173
-
174
173
  function planckToTokens(planck, tokenDecimals) {
175
174
  if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
176
175
  const base = 10;
@@ -207,7 +206,6 @@ exports.formatDecimals = formatDecimals;
207
206
  exports.getBase64ImageUrl = getBase64ImageUrl;
208
207
  exports.hasOwnProperty = hasOwnProperty;
209
208
  exports.isArrayOf = isArrayOf;
210
- exports.isEthereumAddress = isEthereumAddress;
211
209
  exports.planckToTokens = planckToTokens;
212
210
  exports.sleep = sleep;
213
211
  exports.throwAfter = throwAfter;
@@ -17,11 +17,11 @@ var BigNumber__default = /*#__PURE__*/_interopDefault(BigNumber);
17
17
  */
18
18
  const BigMath = {
19
19
  abs(x) {
20
- return x < 0n ? -x : x;
20
+ return x < BigInt("0") ? -x : x;
21
21
  },
22
22
  sign(x) {
23
- if (x === 0n) return 0n;
24
- return x < 0n ? -1n : 1n;
23
+ if (x === BigInt("0")) return BigInt("0");
24
+ return x < BigInt("0") ? BigInt("-1") : BigInt("1");
25
25
  },
26
26
  // TODO: Improve our babel/tsc config to let us use the `**` operator on bigint values.
27
27
  // Error thrown: Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later. ts(2791)
@@ -66,6 +66,7 @@ function decodeAnyAddress(encoded, ignoreChecksum, ss58Format) {
66
66
  */
67
67
  function Deferred() {
68
68
  let resolve;
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
70
  let reject;
70
71
  let isPending = true;
71
72
  let isResolved = false;
@@ -169,8 +170,6 @@ function isArrayOf(array, func) {
169
170
  return false;
170
171
  }
171
172
 
172
- const isEthereumAddress = address => address.startsWith("0x") && address.length === 42;
173
-
174
173
  function planckToTokens(planck, tokenDecimals) {
175
174
  if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
176
175
  const base = 10;
@@ -207,7 +206,6 @@ exports.formatDecimals = formatDecimals;
207
206
  exports.getBase64ImageUrl = getBase64ImageUrl;
208
207
  exports.hasOwnProperty = hasOwnProperty;
209
208
  exports.isArrayOf = isArrayOf;
210
- exports.isEthereumAddress = isEthereumAddress;
211
209
  exports.planckToTokens = planckToTokens;
212
210
  exports.sleep = sleep;
213
211
  exports.throwAfter = throwAfter;
@@ -1,5 +1,5 @@
1
1
  import { u8aToHex, u8aConcat, u8aToU8a, hexToU8a } from '@polkadot/util';
2
- import { blake2AsU8a, isEthereumAddress as isEthereumAddress$1, ethereumEncode, xxhashAsU8a } from '@polkadot/util-crypto';
2
+ import { blake2AsU8a, isEthereumAddress, ethereumEncode, xxhashAsU8a } from '@polkadot/util-crypto';
3
3
  import { decodeAddress, encodeAddress } from '@polkadot/keyring';
4
4
  import BigNumber from 'bignumber.js';
5
5
 
@@ -9,11 +9,11 @@ import BigNumber from 'bignumber.js';
9
9
  */
10
10
  const BigMath = {
11
11
  abs(x) {
12
- return x < 0n ? -x : x;
12
+ return x < BigInt("0") ? -x : x;
13
13
  },
14
14
  sign(x) {
15
- if (x === 0n) return 0n;
16
- return x < 0n ? -1n : 1n;
15
+ if (x === BigInt("0")) return BigInt("0");
16
+ return x < BigInt("0") ? BigInt("-1") : BigInt("1");
17
17
  },
18
18
  // TODO: Improve our babel/tsc config to let us use the `**` operator on bigint values.
19
19
  // Error thrown: Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later. ts(2791)
@@ -44,7 +44,7 @@ function decodeAnyAddress(encoded, ignoreChecksum, ss58Format) {
44
44
  return decodeAddress(encoded, ignoreChecksum, ss58Format);
45
45
  } catch (error) {
46
46
  if (typeof encoded !== "string") throw error;
47
- if (!isEthereumAddress$1(encoded)) throw error;
47
+ if (!isEthereumAddress(encoded)) throw error;
48
48
  return hexToU8a(encoded.slice("0x".length));
49
49
  }
50
50
  }
@@ -58,6 +58,7 @@ function decodeAnyAddress(encoded, ignoreChecksum, ss58Format) {
58
58
  */
59
59
  function Deferred() {
60
60
  let resolve;
61
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
62
  let reject;
62
63
  let isPending = true;
63
64
  let isResolved = false;
@@ -89,7 +90,7 @@ function encodeAnyAddress(key, ss58Format) {
89
90
  return encodeAddress(key, ss58Format);
90
91
  } catch (error) {
91
92
  if (typeof key !== "string") throw error;
92
- if (!isEthereumAddress$1(key)) throw error;
93
+ if (!isEthereumAddress(key)) throw error;
93
94
  return ethereumEncode(key);
94
95
  }
95
96
  }
@@ -161,8 +162,6 @@ function isArrayOf(array, func) {
161
162
  return false;
162
163
  }
163
164
 
164
- const isEthereumAddress = address => address.startsWith("0x") && address.length === 42;
165
-
166
165
  function planckToTokens(planck, tokenDecimals) {
167
166
  if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
168
167
  const base = 10;
@@ -188,4 +187,4 @@ function twox64Concat(input) {
188
187
  return u8aToHex(u8aConcat(xxhashAsU8a(input, bitLength), u8aToU8a(input)));
189
188
  }
190
189
 
191
- export { BigMath, Deferred, MAX_DECIMALS_FORMAT, blake2Concat, classNames, decodeAnyAddress, encodeAnyAddress, formatDecimals, getBase64ImageUrl, hasOwnProperty, isArrayOf, isEthereumAddress, planckToTokens, sleep, throwAfter, tokensToPlanck, twox64Concat };
190
+ export { BigMath, Deferred, MAX_DECIMALS_FORMAT, blake2Concat, classNames, decodeAnyAddress, encodeAnyAddress, formatDecimals, getBase64ImageUrl, hasOwnProperty, isArrayOf, planckToTokens, sleep, throwAfter, tokensToPlanck, twox64Concat };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/util",
3
- "version": "0.0.0-pr677-20230418101345",
3
+ "version": "0.0.0-pr708-20230419032011",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "UNLICENSED",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "scripts": {
24
24
  "test": "jest",
25
- "lint": "eslint . --max-warnings 0",
25
+ "lint": "eslint src --max-warnings 0",
26
26
  "clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
27
27
  },
28
28
  "dependencies": {
@@ -32,8 +32,8 @@
32
32
  "@polkadot/keyring": "^11.1.1",
33
33
  "@polkadot/util": "^11.1.1",
34
34
  "@polkadot/util-crypto": "^11.1.1",
35
- "@talismn/eslint-config": "0.0.1",
36
- "@talismn/tsconfig": "0.0.2",
35
+ "@talismn/eslint-config": "^0.0.0-pr708-20230419032011",
36
+ "@talismn/tsconfig": "^0.0.2",
37
37
  "@types/jest": "^27.5.1",
38
38
  "eslint": "^8.4.0",
39
39
  "jest": "^28.1.0",
@@ -43,7 +43,7 @@
43
43
  "peerDependencies": {
44
44
  "@polkadot/keyring": "11.x",
45
45
  "@polkadot/util": "11.x",
46
- "@polkadot/util-crypto": "11.x"
46
+ "@polkadot/util-crypto": "^11.x"
47
47
  },
48
48
  "eslintConfig": {
49
49
  "root": true,
@@ -1 +0,0 @@
1
- export declare const isEthereumAddress: (address: string) => boolean;