// This method tests Enjin's non-runtime API methods mostly used in the editor window. private void TestStaticEndpoints() { // Helper methods. TestMethod(() => { Enjin.StoreUserData(new User(), "test"); }, "user data storage"); TestMethod <Boolean>(() => { return(Enjin.ValidateAddress("0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c")); }, true, "address validation"); TestMethod(() => { Enjin.URLGetData("https://enjincoin.io/", new System.Collections.Generic.Dictionary <string, string>()); }, "fetching URL data"); TestMethod <String>(() => { return(Enjin.URLGetData("bad URL", new System.Collections.Generic.Dictionary <string, string>())); }, string.Empty, "expected result from bad URL data"); TestMethod(() => { Enjin.ResetErrorReport(); }, "error report reset"); // CryptoItems methods. TestMethod(() => { Enjin.GetCryptoItemBalance(testingIdentityID, TESTING_ITEM_ID); }, "balance by identity"); TestMethod(() => { Enjin.GetMintableItems(TESTING_ITEM_ID); }, "mintable item retrieval"); TestMethod(() => { CryptoItem item = Enjin.GetCryptoItem(TESTING_ITEM_ID); Enjin.GetCryptoItemIDByName(item.name); }, "item identity by name"); TestMethod(() => { Enjin.GetCryptoItemBalances(testingIdentityID); }, "all balances by identity"); TestMethod(() => { Enjin.UpdateCryptoItem(new CryptoItem()); }, "item updating"); TestMethod(() => { Enjin.GetAllCryptoItems(); }, "searching all items"); TestMethod(() => { CryptoItem item = Enjin.GetCryptoItem(TESTING_ITEM_ID); Enjin.GetCryptoItemIDByName(item.name); }, "searching for item name"); TestMethod(() => { Enjin.GetAllItems(0, 0, DEVELOPER_IDENTITY_ID); }, "getting all items by page"); TestMethod(() => { Enjin.GetAllItems(DEVELOPER_IDENTITY_ID); }, "getting all items"); // Enjin Platform API methods. TestMethod(() => { Enjin.GetTotalActiveTokens(DEVELOPER_IDENTITY_ID); }, "getting all active tokens"); TestMethod(() => { Enjin.GetAppsByUserID(loginUser.id); }, "getting apps for user"); TestMethod(() => { Enjin.GetAppByID(APP_ID); }, "getting app by id"); // Identity methods. TestMethod(() => { Enjin.UpdateBalances(new Identity()); }, "identity balance updates"); TestMethod(() => { Enjin.GetIdentity(testingIdentityID); }, "identity retrieval"); TestMethod(() => { Enjin.GetAllIdentities(); }, "bulk identity retrieval"); TestMethod(() => { Enjin.SearchIdentities("enjin"); }, "identity search"); Identity sampleIdentity = new Identity { user = new Identity.User { name = loginUser.name, id = loginUser.id }, id = testingIdentityID, fields = new Fields[] { new Fields("test", "enjin", 0, 0, 0) } }; TestMethod(() => { Enjin.UpdateIdentity(sampleIdentity); }, "identity update"); Enjin.AccessToken = TESTER_TOKEN; TestMethod(() => { Enjin.UpdateIdentityFields(testingIdentityID, new Fields[] { new Fields("test", "enjin!", 0, 0, 0) }); }, "identity field update"); TestMethod(() => { Enjin.LinkIdentity(sampleIdentity); }, "identity link"); TestMethod(() => { Enjin.UnLinkIdentity(testingIdentityID); }, "identity unlinking"); TestMethod(() => { Enjin.DeleteIdentity(testingIdentityID + ""); }, "identity deletion"); TestMethod(() => { Enjin.CreateIdentity(sampleIdentity); }, "identity creation"); TestMethod(() => { Enjin.GetRoles(); }, "fetching identity roles"); TestMethod(() => { Enjin.GetIdentities(0, 0); }, "fetching identity pages"); }
public void DrawCreateEditPane(IdentitiesTabController controller, GUISkin skin) { GUILayout.BeginArea(new Rect(5, 10, 912, 606), skin.GetStyle("TopBackground")); EditorGUILayout.BeginHorizontal(); if (controller.State == IdentitiesTabController.IdentityState.EDIT) { EditorGUILayout.LabelField(new GUIContent("VIEW IDENTITY"), skin.GetStyle("MainTitle")); } else { EditorGUILayout.LabelField(new GUIContent(controller.State.ToString() + " IDENTITY"), skin.GetStyle("MainTitle")); } EditorGUILayout.EndHorizontal(); GUILayout.Space(30); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); EditorGUILayout.LabelField(new GUIContent("CURRENT APPLICATION"), skin.GetStyle("Subtitle")); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); EditorGUILayout.LabelField(new GUIContent("ID: " + Enjin.AppID.ToString() + " -> " + EnjinEditor.AppsNameList[EnjinEditor.SelectedAppIndex]), skin.GetStyle("LargeTextDark")); EditorGUILayout.EndHorizontal(); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); EditorGUILayout.LabelField(new GUIContent("USER ID"), skin.GetStyle("Subtitle")); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); if (controller.State == IdentitiesTabController.IdentityState.CREATE) { EditorStyles.popup.fixedHeight = 30; EditorStyles.popup.fontSize = 12; controller.CurrentIdentity.user.id = System.Convert.ToInt32(EditorGUILayout.Popup(controller.CurrentIdentity.user.id, controller.UserIDs.ToArray(), GUILayout.Width(220), GUILayout.Height(30))); EditorStyles.popup.fixedHeight = 15; EditorStyles.popup.fontSize = 11; } else { EditorGUILayout.LabelField(new GUIContent(controller.CurrentIdentity.user.id.ToString()), skin.GetStyle("LargeText"), GUILayout.Width(320), GUILayout.Height(30)); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); if (controller.State == IdentitiesTabController.IdentityState.CREATE) { EditorGUILayout.LabelField(new GUIContent("ETHEREUM ADDRESS"), skin.GetStyle("Subtitle")); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); controller.CurrentIdentity.ethereum_address = EditorGUILayout.TextField(controller.CurrentIdentity.ethereum_address, skin.textField, GUILayout.Width(320), GUILayout.Height(30)); } else { if (controller.CurrentIdentity.linking_code == "") { EditorGUILayout.LabelField(new GUIContent("ETHEREUM ADDRESS"), skin.GetStyle("Subtitle")); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); EditorGUILayout.LabelField(new GUIContent(controller.CurrentIdentity.ethereum_address), skin.GetStyle("LargeText"), GUILayout.Width(320), GUILayout.Height(30)); } else { EditorGUILayout.LabelField(new GUIContent("LINKING CODE"), skin.GetStyle("Subtitle")); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); EditorGUILayout.LabelField(new GUIContent(controller.CurrentIdentity.linking_code), skin.GetStyle("LargeText"), GUILayout.Width(320), GUILayout.Height(30)); } } EditorGUILayout.EndHorizontal(); if (controller.State != IdentitiesTabController.IdentityState.CREATE && controller.CurrentIdentity.linking_code == "") { GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); EditorGUILayout.LabelField(new GUIContent("To change your wallet addres you will need to unlink this wallet."), skin.GetStyle("ContentDark")); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); if (GUILayout.Button(new GUIContent("Unlink Wallet"), GUILayout.Width(120), GUILayout.Height(30))) { if (EditorUtility.DisplayDialog("Unlink Wallet", "This will unlink this editor from your developer wallet. Do you want to proceed?", "Accept", "Cancel")) { Enjin.UnLinkIdentity(controller.CurrentIdentity.id); EnjinEditor.CurrentUser = Enjin.GetUserRaw(controller.CurrentIdentity.id); EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADALL); } } EditorGUILayout.EndHorizontal(); } /*** * Disabled for V1 */ //GUILayout.Space(20); //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.LabelField(new GUIContent("FIELDS"), skin.GetStyle("MainTitle")); //EditorGUILayout.EndHorizontal(); //GUILayout.Space(20); //EditorGUILayout.BeginHorizontal(); //GUILayout.Space(14); ///* TODO POST V1 // * - Make fields additive so user can add fields as nessisary // */ //if (controller.CurrentIdentity.fields == null || controller.CurrentIdentity.fields.Length == 0) //{ // controller.CurrentIdentity.fields = new Fields[2]; // controller.CurrentIdentity.fields = Enjin.DefaultFields; //} //_scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, GUILayout.Width(320), GUILayout.Height(140)); //for (int i = 0; i < controller.CurrentIdentity.fields.Length; i++) //{ // EditorGUILayout.BeginVertical("helpBox"); // EditorGUILayout.BeginHorizontal(); // GUILayout.Space(14); // EditorGUILayout.LabelField(new GUIContent("KEY"), skin.GetStyle("Subtitle"), GUILayout.Width(140)); // EditorGUILayout.LabelField(new GUIContent("VALUE"), skin.GetStyle("Subtitle"), GUILayout.Width(140)); // EditorGUILayout.EndHorizontal(); // EditorGUILayout.BeginHorizontal(); // GUILayout.Space(14); // EditorGUILayout.LabelField(new GUIContent(controller.CurrentIdentity.fields[i].key), GUILayout.Width(140), GUILayout.Height(30)); // controller.CurrentIdentity.fields[i].value = EditorGUILayout.TextField(controller.CurrentIdentity.fields[i].value, skin.textField, GUILayout.Width(140), GUILayout.Height(30)); // EditorGUILayout.EndHorizontal(); // GUILayout.Space(8); // EditorGUILayout.EndVertical(); //} //EditorGUILayout.EndScrollView(); //EditorGUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (controller.State == IdentitiesTabController.IdentityState.CREATE) { if (GUILayout.Button(new GUIContent("CREATE"), GUILayout.Width(100), GUILayout.Height(30))) { controller.ProcessRequest(ProcessTasks.CREATE, controller.CurrentIdentity, _properties); //if (!Enjin.ValidateAddress(controller.CurrentIdentity.ethereum_address)) // EditorUtility.DisplayDialog("INVALID ADDRESS", "The address you entered is not valid. Please enter a valid address", "Ok"); //else //{ // controller.ProcessRequest(ProcessTasks.CREATE, controller.CurrentIdentity, _properties); //} } } if (GUILayout.Button(new GUIContent("BACK"), GUILayout.Width(100), GUILayout.Height(30))) { controller.CurrentIdentity.fields = new Fields[0]; controller.State = IdentitiesTabController.IdentityState.VIEW; } GUILayout.Space(10); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.EndArea(); }
private void LinkedWallet() { GUILayout.BeginArea(new Rect(5, 10, 912, 606), _skin.GetStyle("TopBackground")); EditorGUILayout.LabelField(new GUIContent("WALLET DETAILS"), _skin.GetStyle("MainTitle")); GUILayout.Space(30); EditorGUILayout.BeginHorizontal(); GUILayout.Space(16); EditorGUILayout.LabelField(new GUIContent("ENJ BALANCE"), _skin.GetStyle("Subtitle"), GUILayout.Width(140)); EditorGUILayout.LabelField(new GUIContent("ETH BALANCE"), _skin.GetStyle("Subtitle"), GUILayout.Width(140)); EditorGUILayout.LabelField(new GUIContent("ACTIVE TOKENS"), _skin.GetStyle("Subtitle"), GUILayout.Width(140)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(16); EditorGUILayout.LabelField(new GUIContent(Enjin.GetEnjBalance.ToString("#,##0.###")), _skin.GetStyle("LargeNumbers"), GUILayout.Width(140)); EditorGUILayout.LabelField(new GUIContent(Enjin.GetEthBalance.ToString("#,##0.########")), _skin.GetStyle("LargeNumbers"), GUILayout.Width(140)); EditorGUILayout.LabelField(new GUIContent(_activeTokenBalance), _skin.GetStyle("LargeNumbers"), GUILayout.Width(140)); EditorGUILayout.EndHorizontal(); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); GUILayout.Space(16); EditorGUILayout.LabelField(new GUIContent("LINKED ADDRESS"), _skin.GetStyle("Subtitle"), GUILayout.Width(120)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); EditorGUILayout.LabelField(new GUIContent(EnjinEditor.CurrentUserIdentity.ethereum_address), _skin.GetStyle("ContentDark")); GUILayout.Space(14); if (GUILayout.Button(new GUIContent(ClipBoardIcon, "Copy Wallet Address to Clipboard"), GUILayout.Width(32), GUILayout.Height(32))) { EditorGUIUtility.systemCopyBuffer = EnjinEditor.CurrentUserIdentity.ethereum_address; } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.Space(20); //EditorGUILayout.BeginHorizontal(); //GUILayout.Space(14); //if (GUILayout.Button(new GUIContent("Download Wallet"), GUILayout.Width(120), GUILayout.Height(30))) // Application.OpenURL("https://enjinwallet.io/"); //EditorGUILayout.EndHorizontal(); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); EditorGUILayout.LabelField(new GUIContent("To change your wallet addres you will need to unlink this wallet."), _skin.GetStyle("ContentLight")); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(14); if (GUILayout.Button(new GUIContent("Unlink Wallet"), GUILayout.Width(120), GUILayout.Height(30))) { if (EditorUtility.DisplayDialog("Unlink Wallet", "This will unlink this editor from your developer wallet. Do you want to proceed?", "Accept", "Cancel")) { Enjin.UnLinkIdentity(EnjinEditor.CurrentUserIdentity.id); EnjinEditor.CurrentUser = Enjin.GetUserRaw(EnjinEditor.CurrentUser.id); EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADALL); } } EditorGUILayout.EndHorizontal(); GUILayout.EndArea(); }