def get_relationships(self, include_list, item):
        relationships = {}

        if 'calls' in include_list:
            relationships['calls'] = RuntimeCall.query(self.session).filter_by(
                spec_version=item.spec_version,
                module_id=item.module_id).order_by('lookup', 'id')

        if 'events' in include_list:
            relationships['events'] = RuntimeEvent.query(
                self.session).filter_by(spec_version=item.spec_version,
                                        module_id=item.module_id).order_by(
                                            'lookup', 'id')

        if 'storage' in include_list:
            relationships['storage'] = RuntimeStorage.query(
                self.session).filter_by(
                    spec_version=item.spec_version,
                    module_id=item.module_id).order_by('name')

        if 'constants' in include_list:
            relationships['constants'] = RuntimeConstant.query(
                self.session).filter_by(
                    spec_version=item.spec_version,
                    module_id=item.module_id).order_by('name')

        if 'errors' in include_list:
            relationships['errors'] = RuntimeErrorMessage.query(
                self.session).filter_by(
                    spec_version=item.spec_version,
                    module_id=item.module_id).order_by('name').order_by(
                        RuntimeErrorMessage.index)

        return relationships
示例#2
0
 def get_item(self, item_id):
     spec_version, module_id, call_id = item_id.split('-')
     return RuntimeCall.query(self.session).filter_by(
         spec_version=spec_version,
         module_id=module_id,
         call_id=call_id
     ).first()
示例#3
0
    def serialize_item(self, item):
        data = item.serialize()

        runtime_call = RuntimeCall.query(self.session).filter_by(
            module_id=item.module_id,
            call_id=item.call_id,
            spec_version=item.spec_version_id
        ).first()

        data['attributes']['documentation'] = runtime_call.documentation

        return data
    def serialize_item(self, item):
        data = item.serialize()

        runtime_call = RuntimeCall.query(self.session).filter_by(
            module_id=item.module_id,
            call_id=item.call_id,
            spec_version=item.spec_version_id).first()

        data['attributes']['documentation'] = runtime_call.documentation

        block = Block.query(self.session).get(item.block_id)

        if block.datetime:
            data['attributes']['datetime'] = block.datetime.replace(
                tzinfo=pytz.UTC).isoformat()
        else:
            data['attributes']['datetime'] = None

        if item.account:
            data['attributes']['account'] = item.account.serialize()

        if item.params:
            item.params = self.check_params(item.params, item.serialize_id())

        if item.error:
            # Retrieve ExtrinsicFailed event
            extrinsic_failed_event = Event.query(self.session).filter_by(
                block_id=item.block_id, event_id='ExtrinsicFailed').first()

            # Retrieve runtime error
            if extrinsic_failed_event:
                if 'Module' in extrinsic_failed_event.attributes[0]['value']:

                    error = RuntimeErrorMessage.query(self.session).filter_by(
                        module_index=extrinsic_failed_event.attributes[0]
                        ['value']['Module']['index'],
                        index=extrinsic_failed_event.attributes[0]['value']
                        ['Module']['error'],
                        spec_version=item.spec_version_id).first()

                    if error:
                        data['attributes'][
                            'error_message'] = error.documentation
                elif 'BadOrigin' in extrinsic_failed_event.attributes[0][
                        'value']:
                    data['attributes']['error_message'] = 'Bad origin'
                elif 'CannotLookup' in extrinsic_failed_event.attributes[0][
                        'value']:
                    data['attributes']['error_message'] = 'Cannot lookup'

        return data
示例#5
0
    def serialize_item(self, item):
        data = item.serialize()

        runtime_call = RuntimeCall.query(self.session).filter_by(
            module_id=item.module_id,
            call_id=item.call_id,
            spec_version=item.spec_version_id).first()

        data['attributes']['documentation'] = runtime_call.documentation

        block = Block.query(self.session).get(item.block_id)

        data['attributes']['datetime'] = block.datetime.replace(
            tzinfo=pytz.UTC).isoformat()

        if item.account:
            data['attributes']['account'] = item.account.serialize()

        if item.error:
            # Retrieve ExtrinsicFailed event
            extrinsic_failed_event = Event.query(self.session).filter_by(
                block_id=item.block_id, event_id='ExtrinsicFailed').first()

            # Retrieve runtime error
            if extrinsic_failed_event and 'Module' in extrinsic_failed_event.attributes[
                    0]['value']:

                error = RuntimeErrorMessage.query(self.session).filter_by(
                    module_id=item.module_id,
                    index=extrinsic_failed_event.attributes[0]['value']
                    ['Module']['error'],
                    spec_version=item.spec_version_id).first()

                if error:
                    data['attributes']['error_message'] = error.documentation

        return data
 def get_query(self):
     return RuntimeCall.query(self.session).order_by(
         RuntimeCall.spec_version.asc(), RuntimeCall.module_id.asc(),
         RuntimeCall.call_id.asc())