Skip to content

Commit

Permalink
[SUBGRAPH] fix governance config always null (#1908)
Browse files Browse the repository at this point in the history
* fix governance config always null

* fix broken tests
  • Loading branch information
0xdavinchee authored Mar 25, 2024
1 parent f3d5d3a commit c3e41bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 7 additions & 0 deletions packages/subgraph/src/mappingHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit c3e41bb

Please sign in to comment.