From b4808999eadeb6353db8b2db7a8a449b15c48d86 Mon Sep 17 00:00:00 2001 From: Ryan Bennett Date: Thu, 12 Dec 2024 10:15:25 -0800 Subject: [PATCH 1/2] fallback on community chain node for weighted upvotes --- libs/model/src/services/stakeHelper.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/model/src/services/stakeHelper.ts b/libs/model/src/services/stakeHelper.ts index 3d0164593bb..82cf25d4e6e 100644 --- a/libs/model/src/services/stakeHelper.ts +++ b/libs/model/src/services/stakeHelper.ts @@ -72,7 +72,9 @@ export async function getVotingWeight( return commonProtocol.calculateVoteWeight(stakeBalance, stake.vote_weight); } else if (topic.weighted_voting === TopicWeightedVoting.ERC20) { - const { eth_chain_id, private_url, url } = topic.ChainNode!; + // if topic chain node is missing, fallback on community chain node + const chainNode = topic.ChainNode || community.ChainNode || ({} as any); + const { eth_chain_id, private_url, url } = chainNode; mustExist('Chain Node Eth Chain Id', eth_chain_id); const chainNodeUrl = private_url! || url!; mustExist('Chain Node URL', chainNodeUrl); From 841ae4c2cee97880336a298c58f7db4af37f2e20 Mon Sep 17 00:00:00 2001 From: Ryan Bennett Date: Thu, 12 Dec 2024 10:27:32 -0800 Subject: [PATCH 2/2] lint --- libs/model/src/services/stakeHelper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/model/src/services/stakeHelper.ts b/libs/model/src/services/stakeHelper.ts index 82cf25d4e6e..c9ad20b9253 100644 --- a/libs/model/src/services/stakeHelper.ts +++ b/libs/model/src/services/stakeHelper.ts @@ -73,7 +73,7 @@ export async function getVotingWeight( return commonProtocol.calculateVoteWeight(stakeBalance, stake.vote_weight); } else if (topic.weighted_voting === TopicWeightedVoting.ERC20) { // if topic chain node is missing, fallback on community chain node - const chainNode = topic.ChainNode || community.ChainNode || ({} as any); + const chainNode = topic.ChainNode || community.ChainNode!; const { eth_chain_id, private_url, url } = chainNode; mustExist('Chain Node Eth Chain Id', eth_chain_id); const chainNodeUrl = private_url! || url!;