Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add v2 addresses endpoints #1876

Merged
merged 9 commits into from
Mar 11, 2024
Merged

feat: add v2 addresses endpoints #1876

merged 9 commits into from
Mar 11, 2024

Conversation

rafaelcr
Copy link
Collaborator

@rafaelcr rafaelcr commented Feb 27, 2024

Create 2 new address transaction endpoints:

  • /extended/v2/addresses/:address/transactions returning a list of transactions for an address including transfer summaries (example)
  • /extended/v2/addresses/:address/transactions/:tx_id/events returning a list of transfers for a specific transaction pertaining to 1 address (example)

This also deprecates the old /transactions_with_transfers endpoint

Copy link

github-actions bot commented Feb 27, 2024

Vercel deployment URL: https://stacks-blockchain-57zm3xiy4-blockstack.vercel.app 🚀

Copy link

codecov bot commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 88.79310% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 72.02%. Comparing base (cf47f8f) to head (7d92e6b).
Report is 1 commits behind head on develop.

❗ Current head 7d92e6b differs from pull request most recent head 9851d86. Consider uploading reports for the commit 9851d86 to get more accurate results

Files Patch % Lines
src/api/routes/v2/addresses.ts 78.26% 8 Missing and 2 partials ⚠️
src/datastore/pg-store-v2.ts 93.54% 2 Missing ⚠️
src/api/routes/v2/helpers.ts 96.15% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1876      +/-   ##
===========================================
+ Coverage    71.77%   72.02%   +0.25%     
===========================================
  Files           92       93       +1     
  Lines        11913    12025     +112     
  Branches      2624     2654      +30     
===========================================
+ Hits          8550     8661     +111     
+ Misses        3209     3208       -1     
- Partials       154      156       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rafaelcr rafaelcr marked this pull request as ready for review February 29, 2024 18:03
@rafaelcr rafaelcr requested review from zone117x and He1DAr February 29, 2024 18:03
@rafaelcr
Copy link
Collaborator Author

rafaelcr commented Mar 6, 2024

Will add expanded counts for mint, burn and transfer for the Explorer

src/tests/address-tests.ts Outdated Show resolved Hide resolved
const limit = args.limit ?? TransactionLimitParamSchema.default;
const offset = args.offset ?? 0;

const eventCond = sql`
Copy link
Collaborator

Choose a reason for hiding this comment

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

are there indexes for sender and recipient?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, we're good 👍

AND tx_id = ${args.tx_id}
AND (sender = ${args.address} OR recipient = ${args.address})
`;
const results = await sql<(DbAddressTransactionEvent & { count: number })[]>`
Copy link
Collaborator

Choose a reason for hiding this comment

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

would a materialized view be a good candidate here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not in this case, because event lookups are super cheap once we know the tx_id, index_block_hash and sender/recipient of what we're looking for. But thanks for looking out!

Copy link
Collaborator

@He1DAr He1DAr left a comment

Choose a reason for hiding this comment

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

LGTM, left a couple of questions.

@rafaelcr rafaelcr merged commit c9440dd into develop Mar 11, 2024
2 checks passed
@rafaelcr rafaelcr deleted the fix/txs-with-transfers branch March 11, 2024 18:25
blockstack-devops pushed a commit that referenced this pull request Mar 11, 2024
## [7.9.0-beta.1](v7.8.2...v7.9.0-beta.1) (2024-03-11)

### Features

* add v2 addresses endpoints ([#1876](#1876)) ([c9440dd](c9440dd))

### Bug Fixes

* show status endpoint in /extended ([#1869](#1869)) ([cf47f8f](cf47f8f))
@blockstack-devops
Copy link

🎉 This PR is included in version 7.9.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

blockstack-devops pushed a commit that referenced this pull request Mar 15, 2024
## [7.9.0](v7.8.2...v7.9.0) (2024-03-15)

### Features

* add v2 addresses endpoints ([#1876](#1876)) ([c9440dd](c9440dd))

### Bug Fixes

* include address transactions from genesis block ([#1888](#1888)) ([cdea9e6](cdea9e6))
* include address transactions with no stx transfers ([#1887](#1887)) ([d308e46](d308e46))
* show status endpoint in /extended ([#1869](#1869)) ([cf47f8f](cf47f8f))
@blockstack-devops
Copy link

🎉 This PR is included in version 7.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants