Exemple #1
0
def create_and_send_nym_request(helpers, client_address, client_utxos):
    # =============
    # Create nym request and add fees.
    # =============

    nym_request = helpers.request.nym()
    nym_request = helpers.request.add_fees(
        nym_request,
        client_utxos,
        fee_amount=TXN_FEES[NYM],
        change_address=client_address,
    )

    # =============
    # Send nym request.
    # =============

    responses = helpers.sdk.send_and_check_request_objects([nym_request])
    result = helpers.sdk.get_first_result(responses)

    formatted_request = demo_logger.format_json(nym_request.as_dict)
    demo_logger.log_header(step5_info)
    demo_logger.log_blue("Sent NYM request:")
    demo_logger.log_yellow(formatted_request)

    return result
def check_tokens_at_address(helpers, client_address):
    client_utxos = helpers.general.get_utxo_addresses([client_address])[0]
    expected_amount = MINT_TOKEN_AMOUNT - TXN_FEES[NYM_FEES_ALIAS]
    assert client_utxos[0][PAYMENT_ADDRESS] == client_address
    assert client_utxos[0][AMOUNT] == expected_amount

    formatted_utxos = demo_logger.format_json(client_utxos)
    demo_logger.log_header(step6_info)
    demo_logger.log_blue(
        "Client address {} contained utxo:".format(client_address))
    demo_logger.log_yellow(formatted_utxos)
Exemple #3
0
def check_tokens_at_address(helpers, client_address):
    client_utxos = helpers.general.get_utxo_addresses([client_address])[0]
    expected_amount = MINT_TOKEN_AMOUNT - TXN_FEES[NYM]
    assert client_utxos == [{
        ADDRESS: client_address,
        SEQNO: 2,
        AMOUNT: expected_amount
    }]

    formatted_utxos = demo_logger.format_json(client_utxos)
    demo_logger.log_header(step6_info)
    demo_logger.log_blue("Client address {} contained utxo:".format(client_address))
    demo_logger.log_yellow(formatted_utxos)
Exemple #4
0
def check_fee_request_on_ledger(helpers, client_address, nym_result):
    transactions = helpers.node.get_last_ledger_transaction_on_nodes(TOKEN_LEDGER_ID)
    for fee_txn in transactions:
        fee_data = get_payload_data(fee_txn)
        assert fee_data[OUTPUTS] == [{
            ADDRESS: client_address,
            AMOUNT: MINT_TOKEN_AMOUNT - TXN_FEES[NYM]
        }]
        assert fee_data[FEES] == TXN_FEES[NYM]
        assert get_seq_no(fee_txn) == 2

    nym_seq_no = get_seq_no(nym_result)
    helpers.node.assert_deducted_fees(NYM, nym_seq_no, TXN_FEES[NYM])

    formatted_txn = demo_logger.format_json(transactions[0])
    demo_logger.log_header(step7_info)
    demo_logger.log_blue("Fee transaction found on Payment ledger:")
    demo_logger.log_yellow(formatted_txn)
def mint_tokens_to_client(helpers, client_address):
    outputs = [{ADDRESS: client_address, AMOUNT: MINT_TOKEN_AMOUNT}]
    result = helpers.general.do_mint(outputs)
    assert get_payload_data(result)[OUTPUTS][0] == {
        ADDRESS: libsovtoken_address_to_address(client_address),
        AMOUNT: MINT_TOKEN_AMOUNT
    }
    client_utxos = helpers.general.get_utxo_addresses([client_address])[0]
    assert client_utxos[0][PAYMENT_ADDRESS] == client_address
    assert client_utxos[0][AMOUNT] == MINT_TOKEN_AMOUNT

    formatted_utxos = demo_logger.format_json(client_utxos)
    demo_logger.log_header(step4_info)
    demo_logger.log_blue(
        "Minted {} tokens to Client".format(MINT_TOKEN_AMOUNT))
    demo_logger.log_blue(
        "Client address {} contained utxo:".format(client_address))
    demo_logger.log_yellow(formatted_utxos)

    return client_utxos