Skip to content

Commit 522581b

Browse files
committed
Rename crates
1 parent a8d47ce commit 522581b

26 files changed

+1349
-713
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[workspace]
22

33
resolver = "2"
4-
members = [ "node", "protocol", "testutil", "wallet"]
4+
members = [ "client", "protocol", "testutil", "wallet"]

node/Cargo.toml client/Cargo.toml

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "spaced"
2+
name = "spaces_client"
33
version = "0.0.6"
44
edition = "2021"
55

@@ -16,7 +16,10 @@ path = "src/bin/spaced.rs"
1616
path = "src/lib.rs"
1717

1818
[dependencies]
19-
wallet = { path = "../wallet" }
19+
spaces_wallet = { path = "../wallet" }
20+
spaces_protocol = { path = "../protocol", version = "*", features = ["std"]}
21+
spacedb = { git = "https://github.com/spacesprotocol/spacedb", rev = "e07259ac6fc9cea1b06ee2cfdbb93d8c3039658a" }
22+
2023
tokio = { version = "1.37.0", features = ["signal"] }
2124
ctrlc = "3.4.4"
2225
anyhow = "1.0.86"
@@ -30,15 +33,14 @@ directories = "5.0.1"
3033
env_logger = "0.11.3"
3134
serde_json = "1.0.116"
3235
bincode = {version = "2.0.0-rc.3", features = ["serde", "derive"]}
33-
protocol = { path = "../protocol", version = "*", features = ["std"]}
34-
spacedb = { git = "https://github.com/spacesprotocol/spacedb", rev = "e07259ac6fc9cea1b06ee2cfdbb93d8c3039658a" }
3536
base64 = "0.22.1"
3637
futures = "0.3.30"
3738
reqwest = { version = "0.12.5", default-features = false, features = ["json", "blocking", "rustls-tls"] }
3839
threadpool = "1.8.1"
3940
tabled = "0.17.0"
4041
colored = "3.0.0"
42+
4143
[dev-dependencies]
4244
assert_cmd = "2.0.16"
4345
predicates = "3.1.2"
44-
testutil = { path = "../testutil" }
46+
spaces_testutil = { path = "../testutil" }

node/src/bin/space-cli.rs client/src/bin/space-cli.rs

+88-60
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ use jsonrpsee::{
88
core::{client::Error, ClientError},
99
http_client::{HttpClient, HttpClientBuilder},
1010
};
11-
use protocol::{
12-
bitcoin::{Amount, FeeRate, OutPoint, Txid},
13-
hasher::KeyHasher,
14-
slabel::SLabel,
15-
};
16-
use spaced::{
11+
use spaces_client::{
1712
config::{default_spaces_rpc_port, ExtendedNetwork},
13+
format::{
14+
print_error_rpc_response, print_list_bidouts, print_list_spaces_response,
15+
print_list_transactions, print_list_unspent, print_server_info,
16+
print_wallet_balance_response, print_wallet_info, print_wallet_response, Format,
17+
},
1818
rpc::{
1919
BidParams, ExecuteParams, OpenParams, RegisterParams, RpcClient, RpcWalletRequest,
20-
RpcWalletTxBuilder, SendCoinsParams, TransferSpacesParams,
20+
RpcWalletTxBuilder, SendCoinsParams, SignedMessage, TransferSpacesParams,
2121
},
2222
store::Sha256,
23-
wallets::AddressKind,
23+
wallets::{AddressKind, WalletResponse},
2424
};
25-
use spaced::format::{print_error_rpc_response, print_list_bidouts, print_list_spaces_response, print_list_transactions, print_list_unspent, print_server_info, print_wallet_balance_response, print_wallet_info, print_wallet_response, Format};
26-
use spaced::rpc::SignedMessage;
27-
use spaced::wallets::WalletResponse;
28-
use wallet::bitcoin::secp256k1::schnorr::Signature;
29-
use wallet::export::WalletExport;
30-
use wallet::Listing;
25+
use spaces_protocol::{
26+
bitcoin::{Amount, FeeRate, OutPoint, Txid},
27+
hasher::KeyHasher,
28+
slabel::SLabel,
29+
};
30+
use spaces_wallet::{bitcoin::secp256k1::schnorr::Signature, export::WalletExport, Listing};
3131

3232
#[derive(Parser, Debug)]
3333
#[command(version, about, long_about = None)]
@@ -138,7 +138,7 @@ enum Commands {
138138
fee_rate: Option<u64>,
139139
},
140140
/// Renew ownership of a space
141-
#[command(name = "renew", )]
141+
#[command(name = "renew")]
142142
Renew {
143143
/// Spaces to renew
144144
#[arg(display_order = 0)]
@@ -372,7 +372,6 @@ impl SpaceCli {
372372
)
373373
.await?;
374374

375-
376375
print_wallet_response(self.network.fallback_network(), result, self.format);
377376
Ok(())
378377
}
@@ -387,8 +386,6 @@ fn normalize_space(space: &str) -> String {
387386
}
388387
}
389388

390-
391-
392389
#[tokio::main]
393390
async fn main() -> anyhow::Result<()> {
394391
let (cli, args) = SpaceCli::configure().await?;
@@ -512,7 +509,7 @@ async fn handle_commands(
512509
fee_rate,
513510
false,
514511
)
515-
.await?
512+
.await?
516513
}
517514
Commands::Bid {
518515
space,
@@ -529,7 +526,7 @@ async fn handle_commands(
529526
fee_rate,
530527
confirmed_only,
531528
)
532-
.await?
529+
.await?
533530
}
534531
Commands::CreateBidOuts { pairs, fee_rate } => {
535532
cli.send_request(None, Some(pairs), fee_rate, false).await?
@@ -548,7 +545,7 @@ async fn handle_commands(
548545
fee_rate,
549546
false,
550547
)
551-
.await?
548+
.await?
552549
}
553550
Commands::Renew { spaces, fee_rate } => {
554551
let spaces: Vec<_> = spaces.into_iter().map(|s| normalize_space(&s)).collect();
@@ -561,7 +558,7 @@ async fn handle_commands(
561558
fee_rate,
562559
false,
563560
)
564-
.await?
561+
.await?
565562
}
566563
Commands::Transfer {
567564
spaces,
@@ -578,7 +575,7 @@ async fn handle_commands(
578575
fee_rate,
579576
false,
580577
)
581-
.await?
578+
.await?
582579
}
583580
Commands::SendCoins {
584581
amount,
@@ -594,7 +591,7 @@ async fn handle_commands(
594591
fee_rate,
595592
false,
596593
)
597-
.await?
594+
.await?
598595
}
599596
Commands::SetRawFallback {
600597
mut space,
@@ -612,7 +609,8 @@ async fn handle_commands(
612609
}
613610
};
614611

615-
let space_script = protocol::script::SpaceScript::create_set_fallback(data.as_slice());
612+
let space_script =
613+
spaces_protocol::script::SpaceScript::create_set_fallback(data.as_slice());
616614

617615
cli.send_request(
618616
Some(RpcWalletRequest::Execute(ExecuteParams {
@@ -623,7 +621,7 @@ async fn handle_commands(
623621
fee_rate,
624622
false,
625623
)
626-
.await?;
624+
.await?;
627625
}
628626
Commands::ListUnspent => {
629627
let utxos = cli.client.wallet_list_unspent(&cli.wallet).await?;
@@ -670,24 +668,36 @@ async fn handle_commands(
670668
.wallet_bump_fee(&cli.wallet, txid, fee_rate, cli.skip_tx_check)
671669
.await?;
672670
print_wallet_response(
673-
cli.network.fallback_network(), WalletResponse {
674-
result: response,
675-
}, cli.format);
671+
cli.network.fallback_network(),
672+
WalletResponse { result: response },
673+
cli.format,
674+
);
676675
}
677676
Commands::HashSpace { space } => {
678677
println!(
679678
"{}",
680679
hash_space(&space).map_err(|e| ClientError::Custom(e.to_string()))?
681680
);
682681
}
683-
Commands::Buy { space, price, signature, seller, fee_rate } => {
682+
Commands::Buy {
683+
space,
684+
price,
685+
signature,
686+
seller,
687+
fee_rate,
688+
} => {
684689
let listing = Listing {
685690
space: normalize_space(&space),
686691
price,
687692
seller,
688-
signature: Signature::from_slice(hex::decode(signature)
689-
.map_err(|_| ClientError::Custom("Signature must be in hex format".to_string()))?.as_slice())
690-
.map_err(|_| ClientError::Custom("Invalid signature".to_string()))?,
693+
signature: Signature::from_slice(
694+
hex::decode(signature)
695+
.map_err(|_| {
696+
ClientError::Custom("Signature must be in hex format".to_string())
697+
})?
698+
.as_slice(),
699+
)
700+
.map_err(|_| ClientError::Custom("Invalid signature".to_string()))?,
691701
};
692702
let result = cli
693703
.client
@@ -696,57 +706,75 @@ async fn handle_commands(
696706
listing,
697707
fee_rate.map(|rate| FeeRate::from_sat_per_vb(rate).expect("valid fee rate")),
698708
cli.skip_tx_check,
699-
).await?;
700-
print_wallet_response(cli.network.fallback_network(), WalletResponse {
701-
result: vec![result],
702-
}, cli.format
709+
)
710+
.await?;
711+
print_wallet_response(
712+
cli.network.fallback_network(),
713+
WalletResponse {
714+
result: vec![result],
715+
},
716+
cli.format,
703717
);
704718
}
705-
Commands::Sell { mut space, price, } => {
719+
Commands::Sell { mut space, price } => {
706720
space = normalize_space(&space);
707-
let result = cli
708-
.client
709-
.wallet_sell(
710-
&cli.wallet,
711-
space,
712-
price,
713-
).await?;
721+
let result = cli.client.wallet_sell(&cli.wallet, space, price).await?;
714722
println!("{}", serde_json::to_string_pretty(&result).expect("result"));
715723
}
716-
Commands::VerifyListing { space, price, signature, seller } => {
724+
Commands::VerifyListing {
725+
space,
726+
price,
727+
signature,
728+
seller,
729+
} => {
717730
let listing = Listing {
718731
space: normalize_space(&space),
719732
price,
720733
seller,
721-
signature: Signature::from_slice(hex::decode(signature)
722-
.map_err(|_| ClientError::Custom("Signature must be in hex format".to_string()))?.as_slice())
723-
.map_err(|_| ClientError::Custom("Invalid signature".to_string()))?,
734+
signature: Signature::from_slice(
735+
hex::decode(signature)
736+
.map_err(|_| {
737+
ClientError::Custom("Signature must be in hex format".to_string())
738+
})?
739+
.as_slice(),
740+
)
741+
.map_err(|_| ClientError::Custom("Invalid signature".to_string()))?,
724742
};
725743

726-
cli.client
727-
.verify_listing(listing).await?;
744+
cli.client.verify_listing(listing).await?;
728745
println!("{} Listing verified", "✓".color(Color::Green));
729746
}
730747
Commands::SignMessage { mut space, message } => {
731748
space = normalize_space(&space);
732-
let result = cli.client
733-
.wallet_sign_message(&cli.wallet, &space, protocol::Bytes::new(message.as_bytes().to_vec())).await?;
749+
let result = cli
750+
.client
751+
.wallet_sign_message(
752+
&cli.wallet,
753+
&space,
754+
spaces_protocol::Bytes::new(message.as_bytes().to_vec()),
755+
)
756+
.await?;
734757
println!("{}", result.signature);
735758
}
736-
Commands::VerifyMessage { mut space, message, signature } => {
759+
Commands::VerifyMessage {
760+
mut space,
761+
message,
762+
signature,
763+
} => {
737764
space = normalize_space(&space);
738765
let raw = hex::decode(signature)
739766
.map_err(|_| ClientError::Custom("Invalid signature".to_string()))?;
740767
let signature = Signature::from_slice(raw.as_slice())
741768
.map_err(|_| ClientError::Custom("Invalid signature".to_string()))?;
742-
cli.client.verify_message(SignedMessage {
743-
space,
744-
message: protocol::Bytes::new(message.as_bytes().to_vec()),
745-
signature,
746-
}).await?;
769+
cli.client
770+
.verify_message(SignedMessage {
771+
space,
772+
message: spaces_protocol::Bytes::new(message.as_bytes().to_vec()),
773+
signature,
774+
})
775+
.await?;
747776
println!("{} Message verified", "✓".color(Color::Green));
748777
}
749-
750778
}
751779

752780
Ok(())

node/src/bin/spaced.rs client/src/bin/spaced.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::Arc;
33
use anyhow::anyhow;
44
use env_logger::Env;
55
use log::error;
6-
use spaced::{
6+
use spaces_client::{
77
config::{safe_exit, Args},
88
rpc::{AsyncChainState, RpcServerImpl, WalletLoadRequest, WalletManager},
99
source::{BitcoinBlockSource, BitcoinRpc},

node/src/checker.rs client/src/checker.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::BTreeMap;
22

33
use anyhow::anyhow;
4-
use protocol::{
4+
use spaces_protocol::{
55
bitcoin::{OutPoint, Transaction},
66
hasher::{KeyHasher, SpaceKey},
77
prepare::{DataSource, TxContext},
@@ -147,14 +147,17 @@ impl DataSource for TxChecker<'_> {
147147
fn get_space_outpoint(
148148
&mut self,
149149
space_hash: &SpaceKey,
150-
) -> protocol::errors::Result<Option<OutPoint>> {
150+
) -> spaces_protocol::errors::Result<Option<OutPoint>> {
151151
match self.spaces.get(space_hash) {
152152
None => self.original.get_space_outpoint(space_hash.into()),
153153
Some(res) => Ok(res.clone()),
154154
}
155155
}
156156

157-
fn get_spaceout(&mut self, outpoint: &OutPoint) -> protocol::errors::Result<Option<SpaceOut>> {
157+
fn get_spaceout(
158+
&mut self,
159+
outpoint: &OutPoint,
160+
) -> spaces_protocol::errors::Result<Option<SpaceOut>> {
158161
match self.spaceouts.get(outpoint) {
159162
None => self.original.get_spaceout(outpoint),
160163
Some(space_out) => Ok(space_out.clone()),

0 commit comments

Comments
 (0)