@pioneer-platform/pioneer-sdk 8.1.41 → 8.1.45
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 +67 -18
- package/package.json +5 -5
package/lib/index.js
CHANGED
@@ -65,6 +65,8 @@ var SDK = /** @class */ (function () {
|
|
65
65
|
this.spec = config.spec;
|
66
66
|
this.clients = {};
|
67
67
|
this.contexts = [];
|
68
|
+
this.pubkeys = [];
|
69
|
+
this.balances = [];
|
68
70
|
this.context = "";
|
69
71
|
this.invocationContext = "";
|
70
72
|
this.assetContext = "";
|
@@ -79,7 +81,7 @@ var SDK = /** @class */ (function () {
|
|
79
81
|
this.nfts = [];
|
80
82
|
this.init = function (blockchains) {
|
81
83
|
return __awaiter(this, void 0, void 0, function () {
|
82
|
-
var tag, i, blockchain, _a, userInfo, e_1;
|
84
|
+
var tag, i, blockchain, _a, userInfo, i, walletInfo, j, pubkey, k, balance, e_1;
|
83
85
|
return __generator(this, function (_b) {
|
84
86
|
switch (_b.label) {
|
85
87
|
case 0:
|
@@ -117,13 +119,29 @@ var SDK = /** @class */ (function () {
|
|
117
119
|
case 3:
|
118
120
|
userInfo = _b.sent();
|
119
121
|
userInfo = userInfo.data;
|
120
|
-
log.
|
122
|
+
log.info(tag, "userInfo: ", userInfo);
|
123
|
+
//for each wallet
|
124
|
+
if (userInfo.walletDescriptions) {
|
125
|
+
for (i = 0; userInfo.walletDescriptions.length; i++) {
|
126
|
+
walletInfo = userInfo.walletDescriptions[i];
|
127
|
+
for (j = 0; j < walletInfo.pubkeys.length; j++) {
|
128
|
+
pubkey = walletInfo.pubkeys[j];
|
129
|
+
pubkey.context = walletInfo.context;
|
130
|
+
this.pubkeys.push(pubkey);
|
131
|
+
for (k = 0; k < pubkey.balances.length; k++) {
|
132
|
+
balance = pubkey.balances[k];
|
133
|
+
//add wallet context
|
134
|
+
balance.context = walletInfo.context;
|
135
|
+
balance.pubkey = pubkey.pubkey;
|
136
|
+
this.balances.push(balance);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
121
141
|
if (!this.username)
|
122
142
|
this.username = userInfo.username;
|
123
143
|
this.wallets = userInfo.wallets;
|
124
|
-
this.
|
125
|
-
this.masters = userInfo.masters;
|
126
|
-
this.pubkeys = userInfo.pubkeys;
|
144
|
+
// this.pubkeys = userInfo.pubkeys
|
127
145
|
this.ibcChannels = userInfo.ibcChannels;
|
128
146
|
this.nfts = userInfo.nfts;
|
129
147
|
this.paymentStreams = userInfo.paymentStreams;
|
@@ -201,7 +219,7 @@ var SDK = /** @class */ (function () {
|
|
201
219
|
tag = TAG + " | registerWallet | ";
|
202
220
|
_a.label = 1;
|
203
221
|
case 1:
|
204
|
-
_a.trys.push([1,
|
222
|
+
_a.trys.push([1, 4, , 5]);
|
205
223
|
if (wallet.network !== 1) {
|
206
224
|
throw Error('Network not supported!');
|
207
225
|
}
|
@@ -226,6 +244,7 @@ var SDK = /** @class */ (function () {
|
|
226
244
|
"path": "m/44'/60'/0'",
|
227
245
|
"script_type": "ethereum",
|
228
246
|
"network": "ethereum",
|
247
|
+
"type": "address",
|
229
248
|
"created": new Date().getTime(),
|
230
249
|
"tags": [
|
231
250
|
wallet.name,
|
@@ -246,12 +265,15 @@ var SDK = /** @class */ (function () {
|
|
246
265
|
return [4 /*yield*/, this.pioneerApi.Register(null, register)];
|
247
266
|
case 2:
|
248
267
|
result = _a.sent();
|
249
|
-
return [
|
268
|
+
return [4 /*yield*/, this.getUserParams()];
|
250
269
|
case 3:
|
270
|
+
_a.sent();
|
271
|
+
return [2 /*return*/, result.data];
|
272
|
+
case 4:
|
251
273
|
e_2 = _a.sent();
|
252
274
|
log.error(tag, "e: ", e_2);
|
253
|
-
return [3 /*break*/,
|
254
|
-
case
|
275
|
+
return [3 /*break*/, 5];
|
276
|
+
case 5: return [2 /*return*/];
|
255
277
|
}
|
256
278
|
});
|
257
279
|
});
|
@@ -519,7 +541,7 @@ var SDK = /** @class */ (function () {
|
|
519
541
|
// @ts-ignore
|
520
542
|
this.getUserParams = function () {
|
521
543
|
return __awaiter(this, void 0, void 0, function () {
|
522
|
-
var tag, userInfo, balance,
|
544
|
+
var tag, userInfo, balance, i, walletInfo, j, pubkey, k, balance_1, result, binance, bitcoin, thorchain, cosmos, osmosis, ethereum, bitcoin, bitcoin, output, e_12;
|
523
545
|
var _this = this;
|
524
546
|
return __generator(this, function (_a) {
|
525
547
|
switch (_a.label) {
|
@@ -549,6 +571,35 @@ var SDK = /** @class */ (function () {
|
|
549
571
|
this.assetBalanceUsdValueContext = balance.valueUsd || '0';
|
550
572
|
log.debug(tag, "this.assetBalanceNativeContext: ", this.assetBalanceNativeContext);
|
551
573
|
log.debug(tag, "this.assetBalanceUsdValueContext: ", this.assetBalanceUsdValueContext);
|
574
|
+
// this.balances = []
|
575
|
+
// this.pubkeys = []
|
576
|
+
//for each wallet
|
577
|
+
if (userInfo.walletDescriptions) {
|
578
|
+
log.info("Parse Wallet Descriptions");
|
579
|
+
for (i = 0; i < userInfo.walletDescriptions.length; i++) {
|
580
|
+
walletInfo = userInfo.walletDescriptions[i];
|
581
|
+
log.info(tag, "walletInfo: ", walletInfo);
|
582
|
+
for (j = 0; j < walletInfo.pubkeys.length; j++) {
|
583
|
+
pubkey = walletInfo.pubkeys[j];
|
584
|
+
pubkey.context = walletInfo.context;
|
585
|
+
this.pubkeys.push(pubkey);
|
586
|
+
for (k = 0; k < pubkey.balances.length; k++) {
|
587
|
+
balance_1 = pubkey.balances[k];
|
588
|
+
//add wallet context
|
589
|
+
balance_1.context = walletInfo.context;
|
590
|
+
balance_1.pubkey = pubkey.pubkey;
|
591
|
+
//force to webspec
|
592
|
+
balance_1.address = pubkey.pubkey;
|
593
|
+
balance_1.name = pubkey.pubkey;
|
594
|
+
balance_1.chainId = 1;
|
595
|
+
balance_1.decimals = 18;
|
596
|
+
if (balance_1.marketData && balance_1.marketData.image)
|
597
|
+
balance_1.logoURI = balance_1.marketData.image;
|
598
|
+
this.balances.push(balance_1);
|
599
|
+
}
|
600
|
+
}
|
601
|
+
}
|
602
|
+
}
|
552
603
|
_a.label = 3;
|
553
604
|
case 3:
|
554
605
|
if (!this.context)
|
@@ -561,18 +612,16 @@ var SDK = /** @class */ (function () {
|
|
561
612
|
case 4:
|
562
613
|
result = _a.sent();
|
563
614
|
result = result.data;
|
564
|
-
log.
|
615
|
+
log.info(tag, "result: ", result);
|
565
616
|
if (result.wallets) {
|
566
617
|
this.contexts = result.wallets;
|
567
618
|
log.debug(tag, "result: ", result);
|
568
619
|
}
|
569
|
-
if (!result.masters.RUNE)
|
570
|
-
throw Error("102: RUNE required asset! ");
|
571
|
-
thorAddress = result.masters.RUNE;
|
572
620
|
this.wallets = result.wallets;
|
573
|
-
|
574
|
-
|
575
|
-
|
621
|
+
if (result.balances)
|
622
|
+
this.balances = result.balances;
|
623
|
+
if (result.pubkeys)
|
624
|
+
this.pubkeys = result.pubkeys;
|
576
625
|
log.debug(tag, "this.spec: ", this.spec);
|
577
626
|
log.debug(tag, "supportedBlockchains: ", supportedBlockchains);
|
578
627
|
if (!this.spec)
|
@@ -689,7 +738,7 @@ var SDK = /** @class */ (function () {
|
|
689
738
|
valueUsdContext: this.valueUsdContext,
|
690
739
|
assetBalanceNativeContext: this.assetBalanceNativeContext,
|
691
740
|
assetBalanceUsdValueContext: this.assetBalanceUsdValueContext,
|
692
|
-
wallet:
|
741
|
+
wallet: this.username || 'sdkuser',
|
693
742
|
keystore: {},
|
694
743
|
clients: this.clients
|
695
744
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pioneer-platform/pioneer-sdk",
|
3
|
-
"version": "8.1.
|
3
|
+
"version": "8.1.45",
|
4
4
|
"main": "./lib/index.js",
|
5
5
|
"types": "./lib/index.d.ts",
|
6
6
|
"scripts": {
|
@@ -20,10 +20,10 @@
|
|
20
20
|
"clean": "rm -rf coverage src/**/*.js src/**/*.map lib node_modules"
|
21
21
|
},
|
22
22
|
"dependencies": {
|
23
|
-
"@pioneer-platform/pioneer-coins": "^8.1.
|
24
|
-
"@pioneer-platform/pioneer-events": "^8.1.
|
25
|
-
"@pioneer-platform/pioneer-types": "^8.1.
|
26
|
-
"@pioneer-platform/pioneer-xchain-client": "^8.1.
|
23
|
+
"@pioneer-platform/pioneer-coins": "^8.1.37",
|
24
|
+
"@pioneer-platform/pioneer-events": "^8.1.29",
|
25
|
+
"@pioneer-platform/pioneer-types": "^8.1.44",
|
26
|
+
"@pioneer-platform/pioneer-xchain-client": "^8.1.38",
|
27
27
|
"bignumber.js": "^9.0.1",
|
28
28
|
"dotenv": "^8.2.0",
|
29
29
|
"openapi-client-axios": "^3.13.1",
|