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: add support for runehook #605

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
5 changes: 4 additions & 1 deletion components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::types::{
BitcoinChainhookSpecification, BitcoinPredicateType, DescriptorMatchingRule, ExactMatchingRule,
HookAction, InputPredicate, MatchingRule, OrdinalOperations, OrdinalsMetaProtocol,
OutputPredicate, StacksOperations,
OutputPredicate, RunesOperations, StacksOperations,
};
use crate::utils::Context;

Expand Down Expand Up @@ -577,6 +577,9 @@ impl BitcoinPredicateType {
}
None => !tx.metadata.ordinal_operations.is_empty(),
},
BitcoinPredicateType::RunesProtocol(RunesOperations::Feed) => {
return !tx.metadata.runes_operations.is_empty()
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions components/chainhook-sdk/src/chainhooks/bitcoin/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ fn script_pubkey_evaluation(output: OutputPredicate, script_pubkey: &str, matche
inputs: vec![],
stacks_operations: vec![],
ordinal_operations: vec![],
runes_operations: vec![],
brc20_operation: None,
outputs,
},
Expand Down Expand Up @@ -212,6 +213,7 @@ fn it_serdes_brc20_payload(tick: String) {
outputs: vec![],
ordinal_operations: vec![],
stacks_operations: vec![],
runes_operations: vec![],
brc20_operation: Some(Brc20Operation::Deploy(Brc20TokenDeployData {
tick,
max: "21000000.000000".to_string(),
Expand Down
7 changes: 7 additions & 0 deletions components/chainhook-sdk/src/chainhooks/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ pub enum BitcoinPredicateType {
Outputs(OutputPredicate),
StacksProtocol(StacksOperations),
OrdinalsProtocol(OrdinalOperations),
RunesProtocol(RunesOperations),
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
Expand Down Expand Up @@ -570,6 +571,12 @@ pub enum OrdinalOperations {
InscriptionFeed(InscriptionFeedData),
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case", tag = "operation")]
pub enum RunesOperations {
Feed,
}

pub fn get_stacks_canonical_magic_bytes(network: &BitcoinNetwork) -> [u8; 2] {
match network {
BitcoinNetwork::Mainnet => *b"X2",
Expand Down
1 change: 1 addition & 0 deletions components/chainhook-sdk/src/indexer/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ pub fn standardize_bitcoin_block(
stacks_operations,
ordinal_operations: vec![],
brc20_operation: None,
runes_operations: vec![],
proof: None,
fee: sats_in.saturating_sub(sats_out),
index: tx_index as u32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub fn generate_test_tx_bitcoin_p2pkh_transfer(
outputs,
ordinal_operations: vec![],
stacks_operations: vec![],
runes_operations: vec![],
brc20_operation: None,
proof: None,
fee: 0,
Expand Down
6 changes: 6 additions & 0 deletions components/chainhook-types-rs/src/ordinals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,9 @@ pub enum Brc20Operation {
Transfer(Brc20BalanceData),
TransferSend(Brc20TransferData),
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum RunesOperation {
Etching,
}
3 changes: 2 additions & 1 deletion components/chainhook-types-rs/src/rosetta.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::bitcoin::{TxIn, TxOut};
use crate::contract_interface::ContractInterface;
use crate::ordinals::OrdinalOperation;
use crate::{events::*, Brc20Operation, DEFAULT_STACKS_NODE_RPC};
use crate::{events::*, Brc20Operation, RunesOperation, DEFAULT_STACKS_NODE_RPC};
use schemars::JsonSchema;
use std::cmp::Ordering;
use std::collections::HashSet;
Expand Down Expand Up @@ -313,6 +313,7 @@ pub struct BitcoinTransactionMetadata {
pub stacks_operations: Vec<StacksBaseChainOperation>,
pub ordinal_operations: Vec<OrdinalOperation>,
pub brc20_operation: Option<Brc20Operation>,
pub runes_operations: Vec<RunesOperation>,
pub proof: Option<String>,
pub fee: u64,
pub index: u32,
Expand Down
Loading