diff --git a/ChainSafe.Gaming.sln.DotSettings b/ChainSafe.Gaming.sln.DotSettings
index 035e93aac..f1d07a668 100644
--- a/ChainSafe.Gaming.sln.DotSettings
+++ b/ChainSafe.Gaming.sln.DotSettings
@@ -1,2 +1,3 @@
- True
\ No newline at end of file
+ True
+ True
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Editor.meta b/Packages/io.chainsafe.web3-unity.mud/Editor.meta
new file mode 100644
index 000000000..5f612106e
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Editor.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 11a7864b1ce44989a0c8c4f8e2519489
+timeCreated: 1723644511
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Editor/MudConfigAssetInspector.cs b/Packages/io.chainsafe.web3-unity.mud/Editor/MudConfigAssetInspector.cs
new file mode 100644
index 000000000..5e0279d8d
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Editor/MudConfigAssetInspector.cs
@@ -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();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Editor/MudConfigAssetInspector.cs.meta b/Packages/io.chainsafe.web3-unity.mud/Editor/MudConfigAssetInspector.cs.meta
new file mode 100644
index 000000000..38702f907
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Editor/MudConfigAssetInspector.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 9ecc20721abf4136bec5ec41196b0b90
+timeCreated: 1723644650
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Editor/io.chainsafe.web3-unity.mud.editor.asmdef b/Packages/io.chainsafe.web3-unity.mud/Editor/io.chainsafe.web3-unity.mud.editor.asmdef
new file mode 100644
index 000000000..66675b98d
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Editor/io.chainsafe.web3-unity.mud.editor.asmdef
@@ -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
+}
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Editor/io.chainsafe.web3-unity.mud.editor.asmdef.meta b/Packages/io.chainsafe.web3-unity.mud/Editor/io.chainsafe.web3-unity.mud.editor.asmdef.meta
new file mode 100644
index 000000000..c223b8559
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Editor/io.chainsafe.web3-unity.mud.editor.asmdef.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: bd8b93e754b5421996f07da73283c36e
+timeCreated: 1723644553
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Runtime/MudConfigAsset.cs b/Packages/io.chainsafe.web3-unity.mud/Runtime/MudConfigAsset.cs
new file mode 100644
index 000000000..471bd210d
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Runtime/MudConfigAsset.cs
@@ -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
+{
+ ///
+ /// Represents a configuration asset for MUD module.
+ ///
+ [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();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Runtime/MudConfigAsset.cs.meta b/Packages/io.chainsafe.web3-unity.mud/Runtime/MudConfigAsset.cs.meta
new file mode 100644
index 000000000..e143b43e2
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Runtime/MudConfigAsset.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 9144050b840b41d29f70ad254a875651
+timeCreated: 1723643882
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Runtime/MudStorageType.cs b/Packages/io.chainsafe.web3-unity.mud/Runtime/MudStorageType.cs
new file mode 100644
index 000000000..ac04be949
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Runtime/MudStorageType.cs
@@ -0,0 +1,14 @@
+namespace ChainSafe.Gaming.Mud.Unity
+{
+ ///
+ /// Represents the different types of storage strategies for a MUD World.
+ ///
+ public enum MudStorageType
+ {
+ /// Use Local Storage Strategy.
+ LocalStorage,
+
+ ///Use Off-Chain Indexer Storage Strategy.
+ OffchainIndexer
+ }
+}
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Runtime/MudStorageType.cs.meta b/Packages/io.chainsafe.web3-unity.mud/Runtime/MudStorageType.cs.meta
new file mode 100644
index 000000000..1df46d3ad
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Runtime/MudStorageType.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: f619dd1d0d184130b68ca1ceb96270b3
+timeCreated: 1723644519
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Runtime/io.chainsafe.web3-unity.mud.runtime.asmdef b/Packages/io.chainsafe.web3-unity.mud/Runtime/io.chainsafe.web3-unity.mud.runtime.asmdef
new file mode 100644
index 000000000..b0e2a7a23
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Runtime/io.chainsafe.web3-unity.mud.runtime.asmdef
@@ -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
+}
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity.mud/Runtime/io.chainsafe.web3-unity.mud.runtime.asmdef.meta b/Packages/io.chainsafe.web3-unity.mud/Runtime/io.chainsafe.web3-unity.mud.runtime.asmdef.meta
new file mode 100644
index 000000000..922dc1fdf
--- /dev/null
+++ b/Packages/io.chainsafe.web3-unity.mud/Runtime/io.chainsafe.web3-unity.mud.runtime.asmdef.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 92a3dff85d90408b8d1f8462122eb7d5
+timeCreated: 1723643922
\ No newline at end of file
diff --git a/Packages/io.chainsafe.web3-unity/Editor/ServerSettings.cs b/Packages/io.chainsafe.web3-unity/Editor/ServerSettings.cs
index 8dd4a526f..77f1c7956 100644
--- a/Packages/io.chainsafe.web3-unity/Editor/ServerSettings.cs
+++ b/Packages/io.chainsafe.web3-unity/Editor/ServerSettings.cs
@@ -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;
diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/ProjectConfigUtilities.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/ProjectConfigUtilities.cs
index 19c875698..504f7ac82 100644
--- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/ProjectConfigUtilities.cs
+++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/ProjectConfigUtilities.cs
@@ -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()
@@ -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; }
+ }
}
}
\ No newline at end of file
diff --git a/scripts/debug-publish-to-unity-package.bat b/scripts/debug-publish-to-unity-package.bat
index 07f9a713d..1d40e8c45 100644
--- a/scripts/debug-publish-to-unity-package.bat
+++ b/scripts/debug-publish-to-unity-package.bat
@@ -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
diff --git a/src/ChainSafe.Gaming.Mud/ChainSafe.Gaming.Mud.csproj b/src/ChainSafe.Gaming.Mud/ChainSafe.Gaming.Mud.csproj
index bfe56d6eb..7ff81156e 100644
--- a/src/ChainSafe.Gaming.Mud/ChainSafe.Gaming.Mud.csproj
+++ b/src/ChainSafe.Gaming.Mud/ChainSafe.Gaming.Mud.csproj
@@ -14,9 +14,6 @@
-
-
-
diff --git a/src/ChainSafe.Gaming.Mud/IMudConfig.cs b/src/ChainSafe.Gaming.Mud/IMudConfig.cs
new file mode 100644
index 000000000..b4a6b60de
--- /dev/null
+++ b/src/ChainSafe.Gaming.Mud/IMudConfig.cs
@@ -0,0 +1,9 @@
+using ChainSafe.Gaming.Mud.Storages;
+
+namespace ChainSafe.Gaming.Mud
+{
+ public interface IMudConfig
+ {
+ IMudStorageConfig StorageConfig { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/ChainSafe.Gaming.Mud/MudConfig.cs b/src/ChainSafe.Gaming.Mud/MudConfig.cs
new file mode 100644
index 000000000..d25ae558e
--- /dev/null
+++ b/src/ChainSafe.Gaming.Mud/MudConfig.cs
@@ -0,0 +1,9 @@
+using ChainSafe.Gaming.Mud.Storages;
+
+namespace ChainSafe.Gaming.Mud
+{
+ public class MudConfig : IMudConfig
+ {
+ public IMudStorageConfig StorageConfig { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/ChainSafe.Gaming.Mud/MudException.cs b/src/ChainSafe.Gaming.Mud/MudException.cs
new file mode 100644
index 000000000..6884cd4e6
--- /dev/null
+++ b/src/ChainSafe.Gaming.Mud/MudException.cs
@@ -0,0 +1,22 @@
+using System;
+using ChainSafe.Gaming.Web3;
+
+namespace ChainSafe.Gaming.Mud
+{
+ ///
+ /// Represents an exception that is thrown when a MUD-related error occurs.
+ ///
+ ///
+ public class MudException : Web3Exception
+ {
+ internal MudException(string message)
+ : base(message)
+ {
+ }
+
+ internal MudException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ChainSafe.Gaming.Mud/MudExtensions.cs b/src/ChainSafe.Gaming.Mud/MudExtensions.cs
index e847048b7..50f707421 100644
--- a/src/ChainSafe.Gaming.Mud/MudExtensions.cs
+++ b/src/ChainSafe.Gaming.Mud/MudExtensions.cs
@@ -1,18 +1,68 @@
-using System.Linq;
+using ChainSafe.Gaming.Mud.Storages;
+using ChainSafe.Gaming.Mud.Storages.InMemory;
+using ChainSafe.Gaming.Mud.Worlds;
+using ChainSafe.Gaming.RPC.Events;
using ChainSafe.Gaming.Web3.Build;
using ChainSafe.Gaming.Web3.Core.Nethereum;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ChainSafe.Gaming.Mud
{
public static class MudExtensions
{
+ ///
+ /// Configures and enables the use of MUD for the Web3 client that is being built.
+ ///
+ /// The Web3 service collection to configure.
+ /// The MUD configuration.
+ /// The same service collection that was passed in. This enables fluent style.
+ public static IWeb3ServiceCollection UseMud(this IWeb3ServiceCollection services, IMudConfig mudConfig)
+ {
+ services.AssertServiceNotBound();
+ services.AssertConfigurationNotBound();
+
+ services.ConfigureMud(mudConfig);
+ services.UseMud();
+
+ return services;
+ }
+
+ ///
+ /// Configures the MUD services with the provided MUD configuration.
+ ///
+ /// The Web3 service collection to configure.
+ /// The MUD configuration.
+ /// The same service collection that was passed in. This enables fluent style.
+ public static IWeb3ServiceCollection ConfigureMud(this IWeb3ServiceCollection services, IMudConfig mudConfig)
+ {
+ services.Replace(ServiceDescriptor.Singleton(mudConfig));
+
+ return services;
+ }
+
+ ///
+ /// Enables the use of MUD for the Web3 client that is being built.
+ ///
+ /// The Web3 service collection to configure.
+ /// The same service collection that was passed in. This enables fluent style.
public static IWeb3ServiceCollection UseMud(this IWeb3ServiceCollection services)
{
- services.AddSingleton(typeof(MudFacade));
+ services.AssertServiceNotBound();
+
+ services.AddSingleton();
services.AddSingleton();
+ services.AddSingleton();
+
+ // Storage strategies
+ services.AddTransient(); // todo implement OffchainIndexerMudStorage, then register it in the next line
+
+ if (!services.IsBound())
+ {
+ services.UseEvents();
+ }
- if (!services.IsNethereumAdaptersBound())
+ if (!services.IsBound())
{
services.UseNethereumAdapters();
}
@@ -20,6 +70,11 @@ public static IWeb3ServiceCollection UseMud(this IWeb3ServiceCollection services
return services;
}
+ ///
+ /// Retrieves the MudFacade instance, a facade class for all the MUD-related functionality, from the Web3 service provider.
+ ///
+ /// The Web3 client.
+ /// The MudFacade instance.
public static MudFacade Mud(this Web3.Web3 web3) => web3.ServiceProvider.GetRequiredService();
}
}
\ No newline at end of file
diff --git a/src/ChainSafe.Gaming.Mud/MudFacade.cs b/src/ChainSafe.Gaming.Mud/MudFacade.cs
index 85b3d6c90..dc4503e0d 100644
--- a/src/ChainSafe.Gaming.Mud/MudFacade.cs
+++ b/src/ChainSafe.Gaming.Mud/MudFacade.cs
@@ -1,23 +1,35 @@
+using System.Diagnostics;
+using System.Threading.Tasks;
+using ChainSafe.Gaming.Mud.Worlds;
+using ChainSafe.Gaming.Web3.Environment;
+
namespace ChainSafe.Gaming.Mud
{
+ ///
+ /// A facade class for all the MUD-related functionality.
+ ///
public class MudFacade
{
private readonly MudWorldFactory worldFactory;
+ private readonly ILogWriter logWriter;
- public MudFacade(MudWorldFactory worldFactory)
+ public MudFacade(MudWorldFactory worldFactory, ILogWriter logWriter)
{
+ this.logWriter = logWriter;
this.worldFactory = worldFactory;
}
///
- /// Builds a MUD World Client to exchange messages with a World Contract.
+ /// Builds a new MudWorld client based on the provided configuration.
///
- /// The address of the World Contract.
- /// The ABI of the World Contract.
- /// The client for the MUD World Contract.
- public MudWorld BuildWorld(string contractAddress, string worldContractAbi)
+ /// The configuration settings for the world.
+ /// A Task that represents the asynchronous operation. The Task's result is the created MudWorld.
+ public Task BuildWorld(IMudWorldConfig worldConfig)
{
- return worldFactory.Build(contractAddress, worldContractAbi);
+ var stopwatch = Stopwatch.StartNew();
+ var world = worldFactory.Build(worldConfig);
+ logWriter.Log($"Loaded world {worldConfig.ContractAddress} in {stopwatch.Elapsed}");
+ return world;
}
}
}
\ No newline at end of file
diff --git a/src/ChainSafe.Gaming.Mud/MudUtils.cs b/src/ChainSafe.Gaming.Mud/MudUtils.cs
new file mode 100644
index 000000000..b9c6a3920
--- /dev/null
+++ b/src/ChainSafe.Gaming.Mud/MudUtils.cs
@@ -0,0 +1,23 @@
+using Nethereum.Mud.EncodingDecoding;
+
+namespace ChainSafe.Gaming.Mud
+{
+ public static class MudUtils
+ {
+ public static byte[] TableResourceId(string @namespace, string tableName, bool isOffChain = false)
+ {
+ var trimmedName = ResourceEncoder.TrimNameAsValidSize(tableName);
+
+ return isOffChain
+ ? ResourceEncoder.EncodeOffchainTable(@namespace, trimmedName)
+ : ResourceEncoder.EncodeTable(@namespace, trimmedName);
+ }
+
+ public static string NamespaceFunctionName(string @namespace, string function)
+ {
+ return !function.StartsWith($"{@namespace}__")
+ ? $"{@namespace}__{function}"
+ : function; // already contains namespace
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ChainSafe.Gaming.Mud/MudWorld.cs b/src/ChainSafe.Gaming.Mud/MudWorld.cs
deleted file mode 100644
index 2a49846ab..000000000
--- a/src/ChainSafe.Gaming.Mud/MudWorld.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System.Threading.Tasks;
-using ChainSafe.Gaming.Evm.Contracts;
-using ChainSafe.Gaming.Evm.Transactions;
-using Nethereum.Contracts;
-using Nethereum.Hex.HexTypes;
-using Nethereum.Mud;
-using Nethereum.Mud.Contracts.World;
-using Nethereum.Web3;
-
-namespace ChainSafe.Gaming.Mud
-{
- // todo add event subscription
- public class MudWorld : IMudWorld, IContract
- {
- private readonly IContract contract;
-
- public MudWorld(IWeb3 nethWeb3, IContract contract)
- {
- this.contract = contract;
- WorldService = new WorldService(nethWeb3, contract.Address);
- }
-
- string IContract.Address => contract.Address;
-
- ///
- /// A Nethereum World Service. Use this if you need more control over the World.
- ///
- public WorldService WorldService { get; }
-
- public async Task Query()
- where TRecord : TableRecordSingleton, new()
- where TValue : class, new()
- {
- return (await WorldService.GetRecordTableQueryAsync()).Values;
- }
-
- public async Task Query(TKey key)
- where TRecord : TableRecord, new()
- where TKey : class, new()
- where TValue : class, new()
- {
- var record = new TRecord { Keys = key };
- return (await WorldService.GetRecordTableQueryAsync(record)).Values;
- }
-
- IContract IContract.Attach(string address)
- {
- return contract.Attach(address);
- }
-
- Task