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

feat: update ordhook schemas #458

Merged
merged 12 commits into from
Nov 17, 2023
6 changes: 3 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions components/chainhook-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainhook-sdk"
version = "0.10.2"
version = "0.10.6"
description = "Stateless Transaction Indexing Engine for Stacks and Bitcoin"
license = "GPL-3.0"
edition = "2021"
Expand All @@ -18,7 +18,7 @@ hiro-system-kit = { version = "0.3.1", optional = true }
# stacks-rpc-client = { version = "1", path = "../../../clarinet/components/stacks-rpc-client" }
# clarinet-utils = { version = "1", path = "../../../clarinet/components/clarinet-utils" }
# hiro-system-kit = { version = "0.1.0", path = "../../../clarinet/components/hiro-system-kit" }
chainhook-types = { version = "1.1.0", path = "../chainhook-types-rs" }
chainhook-types = { version = "1.1.2", path = "../chainhook-types-rs" }
rocket = { version = "=0.5.0-rc.3", features = ["json"] }
bitcoincore-rpc = "0.16.0"
bitcoincore-rpc-json = "0.16.0"
Expand Down
61 changes: 61 additions & 0 deletions components/chainhook-sdk/src/observer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,67 @@ impl EventObserverConfig {
_ => unreachable!(),
}
}

pub fn new_using_overrides(
overrides: Option<&EventObserverConfigOverrides>,
) -> Result<EventObserverConfig, String> {
let bitcoin_network =
if let Some(network) = overrides.and_then(|c| c.bitcoin_network.as_ref()) {
BitcoinNetwork::from_str(network)?
} else {
BitcoinNetwork::Regtest
};

let stacks_network =
if let Some(network) = overrides.and_then(|c| c.stacks_network.as_ref()) {
StacksNetwork::from_str(network)?
} else {
StacksNetwork::Devnet
};

let config = EventObserverConfig {
bitcoin_rpc_proxy_enabled: false,
chainhook_config: None,
ingestion_port: overrides
.and_then(|c| c.ingestion_port)
.unwrap_or(DEFAULT_INGESTION_PORT),
bitcoind_rpc_username: overrides
.and_then(|c| c.bitcoind_rpc_username.clone())
.unwrap_or("devnet".to_string()),
bitcoind_rpc_password: overrides
.and_then(|c| c.bitcoind_rpc_password.clone())
.unwrap_or("devnet".to_string()),
bitcoind_rpc_url: overrides
.and_then(|c| c.bitcoind_rpc_url.clone())
.unwrap_or("http://localhost:18443".to_string()),
bitcoin_block_signaling: overrides
.and_then(|c| match c.bitcoind_zmq_url.as_ref() {
Some(url) => Some(BitcoinBlockSignaling::ZeroMQ(url.clone())),
None => Some(BitcoinBlockSignaling::Stacks(
StacksNodeConfig::default_localhost(
overrides
.and_then(|c| c.ingestion_port)
.unwrap_or(DEFAULT_INGESTION_PORT),
),
)),
})
.unwrap_or(BitcoinBlockSignaling::Stacks(
StacksNodeConfig::default_localhost(
overrides
.and_then(|c| c.ingestion_port)
.unwrap_or(DEFAULT_INGESTION_PORT),
),
)),
display_logs: overrides.and_then(|c| c.display_logs).unwrap_or(false),
cache_path: overrides
.and_then(|c| c.cache_path.clone())
.unwrap_or("cache".to_string()),
bitcoin_network,
stacks_network,
data_handler_tx: None,
};
Ok(config)
}
}

#[derive(Deserialize, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion components/chainhook-types-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "chainhook-types"
description = "Bitcoin and Stacks data schemas, based on the Rosetta specification"
license = "MIT"
version = "1.1.0"
version = "1.1.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
10 changes: 9 additions & 1 deletion components/chainhook-types-rs/src/rosetta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,21 @@ pub enum OrdinalOperation {
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct OrdinalInscriptionTransferData {
pub inscription_id: String,
pub updated_address: Option<String>,
pub destination: OrdinalInscriptionTransferDestination,
pub satpoint_pre_transfer: String,
pub satpoint_post_transfer: String,
pub post_transfer_output_value: Option<u64>,
pub tx_index: usize,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum OrdinalInscriptionTransferDestination {
Transferred(String),
SpentInFees,
Burnt(String),
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub enum OrdinalInscriptionCurseType {
Tag(u8),
Expand Down