Esempio n. 1
0
def find_vote(deck_id, vote_id):
    deck = find_deck(deck_id)
    for vote in pa.find_vote_inits(provider, deck):
        print(vote, vote.vote_id)
        if vote.vote_id == vote_id:
            return vote
    throw("Vote not found.")
Esempio n. 2
0
def info(deck_id):
    '''show detail information about <vote> on the <deck>'''

    deck = find_deck(deck_id)

    for i in pa.find_vote_inits(provider, deck):
        if i.vote_id == args[1]:
            vote = i

    vote.deck = vote.deck.asset_id
    print("\n", vote.__dict__)
Esempio n. 3
0
def export(deck_id, filename):
    ''' export cards to csv <filename> '''

    deck = find_deck(deck_id)

    if not provider.getaddressesbyaccount(deck.asset_id):
        throw("You must subscribe to deck to be able to list transactions.")

    all_cards = pa.find_card_transfers(provider, deck)
    cards = pa.validate_card_issue_modes(deck, all_cards)

    export_to_csv(cards, filename)
Esempio n. 4
0
def burn(burn_order, broadcast):
    '''
    Burn cards of this deck.

    pacli card burn <deck_id> amount_one, amount_two...
    '''

    deck = find_deck(burn_order['deck'])
    amounts = [
        amount_to_exponent(float(i), deck.number_of_decimals)
        for i in burn_order['amounts']
    ]
    transfer_cards(deck, [deck.issuer], amounts, broadcast)
Esempio n. 5
0
def new(deck_id, vote_json, broadcast):
    '''
    Initialize new vote on the <deck>

    pacli vote new <deck> '{"choices": ["y", "n"], "count_mode": "SIMPLE",
    "description": "test", "start_block": int, "end_block": int}'
    '''
    deck = find_deck(deck_id)
    vote_order = json.loads(vote_json)

    inputs = provider.select_inputs(0.02)
    change_address = change(inputs)
    vote = pa.Vote(version=1, deck=deck, **vote_order)

    handle_transaction(pa.vote_init(vote, inputs, change_address), broadcast)
Esempio n. 6
0
def transfer(transfer_order, broadcast):
    '''
    Transfer cards to <receivers>

    pacli card -transfer '{"deck": "deck_id",
                        "receivers": [list of receiver addresses], "amounts": [list of amounts]
                        }
    '''

    deck = find_deck(transfer_order["deck"])
    transfer_order["amount"] = [
        amount_to_exponent(float(i), deck.number_of_decimals)
        for i in transfer_order["amount"]
    ]
    transfer_cards(deck, transfer_order["receiver"], transfer_order["amount"],
                   broadcast)
Esempio n. 7
0
def list(deck_id):
    '''List cards of this <deck>'''
    deck = find_deck(deck_id)

    if isinstance(provider, pa.RpcNode):
        if not provider.getaddressesbyaccount(deck.asset_id):
            print(
                "\n", {
                    "error":
                    "You must subscribe to deck to be able to list transactions."
                })
            return
    all_cards = pa.find_card_transfers(provider, deck)

    if not all_cards:
        print("\n", "No cards have been issued for deck %s" % deck.asset_id)
        return

    cards = pa.validate_card_issue_modes(deck, all_cards)
    print_card_list(cards)
Esempio n. 8
0
def issue(issuence, broadcast):
    '''
    Issue new cards of this deck.

    pacli card issue '{"deck": "deck_id",
                        "receivers": [list of receiver addresses],
                        "amounts": [list of amounts]
                        }
    '''

    deck = find_deck(issuence["deck"])

    if not provider.gettransaction(deck.asset_id)["confirmations"] > 0:
        print(
            "\n",
            "You are trying to issue cards on a deck which has not been confirmed yet."
        )

    if provider.validateaddress(deck.issuer)["ismine"]:
        try:
            utxo = provider.select_inputs(0.02, deck.issuer)
        except ValueError:
            throw("Please send funds to the deck issuing address: {0}".format(
                deck.issuer))
    else:
        raise throw("You are not the owner of this deck.")

    receivers = issuence["receivers"]
    amounts = [
        amount_to_exponent(float(i), deck.number_of_decimals)
        for i in issuence["amounts"]
    ]

    change_address = change(utxo)
    ct = pa.CardTransfer(deck=deck, receiver=receivers, amount=amounts)
    handle_transaction(pa.card_issue(deck, ct, utxo, change_address),
                       broadcast)
Esempio n. 9
0
def list(deck_id):
    '''list all votes on the <deck>'''
    votes = pa.find_vote_inits(provider, find_deck(deck_id))
    print_vote_list(votes)