public App() { InitializeComponent(); Store.RegisterEffects( LyraWallet.States.Effects.CreateWalletEffect, LyraWallet.States.Effects.OpenWalletEffect, LyraWallet.States.Effects.OpenWalletAndSyncEffect, LyraWallet.States.Effects.RestoreWalletEffect, LyraWallet.States.Effects.RemoveWalletEffect, LyraWallet.States.Effects.ChangeVoteWalletEffect, LyraWallet.States.Effects.RefreshWalletEffect, LyraWallet.States.Effects.SendTokenWalletEffect, LyraWallet.States.Effects.CreateTokenWalletEffect, LyraWallet.States.Effects.ImportWalletEffect, LyraWallet.States.Effects.RedeemWalletEffect, LyraWallet.States.Effects.NonFungibleTokenWalletEffect ); WalletPassword wp; // check default wallet exists. var path = DependencyService.Get <IPlatformSvc>().GetStoragePath(); var fn = $"{path}/default.lyrawallet"; if (File.Exists(fn)) { wp = new WalletPassword(true); } else { wp = new WalletPassword(false); } wp.Path = path; MainPage = new NavigationPage(wp); }
public async Task Insert(WalletPassword walletPassword) { try { await _container.CreateItemAsync <WalletPassword>(walletPassword, new PartitionKey(walletPassword.Id)); } catch (Exception ex) { throw new Exception($"Inserting wallet password into Cosmos DB failed with error: {ex}"); } }
public async Task <string> CreateAndUploadUserProfile(string name, string email) { if (!ValidateUserEmail(email)) { throw new Exception("Invalid user profile field: email must be a valid email address."); } // Generate wallet and encrypted keystore var key = EthECKey.GenerateKey(); var privateKey = key.GetPrivateKeyAsBytes(); var address = key.GetPublicAddress(); var password = Guid.NewGuid().ToString(); var keyStoreObj = _keyStoreService.EncryptAndGenerateKeyStore(password, privateKey, address); var userProfile = new UserProfile { Name = name, Email = email, Id = keyStoreObj.Id, UserKeyStore = keyStoreObj }; var walletPassword = new WalletPassword { Id = Guid.NewGuid().ToString(), UserProfileId = userProfile.Id, Password = password }; await _userProfileRepository.Insert(userProfile); await _walletPasswordRepository.Insert(walletPassword); return(keyStoreObj.Id); }
public async Task Update(string id, WalletPassword walletPassword) { await _container.ReplaceItemAsync <WalletPassword>(walletPassword, id, new PartitionKey(id)); }