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

refactor(core): make address, crypto crates #1799

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ members = [
"crates/astria-conductor",
"crates/astria-config",
"crates/astria-core",
"crates/astria-core-address",
"crates/astria-core-consts",
"crates/astria-core-crypto",
"crates/astria-eyre",
"crates/astria-grpc-mock",
"crates/astria-grpc-mock-test",
Expand All @@ -34,6 +37,9 @@ default-members = [
"crates/astria-conductor",
"crates/astria-config",
"crates/astria-core",
"crates/astria-core-address",
"crates/astria-core-consts",
"crates/astria-core-crypto",
"crates/astria-grpc-mock",
"crates/astria-grpc-mock-test",
"crates/astria-grpc-mock-test-codegen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use astria_core::{
Action,
TransactionBody,
},
Protobuf as _,
};
use astria_eyre::eyre::{
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ pub fn default_sequencer_address() -> Address {
/// Constructs an [`Address`] prefixed by `"astria"`.
#[must_use]
pub(crate) fn astria_address(
array: [u8; astria_core::primitive::v1::ADDRESS_LEN],
array: [u8; astria_core::primitive::v1::ADDRESS_LENGTH],
) -> astria_core::primitive::v1::Address {
astria_core::primitive::v1::Address::builder()
.array(array)
Expand Down
7 changes: 6 additions & 1 deletion crates/astria-cli/src/sequencer/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ impl Create {
let signing_key = SigningKey::new(OsRng);
let pretty_signing_key = hex::encode(signing_key.as_bytes());
let pretty_verifying_key = hex::encode(signing_key.verification_key().as_bytes());
let pretty_address = SigningKey::try_address(&signing_key, &self.prefix)?;

let pretty_address: Address = Address::builder()
.array(signing_key.address_bytes())
.prefix(&self.prefix)
.try_build()?;

println!("Create Sequencer Account");
println!();
// TODO: don't print private keys to CLI, prefer writing to file:
Expand Down
4 changes: 2 additions & 2 deletions crates/astria-cli/src/sequencer/address.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use astria_core::primitive::v1::{
Address,
ADDRESS_LEN,
ADDRESS_LENGTH,
};
use color_eyre::eyre::{
self,
Expand Down Expand Up @@ -39,7 +39,7 @@ struct Bech32m {
impl Bech32m {
fn run(self) -> eyre::Result<()> {
use hex::FromHex as _;
let bytes = <[u8; ADDRESS_LEN]>::from_hex(&self.bytes)
let bytes = <[u8; ADDRESS_LENGTH]>::from_hex(&self.bytes)
.wrap_err("failed decoding provided hex bytes")?;
let address = Address::<astria_core::primitive::v1::Bech32m>::builder()
.array(bytes)
Expand Down
14 changes: 14 additions & 0 deletions crates/astria-core-address/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "astria-core-address"
version = "0.1.0"
edition = "2021"

[dependencies]
astria-core-consts = { path = "../astria-core-consts" }

thiserror = { workspace = true }

bech32 = "0.11.0"

[features]
unchecked-constructor = []
Loading
Loading