Skip to content

Instantly share code, notes, and snippets.

@muharem
Created February 26, 2023 13:05
Show Gist options
  • Save muharem/8d21bfdbab6bf4ccf7fbdc9c3ad4d228 to your computer and use it in GitHub Desktop.
Save muharem/8d21bfdbab6bf4ccf7fbdc9c3ad4d228 to your computer and use it in GitHub Desktop.
from substrateinterface import SubstrateInterface
substrate = SubstrateInterface(
# url="wss://kusama-rpc.polkadot.io",
url="wss://kusama-rpc.dwellir.com",
)
block_number = 16799223
block_hash = substrate.get_block_hash(block_number)
# block_hash = substrate.get_block_header()['header']['number']
def get_address_by_rank(rank):
result = substrate.query_map(
module='FellowshipCollective',
storage_function='IndexToId',
params=[rank],
page_size=1000,
block_hash=block_hash)
return result
members = {};
for rank in range(10):
result = get_address_by_rank(rank)
for id, address in result:
members[id.value] = [rank, address.value]
ids = list(members.keys())
ids.sort()
for id in ids:
print("id {}, {}, {}".format(id, members[id][0], members[id][1]))
# print("({}, \"{}\"),".format(members[id][0], members[id][1]))
@muharem
Copy link
Author

muharem commented Feb 26, 2023

this only valid when ids are consistent over ranks for the same member.
which is a case now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment