vocdoni / census3

Golang library and a HTTP/API service that can be used to fetch an updated list of token holders for a Ethereum ERC20, ERC721, ERC777, or other external providers (ex. POAPs or GitcoinPassport).
GNU Affero General Public License v3.0
9 stars 2 forks source link

bug: wrong synced status when outdated chains #169

Closed lucasmenendez closed 9 months ago

lucasmenendez commented 9 months ago

Now the web3 holder providers check if the last scanned block is the same that the creation block, and both are greater than the last network block (cached), and return and error to prevent false synced statuses.

Tokens with a creation block newer than the last cached network block will be scanned when the last block is updated.

Summary by CodeRabbit


github-actions[bot] commented 9 months ago

Image description CodeRabbit

Walkthrough

This update enhances the SetRef function across ERC20, ERC721, and ERC777 providers to set the creation block when it's greater than 0. It also refines the HoldersBalances function to handle outdated last network blocks and introduces error handling for this scenario. Additionally, the Web3ProviderRef struct and ScannerToken have been updated with a new CreationBlock field.

Changes

Files Summary
scanner/providers/web3/erc20_provider.go, scanner/providers/web3/erc721_provider.go, scanner/providers/web3/erc777_provider.go Improved SetRef function to set the creation block if it's greater than 0. Updated HoldersBalances function to handle cases where the last network block is outdated and added error return for this scenario.
scanner/providers/web3/web3_provider.go, scanner/scanner.go Added CreationBlock field to Web3ProviderRef struct and ScannerToken. Updated struct fields and assignments accordingly. Adjusted function signatures for consistency.

🐰 "In the land of code, changes are afoot,

With each pull request, we give bugs the boot.

From ERCs to Web3, in every provider's den,

We refine and enhance, again and again.

So here's to the updates, may they never cease,

In the quest for perfection, and coding peace." 🎉


Uplevel your code reviews with CodeRabbit Pro ### CodeRabbit Pro If you like this project, please support us by purchasing the [Pro version](https://coderabbit.ai). The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.
emmdim commented 9 months ago

LGTM