Skip to content

Commit

Permalink
fix primitives generation (#2123)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepanLav authored Oct 17, 2023
1 parent 2f2c07e commit 591d61b
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 33 deletions.
2 changes: 1 addition & 1 deletion chains/v2/types/bittensor.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"runtime_id": 135,
"types": {
"Balance": "u64",
"Balance": "u128",
"Index": "u32",
"Phase": "frame_system.Phase",
"Address": "sp_runtime.multiaddress.MultiAddress",
Expand Down
2 changes: 1 addition & 1 deletion chains/v2/types/centrifuge.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"runtime_id": 1020,
"runtime_id": 1023,
"types": {
"Balance": "u128",
"Index": "u32",
Expand Down
2 changes: 1 addition & 1 deletion chains/v2/types/encointer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"runtime_id": 16,
"types": {
"Balance": "u128",
"Index": "u8",
"Index": "u32",
"Phase": "frame_system.Phase",
"Address": "sp_runtime.multiaddress.MultiAddress",
"ExtrinsicSignature": "sp_runtime.MultiSignature",
Expand Down
2 changes: 1 addition & 1 deletion chains/v2/types/enjin_matrixchain.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"runtime_id": 604,
"runtime_id": 605,
"types": {
"Balance": "u128",
"Index": "u32",
Expand Down
2 changes: 1 addition & 1 deletion chains/v2/types/imbue.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"runtime_id": 1038,
"runtime_id": 9432,
"types": {
"Balance": "u128",
"Index": "u32",
Expand Down
2 changes: 1 addition & 1 deletion chains/v2/types/jur.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"runtime_id": 103,
"runtime_id": 112,
"types": {
"Balance": "u128",
"Index": "u32",
Expand Down
2 changes: 1 addition & 1 deletion chains/v2/types/kilt_spiritnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"runtime_id": 11110,
"types": {
"Balance": "u128",
"Index": "u64",
"Index": "u32",
"Phase": "frame_system.Phase",
"Address": "sp_runtime.multiaddress.MultiAddress",
"ExtrinsicSignature": "sp_runtime.MultiSignature",
Expand Down
6 changes: 3 additions & 3 deletions chains/v2/types/krest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"runtime_id": 3,
"runtime_id": 4,
"types": {
"Balance": "u128",
"Index": "u32",
"Phase": "frame_system.Phase",
"Address": "sp_runtime.multiaddress.MultiAddress",
"ExtrinsicSignature": "sp_runtime.MultiSignature",
"ParaId": "polkadot_parachain.primitives.Id",
"peaq_krest_runtime.Event": "GenericEvent",
"peaq_krest_runtime.Call": "GenericCall",
"peaq_krest_runtime.RuntimeEvent": "GenericEvent",
"peaq_krest_runtime.RuntimeCall": "GenericCall",
"sp_core.crypto.AccountId32": "GenericAccountId",
"pallet_identity.types.Data": "Data"
},
Expand Down
2 changes: 1 addition & 1 deletion chains/v2/types/tinkernet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"runtime_id": 18,
"runtime_id": 19,
"types": {
"Balance": "u128",
"Index": "u32",
Expand Down
4 changes: 2 additions & 2 deletions chains/v2/types/zeitgeist.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"runtime_id": 48,
"runtime_id": 49,
"types": {
"Balance": "u128",
"Index": "u64",
"Index": "u32",
"Phase": "frame_system.Phase",
"Address": "sp_runtime.multiaddress.MultiAddress",
"ExtrinsicSignature": "sp_runtime.MultiSignature",
Expand Down
6 changes: 3 additions & 3 deletions scripts/create_type_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def compare_type_files_for_all_networks(chains_file):
f"Generating has started for: {chain['name']}. {index}/{len(chains_file)}")
chain_options = chain.get('options')
skip_options = {'ethereumBased', 'noSubstrateRuntime'}

if chain_options is not None:
if skip_options.intersection(chain_options):
# TODO need to implement creation type file for EVM networks
Expand Down Expand Up @@ -81,11 +81,11 @@ def main(argv):
"""

if 'dev' in argv:
chains_path = os.getenv("DEV_CHAINS_JSON_PATH", "chains/v11/chains_dev.json")
chains_path = os.getenv("DEV_CHAINS_JSON_PATH")
chains_file = get_data_from_file(chains_path)
compare_type_files_for_all_networks(chains_file)
elif 'prod' in argv:
chains_path = os.getenv("CHAINS_JSON_PATH", "chains/v11/chains.json")
chains_path = os.getenv("CHAINS_JSON_PATH")
chains_file = get_data_from_file(chains_path)
compare_type_files_for_all_networks(chains_file)
else:
Expand Down
19 changes: 2 additions & 17 deletions scripts/utils/metadata_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def get_metadata_param(substrate: SubstrateInterface) -> JsonObject:

metadata_json = JsonObject(
runtime_id=metadata.runtime_config.active_spec_version_id,
types_balance=find_primitive("Balance", metadata_types),
types_index=find_primitive("Index", metadata_types),
types_balance=substrate.get_type_definition('Balance'),
types_index=substrate.get_type_definition('Index'),
types_phase=find_path_for_type_in_metadata("Phase", metadata_types),
types_address=return_type_path(address_type, 'path'),
types_extrinsicSignature=signature_type_path,
Expand Down Expand Up @@ -195,21 +195,6 @@ def find_dispatch_info(metadata_types) -> dict:
return dispatch_info_object


def find_primitive(name, metadata_types):
"""Find primitive value in metadata types
Args:
name (str): Primitive name
metadata_types (array): Array with metadata types
Returns:
str: Value for found type
"""
type_id = find_type_id_in_metadata(name, metadata_types)
type_with_primitive = metadata_types[type_id]
return deep_search_an_elemnt_by_key(type_with_primitive, "primitive")


def find_path_for_type_in_metadata(name, metadata_types, check_path=None):
"""Find path for type in metadata
Expand Down

0 comments on commit 591d61b

Please sign in to comment.