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; } }
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; } }
public async Task <IAgentContext> GetContextAsync(params object[] args) { var configurationName = Preferences.Get(Constants.PoolConfigurationName, "sovrin-staging"); try { var agentContext = new DefaultAgentContext { SupportedMessages = _agent.GetSupportedMessageTypes(), Wallet = await _walletService.GetWalletAsync( configuration : new WalletConfiguration { Id = Constants.LocalWalletIdKey, StorageConfiguration = new WalletConfiguration.WalletStorageConfiguration { Path = Path.Combine( FileSystem.AppDataDirectory, ".indy_client", "wallets") } }, credentials : new WalletCredentials { Key = await SyncedSecureStorage.GetAsync(Constants.LocalWalletCredentialKey) }), Pool = new PoolAwaitable(async() => await _poolService.GetPoolAsync(configurationName, 2)), Agent = _agent }; return(agentContext); } catch (Exception e) { Debug.WriteLine(e.Message); return(null); } }