Skip to content

Commit 3b92622

Browse files
committed
feat(allocation): update allocation type to align with the updated shema
1 parent 695ad52 commit 3b92622

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

crates/allocation/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use thegraph_core::{
1313
#[derive(Clone, Debug, PartialEq, Eq)]
1414
pub struct Allocation {
1515
pub id: Address,
16+
// True when this allocation belongs to Legacy (V1) TAP, false for Horizon (V2)
17+
pub is_legacy: bool,
1618
pub status: AllocationStatus,
1719
pub subgraph_deployment: SubgraphDeployment,
1820
pub indexer: Address,
@@ -57,6 +59,8 @@ impl<'d> Deserialize<'d> for Allocation {
5759
#[allow(non_snake_case)]
5860
struct Outer {
5961
id: Address,
62+
#[allow(non_snake_case)]
63+
isLegacy: bool,
6064
subgraphDeployment: SubgraphDeployment,
6165
indexer: InnerIndexer,
6266
allocatedTokens: U256,
@@ -69,6 +73,7 @@ impl<'d> Deserialize<'d> for Allocation {
6973

7074
Ok(Allocation {
7175
id: outer.id,
76+
is_legacy: outer.isLegacy,
7277
status: AllocationStatus::Null,
7378
subgraph_deployment: outer.subgraphDeployment,
7479
indexer: outer.indexer.id,
@@ -93,6 +98,8 @@ impl TryFrom<allocations_query::AllocationFragment> for Allocation {
9398
) -> Result<Self, Self::Error> {
9499
Ok(Self {
95100
id: Address::from_str(&value.id)?,
101+
// graphql_client converts `isLegacy` to `is_legacy`
102+
is_legacy: value.is_legacy,
96103
status: AllocationStatus::Null,
97104
subgraph_deployment: SubgraphDeployment {
98105
id: DeploymentId::from_str(&value.subgraph_deployment.id)?,

0 commit comments

Comments
 (0)