+def construct_contract_status(coop_name, contract_name, requester_id):
+ StatusResp = EIProto.ContractCoopStatusResponse()
+ BaseInfo = db_store.get_contract_info(coop_name, contract_name)
+ ContribInfo = db_store.get_coop_contributors(coop_name, contract_name)
+ ContractInfo = contracts.get_contract_by_identifier(contract_name)
+ if BaseInfo is None or ContribInfo is None or ContractInfo is None:
+ return None
+ i = 0
+ for x in ContribInfo:
+ i += 1
+ contributor = StatusResp.contributors.add()
+ contributor.user_id = x[0] if x[0] == requester_id else "cool-guy-" + str(i)
+ contributor.user_name = x[3]
+ contributor.contribution_amount = x[5]
+ StatusResp.total_amount += x[5]
+ contributor.contribution_rate = x[6]
+ contributor.soul_power = x[7]
+ contributor.active = not (int(time.time()) - x[4]) >= 86400
+ contributor.boost_tokens = x[8]
+ StatusResp.coop_identifier = coop_name
+ StatusResp.contract_identifier = contract_name
+ StatusResp.auto_generated = BaseInfo[7]
+ StatusResp.public = BaseInfo[6]
+ StatusResp.creator_id = "hidden-for-safety" if requester_id != BaseInfo[5] else BaseInfo[5]
+ StatusResp.seconds_remaining = (BaseInfo[4] + int(ContractInfo.length_seconds)) - int(time.time())
+ GiftInfo = db_store.get_coop_gifts(coop_name, contract_name, requester_id)
+ for g in GiftInfo:
+ Gift = StatusResp.gifts.add()
+ Gift.user_id = "hidden-for-safety"
+ Gift.user_name = g[3]
+ Gift.amount = g[4]
+ return StatusResp
+