@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/module.js CHANGED
@@ -4,6 +4,7 @@ import $hgUW1$tronweb from "tronweb";
4
4
  import {decodeTxRaw as $hgUW1$decodeTxRaw, Registry as $hgUW1$Registry} from "@cosmjs/proto-signing";
5
5
  import {defaultRegistryTypes as $hgUW1$defaultRegistryTypes} from "@cosmjs/stargate";
6
6
  import $hgUW1$bs58 from "bs58";
7
+ import {Cell as $hgUW1$Cell} from "@ton/core";
7
8
 
8
9
 
9
10
  function $parcel$exportWildcard(dest, source) {
@@ -51,11 +52,6 @@ const $09654dffcb68affa$var$PARTIAL_VM_TO_NETWORK_MAP = {
51
52
  RIPPLE: [
52
53
  "RIPPLE"
53
54
  ],
54
- SNAPCHAIN: [
55
- "CAST_PROTOCOL",
56
- "FARCASTER",
57
- "SNAPCHAIN"
58
- ],
59
55
  STARKNET: [
60
56
  "STARKNET"
61
57
  ],
@@ -552,104 +548,6 @@ function $8f1e0ae1ead9a2a9$export$685b7dc2197cd06c(rawBlock) {
552
548
  }
553
549
 
554
550
 
555
- var $8331f131029dede8$exports = {};
556
-
557
- $parcel$export($8331f131029dede8$exports, "snapchainTimestampFromMsg", () => $8331f131029dede8$export$f69db31cc49f73fd);
558
- $parcel$export($8331f131029dede8$exports, "snapchainParseEvent", () => $8331f131029dede8$export$146821f89c094be4);
559
-
560
- var $8331f131029dede8$require$Buffer = $hgUW1$Buffer;
561
- function $8331f131029dede8$var$getValueFromObject(obj, path) {
562
- if (!obj || !path || !path.length) return undefined;
563
- const parts = path.replace(/\.\./g, ".__dot__").split(".");
564
- if (parts[0].startsWith("__dot__")) parts[0] = parts[0].replace(/__dot__/, ".");
565
- if (parts.length === 1) return obj[parts[0]];
566
- return $8331f131029dede8$var$getValueFromObject(obj[parts[0]], parts.slice(1).join("."));
567
- }
568
- function $8331f131029dede8$export$f69db31cc49f73fd(msg) {
569
- return new Date(parseInt(msg.timestamp || msg.data?.timestamp) * 1000 + 1609459200000);
570
- }
571
- function $8331f131029dede8$export$146821f89c094be4(evt) {
572
- if (!evt?.data?.type) return null;
573
- const data = evt.data;
574
- const processed = {
575
- fid: data.fid,
576
- signer: evt.signer,
577
- timestamp: $8331f131029dede8$export$f69db31cc49f73fd(data).toISOString()
578
- };
579
- switch(data.type){
580
- case "MESSAGE_TYPE_CAST_ADD":
581
- processed._dataType = "cast";
582
- processed.hash = evt.hash;
583
- processed.embeds = $8331f131029dede8$var$getValueFromObject(data, "cast_add_body.embeds");
584
- processed.parentCastUrl = $8331f131029dede8$var$getValueFromObject(data, "cast_add_body.parent_url");
585
- processed.parentCastFid = $8331f131029dede8$var$getValueFromObject(data, "cast_add_body.parent_cast_id.fid");
586
- processed.parentCastHash = $8331f131029dede8$var$getValueFromObject(data, "cast_add_body.parent_cast_id.hash");
587
- processed.text = $8331f131029dede8$var$getValueFromObject(data, "cast_add_body.text");
588
- processed.mentions = $8331f131029dede8$var$getValueFromObject(data, "cast_add_body.mentions");
589
- processed.mentionsPositions = $8331f131029dede8$var$getValueFromObject(data, "cast_add_body.mentions_positions");
590
- processed.deletedAt = "";
591
- break;
592
- case "MESSAGE_TYPE_CAST_REMOVE":
593
- processed._dataType = "cast";
594
- processed.hash = $8331f131029dede8$var$getValueFromObject(data, "cast_remove_body.target_hash");
595
- if (typeof processed.hash === "string" && !processed.hash?.startsWith("0x")) processed.hash = "0x" + $8331f131029dede8$require$Buffer.from(processed.hash, "base64").toString("hex");
596
- processed.deletedAt = processed.timestamp;
597
- break;
598
- case "MESSAGE_TYPE_REACTION_ADD":
599
- case "MESSAGE_TYPE_REACTION_REMOVE":
600
- processed._dataType = "reaction";
601
- processed.targetCastFid = $8331f131029dede8$var$getValueFromObject(data, "reaction_body.target_cast_id.fid");
602
- processed.targetCastHash = $8331f131029dede8$var$getValueFromObject(data, "reaction_body.target_cast_id.hash");
603
- processed.type = $8331f131029dede8$var$getValueFromObject(data, "reaction_body.type")?.split("_TYPE_").pop().toLowerCase();
604
- if (data.type === "MESSAGE_TYPE_REACTION_REMOVE") processed.deletedAt = processed.timestamp;
605
- else processed.deletedAt = "";
606
- break;
607
- case "MESSAGE_TYPE_LINK_ADD":
608
- case "MESSAGE_TYPE_LINK_REMOVE":
609
- processed._dataType = "link";
610
- processed.target_fid = $8331f131029dede8$var$getValueFromObject(data, "link_body.target_fid");
611
- processed.type = $8331f131029dede8$var$getValueFromObject(data, "link_body.type");
612
- if (data.type === "MESSAGE_TYPE_LINK_REMOVE") processed.deletedAt = processed.timestamp;
613
- else processed.deletedAt = "";
614
- break;
615
- case "MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS":
616
- processed._dataType = "verification";
617
- processed.address = $8331f131029dede8$var$getValueFromObject(data, "verification_add_address_body.address");
618
- if (processed.address?.startsWith("0x")) processed.address = processed.address.toLowerCase();
619
- processed.deletedAt = "";
620
- break;
621
- case "MESSAGE_TYPE_VERIFICATION_REMOVE":
622
- processed._dataType = "verification";
623
- processed.address = $8331f131029dede8$var$getValueFromObject(data, "verification_remove_body.address");
624
- if (processed.address?.startsWith("0x")) processed.address = processed.address.toLowerCase();
625
- processed.deletedAt = processed.timestamp;
626
- break;
627
- case "MESSAGE_TYPE_USER_DATA_ADD":
628
- {
629
- processed._dataType = "user_data";
630
- let key = $8331f131029dede8$var$getValueFromObject(data, "user_data_body.type");
631
- if (typeof key === "string") {
632
- key = key.trim().split("_").pop().toLowerCase();
633
- processed.data = {
634
- [key]: $8331f131029dede8$var$getValueFromObject(data, "user_data_body.value")
635
- };
636
- }
637
- break;
638
- }
639
- case "MESSAGE_TYPE_USERNAME_PROOF":
640
- return null;
641
- default:
642
- return null;
643
- }
644
- for(const k in processed){
645
- if (processed[k] === null || processed[k] === undefined) delete processed[k];
646
- if (k === "deletedAt" && processed[k] === "") processed[k] = null;
647
- if ((k.endsWith("Hash") || k === "hash") && processed[k] && !processed[k].startsWith("0x")) processed[k] = "0x" + $8331f131029dede8$require$Buffer.from(processed[k], "base64").toString("hex");
648
- }
649
- return processed;
650
- }
651
-
652
-
653
551
  $parcel$exportWildcard($fde9406d76ec24a9$exports, $82293038337e7b3f$exports);
654
552
  $parcel$exportWildcard($fde9406d76ec24a9$exports, $e23c2d0dc0ca1317$exports);
655
553
  $parcel$exportWildcard($fde9406d76ec24a9$exports, $cc5213c20a6615f3$exports);
@@ -659,7 +557,6 @@ $parcel$exportWildcard($fde9406d76ec24a9$exports, $68871103c7bc00cf$exports);
659
557
  $parcel$exportWildcard($fde9406d76ec24a9$exports, $cfa23334cbdf9391$exports);
660
558
  $parcel$exportWildcard($fde9406d76ec24a9$exports, $f6a81337d3532e59$exports);
661
559
  $parcel$exportWildcard($fde9406d76ec24a9$exports, $8f1e0ae1ead9a2a9$exports);
662
- $parcel$exportWildcard($fde9406d76ec24a9$exports, $8331f131029dede8$exports);
663
560
 
664
561
 
665
562
  var $70cb039dbeb3c65a$exports = {};
@@ -3628,65 +3525,150 @@ const $13c3ff41f568666f$export$bc6c7ab7e0727dd7 = {
3628
3525
 
3629
3526
 
3630
3527
 
3528
+
3529
+
3530
+ var $e97546fe39f2692a$require$Buffer = $hgUW1$Buffer;
3531
+ // TEP-74 jetton `internal_transfer` op-code. This is the message a recipient's
3532
+ // jetton wallet receives when it is credited, so it is the canonical signal of a
3533
+ // jetton deposit landing — and the only jetton message whose executing account
3534
+ // (`tx.address`) is the recipient jetton wallet itself.
3535
+ const $e97546fe39f2692a$var$JETTON_INTERNAL_TRANSFER_OP = 0x178d4519;
3536
+ // Decode a jetton `internal_transfer` message body (a base64-encoded BoC).
3537
+ // Returns null when the body is absent, is not a BoC, or carries a different
3538
+ // op-code (text comments, other jetton ops, arbitrary contract calls) — the
3539
+ // caller then falls back to the native path. Body layout (TEP-74):
3540
+ // internal_transfer#0x178d4519 query_id:uint64 amount:(VarUInteger 16)
3541
+ // from:MsgAddress response_address:MsgAddress ...
3542
+ function $e97546fe39f2692a$var$decodeJettonInternalTransfer(body) {
3543
+ if (!body) return null;
3544
+ try {
3545
+ const slice = (0, $hgUW1$Cell).fromBoc($e97546fe39f2692a$require$Buffer.from(body, "base64"))[0].beginParse();
3546
+ if (slice.loadUint(32) !== $e97546fe39f2692a$var$JETTON_INTERNAL_TRANSFER_OP) return null;
3547
+ slice.loadUintBig(64); // query_id
3548
+ const amount = slice.loadCoins();
3549
+ // `from` is the sending owner, read best-effort: it can be addr_none on some
3550
+ // mints/airdrops, and rare non-standard address encodings can throw. In
3551
+ // either case keep the (valid) amount and let the caller fall back to the
3552
+ // message source rather than dropping a real jetton transfer.
3553
+ let from;
3554
+ try {
3555
+ const fromAddress = slice.loadMaybeAddress();
3556
+ from = fromAddress ? fromAddress.toString({
3557
+ urlSafe: true,
3558
+ bounceable: true,
3559
+ testOnly: false
3560
+ }) : undefined;
3561
+ } catch {
3562
+ from = undefined;
3563
+ }
3564
+ return {
3565
+ amount: amount,
3566
+ from: from
3567
+ };
3568
+ } catch {
3569
+ return null;
3570
+ }
3571
+ }
3631
3572
  const $e97546fe39f2692a$export$608f3f42810b9879 = {
3632
3573
  match: (block)=>(0, $09654dffcb68affa$export$ae001c77434c5340)(block) === "TON",
3633
3574
  transform (block) {
3634
- let transfers = [];
3575
+ const transfers = [];
3635
3576
  const typedBlock = block;
3636
3577
  const blockNumber = typedBlock.seqno;
3637
- const blockTimestamp = new Date(typedBlock.shards?.[0]?.gen_utime * 1000).toISOString();
3638
3578
  for (const shard of typedBlock.shards || [])for (const tx of shard.transactions || []){
3639
- const transactionLT = tx.transaction_id.lt;
3640
- const transactionHash = tx.transaction_id.hash;
3641
- const transactionFee = BigInt(tx.fee || "0");
3642
- const inVal = BigInt(tx.in_msg?.value || "0");
3643
- if (inVal > 0n) transfers.push({
3579
+ const inMsg = tx.in_msg;
3580
+ if (!inMsg) continue;
3581
+ const transactionHash = tx.transaction_id?.hash;
3582
+ const transactionGasFee = BigInt(tx.fee || "0");
3583
+ // Per-transaction time. shards[0].gen_utime — the previous source — is
3584
+ // wrong for any transaction outside the first shard and is undefined for
3585
+ // empty shards (producing `Invalid Date`).
3586
+ const timestamp = new Date((tx.utime || 0) * 1000).toISOString();
3587
+ // The account this transaction executed on: the recipient account for a
3588
+ // native transfer, or the recipient's jetton wallet for a jetton one
3589
+ // (== in_msg.destination).
3590
+ const to = tx.address?.account_address;
3591
+ // Walk `in_msg` only: every transfer is recorded once, at the
3592
+ // recipient's transaction, with `from` carried on the row so sender
3593
+ // queries still match. Walking `out_msgs` too would double-emit each hop
3594
+ // — the sender's and the recipient's transactions both fall in range.
3595
+ const jetton = $e97546fe39f2692a$var$decodeJettonInternalTransfer(inMsg.msg_data?.body);
3596
+ if (jetton) {
3597
+ // Jetton and native value are mutually exclusive per message: a jetton
3598
+ // `internal_transfer` also carries forwarded gas as `in_msg.value`, so
3599
+ // emitting a native transfer here too would surface a phantom TON hop.
3600
+ transfers.push({
3601
+ blockNumber: blockNumber,
3602
+ from: jetton.from || inMsg.source?.account_address,
3603
+ to: to,
3604
+ amount: jetton.amount,
3605
+ // The jetton master is not carried in the wallet-to-wallet
3606
+ // `internal_transfer`; a stateless template can't resolve it without
3607
+ // an RPC call, so `token` is intentionally left undefined.
3608
+ tokenType: "TOKEN",
3609
+ timestamp: timestamp,
3610
+ transactionHash: transactionHash,
3611
+ transactionGasFee: transactionGasFee
3612
+ });
3613
+ continue;
3614
+ }
3615
+ const inValue = BigInt(inMsg.value || "0");
3616
+ if (inValue > 0n) transfers.push({
3644
3617
  blockNumber: blockNumber,
3645
- from: tx.in_msg?.source?.account_address,
3646
- to: tx.address?.account_address,
3647
- amount: inVal,
3618
+ from: inMsg.source?.account_address,
3619
+ to: to,
3620
+ amount: inValue,
3648
3621
  token: "TON",
3649
3622
  tokenType: "NATIVE",
3650
- timestamp: blockTimestamp,
3623
+ timestamp: timestamp,
3651
3624
  transactionHash: transactionHash,
3652
- transactionGasFee: transactionFee
3625
+ transactionGasFee: transactionGasFee
3653
3626
  });
3654
- for (const outMsg of tx.out_msgs || []){
3655
- const outVal = BigInt(outMsg.value || "0");
3656
- if (outVal > 0n) transfers.push({
3657
- blockNumber: blockNumber,
3658
- from: outMsg.source?.account_address,
3659
- to: outMsg.destination?.account_address,
3660
- amount: outVal,
3661
- token: "TON",
3662
- tokenType: "NATIVE",
3663
- timestamp: blockTimestamp,
3664
- transactionHash: transactionHash,
3665
- transactionGasFee: transactionFee
3666
- });
3667
- }
3668
3627
  }
3669
3628
  return transfers;
3670
3629
  },
3671
3630
  tests: [
3672
3631
  {
3632
+ // Native TON transfer — `in_msg` carries value and no jetton body.
3673
3633
  params: {
3674
3634
  network: "TON",
3675
- walletAddress: "EQAFukUyzmHjUvOYDOjNE-wbZFFl2FWas1rFJoh8IiTsWD40",
3676
- contractAddress: ""
3635
+ transactionHash: "rwDRQeWniNdxBayFcDavE/Wo35B+MsfO4lJJmvz5Edk="
3677
3636
  },
3678
- payload: "https://jiti.indexing.co/networks/ton/44919328",
3637
+ payload: "https://jiti.indexing.co/networks/ton/71399000",
3679
3638
  output: [
3680
3639
  {
3681
- blockNumber: 44919328,
3682
- from: "EQAFukUyzmHjUvOYDOjNE-wbZFFl2FWas1rFJoh8IiTsWD40",
3683
- to: "EQCFTFAHOU3vFt2NiZhRD5dwuS0k7GS59vIg3WfCKwfaQGW2",
3684
- amount: 10000000n,
3640
+ blockNumber: 71399000,
3641
+ from: "EQBkhlXTyZjri7SfyZcgFbRkjlLvq4kU3UjBTtiTtwLITn0H",
3642
+ to: "EQABGo8KCza3ea8DNHMnSWZmbRzW-05332eTdfvW-XDQEjQM",
3643
+ amount: 203686310466n,
3685
3644
  token: "TON",
3686
3645
  tokenType: "NATIVE",
3687
- timestamp: "2025-02-13T23:10:18.000Z",
3688
- transactionHash: "Vh5cWr2uvCsdhoouBQ+EiUcF54os9oqvh8A/62EroQc=",
3689
- transactionGasFee: 2355233n
3646
+ timestamp: "2026-06-05T15:31:47.000Z",
3647
+ transactionHash: "rwDRQeWniNdxBayFcDavE/Wo35B+MsfO4lJJmvz5Edk=",
3648
+ transactionGasFee: 6668n
3649
+ }
3650
+ ]
3651
+ },
3652
+ {
3653
+ // Jetton transfer — `in_msg` is an internal_transfer (op 0x178d4519). The
3654
+ // message also carries 49740664 nanoTON of forwarded gas, which must NOT
3655
+ // surface as a phantom native transfer. `token` is left undefined (the
3656
+ // jetton master is not in the wallet-to-wallet message).
3657
+ params: {
3658
+ network: "TON",
3659
+ transactionHash: "Tx+nOxUzqo8kYpNkX20C2OTg6Dd9d6MHadQsknv4620="
3660
+ },
3661
+ payload: "https://jiti.indexing.co/networks/ton/71399000",
3662
+ output: [
3663
+ {
3664
+ blockNumber: 71399000,
3665
+ from: "EQDshc_H_RAJNi5CG1oBQfUQ1lQBB6tz54Kf2h756Xp14_Cv",
3666
+ to: "EQBMzIc7YUB_WkSkmaIooZyONQDayNfipt3PQ4IJRsGXsPGI",
3667
+ amount: 2800000000n,
3668
+ tokenType: "TOKEN",
3669
+ timestamp: "2026-06-05T15:31:47.000Z",
3670
+ transactionHash: "Tx+nOxUzqo8kYpNkX20C2OTg6Dd9d6MHadQsknv4620=",
3671
+ transactionGasFee: 233386n
3690
3672
  }
3691
3673
  ]
3692
3674
  }
@@ -3859,7 +3841,6 @@ const $0ab1acc1eff391f6$var$tokenTransfersTemplate = {
3859
3841
  var $0ab1acc1eff391f6$export$2e2bcd8739ae039 = $0ab1acc1eff391f6$var$tokenTransfersTemplate;
3860
3842
 
3861
3843
 
3862
-
3863
3844
  const $dc0c078500ed1fea$var$NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
3864
3845
  const $dc0c078500ed1fea$var$filterValuesTemplate = {
3865
3846
  key: "filter_values",
@@ -3945,24 +3926,6 @@ const $dc0c078500ed1fea$var$filterValuesTemplate = {
3945
3926
  for(const key in tx)if (tx[key]?.issuer) finalValues.add(tx[key]?.issuer);
3946
3927
  }
3947
3928
  break;
3948
- case "SNAPCHAIN":
3949
- {
3950
- const typedBlock = block;
3951
- let parsed = [];
3952
- if (typedBlock.processed?.length) parsed = typedBlock.processed;
3953
- else {
3954
- const shards = typedBlock.shards ? typedBlock.shards : [
3955
- block
3956
- ];
3957
- const messages = shards.map((s)=>s.transactions?.map((t)=>t.user_messages || []).flat()).flat();
3958
- parsed = messages.map((0, $8331f131029dede8$export$146821f89c094be4));
3959
- }
3960
- for (const p of parsed){
3961
- if (!p) continue;
3962
- finalValues.add(`${p.fid}`);
3963
- }
3964
- break;
3965
- }
3966
3929
  case "STARKNET":
3967
3930
  for (const tx of block.transactions || []){
3968
3931
  const from = tx.send_address?.toLowerCase() || $dc0c078500ed1fea$var$NULL_ADDRESS;
@@ -11334,58 +11297,6 @@ const $dc0c078500ed1fea$var$filterValuesTemplate = {
11334
11297
  "0xe7f571ba7d04d6bc88f519289bc4f94a54fb25634128b3f9884d64904db32c12"
11335
11298
  ]
11336
11299
  },
11337
- {
11338
- params: {},
11339
- payload: "https://jiti.indexing.co/networks/farcaster/2442805",
11340
- output: [
11341
- "1053494",
11342
- "1066546",
11343
- "1090343",
11344
- "1131909",
11345
- "1134046",
11346
- "1134910",
11347
- "1135798",
11348
- "1139813",
11349
- "1146560",
11350
- "1148283",
11351
- "1163463",
11352
- "1164305",
11353
- "1167631",
11354
- "1167984",
11355
- "1181162",
11356
- "1182140",
11357
- "1186458",
11358
- "1198272",
11359
- "1230161",
11360
- "1275123",
11361
- "1278167",
11362
- "12938",
11363
- "1322761",
11364
- "1332557",
11365
- "1334507",
11366
- "1337870",
11367
- "1337940",
11368
- "310644",
11369
- "319554",
11370
- "377148",
11371
- "430267",
11372
- "432992",
11373
- "448300",
11374
- "455743",
11375
- "467181",
11376
- "474644",
11377
- "511842",
11378
- "541835",
11379
- "618593",
11380
- "789371",
11381
- "864838",
11382
- "897445",
11383
- "902685",
11384
- "905676",
11385
- "957928",
11386
- "969084"
11387
- ]
11388
- },
11389
11300
  {
11390
11301
  params: {},
11391
11302
  payload: "https://jiti.indexing.co/networks/hyper_core/8248362",