Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
Library updates and fixes (related to #21)
Browse files Browse the repository at this point in the history
* Updated to latest py-scale-codec and py-substrate-interface
* Several function call fixes (thanks to @imstar15)
  • Loading branch information
arjanz committed Aug 2, 2021
1 parent 9d0393a commit 95c28a9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
8 changes: 3 additions & 5 deletions app/processors/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def process_genesis(self, block):
# Get accounts from storage keys
storage_key_prefix = self.substrate.generate_storage_hash(
storage_module='System',
storage_function='Account',
metadata_version=settings.SUBSTRATE_METADATA_VERSION
storage_function='Account'
)

rpc_result = self.substrate.rpc_request(
Expand Down Expand Up @@ -1027,13 +1026,12 @@ def create_full_balance_snaphot(self, block_id):
)

if storage_method:
if storage_method.get("type_hasher_key1") == "Blake2_128Concat":
if storage_method.type['MapType']['hasher'] == "Blake2_128Concat":

# get balances storage prefix
storage_key_prefix = self.substrate.generate_storage_hash(
storage_module='System',
storage_function='Account',
metadata_version=settings.SUBSTRATE_METADATA_VERSION
storage_function='Account'
)

rpc_result = self.substrate.rpc_request(
Expand Down
29 changes: 16 additions & 13 deletions app/processors/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,17 @@ def add_session_old(self, db_session, session_id):
metadata_version=SUBSTRATE_METADATA_VERSION
) or []
except RemainingScaleBytesNotEmptyException:
validator_session_list = substrate.get_storage(
block_hash=self.block.hash,
module="Session",
function="QueuedKeys",
return_scale_type='Vec<(ValidatorId, EdgewareKeys)>',
hasher=storage_call.type_hasher,
metadata_version=SUBSTRATE_METADATA_VERSION
) or []
try:
validator_session_list = substrate.get_storage(
block_hash=self.block.hash,
module="Session",
function="QueuedKeys",
return_scale_type='Vec<(ValidatorId, EdgewareKeys)>',
hasher=storage_call.type_hasher,
metadata_version=SUBSTRATE_METADATA_VERSION
) or []
except RemainingScaleBytesNotEmptyException:
validator_session_list = []

# build lookup dict
validation_session_lookup = {}
Expand Down Expand Up @@ -345,7 +348,7 @@ def add_session_old(self, db_session, session_id):
block_hash=self.block.hash,
module="Staking",
function="Bonded",
params=validator_stash,
params=[validator_stash],
return_scale_type=storage_call.get_return_type(),
hasher=storage_call.type_hasher,
metadata_version=SUBSTRATE_METADATA_VERSION
Expand Down Expand Up @@ -375,7 +378,7 @@ def add_session_old(self, db_session, session_id):
block_hash=self.block.hash,
module="Staking",
function="Ledger",
params=validator_controller,
params=[validator_controller],
return_scale_type=storage_call.get_return_type(),
hasher=storage_call.type_hasher,
metadata_version=SUBSTRATE_METADATA_VERSION
Expand All @@ -399,7 +402,7 @@ def add_session_old(self, db_session, session_id):
block_hash=self.block.hash,
module="Session",
function="NextKeyFor",
params=validator_controller,
params=[validator_controller],
return_scale_type=storage_call.get_return_type(),
hasher=storage_call.type_hasher,
metadata_version=SUBSTRATE_METADATA_VERSION
Expand All @@ -422,7 +425,7 @@ def add_session_old(self, db_session, session_id):
block_hash=self.block.hash,
module="Staking",
function="Validators",
params=validator_stash,
params=[validator_stash],
return_scale_type=storage_call.get_return_type(),
hasher=storage_call.type_hasher,
metadata_version=SUBSTRATE_METADATA_VERSION
Expand All @@ -443,7 +446,7 @@ def add_session_old(self, db_session, session_id):
block_hash=self.block.hash,
module="Staking",
function="Stakers",
params=validator_stash,
params=[validator_stash],
return_scale_type=storage_call.get_return_type(),
hasher=storage_call.type_hasher,
metadata_version=SUBSTRATE_METADATA_VERSION
Expand Down
2 changes: 1 addition & 1 deletion py-substrate-interface
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ py-ed25519-bindings>=0.1.2
py-bip39-bindings>=0.1.6

scalecodec~=0.11.17
substrate-interface~=0.13.11
substrate-interface~=0.13.12

0 comments on commit 95c28a9

Please sign in to comment.