@indexing/jiti 1.0.0
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.md +18 -0
- package/README.md +11 -0
- package/dist/main.js +405 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +396 -0
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +34 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
GPL-3.0-or-later License
|
|
2
|
+
|
|
3
|
+
JITI - Just In Time Indexing, for all.
|
|
4
|
+
|
|
5
|
+
Copyright (C) 2024 The Indexing Company
|
|
6
|
+
|
|
7
|
+
This program is free software: you can redistribute it and/or modify
|
|
8
|
+
it under the terms of the GNU General Public License as published by
|
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
(at your option) any later version.
|
|
11
|
+
|
|
12
|
+
This program is distributed in the hope that it will be useful,
|
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
GNU General Public License for more details.
|
|
16
|
+
|
|
17
|
+
You should have received a copy of the GNU General Public License
|
|
18
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Just In Time Indexing (JITI)
|
|
2
|
+
|
|
3
|
+
Open source template library for the JITI community.
|
|
4
|
+
|
|
5
|
+
# Contributing
|
|
6
|
+
|
|
7
|
+
This package will be ready for external contributors in early 2025.
|
|
8
|
+
|
|
9
|
+
## License
|
|
10
|
+
|
|
11
|
+
See the [LICENSE](LICENSE.md) file for license rights and limitations (GPL-3.0-or-later).
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
var $8zHUo$viem = require("viem");
|
|
2
|
+
var $8zHUo$isomorphicfetch = require("isomorphic-fetch");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function $parcel$exportWildcard(dest, source) {
|
|
10
|
+
Object.keys(source).forEach(function(key) {
|
|
11
|
+
if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(dest, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function get() {
|
|
18
|
+
return source[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return dest;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function $parcel$interopDefault(a) {
|
|
27
|
+
return a && a.__esModule ? a.default : a;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
$parcel$export(module.exports, "getAllTemplates", () => $882b6d93070905b3$export$cceb5167b935aafb);
|
|
31
|
+
$parcel$export(module.exports, "getTemplateByKey", () => $882b6d93070905b3$export$a07bfd14bbc36e4b);
|
|
32
|
+
$parcel$export(module.exports, "presets", () => $14cf6f53e99b3d5b$exports);
|
|
33
|
+
$parcel$export(module.exports, "utils", () => $d7167569386d0d4c$exports);
|
|
34
|
+
$parcel$export(module.exports, "types", () => $faefaad95e5fcca0$exports);
|
|
35
|
+
const $49a91814dabec06a$var$allBlocks = {
|
|
36
|
+
key: "allBlocks",
|
|
37
|
+
name: "All Blocks",
|
|
38
|
+
description: "Get all blocks with all available fields",
|
|
39
|
+
tags: [
|
|
40
|
+
"EVM",
|
|
41
|
+
"TRANSACTIONS"
|
|
42
|
+
],
|
|
43
|
+
disabled: false,
|
|
44
|
+
params: [],
|
|
45
|
+
function: ()=>{
|
|
46
|
+
return `
|
|
47
|
+
function allBlocks(block, _ctx) {
|
|
48
|
+
return block;
|
|
49
|
+
}`;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
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 = {};
|
|
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
|
+
}
|
|
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);
|
|
183
|
+
var $d7167569386d0d4c$exports = {};
|
|
184
|
+
var $596a656635c74d50$exports = {};
|
|
185
|
+
|
|
186
|
+
$parcel$export($596a656635c74d50$exports, "evmAddressToChecksum", () => $596a656635c74d50$export$db81f9ea057ab646);
|
|
187
|
+
|
|
188
|
+
function $596a656635c74d50$export$db81f9ea057ab646(address) {
|
|
189
|
+
if (!address || !/^(0x)?[0-9a-f]{40}$/i.test(address)) return null;
|
|
190
|
+
const stripAddress = address.slice(2).toLowerCase();
|
|
191
|
+
const keccakHash = (0, $8zHUo$viem.keccak256)(stripAddress);
|
|
192
|
+
let checksumAddress = "0x";
|
|
193
|
+
for(let i = 0; i < stripAddress.length; i++)checksumAddress += parseInt(keccakHash[i], 16) >= 8 ? stripAddress[i].toUpperCase() : stripAddress[i];
|
|
194
|
+
return checksumAddress;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
var $e5566e47593dc3e2$exports = {};
|
|
199
|
+
|
|
200
|
+
$parcel$export($e5566e47593dc3e2$exports, "evmChainToId", () => $e5566e47593dc3e2$export$f93b8abed77a4120);
|
|
201
|
+
const $e5566e47593dc3e2$var$CHAIN_ID = {
|
|
202
|
+
ARBITRUM: 42161,
|
|
203
|
+
AVALANCHE: 43114,
|
|
204
|
+
BASE: 8453,
|
|
205
|
+
BASE_SEPOLIA: 84532,
|
|
206
|
+
BERACHAIN_BARTIO: 80084,
|
|
207
|
+
BLAST: 81457,
|
|
208
|
+
BSC: 56,
|
|
209
|
+
CELO: 42220,
|
|
210
|
+
CYBER: 7560,
|
|
211
|
+
DEGEN: 666666666,
|
|
212
|
+
ETHEREUM: 1,
|
|
213
|
+
ETH_HOLESKY: 17000,
|
|
214
|
+
ETH_SEPOLIA: 11155111,
|
|
215
|
+
FRAXTAL: 252,
|
|
216
|
+
FRAXTAL_SEPOLIA: 2522,
|
|
217
|
+
FUSE: 122,
|
|
218
|
+
GNOSIS: 100,
|
|
219
|
+
GOLD: 4653,
|
|
220
|
+
HAM: 5112,
|
|
221
|
+
HEMI_TESTNET: 743111,
|
|
222
|
+
LINEA: 59144,
|
|
223
|
+
LINEA_SEPOLIA: 59141,
|
|
224
|
+
LISK_SEPOLIA: 4202,
|
|
225
|
+
LYRA: 957,
|
|
226
|
+
LYRA_SEPOLIA: 901,
|
|
227
|
+
MODE: 34443,
|
|
228
|
+
MODE_SEPOLIA: 919,
|
|
229
|
+
NEON: 245022934,
|
|
230
|
+
OASIS_SAPPHIRE: 23294,
|
|
231
|
+
OPTIMISM: 10,
|
|
232
|
+
OP_SEPOLIA: 11155420,
|
|
233
|
+
ORDERLY: 291,
|
|
234
|
+
ORDERLY_SEPOLIA: 4460,
|
|
235
|
+
PGN_SEPOLIA: 58008,
|
|
236
|
+
POLYGON: 137,
|
|
237
|
+
POLYGON_AMOY: 80002,
|
|
238
|
+
POLYGON_ZKEVM: 1101,
|
|
239
|
+
PUBLIC_GOODS_NETWORK: 424,
|
|
240
|
+
SCROLL: 534352,
|
|
241
|
+
SCROLL_SEPOLIA: 534351,
|
|
242
|
+
STACK: 78225,
|
|
243
|
+
SYNDICATE_FRAME_CHAIN: 5101,
|
|
244
|
+
TRON: 728126428,
|
|
245
|
+
ZK_LINK: 810180,
|
|
246
|
+
ZORA: 7777777,
|
|
247
|
+
ZORA_SEPOLIA: 999999999
|
|
248
|
+
};
|
|
249
|
+
function $e5566e47593dc3e2$export$f93b8abed77a4120(chain) {
|
|
250
|
+
return $e5566e47593dc3e2$var$CHAIN_ID[chain?.toUpperCase()];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
var $414c83047563e72e$exports = {};
|
|
257
|
+
|
|
258
|
+
$parcel$export($414c83047563e72e$exports, "normalizeEVMBlock", () => $414c83047563e72e$export$685b7dc2197cd06c);
|
|
259
|
+
|
|
260
|
+
function $414c83047563e72e$export$685b7dc2197cd06c(rawBlock) {
|
|
261
|
+
for (const k of [
|
|
262
|
+
"baseFeePerGas",
|
|
263
|
+
"gasLimit",
|
|
264
|
+
"gasUsed",
|
|
265
|
+
"number",
|
|
266
|
+
"size",
|
|
267
|
+
"timestamp"
|
|
268
|
+
])if (typeof rawBlock[k] === "string") rawBlock[k] = parseInt(rawBlock[k]);
|
|
269
|
+
for (const k of [
|
|
270
|
+
"difficulty",
|
|
271
|
+
"totalDifficulty"
|
|
272
|
+
])if (typeof rawBlock[k] === "string") rawBlock[k] = BigInt(rawBlock[k]).toString();
|
|
273
|
+
for (const k of [
|
|
274
|
+
"miner"
|
|
275
|
+
])rawBlock[k] = (0, $596a656635c74d50$export$db81f9ea057ab646)(rawBlock[k]);
|
|
276
|
+
rawBlock.transactions = rawBlock.transactions.map((tx)=>{
|
|
277
|
+
for (const k of [
|
|
278
|
+
"blockNumber",
|
|
279
|
+
"cumulativeGasUsed",
|
|
280
|
+
"effectiveGasPrice",
|
|
281
|
+
"gas",
|
|
282
|
+
"gasUsed",
|
|
283
|
+
"nonce",
|
|
284
|
+
"status",
|
|
285
|
+
"transactionIndex"
|
|
286
|
+
]){
|
|
287
|
+
if (typeof tx[k] === "string") tx[k] = parseInt(tx[k]);
|
|
288
|
+
if (typeof tx.receipt[k] === "string") tx.receipt[k] = parseInt(tx.receipt[k]);
|
|
289
|
+
}
|
|
290
|
+
for (const k of [
|
|
291
|
+
"gasPrice",
|
|
292
|
+
"maxFeePerGas",
|
|
293
|
+
"maxPriorityFeePerGas",
|
|
294
|
+
"value"
|
|
295
|
+
]){
|
|
296
|
+
if (typeof tx[k] === "string") tx[k] = BigInt(tx[k]).toString();
|
|
297
|
+
if (typeof tx.receipt[k] === "string") tx.receipt[k] = BigInt(tx.receipt[k]).toString();
|
|
298
|
+
}
|
|
299
|
+
for (const k of [
|
|
300
|
+
"from",
|
|
301
|
+
"to"
|
|
302
|
+
])if (typeof tx[k] === "string") tx[k] = (0, $596a656635c74d50$export$db81f9ea057ab646)(tx[k]);
|
|
303
|
+
for (const k of [
|
|
304
|
+
"contractAddress"
|
|
305
|
+
])if (typeof tx.receipt[k] === "string") tx.receipt[k] = (0, $596a656635c74d50$export$db81f9ea057ab646)(tx.receipt[k]);
|
|
306
|
+
tx.type = parseInt(tx.type);
|
|
307
|
+
tx.receipt["status"] = Boolean(tx.receipt["status"]);
|
|
308
|
+
tx.receipt["logs"] = tx.receipt["logs"]?.map((log)=>{
|
|
309
|
+
for (const k of [
|
|
310
|
+
"blockNumber",
|
|
311
|
+
"logIndex",
|
|
312
|
+
"transactionIndex"
|
|
313
|
+
])if (typeof log[k] === "string") log[k] = parseInt(log[k]);
|
|
314
|
+
log["address"] = (0, $596a656635c74d50$export$db81f9ea057ab646)(log["address"]);
|
|
315
|
+
return log;
|
|
316
|
+
});
|
|
317
|
+
return tx;
|
|
318
|
+
});
|
|
319
|
+
return rawBlock;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
$parcel$exportWildcard($d7167569386d0d4c$exports, $596a656635c74d50$exports);
|
|
324
|
+
$parcel$exportWildcard($d7167569386d0d4c$exports, $e5566e47593dc3e2$exports);
|
|
325
|
+
$parcel$exportWildcard($d7167569386d0d4c$exports, $da55be3e40667945$exports);
|
|
326
|
+
$parcel$exportWildcard($d7167569386d0d4c$exports, $f7a3fb164436c9c3$exports);
|
|
327
|
+
$parcel$exportWildcard($d7167569386d0d4c$exports, $414c83047563e72e$exports);
|
|
328
|
+
|
|
329
|
+
|
|
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
|
+
});
|
|
367
|
+
}
|
|
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
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return transfers.filter((txfer)=>txfer.amount > BigInt(0));
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
$parcel$exportWildcard($14cf6f53e99b3d5b$exports, $9c8abe84804d9e5d$exports);
|
|
389
|
+
$parcel$exportWildcard($14cf6f53e99b3d5b$exports, $2bc08226e0d6a193$exports);
|
|
390
|
+
$parcel$exportWildcard($14cf6f53e99b3d5b$exports, $32af5abe02e3405e$exports);
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
var $faefaad95e5fcca0$exports = {};
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
function $882b6d93070905b3$export$cceb5167b935aafb() {
|
|
398
|
+
return 0, $48f9879a44dd1195$export$a8fc3402335b0b04;
|
|
399
|
+
}
|
|
400
|
+
function $882b6d93070905b3$export$a07bfd14bbc36e4b(key) {
|
|
401
|
+
return (0, $48f9879a44dd1195$export$a8fc3402335b0b04).find((template)=>template.key === key);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,IAAM,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAE/E,OA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D,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"}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import {decodeEventLog as $hgUW1$decodeEventLog, parseAbi as $hgUW1$parseAbi, keccak256 as $hgUW1$keccak256} from "viem";
|
|
2
|
+
import $hgUW1$isomorphicfetch from "isomorphic-fetch";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$exportWildcard(dest, source) {
|
|
6
|
+
Object.keys(source).forEach(function(key) {
|
|
7
|
+
if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Object.defineProperty(dest, key, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function get() {
|
|
14
|
+
return source[key];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return dest;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function $parcel$export(e, n, v, s) {
|
|
23
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
24
|
+
}
|
|
25
|
+
const $8369cdd4433d3a57$var$allBlocks = {
|
|
26
|
+
key: "allBlocks",
|
|
27
|
+
name: "All Blocks",
|
|
28
|
+
description: "Get all blocks with all available fields",
|
|
29
|
+
tags: [
|
|
30
|
+
"EVM",
|
|
31
|
+
"TRANSACTIONS"
|
|
32
|
+
],
|
|
33
|
+
disabled: false,
|
|
34
|
+
params: [],
|
|
35
|
+
function: ()=>{
|
|
36
|
+
return `
|
|
37
|
+
function allBlocks(block, _ctx) {
|
|
38
|
+
return block;
|
|
39
|
+
}`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var $8369cdd4433d3a57$export$2e2bcd8739ae039 = $8369cdd4433d3a57$var$allBlocks;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const $c18434deda90759d$var$tokenTransfers = {
|
|
46
|
+
key: "tokenTransfers",
|
|
47
|
+
name: "Token Transfers",
|
|
48
|
+
description: "Get all blocks for a set of token types.",
|
|
49
|
+
tags: [
|
|
50
|
+
"EVM",
|
|
51
|
+
"NFTs",
|
|
52
|
+
"ERC20",
|
|
53
|
+
"ERC721"
|
|
54
|
+
],
|
|
55
|
+
disabled: false,
|
|
56
|
+
params: [],
|
|
57
|
+
function: ()=>{
|
|
58
|
+
return `
|
|
59
|
+
function tokenTransfers(block, _ctx) {
|
|
60
|
+
return block;
|
|
61
|
+
}`;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var $c18434deda90759d$export$2e2bcd8739ae039 = $c18434deda90759d$var$tokenTransfers;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
const $70cb039dbeb3c65a$export$a8fc3402335b0b04 = [
|
|
68
|
+
(0, $8369cdd4433d3a57$export$2e2bcd8739ae039),
|
|
69
|
+
(0, $c18434deda90759d$export$2e2bcd8739ae039)
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
var $aedb69bdc766818f$exports = {};
|
|
74
|
+
var $2b06dfb983c1c46f$exports = {};
|
|
75
|
+
|
|
76
|
+
$parcel$export($2b06dfb983c1c46f$exports, "erc20Transfers", () => $2b06dfb983c1c46f$export$b830a1966711a4f4);
|
|
77
|
+
var $cfa23334cbdf9391$exports = {};
|
|
78
|
+
|
|
79
|
+
$parcel$export($cfa23334cbdf9391$exports, "evmDecodeLog", () => $cfa23334cbdf9391$export$18467e329ea485c9);
|
|
80
|
+
$parcel$export($cfa23334cbdf9391$exports, "evmDecodeLogWithMetadata", () => $cfa23334cbdf9391$export$cf548b70626e2eb9);
|
|
81
|
+
|
|
82
|
+
var $f6a81337d3532e59$exports = {};
|
|
83
|
+
|
|
84
|
+
$parcel$export($f6a81337d3532e59$exports, "evmMethodSignatureToHex", () => $f6a81337d3532e59$export$49d5c9473f8f70f2);
|
|
85
|
+
|
|
86
|
+
function $f6a81337d3532e59$export$49d5c9473f8f70f2(sig) {
|
|
87
|
+
const [method, rest] = sig.split("(");
|
|
88
|
+
const params = rest.split(")")[0].split(",").map((p)=>p.trim());
|
|
89
|
+
const topic0 = (0, $hgUW1$keccak256)(`${method.split(" ").pop()}(${params.map((p)=>p.split(" ")[0]).join(",")})`);
|
|
90
|
+
return topic0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
function $cfa23334cbdf9391$export$18467e329ea485c9(log, signatures) {
|
|
95
|
+
if (Array.isArray(signatures)) {
|
|
96
|
+
for (const sig of signatures){
|
|
97
|
+
const decoded = $cfa23334cbdf9391$export$18467e329ea485c9(log, sig);
|
|
98
|
+
if (decoded) return decoded;
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
if (typeof signatures !== "string" && Array.isArray(signatures.addresses) && signatures.addresses.length) {
|
|
103
|
+
const addresses = signatures.addresses.map((a)=>a?.toLowerCase());
|
|
104
|
+
if (!addresses.includes(log.address.toLowerCase())) return null;
|
|
105
|
+
}
|
|
106
|
+
let sig = (typeof signatures === "string" ? signatures : signatures.signature).trim();
|
|
107
|
+
if (!sig.startsWith("event ")) sig = "event " + sig;
|
|
108
|
+
const topic0 = typeof signatures !== "string" && signatures.topic0 ? signatures.topic0 : (0, $f6a81337d3532e59$export$49d5c9473f8f70f2)(sig);
|
|
109
|
+
if ((sig.match(/ indexed /g)?.length || 0) === log.topics.length - 1) {
|
|
110
|
+
if (log.topics[0] === topic0) try {
|
|
111
|
+
const result = (0, $hgUW1$decodeEventLog)({
|
|
112
|
+
abi: (0, $hgUW1$parseAbi)([
|
|
113
|
+
sig
|
|
114
|
+
]),
|
|
115
|
+
data: log.data,
|
|
116
|
+
topics: log.topics
|
|
117
|
+
});
|
|
118
|
+
return result.args;
|
|
119
|
+
} catch (e) {
|
|
120
|
+
// ignore this
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
function $cfa23334cbdf9391$export$cf548b70626e2eb9(log, signatures) {
|
|
126
|
+
for (const sig of [
|
|
127
|
+
signatures
|
|
128
|
+
].flat()){
|
|
129
|
+
const decoded = $cfa23334cbdf9391$export$18467e329ea485c9(log, sig);
|
|
130
|
+
if (decoded) return {
|
|
131
|
+
decoded: decoded,
|
|
132
|
+
metadata: {
|
|
133
|
+
name: (typeof sig === "string" ? sig : sig.signature).split("(")[0]
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
function $2b06dfb983c1c46f$export$b830a1966711a4f4(block) {
|
|
142
|
+
const txfers = [];
|
|
143
|
+
for (const tx of block.transactions){
|
|
144
|
+
if (!tx.receipt) continue;
|
|
145
|
+
for (const log of tx.receipt.logs){
|
|
146
|
+
const txfer = (0, $cfa23334cbdf9391$export$18467e329ea485c9)(log, "Transfer(address indexed from, address indexed to, uint256 value)");
|
|
147
|
+
if (txfer) txfers.push({
|
|
148
|
+
blockNumber: block.number,
|
|
149
|
+
timestamp: new Date(block.timestamp * 1000).toISOString(),
|
|
150
|
+
transactionHash: tx.hash,
|
|
151
|
+
...txfer
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return txfers;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
var $8a3c50b8cb33d9fb$exports = {};
|
|
160
|
+
|
|
161
|
+
$parcel$export($8a3c50b8cb33d9fb$exports, "tokenPrice", () => $8a3c50b8cb33d9fb$export$e8386b633cdbc2d7);
|
|
162
|
+
|
|
163
|
+
function $8a3c50b8cb33d9fb$export$e8386b633cdbc2d7(tokenAddress, opts) {
|
|
164
|
+
let url = `https://jiti.indexing.co/presets/token-price/${opts?.network || "ethereum"}?tokenAddress=${tokenAddress}`;
|
|
165
|
+
if (opts?.timestamp) url += "&priceTimestamp=" + new Date(opts.timestamp).toISOString();
|
|
166
|
+
return (0, $hgUW1$isomorphicfetch)(url).then((r)=>r.json()).then((r)=>r.data);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
var $8dd8a21b1d9a9d2a$exports = {};
|
|
171
|
+
|
|
172
|
+
$parcel$export($8dd8a21b1d9a9d2a$exports, "tokenTransfers", () => $8dd8a21b1d9a9d2a$export$b62520a34e11070c);
|
|
173
|
+
var $fde9406d76ec24a9$exports = {};
|
|
174
|
+
var $42564d9f228fe302$exports = {};
|
|
175
|
+
|
|
176
|
+
$parcel$export($42564d9f228fe302$exports, "evmAddressToChecksum", () => $42564d9f228fe302$export$db81f9ea057ab646);
|
|
177
|
+
|
|
178
|
+
function $42564d9f228fe302$export$db81f9ea057ab646(address) {
|
|
179
|
+
if (!address || !/^(0x)?[0-9a-f]{40}$/i.test(address)) return null;
|
|
180
|
+
const stripAddress = address.slice(2).toLowerCase();
|
|
181
|
+
const keccakHash = (0, $hgUW1$keccak256)(stripAddress);
|
|
182
|
+
let checksumAddress = "0x";
|
|
183
|
+
for(let i = 0; i < stripAddress.length; i++)checksumAddress += parseInt(keccakHash[i], 16) >= 8 ? stripAddress[i].toUpperCase() : stripAddress[i];
|
|
184
|
+
return checksumAddress;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
var $68871103c7bc00cf$exports = {};
|
|
189
|
+
|
|
190
|
+
$parcel$export($68871103c7bc00cf$exports, "evmChainToId", () => $68871103c7bc00cf$export$f93b8abed77a4120);
|
|
191
|
+
const $68871103c7bc00cf$var$CHAIN_ID = {
|
|
192
|
+
ARBITRUM: 42161,
|
|
193
|
+
AVALANCHE: 43114,
|
|
194
|
+
BASE: 8453,
|
|
195
|
+
BASE_SEPOLIA: 84532,
|
|
196
|
+
BERACHAIN_BARTIO: 80084,
|
|
197
|
+
BLAST: 81457,
|
|
198
|
+
BSC: 56,
|
|
199
|
+
CELO: 42220,
|
|
200
|
+
CYBER: 7560,
|
|
201
|
+
DEGEN: 666666666,
|
|
202
|
+
ETHEREUM: 1,
|
|
203
|
+
ETH_HOLESKY: 17000,
|
|
204
|
+
ETH_SEPOLIA: 11155111,
|
|
205
|
+
FRAXTAL: 252,
|
|
206
|
+
FRAXTAL_SEPOLIA: 2522,
|
|
207
|
+
FUSE: 122,
|
|
208
|
+
GNOSIS: 100,
|
|
209
|
+
GOLD: 4653,
|
|
210
|
+
HAM: 5112,
|
|
211
|
+
HEMI_TESTNET: 743111,
|
|
212
|
+
LINEA: 59144,
|
|
213
|
+
LINEA_SEPOLIA: 59141,
|
|
214
|
+
LISK_SEPOLIA: 4202,
|
|
215
|
+
LYRA: 957,
|
|
216
|
+
LYRA_SEPOLIA: 901,
|
|
217
|
+
MODE: 34443,
|
|
218
|
+
MODE_SEPOLIA: 919,
|
|
219
|
+
NEON: 245022934,
|
|
220
|
+
OASIS_SAPPHIRE: 23294,
|
|
221
|
+
OPTIMISM: 10,
|
|
222
|
+
OP_SEPOLIA: 11155420,
|
|
223
|
+
ORDERLY: 291,
|
|
224
|
+
ORDERLY_SEPOLIA: 4460,
|
|
225
|
+
PGN_SEPOLIA: 58008,
|
|
226
|
+
POLYGON: 137,
|
|
227
|
+
POLYGON_AMOY: 80002,
|
|
228
|
+
POLYGON_ZKEVM: 1101,
|
|
229
|
+
PUBLIC_GOODS_NETWORK: 424,
|
|
230
|
+
SCROLL: 534352,
|
|
231
|
+
SCROLL_SEPOLIA: 534351,
|
|
232
|
+
STACK: 78225,
|
|
233
|
+
SYNDICATE_FRAME_CHAIN: 5101,
|
|
234
|
+
TRON: 728126428,
|
|
235
|
+
ZK_LINK: 810180,
|
|
236
|
+
ZORA: 7777777,
|
|
237
|
+
ZORA_SEPOLIA: 999999999
|
|
238
|
+
};
|
|
239
|
+
function $68871103c7bc00cf$export$f93b8abed77a4120(chain) {
|
|
240
|
+
return $68871103c7bc00cf$var$CHAIN_ID[chain?.toUpperCase()];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
var $8f1e0ae1ead9a2a9$exports = {};
|
|
247
|
+
|
|
248
|
+
$parcel$export($8f1e0ae1ead9a2a9$exports, "normalizeEVMBlock", () => $8f1e0ae1ead9a2a9$export$685b7dc2197cd06c);
|
|
249
|
+
|
|
250
|
+
function $8f1e0ae1ead9a2a9$export$685b7dc2197cd06c(rawBlock) {
|
|
251
|
+
for (const k of [
|
|
252
|
+
"baseFeePerGas",
|
|
253
|
+
"gasLimit",
|
|
254
|
+
"gasUsed",
|
|
255
|
+
"number",
|
|
256
|
+
"size",
|
|
257
|
+
"timestamp"
|
|
258
|
+
])if (typeof rawBlock[k] === "string") rawBlock[k] = parseInt(rawBlock[k]);
|
|
259
|
+
for (const k of [
|
|
260
|
+
"difficulty",
|
|
261
|
+
"totalDifficulty"
|
|
262
|
+
])if (typeof rawBlock[k] === "string") rawBlock[k] = BigInt(rawBlock[k]).toString();
|
|
263
|
+
for (const k of [
|
|
264
|
+
"miner"
|
|
265
|
+
])rawBlock[k] = (0, $42564d9f228fe302$export$db81f9ea057ab646)(rawBlock[k]);
|
|
266
|
+
rawBlock.transactions = rawBlock.transactions.map((tx)=>{
|
|
267
|
+
for (const k of [
|
|
268
|
+
"blockNumber",
|
|
269
|
+
"cumulativeGasUsed",
|
|
270
|
+
"effectiveGasPrice",
|
|
271
|
+
"gas",
|
|
272
|
+
"gasUsed",
|
|
273
|
+
"nonce",
|
|
274
|
+
"status",
|
|
275
|
+
"transactionIndex"
|
|
276
|
+
]){
|
|
277
|
+
if (typeof tx[k] === "string") tx[k] = parseInt(tx[k]);
|
|
278
|
+
if (typeof tx.receipt[k] === "string") tx.receipt[k] = parseInt(tx.receipt[k]);
|
|
279
|
+
}
|
|
280
|
+
for (const k of [
|
|
281
|
+
"gasPrice",
|
|
282
|
+
"maxFeePerGas",
|
|
283
|
+
"maxPriorityFeePerGas",
|
|
284
|
+
"value"
|
|
285
|
+
]){
|
|
286
|
+
if (typeof tx[k] === "string") tx[k] = BigInt(tx[k]).toString();
|
|
287
|
+
if (typeof tx.receipt[k] === "string") tx.receipt[k] = BigInt(tx.receipt[k]).toString();
|
|
288
|
+
}
|
|
289
|
+
for (const k of [
|
|
290
|
+
"from",
|
|
291
|
+
"to"
|
|
292
|
+
])if (typeof tx[k] === "string") tx[k] = (0, $42564d9f228fe302$export$db81f9ea057ab646)(tx[k]);
|
|
293
|
+
for (const k of [
|
|
294
|
+
"contractAddress"
|
|
295
|
+
])if (typeof tx.receipt[k] === "string") tx.receipt[k] = (0, $42564d9f228fe302$export$db81f9ea057ab646)(tx.receipt[k]);
|
|
296
|
+
tx.type = parseInt(tx.type);
|
|
297
|
+
tx.receipt["status"] = Boolean(tx.receipt["status"]);
|
|
298
|
+
tx.receipt["logs"] = tx.receipt["logs"]?.map((log)=>{
|
|
299
|
+
for (const k of [
|
|
300
|
+
"blockNumber",
|
|
301
|
+
"logIndex",
|
|
302
|
+
"transactionIndex"
|
|
303
|
+
])if (typeof log[k] === "string") log[k] = parseInt(log[k]);
|
|
304
|
+
log["address"] = (0, $42564d9f228fe302$export$db81f9ea057ab646)(log["address"]);
|
|
305
|
+
return log;
|
|
306
|
+
});
|
|
307
|
+
return tx;
|
|
308
|
+
});
|
|
309
|
+
return rawBlock;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
$parcel$exportWildcard($fde9406d76ec24a9$exports, $42564d9f228fe302$exports);
|
|
314
|
+
$parcel$exportWildcard($fde9406d76ec24a9$exports, $68871103c7bc00cf$exports);
|
|
315
|
+
$parcel$exportWildcard($fde9406d76ec24a9$exports, $cfa23334cbdf9391$exports);
|
|
316
|
+
$parcel$exportWildcard($fde9406d76ec24a9$exports, $f6a81337d3532e59$exports);
|
|
317
|
+
$parcel$exportWildcard($fde9406d76ec24a9$exports, $8f1e0ae1ead9a2a9$exports);
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
const $8dd8a21b1d9a9d2a$var$NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
321
|
+
function $8dd8a21b1d9a9d2a$export$b62520a34e11070c(block) {
|
|
322
|
+
const transfers = [];
|
|
323
|
+
switch(block._network){
|
|
324
|
+
// @TODO: port non-EVM handlers over
|
|
325
|
+
// assume EVM as default for now
|
|
326
|
+
default:
|
|
327
|
+
for (const tx of block.transactions){
|
|
328
|
+
if (!tx.receipt) continue;
|
|
329
|
+
const timestamp = new Date(block.timestamp * 1000).toISOString();
|
|
330
|
+
const transactionGasFee = BigInt(tx.receipt.gasUsed) * BigInt(tx.receipt.effectiveGasPrice);
|
|
331
|
+
// track direct ETH transfers
|
|
332
|
+
if (tx.value?.length >= 3 || /\d+/.test(tx.value)) transfers.push({
|
|
333
|
+
amount: BigInt(tx.value),
|
|
334
|
+
blockNumber: tx.blockNumber,
|
|
335
|
+
from: (0, $42564d9f228fe302$export$db81f9ea057ab646)(tx.from) || $8dd8a21b1d9a9d2a$var$NULL_ADDRESS,
|
|
336
|
+
timestamp: timestamp,
|
|
337
|
+
to: (0, $42564d9f228fe302$export$db81f9ea057ab646)(tx.to) || $8dd8a21b1d9a9d2a$var$NULL_ADDRESS,
|
|
338
|
+
transactionGasFee: transactionGasFee,
|
|
339
|
+
transactionHash: tx.hash
|
|
340
|
+
});
|
|
341
|
+
// track ERC20 transfers
|
|
342
|
+
for (const log of tx.receipt.logs){
|
|
343
|
+
const txfer = (0, $cfa23334cbdf9391$export$cf548b70626e2eb9)(log, [
|
|
344
|
+
"Transfer(address indexed from, address indexed to, uint256 value)"
|
|
345
|
+
]);
|
|
346
|
+
if (txfer) transfers.push({
|
|
347
|
+
amount: txfer.decoded.value,
|
|
348
|
+
blockNumber: tx.blockNumber,
|
|
349
|
+
from: (0, $42564d9f228fe302$export$db81f9ea057ab646)(txfer.decoded.from) || $8dd8a21b1d9a9d2a$var$NULL_ADDRESS,
|
|
350
|
+
index: log.logIndex,
|
|
351
|
+
timestamp: timestamp,
|
|
352
|
+
to: (0, $42564d9f228fe302$export$db81f9ea057ab646)(txfer.decoded.to) || $8dd8a21b1d9a9d2a$var$NULL_ADDRESS,
|
|
353
|
+
token: (0, $42564d9f228fe302$export$db81f9ea057ab646)(log.address),
|
|
354
|
+
transactionGasFee: transactionGasFee,
|
|
355
|
+
transactionHash: tx.hash
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
if (Array.isArray(tx.traces)) for (const trace of tx.traces.filter((t)=>t.action)){
|
|
359
|
+
const action = trace.action;
|
|
360
|
+
if (!action?.value) continue;
|
|
361
|
+
transfers.push({
|
|
362
|
+
amount: BigInt(action.value),
|
|
363
|
+
blockNumber: tx.blockNumber,
|
|
364
|
+
from: (0, $42564d9f228fe302$export$db81f9ea057ab646)(action.from) || $8dd8a21b1d9a9d2a$var$NULL_ADDRESS,
|
|
365
|
+
index: trace.traceAddress?.join("-"),
|
|
366
|
+
timestamp: timestamp,
|
|
367
|
+
to: (0, $42564d9f228fe302$export$db81f9ea057ab646)(action.to) || $8dd8a21b1d9a9d2a$var$NULL_ADDRESS,
|
|
368
|
+
transactionGasFee: transactionGasFee,
|
|
369
|
+
transactionHash: tx.hash
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return transfers.filter((txfer)=>txfer.amount > BigInt(0));
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
$parcel$exportWildcard($aedb69bdc766818f$exports, $2b06dfb983c1c46f$exports);
|
|
379
|
+
$parcel$exportWildcard($aedb69bdc766818f$exports, $8a3c50b8cb33d9fb$exports);
|
|
380
|
+
$parcel$exportWildcard($aedb69bdc766818f$exports, $8dd8a21b1d9a9d2a$exports);
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
var $81c1b644006d48ec$exports = {};
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
function $149c1bd638913645$export$cceb5167b935aafb() {
|
|
388
|
+
return 0, $70cb039dbeb3c65a$export$a8fc3402335b0b04;
|
|
389
|
+
}
|
|
390
|
+
function $149c1bd638913645$export$a07bfd14bbc36e4b(key) {
|
|
391
|
+
return (0, $70cb039dbeb3c65a$export$a8fc3402335b0b04).find((template)=>template.key === key);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
export {$149c1bd638913645$export$cceb5167b935aafb as getAllTemplates, $149c1bd638913645$export$a07bfd14bbc36e4b as getTemplateByKey};
|
|
396
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,KA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,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":"module.js.map"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type Template = {
|
|
2
|
+
key: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
tags: string[];
|
|
7
|
+
params: Param[];
|
|
8
|
+
function: (params: Record<string, unknown>) => string;
|
|
9
|
+
};
|
|
10
|
+
type Param = {
|
|
11
|
+
key: string;
|
|
12
|
+
name: string;
|
|
13
|
+
type: "NETWORK" | "ADDRESS";
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
optional?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export function getAllTemplates(): Template[];
|
|
18
|
+
export function getTemplateByKey(key: string): Template;
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,gBAAuB;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;CACzD,CAAC;AAEF,aAAoB;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AcTF,8CAEG;AAEH,iCAAiC,GAAG,EAAE,MAAM,YAEzC","sources":["src/types.ts","src/templates/all-blocks.ts","src/templates/token-transfers.ts","src/templates/index.ts","src/utils/evm-method-signature-to-hex.ts","src/utils/evm-decode-log.ts","src/presets/erc20-transfers.ts","src/presets/token-price.ts","src/utils/evm-address-to-checksum.ts","src/utils/evm-chain-to-id.ts","src/utils/evm-normalize-raw-block.ts","src/utils/index.ts","src/presets/token-transfers.ts","src/presets/index.ts","src/index.ts"],"sourcesContent":["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};","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;","import allBlocks from './all-blocks';\nimport tokenTransfers from './token-transfers';\n\nexport const templates = [allBlocks, tokenTransfers];","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 { 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 { 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 _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 { 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 * 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 { 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 './erc20-transfers';\nexport * from './token-price';\nexport * from './token-transfers';\n","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 }"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@indexing/jiti",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Just In Time Indexing, for all",
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"main": "dist/main.js",
|
|
7
|
+
"module": "dist/module.js",
|
|
8
|
+
"types": "dist/types.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "rm -rf dist .parcel-cache && parcel build --dist-dir dist",
|
|
11
|
+
"lint": "prettier --write **.ts && eslint .",
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
+
"watch": "parcel watch"
|
|
14
|
+
},
|
|
15
|
+
"author": "Indexing Co",
|
|
16
|
+
"license": "GPL-3.0-or-later",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@parcel/packager-ts": "^2.12.0",
|
|
19
|
+
"@parcel/transformer-typescript-types": "^2.12.0",
|
|
20
|
+
"@types/isomorphic-fetch": "^0.0.39",
|
|
21
|
+
"eslint-config-prettier": "^9.1.0",
|
|
22
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
23
|
+
"husky": "^9.1.5",
|
|
24
|
+
"parcel": "^2.12.0",
|
|
25
|
+
"prettier": "3.3.3",
|
|
26
|
+
"pretty-quick": "^4.0.0",
|
|
27
|
+
"typescript": "^5.5.4",
|
|
28
|
+
"typescript-eslint": "^8.3.0"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"isomorphic-fetch": "^3.0.0",
|
|
32
|
+
"viem": "^2.21.1"
|
|
33
|
+
}
|
|
34
|
+
}
|