def walletclient(): """ Provide a `WalletClient`, connected to `$WALLETSERVER`. """ walletserver = os.getenv("WALLETSERVER") assert walletserver is not None and walletserver != "" return vac.WalletClient(walletserver)
wallet_passphrase = os.getenv("WALLET_PASSPHRASE") if not helpers.check_var(wallet_passphrase): print("Error: Invalid or missing WALLET_PASSPHRASE environment variable.") exit(1) # Help guide users against including api version suffix on url wallet_server_url = helpers.check_wallet_url(wallet_server_url) # __import_client: import vegaapiclient as vac # Vega gRPC clients for reading/writing data data_client = vac.VegaTradingDataClient(node_url_grpc) trading_client = vac.VegaTradingClient(node_url_grpc) wallet_client = vac.WalletClient(wallet_server_url) # :import_client__ ##################################################################################### # W A L L E T S E R V I C E # ##################################################################################### print(f"Logging into wallet: {wallet_name}") # __login_wallet: # Log in to an existing wallet response = wallet_client.login(wallet_name, wallet_passphrase) helpers.check_response(response) # Note: secret wallet token is stored internally for duration of session # :login_wallet__
if wallet_passphrase is None or not helpers.check_var(wallet_passphrase): print("Error: Invalid or missing WALLET_PASSPHRASE environment variable.") exit(1) # Help guide users against including api version suffix on url walletserver_url = helpers.check_wallet_url(walletserver_url) # __create_wallet: # Vega node: Create client for accessing public data datacli = vac.VegaTradingDataClient(node_url_grpc) # Vega node: Create client for trading (e.g. submitting orders) tradingcli = vac.VegaTradingClient(node_url_grpc) # Wallet server: Create a walletclient (see above for details) walletclient = vac.WalletClient(walletserver_url) login_response = walletclient.login(wallet_name, wallet_passphrase) # :create_wallet__ helpers.check_response(login_response) # __get_market: # Get a list of markets markets = datacli.Markets(vac.api.trading.MarketsRequest()).markets marketID = markets[0].id # :get_market__ # __generate_keypair: GENERATE_NEW_KEYPAIR = False if GENERATE_NEW_KEYPAIR: # If you don't already have a keypair, generate one. response = walletclient.generatekey(wallet_passphrase, [])