@pioneer-platform/helpers 4.2.0 → 4.4.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.
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SwapKitError = void 0;
4
+ const errorMessages = {
5
+ /**
6
+ * Core
7
+ */
8
+ core_wallet_connection_not_found: 10001,
9
+ core_estimated_max_spendable_chain_not_supported: 10002,
10
+ core_extend_error: 10003,
11
+ core_inbound_data_not_found: 10004,
12
+ core_approve_asset_address_or_from_not_found: 10005,
13
+ core_chain_halted: 10099,
14
+ /**
15
+ * Core - Wallet Connection
16
+ */
17
+ core_wallet_xdefi_not_installed: 10101,
18
+ core_wallet_evmwallet_not_installed: 10102,
19
+ core_wallet_walletconnect_not_installed: 10103,
20
+ core_wallet_keystore_not_installed: 10104,
21
+ core_wallet_ledger_not_installed: 10105,
22
+ core_wallet_trezor_not_installed: 10106,
23
+ core_wallet_keplr_not_installed: 10107,
24
+ core_wallet_okx_not_installed: 10108,
25
+ core_wallet_keepkey_not_installed: 10109,
26
+ /**
27
+ * Core - Swap
28
+ */
29
+ core_swap_invalid_params: 10200,
30
+ core_swap_route_not_complete: 10201,
31
+ core_swap_asset_not_recognized: 10202,
32
+ core_swap_contract_not_found: 10203,
33
+ core_swap_route_transaction_not_found: 10204,
34
+ core_swap_contract_not_supported: 10205,
35
+ core_swap_quote_mode_not_supported: 10207,
36
+ /**
37
+ * Core - Transaction
38
+ */
39
+ core_transaction_deposit_error: 10301,
40
+ core_transaction_create_liquidity_rune_error: 10302,
41
+ core_transaction_create_liquidity_asset_error: 10303,
42
+ core_transaction_create_liquidity_invalid_params: 10304,
43
+ core_transaction_add_liquidity_invalid_params: 10305,
44
+ core_transaction_add_liquidity_no_rune_address: 10306,
45
+ core_transaction_add_liquidity_rune_error: 10307,
46
+ core_transaction_add_liquidity_asset_error: 10308,
47
+ core_transaction_withdraw_error: 10309,
48
+ core_transaction_deposit_to_pool_error: 10310,
49
+ core_transaction_deposit_insufficient_funds_error: 10311,
50
+ core_transaction_deposit_gas_error: 10312,
51
+ core_transaction_invalid_sender_address: 10313,
52
+ core_transaction_deposit_server_error: 10314,
53
+ core_swap_transaction_error: 10400,
54
+ /**
55
+ * Wallets
56
+ */
57
+ wallet_ledger_connection_error: 20001,
58
+ /**
59
+ * Helpers
60
+ */
61
+ helpers_number_different_decimals: 99101,
62
+ };
63
+ class SwapKitError extends Error {
64
+ constructor(errorKey, sourceError) {
65
+ console.error(sourceError, { stack: sourceError === null || sourceError === void 0 ? void 0 : sourceError.stack, message: sourceError === null || sourceError === void 0 ? void 0 : sourceError.message });
66
+ // @ts-ignore
67
+ super(errorKey, { cause: { code: errorMessages[errorKey], message: errorKey } });
68
+ Object.setPrototypeOf(this, SwapKitError.prototype);
69
+ }
70
+ }
71
+ exports.SwapKitError = SwapKitError;
@@ -0,0 +1,6 @@
1
+ import { BigIntArithmetics } from './bigIntArithmetics';
2
+ export type SwapKitValueType = BigIntArithmetics | string | number;
3
+ export declare class SwapKitNumber extends BigIntArithmetics {
4
+ eq(value: SwapKitValueType): boolean;
5
+ static fromBigInt(value: bigint, decimal?: number): SwapKitNumber;
6
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SwapKitNumber = void 0;
4
+ const bigIntArithmetics_1 = require("./bigIntArithmetics");
5
+ const DEFAULT_DECIMAL = 8;
6
+ class SwapKitNumber extends bigIntArithmetics_1.BigIntArithmetics {
7
+ eq(value) {
8
+ return this.eqValue(value);
9
+ }
10
+ static fromBigInt(value, decimal) {
11
+ return new SwapKitNumber({
12
+ decimal,
13
+ value: (0, bigIntArithmetics_1.formatBigIntToSafeValue)({ value, bigIntDecimal: (0, bigIntArithmetics_1.toMultiplier)(decimal || DEFAULT_DECIMAL), decimal }),
14
+ });
15
+ }
16
+ }
17
+ exports.SwapKitNumber = SwapKitNumber;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/helpers",
3
- "version": "4.2.0",
3
+ "version": "4.4.0",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  "@coinmasters/tokens": "^3.7.28",
18
18
  "@coinmasters/types": "^4.10.1",
19
19
  "@noble/hashes": "^1.4.0",
20
- "@pioneer-platform/loggerdog": "^8.5.0",
20
+ "@pioneer-platform/loggerdog": "^8.7.0",
21
21
  "@types/node": "^18.15.11",
22
22
  "ethers": "5.7.2",
23
23
  "ky": "^1.8.0",