Skip to content

Commit

Permalink
Merge branch 'new_schedule_handling' of github.com:pinax-network/subs…
Browse files Browse the repository at this point in the history
…treams into new_schedule_handling
  • Loading branch information
DenisCarriere committed Oct 10, 2024
2 parents 00b4b98 + c030c59 commit 760546c
Show file tree
Hide file tree
Showing 4 changed files with 442 additions and 40 deletions.
2 changes: 1 addition & 1 deletion eosmechanics/src/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub fn map_schedule_change(block: Block) -> Result<ScheduleChange, Error> {
};
let pending_schedule: Vec<String> = match block.pending_schedule.as_ref() {
Some(pending_schedule) => schedule_to_accounts(pending_schedule.schedule_v2.as_ref().unwrap()), // Old
None => vec![], // New ???
None => vec![], // New
};

// If there is no pending schedule and it's old block format, then there is no schedule change
Expand Down
150 changes: 138 additions & 12 deletions gems.blend/src/abi/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,36 @@ pub mod types {
pub start_time: TimePointSec,
pub end_time: TimePointSec,
}
impl std::str::FromStr for BlendsRow {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct CollectionsRow {
pub collection_names: Vec<Name>,
}
impl std::str::FromStr for CollectionsRow {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ConfigRow {
pub status: Name,
pub protocol_fee: Uint16,
pub fee_account: Name,
}
impl std::str::FromStr for ConfigRow {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct LimitsRow {
Expand All @@ -35,38 +53,74 @@ pub mod types {
#[serde(deserialize_with = "substreams_antelope::decoder::str_or_i64")]
pub max_mint_assets: Int64,
}
impl std::str::FromStr for LimitsRow {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Nft {
pub collection_name: Name,
pub template_id: Int32,
}
impl std::str::FromStr for Nft {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct NftExtra {
pub collection_name: Name,
pub template_id: Int32,
pub schema_name: Name,
}
impl std::str::FromStr for NftExtra {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct OrdersRow {
pub id: Nft,
pub quantity: ExtendedAsset,
}
impl std::str::FromStr for OrdersRow {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct RecipesRow {
#[serde(deserialize_with = "substreams_antelope::decoder::str_or_u64")]
pub id: Uint64,
pub templates: Vec<NftExtra>,
}
impl std::str::FromStr for RecipesRow {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct StatusRow {
pub counters: Vec<Uint32>,
pub last_updated: TimePointSec,
}
impl std::str::FromStr for StatusRow {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
}
pub mod actions {
use substreams_antelope::types::*;
Expand All @@ -80,12 +134,18 @@ pub mod actions {
pub template_id: Int32,
pub templates: Vec<Nft>,
}
impl std::str::FromStr for Addrecipe {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Addrecipe {
const NAME: &'static str = "addrecipe";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
Expand All @@ -102,12 +162,18 @@ pub mod actions {
pub total_mint: Int32,
pub total_burn: Int32,
}
impl std::str::FromStr for Blendlog {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Blendlog {
const NAME: &'static str = "blendlog";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
Expand All @@ -116,12 +182,18 @@ pub mod actions {
pub owner: Name,
pub template_id: Int32,
}
impl std::str::FromStr for Cancel {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Cancel {
const NAME: &'static str = "cancel";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
Expand All @@ -130,12 +202,18 @@ pub mod actions {
pub collection_name: Name,
pub template_id: Int32,
}
impl std::str::FromStr for Delblend {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Delblend {
const NAME: &'static str = "delblend";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
Expand All @@ -144,12 +222,18 @@ pub mod actions {
pub collection_name: Name,
pub template_id: Int32,
}
impl std::str::FromStr for Dellimit {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Dellimit {
const NAME: &'static str = "dellimit";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
Expand All @@ -160,12 +244,18 @@ pub mod actions {
#[serde(deserialize_with = "substreams_antelope::decoder::str_or_u64")]
pub recipe_id: Uint64,
}
impl std::str::FromStr for Delrecipe {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Delrecipe {
const NAME: &'static str = "delrecipe";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
Expand All @@ -174,12 +264,18 @@ pub mod actions {
pub table: Name,
pub scope: Name,
}
impl std::str::FromStr for Reset {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Reset {
const NAME: &'static str = "reset";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
Expand All @@ -193,12 +289,18 @@ pub mod actions {
pub start_time: TimePointSec,
pub end_time: TimePointSec,
}
impl std::str::FromStr for Setblend {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Setblend {
const NAME: &'static str = "setblend";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
Expand All @@ -207,12 +309,18 @@ pub mod actions {
pub protocol_fee: Uint16,
pub fee_account: Name,
}
impl std::str::FromStr for Setfee {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Setfee {
const NAME: &'static str = "setfee";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
Expand All @@ -223,12 +331,18 @@ pub mod actions {
#[serde(deserialize_with = "substreams_antelope::decoder::str_or_i64")]
pub max_mint_assets: Int64,
}
impl std::str::FromStr for Setlimit {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Setlimit {
const NAME: &'static str = "setlimit";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
Expand All @@ -239,25 +353,37 @@ pub mod actions {
#[serde(deserialize_with = "substreams_antelope::decoder::vec_str_or_u64")]
pub recipe_ids: Vec<Uint64>,
}
impl std::str::FromStr for Setrecipes {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Setrecipes {
const NAME: &'static str = "setrecipes";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Setstatus {
pub status: Name,
}
impl std::str::FromStr for Setstatus {
type Err = substreams_antelope::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
substreams_antelope::decoder::decode::<Self>(value)
}
}
impl substreams_antelope::Action for Setstatus {
const NAME: &'static str = "setstatus";
fn decode(
trace: &substreams_antelope::pb::ActionTrace,
) -> Result<Self, substreams_antelope::Error> {
Ok(decode::<Self>(&trace.action.as_ref().unwrap().json_data)?)
decode::<Self>(&trace.action.as_ref().unwrap().json_data)
}
}
}
Loading

0 comments on commit 760546c

Please sign in to comment.