@pioneer-platform/osmosis-network 8.1.35 → 8.1.36
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/lib/index.js +332 -81
- package/package.json +2 -1
package/lib/index.js
CHANGED
|
@@ -79,6 +79,7 @@ https://github.com/osmosis-labs/osmosis-frontend/tree/master/src/stores/osmosis/
|
|
|
79
79
|
*/
|
|
80
80
|
var pjson = require("../package.json");
|
|
81
81
|
var TAG = " | " + pjson.name.replace("@pioneer-platform/", "") + " | ";
|
|
82
|
+
var lodash_1 = require("lodash");
|
|
82
83
|
require("dotenv").config({ path: '../../../.env' });
|
|
83
84
|
var Axios = require('axios');
|
|
84
85
|
var https = require('https');
|
|
@@ -134,6 +135,9 @@ module.exports = {
|
|
|
134
135
|
getPools: function () {
|
|
135
136
|
return get_pools();
|
|
136
137
|
},
|
|
138
|
+
getPool: function (pair) {
|
|
139
|
+
return get_pool(pair);
|
|
140
|
+
},
|
|
137
141
|
getValidators: function () {
|
|
138
142
|
return get_validators();
|
|
139
143
|
},
|
|
@@ -152,11 +156,29 @@ module.exports = {
|
|
|
152
156
|
getBlock: function (block) {
|
|
153
157
|
return get_block(block);
|
|
154
158
|
},
|
|
159
|
+
getEpochProvisions: function () {
|
|
160
|
+
return get_epoch_provisions();
|
|
161
|
+
},
|
|
155
162
|
getTransaction: function (txid) {
|
|
156
163
|
return get_transaction(txid);
|
|
157
164
|
},
|
|
158
|
-
|
|
159
|
-
return
|
|
165
|
+
getMintParams: function () {
|
|
166
|
+
return get_mint_params();
|
|
167
|
+
},
|
|
168
|
+
getSupply: function (denom) {
|
|
169
|
+
return get_total_supply(denom);
|
|
170
|
+
},
|
|
171
|
+
getPoolInfo: function () {
|
|
172
|
+
return get_pool_info();
|
|
173
|
+
},
|
|
174
|
+
getDistrobution: function () {
|
|
175
|
+
return get_distrobution_params();
|
|
176
|
+
},
|
|
177
|
+
getAPR: function () {
|
|
178
|
+
return get_APR();
|
|
179
|
+
},
|
|
180
|
+
getEpochs: function () {
|
|
181
|
+
return get_epochs();
|
|
160
182
|
},
|
|
161
183
|
transaction: function (txid) {
|
|
162
184
|
return get_transaction(txid);
|
|
@@ -168,9 +190,215 @@ module.exports = {
|
|
|
168
190
|
/**********************************
|
|
169
191
|
// Lib
|
|
170
192
|
//**********************************/
|
|
193
|
+
var get_APR = function () {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
+
var tag, mintParams, distributionProportions, getEpochs, epochProvisionInfo, durationSeconds, epochProvision, poolInfo, bondedToken, mintingEpochProvision, yearMintingProvision, totalSupply, ratio, inflation, apr, e_1;
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0:
|
|
199
|
+
tag = TAG + " | get_APR | ";
|
|
200
|
+
_a.label = 1;
|
|
201
|
+
case 1:
|
|
202
|
+
_a.trys.push([1, 6, , 7]);
|
|
203
|
+
return [4 /*yield*/, get_mint_params()];
|
|
204
|
+
case 2:
|
|
205
|
+
mintParams = _a.sent();
|
|
206
|
+
log.info(tag, "mintParams:", mintParams);
|
|
207
|
+
distributionProportions = mintParams.params.distribution_proportions.staking;
|
|
208
|
+
log.info(tag, "distributionProportions:", distributionProportions);
|
|
209
|
+
return [4 /*yield*/, get_epochs()];
|
|
210
|
+
case 3:
|
|
211
|
+
getEpochs = _a.sent();
|
|
212
|
+
log.info(tag, "getEpochs:", getEpochs);
|
|
213
|
+
epochProvisionInfo = getEpochs.epochs.filter(function (e) { return e.identifier === 'day'; });
|
|
214
|
+
epochProvisionInfo = epochProvisionInfo[0];
|
|
215
|
+
log.info(tag, "epochProvisionInfo:", epochProvisionInfo);
|
|
216
|
+
durationSeconds = epochProvisionInfo.duration.replace("s", "");
|
|
217
|
+
log.info(tag, "durationSeconds:", durationSeconds);
|
|
218
|
+
return [4 /*yield*/, get_epoch_provisions()
|
|
219
|
+
//get bonded tokens
|
|
220
|
+
];
|
|
221
|
+
case 4:
|
|
222
|
+
epochProvision = _a.sent();
|
|
223
|
+
return [4 /*yield*/, get_pool_info()];
|
|
224
|
+
case 5:
|
|
225
|
+
poolInfo = _a.sent();
|
|
226
|
+
bondedToken = poolInfo.pool.bonded_tokens;
|
|
227
|
+
log.info(tag, "bondedToken:", bondedToken);
|
|
228
|
+
// mintingEpochProvision = epochProvision * distributionProportions
|
|
229
|
+
log.info(tag, "epochProvision:", epochProvision);
|
|
230
|
+
log.info(tag, "distributionProportions:", distributionProportions);
|
|
231
|
+
mintingEpochProvision = epochProvision * distributionProportions;
|
|
232
|
+
log.info(tag, "mintingEpochProvision:", mintingEpochProvision);
|
|
233
|
+
yearMintingProvision = mintingEpochProvision * ((365 * 24 * 3600) / durationSeconds);
|
|
234
|
+
log.info(tag, "yearMintingProvision:", yearMintingProvision);
|
|
235
|
+
totalSupply = 1000000000;
|
|
236
|
+
// //let totalSupply = await get_total_supply('uosmo')
|
|
237
|
+
// log.info(tag,"totalSupply:",totalSupply)
|
|
238
|
+
// totalSupply = totalSupply.result.amount
|
|
239
|
+
// log.info(tag,"totalSupply:",totalSupply)
|
|
240
|
+
if (!totalSupply)
|
|
241
|
+
throw Error("unable to calc APR: missing totalSupply");
|
|
242
|
+
if (!epochProvision)
|
|
243
|
+
throw Error("unable to calc APR: missing epochProvision");
|
|
244
|
+
ratio = bondedToken / totalSupply;
|
|
245
|
+
log.info(tag, "ratio:", ratio);
|
|
246
|
+
inflation = yearMintingProvision / totalSupply;
|
|
247
|
+
log.info(tag, "inflation:", inflation);
|
|
248
|
+
apr = inflation / ratio;
|
|
249
|
+
log.info(tag, "apr:", apr);
|
|
250
|
+
apr = apr * 100;
|
|
251
|
+
return [2 /*return*/, apr];
|
|
252
|
+
case 6:
|
|
253
|
+
e_1 = _a.sent();
|
|
254
|
+
throw e_1;
|
|
255
|
+
case 7: return [2 /*return*/];
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
var get_distrobution_params = function () {
|
|
261
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
262
|
+
var tag, output, txInfo, e_2;
|
|
263
|
+
return __generator(this, function (_a) {
|
|
264
|
+
switch (_a.label) {
|
|
265
|
+
case 0:
|
|
266
|
+
tag = TAG + " | get_distrobution_params | ";
|
|
267
|
+
output = {};
|
|
268
|
+
_a.label = 1;
|
|
269
|
+
case 1:
|
|
270
|
+
_a.trys.push([1, 3, , 4]);
|
|
271
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/cosmos/distribution/v1beta1/params' })];
|
|
272
|
+
case 2:
|
|
273
|
+
txInfo = _a.sent();
|
|
274
|
+
return [2 /*return*/, txInfo.data];
|
|
275
|
+
case 3:
|
|
276
|
+
e_2 = _a.sent();
|
|
277
|
+
throw e_2;
|
|
278
|
+
case 4: return [2 /*return*/];
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
var get_pool_info = function () {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
+
var tag, output, txInfo, e_3;
|
|
286
|
+
return __generator(this, function (_a) {
|
|
287
|
+
switch (_a.label) {
|
|
288
|
+
case 0:
|
|
289
|
+
tag = TAG + " | get_pool_info | ";
|
|
290
|
+
output = {};
|
|
291
|
+
_a.label = 1;
|
|
292
|
+
case 1:
|
|
293
|
+
_a.trys.push([1, 3, , 4]);
|
|
294
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/cosmos/staking/v1beta1/pool' })];
|
|
295
|
+
case 2:
|
|
296
|
+
txInfo = _a.sent();
|
|
297
|
+
return [2 /*return*/, txInfo.data];
|
|
298
|
+
case 3:
|
|
299
|
+
e_3 = _a.sent();
|
|
300
|
+
throw e_3;
|
|
301
|
+
case 4: return [2 /*return*/];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
var get_epoch_provisions = function () {
|
|
307
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
308
|
+
var tag, output, txInfo, e_4;
|
|
309
|
+
return __generator(this, function (_a) {
|
|
310
|
+
switch (_a.label) {
|
|
311
|
+
case 0:
|
|
312
|
+
tag = TAG + " | get_total_supply | ";
|
|
313
|
+
output = {};
|
|
314
|
+
_a.label = 1;
|
|
315
|
+
case 1:
|
|
316
|
+
_a.trys.push([1, 3, , 4]);
|
|
317
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/osmosis/mint/v1beta1/epoch_provisions' })];
|
|
318
|
+
case 2:
|
|
319
|
+
txInfo = _a.sent();
|
|
320
|
+
return [2 /*return*/, txInfo.data.epoch_provisions];
|
|
321
|
+
case 3:
|
|
322
|
+
e_4 = _a.sent();
|
|
323
|
+
throw e_4;
|
|
324
|
+
case 4: return [2 /*return*/];
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
var get_total_supply = function (denom) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
331
|
+
var tag, output, txInfo, e_5;
|
|
332
|
+
return __generator(this, function (_a) {
|
|
333
|
+
switch (_a.label) {
|
|
334
|
+
case 0:
|
|
335
|
+
tag = TAG + " | get_total_supply | ";
|
|
336
|
+
output = {};
|
|
337
|
+
_a.label = 1;
|
|
338
|
+
case 1:
|
|
339
|
+
_a.trys.push([1, 3, , 4]);
|
|
340
|
+
log.info(tag, "url: ", URL_OSMO_LCD + '/bank/total/' + denom);
|
|
341
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/bank/total/' + denom })];
|
|
342
|
+
case 2:
|
|
343
|
+
txInfo = _a.sent();
|
|
344
|
+
return [2 /*return*/, txInfo.data];
|
|
345
|
+
case 3:
|
|
346
|
+
e_5 = _a.sent();
|
|
347
|
+
throw e_5;
|
|
348
|
+
case 4: return [2 /*return*/];
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
var get_mint_params = function () {
|
|
354
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
355
|
+
var tag, output, txInfo, e_6;
|
|
356
|
+
return __generator(this, function (_a) {
|
|
357
|
+
switch (_a.label) {
|
|
358
|
+
case 0:
|
|
359
|
+
tag = TAG + " | get_mint_params | ";
|
|
360
|
+
output = {};
|
|
361
|
+
_a.label = 1;
|
|
362
|
+
case 1:
|
|
363
|
+
_a.trys.push([1, 3, , 4]);
|
|
364
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/osmosis/mint/v1beta1/params' })];
|
|
365
|
+
case 2:
|
|
366
|
+
txInfo = _a.sent();
|
|
367
|
+
return [2 /*return*/, txInfo.data];
|
|
368
|
+
case 3:
|
|
369
|
+
e_6 = _a.sent();
|
|
370
|
+
throw e_6;
|
|
371
|
+
case 4: return [2 /*return*/];
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
var get_epochs = function () {
|
|
377
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
378
|
+
var tag, output, txInfo, e_7;
|
|
379
|
+
return __generator(this, function (_a) {
|
|
380
|
+
switch (_a.label) {
|
|
381
|
+
case 0:
|
|
382
|
+
tag = TAG + " | get_epochs | ";
|
|
383
|
+
output = {};
|
|
384
|
+
_a.label = 1;
|
|
385
|
+
case 1:
|
|
386
|
+
_a.trys.push([1, 3, , 4]);
|
|
387
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + "/osmosis/epochs/v1beta1/epochs" })];
|
|
388
|
+
case 2:
|
|
389
|
+
txInfo = _a.sent();
|
|
390
|
+
return [2 /*return*/, txInfo.data];
|
|
391
|
+
case 3:
|
|
392
|
+
e_7 = _a.sent();
|
|
393
|
+
throw e_7;
|
|
394
|
+
case 4: return [2 /*return*/];
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
};
|
|
171
399
|
var get_voucher_info = function (voucher) {
|
|
172
400
|
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
-
var tag, url, txInfo,
|
|
401
|
+
var tag, url, txInfo, e_8;
|
|
174
402
|
return __generator(this, function (_a) {
|
|
175
403
|
switch (_a.label) {
|
|
176
404
|
case 0:
|
|
@@ -179,15 +407,15 @@ var get_voucher_info = function (voucher) {
|
|
|
179
407
|
case 1:
|
|
180
408
|
_a.trys.push([1, 3, , 4]);
|
|
181
409
|
url = URL_OSMO_LCD + '/ibc/applications/transfer/v1beta1/denom_traces/' + voucher;
|
|
182
|
-
log.
|
|
410
|
+
log.info(tag, "url: ", url);
|
|
183
411
|
return [4 /*yield*/, axios({ method: 'GET', url: url })];
|
|
184
412
|
case 2:
|
|
185
413
|
txInfo = _a.sent();
|
|
186
|
-
log.
|
|
414
|
+
log.info(tag, "txInfo: ", txInfo.data);
|
|
187
415
|
return [2 /*return*/, txInfo.data];
|
|
188
416
|
case 3:
|
|
189
|
-
|
|
190
|
-
throw
|
|
417
|
+
e_8 = _a.sent();
|
|
418
|
+
throw e_8;
|
|
191
419
|
case 4: return [2 /*return*/];
|
|
192
420
|
}
|
|
193
421
|
});
|
|
@@ -195,7 +423,7 @@ var get_voucher_info = function (voucher) {
|
|
|
195
423
|
};
|
|
196
424
|
var get_block = function (height) {
|
|
197
425
|
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
-
var tag, output, txInfo,
|
|
426
|
+
var tag, output, txInfo, e_9;
|
|
199
427
|
return __generator(this, function (_a) {
|
|
200
428
|
switch (_a.label) {
|
|
201
429
|
case 0:
|
|
@@ -227,9 +455,9 @@ var get_block = function (height) {
|
|
|
227
455
|
log.debug(tag, "txInfo: ", txInfo.data.block.data.txs);
|
|
228
456
|
return [2 /*return*/, txInfo.data];
|
|
229
457
|
case 3:
|
|
230
|
-
|
|
458
|
+
e_9 = _a.sent();
|
|
231
459
|
//TODO dont shh error fix em
|
|
232
|
-
throw
|
|
460
|
+
throw e_9;
|
|
233
461
|
case 4: return [2 /*return*/];
|
|
234
462
|
}
|
|
235
463
|
});
|
|
@@ -237,7 +465,7 @@ var get_block = function (height) {
|
|
|
237
465
|
};
|
|
238
466
|
var get_staking_txs = function (address) {
|
|
239
467
|
return __awaiter(this, void 0, void 0, function () {
|
|
240
|
-
var tag, output, txInfo,
|
|
468
|
+
var tag, output, txInfo, e_10;
|
|
241
469
|
return __generator(this, function (_a) {
|
|
242
470
|
switch (_a.label) {
|
|
243
471
|
case 0:
|
|
@@ -252,8 +480,8 @@ var get_staking_txs = function (address) {
|
|
|
252
480
|
log.debug(tag, "txInfo: ", txInfo.data);
|
|
253
481
|
return [2 /*return*/, txInfo.data];
|
|
254
482
|
case 3:
|
|
255
|
-
|
|
256
|
-
throw
|
|
483
|
+
e_10 = _a.sent();
|
|
484
|
+
throw e_10;
|
|
257
485
|
case 4: return [2 /*return*/];
|
|
258
486
|
}
|
|
259
487
|
});
|
|
@@ -261,7 +489,7 @@ var get_staking_txs = function (address) {
|
|
|
261
489
|
};
|
|
262
490
|
var get_rewards = function (address) {
|
|
263
491
|
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
-
var tag, output, resp, output_1,
|
|
492
|
+
var tag, output, resp, output_1, e_11;
|
|
265
493
|
return __generator(this, function (_a) {
|
|
266
494
|
switch (_a.label) {
|
|
267
495
|
case 0:
|
|
@@ -277,8 +505,8 @@ var get_rewards = function (address) {
|
|
|
277
505
|
output_1 = resp.data;
|
|
278
506
|
return [2 /*return*/, output_1];
|
|
279
507
|
case 3:
|
|
280
|
-
|
|
281
|
-
throw
|
|
508
|
+
e_11 = _a.sent();
|
|
509
|
+
throw e_11;
|
|
282
510
|
case 4: return [2 /*return*/];
|
|
283
511
|
}
|
|
284
512
|
});
|
|
@@ -287,7 +515,7 @@ var get_rewards = function (address) {
|
|
|
287
515
|
//
|
|
288
516
|
var get_block_height = function () {
|
|
289
517
|
return __awaiter(this, void 0, void 0, function () {
|
|
290
|
-
var tag, output, resp, height,
|
|
518
|
+
var tag, output, resp, height, e_12;
|
|
291
519
|
return __generator(this, function (_a) {
|
|
292
520
|
switch (_a.label) {
|
|
293
521
|
case 0:
|
|
@@ -303,32 +531,55 @@ var get_block_height = function () {
|
|
|
303
531
|
height = resp.data.block.header.height;
|
|
304
532
|
return [2 /*return*/, parseInt(height)];
|
|
305
533
|
case 3:
|
|
306
|
-
|
|
307
|
-
throw
|
|
534
|
+
e_12 = _a.sent();
|
|
535
|
+
throw e_12;
|
|
308
536
|
case 4: return [2 /*return*/];
|
|
309
537
|
}
|
|
310
538
|
});
|
|
311
539
|
});
|
|
312
540
|
};
|
|
313
|
-
|
|
541
|
+
//get pools
|
|
542
|
+
var get_pool = function (pair) {
|
|
314
543
|
return __awaiter(this, void 0, void 0, function () {
|
|
315
|
-
var tag, output, poolInfo,
|
|
544
|
+
var tag, output, assets, poolInfo, sellAssetDenom_1, buyAssetDenom_1, foundPool, e_13;
|
|
316
545
|
return __generator(this, function (_a) {
|
|
317
546
|
switch (_a.label) {
|
|
318
547
|
case 0:
|
|
319
|
-
tag = TAG + " |
|
|
548
|
+
tag = TAG + " | get_pool | ";
|
|
320
549
|
output = {};
|
|
321
550
|
_a.label = 1;
|
|
322
551
|
case 1:
|
|
323
552
|
_a.trys.push([1, 3, , 4]);
|
|
324
|
-
|
|
553
|
+
if (pair.indexOf("_") === -1)
|
|
554
|
+
throw Error("Pair needs to use _ example (ATOM_OSMO)");
|
|
555
|
+
assets = pair.split("_");
|
|
556
|
+
if (assets[0] === 'ATOM')
|
|
557
|
+
assets[0] = "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2";
|
|
558
|
+
if (assets[1] === 'ATOM')
|
|
559
|
+
assets[1] = "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2";
|
|
560
|
+
if (assets[0] === 'OSMO')
|
|
561
|
+
assets[0] = "uosmo";
|
|
562
|
+
if (assets[1] === 'OSMO')
|
|
563
|
+
assets[1] = "uosmo";
|
|
564
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/osmosis/gamm/v1beta1/pools' })
|
|
565
|
+
// log.debug(tag,"poolInfo: ",poolInfo.data)
|
|
566
|
+
];
|
|
325
567
|
case 2:
|
|
326
568
|
poolInfo = _a.sent();
|
|
327
|
-
|
|
328
|
-
|
|
569
|
+
sellAssetDenom_1 = assets[0];
|
|
570
|
+
buyAssetDenom_1 = assets[1];
|
|
571
|
+
foundPool = lodash_1.find(poolInfo.data.pools, function (pool) {
|
|
572
|
+
var token0Denom = pool.poolAssets[0].token.denom;
|
|
573
|
+
var token1Denom = pool.poolAssets[1].token.denom;
|
|
574
|
+
return ((token0Denom === sellAssetDenom_1 && token1Denom === buyAssetDenom_1) ||
|
|
575
|
+
(token0Denom === buyAssetDenom_1 && token1Denom === sellAssetDenom_1));
|
|
576
|
+
});
|
|
577
|
+
if (!foundPool)
|
|
578
|
+
throw new Error('Couldnt find pool');
|
|
579
|
+
return [2 /*return*/, foundPool];
|
|
329
580
|
case 3:
|
|
330
|
-
|
|
331
|
-
throw
|
|
581
|
+
e_13 = _a.sent();
|
|
582
|
+
throw e_13;
|
|
332
583
|
case 4: return [2 /*return*/];
|
|
333
584
|
}
|
|
334
585
|
});
|
|
@@ -337,7 +588,7 @@ var get_pool = function (poolId) {
|
|
|
337
588
|
//get pools
|
|
338
589
|
var get_pools = function () {
|
|
339
590
|
return __awaiter(this, void 0, void 0, function () {
|
|
340
|
-
var tag, output, poolInfo,
|
|
591
|
+
var tag, output, poolInfo, e_14;
|
|
341
592
|
return __generator(this, function (_a) {
|
|
342
593
|
switch (_a.label) {
|
|
343
594
|
case 0:
|
|
@@ -356,8 +607,8 @@ var get_pools = function () {
|
|
|
356
607
|
// log.debug(tag,"txInfo: ",poolInfo.data)
|
|
357
608
|
return [2 /*return*/, poolInfo.data];
|
|
358
609
|
case 3:
|
|
359
|
-
|
|
360
|
-
throw
|
|
610
|
+
e_14 = _a.sent();
|
|
611
|
+
throw e_14;
|
|
361
612
|
case 4: return [2 /*return*/];
|
|
362
613
|
}
|
|
363
614
|
});
|
|
@@ -365,7 +616,7 @@ var get_pools = function () {
|
|
|
365
616
|
};
|
|
366
617
|
var get_delegations_by_address = function (address) {
|
|
367
618
|
return __awaiter(this, void 0, void 0, function () {
|
|
368
|
-
var tag, output, resp, output_2,
|
|
619
|
+
var tag, output, resp, output_2, e_15;
|
|
369
620
|
return __generator(this, function (_a) {
|
|
370
621
|
switch (_a.label) {
|
|
371
622
|
case 0:
|
|
@@ -381,8 +632,8 @@ var get_delegations_by_address = function (address) {
|
|
|
381
632
|
output_2 = resp.data.result;
|
|
382
633
|
return [2 /*return*/, output_2];
|
|
383
634
|
case 3:
|
|
384
|
-
|
|
385
|
-
throw
|
|
635
|
+
e_15 = _a.sent();
|
|
636
|
+
throw e_15;
|
|
386
637
|
case 4: return [2 /*return*/];
|
|
387
638
|
}
|
|
388
639
|
});
|
|
@@ -390,7 +641,7 @@ var get_delegations_by_address = function (address) {
|
|
|
390
641
|
};
|
|
391
642
|
var get_delegations = function (address, valAddress) {
|
|
392
643
|
return __awaiter(this, void 0, void 0, function () {
|
|
393
|
-
var tag, output, txInfo,
|
|
644
|
+
var tag, output, txInfo, e_16;
|
|
394
645
|
return __generator(this, function (_a) {
|
|
395
646
|
switch (_a.label) {
|
|
396
647
|
case 0:
|
|
@@ -409,8 +660,8 @@ var get_delegations = function (address, valAddress) {
|
|
|
409
660
|
// log.debug(tag,"txInfo: ",txInfo.data)
|
|
410
661
|
return [2 /*return*/, txInfo.data];
|
|
411
662
|
case 3:
|
|
412
|
-
|
|
413
|
-
throw
|
|
663
|
+
e_16 = _a.sent();
|
|
664
|
+
throw e_16;
|
|
414
665
|
case 4: return [2 /*return*/];
|
|
415
666
|
}
|
|
416
667
|
});
|
|
@@ -418,7 +669,7 @@ var get_delegations = function (address, valAddress) {
|
|
|
418
669
|
};
|
|
419
670
|
var get_validators = function () {
|
|
420
671
|
return __awaiter(this, void 0, void 0, function () {
|
|
421
|
-
var tag, output, txInfo, validators,
|
|
672
|
+
var tag, output, txInfo, validators, e_17;
|
|
422
673
|
return __generator(this, function (_a) {
|
|
423
674
|
switch (_a.label) {
|
|
424
675
|
case 0:
|
|
@@ -442,8 +693,8 @@ var get_validators = function () {
|
|
|
442
693
|
validators.reverse();
|
|
443
694
|
return [2 /*return*/, validators];
|
|
444
695
|
case 3:
|
|
445
|
-
|
|
446
|
-
throw
|
|
696
|
+
e_17 = _a.sent();
|
|
697
|
+
throw e_17;
|
|
447
698
|
case 4: return [2 /*return*/];
|
|
448
699
|
}
|
|
449
700
|
});
|
|
@@ -451,7 +702,7 @@ var get_validators = function () {
|
|
|
451
702
|
};
|
|
452
703
|
var get_transaction = function (txid) {
|
|
453
704
|
return __awaiter(this, void 0, void 0, function () {
|
|
454
|
-
var tag, txInfo,
|
|
705
|
+
var tag, txInfo, e_18;
|
|
455
706
|
return __generator(this, function (_a) {
|
|
456
707
|
switch (_a.label) {
|
|
457
708
|
case 0:
|
|
@@ -465,9 +716,9 @@ var get_transaction = function (txid) {
|
|
|
465
716
|
log.debug(tag, "txInfo: ", txInfo.data);
|
|
466
717
|
return [2 /*return*/, txInfo.data];
|
|
467
718
|
case 3:
|
|
468
|
-
|
|
719
|
+
e_18 = _a.sent();
|
|
469
720
|
//if not found
|
|
470
|
-
throw Error(
|
|
721
|
+
throw Error(e_18);
|
|
471
722
|
case 4: return [2 /*return*/];
|
|
472
723
|
}
|
|
473
724
|
});
|
|
@@ -475,7 +726,7 @@ var get_transaction = function (txid) {
|
|
|
475
726
|
};
|
|
476
727
|
var broadcast_transaction = function (tx) {
|
|
477
728
|
return __awaiter(this, void 0, void 0, function () {
|
|
478
|
-
var tag, output, payload, urlRemote, result2, logSend,
|
|
729
|
+
var tag, output, payload, urlRemote, result2, logSend, e_19, e_20;
|
|
479
730
|
return __generator(this, function (_a) {
|
|
480
731
|
switch (_a.label) {
|
|
481
732
|
case 0:
|
|
@@ -518,16 +769,16 @@ var broadcast_transaction = function (tx) {
|
|
|
518
769
|
output.raw = result2.data;
|
|
519
770
|
return [3 /*break*/, 5];
|
|
520
771
|
case 4:
|
|
521
|
-
|
|
772
|
+
e_19 = _a.sent();
|
|
522
773
|
//log.error(tag,"failed second broadcast e: ",e.response)
|
|
523
|
-
log.error(tag,
|
|
524
|
-
log.error(tag,
|
|
525
|
-
log.error(tag,
|
|
526
|
-
log.error(tag,
|
|
527
|
-
log.error(tag,
|
|
774
|
+
log.error(tag, e_19);
|
|
775
|
+
log.error(tag, e_19.response);
|
|
776
|
+
log.error(tag, e_19.response.data);
|
|
777
|
+
log.error(tag, e_19.response.data.error);
|
|
778
|
+
log.error(tag, e_19.response.data.error.indexOf('RPC error -32603 - Internal error: Tx already exists in cache'));
|
|
528
779
|
//throw e
|
|
529
780
|
output.success = false;
|
|
530
|
-
output.error =
|
|
781
|
+
output.error = e_19.response.data.error;
|
|
531
782
|
return [3 /*break*/, 5];
|
|
532
783
|
case 5:
|
|
533
784
|
if (output.txid) {
|
|
@@ -535,8 +786,8 @@ var broadcast_transaction = function (tx) {
|
|
|
535
786
|
}
|
|
536
787
|
return [2 /*return*/, output];
|
|
537
788
|
case 6:
|
|
538
|
-
|
|
539
|
-
console.error(tag, "throw error: ",
|
|
789
|
+
e_20 = _a.sent();
|
|
790
|
+
console.error(tag, "throw error: ", e_20);
|
|
540
791
|
return [2 /*return*/, output];
|
|
541
792
|
case 7: return [2 /*return*/];
|
|
542
793
|
}
|
|
@@ -545,7 +796,7 @@ var broadcast_transaction = function (tx) {
|
|
|
545
796
|
};
|
|
546
797
|
var get_account_info = function (address) {
|
|
547
798
|
return __awaiter(this, void 0, void 0, function () {
|
|
548
|
-
var tag, txInfo,
|
|
799
|
+
var tag, txInfo, e_21;
|
|
549
800
|
return __generator(this, function (_a) {
|
|
550
801
|
switch (_a.label) {
|
|
551
802
|
case 0:
|
|
@@ -561,9 +812,9 @@ var get_account_info = function (address) {
|
|
|
561
812
|
log.debug(tag, "txInfo: ", txInfo.data);
|
|
562
813
|
return [2 /*return*/, txInfo.data];
|
|
563
814
|
case 3:
|
|
564
|
-
|
|
565
|
-
log.error(tag, "e: ",
|
|
566
|
-
throw
|
|
815
|
+
e_21 = _a.sent();
|
|
816
|
+
log.error(tag, "e: ", e_21);
|
|
817
|
+
throw e_21;
|
|
567
818
|
case 4: return [2 /*return*/];
|
|
568
819
|
}
|
|
569
820
|
});
|
|
@@ -647,7 +898,7 @@ var normalize_tx = function (tx, address) {
|
|
|
647
898
|
};
|
|
648
899
|
var get_txs_at_height = function (height) {
|
|
649
900
|
return __awaiter(this, void 0, void 0, function () {
|
|
650
|
-
var tag, output, url, resultSends, sends,
|
|
901
|
+
var tag, output, url, resultSends, sends, e_22;
|
|
651
902
|
return __generator(this, function (_a) {
|
|
652
903
|
switch (_a.label) {
|
|
653
904
|
case 0:
|
|
@@ -672,9 +923,9 @@ var get_txs_at_height = function (height) {
|
|
|
672
923
|
//log.debug('sends: ', sends)
|
|
673
924
|
return [2 /*return*/, sends];
|
|
674
925
|
case 3:
|
|
675
|
-
|
|
676
|
-
log.error(tag, "e: ",
|
|
677
|
-
throw
|
|
926
|
+
e_22 = _a.sent();
|
|
927
|
+
log.error(tag, "e: ", e_22);
|
|
928
|
+
throw e_22;
|
|
678
929
|
case 4: return [2 /*return*/];
|
|
679
930
|
}
|
|
680
931
|
});
|
|
@@ -682,7 +933,7 @@ var get_txs_at_height = function (height) {
|
|
|
682
933
|
};
|
|
683
934
|
var get_txs_by_address = function (address) {
|
|
684
935
|
return __awaiter(this, void 0, void 0, function () {
|
|
685
|
-
var tag, output, url, resultSends, sends, i, tx,
|
|
936
|
+
var tag, output, url, resultSends, sends, i, tx, e_23;
|
|
686
937
|
return __generator(this, function (_a) {
|
|
687
938
|
switch (_a.label) {
|
|
688
939
|
case 0:
|
|
@@ -730,9 +981,9 @@ var get_txs_by_address = function (address) {
|
|
|
730
981
|
// }
|
|
731
982
|
return [2 /*return*/, output];
|
|
732
983
|
case 3:
|
|
733
|
-
|
|
734
|
-
log.error(tag, "e: ",
|
|
735
|
-
throw
|
|
984
|
+
e_23 = _a.sent();
|
|
985
|
+
log.error(tag, "e: ", e_23);
|
|
986
|
+
throw e_23;
|
|
736
987
|
case 4: return [2 /*return*/];
|
|
737
988
|
}
|
|
738
989
|
});
|
|
@@ -741,7 +992,7 @@ var get_txs_by_address = function (address) {
|
|
|
741
992
|
var get_balances = function (address) {
|
|
742
993
|
var _a;
|
|
743
994
|
return __awaiter(this, void 0, void 0, function () {
|
|
744
|
-
var tag, output, accountInfo, i, entry, balance, voucher, voucherInfo, balance, poolInfo, totalShares, poolAssets, assetAtom, assetOsmo, totalAtom, totalOsmo, yourLpTokens, yourLpPercent, yourAtomInPool, yourOsmoInPool, balance,
|
|
995
|
+
var tag, output, accountInfo, i, entry, balance, voucher, voucherInfo, balance, poolInfo, totalShares, poolAssets, assetAtom, assetOsmo, totalAtom, totalOsmo, yourLpTokens, yourLpPercent, yourAtomInPool, yourOsmoInPool, balance, e_24, e_25;
|
|
745
996
|
return __generator(this, function (_b) {
|
|
746
997
|
switch (_b.label) {
|
|
747
998
|
case 0:
|
|
@@ -756,7 +1007,7 @@ var get_balances = function (address) {
|
|
|
756
1007
|
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/bank/balances/' + address })];
|
|
757
1008
|
case 3:
|
|
758
1009
|
accountInfo = _b.sent();
|
|
759
|
-
log.
|
|
1010
|
+
log.info(tag, "accountInfo: ", accountInfo.data);
|
|
760
1011
|
if (!((_a = accountInfo.data) === null || _a === void 0 ? void 0 : _a.result)) return [3 /*break*/, 9];
|
|
761
1012
|
i = 0;
|
|
762
1013
|
_b.label = 4;
|
|
@@ -774,11 +1025,11 @@ var get_balances = function (address) {
|
|
|
774
1025
|
}
|
|
775
1026
|
if (!(entry.denom.indexOf('ibc/') >= 0)) return [3 /*break*/, 6];
|
|
776
1027
|
voucher = entry.denom.replace('ibc/', '');
|
|
777
|
-
log.
|
|
1028
|
+
log.info(tag, "voucher: ", voucher);
|
|
778
1029
|
return [4 /*yield*/, get_voucher_info(voucher)];
|
|
779
1030
|
case 5:
|
|
780
1031
|
voucherInfo = _b.sent();
|
|
781
|
-
log.
|
|
1032
|
+
log.info(tag, "voucherInfo: ", voucherInfo);
|
|
782
1033
|
if (voucherInfo.denom_trace.base_denom === 'uatom') {
|
|
783
1034
|
balance = {
|
|
784
1035
|
type: 'ibcChannel',
|
|
@@ -840,13 +1091,13 @@ var get_balances = function (address) {
|
|
|
840
1091
|
return [3 /*break*/, 4];
|
|
841
1092
|
case 9: return [3 /*break*/, 11];
|
|
842
1093
|
case 10:
|
|
843
|
-
|
|
1094
|
+
e_24 = _b.sent();
|
|
844
1095
|
return [3 /*break*/, 11];
|
|
845
1096
|
case 11: return [2 /*return*/, output];
|
|
846
1097
|
case 12:
|
|
847
|
-
|
|
848
|
-
log.error(tag, "e: ",
|
|
849
|
-
throw
|
|
1098
|
+
e_25 = _b.sent();
|
|
1099
|
+
log.error(tag, "e: ", e_25);
|
|
1100
|
+
throw e_25;
|
|
850
1101
|
case 13: return [2 /*return*/];
|
|
851
1102
|
}
|
|
852
1103
|
});
|
|
@@ -855,7 +1106,7 @@ var get_balances = function (address) {
|
|
|
855
1106
|
var get_balance = function (address) {
|
|
856
1107
|
var _a;
|
|
857
1108
|
return __awaiter(this, void 0, void 0, function () {
|
|
858
|
-
var tag, output, accountInfo, i, entry,
|
|
1109
|
+
var tag, output, accountInfo, i, entry, e_26, e_27;
|
|
859
1110
|
return __generator(this, function (_b) {
|
|
860
1111
|
switch (_b.label) {
|
|
861
1112
|
case 0:
|
|
@@ -884,13 +1135,13 @@ var get_balance = function (address) {
|
|
|
884
1135
|
output = output / BASE_OSMO;
|
|
885
1136
|
return [3 /*break*/, 5];
|
|
886
1137
|
case 4:
|
|
887
|
-
|
|
1138
|
+
e_26 = _b.sent();
|
|
888
1139
|
return [3 /*break*/, 5];
|
|
889
1140
|
case 5: return [2 /*return*/, output];
|
|
890
1141
|
case 6:
|
|
891
|
-
|
|
892
|
-
log.error(tag, "e: ",
|
|
893
|
-
throw
|
|
1142
|
+
e_27 = _b.sent();
|
|
1143
|
+
log.error(tag, "e: ", e_27);
|
|
1144
|
+
throw e_27;
|
|
894
1145
|
case 7: return [2 /*return*/];
|
|
895
1146
|
}
|
|
896
1147
|
});
|
|
@@ -898,7 +1149,7 @@ var get_balance = function (address) {
|
|
|
898
1149
|
};
|
|
899
1150
|
var get_node_info_verbose = function () {
|
|
900
1151
|
return __awaiter(this, void 0, void 0, function () {
|
|
901
|
-
var tag, output, syncInfo, nodeInfo,
|
|
1152
|
+
var tag, output, syncInfo, nodeInfo, e_28;
|
|
902
1153
|
return __generator(this, function (_a) {
|
|
903
1154
|
switch (_a.label) {
|
|
904
1155
|
case 0:
|
|
@@ -923,9 +1174,9 @@ var get_node_info_verbose = function () {
|
|
|
923
1174
|
//output.height = lastBlock.data.block.header.height
|
|
924
1175
|
return [2 /*return*/, output];
|
|
925
1176
|
case 4:
|
|
926
|
-
|
|
927
|
-
log.error(tag, "e: ",
|
|
928
|
-
throw
|
|
1177
|
+
e_28 = _a.sent();
|
|
1178
|
+
log.error(tag, "e: ", e_28);
|
|
1179
|
+
throw e_28;
|
|
929
1180
|
case 5: return [2 /*return*/];
|
|
930
1181
|
}
|
|
931
1182
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/osmosis-network",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.36",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"refresh": "rm -rf ./node_modules ./package-lock.json && npm install"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"@keplr-wallet/unit": "^0.10.2",
|
|
14
15
|
"@pioneer-platform/loggerdog": "^8.1.17",
|
|
15
16
|
"@tendermint/amino-js": "^0.6.2",
|
|
16
17
|
"bech32": "^1.1.4",
|