@injectivelabs/utils 1.16.36 → 1.16.38-alpha.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/dist/cjs/constants-DEbTiKzu.cjs +192 -0
- package/dist/cjs/index.cjs +590 -0
- package/dist/cjs/index.d.cts +279 -0
- package/dist/cjs/package.json +2 -2
- package/dist/cjs/test-utils/index.cjs +161 -0
- package/dist/cjs/test-utils/index.d.cts +218 -0
- package/dist/esm/constants-BxcSsKjm.js +66 -0
- package/dist/esm/index.d.ts +279 -6
- package/dist/esm/index.js +509 -6
- package/dist/esm/package.json +2 -2
- package/dist/esm/test-utils/index.d.ts +218 -2
- package/dist/esm/test-utils/index.js +157 -2
- package/package.json +32 -32
- package/dist/cjs/classes/BigNumber.d.ts +0 -14
- package/dist/cjs/classes/BigNumber.js +0 -33
- package/dist/cjs/classes/BigNumberInBase.d.ts +0 -16
- package/dist/cjs/classes/BigNumberInBase.js +0 -39
- package/dist/cjs/classes/BigNumberInWei.d.ts +0 -16
- package/dist/cjs/classes/BigNumberInWei.js +0 -39
- package/dist/cjs/classes/HttpClient.d.ts +0 -11
- package/dist/cjs/classes/HttpClient.js +0 -39
- package/dist/cjs/classes/HttpRestClient.d.ts +0 -14
- package/dist/cjs/classes/HttpRestClient.js +0 -110
- package/dist/cjs/classes/LocalStorage.d.ts +0 -9
- package/dist/cjs/classes/LocalStorage.js +0 -25
- package/dist/cjs/classes/Status.d.ts +0 -22
- package/dist/cjs/classes/Status.js +0 -61
- package/dist/cjs/classes/StreamManager.d.ts +0 -9
- package/dist/cjs/classes/StreamManager.js +0 -41
- package/dist/cjs/classes/index.d.ts +0 -10
- package/dist/cjs/classes/index.js +0 -60
- package/dist/cjs/constants.d.ts +0 -37
- package/dist/cjs/constants.js +0 -54
- package/dist/cjs/enum.d.ts +0 -8
- package/dist/cjs/enum.js +0 -10
- package/dist/cjs/formatters.d.ts +0 -5
- package/dist/cjs/formatters.js +0 -31
- package/dist/cjs/helpers.d.ts +0 -73
- package/dist/cjs/helpers.js +0 -145
- package/dist/cjs/index.d.ts +0 -6
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/numbers.d.ts +0 -4
- package/dist/cjs/numbers.js +0 -37
- package/dist/cjs/test-utils/index.d.ts +0 -2
- package/dist/cjs/test-utils/index.js +0 -18
- package/dist/cjs/test-utils/mocks/index.d.ts +0 -153
- package/dist/cjs/test-utils/mocks/index.js +0 -106
- package/dist/cjs/test-utils/msgs.d.ts +0 -44
- package/dist/cjs/test-utils/msgs.js +0 -54
- package/dist/cjs/time.d.ts +0 -9
- package/dist/cjs/time.js +0 -41
- package/dist/cjs/types.d.ts +0 -3
- package/dist/cjs/types.js +0 -2
- package/dist/esm/classes/BigNumber.d.ts +0 -14
- package/dist/esm/classes/BigNumber.js +0 -27
- package/dist/esm/classes/BigNumberInBase.d.ts +0 -16
- package/dist/esm/classes/BigNumberInBase.js +0 -33
- package/dist/esm/classes/BigNumberInWei.d.ts +0 -16
- package/dist/esm/classes/BigNumberInWei.js +0 -33
- package/dist/esm/classes/HttpClient.d.ts +0 -11
- package/dist/esm/classes/HttpClient.js +0 -33
- package/dist/esm/classes/HttpRestClient.d.ts +0 -14
- package/dist/esm/classes/HttpRestClient.js +0 -104
- package/dist/esm/classes/LocalStorage.d.ts +0 -9
- package/dist/esm/classes/LocalStorage.js +0 -22
- package/dist/esm/classes/Status.d.ts +0 -22
- package/dist/esm/classes/Status.js +0 -58
- package/dist/esm/classes/StreamManager.d.ts +0 -9
- package/dist/esm/classes/StreamManager.js +0 -38
- package/dist/esm/classes/index.d.ts +0 -10
- package/dist/esm/classes/index.js +0 -10
- package/dist/esm/constants.d.ts +0 -37
- package/dist/esm/constants.js +0 -46
- package/dist/esm/enum.d.ts +0 -8
- package/dist/esm/enum.js +0 -7
- package/dist/esm/formatters.d.ts +0 -5
- package/dist/esm/formatters.js +0 -24
- package/dist/esm/helpers.d.ts +0 -73
- package/dist/esm/helpers.js +0 -100
- package/dist/esm/numbers.d.ts +0 -4
- package/dist/esm/numbers.js +0 -28
- package/dist/esm/test-utils/mocks/index.d.ts +0 -153
- package/dist/esm/test-utils/mocks/index.js +0 -103
- package/dist/esm/test-utils/msgs.d.ts +0 -44
- package/dist/esm/test-utils/msgs.js +0 -47
- package/dist/esm/time.d.ts +0 -9
- package/dist/esm/time.js +0 -27
- package/dist/esm/types.d.ts +0 -3
- package/dist/esm/types.js +0 -1
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import HttpClient from './HttpClient.js';
|
|
2
|
-
import type { AxiosRequestConfig } from 'axios';
|
|
3
|
-
/**
|
|
4
|
-
* @hidden
|
|
5
|
-
*/
|
|
6
|
-
export default class HttpRestClient {
|
|
7
|
-
protected client: HttpClient;
|
|
8
|
-
protected endpoint: string;
|
|
9
|
-
constructor(endpoint: string, options?: Record<string, any>);
|
|
10
|
-
setConfig(config: AxiosRequestConfig): HttpRestClient;
|
|
11
|
-
get<T>(endpoint: string, params?: Record<string, any>): Promise<T>;
|
|
12
|
-
retry<TResponse>(httpCall: Function, retries?: number, delay?: number): Promise<TResponse>;
|
|
13
|
-
post<T>(endpoint: string, params?: Record<string, any>): Promise<T>;
|
|
14
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const axios_1 = __importDefault(require("axios"));
|
|
7
|
-
const http_status_codes_1 = require("http-status-codes");
|
|
8
|
-
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
9
|
-
const HttpClient_js_1 = __importDefault(require("./HttpClient.js"));
|
|
10
|
-
const getErrorMessage = (error, endpoint) => {
|
|
11
|
-
if (!error.response) {
|
|
12
|
-
return `The request to ${endpoint} has failed.`;
|
|
13
|
-
}
|
|
14
|
-
return error.response.data
|
|
15
|
-
? error.response.data.message ||
|
|
16
|
-
error.response.data.statusMessage ||
|
|
17
|
-
error.response.data
|
|
18
|
-
: error.response.statusText;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* @hidden
|
|
22
|
-
*/
|
|
23
|
-
class HttpRestClient {
|
|
24
|
-
client;
|
|
25
|
-
endpoint;
|
|
26
|
-
constructor(endpoint, options = {}) {
|
|
27
|
-
this.client = new HttpClient_js_1.default(endpoint, options);
|
|
28
|
-
this.endpoint = endpoint;
|
|
29
|
-
}
|
|
30
|
-
setConfig(config) {
|
|
31
|
-
this.client.setConfig(config);
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
async get(endpoint, params = {}) {
|
|
35
|
-
try {
|
|
36
|
-
return await this.client.get(endpoint, params);
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
const error = e;
|
|
40
|
-
if (axios_1.default.isAxiosError(error)) {
|
|
41
|
-
if (error.code === 'ECONNABORTED') {
|
|
42
|
-
throw new exceptions_1.HttpRequestException(new Error(error.message), {
|
|
43
|
-
code: http_status_codes_1.StatusCodes.REQUEST_TOO_LONG,
|
|
44
|
-
context: endpoint,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
const message = getErrorMessage(error, endpoint);
|
|
48
|
-
throw new exceptions_1.HttpRequestException(new Error(message), {
|
|
49
|
-
context: endpoint,
|
|
50
|
-
code: error.response
|
|
51
|
-
? error.response.status
|
|
52
|
-
: http_status_codes_1.StatusCodes.BAD_REQUEST,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
throw new exceptions_1.HttpRequestException(new Error(error.message), {
|
|
56
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
57
|
-
context: endpoint,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async retry(httpCall, retries = 3, delay = 1000) {
|
|
62
|
-
const retryHttpCall = async (attempt = 1) => {
|
|
63
|
-
try {
|
|
64
|
-
return (await httpCall());
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
if (e instanceof exceptions_1.HttpRequestException) {
|
|
68
|
-
if (e.code === http_status_codes_1.StatusCodes.REQUEST_TOO_LONG) {
|
|
69
|
-
throw e;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (attempt >= retries) {
|
|
73
|
-
throw e;
|
|
74
|
-
}
|
|
75
|
-
return new Promise((resolve) => setTimeout(() => resolve(retryHttpCall(attempt + 1)), delay * attempt));
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
return retryHttpCall();
|
|
79
|
-
}
|
|
80
|
-
async post(endpoint, params = {}) {
|
|
81
|
-
try {
|
|
82
|
-
return await this.client.post(endpoint, params);
|
|
83
|
-
}
|
|
84
|
-
catch (e) {
|
|
85
|
-
const error = e;
|
|
86
|
-
if (axios_1.default.isAxiosError(error)) {
|
|
87
|
-
if (error.code === 'ECONNABORTED') {
|
|
88
|
-
throw new exceptions_1.HttpRequestException(new Error(error.message), {
|
|
89
|
-
code: http_status_codes_1.StatusCodes.REQUEST_TOO_LONG,
|
|
90
|
-
method: exceptions_1.HttpRequestMethod.Post,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
const message = getErrorMessage(error, endpoint);
|
|
94
|
-
throw new exceptions_1.HttpRequestException(new Error(message), {
|
|
95
|
-
code: error.response
|
|
96
|
-
? error.response.status
|
|
97
|
-
: http_status_codes_1.StatusCodes.BAD_REQUEST,
|
|
98
|
-
context: endpoint,
|
|
99
|
-
contextModule: exceptions_1.HttpRequestMethod.Post,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
throw new exceptions_1.HttpRequestException(new Error(error.message), {
|
|
103
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
104
|
-
context: endpoint,
|
|
105
|
-
contextModule: exceptions_1.HttpRequestMethod.Post,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
exports.default = HttpRestClient;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const store2_1 = require("@bangjelkoski/store2");
|
|
4
|
-
class LocalStorage {
|
|
5
|
-
storage;
|
|
6
|
-
constructor(namespace) {
|
|
7
|
-
this.storage = store2_1.store.namespace(namespace);
|
|
8
|
-
}
|
|
9
|
-
get(key, defaultValue = {}) {
|
|
10
|
-
return this.storage.get(key) || defaultValue;
|
|
11
|
-
}
|
|
12
|
-
has(key) {
|
|
13
|
-
return this.storage.has(key);
|
|
14
|
-
}
|
|
15
|
-
set(key, value) {
|
|
16
|
-
this.storage.set(key, value);
|
|
17
|
-
}
|
|
18
|
-
remove(key) {
|
|
19
|
-
this.storage.remove(key);
|
|
20
|
-
}
|
|
21
|
-
clear() {
|
|
22
|
-
this.storage.clear();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.default = LocalStorage;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { StatusType } from '../enum.js';
|
|
2
|
-
export default class Status {
|
|
3
|
-
status: string;
|
|
4
|
-
constructor(status?: StatusType);
|
|
5
|
-
get(): string;
|
|
6
|
-
set(status: StatusType): void;
|
|
7
|
-
is(status: StatusType): boolean;
|
|
8
|
-
isLoading(): boolean;
|
|
9
|
-
isNotLoading(): boolean;
|
|
10
|
-
isCompleted(): boolean;
|
|
11
|
-
isConfirmed(): boolean;
|
|
12
|
-
isIdle(): boolean;
|
|
13
|
-
isError(): boolean;
|
|
14
|
-
setLoading(): void;
|
|
15
|
-
setCompleted(): void;
|
|
16
|
-
setConfirmed(): void;
|
|
17
|
-
setError(): void;
|
|
18
|
-
setIdle(): void;
|
|
19
|
-
toggle(): void;
|
|
20
|
-
toString(): string;
|
|
21
|
-
valueOf(): string;
|
|
22
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const enum_js_1 = require("../enum.js");
|
|
4
|
-
class Status {
|
|
5
|
-
status;
|
|
6
|
-
constructor(status = enum_js_1.StatusType.Idle) {
|
|
7
|
-
this.status = status;
|
|
8
|
-
}
|
|
9
|
-
get() {
|
|
10
|
-
return this.status;
|
|
11
|
-
}
|
|
12
|
-
set(status) {
|
|
13
|
-
this.status = status;
|
|
14
|
-
}
|
|
15
|
-
is(status) {
|
|
16
|
-
return this.status === status;
|
|
17
|
-
}
|
|
18
|
-
isLoading() {
|
|
19
|
-
return this.is(enum_js_1.StatusType.Loading);
|
|
20
|
-
}
|
|
21
|
-
isNotLoading() {
|
|
22
|
-
return !this.is(enum_js_1.StatusType.Loading);
|
|
23
|
-
}
|
|
24
|
-
isCompleted() {
|
|
25
|
-
return this.is(enum_js_1.StatusType.Completed);
|
|
26
|
-
}
|
|
27
|
-
isConfirmed() {
|
|
28
|
-
return this.is(enum_js_1.StatusType.Confirmed);
|
|
29
|
-
}
|
|
30
|
-
isIdle() {
|
|
31
|
-
return this.is(enum_js_1.StatusType.Idle);
|
|
32
|
-
}
|
|
33
|
-
isError() {
|
|
34
|
-
return this.is(enum_js_1.StatusType.Error);
|
|
35
|
-
}
|
|
36
|
-
setLoading() {
|
|
37
|
-
this.set(enum_js_1.StatusType.Loading);
|
|
38
|
-
}
|
|
39
|
-
setCompleted() {
|
|
40
|
-
this.set(enum_js_1.StatusType.Completed);
|
|
41
|
-
}
|
|
42
|
-
setConfirmed() {
|
|
43
|
-
this.set(enum_js_1.StatusType.Confirmed);
|
|
44
|
-
}
|
|
45
|
-
setError() {
|
|
46
|
-
this.set(enum_js_1.StatusType.Error);
|
|
47
|
-
}
|
|
48
|
-
setIdle() {
|
|
49
|
-
this.set(enum_js_1.StatusType.Idle);
|
|
50
|
-
}
|
|
51
|
-
toggle() {
|
|
52
|
-
this.set(this.status === enum_js_1.StatusType.Idle ? enum_js_1.StatusType.Loading : enum_js_1.StatusType.Idle);
|
|
53
|
-
}
|
|
54
|
-
toString() {
|
|
55
|
-
return this.get();
|
|
56
|
-
}
|
|
57
|
-
valueOf() {
|
|
58
|
-
return this.get();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.default = Status;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class StreamManager {
|
|
4
|
-
streams = new Map();
|
|
5
|
-
set(stream, streamKey) {
|
|
6
|
-
if (this.streams.has(streamKey)) {
|
|
7
|
-
throw new Error(`Stream ${streamKey} already exists`);
|
|
8
|
-
}
|
|
9
|
-
this.streams.set(streamKey, stream);
|
|
10
|
-
}
|
|
11
|
-
get(streamKey) {
|
|
12
|
-
if (!this.streams.has(streamKey)) {
|
|
13
|
-
throw new Error(`Stream ${streamKey} is not found`);
|
|
14
|
-
}
|
|
15
|
-
return this.streams.get(streamKey);
|
|
16
|
-
}
|
|
17
|
-
exists(streamKey) {
|
|
18
|
-
return this.streams.has(streamKey);
|
|
19
|
-
}
|
|
20
|
-
cancelAll() {
|
|
21
|
-
this.streams.forEach((stream) => {
|
|
22
|
-
stream.cancel();
|
|
23
|
-
});
|
|
24
|
-
this.streams = new Map();
|
|
25
|
-
}
|
|
26
|
-
cancel(streamKey) {
|
|
27
|
-
if (!this.streams.has(streamKey)) {
|
|
28
|
-
throw new Error(`Stream ${streamKey} is not found`);
|
|
29
|
-
}
|
|
30
|
-
this.streams.get(streamKey).cancel();
|
|
31
|
-
this.streams.delete(streamKey);
|
|
32
|
-
}
|
|
33
|
-
cancelIfExists(streamKey) {
|
|
34
|
-
if (!this.streams.has(streamKey)) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
this.streams.get(streamKey).cancel();
|
|
38
|
-
this.streams.delete(streamKey);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.default = StreamManager;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Status from './Status.js';
|
|
2
|
-
import { StatusType } from '../enum.js';
|
|
3
|
-
import HttpClient from './HttpClient.js';
|
|
4
|
-
import LocalStorage from './LocalStorage.js';
|
|
5
|
-
import StreamManager from './StreamManager.js';
|
|
6
|
-
import BigNumberInWei from './BigNumberInWei.js';
|
|
7
|
-
import HttpRestClient from './HttpRestClient.js';
|
|
8
|
-
import BigNumberInBase from './BigNumberInBase.js';
|
|
9
|
-
import { toBigNumber, toChainFormat, toHumanReadable, default as BigNumber } from './BigNumber.js';
|
|
10
|
-
export { Status, BigNumber, HttpClient, StatusType, toBigNumber, LocalStorage, StreamManager, toChainFormat, BigNumberInWei, HttpRestClient, toHumanReadable, BigNumberInBase, };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.BigNumberInBase = exports.toHumanReadable = exports.HttpRestClient = exports.BigNumberInWei = exports.toChainFormat = exports.StreamManager = exports.LocalStorage = exports.toBigNumber = exports.StatusType = exports.HttpClient = exports.BigNumber = exports.Status = void 0;
|
|
40
|
-
const Status_js_1 = __importDefault(require("./Status.js"));
|
|
41
|
-
exports.Status = Status_js_1.default;
|
|
42
|
-
const enum_js_1 = require("../enum.js");
|
|
43
|
-
Object.defineProperty(exports, "StatusType", { enumerable: true, get: function () { return enum_js_1.StatusType; } });
|
|
44
|
-
const HttpClient_js_1 = __importDefault(require("./HttpClient.js"));
|
|
45
|
-
exports.HttpClient = HttpClient_js_1.default;
|
|
46
|
-
const LocalStorage_js_1 = __importDefault(require("./LocalStorage.js"));
|
|
47
|
-
exports.LocalStorage = LocalStorage_js_1.default;
|
|
48
|
-
const StreamManager_js_1 = __importDefault(require("./StreamManager.js"));
|
|
49
|
-
exports.StreamManager = StreamManager_js_1.default;
|
|
50
|
-
const BigNumberInWei_js_1 = __importDefault(require("./BigNumberInWei.js"));
|
|
51
|
-
exports.BigNumberInWei = BigNumberInWei_js_1.default;
|
|
52
|
-
const HttpRestClient_js_1 = __importDefault(require("./HttpRestClient.js"));
|
|
53
|
-
exports.HttpRestClient = HttpRestClient_js_1.default;
|
|
54
|
-
const BigNumberInBase_js_1 = __importDefault(require("./BigNumberInBase.js"));
|
|
55
|
-
exports.BigNumberInBase = BigNumberInBase_js_1.default;
|
|
56
|
-
const BigNumber_js_1 = __importStar(require("./BigNumber.js"));
|
|
57
|
-
Object.defineProperty(exports, "toBigNumber", { enumerable: true, get: function () { return BigNumber_js_1.toBigNumber; } });
|
|
58
|
-
Object.defineProperty(exports, "toChainFormat", { enumerable: true, get: function () { return BigNumber_js_1.toChainFormat; } });
|
|
59
|
-
Object.defineProperty(exports, "toHumanReadable", { enumerable: true, get: function () { return BigNumber_js_1.toHumanReadable; } });
|
|
60
|
-
Object.defineProperty(exports, "BigNumber", { enumerable: true, get: function () { return BigNumber_js_1.default; } });
|
package/dist/cjs/constants.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
2
|
-
export declare const INJ_DENOM = "inj";
|
|
3
|
-
export declare const INJECTIVE_DENOM = "inj";
|
|
4
|
-
export declare const DEFAULT_FEE_DENOM = "inj";
|
|
5
|
-
export declare const DEFAULT_GAS_LIMIT = 400000;
|
|
6
|
-
export declare const DEFAULT_IBC_GAS_LIMIT = 300000;
|
|
7
|
-
export declare const DEFAULT_GAS_PRICE = 160000000;
|
|
8
|
-
export declare const DEFAULT_EXCHANGE_LIMIT = 200000;
|
|
9
|
-
export declare const DEFAULT_BRIDGE_FEE_DENOM = "inj";
|
|
10
|
-
export declare const DEFAULT_BRIDGE_FEE_PRICE = "160000000";
|
|
11
|
-
export declare const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000";
|
|
12
|
-
export declare const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 120;
|
|
13
|
-
export declare const DEFAULT_BLOCK_TIME_IN_SECONDS = 0.7;
|
|
14
|
-
/**
|
|
15
|
-
* Default timeout for transaction block inclusion polling.
|
|
16
|
-
*
|
|
17
|
-
* Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms
|
|
18
|
-
*/
|
|
19
|
-
export declare const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS: number;
|
|
20
|
-
export declare const DEFAULT_TIMESTAMP_TIMEOUT_MS: number;
|
|
21
|
-
export declare const getDefaultStdFee: () => {
|
|
22
|
-
amount: {
|
|
23
|
-
amount: string;
|
|
24
|
-
denom: string;
|
|
25
|
-
}[];
|
|
26
|
-
gas: string;
|
|
27
|
-
payer: string;
|
|
28
|
-
granter: string;
|
|
29
|
-
feePayer: string;
|
|
30
|
-
};
|
|
31
|
-
export declare const DEFAULT_STD_FEE_BY_DENOM: (denom?: string) => {
|
|
32
|
-
amount: {
|
|
33
|
-
denom: string;
|
|
34
|
-
amount: string;
|
|
35
|
-
}[];
|
|
36
|
-
gas: string;
|
|
37
|
-
};
|
package/dist/cjs/constants.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEFAULT_STD_FEE_BY_DENOM = exports.getDefaultStdFee = exports.DEFAULT_TIMESTAMP_TIMEOUT_MS = exports.DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = exports.DEFAULT_BLOCK_TIME_IN_SECONDS = exports.DEFAULT_BLOCK_TIMEOUT_HEIGHT = exports.DEFAULT_BRIDGE_FEE_AMOUNT = exports.DEFAULT_BRIDGE_FEE_PRICE = exports.DEFAULT_BRIDGE_FEE_DENOM = exports.DEFAULT_EXCHANGE_LIMIT = exports.DEFAULT_GAS_PRICE = exports.DEFAULT_IBC_GAS_LIMIT = exports.DEFAULT_GAS_LIMIT = exports.DEFAULT_FEE_DENOM = exports.INJECTIVE_DENOM = exports.INJ_DENOM = exports.ZERO_ADDRESS = void 0;
|
|
7
|
-
const BigNumber_js_1 = __importDefault(require("./classes/BigNumber.js"));
|
|
8
|
-
exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
9
|
-
exports.INJ_DENOM = 'inj';
|
|
10
|
-
exports.INJECTIVE_DENOM = 'inj';
|
|
11
|
-
exports.DEFAULT_FEE_DENOM = 'inj';
|
|
12
|
-
exports.DEFAULT_GAS_LIMIT = 400000;
|
|
13
|
-
exports.DEFAULT_IBC_GAS_LIMIT = 300000;
|
|
14
|
-
exports.DEFAULT_GAS_PRICE = 160000000;
|
|
15
|
-
exports.DEFAULT_EXCHANGE_LIMIT = 200000;
|
|
16
|
-
exports.DEFAULT_BRIDGE_FEE_DENOM = 'inj';
|
|
17
|
-
exports.DEFAULT_BRIDGE_FEE_PRICE = '160000000';
|
|
18
|
-
exports.DEFAULT_BRIDGE_FEE_AMOUNT = '200000000000000';
|
|
19
|
-
exports.DEFAULT_BLOCK_TIMEOUT_HEIGHT = 120;
|
|
20
|
-
exports.DEFAULT_BLOCK_TIME_IN_SECONDS = 0.7;
|
|
21
|
-
/**
|
|
22
|
-
* Default timeout for transaction block inclusion polling.
|
|
23
|
-
*
|
|
24
|
-
* Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms
|
|
25
|
-
*/
|
|
26
|
-
exports.DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = Math.floor(exports.DEFAULT_BLOCK_TIMEOUT_HEIGHT * exports.DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
|
|
27
|
-
exports.DEFAULT_TIMESTAMP_TIMEOUT_MS = 60 * 1000 * 3;
|
|
28
|
-
const getDefaultStdFee = () => ({
|
|
29
|
-
amount: [
|
|
30
|
-
{
|
|
31
|
-
amount: new BigNumber_js_1.default(exports.DEFAULT_GAS_LIMIT)
|
|
32
|
-
.times(exports.DEFAULT_GAS_PRICE)
|
|
33
|
-
.toString(),
|
|
34
|
-
denom: 'inj',
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
gas: exports.DEFAULT_GAS_LIMIT.toString(),
|
|
38
|
-
payer: '',
|
|
39
|
-
granter: '',
|
|
40
|
-
feePayer: '',
|
|
41
|
-
});
|
|
42
|
-
exports.getDefaultStdFee = getDefaultStdFee;
|
|
43
|
-
const DEFAULT_STD_FEE_BY_DENOM = (denom = 'inj') => ({
|
|
44
|
-
amount: [
|
|
45
|
-
{
|
|
46
|
-
denom,
|
|
47
|
-
amount: new BigNumber_js_1.default(exports.DEFAULT_GAS_LIMIT)
|
|
48
|
-
.times(exports.DEFAULT_GAS_PRICE)
|
|
49
|
-
.toString(),
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
gas: exports.DEFAULT_GAS_LIMIT.toString(),
|
|
53
|
-
});
|
|
54
|
-
exports.DEFAULT_STD_FEE_BY_DENOM = DEFAULT_STD_FEE_BY_DENOM;
|
package/dist/cjs/enum.d.ts
DELETED
package/dist/cjs/enum.js
DELETED
package/dist/cjs/formatters.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AccountAddress } from '@injectivelabs/ts-types';
|
|
2
|
-
export declare const formatWalletAddress: (address: AccountAddress, substrLength?: number) => string;
|
|
3
|
-
export declare const toPascalCase: (str: string) => string;
|
|
4
|
-
export declare const snakeToPascal: (str: string) => string;
|
|
5
|
-
export declare const capitalize: (str: string) => string;
|
package/dist/cjs/formatters.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.capitalize = exports.snakeToPascal = exports.toPascalCase = exports.formatWalletAddress = void 0;
|
|
4
|
-
const formatWalletAddress = (address, substrLength = 6) => {
|
|
5
|
-
if (address.length <= 10) {
|
|
6
|
-
return address;
|
|
7
|
-
}
|
|
8
|
-
return `${address.slice(0, substrLength)}...${address.slice(address.length - substrLength, address.length)}`;
|
|
9
|
-
};
|
|
10
|
-
exports.formatWalletAddress = formatWalletAddress;
|
|
11
|
-
const toPascalCase = (str) => {
|
|
12
|
-
return `${str}`
|
|
13
|
-
.toLowerCase()
|
|
14
|
-
.replace(new RegExp(/[-_]+/, 'g'), ' ')
|
|
15
|
-
.replace(new RegExp(/[^\w\s]/, 'g'), '')
|
|
16
|
-
.replace(new RegExp(/\s+(.)(\w*)/, 'g'), (_$1, $2, $3) => `${$2.toUpperCase() + $3}`)
|
|
17
|
-
.replace(new RegExp(/\w/), (s) => s.toUpperCase());
|
|
18
|
-
};
|
|
19
|
-
exports.toPascalCase = toPascalCase;
|
|
20
|
-
const snakeToPascal = (str) => {
|
|
21
|
-
return str
|
|
22
|
-
.split('/')
|
|
23
|
-
.map((snake) => snake
|
|
24
|
-
.split('_')
|
|
25
|
-
.map((substr) => substr.charAt(0).toUpperCase() + substr.slice(1))
|
|
26
|
-
.join(''))
|
|
27
|
-
.join('/');
|
|
28
|
-
};
|
|
29
|
-
exports.snakeToPascal = snakeToPascal;
|
|
30
|
-
const capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
|
31
|
-
exports.capitalize = capitalize;
|
package/dist/cjs/helpers.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { Awaited } from './types.js';
|
|
2
|
-
export declare const sleep: (timeout: number) => Promise<void>;
|
|
3
|
-
/**
|
|
4
|
-
* When we want to execute the promises in batch
|
|
5
|
-
*/
|
|
6
|
-
export declare const awaitAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>) => Promise<Awaited<S>[]>;
|
|
7
|
-
/**
|
|
8
|
-
* When we want to execute the promises one by one
|
|
9
|
-
* and not all in batch as with await Promise.all()
|
|
10
|
-
*/
|
|
11
|
-
export declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>) => Promise<S[]>;
|
|
12
|
-
export declare const splitArrayToChunksThrow: <T>({ array, filter, chunkSize, }: {
|
|
13
|
-
array: Array<T>;
|
|
14
|
-
chunkSize: number;
|
|
15
|
-
filter?: (item: T) => boolean;
|
|
16
|
-
}) => T[][];
|
|
17
|
-
export declare const splitArrayToChunks: <T>({ array, filter, chunkSize, }: {
|
|
18
|
-
array: Array<T>;
|
|
19
|
-
chunkSize: number;
|
|
20
|
-
filter?: (item: T) => boolean;
|
|
21
|
-
}) => T[][];
|
|
22
|
-
export declare const getStdFeeForToken: (token?: {
|
|
23
|
-
denom: string;
|
|
24
|
-
decimals: number;
|
|
25
|
-
}, gasPrice?: string, gasLimit?: string) => {
|
|
26
|
-
amount: {
|
|
27
|
-
denom: string;
|
|
28
|
-
amount: string;
|
|
29
|
-
}[];
|
|
30
|
-
gas: string;
|
|
31
|
-
};
|
|
32
|
-
export declare const getStdFeeFromObject: (args?: {
|
|
33
|
-
gas?: string | number;
|
|
34
|
-
payer?: string;
|
|
35
|
-
granter?: string;
|
|
36
|
-
gasPrice?: string | number;
|
|
37
|
-
feePayer?: string;
|
|
38
|
-
}) => {
|
|
39
|
-
amount: {
|
|
40
|
-
denom: string;
|
|
41
|
-
amount: string;
|
|
42
|
-
}[];
|
|
43
|
-
gas: string;
|
|
44
|
-
payer: string | undefined; /** for Web3Gateway fee delegation */
|
|
45
|
-
granter: string | undefined;
|
|
46
|
-
feePayer: string | undefined;
|
|
47
|
-
};
|
|
48
|
-
export declare const getStdFeeFromString: (gasPrice: string) => {
|
|
49
|
-
amount: {
|
|
50
|
-
denom: string;
|
|
51
|
-
amount: string;
|
|
52
|
-
}[];
|
|
53
|
-
gas: string;
|
|
54
|
-
payer: string | undefined; /** for Web3Gateway fee delegation */
|
|
55
|
-
granter: string | undefined;
|
|
56
|
-
feePayer: string | undefined;
|
|
57
|
-
};
|
|
58
|
-
export declare const getStdFee: (args?: string | {
|
|
59
|
-
payer?: string;
|
|
60
|
-
granter?: string;
|
|
61
|
-
feePayer?: string;
|
|
62
|
-
gas?: string | number;
|
|
63
|
-
gasPrice?: string | number;
|
|
64
|
-
}) => {
|
|
65
|
-
amount: {
|
|
66
|
-
denom: string;
|
|
67
|
-
amount: string;
|
|
68
|
-
}[];
|
|
69
|
-
gas: string;
|
|
70
|
-
payer: string | undefined; /** for Web3Gateway fee delegation */
|
|
71
|
-
granter: string | undefined;
|
|
72
|
-
feePayer: string | undefined;
|
|
73
|
-
};
|