From 0b8e0477753058f1bbbe795c878bff9a5eeee913 Mon Sep 17 00:00:00 2001 From: Ryan Bennett Date: Mon, 7 Oct 2024 09:55:24 -0700 Subject: [PATCH] fix chain node error when voting erc20 topic --- libs/model/src/models/associations.ts | 2 +- libs/model/src/models/topic.ts | 2 +- libs/model/src/services/stakeHelper.ts | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/model/src/models/associations.ts b/libs/model/src/models/associations.ts index 24b9a77758c..873be2f2669 100644 --- a/libs/model/src/models/associations.ts +++ b/libs/model/src/models/associations.ts @@ -33,7 +33,7 @@ export const buildAssociations = (db: DB) => { .withMany(db.Contract, { asMany: 'contracts' }) .withMany(db.EvmEventSource) .withOne(db.LastProcessedEvmBlock) - .withOne(db.Topic); + .withMany(db.Topic); db.ContractAbi.withMany(db.Contract, { foreignKey: 'abi_id' }).withMany( db.EvmEventSource, diff --git a/libs/model/src/models/topic.ts b/libs/model/src/models/topic.ts index 7439d8f086a..0969f8988f1 100644 --- a/libs/model/src/models/topic.ts +++ b/libs/model/src/models/topic.ts @@ -10,7 +10,7 @@ export type TopicAttributes = z.infer & { // associations community?: CommunityAttributes; threads?: ThreadAttributes[] | TopicAttributes['id'][]; - chain_node?: ChainNodeAttributes; + ChainNode?: ChainNodeAttributes; }; export type TopicInstance = ModelInstance; diff --git a/libs/model/src/services/stakeHelper.ts b/libs/model/src/services/stakeHelper.ts index ef65101b5af..313d979b789 100644 --- a/libs/model/src/services/stakeHelper.ts +++ b/libs/model/src/services/stakeHelper.ts @@ -70,7 +70,11 @@ export async function getVotingWeight( return commonProtocol.calculateVoteWeight(stakeBalance, stake.vote_weight); } else if (topic.weighted_voting === TopicWeightedVoting.ERC20) { - const { chain_node, token_address, vote_weight_multiplier } = topic; + const { + ChainNode: chain_node, + token_address, + vote_weight_multiplier, + } = topic; mustExist('Topic Chain Node Eth Chain Id', chain_node?.eth_chain_id); const balances = await tokenBalanceCache.getBalances({