private void CheckProfileExists(ProfileDef profileDef)
 {
     profileExists = ProfileExistState.INDETERMINATE;
     profileDef.CheckExists((b =>
     {
         if (b)
         {
             profileExists = ProfileExistState.EXISTS;
             profileDef.Save();
         }
         else
         {
             profileExists = ProfileExistState.DOES_NOT_EXIST;
         }
         ready = true;
     }));
 }
        private void ProfileGui(ProfileDef profileDef)
        {
            SetWindowSizeVars();

            using (var h = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("Profile", EditorStyles.boldLabel);
                DrawSpriteForProfileExistState();
            }

            // how to deal w/ the checkexists event...
            using (var h = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField($"Public key: ", EditorStyles.miniLabel, GUILayout.Width(Normalize(96)));
                EditorGUILayout.SelectableLabel(profileDef.PublicKey, EditorStyles.miniTextField);
            };

            using (var h = new EditorGUILayout.HorizontalScope())
            {
                showPrivateKey = EditorGUILayout.Toggle(showPrivateKey, GUILayout.Width(Normalize(26)));
                EditorGUILayout.LabelField($"Private key: ", EditorStyles.miniLabel, GUILayout.Width(Normalize(70)));
                if (showPrivateKey)
                {
                    EditorGUILayout.SelectableLabel(profileDef.PrivateKey, EditorStyles.miniTextField);
                }
                else
                {
                    EditorGUILayout.SelectableLabel("(hidden)", EditorStyles.miniTextField);
                }
            };
            using (var h = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("Address: ", EditorStyles.miniBoldLabel, GUILayout.Width(Normalize(96)));
                EditorGUILayout.SelectableLabel(profileDef.Address, EditorStyles.miniTextField);
            };
            using (var h = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("Name: ", EditorStyles.miniBoldLabel, GUILayout.Width(Normalize(96)));
                //if (profileExists == ProfileExistState.DOES_NOT_EXIST) nameInput = EditorGUILayout.TextField(nameInput, EditorStyles.miniTextField);
                //else EditorGUILayout.SelectableLabel(profileDef.Name, EditorStyles.miniTextField);
                localName = EditorGUILayout.TextField(localName);
            };

            using (var h = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("Notes: ", EditorStyles.miniBoldLabel, GUILayout.Width(Normalize(96)));
                localNote = EditorGUILayout.TextArea(localNote);
            }

            if (localName != profileDef.Name || localNote != profileDef.Note)
            {
                if (GUILayout.Button("Save", GUILayout.Width(Normalize(24))))
                {
                    var index  = GetIndexOfCurrent();
                    var newDef = new ProfileDef(currentDef.PrivateKey, currentDef.PublicKey, localName, currentDef.Address, localNote);
                    currentDef.Delete();
                    newDef.Save();
                    profileDefs[index] = newDef;
                    SetProfile(newDef, currentProfile);
                }
            }

            if (profileExists == ProfileExistState.DOES_NOT_EXIST)
            {
                if (GUILayout.Button("Register profile"))
                {
                    profileExists = ProfileExistState.INDETERMINATE;
                    PylonsService.instance.RegisterProfile(nameInput, (s, e) => {
                        UpdateDataModel();
                    });
                }
            }

            if (currentProfile != null)
            {
                EditorGUILayout.LabelField($"Pylons: {currentProfile.GetCoin("pylon")}", EditorStyles.miniBoldLabel);

                using (var v = new EditorGUILayout.VerticalScope())
                {
                    EditorGUILayout.LabelField("Other coins", EditorStyles.miniBoldLabel);
                    foreach (var coin in currentProfile.Coins)
                    {
                        if (coin.Denom != "pylon")
                        {
                            EditorGUILayout.LabelField($"{coin.Denom}: {coin.Amount}", EditorStyles.miniLabel);
                        }
                    }
                }
                //TODO: also display items
            }
        }