예제 #1
0
    def accumulation_hook(self, db_session):

        self.block.count_contracts_new += 1

        contract = Contract(
            code_hash=self.event.attributes[0]['value'].replace('0x', ''),
            created_at_block=self.event.block_id,
            created_at_extrinsic=self.event.extrinsic_idx,
            created_at_event=self.event.event_idx,
        )

        for param in self.extrinsic.params:
            if param.get('name') == 'code':
                contract.bytecode = param.get('value')

        contract.save(db_session)
예제 #2
0
 def accumulation_revert(self, db_session):
     for item in Contract.query(db_session).filter_by(created_at_block=self.block.id):
         db_session.delete(item)
 def get_item(self, item_id):
     return Contract.query(self.session).get(item_id)
 def get_query(self):
     return Contract.query(self.session).order_by(
         Contract.created_at_block.desc())