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: make from_str parse 0x-prefixed strings #487

Merged
merged 6 commits into from
Dec 30, 2020

Conversation

gakonst
Copy link
Contributor

@gakonst gakonst commented Dec 27, 2020

As title

Travis' error seems unrelated
image

uint/src/uint.rs Outdated Show resolved Hide resolved
fixed-hash/src/hash.rs Outdated Show resolved Hide resolved
uint/tests/uint_tests.rs Outdated Show resolved Hide resolved
@gakonst gakonst requested a review from dvdplm December 28, 2020 16:36
@gakonst
Copy link
Contributor Author

gakonst commented Dec 28, 2020

@dvdplm I've changed to tabs, would appreciate another look - thanks!

@gakonst
Copy link
Contributor Author

gakonst commented Dec 29, 2020

@niklasad1 @ordian would be great if you could approve this PR

@dvdplm
Copy link
Contributor

dvdplm commented Dec 29, 2020

@gakonst We need a cargo fmt I'm afraid.

@gakonst
Copy link
Contributor Author

gakonst commented Dec 29, 2020

@dvdplm I did that initially and you said you prefer multiline :) Addressed in latest commit. Thanks!

@@ -588,6 +588,7 @@ macro_rules! impl_rustc_hex_for_fixed_hash {
/// - When encountering invalid non hex-digits
/// - Upon empty string input or invalid input length in general
fn from_str(input: &str) -> $crate::core_::result::Result<$name, $crate::rustc_hex::FromHexError> {
let input = if input.starts_with("0x") { &input[2..] } else { input };
Copy link
Member

Choose a reason for hiding this comment

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

alternatively we could use

Suggested change
let input = if input.starts_with("0x") { &input[2..] } else { input };
let input = input.strip_prefix("0x").unwrap_or(input);

@dvdplm
Copy link
Contributor

dvdplm commented Dec 29, 2020

@dvdplm I did that initially and you said you prefer multiline :) Addressed in latest commit. Thanks!

I know, my bad. Apologies. :(

@gakonst
Copy link
Contributor Author

gakonst commented Dec 29, 2020

Switched to use strip_prefix, good rec! PR should be good to merge now.

@dvdplm dvdplm merged commit 0264ebf into paritytech:master Dec 30, 2020
@@ -1688,6 +1688,7 @@ macro_rules! construct_uint {
type Err = $crate::FromHexError;

fn from_str(value: &str) -> $crate::core_::result::Result<$name, Self::Err> {
let value = value.strip_prefix("0x").unwrap_or(value);
Copy link
Member

Choose a reason for hiding this comment

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

illegal spaces!

ordian added a commit that referenced this pull request Dec 30, 2020
* master:
  build(deps): update impl-trait-for-tuples requirement (#490)
  fix: make from_str parse 0x-prefixed strings (#487)
  update some dev-dependencies (#493)
  parity-crypto: upgrade deps (#483)
  parity-crypto: remove UB test (#484)
ordian added a commit that referenced this pull request Jan 4, 2021
* master:
  Remove deprecated FromStr/TryFrom impls for Secret (#495)
  primitive-types: address nits of #480 (#485)
  build(deps): update impl-trait-for-tuples requirement (#490)
  fix: make from_str parse 0x-prefixed strings (#487)
  update some dev-dependencies (#493)
sergeyboyko0791 added a commit to KomodoPlatform/parity-common that referenced this pull request Aug 18, 2021
* The time crate after 0.2 is unergonomic to use; just use chrono (paritytech#458)

The 0.2 series of `time` doesn't make it easy to "just" create a timestamp. The `chrono` crate uses `time` v0.1 and is, I believe, what users like us should be using. So let's just do that.

* build(deps): update send_wrapper requirement from 0.3.0 to 0.5.0 (paritytech#461)

Updates the requirements on [send_wrapper](https://github.com/thk1/send_wrapper) to permit the latest version.
- [Release notes](https://github.com/thk1/send_wrapper/releases)
- [Changelog](https://github.com/thk1/send_wrapper/blob/master/CHANGELOG.md)
- [Commits](thk1/send_wrapper@v0.3.0...v0.5.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* rlp: add bytes impls (paritytech#459)

* rlp: add bytes impls

* add tests

* rlp: Fix buffer indexing (paritytech#462)

* Fix buffer indexing

* test for clear

* rlp: store test bytes in hex literals (paritytech#465)

* Make RLP optional in several crates (paritytech#466)

* bump versions and update changelogs (paritytech#463)

* update other dependencies (paritytech#471)

* ethereum-types/rlp should pull primitive-types/rlp (paritytech#474)

* uint: optimize FromStr, make it no_std-compatible (paritytech#468)

* Add from_str bench

* uint: optimize FromStr, make it no_std-compatible

* custom error type

* fmt::Display is actually available in core

* Error::source for FromHexError

* uppercase consts

* additional tests

* kvdb-rocksdb: replace tempdir with tempfile(paritytech#350) (paritytech#477)

* chore(deps): cargo upgrade parking_lot --all (paritytech#470)

* chore(deps): cargo upgrade parking_lot --all

* chore(deps): bump versions breaking change.

* chore: update changelog

	* kvdb
	* kvdb-memorydb
	* kvdb-rocksdb
	* parity-util-mem

* fix nits

* fix: kvdb-web add missing changelog entry

* fix: bad merge

* fix more nits: use breaking label

* [kvdb-memorydb]: add `wasm-bindgen` feature flag

* grumbles: remove `wasm-bindgen` feature flag

* Add hack only in `kvdb-web`
* Remove feature flag `wasm-bindgen` from `kvdb-memorydb`

* Bump bytes to 1.0 (paritytech#482)

* Implement Num from num-traits (paritytech#480)

* parity-crypto: remove UB test (paritytech#484)

* parity-crypto: remove UB test

* rlp: fix unused import

* parity-crypto: upgrade deps (paritytech#483)

* update some dev-dependencies (paritytech#493)

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* fix: make from_str parse 0x-prefixed strings (paritytech#487)

* fix: make from_str parse 0x-prefixed strings

* fix(uint): make from_str parse 0x-prefixed strings

* chore: address review styling comments

* fix: tabs instead of spaces

* chore: cargo fmt

* fix: use strip_prefix instead of starts_with

* build(deps): update impl-trait-for-tuples requirement (paritytech#490)

Updates the requirements on [impl-trait-for-tuples](https://github.com/bkchr/impl-trait-for-tuples) to permit the latest version.
- [Release notes](https://github.com/bkchr/impl-trait-for-tuples/releases)
- [Commits](https://github.com/bkchr/impl-trait-for-tuples/commits/v0.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* primitive-types: address nits of paritytech#480 (paritytech#485)

* primitive-types: address nits of paritytech#480

* fix ethereum-types

* Remove deprecated FromStr/TryFrom impls for Secret (paritytech#495)

* Remove deprecated FromStr/TryFrom impls for Secret

* update CHANGELOG

* build(deps): update secp256k1 requirement from 0.19.0 to 0.20.0 (paritytech#496)

Updates the requirements on [secp256k1](https://github.com/rust-bitcoin/rust-secp256k1) to permit the latest version.
- [Release notes](https://github.com/rust-bitcoin/rust-secp256k1/releases)
- [Changelog](https://github.com/rust-bitcoin/rust-secp256k1/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-bitcoin/rust-secp256k1/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andronik Ordian <write@reusable.software>

* build(deps): update smallvec requirement from 0.6.10 to 1.6.0 (paritytech#494)

Updates the requirements on [smallvec](https://github.com/servo/rust-smallvec) to permit the latest version.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/commits/v1.6.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andronik Ordian <write@reusable.software>

* build(deps): update rand requirement from 0.7.2 to 0.8.0 (paritytech#488)

* build(deps): update rand requirement from 0.7.2 to 0.8.0

Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version.
- [Release notes](https://github.com/rust-random/rand/releases)
- [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md)
- [Commits](rust-random/rand@0.7.3...0.8.0)

Signed-off-by: dependabot[bot] <support@github.com>

* Seed from u64

* uint: use rand 0.7 for quickcheck feature

* kvdb-rocksdb: fix compilation for benches

* parity-crypto: remove unused dep and fix a warning

* cargo fmt and another unused dep

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: David Palm <dvdplm@gmail.com>

* build(deps): update rand_xorshift requirement from 0.2.0 to 0.3.0 (paritytech#491)

Updates the requirements on [rand_xorshift](https://github.com/rust-random/rngs) to permit the latest version.
- [Release notes](https://github.com/rust-random/rngs/releases)
- [Commits](https://github.com/rust-random/rngs/commits/rand_xorshift-0.3.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* update changelogs and bump uint (paritytech#486)

* update changelogs and bump uint

* update ethereum-types changelog

* update uint changelog

* tabs

* fixed-hash: bump to 0.7

* bump keccak-hash to 0.6.0

* contract-address: bump keccak-hash to 0.6

* update changelogs after publishing

* bump fs-swap (paritytech#498)

* triehash: patch release (paritytech#499)

* fix clippy warning (paritytech#504)

* add a test for paritytech#507 (paritytech#508)

* add a test for paritytech#507

* CI: test uint on a big-endian platform

* a workaround for gmp

* grumbles

* bump byteorder to 1.4.2

* ethereum-types: fix wasm builds for serialize feature (paritytech#503)

* ethbloom: do not pull std for 'serialize' feature

* ethereum-types: do not pull std for 'serialize' feature

* CI: check wasm builds for ethbloom and ethereum-types

* fix wasm target

* CI: remove redundant check

* CI: fix wasm target install

* update changelogs

* remove parity-runtime (paritytech#511)

* Update codec and crates depending (paritytech#510)

Co-authored-by: Andronik Ordian <write@reusable.software>

Co-authored-by: David <dvdplm@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Artem Vorotnikov <artem@vorotnikov.me>
Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: Frost Red Lee <frostredlee@gmail.com>
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com>
Co-authored-by: Qinxuan Chen <koushiro.cqx@gmail.com>
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
Co-authored-by: honeywest <50997103+honeywest@users.noreply.github.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
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.

3 participants