Skip to content

Commit

Permalink
fix: exclude burn address, limit to reps with at least 10k weight and…
Browse files Browse the repository at this point in the history
… at least one non null field
  • Loading branch information
mistakia committed Mar 25, 2024
1 parent a019ce2 commit c544c00
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions scripts/generate-nano-reps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const generate_nano_reps = async () => {
'accounts.account',
'accounts_meta_index.account'
)
.whereNot('representatives_meta_index.account', 'nano_1111111111111111111111111111111111111111111111111111hifc8npp')
.select(
'accounts.alias',
'accounts_meta_index.weight',
Expand Down Expand Up @@ -106,14 +107,17 @@ const generate_nano_reps = async () => {
results_index[account] = merged_rep
}

// Add missing representatives with sufficient voting weight (1000 Nano)
// Add missing representatives with sufficient voting weight (10,000 Nano) and at least one non-null field
for (const account in db_reps_index) {
if (
!results_index[account] &&
db_reps_index[account].weight > 1000000000000000000000000000000000
db_reps_index[account].weight > 10000000000000000000000000000000000
) {
const { weight, ...db_rep_without_weight_field } = db_reps_index[account]
results_index[account] = db_rep_without_weight_field
const { weight, account: db_rep_account, ...db_rep_without_weight_field } = db_reps_index[account]
const has_non_null_field = Object.values(db_rep_without_weight_field).some(value => value !== null)
if (has_non_null_field) {
results_index[account] = { account, ...db_rep_without_weight_field }
}
}
}

Expand Down

0 comments on commit c544c00

Please sign in to comment.