Skip to content

Commit

Permalink
added ibc transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman committed Jan 16, 2025
1 parent 9c1430e commit 08e8fc6
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
SELECT 1;
4 changes: 4 additions & 0 deletions orm/migrations/2025-01-16-131336_transaction_ibc_types/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Your SQL goes here
ALTER TYPE TRANSACTION_KIND ADD VALUE 'ibc_transparent_transfer';
ALTER TYPE TRANSACTION_KIND ADD VALUE 'ibc_shielding_transfer';
ALTER TYPE TRANSACTION_KIND ADD VALUE 'ibc_unshielding_transfer';
66 changes: 11 additions & 55 deletions orm/src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,91 +1,47 @@
// @generated automatically by Diesel CLI.

Check warning on line 1 in orm/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/namada-indexer/namada-indexer/orm/src/schema.rs

pub mod sql_types {
#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "crawler_name"))]
pub struct CrawlerName;

#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]

Check warning on line 8 in orm/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/namada-indexer/namada-indexer/orm/src/schema.rs
#[diesel(postgres_type(name = "governance_kind"))]
pub struct GovernanceKind;

#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]

Check warning on line 12 in orm/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/namada-indexer/namada-indexer/orm/src/schema.rs
#[diesel(postgres_type(name = "governance_result"))]
pub struct GovernanceResult;

#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]

Check warning on line 16 in orm/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/namada-indexer/namada-indexer/orm/src/schema.rs
#[diesel(postgres_type(name = "governance_tally_type"))]
pub struct GovernanceTallyType;

#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]

Check warning on line 20 in orm/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/namada-indexer/namada-indexer/orm/src/schema.rs
#[diesel(postgres_type(name = "history_kind"))]
pub struct HistoryKind;

#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]

Check warning on line 24 in orm/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/namada-indexer/namada-indexer/orm/src/schema.rs
#[diesel(postgres_type(name = "ibc_status"))]
pub struct IbcStatus;

#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]

Check warning on line 28 in orm/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/namada-indexer/namada-indexer/orm/src/schema.rs
#[diesel(postgres_type(name = "token_type"))]
pub struct TokenType;

#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]

Check warning on line 32 in orm/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/namada-indexer/namada-indexer/orm/src/schema.rs
#[diesel(postgres_type(name = "transaction_kind"))]
pub struct TransactionKind;

#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]

Check warning on line 36 in orm/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/namada-indexer/namada-indexer/orm/src/schema.rs
#[diesel(postgres_type(name = "transaction_result"))]
pub struct TransactionResult;

#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]

Check warning on line 40 in orm/src/schema.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/namada-indexer/namada-indexer/orm/src/schema.rs
#[diesel(postgres_type(name = "validator_state"))]
pub struct ValidatorState;

#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "vote_kind"))]
pub struct VoteKind;
}
Expand Down
6 changes: 6 additions & 0 deletions orm/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub enum TransactionKindDb {
UnshieldingTransfer,
MixedTransfer,
IbcMsgTransfer,
IbcTransparentTransfer,
IbcShieldingTransfer,
IbcUnshieldingTransfer,
Bond,
Redelegation,
Unbond,
Expand Down Expand Up @@ -48,6 +51,9 @@ impl From<TransactionKind> for TransactionKindDb {
TransactionKind::ShieldingTransfer(_) => Self::ShieldingTransfer,
TransactionKind::MixedTransfer(_) => Self::MixedTransfer,
TransactionKind::IbcMsgTransfer(_) => Self::IbcMsgTransfer,
TransactionKind::IbcTrasparentTransfer(_) => Self::IbcTransparentTransfer,
TransactionKind::IbcShieldingTransfer(_) => Self::IbcShieldingTransfer,
TransactionKind::IbcUnshieldingTransfer(_) => Self::IbcUnshieldingTransfer,
TransactionKind::Bond(_) => Self::Bond,
TransactionKind::Redelegation(_) => Self::Redelegation,
TransactionKind::Unbond(_) => Self::Unbond,
Expand Down
195 changes: 195 additions & 0 deletions shared/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,201 @@ impl Block {
vec![]
}
}
TransactionKind::IbcTrasparentTransfer((ibc_message, _)) => {
if let Some(data) = ibc_message {
match data.0 {
IbcMessage::Transfer(transfer) => {
let sources = transfer
.clone()
.transfer
.unwrap_or_default()
.sources
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
let targets = transfer
.transfer
.unwrap_or_default()
.targets
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
[sources, targets].concat()
}
IbcMessage::NftTransfer(transfer) => {
let sources = transfer
.clone()
.transfer
.unwrap_or_default()
.sources
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
let targets = transfer
.transfer
.unwrap_or_default()
.targets
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
[sources, targets].concat()
}
_ => vec![],
}
} else {
vec![]
}
}
TransactionKind::IbcShieldingTransfer((ibc_message, _)) => {
if let Some(data) = ibc_message {
match data.0 {
IbcMessage::Transfer(transfer) => {
let sources = transfer
.clone()
.transfer
.unwrap_or_default()
.sources
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
let targets = transfer
.transfer
.unwrap_or_default()
.targets
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
[sources, targets].concat()
}
IbcMessage::NftTransfer(transfer) => {
let sources = transfer
.clone()
.transfer
.unwrap_or_default()
.sources
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
let targets = transfer
.transfer
.unwrap_or_default()
.targets
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
[sources, targets].concat()
}
_ => vec![],
}
} else {
vec![]
}
}
TransactionKind::IbcUnshieldingTransfer((ibc_message, _)) => {
if let Some(data) = ibc_message {
match data.0 {
IbcMessage::Transfer(transfer) => {
let sources = transfer
.clone()
.transfer
.unwrap_or_default()
.sources
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
let targets = transfer
.transfer
.unwrap_or_default()
.targets
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
[sources, targets].concat()
}
IbcMessage::NftTransfer(transfer) => {
let sources = transfer
.clone()
.transfer
.unwrap_or_default()
.sources
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
let targets = transfer
.transfer
.unwrap_or_default()
.targets
.keys()
.map(|account| {
TransactionTarget::sent(
tx.tx_id.clone(),
account.owner.to_string(),
)
})
.collect::<Vec<_>>();
[sources, targets].concat()
}
_ => vec![],
}
} else {
vec![]
}
}
TransactionKind::Bond(bond) => {
if let Some(data) = bond {
let source =
Expand Down
Loading

0 comments on commit 08e8fc6

Please sign in to comment.