public void Awake() { if (Instance == null) { Instance = this; } }
public static void SignOut() { // Clear wallets aggregateWallet.Clear(); mnemonicWallet = null; TournamentsMenu.SetState(TournamentsMenu.TournamentMenuState.AccountUnlockRequired); }
public void Initialize() { if (Instance == null) { Instance = this; } calcInput = connectedMenus.calcInput; boundsManager = connectedMenus.boundsManager; pieceWiseControl = connectedMenus.pieceWiseControl; boundsManager = connectedMenus.boundsManager; saveLoadMenu = connectedMenus.saveLoadMenu; tournamentMenu = connectedMenus.tournamentMenu; submissionsMenu = connectedMenus.submissionsMenu; if (connectedMenus.boundsManager != null) { connectedMenus.boundsManager.Initialize(this); } connectedMenus.calcInput.Initialize(this); //tier 3 connectedMenus.outputMenu.Initialize(this); //Req: calcInput connectedMenus.pieceWiseControl.Initialize(this); //Req: calcInput calcInput.ChangeOutput(expressionSet.expressions["X"]); //Req: calcInput connectedMenus.presetMenu.Initialize(this); connectedMenus.saveLoadMenu.Initialize(this); if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name.Equals("3 - FreeParametrization")) { if (connectedMenus.tournamentMenu != null) { connectedMenus.tournamentMenu.Initialize(this); } if (connectedMenus.submissionsMenu != null) { connectedMenus.submissionsMenu.Initialize(this); } if (connectedMenus.mySubmissionsMenu != null) { connectedMenus.mySubmissionsMenu.Initialize(this); } } if (connectedMenus.particleAnimationSettings != null) { connectedMenus.particleAnimationSettings.Initialize(this); } }
// returns success public static bool TryUnlockAccount() { var password = Instance.PasswordInput.text; string cypher = Config.getString("cypher", ""); string cypherType = Config.getString("cypherType", ""); string plainText = Crypto.Decrypt(cypher, password); NetworkSettings.declinedAccountUnlock = false; switch (cypherType) { case "private key": if (plainText.Substring(0, 2) != "0x") { Instance.PasswordInput.GetComponent <Image>().color = new Color(1f, 181f / 255f, 181f / 255f); Instance.AccountUnlockText[2].text = "Invalid password"; Instance.AccountUnlockText[2].gameObject.SetActive(true); return(false); } NetworkSettings.importKey(plainText); break; case "mnemonic": try { NetworkSettings.importWallet(plainText, ""); } catch (System.Exception e) { Instance.ErrorMessage.gameObject.SetActive(true); Instance.ErrorMessage.text = "Invalid password"; return(false); } break; case "keystore": try { NetworkSettings.importKeystore(plainText, ""); } catch (System.Exception e) { Instance.ErrorMessage.gameObject.SetActive(true); Instance.ErrorMessage.text = "Invalid password"; return(false); } break; } TournamentsMenu.SetState(TournamentsMenu.TournamentMenuState.Unlocked); return(true); }
void Start() { if (!MatryxAccountMenu.UnlockAccount()) { TournamentsMenu.SetState(TournamentsMenu.TournamentMenuState.AccountUnlockRequired); } queue(InitializeNetworkSettings()); queue(InitializeContracts()); queue(InitializeUser()); queue(RunTests()); }
protected override void ButtonEnterBehavior(GameObject other) { bool menuActive = accountMenu.gameObject.activeSelf; if (!menuActive) { TournamentsMenu.SetState(TournamentsMenu.TournamentMenuState.WaitingForUnlock); } else { TournamentsMenu.SetState(TournamentsMenu.TournamentMenuState.AccountUnlockRequired); } accountMenu.gameObject.SetActive(!menuActive); // Select the button submissionButtonFlexComponent.SetState(2); }
internal TournamentButtonResponder(TournamentsMenu tournamentMenu, FlexMenu menu) { this.menu = menu; this.tournamentMenu = tournamentMenu; }
// returns success public static bool TrySetPrivateKeyAndCypher() { string password = Instance.PasswordInput.text; string confirmPassword = Instance.ConfirmPasswordInput.text; bool usedPassword = Instance.UsePassword.isOn; string cypher = ""; string cypherType = ""; if (password != confirmPassword) { Instance.ErrorMessage.gameObject.SetActive(true); Instance.ErrorMessage.text = "Passwords do not match"; return(false); } if (Instance.State == AccountMenuState.PrivateKeyInput || Instance.State == AccountMenuState.PrivateKeyPasswordInput) { string privateKey = Instance.PrivateKeyInput.text; if (!Instance.PrivateKeyInput.GetComponent <InputValidator>().isValid) { Instance.AccountUnlockText[2].text = "Invalid private key"; Instance.AccountUnlockText[2].gameObject.SetActive(true); return(false); } if (usedPassword && !Instance.PasswordInput.GetComponent <InputValidator>().isValid) { Instance.AccountUnlockText[2].text = "Invalid password"; Instance.AccountUnlockText[2].gameObject.SetActive(true); return(false); } try { NetworkSettings.importKey(privateKey, true); } catch (System.Exception e) { Instance.ErrorMessage.gameObject.SetActive(true); Instance.ErrorMessage.text = "" + e; return(false); } // Encrypt private key cypher = Crypto.Encrypt(privateKey, usedPassword ? password : ""); cypherType = "private key"; } else if (Instance.State == AccountMenuState.MnemonicInput || Instance.State == AccountMenuState.MnemonicPasswordInput) { string mnemonic = Instance.PrivateKeyInput.text; // Store mnemonic in NetworkSettings for transactions try { NetworkSettings.importWallet(mnemonic, ""); } catch (System.Exception e) { Instance.ErrorMessage.gameObject.SetActive(true); Instance.ErrorMessage.text = "" + e; return(false); } // Encrypt mnemonic cypher = Crypto.Encrypt(mnemonic, usedPassword ? password : ""); cypherType = "mnemonic"; } else if (Instance.State == AccountMenuState.KeyStoreInput) { string keystore = File.readFileContent(keystorePath); try { NetworkSettings.importKeystore(keystore, ""); } catch (System.Exception e) { Instance.ErrorMessage.gameObject.SetActive(true); Instance.ErrorMessage.text = "Invalid keystore file"; return(false); } // Encrypt keystore cypher = Crypto.Encrypt(keystorePath, usedPassword ? password : ""); cypherType = "keystore"; } // Store cypher and related info Config.setString("cypher", cypher, true, "storage"); Config.setString("cypherType", cypherType, true, "storage"); Config.setString("address", NetworkSettings.currentAddress); Config.setBool("usedPassword", usedPassword, true, "storage"); TournamentsMenu.SetState(TournamentsMenu.TournamentMenuState.Unlocked); return(true); }
public void Cancel() { NetworkSettings.declinedAccountUnlock = true; TournamentsMenu.SetState(TournamentsMenu.TournamentMenuState.AccountUnlockRequired); Instance.gameObject.SetActive(false); }