Esempio n. 1
0
 def test_account_upgrade(self):
     account = Account("init0")
     pprint(account)
     tx = account.upgrade()
     ops = tx["operations"]
     op = ops[0][1]
     self.assertEqual(len(ops), 1)
     self.assertEqual(getOperationNameForId(ops[0][0]), "account_upgrade")
     self.assertTrue(op["upgrade_to_lifetime_member"])
     self.assertEqual(op["account_to_upgrade"], "1.2.100")
Esempio n. 2
0
    def test_unlist(self):
        from deexbase.operations import Account_whitelist

        account = Account("init0")
        tx = account.nolist("committee-account")
        self.assertEqual(len(tx["operations"]), 1)
        self.assertEqual(tx["operations"][0][0], 7)
        self.assertEqual(tx["operations"][0][1]["authorizing_account"],
                         account["id"])
        self.assertEqual(tx["operations"][0][1]["new_listing"],
                         Account_whitelist.no_listing)
Esempio n. 3
0
    def test_openorders(self):
        account = Account("xeroc")
        orders = account.openorders
        self.assertIsInstance(orders, list)

        # If this test fails, it may be that the order expired on-chain!
        #
        # $ uptick sell 100.000 PORNXXX 100000 DEEX --account deex
        #
        for order in orders:
            self.assertIsInstance(order, Order)
            self.assertEqual(order["for_sale"]["symbol"], "TEST")
Esempio n. 4
0
def fixture_data():
    # Clear tx buffer
    deex.clear()

    Account.clear_cache()

    with open(os.path.join(os.path.dirname(__file__), "fixtures.yaml")) as fid:
        data = yaml.safe_load(fid)

    for account in data.get("accounts"):
        Account.cache_object(account, account["id"])
        Account.cache_object(account, account["name"])

    for asset in data.get("assets"):
        Asset.cache_object(asset, asset["symbol"])
        Asset.cache_object(asset, asset["id"])

    proposals = []
    for proposal in data.get("proposals", []):
        ops = []
        for _op in proposal["operations"]:
            for opName, op in _op.items():
                ops.append([operations[opName], op])
        # Proposal!
        proposal_id = proposal["proposal_id"]
        proposal_data = {
            "available_active_approvals": [],
            "available_key_approvals": [],
            "available_owner_approvals": [],
            "expiration_time": "2018-05-29T10:23:13",
            "id": proposal_id,
            "proposed_transaction": {
                "expiration": "2018-05-29T10:23:13",
                "extensions": [],
                "operations": ops,
                "ref_block_num": 0,
                "ref_block_prefix": 0,
            },
            "proposer": "1.2.7",
            "required_active_approvals": ["1.2.1"],
            "required_owner_approvals": [],
        }
        proposals.append(Proposal(proposal_data))

    Proposals.cache_objects(proposals, "1.2.1")
    Proposals.cache_objects(proposals, "witness-account")
Esempio n. 5
0
from deexbase import transactions, memo, account, operations, objects
from deexbase.objects import Operation
from deexbase.signedtransactions import Signed_Transaction

from deex.transactionbuilder import TransactionBuilder
from deexbase.operations import Transfer

from deex import DeEx, storage
from deex.instance import set_shared_blockchain_instance
from deex.account import Account

from deexbase.memo import (
    get_shared_secret,
    _pad,
    _unpad,
    encode_memo,
    decode_memo
)

deex = DeEx(
    ["wss://node4p.deexnet.com/ws"]
)
set_shared_blockchain_instance(deex)



account = Account("--your-account-login--", full=True)
print(account['id'])
print(account.balance("1.3.0"))

Esempio n. 6
0
import os
from pprint import pprint
from itertools import cycle
from deexbase.account import BrainKey, Address, PublicKey, PrivateKey
from deexbase import transactions, memo, account, operations, objects
from deexbase.objects import Operation
from deexbase.signedtransactions import Signed_Transaction

from deex.transactionbuilder import TransactionBuilder
from deexbase.operations import Transfer

from deex import DeEx, storage
from deex.instance import set_shared_blockchain_instance
from deex.account import Account

from deexbase.memo import (get_shared_secret, _pad, _unpad, encode_memo,
                           decode_memo)

deex = DeEx(["wss://node4p.deexnet.com/ws"])
set_shared_blockchain_instance(deex)

account = Account("test", full=True)
result = account.history(first="1.11.1", limit=100, only_ops=['transfer'])
for _ in result:
    print(_)

# Read operations for account.
# Parameter first = show operations more then ID. Used for filtering result.
# Parameter limit: How many results will be displayed. MAX 100.
# only_ops Filtering by data type.
Esempio n. 7
0
 def test_calls(self):
     account = Account("init0")
     self.assertIsInstance(account.callpositions, dict)
Esempio n. 8
0
    def test_account(self):
        Account("init0")
        Account("1.2.3")
        account = Account("init0", full=True)
        self.assertEqual(account.name, "init0")
        self.assertEqual(account["name"], account.name)
        self.assertEqual(account["id"], "1.2.100")
        self.assertIsInstance(account.balance("1.3.0"), Amount)
        # self.assertIsInstance(account.balance({"symbol": symbol}), Amount)
        self.assertIsInstance(account.balances, list)
        for _ 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.100")
        self.assertTrue(str(account).startswith("<Account "))
        self.assertIsInstance(Account(account), Account)
Esempio n. 9
0
 def test_create_asset(self):
     symbol = "FOOBAR"
     precision = 7
     max_supply = 100000
     description = "Test asset"
     is_bitasset = True
     market_fee_percent = 0.1
     max_market_fee = 10
     blacklist_authorities = ["init1"]
     blacklist_authorities_ids = [
         Account(a)["id"] for a in blacklist_authorities
     ]
     blacklist_markets = ["DX"]
     blacklist_markets_ids = ["1.3.0"]
     permissions = {
         "charge_market_fee": True,
         "white_list": True,
         "override_authority": True,
         "transfer_restricted": True,
         "disable_force_settle": True,
         "global_settle": True,
         "disable_confidential": True,
         "witness_fed_asset": True,
         "committee_fed_asset": True,
     }
     flags = {
         "charge_market_fee": False,
         "white_list": False,
         "override_authority": False,
         "transfer_restricted": False,
         "disable_force_settle": False,
         "global_settle": False,
         "disable_confidential": False,
         "witness_fed_asset": False,
         "committee_fed_asset": False,
     }
     tx = deex.create_asset(
         symbol,
         precision,
         max_supply,
         market_fee_percent=market_fee_percent,
         max_market_fee=max_market_fee,
         description=description,
         is_bitasset=is_bitasset,
         blacklist_authorities=blacklist_authorities,
         blacklist_markets=blacklist_markets,
         permissions=permissions,
         flags=flags,
     )
     self.assertEqual(getOperationNameForId(tx["operations"][0][0]),
                      "asset_create")
     op = tx["operations"][0][1]
     self.assertEqual(op["issuer"], "1.2.100")
     self.assertEqual(op["symbol"], symbol)
     self.assertEqual(op["precision"], precision)
     self.assertEqual(op["common_options"]["max_supply"],
                      int(max_supply * 10**precision))
     self.assertEqual(op["common_options"]["market_fee_percent"],
                      int(market_fee_percent * 100))
     self.assertEqual(
         op["common_options"]["max_market_fee"],
         int(max_market_fee * 10**precision),
     )
     self.assertEqual(op["common_options"]["description"], description)
     self.assertEqual(op["common_options"]["blacklist_authorities"],
                      blacklist_authorities_ids)
     self.assertEqual(op["common_options"]["blacklist_markets"],
                      blacklist_markets_ids)
     self.assertEqual(todict(op["common_options"]["issuer_permissions"]),
                      permissions)
     self.assertEqual(todict(op["common_options"]["flags"]), flags)