def create_token_asset(dbsession, eth_service, eth_network_id, name, symbol, supply, wait=True) -> UUID: """Create a token in the network and assigns it to coinbase address.""" with transaction.manager: network = dbsession.query(AssetNetwork).get(eth_network_id) asset = network.create_asset(name=name, symbol=symbol, supply=Decimal(10000), asset_class=AssetClass.token) address = get_house_address(network) op = address.create_token(asset) opid = op.id aid = asset.id # This gives op a txid success, fails = eth_service.run_waiting_operations() assert success > 0 assert fails == 0 if wait: wait_for_op_confirmations(eth_service, opid) return aid
def setup_house(request): """Setup different networks supported by the instance. Setup house wallets on each network. Setup ETH giveaway on testnet and private testnet. """ dbsession = request.dbsession services = ServiceCore.parse_network_config(request) networks = services.keys() for network_name in networks: print("Setting up house wallet on ", network_name) network = get_eth_network(dbsession, network_name) assert is_network_alive(network), "Network was dead when we started to create address {}".format(network) dbsession.flush() house_address = get_house_address(network) if not house_address: create_house_address(network) if not "initial_assets" in network.other_data: network.other_data["initial_assets"] = {} if network_name == "testnet": network.other_data["human_friendly_name"] = "Ethereum Testnet" # Setup testnet ETH give away if network_name in ("testnet", "private testnet"): network.other_data["initial_assets"]["eth_amount"] = "5.0"
def setup_toybox(request): """Setup TOYBOX asset for testing.""" print("Setting up TOYBOX asset") dbsession = request.dbsession network = get_eth_network(dbsession, "testnet") toybox = get_toy_box(network) if toybox: return # Roll out toybox contract asset = create_token(network, "Toybox", "TOYBOX", 10222333, get_house_address(network)) # setup toybox give away data for primary network network.other_data["initial_assets"]["toybox"] = str(asset.id) network.other_data["initial_assets"]["toybox_amount"] = 50