这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9b36ed9
MUD integration WIP
creeppak Jul 24, 2024
1caec05
debug-publish-to-unity-package.* script updated to reflect the logic …
creeppak Jul 24, 2024
639bb93
Added LogLevel setting to WalletConnect config
creeppak Jul 24, 2024
b972257
Completed basic MUD integration.
creeppak Jul 25, 2024
b869238
Removed IPC Client as it's redundant at this point
creeppak Jul 29, 2024
6bd46a3
Contract API updated.
creeppak Jul 30, 2024
ed5bab1
Updated publish scripts to handle *.pdb files also
creeppak Aug 2, 2024
320e40b
Removed the ContractExtensions.SendAndGet methods which return value,…
creeppak Aug 2, 2024
586e1ed
Reworked MUD integration to use our Contract system
creeppak Aug 2, 2024
0462a88
Merge remote-tracking branch 'origin/dev' into oleksandr/mud-integrat…
creeppak Aug 5, 2024
94c3dd1
Post-merge fixes
creeppak Aug 5, 2024
f02abc5
Fixed Contract Generation
creeppak Aug 5, 2024
926c471
Introduced draft version of the 3rd MUD iteration
creeppak Aug 9, 2024
71d86f0
Introduced EVM EventManager for listening to EVM events using WebSock…
creeppak Aug 12, 2024
7c34938
Replaced old MUD integration with a new one (previously called "Draft")
creeppak Aug 12, 2024
c848c4e
Updated Unity MUD Sample to reflect changes made to Core
creeppak Aug 13, 2024
175283a
Introduced RecordAdded, RecordUpdated, RecordDeleted events for MudTable
creeppak Aug 14, 2024
6729397
Small MUD sample update
creeppak Aug 14, 2024
4498fde
Polish before merge for MUD V3 Integration
creeppak Aug 14, 2024
5ee5d76
Linter
creeppak Aug 14, 2024
33ff3e4
Small changes
creeppak Aug 16, 2024
c742478
Bugfix: ServerSettings window is throwing because no Project Config a…
creeppak Aug 16, 2024
a836d03
Extracted IMudWorldConfig
creeppak Aug 16, 2024
47c893c
Added QuerySingle & QueryByKey methods to the interface of MudTable
creeppak Aug 16, 2024
b607501
Changed InMemoryMudStorage service type from Singleton to Transient. …
creeppak Aug 26, 2024
4a0679a
Added XML documentation to the ChainSafe.Gaming.Mud module
creeppak Aug 26, 2024
68de193
Polished MUD Unity Sample. Added XML docs.
creeppak Aug 26, 2024
1c499d1
Linter
creeppak Aug 26, 2024
bcf3569
Merge branch 'dev' into oleksandr/mud-integration-v3
creeppak Aug 26, 2024
5776262
Lil editor changes
creeppak Aug 26, 2024
6245fdb
Small edit
creeppak Aug 26, 2024
ad7bca1
Made EventManager non-default service
creeppak Aug 28, 2024
186d354
Linter
creeppak Aug 29, 2024
3bdfd1a
Removed redundant method
creeppak Aug 29, 2024
646faac
Merge branch 'dev' into oleksandr/mud-integration-v3
rob1997 Aug 29, 2024
e227214
Merge branch 'dev' into oleksandr/mud-integration-v3
creeppak Sep 3, 2024
ba059f5
Merge remote-tracking branch 'origin/oleksandr/mud-integration-v3' in…
creeppak Sep 3, 2024
e78d044
Commented out MUD tests as CI machine environment should be configure…
creeppak Sep 3, 2024
a424a0b
Commiting something just for the sake of CI noticing changes and runn…
creeppak Sep 3, 2024
7f882bf
Uncommented the MUD tests and set the test fixture to be ignored
creeppak Sep 3, 2024
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
3 changes: 2 additions & 1 deletion ChainSafe.Gaming.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nethereum/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nethereum/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Offchain/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
3 changes: 3 additions & 0 deletions Packages/io.chainsafe.web3-unity.mud/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using ChainSafe.Gaming.Mud.Unity;
using UnityEditor;
using UnityEngine;

namespace ChainSafe.Gaming.Mud.UnityEditor
{
[CustomEditor(typeof(MudConfigAsset))]
public class MudConfigAssetInspector : Editor
{
private MudConfigAsset asset;
private GUIStyle warningStyle;

public override void OnInspectorGUI()
{
asset = (MudConfigAsset)target;
warningStyle ??= new GUIStyle(EditorStyles.largeLabel)
{
wordWrap = true
};

serializedObject.Update();
var storageProperty = serializedObject.FindProperty(nameof(MudConfigAsset.StorageType));

EditorGUILayout.PropertyField(storageProperty, new GUIContent("From Block Number"));
EditorGUILayout.Space();
GUILayout.Label("Storage Settings", EditorStyles.boldLabel);

EditorGUI.indentLevel++;
EditorGUILayout.BeginVertical();

switch (asset.StorageType)
{
case MudStorageType.LocalStorage:
DrawLocalStorageGui();
break;
case MudStorageType.OffchainIndexer:
DrawOffchainIndexerStorageGui();
break;
default:
throw new ArgumentOutOfRangeException();
}

EditorGUILayout.EndVertical();
EditorGUI.indentLevel--;

serializedObject.ApplyModifiedProperties();
}

private void DrawLocalStorageGui()
{
EditorGUILayout.PropertyField(
serializedObject.FindProperty(nameof(MudConfigAsset.InMemoryFromBlockNumber)),
new GUIContent("Scan From Block Number"));
}

private void DrawOffchainIndexerStorageGui()
{
EditorGUILayout.LabelField("Offchain Indexer Storage is not implemented yet. Please use Local Storage for now.", warningStyle);

EditorGUILayout.Space();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Switch to Local Storage"))
{
asset.StorageType = MudStorageType.LocalStorage;
EditorUtility.SetDirty(asset);
}

GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "io.chainsafe.web3-unity.mud.editor",
"rootNamespace": "ChainSafe.Gaming.Mud.UnityEditor",
"references": [
"GUID:5426c6b788696eb4c88f4198b59839eb",
"GUID:92a3dff85d90408b8d1f8462122eb7d5"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions Packages/io.chainsafe.web3-unity.mud/Runtime/MudConfigAsset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using ChainSafe.Gaming.Mud.Storages;
using ChainSafe.Gaming.Mud.Storages.InMemory;
using ChainSafe.Gaming.Web3;
using UnityEngine;

namespace ChainSafe.Gaming.Mud.Unity
{
/// <summary>
/// Represents a configuration asset for MUD module.
/// </summary>
[CreateAssetMenu(menuName = "ChainSafe/Mud Config Asset", fileName = "MudConfigAsset", order = 0)]
public class MudConfigAsset : ScriptableObject, IMudConfig
{
public MudStorageType StorageType;
public ulong InMemoryFromBlockNumber;

public IMudStorageConfig StorageConfig => BuildStorageConfig();

private IMudStorageConfig BuildStorageConfig()
{
switch (StorageType)
{
case MudStorageType.LocalStorage:
return new InMemoryMudStorageConfig { FromBlockNumber = InMemoryFromBlockNumber };
case MudStorageType.OffchainIndexer:
throw new Web3Exception("Offchain Indexer Storage is not implemented yet.");
default:
throw new ArgumentOutOfRangeException();
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Packages/io.chainsafe.web3-unity.mud/Runtime/MudStorageType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace ChainSafe.Gaming.Mud.Unity
{
/// <summary>
/// Represents the different types of storage strategies for a MUD World.
/// </summary>
public enum MudStorageType
{
/// <summary>Use Local Storage Strategy.</summary>
LocalStorage,

///<summary>Use Off-Chain Indexer Storage Strategy.</summary>
OffchainIndexer
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "io.chainsafe.web3-unity.mud.runtime",
"rootNamespace": "ChainSafe.Gaming.Mud.Unity",
"references": [
"GUID:5426c6b788696eb4c88f4198b59839eb"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Packages/io.chainsafe.web3-unity/Editor/ServerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private enum FetchingStatus
private void Awake()
{
// Get saved settings or revert to default
var projectConfig = ProjectConfigUtilities.Load();
var projectConfig = ProjectConfigUtilities.CreateOrLoad();
projectID = string.IsNullOrEmpty(projectConfig?.ProjectId) ? ProjectIdPrompt : projectConfig.ProjectId;
chainID = string.IsNullOrEmpty(projectConfig?.ChainId) ? ChainIdDefault : projectConfig.ChainId;
chain = string.IsNullOrEmpty(projectConfig?.Chain) ? ChainDefault : projectConfig.Chain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,6 @@ namespace ChainSafe.Gaming.UnityPackage
{
public static class ProjectConfigUtilities
{
private class LocalhostChainConfig : IChainConfig
{
public LocalhostChainConfig(string chainId, string symbol, string chain, string network, string port)
{
var localhostEndPoint = $"127.0.0.1:{port}";

ChainId = chainId;
Symbol = symbol;
Chain = chain;
Network = network;
Rpc = $"http://{localhostEndPoint}";
Ws = $"$ws://{localhostEndPoint}";
BlockExplorerUrl = $"http://{localhostEndPoint}";
}

public string ChainId { get; }
public string Symbol { get; }
public string Chain { get; }
public string Network { get; }
public string Rpc { get; }
public string Ipc => null;
public string Ws { get; }
public string BlockExplorerUrl { get; }
}

private const string AssetName = "ProjectConfigData";

public static ProjectConfigScriptableObject Load()
Expand Down Expand Up @@ -93,5 +68,29 @@ public static void Save(ProjectConfigScriptableObject projectConfig)
UnityEditor.AssetDatabase.SaveAssets();
}
#endif
private class LocalhostChainConfig : IChainConfig
{
public LocalhostChainConfig(string chainId, string symbol, string chain, string network, string port)
{
var localhostEndPoint = $"127.0.0.1:{port}";

ChainId = chainId;
Symbol = symbol;
Chain = chain;
Network = network;
Rpc = $"http://{localhostEndPoint}";
Ws = $"ws://{localhostEndPoint}";
BlockExplorerUrl = $"http://{localhostEndPoint}";
}

public string ChainId { get; }
public string Symbol { get; }
public string Chain { get; }
public string Network { get; }
public string Rpc { get; }
public string Ipc => null;
public string Ws { get; }
public string BlockExplorerUrl { get; }
}
}
}
5 changes: 5 additions & 0 deletions scripts/debug-publish-to-unity-package.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ pushd "%SCRIPT_DIR%\..\src\ChainSafe.Gaming.Unity"
rem Publish the project
dotnet publish ChainSafe.Gaming.Unity.csproj -c Debug /property:Unity=true

IF %ERRORLEVEL% NEQ 0 (
echo Execution failed
exit /b %ERRORLEVEL%
)

set PUBLISH_PATH=bin\Debug\netstandard2.1\publish

rem List generated DLLs
Expand Down
3 changes: 0 additions & 3 deletions src/ChainSafe.Gaming.Mud/ChainSafe.Gaming.Mud.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<ProjectReference Include="..\ChainSafe.Gaming\ChainSafe.Gaming.csproj" />
</ItemGroup>

<ItemGroup>
</ItemGroup>

<ItemGroup Condition="'$(Unity)' != 'True'">
<PackageReference Include="Nethereum.Mud" Version="4.21.2" />
<PackageReference Include="Nethereum.Mud.Contracts" Version="4.21.2" />
Expand Down
9 changes: 9 additions & 0 deletions src/ChainSafe.Gaming.Mud/IMudConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using ChainSafe.Gaming.Mud.Storages;

namespace ChainSafe.Gaming.Mud
{
public interface IMudConfig
{
IMudStorageConfig StorageConfig { get; }
}
}
9 changes: 9 additions & 0 deletions src/ChainSafe.Gaming.Mud/MudConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using ChainSafe.Gaming.Mud.Storages;

namespace ChainSafe.Gaming.Mud
{
public class MudConfig : IMudConfig
{
public IMudStorageConfig StorageConfig { get; set; }
}
}
22 changes: 22 additions & 0 deletions src/ChainSafe.Gaming.Mud/MudException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using ChainSafe.Gaming.Web3;

namespace ChainSafe.Gaming.Mud
{
/// <summary>
/// Represents an exception that is thrown when a MUD-related error occurs.
/// </summary>
/// <seealso cref="Web3Exception"/>
public class MudException : Web3Exception
{
internal MudException(string message)
: base(message)
{
}

internal MudException(string message, Exception innerException)
: base(message, innerException)
{
}
}
}
Loading