예제 #1
0
def dashboard_data_waves():
    # get balance of local wallet
    url = NODE_BASE_URL + f"/assets/balance/{ADDRESS}/{ASSET_ID}"
    logger.info("requesting %s..", url)
    response = requests.get(url)
    try:
        asset_balance = response.json()["balance"]
    except:  # pylint: disable=bare-except
        logger.error("failed to parse response")
        asset_balance = "n/a"
    url = NODE_BASE_URL + f"/addresses/balance/{ADDRESS}"
    logger.info("requesting %s..", url)
    response = requests.get(url)
    try:
        waves_balance = response.json()["balance"]
    except:  # pylint: disable=bare-except
        logger.error("failed to parse response")
        waves_balance = "n/a"
    # get the balance of the main wallet
    url = NODE_BASE_URL + f"/transactions/info/{ASSET_ID}"
    logger.info("requesting %s..", url)
    response = requests.get(url)
    try:
        issuer = response.json()["sender"]
        url = NODE_BASE_URL + f"/assets/balance/{issuer}/{ASSET_ID}"
        logger.info("requesting %s..", url)
        response = requests.get(url)
        master_asset_balance = response.json()["balance"]
        url = NODE_BASE_URL + f"/addresses/balance/{issuer}"
        logger.info("requesting %s..", url)
        response = requests.get(url)
        master_waves_balance = response.json()["balance"]
    except:  # pylint: disable=bare-except
        logger.error("failed to parse response")
        issuer = "n/a"
        master_waves_balance = "n/a"
        master_asset_balance = "n/a"
    # return data
    return {"asset_balance": asset_balance, "asset_address": ADDRESS, "waves_balance": waves_balance, \
            "master_asset_balance": master_asset_balance, "master_waves_balance": master_waves_balance, "master_waves_address": issuer, \
            "asset_id": ASSET_ID, \
            "testnet": TESTNET, \
            "premio_qrcode": utils.qrcode_svg_create(ADDRESS), \
            "issuer_qrcode": utils.qrcode_svg_create(issuer), \
            "wavesexplorer": app.config["WAVESEXPLORER"]}
예제 #2
0
 def render(recipient):
     url_parts = urlparse(request.url)
     url = url_parts._replace(scheme=DEEP_LINK_SCHEME,
                              query='scheme={}'.format(
                                  url_parts.scheme)).geturl()
     qrcode_svg = utils.qrcode_svg_create(url)
     return render_template("claim_payment.html",
                            payment=payment,
                            recipient=recipient,
                            qrcode_svg=qrcode_svg,
                            url=url)
예제 #3
0
def tx_link(txid):
    url_parts = urlparse(request.url)
    url = url_parts._replace(scheme="premiomwlink",
                             path="/txid/" + txid).geturl()
    qrcode_svg = utils.qrcode_svg_create(url)
    return render_template("mw/tx_link.html", qrcode_svg=qrcode_svg, url=url)
예제 #4
0
def inject_config_qrcode_svg():
    url_parts = urlparse(request.url)
    url = url_parts._replace(scheme="premiomwlink", path="/config").geturl()
    qrcode_svg = utils.qrcode_svg_create(url, box_size=6)
    return dict(mw_config_url=url, mw_config_qrcode_svg=qrcode_svg)