Make 'ens' module public (#435)

This commit is contained in:
Alexis Sellier 2021-09-06 10:52:44 +02:00 committed by GitHub
parent 6a938158b6
commit 2e195d91e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -13,6 +13,8 @@
### Unreleased ### Unreleased
* Expose `ens` module
### 0.5.2 ### 0.5.2
* Set resolved ENS name during gas estimation ([1e5a9e](https://github.com/gakonst/ethers-rs/commit/1e5a9efb3c678eecd43d5c341b4932da35445831)) * Set resolved ENS name during gas estimation ([1e5a9e](https://github.com/gakonst/ethers-rs/commit/1e5a9efb3c678eecd43d5c341b4932da35445831))

View File

@ -1,11 +1,11 @@
/// [Ethereum Name Service](https://docs.ens.domains/) support //! [Ethereum Name Service](https://docs.ens.domains/) support
// Adapted from https://github.com/hhatto/rust-ens/blob/master/src/lib.rs //! Adapted from https://github.com/hhatto/rust-ens/blob/master/src/lib.rs
use ethers_core::{ use ethers_core::{
types::{Address, NameOrAddress, Selector, TransactionRequest, H160, H256}, types::{Address, NameOrAddress, Selector, TransactionRequest, H160, H256},
utils::keccak256, utils::keccak256,
}; };
// 0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e /// ENS registry address (`0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e`)
pub const ENS_ADDRESS: Address = H160([ pub const ENS_ADDRESS: Address = H160([
// cannot set type aliases as constructors // cannot set type aliases as constructors
0, 0, 0, 0, 0, 12, 46, 7, 78, 198, 154, 13, 251, 41, 151, 186, 108, 125, 46, 30, 0, 0, 0, 0, 0, 12, 46, 7, 78, 198, 154, 13, 251, 41, 151, 186, 108, 125, 46, 30,
@ -48,6 +48,7 @@ pub fn resolve<T: Into<Address>>(
} }
} }
/// Returns the reverse-registrar name of an address.
pub fn reverse_address(addr: Address) -> String { pub fn reverse_address(addr: Address) -> String {
format!("{:?}.{}", addr, ENS_REVERSE_REGISTRAR_DOMAIN)[2..].to_string() format!("{:?}.{}", addr, ENS_REVERSE_REGISTRAR_DOMAIN)[2..].to_string()
} }

View File

@ -69,7 +69,7 @@ pub use transports::*;
mod provider; mod provider;
// ENS support // ENS support
mod ens; pub mod ens;
mod pending_transaction; mod pending_transaction;
pub use pending_transaction::PendingTransaction; pub use pending_transaction::PendingTransaction;