@pioneer-platform/helpers 4.0.13 → 4.1.0
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 +12 -0
- package/lib/helpers/asset.d.ts +1 -1
- package/lib/helpers/asset.js +83 -145
- package/lib/helpers/liquidity.js +52 -73
- package/lib/helpers/memo.js +19 -22
- package/lib/helpers/others.js +6 -7
- package/lib/helpers/request.d.ts +1 -1
- package/lib/helpers/request.js +30 -68
- package/lib/helpers/validators.js +7 -8
- package/lib/modules/assetValue.js +171 -258
- package/lib/modules/bigIntArithmetics.js +180 -225
- package/lib/modules/swapKitError.js +6 -25
- package/lib/modules/swapKitNumber.js +10 -30
- package/package.json +18 -15
- package/src/helpers/asset.ts +0 -5
- package/tsconfig.json +1 -1
- package/LICENSE +0 -674
- package/lib/modules/__tests__/assetValue.test.d.ts +0 -1
- package/lib/modules/__tests__/assetValue.test.js +0 -399
- package/lib/modules/__tests__/swapKitNumber.test.d.ts +0 -1
- package/lib/modules/__tests__/swapKitNumber.test.js +0 -425
@@ -1,22 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
3
|
-
var extendStatics = function (d, b) {
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
-
return extendStatics(d, b);
|
8
|
-
};
|
9
|
-
return function (d, b) {
|
10
|
-
if (typeof b !== "function" && b !== null)
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
-
extendStatics(d, b);
|
13
|
-
function __() { this.constructor = d; }
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
-
};
|
16
|
-
})();
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
3
|
exports.SwapKitError = void 0;
|
19
|
-
|
4
|
+
const errorMessages = {
|
20
5
|
/**
|
21
6
|
* Core
|
22
7
|
*/
|
@@ -75,16 +60,12 @@ var errorMessages = {
|
|
75
60
|
*/
|
76
61
|
helpers_number_different_decimals: 99101,
|
77
62
|
};
|
78
|
-
|
79
|
-
|
80
|
-
function SwapKitError(errorKey, sourceError) {
|
81
|
-
var _this = this;
|
63
|
+
class SwapKitError extends Error {
|
64
|
+
constructor(errorKey, sourceError) {
|
82
65
|
console.error(sourceError, { stack: sourceError === null || sourceError === void 0 ? void 0 : sourceError.stack, message: sourceError === null || sourceError === void 0 ? void 0 : sourceError.message });
|
83
66
|
// @ts-ignore
|
84
|
-
|
85
|
-
Object.setPrototypeOf(
|
86
|
-
return _this;
|
67
|
+
super(errorKey, { cause: { code: errorMessages[errorKey], message: errorKey } });
|
68
|
+
Object.setPrototypeOf(this, SwapKitError.prototype);
|
87
69
|
}
|
88
|
-
|
89
|
-
}(Error));
|
70
|
+
}
|
90
71
|
exports.SwapKitError = SwapKitError;
|
@@ -1,37 +1,17 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
3
|
-
var extendStatics = function (d, b) {
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
-
return extendStatics(d, b);
|
8
|
-
};
|
9
|
-
return function (d, b) {
|
10
|
-
if (typeof b !== "function" && b !== null)
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
-
extendStatics(d, b);
|
13
|
-
function __() { this.constructor = d; }
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
-
};
|
16
|
-
})();
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
3
|
exports.SwapKitNumber = void 0;
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
function SwapKitNumber() {
|
24
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
25
|
-
}
|
26
|
-
SwapKitNumber.prototype.eq = function (value) {
|
4
|
+
const bigIntArithmetics_1 = require("./bigIntArithmetics");
|
5
|
+
const DEFAULT_DECIMAL = 8;
|
6
|
+
class SwapKitNumber extends bigIntArithmetics_1.BigIntArithmetics {
|
7
|
+
eq(value) {
|
27
8
|
return this.eqValue(value);
|
28
|
-
}
|
29
|
-
|
9
|
+
}
|
10
|
+
static fromBigInt(value, decimal) {
|
30
11
|
return new SwapKitNumber({
|
31
|
-
decimal
|
32
|
-
value: (0, bigIntArithmetics_1.formatBigIntToSafeValue)({ value
|
12
|
+
decimal,
|
13
|
+
value: (0, bigIntArithmetics_1.formatBigIntToSafeValue)({ value, bigIntDecimal: (0, bigIntArithmetics_1.toMultiplier)(decimal || DEFAULT_DECIMAL), decimal }),
|
33
14
|
});
|
34
|
-
}
|
35
|
-
|
36
|
-
}(bigIntArithmetics_1.BigIntArithmetics));
|
15
|
+
}
|
16
|
+
}
|
37
17
|
exports.SwapKitNumber = SwapKitNumber;
|
package/package.json
CHANGED
@@ -1,25 +1,28 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pioneer-platform/helpers",
|
3
|
-
"version": "4.0
|
3
|
+
"version": "4.1.0",
|
4
4
|
"main": "./lib/index.js",
|
5
5
|
"types": "./lib/index.d.ts",
|
6
|
-
"scripts": {
|
7
|
-
"npm": "npm i",
|
8
|
-
"test": "npm run build && node __tests__/test-module.js",
|
9
|
-
"lint": "prettier --write '**/**/*.ts'",
|
10
|
-
"start": "nodemon --watch 'src/**/*.ts' --exec ts-node __tests__node",
|
11
|
-
"build": "tsc -p .",
|
12
|
-
"prepublish": "npm run build",
|
13
|
-
"refresh": "rm -rf ./node_modules ./package-lock.json && npm install"
|
14
|
-
},
|
15
6
|
"dependencies": {
|
7
|
+
"@coinmasters/core": "^12.0.8",
|
16
8
|
"@coinmasters/tokens": "^3.7.28",
|
17
|
-
"@coinmasters/types": "
|
9
|
+
"@coinmasters/types": "^4.10.1",
|
18
10
|
"@noble/hashes": "^1.4.0",
|
19
|
-
"@pioneer-platform/loggerdog": "^8.
|
11
|
+
"@pioneer-platform/loggerdog": "^8.4.0",
|
20
12
|
"@types/node": "^18.15.11",
|
13
|
+
"ethers": "5.7.2",
|
14
|
+
"ky": "^1.8.0",
|
21
15
|
"ts-node": "^8.10.2",
|
22
|
-
"typescript": "^5.0.
|
16
|
+
"typescript": "^5.0.4"
|
23
17
|
},
|
24
|
-
"gitHead": "
|
25
|
-
|
18
|
+
"gitHead": "aeae28273014ab69b42f22abec159c6693a56c40",
|
19
|
+
"scripts": {
|
20
|
+
"npm": "pnpm i",
|
21
|
+
"test": "pnpm run build && node __tests__/test-module.js",
|
22
|
+
"lint": "prettier --write '**/**/*.ts'",
|
23
|
+
"start": "nodemon --watch 'src/**/*.ts' --exec ts-node __tests__node",
|
24
|
+
"build": "tsc -p .",
|
25
|
+
"prepublish": "pnpm run build",
|
26
|
+
"refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
|
27
|
+
}
|
28
|
+
}
|
package/src/helpers/asset.ts
CHANGED
@@ -85,7 +85,6 @@ export const isGasAsset = ({ chain, symbol }: { chain: Chain; symbol: string })
|
|
85
85
|
case Chain.Ripple:
|
86
86
|
case Chain.Litecoin:
|
87
87
|
case Chain.Dogecoin:
|
88
|
-
case Chain.Binance:
|
89
88
|
case Chain.Ethereum:
|
90
89
|
case Chain.Avalanche:
|
91
90
|
return symbol === chain;
|
@@ -144,7 +143,6 @@ export const getCommonAssetInfo = (
|
|
144
143
|
case Chain.Dash:
|
145
144
|
case Chain.Litecoin:
|
146
145
|
case Chain.Dogecoin:
|
147
|
-
case Chain.Binance:
|
148
146
|
case Chain.Polygon:
|
149
147
|
case Chain.Bitcoin:
|
150
148
|
case Chain.Ethereum:
|
@@ -172,10 +170,7 @@ export const getAssetType = ({ chain, symbol }: { chain: Chain; symbol: string }
|
|
172
170
|
return symbol === 'ATOM' ? 'Native' : Chain.Cosmos;
|
173
171
|
case Chain.Kujira:
|
174
172
|
return symbol === Chain.Kujira ? 'Native' : Chain.Kujira;
|
175
|
-
case Chain.Binance:
|
176
|
-
return symbol === Chain.Binance ? 'Native' : 'BEP2';
|
177
173
|
case Chain.BinanceSmartChain:
|
178
|
-
return symbol === Chain.Binance ? 'Native' : 'BEP20';
|
179
174
|
case Chain.Ethereum:
|
180
175
|
return symbol === Chain.Ethereum ? 'Native' : 'ERC20';
|
181
176
|
case Chain.Avalanche:
|