private async Task CreateAgent()
        {
            Preferences.Set(Constants.PoolConfigurationName, _walletConfiguration.PoolConfigurationName);
            var dialog = UserDialogs.Instance.Loading("Creating wallet");

            IsBusy = true;
            try
            {
                _options.AgentName = DeviceInfo.Name;
                _options.WalletConfiguration.Id = Constants.LocalWalletIdKey;
                _options.WalletCredentials.Key  = await SyncedSecureStorage.GetOrCreateSecureAsync(
                    key : Constants.LocalWalletCredentialKey,
                    value : Utils.Utils.GenerateRandomAsync(32));

                await _edgeProvisioningService.ProvisionAsync(_options);

                Preferences.Set("LocalWalletProvisioned", true);
                await NavigationService.NavigateToAsync <MainViewModel>();

                dialog?.Hide();
                dialog?.Dispose();
                DialogService.Alert("Wallet created successfully", "Info", "OK");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex, "Wasn't able to provision the agent");
                dialog?.Hide();
                dialog?.Dispose();
                DialogService.Alert("Failed to create wallet!");
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 2
0
        private async Task CreateAgent(string agentName)
        {
            Preferences.Set(Constants.PoolConfigurationName, _walletConfiguration.PoolConfigurationName);
            var dialog = UserDialogs.Instance.Loading("Creating wallet");

            IsBusy = true;
            try
            {
                _options.AgentName = agentName;
                _options.WalletConfiguration.Id = Constants.LocalWalletIdKey;
                _options.WalletCredentials.Key  = await SyncedSecureStorage.GetOrCreateSecureAsync(
                    key : Constants.LocalWalletCredentialKey,
                    value : Utils.Utils.GenerateRandomAsync(32));

                await _edgeProvisioningService.ProvisionAsync(_options);

                Preferences.Set("LocalWalletProvisioned", true);
                await NavigationService.NavigateToAsync <MainViewModel>();

                dialog?.Hide();
                dialog?.Dispose();
                var toastConfig = new ToastConfig("Successfully created wallet");
                toastConfig.BackgroundColor = Color.Green;
                toastConfig.Position        = ToastPosition.Top;
                toastConfig.SetDuration(3000);
                DialogService.Toast(toastConfig);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex, "Wasn't able to provision the agent");
                dialog?.Hide();
                dialog?.Dispose();
                DialogService.Alert("Failed to create wallet!");
            }
            finally
            {
                IsBusy = false;
            }
        }