def db_merge(self, token_contract, entries): company_list = company_list_factory.get() for entry in entries: # Exchangeアドレスが移転元の場合、処理をSKIPする tradable_exchange = token_contract.functions.tradableExchange( ).call() if entry["args"]["from"] == tradable_exchange: continue token_owner_address = token_contract.functions.owner().call() token_name = token_contract.functions.name().call() company = company_list.find(token_owner_address) metadata = { "company_name": company.corporate_name, "token_address": entry["address"], "token_name": token_name, "exchange_address": "", "token_type": "IbetCoupon" } notification = Notification() notification.notification_id = self._gen_notification_id(entry) notification.notification_type = NotificationType.TRANSFER.value notification.priority = 0 notification.address = entry["args"]["to"] notification.block_timestamp = self._gen_block_timestamp(entry) notification.args = dict(entry["args"]) notification.metainfo = metadata db_session.merge(notification)
def watch(self, entries): company_list = company_list_factory.get() for entry in entries: token_address = entry["args"]["tokenAddress"] if not token_list.is_registered(token_address): continue token = token_factory.get_membership(token_address) company = company_list.find(token.owner_address) metadata = { "company_name": company.corporate_name, "token_address": token_address, "token_name": token.name, "exchange_address": IBET_MEMBERSHIP_EXCHANGE_CONTRACT_ADDRESS, "token_type": "IbetMembership" } notification = Notification() notification.notification_id = self._gen_notification_id(entry, 2) notification.notification_type = NotificationType.SELL_SETTLEMENT_NG.value notification.priority = 2 notification.address = entry["args"]["sellAddress"] notification.block_timestamp = self._gen_block_timestamp(entry) notification.args = dict(entry["args"]) notification.metainfo = metadata db_session.merge(notification)
def watch(self, entries): company_list = company_list_factory.get() for entry in entries: token_address = entry["args"]["tokenAddress"] if not token_list.is_registered(token_address): continue token = token_factory.get_coupon(token_address) company = company_list.find(token.owner_address) metadata = { "company_name": company.corporate_name, "token_address": token_address, "token_name": token.name, "exchange_address": IBET_CP_EXCHANGE_CONTRACT_ADDRESS, "token_type": "IbetCoupon" } notification = Notification() notification.notification_id = self._gen_notification_id(entry, 1) notification.notification_type = NotificationType.BUY_AGREEMENT.value notification.priority = 1 notification.address = entry["args"]["buyAddress"] notification.block_timestamp = self._gen_block_timestamp(entry) notification.args = dict(entry["args"]) notification.metainfo = metadata db_session.merge(notification)
def watch(self, entries): company_list = company_list_factory.get() for entry in entries: token_address = entry["args"]["tokenAddress"] if not token_list.is_registered(token_address): continue # NOTE: OTCExchangeはShare以外のトークンでも利用される可能性があるため、 # token_templateがShareではない場合処理をスキップする if token_list.get_token(token_address)[1] != "IbetShare": continue token = token_factory.get_share(token_address) company = company_list.find(token.owner_address) metadata = { "company_name": company.corporate_name, "token_address": token_address, "token_name": token.name, "exchange_address": IBET_SHARE_EXCHANGE_CONTRACT_ADDRESS, "token_type": "IbetShare" } notification = Notification() notification.notification_id = self._gen_notification_id(entry, 2) notification.notification_type = NotificationType.SELL_SETTLEMENT_NG.value notification.priority = 2 notification.address = entry["args"]["sellAddress"] notification.block_timestamp = self._gen_block_timestamp(entry) notification.args = dict(entry["args"]) notification.metainfo = metadata db_session.merge(notification)
def watch(self, entries): company_list = company_list_factory.get() for entry in entries: token_address = entry["args"]["tokenAddress"] if not token_list.is_registered(token_address): continue token = token_factory.get_straight_bond(token_address) company = company_list.find(token.owner_address) metadata = { "company_name": company.corporate_name, "token_address": token_address, "token_name": token.name, "exchange_address": IBET_SB_EXCHANGE_CONTRACT_ADDRESS, "token_type": "IbetStraightBond" } notification = Notification() notification.notification_id = self._gen_notification_id(entry) notification.notification_type = NotificationType.CANCEL_ORDER.value notification.priority = 0 notification.address = entry["args"]["accountAddress"] notification.block_timestamp = self._gen_block_timestamp(entry) notification.args = dict(entry["args"]) notification.metainfo = metadata db_session.merge(notification)
def watch(self, entries): for entry in entries: notification = Notification() notification.notification_id = self._gen_notification_id(entry) notification.notification_type = NotificationType.PAYMENT_ACCOUNT_BAN.value notification.priority = 2 notification.address = entry["args"]["account_address"] notification.block_timestamp = self._gen_block_timestamp(entry) notification.args = dict(entry["args"]) notification.metainfo = {} db_session.merge(notification)
def db_merge(self, token_contract, entries): company_list = company_list_factory.get() for entry in entries: token_owner_address = token_contract.functions.owner().call() token_name = token_contract.functions.name().call() company = company_list.find(token_owner_address) metadata = { "company_name": company.corporate_name, "token_address": entry["address"], "token_name": token_name, "exchange_address": "", "token_type": "IbetShare" } notification = Notification() notification.notification_id = self._gen_notification_id(entry) notification.notification_type = NotificationType.SUSPEND.value notification.priority = 0 notification.block_timestamp = self._gen_block_timestamp(entry) notification.args = dict(entry["args"]) notification.metainfo = metadata db_session.merge(notification)
def _insert_test_data(self, session): self.session = session # HACK: updateでcommitされてしまう対策 n = Notification() n.notification_id = "0x00000021034300000000000000" n.notification_type = "SampleNotification1" n.priority = 1 n.address = "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf" n.is_read = True n.is_flagged = False n.is_deleted = False n.deleted_at = None n.block_timestamp = datetime(2017, 6, 10, 10, 0, 0) n.args = { "hoge": "fuga", } n.metainfo = { "aaa": "bbb", } session.add(n) n = Notification() n.notification_id = "0x00000021034000000000000000" n.notification_type = "SampleNotification2" n.priority = 1 n.address = "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf" n.is_read = False n.is_flagged = False n.is_deleted = True n.deleted_at = None n.block_timestamp = datetime(2017, 5, 10, 10, 0, 0) n.args = { "hoge": "fuga", } n.metainfo = {} session.add(n) n = Notification() n.notification_id = "0x00000011034000000000000000" n.notification_type = "SampleNotification3" n.priority = 2 n.address = "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf" n.is_read = False n.is_flagged = True n.is_deleted = False n.deleted_at = None n.block_timestamp = datetime(2017, 4, 10, 10, 0, 0) n.args = { "hoge": "fuga", } n.metainfo = {} session.add(n) n = Notification() n.notification_id = "0x00000011032000000000000000" n.notification_type = "SampleNotification4" n.priority = 1 n.address = "0x7E5F4552091A69125d5DfCb7b8C2659029395B00" n.is_read = True n.is_flagged = False n.is_deleted = False n.deleted_at = None n.block_timestamp = datetime(2017, 3, 10, 10, 0, 0) n.args = { "hoge": "fuga", } n.metainfo = {} session.add(n) n = Notification() n.notification_id = "0x00000001034000000000000000" n.notification_type = "SampleNotification5" n.priority = 0 n.address = "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf" n.is_read = False n.is_flagged = False n.is_deleted = False n.deleted_at = None n.block_timestamp = datetime(2017, 2, 10, 10, 0, 0) n.args = { "hoge": "fuga", } n.metainfo = {} session.add(n) session.commit()
def _insert_test_data(self, session): n = Notification() n.notification_id = "0x00000021034300000000000000" n.notification_type = "NewOrder" n.priority = 1 n.address = self.address n.is_read = True n.is_flagged = False n.is_deleted = False n.deleted_at = None n.block_timestamp = datetime(2017, 6, 10, 10, 0, 0) n.args = { "hoge": "fuga", } n.metainfo = { "aaa": "bbb", } n.created = datetime.strptime("2022/01/01 15:20:30", '%Y/%m/%d %H:%M:%S') session.add(n) n = Notification() n.notification_id = "0x00000021034000000000000000" n.notification_type = "NewOrderCounterpart" n.priority = 1 n.address = self.address n.is_read = False n.is_flagged = False n.is_deleted = True n.deleted_at = None n.block_timestamp = datetime(2017, 5, 10, 10, 0, 0) n.args = { "hoge": "fuga", } n.metainfo = {} n.created = datetime.strptime("2022/01/01 16:20:30", '%Y/%m/%d %H:%M:%S') session.add(n) n = Notification() n.notification_id = "0x00000011034000000000000000" n.notification_type = "NewOrder" n.priority = 2 n.address = self.address n.is_read = False n.is_flagged = True n.is_deleted = False n.deleted_at = None n.block_timestamp = datetime(2017, 4, 10, 10, 0, 0) n.args = { "hoge": "fuga", } n.metainfo = {} n.created = datetime.strptime("2022/01/01 17:20:30", '%Y/%m/%d %H:%M:%S') session.add(n) n = Notification() n.notification_id = "0x00000011032000000000000000" n.notification_type = "NewOrderCounterpart" n.priority = 1 n.address = self.address_2 n.is_read = True n.is_flagged = False n.is_deleted = False n.deleted_at = None n.block_timestamp = datetime(2017, 3, 10, 10, 0, 0) n.args = { "hoge": "fuga", } n.metainfo = {} n.created = datetime.strptime("2022/01/01 18:20:30", '%Y/%m/%d %H:%M:%S') session.add(n) n = Notification() n.notification_id = "0x00000001034000000000000000" n.notification_type = "NewOrder" n.priority = 0 n.address = self.address n.is_read = False n.is_flagged = False n.is_deleted = False n.deleted_at = None n.block_timestamp = datetime(2017, 2, 10, 10, 0, 0) n.args = { "hoge": "fuga", } n.metainfo = {} n.created = datetime.strptime("2022/01/01 19:20:30", '%Y/%m/%d %H:%M:%S') session.add(n)