How to use the scalecodec.metadata.MetadataDecoder function in scalecodec

To help you get started, we’ve selected a few scalecodec examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkascan / py-scale-codec / test / test_metadata.py View on Github external
def test_decode_invalid_metadata_v1(self):
        metadata_decoder = MetadataDecoder(ScaleBytes(metadata_v1_hex))
        self.assertRaises(Exception, metadata_decoder.decode())
github polkascan / py-scale-codec / test / test_extrinsic_payload.py View on Github external
def setUpClass(cls):
        RuntimeConfiguration().clear_type_registry()
        RuntimeConfiguration().update_type_registry(load_type_registry_preset("default"))
        RuntimeConfiguration().update_type_registry(load_type_registry_preset("kusama"))
        RuntimeConfiguration().set_active_spec_version_id(1045)

        cls.metadata_decoder = MetadataDecoder(ScaleBytes(metadata_1045_hex))
        cls.metadata_decoder.decode()
github polkascan / py-scale-codec / test / test_metadata.py View on Github external
def test_decode_metadata_v1(self):
        metadata_decoder = MetadataDecoder(ScaleBytes(metadata_v1_hex))
        metadata_decoder.decode()
        self.assertEqual(metadata_decoder.version.value, "MetadataV1Decoder")
github polkascan / py-scale-codec / test / test_metadata.py View on Github external
def test_all_scale_type_supported_v2(self):
        metadata_decoder = MetadataDecoder(ScaleBytes(metadata_v2_hex))
        metadata_decoder.decode()
        self.assertEqual(metadata_decoder.version.value, "MetadataV2Decoder")

        for module in metadata_decoder.metadata.modules:
            if module.calls:
                for call in module.calls:
                    for arg in call.args:
                        decoder_class = ScaleDecoder.get_decoder_class(arg.type, ScaleBytes('0x00'))
                        self.assertIsNotNone(decoder_class, msg='{} is not supported by metadata'.format(arg.type))
github polkascan / py-scale-codec / test / test_metadata.py View on Github external
def test_decode_metadata_v3(self):
        metadata_decoder = MetadataDecoder(ScaleBytes(metadata_v3_hex))
        metadata_decoder.decode()
        self.assertEqual(metadata_decoder.version.value, "MetadataV3Decoder")
github polkascan / py-scale-codec / test / test_scale_types.py View on Github external
def setUpClass(cls):
        RuntimeConfiguration().clear_type_registry()
        RuntimeConfiguration().update_type_registry(load_type_registry_preset("default"))
        RuntimeConfiguration().update_type_registry(load_type_registry_preset("kusama"))
        RuntimeConfiguration().set_active_spec_version_id(1045)

        cls.metadata_decoder = MetadataDecoder(ScaleBytes(metadata_v10_hex))
        cls.metadata_decoder.decode()
github polkascan / py-scale-codec / test / test_metadata.py View on Github external
def test_all_scale_type_supported_v1(self):
        metadata_decoder = MetadataDecoder(ScaleBytes(metadata_v1_hex))
        metadata_decoder.decode()
        self.assertEqual(metadata_decoder.version.value, "MetadataV1Decoder")

        for module in metadata_decoder.metadata.modules:
            if module.calls:
                for call in module.calls:
                    for arg in call.args:
                        decoder_class = ScaleDecoder.get_decoder_class(arg.type, ScaleBytes('0x00'))
                        self.assertIsNotNone(decoder_class, msg='{} is not supported by metadata'.format(arg.type))
github polkascan / py-scale-codec / test / test_metadata.py View on Github external
def test_decode_metadata_v2(self):
        metadata_decoder = MetadataDecoder(ScaleBytes(metadata_v2_hex))
        metadata_decoder.decode()
        self.assertEqual(metadata_decoder.version.value, "MetadataV2Decoder")
github polkascan / py-scale-codec / scalecodec / block.py View on Github external
def __init__(self, data, metadata=None, **kwargs):
        assert (not metadata or type(metadata) == MetadataDecoder)

        self.metadata = metadata
        self.elements = []

        super().__init__(data, metadata=metadata, **kwargs)
github polkascan / polkascan-pre-harvester / app / resources / tools.py View on Github external
def on_post(self, req, resp):
        metadata = MetadataDecoder(ScaleBytes(req.media.get('result')))

        resp.status = falcon.HTTP_200
        resp.media = metadata.process()