@pioneer-platform/zapper-client 8.3.12 → 8.3.14
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 +169 -142
- package/package.json +10 -13
- package/test-output.txt +1230 -0
package/lib/index.js
CHANGED
|
@@ -3,10 +3,6 @@
|
|
|
3
3
|
https://docs.blocknative.com/webhook-api
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
7
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
8
|
-
return cooked;
|
|
9
|
-
};
|
|
10
6
|
var __assign = (this && this.__assign) || function () {
|
|
11
7
|
__assign = Object.assign || function(t) {
|
|
12
8
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -28,8 +24,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
28
24
|
});
|
|
29
25
|
};
|
|
30
26
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
31
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
32
|
-
return g =
|
|
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;
|
|
33
29
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
30
|
function step(op) {
|
|
35
31
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -62,32 +58,124 @@ var pioneer_caip_1 = require("@pioneer-platform/pioneer-caip");
|
|
|
62
58
|
var Axios = require('axios');
|
|
63
59
|
var https = require('https');
|
|
64
60
|
var API_KEY = process.env['ZAPPER_API_KEY'];
|
|
65
|
-
var API_KEY_NEW = process.env['ZAPPER_API_KEY_TIMELINE'];
|
|
66
61
|
if (!API_KEY)
|
|
67
62
|
throw Error("api key required! set env ZAPPER_API_KEY");
|
|
68
|
-
if (!API_KEY_NEW)
|
|
69
|
-
throw Error("api key required! set env ZAPPER_API_KEY_TIMELINE");
|
|
70
63
|
var axios = Axios.create();
|
|
71
64
|
var Authorization = "Basic ".concat(Buffer.from("".concat(API_KEY, ":"), "binary").toString("base64"));
|
|
72
65
|
console.log(Authorization);
|
|
73
66
|
var URL_SERVICE = "https://api.zapper.xyz";
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// if
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
67
|
+
// Removed axios-retry - using basic axios
|
|
68
|
+
/**
|
|
69
|
+
* Validates if a CAIP is correctly formatted for the given token
|
|
70
|
+
*/
|
|
71
|
+
var validateCaip = function (caip, token, networkName) {
|
|
72
|
+
var _a;
|
|
73
|
+
var tag = TAG + " | validateCaip | ";
|
|
74
|
+
try {
|
|
75
|
+
if (!caip || !caip.includes('/')) {
|
|
76
|
+
log.error(tag, "Invalid CAIP format:", caip);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
var _b = caip.split('/'), network = _b[0], assetType = _b[1];
|
|
80
|
+
// Check if token has contract address
|
|
81
|
+
var hasContractAddress = token.address &&
|
|
82
|
+
token.address !== '0x0000000000000000000000000000000000000000' &&
|
|
83
|
+
token.address.toLowerCase() !== '0x0';
|
|
84
|
+
// Special handling for eETH (Ether.fi staked ETH)
|
|
85
|
+
var isEETH = token.symbol === 'eETH' ||
|
|
86
|
+
(token.address && token.address.toLowerCase() === '0x35fa164735182de50811e8e2e824cfb9b6118ac2');
|
|
87
|
+
if (hasContractAddress || isEETH) {
|
|
88
|
+
// This should be an ERC-20 token
|
|
89
|
+
if (!(assetType === null || assetType === void 0 ? void 0 : assetType.includes('erc20'))) {
|
|
90
|
+
log.error(tag, "Token ".concat(token.symbol, " with address ").concat(token.address, " should have ERC-20 CAIP but got: ").concat(caip));
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
// Verify contract address is in CAIP
|
|
94
|
+
if (!(assetType === null || assetType === void 0 ? void 0 : assetType.includes((_a = token.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()))) {
|
|
95
|
+
log.error(tag, "Token ".concat(token.symbol, " CAIP missing contract address: ").concat(caip));
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// This should be a native asset
|
|
101
|
+
if (!(assetType === null || assetType === void 0 ? void 0 : assetType.includes('slip44'))) {
|
|
102
|
+
log.error(tag, "Native asset ".concat(token.symbol, " should have slip44 CAIP but got: ").concat(caip));
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
log.error(tag, "CAIP validation error:", e);
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Assigns the correct CAIP for a token based on its properties
|
|
115
|
+
*/
|
|
116
|
+
var assignCorrectCaip = function (networkId, token, networkName) {
|
|
117
|
+
var tag = TAG + " | assignCorrectCaip | ";
|
|
118
|
+
try {
|
|
119
|
+
// Check if token has a valid contract address
|
|
120
|
+
var hasContractAddress = token.address &&
|
|
121
|
+
token.address !== '0x0000000000000000000000000000000000000000' &&
|
|
122
|
+
token.address.toLowerCase() !== '0x0' &&
|
|
123
|
+
token.address.toLowerCase() !== '0x';
|
|
124
|
+
// Known token addresses for special handling
|
|
125
|
+
var knownTokens = {
|
|
126
|
+
'eETH': '0x35fa164735182de50811e8e2e824cfb9b6118ac2',
|
|
127
|
+
'weETH': '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee',
|
|
128
|
+
'stETH': '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
|
|
129
|
+
'wstETH': '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0'
|
|
130
|
+
};
|
|
131
|
+
// Check if this is a known token that should be ERC-20
|
|
132
|
+
var knownAddress = knownTokens[token.symbol];
|
|
133
|
+
if (knownAddress) {
|
|
134
|
+
var caip_1 = "".concat(networkId, "/erc20:").concat(knownAddress.toLowerCase());
|
|
135
|
+
log.debug(tag, "Assigned known token CAIP for ".concat(token.symbol, ": ").concat(caip_1));
|
|
136
|
+
return caip_1;
|
|
137
|
+
}
|
|
138
|
+
// For tokens with valid contract addresses (ERC-20/ERC-721)
|
|
139
|
+
if (hasContractAddress) {
|
|
140
|
+
var caip_2 = "".concat(networkId, "/erc20:").concat(token.address.toLowerCase());
|
|
141
|
+
log.debug(tag, "Assigned ERC-20 CAIP for ".concat(token.symbol, ": ").concat(caip_2));
|
|
142
|
+
return caip_2;
|
|
143
|
+
}
|
|
144
|
+
// For native tokens (ETH, BNB, MATIC, etc) - only when explicitly base-token or no address
|
|
145
|
+
if (token.type === 'base-token' || token.symbol === 'ETH' || token.symbol === 'BNB' || token.symbol === 'MATIC') {
|
|
146
|
+
var caip_3 = "".concat(networkId, "/slip44:60");
|
|
147
|
+
log.debug(tag, "Assigned native CAIP for ".concat(token.symbol, ": ").concat(caip_3));
|
|
148
|
+
return caip_3;
|
|
149
|
+
}
|
|
150
|
+
// Default to slip44:60 for native assets without addresses
|
|
151
|
+
var caip = "".concat(networkId, "/slip44:60");
|
|
152
|
+
log.warn(tag, "Default CAIP assignment for ".concat(token.symbol, ": ").concat(caip));
|
|
153
|
+
return caip;
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
log.error(tag, "Error assigning CAIP:", e);
|
|
157
|
+
// Fallback to native token CAIP
|
|
158
|
+
return "".concat(networkId, "/slip44:60");
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Logs CAIP assignment for debugging
|
|
163
|
+
*/
|
|
164
|
+
var logCaipAssignment = function (balance, originalCaip) {
|
|
165
|
+
var tag = TAG + " | logCaipAssignment | ";
|
|
166
|
+
if (originalCaip && originalCaip !== balance.caip) {
|
|
167
|
+
log.info(tag, "CAIP corrected for ".concat(balance.symbol, ":"));
|
|
168
|
+
log.info(tag, " Original: ".concat(originalCaip));
|
|
169
|
+
log.info(tag, " Corrected: ".concat(balance.caip));
|
|
170
|
+
log.info(tag, " Token details:", {
|
|
171
|
+
symbol: balance.symbol,
|
|
172
|
+
name: balance.name,
|
|
173
|
+
address: balance.tokenAddress,
|
|
174
|
+
type: balance.tokenType,
|
|
175
|
+
metaType: balance.metaType
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
91
179
|
module.exports = {
|
|
92
180
|
getTokens: function (address) {
|
|
93
181
|
return get_tokens(address);
|
|
@@ -101,93 +189,18 @@ module.exports = {
|
|
|
101
189
|
getTotalNetworth: function (address) {
|
|
102
190
|
return get_total_networth(address);
|
|
103
191
|
},
|
|
104
|
-
getAccountHistory: function (address) {
|
|
105
|
-
return get_account_history(address);
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
var get_account_history = function (address) {
|
|
109
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
110
|
-
var tag, endpoint, encodedKey_1, httpLink, authLink, client, query, variables, response, cleanResponse, e_1;
|
|
111
|
-
return __generator(this, function (_a) {
|
|
112
|
-
switch (_a.label) {
|
|
113
|
-
case 0:
|
|
114
|
-
tag = "get_account_history | ";
|
|
115
|
-
_a.label = 1;
|
|
116
|
-
case 1:
|
|
117
|
-
_a.trys.push([1, 3, , 4]);
|
|
118
|
-
endpoint = "https://public.zapper.xyz/graphql";
|
|
119
|
-
encodedKey_1 = Buffer.from(API_KEY_NEW).toString('base64');
|
|
120
|
-
httpLink = new HttpLink({
|
|
121
|
-
uri: endpoint,
|
|
122
|
-
fetch: fetch,
|
|
123
|
-
});
|
|
124
|
-
authLink = setContext(function (_, _a) {
|
|
125
|
-
var headers = _a.headers;
|
|
126
|
-
return ({
|
|
127
|
-
headers: __assign(__assign({}, headers), { 'Content-Type': 'application/json', 'Authorization': "Basic ".concat(encodedKey_1) }),
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
client = new ApolloClient({
|
|
131
|
-
link: authLink.concat(httpLink),
|
|
132
|
-
cache: new InMemoryCache(),
|
|
133
|
-
});
|
|
134
|
-
query = gql(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query ($addresses: [Address!], $realtimeInterpretation: Boolean, $isSigner: Boolean) {\n accountsTimeline(addresses: $addresses, realtimeInterpretation: $realtimeInterpretation, isSigner: $isSigner) {\n edges {\n node {\n transaction {\n hash\n fromUser {\n address\n displayName {\n value\n }\n }\n toUser {\n address\n displayName {\n value\n }\n }\n input\n value\n gasPrice\n gas\n }\n interpretation {\n processedDescription\n }\n app {\n name\n imgUrl\n }\n network\n timestamp\n similarEventCount\n }\n }\n }\n }\n "], ["\n query ($addresses: [Address!], $realtimeInterpretation: Boolean, $isSigner: Boolean) {\n accountsTimeline(addresses: $addresses, realtimeInterpretation: $realtimeInterpretation, isSigner: $isSigner) {\n edges {\n node {\n transaction {\n hash\n fromUser {\n address\n displayName {\n value\n }\n }\n toUser {\n address\n displayName {\n value\n }\n }\n input\n value\n gasPrice\n gas\n }\n interpretation {\n processedDescription\n }\n app {\n name\n imgUrl\n }\n network\n timestamp\n similarEventCount\n }\n }\n }\n }\n "])));
|
|
135
|
-
variables = {
|
|
136
|
-
addresses: [address],
|
|
137
|
-
realtimeInterpretation: true,
|
|
138
|
-
isSigner: true,
|
|
139
|
-
};
|
|
140
|
-
return [4 /*yield*/, client.query({ query: query, variables: variables })];
|
|
141
|
-
case 2:
|
|
142
|
-
response = _a.sent();
|
|
143
|
-
cleanResponse = response.data.accountsTimeline.edges.map(function (edge) {
|
|
144
|
-
var _a = edge.node, _b = _a.transaction, hash = _b.hash, fromUser = _b.fromUser, toUser = _b.toUser, input = _b.input, value = _b.value, gasPrice = _b.gasPrice, gas = _b.gas, processedDescription = _a.interpretation.processedDescription, app = _a.app, network = _a.network, timestamp = _a.timestamp, similarEventCount = _a.similarEventCount;
|
|
145
|
-
return {
|
|
146
|
-
txid: hash,
|
|
147
|
-
from: {
|
|
148
|
-
address: fromUser.address,
|
|
149
|
-
displayName: fromUser.displayName.value,
|
|
150
|
-
},
|
|
151
|
-
to: toUser ? {
|
|
152
|
-
address: toUser.address,
|
|
153
|
-
displayName: toUser.displayName.value,
|
|
154
|
-
} : null,
|
|
155
|
-
description: processedDescription,
|
|
156
|
-
app: app ? {
|
|
157
|
-
name: app.name,
|
|
158
|
-
imgUrl: app.imgUrl,
|
|
159
|
-
} : null,
|
|
160
|
-
network: network,
|
|
161
|
-
timestamp: new Date(timestamp).toISOString(),
|
|
162
|
-
input: input,
|
|
163
|
-
value: value,
|
|
164
|
-
gasPrice: gasPrice,
|
|
165
|
-
gas: gas,
|
|
166
|
-
similarEventCount: similarEventCount
|
|
167
|
-
};
|
|
168
|
-
});
|
|
169
|
-
console.log("Cleaned response:", cleanResponse);
|
|
170
|
-
return [2 /*return*/, cleanResponse];
|
|
171
|
-
case 3:
|
|
172
|
-
e_1 = _a.sent();
|
|
173
|
-
console.error(tag, "Error: ", e_1);
|
|
174
|
-
return [2 /*return*/, null];
|
|
175
|
-
case 4: return [2 /*return*/];
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
192
|
};
|
|
180
193
|
var get_portfolio = function (address) {
|
|
181
|
-
var _a, _b;
|
|
182
194
|
return __awaiter(this, void 0, void 0, function () {
|
|
183
|
-
var tag, output_1, appsResponse, apps, totalBalanceUSDApp_1, i, app, j, product, k, asset, l, token, balance, tokensResponse, totalBalanceUsdTokens_1, tokens, limit, allTokens, cursor, url, response, tokens, error_1, nftResponse, nftUsdNetWorth, totalNetWorth,
|
|
184
|
-
|
|
185
|
-
|
|
195
|
+
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;
|
|
196
|
+
var _a, _b, _c, _d;
|
|
197
|
+
return __generator(this, function (_e) {
|
|
198
|
+
switch (_e.label) {
|
|
186
199
|
case 0:
|
|
187
200
|
tag = TAG + " | get_portfolio | ";
|
|
188
|
-
|
|
201
|
+
_e.label = 1;
|
|
189
202
|
case 1:
|
|
190
|
-
|
|
203
|
+
_e.trys.push([1, 11, , 12]);
|
|
191
204
|
output_1 = {
|
|
192
205
|
balances: []
|
|
193
206
|
};
|
|
@@ -198,7 +211,7 @@ var get_portfolio = function (address) {
|
|
|
198
211
|
},
|
|
199
212
|
})];
|
|
200
213
|
case 2:
|
|
201
|
-
appsResponse =
|
|
214
|
+
appsResponse = _e.sent();
|
|
202
215
|
log.info(tag, "appsResponse: ", appsResponse.data);
|
|
203
216
|
apps = appsResponse.data;
|
|
204
217
|
totalBalanceUSDApp_1 = 0;
|
|
@@ -220,22 +233,35 @@ var get_portfolio = function (address) {
|
|
|
220
233
|
balance.balance = token === null || token === void 0 ? void 0 : token.balance.toString();
|
|
221
234
|
balance.chain = app.network;
|
|
222
235
|
balance.networkId = pioneer_caip_1.evmCaips[app.network].split('/')[0];
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
236
|
+
tokenForCaip = token;
|
|
237
|
+
if (asset.type === 'app-token' && asset.address &&
|
|
238
|
+
asset.address !== '0x0000000000000000000000000000000000000000') {
|
|
239
|
+
// Use the asset-level address for app tokens
|
|
240
|
+
tokenForCaip = __assign(__assign({}, token), { address: asset.address, symbol: asset.symbol || token.symbol });
|
|
228
241
|
}
|
|
242
|
+
// Assign correct CAIP based on token properties
|
|
243
|
+
balance.caip = assignCorrectCaip(balance.networkId, tokenForCaip, app.network);
|
|
244
|
+
// Log CAIP assignment for debugging
|
|
245
|
+
log.debug(tag, "CAIP assigned for ".concat(asset.symbol || token.symbol, ": ").concat(balance.caip), {
|
|
246
|
+
assetAddress: asset.address,
|
|
247
|
+
tokenAddress: token.address,
|
|
248
|
+
assetType: asset.type,
|
|
249
|
+
tokenType: token.type,
|
|
250
|
+
network: app.network
|
|
251
|
+
});
|
|
229
252
|
balance.metaType = token.metaType || product.metaType;
|
|
230
253
|
balance.name = asset.displayProps.label;
|
|
231
254
|
balance.appId = app.appId;
|
|
232
255
|
balance.icon = asset.displayProps.images[0];
|
|
233
256
|
balance.display = asset.displayProps.images;
|
|
234
257
|
balance.groupId = asset.groupId;
|
|
235
|
-
balance.symbol = token.symbol;
|
|
236
|
-
balance.ticker = token.symbol;
|
|
237
|
-
balance.priceUsd = ((_a = token === null || token === void 0 ? void 0 : token.price) === null ||
|
|
238
|
-
balance.valueUsd = ((
|
|
258
|
+
balance.symbol = asset.symbol || token.symbol; // Use asset symbol if available
|
|
259
|
+
balance.ticker = asset.symbol || token.symbol; // Use asset symbol if available
|
|
260
|
+
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
|
|
261
|
+
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
|
|
262
|
+
// Add additional fields for debugging
|
|
263
|
+
balance.tokenAddress = asset.address || token.address;
|
|
264
|
+
balance.tokenType = asset.type || token.type;
|
|
239
265
|
output_1.balances.push(balance);
|
|
240
266
|
}
|
|
241
267
|
}
|
|
@@ -248,7 +274,7 @@ var get_portfolio = function (address) {
|
|
|
248
274
|
},
|
|
249
275
|
})];
|
|
250
276
|
case 3:
|
|
251
|
-
tokensResponse =
|
|
277
|
+
tokensResponse = _e.sent();
|
|
252
278
|
console.log("tokensResponse: ", tokensResponse.data);
|
|
253
279
|
if (tokensResponse.data && tokensResponse.data[address.toLowerCase()]) {
|
|
254
280
|
tokens = tokensResponse.data;
|
|
@@ -264,12 +290,8 @@ var get_portfolio = function (address) {
|
|
|
264
290
|
var caip = pioneer_caip_1.evmCaips[network];
|
|
265
291
|
if (caip) {
|
|
266
292
|
token.networkId = caip.split('/')[0];
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
token.assetCaip = caip;
|
|
272
|
-
}
|
|
293
|
+
// Assign correct CAIP based on token properties
|
|
294
|
+
token.assetCaip = assignCorrectCaip(token.networkId, token.token, network);
|
|
273
295
|
var balance = {
|
|
274
296
|
balance: token.token.balance.toString(),
|
|
275
297
|
networkId: token.networkId,
|
|
@@ -282,7 +304,13 @@ var get_portfolio = function (address) {
|
|
|
282
304
|
decimals: token.token.decimals,
|
|
283
305
|
priceUsd: token.token.price,
|
|
284
306
|
valueUsd: token.token.balanceUSD.toString(),
|
|
307
|
+
tokenAddress: token.token.address,
|
|
285
308
|
};
|
|
309
|
+
// Log CAIP assignment for debugging
|
|
310
|
+
log.debug(tag, "CAIP assigned for ".concat(token.token.symbol, ": ").concat(token.assetCaip), {
|
|
311
|
+
address: token.token.address,
|
|
312
|
+
network: network
|
|
313
|
+
});
|
|
286
314
|
output_1.balances.push(balance);
|
|
287
315
|
log.debug(tag, "token.balanceUSD: ", token.token.balanceUSD);
|
|
288
316
|
totalBalanceUsdTokens_1 += token.token.balanceUSD;
|
|
@@ -299,12 +327,12 @@ var get_portfolio = function (address) {
|
|
|
299
327
|
limit = 100;
|
|
300
328
|
allTokens = [];
|
|
301
329
|
cursor = null;
|
|
302
|
-
|
|
330
|
+
_e.label = 4;
|
|
303
331
|
case 4:
|
|
304
332
|
if (!true) return [3 /*break*/, 9];
|
|
305
|
-
|
|
333
|
+
_e.label = 5;
|
|
306
334
|
case 5:
|
|
307
|
-
|
|
335
|
+
_e.trys.push([5, 7, , 8]);
|
|
308
336
|
url = "https://api.zapper.xyz/v2/nft/user/tokens?userAddress=".concat(address, "&limit=").concat(limit);
|
|
309
337
|
if (cursor) {
|
|
310
338
|
url += "&cursor=".concat(cursor);
|
|
@@ -316,7 +344,7 @@ var get_portfolio = function (address) {
|
|
|
316
344
|
},
|
|
317
345
|
})];
|
|
318
346
|
case 6:
|
|
319
|
-
response =
|
|
347
|
+
response = _e.sent();
|
|
320
348
|
tokens = response.data;
|
|
321
349
|
//console.log("tokens: ",tokens)
|
|
322
350
|
allTokens = allTokens.concat(tokens.items);
|
|
@@ -326,7 +354,7 @@ var get_portfolio = function (address) {
|
|
|
326
354
|
}
|
|
327
355
|
return [3 /*break*/, 8];
|
|
328
356
|
case 7:
|
|
329
|
-
error_1 =
|
|
357
|
+
error_1 = _e.sent();
|
|
330
358
|
console.error(error_1);
|
|
331
359
|
return [3 /*break*/, 8];
|
|
332
360
|
case 8: return [3 /*break*/, 4];
|
|
@@ -339,7 +367,7 @@ var get_portfolio = function (address) {
|
|
|
339
367
|
},
|
|
340
368
|
})];
|
|
341
369
|
case 10:
|
|
342
|
-
nftResponse =
|
|
370
|
+
nftResponse = _e.sent();
|
|
343
371
|
nftUsdNetWorth = nftResponse.data;
|
|
344
372
|
output_1.nftUsdNetWorth = nftUsdNetWorth;
|
|
345
373
|
output_1.totalBalanceUsdTokens = totalBalanceUsdTokens_1;
|
|
@@ -349,8 +377,8 @@ var get_portfolio = function (address) {
|
|
|
349
377
|
output_1.totalNetWorth = totalNetWorth;
|
|
350
378
|
return [2 /*return*/, output_1];
|
|
351
379
|
case 11:
|
|
352
|
-
|
|
353
|
-
console.error(tag, "e: ",
|
|
380
|
+
e_1 = _e.sent();
|
|
381
|
+
console.error(tag, "e: ", e_1);
|
|
354
382
|
return [3 /*break*/, 12];
|
|
355
383
|
case 12: return [2 /*return*/];
|
|
356
384
|
}
|
|
@@ -359,7 +387,7 @@ var get_portfolio = function (address) {
|
|
|
359
387
|
};
|
|
360
388
|
var get_total_networth = function (address) {
|
|
361
389
|
return __awaiter(this, void 0, void 0, function () {
|
|
362
|
-
var tag, appsResponse, apps, totalBalanceUSDApp_2, tokensResponse, tokens, totalBalanceUsdTokens_2, nftResponse, nftUsdNetWorth, totalNetWorth,
|
|
390
|
+
var tag, appsResponse, apps, totalBalanceUSDApp_2, tokensResponse, tokens, totalBalanceUsdTokens_2, nftResponse, nftUsdNetWorth, totalNetWorth, e_2;
|
|
363
391
|
return __generator(this, function (_a) {
|
|
364
392
|
switch (_a.label) {
|
|
365
393
|
case 0:
|
|
@@ -418,8 +446,8 @@ var get_total_networth = function (address) {
|
|
|
418
446
|
log.debug("totalNetWorth: ", totalNetWorth);
|
|
419
447
|
return [2 /*return*/, totalNetWorth];
|
|
420
448
|
case 5:
|
|
421
|
-
|
|
422
|
-
console.error(tag, "e: ",
|
|
449
|
+
e_2 = _a.sent();
|
|
450
|
+
console.error(tag, "e: ", e_2);
|
|
423
451
|
return [3 /*break*/, 6];
|
|
424
452
|
case 6: return [2 /*return*/];
|
|
425
453
|
}
|
|
@@ -428,7 +456,7 @@ var get_total_networth = function (address) {
|
|
|
428
456
|
};
|
|
429
457
|
var get_tokens = function (address) {
|
|
430
458
|
return __awaiter(this, void 0, void 0, function () {
|
|
431
|
-
var tag, apiKey, appsResponse,
|
|
459
|
+
var tag, apiKey, appsResponse, e_3;
|
|
432
460
|
return __generator(this, function (_a) {
|
|
433
461
|
switch (_a.label) {
|
|
434
462
|
case 0:
|
|
@@ -468,8 +496,8 @@ var get_tokens = function (address) {
|
|
|
468
496
|
// },headers)
|
|
469
497
|
return [2 /*return*/, appsResponse.data];
|
|
470
498
|
case 3:
|
|
471
|
-
|
|
472
|
-
console.error(tag, "e: ",
|
|
499
|
+
e_3 = _a.sent();
|
|
500
|
+
console.error(tag, "e: ", e_3);
|
|
473
501
|
return [3 /*break*/, 4];
|
|
474
502
|
case 4: return [2 /*return*/];
|
|
475
503
|
}
|
|
@@ -478,7 +506,7 @@ var get_tokens = function (address) {
|
|
|
478
506
|
};
|
|
479
507
|
var get_nfts = function (address) {
|
|
480
508
|
return __awaiter(this, void 0, void 0, function () {
|
|
481
|
-
var tag, url, result,
|
|
509
|
+
var tag, url, result, e_4;
|
|
482
510
|
return __generator(this, function (_a) {
|
|
483
511
|
switch (_a.label) {
|
|
484
512
|
case 0:
|
|
@@ -495,12 +523,11 @@ var get_nfts = function (address) {
|
|
|
495
523
|
result = _a.sent();
|
|
496
524
|
return [2 /*return*/, result.data];
|
|
497
525
|
case 3:
|
|
498
|
-
|
|
499
|
-
console.error(tag, "e: ",
|
|
526
|
+
e_4 = _a.sent();
|
|
527
|
+
console.error(tag, "e: ", e_4);
|
|
500
528
|
return [3 /*break*/, 4];
|
|
501
529
|
case 4: return [2 /*return*/];
|
|
502
530
|
}
|
|
503
531
|
});
|
|
504
532
|
});
|
|
505
533
|
};
|
|
506
|
-
var templateObject_1;
|
package/package.json
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/zapper-client",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.14",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@apollo/client": "^3.12.4",
|
|
8
7
|
"@pioneer-platform/loggerdog": "^8.3.1",
|
|
9
8
|
"@pioneer-platform/pioneer-caip": "^9.2.36",
|
|
10
|
-
"axios": "^1.
|
|
11
|
-
"dotenv": "^8.2.0"
|
|
12
|
-
"graphql": "^16.10.0",
|
|
13
|
-
"node-fetch": "2"
|
|
9
|
+
"axios": "^1.6.0",
|
|
10
|
+
"dotenv": "^8.2.0"
|
|
14
11
|
},
|
|
15
12
|
"scripts": {
|
|
16
|
-
"npm": "
|
|
17
|
-
"test": "
|
|
13
|
+
"npm": "pnpm i",
|
|
14
|
+
"test": "pnpm run build && node __tests__/test-module.js",
|
|
18
15
|
"build": "tsc -p .",
|
|
19
|
-
"prepublish": "
|
|
20
|
-
"refresh": "rm -rf ./node_modules ./package-lock.json &&
|
|
16
|
+
"prepublish": "pnpm run build",
|
|
17
|
+
"refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
|
|
21
18
|
},
|
|
22
19
|
"devDependencies": {
|
|
23
20
|
"@types/jest": "^25.2.3",
|
|
24
|
-
"@types/node": "^
|
|
21
|
+
"@types/node": "^18.16.0",
|
|
25
22
|
"@types/source-map-support": "^0.5.3",
|
|
26
23
|
"jest": "^26.4.2",
|
|
27
24
|
"onchange": "^7.0.2",
|
|
28
25
|
"serve": "^11.3.2",
|
|
29
26
|
"source-map-support": "^0.5.19",
|
|
30
27
|
"ts-jest": "^29.0.5",
|
|
31
|
-
"typescript": "^5.0.
|
|
28
|
+
"typescript": "^5.0.4"
|
|
32
29
|
},
|
|
33
30
|
"gitHead": "aeae28273014ab69b42f22abec159c6693a56c40"
|
|
34
|
-
}
|
|
31
|
+
}
|