@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/module.js CHANGED
@@ -3,7 +3,7 @@ import {sha256 as $hgUW1$sha256, keccak256 as $hgUW1$keccak256, decodeEventLog a
3
3
  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
- import {Address as $hgUW1$Address, Cell as $hgUW1$Cell} from "@ton/core";
6
+ import {Address as $hgUW1$Address, Cell as $hgUW1$Cell, beginCell as $hgUW1$beginCell} from "@ton/core";
7
7
  import $hgUW1$bs58 from "bs58";
8
8
 
9
9
 
@@ -178,6 +178,9 @@ const $09654dffcb68affa$var$PARTIAL_VM_TO_NETWORK_MAP = {
178
178
  TON: [
179
179
  "TON"
180
180
  ],
181
+ TRON: [
182
+ "TRON"
183
+ ],
181
184
  UTXO: [
182
185
  "BITCOIN",
183
186
  "BITCOIN_TESTNET",
@@ -4497,6 +4500,30 @@ function $e97546fe39f2692a$var$decodeJettonInternalTransfer(body) {
4497
4500
  return null;
4498
4501
  }
4499
4502
  }
4503
+ // Other TEP-74 jetton messages whose `in_msg.value` is only forwarded gas or a
4504
+ // refund — never a user-facing TON transfer. Emitting a native transfer for
4505
+ // these surfaces phantom TON hops around every jetton send:
4506
+ // 0x0f8a7ea5 transfer — owner → own jetton wallet (attached gas)
4507
+ // 0x7362d09c transfer_notification — jetton wallet → owner (forwarded gas)
4508
+ // 0xd53276db excesses — jetton wallet → response addr (gas refund)
4509
+ // `internal_transfer` (0x178d4519) is handled above as the jetton TOKEN row.
4510
+ const $e97546fe39f2692a$var$JETTON_GAS_ONLY_OPS = new Set([
4511
+ 0x0f8a7ea5,
4512
+ 0x7362d09c,
4513
+ 0xd53276db
4514
+ ]);
4515
+ // True when the message body carries one of the jetton gas-only op-codes above.
4516
+ // Reads only the 32-bit op-code; returns false for text comments, empty/non-BoC
4517
+ // bodies, or any other op — which fall through to the native path.
4518
+ function $e97546fe39f2692a$var$isJettonGasOnlyMessage(body) {
4519
+ if (!body) return false;
4520
+ try {
4521
+ const slice = (0, $hgUW1$Cell).fromBoc($e97546fe39f2692a$require$Buffer.from(body, "base64"))[0].beginParse();
4522
+ return $e97546fe39f2692a$var$JETTON_GAS_ONLY_OPS.has(slice.loadUint(32));
4523
+ } catch {
4524
+ return false;
4525
+ }
4526
+ }
4500
4527
  const $e97546fe39f2692a$export$608f3f42810b9879 = {
4501
4528
  match: (block)=>(0, $09654dffcb68affa$export$ae001c77434c5340)(block) === "TON",
4502
4529
  transform (block) {
@@ -4540,6 +4567,11 @@ const $e97546fe39f2692a$export$608f3f42810b9879 = {
4540
4567
  });
4541
4568
  continue;
4542
4569
  }
4570
+ // A jetton send's own gas hops (transfer / transfer_notification /
4571
+ // excesses) carry `in_msg.value` as forwarded gas, not a real TON
4572
+ // transfer — skip them so they don't surface as phantom native transfers
4573
+ // alongside the jetton `internal_transfer` row emitted above.
4574
+ if ($e97546fe39f2692a$var$isJettonGasOnlyMessage(inMsg.msg_data?.body)) continue;
4543
4575
  const inValue = BigInt(inMsg.value || "0");
4544
4576
  if (inValue > 0n) transfers.push({
4545
4577
  blockNumber: blockNumber,
@@ -4599,6 +4631,259 @@ const $e97546fe39f2692a$export$608f3f42810b9879 = {
4599
4631
  transactionGasFee: 233386n
4600
4632
  }
4601
4633
  ]
4634
+ },
4635
+ {
4636
+ // Jetton gas hops must not surface as native transfers. Synthetic block
4637
+ // (inline payload, no network) with four txs: a genuine native transfer,
4638
+ // an `excesses` (0xd53276db), a `transfer_notification` (0x7362d09c), and a
4639
+ // jetton `internal_transfer` (0x178d4519). Only the native and the jetton
4640
+ // rows survive; the two gas-only ops are dropped despite carrying value.
4641
+ params: {
4642
+ network: "TON"
4643
+ },
4644
+ payload: {
4645
+ _network: "TON",
4646
+ seqno: 76697922,
4647
+ shards: [
4648
+ {
4649
+ transactions: [
4650
+ {
4651
+ address: {
4652
+ account_address: "EQrecipient_native"
4653
+ },
4654
+ utime: 1782844609,
4655
+ fee: "100",
4656
+ transaction_id: {
4657
+ hash: "native-hash"
4658
+ },
4659
+ in_msg: {
4660
+ value: "1000000000",
4661
+ source: {
4662
+ account_address: "EQsender_native"
4663
+ },
4664
+ msg_data: {}
4665
+ }
4666
+ },
4667
+ {
4668
+ address: {
4669
+ account_address: "EQsubject"
4670
+ },
4671
+ utime: 1782844609,
4672
+ fee: "100",
4673
+ transaction_id: {
4674
+ hash: "excesses-hash"
4675
+ },
4676
+ in_msg: {
4677
+ value: "49490794",
4678
+ source: {
4679
+ account_address: "EQjetton_wallet"
4680
+ },
4681
+ msg_data: {
4682
+ body: (0, $hgUW1$beginCell)().storeUint(0xd53276db, 32).storeUint(0, 64).endCell().toBoc().toString("base64")
4683
+ }
4684
+ }
4685
+ },
4686
+ {
4687
+ address: {
4688
+ account_address: "EQowner"
4689
+ },
4690
+ utime: 1782844609,
4691
+ fee: "100",
4692
+ transaction_id: {
4693
+ hash: "notification-hash"
4694
+ },
4695
+ in_msg: {
4696
+ value: "49490794",
4697
+ source: {
4698
+ account_address: "EQowner_jetton_wallet"
4699
+ },
4700
+ msg_data: {
4701
+ body: (0, $hgUW1$beginCell)().storeUint(0x7362d09c, 32).storeUint(0, 64).endCell().toBoc().toString("base64")
4702
+ }
4703
+ }
4704
+ },
4705
+ {
4706
+ address: {
4707
+ account_address: "EQrecipient_jetton_wallet"
4708
+ },
4709
+ utime: 1782844609,
4710
+ fee: "200",
4711
+ transaction_id: {
4712
+ hash: "jetton-hash"
4713
+ },
4714
+ in_msg: {
4715
+ value: "49740664",
4716
+ source: {
4717
+ account_address: "EQsender_jetton_wallet"
4718
+ },
4719
+ msg_data: {
4720
+ body: (0, $hgUW1$beginCell)().storeUint(0x178d4519, 32).storeUint(0, 64).storeCoins(2800000000n).storeAddress(null).endCell().toBoc().toString("base64")
4721
+ }
4722
+ }
4723
+ }
4724
+ ]
4725
+ }
4726
+ ]
4727
+ },
4728
+ output: [
4729
+ {
4730
+ blockNumber: 76697922,
4731
+ from: "EQsender_native",
4732
+ to: "EQrecipient_native",
4733
+ amount: 1000000000n,
4734
+ token: "TON",
4735
+ tokenType: "NATIVE",
4736
+ timestamp: "2026-06-30T18:36:49.000Z",
4737
+ transactionHash: "native-hash",
4738
+ transactionGasFee: 100n
4739
+ },
4740
+ {
4741
+ blockNumber: 76697922,
4742
+ from: "EQsender_jetton_wallet",
4743
+ to: "EQrecipient_jetton_wallet",
4744
+ amount: 2800000000n,
4745
+ tokenType: "TOKEN",
4746
+ timestamp: "2026-06-30T18:36:49.000Z",
4747
+ transactionHash: "jetton-hash",
4748
+ transactionGasFee: 200n
4749
+ }
4750
+ ]
4751
+ }
4752
+ ]
4753
+ };
4754
+
4755
+
4756
+
4757
+
4758
+ const $7de02413bc6a8204$export$3cb99d88eca41d3b = {
4759
+ match: (block)=>(0, $09654dffcb68affa$export$ae001c77434c5340)(block) === "TRON",
4760
+ transform (block, _ctx = {
4761
+ params: {}
4762
+ }) {
4763
+ // Reuse the full EVM extraction — native TRX + TRC-20 (Transfer logs ride on the
4764
+ // receipts the eth-compat path already fetches).
4765
+ const evmTransfers = (0, $5ec62a2088d070a8$export$5beebc5708fabf3c).transform(block, _ctx);
4766
+ const trc10 = block._trc10 || [];
4767
+ if (!trc10.length) return evmTransfers;
4768
+ const trc10ByHash = new Map(trc10.map((t)=>[
4769
+ t.hash,
4770
+ t
4771
+ ]));
4772
+ const relabeled = new Set();
4773
+ // Relabel the phantom NATIVE that eth-compat produced for each TRC-10 tx (amount
4774
+ // → tx.value) into the real TOKEN row, keeping the EVM-computed block / timestamp
4775
+ // / gas fee and taking the authoritative asset id + amount + owner/to from the
4776
+ // native data.
4777
+ const transfers = evmTransfers.map((t)=>{
4778
+ const match = t.tokenType === "NATIVE" ? trc10ByHash.get(t.transactionHash) : undefined;
4779
+ if (!match) return t;
4780
+ relabeled.add(match.hash);
4781
+ return {
4782
+ ...t,
4783
+ tokenType: "TOKEN",
4784
+ token: match.token,
4785
+ amount: BigInt(match.amount),
4786
+ from: match.from,
4787
+ to: match.to
4788
+ };
4789
+ });
4790
+ // Defensive: a TRC-10 tx that left no phantom NATIVE to relabel (a positive-amount
4791
+ // asset transfer always sets tx.value, so this should not happen — but never drop
4792
+ // a real transfer). Emit it directly, borrowing block/timestamp/fee from any EVM
4793
+ // row on the same tx, else the block header.
4794
+ const evmByHash = new Map(evmTransfers.map((t)=>[
4795
+ t.transactionHash,
4796
+ t
4797
+ ]));
4798
+ const typedBlock = block;
4799
+ for (const m of trc10){
4800
+ if (relabeled.has(m.hash)) continue;
4801
+ const ref = evmByHash.get(m.hash);
4802
+ transfers.push({
4803
+ amount: BigInt(m.amount),
4804
+ blockNumber: ref?.blockNumber ?? Number(typedBlock.number),
4805
+ from: m.from,
4806
+ timestamp: ref?.timestamp ?? new Date(typedBlock.timestamp * 1000).toISOString(),
4807
+ to: m.to,
4808
+ token: m.token,
4809
+ tokenType: "TOKEN",
4810
+ transactionGasFee: ref?.transactionGasFee ?? 0n,
4811
+ transactionHash: m.hash
4812
+ });
4813
+ }
4814
+ return transfers;
4815
+ },
4816
+ tests: [
4817
+ {
4818
+ // Synthetic TRON block: a native TRX transfer and a TRC-10 transfer. The TRC-10
4819
+ // arrives EVM-shaped (its amount in `tx.value`, empty logs) so EVM emits a
4820
+ // phantom NATIVE; the `_trc10` supplement (asset id 1005168, à la Mircea's
4821
+ // Pay.bi repro) relabels it to a TOKEN, while the genuine native TRX is untouched.
4822
+ params: {
4823
+ network: "TRON"
4824
+ },
4825
+ payload: {
4826
+ _network: "TRON",
4827
+ number: 84058381,
4828
+ timestamp: 1782844609,
4829
+ transactions: [
4830
+ {
4831
+ hash: "native-trx-hash",
4832
+ blockNumber: 84058381,
4833
+ from: "0x1111111111111111111111111111111111111111",
4834
+ to: "0x2222222222222222222222222222222222222222",
4835
+ value: "1000000",
4836
+ receipt: {
4837
+ gasUsed: "0",
4838
+ logs: []
4839
+ }
4840
+ },
4841
+ {
4842
+ hash: "trc10-hash",
4843
+ blockNumber: 84058381,
4844
+ from: "0x3333333333333333333333333333333333333333",
4845
+ to: "0x4444444444444444444444444444444444444444",
4846
+ // eth-compat mapped the TRC-10 amount into value; asset id is gone here.
4847
+ value: "4444444444",
4848
+ receipt: {
4849
+ gasUsed: "0",
4850
+ logs: []
4851
+ }
4852
+ }
4853
+ ],
4854
+ _trc10: [
4855
+ {
4856
+ hash: "trc10-hash",
4857
+ token: "1005168",
4858
+ amount: "4444444444",
4859
+ from: "0x3333333333333333333333333333333333333333",
4860
+ to: "0x4444444444444444444444444444444444444444"
4861
+ }
4862
+ ]
4863
+ },
4864
+ output: [
4865
+ {
4866
+ amount: 1000000n,
4867
+ blockNumber: 84058381,
4868
+ from: "0x1111111111111111111111111111111111111111",
4869
+ timestamp: "2026-06-30T18:36:49.000Z",
4870
+ to: "0x2222222222222222222222222222222222222222",
4871
+ tokenType: "NATIVE",
4872
+ transactionGasFee: 0n,
4873
+ transactionHash: "native-trx-hash"
4874
+ },
4875
+ {
4876
+ amount: 4444444444n,
4877
+ blockNumber: 84058381,
4878
+ from: "0x3333333333333333333333333333333333333333",
4879
+ timestamp: "2026-06-30T18:36:49.000Z",
4880
+ to: "0x4444444444444444444444444444444444444444",
4881
+ token: "1005168",
4882
+ tokenType: "TOKEN",
4883
+ transactionGasFee: 0n,
4884
+ transactionHash: "trc10-hash"
4885
+ }
4886
+ ]
4602
4887
  }
4603
4888
  ]
4604
4889
  };
@@ -4688,6 +4973,7 @@ const $0ab1acc1eff391f6$var$SUB_TEMPLATES = [
4688
4973
  (0, $13c3ff41f568666f$export$bc6c7ab7e0727dd7),
4689
4974
  (0, $f9f6601c9222cc8e$export$722698bc663d0ac0),
4690
4975
  (0, $e97546fe39f2692a$export$608f3f42810b9879),
4976
+ (0, $7de02413bc6a8204$export$3cb99d88eca41d3b),
4691
4977
  (0, $532fac82d96b89f2$export$4f5322cf4718bd30)
4692
4978
  ];
4693
4979
  const $0ab1acc1eff391f6$var$UNIVERSAL_SUB_TEMPLATES = [
@@ -12513,6 +12799,9 @@ var $f3761421850600fb$exports = {};
12513
12799
  // Samples: 3
12514
12800
 
12515
12801
 
12802
+ var $ff207d45a6836c21$exports = {};
12803
+
12804
+
12516
12805
  var $e64a550a52a9d690$exports = {};
12517
12806
  // Auto-generated by scripts/generate-block-types.ts
12518
12807
  // Generated: 2026-03-17
@@ -12541,6 +12830,7 @@ $parcel$exportWildcard($a4e0e4b4a62175c4$exports, $e964f2aee2d00bfe$exports);
12541
12830
  $parcel$exportWildcard($a4e0e4b4a62175c4$exports, $bb1ffb53a3b14860$exports);
12542
12831
  $parcel$exportWildcard($a4e0e4b4a62175c4$exports, $480b559416e5cd89$exports);
12543
12832
  $parcel$exportWildcard($a4e0e4b4a62175c4$exports, $f3761421850600fb$exports);
12833
+ $parcel$exportWildcard($a4e0e4b4a62175c4$exports, $ff207d45a6836c21$exports);
12544
12834
  $parcel$exportWildcard($a4e0e4b4a62175c4$exports, $e64a550a52a9d690$exports);
12545
12835
 
12546
12836