diff --git a/Cargo.toml b/Cargo.toml index 0cdafda..d3e4060 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,7 @@ license = "CC0-1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace] -members = ["crates/internal/*", "crates/ns-*"] -# exclude = ["crates/internal"] +members = ["crates/*"] [workspace.dependencies] anyhow = "1" diff --git a/crates/internal/axum-web/Cargo.toml b/crates/ns-axum-web/Cargo.toml similarity index 77% rename from crates/internal/axum-web/Cargo.toml rename to crates/ns-axum-web/Cargo.toml index 18e95fd..2833b22 100644 --- a/crates/internal/axum-web/Cargo.toml +++ b/crates/ns-axum-web/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "axum-web" +name = "ns-axum-web" version = "0.1.0" edition = "2021" rust-version = "1.64" -description = "" -publish = false -repository = "https://github.com/ldclabs/ns-rs/crates/internal/axum-web" +description = "axum web middlewares for ns-rs" +publish = true +repository = "https://github.com/ldclabs/ns-rs/tree/main/crates/ns-axum-web" license = "CC0-1.0" [lib] @@ -25,6 +25,6 @@ serde = { workspace = true } serde_json = { workspace = true } structured-logger = { workspace = true } tokio = { workspace = true } -scylla = "0.10" +scylla = "0.11" zstd = "0.12" validator = { version = "0.16", features = ["derive"] } diff --git a/crates/internal/axum-web/src/context.rs b/crates/ns-axum-web/src/context.rs similarity index 100% rename from crates/internal/axum-web/src/context.rs rename to crates/ns-axum-web/src/context.rs diff --git a/crates/internal/axum-web/src/encoding.rs b/crates/ns-axum-web/src/encoding.rs similarity index 100% rename from crates/internal/axum-web/src/encoding.rs rename to crates/ns-axum-web/src/encoding.rs diff --git a/crates/internal/axum-web/src/erring.rs b/crates/ns-axum-web/src/erring.rs similarity index 100% rename from crates/internal/axum-web/src/erring.rs rename to crates/ns-axum-web/src/erring.rs diff --git a/crates/internal/axum-web/src/lib.rs b/crates/ns-axum-web/src/lib.rs similarity index 100% rename from crates/internal/axum-web/src/lib.rs rename to crates/ns-axum-web/src/lib.rs diff --git a/crates/internal/axum-web/src/object.rs b/crates/ns-axum-web/src/object.rs similarity index 100% rename from crates/internal/axum-web/src/object.rs rename to crates/ns-axum-web/src/object.rs diff --git a/crates/ns-fetcher/Cargo.toml b/crates/ns-fetcher/Cargo.toml index 927472c..c98b5bb 100644 --- a/crates/ns-fetcher/Cargo.toml +++ b/crates/ns-fetcher/Cargo.toml @@ -11,7 +11,7 @@ license = "CC0-1.0" [lib] [dependencies] -ns-protocol = { path = "../ns-protocol" } +ns-protocol = { path = "../ns-protocol", version = "0.4" } anyhow = { workspace = true } bytes = { workspace = true } base64 = { workspace = true } diff --git a/crates/ns-indexer/Cargo.toml b/crates/ns-indexer/Cargo.toml index 9e11f08..8593054 100644 --- a/crates/ns-indexer/Cargo.toml +++ b/crates/ns-indexer/Cargo.toml @@ -15,10 +15,10 @@ name = "ns-indexer" path = "src/bin/main.rs" [dependencies] -ns-protocol = { path = "../ns-protocol" } -axum-web = { path = "../internal/axum-web" } -scylla-orm = { path = "../internal/scylla-orm" } -scylla-orm-macros = { path = "../internal/scylla-orm-macros" } +ns-protocol = { path = "../ns-protocol", version = "0.4" } +ns-axum-web = { path = "../ns-axum-web", version = "0.1" } +ns-scylla-orm = { path = "../ns-scylla-orm", version = "0.1" } +ns-scylla-orm-macros = { path = "../ns-scylla-orm-macros", version = "0.1" } anyhow = { workspace = true } axum = { workspace = true } bytes = { workspace = true } @@ -42,7 +42,7 @@ bitcoin = { version = "0.31", features = ["serde", "base64", "rand"] } dotenvy = "0.15" hex = "0.4" bitcoincore-rpc-json = "0.18.0" -scylla = "0.10" +scylla = "0.11" tower = "0.4" tower-http = { version = "0.5", features = [ "catch-panic", diff --git a/crates/ns-indexer/src/api/inscription.rs b/crates/ns-indexer/src/api/inscription.rs index f64be1b..dd7ae5b 100644 --- a/crates/ns-indexer/src/api/inscription.rs +++ b/crates/ns-indexer/src/api/inscription.rs @@ -5,7 +5,7 @@ use axum::{ use std::sync::Arc; use validator::Validate; -use axum_web::{ +use ns_axum_web::{ context::ReqContext, erring::{HTTPError, SuccessResponse}, object::PackObject, diff --git a/crates/ns-indexer/src/api/mod.rs b/crates/ns-indexer/src/api/mod.rs index fe78ff0..7ea299b 100644 --- a/crates/ns-indexer/src/api/mod.rs +++ b/crates/ns-indexer/src/api/mod.rs @@ -3,8 +3,8 @@ use serde::{Deserialize, Serialize}; use std::sync::Arc; use validator::{Validate, ValidationError}; -use axum_web::erring::{HTTPError, SuccessResponse}; -use axum_web::object::PackObject; +use ns_axum_web::erring::{HTTPError, SuccessResponse}; +use ns_axum_web::object::PackObject; use ns_protocol::ns; use crate::db::scylladb::ScyllaDB; diff --git a/crates/ns-indexer/src/api/name.rs b/crates/ns-indexer/src/api/name.rs index 0634ebe..4f8498e 100644 --- a/crates/ns-indexer/src/api/name.rs +++ b/crates/ns-indexer/src/api/name.rs @@ -5,7 +5,7 @@ use axum::{ use std::sync::Arc; use validator::Validate; -use axum_web::{ +use ns_axum_web::{ context::ReqContext, erring::{HTTPError, SuccessResponse}, object::PackObject, diff --git a/crates/ns-indexer/src/api/service.rs b/crates/ns-indexer/src/api/service.rs index 5cc2af4..f8a0533 100644 --- a/crates/ns-indexer/src/api/service.rs +++ b/crates/ns-indexer/src/api/service.rs @@ -5,7 +5,7 @@ use axum::{ use std::sync::Arc; use validator::Validate; -use axum_web::{ +use ns_axum_web::{ context::ReqContext, erring::{HTTPError, SuccessResponse}, object::PackObject, diff --git a/crates/ns-indexer/src/api/utxo.rs b/crates/ns-indexer/src/api/utxo.rs index 4938ddb..3fd5cab 100644 --- a/crates/ns-indexer/src/api/utxo.rs +++ b/crates/ns-indexer/src/api/utxo.rs @@ -6,7 +6,7 @@ use bitcoin::{Address, AddressType}; use std::{collections::BTreeMap, str::FromStr, sync::Arc}; use validator::Validate; -use axum_web::{ +use ns_axum_web::{ context::ReqContext, erring::{HTTPError, SuccessResponse}, object::PackObject, diff --git a/crates/ns-indexer/src/db/model_inscription.rs b/crates/ns-indexer/src/db/model_inscription.rs index d360bef..9517854 100644 --- a/crates/ns-indexer/src/db/model_inscription.rs +++ b/crates/ns-indexer/src/db/model_inscription.rs @@ -1,6 +1,6 @@ -use axum_web::erring::HTTPError; -use scylla_orm::{ColumnsMap, CqlValue, ToCqlVal}; -use scylla_orm_macros::CqlOrm; +use ns_axum_web::erring::HTTPError; +use ns_scylla_orm::{ColumnsMap, CqlValue, ToCqlVal}; +use ns_scylla_orm_macros::CqlOrm; use ns_protocol::state; diff --git a/crates/ns-indexer/src/db/model_name_state.rs b/crates/ns-indexer/src/db/model_name_state.rs index 4adbfc8..a17b94a 100644 --- a/crates/ns-indexer/src/db/model_name_state.rs +++ b/crates/ns-indexer/src/db/model_name_state.rs @@ -1,6 +1,6 @@ -use axum_web::erring::HTTPError; -use scylla_orm::{ColumnsMap, CqlValue, ToCqlVal}; -use scylla_orm_macros::CqlOrm; +use ns_axum_web::erring::HTTPError; +use ns_scylla_orm::{ColumnsMap, CqlValue, ToCqlVal}; +use ns_scylla_orm_macros::CqlOrm; use std::collections::{BTreeMap, HashSet}; use ns_protocol::state; diff --git a/crates/ns-indexer/src/db/model_service_protocol.rs b/crates/ns-indexer/src/db/model_service_protocol.rs index 0368cea..3c33b6a 100644 --- a/crates/ns-indexer/src/db/model_service_protocol.rs +++ b/crates/ns-indexer/src/db/model_service_protocol.rs @@ -1,6 +1,6 @@ -use axum_web::erring::HTTPError; -use scylla_orm::{ColumnsMap, ToCqlVal}; -use scylla_orm_macros::CqlOrm; +use ns_axum_web::erring::HTTPError; +use ns_scylla_orm::{ColumnsMap, ToCqlVal}; +use ns_scylla_orm_macros::CqlOrm; use ns_protocol::state; diff --git a/crates/ns-indexer/src/db/model_service_state.rs b/crates/ns-indexer/src/db/model_service_state.rs index 360a5c2..e41ea11 100644 --- a/crates/ns-indexer/src/db/model_service_state.rs +++ b/crates/ns-indexer/src/db/model_service_state.rs @@ -1,6 +1,6 @@ -use axum_web::erring::HTTPError; -use scylla_orm::{ColumnsMap, ToCqlVal}; -use scylla_orm_macros::CqlOrm; +use ns_axum_web::erring::HTTPError; +use ns_scylla_orm::{ColumnsMap, ToCqlVal}; +use ns_scylla_orm_macros::CqlOrm; use ns_protocol::state; diff --git a/crates/ns-indexer/src/db/model_utxo.rs b/crates/ns-indexer/src/db/model_utxo.rs index cc5dda4..2aca136 100644 --- a/crates/ns-indexer/src/db/model_utxo.rs +++ b/crates/ns-indexer/src/db/model_utxo.rs @@ -1,7 +1,7 @@ use std::vec; -use scylla_orm::{ColumnsMap, CqlValue, ToCqlVal}; -use scylla_orm_macros::CqlOrm; +use ns_scylla_orm::{ColumnsMap, CqlValue, ToCqlVal}; +use ns_scylla_orm_macros::CqlOrm; use crate::db::scylladb; use crate::utxo; diff --git a/crates/ns-indexer/src/db/scylladb.rs b/crates/ns-indexer/src/db/scylladb.rs index 61cb20d..636e86a 100644 --- a/crates/ns-indexer/src/db/scylladb.rs +++ b/crates/ns-indexer/src/db/scylladb.rs @@ -1,6 +1,6 @@ use futures::{stream::StreamExt, Stream}; use scylla::{ - frame::value::{BatchValues, ValueList}, + serialize::{batch::BatchValues, row::SerializeRow}, statement::{Consistency, SerialConsistency}, transport::{ iterator::RowIterator, @@ -62,7 +62,7 @@ impl ScyllaDB { pub async fn execute( &self, query: impl Into, - params: impl ValueList, + params: impl SerializeRow, ) -> anyhow::Result { let res = self.session.execute(query, params).await?; Ok(res) @@ -71,7 +71,7 @@ impl ScyllaDB { pub async fn execute_iter( &self, query: impl Into, - params: impl ValueList, + params: impl SerializeRow, ) -> anyhow::Result> { let mut rows_stream = self.session.execute_iter(query, params).await?; @@ -86,7 +86,7 @@ impl ScyllaDB { pub async fn stream( &self, query: impl Into, - params: impl ValueList, + params: impl SerializeRow, ) -> anyhow::Result { let stream = self.session.execute_iter(query, params).await?; Ok(stream) diff --git a/crates/ns-indexer/src/router.rs b/crates/ns-indexer/src/router.rs index 8198464..6363ca2 100644 --- a/crates/ns-indexer/src/router.rs +++ b/crates/ns-indexer/src/router.rs @@ -6,8 +6,8 @@ use tower_http::{ compression::{predicate::SizeAbove, CompressionLayer}, }; -use axum_web::context; -use axum_web::encoding; +use ns_axum_web::context; +use ns_axum_web::encoding; use crate::api; diff --git a/crates/ns-inscriber/Cargo.toml b/crates/ns-inscriber/Cargo.toml index 1c24fc9..eb21c76 100644 --- a/crates/ns-inscriber/Cargo.toml +++ b/crates/ns-inscriber/Cargo.toml @@ -15,8 +15,8 @@ name = "ns-inscriber" path = "src/bin/main.rs" [dependencies] -ns-protocol = { path = "../ns-protocol" } -ns-indexer = { path = "../ns-indexer" } +ns-protocol = { path = "../ns-protocol", version = "0.4" } +ns-indexer = { path = "../ns-indexer", version = "0.1" } anyhow = { workspace = true } bytes = { workspace = true } base64 = { workspace = true } diff --git a/crates/ns-inscriber/src/bin/main.rs b/crates/ns-inscriber/src/bin/main.rs index ce68f9b..cc732bb 100644 --- a/crates/ns-inscriber/src/bin/main.rs +++ b/crates/ns-inscriber/src/bin/main.rs @@ -567,7 +567,6 @@ async fn main() -> anyhow::Result<()> { amount: txout.value, script_pubkey: txout.script_pubkey.clone(), }], - None, ) .await?; diff --git a/crates/ns-inscriber/src/inscriber.rs b/crates/ns-inscriber/src/inscriber.rs index 125725f..1d4a6c4 100644 --- a/crates/ns-inscriber/src/inscriber.rs +++ b/crates/ns-inscriber/src/inscriber.rs @@ -59,17 +59,11 @@ impl Inscriber { fee_rate: Amount, secret: &SecretKey, unspent_txouts: &Vec, - inscription_keypair: Option, // safe to use one-time KeyPair ) -> anyhow::Result { let keypair = Keypair::from_secret_key(&self.secp, secret); let (unspent_txout, unsigned_commit_tx, signed_reveal_tx) = self - .build_inscription_transactions( - names, - fee_rate, - unspent_txouts, - Some(inscription_keypair.unwrap_or(keypair)), - ) + .build_inscription_transactions(names, fee_rate, unspent_txouts, Some(keypair)) .await?; let mut signed_commit_tx = unsigned_commit_tx; @@ -137,9 +131,13 @@ impl Inscriber { } let commit = self.bitcoin.send_transaction(&signed_commit_tx).await?; - let reveal = self.bitcoin.send_transaction(&signed_reveal_tx).await - .map_err(|err| anyhow::anyhow!("failed to send reveal transaction: {err}\ncommit tx {commit} will be recovered once mined" - ))?; + let reveal = self + .bitcoin + .send_transaction(&signed_reveal_tx) + .await + .map_err(|err| { + anyhow::anyhow!("failed to send reveal transaction: {err}\ncommit tx: {commit}") + })?; Ok(reveal) } @@ -704,7 +702,7 @@ mod tests { let names = vec![get_name("0")]; let fee_rate = Amount::from_sat(20); let txid = inscriber - .inscribe(&names, fee_rate, &keypair.secret_key(), &unspent_txs, None) + .inscribe(&names, fee_rate, &keypair.secret_key(), &unspent_txs) .await .unwrap(); println!("txid: {}", txid); @@ -764,13 +762,7 @@ mod tests { assert_eq!("z", names[35].name); let txid = inscriber - .inscribe( - &names, - fee_rate, - &keypair.secret_key(), - &unspent_txs, - Some(keypair), - ) + .inscribe(&names, fee_rate, &keypair.secret_key(), &unspent_txs) .await .unwrap(); println!("txid: {}", txid); diff --git a/crates/internal/scylla-orm-macros/Cargo.toml b/crates/ns-scylla-orm-macros/Cargo.toml similarity index 53% rename from crates/internal/scylla-orm-macros/Cargo.toml rename to crates/ns-scylla-orm-macros/Cargo.toml index 930c233..812f765 100644 --- a/crates/internal/scylla-orm-macros/Cargo.toml +++ b/crates/ns-scylla-orm-macros/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "scylla-orm-macros" +name = "ns-scylla-orm-macros" version = "0.1.0" edition = "2021" rust-version = "1.64" -description = "" -publish = false -repository = "https://github.com/ldclabs/ns-rs/crates/internal/scylla-orm-macros" +description = "scylla orm macros for ns-rs" +publish = true +repository = "https://github.com/ldclabs/ns-rs/tree/main/crates/ns-scylla-orm-macros" license = "CC0-1.0" [lib] diff --git a/crates/internal/scylla-orm-macros/src/cql_orm.rs b/crates/ns-scylla-orm-macros/src/cql_orm.rs similarity index 90% rename from crates/internal/scylla-orm-macros/src/cql_orm.rs rename to crates/ns-scylla-orm-macros/src/cql_orm.rs index 8d85661..39748bf 100644 --- a/crates/internal/scylla-orm-macros/src/cql_orm.rs +++ b/crates/ns-scylla-orm-macros/src/cql_orm.rs @@ -42,7 +42,7 @@ pub fn cql_orm(input: TokenStream) -> TokenStream { ] } - pub fn fill(&mut self, cols: &scylla_orm::ColumnsMap) { + pub fn fill(&mut self, cols: &ColumnsMap) { #( if cols.has(#field_names_string1) { self.#field_names0 = cols.get_as(#field_names_string2).unwrap_or_default(); @@ -50,8 +50,8 @@ pub fn cql_orm(input: TokenStream) -> TokenStream { )* } - pub fn to(&self) -> scylla_orm::ColumnsMap { - let mut cols = scylla_orm::ColumnsMap::with_capacity(#fields_num); + pub fn to(&self) -> ColumnsMap { + let mut cols = ColumnsMap::with_capacity(#fields_num); #( cols.set_as(#field_names_string3, &self.#field_names1); )* diff --git a/crates/internal/scylla-orm-macros/src/lib.rs b/crates/ns-scylla-orm-macros/src/lib.rs similarity index 100% rename from crates/internal/scylla-orm-macros/src/lib.rs rename to crates/ns-scylla-orm-macros/src/lib.rs diff --git a/crates/internal/scylla-orm/Cargo.toml b/crates/ns-scylla-orm/Cargo.toml similarity index 56% rename from crates/internal/scylla-orm/Cargo.toml rename to crates/ns-scylla-orm/Cargo.toml index c5643f6..8a5ec62 100644 --- a/crates/internal/scylla-orm/Cargo.toml +++ b/crates/ns-scylla-orm/Cargo.toml @@ -1,18 +1,18 @@ [package] -name = "scylla-orm" +name = "ns-scylla-orm" version = "0.1.0" edition = "2021" rust-version = "1.64" -description = "" -publish = false -repository = "https://github.com/ldclabs/ns-rs/crates/internal/scylla-orm" +description = "scylla orm for ns-rs" +publish = true +repository = "https://github.com/ldclabs/ns-rs/tree/main/crates/ns-scylla-orm" license = "CC0-1.0" [lib] [dependencies] anyhow = { workspace = true } -scylla = "0.10" +scylla = "0.11" [dev-dependencies] ciborium = { workspace = true } diff --git a/crates/internal/scylla-orm/src/columns.rs b/crates/ns-scylla-orm/src/columns.rs similarity index 100% rename from crates/internal/scylla-orm/src/columns.rs rename to crates/ns-scylla-orm/src/columns.rs diff --git a/crates/internal/scylla-orm/src/cql_value.rs b/crates/ns-scylla-orm/src/cql_value.rs similarity index 100% rename from crates/internal/scylla-orm/src/cql_value.rs rename to crates/ns-scylla-orm/src/cql_value.rs diff --git a/crates/internal/scylla-orm/src/lib.rs b/crates/ns-scylla-orm/src/lib.rs similarity index 100% rename from crates/internal/scylla-orm/src/lib.rs rename to crates/ns-scylla-orm/src/lib.rs