Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chain node error for erc20 votes #9474

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/model/src/models/associations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion libs/model/src/models/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type TopicAttributes = z.infer<typeof Topic> & {
// associations
community?: CommunityAttributes;
threads?: ThreadAttributes[] | TopicAttributes['id'][];
chain_node?: ChainNodeAttributes;
ChainNode?: ChainNodeAttributes;
};
export type TopicInstance = ModelInstance<TopicAttributes>;

Expand Down
6 changes: 5 additions & 1 deletion libs/model/src/services/stakeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading