@pioneer-platform/zapper-client 8.1.18 → 8.1.24
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/LICENSE +674 -0
- package/lib/index.d.ts +1 -11
- package/lib/index.js +38 -12
- package/package.json +7 -6
- package/yarn-error.log +14584 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +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 get_portfolio: (address: string) => Promise<any>;
|
|
9
|
-
declare const get_total_networth: (address: string) => Promise<number | undefined>;
|
|
10
|
-
declare const get_tokens: (address: string) => Promise<any>;
|
|
11
|
-
declare const get_nfts: (address: string) => Promise<any>;
|
|
1
|
+
export {};
|
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,33 @@ 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
|
-
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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'];
|
|
46
50
|
if (!API_KEY)
|
|
47
51
|
throw Error("api key required! set env ZAPPER_API_KEY");
|
|
48
52
|
var axios = Axios.create();
|
|
49
|
-
var Authorization = "Basic "
|
|
53
|
+
var Authorization = "Basic ".concat(Buffer.from("".concat(API_KEY, ":"), "binary").toString("base64"));
|
|
54
|
+
console.log(Authorization);
|
|
50
55
|
var URL_SERVICE = "https://api.zapper.xyz";
|
|
56
|
+
var axiosRetry = require('axios-retry');
|
|
57
|
+
axiosRetry(axios, {
|
|
58
|
+
retries: 3,
|
|
59
|
+
retryDelay: function (retryCount) {
|
|
60
|
+
log.info(TAG, "retry attempt: ".concat(retryCount));
|
|
61
|
+
return retryCount * 2000; // time interval between retries
|
|
62
|
+
},
|
|
63
|
+
retryCondition: function (error) {
|
|
64
|
+
log.error(TAG, error);
|
|
65
|
+
// if retry condition is not specified, by default idempotent requests are retried
|
|
66
|
+
return error.response.status === 503;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
51
69
|
module.exports = {
|
|
52
70
|
getTokens: function (address) {
|
|
53
71
|
return get_tokens(address);
|
|
@@ -73,7 +91,7 @@ var get_portfolio = function (address) {
|
|
|
73
91
|
case 1:
|
|
74
92
|
_a.trys.push([1, 11, , 12]);
|
|
75
93
|
output = {};
|
|
76
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D="
|
|
94
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=".concat(address), {
|
|
77
95
|
headers: {
|
|
78
96
|
accept: "*/*",
|
|
79
97
|
Authorization: Authorization,
|
|
@@ -86,7 +104,7 @@ var get_portfolio = function (address) {
|
|
|
86
104
|
apps.forEach(function (app) {
|
|
87
105
|
totalBalanceUSDApp_1 += app.balanceUSD;
|
|
88
106
|
});
|
|
89
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/tokens?addresses%5B%5D="
|
|
107
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/tokens?addresses%5B%5D=".concat(address), {
|
|
90
108
|
headers: {
|
|
91
109
|
accept: "*/*",
|
|
92
110
|
Authorization: Authorization,
|
|
@@ -102,6 +120,10 @@ var get_portfolio = function (address) {
|
|
|
102
120
|
if (tokens) {
|
|
103
121
|
tokens.forEach(function (token) {
|
|
104
122
|
console.log("token: ", token);
|
|
123
|
+
var network = token.network;
|
|
124
|
+
console.log("network: ", token);
|
|
125
|
+
var caip = pioneer_caip_1.evmCaips[network];
|
|
126
|
+
token.caip = caip;
|
|
105
127
|
console.log("token.balanceUSD: ", token.token.balanceUSD);
|
|
106
128
|
totalBalanceUsdTokens_1 += token.token.balanceUSD;
|
|
107
129
|
});
|
|
@@ -115,9 +137,9 @@ var get_portfolio = function (address) {
|
|
|
115
137
|
_a.label = 5;
|
|
116
138
|
case 5:
|
|
117
139
|
_a.trys.push([5, 7, , 8]);
|
|
118
|
-
url = "https://api.zapper.xyz/v2/nft/user/tokens?userAddress="
|
|
140
|
+
url = "https://api.zapper.xyz/v2/nft/user/tokens?userAddress=".concat(address, "&limit=").concat(limit);
|
|
119
141
|
if (cursor) {
|
|
120
|
-
url += "&cursor="
|
|
142
|
+
url += "&cursor=".concat(cursor);
|
|
121
143
|
}
|
|
122
144
|
return [4 /*yield*/, Axios.get(url, {
|
|
123
145
|
headers: {
|
|
@@ -142,7 +164,7 @@ var get_portfolio = function (address) {
|
|
|
142
164
|
case 8: return [3 /*break*/, 4];
|
|
143
165
|
case 9:
|
|
144
166
|
output.nfts = allTokens;
|
|
145
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D="
|
|
167
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D=".concat(address), {
|
|
146
168
|
headers: {
|
|
147
169
|
accept: "*/*",
|
|
148
170
|
Authorization: Authorization,
|
|
@@ -177,7 +199,7 @@ var get_total_networth = function (address) {
|
|
|
177
199
|
_a.label = 1;
|
|
178
200
|
case 1:
|
|
179
201
|
_a.trys.push([1, 5, , 6]);
|
|
180
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D="
|
|
202
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=".concat(address), {
|
|
181
203
|
headers: {
|
|
182
204
|
accept: "*/*",
|
|
183
205
|
Authorization: Authorization,
|
|
@@ -190,7 +212,7 @@ var get_total_networth = function (address) {
|
|
|
190
212
|
apps.forEach(function (app) {
|
|
191
213
|
totalBalanceUSDApp_2 += app.balanceUSD;
|
|
192
214
|
});
|
|
193
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/tokens?addresses%5B%5D="
|
|
215
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/tokens?addresses%5B%5D=".concat(address), {
|
|
194
216
|
headers: {
|
|
195
217
|
accept: "*/*",
|
|
196
218
|
Authorization: Authorization,
|
|
@@ -205,10 +227,14 @@ var get_total_networth = function (address) {
|
|
|
205
227
|
// console.log("tokens: ",tokens)
|
|
206
228
|
tokens.forEach(function (token) {
|
|
207
229
|
console.log("token: ", token);
|
|
230
|
+
var network = token.network;
|
|
231
|
+
console.log("network: ", token);
|
|
232
|
+
var caip = pioneer_caip_1.evmCaips[network];
|
|
233
|
+
token.caip = caip;
|
|
208
234
|
console.log("token.balanceUSD: ", token.token.balanceUSD);
|
|
209
235
|
totalBalanceUsdTokens_2 += token.token.balanceUSD;
|
|
210
236
|
});
|
|
211
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D="
|
|
237
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/nft/balances/net-worth?addresses%5B%5D=".concat(address), {
|
|
212
238
|
headers: {
|
|
213
239
|
accept: "*/*",
|
|
214
240
|
Authorization: Authorization,
|
|
@@ -244,7 +270,7 @@ var get_tokens = function (address) {
|
|
|
244
270
|
_a.trys.push([1, 3, , 4]);
|
|
245
271
|
apiKey = API_KEY;
|
|
246
272
|
console.log(Authorization);
|
|
247
|
-
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D="
|
|
273
|
+
return [4 /*yield*/, Axios.get("https://api.zapper.xyz/v2/balances/apps?addresses%5B%5D=".concat(address), {
|
|
248
274
|
headers: {
|
|
249
275
|
accept: "*/*",
|
|
250
276
|
Authorization: Authorization,
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/zapper-client",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.24",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@pioneer-platform/loggerdog": "^8.1.
|
|
8
|
-
"
|
|
7
|
+
"@pioneer-platform/loggerdog": "^8.1.30",
|
|
8
|
+
"@pioneer-platform/pioneer-caip": "^8.1.74",
|
|
9
|
+
"axios": "^1.3.4",
|
|
9
10
|
"dotenv": "^8.2.0"
|
|
10
11
|
},
|
|
11
12
|
"scripts": {
|
|
@@ -23,8 +24,8 @@
|
|
|
23
24
|
"onchange": "^7.0.2",
|
|
24
25
|
"serve": "^11.3.2",
|
|
25
26
|
"source-map-support": "^0.5.19",
|
|
26
|
-
"ts-jest": "^
|
|
27
|
-
"typescript": "^
|
|
27
|
+
"ts-jest": "^29.0.5",
|
|
28
|
+
"typescript": "^5.0.2"
|
|
28
29
|
},
|
|
29
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "a3cd70b076ea1593fd2ef33f8929527a35bcf845"
|
|
30
31
|
}
|