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

Update contracts dependency to latest dev #101

Merged
merged 6 commits into from
Feb 24, 2025
Merged

Update contracts dependency to latest dev #101

merged 6 commits into from
Feb 24, 2025

Conversation

evlekht
Copy link
Member

@evlekht evlekht commented Feb 24, 2025

  • Update go version to 1.23.5 to match contracts repo go version.
  • Update github.com/chain4travel/camino-messenger-contracts/go/contracts to latest dev (90f8b12cd935)
  • Replace removed bookingtokenV2 with just bookingtoken.
  • Update BuyBookingToken method to match contract binding changes.

Summary by CodeRabbit

  • New Features

    • Enhanced booking token purchases now require additional pricing and payment token information, with improved error handling to ensure smoother transaction flows.
  • Refactor

    • Streamlined integration by switching to a unified booking token contract version across the system, resulting in more consistent event handling and transaction processing.
  • Chores

    • Upgraded Go version and updated key dependencies to improve performance and security.

Copy link
Contributor

coderabbitai bot commented Feb 24, 2025

📝 Walkthrough

Walkthrough

The pull request updates the code to transition from using the bookingtokenv2 contract to the new bookingtoken implementation. This includes changes to import paths, contract instantiation, and type assertions across multiple files. Additionally, the BuyBookingToken methods have been updated to accept extra parameters (price and payment token) along with added error handling in mint response flows. The Go module file also sees adjustments with an updated Go version, dependency upgrades, and removals of some indirect dependencies.

Changes

File(s) Change Summary
examples/booking/mintnbuy.go, examples/events/listen.go, internal/messaging/mint.go, internal/messaging/response_handler.go, pkg/events/listener.go, tests/e2e/blockchain/client.go Updated import paths and contract instantiation from bookingtokenv2 to bookingtoken; updated ABI references and type assertions accordingly.
internal/messaging/mint_v1.go, internal/messaging/mint_v2.go, pkg/booking/booking.go, pkg/cm_accounts/cm_accounts.go, pkg/cm_accounts/mock_cm_accounts.go Modified BuyBookingToken method signatures to include new parameters (price and paymentToken) and integrated error handling for price/token retrieval in mint response flows.
go.mod Incremented Go version, updated dependency versions (including for the chain4travel contracts, go-ethereum, and blst), and removed certain indirect dependencies.
.github/workflows/ci.yml, .github/workflows/release.yml, Dockerfile, Dockerfile.plugin Updated Go version to 1.23.5 in CI workflows and Dockerfiles.

Possibly related PRs

Suggested reviewers

  • Noctunus

Poem

I'm a bunny with a coding hop,
Changing contracts from tip to top.
Carrots and code in the moonlight glow,
New parameters make our functions grow.
With every update, a joyful leap –
In this garden of code, our progress we keep!


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

Noctunus
Noctunus previously approved these changes Feb 24, 2025
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
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 226808d and 527d018.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (12)
  • examples/booking/mintnbuy.go (3 hunks)
  • examples/events/listen.go (2 hunks)
  • go.mod (2 hunks)
  • internal/messaging/mint.go (2 hunks)
  • internal/messaging/mint_v1.go (1 hunks)
  • internal/messaging/mint_v2.go (1 hunks)
  • internal/messaging/response_handler.go (3 hunks)
  • pkg/booking/booking.go (2 hunks)
  • pkg/cm_accounts/cm_accounts.go (3 hunks)
  • pkg/cm_accounts/mock_cm_accounts.go (1 hunks)
  • pkg/events/listener.go (8 hunks)
  • tests/e2e/blockchain/client.go (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests
  • GitHub Check: Static Analysis
🔇 Additional comments (31)
pkg/booking/booking.go (2)

134-135: LGTM! Method signature updated to support price and payment token.

The addition of price and paymentToken parameters aligns with the contract updates.


145-145: LGTM! Implementation correctly forwards new parameters.

The updated implementation properly passes the new parameters to the underlying service.

examples/booking/mintnbuy.go (3)

24-24: LGTM! Updated import to use new bookingtoken package.

The import path has been correctly updated to use the new contract package.


83-83: LGTM! Contract instantiation updated.

The contract instantiation has been correctly updated to use the new bookingtoken package.


237-238: LGTM! BuyBookingToken call updated with required parameters.

The method call has been properly updated to include the new price and payment token parameters.

internal/messaging/mint_v1.go (2)

102-108: LGTM! Added robust error handling for price retrieval.

The code now properly validates price and payment token before proceeding with the purchase, improving reliability.


110-110: LGTM! Updated BuyBookingToken call with required parameters.

The method call has been properly updated to include the retrieved price and payment token.

examples/events/listen.go (2)

13-13: LGTM! Updated import to use new bookingtoken package.

The import path has been correctly updated to use the new contract package.


75-75: LGTM! Updated event type assertions.

Type assertions have been properly updated to use the new bookingtoken event types.

Also applies to: 83-83

pkg/cm_accounts/cm_accounts.go (2)

77-78: LGTM! The new parameters enhance the method signature.

The addition of price and paymentToken parameters to the BuyBookingToken method provides better control over the token purchase process.


321-322: LGTM! The contract call is properly updated.

The new parameters are correctly passed to the underlying contract method.

go.mod (1)

8-8:

❓ Verification inconclusive

Verify the contracts dependency version.

The pseudo-version contains a future date (January 29, 2025). Please ensure this is the correct version and commit hash.


🏁 Script executed:

#!/bin/bash
# Description: Verify the contracts dependency version.

# Check if the commit exists in the repository
gh api repos/chain4travel/camino-messenger-contracts/commits/90f8b12cd935 --jq '.sha'

Length of output: 126


Contracts dependency version verified, but please double-check the future timestamp

The dependency in go.mod now references commit 90f8b12cd935 (full SHA: 90f8b12cd935948d386941b309f8c224aecfb7e1), and execution of the verification script confirms that this commit exists in the chain4travel/camino-messenger-contracts repository. However, notice that the pseudo-version includes a future date (January 29, 2025). Please verify that this timestamp is intentional and aligns with your dependency management strategy.

internal/messaging/mint.go (2)

17-17: LGTM! The import path is correctly updated.

The import path is updated to use the new bookingtoken package, consistent with the dependency changes.


78-78: LGTM! The type assertion is correctly updated.

The type assertion is updated to use the new BookingtokenTokenBought type, consistent with the package changes.

pkg/cm_accounts/mock_cm_accounts.go (3)

49-49: LGTM! The mock method signature is correctly updated.

The BuyBookingToken method signature in the mock matches the interface definition.


51-51: LGTM! The mock method call is correctly updated.

The Call method correctly includes all parameters in the right order.


58-60: LGTM! The mock recorder is correctly updated.

The mock recorder is properly updated to handle the new parameters.

internal/messaging/mint_v2.go (1)

106-114:

❓ Verification inconclusive

LGTM! Proper error handling for price and payment token retrieval.

The changes correctly handle price and payment token retrieval before buying the booking token, with appropriate error handling and logging.

Run the following script to verify the updated method signature:


🏁 Script executed:

#!/bin/bash
# Description: Verify the updated BuyBookingToken method signature.

# Test: Search for the method signature. Expect: Only occurrences of the new signature.
ast-grep --pattern 'BuyBookingToken($ctx, $tokenID, $price, $paymentToken)'

Length of output: 77


Action Required: Updated BuyBookingToken Signature Needs Further Verification

The changes in internal/messaging/mint_v2.go (lines 106-114) correctly update the call to include the new parameters for retrieving the price and payment token, with proper error handling and logging. However, the automated AST grep script did not produce any output, so we cannot conclusively verify that the new signature is the only occurrence or that no outdated call sites remain.

  • Please run a manual check or an additional script (e.g., using rg "BuyBookingToken\\(" -n .) to confirm that all calls to BuyBookingToken now use the updated signature BuyBookingToken(ctx, tokenID, price, paymentToken).
  • Once verified, confirm that no legacy usages remain in the codebase.
internal/messaging/response_handler.go (3)

23-23: LGTM! Import path updated correctly.

The import path has been updated to use the new bookingtoken package.


74-74: LGTM! Contract instantiation updated correctly.

The booking token contract instantiation has been updated to use the new package's constructor.


99-99: LGTM! Type declaration updated correctly.

The bookingToken field type has been updated to use the new package's type.

tests/e2e/blockchain/client.go (4)

14-14: LGTM! Import path updated correctly.

The import path has been updated to use the new bookingtoken package.


347-347: LGTM! Contract deployment updated correctly.

The booking token contract deployment has been updated to use the new package's constructor.


416-416: LGTM! ABI parsing updated correctly.

The ABI parsing has been updated to use the new package's ABI.


462-462: LGTM! Contract binding updated correctly.

The booking token contract binding has been updated to use the new package's constructor.

pkg/events/listener.go (6)

13-13: LGTM! Import and type declarations updated correctly.

The import path and btContracts map type have been updated to use the new bookingtoken package.

Also applies to: 42-42, 52-52


78-87: LGTM! Method updated correctly.

The getOrCreateBookingToken method has been updated to use the new package's type and constructor.


500-500: LGTM! Event handling updated correctly.

The resubscribeTokenBought method has been updated to use the new package's types for contract and events.

Also applies to: 508-508


540-540: LGTM! Event listener updated correctly.

The listenForTokenBoughtEvents method has been updated to use the new package's event type.


581-581: LGTM! Event handling updated correctly.

The resubscribeTokenReserved method has been updated to use the new package's types for contract and events.

Also applies to: 589-589


621-621: LGTM! Event listener updated correctly.

The listenForTokenReservedEvents method has been updated to use the new package's event type.

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

🧹 Nitpick comments (1)
.github/workflows/release.yml (1)

1-2: Nitpick: Fix Typo in Workflow Name
The workflow name "Publish Release Artifcats" contains a typo. Consider updating "Artifcats" to "Artifacts" for clarity and professionalism.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 527d018 and d6871ea.

📒 Files selected for processing (4)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/release.yml (1 hunks)
  • Dockerfile (1 hunks)
  • Dockerfile.plugin (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • Dockerfile.plugin
  • Dockerfile
🔇 Additional comments (2)
.github/workflows/release.yml (1)

22-24: Update Go Version in Release Workflow
The Go version has been updated to ~1.23.5, which aligns with updated dependency specifications across the project. Please verify that this version is fully compatible with your build and release scripts.

.github/workflows/ci.yml (1)

13-15: Update CI Environment Variable for Go Version
The environment variable go_version has been updated to "~1.23.5", ensuring consistency across the CI workflow, Docker builds, and the Go module. This change helps maintain a unified build environment.

@evlekht evlekht merged commit 5cfb401 into dev Feb 24, 2025
7 checks passed
@evlekht evlekht deleted the evlekht/contracts branch February 24, 2025 18:09
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.

2 participants