private void InitData() { var httpClient = new HttpClient(); var urls = new[] { DefaultUrl }; var jsonRpcClientProxy = new JsonRpcClientProxy(new DefaultHttpClient(httpClient, new EthereumJsonSerializer(), LimboLogs.Instance, 0), urls, LimboLogs.Instance); _ethJsonRpcClientProxy = new EthJsonRpcClientProxy(jsonRpcClientProxy); }
static async Task Main(string[] args) { Application.Init(); var addressesModule = new AddressesModule(); addressesModule.AddressesSelected += async(_, data) => { var urls = new[] { data.nodeAddress }; var httpClient = new HttpClient(); AddAuthorizationHeader(httpClient, data.nodeAddress); var jsonRpcClientProxy = new JsonRpcClientProxy(new DefaultHttpClient(httpClient, new EthereumJsonSerializer(), LimboLogs.Instance, int.MaxValue), urls, LimboLogs.Instance); var jsonRpcWalletClientProxy = new JsonRpcWalletClientProxy(jsonRpcClientProxy); var ethJsonRpcClientProxy = new EthJsonRpcClientProxy(jsonRpcClientProxy); var dataModule = new DataModule(ethJsonRpcClientProxy, data.address); dataModule.TransferClicked += async(_, e) => { var transferModule = new TransferModule(ethJsonRpcClientProxy, jsonRpcWalletClientProxy, e.Address, e.Balance); var transferWindow = await transferModule.InitAsync(); Application.Top.Add(transferWindow); Application.Run(transferWindow); }; var dataWindow = await dataModule.InitAsync(); Application.Top.Add(dataWindow); Application.Run(dataWindow); }; Application.Top.Add(await addressesModule.InitAsync()); Application.Run(); }
public INdmServices Init(NdmRequiredServices services) { AddDecoders(); var config = services.NdmConfig; var providerAddress = string.IsNullOrWhiteSpace(config.ProviderAddress) ? Address.Zero : new Address(config.ProviderAddress); var consumerAddress = string.IsNullOrWhiteSpace(config.ConsumerAddress) ? Address.Zero : new Address(config.ConsumerAddress); var contractAddress = string.IsNullOrWhiteSpace(config.ContractAddress) ? Address.Zero : new Address(config.ContractAddress); UnlockHardcodedAccounts(providerAddress, consumerAddress, services.Wallet); var logManager = services.LogManager; var jsonSerializer = services.JsonSerializer; var readOnlyTree = new ReadOnlyBlockTree(services.BlockTree); var readOnlyDbProvider = new ReadOnlyDbProvider(services.RocksProvider, false); var readOnlyTxProcessingEnv = new ReadOnlyTxProcessingEnv(readOnlyDbProvider, readOnlyTree, services.SpecProvider, logManager); var blockchainBridge = new BlockchainBridge( readOnlyTxProcessingEnv.StateReader, readOnlyTxProcessingEnv.StateProvider, readOnlyTxProcessingEnv.StorageProvider, readOnlyTxProcessingEnv.BlockTree, services.TransactionPool, services.ReceiptStorage, services.FilterStore, services.FilterManager, services.Wallet, readOnlyTxProcessingEnv.TransactionProcessor, services.Ecdsa); var dataAssetRlpDecoder = new DataAssetDecoder(); var encoder = new AbiEncoder(); IEthJsonRpcClientProxy ethJsonRpcClientProxy = null; INdmBlockchainBridge ndmBlockchainBridge; if (config.ProxyEnabled) { ethJsonRpcClientProxy = new EthJsonRpcClientProxy(new JsonRpcClientProxy( new DefaultHttpClient(new HttpClient(), jsonSerializer, logManager), config.JsonRpcUrlProxies)); ndmBlockchainBridge = new NdmBlockchainBridgeProxy(ethJsonRpcClientProxy); } else { ndmBlockchainBridge = new NdmBlockchainBridge(blockchainBridge, services.TransactionPool); } var depositService = new DepositService(ndmBlockchainBridge, services.TransactionPool, encoder, services.Wallet, contractAddress, logManager); var ndmConsumerChannelManager = services.NdmConsumerChannelManager; var ndmDataPublisher = services.NdmDataPublisher; var jsonRpcNdmConsumerChannel = new JsonRpcNdmConsumerChannel(); // ndmConsumerChannelManager.Add(jsonRpcNdmConsumerChannel); return(new Services(services, new NdmCreatedServices(consumerAddress, encoder, dataAssetRlpDecoder, depositService, ndmDataPublisher, jsonRpcNdmConsumerChannel, ndmConsumerChannelManager, ndmBlockchainBridge, ethJsonRpcClientProxy))); }
static async Task Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += (_, e) => { Application.Top.Running = false; Application.RequestStop(); Application.Shutdown(); Console.WriteLine($"There was an error.{Environment.NewLine}{e.ExceptionObject}"); }; Application.Init(); var httpClient = new HttpClient(); var urls = new[] { DefaultUrl }; var jsonRpcClientProxyMaxRetries = new JsonRpcClientProxy(new DefaultHttpClient(httpClient, new EthereumJsonSerializer(), LimboLogs.Instance, int.MaxValue), urls, LimboLogs.Instance); var ethJsonRpcClientProxyMaxRetries = new EthJsonRpcClientProxy(jsonRpcClientProxyMaxRetries); var jsonRpcWalletClientProxyMaxRetries = new JsonRpcWalletClientProxy(jsonRpcClientProxyMaxRetries); var runnerValidator = new RunnerValidator(httpClient, DefaultUrl); var networkModule = new NetworkModule(); networkModule.NetworkSelected += async(_, network) => { var initModule = new InitModule(ethJsonRpcClientProxyMaxRetries, runnerValidator, network); initModule.OptionSelected += async(_, optionInfo) => { var addressesModule = new AddressesModule(optionInfo, jsonRpcWalletClientProxyMaxRetries); addressesModule.AddressesSelected += async(_, addressesEvent) => { urls = new[] { addressesEvent.NodeAddress }; AddAuthorizationHeader(httpClient, addressesEvent.NodeAddress); Application.MainLoop.Invoke(async() => { var balanceModule = new BalanceModule(ethJsonRpcClientProxyMaxRetries, addressesEvent.AccountAddress); balanceModule.TransferClicked += async(_, transferEvent) => { var transferModule = new TransferModule(ethJsonRpcClientProxyMaxRetries, jsonRpcWalletClientProxyMaxRetries, transferEvent.Address, transferEvent.Balance); var transferWindow = await transferModule.InitAsync(); Application.Top.Add(transferWindow); Application.Run(transferWindow); }; var balanceWindow = await balanceModule.InitAsync(); Application.Top.Add(balanceWindow); Application.Run(balanceWindow); }); }; var addressesWindow = await addressesModule.InitAsync(); Application.Top.Add(addressesWindow); Application.Run(addressesWindow); }; var initWindow = await initModule.InitAsync(); Application.Top.Add(initWindow); Application.Run(initWindow); }; var networkWindow = await networkModule.InitAsync(); Application.Top.Add(networkWindow); Application.Run(); }