@pioneer-platform/osmosis-network 8.1.31 → 8.1.34
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.d.ts +1 -26
- package/lib/index.js +395 -91
- package/package.json +2 -1
- package/LICENSE +0 -674
package/lib/index.js
CHANGED
|
@@ -35,11 +35,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
39
|
/*
|
|
39
40
|
OSMO Network
|
|
40
41
|
|
|
41
42
|
https://api-osmosis.imperator.co/swagger/#/
|
|
42
43
|
|
|
44
|
+
OSMO version of cosmoSDK
|
|
45
|
+
https://v1.cosmos.network/rpc/v0.41.4
|
|
46
|
+
|
|
43
47
|
|
|
44
48
|
https://github.com/osmosis-labs/osmosis-frontend/tree/master/src/stores/osmosis/query
|
|
45
49
|
|
|
@@ -67,6 +71,11 @@ https://github.com/osmosis-labs/osmosis-frontend/tree/master/src/stores/osmosis/
|
|
|
67
71
|
`/ibc/core/channel/v1beta1/channels/${params.channelId}/ports/${params.portId}`
|
|
68
72
|
`/ibc/core/channel/v1beta1/channels/${channelId}/ports/${portId}/client_state`
|
|
69
73
|
"/cosmos/base/tendermint/v1beta1/node_info"
|
|
74
|
+
|
|
75
|
+
voucher denoum trace
|
|
76
|
+
/ibc/applications/transfer/v1beta1/denom_traces
|
|
77
|
+
|
|
78
|
+
|
|
70
79
|
*/
|
|
71
80
|
var pjson = require("../package.json");
|
|
72
81
|
var TAG = " | " + pjson.name.replace("@pioneer-platform/", "") + " | ";
|
|
@@ -87,7 +96,7 @@ var URL_OSMO_LCD = process.env['URL_OSMO_LCD'];
|
|
|
87
96
|
if (!URL_OSMO_LCD)
|
|
88
97
|
throw Error('missing env URL_OSMO_LCD');
|
|
89
98
|
var URL_OSMO_POOLS = process.env['URL_OSMO_POOLS'] || "https://api-osmosis.imperator.co";
|
|
90
|
-
var BASE_OSMO =
|
|
99
|
+
var BASE_OSMO = 1000000;
|
|
91
100
|
/**********************************
|
|
92
101
|
// Module
|
|
93
102
|
//**********************************/
|
|
@@ -110,16 +119,25 @@ module.exports = {
|
|
|
110
119
|
getBalances: function (address) {
|
|
111
120
|
return get_balances(address);
|
|
112
121
|
},
|
|
122
|
+
getDelegations: function (address) {
|
|
123
|
+
return get_delegations_by_address(address);
|
|
124
|
+
},
|
|
125
|
+
getRewards: function (address) {
|
|
126
|
+
return get_rewards(address);
|
|
127
|
+
},
|
|
113
128
|
getAccount: function (address) {
|
|
114
129
|
return get_account_info(address);
|
|
115
130
|
},
|
|
131
|
+
getIbcTrace: function (voucher) {
|
|
132
|
+
return get_voucher_info(voucher);
|
|
133
|
+
},
|
|
116
134
|
getPools: function () {
|
|
117
135
|
return get_pools();
|
|
118
136
|
},
|
|
119
137
|
getValidators: function () {
|
|
120
138
|
return get_validators();
|
|
121
139
|
},
|
|
122
|
-
|
|
140
|
+
getDelegationsByValidator: function (address, validator) {
|
|
123
141
|
return get_delegations(address, validator);
|
|
124
142
|
},
|
|
125
143
|
getAccountInfo: function (address) {
|
|
@@ -128,9 +146,18 @@ module.exports = {
|
|
|
128
146
|
txs: function (address) {
|
|
129
147
|
return get_txs_by_address(address);
|
|
130
148
|
},
|
|
149
|
+
txsAtHeight: function (height) {
|
|
150
|
+
return get_txs_at_height(height);
|
|
151
|
+
},
|
|
152
|
+
getBlock: function (block) {
|
|
153
|
+
return get_block(block);
|
|
154
|
+
},
|
|
131
155
|
getTransaction: function (txid) {
|
|
132
156
|
return get_transaction(txid);
|
|
133
157
|
},
|
|
158
|
+
getStakingTxs: function (address) {
|
|
159
|
+
return get_staking_txs(address);
|
|
160
|
+
},
|
|
134
161
|
transaction: function (txid) {
|
|
135
162
|
return get_transaction(txid);
|
|
136
163
|
},
|
|
@@ -141,10 +168,126 @@ module.exports = {
|
|
|
141
168
|
/**********************************
|
|
142
169
|
// Lib
|
|
143
170
|
//**********************************/
|
|
171
|
+
var get_voucher_info = function (voucher) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
+
var tag, url, txInfo, e_1;
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
switch (_a.label) {
|
|
176
|
+
case 0:
|
|
177
|
+
tag = TAG + " | get_voucher_info | ";
|
|
178
|
+
_a.label = 1;
|
|
179
|
+
case 1:
|
|
180
|
+
_a.trys.push([1, 3, , 4]);
|
|
181
|
+
url = URL_OSMO_LCD + '/ibc/applications/transfer/v1beta1/denom_traces/' + voucher;
|
|
182
|
+
log.debug(tag, "url: ", url);
|
|
183
|
+
return [4 /*yield*/, axios({ method: 'GET', url: url })];
|
|
184
|
+
case 2:
|
|
185
|
+
txInfo = _a.sent();
|
|
186
|
+
log.debug(tag, "txInfo: ", txInfo.data);
|
|
187
|
+
return [2 /*return*/, txInfo.data];
|
|
188
|
+
case 3:
|
|
189
|
+
e_1 = _a.sent();
|
|
190
|
+
throw e_1;
|
|
191
|
+
case 4: return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
var get_block = function (height) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
+
var tag, output, txInfo, e_2;
|
|
199
|
+
return __generator(this, function (_a) {
|
|
200
|
+
switch (_a.label) {
|
|
201
|
+
case 0:
|
|
202
|
+
tag = TAG + " | get_block | ";
|
|
203
|
+
output = {};
|
|
204
|
+
_a.label = 1;
|
|
205
|
+
case 1:
|
|
206
|
+
_a.trys.push([1, 3, , 4]);
|
|
207
|
+
//
|
|
208
|
+
log.debug(tag, " URL_OSMO_LCD: ", URL_OSMO_LCD);
|
|
209
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/blocks/' + height })
|
|
210
|
+
// log.debug(tag,"txInfo: ",txInfo.data)
|
|
211
|
+
//for each tx in block decode
|
|
212
|
+
// log.debug(tag,"txInfo: ",txInfo.data.block)
|
|
213
|
+
];
|
|
214
|
+
case 2:
|
|
215
|
+
txInfo = _a.sent();
|
|
216
|
+
// log.debug(tag,"txInfo: ",txInfo.data)
|
|
217
|
+
//for each tx in block decode
|
|
218
|
+
// log.debug(tag,"txInfo: ",txInfo.data.block)
|
|
219
|
+
log.debug(tag, "txInfo: ", txInfo.data.block.data.txs);
|
|
220
|
+
// txInfo.data.block.data.txsDecoded = []
|
|
221
|
+
// for(let i = 0; i < txInfo.data.block.data.txs.length; i++){
|
|
222
|
+
// let txEncoded = txInfo.data.block.data.txs[i]
|
|
223
|
+
// let txDecoded = unmarshalTx(txEncoded)
|
|
224
|
+
// log.debug(tag,"txDecoded: ", txDecoded )
|
|
225
|
+
// txInfo.data.block.data.txsDecoded(txDecoded)
|
|
226
|
+
// }
|
|
227
|
+
log.debug(tag, "txInfo: ", txInfo.data.block.data.txs);
|
|
228
|
+
return [2 /*return*/, txInfo.data];
|
|
229
|
+
case 3:
|
|
230
|
+
e_2 = _a.sent();
|
|
231
|
+
//TODO dont shh error fix em
|
|
232
|
+
throw e_2;
|
|
233
|
+
case 4: return [2 /*return*/];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
var get_staking_txs = function (address) {
|
|
239
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
240
|
+
var tag, output, txInfo, e_3;
|
|
241
|
+
return __generator(this, function (_a) {
|
|
242
|
+
switch (_a.label) {
|
|
243
|
+
case 0:
|
|
244
|
+
tag = TAG + " | get_staking_txs | ";
|
|
245
|
+
output = {};
|
|
246
|
+
_a.label = 1;
|
|
247
|
+
case 1:
|
|
248
|
+
_a.trys.push([1, 3, , 4]);
|
|
249
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/txs?delegator=' + address })];
|
|
250
|
+
case 2:
|
|
251
|
+
txInfo = _a.sent();
|
|
252
|
+
log.debug(tag, "txInfo: ", txInfo.data);
|
|
253
|
+
return [2 /*return*/, txInfo.data];
|
|
254
|
+
case 3:
|
|
255
|
+
e_3 = _a.sent();
|
|
256
|
+
throw e_3;
|
|
257
|
+
case 4: return [2 /*return*/];
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
var get_rewards = function (address) {
|
|
263
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
+
var tag, output, resp, output_1, e_4;
|
|
265
|
+
return __generator(this, function (_a) {
|
|
266
|
+
switch (_a.label) {
|
|
267
|
+
case 0:
|
|
268
|
+
tag = TAG + " | get_rewards | ";
|
|
269
|
+
output = {};
|
|
270
|
+
_a.label = 1;
|
|
271
|
+
case 1:
|
|
272
|
+
_a.trys.push([1, 3, , 4]);
|
|
273
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/distribution/delegators/' + address + '/rewards' })];
|
|
274
|
+
case 2:
|
|
275
|
+
resp = _a.sent();
|
|
276
|
+
log.debug(tag, "resp: ", resp.data);
|
|
277
|
+
output_1 = resp.data;
|
|
278
|
+
return [2 /*return*/, output_1];
|
|
279
|
+
case 3:
|
|
280
|
+
e_4 = _a.sent();
|
|
281
|
+
throw e_4;
|
|
282
|
+
case 4: return [2 /*return*/];
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
};
|
|
144
287
|
//
|
|
145
288
|
var get_block_height = function () {
|
|
146
289
|
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
-
var tag, output, resp, height,
|
|
290
|
+
var tag, output, resp, height, e_5;
|
|
148
291
|
return __generator(this, function (_a) {
|
|
149
292
|
switch (_a.label) {
|
|
150
293
|
case 0:
|
|
@@ -160,8 +303,32 @@ var get_block_height = function () {
|
|
|
160
303
|
height = resp.data.block.header.height;
|
|
161
304
|
return [2 /*return*/, parseInt(height)];
|
|
162
305
|
case 3:
|
|
163
|
-
|
|
164
|
-
throw
|
|
306
|
+
e_5 = _a.sent();
|
|
307
|
+
throw e_5;
|
|
308
|
+
case 4: return [2 /*return*/];
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
var get_pool = function (poolId) {
|
|
314
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
315
|
+
var tag, output, poolInfo, e_6;
|
|
316
|
+
return __generator(this, function (_a) {
|
|
317
|
+
switch (_a.label) {
|
|
318
|
+
case 0:
|
|
319
|
+
tag = TAG + " | get_pools | ";
|
|
320
|
+
output = {};
|
|
321
|
+
_a.label = 1;
|
|
322
|
+
case 1:
|
|
323
|
+
_a.trys.push([1, 3, , 4]);
|
|
324
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/osmosis/gamm/v1beta1/pool/' + poolId })];
|
|
325
|
+
case 2:
|
|
326
|
+
poolInfo = _a.sent();
|
|
327
|
+
log.debug(tag, "poolInfo: ", poolInfo.data);
|
|
328
|
+
return [2 /*return*/, poolInfo.data];
|
|
329
|
+
case 3:
|
|
330
|
+
e_6 = _a.sent();
|
|
331
|
+
throw e_6;
|
|
165
332
|
case 4: return [2 /*return*/];
|
|
166
333
|
}
|
|
167
334
|
});
|
|
@@ -170,7 +337,7 @@ var get_block_height = function () {
|
|
|
170
337
|
//get pools
|
|
171
338
|
var get_pools = function () {
|
|
172
339
|
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
-
var tag, output, poolInfo,
|
|
340
|
+
var tag, output, poolInfo, e_7;
|
|
174
341
|
return __generator(this, function (_a) {
|
|
175
342
|
switch (_a.label) {
|
|
176
343
|
case 0:
|
|
@@ -189,8 +356,33 @@ var get_pools = function () {
|
|
|
189
356
|
// log.debug(tag,"txInfo: ",poolInfo.data)
|
|
190
357
|
return [2 /*return*/, poolInfo.data];
|
|
191
358
|
case 3:
|
|
192
|
-
|
|
193
|
-
throw
|
|
359
|
+
e_7 = _a.sent();
|
|
360
|
+
throw e_7;
|
|
361
|
+
case 4: return [2 /*return*/];
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
var get_delegations_by_address = function (address) {
|
|
367
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
368
|
+
var tag, output, resp, output_2, e_8;
|
|
369
|
+
return __generator(this, function (_a) {
|
|
370
|
+
switch (_a.label) {
|
|
371
|
+
case 0:
|
|
372
|
+
tag = TAG + " | get_delegations_by_validator | ";
|
|
373
|
+
output = {};
|
|
374
|
+
_a.label = 1;
|
|
375
|
+
case 1:
|
|
376
|
+
_a.trys.push([1, 3, , 4]);
|
|
377
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/staking/delegators/' + address + '/delegations' })];
|
|
378
|
+
case 2:
|
|
379
|
+
resp = _a.sent();
|
|
380
|
+
log.debug(tag, "resp: ", resp.data);
|
|
381
|
+
output_2 = resp.data.result;
|
|
382
|
+
return [2 /*return*/, output_2];
|
|
383
|
+
case 3:
|
|
384
|
+
e_8 = _a.sent();
|
|
385
|
+
throw e_8;
|
|
194
386
|
case 4: return [2 /*return*/];
|
|
195
387
|
}
|
|
196
388
|
});
|
|
@@ -198,7 +390,7 @@ var get_pools = function () {
|
|
|
198
390
|
};
|
|
199
391
|
var get_delegations = function (address, valAddress) {
|
|
200
392
|
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
-
var tag, output, txInfo,
|
|
393
|
+
var tag, output, txInfo, e_9;
|
|
202
394
|
return __generator(this, function (_a) {
|
|
203
395
|
switch (_a.label) {
|
|
204
396
|
case 0:
|
|
@@ -217,8 +409,8 @@ var get_delegations = function (address, valAddress) {
|
|
|
217
409
|
// log.debug(tag,"txInfo: ",txInfo.data)
|
|
218
410
|
return [2 /*return*/, txInfo.data];
|
|
219
411
|
case 3:
|
|
220
|
-
|
|
221
|
-
throw
|
|
412
|
+
e_9 = _a.sent();
|
|
413
|
+
throw e_9;
|
|
222
414
|
case 4: return [2 /*return*/];
|
|
223
415
|
}
|
|
224
416
|
});
|
|
@@ -226,7 +418,7 @@ var get_delegations = function (address, valAddress) {
|
|
|
226
418
|
};
|
|
227
419
|
var get_validators = function () {
|
|
228
420
|
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
-
var tag, output, txInfo, validators,
|
|
421
|
+
var tag, output, txInfo, validators, e_10;
|
|
230
422
|
return __generator(this, function (_a) {
|
|
231
423
|
switch (_a.label) {
|
|
232
424
|
case 0:
|
|
@@ -250,8 +442,8 @@ var get_validators = function () {
|
|
|
250
442
|
validators.reverse();
|
|
251
443
|
return [2 /*return*/, validators];
|
|
252
444
|
case 3:
|
|
253
|
-
|
|
254
|
-
throw
|
|
445
|
+
e_10 = _a.sent();
|
|
446
|
+
throw e_10;
|
|
255
447
|
case 4: return [2 /*return*/];
|
|
256
448
|
}
|
|
257
449
|
});
|
|
@@ -259,7 +451,7 @@ var get_validators = function () {
|
|
|
259
451
|
};
|
|
260
452
|
var get_transaction = function (txid) {
|
|
261
453
|
return __awaiter(this, void 0, void 0, function () {
|
|
262
|
-
var tag, txInfo,
|
|
454
|
+
var tag, txInfo, e_11;
|
|
263
455
|
return __generator(this, function (_a) {
|
|
264
456
|
switch (_a.label) {
|
|
265
457
|
case 0:
|
|
@@ -273,8 +465,9 @@ var get_transaction = function (txid) {
|
|
|
273
465
|
log.debug(tag, "txInfo: ", txInfo.data);
|
|
274
466
|
return [2 /*return*/, txInfo.data];
|
|
275
467
|
case 3:
|
|
276
|
-
|
|
277
|
-
|
|
468
|
+
e_11 = _a.sent();
|
|
469
|
+
//if not found
|
|
470
|
+
throw Error(e_11);
|
|
278
471
|
case 4: return [2 /*return*/];
|
|
279
472
|
}
|
|
280
473
|
});
|
|
@@ -282,7 +475,7 @@ var get_transaction = function (txid) {
|
|
|
282
475
|
};
|
|
283
476
|
var broadcast_transaction = function (tx) {
|
|
284
477
|
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
-
var tag, output,
|
|
478
|
+
var tag, output, payload, urlRemote, result2, logSend, e_12, e_13;
|
|
286
479
|
return __generator(this, function (_a) {
|
|
287
480
|
switch (_a.label) {
|
|
288
481
|
case 0:
|
|
@@ -296,13 +489,16 @@ var broadcast_transaction = function (tx) {
|
|
|
296
489
|
_a.label = 2;
|
|
297
490
|
case 2:
|
|
298
491
|
_a.trys.push([2, 4, , 5]);
|
|
299
|
-
|
|
300
|
-
|
|
492
|
+
payload = {
|
|
493
|
+
"tx_bytes": tx,
|
|
494
|
+
"mode": "BROADCAST_MODE_SYNC"
|
|
495
|
+
};
|
|
496
|
+
urlRemote = URL_OSMO_LCD + '/cosmos/tx/v1beta1/txs';
|
|
301
497
|
log.debug(tag, "urlRemote: ", urlRemote);
|
|
302
498
|
return [4 /*yield*/, axios({
|
|
303
499
|
url: urlRemote,
|
|
304
500
|
method: 'POST',
|
|
305
|
-
data:
|
|
501
|
+
data: payload,
|
|
306
502
|
})];
|
|
307
503
|
case 3:
|
|
308
504
|
result2 = _a.sent();
|
|
@@ -320,16 +516,16 @@ var broadcast_transaction = function (tx) {
|
|
|
320
516
|
output.raw = result2.data;
|
|
321
517
|
return [3 /*break*/, 5];
|
|
322
518
|
case 4:
|
|
323
|
-
|
|
519
|
+
e_12 = _a.sent();
|
|
324
520
|
//log.error(tag,"failed second broadcast e: ",e.response)
|
|
325
|
-
log.error(tag,
|
|
326
|
-
log.error(tag,
|
|
327
|
-
log.error(tag,
|
|
328
|
-
log.error(tag,
|
|
329
|
-
log.error(tag,
|
|
521
|
+
log.error(tag, e_12);
|
|
522
|
+
log.error(tag, e_12.response);
|
|
523
|
+
log.error(tag, e_12.response.data);
|
|
524
|
+
log.error(tag, e_12.response.data.error);
|
|
525
|
+
log.error(tag, e_12.response.data.error.indexOf('RPC error -32603 - Internal error: Tx already exists in cache'));
|
|
330
526
|
//throw e
|
|
331
527
|
output.success = false;
|
|
332
|
-
output.error =
|
|
528
|
+
output.error = e_12.response.data.error;
|
|
333
529
|
return [3 /*break*/, 5];
|
|
334
530
|
case 5:
|
|
335
531
|
if (output.txid) {
|
|
@@ -337,8 +533,8 @@ var broadcast_transaction = function (tx) {
|
|
|
337
533
|
}
|
|
338
534
|
return [2 /*return*/, output];
|
|
339
535
|
case 6:
|
|
340
|
-
|
|
341
|
-
console.error(tag, "throw error: ",
|
|
536
|
+
e_13 = _a.sent();
|
|
537
|
+
console.error(tag, "throw error: ", e_13);
|
|
342
538
|
return [2 /*return*/, output];
|
|
343
539
|
case 7: return [2 /*return*/];
|
|
344
540
|
}
|
|
@@ -347,7 +543,7 @@ var broadcast_transaction = function (tx) {
|
|
|
347
543
|
};
|
|
348
544
|
var get_account_info = function (address) {
|
|
349
545
|
return __awaiter(this, void 0, void 0, function () {
|
|
350
|
-
var tag, txInfo,
|
|
546
|
+
var tag, txInfo, e_14;
|
|
351
547
|
return __generator(this, function (_a) {
|
|
352
548
|
switch (_a.label) {
|
|
353
549
|
case 0:
|
|
@@ -363,9 +559,9 @@ var get_account_info = function (address) {
|
|
|
363
559
|
log.debug(tag, "txInfo: ", txInfo.data);
|
|
364
560
|
return [2 /*return*/, txInfo.data];
|
|
365
561
|
case 3:
|
|
366
|
-
|
|
367
|
-
log.error(tag, "e: ",
|
|
368
|
-
throw
|
|
562
|
+
e_14 = _a.sent();
|
|
563
|
+
log.error(tag, "e: ", e_14);
|
|
564
|
+
throw e_14;
|
|
369
565
|
case 4: return [2 /*return*/];
|
|
370
566
|
}
|
|
371
567
|
});
|
|
@@ -447,18 +643,54 @@ var normalize_tx = function (tx, address) {
|
|
|
447
643
|
throw e;
|
|
448
644
|
}
|
|
449
645
|
};
|
|
646
|
+
var get_txs_at_height = function (height) {
|
|
647
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
648
|
+
var tag, output, url, resultSends, sends, e_15;
|
|
649
|
+
return __generator(this, function (_a) {
|
|
650
|
+
switch (_a.label) {
|
|
651
|
+
case 0:
|
|
652
|
+
tag = TAG + " | get_txs_by_address | ";
|
|
653
|
+
_a.label = 1;
|
|
654
|
+
case 1:
|
|
655
|
+
_a.trys.push([1, 3, , 4]);
|
|
656
|
+
output = [];
|
|
657
|
+
url = URL_OSMO_LCD + '/cosmos/tx/v1beta1/txs?events=tx.height=%27' + height + '%27';
|
|
658
|
+
// let url = URL_OSMO_LCD+ '/txs?block.height='+height
|
|
659
|
+
// let url = URL_OSMO_LCD+ '/txs?tx.height='+height
|
|
660
|
+
//tx.height=
|
|
661
|
+
//?tx.height=1891147&page=1
|
|
662
|
+
log.debug(tag, "url: ", url);
|
|
663
|
+
return [4 /*yield*/, axios({
|
|
664
|
+
url: url,
|
|
665
|
+
method: 'GET'
|
|
666
|
+
})];
|
|
667
|
+
case 2:
|
|
668
|
+
resultSends = _a.sent();
|
|
669
|
+
sends = resultSends.data;
|
|
670
|
+
//log.debug('sends: ', sends)
|
|
671
|
+
return [2 /*return*/, sends];
|
|
672
|
+
case 3:
|
|
673
|
+
e_15 = _a.sent();
|
|
674
|
+
log.error(tag, "e: ", e_15);
|
|
675
|
+
throw e_15;
|
|
676
|
+
case 4: return [2 /*return*/];
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
};
|
|
450
681
|
var get_txs_by_address = function (address) {
|
|
451
682
|
return __awaiter(this, void 0, void 0, function () {
|
|
452
|
-
var tag, output, url, resultSends, sends, i, tx,
|
|
683
|
+
var tag, output, url, resultSends, sends, i, tx, e_16;
|
|
453
684
|
return __generator(this, function (_a) {
|
|
454
685
|
switch (_a.label) {
|
|
455
686
|
case 0:
|
|
456
687
|
tag = TAG + " | get_txs_by_address | ";
|
|
457
688
|
_a.label = 1;
|
|
458
689
|
case 1:
|
|
459
|
-
_a.trys.push([1,
|
|
690
|
+
_a.trys.push([1, 3, , 4]);
|
|
460
691
|
output = [];
|
|
461
|
-
url = URL_OSMO_LCD + '/txs?transfer.sender
|
|
692
|
+
url = URL_OSMO_LCD + '/cosmos/tx/v1beta1/txs?events=transfer.sender=%27' + address + '%27';
|
|
693
|
+
//let url = URL_OSMO_LCD+ '/txs?message.sender='+address
|
|
462
694
|
log.debug(tag, "url: ", url);
|
|
463
695
|
return [4 /*yield*/, axios({
|
|
464
696
|
url: url,
|
|
@@ -471,34 +703,35 @@ var get_txs_by_address = function (address) {
|
|
|
471
703
|
if (sends.txs) {
|
|
472
704
|
for (i = 0; i < sends.txs.length; i++) {
|
|
473
705
|
tx = sends.txs[i];
|
|
474
|
-
tx = normalize_tx(tx,
|
|
706
|
+
//tx = normalize_tx(tx,address)
|
|
475
707
|
output.push(tx);
|
|
476
708
|
}
|
|
477
709
|
}
|
|
478
710
|
//receives
|
|
479
|
-
url = URL_OSMO_LCD
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
//
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
711
|
+
//url = URL_OSMO_LCD+ '/txs?transfer.recipient='+address
|
|
712
|
+
//
|
|
713
|
+
// url = URL_OSMO_LCD+ '/cosmos/tx/v1beta1/txs?events=transfer.recipient=%27'+address+'%27'
|
|
714
|
+
// //console.log("URL_OSMO_LCD: ",url)
|
|
715
|
+
// let resultRecieves = await axios({
|
|
716
|
+
// url: url,
|
|
717
|
+
// method: 'GET'
|
|
718
|
+
// })
|
|
719
|
+
// let receives = resultRecieves.data
|
|
720
|
+
// //log.debug('receives: ', JSON.stringify(receives.tx_responses))
|
|
721
|
+
// if(receives.tx_responses){
|
|
722
|
+
// for(let i = 0; i < receives.txs.length; i++ ){
|
|
723
|
+
// let tx = receives.txs[i]
|
|
724
|
+
// //normalize
|
|
725
|
+
// // tx = normalize_tx(tx,address)
|
|
726
|
+
// output.push(tx)
|
|
727
|
+
// }
|
|
728
|
+
// }
|
|
496
729
|
return [2 /*return*/, output];
|
|
497
|
-
case
|
|
498
|
-
|
|
499
|
-
log.error(tag, "e: ",
|
|
500
|
-
throw
|
|
501
|
-
case
|
|
730
|
+
case 3:
|
|
731
|
+
e_16 = _a.sent();
|
|
732
|
+
log.error(tag, "e: ", e_16);
|
|
733
|
+
throw e_16;
|
|
734
|
+
case 4: return [2 /*return*/];
|
|
502
735
|
}
|
|
503
736
|
});
|
|
504
737
|
});
|
|
@@ -506,42 +739,113 @@ var get_txs_by_address = function (address) {
|
|
|
506
739
|
var get_balances = function (address) {
|
|
507
740
|
var _a;
|
|
508
741
|
return __awaiter(this, void 0, void 0, function () {
|
|
509
|
-
var tag, output, accountInfo, i, entry,
|
|
742
|
+
var tag, output, accountInfo, i, entry, balance, voucher, voucherInfo, balance, poolInfo, totalShares, poolAssets, assetAtom, assetOsmo, totalAtom, totalOsmo, yourLpTokens, yourLpPercent, yourAtomInPool, yourOsmoInPool, balance, e_17, e_18;
|
|
510
743
|
return __generator(this, function (_b) {
|
|
511
744
|
switch (_b.label) {
|
|
512
745
|
case 0:
|
|
513
746
|
tag = TAG + " | get_balances | ";
|
|
514
747
|
_b.label = 1;
|
|
515
748
|
case 1:
|
|
516
|
-
_b.trys.push([1,
|
|
517
|
-
output =
|
|
749
|
+
_b.trys.push([1, 12, , 13]);
|
|
750
|
+
output = [];
|
|
518
751
|
_b.label = 2;
|
|
519
752
|
case 2:
|
|
520
|
-
_b.trys.push([2,
|
|
753
|
+
_b.trys.push([2, 10, , 11]);
|
|
521
754
|
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/bank/balances/' + address })];
|
|
522
755
|
case 3:
|
|
523
756
|
accountInfo = _b.sent();
|
|
524
757
|
log.debug(tag, "accountInfo: ", accountInfo.data);
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
entry = accountInfo.data.result[i];
|
|
529
|
-
if (entry.denom === 'uosmo') {
|
|
530
|
-
output = entry.amount;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
output = output / BASE_OSMO;
|
|
535
|
-
return [3 /*break*/, 5];
|
|
758
|
+
if (!((_a = accountInfo.data) === null || _a === void 0 ? void 0 : _a.result)) return [3 /*break*/, 9];
|
|
759
|
+
i = 0;
|
|
760
|
+
_b.label = 4;
|
|
536
761
|
case 4:
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
762
|
+
if (!(i < accountInfo.data.result.length)) return [3 /*break*/, 9];
|
|
763
|
+
entry = accountInfo.data.result[i];
|
|
764
|
+
if (entry.denom === 'uosmo') {
|
|
765
|
+
balance = {
|
|
766
|
+
type: 'balance',
|
|
767
|
+
asset: 'OSMO',
|
|
768
|
+
denom: 'uosmo',
|
|
769
|
+
balance: entry.amount
|
|
770
|
+
};
|
|
771
|
+
output.push(balance);
|
|
772
|
+
}
|
|
773
|
+
if (!(entry.denom.indexOf('ibc/') >= 0)) return [3 /*break*/, 6];
|
|
774
|
+
voucher = entry.denom.replace('ibc/', '');
|
|
775
|
+
log.debug(tag, "voucher: ", voucher);
|
|
776
|
+
return [4 /*yield*/, get_voucher_info(voucher)];
|
|
777
|
+
case 5:
|
|
778
|
+
voucherInfo = _b.sent();
|
|
779
|
+
log.debug(tag, "voucherInfo: ", voucherInfo);
|
|
780
|
+
if (voucherInfo.denom_trace.base_denom === 'uatom') {
|
|
781
|
+
balance = {
|
|
782
|
+
type: 'ibcChannel',
|
|
783
|
+
ibc: true,
|
|
784
|
+
voucherId: entry.denom,
|
|
785
|
+
asset: 'ATOM',
|
|
786
|
+
denom: voucherInfo.denom_trace.base_denom,
|
|
787
|
+
channel: voucherInfo.denom_trace.path,
|
|
788
|
+
balance: entry.amount / 1000000
|
|
789
|
+
};
|
|
790
|
+
output.push(balance);
|
|
791
|
+
}
|
|
792
|
+
else {
|
|
793
|
+
//TODO lookup base_denum to asset
|
|
794
|
+
//handle more assets
|
|
795
|
+
}
|
|
796
|
+
_b.label = 6;
|
|
540
797
|
case 6:
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
798
|
+
if (!(entry.denom === 'gamm/pool/1')) return [3 /*break*/, 8];
|
|
799
|
+
return [4 /*yield*/, get_pools()];
|
|
800
|
+
case 7:
|
|
801
|
+
poolInfo = _b.sent();
|
|
802
|
+
poolInfo = poolInfo.pools[0];
|
|
803
|
+
log.debug(tag, "poolInfo: ", poolInfo);
|
|
804
|
+
totalShares = poolInfo.totalShares.amount / 1000000000000000000;
|
|
805
|
+
log.debug(tag, "totalShares: ", totalShares);
|
|
806
|
+
poolAssets = poolInfo.poolAssets;
|
|
807
|
+
log.debug(tag, "poolAssets: ", poolAssets);
|
|
808
|
+
assetAtom = poolAssets[0];
|
|
809
|
+
log.debug(tag, "assetAtom: ", assetAtom);
|
|
810
|
+
assetOsmo = poolAssets[1];
|
|
811
|
+
log.debug(tag, "assetOsmo: ", assetOsmo);
|
|
812
|
+
totalAtom = assetAtom.token.amount / 10000000;
|
|
813
|
+
log.debug(tag, "totalAtom: ", totalAtom);
|
|
814
|
+
totalOsmo = assetOsmo.token.amount / 1000000;
|
|
815
|
+
log.debug(tag, "totalOsmo: ", totalOsmo);
|
|
816
|
+
yourLpTokens = entry.amount / 1000000000000000000;
|
|
817
|
+
log.debug(tag, "yourLpTokens: ", yourLpTokens);
|
|
818
|
+
yourLpPercent = yourLpTokens / totalShares;
|
|
819
|
+
log.debug(tag, "yourLpPercent: ", yourLpPercent);
|
|
820
|
+
yourAtomInPool = totalAtom * yourLpPercent;
|
|
821
|
+
log.debug(tag, "yourAtomInPool: ", yourAtomInPool);
|
|
822
|
+
yourOsmoInPool = totalOsmo * yourLpPercent;
|
|
823
|
+
log.debug(tag, "yourOsmoInPool: ", yourOsmoInPool);
|
|
824
|
+
balance = {
|
|
825
|
+
type: 'lptoken',
|
|
826
|
+
lp: true,
|
|
827
|
+
amountATOM: yourAtomInPool,
|
|
828
|
+
amountOSMO: yourOsmoInPool,
|
|
829
|
+
poolPercent: yourLpPercent,
|
|
830
|
+
poolPair: "ATOM_OSMO",
|
|
831
|
+
asset: 'gamm/pool/1',
|
|
832
|
+
balance: yourLpTokens
|
|
833
|
+
};
|
|
834
|
+
output.push(balance);
|
|
835
|
+
_b.label = 8;
|
|
836
|
+
case 8:
|
|
837
|
+
i++;
|
|
838
|
+
return [3 /*break*/, 4];
|
|
839
|
+
case 9: return [3 /*break*/, 11];
|
|
840
|
+
case 10:
|
|
841
|
+
e_17 = _b.sent();
|
|
842
|
+
return [3 /*break*/, 11];
|
|
843
|
+
case 11: return [2 /*return*/, output];
|
|
844
|
+
case 12:
|
|
845
|
+
e_18 = _b.sent();
|
|
846
|
+
log.error(tag, "e: ", e_18);
|
|
847
|
+
throw e_18;
|
|
848
|
+
case 13: return [2 /*return*/];
|
|
545
849
|
}
|
|
546
850
|
});
|
|
547
851
|
});
|
|
@@ -549,7 +853,7 @@ var get_balances = function (address) {
|
|
|
549
853
|
var get_balance = function (address) {
|
|
550
854
|
var _a;
|
|
551
855
|
return __awaiter(this, void 0, void 0, function () {
|
|
552
|
-
var tag, output, accountInfo, i, entry,
|
|
856
|
+
var tag, output, accountInfo, i, entry, e_19, e_20;
|
|
553
857
|
return __generator(this, function (_b) {
|
|
554
858
|
switch (_b.label) {
|
|
555
859
|
case 0:
|
|
@@ -578,13 +882,13 @@ var get_balance = function (address) {
|
|
|
578
882
|
output = output / BASE_OSMO;
|
|
579
883
|
return [3 /*break*/, 5];
|
|
580
884
|
case 4:
|
|
581
|
-
|
|
885
|
+
e_19 = _b.sent();
|
|
582
886
|
return [3 /*break*/, 5];
|
|
583
887
|
case 5: return [2 /*return*/, output];
|
|
584
888
|
case 6:
|
|
585
|
-
|
|
586
|
-
log.error(tag, "e: ",
|
|
587
|
-
throw
|
|
889
|
+
e_20 = _b.sent();
|
|
890
|
+
log.error(tag, "e: ", e_20);
|
|
891
|
+
throw e_20;
|
|
588
892
|
case 7: return [2 /*return*/];
|
|
589
893
|
}
|
|
590
894
|
});
|
|
@@ -592,7 +896,7 @@ var get_balance = function (address) {
|
|
|
592
896
|
};
|
|
593
897
|
var get_node_info_verbose = function () {
|
|
594
898
|
return __awaiter(this, void 0, void 0, function () {
|
|
595
|
-
var tag, output, syncInfo, nodeInfo,
|
|
899
|
+
var tag, output, syncInfo, nodeInfo, e_21;
|
|
596
900
|
return __generator(this, function (_a) {
|
|
597
901
|
switch (_a.label) {
|
|
598
902
|
case 0:
|
|
@@ -617,9 +921,9 @@ var get_node_info_verbose = function () {
|
|
|
617
921
|
//output.height = lastBlock.data.block.header.height
|
|
618
922
|
return [2 /*return*/, output];
|
|
619
923
|
case 4:
|
|
620
|
-
|
|
621
|
-
log.error(tag, "e: ",
|
|
622
|
-
throw
|
|
924
|
+
e_21 = _a.sent();
|
|
925
|
+
log.error(tag, "e: ", e_21);
|
|
926
|
+
throw e_21;
|
|
623
927
|
case 5: return [2 /*return*/];
|
|
624
928
|
}
|
|
625
929
|
});
|