@indexing/jiti 0.1.12 → 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) {
@@ -3524,65 +3525,150 @@ const $13c3ff41f568666f$export$bc6c7ab7e0727dd7 = {
3524
3525
 
3525
3526
 
3526
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
+ }
3527
3572
  const $e97546fe39f2692a$export$608f3f42810b9879 = {
3528
3573
  match: (block)=>(0, $09654dffcb68affa$export$ae001c77434c5340)(block) === "TON",
3529
3574
  transform (block) {
3530
- let transfers = [];
3575
+ const transfers = [];
3531
3576
  const typedBlock = block;
3532
3577
  const blockNumber = typedBlock.seqno;
3533
- const blockTimestamp = new Date(typedBlock.shards?.[0]?.gen_utime * 1000).toISOString();
3534
3578
  for (const shard of typedBlock.shards || [])for (const tx of shard.transactions || []){
3535
- const transactionLT = tx.transaction_id.lt;
3536
- const transactionHash = tx.transaction_id.hash;
3537
- const transactionFee = BigInt(tx.fee || "0");
3538
- const inVal = BigInt(tx.in_msg?.value || "0");
3539
- 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({
3540
3617
  blockNumber: blockNumber,
3541
- from: tx.in_msg?.source?.account_address,
3542
- to: tx.address?.account_address,
3543
- amount: inVal,
3618
+ from: inMsg.source?.account_address,
3619
+ to: to,
3620
+ amount: inValue,
3544
3621
  token: "TON",
3545
3622
  tokenType: "NATIVE",
3546
- timestamp: blockTimestamp,
3623
+ timestamp: timestamp,
3547
3624
  transactionHash: transactionHash,
3548
- transactionGasFee: transactionFee
3625
+ transactionGasFee: transactionGasFee
3549
3626
  });
3550
- for (const outMsg of tx.out_msgs || []){
3551
- const outVal = BigInt(outMsg.value || "0");
3552
- if (outVal > 0n) transfers.push({
3553
- blockNumber: blockNumber,
3554
- from: outMsg.source?.account_address,
3555
- to: outMsg.destination?.account_address,
3556
- amount: outVal,
3557
- token: "TON",
3558
- tokenType: "NATIVE",
3559
- timestamp: blockTimestamp,
3560
- transactionHash: transactionHash,
3561
- transactionGasFee: transactionFee
3562
- });
3563
- }
3564
3627
  }
3565
3628
  return transfers;
3566
3629
  },
3567
3630
  tests: [
3568
3631
  {
3632
+ // Native TON transfer — `in_msg` carries value and no jetton body.
3569
3633
  params: {
3570
3634
  network: "TON",
3571
- walletAddress: "EQAFukUyzmHjUvOYDOjNE-wbZFFl2FWas1rFJoh8IiTsWD40",
3572
- contractAddress: ""
3635
+ transactionHash: "rwDRQeWniNdxBayFcDavE/Wo35B+MsfO4lJJmvz5Edk="
3573
3636
  },
3574
- payload: "https://jiti.indexing.co/networks/ton/44919328",
3637
+ payload: "https://jiti.indexing.co/networks/ton/71399000",
3575
3638
  output: [
3576
3639
  {
3577
- blockNumber: 44919328,
3578
- from: "EQAFukUyzmHjUvOYDOjNE-wbZFFl2FWas1rFJoh8IiTsWD40",
3579
- to: "EQCFTFAHOU3vFt2NiZhRD5dwuS0k7GS59vIg3WfCKwfaQGW2",
3580
- amount: 10000000n,
3640
+ blockNumber: 71399000,
3641
+ from: "EQBkhlXTyZjri7SfyZcgFbRkjlLvq4kU3UjBTtiTtwLITn0H",
3642
+ to: "EQABGo8KCza3ea8DNHMnSWZmbRzW-05332eTdfvW-XDQEjQM",
3643
+ amount: 203686310466n,
3581
3644
  token: "TON",
3582
3645
  tokenType: "NATIVE",
3583
- timestamp: "2025-02-13T23:10:18.000Z",
3584
- transactionHash: "Vh5cWr2uvCsdhoouBQ+EiUcF54os9oqvh8A/62EroQc=",
3585
- 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
3586
3672
  }
3587
3673
  ]
3588
3674
  }