def update(config: BoardCommmadConfiguration): """Update transaction status. Connects to Ethereum network, queries the status of our broadcasted transactions. Then print outs the still currently pending transactions or freshly mined transactions. """ assert is_ethereum_network(config.network) logger = config.logger from sto.ethereum.status import update_status dbsession = config.dbsession txs = update_status(logger, dbsession, config.network, ethereum_node_url=config.ethereum_node_url, ethereum_private_key=config.ethereum_private_key, ethereum_gas_limit=config.ethereum_gas_limit, ethereum_gas_price=config.ethereum_gas_price) if txs: from sto.ethereum.txservice import EthereumStoredTXService EthereumStoredTXService.print_transactions(txs) # Write database dbsession.commit()
def update(config: BoardCommmadConfiguration): """Update transaction status.""" assert is_ethereum_network(config.network) logger = config.logger from sto.ethereum.status import update_status dbsession = config.dbsession txs = update_status(logger, dbsession, config.network, ethereum_node_url=config.ethereum_node_url, ethereum_private_key=config.ethereum_private_key, ethereum_gas_limit=config.ethereum_gas_limit, ethereum_gas_price=config.ethereum_gas_price) if txs: from sto.ethereum.txservice import EthereumStoredTXService EthereumStoredTXService.print_transactions(txs) # Write database dbsession.commit()
def scanned_distribution(logger, dbsession, web3, private_key_hex, sample_csv_file, sample_token): """Create some sample transactions so we can scan the token holder balances.""" token_address = sample_token entries = read_csv(logger, sample_csv_file) new_distributes, old_distributes = distribute_tokens(logger, dbsession, "testing", web3, ethereum_abi_file=None, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, token_address=token_address, dists=entries) assert new_distributes == 2 assert old_distributes == 0 # Check they got mined # Send transactions to emphmereal test chain txs = broadcast(logger, dbsession, "testing", web3, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, ) # Check they got mined txs = update_status(logger, dbsession, "testing", web3, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, ) # Check that rerun does not recreate txs new_distributes, old_distributes = distribute_tokens(logger, dbsession, "testing", web3, ethereum_abi_file=None, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, token_address=token_address, dists=entries) assert new_distributes == 0 assert old_distributes == 2 token_scan(logger, dbsession, "testing", web3, None, token_address) return token_address
def test_issuance(logger, dbsession, web3, private_key_hex): """Walk through issuance process from top to bottom""" # Creating transactions txs = deploy_token_contracts(logger, dbsession, "testing", web3, ethereum_abi_file=None, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, name="Moo Corp", symbol="MOO", amount=9999, transfer_restriction="unrestricted") assert len(txs) == 5 # Send transactions to emphmereal test chain txs = broadcast(logger, dbsession, "testing", web3, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, ) assert len(txs) == 5 # Check they got mined txs = update_status(logger, dbsession, "testing", web3, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, ) assert len(txs) == 5 for tx in txs: # type: PreparedTransaction assert tx.result_transaction_success token_address = txs[0].contract_address # Check that we can view the token status status = contract_status(logger, dbsession, "testing", web3, ethereum_abi_file=None, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, token_contract=token_address, ) assert status["name"] == "Moo Corp" assert status["totalSupply"] == 9999 * 10**18
def test_distribute(logger, dbsession, web3, private_key_hex, sample_csv_file): """Distribute tokens.""" # Creating transactions txs = deploy_token_contracts( logger, dbsession, "testing", web3, ethereum_abi_file=None, ethereum_private_key=private_key_hex, ethereum_gas_limit=99999999, ethereum_gas_price=None, name="Moo Corp", symbol="MOO", url="https://tokenmarket.net", amount=9999, transfer_restriction="unrestricted" ) token_address = txs[0].contract_address # Deploy contract transactions to emphmereal test chain broadcast( logger, dbsession, "testing", web3, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, ) # Check that we can view the token status status = contract_status( logger, dbsession, "testing", web3, ethereum_abi_file=None, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, token_contract=token_address, ) assert status["name"] == "Moo Corp" assert status["totalSupply"] == 9999 * 10 ** 18 entries = read_csv(logger, sample_csv_file) new_distributes, old_distributes = distribute_tokens( logger, dbsession, "testing", web3, ethereum_abi_file=None, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, token_address=token_address, dists=entries ) assert new_distributes == 2 assert old_distributes == 0 # Check they got mined # Send transactions to emphmereal test chain txs = broadcast( logger, dbsession, "testing", web3, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, ) # Check they got mined txs = update_status( logger, dbsession, "testing", web3, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, ) assert len(txs) == 6 for tx in txs: # type: PreparedTransaction assert tx.result_transaction_success # Check that rerun does not recreate txs new_distributes, old_distributes = distribute_tokens( logger, dbsession, "testing", web3, ethereum_abi_file=None, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, token_address=token_address, dists=entries ) assert new_distributes == 0 assert old_distributes == 2
def scanned_distribution(logger, dbsession, web3, private_key_hex, sample_csv_file, sample_token, click_runner, db_path, monkeypatch_create_web3): """Create some sample transactions so we can scan the token holder balances.""" token_address = sample_token entries = read_csv(logger, sample_csv_file) for entry in entries: # whitelist customers result = click_runner.invoke(cli, [ '--database-file', db_path, '--ethereum-private-key', private_key_hex, '--ethereum-gas-limit', 999999999, 'kyc-manage', '--whitelist-address', entry.address ]) assert result.exit_code == 0 result = click_runner.invoke(cli, [ '--database-file', db_path, '--ethereum-private-key', private_key_hex, '--ethereum-gas-limit', 999999999, "distribute-multiple", '--csv-input', sample_csv_file, '--address', token_address ]) assert result.exit_code == 0 result = click_runner.invoke(cli, [ '--database-file', db_path, '--ethereum-private-key', private_key_hex, '--ethereum-gas-limit', 999999999, 'tx-broadcast', ]) assert result.exit_code == 0 # Check they got mined # Send transactions to emphmereal test chain result = click_runner.invoke(cli, [ '--database-file', db_path, '--ethereum-private-key', private_key_hex, '--ethereum-gas-limit', 999999999, 'tx-broadcast', ]) assert result.exit_code == 0 # Check they got mined txs = update_status( logger, dbsession, "testing", web3, ethereum_private_key=private_key_hex, ethereum_gas_limit=None, ethereum_gas_price=None, ) # Check that rerun does not recreate txs result = click_runner.invoke(cli, [ '--database-file', db_path, '--ethereum-private-key', private_key_hex, '--ethereum-gas-limit', 999999999, "distribute-multiple", '--csv-input', sample_csv_file, '--address', token_address ]) assert result.exit_code == 0 result = click_runner.invoke(cli, [ '--database-file', db_path, '--ethereum-private-key', private_key_hex, '--ethereum-gas-limit', 999999999, 'tx-broadcast', ]) assert result.exit_code == 0 token_scan(logger, dbsession, "testing", web3, None, token_address) return token_address