@indexing/jiti 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -4,6 +4,7 @@ var $8zHUo$tronweb = require("tronweb");
4
4
  var $8zHUo$cosmjsprotosigning = require("@cosmjs/proto-signing");
5
5
  var $8zHUo$cosmjsstargate = require("@cosmjs/stargate");
6
6
  var $8zHUo$bs58 = require("bs58");
7
+ var $8zHUo$toncore = require("@ton/core");
7
8
 
8
9
 
9
10
  function $parcel$exportWildcard(dest, source) {
@@ -60,11 +61,6 @@ const $6bd2ca253e883278$var$PARTIAL_VM_TO_NETWORK_MAP = {
60
61
  RIPPLE: [
61
62
  "RIPPLE"
62
63
  ],
63
- SNAPCHAIN: [
64
- "CAST_PROTOCOL",
65
- "FARCASTER",
66
- "SNAPCHAIN"
67
- ],
68
64
  STARKNET: [
69
65
  "STARKNET"
70
66
  ],
@@ -561,104 +557,6 @@ function $414c83047563e72e$export$685b7dc2197cd06c(rawBlock) {
561
557
  }
562
558
 
563
559
 
564
- var $7fd98ef3967673b0$exports = {};
565
-
566
- $parcel$export($7fd98ef3967673b0$exports, "snapchainTimestampFromMsg", () => $7fd98ef3967673b0$export$f69db31cc49f73fd);
567
- $parcel$export($7fd98ef3967673b0$exports, "snapchainParseEvent", () => $7fd98ef3967673b0$export$146821f89c094be4);
568
-
569
- var $7fd98ef3967673b0$require$Buffer = $8zHUo$buffer.Buffer;
570
- function $7fd98ef3967673b0$var$getValueFromObject(obj, path) {
571
- if (!obj || !path || !path.length) return undefined;
572
- const parts = path.replace(/\.\./g, ".__dot__").split(".");
573
- if (parts[0].startsWith("__dot__")) parts[0] = parts[0].replace(/__dot__/, ".");
574
- if (parts.length === 1) return obj[parts[0]];
575
- return $7fd98ef3967673b0$var$getValueFromObject(obj[parts[0]], parts.slice(1).join("."));
576
- }
577
- function $7fd98ef3967673b0$export$f69db31cc49f73fd(msg) {
578
- return new Date(parseInt(msg.timestamp || msg.data?.timestamp) * 1000 + 1609459200000);
579
- }
580
- function $7fd98ef3967673b0$export$146821f89c094be4(evt) {
581
- if (!evt?.data?.type) return null;
582
- const data = evt.data;
583
- const processed = {
584
- fid: data.fid,
585
- signer: evt.signer,
586
- timestamp: $7fd98ef3967673b0$export$f69db31cc49f73fd(data).toISOString()
587
- };
588
- switch(data.type){
589
- case "MESSAGE_TYPE_CAST_ADD":
590
- processed._dataType = "cast";
591
- processed.hash = evt.hash;
592
- processed.embeds = $7fd98ef3967673b0$var$getValueFromObject(data, "cast_add_body.embeds");
593
- processed.parentCastUrl = $7fd98ef3967673b0$var$getValueFromObject(data, "cast_add_body.parent_url");
594
- processed.parentCastFid = $7fd98ef3967673b0$var$getValueFromObject(data, "cast_add_body.parent_cast_id.fid");
595
- processed.parentCastHash = $7fd98ef3967673b0$var$getValueFromObject(data, "cast_add_body.parent_cast_id.hash");
596
- processed.text = $7fd98ef3967673b0$var$getValueFromObject(data, "cast_add_body.text");
597
- processed.mentions = $7fd98ef3967673b0$var$getValueFromObject(data, "cast_add_body.mentions");
598
- processed.mentionsPositions = $7fd98ef3967673b0$var$getValueFromObject(data, "cast_add_body.mentions_positions");
599
- processed.deletedAt = "";
600
- break;
601
- case "MESSAGE_TYPE_CAST_REMOVE":
602
- processed._dataType = "cast";
603
- processed.hash = $7fd98ef3967673b0$var$getValueFromObject(data, "cast_remove_body.target_hash");
604
- if (typeof processed.hash === "string" && !processed.hash?.startsWith("0x")) processed.hash = "0x" + $7fd98ef3967673b0$require$Buffer.from(processed.hash, "base64").toString("hex");
605
- processed.deletedAt = processed.timestamp;
606
- break;
607
- case "MESSAGE_TYPE_REACTION_ADD":
608
- case "MESSAGE_TYPE_REACTION_REMOVE":
609
- processed._dataType = "reaction";
610
- processed.targetCastFid = $7fd98ef3967673b0$var$getValueFromObject(data, "reaction_body.target_cast_id.fid");
611
- processed.targetCastHash = $7fd98ef3967673b0$var$getValueFromObject(data, "reaction_body.target_cast_id.hash");
612
- processed.type = $7fd98ef3967673b0$var$getValueFromObject(data, "reaction_body.type")?.split("_TYPE_").pop().toLowerCase();
613
- if (data.type === "MESSAGE_TYPE_REACTION_REMOVE") processed.deletedAt = processed.timestamp;
614
- else processed.deletedAt = "";
615
- break;
616
- case "MESSAGE_TYPE_LINK_ADD":
617
- case "MESSAGE_TYPE_LINK_REMOVE":
618
- processed._dataType = "link";
619
- processed.target_fid = $7fd98ef3967673b0$var$getValueFromObject(data, "link_body.target_fid");
620
- processed.type = $7fd98ef3967673b0$var$getValueFromObject(data, "link_body.type");
621
- if (data.type === "MESSAGE_TYPE_LINK_REMOVE") processed.deletedAt = processed.timestamp;
622
- else processed.deletedAt = "";
623
- break;
624
- case "MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS":
625
- processed._dataType = "verification";
626
- processed.address = $7fd98ef3967673b0$var$getValueFromObject(data, "verification_add_address_body.address");
627
- if (processed.address?.startsWith("0x")) processed.address = processed.address.toLowerCase();
628
- processed.deletedAt = "";
629
- break;
630
- case "MESSAGE_TYPE_VERIFICATION_REMOVE":
631
- processed._dataType = "verification";
632
- processed.address = $7fd98ef3967673b0$var$getValueFromObject(data, "verification_remove_body.address");
633
- if (processed.address?.startsWith("0x")) processed.address = processed.address.toLowerCase();
634
- processed.deletedAt = processed.timestamp;
635
- break;
636
- case "MESSAGE_TYPE_USER_DATA_ADD":
637
- {
638
- processed._dataType = "user_data";
639
- let key = $7fd98ef3967673b0$var$getValueFromObject(data, "user_data_body.type");
640
- if (typeof key === "string") {
641
- key = key.trim().split("_").pop().toLowerCase();
642
- processed.data = {
643
- [key]: $7fd98ef3967673b0$var$getValueFromObject(data, "user_data_body.value")
644
- };
645
- }
646
- break;
647
- }
648
- case "MESSAGE_TYPE_USERNAME_PROOF":
649
- return null;
650
- default:
651
- return null;
652
- }
653
- for(const k in processed){
654
- if (processed[k] === null || processed[k] === undefined) delete processed[k];
655
- if (k === "deletedAt" && processed[k] === "") processed[k] = null;
656
- if ((k.endsWith("Hash") || k === "hash") && processed[k] && !processed[k].startsWith("0x")) processed[k] = "0x" + $7fd98ef3967673b0$require$Buffer.from(processed[k], "base64").toString("hex");
657
- }
658
- return processed;
659
- }
660
-
661
-
662
560
  $parcel$exportWildcard($d7167569386d0d4c$exports, $56acd58307ebf8e6$exports);
663
561
  $parcel$exportWildcard($d7167569386d0d4c$exports, $77809331c5210b08$exports);
664
562
  $parcel$exportWildcard($d7167569386d0d4c$exports, $b8691f253b6baa6e$exports);
@@ -668,7 +566,6 @@ $parcel$exportWildcard($d7167569386d0d4c$exports, $e5566e47593dc3e2$exports);
668
566
  $parcel$exportWildcard($d7167569386d0d4c$exports, $da55be3e40667945$exports);
669
567
  $parcel$exportWildcard($d7167569386d0d4c$exports, $f7a3fb164436c9c3$exports);
670
568
  $parcel$exportWildcard($d7167569386d0d4c$exports, $414c83047563e72e$exports);
671
- $parcel$exportWildcard($d7167569386d0d4c$exports, $7fd98ef3967673b0$exports);
672
569
 
673
570
 
674
571
  var $48f9879a44dd1195$exports = {};
@@ -3637,65 +3534,150 @@ const $11a2c5b0fd56c033$export$bc6c7ab7e0727dd7 = {
3637
3534
 
3638
3535
 
3639
3536
 
3537
+
3538
+
3539
+ var $cd430dd11c31e572$require$Buffer = $8zHUo$buffer.Buffer;
3540
+ // TEP-74 jetton `internal_transfer` op-code. This is the message a recipient's
3541
+ // jetton wallet receives when it is credited, so it is the canonical signal of a
3542
+ // jetton deposit landing — and the only jetton message whose executing account
3543
+ // (`tx.address`) is the recipient jetton wallet itself.
3544
+ const $cd430dd11c31e572$var$JETTON_INTERNAL_TRANSFER_OP = 0x178d4519;
3545
+ // Decode a jetton `internal_transfer` message body (a base64-encoded BoC).
3546
+ // Returns null when the body is absent, is not a BoC, or carries a different
3547
+ // op-code (text comments, other jetton ops, arbitrary contract calls) — the
3548
+ // caller then falls back to the native path. Body layout (TEP-74):
3549
+ // internal_transfer#0x178d4519 query_id:uint64 amount:(VarUInteger 16)
3550
+ // from:MsgAddress response_address:MsgAddress ...
3551
+ function $cd430dd11c31e572$var$decodeJettonInternalTransfer(body) {
3552
+ if (!body) return null;
3553
+ try {
3554
+ const slice = (0, $8zHUo$toncore.Cell).fromBoc($cd430dd11c31e572$require$Buffer.from(body, "base64"))[0].beginParse();
3555
+ if (slice.loadUint(32) !== $cd430dd11c31e572$var$JETTON_INTERNAL_TRANSFER_OP) return null;
3556
+ slice.loadUintBig(64); // query_id
3557
+ const amount = slice.loadCoins();
3558
+ // `from` is the sending owner, read best-effort: it can be addr_none on some
3559
+ // mints/airdrops, and rare non-standard address encodings can throw. In
3560
+ // either case keep the (valid) amount and let the caller fall back to the
3561
+ // message source rather than dropping a real jetton transfer.
3562
+ let from;
3563
+ try {
3564
+ const fromAddress = slice.loadMaybeAddress();
3565
+ from = fromAddress ? fromAddress.toString({
3566
+ urlSafe: true,
3567
+ bounceable: true,
3568
+ testOnly: false
3569
+ }) : undefined;
3570
+ } catch {
3571
+ from = undefined;
3572
+ }
3573
+ return {
3574
+ amount: amount,
3575
+ from: from
3576
+ };
3577
+ } catch {
3578
+ return null;
3579
+ }
3580
+ }
3640
3581
  const $cd430dd11c31e572$export$608f3f42810b9879 = {
3641
3582
  match: (block)=>(0, $6bd2ca253e883278$export$ae001c77434c5340)(block) === "TON",
3642
3583
  transform (block) {
3643
- let transfers = [];
3584
+ const transfers = [];
3644
3585
  const typedBlock = block;
3645
3586
  const blockNumber = typedBlock.seqno;
3646
- const blockTimestamp = new Date(typedBlock.shards?.[0]?.gen_utime * 1000).toISOString();
3647
3587
  for (const shard of typedBlock.shards || [])for (const tx of shard.transactions || []){
3648
- const transactionLT = tx.transaction_id.lt;
3649
- const transactionHash = tx.transaction_id.hash;
3650
- const transactionFee = BigInt(tx.fee || "0");
3651
- const inVal = BigInt(tx.in_msg?.value || "0");
3652
- if (inVal > 0n) transfers.push({
3588
+ const inMsg = tx.in_msg;
3589
+ if (!inMsg) continue;
3590
+ const transactionHash = tx.transaction_id?.hash;
3591
+ const transactionGasFee = BigInt(tx.fee || "0");
3592
+ // Per-transaction time. shards[0].gen_utime — the previous source — is
3593
+ // wrong for any transaction outside the first shard and is undefined for
3594
+ // empty shards (producing `Invalid Date`).
3595
+ const timestamp = new Date((tx.utime || 0) * 1000).toISOString();
3596
+ // The account this transaction executed on: the recipient account for a
3597
+ // native transfer, or the recipient's jetton wallet for a jetton one
3598
+ // (== in_msg.destination).
3599
+ const to = tx.address?.account_address;
3600
+ // Walk `in_msg` only: every transfer is recorded once, at the
3601
+ // recipient's transaction, with `from` carried on the row so sender
3602
+ // queries still match. Walking `out_msgs` too would double-emit each hop
3603
+ // — the sender's and the recipient's transactions both fall in range.
3604
+ const jetton = $cd430dd11c31e572$var$decodeJettonInternalTransfer(inMsg.msg_data?.body);
3605
+ if (jetton) {
3606
+ // Jetton and native value are mutually exclusive per message: a jetton
3607
+ // `internal_transfer` also carries forwarded gas as `in_msg.value`, so
3608
+ // emitting a native transfer here too would surface a phantom TON hop.
3609
+ transfers.push({
3610
+ blockNumber: blockNumber,
3611
+ from: jetton.from || inMsg.source?.account_address,
3612
+ to: to,
3613
+ amount: jetton.amount,
3614
+ // The jetton master is not carried in the wallet-to-wallet
3615
+ // `internal_transfer`; a stateless template can't resolve it without
3616
+ // an RPC call, so `token` is intentionally left undefined.
3617
+ tokenType: "TOKEN",
3618
+ timestamp: timestamp,
3619
+ transactionHash: transactionHash,
3620
+ transactionGasFee: transactionGasFee
3621
+ });
3622
+ continue;
3623
+ }
3624
+ const inValue = BigInt(inMsg.value || "0");
3625
+ if (inValue > 0n) transfers.push({
3653
3626
  blockNumber: blockNumber,
3654
- from: tx.in_msg?.source?.account_address,
3655
- to: tx.address?.account_address,
3656
- amount: inVal,
3627
+ from: inMsg.source?.account_address,
3628
+ to: to,
3629
+ amount: inValue,
3657
3630
  token: "TON",
3658
3631
  tokenType: "NATIVE",
3659
- timestamp: blockTimestamp,
3632
+ timestamp: timestamp,
3660
3633
  transactionHash: transactionHash,
3661
- transactionGasFee: transactionFee
3634
+ transactionGasFee: transactionGasFee
3662
3635
  });
3663
- for (const outMsg of tx.out_msgs || []){
3664
- const outVal = BigInt(outMsg.value || "0");
3665
- if (outVal > 0n) transfers.push({
3666
- blockNumber: blockNumber,
3667
- from: outMsg.source?.account_address,
3668
- to: outMsg.destination?.account_address,
3669
- amount: outVal,
3670
- token: "TON",
3671
- tokenType: "NATIVE",
3672
- timestamp: blockTimestamp,
3673
- transactionHash: transactionHash,
3674
- transactionGasFee: transactionFee
3675
- });
3676
- }
3677
3636
  }
3678
3637
  return transfers;
3679
3638
  },
3680
3639
  tests: [
3681
3640
  {
3641
+ // Native TON transfer — `in_msg` carries value and no jetton body.
3682
3642
  params: {
3683
3643
  network: "TON",
3684
- walletAddress: "EQAFukUyzmHjUvOYDOjNE-wbZFFl2FWas1rFJoh8IiTsWD40",
3685
- contractAddress: ""
3644
+ transactionHash: "rwDRQeWniNdxBayFcDavE/Wo35B+MsfO4lJJmvz5Edk="
3686
3645
  },
3687
- payload: "https://jiti.indexing.co/networks/ton/44919328",
3646
+ payload: "https://jiti.indexing.co/networks/ton/71399000",
3688
3647
  output: [
3689
3648
  {
3690
- blockNumber: 44919328,
3691
- from: "EQAFukUyzmHjUvOYDOjNE-wbZFFl2FWas1rFJoh8IiTsWD40",
3692
- to: "EQCFTFAHOU3vFt2NiZhRD5dwuS0k7GS59vIg3WfCKwfaQGW2",
3693
- amount: 10000000n,
3649
+ blockNumber: 71399000,
3650
+ from: "EQBkhlXTyZjri7SfyZcgFbRkjlLvq4kU3UjBTtiTtwLITn0H",
3651
+ to: "EQABGo8KCza3ea8DNHMnSWZmbRzW-05332eTdfvW-XDQEjQM",
3652
+ amount: 203686310466n,
3694
3653
  token: "TON",
3695
3654
  tokenType: "NATIVE",
3696
- timestamp: "2025-02-13T23:10:18.000Z",
3697
- transactionHash: "Vh5cWr2uvCsdhoouBQ+EiUcF54os9oqvh8A/62EroQc=",
3698
- transactionGasFee: 2355233n
3655
+ timestamp: "2026-06-05T15:31:47.000Z",
3656
+ transactionHash: "rwDRQeWniNdxBayFcDavE/Wo35B+MsfO4lJJmvz5Edk=",
3657
+ transactionGasFee: 6668n
3658
+ }
3659
+ ]
3660
+ },
3661
+ {
3662
+ // Jetton transfer — `in_msg` is an internal_transfer (op 0x178d4519). The
3663
+ // message also carries 49740664 nanoTON of forwarded gas, which must NOT
3664
+ // surface as a phantom native transfer. `token` is left undefined (the
3665
+ // jetton master is not in the wallet-to-wallet message).
3666
+ params: {
3667
+ network: "TON",
3668
+ transactionHash: "Tx+nOxUzqo8kYpNkX20C2OTg6Dd9d6MHadQsknv4620="
3669
+ },
3670
+ payload: "https://jiti.indexing.co/networks/ton/71399000",
3671
+ output: [
3672
+ {
3673
+ blockNumber: 71399000,
3674
+ from: "EQDshc_H_RAJNi5CG1oBQfUQ1lQBB6tz54Kf2h756Xp14_Cv",
3675
+ to: "EQBMzIc7YUB_WkSkmaIooZyONQDayNfipt3PQ4IJRsGXsPGI",
3676
+ amount: 2800000000n,
3677
+ tokenType: "TOKEN",
3678
+ timestamp: "2026-06-05T15:31:47.000Z",
3679
+ transactionHash: "Tx+nOxUzqo8kYpNkX20C2OTg6Dd9d6MHadQsknv4620=",
3680
+ transactionGasFee: 233386n
3699
3681
  }
3700
3682
  ]
3701
3683
  }
@@ -3868,7 +3850,6 @@ const $7dd402f6ad0dab6a$var$tokenTransfersTemplate = {
3868
3850
  var $7dd402f6ad0dab6a$export$2e2bcd8739ae039 = $7dd402f6ad0dab6a$var$tokenTransfersTemplate;
3869
3851
 
3870
3852
 
3871
-
3872
3853
  const $9af31dbb692f94e3$var$NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
3873
3854
  const $9af31dbb692f94e3$var$filterValuesTemplate = {
3874
3855
  key: "filter_values",
@@ -3954,24 +3935,6 @@ const $9af31dbb692f94e3$var$filterValuesTemplate = {
3954
3935
  for(const key in tx)if (tx[key]?.issuer) finalValues.add(tx[key]?.issuer);
3955
3936
  }
3956
3937
  break;
3957
- case "SNAPCHAIN":
3958
- {
3959
- const typedBlock = block;
3960
- let parsed = [];
3961
- if (typedBlock.processed?.length) parsed = typedBlock.processed;
3962
- else {
3963
- const shards = typedBlock.shards ? typedBlock.shards : [
3964
- block
3965
- ];
3966
- const messages = shards.map((s)=>s.transactions?.map((t)=>t.user_messages || []).flat()).flat();
3967
- parsed = messages.map((0, $7fd98ef3967673b0$export$146821f89c094be4));
3968
- }
3969
- for (const p of parsed){
3970
- if (!p) continue;
3971
- finalValues.add(`${p.fid}`);
3972
- }
3973
- break;
3974
- }
3975
3938
  case "STARKNET":
3976
3939
  for (const tx of block.transactions || []){
3977
3940
  const from = tx.send_address?.toLowerCase() || $9af31dbb692f94e3$var$NULL_ADDRESS;
@@ -11343,58 +11306,6 @@ const $9af31dbb692f94e3$var$filterValuesTemplate = {
11343
11306
  "0xe7f571ba7d04d6bc88f519289bc4f94a54fb25634128b3f9884d64904db32c12"
11344
11307
  ]
11345
11308
  },
11346
- {
11347
- params: {},
11348
- payload: "https://jiti.indexing.co/networks/farcaster/2442805",
11349
- output: [
11350
- "1053494",
11351
- "1066546",
11352
- "1090343",
11353
- "1131909",
11354
- "1134046",
11355
- "1134910",
11356
- "1135798",
11357
- "1139813",
11358
- "1146560",
11359
- "1148283",
11360
- "1163463",
11361
- "1164305",
11362
- "1167631",
11363
- "1167984",
11364
- "1181162",
11365
- "1182140",
11366
- "1186458",
11367
- "1198272",
11368
- "1230161",
11369
- "1275123",
11370
- "1278167",
11371
- "12938",
11372
- "1322761",
11373
- "1332557",
11374
- "1334507",
11375
- "1337870",
11376
- "1337940",
11377
- "310644",
11378
- "319554",
11379
- "377148",
11380
- "430267",
11381
- "432992",
11382
- "448300",
11383
- "455743",
11384
- "467181",
11385
- "474644",
11386
- "511842",
11387
- "541835",
11388
- "618593",
11389
- "789371",
11390
- "864838",
11391
- "897445",
11392
- "902685",
11393
- "905676",
11394
- "957928",
11395
- "969084"
11396
- ]
11397
- },
11398
11309
  {
11399
11310
  params: {},
11400
11311
  payload: "https://jiti.indexing.co/networks/hyper_core/8248362",