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 address range functions #316

Merged
merged 5 commits into from
Jul 12, 2021
Merged

Conversation

pronvis
Copy link
Contributor

@pronvis pronvis commented Jun 30, 2021

No description provided.

@CLAassistant
Copy link

CLAassistant commented Jun 30, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@orkunkl orkunkl left a comment

Choose a reason for hiding this comment

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

LGTM. tests for extra coverage would be great if you will like coding more.
Let's wait for core maintainers approval for merging.

@orkunkl orkunkl self-requested a review June 30, 2021 15:31
@pronvis
Copy link
Contributor Author

pronvis commented Jun 30, 2021

Do not merge please. I will add some tests

@pronvis
Copy link
Contributor Author

pronvis commented Jul 1, 2021

Tests added. (hope you are OK with that fact that I add dev-dependency to wrote tests

@pronvis
Copy link
Contributor Author

pronvis commented Jul 1, 2021

cargo fmt does not change anything. Don't know why lint fails

@maurolacy
Copy link
Contributor

cargo fmt does not change anything. Don't know why lint fails

Likely, some version / rules updates.

Check https://app.circleci.com/pipelines/github/CosmWasm/cosmwasm-plus/1252/workflows/4623eeff-43b1-4e5b-aba5-970584ca9f55/jobs/23104/parallel-runs/0/steps/0-107

@pronvis
Copy link
Contributor Author

pronvis commented Jul 2, 2021

@maurolacy there is no way to log in in circle without providing This application will be able to read and write all public and private repository data. which I do not like.
So, can't open your url.
I did rustup update, state:

stable-x86_64-apple-darwin updated - rustc 1.53.0 (53cb7b09b 2021-06-17) (from rustc 1.52.1 (9bc8c42bb 2021-05-09))
nightly-x86_64-apple-darwin updated - rustc 1.55.0-nightly (7100b311d 2021-07-01) (from rustc 1.54.0-nightly (1c6868aa2 2021-05-27))

Still no changes from cargo fmt, so have no idea how to fix.

@maurolacy
Copy link
Contributor

@maurolacy there is no way to log in in circle without providing This application will be able to read and write all public and private repository data. which I do not like.
So, can't open your url.
I did rustup update, state:

stable-x86_64-apple-darwin updated - rustc 1.53.0 (53cb7b09b 2021-06-17) (from rustc 1.52.1 (9bc8c42bb 2021-05-09))
nightly-x86_64-apple-darwin updated - rustc 1.55.0-nightly (7100b311d 2021-07-01) (from rustc 1.54.0-nightly (1c6868aa2 2021-05-27))

Still no changes from cargo fmt, so have no idea how to fix.

Don't worry, we'll fix it later.

@maurolacy
Copy link
Contributor

Still no changes from cargo fmt, so have no idea how to fix.

You can always try and reproduce the CI setup / tests locally. Take a look a the cicleci config file for reference.

@pronvis
Copy link
Contributor Author

pronvis commented Jul 2, 2021

cargo clippy --all-targets -- -D warnings helped

@orkunkl orkunkl requested review from ethanfrey and maurolacy July 5, 2021 12:02
Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

Just some code style remarks. Mauro and Ethan know the logic better than I do.

@@ -16,3 +16,6 @@ cosmwasm-std = { version = "0.14.0" }
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.21" }

[dev-dependencies]
cw-storage-plus = { version = "0.6.1", features = ["iterator"] }
Copy link
Member

Choose a reason for hiding this comment

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

Can you use a local dependency, e.g.

Suggested change
cw-storage-plus = { version = "0.6.1", features = ["iterator"] }
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.6.2", features = ["iterator"] }

}
pub fn calc_range_start(start_after: Option<Addr>) -> Option<Vec<u8>> {
start_after.map(|addr| {
let mut v: Vec<u8> = addr.as_ref().into();
Copy link
Member

Choose a reason for hiding this comment

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

There is now .as_bytes() which is a bit more explicit and does the same

Suggested change
let mut v: Vec<u8> = addr.as_ref().into();
let mut v: Vec<u8> = addr.as_bytes().into();

None => Ok(None),
}
pub fn calc_range_end(end_before: Option<Addr>) -> Option<Vec<u8>> {
end_before.map(|addr| addr.as_ref().into())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
end_before.map(|addr| addr.as_ref().into())
end_before.map(|addr| addr.as_bytes().into())

}
None => Ok(None),
}
pub fn calc_range_start(start_after: Option<Addr>) -> Option<Vec<u8>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can only do proper / full reviews beginning next week.

Perhaps the original functions must be kept, as they can be useful for old-style ranges / storage. These new ones can also be suffixed by _addr for clarity, but given that this is the new standard, I don't think that's really necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see now that the original argument is Addr already so, it's OK to remove / rename these functions.

Copy link
Contributor

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

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

lgtm.

@pronvis
Copy link
Contributor Author

pronvis commented Jul 7, 2021

  --> packages/cw0/src/pagination.rs:16:35
   |
16 |         let mut v: Vec<u8> = addr.as_bytes().into();
   |                                   ^^^^^^^^ method not found in `Addr`

error[E0599]: no method named `as_bytes` found for struct `Addr` in the current scope
  --> packages/cw0/src/pagination.rs:24:32
   |
24 |     end_before.map(|addr| addr.as_bytes().into())
   |                                ^^^^^^^^ method not found in `Addr`

Fix dependency section.

@webmaster128
Copy link
Member

^^^^^^^ method not found in Addr

The version of cosmwasm-std is not up to date anymore. Your branch has 0.14. Could you update this PR to the latest main state?

pronvis added 5 commits July 7, 2021 15:45
Signed-off-by: Stanislav Pirx <stanislav.pirx@gmail.com>
Signed-off-by: Stanislav Pirx <stanislav.pirx@gmail.com>
Signed-off-by: Stanislav Pirx <stanislav.pirx@gmail.com>
Signed-off-by: Stanislav Pirx <stanislav.pirx@gmail.com>
Signed-off-by: Stanislav Pirx <stanislav.pirx@gmail.com>
@pronvis pronvis force-pushed the fix_addr_range_functions branch from b833b61 to 0509cc7 Compare July 7, 2021 12:48
@pronvis
Copy link
Contributor Author

pronvis commented Jul 7, 2021

^^^^^^^ method not found in Addr

The version of cosmwasm-std is not up to date anymore. Your branch has 0.14. Could you update this PR to the latest main state?

Done, rebase it to main

@orkunkl
Copy link
Contributor

orkunkl commented Jul 12, 2021

Merging

@orkunkl orkunkl merged commit c6f8663 into CosmWasm:main Jul 12, 2021
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.

5 participants