@pioneer-platform/osmosis-network 8.1.32 → 8.1.35
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 +400 -94
- package/package.json +3 -2
- 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,19 +489,24 @@ 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();
|
|
309
|
-
log.
|
|
310
|
-
if (result2.data.txhash)
|
|
311
|
-
output.txid = result2.data.txhash;
|
|
505
|
+
log.info(tag, '** Broadcast ** REMOTE: result: ', result2.data);
|
|
506
|
+
if (result2.data.tx_response.txhash) {
|
|
507
|
+
output.txid = result2.data.tx_response.txhash;
|
|
508
|
+
output.success = true;
|
|
509
|
+
}
|
|
312
510
|
//verify success
|
|
313
511
|
if (result2.data.raw_log) {
|
|
314
512
|
logSend = result2.data.raw_log;
|
|
@@ -320,16 +518,16 @@ var broadcast_transaction = function (tx) {
|
|
|
320
518
|
output.raw = result2.data;
|
|
321
519
|
return [3 /*break*/, 5];
|
|
322
520
|
case 4:
|
|
323
|
-
|
|
521
|
+
e_12 = _a.sent();
|
|
324
522
|
//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,
|
|
523
|
+
log.error(tag, e_12);
|
|
524
|
+
log.error(tag, e_12.response);
|
|
525
|
+
log.error(tag, e_12.response.data);
|
|
526
|
+
log.error(tag, e_12.response.data.error);
|
|
527
|
+
log.error(tag, e_12.response.data.error.indexOf('RPC error -32603 - Internal error: Tx already exists in cache'));
|
|
330
528
|
//throw e
|
|
331
529
|
output.success = false;
|
|
332
|
-
output.error =
|
|
530
|
+
output.error = e_12.response.data.error;
|
|
333
531
|
return [3 /*break*/, 5];
|
|
334
532
|
case 5:
|
|
335
533
|
if (output.txid) {
|
|
@@ -337,8 +535,8 @@ var broadcast_transaction = function (tx) {
|
|
|
337
535
|
}
|
|
338
536
|
return [2 /*return*/, output];
|
|
339
537
|
case 6:
|
|
340
|
-
|
|
341
|
-
console.error(tag, "throw error: ",
|
|
538
|
+
e_13 = _a.sent();
|
|
539
|
+
console.error(tag, "throw error: ", e_13);
|
|
342
540
|
return [2 /*return*/, output];
|
|
343
541
|
case 7: return [2 /*return*/];
|
|
344
542
|
}
|
|
@@ -347,7 +545,7 @@ var broadcast_transaction = function (tx) {
|
|
|
347
545
|
};
|
|
348
546
|
var get_account_info = function (address) {
|
|
349
547
|
return __awaiter(this, void 0, void 0, function () {
|
|
350
|
-
var tag, txInfo,
|
|
548
|
+
var tag, txInfo, e_14;
|
|
351
549
|
return __generator(this, function (_a) {
|
|
352
550
|
switch (_a.label) {
|
|
353
551
|
case 0:
|
|
@@ -363,9 +561,9 @@ var get_account_info = function (address) {
|
|
|
363
561
|
log.debug(tag, "txInfo: ", txInfo.data);
|
|
364
562
|
return [2 /*return*/, txInfo.data];
|
|
365
563
|
case 3:
|
|
366
|
-
|
|
367
|
-
log.error(tag, "e: ",
|
|
368
|
-
throw
|
|
564
|
+
e_14 = _a.sent();
|
|
565
|
+
log.error(tag, "e: ", e_14);
|
|
566
|
+
throw e_14;
|
|
369
567
|
case 4: return [2 /*return*/];
|
|
370
568
|
}
|
|
371
569
|
});
|
|
@@ -447,18 +645,54 @@ var normalize_tx = function (tx, address) {
|
|
|
447
645
|
throw e;
|
|
448
646
|
}
|
|
449
647
|
};
|
|
648
|
+
var get_txs_at_height = function (height) {
|
|
649
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
650
|
+
var tag, output, url, resultSends, sends, e_15;
|
|
651
|
+
return __generator(this, function (_a) {
|
|
652
|
+
switch (_a.label) {
|
|
653
|
+
case 0:
|
|
654
|
+
tag = TAG + " | get_txs_by_address | ";
|
|
655
|
+
_a.label = 1;
|
|
656
|
+
case 1:
|
|
657
|
+
_a.trys.push([1, 3, , 4]);
|
|
658
|
+
output = [];
|
|
659
|
+
url = URL_OSMO_LCD + '/cosmos/tx/v1beta1/txs?events=tx.height=%27' + height + '%27';
|
|
660
|
+
// let url = URL_OSMO_LCD+ '/txs?block.height='+height
|
|
661
|
+
// let url = URL_OSMO_LCD+ '/txs?tx.height='+height
|
|
662
|
+
//tx.height=
|
|
663
|
+
//?tx.height=1891147&page=1
|
|
664
|
+
log.debug(tag, "url: ", url);
|
|
665
|
+
return [4 /*yield*/, axios({
|
|
666
|
+
url: url,
|
|
667
|
+
method: 'GET'
|
|
668
|
+
})];
|
|
669
|
+
case 2:
|
|
670
|
+
resultSends = _a.sent();
|
|
671
|
+
sends = resultSends.data;
|
|
672
|
+
//log.debug('sends: ', sends)
|
|
673
|
+
return [2 /*return*/, sends];
|
|
674
|
+
case 3:
|
|
675
|
+
e_15 = _a.sent();
|
|
676
|
+
log.error(tag, "e: ", e_15);
|
|
677
|
+
throw e_15;
|
|
678
|
+
case 4: return [2 /*return*/];
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
};
|
|
450
683
|
var get_txs_by_address = function (address) {
|
|
451
684
|
return __awaiter(this, void 0, void 0, function () {
|
|
452
|
-
var tag, output, url, resultSends, sends, i, tx,
|
|
685
|
+
var tag, output, url, resultSends, sends, i, tx, e_16;
|
|
453
686
|
return __generator(this, function (_a) {
|
|
454
687
|
switch (_a.label) {
|
|
455
688
|
case 0:
|
|
456
689
|
tag = TAG + " | get_txs_by_address | ";
|
|
457
690
|
_a.label = 1;
|
|
458
691
|
case 1:
|
|
459
|
-
_a.trys.push([1,
|
|
692
|
+
_a.trys.push([1, 3, , 4]);
|
|
460
693
|
output = [];
|
|
461
|
-
url = URL_OSMO_LCD + '/txs?transfer.sender
|
|
694
|
+
url = URL_OSMO_LCD + '/cosmos/tx/v1beta1/txs?events=transfer.sender=%27' + address + '%27';
|
|
695
|
+
//let url = URL_OSMO_LCD+ '/txs?message.sender='+address
|
|
462
696
|
log.debug(tag, "url: ", url);
|
|
463
697
|
return [4 /*yield*/, axios({
|
|
464
698
|
url: url,
|
|
@@ -471,34 +705,35 @@ var get_txs_by_address = function (address) {
|
|
|
471
705
|
if (sends.txs) {
|
|
472
706
|
for (i = 0; i < sends.txs.length; i++) {
|
|
473
707
|
tx = sends.txs[i];
|
|
474
|
-
tx = normalize_tx(tx,
|
|
708
|
+
//tx = normalize_tx(tx,address)
|
|
475
709
|
output.push(tx);
|
|
476
710
|
}
|
|
477
711
|
}
|
|
478
712
|
//receives
|
|
479
|
-
url = URL_OSMO_LCD
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
//
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
713
|
+
//url = URL_OSMO_LCD+ '/txs?transfer.recipient='+address
|
|
714
|
+
//
|
|
715
|
+
// url = URL_OSMO_LCD+ '/cosmos/tx/v1beta1/txs?events=transfer.recipient=%27'+address+'%27'
|
|
716
|
+
// //console.log("URL_OSMO_LCD: ",url)
|
|
717
|
+
// let resultRecieves = await axios({
|
|
718
|
+
// url: url,
|
|
719
|
+
// method: 'GET'
|
|
720
|
+
// })
|
|
721
|
+
// let receives = resultRecieves.data
|
|
722
|
+
// //log.debug('receives: ', JSON.stringify(receives.tx_responses))
|
|
723
|
+
// if(receives.tx_responses){
|
|
724
|
+
// for(let i = 0; i < receives.txs.length; i++ ){
|
|
725
|
+
// let tx = receives.txs[i]
|
|
726
|
+
// //normalize
|
|
727
|
+
// // tx = normalize_tx(tx,address)
|
|
728
|
+
// output.push(tx)
|
|
729
|
+
// }
|
|
730
|
+
// }
|
|
496
731
|
return [2 /*return*/, output];
|
|
497
|
-
case
|
|
498
|
-
|
|
499
|
-
log.error(tag, "e: ",
|
|
500
|
-
throw
|
|
501
|
-
case
|
|
732
|
+
case 3:
|
|
733
|
+
e_16 = _a.sent();
|
|
734
|
+
log.error(tag, "e: ", e_16);
|
|
735
|
+
throw e_16;
|
|
736
|
+
case 4: return [2 /*return*/];
|
|
502
737
|
}
|
|
503
738
|
});
|
|
504
739
|
});
|
|
@@ -506,42 +741,113 @@ var get_txs_by_address = function (address) {
|
|
|
506
741
|
var get_balances = function (address) {
|
|
507
742
|
var _a;
|
|
508
743
|
return __awaiter(this, void 0, void 0, function () {
|
|
509
|
-
var tag, output, accountInfo, i, entry,
|
|
744
|
+
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
745
|
return __generator(this, function (_b) {
|
|
511
746
|
switch (_b.label) {
|
|
512
747
|
case 0:
|
|
513
748
|
tag = TAG + " | get_balances | ";
|
|
514
749
|
_b.label = 1;
|
|
515
750
|
case 1:
|
|
516
|
-
_b.trys.push([1,
|
|
517
|
-
output =
|
|
751
|
+
_b.trys.push([1, 12, , 13]);
|
|
752
|
+
output = [];
|
|
518
753
|
_b.label = 2;
|
|
519
754
|
case 2:
|
|
520
|
-
_b.trys.push([2,
|
|
755
|
+
_b.trys.push([2, 10, , 11]);
|
|
521
756
|
return [4 /*yield*/, axios({ method: 'GET', url: URL_OSMO_LCD + '/bank/balances/' + address })];
|
|
522
757
|
case 3:
|
|
523
758
|
accountInfo = _b.sent();
|
|
524
759
|
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];
|
|
760
|
+
if (!((_a = accountInfo.data) === null || _a === void 0 ? void 0 : _a.result)) return [3 /*break*/, 9];
|
|
761
|
+
i = 0;
|
|
762
|
+
_b.label = 4;
|
|
536
763
|
case 4:
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
764
|
+
if (!(i < accountInfo.data.result.length)) return [3 /*break*/, 9];
|
|
765
|
+
entry = accountInfo.data.result[i];
|
|
766
|
+
if (entry.denom === 'uosmo') {
|
|
767
|
+
balance = {
|
|
768
|
+
type: 'balance',
|
|
769
|
+
asset: 'OSMO',
|
|
770
|
+
denom: 'uosmo',
|
|
771
|
+
balance: entry.amount
|
|
772
|
+
};
|
|
773
|
+
output.push(balance);
|
|
774
|
+
}
|
|
775
|
+
if (!(entry.denom.indexOf('ibc/') >= 0)) return [3 /*break*/, 6];
|
|
776
|
+
voucher = entry.denom.replace('ibc/', '');
|
|
777
|
+
log.debug(tag, "voucher: ", voucher);
|
|
778
|
+
return [4 /*yield*/, get_voucher_info(voucher)];
|
|
779
|
+
case 5:
|
|
780
|
+
voucherInfo = _b.sent();
|
|
781
|
+
log.debug(tag, "voucherInfo: ", voucherInfo);
|
|
782
|
+
if (voucherInfo.denom_trace.base_denom === 'uatom') {
|
|
783
|
+
balance = {
|
|
784
|
+
type: 'ibcChannel',
|
|
785
|
+
ibc: true,
|
|
786
|
+
voucherId: entry.denom,
|
|
787
|
+
asset: 'ATOM',
|
|
788
|
+
denom: voucherInfo.denom_trace.base_denom,
|
|
789
|
+
channel: voucherInfo.denom_trace.path,
|
|
790
|
+
balance: entry.amount / 1000000
|
|
791
|
+
};
|
|
792
|
+
output.push(balance);
|
|
793
|
+
}
|
|
794
|
+
else {
|
|
795
|
+
//TODO lookup base_denum to asset
|
|
796
|
+
//handle more assets
|
|
797
|
+
}
|
|
798
|
+
_b.label = 6;
|
|
540
799
|
case 6:
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
800
|
+
if (!(entry.denom === 'gamm/pool/1')) return [3 /*break*/, 8];
|
|
801
|
+
return [4 /*yield*/, get_pools()];
|
|
802
|
+
case 7:
|
|
803
|
+
poolInfo = _b.sent();
|
|
804
|
+
poolInfo = poolInfo.pools[0];
|
|
805
|
+
log.debug(tag, "poolInfo: ", poolInfo);
|
|
806
|
+
totalShares = poolInfo.totalShares.amount / 1000000000000000000;
|
|
807
|
+
log.debug(tag, "totalShares: ", totalShares);
|
|
808
|
+
poolAssets = poolInfo.poolAssets;
|
|
809
|
+
log.debug(tag, "poolAssets: ", poolAssets);
|
|
810
|
+
assetAtom = poolAssets[0];
|
|
811
|
+
log.debug(tag, "assetAtom: ", assetAtom);
|
|
812
|
+
assetOsmo = poolAssets[1];
|
|
813
|
+
log.debug(tag, "assetOsmo: ", assetOsmo);
|
|
814
|
+
totalAtom = assetAtom.token.amount / 10000000;
|
|
815
|
+
log.debug(tag, "totalAtom: ", totalAtom);
|
|
816
|
+
totalOsmo = assetOsmo.token.amount / 1000000;
|
|
817
|
+
log.debug(tag, "totalOsmo: ", totalOsmo);
|
|
818
|
+
yourLpTokens = entry.amount / 1000000000000000000;
|
|
819
|
+
log.debug(tag, "yourLpTokens: ", yourLpTokens);
|
|
820
|
+
yourLpPercent = yourLpTokens / totalShares;
|
|
821
|
+
log.debug(tag, "yourLpPercent: ", yourLpPercent);
|
|
822
|
+
yourAtomInPool = totalAtom * yourLpPercent;
|
|
823
|
+
log.debug(tag, "yourAtomInPool: ", yourAtomInPool);
|
|
824
|
+
yourOsmoInPool = totalOsmo * yourLpPercent;
|
|
825
|
+
log.debug(tag, "yourOsmoInPool: ", yourOsmoInPool);
|
|
826
|
+
balance = {
|
|
827
|
+
type: 'lptoken',
|
|
828
|
+
lp: true,
|
|
829
|
+
amountATOM: yourAtomInPool,
|
|
830
|
+
amountOSMO: yourOsmoInPool,
|
|
831
|
+
poolPercent: yourLpPercent,
|
|
832
|
+
poolPair: "ATOM_OSMO",
|
|
833
|
+
asset: 'gamm/pool/1',
|
|
834
|
+
balance: yourLpTokens
|
|
835
|
+
};
|
|
836
|
+
output.push(balance);
|
|
837
|
+
_b.label = 8;
|
|
838
|
+
case 8:
|
|
839
|
+
i++;
|
|
840
|
+
return [3 /*break*/, 4];
|
|
841
|
+
case 9: return [3 /*break*/, 11];
|
|
842
|
+
case 10:
|
|
843
|
+
e_17 = _b.sent();
|
|
844
|
+
return [3 /*break*/, 11];
|
|
845
|
+
case 11: return [2 /*return*/, output];
|
|
846
|
+
case 12:
|
|
847
|
+
e_18 = _b.sent();
|
|
848
|
+
log.error(tag, "e: ", e_18);
|
|
849
|
+
throw e_18;
|
|
850
|
+
case 13: return [2 /*return*/];
|
|
545
851
|
}
|
|
546
852
|
});
|
|
547
853
|
});
|
|
@@ -549,7 +855,7 @@ var get_balances = function (address) {
|
|
|
549
855
|
var get_balance = function (address) {
|
|
550
856
|
var _a;
|
|
551
857
|
return __awaiter(this, void 0, void 0, function () {
|
|
552
|
-
var tag, output, accountInfo, i, entry,
|
|
858
|
+
var tag, output, accountInfo, i, entry, e_19, e_20;
|
|
553
859
|
return __generator(this, function (_b) {
|
|
554
860
|
switch (_b.label) {
|
|
555
861
|
case 0:
|
|
@@ -578,13 +884,13 @@ var get_balance = function (address) {
|
|
|
578
884
|
output = output / BASE_OSMO;
|
|
579
885
|
return [3 /*break*/, 5];
|
|
580
886
|
case 4:
|
|
581
|
-
|
|
887
|
+
e_19 = _b.sent();
|
|
582
888
|
return [3 /*break*/, 5];
|
|
583
889
|
case 5: return [2 /*return*/, output];
|
|
584
890
|
case 6:
|
|
585
|
-
|
|
586
|
-
log.error(tag, "e: ",
|
|
587
|
-
throw
|
|
891
|
+
e_20 = _b.sent();
|
|
892
|
+
log.error(tag, "e: ", e_20);
|
|
893
|
+
throw e_20;
|
|
588
894
|
case 7: return [2 /*return*/];
|
|
589
895
|
}
|
|
590
896
|
});
|
|
@@ -592,7 +898,7 @@ var get_balance = function (address) {
|
|
|
592
898
|
};
|
|
593
899
|
var get_node_info_verbose = function () {
|
|
594
900
|
return __awaiter(this, void 0, void 0, function () {
|
|
595
|
-
var tag, output, syncInfo, nodeInfo,
|
|
901
|
+
var tag, output, syncInfo, nodeInfo, e_21;
|
|
596
902
|
return __generator(this, function (_a) {
|
|
597
903
|
switch (_a.label) {
|
|
598
904
|
case 0:
|
|
@@ -617,9 +923,9 @@ var get_node_info_verbose = function () {
|
|
|
617
923
|
//output.height = lastBlock.data.block.header.height
|
|
618
924
|
return [2 /*return*/, output];
|
|
619
925
|
case 4:
|
|
620
|
-
|
|
621
|
-
log.error(tag, "e: ",
|
|
622
|
-
throw
|
|
926
|
+
e_21 = _a.sent();
|
|
927
|
+
log.error(tag, "e: ", e_21);
|
|
928
|
+
throw e_21;
|
|
623
929
|
case 5: return [2 /*return*/];
|
|
624
930
|
}
|
|
625
931
|
});
|