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

MASP flows #289

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

MASP flows #289

wants to merge 4 commits into from

Conversation

grarco
Copy link
Contributor

@grarco grarco commented Feb 20, 2025

Adds support for indexing MASP's in and out flows

@grarco grarco requested review from Fraccaman and sug0 February 20, 2025 14:29
@grarco grarco force-pushed the fraccaman+grarco/masp-flows branch from afb9f89 to 807693d Compare February 20, 2025 14:48
@Fraccaman Fraccaman mentioned this pull request Feb 21, 2025
Comment on lines +441 to +479
TransactionKind::MixedTransfer(Some(transfer_data)) => {
transfer_data
.sources
.0
.iter()
.filter_map(|(source, denominated_amount)| {
if source.owner == MASP_ADDRESS {
Some(MaspEntry {
token_address: source.token.to_string(),
timestamp: self.header.timestamp,
raw_amount: denominated_amount
.amount()
.into(),
direction: MaspEntryDirection::Out,
inner_tx_id: tx.tx_id.clone(),
})
} else {
None
}
})
.chain(transfer_data.targets.0.iter().filter_map(
|(target, denominated_amount)| {
if target.owner == MASP_ADDRESS {
Some(MaspEntry {
token_address: target.token.to_string(),
timestamp: self.header.timestamp,
raw_amount: denominated_amount
.amount()
.into(),
direction: MaspEntryDirection::In,
inner_tx_id: tx.tx_id.clone(),
})
} else {
None
}
},
))
.collect()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not as much code repetition here

Suggested change
TransactionKind::MixedTransfer(Some(transfer_data)) => {
transfer_data
.sources
.0
.iter()
.filter_map(|(source, denominated_amount)| {
if source.owner == MASP_ADDRESS {
Some(MaspEntry {
token_address: source.token.to_string(),
timestamp: self.header.timestamp,
raw_amount: denominated_amount
.amount()
.into(),
direction: MaspEntryDirection::Out,
inner_tx_id: tx.tx_id.clone(),
})
} else {
None
}
})
.chain(transfer_data.targets.0.iter().filter_map(
|(target, denominated_amount)| {
if target.owner == MASP_ADDRESS {
Some(MaspEntry {
token_address: target.token.to_string(),
timestamp: self.header.timestamp,
raw_amount: denominated_amount
.amount()
.into(),
direction: MaspEntryDirection::In,
inner_tx_id: tx.tx_id.clone(),
})
} else {
None
}
},
))
.collect()
}
TransactionKind::MixedTransfer(Some(transfer_data)) => {
transfer_data
.sources
.0
.iter()
.map(|(source, denominated_amount)| {
(
source,
denominated_amount,
MaspEntryDirection::Out,
)
})
.chain(transfer_data.targets.0.iter().map(
|(target, denominated_amount)| {
(
target,
denominated_amount,
MaspEntryDirection::In,
)
},
))
.filter_map(|(transfer, denominated_amount, dir)| {
if transfer.owner == MASP_ADDRESS {
Some(MaspEntry {
token_address: transfer.token.to_string(),
timestamp: self.header.timestamp,
raw_amount: denominated_amount
.amount()
.into(),
direction: dir,
inner_tx_id: tx.tx_id.clone(),
})
} else {
None
}
})
.collect()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants