-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74fde2d
commit 05f5033
Showing
4 changed files
with
100 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,58 @@ | ||
use substreams_antelope::ActionTrace; | ||
// use antelope::Asset; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
macro_rules! impl_from_str { | ||
($type:ty) => { | ||
impl From<&str> for $type { | ||
#[inline] | ||
#[must_use] | ||
fn from(str: &str) -> Self { | ||
serde_json::from_str(str).unwrap() | ||
} | ||
} | ||
}; | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct SetGrant { | ||
pub author_id: String, | ||
pub project_id: String, | ||
pub struct GrantsRow { | ||
pub id: String, | ||
pub r#type: String, | ||
pub author_user_id: String, | ||
pub funding_account: String, | ||
pub accepted_tokens: Vec<String>, | ||
pub status: String, | ||
pub created_at: String, | ||
pub updated_at: String, | ||
} | ||
impl_from_str!(GrantsRow); | ||
|
||
|
||
pub fn parse_setgrant(action_trace: &ActionTrace) -> Option<SetGrant> { | ||
let action = action_trace.action.as_ref()?; | ||
if action.name != "setgrant" { return None; } | ||
let data: SetGrant = serde_json::from_str(&action.json_data).unwrap(); | ||
Some(data) | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct ExtendedQuantity { | ||
pub quantity: String, | ||
pub contract: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct TransfersRow { | ||
pub transfer_id: u64, | ||
pub from: String, | ||
pub to: String, | ||
pub ext_quantity: ExtendedQuantity, | ||
pub fee: String, | ||
pub memo: String, | ||
pub user_id: String, | ||
pub season_id: u16, | ||
pub round_id: u16, | ||
pub project_type: String, | ||
pub project_id: String, | ||
pub value: String, | ||
pub trx_id: String, | ||
pub created_at: String, | ||
} | ||
impl_from_str!(TransfersRow); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
use substreams_antelope::db_op; | ||
use substreams_entity_change::pb::entity::entity_change; | ||
|
||
|
||
pub fn from_dbop_to_entityop(op: &db_op::Operation) -> entity_change::Operation { | ||
match op { | ||
db_op::Operation::Insert => entity_change::Operation::Create, | ||
db_op::Operation::Update => entity_change::Operation::Update, | ||
db_op::Operation::Remove => entity_change::Operation::Delete, | ||
db_op::Operation::Unknown => entity_change::Operation::Unset, | ||
} | ||
} |