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

Add airdrop tool #204

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open

Add airdrop tool #204

wants to merge 65 commits into from

Conversation

trungnt1811
Copy link
Collaborator

@trungnt1811 trungnt1811 commented May 3, 2024

Close #113

Notes

  • This PR adds a tool that retrieves the latest height of each chain, fetches all delegations from all validators of each chain, calculates rewards, and writes the results to a JSON file in bank balance format.
  • Currently, the logic is done with composable chain at this repo (https://github.com/notional-labs/airdrop).
  • This PR involves extending this feature to support all chains.
  • Implement concurrent data fetching using goroutines to improve performance.

Summary by CodeRabbit

  • New Features

    • Introduced utility functions for handling HTTP requests, gRPC connections, and processing data related to validators, delegations, token prices, and token information.
  • Chores

    • Updated .gitignore to include files related to an Airdrop tool.
    • Added a Makefile for building the airdropd executable.
    • Updated dependencies in go.mod for the airdrop module.
  • Documentation

    • Provided summaries for various functions and packages related to reward calculations for different blockchain networks.

@trungnt1811 trungnt1811 marked this pull request as draft May 3, 2024 02:40
Copy link
Contributor

coderabbitai bot commented May 3, 2024

Walkthrough

This update introduces changes to the airdrop functionality by incorporating the snapshot process of various Cosmos chains. It enhances existing modules with robust reward calculation logic for different chains while adding new utility functions for efficient data handling and improving configuration management.

Changes

Files/Modules Change Summary
.gitignore, airdrop/.gitignore Updated .gitignore to manage new files and scripts related to the airdrop tool.
airdrop/backoff/backoff.go Introduced exponential backoff strategy using the backoff library.
airdrop/chains/*.go Added reward and balance calculation logic for multiple chains (e.g., Akash, Bostrom, Celestia, etc.).
airdrop/config/constant.go, airdrop/config/types.go Defined constants and added new data structures for configuration management.
airdrop/main.go Facilitates orchestration of balance calculations, error handling, and airdrop generation.
airdrop/utils/utils.go Added utility functions for handling HTTP requests, gRPC, token data, and balance calculations.
go.mod, airdrop/go.mod Updated dependencies and versions in go.mod files.
airdrop/Makefile Introduced build logic to compile the airdropd executable.

Assessment against linked issues

Objective Addressed Explanation
Snapshot process for different Cosmos chains and reward calculation (#113)
Inclusion of new chains like Composable, Celestia, Neutron, Luna, etc. (#113)
Filtering out accounts with dust staking amounts less than $20 (#113)
Utilizing various backend tools and cosmos SDK modules for processing (#113)
Ensure proper reward distribution percentages (e.g., Composable 13%) (#113) Weights and percentages are subject to finalization.

Poem

Amidst the stars, rewards do gleam,
For deeds and staked ethereal dream.
Oh Cosmos, Akash, and Celestia bright,
In tokens and NFTs, we share the light.
Rabbits leap with joyful cheer,
Airdrops aplenty for all to hear. 🍀✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 30

airdrop/cosmosnft.go Outdated Show resolved Hide resolved
airdrop/cosmosnft.go Outdated Show resolved Hide resolved
airdrop/cosmosnft.go Outdated Show resolved Hide resolved
airdrop/terra.go Outdated Show resolved Hide resolved
airdrop/neutron.go Outdated Show resolved Hide resolved
airdrop/composable.go Outdated Show resolved Hide resolved
airdrop/bostrom.go Outdated Show resolved Hide resolved
airdrop/bostrom.go Outdated Show resolved Hide resolved
airdrop/celestia.go Outdated Show resolved Hide resolved
airdrop/celestia.go Outdated Show resolved Hide resolved
@trungnt1811
Copy link
Collaborator Author

@coderabbitai review

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

airdrop/terra.go Outdated Show resolved Hide resolved
airdrop/main.go Outdated Show resolved Hide resolved
airdrop/main.go Outdated Show resolved Hide resolved
airdrop/main.go Outdated Show resolved Hide resolved
@trungnt1811
Copy link
Collaborator Author

@coderabbitai review

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

airdrop/main.go Outdated Show resolved Hide resolved
@trungnt1811
Copy link
Collaborator Author

@coderabbitai review

airdrop/main.go Fixed Show fixed Hide fixed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 02941b1 and 9a4b51d.

Files selected for processing (2)
  • airdrop/chains/terra.go (1 hunks)
  • airdrop/utils/utils.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • airdrop/chains/terra.go
Additional comments not posted (2)
airdrop/utils/utils.go (2)

39-53: Ensure proper resource management in HTTP requests.

The MakeGetRequest function creates an HTTP request but does not ensure that the response body is closed in case of errors before returning. This can lead to resource leaks. Consider adding a deferred close after checking the error from the Do method.

+ if res != nil {
+     defer res.Body.Close()
+ }

266-281: Refactor to centralize error handling and retry logic.

The previous comment about centralizing error handling and retry logic is still valid here. Consider applying the same refactor to the RetryableBalanceFunc.

airdrop/utils/utils.go Outdated Show resolved Hide resolved
airdrop/utils/utils.go Show resolved Hide resolved
airdrop/utils/utils.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9a4b51d and acb2fe9.

Files selected for processing (2)
  • airdrop/config/constant.go (1 hunks)
  • airdrop/main.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • airdrop/config/constant.go
  • airdrop/main.go

@faddat
Copy link
Contributor

faddat commented Jul 4, 2024

I'm thinking to merge this and then stick it into the CI system.

Thank you.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between acb2fe9 and 2de323a.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (1)
  • go.mod (8 hunks)
Additional comments not posted (4)
go.mod (4)

31-31: Verify impact of gRPC update.

Ensure that the update to google.golang.org/grpc v1.64.0 does not introduce any breaking changes or incompatibilities in the project.


78-78: Verify impact of bitset update.

Ensure that the update to github.com/bits-and-blooms/bitset v1.11.0 does not introduce any breaking changes or incompatibilities in the project.


80-80: Verify impact of backoff update.

Ensure that the update to github.com/cenkalti/backoff/v4 v4.3.0 does not introduce any breaking changes or incompatibilities in the project.


106-106: Verify necessity and impact of new dependencies.

Ensure that the new dependencies github.com/ethereum/go-ethereum v1.14.3, github.com/holiman/uint256 v1.2.4, github.com/joho/godotenv v1.5.1, and github.com/onsi/gomega v1.30.0 are necessary and do not introduce any security vulnerabilities or significant performance overhead.

Also applies to: 147-147, 154-154, 172-172

@trungnt1811
Copy link
Collaborator Author

trungnt1811 commented Jul 4, 2024

I'm thinking to merge this and then stick it into the CI system.

Thank you.

I think we can still make the codebase more readable and maintainable. A bit of refactoring is necessary, and I'll take care of it. I'll also change this PR to draft before refactoring.

@trungnt1811 trungnt1811 marked this pull request as draft July 4, 2024 04:25
@trungnt1811 trungnt1811 marked this pull request as ready for review July 8, 2024 06:51
@trungnt1811
Copy link
Collaborator Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jul 8, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

1 similar comment
Copy link
Contributor

coderabbitai bot commented Jul 8, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 22

Outside diff range and nitpick comments (26)
airdrop/chains/terra.go (5)

23-24: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to fetch validators for Terra: %v\n", err)
+ log.Printf("Failed to fetch validators for Terra using URL %s: %v\n", config.GetTerraConfig().API, err)

36-37: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to fetch delegations for validator %s at Terra: %v\n", validator.OperatorAddress, err)
+ log.Printf("Failed to fetch delegations for validator %s at Terra using URL %s: %v\n", validator.OperatorAddress, config.GetTerraConfig().API, err)

48-49: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to fetch Terra token price: %v", err)
+ log.Printf("Failed to fetch Terra token price from CoinID %s: %v", config.GetTerraConfig().CoinID, err)

65-66: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to convert EveAirdrop string to dec: %v", err)
+ log.Printf("Failed to convert EveAirdrop string %s to dec: %v", config.EveAirdrop, err)

85-86: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to convert Terra bech32 address for delegator %s: %v\n", delegator.Delegation.DelegatorAddress, err)
+ log.Printf("Failed to convert Terra bech32 address for delegator %s with address %s: %v\n", delegator.Delegation.DelegatorAddress, eveBech32Address, err)
airdrop/chains/stargaze.go (8)

20-21: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Error loading Stargaze environment variables: %v", err)
+ log.Printf("Error loading Stargaze environment variables from .env file: %v", err)

26-27: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to get latest height for Stargaze: %v", err)
+ log.Printf("Failed to get latest height for Stargaze using URL %s: %v", config.GetStargazeConfig().RPC+"/status", err)

32-33: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to connect to gRPC Stargaze: %v", err)
+ log.Printf("Failed to connect to gRPC Stargaze using address %s: %v", config.GetStargazeConfig().GRPCAddr, err)

40-41: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to get Stargaze validators: %v", err)
+ log.Printf("Failed to get Stargaze validators at block height %s: %v", blockHeight, err)

48-49: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to query delegate info for Stagaze validator: %v", err)
+ log.Printf("Failed to query delegate info for Stagaze validator %s at block height %s: %v", validator.OperatorAddress, blockHeight, err)

58-59: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to fetch Stargaze token price: %v", err)
+ log.Printf("Failed to fetch Stargaze token price from CoinID %s: %v", config.GetStargazeConfig().CoinID, err)

73-74: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to convert EveAirdrop string to dec: %v", err)
+ log.Printf("Failed to convert EveAirdrop string %s to dec: %v", config.EveAirdrop, err)

88-89: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to convert Stargaze bech32 address: %v", err)
+ log.Printf("Failed to convert Stargaze bech32 address for delegator %s: %v", delegator.Delegation.DelegatorAddress, err)
airdrop/chains/sentinel.go (8)

21-22: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Error loading Sentinel environment variables: %v", err)
+ log.Printf("Error loading Sentinel environment variables from .env file: %v", err)

27-28: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to get latest height for Sentinel: %v", err)
+ log.Printf("Failed to get latest height for Sentinel using URL %s: %v", config.GetSentinelConfig().RPC+"/status", err)

33-34: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to connect to gRPC Sentinel: %v", err)
+ log.Printf("Failed to connect to gRPC Sentinel using address %s: %v", config.GetSentinelConfig().GRPCAddr, err)

41-42: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to get Sentinel validators: %v", err)
+ log.Printf("Failed to get Sentinel validators at block height %s: %v", blockHeight, err)

50-51: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to query delegate info for Sentinel validator: %v", err)
+ log.Printf("Failed to query delegate info for Sentinel validator %s at block height %s: %v", validator.OperatorAddress, blockHeight, err)

61-62: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to fetch Sentinel token price: %v", err)
+ log.Printf("Failed to fetch Sentinel token price from CoinID %s: %v", config.GetSentinelConfig().CoinID, err)

78-79: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to convert EveAirdrop string to dec: %v", err)
+ log.Printf("Failed to convert EveAirdrop string %s to dec: %v", config.EveAirdrop, err)

94-95: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to convert Sentinel bech32 address: %v", err)
+ log.Printf("Failed to convert Sentinel bech32 address for delegator %s: %v", delegator.Delegation.DelegatorAddress, err)
airdrop/chains/akash.go (5)

21-22: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Error loading Akash environment variables: %v", err)
+ log.Printf("Error loading Akash environment variables from .env file: %v", err)

27-28: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to get latest height for Akash: %v", err)
+ log.Printf("Failed to get latest height for Akash using URL %s: %v", config.GetAkashConfig().RPC+"/status", err)

36-37: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to connect to gRPC Akash: %v", err)
+ log.Printf("Failed to connect to gRPC Akash using address %s: %v", config.GetAkashConfig().GRPCAddr, err)

47-48: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to get Akash validators: %v", err)
+ log.Printf("Failed to get Akash validators at block height %s: %v", blockHeight, err)

56-57: Enhance error logging for better traceability.

Consider enhancing the error logging by including more context about the operation being performed. This can help in debugging issues more effectively.

- log.Printf("Failed to query delegate info for Akash validator: %v", err)
+ log.Printf("Failed to query delegate info for Akash validator %s at block height %s: %v", validator.OperatorAddress, blockHeight

</blockquote></details>

</blockquote></details>

<details>
<summary>Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**

<details>
<summary>Commits</summary>

Files that changed from the base of the PR and between 2de323a93bfe78b02dd06eb1e480f9f71ca0313c and 9968d3a3ea60508cc60bca64fbede1fbfa0ceff0.

</details>
<details>
<summary>Files ignored due to path filters (1)</summary>

* `airdrop/go.sum` is excluded by `!**/*.sum`

</details>

<details>
<summary>Files selected for processing (18)</summary>

* airdrop/.gitignore (1 hunks)
* airdrop/Makefile (1 hunks)
* airdrop/chains/akash.go (1 hunks)
* airdrop/chains/bostrom.go (1 hunks)
* airdrop/chains/celestia.go (1 hunks)
* airdrop/chains/composable.go (1 hunks)
* airdrop/chains/cosmos.go (1 hunks)
* airdrop/chains/cosmosnft.go (1 hunks)
* airdrop/chains/ethereumnft.go (1 hunks)
* airdrop/chains/neutron.go (1 hunks)
* airdrop/chains/sentinel.go (1 hunks)
* airdrop/chains/stargaze.go (1 hunks)
* airdrop/chains/terra.go (1 hunks)
* airdrop/chains/terrac.go (1 hunks)
* airdrop/cmd/airdrop/main.go (1 hunks)
* airdrop/config/constant.go (1 hunks)
* airdrop/go.mod (1 hunks)
* airdrop/utils/utils.go (1 hunks)

</details>






<details>
<summary>Files skipped from review due to trivial changes (2)</summary>

* airdrop/.gitignore
* airdrop/config/constant.go

</details>




<details>
<summary>Additional comments not posted (33)</summary><blockquote>

<details>
<summary>airdrop/Makefile (1)</summary><blockquote>

`1-3`: **LGTM! Ensure the build target is correctly defined.**

The build target `airdrop-tool` uses the `go build` command to compile the `airdropd` executable from the `cmd/airdrop` directory. Ensure that the directory structure is correct and the `cmd/airdrop` directory contains the main package.

</blockquote></details>
<details>
<summary>airdrop/chains/bostrom.go (1)</summary><blockquote>

`63-67`: **Improve error handling.**

Instead of logging the error and returning a new error, consider wrapping the original error with additional context using `fmt.Errorf`.

```diff
-    log.Printf("Failed to convert EveAirdrop string to dec: %v", err)
-    return nil, nil, 0, fmt.Errorf("failed to convert EveAirdrop string to dec: %w", err)
+    return nil, nil, 0, fmt.Errorf("failed to convert EveAirdrop string to dec: %w", err)

Likely invalid or redundant comment.

airdrop/chains/terrac.go (1)

46-50: Improve error handling.

Instead of logging the error and returning a new error, consider wrapping the original error with additional context using fmt.Errorf.

-    log.Printf("Failed to fetch TerraC token price: %v", err)
-    return nil, nil, 0, fmt.Errorf("failed to fetch TerraC token price: %w", err)
+    return nil, nil, 0, fmt.Errorf("failed to fetch TerraC token price: %w", err)

Likely invalid or redundant comment.

airdrop/chains/neutron.go (3)

87-90: Improve error handling.

Instead of logging the error and returning a new error, consider wrapping the original error with additional context using fmt.Errorf.

-    return nil, fmt.Errorf("failed to connect to gRPC Neutron: %w", err)
+    return nil, fmt.Errorf("failed to connect to gRPC Neutron: %w", err)

Likely invalid or redundant comment.


112-114: Improve error handling.

Instead of logging the error and returning a new error, consider wrapping the original error with additional context using fmt.Errorf.

-    return nil, fmt.Errorf("failed to query all Neutron's denom owners: %w", err)
+    return nil, fmt.Errorf("failed to query all Neutron's denom owners: %w", err)

Likely invalid or redundant comment.


34-38: Improve error handling.

Instead of logging the error and returning a new error, consider wrapping the original error with additional context using fmt.Errorf.

-    log.Printf("Failed to fetch Neutron token price: %v", err)
-    return nil, nil, 0, fmt.Errorf("failed to fetch Neutron token price: %w", err)
+    return nil, nil, 0, fmt.Errorf("failed to fetch Neutron token price: %w", err)

Likely invalid or redundant comment.

airdrop/chains/cosmos.go (1)

32-39: Improve error handling.

Instead of logging the error and returning a new error, consider wrapping the original error with additional context using fmt.Errorf.

-    log.Printf("Failed to fetch Delegations for Cosmos: %v", err)
-    return nil, nil, 0, fmt.Errorf("failed to fetch Delegations for Cosmos: %w", err)
+    return nil, nil, 0, fmt.Errorf("failed to fetch Delegations for Cosmos: %w", err)

Likely invalid or redundant comment.

airdrop/chains/celestia.go (6)

19-23: LGTM!

Environment variables are loaded correctly and errors are handled appropriately.


25-30: LGTM!

Fetching the latest block height is handled correctly and errors are logged appropriately.


32-37: LGTM!

Setting up the gRPC connection is handled correctly and errors are logged appropriately.


41-46: LGTM!

Fetching validators is handled correctly and errors are logged appropriately.


49-63: LGTM!

Fetching delegations for each validator is handled correctly and errors are logged appropriately.


65-70: LGTM!

Calculating the token price and threshold is handled correctly and errors are logged appropriately.

airdrop/chains/composable.go (6)

19-23: LGTM!

Environment variables are loaded correctly and errors are handled appropriately.


25-30: LGTM!

Fetching the latest block height is handled correctly and errors are logged appropriately.


32-37: LGTM!

Setting up the gRPC connection is handled correctly and errors are logged appropriately.


41-46: LGTM!

Fetching validators is handled correctly and errors are logged appropriately.


49-61: LGTM!

Fetching delegations for each validator is handled correctly and errors are logged appropriately.


63-68: LGTM!

Calculating the token price and threshold is handled correctly and errors are logged appropriately.

airdrop/go.mod (4)

1-5: LGTM!

Module declaration and Go version are specified correctly.


7-28: LGTM!

Required dependencies are listed correctly.


30-36: LGTM!

Additional required dependencies are listed correctly.


38-162: LGTM!

Indirect dependencies are listed correctly.

airdrop/utils/utils.go (10)

34-40: LGTM!

The handleHTTPError function handles HTTP-related errors correctly.


42-55: LGTM!

The MakeGetRequest function handles HTTP GET requests and errors correctly.


57-60: LGTM!

The GetFunctionName function correctly returns the name of the given function.


62-70: LGTM!

The FindValidatorInfo function correctly finds the index of a validator by its address.


72-104: LGTM!

The GetLatestHeight function handles fetching the latest block height correctly and uses exponential backoff for retries.


106-133: LGTM!

The GetValidators function handles retrieving the list of validators correctly and uses exponential backoff for retries.


135-160: LGTM!

The GetValidatorDelegations function handles retrieving the delegations for a specific validator correctly and uses exponential backoff for retries.


162-173: LGTM!

The ConvertBech32Address function handles converting an address to a Bech32 address correctly.


175-183: LGTM!

The FindValidatorInfoCustomType function correctly finds the index of a validator by its address in a custom validator type.


185-218: LGTM!

The FetchValidators function handles fetching the list of validators correctly and uses exponential backoff for retries.

airdrop/chains/cosmosnft.go Show resolved Hide resolved
airdrop/chains/ethereumnft.go Show resolved Hide resolved
airdrop/cmd/airdrop/main.go Show resolved Hide resolved
airdrop/chains/terra.go Show resolved Hide resolved
airdrop/chains/bostrom.go Show resolved Hide resolved
airdrop/chains/cosmos.go Show resolved Hide resolved
airdrop/chains/cosmos.go Show resolved Hide resolved
airdrop/chains/cosmos.go Show resolved Hide resolved
airdrop/chains/cosmos.go Show resolved Hide resolved
airdrop/chains/composable.go Show resolved Hide resolved
@trungnt1811 trungnt1811 requested a review from faddat July 8, 2024 07:17
@trungnt1811
Copy link
Collaborator Author

@faddat sir, have you finalized the percentage weight for the airdrop across the chains? Please ensure that the total percentage is 100%

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

Successfully merging this pull request may close these issues.

airdrop
3 participants