Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }