Exemplo n.º 1
0
def make_info(name, private_key_name):
    # assume that this account has ETH with gas.
    class _Info:
        pass

    info = _Info()
    web3 = get_web3()

    info.web3 = web3

    info.private_key = os.environ.get(private_key_name)
    info.wallet = Wallet(web3, private_key=info.private_key)
    info.address = info.wallet.address
    info.account = Account(private_key=info.private_key)
    wallet = get_ganache_wallet()
    if wallet:
        assert Web3Helper.from_wei(Web3Helper.get_ether_balance(wallet.address)) > 4
        if Web3Helper.from_wei(Web3Helper.get_ether_balance(info.address)) < 2:
            Web3Helper.send_ether(wallet, info.address, 4)

    from ocean_lib.ocean.ocean import Ocean
    info.ocean = Ocean()
    info.T1 = _deployAndMintToken('TOK1', info.address)
    info.T2 = _deployAndMintToken('TOK2', info.address)

    return info
Exemplo n.º 2
0
def setup_all():
    config = ExampleConfig.get_config()
    ConfigProvider.set_config(config)
    Web3Provider.init_web3(
        provider=get_web3_connection_provider(config.network_url))
    ContractHandler.set_artifacts_path(config.artifacts_path)

    network = Web3Helper.get_network_name()
    wallet = get_ganache_wallet()
    if network in ["ganache", "development"] and wallet:

        print(
            f"sender: {wallet.key}, {wallet.address}, {wallet.password}, {wallet.keysStr()}"
        )
        print(
            f"sender balance: {Web3Helper.from_wei(Web3Helper.get_ether_balance(wallet.address))}"
        )
        assert Web3Helper.from_wei(Web3Helper.get_ether_balance(
            wallet.address)) > 10

        from ocean_lib.models.data_token import DataToken

        OCEAN_token = DataToken(get_ocean_token_address(network))
        amt_distribute = 1000
        amt_distribute_base = to_base_18(float(amt_distribute))
        for w in (get_publisher_wallet(), get_consumer_wallet()):
            if Web3Helper.from_wei(Web3Helper.get_ether_balance(
                    w.address)) < 2:
                Web3Helper.send_ether(wallet, w.address, 4)

            if OCEAN_token.token_balance(w.address) < 100:
                OCEAN_token.transfer(w.address,
                                     amt_distribute_base,
                                     from_wallet=wallet)