public WalletNameSection(
            HopeWalletInfoManager hopeWalletInfoManager,
            WalletPasswordVerification walletPasswordVerification,
            ContactsManager contactsManager,
            DynamicDataCache dynamicDataCache,
            UserWalletManager userWalletManager,
            SettingsPopupAnimator settingsPopupAnimator,
            GameObject currentPasswordSection,
            GameObject walletNameSection,
            GameObject loadingIcon,
            HopeInputField currentPasswordField,
            HopeInputField currentWalletNameField,
            HopeInputField newWalletNameField,
            Button nextButton,
            Button saveButton,
            GameObject[] hopeOnlyCategoryButtons)
        {
            this.hopeWalletInfoManager      = hopeWalletInfoManager;
            this.walletPasswordVerification = walletPasswordVerification;
            this.contactsManager            = contactsManager;
            this.dynamicDataCache           = dynamicDataCache;
            this.settingsPopupAnimator      = settingsPopupAnimator;
            this.currentPasswordSection     = currentPasswordSection;
            this.walletNameSection          = walletNameSection;
            this.loadingIcon             = loadingIcon;
            this.currentPasswordField    = currentPasswordField;
            this.currentWalletNameField  = currentWalletNameField;
            this.newWalletNameField      = newWalletNameField;
            this.nextButton              = nextButton;
            this.saveButton              = saveButton;
            this.hopeOnlyCategoryButtons = hopeOnlyCategoryButtons;

            walletInfo = hopeWalletInfoManager.GetWalletInfo(userWalletManager.GetWalletAddress());
            SetListeners();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the <see cref="AmountManager"/> by assigning the references to the popup, max toggle, and amount input field.
        /// </summary>
        /// <param name="currencyManager"> The active <see cref="CurrencyManager"/>. </param>
        /// <param name="tradableAssetPriceManager"> The active <see cref="TradableAssetPriceManager"/>. </param>
        /// <param name="maxToggle"> The toggle for switching between maximum sendable amount and the entered amount. </param>
        /// <param name="maxText"> The max text header. </param>
        /// <param name="amountInputField"> The input field used for entering the sendable amount. </param>
        /// <param name="currencyText"> The currency text object. </param>
        /// <param name="oppositeCurrencyAmountText"> The opposite currency amount text object. </param>
        /// <param name="currencyButton"> The currency button. </param>
        /// <param name="tokenSymbol"> The token symbol. </param>
        public AmountManager(
            CurrencyManager currencyManager,
            TradableAssetPriceManager tradableAssetPriceManager,
            Toggle maxToggle,
            GameObject maxText,
            HopeInputField amountInputField,
            TMP_Text currencyText,
            TMP_Text oppositeCurrencyAmountText,
            Button currencyButton,
            string tokenSymbol)
        {
            this.maxToggle                  = maxToggle;
            this.maxText                    = maxText;
            this.amountInputField           = amountInputField;
            this.currencyText               = currencyText;
            this.oppositeCurrencyAmountText = oppositeCurrencyAmountText;
            this.currencyButton             = currencyButton;
            this.currencyManager            = currencyManager;
            this.tradableAssetPriceManager  = tradableAssetPriceManager;
            tradableTokenSymbol             = tokenSymbol;

            currencyText.text = currencyManager.ActiveCurrency.ToString();

            amountInputField.SetPlaceholderText("Amount<style=Symbol> (" + tokenSymbol + ")</style>");
            SetupListeners();
        }
Exemplo n.º 3
0
    /// <summary>
    /// Checks if an input field's text is equal to another
    /// </summary>
    /// <param name="other"> The given object being checked </param>
    /// <returns></returns>
    public override bool Equals(object other)
    {
        if (other.GetType() != typeof(HopeInputField))
        {
            return(false);
        }

        HopeInputField otherHopeInputField = other as HopeInputField;

        if (inputFieldBase.inputType == InputField.InputType.Password && otherHopeInputField.inputFieldBase.inputType == InputField.InputType.Password)
        {
            if (passwordBytes.Length != otherHopeInputField.passwordBytes.Length)
            {
                return(false);
            }

            return(passwordBytes.SequenceEqual(otherHopeInputField.passwordBytes));
        }
        else
        {
            string thisText  = inputFieldBase.inputType == InputField.InputType.Password ? passwordBytes.GetUTF8String() : text;
            string otherText = otherHopeInputField.inputFieldBase.inputType == InputField.InputType.Password ? otherHopeInputField.passwordBytes.GetUTF8String() : otherHopeInputField.Text;

            if (thisText != otherText)
            {
                return(false);
            }
        }

        return(true);
    }
        public PasswordSection(
            PlayerPrefPasswordDerivation playerPrefPasswordDerivation,
            UserWalletManager userWalletManager,
            HopeWalletInfoManager hopeWalletInfoManager,
            DynamicDataCache dynamicDataCache,
            SettingsPopupAnimator settingsPopupAnimator,
            HopeInputField newPasswordField,
            HopeInputField confirmPasswordField,
            Button saveButton,
            GameObject loadingIcon)
        {
            this.playerPrefPasswordDerivation = playerPrefPasswordDerivation;
            this.hopeWalletInfoManager        = hopeWalletInfoManager;
            this.dynamicDataCache             = dynamicDataCache;
            this.settingsPopupAnimator        = settingsPopupAnimator;
            this.newPasswordField             = newPasswordField;
            this.confirmPasswordField         = confirmPasswordField;
            this.saveButton  = saveButton;
            this.loadingIcon = loadingIcon;

            walletEncryptor = new WalletEncryptor(playerPrefPasswordDerivation, dynamicDataCache);
            walletDecryptor = new WalletDecryptor(playerPrefPasswordDerivation, dynamicDataCache);
            walletInfo      = hopeWalletInfoManager.GetWalletInfo(userWalletManager.GetWalletAddress());

            newPasswordField.OnInputUpdated     += _ => PasswordsUpdated();
            confirmPasswordField.OnInputUpdated += _ => PasswordsUpdated();
            saveButton.onClick.AddListener(SavePasswordButtonClicked);
        }
    /// <summary>
    /// The nextButton has been clicked
    /// </summary>
    private void NextButtonClicked()
    {
        var            word       = ((string[])dynamicDataCache.GetData("confirmation words"))[wordIndex];
        HopeInputField inputField = wordInputField.GetComponent <HopeInputField>();

        if (inputField.Text.EqualsIgnoreCase(word))
        {
            if (wordIndex != checkBoxes.Length - 1)
            {
                checkBoxes[wordIndex].transform.GetChild(1).gameObject.AnimateGraphicAndScale(1f, 1f, 0.15f);
                checkBoxes[wordIndex].transform.GetChild(0).gameObject.AnimateColor(UIColors.Green, 0.15f);
                ++wordIndex;
                SetWordText();
                wordInputField.GetComponent <HopeInputField>().InputFieldBase.ActivateInputField();
            }
            else
            {
                OpeningWallet = true;
                inputField.InputFieldBase.interactable = false;
                checkBoxes[wordIndex].transform.GetChild(1).gameObject.AnimateGraphicAndScale(1f, 1f, 0.15f, confirmMnemonicMenu.LoadWallet);
                checkBoxes[wordIndex].transform.GetChild(0).gameObject.AnimateColor(UIColors.Green, 0.15f);
            }
        }
        else
        {
            inputField.Error             = true;
            inputField.errorMessage.text = "Incorrect word";
            inputField.UpdateVisuals();
            nextButton.GetComponent <Button>().interactable = false;
        }
    }
        /// <summary>
        /// Initializes the <see cref="GasManager"/> by assigning all required references.
        /// </summary>
        /// <param name="tradableAssetManager"> The active <see cref="TradableAssetManager"/>. </param>
        /// <param name="tradableAssetPriceManager"> The active <see cref="TradableAssetPriceManager"/>. </param>
        /// <param name="currencyManager"> The active <see cref="CurrencyManager"/>. </param>
        /// <param name="gasPriceObserver"> The active <see cref="GasPriceObserver"/>. </param>
        /// <param name="periodicUpdateManager"> The active <see cref="PeriodicUpdateManager"/>. </param>
        /// <param name="advancedModeToggle"> The toggle for switching between advanced and simple mode. </param>
        /// <param name="slider"> The slider used to control transaction speed. </param>
        /// <param name="gasLimitField"> The input field for the gas limit when in advanced mode. </param>
        /// <param name="gasPriceField"> The input field for the gas price when in advanced mode. </param>
        /// <param name="transactionFeeText"> The text component to use to set the transaction fee. </param>
        public GasManager(
            TradableAssetManager tradableAssetManager,
            TradableAssetPriceManager tradableAssetPriceManager,
            CurrencyManager currencyManager,
            GasPriceObserver gasPriceObserver,
            PeriodicUpdateManager periodicUpdateManager,
            Toggle advancedModeToggle,
            Slider slider,
            HopeInputField gasLimitField,
            HopeInputField gasPriceField,
            TMP_Text transactionFeeText)
        {
            this.tradableAssetManager      = tradableAssetManager;
            this.tradableAssetPriceManager = tradableAssetPriceManager;
            this.currencyManager           = currencyManager;
            this.periodicUpdateManager     = periodicUpdateManager;
            this.advancedModeToggle        = advancedModeToggle;
            this.gasLimitField             = gasLimitField;
            this.gasPriceField             = gasPriceField;
            this.transactionFeeText        = transactionFeeText;

            transactionSpeedSlider = new TransactionSpeedSlider(gasPriceObserver, slider, UpdateGasPriceEstimate);

            OnGasChanged += UpdateTransactionFeeVisuals;

            AddListenersAndObservables();
            EstimateGasLimit();
            transactionSpeedSlider.Start();
        }
    /// <summary>
    /// Sets the various text to ask for the next number
    /// </summary>
    private void SetWordText()
    {
        int[] randomNums = dynamicDataCache.GetData("confirmation numbers");

        HopeInputField inputField = wordInputField.GetComponent <HopeInputField>();

        inputField.SetPlaceholderText("Word #" + randomNums[wordIndex]);
        inputField.Text = string.Empty;
    }
        /// <summary>
        /// Initializes the <see cref="AddressManager"/> by assigning the send address input field.
        /// </summary>
        /// <param name="addressField"> The input field for the address. </param>
        /// <param name="contactName"> The contactName text component. </param>
        /// <param name="contactsManager"> The active ContactsManager. </param>
        public AddressManager(
            HopeInputField addressField,
            TMP_Text contactName,
            ContactsManager contactsManager,
            RestrictedAddressManager restrictedAddressManager)
        {
            this.addressField             = addressField;
            this.contactName              = contactName;
            this.contactsManager          = contactsManager;
            this.restrictedAddressManager = restrictedAddressManager;

            addressField.OnInputUpdated += _ => CheckAddress();
        }
    /// <summary>
    /// Verifies the password entered in the password input field.
    /// </summary>
    /// <param name="passwordInputField"> The input field containing the password. </param>
    /// <returns> The current instance of WalletPasswordVerification. </returns>
    public WalletPasswordVerification VerifyPassword(HopeInputField passwordInputField)
    {
        this.passwordInputField = passwordInputField;

        if (passwordInputField?.InputFieldBase != null)
        {
            passwordInputField.InputFieldBase.interactable = false;
        }

        VerifyPassword(passwordInputField.InputFieldBytes);

        return(this);
    }
Exemplo n.º 10
0
        /// <summary>
        /// Sets the necessary variables
        /// </summary>
        /// <param name="idleTimeoutTimeCheckbox"> The idle timeout time checkbox </param>
        /// <param name="loginAttemptsCheckbox"> The login attempts checbox </param>
        /// <param name="idleTimeoutTimeInputField"> The idle timeout time input field </param>
        /// <param name="loginAttemptsInputField"> The login attempts input field </param>
        public SecuritySection(CheckBox idleTimeoutTimeCheckbox,
                               CheckBox loginAttemptsCheckbox,
                               HopeInputField idleTimeoutTimeInputField,
                               HopeInputField loginAttemptsInputField)
        {
            this.idleTimeoutTimeCheckbox   = idleTimeoutTimeCheckbox;
            this.loginAttemptsCheckbox     = loginAttemptsCheckbox;
            this.idleTimeoutTimeInputField = idleTimeoutTimeInputField;
            this.loginAttemptsInputField   = loginAttemptsInputField;

            SetListeners();
            SetCurrentSettings();
        }
    /// <summary>
    /// Sets the next button to interactable if the word input field has at least something in the input
    /// </summary>
    /// <param name="str"> The current string that is in the word input field </param>
    private void InputFieldChanged()
    {
        HopeInputField inputField = wordInputField.GetComponent <HopeInputField>();

        bool stringContainsNonLetter = inputField.Text.Any(c => !char.IsLetter(c));

        inputField.Error = string.IsNullOrEmpty(inputField.Text) || stringContainsNonLetter;

        if (!string.IsNullOrEmpty(inputField.Text))
        {
            inputField.errorMessage.text = "Invalid word";
        }

        nextButton.GetComponent <Button>().interactable = !inputField.Error;
    }
Exemplo n.º 12
0
        /// <summary>
        /// Sets the necessary variables
        /// </summary>
        /// <param name="twoFactorAuthenticationCheckbox"> The checkbox to enable two-factor authentication or not </param>
        /// <param name="setUpSection"> The set-up section </param>
        /// <param name="keyText"> The key text element </param>
        /// <param name="qrCodeImage"> The qr code image </param>
        /// <param name="codeInputField"> The input field for the user to input the code </param>
        /// <param name="confirmButton"> The confirm button </param>
        public TwoFactorAuthenticationSection(CheckBox twoFactorAuthenticationCheckbox,
                                              GameObject setUpSection,
                                              TextMeshProUGUI keyText,
                                              Image qrCodeImage,
                                              HopeInputField codeInputField,
                                              Button confirmButton)
        {
            this.twoFactorAuthenticationCheckbox = twoFactorAuthenticationCheckbox;
            this.setUpSection   = setUpSection;
            this.keyText        = keyText;
            this.qrCodeImage    = qrCodeImage;
            this.codeInputField = codeInputField;
            this.confirmButton  = confirmButton;

            SetUpVisuals();
        }
        /// <summary>
        /// Initializes the <see cref="AmountManager"/> by assigning the references to the popup, max toggle, and amount input field.
        /// </summary>
        /// <param name="lockPRPSManager"> The active LockPRPSManager. </param>
        /// <param name="maxToggle"> The toggle for switching between maximum sendable amount and the entered amount. </param>
        /// <param name="amountInputField"> The input field used for entering the sendable amount. </param>
        /// <param name="prpsBalanceText"> Text component used for displaying the current purpose balance. </param>
        /// <param name="dubiBalanceText"> Text component used for displaying the current dubi balance. </param>
        /// <param name="dubiRewardText"> Text component used for displaying the dubi reward. </param>
        /// <param name="buttonTooltipItem"> The lock button tooltip item </param>
        public AmountManager(
            LockPRPSManager lockPRPSManager,
            Toggle maxToggle,
            HopeInputField amountInputField,
            TMP_Text prpsBalanceText,
            TMP_Text dubiBalanceText,
            TMP_Text dubiRewardText,
            TooltipItem buttonTooltipItem)
        {
            this.lockPRPSManager   = lockPRPSManager;
            this.maxToggle         = maxToggle;
            this.amountInputField  = amountInputField;
            this.prpsBalanceText   = prpsBalanceText;
            this.dubiBalanceText   = dubiBalanceText;
            this.dubiRewardText    = dubiRewardText;
            this.buttonTooltipItem = buttonTooltipItem;

            lockPRPSManager.OnAmountsUpdated += BalancesUpdated;

            maxToggle.AddToggleListener(MaxChanged);
            amountInputField.OnInputUpdated += _ => AmountFieldChanged();

            BalancesUpdated();
        }