Skip to content

feat(api): add event_count to v3 transaction summaries - #2724

Merged
rafa-stacks merged 1 commit into
mainfrom
work/event-count-tx-summary-c49a53
Oct 19, 2026
Merged

rafa-stacks merged 1 commit into
mainfrom
work/event-count-tx-summary-c49a53

Conversation

@rafa-stacks

Copy link
Copy Markdown
Collaborator

Adds event_count to the v3 transaction summary, so it is now returned by every v3 endpoint that lists transaction summaries (transactions list and batch, block transactions, principal transactions, and search), not only by the single-transaction endpoint.

Sample responses below were captured from the real endpoints against a seeded test fixture. TestBlockBuilder derives block.time and sets bitcoin_block.height equal to the block height, so those values are fixture artifacts.

`GET /extended/v3/transactions?limit=1`
{
  "total": 3,
  "limit": 1,
  "cursor": {
    "next": "2:0:0",
    "previous": null,
    "current": "2:0:1"
  },
  "results": [
    {
      "tx_id": "0xc3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3",
      "sender": {
        "address": "ST3J8EVYHVKH6XXPD61EE8XEHW4Y2K83861225AB1",
        "nonce": 2
      },
      "sponsor": null,
      "fee_rate": "3000",
      "block": {
        "height": 2,
        "hash": "0x0202020202020202020202020202020202020202020202020202020202020202",
        "index_hash": "0x2222222222222222222222222222222222222222222222222222222222222222",
        "time": 94869287,
        "time_iso": "1973-01-03T00:34:47.000Z",
        "tx_index": 1
      },
      "bitcoin_block": {
        "height": 2,
        "time": 1760000600,
        "time_iso": "2025-10-09T09:03:20.000Z"
      },
      "status": "success",
      "event_count": 3,
      "type": "contract_call",
      "contract_call": {
        "contract_id": "ST000000000000000000002AMW42H.pox-5",
        "function_name": "stake"
      }
    }
  ]
}
`GET /extended/v3/blocks/2/transactions?limit=1`
{
  "total": 2,
  "limit": 1,
  "cursor": {
    "next": "2:0:0",
    "previous": null,
    "current": "2:0:1"
  },
  "results": [
    {
      "tx_id": "0xc3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3",
      "sender": {
        "address": "ST3J8EVYHVKH6XXPD61EE8XEHW4Y2K83861225AB1",
        "nonce": 2
      },
      "sponsor": null,
      "fee_rate": "3000",
      "block": {
        "height": 2,
        "hash": "0x0202020202020202020202020202020202020202020202020202020202020202",
        "index_hash": "0x2222222222222222222222222222222222222222222222222222222222222222",
        "time": 94869287,
        "time_iso": "1973-01-03T00:34:47.000Z",
        "tx_index": 1
      },
      "bitcoin_block": {
        "height": 2,
        "time": 1760000600,
        "time_iso": "2025-10-09T09:03:20.000Z"
      },
      "status": "success",
      "event_count": 3,
      "type": "contract_call",
      "contract_call": {
        "contract_id": "ST000000000000000000002AMW42H.pox-5",
        "function_name": "stake"
      }
    }
  ]
}
`GET /extended/v3/principals/{principal}/transactions?limit=1`
{
  "total": 3,
  "limit": 1,
  "cursor": {
    "next": "2:0:0",
    "previous": null,
    "current": "2:0:1"
  },
  "results": [
    {
      "transaction": {
        "tx_id": "0xc3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3",
        "sender": {
          "address": "ST3J8EVYHVKH6XXPD61EE8XEHW4Y2K83861225AB1",
          "nonce": 2
        },
        "sponsor": null,
        "fee_rate": "3000",
        "block": {
          "height": 2,
          "hash": "0x0202020202020202020202020202020202020202020202020202020202020202",
          "index_hash": "0x2222222222222222222222222222222222222222222222222222222222222222",
          "time": 94869287,
          "time_iso": "1973-01-03T00:34:47.000Z",
          "tx_index": 1
        },
        "bitcoin_block": {
          "height": 2,
          "time": 1760000600,
          "time_iso": "2025-10-09T09:03:20.000Z"
        },
        "status": "success",
        "event_count": 3,
        "type": "contract_call",
        "contract_call": {
          "contract_id": "ST000000000000000000002AMW42H.pox-5",
          "function_name": "stake"
        }
      },
      "involvement": "sender",
      "balance_changes": {
        "stx": {
          "sent": "3006",
          "received": "0",
          "net": "-3006"
        }
      },
      "affected_balances": {
        "stx": true,
        "ft": false,
        "nft": false
      }
    }
  ]
}
`GET /extended/v3/transactions/batch?tx_id=…`
{
  "results": [
    {
      "tx_id": "0xb2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2",
      "sender": {
        "address": "ST3J8EVYHVKH6XXPD61EE8XEHW4Y2K83861225AB1",
        "nonce": 1
      },
      "sponsor": null,
      "fee_rate": "180",
      "block": {
        "height": 2,
        "hash": "0x0202020202020202020202020202020202020202020202020202020202020202",
        "index_hash": "0x2222222222222222222222222222222222222222222222222222222222222222",
        "time": 94869287,
        "time_iso": "1973-01-03T00:34:47.000Z",
        "tx_index": 0
      },
      "bitcoin_block": {
        "height": 2,
        "time": 1760000600,
        "time_iso": "2025-10-09T09:03:20.000Z"
      },
      "status": "success",
      "event_count": 1,
      "type": "token_transfer",
      "token_transfer": {
        "recipient": "STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6",
        "amount": "2500000",
        "memo": {
          "hex": "0x",
          "repr": ""
        }
      }
    },
    {
      "tx_id": "0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
      "sender": {
        "address": "ST3J8EVYHVKH6XXPD61EE8XEHW4Y2K83861225AB1",
        "nonce": 0
      },
      "sponsor": null,
      "fee_rate": "0",
      "block": {
        "height": 1,
        "hash": "0x0101010101010101010101010101010101010101010101010101010101010101",
        "index_hash": "0x1111111111111111111111111111111111111111111111111111111111111111",
        "time": 94869287,
        "time_iso": "1973-01-03T00:34:47.000Z",
        "tx_index": 0
      },
      "bitcoin_block": {
        "height": 1,
        "time": 1760000000,
        "time_iso": "2025-10-09T08:53:20.000Z"
      },
      "status": "success",
      "event_count": 0,
      "type": "coinbase",
      "coinbase": {
        "alt_recipient": null
      }
    }
  ]
}
`GET /extended/v3/search?q={tx_id}&type=transaction`
{
  "results": [
    {
      "type": "transaction",
      "result": {
        "tx_id": "0xc3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3",
        "sender": {
          "address": "ST3J8EVYHVKH6XXPD61EE8XEHW4Y2K83861225AB1",
          "nonce": 2
        },
        "sponsor": null,
        "fee_rate": "3000",
        "block": {
          "height": 2,
          "hash": "0x0202020202020202020202020202020202020202020202020202020202020202",
          "index_hash": "0x2222222222222222222222222222222222222222222222222222222222222222",
          "time": 94869287,
          "time_iso": "1973-01-03T00:34:47.000Z",
          "tx_index": 1
        },
        "bitcoin_block": {
          "height": 2,
          "time": 1760000600,
          "time_iso": "2025-10-09T09:03:20.000Z"
        },
        "status": "success",
        "event_count": 3,
        "type": "contract_call",
        "contract_call": {
          "contract_id": "ST000000000000000000002AMW42H.pox-5",
          "function_name": "stake"
        }
      }
    }
  ]
}

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The shared-layer changes are consistent and no blocking issues were identified; tests were not executed.

No open issues 🎉

What changed in this PR

Adds event_count to shared v3 transaction summaries so listing endpoints expose it alongside the single-transaction endpoint.

Changes:

  • Moves the field into shared datastore types, query columns, schemas, and serialization.
  • Updates endpoint tests to assert zero and nonzero event counts.
File Description
tests/​api/​transactions/​tx-v3.test.ts Checks counts in transaction lists.
tests/​api/​transactions/​tx-batch-v3.test.ts Checks counts in batch summaries.
tests/​api/​principal-v3/​principals.test.ts Updates principal transaction expectations.
tests/​api/​blocks/​block-v3.test.ts Checks counts in block transactions.
src/​datastore/​v3/​types.ts Adds the field to the shared summary type.
src/​datastore/​v3/​constants.ts Includes the field in summary queries.
src/​api/​serializers/​v3/​transactions.ts Serializes the field through shared summaries.
src/​api/​schemas/​v3/​entities/​transactions.ts Removes the redundant full-transaction declaration.
src/​api/​schemas/​v3/​entities/​transaction-summaries.ts Declares the field in the shared response schema.

Review effort: Balanced

@rafa-stacks
rafa-stacks marked this pull request as ready for review October 19, 2026 21:11
@rafa-stacks
rafa-stacks merged commit 9643f21 into main Oct 19, 2026
27 checks passed
@rafa-stacks
rafa-stacks deleted the work/event-count-tx-summary-c49a53 branch October 19, 2026 21:18
@github-project-automation github-project-automation Bot moved this to ✅ Done in API Board Oct 19, 2026

This branch was successfully deployed

1 active deployment
Production — 6de6bde1 Deployed Oct 19, 2026 by rafa-stacks via build-publish #3846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants