@pioneer-platform/zapper-client 8.1.18 → 8.1.23
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 +2 -1
- package/lib/index.js +26 -12
- package/package.json +6 -6
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
declare const TAG = " |
|
|
1
|
+
declare const TAG = " | zapper | ";
|
|
2
2
|
declare const Axios: any;
|
|
3
3
|
declare const https: any;
|
|
4
4
|
declare let API_KEY: string | undefined;
|
|
5
5
|
declare const axios: any;
|
|
6
6
|
declare const Authorization: string;
|
|
7
7
|
declare let URL_SERVICE: string;
|
|
8
|
+
declare const axiosRetry: any;
|
|
8
9
|
declare const get_portfolio: (address: string) => Promise<any>;
|
|
9
10
|
declare const get_total_networth: (address: string) => Promise<number | undefined>;
|
|
10
11
|
declare const get_tokens: (address: string) => Promise<any>;
|
package/lib/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
18
18
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
19
|
function step(op) {
|
|
20
20
|
if (f) throw new TypeError("Generator is already executing.");
|
|
21
|
-
while (_) try {
|
|
21
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
22
22
|
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;
|
|
23
23
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
24
24
|
switch (op[0]) {
|
|
@@ -39,15 +39,29 @@ 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
|
-
var TAG = " |
|
|
42
|
+
var TAG = " | zapper | ";
|
|
43
43
|
var Axios = require('axios');
|
|
44
44
|
var https = require('https');
|
|
45
45
|
var API_KEY = process.env['ZAPPER_API_KEY'];
|
|
46
46
|
if (!API_KEY)
|
|
47
47
|
throw Error("api key required! set env ZAPPER_API_KEY");
|
|
48
48
|
var axios = Axios.create();
|
|
49
|
-
var Authorization = "Basic "
|
|
49
|
+
var Authorization = "Basic ".concat(Buffer.from("".concat(API_KEY, ":"), "binary").toString("base64"));
|
|
50
|
+
console.log(Authorization);
|
|
50
51
|
var URL_SERVICE = "https://api.zapper.xyz";
|
|
52
|
+
var axiosRetry = require('axios-retry');
|
|
53
|
+
axiosRetry(axios, {
|
|
54
|
+
retries: 3,
|
|
55
|
+
retryDelay: function (retryCount) {
|
|
56
|
+
console.log("retry attempt: ".concat(retryCount));
|
|
57
|
+
return retryCount * 2000; // time interval between retries
|
|
58
|
+
},
|
|
59
|
+
retryCondition: function (error) {
|
|
60
|
+
//console.error(error)
|
|
61
|
+
// if retry condition is not specified, by default idempotent requests are retried
|
|
62
|
+
return error.response.status === 503;
|
|
63
|
+
},
|
|
64
|
+
});
|
|
51
65
|
module.exports = {
|
|
52
66
|
getTokens: function (address) {
|
|
53
67
|
return get_tokens(address);
|
|
@@ -73,7 +87,7 @@ var get_portfolio = function (address) {
|
|
|
73
87
|
case 1:
|
|
74
88
|
_a.trys.push([1, 11, , 12]);
|
|
75
89
|
output = {};
|
|
76
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D="
|
|
90
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=".concat(address), {
|
|
77
91
|
headers: {
|
|
78
92
|
accept: "*/*",
|
|
79
93
|
Authorization: Authorization,
|
|
@@ -86,7 +100,7 @@ var get_portfolio = function (address) {
|
|
|
86
100
|
apps.forEach(function (app) {
|
|
87
101
|
totalBalanceUSDApp_1 += app.balanceUSD;
|
|
88
102
|
});
|
|
89
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/tokens?addresses%5B%5D="
|
|
103
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/tokens?addresses%5B%5D=".concat(address), {
|
|
90
104
|
headers: {
|
|
91
105
|
accept: "*/*",
|
|
92
106
|
Authorization: Authorization,
|
|
@@ -115,9 +129,9 @@ var get_portfolio = function (address) {
|
|
|
115
129
|
_a.label = 5;
|
|
116
130
|
case 5:
|
|
117
131
|
_a.trys.push([5, 7, , 8]);
|
|
118
|
-
url = "https://api.zapper.xyz/v2/nft/user/tokens?userAddress="
|
|
132
|
+
url = "https://api.zapper.xyz/v2/nft/user/tokens?userAddress=".concat(address, "&limit=").concat(limit);
|
|
119
133
|
if (cursor) {
|
|
120
|
-
url += "&cursor="
|
|
134
|
+
url += "&cursor=".concat(cursor);
|
|
121
135
|
}
|
|
122
136
|
return [4 /*yield*/, Axios.get(url, {
|
|
123
137
|
headers: {
|
|
@@ -142,7 +156,7 @@ var get_portfolio = function (address) {
|
|
|
142
156
|
case 8: return [3 /*break*/, 4];
|
|
143
157
|
case 9:
|
|
144
158
|
output.nfts = allTokens;
|
|
145
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D="
|
|
159
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D=".concat(address), {
|
|
146
160
|
headers: {
|
|
147
161
|
accept: "*/*",
|
|
148
162
|
Authorization: Authorization,
|
|
@@ -177,7 +191,7 @@ var get_total_networth = function (address) {
|
|
|
177
191
|
_a.label = 1;
|
|
178
192
|
case 1:
|
|
179
193
|
_a.trys.push([1, 5, , 6]);
|
|
180
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D="
|
|
194
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=".concat(address), {
|
|
181
195
|
headers: {
|
|
182
196
|
accept: "*/*",
|
|
183
197
|
Authorization: Authorization,
|
|
@@ -190,7 +204,7 @@ var get_total_networth = function (address) {
|
|
|
190
204
|
apps.forEach(function (app) {
|
|
191
205
|
totalBalanceUSDApp_2 += app.balanceUSD;
|
|
192
206
|
});
|
|
193
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/tokens?addresses%5B%5D="
|
|
207
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/tokens?addresses%5B%5D=".concat(address), {
|
|
194
208
|
headers: {
|
|
195
209
|
accept: "*/*",
|
|
196
210
|
Authorization: Authorization,
|
|
@@ -208,7 +222,7 @@ var get_total_networth = function (address) {
|
|
|
208
222
|
console.log("token.balanceUSD: ", token.token.balanceUSD);
|
|
209
223
|
totalBalanceUsdTokens_2 += token.token.balanceUSD;
|
|
210
224
|
});
|
|
211
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D="
|
|
225
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D=".concat(address), {
|
|
212
226
|
headers: {
|
|
213
227
|
accept: "*/*",
|
|
214
228
|
Authorization: Authorization,
|
|
@@ -244,7 +258,7 @@ var get_tokens = function (address) {
|
|
|
244
258
|
_a.trys.push([1, 3, , 4]);
|
|
245
259
|
apiKey = API_KEY;
|
|
246
260
|
console.log(Authorization);
|
|
247
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D="
|
|
261
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=".concat(address), {
|
|
248
262
|
headers: {
|
|
249
263
|
accept: "*/*",
|
|
250
264
|
Authorization: Authorization,
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/zapper-client",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.23",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@pioneer-platform/loggerdog": "^8.1.
|
|
8
|
-
"axios": "^
|
|
7
|
+
"@pioneer-platform/loggerdog": "^8.1.29",
|
|
8
|
+
"axios": "^1.3.4",
|
|
9
9
|
"dotenv": "^8.2.0"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"onchange": "^7.0.2",
|
|
24
24
|
"serve": "^11.3.2",
|
|
25
25
|
"source-map-support": "^0.5.19",
|
|
26
|
-
"ts-jest": "^
|
|
27
|
-
"typescript": "^
|
|
26
|
+
"ts-jest": "^29.0.5",
|
|
27
|
+
"typescript": "^5.0.2"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "974ddd872e4595ebc78a4f983811303b9623cf82"
|
|
30
30
|
}
|