-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor!: use chainhook to listen for chain events instead of a direct stacks api connection #200
Conversation
Vercel deployment URL: https://token-metadata-eco3k2mc9-hirosystems.vercel.app 🚀 |
* fix: image cache ts * test: more * fix: code * build: use v2 docker compose * fix: admin tests * fix: try finally * test: debug logs * test: only 1 * test: one more * fix: not the timeout * fix: different ports * fix: improve test servers * fix: add cause to error message * fix: try 127.0.0.1 * fix: try timeout sleep * fix: standard close * test: more * fix: improve message * fix: echo status * fix: detect * fix: finally * fix: x * fix: timeouts * fix: revert debug stuff * chore: remove old test
* fix: try to use native sharp pipeline * fix: job queue controls, profiler * fix: tests * fix: upgrade toolkit * fix: improve error propagation * fix: listen to stream errors * fix: process cached image step by step * fix: report errors retried immediately * fix: image stream * fix: wait for sharp stream correctly
…errors (#236) * chore: demote httperror to usererror * fix: add errors * fix: custom messages
@@ -361,17 +370,25 @@ export function getContractLogMetadataUpdateNotification( | |||
} | |||
} | |||
|
|||
export type NftMintEvent = { | |||
contractId: string; | |||
tokenId: bigint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few areas where token-id
int sizes are different, like in some postgres tables it's an int32. Anything to worry about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I'll make a pass on these to double check
} | ||
} | ||
|
||
async function uploadImage(localPath: string, remoteName: string): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a good time to switch to @google-cloud/storage
#215 it would simplify a lot of the auth and streaming here. Just a suggestion, this code seems fine too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah for sure... I'll prioritize that issue to work on it next
@@ -86,6 +109,17 @@ export type DbJob = { | |||
updated_at?: string; | |||
}; | |||
|
|||
export type DbUpdateNotification = { | |||
token_id: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Token-id is type number
here, just a heads up in case it needs to handle larger int sizes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that particular token ID is a postgres ID, not a bigint clarity token ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome refactor! Left some nits but overall looks great 💯
## [1.0.0-beta.1](v0.7.0...v1.0.0-beta.1) (2024-08-21) ### ⚠ BREAKING CHANGES * use chainhook to listen for chain events instead of a direct stacks api connection (#200) ### Bug Fixes * use prometheus port configured in ENV ([c769d29](c769d29)) ### Code Refactoring * use chainhook to listen for chain events instead of a direct stacks api connection ([#200](#200)) ([2ddb2c7](2ddb2c7)), closes [#229](#229) [#232](#232) [#233](#233) [#234](#234) [#235](#235) [#236](#236)
🎉 This PR is included in version 1.0.0-beta.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
## [1.0.0](v0.7.0...v1.0.0) (2024-08-26) ### ⚠ BREAKING CHANGES * use chainhook to listen for chain events instead of a direct stacks api connection (#200) ### Features * convert data: image uris into image files and upload to cdn ([#245](#245)) ([903b0aa](903b0aa)) ### Bug Fixes * catch econnreset errors ([#247](#247)) ([51347d6](51347d6)) * set maximum job timeout ([#244](#244)) ([3444917](3444917)) * take only first page of gif images ([#241](#241)) ([334f8c5](334f8c5)) * use bignumber to handle FT supplies ([#239](#239)) ([053d622](053d622)) * use google cloud library for image uploads ([#238](#238)) ([c7f1b43](c7f1b43)) * use prometheus port configured in ENV ([c769d29](c769d29)) ### Code Refactoring * use chainhook to listen for chain events instead of a direct stacks api connection ([#200](#200)) ([2ddb2c7](2ddb2c7)), closes [#229](#229) [#232](#232) [#233](#233) [#234](#234) [#235](#235) [#236](#236)
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This PR replaces the direct connection between this API and the Stacks Blockchain API DB with a Chainhook predicate that feeds every Stacks block for analysis. This API then checks for token contract deployments, metadata notifications, and token mints in order to fetch their metadata.
This PR significantly changes the DB schema so it represents a breaking change.