-
Notifications
You must be signed in to change notification settings - Fork 22
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
Projected NFT indexing #158
Changes from 10 commits
4c459a8
c77cff3
0a07a07
20dc1b3
3459313
11ef5e1
17c8060
c289809
3cd386d
32de9cd
1d0ba09
012ce13
147597b
33ec02e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM rust:1.67 AS x-builder | ||
FROM rust:1.73 AS x-builder | ||
|
||
WORKDIR /indexer | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use sea_orm::entity::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)] | ||
#[sea_orm(table_name = "ProjectedNFT")] | ||
pub struct Model { | ||
#[sea_orm(primary_key, column_type = "BigInteger")] | ||
pub id: i64, | ||
pub owner_address: Vec<u8>, | ||
pub previous_utxo_tx_hash: Vec<u8>, | ||
#[sea_orm(column_type = "BigInteger", nullable)] | ||
pub previous_utxo_tx_output_index: Option<i64>, | ||
Comment on lines
+10
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can these not be a foreign key to the output table? |
||
#[sea_orm(column_type = "BigInteger", nullable)] | ||
pub hololocker_utxo_id: Option<i64>, | ||
#[sea_orm(column_type = "BigInteger")] | ||
pub tx_id: i64, | ||
pub asset: String, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, we can use a foreign key for this asset as well |
||
#[sea_orm(column_type = "BigInteger")] | ||
pub amount: i64, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it's too ugly, but you can probably get the amount information implicitly from the fact you're already referencing the UTXO table |
||
pub operation: i32, // lock / unlock / claim | ||
pub for_how_long: Option<i64>, | ||
pub plutus_datum: Vec<u8>, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, DeriveRelation, EnumIter)] | ||
pub enum Relation { | ||
#[sea_orm( | ||
belongs_to = "super::transaction_output::Entity", | ||
from = "Column::HololockerUtxoId", | ||
to = "super::transaction_output::Column::Id" | ||
)] | ||
TransactionOutput, | ||
#[sea_orm( | ||
belongs_to = "super::transaction::Entity", | ||
from = "Column::TxId", | ||
to = "super::transaction::Column::Id" | ||
)] | ||
Transaction, | ||
} | ||
|
||
// TODO: figure out why this isn't automatically handle by the macros above | ||
impl Related<super::transaction_output::Entity> for Entity { | ||
fn to() -> RelationDef { | ||
Relation::TransactionOutput.def() | ||
} | ||
} | ||
|
||
// TODO: figure out why this isn't automatically handle by the macros above | ||
impl Related<super::transaction::Entity> for Entity { | ||
fn to() -> RelationDef { | ||
Relation::Transaction.def() | ||
} | ||
} | ||
|
||
impl ActiveModelBehavior for ActiveModel {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use sea_schema::migration::prelude::*; | ||
|
||
use entity::projected_nft::*; | ||
|
||
pub struct Migration; | ||
|
||
impl MigrationName for Migration { | ||
fn name(&self) -> &str { | ||
"m20231025_000016_projected_nft" | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.create_table( | ||
Table::create() | ||
.table(Entity) | ||
.if_not_exists() | ||
.col( | ||
ColumnDef::new(Column::Id) | ||
.big_integer() | ||
.not_null() | ||
.auto_increment(), | ||
) | ||
.col(ColumnDef::new(Column::OwnerAddress).binary().not_null()) | ||
.col( | ||
ColumnDef::new(Column::PreviousUtxoTxHash) | ||
.binary() | ||
.not_null(), | ||
) | ||
.col(ColumnDef::new(Column::PreviousUtxoTxOutputIndex).big_integer()) | ||
.col(ColumnDef::new(Column::HololockerUtxoId).big_integer()) | ||
.col(ColumnDef::new(Column::TxId).big_integer().not_null()) | ||
.col(ColumnDef::new(Column::Asset).text().not_null()) | ||
.col(ColumnDef::new(Column::Amount).big_integer().not_null()) | ||
.col(ColumnDef::new(Column::Operation).integer().not_null()) | ||
.col(ColumnDef::new(Column::PlutusDatum).binary().not_null()) | ||
.col(ColumnDef::new(Column::ForHowLong).big_integer()) | ||
.foreign_key( | ||
ForeignKey::create() | ||
.name("fk-projected_nft-tx_id") | ||
.from(Entity, Column::TxId) | ||
.to( | ||
entity::prelude::Transaction, | ||
entity::prelude::TransactionColumn::Id, | ||
) | ||
.on_delete(ForeignKeyAction::Cascade), | ||
) | ||
.foreign_key( | ||
ForeignKey::create() | ||
.name("fk-projected_nft-utxo_id") | ||
.from(Entity, Column::HololockerUtxoId) | ||
.to( | ||
entity::prelude::TransactionOutput, | ||
entity::prelude::TransactionOutputColumn::Id, | ||
) | ||
.on_delete(ForeignKeyAction::Cascade), | ||
) | ||
.primary_key( | ||
Index::create() | ||
.table(Entity) | ||
.name("projected_nft-pk") | ||
.col(Column::Id), | ||
) | ||
.to_owned(), | ||
) | ||
.await | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.drop_table(Table::drop().table(Entity).to_owned()) | ||
.await | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use pallas::ledger::addresses::Address; | ||
use pallas::ledger::primitives::alonzo::PlutusScript; | ||
use pallas::ledger::primitives::babbage::PlutusV2Script; | ||
|
||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
pub struct PayloadAndReadonlyConfig { | ||
pub address: String, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,7 +268,7 @@ cfg_if::cfg_if! { | |
block, | ||
handle, | ||
perf_aggregator, | ||
config: *config | ||
config: config.clone(), | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a
Vec<u8>
instead of a foreign key into the stake credential table (careful: there is no guarantee this staking key exists in the table)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as soon as there's no guarantee and this address is what we actually get from the plutus datum i think it makes sense to leave it like this