def identity_implementation(jsonrpc: str, gas: int, gas_price: int, nonce: int, auto_nonce: bool, keystore: str): """Deploy an identity contract without initializing it. Can be used as the implementation for deployed identity proxies. """ web3 = connect_to_json_rpc(jsonrpc) private_key = retrieve_private_key(keystore) nonce = get_nonce(web3=web3, nonce=nonce, auto_nonce=auto_nonce, private_key=private_key) transaction_options = build_transaction_options(gas=gas, gas_price=gas_price, nonce=nonce) identity_implementation = deploy_identity_implementation( web3=web3, transaction_options=transaction_options, private_key=private_key) click.echo("Identity implementation: {}".format( to_checksum_address(identity_implementation.address)))
def identity_implementation(web3): return deploy_identity_implementation(web3=web3)
def test( jsonrpc: str, file: str, gas: int, gas_price: int, nonce: int, auto_nonce: bool, keystore: str, currency_network_contract_name: str, ): """Deploy three test currency network contracts connected to an exchange contract and an unwrapping ether contract. Also deploys an identity proxy factory and a identity implementation contract. This can be used for testing""" expiration_time = 4_102_444_800 # 01/01/2100 network_settings = [ { "name": "Cash", "symbol": "CASH", "decimals": 4, "fee_divisor": 1000, "default_interest_rate": 0, "custom_interests": True, "expiration_time": expiration_time, }, { "name": "Work Hours", "symbol": "HOU", "decimals": 4, "fee_divisor": 0, "default_interest_rate": 1000, "custom_interests": False, "expiration_time": expiration_time, }, { "name": "Beers", "symbol": "BEER", "decimals": 0, "fee_divisor": 0, "custom_interests": False, "expiration_time": expiration_time, }, ] web3 = connect_to_json_rpc(jsonrpc) private_key = retrieve_private_key(keystore) nonce = get_nonce(web3=web3, nonce=nonce, auto_nonce=auto_nonce, private_key=private_key) transaction_options = build_transaction_options(gas=gas, gas_price=gas_price, nonce=nonce) networks, exchange, unw_eth = deploy_networks( web3, network_settings, currency_network_contract_name=currency_network_contract_name, ) identity_implementation = deploy_identity_implementation( web3=web3, transaction_options=transaction_options, private_key=private_key) identity_proxy_factory = deploy_identity_proxy_factory( web3=web3, transaction_options=transaction_options, private_key=private_key) addresses = dict() network_addresses = [network.address for network in networks] exchange_address = exchange.address unw_eth_address = unw_eth.address addresses["networks"] = network_addresses addresses["exchange"] = exchange_address addresses["unwEth"] = unw_eth_address addresses["identityImplementation"] = identity_implementation.address addresses["identityProxyFactory"] = identity_proxy_factory.address if file: with open(file, "w") as outfile: json.dump(addresses, outfile) click.echo("Exchange: {}".format(to_checksum_address(exchange_address))) click.echo("Unwrapping ether: {}".format( to_checksum_address(unw_eth_address))) click.echo("Identity proxy factory: {}".format( to_checksum_address(identity_proxy_factory.address))) click.echo("Identity implementation: {}".format( to_checksum_address(identity_implementation.address))) for settings, address in zip(network_settings, network_addresses): click.echo("CurrencyNetwork({settings}) at {address}".format( settings=settings, address=to_checksum_address(address)))
def test( jsonrpc: str, file: str, gas: int, gas_price: int, nonce: int, keystore: str, currency_network_contract_name: str, ): """Deploy three test currency network contracts connected to an exchange contract and an unwrapping ether contract. Also deploys an identity proxy factory and an identity implementation contract. This can be used for testing""" expiration_time = 4_102_444_800 # 01/01/2100 network_settings = [ NetworkSettings( name="Euro", symbol="EUR", decimals=4, fee_divisor=1000, default_interest_rate=0, custom_interests=True, expiration_time=expiration_time, prevent_mediator_interests=False, ), NetworkSettings( name="Hours", symbol="HOURS", decimals=4, fee_divisor=0, default_interest_rate=1000, custom_interests=False, expiration_time=expiration_time, prevent_mediator_interests=False, ), NetworkSettings( name="Beer", symbol="BEER", decimals=0, fee_divisor=0, default_interest_rate=0, custom_interests=False, expiration_time=expiration_time, prevent_mediator_interests=False, ), ] web3 = connect_to_json_rpc(jsonrpc) private_key = retrieve_private_key(keystore) nonce = get_nonce(web3=web3, nonce=nonce, private_key=private_key) transaction_options = build_transaction_options( gas=gas, gas_price=gas_price, nonce=nonce ) networks, exchange, unw_eth = deploy_networks( web3, network_settings, currency_network_contract_name=currency_network_contract_name, transaction_options=transaction_options, ) identity_implementation = deploy_identity_implementation( web3=web3, transaction_options=transaction_options, private_key=private_key ) second_identity_implementation = deploy_identity_implementation( web3=web3, transaction_options=transaction_options, private_key=private_key ) identity_proxy_factory = deploy_identity_proxy_factory( web3=web3, transaction_options=transaction_options, private_key=private_key ) addresses = dict() network_addresses = [network.address for network in networks] exchange_address = exchange.address unw_eth_address = unw_eth.address addresses["networks"] = network_addresses addresses["exchange"] = exchange_address addresses["unwEth"] = unw_eth_address # TODO: remove address["identityImplementation"], left for backward compatibility addresses["identityImplementation"] = identity_implementation.address addresses["identityProxyFactory"] = identity_proxy_factory.address addresses["identityImplementations"] = [ identity_implementation.address, second_identity_implementation.address, ] if file: with open(file, "w") as outfile: json.dump(addresses, outfile) click.echo("Exchange: {}".format(to_checksum_address(exchange_address))) click.echo("Unwrapping ether: {}".format(to_checksum_address(unw_eth_address))) click.echo( "Identity proxy factory: {}".format( to_checksum_address(identity_proxy_factory.address) ) ) click.echo( "Identity implementations: {} and {}".format( to_checksum_address(identity_implementation.address), to_checksum_address(second_identity_implementation.address), ) ) for settings, address in zip(network_settings, network_addresses): click.echo( "CurrencyNetwork({settings}) at {address}".format( settings=settings, address=to_checksum_address(address) ) )