Skip to content

Commit

Permalink
Merge pull request #4 from reef-defi/dependency-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
jbargu authored Oct 27, 2021
2 parents 4479ecd + 50b19f2 commit 2a04aa0
Show file tree
Hide file tree
Showing 13 changed files with 583 additions and 569 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ py-bip39-bindings = "~=0.1.6"
black = "*"
packaging = "~=21.0"
reef-interface = {editable = true, path = "."}
scalecodec = "*"
scalecodec = "==0.11.23"

[dev-packages]

Expand Down
160 changes: 86 additions & 74 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions reefinterface/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@ def query(
params: list = None,
block_hash: str = None,
subscription_handler: callable = None,
override_result_type: str = None
) -> Optional[ScaleType]:
"""
Retrieves the storage entry for given module, function and optional parameters at given block hash.
Expand Down Expand Up @@ -1652,9 +1653,9 @@ def subscription_handler(obj, update_nr, subscription_id):
return_scale_type = map_type.get("value")

if len(params) != 2:
raise ValueError(
'Storage call of type "DoubleMapType" requires 2 parameters'
)
raise ValueError(
'Storage call of type "DoubleMapType" requires 2 parameters'
)

elif "NMapType" in storage_item.type:

Expand Down Expand Up @@ -1682,15 +1683,15 @@ def subscription_handler(obj, update_nr, subscription_id):
)

def result_handler(message, update_nr, subscription_id):
if return_scale_type:
if return_scale_type or override_result_type:

for change_storage_key, change_data in message["params"]["result"][
"changes"
]:
if change_storage_key == storage_hash:

updated_obj = ScaleDecoder.get_decoder_class(
type_string=return_scale_type,
type_string=override_result_type if override_result_type else return_scale_type,
data=ScaleBytes(change_data),
metadata=self.metadata_decoder,
runtime_config=self.runtime_config,
Expand Down Expand Up @@ -1728,7 +1729,7 @@ def result_handler(message, update_nr, subscription_id):
raise SubstrateRequestException(response["error"]["message"])

if "result" in response:
if return_scale_type:
if return_scale_type or override_result_type:

if response.get("result") is not None:
query_value = response.get("result")
Expand All @@ -1741,7 +1742,7 @@ def result_handler(message, update_nr, subscription_id):
query_value = storage_item.fallback

obj = ScaleDecoder.get_decoder_class(
type_string=return_scale_type,
type_string=override_result_type if override_result_type else return_scale_type,
data=ScaleBytes(query_value),
metadata=self.metadata_decoder,
runtime_config=self.runtime_config,
Expand Down Expand Up @@ -3632,6 +3633,14 @@ def total_fee_amount(self) -> int:
"""
if self.__total_fee_amount is None:
self.process_events()

if self.__total_fee_amount == 0:
fee_details = self.substrate.rpc_request("payment_queryFeeDetails", [str(self.extrinsic.data)])
if "result" in fee_details and "inclusionFee" in fee_details["result"]:
for fee in fee_details["result"]["inclusionFee"].values():
self.__total_fee_amount += int(fee, 16)
else:
raise SubstrateRequestException(fee_details["error"]["message"])
return self.__total_fee_amount

# Helper functions
Expand Down
46 changes: 44 additions & 2 deletions reefinterface/types.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
{
"types": {
"AccountInfo": "AccountInfoWithDualRefCount"
}
"Keys": {
"type": "struct",
"type_mapping": [
["babe", "AccountId"],
["grandpa", "AccountId"],
["im_online", "AccountId"],
["authority_discovery", "AccountId"]
]
},
"EvmAddress": "H160",
"Log": {
"type": "struct",
"type_mapping": [
["address", "H160"],
["topics", "Vec<H256>"],
["data", "Bytes"]
]
},
"EvmAccountInfoOption": "Option<EvmAccountInfo>",
"EvmAccountInfo": {
"type": "struct",
"type_mapping": [
["nonce", "Index"],
["contract_info", "Option<EvmContractInfo>"],
["developer_deposit", "Option<BalanceOf>"]
]
},
"EvmContractInfo": {
"type": "struct",
"type_mapping": [
["code_hash", "H256"],
["maintainer", "EvmAddress"],
["deployed", "Bool"]
]
}
},
"versioning": [
{
"runtime_range": [0, 7],
"types": {
"AccountInfo": "AccountInfoWithDualRefCount"
}
}
]
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ xxhash>=2.0.0
pytest>=6.2.2
packaging~=21.0

scalecodec~=0.11.16
scalecodec>=0.11.16,<=0.11.23
py-sr25519-bindings~=0.1.2
py-ed25519-bindings~=0.1.2
py-bip39-bindings~=0.1.6
Loading

0 comments on commit 2a04aa0

Please sign in to comment.