@polkadot/types-codec 7.2.2-9 → 7.3.2-2

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.
@@ -42,6 +42,10 @@ function decodeAbstractInt(value, bitLength, isNegative) {
42
42
  isLe: false,
43
43
  isNegative
44
44
  }).toString();
45
+ } else if ((0, _util.isNumber)(value)) {
46
+ (0, _util.assert)(value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER && Math.floor(value) === value, 'Number needs to be an integer <= Number.MAX_SAFE_INTEGER, i.e. 2 ^ 53 - 1');
47
+ } else if ((0, _util.isString)(value)) {
48
+ (0, _util.assert)(!(value.includes('.') || value.includes(',') || value.includes('e')), 'String should not contain decimal points or scientific notation');
45
49
  }
46
50
 
47
51
  return (0, _util.bnToBn)(value).toString();
@@ -2,7 +2,7 @@ import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivate
2
2
  import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
3
3
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
4
4
  // SPDX-License-Identifier: Apache-2.0
5
- import { assert, BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, BN_ZERO, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isBn, isHex, isU8a, u8aToBn } from '@polkadot/util';
5
+ import { assert, BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, BN_ZERO, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isBn, isHex, isNumber, isString, isU8a, u8aToBn } from '@polkadot/util';
6
6
  export const DEFAULT_UINT_BITS = 64; // Maximum allowed integer for JS is 2^53 - 1, set limit at 52
7
7
  // In this case however, we always print any >32 as hex
8
8
 
@@ -29,6 +29,10 @@ function decodeAbstractInt(value, bitLength, isNegative) {
29
29
  isLe: false,
30
30
  isNegative
31
31
  }).toString();
32
+ } else if (isNumber(value)) {
33
+ assert(value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER && Math.floor(value) === value, 'Number needs to be an integer <= Number.MAX_SAFE_INTEGER, i.e. 2 ^ 53 - 1');
34
+ } else if (isString(value)) {
35
+ assert(!(value.includes('.') || value.includes(',') || value.includes('e')), 'String should not contain decimal points or scientific notation');
32
36
  }
33
37
 
34
38
  return bnToBn(value).toString();
package/detectPackage.cjs CHANGED
@@ -11,4 +11,4 @@ var _packageInfo = require("./packageInfo.cjs");
11
11
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
12
12
  // SPDX-License-Identifier: Apache-2.0
13
13
  // Do not edit, auto-generated by @polkadot/dev
14
- (0, _util.detectPackage)(_packageInfo.packageInfo, _packageInfo.packageInfo.path, _detectOther.default);
14
+ (0, _util.detectPackage)(_packageInfo.packageInfo, null, _detectOther.default);
package/detectPackage.js CHANGED
@@ -4,4 +4,4 @@
4
4
  import { detectPackage } from '@polkadot/util';
5
5
  import others from "./detectOther.js";
6
6
  import { packageInfo } from "./packageInfo.js";
7
- detectPackage(packageInfo, packageInfo.path, others);
7
+ detectPackage(packageInfo, null, others);
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./detectPackage.cjs"
21
21
  ],
22
22
  "type": "module",
23
- "version": "7.2.2-9",
23
+ "version": "7.3.2-2",
24
24
  "main": "index.cjs",
25
25
  "module": "index.js",
26
26
  "types": "index.d.ts",
@@ -400,6 +400,6 @@
400
400
  },
401
401
  "dependencies": {
402
402
  "@babel/runtime": "^7.16.7",
403
- "@polkadot/util": "^8.2.3-30"
403
+ "@polkadot/util": "^8.3.1"
404
404
  }
405
405
  }
package/packageInfo.cjs CHANGED
@@ -11,6 +11,6 @@ const packageInfo = {
11
11
  name: '@polkadot/types-codec',
12
12
  path: typeof __dirname === 'string' ? __dirname : 'auto',
13
13
  type: 'cjs',
14
- version: '7.2.2-9'
14
+ version: '7.3.2-2'
15
15
  };
16
16
  exports.packageInfo = packageInfo;
package/packageInfo.js CHANGED
@@ -5,5 +5,5 @@ export const packageInfo = {
5
5
  name: '@polkadot/types-codec',
6
6
  path: new URL('.', import.meta.url).pathname,
7
7
  type: 'esm',
8
- version: '7.2.2-9'
8
+ version: '7.3.2-2'
9
9
  };