@indexing/jiti 0.0.3 → 1.0.1

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/dist/main.js CHANGED
@@ -1,4 +1,5 @@
1
1
  var $8zHUo$viem = require("viem");
2
+ var $8zHUo$isomorphicfetch = require("isomorphic-fetch");
2
3
 
3
4
 
4
5
  function $parcel$export(e, n, v, s) {
@@ -22,27 +23,163 @@ function $parcel$exportWildcard(dest, source) {
22
23
  return dest;
23
24
  }
24
25
 
25
- $parcel$export(module.exports, "templates", () => $882b6d93070905b3$export$a8fc3402335b0b04);
26
+ function $parcel$interopDefault(a) {
27
+ return a && a.__esModule ? a.default : a;
28
+ }
29
+
26
30
  $parcel$export(module.exports, "getAllTemplates", () => $882b6d93070905b3$export$cceb5167b935aafb);
27
31
  $parcel$export(module.exports, "getTemplateByKey", () => $882b6d93070905b3$export$a07bfd14bbc36e4b);
32
+ $parcel$export(module.exports, "presets", () => $14cf6f53e99b3d5b$exports);
28
33
  $parcel$export(module.exports, "utils", () => $d7167569386d0d4c$exports);
29
34
  $parcel$export(module.exports, "types", () => $faefaad95e5fcca0$exports);
30
- const $59fb8e0333a5d25f$var$rawTemplate = {
31
- key: "raw",
32
- name: "Raw Block Data",
35
+ const $49a91814dabec06a$var$allBlocks = {
36
+ key: "allBlocks",
37
+ name: "All Blocks",
33
38
  description: "Get all blocks with all available fields",
34
39
  tags: [
35
40
  "EVM",
36
- "RAW"
41
+ "TRANSACTIONS"
37
42
  ],
38
43
  disabled: false,
39
44
  params: [],
40
- transform: (payload)=>payload,
41
- tests: []
45
+ function: ()=>{
46
+ return `
47
+ function allBlocks(block, _ctx) {
48
+ return block;
49
+ }`;
50
+ }
42
51
  };
43
- var $59fb8e0333a5d25f$export$2e2bcd8739ae039 = $59fb8e0333a5d25f$var$rawTemplate;
52
+ var $49a91814dabec06a$export$2e2bcd8739ae039 = $49a91814dabec06a$var$allBlocks;
53
+
54
+
55
+ const $6144a02851f23907$var$tokenTransfers = {
56
+ key: "tokenTransfers",
57
+ name: "Token Transfers",
58
+ description: "Get all blocks for a set of token types.",
59
+ tags: [
60
+ "EVM",
61
+ "NFTs",
62
+ "ERC20",
63
+ "ERC721"
64
+ ],
65
+ disabled: false,
66
+ params: [],
67
+ function: ()=>{
68
+ return `
69
+ function tokenTransfers(block, _ctx) {
70
+ return block;
71
+ }`;
72
+ }
73
+ };
74
+ var $6144a02851f23907$export$2e2bcd8739ae039 = $6144a02851f23907$var$tokenTransfers;
75
+
76
+
77
+ const $48f9879a44dd1195$export$a8fc3402335b0b04 = [
78
+ (0, $49a91814dabec06a$export$2e2bcd8739ae039),
79
+ (0, $6144a02851f23907$export$2e2bcd8739ae039)
80
+ ];
81
+
82
+
83
+ var $14cf6f53e99b3d5b$exports = {};
84
+ var $9c8abe84804d9e5d$exports = {};
85
+
86
+ $parcel$export($9c8abe84804d9e5d$exports, "erc20Transfers", () => $9c8abe84804d9e5d$export$b830a1966711a4f4);
87
+ var $da55be3e40667945$exports = {};
44
88
 
89
+ $parcel$export($da55be3e40667945$exports, "evmDecodeLog", () => $da55be3e40667945$export$18467e329ea485c9);
90
+ $parcel$export($da55be3e40667945$exports, "evmDecodeLogWithMetadata", () => $da55be3e40667945$export$cf548b70626e2eb9);
91
+
92
+ var $f7a3fb164436c9c3$exports = {};
93
+
94
+ $parcel$export($f7a3fb164436c9c3$exports, "evmMethodSignatureToHex", () => $f7a3fb164436c9c3$export$49d5c9473f8f70f2);
95
+
96
+ function $f7a3fb164436c9c3$export$49d5c9473f8f70f2(sig) {
97
+ const [method, rest] = sig.split("(");
98
+ const params = rest.split(")")[0].split(",").map((p)=>p.trim());
99
+ const topic0 = (0, $8zHUo$viem.keccak256)(`${method.split(" ").pop()}(${params.map((p)=>p.split(" ")[0]).join(",")})`);
100
+ return topic0;
101
+ }
102
+
103
+
104
+ function $da55be3e40667945$export$18467e329ea485c9(log, signatures) {
105
+ if (Array.isArray(signatures)) {
106
+ for (const sig of signatures){
107
+ const decoded = $da55be3e40667945$export$18467e329ea485c9(log, sig);
108
+ if (decoded) return decoded;
109
+ }
110
+ return null;
111
+ }
112
+ if (typeof signatures !== "string" && Array.isArray(signatures.addresses) && signatures.addresses.length) {
113
+ const addresses = signatures.addresses.map((a)=>a?.toLowerCase());
114
+ if (!addresses.includes(log.address.toLowerCase())) return null;
115
+ }
116
+ let sig = (typeof signatures === "string" ? signatures : signatures.signature).trim();
117
+ if (!sig.startsWith("event ")) sig = "event " + sig;
118
+ const topic0 = typeof signatures !== "string" && signatures.topic0 ? signatures.topic0 : (0, $f7a3fb164436c9c3$export$49d5c9473f8f70f2)(sig);
119
+ if ((sig.match(/ indexed /g)?.length || 0) === log.topics.length - 1) {
120
+ if (log.topics[0] === topic0) try {
121
+ const result = (0, $8zHUo$viem.decodeEventLog)({
122
+ abi: (0, $8zHUo$viem.parseAbi)([
123
+ sig
124
+ ]),
125
+ data: log.data,
126
+ topics: log.topics
127
+ });
128
+ return result.args;
129
+ } catch (e) {
130
+ // ignore this
131
+ }
132
+ }
133
+ return null;
134
+ }
135
+ function $da55be3e40667945$export$cf548b70626e2eb9(log, signatures) {
136
+ for (const sig of [
137
+ signatures
138
+ ].flat()){
139
+ const decoded = $da55be3e40667945$export$18467e329ea485c9(log, sig);
140
+ if (decoded) return {
141
+ decoded: decoded,
142
+ metadata: {
143
+ name: (typeof sig === "string" ? sig : sig.signature).split("(")[0]
144
+ }
145
+ };
146
+ }
147
+ return null;
148
+ }
149
+
150
+
151
+ function $9c8abe84804d9e5d$export$b830a1966711a4f4(block) {
152
+ const txfers = [];
153
+ for (const tx of block.transactions){
154
+ if (!tx.receipt) continue;
155
+ for (const log of tx.receipt.logs){
156
+ const txfer = (0, $da55be3e40667945$export$18467e329ea485c9)(log, "Transfer(address indexed from, address indexed to, uint256 value)");
157
+ if (txfer) txfers.push({
158
+ blockNumber: block.number,
159
+ timestamp: new Date(block.timestamp * 1000).toISOString(),
160
+ transactionHash: tx.hash,
161
+ ...txfer
162
+ });
163
+ }
164
+ }
165
+ return txfers;
166
+ }
45
167
 
168
+
169
+ var $2bc08226e0d6a193$exports = {};
170
+
171
+ $parcel$export($2bc08226e0d6a193$exports, "tokenPrice", () => $2bc08226e0d6a193$export$e8386b633cdbc2d7);
172
+
173
+ function $2bc08226e0d6a193$export$e8386b633cdbc2d7(tokenAddress, opts) {
174
+ let url = `https://jiti.indexing.co/presets/token-price/${opts?.network || "ethereum"}?tokenAddress=${tokenAddress}`;
175
+ if (opts?.timestamp) url += "&priceTimestamp=" + new Date(opts.timestamp).toISOString();
176
+ return (0, ($parcel$interopDefault($8zHUo$isomorphicfetch)))(url).then((r)=>r.json()).then((r)=>r.data);
177
+ }
178
+
179
+
180
+ var $32af5abe02e3405e$exports = {};
181
+
182
+ $parcel$export($32af5abe02e3405e$exports, "tokenTransfers", () => $32af5abe02e3405e$export$b62520a34e11070c);
46
183
  var $d7167569386d0d4c$exports = {};
47
184
  var $596a656635c74d50$exports = {};
48
185
 
@@ -105,7 +242,6 @@ const $e5566e47593dc3e2$var$CHAIN_ID = {
105
242
  STACK: 78225,
106
243
  SYNDICATE_FRAME_CHAIN: 5101,
107
244
  TRON: 728126428,
108
- ZER0: 543210,
109
245
  ZK_LINK: 810180,
110
246
  ZORA: 7777777,
111
247
  ZORA_SEPOLIA: 999999999
@@ -115,69 +251,6 @@ function $e5566e47593dc3e2$export$f93b8abed77a4120(chain) {
115
251
  }
116
252
 
117
253
 
118
- var $da55be3e40667945$exports = {};
119
-
120
- $parcel$export($da55be3e40667945$exports, "evmDecodeLog", () => $da55be3e40667945$export$18467e329ea485c9);
121
- $parcel$export($da55be3e40667945$exports, "evmDecodeLogWithMetadata", () => $da55be3e40667945$export$cf548b70626e2eb9);
122
-
123
- var $f7a3fb164436c9c3$exports = {};
124
-
125
- $parcel$export($f7a3fb164436c9c3$exports, "evmMethodSignatureToHex", () => $f7a3fb164436c9c3$export$49d5c9473f8f70f2);
126
-
127
- function $f7a3fb164436c9c3$export$49d5c9473f8f70f2(sig) {
128
- const [method, rest] = sig.split("(");
129
- const params = rest.split(")")[0].split(",").map((p)=>p.trim());
130
- const topic0 = (0, $8zHUo$viem.keccak256)(`${method.split(" ").pop()}(${params.map((p)=>p.split(" ")[0]).join(",")})`);
131
- return topic0;
132
- }
133
-
134
-
135
- function $da55be3e40667945$export$18467e329ea485c9(log, signatures) {
136
- if (Array.isArray(signatures)) {
137
- for (const sig of signatures){
138
- const decoded = $da55be3e40667945$export$18467e329ea485c9(log, sig);
139
- if (decoded) return decoded;
140
- }
141
- return null;
142
- }
143
- if (typeof signatures !== "string" && Array.isArray(signatures.addresses) && signatures.addresses.length) {
144
- const addresses = signatures.addresses.map((a)=>a?.toLowerCase());
145
- if (!addresses.includes(log.address.toLowerCase())) return null;
146
- }
147
- let sig = (typeof signatures === "string" ? signatures : signatures.signature).trim();
148
- if (!sig.startsWith("event ")) sig = "event " + sig;
149
- const topic0 = typeof signatures !== "string" && signatures.topic0 ? signatures.topic0 : (0, $f7a3fb164436c9c3$export$49d5c9473f8f70f2)(sig);
150
- if ((sig.match(/ indexed /g)?.length || 0) === log.topics.length - 1) {
151
- if (log.topics[0] === topic0) try {
152
- const result = (0, $8zHUo$viem.decodeEventLog)({
153
- abi: (0, $8zHUo$viem.parseAbi)([
154
- sig
155
- ]),
156
- data: log.data,
157
- topics: log.topics
158
- });
159
- return result.args;
160
- } catch (e) {
161
- // ignore this
162
- }
163
- }
164
- return null;
165
- }
166
- function $da55be3e40667945$export$cf548b70626e2eb9(log, signatures) {
167
- for (const sig of [
168
- signatures
169
- ].flat()){
170
- const decoded = $da55be3e40667945$export$18467e329ea485c9(log, sig);
171
- if (decoded) return {
172
- decoded: decoded,
173
- metadata: {
174
- name: (typeof sig === "string" ? sig : sig.signature).split("(")[0]
175
- }
176
- };
177
- }
178
- return null;
179
- }
180
-
181
254
 
182
255
 
183
256
  var $414c83047563e72e$exports = {};
@@ -254,223 +327,78 @@ $parcel$exportWildcard($d7167569386d0d4c$exports, $f7a3fb164436c9c3$exports);
254
327
  $parcel$exportWildcard($d7167569386d0d4c$exports, $414c83047563e72e$exports);
255
328
 
256
329
 
257
- const $6144a02851f23907$var$NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
258
- const $6144a02851f23907$var$tokenTransfersTemplate = {
259
- key: "token_transfers",
260
- name: "Token Transfers",
261
- description: "Get all token transfers for a set of token types.",
262
- tags: [
263
- "EVM",
264
- "ERC20",
265
- "ERC721",
266
- "NFT",
267
- "TOKEN"
268
- ],
269
- disabled: false,
270
- params: [
271
- {
272
- key: "network",
273
- name: "Network",
274
- type: "NETWORK",
275
- optional: false
276
- },
277
- {
278
- key: "tokenAddress",
279
- name: "Token Address",
280
- type: "ADDRESS",
281
- optional: true
282
- },
283
- {
284
- key: "walletAddress",
285
- name: "Wallet Address",
286
- type: "ADDRESS",
287
- optional: true
288
- },
289
- {
290
- key: "tokenTypes",
291
- name: "Token Types",
292
- type: "STRING",
293
- multiple: true,
294
- optional: true
295
- }
296
- ],
297
- transform: (block, _ctx)=>{
298
- const TOKEN_TYPES = _ctx.params.tokenTypes || [];
299
- let transfers = [];
300
- switch(block._network){
301
- // @TODO: expand to non-EVM
302
- // assume EVM as default for now
303
- default:
304
- for (const tx of block.transactions){
305
- if (!tx.receipt) continue;
306
- const timestamp = new Date(block.timestamp * 1000).toISOString();
307
- const transactionGasFee = BigInt(tx.receipt.gasUsed) * BigInt(tx.receipt.effectiveGasPrice);
308
- // track direct ETH transfers
309
- if (!TOKEN_TYPES.length || TOKEN_TYPES.includes("NATIVE")) {
310
- // pull from traces, if available
311
- if (Array.isArray(tx.traces)) for (const trace of tx.traces.filter((t)=>t.action)){
312
- const action = trace.action;
313
- if (!action?.value) continue;
314
- transfers.push({
315
- amount: BigInt(action.value),
316
- blockNumber: tx.blockNumber,
317
- from: action.from?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
318
- index: trace.traceAddress?.join("-"),
319
- timestamp: timestamp,
320
- to: action.to?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
321
- tokenType: "NATIVE",
322
- transactionGasFee: transactionGasFee,
323
- transactionHash: tx.hash
324
- });
325
- }
326
- else if (tx.value?.length >= 3 || /\d+/.test(tx.value)) transfers.push({
327
- amount: BigInt(tx.value),
328
- blockNumber: tx.blockNumber,
329
- from: tx.from?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
330
- timestamp: timestamp,
331
- to: tx.to?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
332
- tokenType: "NATIVE",
333
- transactionGasFee: transactionGasFee,
334
- transactionHash: tx.hash
335
- });
336
- }
337
- // track ERC20 transfers
338
- if (!TOKEN_TYPES.length || TOKEN_TYPES.includes("TOKEN")) for (const log of tx.receipt.logs){
339
- const txfer = (0, $da55be3e40667945$export$cf548b70626e2eb9)(log, [
340
- "Transfer(address indexed from, address indexed to, uint256 value)"
341
- ]);
342
- if (txfer) transfers.push({
343
- amount: txfer.decoded.value,
344
- blockNumber: tx.blockNumber,
345
- from: txfer.decoded.from?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
346
- index: log.logIndex,
347
- timestamp: timestamp,
348
- to: txfer.decoded.to?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
349
- token: log.address.toLowerCase(),
350
- tokenType: "TOKEN",
351
- transactionGasFee: transactionGasFee,
352
- transactionHash: tx.hash
353
- });
354
- }
355
- // @TODO: add NFT transfers
356
- if (!TOKEN_TYPES.length || TOKEN_TYPES.includes("NFT")) for (const log of tx.receipt.logs){
357
- const txfer = (0, $da55be3e40667945$export$cf548b70626e2eb9)(log, [
358
- "Transfer(address indexed from, address indexed to, uint256 indexed value)",
359
- "TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)",
360
- "TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values)"
361
- ]);
362
- if (!txfer) continue;
363
- switch(txfer.metadata.name){
364
- case "Transfer":
365
- transfers.push({
366
- amount: 1,
367
- blockNumber: tx.blockNumber,
368
- from: txfer.decoded.from?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
369
- index: log.logIndex,
370
- timestamp: timestamp,
371
- to: txfer.decoded.to?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
372
- token: log.address.toLowerCase(),
373
- tokenId: txfer.decoded.value.toString(),
374
- tokenType: "NFT",
375
- transactionGasFee: transactionGasFee,
376
- transactionHash: tx.hash
377
- });
378
- break;
379
- case "TransferSingle":
380
- transfers.push({
381
- amount: txfer.decoded.value,
382
- blockNumber: tx.blockNumber,
383
- from: txfer.decoded.from?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
384
- index: log.logIndex,
385
- timestamp: timestamp,
386
- to: txfer.decoded.to?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
387
- token: log.address.toLowerCase(),
388
- tokenId: txfer.decoded.id.toString(),
389
- tokenType: "NFT",
390
- transactionGasFee: transactionGasFee,
391
- transactionHash: tx.hash
392
- });
393
- break;
394
- case "TransferBatch":
395
- for(let i = 0; i < txfer.decoded.ids.length; i += 1)transfers.push({
396
- amount: txfer.decoded.values[i],
397
- blockNumber: tx.blockNumber,
398
- from: txfer.decoded.from?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
399
- index: log.logIndex,
400
- timestamp: timestamp,
401
- to: txfer.decoded.to?.toLowerCase() || $6144a02851f23907$var$NULL_ADDRESS,
402
- token: log.address.toLowerCase(),
403
- tokenId: txfer.decoded.ids[i].toString(),
404
- tokenType: "NFT",
405
- transactionGasFee: transactionGasFee,
406
- transactionHash: tx.hash
407
- });
408
- break;
409
- }
410
- }
330
+ const $32af5abe02e3405e$var$NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
331
+ function $32af5abe02e3405e$export$b62520a34e11070c(block) {
332
+ const transfers = [];
333
+ switch(block._network){
334
+ // @TODO: port non-EVM handlers over
335
+ // assume EVM as default for now
336
+ default:
337
+ for (const tx of block.transactions){
338
+ if (!tx.receipt) continue;
339
+ const timestamp = new Date(block.timestamp * 1000).toISOString();
340
+ const transactionGasFee = BigInt(tx.receipt.gasUsed) * BigInt(tx.receipt.effectiveGasPrice);
341
+ // track direct ETH transfers
342
+ if (tx.value?.length >= 3 || /\d+/.test(tx.value)) transfers.push({
343
+ amount: BigInt(tx.value),
344
+ blockNumber: tx.blockNumber,
345
+ from: (0, $596a656635c74d50$export$db81f9ea057ab646)(tx.from) || $32af5abe02e3405e$var$NULL_ADDRESS,
346
+ timestamp: timestamp,
347
+ to: (0, $596a656635c74d50$export$db81f9ea057ab646)(tx.to) || $32af5abe02e3405e$var$NULL_ADDRESS,
348
+ transactionGasFee: transactionGasFee,
349
+ transactionHash: tx.hash
350
+ });
351
+ // track ERC20 transfers
352
+ for (const log of tx.receipt.logs){
353
+ const txfer = (0, $da55be3e40667945$export$cf548b70626e2eb9)(log, [
354
+ "Transfer(address indexed from, address indexed to, uint256 value)"
355
+ ]);
356
+ if (txfer) transfers.push({
357
+ amount: txfer.decoded.value,
358
+ blockNumber: tx.blockNumber,
359
+ from: (0, $596a656635c74d50$export$db81f9ea057ab646)(txfer.decoded.from) || $32af5abe02e3405e$var$NULL_ADDRESS,
360
+ index: log.logIndex,
361
+ timestamp: timestamp,
362
+ to: (0, $596a656635c74d50$export$db81f9ea057ab646)(txfer.decoded.to) || $32af5abe02e3405e$var$NULL_ADDRESS,
363
+ token: (0, $596a656635c74d50$export$db81f9ea057ab646)(log.address),
364
+ transactionGasFee: transactionGasFee,
365
+ transactionHash: tx.hash
366
+ });
411
367
  }
412
- if (typeof _ctx.params.contractAddress === "string") _ctx.params.contractAddress = _ctx.params.contractAddress.toLowerCase();
413
- if (typeof _ctx.params.walletAddress === "string") _ctx.params.walletAddress = _ctx.params.walletAddress.toLowerCase();
414
- break;
415
- }
416
- transfers = transfers.filter((txfer)=>{
417
- if (txfer.amount <= BigInt(0)) return false;
418
- if (_ctx.params.tokenAddress && _ctx.params.tokenAddress !== txfer.token) return false;
419
- if (_ctx.params.walletAddress && ![
420
- txfer.from,
421
- txfer.to
422
- ].includes(_ctx.params.walletAddress)) return false;
423
- return true;
424
- });
425
- return transfers;
426
- },
427
- tests: [
428
- {
429
- params: {
430
- network: "BASE",
431
- walletAddress: "0x4F80864cD68782144e3736626896990acAe15a11",
432
- contractAddress: "0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed"
433
- },
434
- payload: "https://jiti.indexing.co/networks/base/23507423",
435
- output: [
436
- {
437
- amount: 1000000000000000000000n,
438
- blockNumber: 23507423,
439
- from: "0x053002b4b332b422733c9469ddf9990bb6235e3d",
440
- index: 536,
441
- timestamp: "2024-12-10T04:16:33.000Z",
442
- to: "0x4f80864cd68782144e3736626896990acae15a11",
443
- token: "0x4ed4e862860bed51a9570b96d89af5e1b0efefed",
444
- tokenType: "TOKEN",
445
- transactionGasFee: 1192354854229n,
446
- transactionHash: "0x69c9b12ccbe2d4f2f1dfc7c4a8557fc099fc5df276424417815acbc79a06fd56"
368
+ if (Array.isArray(tx.traces)) for (const trace of tx.traces.filter((t)=>t.action)){
369
+ const action = trace.action;
370
+ if (!action?.value) continue;
371
+ transfers.push({
372
+ amount: BigInt(action.value),
373
+ blockNumber: tx.blockNumber,
374
+ from: (0, $596a656635c74d50$export$db81f9ea057ab646)(action.from) || $32af5abe02e3405e$var$NULL_ADDRESS,
375
+ index: trace.traceAddress?.join("-"),
376
+ timestamp: timestamp,
377
+ to: (0, $596a656635c74d50$export$db81f9ea057ab646)(action.to) || $32af5abe02e3405e$var$NULL_ADDRESS,
378
+ transactionGasFee: transactionGasFee,
379
+ transactionHash: tx.hash
380
+ });
447
381
  }
448
- ]
449
- }
450
- ]
451
- };
452
- var $6144a02851f23907$export$2e2bcd8739ae039 = $6144a02851f23907$var$tokenTransfersTemplate;
382
+ }
383
+ }
384
+ return transfers.filter((txfer)=>txfer.amount > BigInt(0));
385
+ }
453
386
 
454
387
 
455
- const $48f9879a44dd1195$export$a8fc3402335b0b04 = [
456
- (0, $59fb8e0333a5d25f$export$2e2bcd8739ae039),
457
- (0, $6144a02851f23907$export$2e2bcd8739ae039)
458
- ];
388
+ $parcel$exportWildcard($14cf6f53e99b3d5b$exports, $9c8abe84804d9e5d$exports);
389
+ $parcel$exportWildcard($14cf6f53e99b3d5b$exports, $2bc08226e0d6a193$exports);
390
+ $parcel$exportWildcard($14cf6f53e99b3d5b$exports, $32af5abe02e3405e$exports);
459
391
 
460
392
 
461
393
 
462
394
  var $faefaad95e5fcca0$exports = {};
463
395
 
464
396
 
465
- const $882b6d93070905b3$export$a8fc3402335b0b04 = (0, $48f9879a44dd1195$export$a8fc3402335b0b04).reduce((a, b)=>({
466
- ...a,
467
- [b.key]: Object.assign({}, b)
468
- }), {});
469
397
  function $882b6d93070905b3$export$cceb5167b935aafb() {
470
- return (0, $48f9879a44dd1195$export$a8fc3402335b0b04).slice();
398
+ return 0, $48f9879a44dd1195$export$a8fc3402335b0b04;
471
399
  }
472
400
  function $882b6d93070905b3$export$a07bfd14bbc36e4b(key) {
473
- return (0, $48f9879a44dd1195$export$a8fc3402335b0b04).slice().find((template)=>template.key === key);
401
+ return (0, $48f9879a44dd1195$export$a8fc3402335b0b04).find((template)=>template.key === key);
474
402
  }
475
403
 
476
404
 
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEEA,MAAM,oCAAwB;IAC5B,KAAK;IACL,MAAM;IACN,aAAa;IACb,MAAM;QAAC;QAAO;KAAM;IACpB,UAAU;IACV,QAAQ,EAAE;IACV,WAAW,CAAC,UAAY;IACxB,OAAO,EAAE;AACX;IAEA,2CAAe;;;;;;;;AGXR,SAAS,0CAAqB,OAAe;IAClD,IAAI,CAAC,WAAW,CAAC,uBAAuB,IAAI,CAAC,UAC3C,OAAO;IAGT,MAAM,eAAe,QAAQ,KAAK,CAAC,GAAG,WAAW;IACjD,MAAM,aAAa,CAAA,GAAA,qBAAQ,EAAE;IAC7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/templates/raw.ts","src/templates/token-transfers.ts","src/utils/index.ts","src/utils/evm-address-to-checksum.ts","src/utils/evm-chain-to-id.ts","src/utils/evm-decode-log.ts","src/utils/evm-method-signature-to-hex.ts","src/utils/evm-normalize-raw-block.ts","src/types.ts"],"sourcesContent":["import { templates as templateList } from './templates';\nimport * as utils from './utils';\nimport * as types from './types';\n\nconst templates = templateList.reduce((a, b) => ({ ...a, [b.key]: Object.assign({}, b) }), {});\n\nexport { utils, templates, types };\n\nexport function getAllTemplates() {\n return templateList.slice();\n}\n\nexport function getTemplateByKey(key: string) {\n return templateList.slice().find((template) => template.key === key);\n}\n","import rawTemplate from './raw';\nimport tokenTransfersTemplate from './token-transfers';\n\nexport const templates = [rawTemplate, tokenTransfersTemplate];\n","import { Template } from '../types';\n\nconst rawTemplate: Template = {\n key: 'raw',\n name: 'Raw Block Data',\n description: 'Get all blocks with all available fields',\n tags: ['EVM', 'RAW'],\n disabled: false,\n params: [],\n transform: (payload) => payload,\n tests: [],\n};\n\nexport default rawTemplate;\n","import { evmDecodeLogWithMetadata } from '../utils';\nimport { Template } from '../types';\n\ntype NetworkTransfer = {\n amount: number | bigint;\n blockNumber: number;\n from: string;\n index?: string;\n timestamp: string;\n to: string;\n token?: string;\n tokenId?: string;\n tokenType: 'NATIVE' | 'TOKEN' | 'NFT';\n transactionGasFee: bigint;\n transactionHash: string;\n};\n\nconst NULL_ADDRESS = '0x0000000000000000000000000000000000000000';\n\nconst tokenTransfersTemplate: Template = {\n key: 'token_transfers',\n name: 'Token Transfers',\n description: 'Get all token transfers for a set of token types.',\n tags: ['EVM', 'ERC20', 'ERC721', 'NFT', 'TOKEN'],\n disabled: false,\n params: [\n { key: 'network', name: 'Network', type: 'NETWORK', optional: false },\n { key: 'tokenAddress', name: 'Token Address', type: 'ADDRESS', optional: true },\n { key: 'walletAddress', name: 'Wallet Address', type: 'ADDRESS', optional: true },\n { key: 'tokenTypes', name: 'Token Types', type: 'STRING', multiple: true, optional: true },\n ],\n\n transform: (block, _ctx) => {\n const TOKEN_TYPES = (_ctx.params.tokenTypes as NetworkTransfer['tokenType'][]) || [];\n let transfers: NetworkTransfer[] = [];\n\n switch (block._network) {\n // @TODO: expand to non-EVM\n\n // assume EVM as default for now\n default: {\n for (const tx of block.transactions as any[]) {\n if (!tx.receipt) {\n continue;\n }\n\n const timestamp = new Date((block.timestamp as number) * 1000).toISOString();\n const transactionGasFee = BigInt(tx.receipt.gasUsed) * BigInt(tx.receipt.effectiveGasPrice);\n\n // track direct ETH transfers\n if (!TOKEN_TYPES.length || TOKEN_TYPES.includes('NATIVE')) {\n // pull from traces, if available\n if (Array.isArray(tx.traces)) {\n for (const trace of tx.traces.filter((t) => t.action)) {\n const action = trace.action as unknown as { from: string; to: string; value: string };\n if (!action?.value) continue;\n\n transfers.push({\n amount: BigInt(action.value),\n blockNumber: tx.blockNumber as number,\n from: action.from?.toLowerCase() || NULL_ADDRESS,\n index: trace.traceAddress?.join('-'),\n timestamp,\n to: action.to?.toLowerCase() || NULL_ADDRESS,\n tokenType: 'NATIVE',\n transactionGasFee,\n transactionHash: tx.hash,\n });\n }\n } else if ((tx.value as string)?.length >= 3 || /\\d+/.test(tx.value as string)) {\n transfers.push({\n amount: BigInt(tx.value as string),\n blockNumber: tx.blockNumber as number,\n from: tx.from?.toLowerCase() || NULL_ADDRESS,\n timestamp,\n to: tx.to?.toLowerCase() || NULL_ADDRESS,\n tokenType: 'NATIVE',\n transactionGasFee,\n transactionHash: tx.hash,\n });\n }\n }\n\n // track ERC20 transfers\n if (!TOKEN_TYPES.length || TOKEN_TYPES.includes('TOKEN')) {\n for (const log of tx.receipt.logs) {\n const txfer = evmDecodeLogWithMetadata(log, [\n 'Transfer(address indexed from, address indexed to, uint256 value)',\n ]);\n if (txfer) {\n transfers.push({\n amount: txfer.decoded.value as bigint,\n blockNumber: tx.blockNumber as number,\n from: (txfer.decoded.from as string)?.toLowerCase() || NULL_ADDRESS,\n index: log.logIndex,\n timestamp,\n to: (txfer.decoded.to as string)?.toLowerCase() || NULL_ADDRESS,\n token: (log.address as string).toLowerCase(),\n tokenType: 'TOKEN',\n transactionGasFee,\n transactionHash: tx.hash,\n });\n }\n }\n }\n\n // @TODO: add NFT transfers\n if (!TOKEN_TYPES.length || TOKEN_TYPES.includes('NFT')) {\n for (const log of tx.receipt.logs) {\n const txfer = evmDecodeLogWithMetadata(log, [\n 'Transfer(address indexed from, address indexed to, uint256 indexed value)',\n 'TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)',\n 'TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values)',\n ]);\n\n if (!txfer) continue;\n\n switch (txfer.metadata.name) {\n case 'Transfer': {\n transfers.push({\n amount: 1,\n blockNumber: tx.blockNumber as number,\n from: (txfer.decoded.from as string)?.toLowerCase() || NULL_ADDRESS,\n index: log.logIndex,\n timestamp,\n to: (txfer.decoded.to as string)?.toLowerCase() || NULL_ADDRESS,\n token: (log.address as string).toLowerCase(),\n tokenId: (txfer.decoded.value as bigint).toString(),\n tokenType: 'NFT',\n transactionGasFee,\n transactionHash: tx.hash,\n });\n break;\n }\n case 'TransferSingle': {\n transfers.push({\n amount: txfer.decoded.value as bigint,\n blockNumber: tx.blockNumber as number,\n from: (txfer.decoded.from as string)?.toLowerCase() || NULL_ADDRESS,\n index: log.logIndex,\n timestamp,\n to: (txfer.decoded.to as string)?.toLowerCase() || NULL_ADDRESS,\n token: (log.address as string).toLowerCase(),\n tokenId: (txfer.decoded.id as bigint).toString(),\n tokenType: 'NFT',\n transactionGasFee,\n transactionHash: tx.hash,\n });\n break;\n }\n case 'TransferBatch': {\n for (let i = 0; i < (txfer.decoded.ids as bigint[]).length; i += 1) {\n transfers.push({\n amount: txfer.decoded.values[i] as bigint,\n blockNumber: tx.blockNumber as number,\n from: (txfer.decoded.from as string)?.toLowerCase() || NULL_ADDRESS,\n index: log.logIndex,\n timestamp,\n to: (txfer.decoded.to as string)?.toLowerCase() || NULL_ADDRESS,\n token: (log.address as string).toLowerCase(),\n tokenId: (txfer.decoded.ids[i] as bigint).toString(),\n tokenType: 'NFT',\n transactionGasFee,\n transactionHash: tx.hash,\n });\n }\n break;\n }\n }\n }\n }\n }\n if (typeof _ctx.params.contractAddress === 'string') {\n _ctx.params.contractAddress = _ctx.params.contractAddress.toLowerCase();\n }\n if (typeof _ctx.params.walletAddress === 'string') {\n _ctx.params.walletAddress = _ctx.params.walletAddress.toLowerCase();\n }\n break;\n }\n }\n\n transfers = transfers.filter((txfer) => {\n if (txfer.amount <= BigInt(0)) {\n return false;\n }\n if (_ctx.params.tokenAddress && _ctx.params.tokenAddress !== txfer.token) {\n return false;\n }\n if (_ctx.params.walletAddress && ![txfer.from, txfer.to].includes(_ctx.params.walletAddress as string)) {\n return false;\n }\n return true;\n });\n\n return transfers;\n },\n\n tests: [\n {\n params: {\n network: 'BASE',\n walletAddress: '0x4F80864cD68782144e3736626896990acAe15a11',\n contractAddress: '0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed',\n },\n payload: 'https://jiti.indexing.co/networks/base/23507423',\n output: [\n {\n amount: 1000000000000000000000n,\n blockNumber: 23507423,\n from: '0x053002b4b332b422733c9469ddf9990bb6235e3d',\n index: 536,\n timestamp: '2024-12-10T04:16:33.000Z',\n to: '0x4f80864cd68782144e3736626896990acae15a11',\n token: '0x4ed4e862860bed51a9570b96d89af5e1b0efefed',\n tokenType: 'TOKEN',\n transactionGasFee: 1192354854229n,\n transactionHash: '0x69c9b12ccbe2d4f2f1dfc7c4a8557fc099fc5df276424417815acbc79a06fd56',\n },\n ],\n },\n ],\n};\n\nexport default tokenTransfersTemplate;\n","export * from './evm-address-to-checksum';\nexport * from './evm-chain-to-id';\nexport * from './evm-decode-log';\nexport * from './evm-method-signature-to-hex';\nexport * from './evm-normalize-raw-block';\n","import { keccak256 } from 'viem';\n\nexport function evmAddressToChecksum(address: string) {\n if (!address || !/^(0x)?[0-9a-f]{40}$/i.test(address)) {\n return null;\n }\n\n const stripAddress = address.slice(2).toLowerCase();\n const keccakHash = keccak256(stripAddress as `0x${string}`);\n let checksumAddress = '0x';\n\n for (let i = 0; i < stripAddress.length; i++) {\n checksumAddress += parseInt(keccakHash[i], 16) >= 8 ? stripAddress[i].toUpperCase() : stripAddress[i];\n }\n\n return checksumAddress;\n}\n","const CHAIN_ID = {\n ARBITRUM: 42161,\n AVALANCHE: 43114,\n BASE: 8453,\n BASE_SEPOLIA: 84532,\n BERACHAIN_BARTIO: 80084,\n BLAST: 81457,\n BSC: 56,\n CELO: 42220,\n CYBER: 7560,\n DEGEN: 666666666,\n ETHEREUM: 1,\n ETH_HOLESKY: 17000,\n ETH_SEPOLIA: 11155111,\n FRAXTAL: 252,\n FRAXTAL_SEPOLIA: 2522,\n FUSE: 122,\n GNOSIS: 100,\n GOLD: 4653,\n HAM: 5112,\n HEMI_TESTNET: 743111,\n LINEA: 59144,\n LINEA_SEPOLIA: 59141,\n LISK_SEPOLIA: 4202,\n LYRA: 957,\n LYRA_SEPOLIA: 901,\n MODE: 34443,\n MODE_SEPOLIA: 919,\n NEON: 245022934,\n OASIS_SAPPHIRE: 23294,\n OPTIMISM: 10,\n OP_SEPOLIA: 11155420,\n ORDERLY: 291,\n ORDERLY_SEPOLIA: 4460,\n PGN_SEPOLIA: 58008,\n POLYGON: 137,\n POLYGON_AMOY: 80002,\n POLYGON_ZKEVM: 1101,\n PUBLIC_GOODS_NETWORK: 424,\n SCROLL: 534352,\n SCROLL_SEPOLIA: 534351,\n STACK: 78225,\n SYNDICATE_FRAME_CHAIN: 5101,\n TRON: 728126428,\n ZER0: 543210,\n ZK_LINK: 810180,\n ZORA: 7777777,\n ZORA_SEPOLIA: 999999999,\n};\n\nexport function evmChainToId(chain: string) {\n return CHAIN_ID[chain?.toUpperCase()];\n}\n","import { decodeEventLog, parseAbi } from 'viem';\n\nimport { evmMethodSignatureToHex } from './evm-method-signature-to-hex';\n\ntype BasicLog = Record<string, unknown> & { address: string; topics: string[] };\ntype SignaturesToDecode = string | { addresses?: string[]; signature: string; topic0?: string };\n\nexport function evmDecodeLog(\n log: BasicLog,\n signatures: SignaturesToDecode | SignaturesToDecode[]\n): Record<string, unknown> {\n if (Array.isArray(signatures)) {\n for (const sig of signatures) {\n const decoded = evmDecodeLog(log, sig);\n if (decoded) {\n return decoded;\n }\n }\n\n return null;\n }\n\n if (typeof signatures !== 'string' && Array.isArray(signatures.addresses) && signatures.addresses.length) {\n const addresses = signatures.addresses.map((a) => a?.toLowerCase());\n if (!addresses.includes(log.address.toLowerCase())) {\n return null;\n }\n }\n\n let sig = (typeof signatures === 'string' ? signatures : signatures.signature).trim();\n if (!sig.startsWith('event ')) {\n sig = 'event ' + sig;\n }\n const topic0 = typeof signatures !== 'string' && signatures.topic0 ? signatures.topic0 : evmMethodSignatureToHex(sig);\n if ((sig.match(/ indexed /g)?.length || 0) === log.topics.length - 1) {\n if (log.topics[0] === topic0) {\n try {\n const result = decodeEventLog({\n abi: parseAbi([sig]),\n data: log.data as `0x${string}`,\n topics: log.topics as [],\n });\n return result.args as unknown as Record<string, unknown>;\n } catch (e) {\n // ignore this\n }\n }\n }\n\n return null;\n}\n\nexport function evmDecodeLogWithMetadata(\n log: BasicLog,\n signatures: SignaturesToDecode | SignaturesToDecode[]\n): { decoded: Record<string, unknown>; metadata: { name: string } } {\n for (const sig of [signatures].flat()) {\n const decoded = evmDecodeLog(log, sig);\n if (decoded) {\n return {\n decoded,\n metadata: {\n name: (typeof sig === 'string' ? sig : sig.signature).split('(')[0],\n },\n };\n }\n }\n\n return null;\n}\n","import { keccak256 } from 'viem';\n\nexport function evmMethodSignatureToHex(sig: string): string {\n const [method, rest] = sig.split('(');\n const params = rest\n .split(')')[0]\n .split(',')\n .map((p) => p.trim());\n const topic0 = keccak256(\n `${method.split(' ').pop()}(${params.map((p) => p.split(' ')[0]).join(',')})` as `0x${string}`\n );\n return topic0;\n}\n","import { evmAddressToChecksum } from './evm-address-to-checksum';\n\nexport function normalizeEVMBlock(rawBlock: Record<string, unknown>): Record<string, unknown> {\n for (const k of ['baseFeePerGas', 'gasLimit', 'gasUsed', 'number', 'size', 'timestamp']) {\n if (typeof rawBlock[k] === 'string') {\n rawBlock[k] = parseInt(rawBlock[k] as string);\n }\n }\n\n for (const k of ['difficulty', 'totalDifficulty']) {\n if (typeof rawBlock[k] === 'string') {\n rawBlock[k] = BigInt(rawBlock[k] as string).toString();\n }\n }\n for (const k of ['miner']) {\n rawBlock[k] = evmAddressToChecksum(rawBlock[k] as string);\n }\n\n rawBlock.transactions = (\n rawBlock.transactions as { receipt: Record<string, unknown>; traces: Record<string, unknown>[] } & Record<\n string,\n unknown\n >[]\n ).map((tx) => {\n for (const k of [\n 'blockNumber',\n 'cumulativeGasUsed',\n 'effectiveGasPrice',\n 'gas',\n 'gasUsed',\n 'nonce',\n 'status',\n 'transactionIndex',\n ]) {\n if (typeof tx[k] === 'string') {\n tx[k] = parseInt(tx[k] as string);\n }\n if (typeof tx.receipt[k] === 'string') {\n tx.receipt[k] = parseInt(tx.receipt[k] as string);\n }\n }\n\n for (const k of ['gasPrice', 'maxFeePerGas', 'maxPriorityFeePerGas', 'value']) {\n if (typeof tx[k] === 'string') {\n tx[k] = BigInt(tx[k] as string).toString();\n }\n if (typeof tx.receipt[k] === 'string') {\n tx.receipt[k] = BigInt(tx.receipt[k] as string).toString();\n }\n }\n\n for (const k of ['from', 'to']) {\n if (typeof tx[k] === 'string') {\n tx[k] = evmAddressToChecksum(tx[k] as string);\n }\n }\n for (const k of ['contractAddress']) {\n if (typeof tx.receipt[k] === 'string') {\n tx.receipt[k] = evmAddressToChecksum(tx.receipt[k] as string);\n }\n }\n\n tx.type = parseInt(tx.type as string);\n tx.receipt['status'] = Boolean(tx.receipt['status'] as string);\n\n tx.receipt['logs'] = (tx.receipt['logs'] as Record<string, unknown>[])?.map((log) => {\n for (const k of ['blockNumber', 'logIndex', 'transactionIndex']) {\n if (typeof log[k] === 'string') {\n log[k] = parseInt(log[k] as string);\n }\n }\n log['address'] = evmAddressToChecksum(log['address'] as string);\n return log;\n });\n\n return tx;\n });\n\n return rawBlock;\n}\n","export type Template = {\n key: string;\n name: string;\n description: string;\n disabled: boolean;\n tags: string[];\n params: Param[];\n transform: (\n payload: Record<string, unknown>,\n _ctx?: Record<string, unknown> & { params: Record<string, unknown> }\n ) => unknown;\n tests: TemplateTest[];\n};\n\nexport type Param = {\n key: string;\n name: string;\n type: 'NETWORK' | 'ADDRESS' | 'STRING';\n multiple?: boolean;\n optional?: boolean;\n};\n\nexport type TemplateTest = {\n params: Record<string, unknown>;\n payload: `https://${string}` | Record<string, unknown>;\n output: Record<string, unknown>[];\n};\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEEA,MAAM,kCAAsB;IAC1B,KAAK;IACL,MAAM;IACN,aAAa;IACb,MAAM;QAAC;QAAO;KAAe;IAC7B,UAAU;IACV,QAAQ,EAAE;IACV,UAAU;QACR,OAAO,CAAC;;;KAGP,CAAC;IACJ;AACF;IAEA,2CAAe;;;ACff,MAAM,uCAA2B;IAC/B,KAAK;IACL,MAAM;IACN,aAAa;IACb,MAAM;QAAC;QAAO;QAAQ;QAAS;KAAS;IACxC,UAAU;IACV,QAAQ,EAAE;IACV,UAAU;QACR,OAAO,CAAC;;;KAGP,CAAC;IACJ;AACF;IAEA,2CAAe;;;AFdR,MAAM,4CAAY;IAAC,CAAA,GAAA,wCAAQ;IAAG,CAAA,GAAA,wCAAa;CAAE;;;;;;;;;;;;;;;;AMD7C,SAAS,0CAAwB,GAAW;IACjD,MAAM,CAAC,QAAQ,KAAK,GAAG,IAAI,KAAK,CAAC;IACjC,MAAM,SAAS,KACZ,KAAK,CAAC,IAAI,CAAC,EAAE,CACb,KAAK,CAAC,KACN,GAAG,CAAC,CAAC,IAAM,EAAE,IAAI;IACpB,MAAM,SAAS,CAAA,GAAA,qBAAQ,EACrB,CAAC,EAAE,OAAO,KAAK,CAAC,KAAK,GAAG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Q,MAAM,OAAO,CAAC,KAAK;wBAC3B,aAAa,GAAG,WAAW;wBAC3B,MAAM,CAAA,GAAA,yCAAmB,EAAE,MAAM,OAAO,CAAC,IAAI,KAAe;wBAC5D,OAAO,IAAI,QAAQ;mCACnB;wBACA,IAAI,CAAA,GAAA,yCAAmB,EAAE,MAAM,OAAO,CAAC,EAAE,KAAe;wBACxD,OAAO,CAAA,GAAA,yCAAmB,EAAE,IAAI,OAAO;2CACvC;wBACA,iBAAiB,GAAG,IAAI;oBAC1B;gBAEJ;gBAEA,IAAI,MAAM,OAAO,CAAC,GAAG,MAAM,GACzB,KAAK,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAM,EAAE,MAAM,EAAG;oBACrD,MAAM,SAAS,MAAM,MAAM;oBAC3B,IAAI,CAAC,QAAQ,OAAO;oBAEpB,UAAU,IAAI,CAAC;wBACb,QAAQ,OAAO,OAAO,KAAK;wBAC3B,aAAa,GAAG,WAAW;wBAC3B,MAAM,CAAA,GAAA,yCAAmB,EAAE,OAAO,IAAI,KAAK;wBAC3C,OAAO,MAAM,YAAY,EAAE,KAAK;mCAChC;wBACA,IAAI,CAAA,GAAA,yCAAmB,EAAE,OAAO,EAAE,KAAK;2CACvC;wBACA,iBAAiB,GAAG,IAAI;oBAC1B;gBACF;YAEJ;IAEJ;IAEA,OAAO,UAAU,MAAM,CAAC,CAAC,QAAU,MAAM,MAAM,GAAG,OAAO;AAC3D;;;;;;;;;;;;ATlFO,SAAS;IACZ,OAAO,GAAA;AACT;AAEK,SAAS,0CAAiB,GAAW;IACxC,OAAO,CAAA,GAAA,yCAAQ,EAAE,IAAI,CAAC,CAAC,WAAa,SAAS,GAAG,KAAK;AACvD","sources":["src/index.ts","src/templates/index.ts","src/templates/all-blocks.ts","src/templates/token-transfers.ts","src/presets/index.ts","src/presets/erc20-transfers.ts","src/utils/evm-decode-log.ts","src/utils/evm-method-signature-to-hex.ts","src/presets/token-price.ts","src/presets/token-transfers.ts","src/utils/index.ts","src/utils/evm-address-to-checksum.ts","src/utils/evm-chain-to-id.ts","src/utils/evm-normalize-raw-block.ts","src/types.ts"],"sourcesContent":["import { templates } from './templates';\nimport * as presets from './presets';\nimport * as utils from './utils';\nimport * as types from './types';\n\nexport { presets, utils, types };\n\nexport function getAllTemplates() {\n return templates;\n }\n\nexport function getTemplateByKey(key: string) {\n return templates.find((template) => template.key === key);\n }","import allBlocks from './all-blocks';\nimport tokenTransfers from './token-transfers';\n\nexport const templates = [allBlocks, tokenTransfers];","import { Template, Param } from \"../types\";\n\nconst allBlocks: Template = {\n key: \"allBlocks\",\n name: \"All Blocks\",\n description: \"Get all blocks with all available fields\",\n tags: [\"EVM\", \"TRANSACTIONS\"],\n disabled: false,\n params: [],\n function: () => {\n return `\n function allBlocks(block, _ctx) {\n return block;\n }`;\n },\n};\n\nexport default allBlocks;","import { Template, Param } from \"../types\";\n\nconst tokenTransfers: Template = {\n key: \"tokenTransfers\",\n name: \"Token Transfers\",\n description: \"Get all blocks for a set of token types.\",\n tags: [\"EVM\", \"NFTs\", \"ERC20\", \"ERC721\"],\n disabled: false,\n params: [],\n function: () => {\n return `\n function tokenTransfers(block, _ctx) {\n return block;\n }`;\n },\n};\n\nexport default tokenTransfers;","export * from './erc20-transfers';\nexport * from './token-price';\nexport * from './token-transfers';\n","import { evmDecodeLog } from '../utils/evm-decode-log';\n\nexport function erc20Transfers(block) {\n const txfers = [];\n\n for (const tx of block.transactions) {\n if (!tx.receipt) continue;\n\n for (const log of tx.receipt.logs) {\n const txfer = evmDecodeLog(log, 'Transfer(address indexed from, address indexed to, uint256 value)');\n if (txfer) {\n txfers.push({\n blockNumber: block.number,\n timestamp: new Date(block.timestamp * 1000).toISOString(),\n transactionHash: tx.hash,\n ...txfer,\n });\n }\n }\n }\n\n return txfers;\n}\n","import { decodeEventLog, parseAbi } from 'viem';\n\nimport { evmMethodSignatureToHex } from './evm-method-signature-to-hex';\n\ntype BasicLog = Record<string, unknown> & { address: string; topics: string[] };\ntype SignaturesToDecode = string | { addresses?: string[]; signature: string; topic0?: string };\n\nexport function evmDecodeLog(\n log: BasicLog,\n signatures: SignaturesToDecode | SignaturesToDecode[]\n): Record<string, unknown> {\n if (Array.isArray(signatures)) {\n for (const sig of signatures) {\n const decoded = evmDecodeLog(log, sig);\n if (decoded) {\n return decoded;\n }\n }\n\n return null;\n }\n\n if (typeof signatures !== 'string' && Array.isArray(signatures.addresses) && signatures.addresses.length) {\n const addresses = signatures.addresses.map((a) => a?.toLowerCase());\n if (!addresses.includes(log.address.toLowerCase())) {\n return null;\n }\n }\n\n let sig = (typeof signatures === 'string' ? signatures : signatures.signature).trim();\n if (!sig.startsWith('event ')) {\n sig = 'event ' + sig;\n }\n const topic0 = typeof signatures !== 'string' && signatures.topic0 ? signatures.topic0 : evmMethodSignatureToHex(sig);\n if ((sig.match(/ indexed /g)?.length || 0) === log.topics.length - 1) {\n if (log.topics[0] === topic0) {\n try {\n const result = decodeEventLog({\n abi: parseAbi([sig]),\n data: log.data as `0x${string}`,\n topics: log.topics as [],\n });\n return result.args as unknown as Record<string, unknown>;\n } catch (e) {\n // ignore this\n }\n }\n }\n\n return null;\n}\n\nexport function evmDecodeLogWithMetadata(\n log: BasicLog,\n signatures: SignaturesToDecode | SignaturesToDecode[]\n): { decoded: Record<string, unknown>; metadata: { name: string } } {\n for (const sig of [signatures].flat()) {\n const decoded = evmDecodeLog(log, sig);\n if (decoded) {\n return {\n decoded,\n metadata: {\n name: (typeof sig === 'string' ? sig : sig.signature).split('(')[0],\n },\n };\n }\n }\n\n return null;\n}\n","import { keccak256 } from 'viem';\n\nexport function evmMethodSignatureToHex(sig: string): string {\n const [method, rest] = sig.split('(');\n const params = rest\n .split(')')[0]\n .split(',')\n .map((p) => p.trim());\n const topic0 = keccak256(\n `${method.split(' ').pop()}(${params.map((p) => p.split(' ')[0]).join(',')})` as `0x${string}`\n );\n return topic0;\n}\n","import _fetch from 'isomorphic-fetch';\n\nexport function tokenPrice(tokenAddress: string, opts?: { network?: string; timestamp?: string }) {\n let url = `https://jiti.indexing.co/presets/token-price/${opts?.network || 'ethereum'}?tokenAddress=${tokenAddress}`;\n if (opts?.timestamp) {\n url += '&priceTimestamp=' + new Date(opts.timestamp).toISOString();\n }\n\n return _fetch(url)\n .then((r) => r.json())\n .then((r) => r.data);\n}\n","import { evmAddressToChecksum, evmDecodeLogWithMetadata } from '../utils';\n\ntype NetworkTransfer = {\n amount: bigint;\n blockNumber: number;\n from: string;\n index?: string;\n timestamp: string;\n to: string;\n token?: string;\n tokenId?: string;\n // @TODO: tokenType: 'CURRENCY' | 'NFT';\n transactionGasFee: bigint;\n transactionHash: string;\n};\n\nconst NULL_ADDRESS = '0x0000000000000000000000000000000000000000';\n\nexport function tokenTransfers(block) {\n const transfers: NetworkTransfer[] = [];\n\n switch (block._network) {\n // @TODO: port non-EVM handlers over\n\n // assume EVM as default for now\n default: {\n for (const tx of block.transactions) {\n if (!tx.receipt) {\n continue;\n }\n\n const timestamp = new Date((block.timestamp as number) * 1000).toISOString();\n const transactionGasFee = BigInt(tx.receipt.gasUsed) * BigInt(tx.receipt.effectiveGasPrice);\n\n // track direct ETH transfers\n if ((tx.value as string)?.length >= 3 || /\\d+/.test(tx.value as string)) {\n transfers.push({\n amount: BigInt(tx.value as string),\n blockNumber: tx.blockNumber as number,\n from: evmAddressToChecksum(tx.from) || NULL_ADDRESS,\n timestamp,\n to: evmAddressToChecksum(tx.to) || NULL_ADDRESS,\n transactionGasFee,\n transactionHash: tx.hash,\n });\n }\n\n // track ERC20 transfers\n for (const log of tx.receipt.logs) {\n const txfer = evmDecodeLogWithMetadata(log, [\n 'Transfer(address indexed from, address indexed to, uint256 value)',\n ]);\n if (txfer) {\n transfers.push({\n amount: txfer.decoded.value as bigint,\n blockNumber: tx.blockNumber as number,\n from: evmAddressToChecksum(txfer.decoded.from as string) || NULL_ADDRESS,\n index: log.logIndex,\n timestamp,\n to: evmAddressToChecksum(txfer.decoded.to as string) || NULL_ADDRESS,\n token: evmAddressToChecksum(log.address as string),\n transactionGasFee,\n transactionHash: tx.hash,\n });\n }\n }\n\n if (Array.isArray(tx.traces)) {\n for (const trace of tx.traces.filter((t) => t.action)) {\n const action = trace.action as unknown as { from: string; to: string; value: string };\n if (!action?.value) continue;\n\n transfers.push({\n amount: BigInt(action.value),\n blockNumber: tx.blockNumber as number,\n from: evmAddressToChecksum(action.from) || NULL_ADDRESS,\n index: trace.traceAddress?.join('-'),\n timestamp,\n to: evmAddressToChecksum(action.to) || NULL_ADDRESS,\n transactionGasFee,\n transactionHash: tx.hash,\n });\n }\n }\n }\n }\n }\n\n return transfers.filter((txfer) => txfer.amount > BigInt(0));\n}\n","export * from './evm-address-to-checksum';\nexport * from './evm-chain-to-id';\nexport * from './evm-decode-log';\nexport * from './evm-method-signature-to-hex';\nexport * from './evm-normalize-raw-block';\n","import { keccak256 } from 'viem';\n\nexport function evmAddressToChecksum(address: string) {\n if (!address || !/^(0x)?[0-9a-f]{40}$/i.test(address)) {\n return null;\n }\n\n const stripAddress = address.slice(2).toLowerCase();\n const keccakHash = keccak256(stripAddress as `0x${string}`);\n let checksumAddress = '0x';\n\n for (let i = 0; i < stripAddress.length; i++) {\n checksumAddress += parseInt(keccakHash[i], 16) >= 8 ? stripAddress[i].toUpperCase() : stripAddress[i];\n }\n\n return checksumAddress;\n}\n","const CHAIN_ID = {\n ARBITRUM: 42161,\n AVALANCHE: 43114,\n BASE: 8453,\n BASE_SEPOLIA: 84532,\n BERACHAIN_BARTIO: 80084,\n BLAST: 81457,\n BSC: 56,\n CELO: 42220,\n CYBER: 7560,\n DEGEN: 666666666,\n ETHEREUM: 1,\n ETH_HOLESKY: 17000,\n ETH_SEPOLIA: 11155111,\n FRAXTAL: 252,\n FRAXTAL_SEPOLIA: 2522,\n FUSE: 122,\n GNOSIS: 100,\n GOLD: 4653,\n HAM: 5112,\n HEMI_TESTNET: 743111,\n LINEA: 59144,\n LINEA_SEPOLIA: 59141,\n LISK_SEPOLIA: 4202,\n LYRA: 957,\n LYRA_SEPOLIA: 901,\n MODE: 34443,\n MODE_SEPOLIA: 919,\n NEON: 245022934,\n OASIS_SAPPHIRE: 23294,\n OPTIMISM: 10,\n OP_SEPOLIA: 11155420,\n ORDERLY: 291,\n ORDERLY_SEPOLIA: 4460,\n PGN_SEPOLIA: 58008,\n POLYGON: 137,\n POLYGON_AMOY: 80002,\n POLYGON_ZKEVM: 1101,\n PUBLIC_GOODS_NETWORK: 424,\n SCROLL: 534352,\n SCROLL_SEPOLIA: 534351,\n STACK: 78225,\n SYNDICATE_FRAME_CHAIN: 5101,\n TRON: 728126428,\n ZK_LINK: 810180,\n ZORA: 7777777,\n ZORA_SEPOLIA: 999999999,\n};\n\nexport function evmChainToId(chain: string) {\n return CHAIN_ID[chain?.toUpperCase()];\n}\n","import { evmAddressToChecksum } from './evm-address-to-checksum';\n\nexport function normalizeEVMBlock(rawBlock: Record<string, unknown>): Record<string, unknown> {\n for (const k of ['baseFeePerGas', 'gasLimit', 'gasUsed', 'number', 'size', 'timestamp']) {\n if (typeof rawBlock[k] === 'string') {\n rawBlock[k] = parseInt(rawBlock[k] as string);\n }\n }\n\n for (const k of ['difficulty', 'totalDifficulty']) {\n if (typeof rawBlock[k] === 'string') {\n rawBlock[k] = BigInt(rawBlock[k] as string).toString();\n }\n }\n for (const k of ['miner']) {\n rawBlock[k] = evmAddressToChecksum(rawBlock[k] as string);\n }\n\n rawBlock.transactions = (\n rawBlock.transactions as { receipt: Record<string, unknown>; traces: Record<string, unknown>[] } & Record<\n string,\n unknown\n >[]\n ).map((tx) => {\n for (const k of [\n 'blockNumber',\n 'cumulativeGasUsed',\n 'effectiveGasPrice',\n 'gas',\n 'gasUsed',\n 'nonce',\n 'status',\n 'transactionIndex',\n ]) {\n if (typeof tx[k] === 'string') {\n tx[k] = parseInt(tx[k] as string);\n }\n if (typeof tx.receipt[k] === 'string') {\n tx.receipt[k] = parseInt(tx.receipt[k] as string);\n }\n }\n\n for (const k of ['gasPrice', 'maxFeePerGas', 'maxPriorityFeePerGas', 'value']) {\n if (typeof tx[k] === 'string') {\n tx[k] = BigInt(tx[k] as string).toString();\n }\n if (typeof tx.receipt[k] === 'string') {\n tx.receipt[k] = BigInt(tx.receipt[k] as string).toString();\n }\n }\n\n for (const k of ['from', 'to']) {\n if (typeof tx[k] === 'string') {\n tx[k] = evmAddressToChecksum(tx[k] as string);\n }\n }\n for (const k of ['contractAddress']) {\n if (typeof tx.receipt[k] === 'string') {\n tx.receipt[k] = evmAddressToChecksum(tx.receipt[k] as string);\n }\n }\n\n tx.type = parseInt(tx.type as string);\n tx.receipt['status'] = Boolean(tx.receipt['status'] as string);\n\n tx.receipt['logs'] = (tx.receipt['logs'] as Record<string, unknown>[])?.map((log) => {\n for (const k of ['blockNumber', 'logIndex', 'transactionIndex']) {\n if (typeof log[k] === 'string') {\n log[k] = parseInt(log[k] as string);\n }\n }\n log['address'] = evmAddressToChecksum(log['address'] as string);\n return log;\n });\n\n return tx;\n });\n\n return rawBlock;\n}\n","export type Template = {\n key: string;\n name: string;\n description: string;\n disabled: boolean;\n tags: string[];\n params: Param[];\n function: (params: Record<string, unknown>) => string;\n};\n\nexport type Param = {\n key: string;\n name: string;\n type: \"NETWORK\" | \"ADDRESS\";\n multiple?: boolean;\n optional?: boolean;\n};"],"names":[],"version":3,"file":"main.js.map"}