@pioneer-platform/zapper-client 8.1.23 → 8.1.25
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 -12
- package/lib/index.js +29 -16
- package/package.json +4 -3
- package/yarn-error.log +14584 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
declare const Axios: any;
|
|
3
|
-
declare const https: any;
|
|
4
|
-
declare let API_KEY: string | undefined;
|
|
5
|
-
declare const axios: any;
|
|
6
|
-
declare const Authorization: string;
|
|
7
|
-
declare let URL_SERVICE: string;
|
|
8
|
-
declare const axiosRetry: any;
|
|
9
|
-
declare const get_portfolio: (address: string) => Promise<any>;
|
|
10
|
-
declare const get_total_networth: (address: string) => Promise<number | undefined>;
|
|
11
|
-
declare const get_tokens: (address: string) => Promise<any>;
|
|
12
|
-
declare const get_nfts: (address: string) => Promise<any>;
|
|
1
|
+
export {};
|
package/lib/index.js
CHANGED
|
@@ -39,7 +39,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
39
39
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
43
|
var TAG = " | zapper | ";
|
|
44
|
+
var log = require('@pioneer-platform/loggerdog')();
|
|
45
|
+
//@ts-ignore
|
|
46
|
+
var pioneer_caip_1 = require("@pioneer-platform/pioneer-caip");
|
|
43
47
|
var Axios = require('axios');
|
|
44
48
|
var https = require('https');
|
|
45
49
|
var API_KEY = process.env['ZAPPER_API_KEY'];
|
|
@@ -53,11 +57,11 @@ var axiosRetry = require('axios-retry');
|
|
|
53
57
|
axiosRetry(axios, {
|
|
54
58
|
retries: 3,
|
|
55
59
|
retryDelay: function (retryCount) {
|
|
56
|
-
|
|
60
|
+
log.debug(TAG, "retry attempt: ".concat(retryCount));
|
|
57
61
|
return retryCount * 2000; // time interval between retries
|
|
58
62
|
},
|
|
59
63
|
retryCondition: function (error) {
|
|
60
|
-
|
|
64
|
+
log.error(TAG, error);
|
|
61
65
|
// if retry condition is not specified, by default idempotent requests are retried
|
|
62
66
|
return error.response.status === 503;
|
|
63
67
|
},
|
|
@@ -112,11 +116,16 @@ var get_portfolio = function (address) {
|
|
|
112
116
|
totalBalanceUsdTokens_1 = 0;
|
|
113
117
|
tokens = tokens[address.toLowerCase()];
|
|
114
118
|
output.tokens = tokens;
|
|
115
|
-
|
|
119
|
+
log.debug(tag, "tokens: ", tokens.length);
|
|
116
120
|
if (tokens) {
|
|
117
121
|
tokens.forEach(function (token) {
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
log.debug(tag, "token: ", token);
|
|
123
|
+
var network = token.network;
|
|
124
|
+
log.debug(tag, "network: ", token);
|
|
125
|
+
var caip = pioneer_caip_1.evmCaips[network];
|
|
126
|
+
token.blockchainCaip = caip;
|
|
127
|
+
token.assetCaip = caip + ":" + token.token.address;
|
|
128
|
+
log.debug(tag, "token.balanceUSD: ", token.token.balanceUSD);
|
|
120
129
|
totalBalanceUsdTokens_1 += token.token.balanceUSD;
|
|
121
130
|
});
|
|
122
131
|
}
|
|
@@ -142,7 +151,7 @@ var get_portfolio = function (address) {
|
|
|
142
151
|
case 6:
|
|
143
152
|
response = _a.sent();
|
|
144
153
|
tokens_1 = response.data;
|
|
145
|
-
console.log("tokens: ",
|
|
154
|
+
//console.log("tokens: ",tokens)
|
|
146
155
|
allTokens = allTokens.concat(tokens_1.items);
|
|
147
156
|
cursor = response.data.cursor;
|
|
148
157
|
if (!cursor) {
|
|
@@ -169,7 +178,7 @@ var get_portfolio = function (address) {
|
|
|
169
178
|
output.totalBalanceUsdTokens = totalBalanceUsdTokens_1;
|
|
170
179
|
output.totalBalanceUSDApp = totalBalanceUSDApp_1;
|
|
171
180
|
totalNetWorth = totalBalanceUSDApp_1 + totalBalanceUsdTokens_1 + parseFloat(nftUsdNetWorth[address.toLowerCase()]);
|
|
172
|
-
//
|
|
181
|
+
//console.log("totalNetWorth: ",totalNetWorth);
|
|
173
182
|
output.totalNetWorth = totalNetWorth;
|
|
174
183
|
return [2 /*return*/, output];
|
|
175
184
|
case 11:
|
|
@@ -212,14 +221,18 @@ var get_total_networth = function (address) {
|
|
|
212
221
|
})];
|
|
213
222
|
case 3:
|
|
214
223
|
tokensResponse = _a.sent();
|
|
215
|
-
|
|
224
|
+
log.debug("tokensResponse: ", tokensResponse.data);
|
|
216
225
|
tokens = tokensResponse.data;
|
|
217
226
|
totalBalanceUsdTokens_2 = 0;
|
|
218
227
|
tokens = tokens[address.toLowerCase()];
|
|
219
|
-
//
|
|
228
|
+
// log.debug("tokens: ",tokens)
|
|
220
229
|
tokens.forEach(function (token) {
|
|
221
|
-
|
|
222
|
-
|
|
230
|
+
log.debug("token: ", token);
|
|
231
|
+
var network = token.network;
|
|
232
|
+
log.debug("network: ", token);
|
|
233
|
+
var caip = pioneer_caip_1.evmCaips[network];
|
|
234
|
+
token.caip = caip;
|
|
235
|
+
log.debug("token.balanceUSD: ", token.token.balanceUSD);
|
|
223
236
|
totalBalanceUsdTokens_2 += token.token.balanceUSD;
|
|
224
237
|
});
|
|
225
238
|
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D=".concat(address), {
|
|
@@ -231,11 +244,11 @@ var get_total_networth = function (address) {
|
|
|
231
244
|
case 4:
|
|
232
245
|
nftResponse = _a.sent();
|
|
233
246
|
nftUsdNetWorth = nftResponse.data;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
247
|
+
log.debug("nftUsdNetWorth: ", nftUsdNetWorth);
|
|
248
|
+
log.debug("totalBalanceUsdTokens: ", totalBalanceUsdTokens_2);
|
|
249
|
+
log.debug("totalBalanceUSDApp: ", totalBalanceUSDApp_2);
|
|
237
250
|
totalNetWorth = totalBalanceUSDApp_2 + totalBalanceUsdTokens_2 + parseFloat(nftUsdNetWorth[address.toLowerCase()]);
|
|
238
|
-
|
|
251
|
+
log.debug("totalNetWorth: ", totalNetWorth);
|
|
239
252
|
return [2 /*return*/, totalNetWorth];
|
|
240
253
|
case 5:
|
|
241
254
|
e_2 = _a.sent();
|
|
@@ -257,7 +270,7 @@ var get_tokens = function (address) {
|
|
|
257
270
|
case 1:
|
|
258
271
|
_a.trys.push([1, 3, , 4]);
|
|
259
272
|
apiKey = API_KEY;
|
|
260
|
-
|
|
273
|
+
log.debug(Authorization);
|
|
261
274
|
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=".concat(address), {
|
|
262
275
|
headers: {
|
|
263
276
|
accept: "*/*",
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/zapper-client",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.25",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@pioneer-platform/loggerdog": "^8.1.
|
|
7
|
+
"@pioneer-platform/loggerdog": "^8.1.30",
|
|
8
|
+
"@pioneer-platform/pioneer-caip": "^8.1.74",
|
|
8
9
|
"axios": "^1.3.4",
|
|
9
10
|
"dotenv": "^8.2.0"
|
|
10
11
|
},
|
|
@@ -26,5 +27,5 @@
|
|
|
26
27
|
"ts-jest": "^29.0.5",
|
|
27
28
|
"typescript": "^5.0.2"
|
|
28
29
|
},
|
|
29
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "4e125fc566bffddabfad7fcc74b9a02f63db7932"
|
|
30
31
|
}
|