@pioneer-platform/maya-network 8.13.13 → 8.13.15
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/CHANGELOG.md +12 -0
- package/lib/index.js +30 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pioneer-platform/maya-network
|
|
2
2
|
|
|
3
|
+
## 8.13.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix(pioneer-nodes): remove broken node entry without service field
|
|
8
|
+
|
|
9
|
+
## 8.13.14
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fix(pioneer-nodes): remove broken node entry without service field
|
|
14
|
+
|
|
3
15
|
## 8.13.13
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/lib/index.js
CHANGED
|
@@ -346,7 +346,7 @@ var get_balance = function (address) {
|
|
|
346
346
|
};
|
|
347
347
|
var get_balances = function (address) {
|
|
348
348
|
return __awaiter(this, void 0, void 0, function () {
|
|
349
|
-
var tag, accountInfo, output,
|
|
349
|
+
var tag, accountInfo, output, addedDenoms, _i, _a, asset, cacaoBalance, e_4;
|
|
350
350
|
return __generator(this, function (_b) {
|
|
351
351
|
switch (_b.label) {
|
|
352
352
|
case 0:
|
|
@@ -358,41 +358,53 @@ var get_balances = function (address) {
|
|
|
358
358
|
case 2:
|
|
359
359
|
accountInfo = _b.sent();
|
|
360
360
|
output = [];
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
output.push({
|
|
364
|
-
denom: 'cacao',
|
|
365
|
-
amountBase: accountInfo.balance,
|
|
366
|
-
amount: cacaoBalance / BASE_MAYA,
|
|
367
|
-
decimals: 10
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
// Parse assets array if present (MAYA and other assets)
|
|
361
|
+
addedDenoms = new Set();
|
|
362
|
+
// Parse all assets from the coins/assets array
|
|
371
363
|
if (accountInfo.assets && Array.isArray(accountInfo.assets)) {
|
|
372
364
|
for (_i = 0, _a = accountInfo.assets; _i < _a.length; _i++) {
|
|
373
365
|
asset = _a[_i];
|
|
374
|
-
if (asset.denom === '
|
|
366
|
+
if (asset.denom === 'cacao') {
|
|
375
367
|
output.push({
|
|
376
|
-
denom:
|
|
368
|
+
denom: 'cacao',
|
|
377
369
|
amountBase: asset.amount,
|
|
378
|
-
amount: parseFloat(asset.amount) /
|
|
379
|
-
decimals:
|
|
370
|
+
amount: parseFloat(asset.amount) / BASE_MAYA, // 10 decimals for CACAO
|
|
371
|
+
decimals: 10
|
|
380
372
|
});
|
|
373
|
+
addedDenoms.add('cacao');
|
|
381
374
|
}
|
|
382
|
-
else if (asset.denom === '
|
|
383
|
-
|
|
384
|
-
|
|
375
|
+
else if (asset.denom === 'maya') {
|
|
376
|
+
output.push({
|
|
377
|
+
denom: 'maya',
|
|
378
|
+
amountBase: asset.amount,
|
|
379
|
+
amount: parseFloat(asset.amount) / 10000, // 4 decimals for MAYA token
|
|
380
|
+
decimals: 4
|
|
381
|
+
});
|
|
382
|
+
addedDenoms.add('maya');
|
|
385
383
|
}
|
|
386
384
|
else {
|
|
385
|
+
// Other assets - use raw amount (no decimals assumed)
|
|
387
386
|
output.push({
|
|
388
387
|
denom: asset.denom,
|
|
389
388
|
amountBase: asset.amount,
|
|
390
389
|
amount: parseFloat(asset.amount),
|
|
391
390
|
decimals: 0
|
|
392
391
|
});
|
|
392
|
+
addedDenoms.add(asset.denom);
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
|
+
// Fallback: If CACAO wasn't in assets array, check the balance field
|
|
397
|
+
if (!addedDenoms.has('cacao')) {
|
|
398
|
+
cacaoBalance = parseFloat(accountInfo.balance || '0');
|
|
399
|
+
if (cacaoBalance > 0) {
|
|
400
|
+
output.push({
|
|
401
|
+
denom: 'cacao',
|
|
402
|
+
amountBase: accountInfo.balance,
|
|
403
|
+
amount: cacaoBalance / BASE_MAYA,
|
|
404
|
+
decimals: 10
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
396
408
|
return [2 /*return*/, output];
|
|
397
409
|
case 3:
|
|
398
410
|
e_4 = _b.sent();
|