From c3e41bbd738e0d47462b492ec1873e610b18119b Mon Sep 17 00:00:00 2001 From: 0xdavinchee <0xdavinchee@gmail.com> Date: Mon, 25 Mar 2024 16:06:15 +0200 Subject: [PATCH] [SUBGRAPH] fix governance config always null (#1908) * fix governance config always null * fix broken tests --- packages/subgraph/schema.graphql | 1 + packages/subgraph/src/mappingHelpers.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/packages/subgraph/schema.graphql b/packages/subgraph/schema.graphql index dc662fbc35..d66a1060da 100644 --- a/packages/subgraph/schema.graphql +++ b/packages/subgraph/schema.graphql @@ -2272,6 +2272,7 @@ type Token @entity { underlyingToken: Token """ + If `governanceConfig.id` is the zero address, the token uses the default governance config. """ governanceConfig: TokenGovernanceConfig } diff --git a/packages/subgraph/src/mappingHelpers.ts b/packages/subgraph/src/mappingHelpers.ts index 2d14d64e98..67b97e7b11 100644 --- a/packages/subgraph/src/mappingHelpers.ts +++ b/packages/subgraph/src/mappingHelpers.ts @@ -121,6 +121,7 @@ export function getOrInitSuperToken( token.isListed = false; const underlyingAddress = token.underlyingAddress; token.underlyingToken = underlyingAddress.toHexString(); + token.governanceConfig = ZERO_ADDRESS.toHexString(); token.save(); @@ -203,6 +204,12 @@ export function getOrInitTokenGovernanceConfig( governanceConfig.token = superTokenAddress.toHexString(); governanceConfig.save(); + + const superToken = Token.load(superTokenAddress.toHexString()); + if (superToken) { + superToken.governanceConfig = governanceConfig.id; + superToken.save(); + } } return governanceConfig; }