コード例 #1
0
def history(ctx, account, limit, type, csv, exclude, raw):
    """ Show history of an account
    """
    from peerplaysbase.operations import getOperationNameForId
    header = ["#", "time (block)", "operation", "details"]
    if csv:
        import csv
        t = csv.writer(sys.stdout, delimiter=";")
        t.writerow(header)
    else:
        t = PrettyTable(header)
        t.align = "r"
        t.align["details"] = "l"

    for a in account:
        account = Account(a, peerplays_instance=ctx.peerplays)
        for b in account.history(limit=limit,
                                 only_ops=type,
                                 exclude_ops=exclude):
            row = [
                b["id"].split(".")[2],
                "%s" % (b["block_num"]),
                "{} ({})".format(getOperationNameForId(b["op"][0]),
                                 b["op"][0]),
                pprintOperation(b) if not raw else json.dumps(b, indent=4),
            ]
            if csv:
                t.writerow(row)
            else:
                t.add_row(row)
    if not csv:
        click.echo(t)
コード例 #2
0
def getResolutions(bettor_id, bmg_id=None):
    a = Account(bettor_id, peerplays_instance=ppy, full=True)
    history = []
    for line in a.history(
            limit=1000):  # sufficiently large to get all resolutions
        if line['op'][0] == 64:
            if bmg_id is not None:
                if line['op'][1]['betting_market_group_id'] == bmg_id:
                    history.append(line)
            else:
                history.append(line)
    return history
コード例 #3
0
    def test_account(self):
        Account("witness-account")
        Account("1.2.3")
        asset = Asset("1.3.0")
        symbol = asset["symbol"]
        account = Account("witness-account", full=True)
        self.assertEqual(account.name, "witness-account")
        self.assertEqual(account["name"], account.name)
        self.assertEqual(account["id"], "1.2.1")
        self.assertIsInstance(account.balance("1.3.0"), Amount)
        self.assertIsInstance(account.balance({"symbol": symbol}), Amount)
        self.assertIsInstance(account.balances, list)
        for h in account.history(limit=1):
            pass

        # BlockchainObjects method
        account.cached = False
        self.assertTrue(account.items())
        account.cached = False
        self.assertIn("id", account)
        account.cached = False
        self.assertEqual(account["id"], "1.2.1")
        self.assertEqual(str(account), "<Account 1.2.1>")
        self.assertIsInstance(Account(account), Account)
コード例 #4
0
def getHistory(bettor_id, limit=10):
    a = Account(bettor_id, peerplays_instance=ppy, full=True)
    history = []
    for line in a.history(limit=limit):
        history.append(line)
    return history