Beispiel #1
0
 def test_asset_create(self):
     self.op = operations.Asset_create(
         **{
             "fee": {
                 "amount": 0,
                 "asset_id": "1.3.0"
             },
             "issuer": "1.2.0",
             "symbol": "THING",
             "precision": 0,
             "common_options": {
                 "max_supply": "1000000000000000",
                 "market_fee_percent": 0,
                 "max_market_fee": "1000000000000000",
                 "issuer_permissions": 79,
                 "flags": 0,
                 "core_exchange_rate": {
                     "base": {
                         "amount": 0,
                         "asset_id": "1.3.0"
                     },
                     "quote": {
                         "amount": 0,
                         "asset_id": "1.3.0"
                     },
                 },
                 "whitelist_authorities": ["1.2.0"],
                 "blacklist_authorities": ["1.2.1"],
                 "whitelist_markets": ["1.3.0"],
                 "blacklist_markets": ["1.3.1"],
                 "description": "Foobar think",
                 "extensions": [],
             },
             "bitasset_opts": {
                 "feed_lifetime_sec": 86400,
                 "minimum_feeds": 7,
                 "force_settlement_delay_sec": 86400,
                 "force_settlement_offset_percent": 100,
                 "maximum_force_settlement_volume": 50,
                 "short_backing_asset": "1.3.0",
                 "extensions": [],
             },
             "is_prediction_market": False,
             "extensions": [],
         })
     self.cm = ("f68585abf4dce7c80457010a000000000000000000000554484"
                "94e47000080c6a47e8d030000000080c6a47e8d03004f000000"
                "000000000000000000000000000000000000010001010100010"
                "10c466f6f626172207468696e6b000180510100078051010064"
                "0032000000000000011f1b8ac491bb327921d9346d543e530d8"
                "8acb68bade58296a7a27b0a74a28eaca762260dbb905a6415f6"
                "225a8028a810de6290badc29d16fea0ffd88bc8c0cbec4")
     self.doit()
Beispiel #2
0
def create_asset(inst,
                 symbol,
                 precision,
                 is_prediction_market=False,
                 account=None,
                 **kwargs):
    """ create_asset
   """
    key = {}
    perm = {}
    perm["charge_market_fee"] = 0x01
    perm["white_list"] = 0x02
    perm["override_authority"] = 0x04
    perm["transfer_restricted"] = 0x08
    perm["disable_force_settle"] = 0x10
    perm["global_settle"] = 0x20
    perm["disable_confidential"] = 0x40
    perm["witness_fed_asset"] = 0x80
    perm["committee_fed_asset"] = 0x100

    permissions = {
        "charge_market_fee": False,
        "white_list": True,
        "override_authority": True,
        "transfer_restricted": True,
        "disable_force_settle": False,
        "global_settle": True,
        "disable_confidential": True,
        "witness_fed_asset": False,
        "committee_fed_asset": False,
    }
    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,
    }
    permissions_int = 0
    for p in permissions:
        if permissions[p]:
            permissions_int += perm[p]
    flags_int = 0
    for p in permissions:
        if flags[p]:
            flags_int += perm[p]

    extension = []
    options = {
        "max_supply": 1000000000000000,
        "market_fee_percent": 0,
        "max_market_fee": 0,
        "issuer_permissions": permissions_int,
        "flags": flags_int,
        "precision": precision,
        "core_exchange_rate": {
            "base": {
                "amount": 10,
                "asset_id": "1.3.0"
            },
            "quote": {
                "amount": 10,
                "asset_id": "1.3.1"
            }
        },
        "whitelist_authorities": [],
        "blacklist_authorities": [],
        "whitelist_markets": [],
        "blacklist_markets": [],
        "description": "My fancy description",
        "extensions": extension
    }

    if not account:
        if "default_account" in inst.config:
            account = inst.config["default_account"]
    if not account:
        raise ValueError("You need to provide an account")
    account = Account(account)

    if 'common_options' in kwargs:
        common_options = kwargs['common_options']
    else:
        common_options = options

    if 'bitasset_options' in kwargs:
        bitasset_options = kwargs['bitasset_options']
    else:
        bitasset_options = None

    kwargs = {
        'fee': {
            "amount": 0,
            "asset_id": "1.3.0"
        },
        'issuer': account["id"],
        'symbol': symbol,
        'precision': precision,
        'common_options': common_options,
        'is_prediction_market': is_prediction_market
    }
    if bitasset_options:
        kwargs['bitasset_opts'] = bitasset_options

    op = operations.Asset_create(**kwargs)

    return inst.finalizeOp(op, account, "active")