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(sdk): uuid BridgeQuote.id #2896

Merged
merged 14 commits into from
Aug 26, 2024
Merged

feat(sdk): uuid BridgeQuote.id #2896

merged 14 commits into from
Aug 26, 2024

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Jul 19, 2024

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced unique identifier generation for bridge quotes using UUIDv7.
    • Enhanced data structure for bridge route processing by including unique identifiers.
  • Tests

    • Implemented test cases to validate the correct generation and uniqueness of UUIDs for bridge quotes.

Copy link
Contributor

coderabbitai bot commented Jul 19, 2024

Walkthrough

The recent changes enhance the SDK Router package by integrating UUID version 7 (UUIDv7) generation. Key updates include importing the uuidv7 library, modifying the return structure to include unique identifiers, and implementing tests to validate UUID functionality. Additionally, a utility function for validating UUIDv7 strings was created, accompanied by a comprehensive test suite to ensure correctness and reliability in handling unique identifiers.

Changes

Files Change Summary
.../package.json Added dependencies "@babel/plugin-transform-modules-commonjs": "^7.24.8", "jest": "^29.7.0", and "uuidv7": "^1.0.1". Updated babel-jest from ^29.4.1 to ^25.2.6.
.../jest.config.js Updated moduleNameMapper to resolve uuidv7 to its CommonJS entry point for Jest compatibility.
.../src/module/synapseModuleSet.ts Imported uuidv7 and added UUID generation for the id field in the SynapseModuleSet class.
.../src/sdk.test.ts Added test cases to validate UUID generation and ensure unique IDs for bridge quotes.
.../src/utils/validateUUID.ts Created validateUUID function to check UUIDv7 format.
.../src/utils/validateUUID.test.ts Introduced tests for validateUUID function, ensuring valid and invalid UUIDs are properly handled.

Poem

In a land of code, new UUIDs bloom,
With v7’s charm, they dispel the gloom.
Quotes now bear their unique mark,
Ensuring journeys leave a spark.
Validation strong, tests do sing,
In the realm of routers, progress springs! 🐇✨


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.

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

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

  • Added uuidv7 dependency in packages/sdk-router/package.json
  • Introduced UUID generation for BridgeQuote in packages/sdk-router/src/module/synapseModuleSet.ts
  • Added id field to BridgeQuote type in packages/sdk-router/src/module/types.ts
  • Added test for UUID validation in packages/sdk-router/src/sdk.test.ts
  • Created validateUUID utility and its test in packages/sdk-router/src/utils/validateUUID.ts and packages/sdk-router/src/utils/validateUUID.test.ts

6 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bc7c012 and 54ed56d.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (6)
  • packages/sdk-router/package.json (1 hunks)
  • packages/sdk-router/src/module/synapseModuleSet.ts (2 hunks)
  • packages/sdk-router/src/module/types.ts (1 hunks)
  • packages/sdk-router/src/sdk.test.ts (2 hunks)
  • packages/sdk-router/src/utils/validateUUID.test.ts (1 hunks)
  • packages/sdk-router/src/utils/validateUUID.ts (1 hunks)
Additional comments not posted (9)
packages/sdk-router/src/utils/validateUUID.ts (1)

1-10: LGTM!

The function correctly validates UUIDv7 strings using a regular expression.

packages/sdk-router/src/utils/validateUUID.test.ts (1)

1-12: LGTM!

The test cases correctly cover both valid and invalid UUIDv7 strings, ensuring the validateUUID function works as expected.

packages/sdk-router/src/module/types.ts (1)

58-58: LGTM!

The addition of the id field to the BridgeQuote type is correct and consistent with the rest of the type definition.

packages/sdk-router/package.json (1)

78-79: LGTM!

The addition of the uuidv7 dependency is correct and necessary for the UUIDv7 generation functionality.

packages/sdk-router/src/module/synapseModuleSet.ts (3)

2-2: LGTM!

The import statement for uuidv7 is correct and follows standard practices.


203-203: LGTM!

The uuid constant is correctly generated using uuidv7().


211-211: LGTM! But verify the UUID usage in the codebase.

The code changes are approved.

However, ensure that the id field is used consistently and correctly throughout the codebase.

Verification successful

UUID usage verified and consistent

The id field usage with UUID in the file packages/sdk-router/src/module/synapseModuleSet.ts is consistent with other usages of id fields across the codebase. No issues found.

  • packages/sdk-router/src/module/synapseModuleSet.ts (line 211)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `id` field in the codebase.

# Test: Search for the usage of the `id` field. Expect: Proper usage of the `id` field.
rg --type python -A 5 $'id: '

Length of output: 61


Script:

#!/bin/bash
# Description: Verify the usage of the `id` field in the TypeScript codebase.

# Test: Search for the usage of the `id` field. Expect: Proper usage of the `id` field.
rg --type ts -A 5 $'id: '

Length of output: 67310

packages/sdk-router/src/sdk.test.ts (2)

47-47: LGTM!

The import statement for validateUUID is correct and follows standard practices.


105-107: LGTM!

The test case correctly validates the UUID of the result using the validateUUID function.

@bigboydiamonds bigboydiamonds marked this pull request as draft July 19, 2024 01:20
@bigboydiamonds bigboydiamonds changed the title feat(sdk): uuid BridgeQuote.id [wip] feat(sdk): uuid BridgeQuote.id Jul 19, 2024
Copy link

cloudflare-workers-and-pages bot commented Jul 19, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4bc1a1e
Status: ✅  Deploy successful!
Preview URL: https://11f8942a.sanguine-fe.pages.dev
Branch Preview URL: https://sdk-bridge-quote-uuid.sanguine-fe.pages.dev

View logs

@github-actions github-actions bot added javascript Pull requests that update Javascript code size/m and removed size/xs labels Jul 23, 2024
@bigboydiamonds bigboydiamonds changed the title [wip] feat(sdk): uuid BridgeQuote.id feat(sdk): uuid BridgeQuote.id Jul 23, 2024
@bigboydiamonds bigboydiamonds marked this pull request as ready for review July 23, 2024 23:31
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The pull request introduces UUIDv7 for generating unique identifiers for bridge quotes and addresses test errors related to the uuidv7 package.

  • Updated packages/sdk-router/jest.config.js to include moduleNameMapper for resolving uuidv7 with CommonJS entry point.
  • Added @babel/plugin-transform-modules-commonjs dependency in packages/sdk-router/package.json to ensure compatibility with CommonJS module syntax.

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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: 2

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 54ed56d and b652748.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (2)
  • packages/sdk-router/jest.config.js (1 hunks)
  • packages/sdk-router/package.json (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/sdk-router/package.json
Additional context used
GitHub Check: lint
packages/sdk-router/jest.config.js

[warning] 10-10:
Replace "uuidv7" with uuidv7


[warning] 11-11:
Insert ,

packages/sdk-router/jest.config.js Outdated Show resolved Hide resolved
packages/sdk-router/jest.config.js Outdated Show resolved Hide resolved
@github-actions github-actions bot added size/l and removed size/m labels Jul 23, 2024
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The pull request introduces UUIDv7 for generating unique identifiers for bridge quotes and addresses test errors related to the uuidv7 package.

  • Updated packages/sdk-router/package.json to include jest dependency version ^29.7.0.
  • Added validation to ensure generated UUIDs are correctly formatted in /packages/sdk-router/src/sdk.test.ts.
  • Implemented tests to validate the correct generation and format of UUIDs in /packages/sdk-router/src/rfq/quote.test.ts.
  • Updated jest.config.js to include moduleNameMapper for resolving uuidv7 with CommonJS entry point.
  • Added @babel/plugin-transform-modules-commonjs dependency in packages/sdk-router/package.json to ensure compatibility with CommonJS module syntax.

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4e99d8c and 923bf54.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (1)
  • packages/sdk-router/package.json (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/sdk-router/package.json

@github-actions github-actions bot added size/m and removed size/l labels Jul 24, 2024
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The recent changes focus on integrating UUIDv7 for unique identifier generation in bridge quotes and ensuring proper validation and testing.

  • Updated packages/sdk-router/package.json to include uuidv7 dependency.
  • Modified packages/sdk-router/src/sdk.test.ts to validate UUID format.
  • Implemented UUID generation tests in packages/sdk-router/src/rfq/quote.test.ts.
  • Adjusted packages/sdk-router/jest.config.js for uuidv7 module compatibility.
  • Added @babel/plugin-transform-modules-commonjs in packages/sdk-router/package.json for CommonJS support.

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 923bf54 and b7f53c3.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (1)
  • packages/sdk-router/package.json (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/sdk-router/package.json

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 23.58368%. Comparing base (694626a) to head (4bc1a1e).
Report is 80 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2896         +/-   ##
===================================================
- Coverage   25.24881%   23.58368%   -1.66513%     
===================================================
  Files            780         679        -101     
  Lines          56771       50836       -5935     
  Branches          82          82                 
===================================================
- Hits           14334       11989       -2345     
+ Misses         40958       37525       -3433     
+ Partials        1479        1322        -157     
Flag Coverage Δ
core ?
git-changes-action ?
packages 90.56974% <100.00000%> (+0.01855%) ⬆️
screener-api ?

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link

codecov bot commented Jul 24, 2024

Bundle Report

Changes will decrease total bundle size by 7.03MB ⬇️

Bundle name Size Change
widget-cjs-esm 273.3kB 273.3kB ⬆️
synapse-interface-server-cjs 1.38MB 12.78kB ⬆️
sdk-router-@synapsecns/sdk-router-cjs 522.3kB 405.39kB ⬆️
sdk-router-@synapsecns/sdk-router-esm 252.46kB 382 bytes ⬆️
synapse-interface-edge-server-array-push 83 bytes 0 bytes
synapse-interface-client-array-push (removed) 7.44MB ⬇️
widget-esm-cjs (removed) 275.25kB ⬇️

Copy link
Collaborator

@ChiTimesChi ChiTimesChi left a comment

Choose a reason for hiding this comment

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

This LGTM. Tried to think of a scenario where this could be a breaking change for an external integration, don't think so, right?

@bigboydiamonds
Copy link
Collaborator Author

This LGTM. Tried to think of a scenario where this could be a breaking change for an external integration, don't think so, right?

Agreed, don't believe this would be a breaking change for any external integrations.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The recent changes focus on integrating UUIDv7 for unique identifier generation in bridge quotes and ensuring proper validation and testing.

  • Modified packages/sdk-router/src/sdk.test.ts to validate UUID format and uniqueness.
  • Implemented UUID generation tests in packages/sdk-router/src/rfq/quote.test.ts.
  • Updated packages/sdk-router/CHANGELOG.md to document the new UUID feature.
  • Ensured UUID validation logic is thoroughly tested to avoid potential issues in production.

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b7f53c3 and c8b350c.

Files selected for processing (1)
  • packages/sdk-router/src/sdk.test.ts (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/sdk-router/src/sdk.test.ts

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c8b350c and 1cdca09.

Files selected for processing (3)
  • packages/sdk-router/package.json (1 hunks)
  • packages/sdk-router/src/module/synapseModuleSet.ts (2 hunks)
  • packages/sdk-router/src/sdk.test.ts (5 hunks)
Additional comments not posted (12)
packages/sdk-router/package.json (4)

63-63: Add @babel/plugin-transform-modules-commonjs dependency.

This addition suggests a need for CommonJS module transformation, potentially for compatibility with certain environments or tools.


75-75: Add jest dependency.

Adding jest indicates an enhancement in the testing framework, which aligns with modern JavaScript testing practices.


81-81: Add uuidv7 dependency.

This addition is crucial for generating UUID version 7, which is central to the PR's objective of enhancing unique identifier functionality.


71-71: Downgrade babel-jest from ^29.4.1 to ^25.2.6.

Downgrading babel-jest might be necessary for compatibility reasons, but ensure this does not introduce any issues with other dependencies or testing functionalities.

packages/sdk-router/src/module/synapseModuleSet.ts (3)

2-2: Import uuidv7 from uuidv7.

This import is necessary for generating UUIDs, aligning with the PR's goal of enhancing unique identifier functionality.


205-205: Generate UUID for bridge routes.

The introduction of uuidv7() to generate a unique identifier for each bridge route is a positive change, enhancing the ability to track and reference specific instances.


213-213: Include id: uuid in return object.

Adding a unique ID to the return object improves the traceability and management of bridge routes.

packages/sdk-router/src/sdk.test.ts (5)

47-47: Import validateUUID for UUID validation.

This import is crucial for testing the validity of UUIDs, ensuring that generated IDs conform to the expected format.


105-107: Test UUID validity in bridge quotes.

The test case effectively checks that the generated UUID is valid, which is essential for maintaining data integrity.


410-416: Create second bridge quote for ID uniqueness test.

Generating a second bridge quote to test ID uniqueness is a good practice, ensuring that each quote has a distinct identifier.


446-450: Test uniqueness of bridge quote IDs.

This test ensures that two successive bridge quotes have different IDs, which is critical for maintaining unique identifiers across transactions.


830-838: Test unique IDs for different bridge quotes.

This test confirms that quotes from different sources have unique IDs, reinforcing the reliability of the UUID generation process.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The recent changes introduce UUIDv7 for unique identifier generation in bridge quotes, along with validation and testing enhancements.

  • UUID Integration: Added UUIDv7 generation and validation for bridge quotes in packages/sdk-router/src/module/synapseModuleSet.ts and packages/sdk-router/src/operations/bridge.ts.
  • Dependency Updates: Updated go.mod and go.sum files across multiple directories to include github.com/samborkent/uuid for UUID generation.
  • Test Enhancements: Implemented comprehensive test cases for UUID generation and validation in packages/sdk-router/src/rfq/fastBridgeRouterSet.test.ts and packages/sdk-router/src/sdk.test.ts.
  • Maintenance Handling: Refactored maintenance-related logic into a new useMaintenance hook in packages/synapse-interface/components/Maintenance/Maintenance.tsx.
  • Chain and Token Support: Added support for new chains and tokens, including Linea and Scroll, in packages/synapse-constants/constants/chains/index.ts and packages/synapse-constants/constants/tokens/bridgeable.ts.

294 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Aug 22, 2024
@trajan0x trajan0x removed the Stale label Aug 23, 2024
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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1cdca09 and 4bc1a1e.

Files selected for processing (1)
  • packages/sdk-router/src/sdk.test.ts (4 hunks)
Additional comments not posted (4)
packages/sdk-router/src/sdk.test.ts (4)

104-106: Good addition for UUID validation.

The test case correctly checks that the id property of the bridge quote is a string, ensuring basic UUID validation.


409-416: Setup for unique ID validation.

Creating a second promise for fetching a bridge quote is a good setup for validating that different quotes have unique IDs.


445-450: Effective test for unique ID generation.

The test case correctly ensures that two bridge quotes have different IDs, validating the uniqueness of the UUID generation.


829-838: Validation of unique IDs across modules.

The test case effectively ensures that SynapseBridge and SynapseCCTP quotes have unique IDs, maintaining the integrity of the ID generation process.

@abtestingalpha abtestingalpha merged commit 85b5f53 into master Aug 26, 2024
35 checks passed
@abtestingalpha abtestingalpha deleted the sdk/bridge-quote-uuid branch August 26, 2024 16:47
@bigboydiamonds bigboydiamonds restored the sdk/bridge-quote-uuid branch August 26, 2024 20:28
@bigboydiamonds bigboydiamonds deleted the sdk/bridge-quote-uuid branch August 26, 2024 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code M-deps size/m Sol Typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants