def set_types(items):
    for i in items:
        if tokenPattern.match(i["target"]) or addressPattern.match(
                i["target"]):
            i["type"] = "boost"
        elif i.get("about"):
            if tokenPattern.match(i["about"]):
                i["type"] = "post_to"
            elif addressPattern.match(i["about"]):
                i["type"] = "post_to_simple"
            else:
                i["type"] = "post_about"
        else:
            i["type"] = "regular"
Ejemplo n.º 2
0
def set_type(i):
    if tokenPattern.match(i["target"]) or addressPattern.match(i["target"]):
        i["type"] = "boost"
    elif i["about"]:
        if claimPattern.match(i["about"]):
            i["type"] = "regular"
        elif tokenPattern.match(i["about"]):
            i["type"] = "post_to"
        elif addressPattern.match(i["about"]):
            i["type"] = "post_to_simple"
        elif assetPattern.match(i["about"]):
            i["type"] = "post_club"
        else:
            i["type"] = "post_about"
    else:
        i["type"] = "regular"
Ejemplo n.º 3
0
def remove_non_matching_ids(result):
    return {
        "items": [
            item for item in result["items"] if
            addressPattern.match(item["id"]) or tokenPattern.match(item["id"])
        ]
    }
def run(conn_mgr, input, **params):
    ids = params["id"]
    if isinstance(ids, str):
        ids = [ids]
    address_ids = [id for id in ids if addressPattern.match(id)]
    token_ids = [id for id in ids if not addressPattern.match(id)]
    address_result = notifications_address.run(conn_mgr, input, id=address_ids)
    token_result = notifications.run(conn_mgr, input, id=token_ids)
    result = {
        "items":
        sorted(address_result["items"] + token_result["items"],
               key=lambda x: x["created_at"],
               reverse=True)
    }
    result = replies.run(conn_mgr, result)
    result = reactions.run(conn_mgr, result)
    set_types(result["items"])
    return result
Ejemplo n.º 5
0
def set_type(i):
    if i.get("reply_to"):
        i["type"] = "response"
    elif tokenPattern.match(i["target"]) or addressPattern.match(i["target"]):
        i["type"] = "boost"
    elif i.get("label") in ["github", "twitter", "instagram", "facebook", "discord", "telegram"]:
        i["type"] = "social"
    elif i["about"]:
        if tokenPattern.match(i["about"]):
            i["type"] = "post_to"
        elif addressPattern.match(i["about"]):
            i["type"] = "post_to_simple"
        elif assetPattern.match(i["about"]):
            i["type"] = "post_club"
        else:
            i["type"] = "post_about"
    else:
        i["type"] = "regular"
Ejemplo n.º 6
0
def run(conn_mgr, input, **params):
    if addressPattern.match(params["id"]):
        result = single_address.run(conn_mgr, input, **params)
    else:
        result = single.run(conn_mgr, input, **params)
    result = replies.run(conn_mgr, result)
    result = reactions.run(conn_mgr, result)
    set_types(result["items"])
    return result
Ejemplo n.º 7
0
def run(conn_mgr, input, **params):
    if not addressPattern.match(params["entity"]):
        erc721, token_id = params["entity"].rsplit(":", 1)
        results = conn_mgr.run_graph(IDENTITY_FROM_CONTEXT, {
            "erc721": erc721,
            "tokenId": token_id
        })
        params["entity"] = results.single()["identity"]
    results = conn_mgr.run_graph(ALL_BALANCES, params)
    balances = defaultdict(int)
    for r in results:
        balances[r["asset"]] += int(float(r["amount"]))
    return {k: v for k, v in balances.items() if v > 0}
Ejemplo n.º 8
0
def run(conn_mgr, input, **params):
    id = params["id"]
    output = {}
    if addressPattern.match(id):
        input = conn_mgr.run_graph(ADDRESS_PROFILE_QUERY, {"identity": id})
        for item in input:
            output[item["label"]] = item["social"]
    else:
        input = context_feed.run(conn_mgr, input, id=id)
        input = filter_labels.run(conn_mgr,
                                  input,
                                  id=[
                                      "facebook", "instagram", "twitter",
                                      "github", "discord", "telegram"
                                  ])
        input = valid_erc721.run(conn_mgr, input)
        input = sort.run(conn_mgr, input, by="created_at")
        for claim in input["items"]:
            for label in claim["labels"]:
                output[label] = claim["target"]
    return output