@injectivelabs/utils 1.20.14 → 1.20.16
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/BigNumber-B-r__Egf.d.cts +18 -0
- package/dist/cjs/BigNumber-DbDA4_xA.cjs +51 -0
- package/dist/cjs/BigNumberInBase-CVKbAXw6.cjs +84 -0
- package/dist/cjs/BigNumberInWei-BMQpZg3S.d.cts +36 -0
- package/dist/cjs/HttpRestClient-C0p7w6ht.d.cts +29 -0
- package/dist/cjs/HttpRestClient-C761J3nA.cjs +138 -0
- package/dist/cjs/LocalStorage-DRuofBv_.cjs +35 -0
- package/dist/cjs/LocalStorage-Dqm913-z.d.cts +12 -0
- package/dist/cjs/Status-C1EkdFOa.cjs +84 -0
- package/dist/cjs/Status-lj0Wyw_3.d.cts +34 -0
- package/dist/cjs/big-number.cjs +9 -0
- package/dist/cjs/big-number.d.cts +3 -0
- package/dist/cjs/chunk-CbDLau6x.cjs +34 -0
- package/dist/cjs/constants-BRub-WIk.d.cts +42 -0
- package/dist/cjs/{constants-BFjeP4ow.cjs → constants-BdaegCnI.cjs} +3 -84
- package/dist/cjs/constants.cjs +22 -0
- package/dist/cjs/constants.d.cts +2 -0
- package/dist/cjs/defineProperty-CImP5zIM.cjs +49 -0
- package/dist/cjs/formatters-CBhRviK1.cjs +42 -0
- package/dist/cjs/formatters-lY6KvxzC.d.cts +9 -0
- package/dist/cjs/formatters.cjs +6 -0
- package/dist/cjs/formatters.d.cts +2 -0
- package/dist/cjs/helpers-BW4oKV4e.cjs +144 -0
- package/dist/cjs/helpers-BmH3TkaY.d.cts +88 -0
- package/dist/cjs/helpers.cjs +13 -0
- package/dist/cjs/helpers.d.cts +2 -0
- package/dist/cjs/http.cjs +5 -0
- package/dist/cjs/http.d.cts +2 -0
- package/dist/cjs/index.cjs +47 -512
- package/dist/cjs/index.d.cts +10 -269
- package/dist/cjs/light.cjs +180 -0
- package/dist/cjs/light.d.cts +93 -0
- package/dist/cjs/numbers-BRXzNJ1I.cjs +39 -0
- package/dist/cjs/numbers-CVJM893V.d.cts +8 -0
- package/dist/cjs/numbers.cjs +6 -0
- package/dist/cjs/numbers.d.cts +3 -0
- package/dist/cjs/status.cjs +5 -0
- package/dist/cjs/status.d.cts +2 -0
- package/dist/cjs/storage.cjs +4 -0
- package/dist/cjs/storage.d.cts +2 -0
- package/dist/cjs/test-utils/index.cjs +4 -2
- package/dist/cjs/time-CPSnQ8xf.cjs +74 -0
- package/dist/cjs/time-DQwWSv4e.d.cts +13 -0
- package/dist/cjs/time.cjs +11 -0
- package/dist/cjs/time.d.cts +3 -0
- package/dist/esm/BigNumber-DUr2WQBK.js +26 -0
- package/dist/esm/BigNumber-jKUujKpO.d.ts +18 -0
- package/dist/esm/BigNumberInBase-Dcx5wyxY.js +73 -0
- package/dist/esm/BigNumberInWei-JtQuFET_.d.ts +36 -0
- package/dist/esm/HttpRestClient-B-UvB9KB.d.ts +29 -0
- package/dist/esm/HttpRestClient-CsKkn8lo.js +125 -0
- package/dist/esm/LocalStorage-Cpe5wG8z.js +28 -0
- package/dist/esm/LocalStorage-CyTj3H1T.d.ts +12 -0
- package/dist/esm/Status-C6A6ZtpL.d.ts +34 -0
- package/dist/esm/Status-eHtiFREA.js +73 -0
- package/dist/esm/big-number.d.ts +3 -0
- package/dist/esm/big-number.js +4 -0
- package/dist/esm/{constants-BY74CT5-.js → constants-0w1sGXWU.js} +2 -25
- package/dist/esm/constants-BPYHMKzA.d.ts +42 -0
- package/dist/esm/constants.d.ts +2 -0
- package/dist/esm/constants.js +4 -0
- package/dist/esm/defineProperty-Zp25b8Cm.js +43 -0
- package/dist/esm/formatters-QUaa2UZY.js +18 -0
- package/dist/esm/formatters-v2reo54H.d.ts +9 -0
- package/dist/esm/formatters.d.ts +2 -0
- package/dist/esm/formatters.js +3 -0
- package/dist/esm/helpers-BZ1LFB-6.d.ts +88 -0
- package/dist/esm/helpers-BsGkkq54.js +91 -0
- package/dist/esm/helpers.d.ts +2 -0
- package/dist/esm/helpers.js +5 -0
- package/dist/esm/http.d.ts +2 -0
- package/dist/esm/http.js +4 -0
- package/dist/esm/index.d.ts +10 -269
- package/dist/esm/index.js +11 -474
- package/dist/esm/light.d.ts +93 -0
- package/dist/esm/light.js +151 -0
- package/dist/esm/numbers-Bnbd75cb.d.ts +8 -0
- package/dist/esm/numbers-Dh5x3_mA.js +22 -0
- package/dist/esm/numbers.d.ts +3 -0
- package/dist/esm/numbers.js +4 -0
- package/dist/esm/status.d.ts +2 -0
- package/dist/esm/status.js +4 -0
- package/dist/esm/storage.d.ts +2 -0
- package/dist/esm/storage.js +4 -0
- package/dist/esm/test-utils/index.js +2 -1
- package/dist/esm/time-BBEhFnvo.js +27 -0
- package/dist/esm/time-DJirA2PE.d.ts +13 -0
- package/dist/esm/time.d.ts +3 -0
- package/dist/esm/time.js +4 -0
- package/package.json +204 -4
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
|
|
3
|
+
//#region src/classes/BigNumber.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts a value to BigNumber if it isn't already
|
|
7
|
+
*/
|
|
8
|
+
declare const toBigNumber: (value: BigNumber | string | number) => BigNumber;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals
|
|
11
|
+
*/
|
|
12
|
+
declare const toChainFormat: (value: BigNumber | string | number, decimals?: number) => BigNumber;
|
|
13
|
+
/**
|
|
14
|
+
* Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals
|
|
15
|
+
*/
|
|
16
|
+
declare const toHumanReadable: (value: BigNumber | string | number, decimals?: number) => BigNumber;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { toHumanReadable as i, toBigNumber as n, toChainFormat as r, BigNumber as t };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
+
let bignumber_js = require("bignumber.js");
|
|
3
|
+
bignumber_js = require_chunk.__toESM(bignumber_js);
|
|
4
|
+
|
|
5
|
+
//#region src/classes/BigNumber.ts
|
|
6
|
+
var BigNumber_default = bignumber_js.default;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a value to BigNumber if it isn't already
|
|
9
|
+
*/
|
|
10
|
+
const toBigNumber = (value) => {
|
|
11
|
+
if (value instanceof bignumber_js.default) return value;
|
|
12
|
+
return new bignumber_js.default(value);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals
|
|
16
|
+
*/
|
|
17
|
+
const toChainFormat = (value, decimals = 18) => {
|
|
18
|
+
return toBigNumber(value).multipliedBy(new bignumber_js.default(10).pow(decimals));
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals
|
|
22
|
+
*/
|
|
23
|
+
const toHumanReadable = (value, decimals = 18) => {
|
|
24
|
+
return toBigNumber(value).dividedBy(new bignumber_js.default(10).pow(decimals));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
Object.defineProperty(exports, 'BigNumber_default', {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () {
|
|
31
|
+
return BigNumber_default;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, 'toBigNumber', {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return toBigNumber;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, 'toChainFormat', {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () {
|
|
43
|
+
return toChainFormat;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, 'toHumanReadable', {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () {
|
|
49
|
+
return toHumanReadable;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const require_BigNumber = require('./BigNumber-DbDA4_xA.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/classes/BigNumberInWei.ts
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated - use toChainFormat instead
|
|
6
|
+
*/
|
|
7
|
+
var BigNumberInWei = class BigNumberInWei extends require_BigNumber.BigNumber_default {
|
|
8
|
+
static make(number) {
|
|
9
|
+
return new BigNumberInWei(number);
|
|
10
|
+
}
|
|
11
|
+
minus(n, base) {
|
|
12
|
+
return new BigNumberInWei(super.minus(n, base));
|
|
13
|
+
}
|
|
14
|
+
plus(n, base) {
|
|
15
|
+
return new BigNumberInWei(super.plus(n, base));
|
|
16
|
+
}
|
|
17
|
+
dividedBy(n, base) {
|
|
18
|
+
return new BigNumberInWei(super.dividedBy(n, base));
|
|
19
|
+
}
|
|
20
|
+
div(n, base) {
|
|
21
|
+
return new BigNumberInWei(super.div(n, base));
|
|
22
|
+
}
|
|
23
|
+
multipliedBy(n, base) {
|
|
24
|
+
return new BigNumberInWei(super.multipliedBy(n, base));
|
|
25
|
+
}
|
|
26
|
+
times(n, base) {
|
|
27
|
+
return new BigNumberInWei(super.times(n, base));
|
|
28
|
+
}
|
|
29
|
+
pow(n, base) {
|
|
30
|
+
return new BigNumberInWei(super.pow(n, base));
|
|
31
|
+
}
|
|
32
|
+
toBase(decimals = 18) {
|
|
33
|
+
return new require_BigNumber.BigNumber_default(this).dividedBy(new require_BigNumber.BigNumber_default(10).pow(decimals));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/classes/BigNumberInBase.ts
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated - use toHumanReadable instead
|
|
41
|
+
*/
|
|
42
|
+
var BigNumberInBase = class BigNumberInBase extends require_BigNumber.BigNumber_default {
|
|
43
|
+
static make(number) {
|
|
44
|
+
return new BigNumberInBase(number);
|
|
45
|
+
}
|
|
46
|
+
minus(n, base) {
|
|
47
|
+
return new BigNumberInBase(super.minus(n, base));
|
|
48
|
+
}
|
|
49
|
+
plus(n, base) {
|
|
50
|
+
return new BigNumberInBase(super.plus(n, base));
|
|
51
|
+
}
|
|
52
|
+
dividedBy(n, base) {
|
|
53
|
+
return new BigNumberInBase(super.dividedBy(n, base));
|
|
54
|
+
}
|
|
55
|
+
div(n, base) {
|
|
56
|
+
return new BigNumberInBase(super.div(n, base));
|
|
57
|
+
}
|
|
58
|
+
multipliedBy(n, base) {
|
|
59
|
+
return new BigNumberInBase(super.multipliedBy(n, base));
|
|
60
|
+
}
|
|
61
|
+
times(n, base) {
|
|
62
|
+
return new BigNumberInBase(super.times(n, base));
|
|
63
|
+
}
|
|
64
|
+
pow(n, base) {
|
|
65
|
+
return new BigNumberInBase(super.pow(n, base));
|
|
66
|
+
}
|
|
67
|
+
toWei(decimals = 18) {
|
|
68
|
+
return new require_BigNumber.BigNumber_default(this).multipliedBy(new require_BigNumber.BigNumber_default(10).pow(decimals));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
Object.defineProperty(exports, 'BigNumberInBase', {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return BigNumberInBase;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, 'BigNumberInWei', {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return BigNumberInWei;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { t as BigNumber } from "./BigNumber-B-r__Egf.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/classes/BigNumberInBase.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated - use toHumanReadable instead
|
|
7
|
+
*/
|
|
8
|
+
declare class BigNumberInBase extends BigNumber {
|
|
9
|
+
static make(number: BigNumber.Value): BigNumberInBase;
|
|
10
|
+
minus(n: BigNumber.Value, base?: number): BigNumberInBase;
|
|
11
|
+
plus(n: BigNumber.Value, base?: number): BigNumberInBase;
|
|
12
|
+
dividedBy(n: BigNumber.Value, base?: number): BigNumberInBase;
|
|
13
|
+
div(n: BigNumber.Value, base?: number): BigNumberInBase;
|
|
14
|
+
multipliedBy(n: BigNumber.Value, base?: number): BigNumberInBase;
|
|
15
|
+
times(n: BigNumber.Value, base?: number): BigNumberInBase;
|
|
16
|
+
pow(n: BigNumber.Value, base?: number): BigNumberInBase;
|
|
17
|
+
toWei(decimals?: number): BigNumberInWei;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/classes/BigNumberInWei.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated - use toChainFormat instead
|
|
23
|
+
*/
|
|
24
|
+
declare class BigNumberInWei extends BigNumber {
|
|
25
|
+
static make(number: BigNumber.Value): BigNumberInWei;
|
|
26
|
+
minus(n: BigNumber.Value, base?: number): BigNumberInWei;
|
|
27
|
+
plus(n: BigNumber.Value, base?: number): BigNumberInWei;
|
|
28
|
+
dividedBy(n: BigNumber.Value, base?: number): BigNumberInWei;
|
|
29
|
+
div(n: BigNumber.Value, base?: number): BigNumberInWei;
|
|
30
|
+
multipliedBy(n: BigNumber.Value, base?: number): BigNumberInWei;
|
|
31
|
+
times(n: BigNumber.Value, base?: number): BigNumberInWei;
|
|
32
|
+
pow(n: BigNumber.Value, base?: number): BigNumberInWei;
|
|
33
|
+
toBase(decimals?: number): BigNumberInBase;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { BigNumberInBase as n, BigNumberInWei as t };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from "axios";
|
|
2
|
+
|
|
3
|
+
//#region src/classes/HttpClient.d.ts
|
|
4
|
+
declare class HttpClient {
|
|
5
|
+
private readonly client;
|
|
6
|
+
private config;
|
|
7
|
+
constructor(endpoint: string, options?: Record<string, any>);
|
|
8
|
+
setConfig(config: AxiosRequestConfig): HttpClient;
|
|
9
|
+
get<T, P>(endpoint: string, params?: T): Promise<P>;
|
|
10
|
+
post<T, P>(endpoint: string, data?: T): Promise<P>;
|
|
11
|
+
put<T, P>(endpoint: string, data?: T): Promise<P>;
|
|
12
|
+
delete<T, P>(endpoint: string, params?: T): Promise<P>;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/classes/HttpRestClient.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
19
|
+
declare class HttpRestClient {
|
|
20
|
+
protected client: HttpClient;
|
|
21
|
+
protected endpoint: string;
|
|
22
|
+
constructor(endpoint: string, options?: Record<string, any>);
|
|
23
|
+
setConfig(config: AxiosRequestConfig): HttpRestClient;
|
|
24
|
+
get<T>(endpoint: string, params?: Record<string, any>): Promise<T>;
|
|
25
|
+
retry<TResponse>(httpCall: Function, retries?: number, delay?: number): Promise<TResponse>;
|
|
26
|
+
post<T>(endpoint: string, params?: Record<string, any>): Promise<T>;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { HttpClient as n, HttpRestClient as t };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_defineProperty = require('./defineProperty-CImP5zIM.cjs');
|
|
3
|
+
let axios = require("axios");
|
|
4
|
+
axios = require_chunk.__toESM(axios);
|
|
5
|
+
let http_status_codes = require("http-status-codes");
|
|
6
|
+
let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
|
|
7
|
+
|
|
8
|
+
//#region src/classes/HttpClient.ts
|
|
9
|
+
var HttpClient = class {
|
|
10
|
+
constructor(endpoint, options = { headers: { "Content-Type": "application/json" } }) {
|
|
11
|
+
require_defineProperty._defineProperty(this, "client", void 0);
|
|
12
|
+
require_defineProperty._defineProperty(this, "config", {});
|
|
13
|
+
this.client = axios.default.create({
|
|
14
|
+
baseURL: endpoint,
|
|
15
|
+
timeout: 15e3,
|
|
16
|
+
...options
|
|
17
|
+
});
|
|
18
|
+
this.config = {};
|
|
19
|
+
}
|
|
20
|
+
setConfig(config) {
|
|
21
|
+
this.config = config;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
get(endpoint, params = {}) {
|
|
25
|
+
return this.client.get(endpoint, {
|
|
26
|
+
params,
|
|
27
|
+
...this.config
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
post(endpoint, data = {}) {
|
|
31
|
+
return this.client.post(endpoint, data, this.config);
|
|
32
|
+
}
|
|
33
|
+
put(endpoint, data = {}) {
|
|
34
|
+
return this.client.put(endpoint, data, this.config);
|
|
35
|
+
}
|
|
36
|
+
delete(endpoint, params = {}) {
|
|
37
|
+
return this.client.delete(endpoint, {
|
|
38
|
+
params,
|
|
39
|
+
...this.config
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/classes/HttpRestClient.ts
|
|
46
|
+
const getErrorMessage = (error, endpoint) => {
|
|
47
|
+
if (!error.response) return `The request to ${endpoint} has failed.`;
|
|
48
|
+
return error.response.data ? error.response.data.message || error.response.data.statusMessage || error.response.data : error.response.statusText;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @hidden
|
|
52
|
+
*/
|
|
53
|
+
var HttpRestClient = class {
|
|
54
|
+
constructor(endpoint, options = {}) {
|
|
55
|
+
require_defineProperty._defineProperty(this, "client", void 0);
|
|
56
|
+
require_defineProperty._defineProperty(this, "endpoint", void 0);
|
|
57
|
+
this.client = new HttpClient(endpoint, options);
|
|
58
|
+
this.endpoint = endpoint;
|
|
59
|
+
}
|
|
60
|
+
setConfig(config) {
|
|
61
|
+
this.client.setConfig(config);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
async get(endpoint, params = {}) {
|
|
65
|
+
try {
|
|
66
|
+
return await this.client.get(endpoint, params);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
const error = e;
|
|
69
|
+
if (axios.default.isAxiosError(error)) {
|
|
70
|
+
if (error.code === "ECONNABORTED") throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), {
|
|
71
|
+
code: http_status_codes.StatusCodes.REQUEST_TOO_LONG,
|
|
72
|
+
context: endpoint
|
|
73
|
+
});
|
|
74
|
+
const message = getErrorMessage(error, endpoint);
|
|
75
|
+
throw new __injectivelabs_exceptions.HttpRequestException(new Error(message), {
|
|
76
|
+
context: endpoint,
|
|
77
|
+
code: error.response ? error.response.status : http_status_codes.StatusCodes.BAD_REQUEST
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), {
|
|
81
|
+
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
82
|
+
context: endpoint
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async retry(httpCall, retries = 3, delay = 1e3) {
|
|
87
|
+
const retryHttpCall = async (attempt = 1) => {
|
|
88
|
+
try {
|
|
89
|
+
return await httpCall();
|
|
90
|
+
} catch (e) {
|
|
91
|
+
if (e instanceof __injectivelabs_exceptions.HttpRequestException) {
|
|
92
|
+
if (e.code === http_status_codes.StatusCodes.REQUEST_TOO_LONG) throw e;
|
|
93
|
+
}
|
|
94
|
+
if (attempt >= retries) throw e;
|
|
95
|
+
return new Promise((resolve) => setTimeout(() => resolve(retryHttpCall(attempt + 1)), delay * attempt));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return retryHttpCall();
|
|
99
|
+
}
|
|
100
|
+
async post(endpoint, params = {}) {
|
|
101
|
+
try {
|
|
102
|
+
return await this.client.post(endpoint, params);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
const error = e;
|
|
105
|
+
if (axios.default.isAxiosError(error)) {
|
|
106
|
+
if (error.code === "ECONNABORTED") throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), {
|
|
107
|
+
code: http_status_codes.StatusCodes.REQUEST_TOO_LONG,
|
|
108
|
+
method: __injectivelabs_exceptions.HttpRequestMethod.Post
|
|
109
|
+
});
|
|
110
|
+
const message = getErrorMessage(error, endpoint);
|
|
111
|
+
throw new __injectivelabs_exceptions.HttpRequestException(new Error(message), {
|
|
112
|
+
code: error.response ? error.response.status : http_status_codes.StatusCodes.BAD_REQUEST,
|
|
113
|
+
context: endpoint,
|
|
114
|
+
contextModule: __injectivelabs_exceptions.HttpRequestMethod.Post
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), {
|
|
118
|
+
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
119
|
+
context: endpoint,
|
|
120
|
+
contextModule: __injectivelabs_exceptions.HttpRequestMethod.Post
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
Object.defineProperty(exports, 'HttpClient', {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
get: function () {
|
|
130
|
+
return HttpClient;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(exports, 'HttpRestClient', {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function () {
|
|
136
|
+
return HttpRestClient;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_defineProperty = require('./defineProperty-CImP5zIM.cjs');
|
|
3
|
+
let store2 = require("store2");
|
|
4
|
+
store2 = require_chunk.__toESM(store2);
|
|
5
|
+
|
|
6
|
+
//#region src/classes/LocalStorage.ts
|
|
7
|
+
var LocalStorage = class {
|
|
8
|
+
constructor(namespace) {
|
|
9
|
+
require_defineProperty._defineProperty(this, "storage", void 0);
|
|
10
|
+
this.storage = store2.default.namespace(namespace);
|
|
11
|
+
}
|
|
12
|
+
get(key, defaultValue = {}) {
|
|
13
|
+
return this.storage.get(key) || defaultValue;
|
|
14
|
+
}
|
|
15
|
+
has(key) {
|
|
16
|
+
return this.storage.has(key);
|
|
17
|
+
}
|
|
18
|
+
set(key, value) {
|
|
19
|
+
this.storage.set(key, value);
|
|
20
|
+
}
|
|
21
|
+
remove(key) {
|
|
22
|
+
this.storage.remove(key);
|
|
23
|
+
}
|
|
24
|
+
clear() {
|
|
25
|
+
this.storage.clear();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
Object.defineProperty(exports, 'LocalStorage', {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return LocalStorage;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/classes/LocalStorage.d.ts
|
|
2
|
+
declare class LocalStorage {
|
|
3
|
+
private storage;
|
|
4
|
+
constructor(namespace: string);
|
|
5
|
+
get(key: string, defaultValue?: unknown): unknown;
|
|
6
|
+
has(key: string): boolean;
|
|
7
|
+
set(key: string, value: unknown): void;
|
|
8
|
+
remove(key: string): void;
|
|
9
|
+
clear(): void;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { LocalStorage as t };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const require_defineProperty = require('./defineProperty-CImP5zIM.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/enum.ts
|
|
4
|
+
const StatusType = {
|
|
5
|
+
Idle: "idle",
|
|
6
|
+
Loading: "loading",
|
|
7
|
+
Completed: "completed",
|
|
8
|
+
Error: "error",
|
|
9
|
+
Confirmed: "confirmed"
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/classes/Status.ts
|
|
14
|
+
var Status = class {
|
|
15
|
+
constructor(status = StatusType.Idle) {
|
|
16
|
+
require_defineProperty._defineProperty(this, "status", void 0);
|
|
17
|
+
this.status = status;
|
|
18
|
+
}
|
|
19
|
+
get() {
|
|
20
|
+
return this.status;
|
|
21
|
+
}
|
|
22
|
+
set(status) {
|
|
23
|
+
this.status = status;
|
|
24
|
+
}
|
|
25
|
+
is(status) {
|
|
26
|
+
return this.status === status;
|
|
27
|
+
}
|
|
28
|
+
isLoading() {
|
|
29
|
+
return this.is(StatusType.Loading);
|
|
30
|
+
}
|
|
31
|
+
isNotLoading() {
|
|
32
|
+
return !this.is(StatusType.Loading);
|
|
33
|
+
}
|
|
34
|
+
isCompleted() {
|
|
35
|
+
return this.is(StatusType.Completed);
|
|
36
|
+
}
|
|
37
|
+
isConfirmed() {
|
|
38
|
+
return this.is(StatusType.Confirmed);
|
|
39
|
+
}
|
|
40
|
+
isIdle() {
|
|
41
|
+
return this.is(StatusType.Idle);
|
|
42
|
+
}
|
|
43
|
+
isError() {
|
|
44
|
+
return this.is(StatusType.Error);
|
|
45
|
+
}
|
|
46
|
+
setLoading() {
|
|
47
|
+
this.set(StatusType.Loading);
|
|
48
|
+
}
|
|
49
|
+
setCompleted() {
|
|
50
|
+
this.set(StatusType.Completed);
|
|
51
|
+
}
|
|
52
|
+
setConfirmed() {
|
|
53
|
+
this.set(StatusType.Confirmed);
|
|
54
|
+
}
|
|
55
|
+
setError() {
|
|
56
|
+
this.set(StatusType.Error);
|
|
57
|
+
}
|
|
58
|
+
setIdle() {
|
|
59
|
+
this.set(StatusType.Idle);
|
|
60
|
+
}
|
|
61
|
+
toggle() {
|
|
62
|
+
this.set(this.status === StatusType.Idle ? StatusType.Loading : StatusType.Idle);
|
|
63
|
+
}
|
|
64
|
+
toString() {
|
|
65
|
+
return this.get();
|
|
66
|
+
}
|
|
67
|
+
valueOf() {
|
|
68
|
+
return this.get();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
Object.defineProperty(exports, 'Status', {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return Status;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, 'StatusType', {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return StatusType;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/enum.d.ts
|
|
2
|
+
declare const StatusType: {
|
|
3
|
+
readonly Idle: "idle";
|
|
4
|
+
readonly Loading: "loading";
|
|
5
|
+
readonly Completed: "completed";
|
|
6
|
+
readonly Error: "error";
|
|
7
|
+
readonly Confirmed: "confirmed";
|
|
8
|
+
};
|
|
9
|
+
type StatusType = (typeof StatusType)[keyof typeof StatusType];
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/classes/Status.d.ts
|
|
12
|
+
declare class Status {
|
|
13
|
+
status: string;
|
|
14
|
+
constructor(status?: StatusType);
|
|
15
|
+
get(): string;
|
|
16
|
+
set(status: StatusType): void;
|
|
17
|
+
is(status: StatusType): boolean;
|
|
18
|
+
isLoading(): boolean;
|
|
19
|
+
isNotLoading(): boolean;
|
|
20
|
+
isCompleted(): boolean;
|
|
21
|
+
isConfirmed(): boolean;
|
|
22
|
+
isIdle(): boolean;
|
|
23
|
+
isError(): boolean;
|
|
24
|
+
setLoading(): void;
|
|
25
|
+
setCompleted(): void;
|
|
26
|
+
setConfirmed(): void;
|
|
27
|
+
setError(): void;
|
|
28
|
+
setIdle(): void;
|
|
29
|
+
toggle(): void;
|
|
30
|
+
toString(): string;
|
|
31
|
+
valueOf(): string;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { StatusType as n, Status as t };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_BigNumber = require('./BigNumber-DbDA4_xA.cjs');
|
|
2
|
+
const require_BigNumberInBase = require('./BigNumberInBase-CVKbAXw6.cjs');
|
|
3
|
+
|
|
4
|
+
exports.BigNumber = require_BigNumber.BigNumber_default;
|
|
5
|
+
exports.BigNumberInBase = require_BigNumberInBase.BigNumberInBase;
|
|
6
|
+
exports.BigNumberInWei = require_BigNumberInBase.BigNumberInWei;
|
|
7
|
+
exports.toBigNumber = require_BigNumber.toBigNumber;
|
|
8
|
+
exports.toChainFormat = require_BigNumber.toChainFormat;
|
|
9
|
+
exports.toHumanReadable = require_BigNumber.toHumanReadable;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { i as toHumanReadable, n as toBigNumber, r as toChainFormat, t as BigNumber } from "./BigNumber-B-r__Egf.cjs";
|
|
2
|
+
import { n as BigNumberInBase, t as BigNumberInWei } from "./BigNumberInWei-BMQpZg3S.cjs";
|
|
3
|
+
export { BigNumber, BigNumberInBase, BigNumberInWei, toBigNumber, toChainFormat, toHumanReadable };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
Object.defineProperty(exports, '__toESM', {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return __toESM;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/constants.d.ts
|
|
2
|
+
declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
3
|
+
declare const INJ_DENOM = "inj";
|
|
4
|
+
declare const INJECTIVE_DENOM = "inj";
|
|
5
|
+
declare const DEFAULT_FEE_DENOM = "inj";
|
|
6
|
+
declare const DEFAULT_GAS_LIMIT = 400000;
|
|
7
|
+
declare const DEFAULT_IBC_GAS_LIMIT = 300000;
|
|
8
|
+
declare const DEFAULT_GAS_PRICE = 160000000;
|
|
9
|
+
declare const DEFAULT_EXCHANGE_LIMIT = 200000;
|
|
10
|
+
declare const DEFAULT_BRIDGE_FEE_DENOM = "inj";
|
|
11
|
+
declare const DEFAULT_BRIDGE_FEE_PRICE = "160000000";
|
|
12
|
+
declare const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000";
|
|
13
|
+
declare const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60;
|
|
14
|
+
declare const DEFAULT_BLOCK_TIME_IN_SECONDS = 0.7;
|
|
15
|
+
/**
|
|
16
|
+
* Default timeout for transaction block inclusion polling.
|
|
17
|
+
*
|
|
18
|
+
* Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms
|
|
19
|
+
*/
|
|
20
|
+
declare const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS: number;
|
|
21
|
+
declare const DEFAULT_TX_POLL_INTERVAL_MS = 500;
|
|
22
|
+
declare const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3000;
|
|
23
|
+
declare const DEFAULT_TIMESTAMP_TIMEOUT_MS: number;
|
|
24
|
+
declare const getDefaultStdFee: () => {
|
|
25
|
+
amount: {
|
|
26
|
+
amount: string;
|
|
27
|
+
denom: string;
|
|
28
|
+
}[];
|
|
29
|
+
gas: string;
|
|
30
|
+
payer: string;
|
|
31
|
+
granter: string;
|
|
32
|
+
feePayer: string;
|
|
33
|
+
};
|
|
34
|
+
declare const DEFAULT_STD_FEE_BY_DENOM: (denom?: string) => {
|
|
35
|
+
amount: {
|
|
36
|
+
denom: string;
|
|
37
|
+
amount: string;
|
|
38
|
+
}[];
|
|
39
|
+
gas: string;
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { INJ_DENOM as _, DEFAULT_BRIDGE_FEE_PRICE as a, DEFAULT_GAS_LIMIT as c, DEFAULT_STD_FEE_BY_DENOM as d, DEFAULT_TIMESTAMP_TIMEOUT_MS as f, INJECTIVE_DENOM as g, DEFAULT_TX_POLL_INTERVAL_MS as h, DEFAULT_BRIDGE_FEE_DENOM as i, DEFAULT_GAS_PRICE as l, DEFAULT_TX_POLL_CALL_TIMEOUT_MS as m, DEFAULT_BLOCK_TIME_IN_SECONDS as n, DEFAULT_EXCHANGE_LIMIT as o, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS as p, DEFAULT_BRIDGE_FEE_AMOUNT as r, DEFAULT_FEE_DENOM as s, DEFAULT_BLOCK_TIMEOUT_HEIGHT as t, DEFAULT_IBC_GAS_LIMIT as u, ZERO_ADDRESS as v, getDefaultStdFee as y };
|