Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoder class for "MerkleRoot" not found #73

Closed
khssnv opened this issue Jun 24, 2022 · 3 comments
Closed

Decoder class for "MerkleRoot" not found #73

khssnv opened this issue Jun 24, 2022 · 3 comments
Assignees

Comments

@khssnv
Copy link

khssnv commented Jun 24, 2022

Hi there 👋

I tried to use py-substrate-interface to work with Crust Network and by an error message (below) it seems like py-scale-codec misses a type registry file for it.

I would like to add the type registry JSON file if you may tell me how I can get it.

Code sample:

crust_network_place_storage_order.py
import substrateinterface

CID = "QmYoEcsE1aCCDPrgNfEtiLdPZBj4dncFNUvD6vZLSokeXa"
SIZE = 7388569
MNEMONIC = "bottom drive obey lake curtain smoke basket hold race lonely fit walk"  # well known account


def place_storage_order(cid: str, size: int) -> None:
    keypair = substrateinterface.Keypair.create_from_mnemonic(MNEMONIC)
    crust = substrateinterface.SubstrateInterface(
        url="wss://rpc.crust.network",
    )
    call = crust.compose_call(
        call_module="Market",
        call_function="place_storage_order",
        call_params=dict(
            cid=cid,
            reported_file_size=size,
            tips=0,
            memo="",
        )
    )
    extrinsic = crust.create_signed_extrinsic(
        call=call,
        keypair=keypair,
    )
    receipt = crust.submit_extrinsic(extrinsic, wait_for_finalization=True)
    return receipt


if __name__ == "__main__":
    receipt = place_storage_order(CID, SIZE)
    print(receipt)

Error message:

$ python crust_network_place_storage_order.py 
Traceback (most recent call last):
  File "crust_network_place_storage_order.py", line 32, in <module>
    receipt = place_storage_order(CID, SIZE)
  File "crust_network_place_storage_order.py", line 13, in place_storage_order
    call = crust.compose_call(
  File "/home/khassanov/.cache/pypoetry/virtualenvs/crust-network-python-example-Zg3OD2BK-py3.8/lib/python3.8/site-packages/substrateinterface/base.py", line 1622, in compose_call
    call.encode({
  File "/home/khassanov/.cache/pypoetry/virtualenvs/crust-network-python-example-Zg3OD2BK-py3.8/lib/python3.8/site-packages/scalecodec/base.py", line 709, in encode
    self.data = self.process_encode(self.value_serialized)
  File "/home/khassanov/.cache/pypoetry/virtualenvs/crust-network-python-example-Zg3OD2BK-py3.8/lib/python3.8/site-packages/scalecodec/types.py", line 1483, in process_encode
    arg_obj = self.runtime_config.create_scale_object(
  File "/home/khassanov/.cache/pypoetry/virtualenvs/crust-network-python-example-Zg3OD2BK-py3.8/lib/python3.8/site-packages/scalecodec/base.py", line 160, in create_scale_object
    raise NotImplementedError('Decoder class for "{}" not found'.format(type_string))
NotImplementedError: Decoder class for "MerkleRoot" not found
@arjanz arjanz self-assigned this Jun 24, 2022
@arjanz
Copy link
Member

arjanz commented Jun 25, 2022

Ok I found a type registry for Crust in the PolkadotJS repos, so I converted the format and it seems to work.

The only change in your supplied sample I did was change the call param memo to _memo.

@arjanz
Copy link
Member

arjanz commented Jun 25, 2022

Released in https://github.com/polkascan/py-scale-codec/releases/tag/v1.0.37

@khssnv
Copy link
Author

khssnv commented Jun 25, 2022

Closed by 6622087

@khssnv khssnv closed this as completed Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants