@pioneer-platform/zapper-client 8.5.0 → 8.7.0

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.
@@ -0,0 +1 @@
1
+ $ tsc -p .
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @pioneer-platform/zapper-client
2
2
 
3
+ ## 8.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Automated minor version bump for all packages
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @pioneer-platform/loggerdog@8.7.0
13
+ - @pioneer-platform/pioneer-caip@9.6.0
14
+
15
+ ## 8.6.0
16
+
17
+ ### Minor Changes
18
+
19
+ - Automated minor version bump for all packages
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+ - @pioneer-platform/loggerdog@8.6.0
25
+ - @pioneer-platform/pioneer-caip@9.5.0
26
+
3
27
  ## 8.5.0
4
28
 
5
29
  ### Minor Changes
package/build.sh ADDED
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+ # Fast Bun build (replaces slow tsc)
3
+
4
+ OUTDIR="${1:-lib}"
5
+ ENTRY="${2:-src/index.ts}"
6
+
7
+ # Clean output
8
+ rm -rf "$OUTDIR"
9
+ mkdir -p "$OUTDIR"
10
+
11
+ # Build with Bun (10x faster than tsc)
12
+ bun build "$ENTRY" \
13
+ --outdir "$OUTDIR" \
14
+ --target node \
15
+ --format cjs \
16
+ --sourcemap \
17
+ --minify
18
+
19
+ # Generate TypeScript declarations
20
+ bunx tsc --emitDeclarationOnly --outDir "$OUTDIR" --project .
21
+
22
+ echo "✅ Built $OUTDIR"
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/lib/index.js ADDED
@@ -0,0 +1,534 @@
1
+ "use strict";
2
+ /*
3
+ https://docs.blocknative.com/webhook-api
4
+
5
+ */
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
28
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ var TAG = " | zapper | ";
55
+ var log = require('@pioneer-platform/loggerdog')();
56
+ //@ts-ignore
57
+ var pioneer_caip_1 = require("@pioneer-platform/pioneer-caip");
58
+ var axiosLib = require('axios');
59
+ var Axios = axiosLib.default || axiosLib;
60
+ var https = require('https');
61
+ var API_KEY = process.env['ZAPPER_API_KEY'];
62
+ if (!API_KEY)
63
+ throw Error("api key required! set env ZAPPER_API_KEY");
64
+ var axios = Axios.create();
65
+ var Authorization = "Basic ".concat(Buffer.from("".concat(API_KEY, ":"), "binary").toString("base64"));
66
+ console.log(Authorization);
67
+ var URL_SERVICE = "https://api.zapper.xyz";
68
+ // Removed axios-retry - using basic axios
69
+ /**
70
+ * Validates if a CAIP is correctly formatted for the given token
71
+ */
72
+ var validateCaip = function (caip, token, networkName) {
73
+ var _a;
74
+ var tag = TAG + " | validateCaip | ";
75
+ try {
76
+ if (!caip || !caip.includes('/')) {
77
+ log.error(tag, "Invalid CAIP format:", caip);
78
+ return false;
79
+ }
80
+ var _b = caip.split('/'), network = _b[0], assetType = _b[1];
81
+ // Check if token has contract address
82
+ var hasContractAddress = token.address &&
83
+ token.address !== '0x0000000000000000000000000000000000000000' &&
84
+ token.address.toLowerCase() !== '0x0';
85
+ // Special handling for eETH (Ether.fi staked ETH)
86
+ var isEETH = token.symbol === 'eETH' ||
87
+ (token.address && token.address.toLowerCase() === '0x35fa164735182de50811e8e2e824cfb9b6118ac2');
88
+ if (hasContractAddress || isEETH) {
89
+ // This should be an ERC-20 token
90
+ if (!(assetType === null || assetType === void 0 ? void 0 : assetType.includes('erc20'))) {
91
+ log.error(tag, "Token ".concat(token.symbol, " with address ").concat(token.address, " should have ERC-20 CAIP but got: ").concat(caip));
92
+ return false;
93
+ }
94
+ // Verify contract address is in CAIP
95
+ if (!(assetType === null || assetType === void 0 ? void 0 : assetType.includes((_a = token.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()))) {
96
+ log.error(tag, "Token ".concat(token.symbol, " CAIP missing contract address: ").concat(caip));
97
+ return false;
98
+ }
99
+ }
100
+ else {
101
+ // This should be a native asset
102
+ if (!(assetType === null || assetType === void 0 ? void 0 : assetType.includes('slip44'))) {
103
+ log.error(tag, "Native asset ".concat(token.symbol, " should have slip44 CAIP but got: ").concat(caip));
104
+ return false;
105
+ }
106
+ }
107
+ return true;
108
+ }
109
+ catch (e) {
110
+ log.error(tag, "CAIP validation error:", e);
111
+ return false;
112
+ }
113
+ };
114
+ /**
115
+ * Assigns the correct CAIP for a token based on its properties
116
+ */
117
+ var assignCorrectCaip = function (networkId, token, networkName) {
118
+ var tag = TAG + " | assignCorrectCaip | ";
119
+ try {
120
+ // Check if token has a valid contract address
121
+ var hasContractAddress = token.address &&
122
+ token.address !== '0x0000000000000000000000000000000000000000' &&
123
+ token.address.toLowerCase() !== '0x0' &&
124
+ token.address.toLowerCase() !== '0x';
125
+ // Known token addresses for special handling
126
+ var knownTokens = {
127
+ 'eETH': '0x35fa164735182de50811e8e2e824cfb9b6118ac2',
128
+ 'weETH': '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee',
129
+ 'stETH': '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
130
+ 'wstETH': '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0'
131
+ };
132
+ // Check if this is a known token that should be ERC-20
133
+ var knownAddress = knownTokens[token.symbol];
134
+ if (knownAddress) {
135
+ var caip_1 = "".concat(networkId, "/erc20:").concat(knownAddress.toLowerCase());
136
+ log.debug(tag, "Assigned known token CAIP for ".concat(token.symbol, ": ").concat(caip_1));
137
+ return caip_1;
138
+ }
139
+ // For tokens with valid contract addresses (ERC-20/ERC-721)
140
+ if (hasContractAddress) {
141
+ var caip_2 = "".concat(networkId, "/erc20:").concat(token.address.toLowerCase());
142
+ log.debug(tag, "Assigned ERC-20 CAIP for ".concat(token.symbol, ": ").concat(caip_2));
143
+ return caip_2;
144
+ }
145
+ // For native tokens (ETH, BNB, MATIC, etc) - only when explicitly base-token or no address
146
+ if (token.type === 'base-token' || token.symbol === 'ETH' || token.symbol === 'BNB' || token.symbol === 'MATIC') {
147
+ var caip_3 = "".concat(networkId, "/slip44:60");
148
+ log.debug(tag, "Assigned native CAIP for ".concat(token.symbol, ": ").concat(caip_3));
149
+ return caip_3;
150
+ }
151
+ // Default to slip44:60 for native assets without addresses
152
+ var caip = "".concat(networkId, "/slip44:60");
153
+ log.warn(tag, "Default CAIP assignment for ".concat(token.symbol, ": ").concat(caip));
154
+ return caip;
155
+ }
156
+ catch (e) {
157
+ log.error(tag, "Error assigning CAIP:", e);
158
+ // Fallback to native token CAIP
159
+ return "".concat(networkId, "/slip44:60");
160
+ }
161
+ };
162
+ /**
163
+ * Logs CAIP assignment for debugging
164
+ */
165
+ var logCaipAssignment = function (balance, originalCaip) {
166
+ var tag = TAG + " | logCaipAssignment | ";
167
+ if (originalCaip && originalCaip !== balance.caip) {
168
+ log.info(tag, "CAIP corrected for ".concat(balance.symbol, ":"));
169
+ log.info(tag, " Original: ".concat(originalCaip));
170
+ log.info(tag, " Corrected: ".concat(balance.caip));
171
+ log.info(tag, " Token details:", {
172
+ symbol: balance.symbol,
173
+ name: balance.name,
174
+ address: balance.tokenAddress,
175
+ type: balance.tokenType,
176
+ metaType: balance.metaType
177
+ });
178
+ }
179
+ };
180
+ module.exports = {
181
+ getTokens: function (address) {
182
+ return get_tokens(address);
183
+ },
184
+ getNFTs: function (address) {
185
+ return get_nfts(address);
186
+ },
187
+ getPortfolio: function (address) {
188
+ return get_portfolio(address);
189
+ },
190
+ getTotalNetworth: function (address) {
191
+ return get_total_networth(address);
192
+ },
193
+ };
194
+ var get_portfolio = function (address) {
195
+ return __awaiter(this, void 0, void 0, function () {
196
+ var tag, output_1, appsResponse, apps, totalBalanceUSDApp_1, i, app, j, product, k, asset, l, token, balance, tokenForCaip, tokensResponse, totalBalanceUsdTokens_1, tokens, limit, allTokens, cursor, url, response, tokens, error_1, nftResponse, nftUsdNetWorth, totalNetWorth, e_1;
197
+ var _a, _b, _c, _d;
198
+ return __generator(this, function (_e) {
199
+ switch (_e.label) {
200
+ case 0:
201
+ tag = TAG + " | get_portfolio | ";
202
+ _e.label = 1;
203
+ case 1:
204
+ _e.trys.push([1, 11, , 12]);
205
+ output_1 = {
206
+ balances: []
207
+ };
208
+ return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=".concat(address), {
209
+ headers: {
210
+ accept: "*/*",
211
+ Authorization: Authorization,
212
+ },
213
+ })];
214
+ case 2:
215
+ appsResponse = _e.sent();
216
+ log.info(tag, "appsResponse: ", appsResponse.data);
217
+ apps = appsResponse.data;
218
+ totalBalanceUSDApp_1 = 0;
219
+ apps.forEach(function (app) {
220
+ totalBalanceUSDApp_1 += app.balanceUSD;
221
+ });
222
+ for (i = 0; i < apps.length; i++) {
223
+ app = apps[i];
224
+ for (j = 0; j < app.products.length; j++) {
225
+ product = app.products[j];
226
+ log.info(tag, "product: ", product);
227
+ for (k = 0; k < product.assets.length; k++) {
228
+ asset = product.assets[k];
229
+ log.info(tag, "asset: ", asset);
230
+ for (l = 0; l < asset.tokens.length; l++) {
231
+ token = asset.tokens[l];
232
+ balance = {};
233
+ balance.pubkey = app.address;
234
+ balance.balance = token === null || token === void 0 ? void 0 : token.balance.toString();
235
+ balance.chain = app.network;
236
+ balance.networkId = pioneer_caip_1.evmCaips[app.network].split('/')[0];
237
+ tokenForCaip = token;
238
+ if (asset.type === 'app-token' && asset.address &&
239
+ asset.address !== '0x0000000000000000000000000000000000000000') {
240
+ // Use the asset-level address for app tokens
241
+ tokenForCaip = __assign(__assign({}, token), { address: asset.address, symbol: asset.symbol || token.symbol });
242
+ }
243
+ // Assign correct CAIP based on token properties
244
+ balance.caip = assignCorrectCaip(balance.networkId, tokenForCaip, app.network);
245
+ // Log CAIP assignment for debugging
246
+ log.debug(tag, "CAIP assigned for ".concat(asset.symbol || token.symbol, ": ").concat(balance.caip), {
247
+ assetAddress: asset.address,
248
+ tokenAddress: token.address,
249
+ assetType: asset.type,
250
+ tokenType: token.type,
251
+ network: app.network
252
+ });
253
+ balance.metaType = token.metaType || product.metaType;
254
+ balance.name = asset.displayProps.label;
255
+ balance.appId = app.appId;
256
+ balance.icon = asset.displayProps.images[0];
257
+ balance.display = asset.displayProps.images;
258
+ balance.groupId = asset.groupId;
259
+ balance.symbol = asset.symbol || token.symbol; // Use asset symbol if available
260
+ balance.ticker = asset.symbol || token.symbol; // Use asset symbol if available
261
+ balance.priceUsd = ((_a = asset.price) === null || _a === void 0 ? void 0 : _a.toString()) || ((_b = token === null || token === void 0 ? void 0 : token.price) === null || _b === void 0 ? void 0 : _b.toString()) || '0'; // Use asset price if available
262
+ balance.valueUsd = ((_c = asset.balanceUSD) === null || _c === void 0 ? void 0 : _c.toString()) || ((_d = token === null || token === void 0 ? void 0 : token.balanceUSD) === null || _d === void 0 ? void 0 : _d.toString()) || '0'; // Use asset value if available
263
+ // Add additional fields for debugging
264
+ balance.tokenAddress = asset.address || token.address;
265
+ balance.tokenType = asset.type || token.type;
266
+ output_1.balances.push(balance);
267
+ }
268
+ }
269
+ }
270
+ }
271
+ return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/tokens?addresses%5B%5D=".concat(address), {
272
+ headers: {
273
+ accept: "*/*",
274
+ Authorization: Authorization,
275
+ },
276
+ })];
277
+ case 3:
278
+ tokensResponse = _e.sent();
279
+ console.log("tokensResponse: ", tokensResponse.data);
280
+ if (tokensResponse.data && tokensResponse.data[address.toLowerCase()]) {
281
+ tokens = tokensResponse.data;
282
+ totalBalanceUsdTokens_1 = 0;
283
+ tokens = tokens[address.toLowerCase()];
284
+ output_1.tokens = tokens;
285
+ log.info(tag, "tokens: ", tokens.length);
286
+ if (tokens) {
287
+ tokens.forEach(function (token) {
288
+ log.debug(tag, "token: ", token);
289
+ var network = token.network;
290
+ log.debug(tag, "network: ", network);
291
+ var caip = pioneer_caip_1.evmCaips[network];
292
+ if (caip) {
293
+ token.networkId = caip.split('/')[0];
294
+ // Assign correct CAIP based on token properties
295
+ token.assetCaip = assignCorrectCaip(token.networkId, token.token, network);
296
+ var balance = {
297
+ balance: token.token.balance.toString(),
298
+ networkId: token.networkId,
299
+ chain: token.network,
300
+ caip: token.assetCaip,
301
+ type: 'erc20',
302
+ name: token.token.name,
303
+ symbol: token.token.symbol,
304
+ ticker: token.token.symbol,
305
+ decimals: token.token.decimals,
306
+ priceUsd: token.token.price,
307
+ valueUsd: token.token.balanceUSD.toString(),
308
+ tokenAddress: token.token.address,
309
+ };
310
+ // Log CAIP assignment for debugging
311
+ log.debug(tag, "CAIP assigned for ".concat(token.token.symbol, ": ").concat(token.assetCaip), {
312
+ address: token.token.address,
313
+ network: network
314
+ });
315
+ output_1.balances.push(balance);
316
+ log.debug(tag, "token.balanceUSD: ", token.token.balanceUSD);
317
+ totalBalanceUsdTokens_1 += token.token.balanceUSD;
318
+ }
319
+ else {
320
+ log.error(tag, "No caip found for network: ", network);
321
+ }
322
+ });
323
+ }
324
+ }
325
+ else {
326
+ totalBalanceUsdTokens_1 = 0;
327
+ }
328
+ limit = 100;
329
+ allTokens = [];
330
+ cursor = null;
331
+ _e.label = 4;
332
+ case 4:
333
+ if (!true) return [3 /*break*/, 9];
334
+ _e.label = 5;
335
+ case 5:
336
+ _e.trys.push([5, 7, , 8]);
337
+ url = "https://api.zapper.xyz/v2/nft/user/tokens?userAddress=".concat(address, "&limit=").concat(limit);
338
+ if (cursor) {
339
+ url += "&cursor=".concat(cursor);
340
+ }
341
+ return [4 /*yield*/, Axios.get(url, {
342
+ headers: {
343
+ accept: "*/*",
344
+ Authorization: Authorization,
345
+ },
346
+ })];
347
+ case 6:
348
+ response = _e.sent();
349
+ tokens = response.data;
350
+ //console.log("tokens: ",tokens)
351
+ allTokens = allTokens.concat(tokens.items);
352
+ cursor = response.data.cursor;
353
+ if (!cursor) {
354
+ return [3 /*break*/, 9];
355
+ }
356
+ return [3 /*break*/, 8];
357
+ case 7:
358
+ error_1 = _e.sent();
359
+ console.error(error_1);
360
+ return [3 /*break*/, 8];
361
+ case 8: return [3 /*break*/, 4];
362
+ case 9:
363
+ output_1.nfts = allTokens;
364
+ return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D=".concat(address), {
365
+ headers: {
366
+ accept: "*/*",
367
+ Authorization: Authorization,
368
+ },
369
+ })];
370
+ case 10:
371
+ nftResponse = _e.sent();
372
+ nftUsdNetWorth = nftResponse.data;
373
+ output_1.nftUsdNetWorth = nftUsdNetWorth;
374
+ output_1.totalBalanceUsdTokens = totalBalanceUsdTokens_1;
375
+ output_1.totalBalanceUSDApp = totalBalanceUSDApp_1;
376
+ totalNetWorth = totalBalanceUSDApp_1 + totalBalanceUsdTokens_1 + parseFloat(nftUsdNetWorth[address.toLowerCase()]);
377
+ //console.log("totalNetWorth: ",totalNetWorth);
378
+ output_1.totalNetWorth = totalNetWorth;
379
+ return [2 /*return*/, output_1];
380
+ case 11:
381
+ e_1 = _e.sent();
382
+ console.error(tag, "e: ", e_1);
383
+ return [3 /*break*/, 12];
384
+ case 12: return [2 /*return*/];
385
+ }
386
+ });
387
+ });
388
+ };
389
+ var get_total_networth = function (address) {
390
+ return __awaiter(this, void 0, void 0, function () {
391
+ var tag, appsResponse, apps, totalBalanceUSDApp_2, tokensResponse, tokens, totalBalanceUsdTokens_2, nftResponse, nftUsdNetWorth, totalNetWorth, e_2;
392
+ return __generator(this, function (_a) {
393
+ switch (_a.label) {
394
+ case 0:
395
+ tag = TAG + " | get_tokens | ";
396
+ _a.label = 1;
397
+ case 1:
398
+ _a.trys.push([1, 5, , 6]);
399
+ return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=".concat(address), {
400
+ headers: {
401
+ accept: "*/*",
402
+ Authorization: Authorization,
403
+ },
404
+ })];
405
+ case 2:
406
+ appsResponse = _a.sent();
407
+ apps = appsResponse.data;
408
+ totalBalanceUSDApp_2 = 0;
409
+ apps.forEach(function (app) {
410
+ totalBalanceUSDApp_2 += app.balanceUSD;
411
+ });
412
+ return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/tokens?addresses%5B%5D=".concat(address), {
413
+ headers: {
414
+ accept: "*/*",
415
+ Authorization: Authorization,
416
+ },
417
+ })];
418
+ case 3:
419
+ tokensResponse = _a.sent();
420
+ log.debug("tokensResponse: ", tokensResponse.data);
421
+ tokens = tokensResponse.data;
422
+ totalBalanceUsdTokens_2 = 0;
423
+ tokens = tokens[address.toLowerCase()];
424
+ // log.debug("tokens: ",tokens)
425
+ tokens.forEach(function (token) {
426
+ log.debug("token: ", token);
427
+ var network = token.network;
428
+ log.debug("network: ", token);
429
+ var caip = pioneer_caip_1.evmCaips[network];
430
+ token.caip = caip;
431
+ log.debug("token.balanceUSD: ", token.token.balanceUSD);
432
+ totalBalanceUsdTokens_2 += token.token.balanceUSD;
433
+ });
434
+ return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D=".concat(address), {
435
+ headers: {
436
+ accept: "*/*",
437
+ Authorization: Authorization,
438
+ },
439
+ })];
440
+ case 4:
441
+ nftResponse = _a.sent();
442
+ nftUsdNetWorth = nftResponse.data;
443
+ log.debug("nftUsdNetWorth: ", nftUsdNetWorth);
444
+ log.debug("totalBalanceUsdTokens: ", totalBalanceUsdTokens_2);
445
+ log.debug("totalBalanceUSDApp: ", totalBalanceUSDApp_2);
446
+ totalNetWorth = totalBalanceUSDApp_2 + totalBalanceUsdTokens_2 + parseFloat(nftUsdNetWorth[address.toLowerCase()]);
447
+ log.debug("totalNetWorth: ", totalNetWorth);
448
+ return [2 /*return*/, totalNetWorth];
449
+ case 5:
450
+ e_2 = _a.sent();
451
+ console.error(tag, "e: ", e_2);
452
+ return [3 /*break*/, 6];
453
+ case 6: return [2 /*return*/];
454
+ }
455
+ });
456
+ });
457
+ };
458
+ var get_tokens = function (address) {
459
+ return __awaiter(this, void 0, void 0, function () {
460
+ var tag, apiKey, appsResponse, e_3;
461
+ return __generator(this, function (_a) {
462
+ switch (_a.label) {
463
+ case 0:
464
+ tag = TAG + " | get_tokens | ";
465
+ _a.label = 1;
466
+ case 1:
467
+ _a.trys.push([1, 3, , 4]);
468
+ apiKey = API_KEY;
469
+ log.debug(Authorization);
470
+ return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=".concat(address), {
471
+ headers: {
472
+ accept: "*/*",
473
+ Authorization: Authorization,
474
+ },
475
+ })];
476
+ case 2:
477
+ appsResponse = _a.sent();
478
+ // @ts-ignore
479
+ // const appsResponse = await Axios.get(
480
+ // `https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=${address}`,
481
+ // {
482
+ // headers: {
483
+ // accept: "*/*",
484
+ // Authorization,
485
+ // },
486
+ // }
487
+ // );
488
+ // let url = URL_SERVICE + "/v2/balances/apps?addresses=" + address+",api_key="+API_KEY
489
+ // const headers = {
490
+ // headers: {
491
+ // "Authorization": "Bearer "+process.env['ZAPPER_API_KEY'],
492
+ // }
493
+ // }
494
+ // let result = await axios({
495
+ // url,
496
+ // method: 'GET'
497
+ // },headers)
498
+ return [2 /*return*/, appsResponse.data];
499
+ case 3:
500
+ e_3 = _a.sent();
501
+ console.error(tag, "e: ", e_3);
502
+ return [3 /*break*/, 4];
503
+ case 4: return [2 /*return*/];
504
+ }
505
+ });
506
+ });
507
+ };
508
+ var get_nfts = function (address) {
509
+ return __awaiter(this, void 0, void 0, function () {
510
+ var tag, url, result, e_4;
511
+ return __generator(this, function (_a) {
512
+ switch (_a.label) {
513
+ case 0:
514
+ tag = TAG + " | get_tokens | ";
515
+ _a.label = 1;
516
+ case 1:
517
+ _a.trys.push([1, 3, , 4]);
518
+ url = URL_SERVICE + "/v2/nft/user/tokens?userAddress=" + address;
519
+ return [4 /*yield*/, axios({
520
+ url: url,
521
+ method: 'GET',
522
+ })];
523
+ case 2:
524
+ result = _a.sent();
525
+ return [2 /*return*/, result.data];
526
+ case 3:
527
+ e_4 = _a.sent();
528
+ console.error(tag, "e: ", e_4);
529
+ return [3 /*break*/, 4];
530
+ case 4: return [2 /*return*/];
531
+ }
532
+ });
533
+ });
534
+ };