@indexing/jiti 0.1.20 → 0.1.22

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
@@ -196,6 +196,9 @@ const $6bd2ca253e883278$var$PARTIAL_VM_TO_NETWORK_MAP = {
196
196
  TON: [
197
197
  "TON"
198
198
  ],
199
+ TRON: [
200
+ "TRON"
201
+ ],
199
202
  UTXO: [
200
203
  "BITCOIN",
201
204
  "BITCOIN_TESTNET",
@@ -4515,6 +4518,30 @@ function $cd430dd11c31e572$var$decodeJettonInternalTransfer(body) {
4515
4518
  return null;
4516
4519
  }
4517
4520
  }
4521
+ // Other TEP-74 jetton messages whose `in_msg.value` is only forwarded gas or a
4522
+ // refund — never a user-facing TON transfer. Emitting a native transfer for
4523
+ // these surfaces phantom TON hops around every jetton send:
4524
+ // 0x0f8a7ea5 transfer — owner → own jetton wallet (attached gas)
4525
+ // 0x7362d09c transfer_notification — jetton wallet → owner (forwarded gas)
4526
+ // 0xd53276db excesses — jetton wallet → response addr (gas refund)
4527
+ // `internal_transfer` (0x178d4519) is handled above as the jetton TOKEN row.
4528
+ const $cd430dd11c31e572$var$JETTON_GAS_ONLY_OPS = new Set([
4529
+ 0x0f8a7ea5,
4530
+ 0x7362d09c,
4531
+ 0xd53276db
4532
+ ]);
4533
+ // True when the message body carries one of the jetton gas-only op-codes above.
4534
+ // Reads only the 32-bit op-code; returns false for text comments, empty/non-BoC
4535
+ // bodies, or any other op — which fall through to the native path.
4536
+ function $cd430dd11c31e572$var$isJettonGasOnlyMessage(body) {
4537
+ if (!body) return false;
4538
+ try {
4539
+ const slice = (0, $8zHUo$toncore.Cell).fromBoc($cd430dd11c31e572$require$Buffer.from(body, "base64"))[0].beginParse();
4540
+ return $cd430dd11c31e572$var$JETTON_GAS_ONLY_OPS.has(slice.loadUint(32));
4541
+ } catch {
4542
+ return false;
4543
+ }
4544
+ }
4518
4545
  const $cd430dd11c31e572$export$608f3f42810b9879 = {
4519
4546
  match: (block)=>(0, $6bd2ca253e883278$export$ae001c77434c5340)(block) === "TON",
4520
4547
  transform (block) {
@@ -4558,6 +4585,11 @@ const $cd430dd11c31e572$export$608f3f42810b9879 = {
4558
4585
  });
4559
4586
  continue;
4560
4587
  }
4588
+ // A jetton send's own gas hops (transfer / transfer_notification /
4589
+ // excesses) carry `in_msg.value` as forwarded gas, not a real TON
4590
+ // transfer — skip them so they don't surface as phantom native transfers
4591
+ // alongside the jetton `internal_transfer` row emitted above.
4592
+ if ($cd430dd11c31e572$var$isJettonGasOnlyMessage(inMsg.msg_data?.body)) continue;
4561
4593
  const inValue = BigInt(inMsg.value || "0");
4562
4594
  if (inValue > 0n) transfers.push({
4563
4595
  blockNumber: blockNumber,
@@ -4617,6 +4649,259 @@ const $cd430dd11c31e572$export$608f3f42810b9879 = {
4617
4649
  transactionGasFee: 233386n
4618
4650
  }
4619
4651
  ]
4652
+ },
4653
+ {
4654
+ // Jetton gas hops must not surface as native transfers. Synthetic block
4655
+ // (inline payload, no network) with four txs: a genuine native transfer,
4656
+ // an `excesses` (0xd53276db), a `transfer_notification` (0x7362d09c), and a
4657
+ // jetton `internal_transfer` (0x178d4519). Only the native and the jetton
4658
+ // rows survive; the two gas-only ops are dropped despite carrying value.
4659
+ params: {
4660
+ network: "TON"
4661
+ },
4662
+ payload: {
4663
+ _network: "TON",
4664
+ seqno: 76697922,
4665
+ shards: [
4666
+ {
4667
+ transactions: [
4668
+ {
4669
+ address: {
4670
+ account_address: "EQrecipient_native"
4671
+ },
4672
+ utime: 1782844609,
4673
+ fee: "100",
4674
+ transaction_id: {
4675
+ hash: "native-hash"
4676
+ },
4677
+ in_msg: {
4678
+ value: "1000000000",
4679
+ source: {
4680
+ account_address: "EQsender_native"
4681
+ },
4682
+ msg_data: {}
4683
+ }
4684
+ },
4685
+ {
4686
+ address: {
4687
+ account_address: "EQsubject"
4688
+ },
4689
+ utime: 1782844609,
4690
+ fee: "100",
4691
+ transaction_id: {
4692
+ hash: "excesses-hash"
4693
+ },
4694
+ in_msg: {
4695
+ value: "49490794",
4696
+ source: {
4697
+ account_address: "EQjetton_wallet"
4698
+ },
4699
+ msg_data: {
4700
+ body: (0, $8zHUo$toncore.beginCell)().storeUint(0xd53276db, 32).storeUint(0, 64).endCell().toBoc().toString("base64")
4701
+ }
4702
+ }
4703
+ },
4704
+ {
4705
+ address: {
4706
+ account_address: "EQowner"
4707
+ },
4708
+ utime: 1782844609,
4709
+ fee: "100",
4710
+ transaction_id: {
4711
+ hash: "notification-hash"
4712
+ },
4713
+ in_msg: {
4714
+ value: "49490794",
4715
+ source: {
4716
+ account_address: "EQowner_jetton_wallet"
4717
+ },
4718
+ msg_data: {
4719
+ body: (0, $8zHUo$toncore.beginCell)().storeUint(0x7362d09c, 32).storeUint(0, 64).endCell().toBoc().toString("base64")
4720
+ }
4721
+ }
4722
+ },
4723
+ {
4724
+ address: {
4725
+ account_address: "EQrecipient_jetton_wallet"
4726
+ },
4727
+ utime: 1782844609,
4728
+ fee: "200",
4729
+ transaction_id: {
4730
+ hash: "jetton-hash"
4731
+ },
4732
+ in_msg: {
4733
+ value: "49740664",
4734
+ source: {
4735
+ account_address: "EQsender_jetton_wallet"
4736
+ },
4737
+ msg_data: {
4738
+ body: (0, $8zHUo$toncore.beginCell)().storeUint(0x178d4519, 32).storeUint(0, 64).storeCoins(2800000000n).storeAddress(null).endCell().toBoc().toString("base64")
4739
+ }
4740
+ }
4741
+ }
4742
+ ]
4743
+ }
4744
+ ]
4745
+ },
4746
+ output: [
4747
+ {
4748
+ blockNumber: 76697922,
4749
+ from: "EQsender_native",
4750
+ to: "EQrecipient_native",
4751
+ amount: 1000000000n,
4752
+ token: "TON",
4753
+ tokenType: "NATIVE",
4754
+ timestamp: "2026-06-30T18:36:49.000Z",
4755
+ transactionHash: "native-hash",
4756
+ transactionGasFee: 100n
4757
+ },
4758
+ {
4759
+ blockNumber: 76697922,
4760
+ from: "EQsender_jetton_wallet",
4761
+ to: "EQrecipient_jetton_wallet",
4762
+ amount: 2800000000n,
4763
+ tokenType: "TOKEN",
4764
+ timestamp: "2026-06-30T18:36:49.000Z",
4765
+ transactionHash: "jetton-hash",
4766
+ transactionGasFee: 200n
4767
+ }
4768
+ ]
4769
+ }
4770
+ ]
4771
+ };
4772
+
4773
+
4774
+
4775
+
4776
+ const $3ac9986ae4227040$export$3cb99d88eca41d3b = {
4777
+ match: (block)=>(0, $6bd2ca253e883278$export$ae001c77434c5340)(block) === "TRON",
4778
+ transform (block, _ctx = {
4779
+ params: {}
4780
+ }) {
4781
+ // Reuse the full EVM extraction — native TRX + TRC-20 (Transfer logs ride on the
4782
+ // receipts the eth-compat path already fetches).
4783
+ const evmTransfers = (0, $8deaea1ef39b6485$export$5beebc5708fabf3c).transform(block, _ctx);
4784
+ const trc10 = block._trc10 || [];
4785
+ if (!trc10.length) return evmTransfers;
4786
+ const trc10ByHash = new Map(trc10.map((t)=>[
4787
+ t.hash,
4788
+ t
4789
+ ]));
4790
+ const relabeled = new Set();
4791
+ // Relabel the phantom NATIVE that eth-compat produced for each TRC-10 tx (amount
4792
+ // → tx.value) into the real TOKEN row, keeping the EVM-computed block / timestamp
4793
+ // / gas fee and taking the authoritative asset id + amount + owner/to from the
4794
+ // native data.
4795
+ const transfers = evmTransfers.map((t)=>{
4796
+ const match = t.tokenType === "NATIVE" ? trc10ByHash.get(t.transactionHash) : undefined;
4797
+ if (!match) return t;
4798
+ relabeled.add(match.hash);
4799
+ return {
4800
+ ...t,
4801
+ tokenType: "TOKEN",
4802
+ token: match.token,
4803
+ amount: BigInt(match.amount),
4804
+ from: match.from,
4805
+ to: match.to
4806
+ };
4807
+ });
4808
+ // Defensive: a TRC-10 tx that left no phantom NATIVE to relabel (a positive-amount
4809
+ // asset transfer always sets tx.value, so this should not happen — but never drop
4810
+ // a real transfer). Emit it directly, borrowing block/timestamp/fee from any EVM
4811
+ // row on the same tx, else the block header.
4812
+ const evmByHash = new Map(evmTransfers.map((t)=>[
4813
+ t.transactionHash,
4814
+ t
4815
+ ]));
4816
+ const typedBlock = block;
4817
+ for (const m of trc10){
4818
+ if (relabeled.has(m.hash)) continue;
4819
+ const ref = evmByHash.get(m.hash);
4820
+ transfers.push({
4821
+ amount: BigInt(m.amount),
4822
+ blockNumber: ref?.blockNumber ?? Number(typedBlock.number),
4823
+ from: m.from,
4824
+ timestamp: ref?.timestamp ?? new Date(typedBlock.timestamp * 1000).toISOString(),
4825
+ to: m.to,
4826
+ token: m.token,
4827
+ tokenType: "TOKEN",
4828
+ transactionGasFee: ref?.transactionGasFee ?? 0n,
4829
+ transactionHash: m.hash
4830
+ });
4831
+ }
4832
+ return transfers;
4833
+ },
4834
+ tests: [
4835
+ {
4836
+ // Synthetic TRON block: a native TRX transfer and a TRC-10 transfer. The TRC-10
4837
+ // arrives EVM-shaped (its amount in `tx.value`, empty logs) so EVM emits a
4838
+ // phantom NATIVE; the `_trc10` supplement (asset id 1005168, à la Mircea's
4839
+ // Pay.bi repro) relabels it to a TOKEN, while the genuine native TRX is untouched.
4840
+ params: {
4841
+ network: "TRON"
4842
+ },
4843
+ payload: {
4844
+ _network: "TRON",
4845
+ number: 84058381,
4846
+ timestamp: 1782844609,
4847
+ transactions: [
4848
+ {
4849
+ hash: "native-trx-hash",
4850
+ blockNumber: 84058381,
4851
+ from: "0x1111111111111111111111111111111111111111",
4852
+ to: "0x2222222222222222222222222222222222222222",
4853
+ value: "1000000",
4854
+ receipt: {
4855
+ gasUsed: "0",
4856
+ logs: []
4857
+ }
4858
+ },
4859
+ {
4860
+ hash: "trc10-hash",
4861
+ blockNumber: 84058381,
4862
+ from: "0x3333333333333333333333333333333333333333",
4863
+ to: "0x4444444444444444444444444444444444444444",
4864
+ // eth-compat mapped the TRC-10 amount into value; asset id is gone here.
4865
+ value: "4444444444",
4866
+ receipt: {
4867
+ gasUsed: "0",
4868
+ logs: []
4869
+ }
4870
+ }
4871
+ ],
4872
+ _trc10: [
4873
+ {
4874
+ hash: "trc10-hash",
4875
+ token: "1005168",
4876
+ amount: "4444444444",
4877
+ from: "0x3333333333333333333333333333333333333333",
4878
+ to: "0x4444444444444444444444444444444444444444"
4879
+ }
4880
+ ]
4881
+ },
4882
+ output: [
4883
+ {
4884
+ amount: 1000000n,
4885
+ blockNumber: 84058381,
4886
+ from: "0x1111111111111111111111111111111111111111",
4887
+ timestamp: "2026-06-30T18:36:49.000Z",
4888
+ to: "0x2222222222222222222222222222222222222222",
4889
+ tokenType: "NATIVE",
4890
+ transactionGasFee: 0n,
4891
+ transactionHash: "native-trx-hash"
4892
+ },
4893
+ {
4894
+ amount: 4444444444n,
4895
+ blockNumber: 84058381,
4896
+ from: "0x3333333333333333333333333333333333333333",
4897
+ timestamp: "2026-06-30T18:36:49.000Z",
4898
+ to: "0x4444444444444444444444444444444444444444",
4899
+ token: "1005168",
4900
+ tokenType: "TOKEN",
4901
+ transactionGasFee: 0n,
4902
+ transactionHash: "trc10-hash"
4903
+ }
4904
+ ]
4620
4905
  }
4621
4906
  ]
4622
4907
  };
@@ -4706,6 +4991,7 @@ const $7dd402f6ad0dab6a$var$SUB_TEMPLATES = [
4706
4991
  (0, $11a2c5b0fd56c033$export$bc6c7ab7e0727dd7),
4707
4992
  (0, $3b9b8f5747dcca8e$export$722698bc663d0ac0),
4708
4993
  (0, $cd430dd11c31e572$export$608f3f42810b9879),
4994
+ (0, $3ac9986ae4227040$export$3cb99d88eca41d3b),
4709
4995
  (0, $990c4f660694d8bc$export$4f5322cf4718bd30)
4710
4996
  ];
4711
4997
  const $7dd402f6ad0dab6a$var$UNIVERSAL_SUB_TEMPLATES = [
@@ -12531,6 +12817,9 @@ var $4828ba704a8a504f$exports = {};
12531
12817
  // Samples: 3
12532
12818
 
12533
12819
 
12820
+ var $1683c098f2192b9f$exports = {};
12821
+
12822
+
12534
12823
  var $4a8e5fd52443a474$exports = {};
12535
12824
  // Auto-generated by scripts/generate-block-types.ts
12536
12825
  // Generated: 2026-03-17
@@ -12559,6 +12848,7 @@ $parcel$exportWildcard($b4b970cc11bce2a5$exports, $2c47a7d2c09ba685$exports);
12559
12848
  $parcel$exportWildcard($b4b970cc11bce2a5$exports, $de65544ccdf7550c$exports);
12560
12849
  $parcel$exportWildcard($b4b970cc11bce2a5$exports, $bfa1637983c7bdd8$exports);
12561
12850
  $parcel$exportWildcard($b4b970cc11bce2a5$exports, $4828ba704a8a504f$exports);
12851
+ $parcel$exportWildcard($b4b970cc11bce2a5$exports, $1683c098f2192b9f$exports);
12562
12852
  $parcel$exportWildcard($b4b970cc11bce2a5$exports, $4a8e5fd52443a474$exports);
12563
12853
 
12564
12854