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

fix: recipient address asset cases only #50

Closed
wants to merge 5 commits into from

Conversation

singhhp1069
Copy link
Contributor

@singhhp1069 singhhp1069 commented Aug 29, 2024

  • Recipient on asset cases only
  • Remove unsed extradata field
  • Doc updated
  • Release note pipeline fixes

Summary by CodeRabbit

  • New Features

    • Introduced FromAsset and ToAsset classes for improved asset handling.
    • Added Recipient field to ToAsset for specifying the recipient address.
    • Enhanced JSON structure for user operations with new timestamp fields.
  • Bug Fixes

    • Removed the ExtraData field from various structures to simplify the data model.
  • Documentation

    • Updated README.md with new sections for releases, contributions, and licensing.
  • Chores

    • Automated release notes generation and README updates in the release workflow.
    • Updated copyright year in the LICENSE file.

@singhhp1069 singhhp1069 changed the title fix: recipient address swap case only fix: recipient address asset cases only Aug 29, 2024
Copy link

coderabbitai bot commented Aug 29, 2024

Walkthrough

The changes involve significant modifications to asset-related structures and their validation logic across multiple files. The Asset structure has been renamed to FromAsset, and a new ToAsset structure has been introduced. Validation methods and error types have been updated accordingly. Additionally, the ExtraData class has been removed, and several JSON-related fields have been adjusted or added in various tests and protocol definitions.

Changes

Files Change Summary
gen/go/proto/v1/asset.pb.validate.go Renamed Asset to FromAsset and Stake to ToAsset, updated validation methods and error types, and added multi-error types.
gen/ts/proto/v1/asset_pb.d.ts, gen/ts/proto/v1/asset_pb.ts Renamed Asset to FromAsset, introduced ToAsset, updated related methods and types, and removed ExtraData class.
intents_test.go Updated Intent tests to use FromAsset and ToAsset, removed ExtraData, and added Recipient field to ToAsset.
proto/v1/asset.proto Renamed Asset to FromAsset, added ToAsset, updated Intent references, adjusted field numbers, and removed ExtraData.
userops_ext_test.go Removed extraData field from JSON structure, added createdAt and expirationAt fields, and updated CallData to use dynamic JSON construction.
.github/workflows/release.yml Added job steps for generating release notes and updating the README.md file with release information.
LICENSE Updated copyright year from 2023 to 2024.
README.md Added new sections for "Release", "Contributing", and "License" to enhance documentation.

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

@singhhp1069 singhhp1069 requested review from blewater and adelowo and removed request for blewater August 29, 2024 14:49
Copy link

codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.88%. Comparing base (7f6a560) to head (d7dc334).
Report is 20 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #50   +/-   ##
=======================================
  Coverage   68.88%   68.88%           
=======================================
  Files           3        3           
  Lines         376      376           
=======================================
  Hits          259      259           
  Misses         94       94           
  Partials       23       23           
Flag Coverage Δ
unittests 68.88% <ø> (ø)

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

Copy link

@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 f46cfe6 and 92493f1.

Files ignored due to path filters (1)
  • gen/go/proto/v1/asset.pb.go is excluded by !**/*.pb.go
Files selected for processing (6)
  • gen/go/proto/v1/asset.pb.validate.go (23 hunks)
  • gen/ts/proto/v1/asset_pb.d.ts (6 hunks)
  • gen/ts/proto/v1/asset_pb.ts (8 hunks)
  • intents_test.go (9 hunks)
  • proto/v1/asset.proto (4 hunks)
  • userops_ext_test.go (3 hunks)
Additional comments not posted (25)
proto/v1/asset.proto (3)

Line range hint 28-38: LGTM!

The FromAsset message is correctly defined with appropriate validation rules.


40-53: LGTM!

The ToAsset message is correctly defined with appropriate validation rules.


80-100: LGTM! But verify the impact of field renumbering.

The changes to the Intent message are correctly implemented. However, ensure that the renumbering of created_at and expiration_at fields does not affect serialization and deserialization.

Run the following script to verify the impact of field renumbering:

Verification successful

Field renumbering appears correct, but verify in a testing environment.

The created_at and expiration_at fields have been renumbered correctly in the proto/v1/asset.proto file and the changes are reflected in the generated TypeScript files. Ensure to test these changes in a testing environment to confirm that serialization and deserialization are not affected.

  • proto/v1/asset.proto: Fields created_at = 9 and expiration_at = 10 are present.
  • gen/ts/proto/v1/asset_pb.d.ts and gen/ts/proto/v1/asset_pb.ts: Reflect the renumbered fields.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of field renumbering in the `Intent` message.

# Test: Search for the usage of `created_at` and `expiration_at` fields. Expect: Only occurrences of the new field numbers.
rg --type proto -A 5 $'created_at = 9'
rg --type proto -A 5 $'expiration_at = 10'

Length of output: 143


Script:

#!/bin/bash
# Description: Verify the impact of field renumbering in the `Intent` message.

# Test: Search for the usage of `created_at` and `expiration_at` fields without specifying file type.
rg -A 5 'created_at = 9'
rg -A 5 'expiration_at = 10'

Length of output: 2104

intents_test.go (8)

88-101: LGTM!

The changes to the test case for a valid request with TOKEN assets are correctly implemented.


116-129: LGTM!

The changes to the test case for an invalid request with an invalid Ethereum address format are correctly implemented.


144-157: LGTM!

The changes to the test case for a valid operation without an expiration date are correctly implemented.


169-182: LGTM!

The changes to the test case for a valid operation with an expiration date are correctly implemented.


Line range hint 197-210: LGTM!

The changes to the test case for a valid operation with staking are correctly implemented.


Line range hint 232-245: LGTM!

The changes to the test case for a valid operation with unstaking are correctly implemented.


259-262: LGTM!

The changes to the test case for a valid operation with a correct recipient are correctly implemented.


287-290: LGTM!

The changes to the test case for an invalid operation with an incorrect recipient are correctly implemented.

gen/ts/proto/v1/asset_pb.d.ts (3)

Line range hint 101-140: LGTM!

The FromAsset class is correctly defined with appropriate methods for binary and JSON serialization.


142-190: LGTM!

The ToAsset class is correctly defined with appropriate methods for binary and JSON serialization.


Line range hint 299-369: LGTM! But verify the impact of field renumbering.

The changes to the Intent class are correctly implemented. However, ensure that the renumbering of created_at and expiration_at fields does not affect serialization and deserialization.

Run the following script to verify the impact of field renumbering:

Verification successful

Field Renumbering Verified: Check Serialization/Deserialization Logic

The renumbering of created_at to 9 and expiration_at to 10 is consistent across the TypeScript files. Ensure that these changes do not affect serialization or deserialization processes elsewhere in the codebase.

  • Files Checked:
    • gen/ts/proto/v1/asset_pb.d.ts
    • gen/ts/proto/v1/asset_pb.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of field renumbering in the `Intent` class.

# Test: Search for the usage of `created_at` and `expiration_at` fields. Expect: Only occurrences of the new field numbers.
rg --type ts -A 5 $'created_at = 9'
rg --type ts -A 5 $'expiration_at = 10'

Length of output: 1380

gen/ts/proto/v1/asset_pb.ts (3)

Line range hint 385-475: LGTM! But verify the class usage in the codebase.

The class is correctly implemented. However, ensure that all references to the old Asset class have been updated to FromAsset and ToAsset.

The code changes are approved.

Run the following script to verify the class usage:

Verification successful

Verification Successful: No Issues Found with Class Usage

The FromAsset and ToAsset classes are correctly implemented and used throughout the codebase. There are no remaining references to the old Asset class. The changes have been properly propagated.

  • All references to the old Asset class have been updated to FromAsset and ToAsset.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the old `Asset` class have been updated to `FromAsset` and `ToAsset`.

# Test: Search for the old class name. Expect: No occurrences of the old class name.
rg --type ts -A 5 $'Asset'

Length of output: 12664


181-244: LGTM! But verify the class usage in the codebase.

The class is correctly implemented. However, ensure that all references to the new ToAsset class are correctly integrated.

The code changes are approved.

Run the following script to verify the class usage:

Verification successful

Verification complete: The ToAsset class is self-contained.

The ToAsset class is defined and used within the same file, gen/ts/proto/v1/asset_pb.ts, and its TypeScript definition file. There are no external references found in other parts of the codebase, indicating that the class is self-contained within these generated files. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the new `ToAsset` class are correctly integrated.

# Test: Search for the new class name. Expect: Occurrences of the new class name in relevant files.
rg --type ts -A 5 $'ToAsset'

Length of output: 5582


Line range hint 125-179: LGTM! But verify the class usage in the codebase.

The class is correctly implemented. However, ensure that all references to the old Asset class have been updated to FromAsset.

The code changes are approved.

Run the following script to verify the class usage:

Verification successful

The Asset class has been successfully replaced by FromAsset. The search for the specific class name Asset yielded no results, confirming that the old class has been removed or renamed. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the old `Asset` class have been updated to `FromAsset`.

# Test: Search for the old class name. Expect: No occurrences of the old class name.
rg --type ts -A 5 $'Asset'

Length of output: 12664


Script:

#!/bin/bash
# Description: Specifically search for the old `Asset` class to confirm its replacement.

# Test: Search for the specific class name `Asset`. Expect: No occurrences of the old class name.
rg --type ts -A 5 $'class Asset'

Length of output: 33

gen/go/proto/v1/asset.pb.validate.go (6)

Line range hint 138-221: LGTM! But verify the method usage in the codebase.

The method is correctly implemented. However, ensure that all references to the old Asset validation method have been updated to FromAsset.

The code changes are approved.

Run the following script to verify the method usage:

Verification successful

Transition to FromAsset Validation Methods Verified

The FromAsset validation methods are correctly used and referenced throughout the codebase, including in test files. No references to the old Asset validation method were found, indicating a successful transition. No issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the old `Asset` validation method have been updated to `FromAsset`.

# Test: Search for the old method name. Expect: No occurrences of the old method name.
rg --type go -A 5 $'Validate() error'

Length of output: 38


Script:

#!/bin/bash
# Description: Verify the usage of `FromAsset` validation methods in the codebase.

# Test: Search for `FromAsset` method usages. Expect: Occurrences of `FromAsset` validation methods.
rg --type go -A 5 'FromAsset'

Length of output: 20234


Line range hint 775-860: LGTM! But verify the method usage in the codebase.

The method is correctly implemented. However, ensure that all references to the old Intent validation method have been updated.

The code changes are approved.

Run the following script to verify the method usage:

Verification successful

No external usage of Intent.Validate and Intent.ValidateAll methods found.

The Intent.Validate and Intent.ValidateAll methods are not used outside their definition file (gen/go/proto/v1/asset.pb.validate.go). This confirms that the changes do not impact other parts of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the old `Intent` validation method have been updated.

# Test: Search for the old method name. Expect: No occurrences of the old method name.
rg --type go -A 5 $'Validate() error'

Length of output: 38


Script:

#!/bin/bash
# Description: Verify the usage of `Intent.Validate` and `Intent.ValidateAll` methods in the codebase.

# Search for the usage of `Intent.Validate` method.
rg --type go 'Intent.*\.Validate\(' -A 5

# Search for the usage of `Intent.ValidateAll` method.
rg --type go 'Intent.*\.ValidateAll\(' -A 5

Length of output: 538


617-701: LGTM! But verify the method usage in the codebase.

The method is correctly implemented. However, ensure that all references to the old Loan validation method have been updated.

The code changes are approved.

Run the following script to verify the method usage:

Verification successful

No external usage of Loan.Validate and Loan.ValidateAll methods found.

The Loan.Validate and Loan.ValidateAll methods are not used outside the gen/go/proto/v1/asset.pb.validate.go file, indicating no outdated references exist. The implementation is consistent with the rest of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the old `Loan` validation method have been updated.

# Test: Search for the old method name. Expect: No occurrences of the old method name.
rg --type go -A 5 $'Validate() error'

Length of output: 38


Script:

#!/bin/bash
# Description: Verify the usage of `Loan.Validate` and `Loan.ValidateAll` methods in the codebase.

# Search for the usage of `Loan.Validate` method.
rg --type go 'Loan.*\.Validate\(' -A 3

# Search for the usage of `Loan.ValidateAll` method.
rg --type go 'Loan.*\.ValidateAll\(' -A 3

Length of output: 394


Line range hint 297-383: LGTM! But verify the method usage in the codebase.

The method is correctly implemented. However, ensure that all references to the new ToAsset validation method are correctly integrated.

The code changes are approved.

Run the following script to verify the method usage:


Line range hint 459-541: LGTM! But verify the method usage in the codebase.

The method is correctly implemented. However, ensure that all references to the old Stake validation method have been updated to ToAsset.

The code changes are approved.

Run the following script to verify the method usage:

Verification successful

Validation Method Usage Verified

The Validate method for the Stake struct is correctly implemented and used in the codebase. The ToAsset method and related structures are used extensively, but they do not replace the Stake validation method. No further action is needed.

  • Validate method is present in gen/go/proto/v1/asset.pb.validate.go.
  • ToAsset is used in various parts of the codebase, including tests.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the old `Stake` validation method have been updated to `ToAsset`.

# Test: Search for the old method name. Expect: No occurrences of the old method name.
rg --type go -A 5 $'Validate() error'

Length of output: 38


Script:

#!/bin/bash
# Description: Specifically search for the `Validate` method in the context of the `Stake` struct.

# Test: Search for the `Validate` method in the context of the `Stake` struct.
ast-grep --lang go --pattern $'func (m *Stake) Validate() error { $$$ }'

# Additionally, search for any `ToAsset` method usage if it is supposed to replace the old validation method.
rg --type go 'ToAsset'

Length of output: 6191


Line range hint 889-973: LGTM! But verify the method usage in the codebase.

The method is correctly implemented. However, ensure that all references to the old Body validation method have been updated.

The code changes are approved.

Run the following script to verify the method usage:

Verification successful

Validation Logic Correctly Implemented

The methods GetFromAsset, GetFromStake, and GetFromLoan are correctly defined and used in the validation logic. The validation checks for both ValidateAll and Validate methods, ensuring comprehensive validation. No issues were found with the method usage in the codebase.

  • gen/go/proto/v1/asset.pb.validate.go: Validation logic for FromAsset, FromStake, and FromLoan.
  • gen/go/proto/v1/asset.pb.go: Definitions of GetFromAsset, GetFromStake, and GetFromLoan.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the old `Body` validation method have been updated.

# Test: Search for the old method name. Expect: No occurrences of the old method name.
rg --type go -A 5 $'Validate() error'

Length of output: 38


Script:

#!/bin/bash
# Description: Verify usage of specific methods related to validation in the codebase.

# Search for occurrences of GetFromAsset, GetFromStake, and GetFromLoan methods.
rg --type go -A 5 'GetFromAsset'
rg --type go -A 5 'GetFromStake'
rg --type go -A 5 'GetFromLoan'

Length of output: 4193

userops_ext_test.go (2)

635-671: LGTM! But consider adding more test cases.

The test case is correctly updated to include the new fields. However, consider adding additional test cases to cover edge cases, such as invalid date formats or missing fields.

The code changes are approved.


635-671: LGTM! But verify the function usage in the codebase.

The function is correctly generating a JSON string with the new fields. However, ensure that all references to mockIntentJSON are updated to handle the new fields and the removal of the "extraData" field.

The code changes are approved.

Run the following script to verify the function usage:

Verification successful

Function usage is consistent with the new structure.

The mockIntentJSON function is used consistently throughout the userops_ext_test.go file, and the new fields "createdAt" and "expirationAt" are handled correctly. There are no references to the removed "extraData" field.

  • All occurrences of mockIntentJSON match the new structure.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `mockIntentJSON` match the new structure.

# Test: Search for the function usage. Expect: Only occurrences of the new structure.
rg --type go -A 5 $'mockIntentJSON'

Length of output: 5639

Copy link

@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

Outside diff range, codebase verification and nitpick comments (1)
README.md (1)

62-65: Consider using a stronger verb.

The Contributing section is clear and encourages community contributions. Consider using a stronger verb to enhance the wording.

-Contributions to the Protocol Registry Package are welcome!
+We welcome contributions to the Protocol Registry Package!
Tools
LanguageTool

[style] ~64-~64: Consider using a different verb to strengthen your wording.
Context: ...ol Registry Package are welcome! If you find any issues or have suggestions for impr...

(FIND_ENCOUNTER)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 92493f1 and d7dc334.

Files selected for processing (3)
  • .github/workflows/release.yml (2 hunks)
  • LICENSE (1 hunks)
  • README.md (1 hunks)
Files skipped from review due to trivial changes (1)
  • LICENSE
Additional context used
LanguageTool
README.md

[style] ~64-~64: Consider using a different verb to strengthen your wording.
Context: ...ol Registry Package are welcome! If you find any issues or have suggestions for impr...

(FIND_ENCOUNTER)

actionlint
.github/workflows/release.yml

42-42: shellcheck reported issue in this script: SC2129:style:4:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


42-42: shellcheck reported issue in this script: SC2086:info:4:26: Double quote to prevent globbing and word splitting

(shellcheck)


42-42: shellcheck reported issue in this script: SC2086:info:5:22: Double quote to prevent globbing and word splitting

(shellcheck)


42-42: shellcheck reported issue in this script: SC2086:info:6:15: Double quote to prevent globbing and word splitting

(shellcheck)

Additional comments not posted (3)
README.md (2)

57-61: LGTM!

The Release section is well-structured and provides essential information for users.


66-68: LGTM!

The License section is clear and provides essential information about the licensing terms.

.github/workflows/release.yml (1)

60-73: LGTM!

The step ensures that the README.md file is updated with the latest release information.

@singhhp1069
Copy link
Contributor Author

redundent

@singhhp1069 singhhp1069 deleted the singh/recipient-changes branch November 26, 2024 19:48
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.

1 participant