@injectivelabs/utils 1.16.13-alpha.1 → 1.16.13-alpha.3
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/helpers.d.ts +12 -12
- package/dist/cjs/helpers.js +9 -10
- package/dist/esm/helpers.d.ts +12 -12
- package/dist/esm/helpers.js +10 -11
- package/package.json +5 -5
package/dist/cjs/helpers.d.ts
CHANGED
|
@@ -37,23 +37,23 @@ export declare const getStdFeeFromObject: (args?: {
|
|
|
37
37
|
feePayer?: string;
|
|
38
38
|
}) => {
|
|
39
39
|
amount: {
|
|
40
|
-
amount: string;
|
|
41
40
|
denom: string;
|
|
41
|
+
amount: string;
|
|
42
42
|
}[];
|
|
43
43
|
gas: string;
|
|
44
|
-
payer: string;
|
|
45
|
-
granter: string;
|
|
46
|
-
feePayer: string;
|
|
44
|
+
payer: string | undefined; /** for Web3Gateway fee delegation */
|
|
45
|
+
granter: string | undefined;
|
|
46
|
+
feePayer: string | undefined;
|
|
47
47
|
};
|
|
48
48
|
export declare const getStdFeeFromString: (gasPrice: string) => {
|
|
49
49
|
amount: {
|
|
50
|
-
amount: string;
|
|
51
50
|
denom: string;
|
|
51
|
+
amount: string;
|
|
52
52
|
}[];
|
|
53
53
|
gas: string;
|
|
54
|
-
payer: string;
|
|
55
|
-
granter: string;
|
|
56
|
-
feePayer: string;
|
|
54
|
+
payer: string | undefined; /** for Web3Gateway fee delegation */
|
|
55
|
+
granter: string | undefined;
|
|
56
|
+
feePayer: string | undefined;
|
|
57
57
|
};
|
|
58
58
|
export declare const getStdFee: (args?: string | {
|
|
59
59
|
payer?: string;
|
|
@@ -63,11 +63,11 @@ export declare const getStdFee: (args?: string | {
|
|
|
63
63
|
gasPrice?: string | number;
|
|
64
64
|
}) => {
|
|
65
65
|
amount: {
|
|
66
|
-
amount: string;
|
|
67
66
|
denom: string;
|
|
67
|
+
amount: string;
|
|
68
68
|
}[];
|
|
69
69
|
gas: string;
|
|
70
|
-
payer: string;
|
|
71
|
-
granter: string;
|
|
72
|
-
feePayer: string;
|
|
70
|
+
payer: string | undefined; /** for Web3Gateway fee delegation */
|
|
71
|
+
granter: string | undefined;
|
|
72
|
+
feePayer: string | undefined;
|
|
73
73
|
};
|
package/dist/cjs/helpers.js
CHANGED
|
@@ -106,21 +106,20 @@ const getStdFeeFromObject = (args) => {
|
|
|
106
106
|
if (!args) {
|
|
107
107
|
return (0, constants_js_1.getDefaultStdFee)();
|
|
108
108
|
}
|
|
109
|
-
const
|
|
110
|
-
const
|
|
109
|
+
const { payer, granter, feePayer, gasPrice = constants_js_1.DEFAULT_GAS_PRICE, gas = constants_js_1.DEFAULT_GAS_LIMIT.toString(), } = args;
|
|
110
|
+
const gasNormalized = (0, BigNumber_js_1.toBigNumber)(gas).toFixed(0);
|
|
111
|
+
const gasPriceNormalized = (0, BigNumber_js_1.toBigNumber)(gasPrice).toFixed(0);
|
|
111
112
|
return {
|
|
112
113
|
amount: [
|
|
113
114
|
{
|
|
114
115
|
denom: 'inj',
|
|
115
|
-
amount:
|
|
116
|
-
.times(gasPriceScaled)
|
|
117
|
-
.toFixed(0),
|
|
116
|
+
amount: (0, BigNumber_js_1.toBigNumber)(gasNormalized).times(gasPriceNormalized).toFixed(),
|
|
118
117
|
},
|
|
119
118
|
],
|
|
120
|
-
gas:
|
|
121
|
-
payer
|
|
122
|
-
granter
|
|
123
|
-
feePayer
|
|
119
|
+
gas: (0, BigNumber_js_1.toBigNumber)(gasNormalized).toFixed(),
|
|
120
|
+
payer /** for Web3Gateway fee delegation */,
|
|
121
|
+
granter,
|
|
122
|
+
feePayer,
|
|
124
123
|
};
|
|
125
124
|
};
|
|
126
125
|
exports.getStdFeeFromObject = getStdFeeFromObject;
|
|
@@ -130,7 +129,7 @@ const getStdFeeFromString = (gasPrice) => {
|
|
|
130
129
|
throw new Error('Invalid gas price string');
|
|
131
130
|
}
|
|
132
131
|
const [_, amount] = matchResult;
|
|
133
|
-
const gas = (0, BigNumber_js_1.toChainFormat)(amount).dividedBy(constants_js_1.DEFAULT_GAS_PRICE).toFixed(0);
|
|
132
|
+
const gas = (0, BigNumber_js_1.toChainFormat)(amount, 18).dividedBy(constants_js_1.DEFAULT_GAS_PRICE).toFixed(0);
|
|
134
133
|
return (0, exports.getStdFeeFromObject)({ gas, gasPrice: constants_js_1.DEFAULT_GAS_PRICE });
|
|
135
134
|
};
|
|
136
135
|
exports.getStdFeeFromString = getStdFeeFromString;
|
package/dist/esm/helpers.d.ts
CHANGED
|
@@ -37,23 +37,23 @@ export declare const getStdFeeFromObject: (args?: {
|
|
|
37
37
|
feePayer?: string;
|
|
38
38
|
}) => {
|
|
39
39
|
amount: {
|
|
40
|
-
amount: string;
|
|
41
40
|
denom: string;
|
|
41
|
+
amount: string;
|
|
42
42
|
}[];
|
|
43
43
|
gas: string;
|
|
44
|
-
payer: string;
|
|
45
|
-
granter: string;
|
|
46
|
-
feePayer: string;
|
|
44
|
+
payer: string | undefined; /** for Web3Gateway fee delegation */
|
|
45
|
+
granter: string | undefined;
|
|
46
|
+
feePayer: string | undefined;
|
|
47
47
|
};
|
|
48
48
|
export declare const getStdFeeFromString: (gasPrice: string) => {
|
|
49
49
|
amount: {
|
|
50
|
-
amount: string;
|
|
51
50
|
denom: string;
|
|
51
|
+
amount: string;
|
|
52
52
|
}[];
|
|
53
53
|
gas: string;
|
|
54
|
-
payer: string;
|
|
55
|
-
granter: string;
|
|
56
|
-
feePayer: string;
|
|
54
|
+
payer: string | undefined; /** for Web3Gateway fee delegation */
|
|
55
|
+
granter: string | undefined;
|
|
56
|
+
feePayer: string | undefined;
|
|
57
57
|
};
|
|
58
58
|
export declare const getStdFee: (args?: string | {
|
|
59
59
|
payer?: string;
|
|
@@ -63,11 +63,11 @@ export declare const getStdFee: (args?: string | {
|
|
|
63
63
|
gasPrice?: string | number;
|
|
64
64
|
}) => {
|
|
65
65
|
amount: {
|
|
66
|
-
amount: string;
|
|
67
66
|
denom: string;
|
|
67
|
+
amount: string;
|
|
68
68
|
}[];
|
|
69
69
|
gas: string;
|
|
70
|
-
payer: string;
|
|
71
|
-
granter: string;
|
|
72
|
-
feePayer: string;
|
|
70
|
+
payer: string | undefined; /** for Web3Gateway fee delegation */
|
|
71
|
+
granter: string | undefined;
|
|
72
|
+
feePayer: string | undefined;
|
|
73
73
|
};
|
package/dist/esm/helpers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getDefaultStdFee, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, } from './constants.js';
|
|
2
|
-
import { toChainFormat, toHumanReadable, default as BigNumber, } from './classes/BigNumber.js';
|
|
2
|
+
import { toBigNumber, toChainFormat, toHumanReadable, default as BigNumber, } from './classes/BigNumber.js';
|
|
3
3
|
export const sleep = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout));
|
|
4
4
|
/**
|
|
5
5
|
* When we want to execute the promises in batch
|
|
@@ -64,21 +64,20 @@ export const getStdFeeFromObject = (args) => {
|
|
|
64
64
|
if (!args) {
|
|
65
65
|
return getDefaultStdFee();
|
|
66
66
|
}
|
|
67
|
-
const
|
|
68
|
-
const
|
|
67
|
+
const { payer, granter, feePayer, gasPrice = DEFAULT_GAS_PRICE, gas = DEFAULT_GAS_LIMIT.toString(), } = args;
|
|
68
|
+
const gasNormalized = toBigNumber(gas).toFixed(0);
|
|
69
|
+
const gasPriceNormalized = toBigNumber(gasPrice).toFixed(0);
|
|
69
70
|
return {
|
|
70
71
|
amount: [
|
|
71
72
|
{
|
|
72
73
|
denom: 'inj',
|
|
73
|
-
amount:
|
|
74
|
-
.times(gasPriceScaled)
|
|
75
|
-
.toFixed(0),
|
|
74
|
+
amount: toBigNumber(gasNormalized).times(gasPriceNormalized).toFixed(),
|
|
76
75
|
},
|
|
77
76
|
],
|
|
78
|
-
gas:
|
|
79
|
-
payer
|
|
80
|
-
granter
|
|
81
|
-
feePayer
|
|
77
|
+
gas: toBigNumber(gasNormalized).toFixed(),
|
|
78
|
+
payer /** for Web3Gateway fee delegation */,
|
|
79
|
+
granter,
|
|
80
|
+
feePayer,
|
|
82
81
|
};
|
|
83
82
|
};
|
|
84
83
|
export const getStdFeeFromString = (gasPrice) => {
|
|
@@ -87,7 +86,7 @@ export const getStdFeeFromString = (gasPrice) => {
|
|
|
87
86
|
throw new Error('Invalid gas price string');
|
|
88
87
|
}
|
|
89
88
|
const [_, amount] = matchResult;
|
|
90
|
-
const gas = toChainFormat(amount).dividedBy(DEFAULT_GAS_PRICE).toFixed(0);
|
|
89
|
+
const gas = toChainFormat(amount, 18).dividedBy(DEFAULT_GAS_PRICE).toFixed(0);
|
|
91
90
|
return getStdFeeFromObject({ gas, gasPrice: DEFAULT_GAS_PRICE });
|
|
92
91
|
};
|
|
93
92
|
export const getStdFee = (args) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/utils",
|
|
3
3
|
"description": "List of utils and helper functions that can be reused throughout Injective's projects.",
|
|
4
|
-
"version": "1.16.13-alpha.
|
|
4
|
+
"version": "1.16.13-alpha.3",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": {
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@bangjelkoski/store2": "^2.14.3",
|
|
82
|
-
"@injectivelabs/exceptions": "1.16.13-alpha.
|
|
83
|
-
"@injectivelabs/networks": "1.16.13-alpha.
|
|
84
|
-
"@injectivelabs/ts-types": "1.16.13-alpha.
|
|
82
|
+
"@injectivelabs/exceptions": "1.16.13-alpha.3",
|
|
83
|
+
"@injectivelabs/networks": "1.16.13-alpha.3",
|
|
84
|
+
"@injectivelabs/ts-types": "1.16.13-alpha.3",
|
|
85
85
|
"axios": "^1.8.1",
|
|
86
86
|
"bignumber.js": "^9.1.2",
|
|
87
87
|
"http-status-codes": "^2.3.0"
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"shx": "^0.3.4"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "9714d8be468bec92c649fee736e797912e3d5c12"
|
|
93
93
|
}
|