@indexing/jiti 0.0.30 → 0.0.32

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/module.js CHANGED
@@ -58,6 +58,246 @@ const $a4b307b872b01f44$var$rawTemplate = {
58
58
  var $a4b307b872b01f44$export$2e2bcd8739ae039 = $a4b307b872b01f44$var$rawTemplate;
59
59
 
60
60
 
61
+ const $bea1ed486f96b980$export$ace043a4f2efe476 = {
62
+ match: (block)=>[
63
+ "APTOS",
64
+ "APTOS_TESTNET"
65
+ ].includes(block._network),
66
+ transform (block) {
67
+ let transfers = [];
68
+ for (const tx of block.transactions){
69
+ if (!tx?.events || !Array.isArray(tx.events)) continue;
70
+ const timestamp = tx.timestamp ? new Date(parseInt(tx.timestamp, 10) / 1000).toISOString() : null;
71
+ const transfersByKey = {};
72
+ for (const evt of tx.events){
73
+ const evtType = evt.type;
74
+ if (/::(Withdraw|Deposit)[^:]*/.test(evtType)) {
75
+ const data = evt.data;
76
+ const amount = data.amount;
77
+ const accountAddr = data.store_owner || evt.guid?.account_address || "";
78
+ let tokenAddr = "0x1::aptos_coin::AptosCoin";
79
+ if (data.store) tokenAddr = tx.changes.find((c)=>c.address === data.store && c.data.type === "0x1::fungible_asset::FungibleStore")?.data?.data?.metadata?.inner || data.store;
80
+ const compositeKey = `${tx.hash}-${tokenAddr}-${amount}`;
81
+ if (!transfersByKey[compositeKey]) transfersByKey[compositeKey] = {
82
+ amount: amount,
83
+ tokenAddress: tokenAddr
84
+ };
85
+ if (/::Withdraw[^:]*/.test(evtType)) transfersByKey[compositeKey].from = accountAddr;
86
+ else transfersByKey[compositeKey].to = accountAddr;
87
+ }
88
+ }
89
+ for (const partial of Object.values(transfersByKey)){
90
+ if (!partial.from || !partial.to) continue;
91
+ const fromAddr = partial.from.length < 66 ? `0x0${partial.from.slice(2)}` : partial.from;
92
+ const toAddr = partial.to.length < 66 ? `0x0${partial.to.slice(2)}` : partial.to;
93
+ let finalToken = null;
94
+ let finalTokenType = "TOKEN";
95
+ if (partial.tokenAddress?.toLowerCase().includes("aptos_coin")) finalToken = null;
96
+ else finalToken = partial.tokenAddress?.toLowerCase();
97
+ const gasUsed = BigInt(tx.gas_used || "0");
98
+ transfers.push({
99
+ amount: BigInt(partial.amount),
100
+ blockNumber: parseInt(block.block_height, 10),
101
+ from: fromAddr,
102
+ to: toAddr,
103
+ timestamp: timestamp,
104
+ token: finalToken,
105
+ tokenType: finalTokenType,
106
+ transactionGasFee: gasUsed,
107
+ transactionHash: tx.hash
108
+ });
109
+ }
110
+ }
111
+ return transfers;
112
+ },
113
+ tests: [
114
+ {
115
+ params: {
116
+ network: "APTOS",
117
+ walletAddress: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00"
118
+ },
119
+ payload: "https://jiti.indexing.co/networks/aptos/297956660",
120
+ output: [
121
+ {
122
+ amount: 1611839920n,
123
+ blockNumber: 297956660,
124
+ from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
125
+ to: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0",
126
+ timestamp: "2025-03-02T21:07:06.002Z",
127
+ token: null,
128
+ tokenType: "TOKEN",
129
+ transactionGasFee: 13n,
130
+ transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
131
+ },
132
+ {
133
+ amount: 1502138836n,
134
+ blockNumber: 297956660,
135
+ from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
136
+ to: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
137
+ timestamp: "2025-03-02T21:07:06.002Z",
138
+ token: null,
139
+ tokenType: "TOKEN",
140
+ transactionGasFee: 13n,
141
+ transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
142
+ }
143
+ ]
144
+ },
145
+ {
146
+ params: {
147
+ network: "APTOS",
148
+ contractAddress: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"
149
+ },
150
+ payload: "https://jiti.indexing.co/networks/aptos/303623631",
151
+ output: [
152
+ {
153
+ amount: 1000060n,
154
+ blockNumber: 303623631,
155
+ from: "0xa4e7455d27731ab857e9701b1e6ed72591132b909fe6e4fd99b66c1d6318d9e8",
156
+ timestamp: "2025-03-14T15:39:49.845Z",
157
+ to: "0x9317336bfc9ba6987d40492ddea8d41e11b7c2e473f3556a9c82309d326e79ce",
158
+ token: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
159
+ tokenType: "TOKEN",
160
+ transactionGasFee: 16n,
161
+ transactionHash: "0x24b8854bad1f6543b35069eacd6ec40a583ca7fa452b422b04d747d24b65279c"
162
+ }
163
+ ]
164
+ }
165
+ ]
166
+ };
167
+
168
+
169
+ const $8860a67278817de8$export$893111d8d332e195 = {
170
+ match: (block)=>[
171
+ "CARDANO"
172
+ ].includes(block._network),
173
+ transform (block) {
174
+ let transfers = [];
175
+ const blockTimestamp = new Date(block.timestamp * 1000).toISOString();
176
+ for (const tx of block.transactions){
177
+ const typedTx = tx;
178
+ if (!Array.isArray(typedTx.operations)) continue;
179
+ const transactionHash = typedTx.transaction_identifier?.hash || "";
180
+ const inputs = typedTx.operations.filter((op)=>op.type === "input");
181
+ const outputs = typedTx.operations.filter((op)=>op.type === "output");
182
+ if (!inputs.length && !outputs.length) continue;
183
+ const fromAddress = inputs[0]?.account?.address;
184
+ if (!fromAddress) continue;
185
+ const sumInputs = inputs.reduce((acc, op)=>{
186
+ const val = BigInt(op.amount?.value || "0");
187
+ return acc + val;
188
+ }, BigInt(0));
189
+ const sumOutputs = outputs.reduce((acc, op)=>{
190
+ const val = BigInt(op.amount?.value || "0");
191
+ return acc + val;
192
+ }, BigInt(0));
193
+ const transactionFee = sumInputs + BigInt(sumOutputs);
194
+ for (const out of outputs){
195
+ const rawValue = out.amount?.value || "0";
196
+ const absoluteValue = BigInt(rawValue);
197
+ transfers.push({
198
+ amount: absoluteValue < 0 ? -absoluteValue : absoluteValue,
199
+ blockNumber: block.block_identifier.index,
200
+ from: fromAddress,
201
+ timestamp: blockTimestamp,
202
+ to: out.account?.address || "",
203
+ token: out.amount?.currency?.symbol?.toUpperCase() === "ADA" ? null : out.amount?.currency?.symbol,
204
+ tokenType: out.amount?.currency?.symbol?.toUpperCase() === "ADA" ? "NATIVE" : "TOKEN",
205
+ transactionGasFee: transactionFee < 0 ? -transactionFee : transactionFee,
206
+ transactionHash: transactionHash
207
+ });
208
+ }
209
+ }
210
+ return transfers;
211
+ },
212
+ tests: [
213
+ {
214
+ params: {
215
+ network: "CARDANO",
216
+ walletAddress: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
217
+ contractAddress: ""
218
+ },
219
+ payload: "https://jiti.indexing.co/networks/cardano/11443286",
220
+ output: [
221
+ {
222
+ amount: 1110000n,
223
+ blockNumber: 11443286,
224
+ from: "addr1qymdv285few5tyqvya86rl97r9e608njs37shfew6l2nn473aw2pcnrcvfwfgg2dnew99m4tjj0apsu7232w2euzwpysndh0h3",
225
+ timestamp: "+057068-01-19T05:23:20.000Z",
226
+ to: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
227
+ token: null,
228
+ tokenType: "NATIVE",
229
+ transactionGasFee: 174257n,
230
+ transactionHash: "261c42ba9124f55d8e169ebb692cd3759d796a54369acb316ee449b546e79309"
231
+ }
232
+ ]
233
+ }
234
+ ]
235
+ };
236
+
237
+
238
+
239
+
240
+
241
+
242
+ var $8d6646508fb2fa58$require$Buffer = $hgUW1$Buffer;
243
+ const $8d6646508fb2fa58$export$b5fd4920e8b7d913 = {
244
+ match: (block)=>!!block.block,
245
+ transform (block) {
246
+ let transfers = [];
247
+ const typedBlock = block;
248
+ const blockNumber = Number(typedBlock.block.header.height);
249
+ const blockTimestamp = new Date(typedBlock.block.header.time).toISOString();
250
+ for (const txRaw of typedBlock.block.data.txs || []){
251
+ const decoded = (0, $hgUW1$decodeTxRaw)(new Uint8Array($8d6646508fb2fa58$require$Buffer.from(txRaw, "base64")));
252
+ const txHash = (0, $hgUW1$sha256)(new Uint8Array($8d6646508fb2fa58$require$Buffer.from(txRaw, "base64")));
253
+ const transactionGasFee = BigInt(decoded.authInfo.fee?.amount?.[0]?.amount || "0");
254
+ const registry = new (0, $hgUW1$Registry)((0, $hgUW1$defaultRegistryTypes));
255
+ for (const message of decoded.body.messages)if ([
256
+ "/ibc.applications.transfer.v1.MsgTransfer",
257
+ "/cosmos.bank.v1beta1.MsgSend"
258
+ ].includes(message.typeUrl)) {
259
+ const decodedMsg = registry.decode(message);
260
+ transfers.push({
261
+ blockNumber: blockNumber,
262
+ from: decodedMsg.sender,
263
+ to: decodedMsg.receiver,
264
+ amount: BigInt(decodedMsg.token.amount),
265
+ token: decodedMsg.token.denom,
266
+ tokenType: "NATIVE",
267
+ timestamp: blockTimestamp,
268
+ transactionHash: txHash.slice(2).toUpperCase(),
269
+ transactionGasFee: transactionGasFee
270
+ });
271
+ }
272
+ }
273
+ return transfers;
274
+ },
275
+ tests: [
276
+ {
277
+ params: {
278
+ network: "COSMOS",
279
+ walletAddress: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
280
+ contractAddress: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013"
281
+ },
282
+ payload: "https://jiti.indexing.co/networks/cosmos/24419691",
283
+ output: [
284
+ {
285
+ blockNumber: 24419691,
286
+ from: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
287
+ to: "noble1x4qvmtcfc02pklttfgxzdccxcsyzklrx4073uv",
288
+ amount: 500000n,
289
+ token: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013",
290
+ tokenType: "NATIVE",
291
+ timestamp: "2025-02-14T21:48:22.809Z",
292
+ transactionHash: "963D4D7BB59C1280F58A7ECA2F1934E2AA005109A989193C815C7B98EDCD7445",
293
+ transactionGasFee: 4860n
294
+ }
295
+ ]
296
+ }
297
+ ]
298
+ };
299
+
300
+
61
301
  var $fde9406d76ec24a9$exports = {};
62
302
  var $42564d9f228fe302$exports = {};
63
303
 
@@ -269,692 +509,131 @@ $parcel$exportWildcard($fde9406d76ec24a9$exports, $f6a81337d3532e59$exports);
269
509
  $parcel$exportWildcard($fde9406d76ec24a9$exports, $8f1e0ae1ead9a2a9$exports);
270
510
 
271
511
 
272
-
273
-
274
-
275
-
276
- var $c18434deda90759d$require$Buffer = $hgUW1$Buffer;
277
- const $c18434deda90759d$var$NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
278
- const $c18434deda90759d$var$tokenTransfersTemplate = {
279
- key: "token_transfers",
280
- name: "Token Transfers",
281
- description: "Get all token transfers for a set of token types.",
282
- tags: [
283
- "EVM",
284
- "ERC20",
285
- "ERC721",
286
- "NFT",
287
- "TOKEN"
288
- ],
289
- disabled: false,
290
- params: [
291
- {
292
- key: "network",
293
- name: "Network",
294
- type: "NETWORK",
295
- optional: false
296
- },
297
- {
298
- key: "contractAddress",
299
- name: "Contract Address",
300
- type: "ADDRESS",
301
- optional: true
302
- },
303
- {
304
- key: "walletAddress",
305
- name: "Wallet Address",
306
- type: "ADDRESS",
307
- optional: true
308
- },
309
- {
310
- key: "tokenTypes",
311
- name: "Token Types",
312
- type: "STRING",
313
- multiple: true,
314
- optional: true,
315
- values: [
316
- "NATIVE",
317
- "TOKEN",
318
- "NFT"
319
- ]
320
- }
321
- ],
322
- transform: (block, _ctx)=>{
512
+ const $5ec62a2088d070a8$var$NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
513
+ const $5ec62a2088d070a8$export$5beebc5708fabf3c = {
514
+ match: (block)=>true,
515
+ transform (block, _ctx) {
323
516
  const TOKEN_TYPES = _ctx.params.tokenTypes || [];
324
517
  let transfers = [];
325
- switch(block._network){
326
- case "APTOS":
327
- case "APTOS_TESTNET":
328
- for (const tx of block.transactions){
329
- if (!tx?.events || !Array.isArray(tx.events)) continue;
330
- const timestamp = tx.timestamp ? new Date(parseInt(tx.timestamp, 10) / 1000).toISOString() : null;
331
- const transfersByKey = {};
332
- for (const evt of tx.events){
333
- const evtType = evt.type;
334
- if (/::(Withdraw|Deposit)[^:]*/.test(evtType)) {
335
- const data = evt.data;
336
- const amount = data.amount;
337
- const accountAddr = data.store_owner || evt.guid?.account_address || "";
338
- let tokenAddr = "0x1::aptos_coin::AptosCoin";
339
- if (data.store) tokenAddr = tx.changes.find((c)=>c.address === data.store && c.data.type === "0x1::fungible_asset::FungibleStore")?.data?.data?.metadata?.inner || data.store;
340
- const compositeKey = `${tx.hash}-${tokenAddr}-${amount}`;
341
- if (!transfersByKey[compositeKey]) transfersByKey[compositeKey] = {
342
- amount: amount,
343
- tokenAddress: tokenAddr
344
- };
345
- if (/::Withdraw[^:]*/.test(evtType)) transfersByKey[compositeKey].from = accountAddr;
346
- else transfersByKey[compositeKey].to = accountAddr;
347
- }
348
- }
349
- for (const partial of Object.values(transfersByKey)){
350
- if (!partial.from || !partial.to) continue;
351
- const fromAddr = partial.from.length < 66 ? `0x0${partial.from.slice(2)}` : partial.from;
352
- const toAddr = partial.to.length < 66 ? `0x0${partial.to.slice(2)}` : partial.to;
353
- let finalToken = null;
354
- let finalTokenType = "TOKEN";
355
- if (partial.tokenAddress?.toLowerCase().includes("aptos_coin")) finalToken = null;
356
- else finalToken = partial.tokenAddress?.toLowerCase();
357
- const gasUsed = BigInt(tx.gas_used || "0");
358
- transfers.push({
359
- amount: BigInt(partial.amount),
360
- blockNumber: parseInt(block.block_height, 10),
361
- from: fromAddr,
362
- to: toAddr,
363
- timestamp: timestamp,
364
- token: finalToken,
365
- tokenType: finalTokenType,
366
- transactionGasFee: gasUsed,
367
- transactionHash: tx.hash
368
- });
369
- }
370
- }
371
- break;
372
- case "BITCOIN":
373
- case "BITCOIN_TESTNET":
374
- case "LITCOIN":
375
- case "DOGECOIN":
376
- for (const tx of block.tx){
377
- const timestamp = tx.time ? new Date(tx.time * 1000).toISOString() : null;
378
- const vin = tx.vin[0];
379
- const vout = tx.vout;
380
- const fromVout = Math.min(vin.vout || 1000, vout.length - 1);
381
- const fromAddress = vin.prevout?.scriptPubKey?.address || vout[fromVout]?.scriptPubKey?.address || vout[fromVout]?.scriptPubKey?.addresses?.[0];
382
- if (!fromAddress) continue;
383
- for (const v of vout)transfers.push({
384
- amount: BigInt(Math.round(v.value * Math.pow(10, 8))),
385
- blockNumber: block.height,
386
- from: fromAddress,
387
- timestamp: timestamp,
388
- to: v.scriptPubKey.address || v.scriptPubKey.addresses?.[0],
389
- transactionGasFee: BigInt(Math.round((tx.fee || 0) * Math.pow(10, 8))),
390
- transactionHash: tx.txid,
391
- token: null,
392
- tokenType: "NATIVE"
393
- });
394
- }
395
- break;
396
- case "CARDANO":
397
- {
398
- const blockTimestamp = new Date(block.timestamp * 1000).toISOString();
399
- for (const tx of block.transactions){
400
- const typedTx = tx;
401
- if (!Array.isArray(typedTx.operations)) continue;
402
- const transactionHash = typedTx.transaction_identifier?.hash || "";
403
- const inputs = typedTx.operations.filter((op)=>op.type === "input");
404
- const outputs = typedTx.operations.filter((op)=>op.type === "output");
405
- if (!inputs.length && !outputs.length) continue;
406
- const fromAddress = inputs[0]?.account?.address;
407
- if (!fromAddress) continue;
408
- const sumInputs = inputs.reduce((acc, op)=>{
409
- const val = BigInt(op.amount?.value || "0");
410
- return acc + val;
411
- }, BigInt(0));
412
- const sumOutputs = outputs.reduce((acc, op)=>{
413
- const val = BigInt(op.amount?.value || "0");
414
- return acc + val;
415
- }, BigInt(0));
416
- const transactionFee = sumInputs + BigInt(sumOutputs);
417
- for (const out of outputs){
418
- const rawValue = out.amount?.value || "0";
419
- const absoluteValue = BigInt(rawValue);
420
- transfers.push({
421
- amount: absoluteValue < 0 ? -absoluteValue : absoluteValue,
422
- blockNumber: block.block_identifier.index,
423
- from: fromAddress,
424
- timestamp: blockTimestamp,
425
- to: out.account?.address || "",
426
- token: out.amount?.currency?.symbol?.toUpperCase() === "ADA" ? null : out.amount?.currency?.symbol,
427
- tokenType: out.amount?.currency?.symbol?.toUpperCase() === "ADA" ? "NATIVE" : "TOKEN",
428
- transactionGasFee: transactionFee < 0 ? -transactionFee : transactionFee,
429
- transactionHash: transactionHash
430
- });
431
- }
432
- }
433
- break;
434
- }
435
- case "RIPPLE":
436
- if (!Array.isArray(block.transactions)) break;
437
- for (const rawTx of block.transactions){
438
- const typedTx = rawTx;
439
- if (typedTx.TransactionType !== "Payment") continue;
440
- const deliveredOrAmount = typedTx.metaData?.delivered_amount ?? typedTx.Amount ?? "0";
441
- let tokenSymbol = "XRP";
442
- let tokenType = "NATIVE";
443
- let parsedAmount;
444
- if (typeof deliveredOrAmount === "object") {
445
- tokenSymbol = deliveredOrAmount.currency?.toUpperCase() ?? "UNKNOWN";
446
- tokenType = "TOKEN";
447
- const floatVal = parseFloat(deliveredOrAmount.value);
448
- const smallestUnit = Math.round(floatVal * 1000000);
449
- parsedAmount = BigInt(smallestUnit);
450
- } else parsedAmount = BigInt(String(deliveredOrAmount));
518
+ for (const tx of block.transactions){
519
+ if (!tx.receipt) continue;
520
+ const timestamp = new Date(block.timestamp * 1000).toISOString();
521
+ const transactionGasFee = BigInt(tx.receipt.gasUsed) * BigInt(tx.receipt.effectiveGasPrice);
522
+ // track direct ETH transfers
523
+ if (!TOKEN_TYPES.length || TOKEN_TYPES.includes("NATIVE")) {
524
+ // pull from traces, if available
525
+ if (Array.isArray(tx.traces)) for (const trace of tx.traces.filter((t)=>t.action)){
526
+ const action = trace.action;
527
+ if (!action?.value) continue;
451
528
  transfers.push({
452
- amount: parsedAmount,
453
- blockNumber: parseInt(block.ledger_index, 10),
454
- from: typedTx.Account ?? "UNKNOWN",
455
- timestamp: block.close_time_iso ? block.close_time_iso : null,
456
- to: typedTx.Destination ?? "UNKNOWN",
457
- token: tokenSymbol,
458
- tokenType: tokenType,
459
- transactionGasFee: BigInt(typedTx.Fee ?? "0"),
460
- transactionHash: typedTx.hash ?? ""
529
+ amount: BigInt(action.value),
530
+ blockNumber: tx.blockNumber,
531
+ from: action.from?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
532
+ index: trace.traceAddress?.join("-"),
533
+ timestamp: timestamp,
534
+ to: action.to?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
535
+ tokenType: "NATIVE",
536
+ transactionGasFee: transactionGasFee,
537
+ transactionHash: tx.hash
461
538
  });
462
539
  }
463
- break;
464
- case "SOLANA":
465
- for (const tx of block.transactions){
466
- const solanaTx = tx;
467
- const txHash = solanaTx.transaction.signatures[0];
468
- const timestamp = block.blockTime ? new Date(block.blockTime * 1000).toISOString() : null;
469
- let txFee = BigInt(solanaTx.meta.fee);
470
- if (txFee < BigInt(10)) txFee = txFee * BigInt(Math.pow(10, 9));
471
- const transfersByKey = {};
472
- for (const post of solanaTx.meta.postTokenBalances){
473
- let matched = false;
474
- for (const pre of solanaTx.meta.preTokenBalances)if (post.mint === pre.mint && post.owner === pre.owner) {
475
- let diff = BigInt(post.uiTokenAmount.amount) - BigInt(pre.uiTokenAmount.amount);
476
- if (diff === BigInt(0)) continue;
477
- const isNegDiff = diff < 0;
478
- if (diff < 0) diff = -diff;
479
- const key = `${post.mint}-${diff.toString()}`;
480
- const txfer = {
481
- amount: diff,
482
- blockNumber: block.blockHeight,
483
- from: pre.owner,
484
- timestamp: timestamp,
485
- to: post.owner,
486
- transactionGasFee: txFee,
487
- transactionHash: txHash,
488
- token: post.mint,
489
- tokenType: "TOKEN"
490
- };
491
- if (transfersByKey[key]) {
492
- if (isNegDiff) delete txfer.to;
493
- else delete txfer.from;
494
- }
495
- transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
496
- matched = true;
497
- }
498
- if (!matched) {
499
- let diff = BigInt(post.uiTokenAmount.amount);
500
- const isNegDiff = diff < 0;
501
- if (diff < 0) diff = -diff;
502
- const key = `${post.mint}-${diff.toString()}`;
503
- const txfer = {
504
- amount: diff,
505
- blockNumber: block.blockHeight,
506
- from: null,
507
- timestamp: timestamp,
508
- to: post.owner,
509
- token: post.mint,
510
- tokenType: "TOKEN",
511
- transactionGasFee: txFee,
512
- transactionHash: txHash
513
- };
514
- if (transfersByKey[key]) {
515
- if (isNegDiff) delete txfer.to;
516
- else delete txfer.from;
517
- }
518
- transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
519
- }
520
- }
521
- for(let i = 1; i < solanaTx.meta.postBalances.length; i += 1){
522
- const post = solanaTx.meta.postBalances[i];
523
- const pre = solanaTx.meta.preBalances[i];
524
- if (post !== undefined && pre !== undefined && post !== pre) {
525
- let diff = BigInt(post) - BigInt(pre);
526
- if (diff < 0) diff = -diff;
527
- const key = `null-${diff.toString()}`;
528
- const txfer = {
529
- amount: diff,
530
- blockNumber: block.blockHeight,
531
- from: post > pre ? typeof solanaTx.transaction.message.accountKeys[0] === "string" ? solanaTx.transaction.message.accountKeys[0] : solanaTx.transaction.message.accountKeys[0]?.pubkey : typeof solanaTx.transaction.message.accountKeys[i] === "string" ? solanaTx.transaction.message.accountKeys[i] : solanaTx.transaction.message.accountKeys[i]?.pubkey,
532
- timestamp: timestamp,
533
- to: typeof solanaTx.transaction.message.accountKeys[i] === "string" ? solanaTx.transaction.message.accountKeys[i] : solanaTx.transaction.message.accountKeys[i]?.pubkey?.toString(),
534
- token: null,
535
- tokenType: "NATIVE",
536
- transactionGasFee: txFee,
537
- transactionHash: txHash
538
- };
539
- if (transfersByKey[key]) {
540
- if (post > pre) delete txfer.from;
541
- else delete txfer.to;
542
- }
543
- transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
544
- }
545
- }
546
- transfers.push(...Object.values(transfersByKey));
547
- }
548
- break;
549
- case "STARKNET":
550
- if (!Array.isArray(block.transactions)) break;
551
- for (const tx of block.transactions){
552
- const typedTx = tx;
553
- const timestamp = block.timestamp ? new Date(block.timestamp * 1000).toISOString() : null;
554
- let transactionGasFee = BigInt(0);
555
- if (typedTx?.receipt?.actual_fee?.amount) transactionGasFee = BigInt(typedTx.receipt.actual_fee.amount);
556
- const transactionHash = typedTx.transaction_hash;
557
- if (!typedTx.receipt?.events) continue;
558
- for (const event of typedTx.receipt.events){
559
- if (!event.keys.includes("0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9")) continue;
560
- if (event.data.length < 3) continue;
561
- const [from, to, amountHex] = event.data;
562
- const amount = BigInt(amountHex);
540
+ else if (tx.value?.length >= 3 || /\d+/.test(tx.value)) transfers.push({
541
+ amount: BigInt(tx.value),
542
+ blockNumber: tx.blockNumber,
543
+ from: tx.from?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
544
+ timestamp: timestamp,
545
+ to: tx.to?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
546
+ tokenType: "NATIVE",
547
+ transactionGasFee: transactionGasFee,
548
+ transactionHash: tx.hash
549
+ });
550
+ }
551
+ // track ERC20 transfers
552
+ if (!TOKEN_TYPES.length || TOKEN_TYPES.includes("TOKEN")) for (const log of tx.receipt.logs){
553
+ const txfer = (0, $cfa23334cbdf9391$export$cf548b70626e2eb9)(log, [
554
+ "Transfer(address indexed from, address indexed to, uint256 value)"
555
+ ]);
556
+ if (txfer) transfers.push({
557
+ amount: txfer.decoded.value,
558
+ blockNumber: tx.blockNumber,
559
+ from: txfer.decoded.from?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
560
+ index: log.logIndex,
561
+ timestamp: timestamp,
562
+ to: txfer.decoded.to?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
563
+ token: log.address.toLowerCase(),
564
+ tokenType: "TOKEN",
565
+ transactionGasFee: transactionGasFee,
566
+ transactionHash: tx.hash
567
+ });
568
+ }
569
+ if (!TOKEN_TYPES.length || TOKEN_TYPES.includes("NFT")) for (const log of tx.receipt.logs){
570
+ const txfer = (0, $cfa23334cbdf9391$export$cf548b70626e2eb9)(log, [
571
+ "Transfer(address indexed from, address indexed to, uint256 indexed value)",
572
+ "TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)",
573
+ "TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values)"
574
+ ]);
575
+ if (!txfer) continue;
576
+ switch(txfer.metadata.name){
577
+ case "Transfer":
563
578
  transfers.push({
564
- amount: amount,
565
- blockNumber: block.block_number,
566
- from: from,
579
+ amount: 1,
580
+ blockNumber: tx.blockNumber,
581
+ from: txfer.decoded.from?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
582
+ index: log.logIndex,
567
583
  timestamp: timestamp,
568
- to: to,
569
- token: null,
570
- tokenType: "NATIVE",
584
+ to: txfer.decoded.to?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
585
+ token: log.address.toLowerCase(),
586
+ tokenId: txfer.decoded.value.toString(),
587
+ tokenType: "NFT",
571
588
  transactionGasFee: transactionGasFee,
572
- transactionHash: transactionHash
573
- });
574
- }
575
- }
576
- break;
577
- case "STELLAR":
578
- for (const tx of block.transactions){
579
- const typedTx = tx;
580
- for (const op of typedTx.operations)if (op.type === "payment") transfers.push({
581
- amount: BigInt(op.amount.replace(".", "")),
582
- blockNumber: block.sequence,
583
- from: op.from,
584
- timestamp: typedTx.created_at,
585
- to: op.to,
586
- token: op.asset_type === "native" ? null : op.asset_issuer,
587
- tokenType: op.asset_type === "native" ? "NATIVE" : "TOKEN",
588
- transactionGasFee: BigInt(typedTx.fee_charged),
589
- transactionHash: typedTx.hash
590
- });
591
- }
592
- break;
593
- case "SUI":
594
- {
595
- const blockNumber = parseInt(block.sequence, 10);
596
- const blockTimestamp = new Date(parseInt(block.timestamp, 10)).toISOString();
597
- const transactions = block.transactions || [];
598
- for (const tx of transactions){
599
- const transactionHash = tx.digest;
600
- let transactionGasFee = BigInt(0);
601
- if (tx.effects?.gasUsed) {
602
- const gu = tx.effects.gasUsed;
603
- transactionGasFee = BigInt(gu.computationCost) + BigInt(gu.storageCost) - BigInt(gu.storageRebate) + BigInt(gu.nonRefundableStorageFee);
604
- if (transactionGasFee < 0n) transactionGasFee = 0n;
605
- }
606
- const balanceChanges = tx.balanceChanges || [];
607
- for (const bc of balanceChanges){
608
- let rawAmt = BigInt(bc.amount);
609
- if (rawAmt === 0n) continue;
610
- let fromAddr;
611
- let toAddr;
612
- const rawOwner = bc.owner?.AddressOwner || bc.owner?.ObjectOwner || bc.owner?.Shared?.initial_shared_version || "UNKNOWN_OWNER";
613
- if (rawAmt < 0n) {
614
- fromAddr = String(rawOwner);
615
- toAddr = undefined;
616
- rawAmt = -rawAmt;
617
- } else {
618
- fromAddr = undefined;
619
- toAddr = String(rawOwner);
620
- }
621
- transfers.push({
622
- blockNumber: blockNumber,
623
- from: fromAddr,
624
- to: toAddr,
625
- amount: rawAmt,
626
- token: bc.coinType,
627
- tokenType: "NATIVE",
628
- timestamp: blockTimestamp,
629
- transactionHash: transactionHash,
630
- transactionGasFee: transactionGasFee
631
- });
632
- }
633
- }
634
- break;
635
- }
636
- case "TON":
637
- {
638
- const blockNumber = block.seqno;
639
- const blockTimestamp = new Date(block.shards?.[0]?.gen_utime * 1000).toISOString();
640
- for (const shard of block.shards || [])for (const tx of shard.transactions || []){
641
- const transactionLT = tx.transaction_id.lt;
642
- const transactionHash = tx.transaction_id.hash;
643
- const transactionFee = BigInt(tx.fee || "0");
644
- const inVal = BigInt(tx.in_msg?.value || "0");
645
- if (inVal > 0n) transfers.push({
646
- blockNumber: blockNumber,
647
- from: tx.in_msg?.source?.account_address,
648
- to: tx.address?.account_address,
649
- amount: inVal,
650
- token: "TON",
651
- tokenType: "NATIVE",
652
- timestamp: blockTimestamp,
653
- transactionHash: transactionHash,
654
- transactionGasFee: transactionFee
589
+ transactionHash: tx.hash
655
590
  });
656
- for (const outMsg of tx.out_msgs || []){
657
- const outVal = BigInt(outMsg.value || "0");
658
- if (outVal > 0n) transfers.push({
659
- blockNumber: blockNumber,
660
- from: outMsg.source?.account_address,
661
- to: outMsg.destination?.account_address,
662
- amount: outVal,
663
- token: "TON",
664
- tokenType: "NATIVE",
665
- timestamp: blockTimestamp,
666
- transactionHash: transactionHash,
667
- transactionGasFee: transactionFee
668
- });
669
- }
670
- }
671
- break;
672
- }
673
- case "ASTAR":
674
- case "ENJIN":
675
- case "KUSAMA":
676
- case "POLKADOT":
677
- case "BITTENSOR":
678
- {
679
- const typedBlock = block;
680
- const blockNumber = typedBlock.blockNumber;
681
- const timestampExtrinsic = typedBlock.extrinsics.find((ex)=>ex.method === "timestamp.set");
682
- const blockTimestamp = timestampExtrinsic ? new Date(Number(timestampExtrinsic.args[0].toString().replace(/,/g, ""))).toISOString() : new Date().toISOString();
683
- for (const extrinsic of typedBlock.extrinsics)if ([
684
- "balances.transfer",
685
- "balances.transferKeepAlive"
686
- ].includes(extrinsic.method)) {
687
- const from = extrinsic.signer;
688
- const to = extrinsic.args[0]?.Id || "";
689
- const amount = BigInt(extrinsic.args[1].replace(/,/g, ""));
591
+ break;
592
+ case "TransferSingle":
690
593
  transfers.push({
691
- amount: amount,
692
- blockNumber: blockNumber,
693
- from: from,
694
- to: to,
695
- token: null,
696
- tokenType: "NATIVE",
697
- timestamp: blockTimestamp,
698
- transactionGasFee: 0n,
699
- transactionHash: extrinsic.hash
700
- });
701
- }
702
- break;
703
- }
704
- case "FILECOIN":
705
- {
706
- const typedBlock = block;
707
- const blockNumber = typedBlock.Height;
708
- const blockTimestamp = new Date(typedBlock.Blocks[0].Timestamp * 1000).toISOString();
709
- const parentBaseFee = BigInt(typedBlock.Blocks[0].ParentBaseFee);
710
- let receiptIndex = 0;
711
- for (const msgGroup of typedBlock.messages){
712
- const secpkMessages = msgGroup.blockMessages.SecpkMessages || [];
713
- for (const msg of secpkMessages){
714
- const receipt = typedBlock.receipts[receiptIndex++];
715
- const gasUsed = receipt ? BigInt(receipt.GasUsed) : BigInt(0);
716
- const gasFeeCap = BigInt(msg.Message.GasFeeCap);
717
- const gasPremium = BigInt(msg.Message.GasPremium);
718
- const baseFeeBurn = gasUsed * parentBaseFee;
719
- const minerTip = gasUsed * (gasPremium < gasFeeCap - parentBaseFee ? gasPremium : gasFeeCap - parentBaseFee);
720
- const transactionGasFee = baseFeeBurn + minerTip;
721
- transfers.push({
722
- amount: BigInt(msg.Message.Value),
723
- blockNumber: blockNumber,
724
- from: msg.Message.From,
725
- to: msg.Message.To,
726
- token: null,
727
- tokenType: "NATIVE",
728
- timestamp: blockTimestamp,
729
- transactionGasFee: transactionGasFee,
730
- transactionHash: msg.CID["/"]
731
- });
732
- }
733
- }
734
- break;
735
- }
736
- // attempt to introspect data types
737
- default:
738
- // try Cosmos
739
- if (block.block) {
740
- const typedBlock = block;
741
- const blockNumber = Number(typedBlock.block.header.height);
742
- const blockTimestamp = new Date(typedBlock.block.header.time).toISOString();
743
- for (const txRaw of typedBlock.block.data.txs || []){
744
- const decoded = (0, $hgUW1$decodeTxRaw)(new Uint8Array($c18434deda90759d$require$Buffer.from(txRaw, "base64")));
745
- const txHash = (0, $hgUW1$sha256)(new Uint8Array($c18434deda90759d$require$Buffer.from(txRaw, "base64")));
746
- const transactionGasFee = BigInt(decoded.authInfo.fee?.amount?.[0]?.amount || "0");
747
- const registry = new (0, $hgUW1$Registry)((0, $hgUW1$defaultRegistryTypes));
748
- for (const message of decoded.body.messages)if ([
749
- "/ibc.applications.transfer.v1.MsgTransfer",
750
- "/cosmos.bank.v1beta1.MsgSend"
751
- ].includes(message.typeUrl)) {
752
- const decodedMsg = registry.decode(message);
753
- transfers.push({
754
- blockNumber: blockNumber,
755
- from: decodedMsg.sender,
756
- to: decodedMsg.receiver,
757
- amount: BigInt(decodedMsg.token.amount),
758
- token: decodedMsg.token.denom,
759
- tokenType: "NATIVE",
760
- timestamp: blockTimestamp,
761
- transactionHash: txHash.slice(2).toUpperCase(),
762
- transactionGasFee: transactionGasFee
763
- });
764
- }
765
- }
766
- break;
767
- }
768
- // otherwise assume EVM
769
- for (const tx of block.transactions){
770
- if (!tx.receipt) continue;
771
- const timestamp = new Date(block.timestamp * 1000).toISOString();
772
- const transactionGasFee = BigInt(tx.receipt.gasUsed) * BigInt(tx.receipt.effectiveGasPrice);
773
- // track direct ETH transfers
774
- if (!TOKEN_TYPES.length || TOKEN_TYPES.includes("NATIVE")) {
775
- // pull from traces, if available
776
- if (Array.isArray(tx.traces)) for (const trace of tx.traces.filter((t)=>t.action)){
777
- const action = trace.action;
778
- if (!action?.value) continue;
779
- transfers.push({
780
- amount: BigInt(action.value),
781
- blockNumber: tx.blockNumber,
782
- from: action.from?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
783
- index: trace.traceAddress?.join("-"),
784
- timestamp: timestamp,
785
- to: action.to?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
786
- tokenType: "NATIVE",
787
- transactionGasFee: transactionGasFee,
788
- transactionHash: tx.hash
789
- });
790
- }
791
- else if (tx.value?.length >= 3 || /\d+/.test(tx.value)) transfers.push({
792
- amount: BigInt(tx.value),
594
+ amount: txfer.decoded.value,
793
595
  blockNumber: tx.blockNumber,
794
- from: tx.from?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
596
+ from: txfer.decoded.from?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
597
+ index: log.logIndex,
795
598
  timestamp: timestamp,
796
- to: tx.to?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
797
- tokenType: "NATIVE",
599
+ to: txfer.decoded.to?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
600
+ token: log.address.toLowerCase(),
601
+ tokenId: txfer.decoded.id.toString(),
602
+ tokenType: "NFT",
798
603
  transactionGasFee: transactionGasFee,
799
604
  transactionHash: tx.hash
800
605
  });
801
- }
802
- // track ERC20 transfers
803
- if (!TOKEN_TYPES.length || TOKEN_TYPES.includes("TOKEN")) for (const log of tx.receipt.logs){
804
- const txfer = (0, $cfa23334cbdf9391$export$cf548b70626e2eb9)(log, [
805
- "Transfer(address indexed from, address indexed to, uint256 value)"
806
- ]);
807
- if (txfer) transfers.push({
808
- amount: txfer.decoded.value,
606
+ break;
607
+ case "TransferBatch":
608
+ for(let i = 0; i < txfer.decoded.ids.length; i += 1)transfers.push({
609
+ amount: txfer.decoded.values[i],
809
610
  blockNumber: tx.blockNumber,
810
- from: txfer.decoded.from?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
611
+ from: txfer.decoded.from?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
811
612
  index: log.logIndex,
812
613
  timestamp: timestamp,
813
- to: txfer.decoded.to?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
614
+ to: txfer.decoded.to?.toLowerCase() || $5ec62a2088d070a8$var$NULL_ADDRESS,
814
615
  token: log.address.toLowerCase(),
815
- tokenType: "TOKEN",
616
+ tokenId: txfer.decoded.ids[i].toString(),
617
+ tokenType: "NFT",
816
618
  transactionGasFee: transactionGasFee,
817
619
  transactionHash: tx.hash
818
620
  });
819
- }
820
- if (!TOKEN_TYPES.length || TOKEN_TYPES.includes("NFT")) for (const log of tx.receipt.logs){
821
- const txfer = (0, $cfa23334cbdf9391$export$cf548b70626e2eb9)(log, [
822
- "Transfer(address indexed from, address indexed to, uint256 indexed value)",
823
- "TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)",
824
- "TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values)"
825
- ]);
826
- if (!txfer) continue;
827
- switch(txfer.metadata.name){
828
- case "Transfer":
829
- transfers.push({
830
- amount: 1,
831
- blockNumber: tx.blockNumber,
832
- from: txfer.decoded.from?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
833
- index: log.logIndex,
834
- timestamp: timestamp,
835
- to: txfer.decoded.to?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
836
- token: log.address.toLowerCase(),
837
- tokenId: txfer.decoded.value.toString(),
838
- tokenType: "NFT",
839
- transactionGasFee: transactionGasFee,
840
- transactionHash: tx.hash
841
- });
842
- break;
843
- case "TransferSingle":
844
- transfers.push({
845
- amount: txfer.decoded.value,
846
- blockNumber: tx.blockNumber,
847
- from: txfer.decoded.from?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
848
- index: log.logIndex,
849
- timestamp: timestamp,
850
- to: txfer.decoded.to?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
851
- token: log.address.toLowerCase(),
852
- tokenId: txfer.decoded.id.toString(),
853
- tokenType: "NFT",
854
- transactionGasFee: transactionGasFee,
855
- transactionHash: tx.hash
856
- });
857
- break;
858
- case "TransferBatch":
859
- for(let i = 0; i < txfer.decoded.ids.length; i += 1)transfers.push({
860
- amount: txfer.decoded.values[i],
861
- blockNumber: tx.blockNumber,
862
- from: txfer.decoded.from?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
863
- index: log.logIndex,
864
- timestamp: timestamp,
865
- to: txfer.decoded.to?.toLowerCase() || $c18434deda90759d$var$NULL_ADDRESS,
866
- token: log.address.toLowerCase(),
867
- tokenId: txfer.decoded.ids[i].toString(),
868
- tokenType: "NFT",
869
- transactionGasFee: transactionGasFee,
870
- transactionHash: tx.hash
871
- });
872
- break;
873
- }
874
- }
621
+ break;
875
622
  }
876
- if (typeof _ctx.params.contractAddress === "string") _ctx.params.contractAddress = _ctx.params.contractAddress.toLowerCase();
877
- if (typeof _ctx.params.walletAddress === "string") _ctx.params.walletAddress = _ctx.params.walletAddress.toLowerCase();
878
- break;
623
+ }
879
624
  }
880
- const seenTransfers = new Set();
881
- transfers = transfers.filter((txfer)=>{
882
- if (txfer.amount <= BigInt(0)) return false;
883
- if (_ctx.params.contractAddress && _ctx.params.contractAddress !== txfer.token && txfer.token) return false;
884
- if (_ctx.params.walletAddress && ![
885
- txfer.from,
886
- txfer.to
887
- ].includes(_ctx.params.walletAddress)) return false;
888
- const key = `${txfer.transactionHash}-${txfer.from}-${txfer.to}-${txfer.amount}-${txfer.token}`;
889
- if (seenTransfers.has(key)) return false;
890
- seenTransfers.add(key);
891
- return true;
892
- });
625
+ if (typeof _ctx.params.contractAddress === "string") _ctx.params.contractAddress = _ctx.params.contractAddress.toLowerCase();
626
+ if (typeof _ctx.params.walletAddress === "string") _ctx.params.walletAddress = _ctx.params.walletAddress.toLowerCase();
893
627
  return transfers;
894
628
  },
895
629
  tests: [
896
- // APTOS
897
630
  {
898
631
  params: {
899
- network: "APTOS",
900
- walletAddress: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
901
- contractAddress: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0"
632
+ network: "BASE",
633
+ walletAddress: "0x4F80864cD68782144e3736626896990acAe15a11",
634
+ contractAddress: "0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed"
902
635
  },
903
- payload: "https://jiti.indexing.co/networks/aptos/297956660",
904
- output: [
905
- {
906
- amount: 1611839920n,
907
- blockNumber: 297956660,
908
- from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
909
- to: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0",
910
- timestamp: "2025-03-02T21:07:06.002Z",
911
- token: null,
912
- tokenType: "TOKEN",
913
- transactionGasFee: 13n,
914
- transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
915
- },
916
- {
917
- amount: 1502138836n,
918
- blockNumber: 297956660,
919
- from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
920
- to: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
921
- timestamp: "2025-03-02T21:07:06.002Z",
922
- token: null,
923
- tokenType: "TOKEN",
924
- transactionGasFee: 13n,
925
- transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
926
- }
927
- ]
928
- },
929
- // APTOS
930
- {
931
- params: {
932
- network: "APTOS",
933
- contractAddress: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"
934
- },
935
- payload: "https://jiti.indexing.co/networks/aptos/303623631",
936
- output: [
937
- {
938
- amount: 1000060n,
939
- blockNumber: 303623631,
940
- from: "0xa4e7455d27731ab857e9701b1e6ed72591132b909fe6e4fd99b66c1d6318d9e8",
941
- timestamp: "2025-03-14T15:39:49.845Z",
942
- to: "0x9317336bfc9ba6987d40492ddea8d41e11b7c2e473f3556a9c82309d326e79ce",
943
- token: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
944
- tokenType: "TOKEN",
945
- transactionGasFee: 16n,
946
- transactionHash: "0x24b8854bad1f6543b35069eacd6ec40a583ca7fa452b422b04d747d24b65279c"
947
- }
948
- ]
949
- },
950
- // BASE
951
- {
952
- params: {
953
- network: "BASE",
954
- walletAddress: "0x4F80864cD68782144e3736626896990acAe15a11",
955
- contractAddress: "0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed"
956
- },
957
- payload: "https://jiti.indexing.co/networks/base/23507423",
636
+ payload: "https://jiti.indexing.co/networks/base/23507423",
958
637
  output: [
959
638
  {
960
639
  amount: 1000000000000000000000n,
@@ -969,101 +648,52 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
969
648
  transactionHash: "0x69c9b12ccbe2d4f2f1dfc7c4a8557fc099fc5df276424417815acbc79a06fd56"
970
649
  }
971
650
  ]
972
- },
973
- // BITTENSOR
974
- {
975
- params: {
976
- network: "BITTENSOR",
977
- walletAddress: "5G6WmJ4mym9oSQzUF5tr7LvsNMvH5vWtutZM8vMvRv1Wwy6J",
978
- contractAddress: ""
979
- },
980
- payload: "https://jiti.indexing.co/networks/bittensor/2652896",
981
- output: [
982
- {
983
- amount: 2154999850n,
984
- blockNumber: 2652896,
985
- from: "5G6WmJ4mym9oSQzUF5tr7LvsNMvH5vWtutZM8vMvRv1Wwy6J",
986
- to: "5CFwmfLfL1Z6vXU6hgGksh6irDFpcVXaTTNRoqDGMyHrDKK1",
987
- token: null,
988
- tokenType: "NATIVE",
989
- timestamp: "2024-03-28T12:53:36.001Z",
990
- transactionGasFee: 0n,
991
- transactionHash: "0x9ea55a8f40b8d7704f27964155476ab9c744ec2ef2b1f431ad0e05a3a6f3c1ab"
992
- }
993
- ]
994
- },
995
- // CARDANO
996
- {
997
- params: {
998
- network: "CARDANO",
999
- walletAddress: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
1000
- contractAddress: ""
1001
- },
1002
- payload: "https://jiti.indexing.co/networks/cardano/11443286",
1003
- output: [
1004
- {
1005
- amount: 1110000n,
1006
- blockNumber: 11443286,
1007
- from: "addr1qymdv285few5tyqvya86rl97r9e608njs37shfew6l2nn473aw2pcnrcvfwfgg2dnew99m4tjj0apsu7232w2euzwpysndh0h3",
1008
- timestamp: "+057068-01-19T05:23:20.000Z",
1009
- to: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
1010
- token: null,
1011
- tokenType: "NATIVE",
1012
- transactionGasFee: 174257n,
1013
- transactionHash: "261c42ba9124f55d8e169ebb692cd3759d796a54369acb316ee449b546e79309"
1014
- }
1015
- ]
1016
- },
1017
- // COSMOS
1018
- {
1019
- params: {
1020
- network: "COSMOS",
1021
- walletAddress: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1022
- contractAddress: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013"
1023
- },
1024
- payload: "https://jiti.indexing.co/networks/cosmos/24419691",
1025
- output: [
1026
- {
1027
- blockNumber: 24419691,
1028
- from: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1029
- to: "noble1x4qvmtcfc02pklttfgxzdccxcsyzklrx4073uv",
1030
- amount: 500000n,
1031
- token: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013",
1032
- tokenType: "NATIVE",
1033
- timestamp: "2025-02-14T21:48:22.809Z",
1034
- transactionHash: "963D4D7BB59C1280F58A7ECA2F1934E2AA005109A989193C815C7B98EDCD7445",
1035
- transactionGasFee: 4860n
1036
- }
1037
- ]
1038
- },
1039
- // DOGECOIN
1040
- {
1041
- params: {
1042
- network: "DOGECOIN",
1043
- walletAddress: "DMqRVLrhbam3Kcfddpxd6EYvEBbpi3bEpP",
1044
- contractAddress: ""
1045
- },
1046
- payload: "https://jiti.indexing.co/networks/dogecoin/1000075",
1047
- output: [
1048
- {
1049
- amount: 1008521000000n,
1050
- blockNumber: 1000075,
1051
- from: "DMqRVLrhbam3Kcfddpxd6EYvEBbpi3bEpP",
1052
- to: "DMqRVLrhbam3Kcfddpxd6EYvEBbpi3bEpP",
651
+ }
652
+ ]
653
+ };
654
+
655
+
656
+ const $548ae36ea3681b01$export$d7ac970e8e789607 = {
657
+ match: (block)=>[
658
+ "FILECOIN"
659
+ ].includes(block._network),
660
+ transform (block) {
661
+ let transfers = [];
662
+ const typedBlock = block;
663
+ const blockNumber = typedBlock.Height;
664
+ const blockTimestamp = new Date(typedBlock.Blocks[0].Timestamp * 1000).toISOString();
665
+ const parentBaseFee = BigInt(typedBlock.Blocks[0].ParentBaseFee);
666
+ let receiptIndex = 0;
667
+ for (const msgGroup of typedBlock.messages){
668
+ const secpkMessages = msgGroup.blockMessages.SecpkMessages || [];
669
+ for (const msg of secpkMessages){
670
+ const receipt = typedBlock.receipts[receiptIndex++];
671
+ const gasUsed = receipt ? BigInt(receipt.GasUsed) : BigInt(0);
672
+ const gasFeeCap = BigInt(msg.Message.GasFeeCap);
673
+ const gasPremium = BigInt(msg.Message.GasPremium);
674
+ const baseFeeBurn = gasUsed * parentBaseFee;
675
+ const minerTip = gasUsed * (gasPremium < gasFeeCap - parentBaseFee ? gasPremium : gasFeeCap - parentBaseFee);
676
+ const transactionGasFee = baseFeeBurn + minerTip;
677
+ transfers.push({
678
+ amount: BigInt(msg.Message.Value),
679
+ blockNumber: blockNumber,
680
+ from: msg.Message.From,
681
+ to: msg.Message.To,
1053
682
  token: null,
1054
683
  tokenType: "NATIVE",
1055
- transactionGasFee: 0n,
1056
- transactionHash: "9873fe46ab29f61cefdec498b691af68e0ad29a7599c94f42d2d4e9a5d461dbe",
1057
- timestamp: "2015-12-13T19:59:52.000Z"
1058
- }
1059
- ]
1060
- },
1061
- // FILECOIN
684
+ timestamp: blockTimestamp,
685
+ transactionGasFee: transactionGasFee,
686
+ transactionHash: msg.CID["/"]
687
+ });
688
+ }
689
+ }
690
+ return transfers;
691
+ },
692
+ tests: [
1062
693
  {
1063
694
  params: {
1064
695
  network: "FILECOIN",
1065
- walletAddress: "f1e3aa3z6gkaqxxwmbbna5gf2frggswwjaeavx7bq",
1066
- contractAddress: "f1bqdligg7ipuiizvmdn7ijobhbkwaieh6z6lah5y"
696
+ walletAddress: "f1e3aa3z6gkaqxxwmbbna5gf2frggswwjaeavx7bq"
1067
697
  },
1068
698
  payload: "https://jiti.indexing.co/networks/filecoin/4818438",
1069
699
  output: [
@@ -1079,8 +709,47 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
1079
709
  transactionHash: "bafy2bzacecxud3tayyq3caagjej5srufcx5fufjuqkz3ltgfty27wdsrmqeew"
1080
710
  }
1081
711
  ]
1082
- },
1083
- // RIPPLE
712
+ }
713
+ ]
714
+ };
715
+
716
+
717
+ const $07b3982e2fc4c8b2$export$400f08bfae9ee97f = {
718
+ match: (block)=>[
719
+ "RIPPLE"
720
+ ].includes(block._network),
721
+ transform (block) {
722
+ let transfers = [];
723
+ if (!Array.isArray(block.transactions)) return [];
724
+ for (const rawTx of block.transactions){
725
+ const typedTx = rawTx;
726
+ if (typedTx.TransactionType !== "Payment") continue;
727
+ const deliveredOrAmount = typedTx.metaData?.delivered_amount ?? typedTx.Amount ?? "0";
728
+ let tokenSymbol = "XRP";
729
+ let tokenType = "NATIVE";
730
+ let parsedAmount;
731
+ if (typeof deliveredOrAmount === "object") {
732
+ tokenSymbol = deliveredOrAmount.currency?.toUpperCase() ?? "UNKNOWN";
733
+ tokenType = "TOKEN";
734
+ const floatVal = parseFloat(deliveredOrAmount.value);
735
+ const smallestUnit = Math.round(floatVal * 1000000);
736
+ parsedAmount = BigInt(smallestUnit);
737
+ } else parsedAmount = BigInt(String(deliveredOrAmount));
738
+ transfers.push({
739
+ amount: parsedAmount,
740
+ blockNumber: parseInt(block.ledger_index, 10),
741
+ from: typedTx.Account ?? "UNKNOWN",
742
+ timestamp: block.close_time_iso ? block.close_time_iso : null,
743
+ to: typedTx.Destination ?? "UNKNOWN",
744
+ token: tokenSymbol,
745
+ tokenType: tokenType,
746
+ transactionGasFee: BigInt(typedTx.Fee ?? "0"),
747
+ transactionHash: typedTx.hash ?? ""
748
+ });
749
+ }
750
+ return transfers;
751
+ },
752
+ tests: [
1084
753
  {
1085
754
  params: {
1086
755
  network: "RIPPLE",
@@ -1101,52 +770,59 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
1101
770
  transactionHash: "03564E6109261CDE73FCC5062C2A0A70F365CB1A0F9408C065B60EC3E94E4DBF"
1102
771
  }
1103
772
  ]
1104
- },
1105
- // STELLAR
1106
- {
1107
- params: {
1108
- network: "STELLAR",
1109
- walletAddress: "GA5KLTNAWV27IOTBX5PKUOMVWFMLX4X7CPMQJ4QLR3G266MMVL7NMA4X",
1110
- contractAddress: "GC4Z2TDXU4GXVLHOS5P5SU6HKBCP7NKN4TJ5ZGTVRBW7MCBZTU7SNUSA"
1111
- },
1112
- payload: "https://jiti.indexing.co/networks/stellar/51720546",
1113
- output: [
1114
- {
1115
- amount: 150000n,
1116
- blockNumber: 51720546,
1117
- from: "GA5KLTNAWV27IOTBX5PKUOMVWFMLX4X7CPMQJ4QLR3G266MMVL7NMA4X",
1118
- timestamp: "2024-05-18T04:41:39Z",
1119
- to: "GC4Z2TDXU4GXVLHOS5P5SU6HKBCP7NKN4TJ5ZGTVRBW7MCBZTU7SNUSA",
1120
- token: "GC4Z2TDXU4GXVLHOS5P5SU6HKBCP7NKN4TJ5ZGTVRBW7MCBZTU7SNUSA",
1121
- tokenType: "TOKEN",
1122
- transactionGasFee: 100n,
1123
- transactionHash: "4fb2441210cbe87f5003abdfa86f03bafa54f789ed041feccbda0bd054297c4d"
773
+ }
774
+ ]
775
+ };
776
+
777
+
778
+ const $f9f6601c9222cc8e$export$722698bc663d0ac0 = {
779
+ match: (block)=>[
780
+ "SUI"
781
+ ].includes(block._network),
782
+ transform (block) {
783
+ let transfers = [];
784
+ const blockNumber = parseInt(block.sequence, 10);
785
+ const blockTimestamp = new Date(parseInt(block.timestamp, 10)).toISOString();
786
+ const transactions = block.transactions || [];
787
+ for (const tx of transactions){
788
+ const transactionHash = tx.digest;
789
+ let transactionGasFee = BigInt(0);
790
+ if (tx.effects?.gasUsed) {
791
+ const gu = tx.effects.gasUsed;
792
+ transactionGasFee = BigInt(gu.computationCost) + BigInt(gu.storageCost) - BigInt(gu.storageRebate) + BigInt(gu.nonRefundableStorageFee);
793
+ if (transactionGasFee < 0n) transactionGasFee = 0n;
794
+ }
795
+ const balanceChanges = tx.balanceChanges || [];
796
+ for (const bc of balanceChanges){
797
+ let rawAmt = BigInt(bc.amount);
798
+ if (rawAmt === 0n) continue;
799
+ let fromAddr;
800
+ let toAddr;
801
+ const rawOwner = bc.owner?.AddressOwner || bc.owner?.ObjectOwner || bc.owner?.Shared?.initial_shared_version || "UNKNOWN_OWNER";
802
+ if (rawAmt < 0n) {
803
+ fromAddr = String(rawOwner);
804
+ toAddr = undefined;
805
+ rawAmt = -rawAmt;
806
+ } else {
807
+ fromAddr = undefined;
808
+ toAddr = String(rawOwner);
1124
809
  }
1125
- ]
1126
- },
1127
- // STARKNET
1128
- {
1129
- params: {
1130
- network: "STARKNET",
1131
- walletAddress: "0x309e6b209031362268d62d646a067365e6f6d6eb7f571b5212cbdfd5f26fe54",
1132
- contractAddress: ""
1133
- },
1134
- payload: "https://jiti.indexing.co/networks/starknet/1149460",
1135
- output: [
1136
- {
1137
- amount: 0x1c286f74458fc6n,
1138
- blockNumber: 1149460,
1139
- from: "0x309e6b209031362268d62d646a067365e6f6d6eb7f571b5212cbdfd5f26fe54",
1140
- timestamp: "2025-02-13T17:36:52.000Z",
1141
- to: "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
1142
- token: null,
810
+ transfers.push({
811
+ blockNumber: blockNumber,
812
+ from: fromAddr,
813
+ to: toAddr,
814
+ amount: rawAmt,
815
+ token: bc.coinType,
1143
816
  tokenType: "NATIVE",
1144
- transactionGasFee: 7925758505095110n,
1145
- transactionHash: "0x707203dba31f442ae9a5477e6a8906f3676effa0f1d3bb19cbbc14e1ddfe21"
1146
- }
1147
- ]
1148
- },
1149
- // SUI
817
+ timestamp: blockTimestamp,
818
+ transactionHash: transactionHash,
819
+ transactionGasFee: transactionGasFee
820
+ });
821
+ }
822
+ }
823
+ return transfers;
824
+ },
825
+ tests: [
1150
826
  {
1151
827
  params: {
1152
828
  network: "SUI",
@@ -1200,30 +876,123 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
1200
876
  transactionGasFee: 5408192n
1201
877
  }
1202
878
  ]
1203
- },
1204
- // TON
1205
- {
1206
- params: {
1207
- network: "TON",
1208
- walletAddress: "EQAFukUyzmHjUvOYDOjNE-wbZFFl2FWas1rFJoh8IiTsWD40",
1209
- contractAddress: ""
1210
- },
1211
- payload: "https://jiti.indexing.co/networks/ton/44919328",
1212
- output: [
1213
- {
1214
- blockNumber: 44919328,
1215
- from: "EQAFukUyzmHjUvOYDOjNE-wbZFFl2FWas1rFJoh8IiTsWD40",
1216
- to: "EQCFTFAHOU3vFt2NiZhRD5dwuS0k7GS59vIg3WfCKwfaQGW2",
1217
- amount: 10000000n,
1218
- token: "TON",
1219
- tokenType: "NATIVE",
1220
- timestamp: "2025-02-13T23:10:18.000Z",
1221
- transactionHash: "Vh5cWr2uvCsdhoouBQ+EiUcF54os9oqvh8A/62EroQc=",
1222
- transactionGasFee: 2355233n
879
+ }
880
+ ]
881
+ };
882
+
883
+
884
+ const $f0bdc73ab4ea9846$export$1f0fe79deb1b813b = {
885
+ match: (block)=>[
886
+ "SOLANA"
887
+ ].includes(block._network),
888
+ transform (block) {
889
+ let transfers = [];
890
+ for (const tx of block.transactions){
891
+ const solanaTx = tx;
892
+ const txHash = solanaTx.transaction.signatures[0];
893
+ const timestamp = block.blockTime ? new Date(block.blockTime * 1000).toISOString() : null;
894
+ const allAccounts = solanaTx.transaction.message.accountKeys.concat(solanaTx.meta.loadedAddresses.writable).concat(solanaTx.meta.loadedAddresses.readonly);
895
+ let txFee = BigInt(solanaTx.meta.fee);
896
+ if (txFee < BigInt(10)) txFee = txFee * BigInt(Math.pow(10, 9));
897
+ const transfersByKey = {};
898
+ for (const post of solanaTx.meta.postTokenBalances){
899
+ let matched = false;
900
+ for (const pre of solanaTx.meta.preTokenBalances)if (post.mint === pre.mint && post.owner === pre.owner) {
901
+ let diff = BigInt(post.uiTokenAmount.amount) - BigInt(pre.uiTokenAmount.amount);
902
+ if (diff === BigInt(0)) {
903
+ matched = true;
904
+ continue;
905
+ }
906
+ const isNegDiff = diff < 0;
907
+ if (diff < 0) diff = -diff;
908
+ const key = `${post.mint}-${diff.toString()}`;
909
+ const txfer = {
910
+ amount: diff,
911
+ blockNumber: block.blockHeight,
912
+ from: pre.owner,
913
+ timestamp: timestamp,
914
+ to: post.owner,
915
+ transactionGasFee: txFee,
916
+ transactionHash: txHash,
917
+ token: post.mint,
918
+ tokenType: "TOKEN"
919
+ };
920
+ if (isNegDiff) delete txfer.to;
921
+ else delete txfer.from;
922
+ transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
923
+ matched = true;
1223
924
  }
1224
- ]
1225
- },
1226
- // SOLANA
925
+ if (!matched) {
926
+ let diff = BigInt(post.uiTokenAmount.amount);
927
+ const isNegDiff = diff < 0;
928
+ if (diff < 0) diff = -diff;
929
+ const key = `${post.mint}-${diff.toString()}`;
930
+ const txfer = {
931
+ amount: diff,
932
+ blockNumber: block.blockHeight,
933
+ from: null,
934
+ timestamp: timestamp,
935
+ to: post.owner,
936
+ token: post.mint,
937
+ tokenType: "TOKEN",
938
+ transactionGasFee: txFee,
939
+ transactionHash: txHash
940
+ };
941
+ if (isNegDiff) delete txfer.to;
942
+ else delete txfer.from;
943
+ transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
944
+ }
945
+ }
946
+ for(let i = 1; i < solanaTx.meta.postBalances.length; i += 1){
947
+ const post = solanaTx.meta.postBalances[i];
948
+ const pre = solanaTx.meta.preBalances[i];
949
+ if (post !== undefined && pre !== undefined && post !== pre) {
950
+ let diff = BigInt(post) - BigInt(pre);
951
+ if (diff < 0) diff = -diff;
952
+ const key = `null-${diff.toString()}`;
953
+ const txfer = {
954
+ amount: diff,
955
+ blockNumber: block.blockHeight,
956
+ from: post > pre ? typeof allAccounts[0] === "string" ? allAccounts[0] : allAccounts[0]?.pubkey : typeof allAccounts[i] === "string" ? allAccounts[i] : allAccounts[i]?.pubkey,
957
+ timestamp: timestamp,
958
+ to: typeof allAccounts[i] === "string" ? allAccounts[i] : allAccounts[i]?.pubkey?.toString(),
959
+ token: null,
960
+ tokenType: "NATIVE",
961
+ transactionGasFee: txFee,
962
+ transactionHash: txHash
963
+ };
964
+ if (post > pre) {
965
+ if (transfersByKey[key]) delete txfer.from;
966
+ } else delete txfer.to;
967
+ transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
968
+ }
969
+ }
970
+ const unmatchedFrom = {};
971
+ const unmatchedTo = {};
972
+ for(const key in transfersByKey){
973
+ const txfer = transfersByKey[key];
974
+ if (!txfer.from) {
975
+ if (!unmatchedFrom[txfer.token]) unmatchedFrom[txfer.token] = [];
976
+ unmatchedFrom[txfer.token].push(txfer);
977
+ delete transfersByKey[key];
978
+ } else if (!txfer.to) {
979
+ if (!unmatchedTo[txfer.token]) unmatchedTo[txfer.token] = [];
980
+ unmatchedTo[txfer.token].push(txfer);
981
+ delete transfersByKey[key];
982
+ }
983
+ }
984
+ for(const token in unmatchedFrom)if (unmatchedTo[token]?.length && unmatchedTo[token].reduce((a, b)=>a + BigInt(b.amount), BigInt(0)) - unmatchedFrom[token].reduce((a, b)=>a + BigInt(b.amount), BigInt(0)) === BigInt(0)) {
985
+ unmatchedTo[token].sort((a, b)=>a.amount > b.amount ? 1 : -1);
986
+ unmatchedFrom[token].forEach((um)=>{
987
+ um.from = unmatchedTo[token][0].from;
988
+ transfersByKey[`${token}-${um.amount.toString()}`] = um;
989
+ });
990
+ }
991
+ transfers.push(...Object.values(transfersByKey));
992
+ }
993
+ return transfers;
994
+ },
995
+ tests: [
1227
996
  {
1228
997
  params: {
1229
998
  network: "SOLANA",
@@ -1297,15 +1066,478 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
1297
1066
  tokenType: "TOKEN"
1298
1067
  }
1299
1068
  ]
1069
+ },
1070
+ {
1071
+ params: {
1072
+ network: "SOLANA",
1073
+ walletAddress: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz"
1074
+ },
1075
+ payload: "https://jiti.indexing.co/networks/solana/332450156",
1076
+ output: [
1077
+ {
1078
+ amount: 402062750n,
1079
+ blockNumber: 310691098,
1080
+ from: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1081
+ timestamp: "2025-04-10T02:29:35.000Z",
1082
+ to: "5yY5BGRgwa5rxvYPpMV9EkDpwp6w1vNNXUNzUCtMoFfR",
1083
+ token: null,
1084
+ tokenType: "NATIVE",
1085
+ transactionGasFee: 80001n,
1086
+ transactionHash: "32T7ANVqz1sHBoKhfk3omrRqwDCJFYMi6TfuAwyqHPCZPCihdWTU9t9i5D6tGwuytWRwRqnEXksMPMWbFbfBzVUk"
1087
+ },
1088
+ {
1089
+ amount: 97937250n,
1090
+ blockNumber: 310691098,
1091
+ from: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1092
+ timestamp: "2025-04-10T02:29:35.000Z",
1093
+ to: "9zF2ZWTjnk6UkyWRxNtqy9UHims9u7LSaHGyhA5PwDSx",
1094
+ token: null,
1095
+ tokenType: "NATIVE",
1096
+ transactionGasFee: 80001n,
1097
+ transactionHash: "32T7ANVqz1sHBoKhfk3omrRqwDCJFYMi6TfuAwyqHPCZPCihdWTU9t9i5D6tGwuytWRwRqnEXksMPMWbFbfBzVUk"
1098
+ },
1099
+ {
1100
+ amount: 19796403663n,
1101
+ blockNumber: 310691098,
1102
+ timestamp: "2025-04-10T02:29:35.000Z",
1103
+ to: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1104
+ transactionGasFee: 80001n,
1105
+ transactionHash: "32T7ANVqz1sHBoKhfk3omrRqwDCJFYMi6TfuAwyqHPCZPCihdWTU9t9i5D6tGwuytWRwRqnEXksMPMWbFbfBzVUk",
1106
+ token: "CniPCE4b3s8gSUPhUiyMjXnytrEqUrMfSsnbBjLCpump",
1107
+ tokenType: "TOKEN",
1108
+ from: "4acL7mD2J6GYJy2g3iVTvfpmHCQSZ1rb8DBuupjcVzHJ"
1109
+ }
1110
+ ]
1111
+ },
1112
+ {
1113
+ params: {
1114
+ network: "SOLANA",
1115
+ walletAddress: "J1dHwpKBs8Jo4n7jWEJWwMGNH2DJQnApBFPnnYXg74v7",
1116
+ contractAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
1117
+ },
1118
+ payload: "https://jiti.indexing.co/networks/solana/332822080",
1119
+ output: [
1120
+ {
1121
+ amount: 2500000n,
1122
+ blockNumber: 311062104,
1123
+ from: "J1dHwpKBs8Jo4n7jWEJWwMGNH2DJQnApBFPnnYXg74v7",
1124
+ timestamp: "2025-04-11T19:36:39.000Z",
1125
+ to: "3LoAYHuSd7Gh8d7RTFnhvYtiTiefdZ5ByamU42vkzd76",
1126
+ token: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
1127
+ tokenType: "TOKEN",
1128
+ transactionGasFee: 350362n,
1129
+ transactionHash: "xKTWvnhSRErcHCMozRMEue4MriNr1Any6LiaQzXrR7imZ1MpZxRqbyv9LLg4JQoDq4oJZpDqPmzxLCtMCkgj2hn"
1130
+ },
1131
+ {
1132
+ amount: 1373625000n,
1133
+ blockNumber: 311062104,
1134
+ from: "J1dHwpKBs8Jo4n7jWEJWwMGNH2DJQnApBFPnnYXg74v7",
1135
+ timestamp: "2025-04-11T19:36:39.000Z",
1136
+ to: "5guD4Uz462GT4Y4gEuqyGsHZ59JGxFN4a3rF6KWguMcJ",
1137
+ token: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
1138
+ tokenType: "TOKEN",
1139
+ transactionGasFee: 350362n,
1140
+ transactionHash: "xKTWvnhSRErcHCMozRMEue4MriNr1Any6LiaQzXrR7imZ1MpZxRqbyv9LLg4JQoDq4oJZpDqPmzxLCtMCkgj2hn"
1141
+ },
1142
+ {
1143
+ amount: 1123875000n,
1144
+ blockNumber: 311062104,
1145
+ from: "J1dHwpKBs8Jo4n7jWEJWwMGNH2DJQnApBFPnnYXg74v7",
1146
+ timestamp: "2025-04-11T19:36:39.000Z",
1147
+ to: "DH4xmaWDnTzKXehVaPSNy9tMKJxnYL5Mo5U3oTHFtNYJ",
1148
+ token: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
1149
+ tokenType: "TOKEN",
1150
+ transactionGasFee: 350362n,
1151
+ transactionHash: "xKTWvnhSRErcHCMozRMEue4MriNr1Any6LiaQzXrR7imZ1MpZxRqbyv9LLg4JQoDq4oJZpDqPmzxLCtMCkgj2hn"
1152
+ }
1153
+ ]
1154
+ }
1155
+ ]
1156
+ };
1157
+
1158
+
1159
+ const $f7da547a9d6b4fc0$export$36783fc9701281c6 = {
1160
+ match: (block)=>[
1161
+ "STARKNET"
1162
+ ].includes(block._network),
1163
+ transform (block) {
1164
+ let transfers = [];
1165
+ if (!Array.isArray(block.transactions)) return [];
1166
+ for (const tx of block.transactions){
1167
+ const typedTx = tx;
1168
+ const timestamp = block.timestamp ? new Date(block.timestamp * 1000).toISOString() : null;
1169
+ let transactionGasFee = BigInt(0);
1170
+ if (typedTx?.receipt?.actual_fee?.amount) transactionGasFee = BigInt(typedTx.receipt.actual_fee.amount);
1171
+ const transactionHash = typedTx.transaction_hash;
1172
+ if (!typedTx.receipt?.events) continue;
1173
+ for (const event of typedTx.receipt.events){
1174
+ if (!event.keys.includes("0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9")) continue;
1175
+ if (event.data.length < 3) continue;
1176
+ const [from, to, amountHex] = event.data;
1177
+ const amount = BigInt(amountHex);
1178
+ transfers.push({
1179
+ amount: amount,
1180
+ blockNumber: block.block_number,
1181
+ from: from,
1182
+ timestamp: timestamp,
1183
+ to: to,
1184
+ token: null,
1185
+ tokenType: "NATIVE",
1186
+ transactionGasFee: transactionGasFee,
1187
+ transactionHash: transactionHash
1188
+ });
1189
+ }
1190
+ }
1191
+ return transfers;
1192
+ },
1193
+ tests: [
1194
+ {
1195
+ params: {
1196
+ network: "STARKNET",
1197
+ walletAddress: "0x309e6b209031362268d62d646a067365e6f6d6eb7f571b5212cbdfd5f26fe54",
1198
+ contractAddress: ""
1199
+ },
1200
+ payload: "https://jiti.indexing.co/networks/starknet/1149460",
1201
+ output: [
1202
+ {
1203
+ amount: 0x1c286f74458fc6n,
1204
+ blockNumber: 1149460,
1205
+ from: "0x309e6b209031362268d62d646a067365e6f6d6eb7f571b5212cbdfd5f26fe54",
1206
+ timestamp: "2025-02-13T17:36:52.000Z",
1207
+ to: "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
1208
+ token: null,
1209
+ tokenType: "NATIVE",
1210
+ transactionGasFee: 7925758505095110n,
1211
+ transactionHash: "0x707203dba31f442ae9a5477e6a8906f3676effa0f1d3bb19cbbc14e1ddfe21"
1212
+ }
1213
+ ]
1214
+ }
1215
+ ]
1216
+ };
1217
+
1218
+
1219
+ const $725699ccb951d76d$export$681f497010b17679 = {
1220
+ match: (block)=>[
1221
+ "STELLAR"
1222
+ ].includes(block._network),
1223
+ transform (block) {
1224
+ let transfers = [];
1225
+ for (const tx of block.transactions){
1226
+ const typedTx = tx;
1227
+ for (const op of typedTx.operations)if (op.type === "payment") transfers.push({
1228
+ amount: BigInt(op.amount.replace(".", "")),
1229
+ blockNumber: block.sequence,
1230
+ from: op.from,
1231
+ timestamp: typedTx.created_at,
1232
+ to: op.to,
1233
+ token: op.asset_type === "native" ? null : op.asset_issuer,
1234
+ tokenType: op.asset_type === "native" ? "NATIVE" : "TOKEN",
1235
+ transactionGasFee: BigInt(typedTx.fee_charged),
1236
+ transactionHash: typedTx.hash
1237
+ });
1238
+ }
1239
+ return transfers;
1240
+ },
1241
+ tests: [
1242
+ {
1243
+ params: {
1244
+ network: "STELLAR",
1245
+ walletAddress: "GA5KLTNAWV27IOTBX5PKUOMVWFMLX4X7CPMQJ4QLR3G266MMVL7NMA4X",
1246
+ contractAddress: "GC4Z2TDXU4GXVLHOS5P5SU6HKBCP7NKN4TJ5ZGTVRBW7MCBZTU7SNUSA"
1247
+ },
1248
+ payload: "https://jiti.indexing.co/networks/stellar/51720546",
1249
+ output: [
1250
+ {
1251
+ amount: 150000n,
1252
+ blockNumber: 51720546,
1253
+ from: "GA5KLTNAWV27IOTBX5PKUOMVWFMLX4X7CPMQJ4QLR3G266MMVL7NMA4X",
1254
+ timestamp: "2024-05-18T04:41:39Z",
1255
+ to: "GC4Z2TDXU4GXVLHOS5P5SU6HKBCP7NKN4TJ5ZGTVRBW7MCBZTU7SNUSA",
1256
+ token: "GC4Z2TDXU4GXVLHOS5P5SU6HKBCP7NKN4TJ5ZGTVRBW7MCBZTU7SNUSA",
1257
+ tokenType: "TOKEN",
1258
+ transactionGasFee: 100n,
1259
+ transactionHash: "4fb2441210cbe87f5003abdfa86f03bafa54f789ed041feccbda0bd054297c4d"
1260
+ }
1261
+ ]
1262
+ }
1263
+ ]
1264
+ };
1265
+
1266
+
1267
+ const $13c3ff41f568666f$export$bc6c7ab7e0727dd7 = {
1268
+ match: (block)=>[
1269
+ "ASTAR",
1270
+ "ENJIN",
1271
+ "KUSAMA",
1272
+ "POLKADOT",
1273
+ "BITTENSOR"
1274
+ ].includes(block._network),
1275
+ transform (block) {
1276
+ let transfers = [];
1277
+ const typedBlock = block;
1278
+ const blockNumber = typedBlock.blockNumber;
1279
+ const timestampExtrinsic = typedBlock.extrinsics.find((ex)=>ex.method === "timestamp.set");
1280
+ const blockTimestamp = timestampExtrinsic ? new Date(Number(timestampExtrinsic.args[0].toString().replace(/,/g, ""))).toISOString() : new Date().toISOString();
1281
+ for (const extrinsic of typedBlock.extrinsics)if ([
1282
+ "balances.transfer",
1283
+ "balances.transferKeepAlive"
1284
+ ].includes(extrinsic.method)) {
1285
+ const from = extrinsic.signer;
1286
+ const to = extrinsic.args[0]?.Id || "";
1287
+ const amount = BigInt(extrinsic.args[1].replace(/,/g, ""));
1288
+ transfers.push({
1289
+ amount: amount,
1290
+ blockNumber: blockNumber,
1291
+ from: from,
1292
+ to: to,
1293
+ token: null,
1294
+ tokenType: "NATIVE",
1295
+ timestamp: blockTimestamp,
1296
+ transactionGasFee: 0n,
1297
+ transactionHash: extrinsic.hash
1298
+ });
1299
+ }
1300
+ return transfers;
1301
+ },
1302
+ tests: [
1303
+ {
1304
+ params: {
1305
+ network: "BITTENSOR",
1306
+ walletAddress: "5G6WmJ4mym9oSQzUF5tr7LvsNMvH5vWtutZM8vMvRv1Wwy6J",
1307
+ contractAddress: ""
1308
+ },
1309
+ payload: "https://jiti.indexing.co/networks/bittensor/2652896",
1310
+ output: [
1311
+ {
1312
+ amount: 2154999850n,
1313
+ blockNumber: 2652896,
1314
+ from: "5G6WmJ4mym9oSQzUF5tr7LvsNMvH5vWtutZM8vMvRv1Wwy6J",
1315
+ to: "5CFwmfLfL1Z6vXU6hgGksh6irDFpcVXaTTNRoqDGMyHrDKK1",
1316
+ token: null,
1317
+ tokenType: "NATIVE",
1318
+ timestamp: "2024-03-28T12:53:36.001Z",
1319
+ transactionGasFee: 0n,
1320
+ transactionHash: "0x9ea55a8f40b8d7704f27964155476ab9c744ec2ef2b1f431ad0e05a3a6f3c1ab"
1321
+ }
1322
+ ]
1300
1323
  }
1301
1324
  ]
1302
1325
  };
1303
- var $c18434deda90759d$export$2e2bcd8739ae039 = $c18434deda90759d$var$tokenTransfersTemplate;
1326
+
1327
+
1328
+ const $e97546fe39f2692a$export$608f3f42810b9879 = {
1329
+ match: (block)=>[
1330
+ "TON"
1331
+ ].includes(block._network),
1332
+ transform (block) {
1333
+ let transfers = [];
1334
+ const blockNumber = block.seqno;
1335
+ const blockTimestamp = new Date(block.shards?.[0]?.gen_utime * 1000).toISOString();
1336
+ for (const shard of block.shards || [])for (const tx of shard.transactions || []){
1337
+ const transactionLT = tx.transaction_id.lt;
1338
+ const transactionHash = tx.transaction_id.hash;
1339
+ const transactionFee = BigInt(tx.fee || "0");
1340
+ const inVal = BigInt(tx.in_msg?.value || "0");
1341
+ if (inVal > 0n) transfers.push({
1342
+ blockNumber: blockNumber,
1343
+ from: tx.in_msg?.source?.account_address,
1344
+ to: tx.address?.account_address,
1345
+ amount: inVal,
1346
+ token: "TON",
1347
+ tokenType: "NATIVE",
1348
+ timestamp: blockTimestamp,
1349
+ transactionHash: transactionHash,
1350
+ transactionGasFee: transactionFee
1351
+ });
1352
+ for (const outMsg of tx.out_msgs || []){
1353
+ const outVal = BigInt(outMsg.value || "0");
1354
+ if (outVal > 0n) transfers.push({
1355
+ blockNumber: blockNumber,
1356
+ from: outMsg.source?.account_address,
1357
+ to: outMsg.destination?.account_address,
1358
+ amount: outVal,
1359
+ token: "TON",
1360
+ tokenType: "NATIVE",
1361
+ timestamp: blockTimestamp,
1362
+ transactionHash: transactionHash,
1363
+ transactionGasFee: transactionFee
1364
+ });
1365
+ }
1366
+ }
1367
+ return transfers;
1368
+ },
1369
+ tests: [
1370
+ {
1371
+ params: {
1372
+ network: "TON",
1373
+ walletAddress: "EQAFukUyzmHjUvOYDOjNE-wbZFFl2FWas1rFJoh8IiTsWD40",
1374
+ contractAddress: ""
1375
+ },
1376
+ payload: "https://jiti.indexing.co/networks/ton/44919328",
1377
+ output: [
1378
+ {
1379
+ blockNumber: 44919328,
1380
+ from: "EQAFukUyzmHjUvOYDOjNE-wbZFFl2FWas1rFJoh8IiTsWD40",
1381
+ to: "EQCFTFAHOU3vFt2NiZhRD5dwuS0k7GS59vIg3WfCKwfaQGW2",
1382
+ amount: 10000000n,
1383
+ token: "TON",
1384
+ tokenType: "NATIVE",
1385
+ timestamp: "2025-02-13T23:10:18.000Z",
1386
+ transactionHash: "Vh5cWr2uvCsdhoouBQ+EiUcF54os9oqvh8A/62EroQc=",
1387
+ transactionGasFee: 2355233n
1388
+ }
1389
+ ]
1390
+ }
1391
+ ]
1392
+ };
1393
+
1394
+
1395
+ const $532fac82d96b89f2$export$4f5322cf4718bd30 = {
1396
+ match: (block)=>[
1397
+ "BITCOIN",
1398
+ "BITCOIN_TESTNET",
1399
+ "LITECOIN",
1400
+ "DOGECOIN"
1401
+ ].includes(block._network),
1402
+ transform (block) {
1403
+ let transfers = [];
1404
+ for (const tx of block.tx){
1405
+ const timestamp = tx.time ? new Date(tx.time * 1000).toISOString() : null;
1406
+ const vin = tx.vin[0];
1407
+ const vout = tx.vout;
1408
+ const fromVout = Math.min(vin.vout || 1000, vout.length - 1);
1409
+ const fromAddress = vin.prevout?.scriptPubKey?.address || vout[fromVout]?.scriptPubKey?.address || vout[fromVout]?.scriptPubKey?.addresses?.[0];
1410
+ if (!fromAddress) continue;
1411
+ for (const v of vout)transfers.push({
1412
+ amount: BigInt(Math.round(v.value * Math.pow(10, 8))),
1413
+ blockNumber: block.height,
1414
+ from: fromAddress,
1415
+ timestamp: timestamp,
1416
+ to: v.scriptPubKey.address || v.scriptPubKey.addresses?.[0],
1417
+ transactionGasFee: BigInt(Math.round((tx.fee || 0) * Math.pow(10, 8))),
1418
+ transactionHash: tx.txid,
1419
+ token: null,
1420
+ tokenType: "NATIVE"
1421
+ });
1422
+ }
1423
+ return transfers;
1424
+ },
1425
+ tests: [
1426
+ {
1427
+ params: {
1428
+ network: "DOGECOIN",
1429
+ walletAddress: "DMqRVLrhbam3Kcfddpxd6EYvEBbpi3bEpP",
1430
+ contractAddress: ""
1431
+ },
1432
+ payload: "https://jiti.indexing.co/networks/dogecoin/1000075",
1433
+ output: [
1434
+ {
1435
+ amount: 1008521000000n,
1436
+ blockNumber: 1000075,
1437
+ from: "DMqRVLrhbam3Kcfddpxd6EYvEBbpi3bEpP",
1438
+ to: "DMqRVLrhbam3Kcfddpxd6EYvEBbpi3bEpP",
1439
+ token: null,
1440
+ tokenType: "NATIVE",
1441
+ transactionGasFee: 0n,
1442
+ transactionHash: "9873fe46ab29f61cefdec498b691af68e0ad29a7599c94f42d2d4e9a5d461dbe",
1443
+ timestamp: "2015-12-13T19:59:52.000Z"
1444
+ }
1445
+ ]
1446
+ }
1447
+ ]
1448
+ };
1449
+
1450
+
1451
+ const $0ab1acc1eff391f6$var$SUB_TEMPLATES = [
1452
+ (0, $bea1ed486f96b980$export$ace043a4f2efe476),
1453
+ (0, $8860a67278817de8$export$893111d8d332e195),
1454
+ (0, $548ae36ea3681b01$export$d7ac970e8e789607),
1455
+ (0, $07b3982e2fc4c8b2$export$400f08bfae9ee97f),
1456
+ (0, $f0bdc73ab4ea9846$export$1f0fe79deb1b813b),
1457
+ (0, $f7da547a9d6b4fc0$export$36783fc9701281c6),
1458
+ (0, $725699ccb951d76d$export$681f497010b17679),
1459
+ (0, $13c3ff41f568666f$export$bc6c7ab7e0727dd7),
1460
+ (0, $f9f6601c9222cc8e$export$722698bc663d0ac0),
1461
+ (0, $e97546fe39f2692a$export$608f3f42810b9879),
1462
+ (0, $532fac82d96b89f2$export$4f5322cf4718bd30)
1463
+ ];
1464
+ const $0ab1acc1eff391f6$var$UNIVERSAL_SUB_TEMPLATES = [
1465
+ (0, $8d6646508fb2fa58$export$b5fd4920e8b7d913),
1466
+ (0, $5ec62a2088d070a8$export$5beebc5708fabf3c)
1467
+ ];
1468
+ const $0ab1acc1eff391f6$var$tokenTransfersTemplate = {
1469
+ key: "token_transfers",
1470
+ name: "Token Transfers",
1471
+ description: "Get all token transfers for a set of token types.",
1472
+ tags: [
1473
+ "EVM",
1474
+ "ERC20",
1475
+ "ERC721",
1476
+ "NFT",
1477
+ "TOKEN"
1478
+ ],
1479
+ disabled: false,
1480
+ params: [
1481
+ {
1482
+ key: "network",
1483
+ name: "Network",
1484
+ type: "NETWORK",
1485
+ optional: false
1486
+ },
1487
+ {
1488
+ key: "contractAddress",
1489
+ name: "Contract Address",
1490
+ type: "ADDRESS",
1491
+ optional: true
1492
+ },
1493
+ {
1494
+ key: "walletAddress",
1495
+ name: "Wallet Address",
1496
+ type: "ADDRESS",
1497
+ optional: true
1498
+ },
1499
+ {
1500
+ key: "tokenTypes",
1501
+ name: "Token Types",
1502
+ type: "STRING",
1503
+ multiple: true,
1504
+ optional: true,
1505
+ values: [
1506
+ "NATIVE",
1507
+ "TOKEN",
1508
+ "NFT"
1509
+ ]
1510
+ }
1511
+ ],
1512
+ transform: (block, _ctx)=>{
1513
+ let transfers = [];
1514
+ for (const sub of $0ab1acc1eff391f6$var$SUB_TEMPLATES.concat($0ab1acc1eff391f6$var$UNIVERSAL_SUB_TEMPLATES))if (sub.match(block)) {
1515
+ transfers = sub.transform(block, _ctx);
1516
+ break;
1517
+ }
1518
+ const seenTransfers = new Set();
1519
+ transfers = transfers.filter((txfer)=>{
1520
+ if (txfer.amount <= BigInt(0)) return false;
1521
+ if (_ctx.params.contractAddress && _ctx.params.contractAddress !== txfer.token) return false;
1522
+ if (_ctx.params.walletAddress && ![
1523
+ txfer.from,
1524
+ txfer.to
1525
+ ].includes(_ctx.params.walletAddress)) return false;
1526
+ const key = `${txfer.transactionHash}-${txfer.from}-${txfer.to}-${txfer.amount}-${txfer.token}`;
1527
+ if (seenTransfers.has(key)) return false;
1528
+ seenTransfers.add(key);
1529
+ return true;
1530
+ });
1531
+ return transfers;
1532
+ },
1533
+ tests: $0ab1acc1eff391f6$var$SUB_TEMPLATES.concat($0ab1acc1eff391f6$var$UNIVERSAL_SUB_TEMPLATES).map((v)=>v.tests).flat()
1534
+ };
1535
+ var $0ab1acc1eff391f6$export$2e2bcd8739ae039 = $0ab1acc1eff391f6$var$tokenTransfersTemplate;
1304
1536
 
1305
1537
 
1306
1538
  const $70cb039dbeb3c65a$export$a8fc3402335b0b04 = [
1307
1539
  (0, $a4b307b872b01f44$export$2e2bcd8739ae039),
1308
- (0, $c18434deda90759d$export$2e2bcd8739ae039)
1540
+ (0, $0ab1acc1eff391f6$export$2e2bcd8739ae039)
1309
1541
  ];
1310
1542
 
1311
1543