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
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)
def setup_all(): setup_network() web3 = Web3Provider.get_web3() if web3.eth.accounts and web3.eth.accounts[0].lower( ) == '0xe2DD09d719Da89e5a3D0F2549c7E24566e947260'.lower(): wallet = Wallet( web3, private_key= '0xc594c6e5def4bab63ac29eed19a134c130388f74f019bc74b8f4389df2837a58' ) provider = get_provider_wallet() if web3.fromWei(Web3Helper.get_ether_balance(provider.address), 'ether') < 10: Web3Helper.send_ether(wallet, provider.address, 25) consumer = get_consumer_wallet() if web3.fromWei(Web3Helper.get_ether_balance(consumer.address), 'ether') < 10: Web3Helper.send_ether(wallet, consumer.address, 25)
def setup_all(): setup_network() web3 = Web3Provider.get_web3() if ( web3.eth.accounts and web3.eth.accounts[0].lower() == "0xe2DD09d719Da89e5a3D0F2549c7E24566e947260".lower() ): wallet = Wallet( web3, private_key="0xfd5c1ccea015b6d663618850824154a3b3fb2882c46cefb05b9a93fea8c3d215", ) provider = get_provider_wallet() if web3.fromWei(Web3Helper.get_ether_balance(provider.address), "ether") < 10: Web3Helper.send_ether(wallet, provider.address, 25) consumer = get_consumer_wallet() if web3.fromWei(Web3Helper.get_ether_balance(consumer.address), "ether") < 10: Web3Helper.send_ether(wallet, consumer.address, 25)