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

Remove regex requirement #876

Merged
merged 23 commits into from
Sep 27, 2023
Merged

Remove regex requirement #876

merged 23 commits into from
Sep 27, 2023

Conversation

rnbguy
Copy link
Collaborator

@rnbguy rnbguy commented Sep 22, 2023

Closes: #875

Description

  • Removes any regex requirement
  • Removes safe_regex which is breaking our docsrs builds

PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests.
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@codecov
Copy link

codecov bot commented Sep 22, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (c83f26a) 68.36% compared to head (3ef390c) 68.32%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #876      +/-   ##
==========================================
- Coverage   68.36%   68.32%   -0.05%     
==========================================
  Files         128      128              
  Lines       15833    15811      -22     
==========================================
- Hits        10825    10803      -22     
  Misses       5008     5008              
Files Coverage Δ
crates/ibc/src/applications/transfer/coin.rs 71.69% <100.00%> (-8.31%) ⬇️

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

Copy link
Collaborator

@soareschen soareschen left a comment

Choose a reason for hiding this comment

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

We need to write tests to ensure that the new implementation works as expected.

.position(|x| !x.is_numeric())
.map(|index| coin_str.split_at(index))
.filter(|(amount, denom)| !amount.is_empty() && !denom.is_empty())
.filter(|(_, denom)| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think filter means that you will exclude the invalid characters, but the result would be valid. In the original case, invalid characters will cause the method to fail.

.filter(|(amount, denom)| !amount.is_empty() && !denom.is_empty())
.filter(|(_, denom)| {
!denom.contains(|x| {
!matches!(x, 'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | ':' | '\\' | '.' | '_' | '-')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think \\ was used as an escape for \, which is an escape for . in the original regex.

@rnbguy
Copy link
Collaborator Author

rnbguy commented Sep 25, 2023

We need to write tests to ensure that the new implementation works as expected.

Yea. Tests are coming 🙂 I wanted to confirm the parsing logic before that.

@rnbguy rnbguy marked this pull request as ready for review September 26, 2023 15:54
crates/ibc/src/applications/transfer/coin.rs Outdated Show resolved Hide resolved
crates/ibc/src/applications/transfer/coin.rs Outdated Show resolved Hide resolved
crates/ibc/src/applications/transfer/coin.rs Show resolved Hide resolved
crates/ibc/src/applications/transfer/coin.rs Outdated Show resolved Hide resolved
rnbguy and others added 4 commits September 27, 2023 13:40
Co-authored-by: Farhad Shabani <Farhad.Shabani@gmail.com>
Signed-off-by: Rano | Ranadeep <ranadip.bswas@gmail.com>
Copy link
Member

@Farhad-Shabani Farhad-Shabani left a comment

Choose a reason for hiding this comment

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

Good job @rnbguy. Thanks 👌🏻

@Farhad-Shabani Farhad-Shabani merged commit 45b297f into main Sep 27, 2023
13 checks passed
@Farhad-Shabani Farhad-Shabani deleted the rano/rm-regex-dep branch September 27, 2023 19:07
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
* regex dep over safe-regex

* new error variant

* refactor regex use

* coin parser wo regex

* rm regex dep

* fix incorrect conditions

* add Coin::new

* rm blackslash from valid charset

* rewrite coin tests using rstest

* fix broken test for denom with backslash

* add name to testcases and add new tests

* expect test panic message

* addd tests with plus sign

* update regex comment

* simplify impl logic

* implicit from_str

* slash delim test

* add changelog entry

* version bump for ref link

Co-authored-by: Farhad Shabani <Farhad.Shabani@gmail.com>
Signed-off-by: Rano | Ranadeep <ranadip.bswas@gmail.com>

* refactor denom parsing

* refactor tests without Coin::new

* rm Coin::new

* nit

---------

Signed-off-by: Rano | Ranadeep <ranadip.bswas@gmail.com>
Co-authored-by: Farhad Shabani <Farhad.Shabani@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

docs.rs build is failing
3 participants