@autonomys/auto-utils 0.6.6 → 0.6.8
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/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/constants/number.d.ts +2 -0
- package/dist/constants/number.d.ts.map +1 -0
- package/dist/constants/number.js +4 -0
- package/dist/number.d.ts +1 -0
- package/dist/number.d.ts.map +1 -1
- package/dist/number.js +12 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAEA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAEA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
package/dist/constants/index.js
CHANGED
|
@@ -17,5 +17,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
__exportStar(require("./domain"), exports);
|
|
19
19
|
__exportStar(require("./network"), exports);
|
|
20
|
+
__exportStar(require("./number"), exports);
|
|
20
21
|
__exportStar(require("./token"), exports);
|
|
21
22
|
__exportStar(require("./wallet"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/constants/number.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAAY,CAAA"}
|
package/dist/number.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const parseTokenAmount: (amount: string | bigint, decimals?: number) => number | bigint;
|
|
2
2
|
export declare const formatTokenAmount: (amount: number | bigint, decimals?: number) => number | bigint;
|
|
3
|
+
export declare const formatSpacePledged: (value: bigint, decimals?: number) => string;
|
|
3
4
|
//# sourceMappingURL=number.d.ts.map
|
package/dist/number.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,WACnB,MAAM,GAAG,MAAM,aACb,MAAM,oBAIjB,CAAA;AAED,eAAO,MAAM,iBAAiB,WACpB,MAAM,GAAG,MAAM,aACb,MAAM,oBAIjB,CAAA;AAED,eAAO,MAAM,kBAAkB,UAAW,MAAM,8BAU/C,CAAA"}
|
package/dist/number.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatTokenAmount = exports.parseTokenAmount = void 0;
|
|
3
|
+
exports.formatSpacePledged = exports.formatTokenAmount = exports.parseTokenAmount = void 0;
|
|
4
|
+
const number_1 = require("./constants/number");
|
|
4
5
|
const token_1 = require("./constants/token");
|
|
5
6
|
const parseTokenAmount = (amount, decimals = token_1.DEFAULT_TOKEN_DECIMALS) => {
|
|
6
7
|
if (typeof amount === 'bigint')
|
|
@@ -14,3 +15,13 @@ const formatTokenAmount = (amount, decimals = token_1.DEFAULT_TOKEN_DECIMALS) =>
|
|
|
14
15
|
return amount * Math.pow(10, decimals);
|
|
15
16
|
};
|
|
16
17
|
exports.formatTokenAmount = formatTokenAmount;
|
|
18
|
+
const formatSpacePledged = (value, decimals = 2) => {
|
|
19
|
+
if (typeof value !== 'bigint' || value === number_1.BIGINT_ZERO)
|
|
20
|
+
return '0 Bytes';
|
|
21
|
+
const k = 1024;
|
|
22
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
23
|
+
const sizes = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
|
24
|
+
const i = Math.floor(Math.log(Number(value)) / Math.log(k));
|
|
25
|
+
return (Number(value) / Math.pow(k, i)).toFixed(dm) + ' ' + sizes[i];
|
|
26
|
+
};
|
|
27
|
+
exports.formatSpacePledged = formatSpacePledged;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomys/auto-utils",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@polkadot/api": "^
|
|
18
|
-
"@polkadot/extension-dapp": "^0.
|
|
17
|
+
"@polkadot/api": "^13.1.1",
|
|
18
|
+
"@polkadot/extension-dapp": "^0.54.1",
|
|
19
19
|
"fs": "^0.0.1-security"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@polkadot/types-codec": "^
|
|
22
|
+
"@polkadot/types-codec": "^13.1.1",
|
|
23
23
|
"@types/jest": "^29.5.12",
|
|
24
24
|
"eslint": "^8.57.0",
|
|
25
25
|
"jest": "^29.7.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"browser": {
|
|
39
39
|
"fs": false
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "509bb6d337ca6c0f4da389cd342f1b58be57cb7e"
|
|
42
42
|
}
|