Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions ChainSafe.Gaming.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChainSafe.Gaming.Unity.Meta
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChainSafe.Gaming.SygmaClient", "src\ChainSafe.Gaming.SygmaClient\ChainSafe.Gaming.SygmaClient.csproj", "{6D329479-C391-4BF9-B6FC-FFA3AD3A12D7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChainSafe.Gaming.Marketplace", "src/ChainSafe.Gaming.Marketplace\ChainSafe.Gaming.Marketplace.csproj", "{E7A9FE35-BEFD-4569-B848-495E0B85B674}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChainSafe.Gaming.HyperPlay", "src\ChainSafe.Gaming.HyperPlay\ChainSafe.Gaming.HyperPlay.csproj", "{0859E3E2-5AB9-4997-9DE7-368EAB89313B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChainSafe.Gaming.Unity.EthereumWindow", "src\ChainSafe.Gaming.Unity.EthereumWindow\ChainSafe.Gaming.Unity.EthereumWindow.csproj", "{F743DE56-1650-4111-8613-96E8EC7CFD2D}"
Expand Down Expand Up @@ -137,12 +135,6 @@ Global
{6D329479-C391-4BF9-B6FC-FFA3AD3A12D7}.Release|Any CPU.Build.0 = Release|Any CPU
{6D329479-C391-4BF9-B6FC-FFA3AD3A12D7}.Test|Any CPU.ActiveCfg = Test|Any CPU
{6D329479-C391-4BF9-B6FC-FFA3AD3A12D7}.Test|Any CPU.Build.0 = Test|Any CPU
{E7A9FE35-BEFD-4569-B848-495E0B85B674}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7A9FE35-BEFD-4569-B848-495E0B85B674}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7A9FE35-BEFD-4569-B848-495E0B85B674}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7A9FE35-BEFD-4569-B848-495E0B85B674}.Release|Any CPU.Build.0 = Release|Any CPU
{E7A9FE35-BEFD-4569-B848-495E0B85B674}.Test|Any CPU.ActiveCfg = Debug|Any CPU
{E7A9FE35-BEFD-4569-B848-495E0B85B674}.Test|Any CPU.Build.0 = Debug|Any CPU
{0859E3E2-5AB9-4997-9DE7-368EAB89313B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0859E3E2-5AB9-4997-9DE7-368EAB89313B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0859E3E2-5AB9-4997-9DE7-368EAB89313B}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
20 changes: 1 addition & 19 deletions Packages/io.chainsafe.web3-unity/Editor/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,9 @@ static Startup()
WebGLTemplateSync.Syncronize();
}
#endif

// Checks project ID
ValidateProjectID();
};
}

static void ValidateProjectID()
{
try
{
var projectID = ProjectConfigUtilities.Load()?.ProjectId;
if (string.IsNullOrWhiteSpace(projectID))
{
Web3SettingsEditor.ShowWindow(Web3SettingsEditor.Tabs.Project);
}
}
catch (Exception e)
{
Debug.LogError("Failed to validate project ID");
Debug.LogException(e);
}
}

}
}
84 changes: 7 additions & 77 deletions Packages/io.chainsafe.web3-unity/Editor/Web3SettingsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,22 @@ public partial class Web3SettingsEditor : EditorWindow
// Default values
private const string EnableAnalyticsScriptingDefineSymbol = "ENABLE_ANALYTICS";


// Initializes window
[MenuItem("ChainSafe SDK/Project Settings", false, -200)]
public static void ShowWindow() => ShowWindow(null);

public static void ShowWindow(Tabs? tabOverride = null)
public static void ShowWindow()
{
// Show existing window instance. If it doesn't exist, make one.
var window = (Web3SettingsEditor)GetWindow(typeof(Web3SettingsEditor));
window.titleContent = new GUIContent("Web3 Settings");
window.minSize = new Vector2(450, 300);

if (tabOverride.HasValue)
{
window.ActiveTab = tabOverride.Value;
}

}


private static GUIStyle centeredLabelStyle;
private static GUIStyle wrappedGreyMiniLabel;

// Chain values
public string previousProjectId;

private Web3ConfigAsset web3Config;
private List<ChainSettingsPanel> chainSettingPanels;
Expand All @@ -49,17 +43,11 @@ public static void ShowWindow(Tabs? tabOverride = null)

private Texture2D logo;
private Vector2 chainsScrollPosition;

private Tabs ActiveTab
{
get => (Tabs)EditorPrefs.GetInt("Web3SdkSettingsEditor.Tab", (int)Tabs.Project);
set => EditorPrefs.SetInt("Web3SdkSettingsEditor.Tab", (int)value);
}


private void Awake()
{
web3Config = ProjectConfigUtilities.CreateOrLoad();
previousProjectId = web3Config.ProjectId;
}

private void OnEnable()
Expand Down Expand Up @@ -126,67 +114,15 @@ private void DrawBody()
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
ActiveTab = (Tabs)GUILayout.Toolbar((int)ActiveTab, new[] { "Project Settings", "Chain Settings" });
GUILayout.FlexibleSpace();
DrawChainsTabContent();
}

// EditorGUILayout.Separator();
GUILayout.Space(15);

// DrawHorizontalLine();

switch (ActiveTab)
{
case Tabs.Project:
DrawProjectTabContent();
break;
case Tabs.Chains:
DrawChainsTabContent();
break;
}
}

private void DrawProjectTabContent()
{
EditorGUI.BeginChangeCheck();

web3Config.ProjectId = EditorGUILayout.TextField("Project ID", web3Config.ProjectId);
if (string.IsNullOrWhiteSpace(web3Config.ProjectId))
{
EditorGUILayout.HelpBox(
"Please enter your Project ID to start using the ChainSafe Gaming SDK.",
MessageType.Warning);
if (GUILayout.Button("Get a Project ID"))
{
Application.OpenURL("https://dashboard.gaming.chainsafe.io/");
}
}
EditorGUILayout.Space();
web3Config.EnableAnalytics =
EditorGUILayout.Toggle(
new GUIContent("Allow Analytics:",
"Consent to collecting data for analytics purposes. This will help improve our product."),
web3Config.EnableAnalytics);
GUILayout.Label(
"We will collect data for analytics to help improve your experience with our SDK. This data allows us to optimize performance, introduce new features, and ensure seamless integration. You can opt out at any time, but we encourage keeping analytics enabled for the best results!",
wrappedGreyMiniLabel);

if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(web3Config);

if (web3Config.ProjectId != previousProjectId)
{
ValidateProjectID(web3Config.ProjectId);
previousProjectId = web3Config.ProjectId;
}

if (web3Config.EnableAnalytics)
ScriptingDefineSymbols.TryAddDefineSymbol(EnableAnalyticsScriptingDefineSymbol);
else
ScriptingDefineSymbols.TryRemoveDefineSymbol(EnableAnalyticsScriptingDefineSymbol);
}
}


private void DrawChainsTabContent()
{
Expand Down Expand Up @@ -337,12 +273,6 @@ private class ValidateProjectIDResponse
[JsonProperty("response")] public bool Response { get; set; }
}

public enum Tabs
{
Project = 0,
Chains = 1
}

private enum FetchingStatus
{
NotFetching,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ public async void CaptureEvent(AnalyticsEvent eventData)

public string AnalyticsVersion => "2.6";
public IChainConfig ChainConfig => _chainManager.Current;
public IProjectConfig ProjectConfig { get; }

public CountlyAnalytics(IChainConfigSet chainConfigSet, IChainManager chainManager, IProjectConfig projectConfig)
public CountlyAnalytics(IChainConfigSet chainConfigSet, IChainManager chainManager)
{
Countly.Instance.Init(new CountlyConfiguration(AppKey, ServerUrl));

Expand All @@ -35,13 +34,10 @@ public CountlyAnalytics(IChainConfigSet chainConfigSet, IChainManager chainManag
{ "chainId", chainConfig.ChainId },
{ "rpc", chainConfig.Rpc },
{ "network", chainConfig.Network },
{ "projectId", projectConfig.ProjectId },
{ "analyticsVersion", AnalyticsVersion }
};

Countly.Instance.UserDetails.SetCustomUserDetails(userDetails);

ProjectConfig = projectConfig;
}

}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static Web3ConfigAsset Load()
{
bool isWindowsEditor = Application.platform == RuntimePlatform.WindowsEditor;

return Create("3dc3e125-71c4-4511-a367-e981a6a94371",
return Create(
"11155111",
"Anvil", "Sepolia", "Seth", isWindowsEditor ? "http://127.0.0.1:8545" : "http://172.17.0.1:8545",
"https://sepolia.etherscan.io/", false, isWindowsEditor ? "ws://127.0.0.1:8545" : "ws://172.17.0.1:8545");
Expand All @@ -25,12 +25,11 @@ public static Web3ConfigAsset Load()
return projectConfig ? projectConfig : null;
}

public static Web3ConfigAsset Create(string projectId, string chainId, string chain, string network,
public static Web3ConfigAsset Create(string chainId, string chain, string network,
string symbol, string rpc, string blockExplorerUrl, bool enableAnalytics, string ws = "")
{
var projectConfig = ScriptableObject.CreateInstance<Web3ConfigAsset>();

projectConfig.ProjectId = projectId;
projectConfig.EnableAnalytics = enableAnalytics;
projectConfig.ChainConfigs = new List<ChainConfigEntry>
{
Expand Down
Loading
Loading