Skip to content

Commit

Permalink
Explicitly set the minimum supported rust version (gakonst#28)
Browse files Browse the repository at this point in the history
* Explicitly set MSRV

* Appease clippy
  • Loading branch information
SamWilsn committed Sep 21, 2021
1 parent a519056 commit a769fc0
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 47 deletions.
38 changes: 30 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,70 @@
on:
push:
branches:
branches:
- master
pull_request:

name: Tests

jobs:
tests:
tests-msrv:
name: Tests (MSRV)
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install stable toolchain

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal

- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true

- name: cargo test
run: cargo test --all

tests-stable:
name: Tests (Stable)
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true

- name: cargo test
run: cargo test
run: cargo test --all

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install stable toolchain

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true

- name: cargo fmt
run: cargo fmt --all -- --check

- name: cargo clippy
run: cargo clippy -- -D warnings
run: cargo clippy --all -- -D warnings
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ This repository has been tested against the following DappTools repos:

We use the stable Rust toolchain. Install by running: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`

#### Minimum Supported Rust Version

The current minimum supported Rust version is `rustc 1.51.0 (2fd73fabe 2021-03-23)`.

### Building & testing

```
Expand All @@ -92,8 +96,3 @@ cargo test
cargo doc --open
cargo build [--release]
```
**Tip**: If you encounter the following error when building the project, please update your Rust toolchain with `rustup update`.

```
error[E0658]: use of unstable library feature 'map_into_keys_values'
```
2 changes: 1 addition & 1 deletion dapp/src/solc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a> SolcBuilder<'a> {
.join(",");

// tracing::trace!(?lib_paths);
solc = solc.args(["--allow-paths", &lib_paths]);
solc = solc.args(std::array::IntoIter::new(["--allow-paths", &lib_paths]));

// tracing::trace!(?self.remappings);
if !self.remappings.is_empty() {
Expand Down
10 changes: 5 additions & 5 deletions dapptools/src/seth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ use structopt::StructOpt;
async fn main() -> eyre::Result<()> {
let opts = Opts::from_args();
match opts.sub {
Subcommands::FromAscii { text } => {
println!("{}", SimpleSeth::from_ascii(&text));
Subcommands::FromUtf8 { text } => {
println!("{}", SimpleSeth::from_utf8(&text));
}
Subcommands::ToHex { decimal } => {
println!("{}", SimpleSeth::to_hex(unwrap_or_stdin(decimal)?));
println!("{}", SimpleSeth::hex(unwrap_or_stdin(decimal)?));
}
Subcommands::ToCheckSumAddress { address } => {
println!("{}", SimpleSeth::to_checksum_address(&address)?);
println!("{}", SimpleSeth::checksum_address(&address)?);
}
Subcommands::ToBytes32 { bytes } => {
println!("{}", SimpleSeth::to_bytes32(&bytes)?);
println!("{}", SimpleSeth::bytes32(&bytes)?);
}
Subcommands::Block {
rpc_url,
Expand Down
20 changes: 8 additions & 12 deletions dapptools/src/seth_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(about = "Perform Ethereum RPC calls from the comfort of your command line.")]
pub enum Subcommands {
#[structopt(name = "--from-ascii")]
#[structopt(aliases = &["--from-ascii"])]
#[structopt(name = "--from-utf8")]
#[structopt(about = "convert text data into hexdata")]
FromAscii { text: String },
FromUtf8 { text: String },
#[structopt(name = "--to-hex")]
#[structopt(about = "convert a decimal number into hex")]
ToHex { decimal: Option<u128> },
Expand Down Expand Up @@ -185,17 +186,12 @@ pub struct Wallet {
}

impl Wallet {
#[allow(clippy::manual_map)]
pub fn signer(&self) -> Result<Option<LocalWallet>> {
Ok(if let Some(wallet) = self.private_key()? {
Some(wallet)
} else if let Some(wallet) = self.mnemonic()? {
Some(wallet)
} else if let Some(wallet) = self.keystore()? {
Some(wallet)
} else {
None
})
self.private_key()
.transpose()
.or_else(|| self.mnemonic().transpose())
.or_else(|| self.keystore().transpose())
.transpose()
}

fn private_key(&self) -> Result<Option<LocalWallet>> {
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.51.0
24 changes: 12 additions & 12 deletions seth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ where

pub struct SimpleSeth;
impl SimpleSeth {
/// Converts ASCII text input to hex
/// Converts UTF-8 text input to hex
///
/// ```
/// use seth::SimpleSeth as Seth;
///
/// let bin = Seth::from_ascii("yo");
/// let bin = Seth::from_utf8("yo");
/// assert_eq!(bin, "0x796f")
/// ```
pub fn from_ascii(s: &str) -> String {
pub fn from_utf8(s: &str) -> String {
let s: String = s.as_bytes().to_hex();
format!("0x{}", s)
}
Expand All @@ -216,10 +216,10 @@ impl SimpleSeth {
/// ```
/// use seth::SimpleSeth as Seth;
///
/// assert_eq!(Seth::to_hex(424242), "0x67932");
/// assert_eq!(Seth::to_hex(1234), "0x4d2");
/// assert_eq!(Seth::hex(424242), "0x67932");
/// assert_eq!(Seth::hex(1234), "0x4d2");
/// ```
pub fn to_hex(u: u128) -> String {
pub fn hex(u: u128) -> String {
format!("{:#x}", u)
}

Expand All @@ -233,13 +233,13 @@ impl SimpleSeth {
///
/// # fn main() -> eyre::Result<()> {
/// let addr = Address::from_str("0xb7e390864a90b7b923c9f9310c6f98aafe43f707")?;
/// let addr = Seth::to_checksum_address(&addr)?;
/// let addr = Seth::checksum_address(&addr)?;
/// assert_eq!(addr, "0xB7e390864a90b7b923C9f9310C6F98aafE43F707");
///
/// # Ok(())
/// # }
/// ```
pub fn to_checksum_address(address: &Address) -> Result<String> {
pub fn checksum_address(address: &Address) -> Result<String> {
Ok(utils::to_checksum(address, None))
}

Expand All @@ -248,18 +248,18 @@ impl SimpleSeth {
/// use seth::SimpleSeth as Seth;
///
/// # fn main() -> eyre::Result<()> {
/// let bytes = Seth::to_bytes32("1234")?;
/// let bytes = Seth::bytes32("1234")?;
/// assert_eq!(bytes, "0x1234000000000000000000000000000000000000000000000000000000000000");
///
/// let bytes = Seth::to_bytes32("0x1234")?;
/// let bytes = Seth::bytes32("0x1234")?;
/// assert_eq!(bytes, "0x1234000000000000000000000000000000000000000000000000000000000000");
///
/// let err = Seth::to_bytes32("0x123400000000000000000000000000000000000000000000000000000000000011").unwrap_err();
/// let err = Seth::bytes32("0x123400000000000000000000000000000000000000000000000000000000000011").unwrap_err();
/// assert_eq!(err.to_string(), "string >32 bytes");
///
/// # Ok(())
/// # }
pub fn to_bytes32(s: &str) -> Result<String> {
pub fn bytes32(s: &str) -> Result<String> {
let s = strip_0x(s);
if s.len() > 64 {
eyre::bail!("string >32 bytes");
Expand Down

0 comments on commit a769fc0

Please sign in to comment.