Skip to content

Commit

Permalink
add display name to collator
Browse files Browse the repository at this point in the history
  • Loading branch information
wuminzhe committed Aug 24, 2023
1 parent 0ce33a3 commit 4abd2ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ task :update_nominees, [:network_name] do |_t, args|
kton_pool = get_storage(rpc, metadata, 'darwinia_staking', 'kton_pool', nil, nil)
collator_commissions = get_collator_commissions(rpc, metadata) # includes active and waiting collators
active_collator_addresses = get_active_collators(rpc, metadata)
identities = get_identities(rpc, metadata) # address => name

# 1. Get all nominators with their nominees
# ---------------------------------------
Expand Down Expand Up @@ -163,6 +164,7 @@ task :update_nominees, [:network_name] do |_t, args|
[
nominee_address,
{
name: identities[nominee_address],
power: nominee_powers[nominee_address],
commission: collator_commissions[nominee_address],
status: get_nominee_status(active_collator_addresses, waiting_collator_addresses, nominee_address)
Expand Down
14 changes: 14 additions & 0 deletions src/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,25 @@ def get_nominee_status(active_collator_addresses, waiting_collator_addresses, no
end
end

def get_identities(rpc, metadata)
storages = get_storage(rpc, metadata, 'identity', 'identity_of', nil, nil)
storages.map do |storage|
address = "0x#{storage[:storage_key][-40..]}"
name = if storage[:storage][:info][:display].instance_of?(Hash)
storage[:storage][:info][:display].values.first.to_utf8
end
[address, name]
end.to_h
end

# require_relative '../config/config'
# config = get_config
# crab_metadata = JSON.parse(File.read(config[:metadata][:crab]))
# crab_rpc = config[:crab_rpc]

# # get_identities
# puts get_identities(crab_rpc, crab_metadata)

# # collators
# puts collators(crab_rpc, crab_metadata)

Expand Down

0 comments on commit 4abd2ee

Please sign in to comment.