Skip to content

Commit 6f9c718

Browse files
authored
fix: read contract_interface from Stacks node block events (#712)
Reads a deployed smart contract ABI from `contract_interface` instead of `contract_abi` in `/new_block` events. We still keep support for the old property in case someone runs chainhook with an older Stacks node or TSV file.
1 parent 5c74a55 commit 6f9c718

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

components/chainhook-cli/src/service/tests/helpers/mock_stacks_node.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ fn create_stacks_new_transaction(index: u64) -> NewTransaction {
124124
raw_result: "0x0703".to_string(),
125125
raw_tx: "0x00000000010400e2cd0871da5bdd38c4d5569493dc3b14aac4e0a10000000000000019000000000000000000008373b16e4a6f9d87864c314dd77bbd8b27a2b1805e96ec5a6509e7e4f833cd6a7bdb2462c95f6968a867ab6b0e8f0a6498e600dbc46cfe9f84c79709da7b9637010200000000040000000000000000000000000000000000000000000000000000000000000000".to_string(),
126126
execution_cost: None,
127-
contract_abi: None
127+
contract_interface: None,
128+
contract_abi: None,
128129
}
129130
}
130131

components/chainhook-sdk/src/indexer/stacks/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ pub struct NewTransaction {
112112
pub raw_result: String,
113113
pub raw_tx: String,
114114
pub execution_cost: Option<StacksTransactionExecutionCost>,
115+
pub contract_interface: Option<ContractInterface>,
116+
/// @deprecated Use `contract_interface` instead
115117
pub contract_abi: Option<ContractInterface>,
116118
}
117119

@@ -456,7 +458,7 @@ pub fn standardize_stacks_block(
456458
description,
457459
position: StacksTransactionPosition::anchor_block(tx.tx_index),
458460
proof: None,
459-
contract_abi: tx.contract_abi.clone(),
461+
contract_abi: tx.contract_interface.clone().or_else(|| tx.contract_abi.clone()),
460462
},
461463
});
462464
}

0 commit comments

Comments
 (0)