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

fix: add event index to transaction events #417

Closed
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
aa30d42
spelling fix in tests
MicaiahReid Aug 23, 2023
96fb8dd
variable rename
MicaiahReid Aug 23, 2023
4457533
update status for first scan
MicaiahReid Aug 23, 2023
0f8ed57
update StreamingData status
MicaiahReid Aug 23, 2023
aea9e15
missed rename
MicaiahReid Aug 23, 2023
1832ec8
add more info to predicate status updates
MicaiahReid Aug 24, 2023
9eec034
doc comments
MicaiahReid Aug 24, 2023
73a9c0f
remove changes to Interrupted status
MicaiahReid Aug 24, 2023
9741167
return error details to user for failed hook actions
MicaiahReid Aug 24, 2023
3208481
add predicate streaming status update for bitcoin
MicaiahReid Aug 24, 2023
78592ba
augment LIST endpoint; merge helpers
MicaiahReid Aug 24, 2023
7742043
variable/status renames
MicaiahReid Aug 28, 2023
dc2cbd9
check end_block when evaluating blocks
MicaiahReid Aug 28, 2023
dc63688
set expired status
MicaiahReid Aug 29, 2023
8b5fa75
missed updates in setting expired status
MicaiahReid Aug 29, 2023
3166833
fix blockheight after scan
MicaiahReid Aug 29, 2023
3b47b33
simplify fix for blockheight after scan
MicaiahReid Aug 29, 2023
4fd2ebb
fix expiration tracking
MicaiahReid Aug 30, 2023
ba775a5
revert stuff moved to other PR
MicaiahReid Aug 30, 2023
6295b86
allow expired => streaming/scanning status update
MicaiahReid Aug 30, 2023
6530b6a
remove unused var
MicaiahReid Aug 30, 2023
726024e
add doc images
MicaiahReid Aug 30, 2023
e68b095
link to doc image
MicaiahReid Aug 30, 2023
eb08eda
expire blocks once confirmed by chain
MicaiahReid Sep 6, 2023
636f510
create db on readonly connect if not exist
MicaiahReid Sep 11, 2023
8ab1dd0
add some serde derivations
MicaiahReid Sep 11, 2023
53080f7
only enable predicate if not expired
MicaiahReid Sep 11, 2023
c7b4d7a
unimplemented => noop
MicaiahReid Sep 11, 2023
01ca09b
add tests for chainhook service get status api
MicaiahReid Sep 11, 2023
55298f3
fix: handle service restarts (#400)
MicaiahReid Sep 11, 2023
ead4854
clean up some tests
MicaiahReid Sep 12, 2023
994d84c
fix some imports
MicaiahReid Sep 12, 2023
8038227
ignore tests that won't work in ci
MicaiahReid Sep 12, 2023
aa39c96
set expired status for bitcoin after scan
MicaiahReid Sep 13, 2023
1b17af6
remove redundant variable
MicaiahReid Sep 13, 2023
9c42189
rename expiration statuses
MicaiahReid Sep 13, 2023
f6970c7
make expired field expired_at
MicaiahReid Sep 13, 2023
e348b17
expire predicate after end_block has >= 7 confirmations
MicaiahReid Sep 13, 2023
0275bbb
create const CONFIRMED_SEGMENT_MINIMUM_LENGTH
MicaiahReid Sep 13, 2023
b6879ee
add todo
MicaiahReid Sep 13, 2023
2231c88
serialize NewBitcoinBlock
MicaiahReid Sep 14, 2023
4637f9e
fix return false on bitcion scan
MicaiahReid Sep 14, 2023
4a742a4
only insert predicate expiration once
MicaiahReid Sep 14, 2023
8ef521f
warn on set unconfirmed after confirmed expiration
MicaiahReid Sep 14, 2023
bcd06fa
fix: use correct prefixed key when expiring hooks
MicaiahReid Sep 14, 2023
bd9bf64
scan _through_ end_block, not _to_
MicaiahReid Sep 14, 2023
aaefe0a
indentation fix
MicaiahReid Sep 14, 2023
d6bfa28
start on bitcoin tests
MicaiahReid Sep 14, 2023
fa7f31e
refactor service tests
MicaiahReid Sep 14, 2023
58c2731
test cleanup
MicaiahReid Sep 15, 2023
72eeaa3
Merge branch 'develop' into service-tests
MicaiahReid Sep 15, 2023
1244586
fix flowchart
MicaiahReid Sep 15, 2023
23e365e
delete file to fix merge
MicaiahReid Sep 15, 2023
7861b34
ci: install redis
MicaiahReid Sep 15, 2023
59dd7f5
Merge branch 'develop' into service-tests
MicaiahReid Sep 15, 2023
4829cb2
test get predicates route
MicaiahReid Sep 15, 2023
8be6cd5
fixes on mock bitcoin rpc
MicaiahReid Sep 15, 2023
5396d82
add tests for interrupted status
MicaiahReid Sep 15, 2023
d09c304
add helper to setup bitcion test
MicaiahReid Sep 15, 2023
2e6536f
improve test error handling
MicaiahReid Sep 15, 2023
65db3c1
helper to set up stacks predicate
MicaiahReid Sep 15, 2023
8a8afce
add tests for deregistering predicate
MicaiahReid Sep 15, 2023
8a6c644
add feature flag for tests
MicaiahReid Sep 15, 2023
20be146
remove unused bitcoin rocksdb helpers
MicaiahReid Sep 17, 2023
bd0c9ef
remove ordinals specific functions from config
MicaiahReid Sep 18, 2023
1d6f0b8
implement partial_eq on config types
MicaiahReid Sep 18, 2023
52ab633
add config test fixtures
MicaiahReid Sep 18, 2023
a708d70
fix config generator
MicaiahReid Sep 18, 2023
fbec55c
add config tests
MicaiahReid Sep 18, 2023
c4553d2
add more tests for predicate status
MicaiahReid Sep 18, 2023
3a8db38
remove unused function from ChainhookConfig
MicaiahReid Sep 18, 2023
eecc72e
remove unused functions from ChainhookSpecification
MicaiahReid Sep 18, 2023
85d6b8f
Merge branch 'develop' into improve-test-coverage
MicaiahReid Sep 18, 2023
681c144
fix merge
MicaiahReid Sep 18, 2023
965c3d4
update openapi spec
MicaiahReid Sep 18, 2023
3e4b298
remove benches folder
MicaiahReid Sep 18, 2023
6db86a2
add tests for archive
MicaiahReid Sep 18, 2023
1d62729
remove unreachable, do nothing
MicaiahReid Sep 20, 2023
e5da223
improve logging for setting status
MicaiahReid Sep 20, 2023
3a7963d
flush redis better
MicaiahReid Sep 20, 2023
91ce511
remove unused code from bitcoin indexer
MicaiahReid Sep 20, 2023
08c871f
add helper for testing stacks events; test events in indexer
MicaiahReid Sep 20, 2023
1f2b240
add stacks events to test blocks
MicaiahReid Sep 20, 2023
b4400bd
add test helper
MicaiahReid Sep 20, 2023
b013aa6
helper to create stacks events
MicaiahReid Sep 20, 2023
0824724
use helper to create stacks events
MicaiahReid Sep 20, 2023
ed492d9
fix indexer tests
MicaiahReid Sep 20, 2023
f60b805
remove duplicate export
MicaiahReid Sep 20, 2023
c087be7
remove unused new_using_overrides EventObserverConfig fn
MicaiahReid Sep 20, 2023
5435a1f
add bitcoin reorg test
MicaiahReid Sep 20, 2023
58aaf4e
add function to call /ping on observer
MicaiahReid Sep 21, 2023
df49ace
fix logging
MicaiahReid Sep 21, 2023
7e50bfc
fix logging
MicaiahReid Sep 21, 2023
5da8022
add missing import
MicaiahReid Sep 21, 2023
13ecd36
add test for observer ping endpoint
MicaiahReid Sep 21, 2023
bf5cd10
clean up calls to observer svc
MicaiahReid Sep 21, 2023
7913913
tests for empty observer endpoints
MicaiahReid Sep 21, 2023
daf9b13
add helper function for starting evnet observer
MicaiahReid Sep 22, 2023
606de26
add tests for event observer rpc endpoints
MicaiahReid Sep 22, 2023
7c4d300
remove debug logging
MicaiahReid Sep 22, 2023
33e8378
chore: update predicate status format for easier parsing
MicaiahReid Sep 22, 2023
a6b43d5
fix tests for serde change
MicaiahReid Sep 22, 2023
44fedf2
remove debug logging
MicaiahReid Sep 22, 2023
aa1961d
fix: add event index to transaction events
janniks Sep 18, 2023
697baae
fix: update tests
janniks Sep 26, 2023
0578ce5
rebase fixes
MicaiahReid Oct 3, 2023
8469b83
Merge branch 'develop' into 387-return-event_index-in-stacks-transact…
MicaiahReid Oct 3, 2023
b02d35c
Merge branch 'develop' into 387-return-event_index-in-stacks-transact…
Oct 23, 2023
32495f4
Merge branch 'develop' into 387-return-event_index-in-stacks-transact…
janniks Jan 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use chainhook_sdk::indexer::stacks::{NewBlock, NewEvent, NewTransaction};
use chainhook_sdk::types::{
FTBurnEventData, FTMintEventData, FTTransferEventData, NFTBurnEventData, NFTMintEventData,
NFTTransferEventData, STXBurnEventData, STXLockEventData, STXMintEventData,
STXTransferEventData, SmartContractEventData, StacksTransactionEvent,
STXTransferEventData, SmartContractEventData, StacksTransactionEventPayload,
};

use super::{branch_and_height_to_prefixed_hash, height_to_prefixed_hash};
Expand All @@ -21,69 +21,73 @@ pub fn create_tmp_working_dir() -> Result<(String, String), String> {
.map_err(|e| format!("failed to create temp working dir: {}", e.to_string()))?;
Ok((working_dir, tsv_dir))
}
fn create_stacks_new_event(tx_index: u64, index: u32, event: StacksTransactionEvent) -> NewEvent {
fn create_stacks_new_event(
tx_index: u64,
index: u32,
event: StacksTransactionEventPayload,
) -> NewEvent {
let mut event_type = String::new();
let stx_transfer_event = if let StacksTransactionEvent::STXTransferEvent(data) = &event {
let stx_transfer_event = if let StacksTransactionEventPayload::STXTransferEvent(data) = &event {
event_type = format!("stx_transfer");
Some(serde_json::to_value(data).unwrap())
} else {
None
};
let stx_mint_event = if let StacksTransactionEvent::STXMintEvent(data) = &event {
let stx_mint_event = if let StacksTransactionEventPayload::STXMintEvent(data) = &event {
event_type = format!("stx_mint");
Some(serde_json::to_value(data).unwrap())
} else {
None
};
let stx_burn_event = if let StacksTransactionEvent::STXBurnEvent(data) = &event {
let stx_burn_event = if let StacksTransactionEventPayload::STXBurnEvent(data) = &event {
event_type = format!("stx_burn");
Some(serde_json::to_value(data).unwrap())
} else {
None
};
let stx_lock_event = if let StacksTransactionEvent::STXLockEvent(data) = &event {
let stx_lock_event = if let StacksTransactionEventPayload::STXLockEvent(data) = &event {
event_type = format!("stx_lock");
Some(serde_json::to_value(data).unwrap())
} else {
None
};
let nft_transfer_event = if let StacksTransactionEvent::NFTTransferEvent(data) = &event {
let nft_transfer_event = if let StacksTransactionEventPayload::NFTTransferEvent(data) = &event {
event_type = format!("nft_transfer");
Some(serde_json::to_value(data).unwrap())
} else {
None
};
let nft_mint_event = if let StacksTransactionEvent::NFTMintEvent(data) = &event {
let nft_mint_event = if let StacksTransactionEventPayload::NFTMintEvent(data) = &event {
event_type = format!("nft_mint");
Some(serde_json::to_value(data).unwrap())
} else {
None
};
let nft_burn_event = if let StacksTransactionEvent::NFTBurnEvent(data) = &event {
let nft_burn_event = if let StacksTransactionEventPayload::NFTBurnEvent(data) = &event {
event_type = format!("nft_burn");
Some(serde_json::to_value(data).unwrap())
} else {
None
};
let ft_transfer_event = if let StacksTransactionEvent::FTTransferEvent(data) = &event {
let ft_transfer_event = if let StacksTransactionEventPayload::FTTransferEvent(data) = &event {
event_type = format!("ft_transfer");
Some(serde_json::to_value(data).unwrap())
} else {
None
};
let ft_mint_event = if let StacksTransactionEvent::FTMintEvent(data) = &event {
let ft_mint_event = if let StacksTransactionEventPayload::FTMintEvent(data) = &event {
event_type = format!("ft_mint");
Some(serde_json::to_value(data).unwrap())
} else {
None
};
let ft_burn_event = if let StacksTransactionEvent::FTBurnEvent(data) = &event {
let ft_burn_event = if let StacksTransactionEventPayload::FTBurnEvent(data) = &event {
event_type = format!("ft_burn");
Some(serde_json::to_value(data).unwrap())
} else {
None
};
let contract_event = if let StacksTransactionEvent::SmartContractEvent(data) = &event {
let contract_event = if let StacksTransactionEventPayload::SmartContractEvent(data) = &event {
event_type = format!("smart_contract_print_event");
Some(serde_json::to_value(data).unwrap())
} else {
Expand Down Expand Up @@ -136,7 +140,7 @@ pub fn create_stacks_new_block(height: u64, burn_block_height: u64) -> NewBlock
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::STXTransferEvent(STXTransferEventData {
StacksTransactionEventPayload::STXTransferEvent(STXTransferEventData {
sender: format!(""),
recipient: format!(""),
amount: format!("1"),
Expand All @@ -145,23 +149,23 @@ pub fn create_stacks_new_block(height: u64, burn_block_height: u64) -> NewBlock
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::STXMintEvent(STXMintEventData {
StacksTransactionEventPayload::STXMintEvent(STXMintEventData {
recipient: format!(""),
amount: format!("1"),
}),
));
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::STXBurnEvent(STXBurnEventData {
StacksTransactionEventPayload::STXBurnEvent(STXBurnEventData {
sender: format!(""),
amount: format!("1"),
}),
));
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::STXLockEvent(STXLockEventData {
StacksTransactionEventPayload::STXLockEvent(STXLockEventData {
locked_amount: format!("1"),
unlock_height: format!(""),
locked_address: format!(""),
Expand All @@ -170,7 +174,7 @@ pub fn create_stacks_new_block(height: u64, burn_block_height: u64) -> NewBlock
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::NFTTransferEvent(NFTTransferEventData {
StacksTransactionEventPayload::NFTTransferEvent(NFTTransferEventData {
asset_class_identifier: format!(""),
hex_asset_identifier: format!(""),
sender: format!(""),
Expand All @@ -180,7 +184,7 @@ pub fn create_stacks_new_block(height: u64, burn_block_height: u64) -> NewBlock
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::NFTMintEvent(NFTMintEventData {
StacksTransactionEventPayload::NFTMintEvent(NFTMintEventData {
asset_class_identifier: format!(""),
hex_asset_identifier: format!(""),
recipient: format!(""),
Expand All @@ -189,7 +193,7 @@ pub fn create_stacks_new_block(height: u64, burn_block_height: u64) -> NewBlock
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::NFTBurnEvent(NFTBurnEventData {
StacksTransactionEventPayload::NFTBurnEvent(NFTBurnEventData {
asset_class_identifier: format!(""),
hex_asset_identifier: format!(""),
sender: format!(""),
Expand All @@ -198,7 +202,7 @@ pub fn create_stacks_new_block(height: u64, burn_block_height: u64) -> NewBlock
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::FTTransferEvent(FTTransferEventData {
StacksTransactionEventPayload::FTTransferEvent(FTTransferEventData {
asset_class_identifier: format!(""),
sender: format!(""),
recipient: format!(""),
Expand All @@ -208,7 +212,7 @@ pub fn create_stacks_new_block(height: u64, burn_block_height: u64) -> NewBlock
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::FTMintEvent(FTMintEventData {
StacksTransactionEventPayload::FTMintEvent(FTMintEventData {
asset_class_identifier: format!(""),
recipient: format!(""),
amount: format!("1"),
Expand All @@ -217,7 +221,7 @@ pub fn create_stacks_new_block(height: u64, burn_block_height: u64) -> NewBlock
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::FTBurnEvent(FTBurnEventData {
StacksTransactionEventPayload::FTBurnEvent(FTBurnEventData {
asset_class_identifier: format!(""),
sender: format!(""),
amount: format!("1"),
Expand All @@ -226,7 +230,7 @@ pub fn create_stacks_new_block(height: u64, burn_block_height: u64) -> NewBlock
events.push(create_stacks_new_event(
0,
events.len() as u32,
StacksTransactionEvent::SmartContractEvent(SmartContractEventData {
StacksTransactionEventPayload::SmartContractEvent(SmartContractEventData {
contract_identifier: format!(""),
topic: format!("print"),
hex_value: format!(""),
Expand Down
Loading
Loading