diff --git a/Packages/io.chainsafe.web3-unity.hyperplay/Runtime/Scripts/HyperPlayConnectionProvider.cs b/Packages/io.chainsafe.web3-unity.hyperplay/Runtime/Scripts/HyperPlayConnectionProvider.cs index 112bad78f..0969d96a8 100644 --- a/Packages/io.chainsafe.web3-unity.hyperplay/Runtime/Scripts/HyperPlayConnectionProvider.cs +++ b/Packages/io.chainsafe.web3-unity.hyperplay/Runtime/Scripts/HyperPlayConnectionProvider.cs @@ -17,7 +17,7 @@ public override Task Initialize() { return Task.CompletedTask; } - + public override Web3Builder ConfigureServices(Web3Builder web3Builder) { return web3Builder.Configure(services => @@ -27,7 +27,7 @@ public override Web3Builder ConfigureServices(Web3Builder web3Builder) // RememberSession = rememberMeToggle.isOn || _storedSessionAvailable, }; #if UNITY_WEBGL && !UNITY_EDITOR - services.UseHyperPlay(config); + services.UseHyperPlay(config); #else services.UseHyperPlay(config); #endif diff --git a/Packages/io.chainsafe.web3-unity.marketplace/Runtime/Scripts/Marketplace/Marketplace.cs b/Packages/io.chainsafe.web3-unity.marketplace/Runtime/Scripts/Marketplace/Marketplace.cs index 674c9b362..0d9334ac3 100644 --- a/Packages/io.chainsafe.web3-unity.marketplace/Runtime/Scripts/Marketplace/Marketplace.cs +++ b/Packages/io.chainsafe.web3-unity.marketplace/Runtime/Scripts/Marketplace/Marketplace.cs @@ -18,7 +18,7 @@ namespace Scripts.EVM.Marketplace public class Marketplace { #region Methods - + /// /// Gets profile marketplaces. /// Path: https://api.gaming.chainsafe.io/v1/projects/{projectID}/marketplaces @@ -31,7 +31,7 @@ public class Marketplace var response = await CSServer.GetDataWithToken(path, bearerToken); return response; } - + /// /// Gets project collections. /// Path: https://api.gaming.chainsafe.io/v1/projects/{projectID}/collections @@ -44,7 +44,7 @@ public class Marketplace var response = await CSServer.GetDataWithToken(path, bearerToken); return response; } - + /// /// Gets all items in a project. /// Path: https://api.gaming.chainsafe.io/v1/projects/{projectID}/items @@ -83,7 +83,7 @@ public class Marketplace var response = await CSServer.GetData(path); return response; } - + /// /// Gets all tokens in a project. /// Path: https://api.gaming.chainsafe.io/v1/projects/{projectID}/tokens @@ -150,7 +150,7 @@ public class Marketplace var response = await CSServer.GetData(path); return response; } - + /// /// Creates a 721 collection /// /// Path https://api.gaming.chainsafe.io/v1/projects/8524f420-ecd1-4cfd-a651-706ade97cac7/collections @@ -162,9 +162,9 @@ public class Marketplace /// Contract send data object public static async Task Create721Collection(string _bearerToken, string _name, string _description, bool _isMintingPublic) { - var logoImageData = await UploadPlatforms.GetImageData(); - var bannerImageData = await UploadPlatforms.GetImageData(); - var formData = new List + var logoImageData = await UploadPlatforms.GetImageData(); + var bannerImageData = await UploadPlatforms.GetImageData(); + var formData = new List { new MultipartFormDataSection("name", _name), new MultipartFormDataSection("description", _description), @@ -177,12 +177,12 @@ public static async Task Create721Collection(string _bearerT new MultipartFormDataSection("contractAddress", ChainSafeContracts.MarketplaceContracts[Web3Accessor.Web3.ChainConfig.ChainId]), new MultipartFormDataSection("type", "erc721") }; - var path = "/collections"; - var collectionResponse = await CSServer.CreateData(_bearerToken, path, formData); - var collectionData = JsonConvert.DeserializeObject(collectionResponse); - var method = "create721Collection"; - object[] args = - { + var path = "/collections"; + var collectionResponse = await CSServer.CreateData(_bearerToken, path, formData); + var collectionData = JsonConvert.DeserializeObject(collectionResponse); + var method = "create721Collection"; + object[] args = + { Web3Accessor.Web3.ProjectConfig.ProjectId, collectionData.id, _name, @@ -190,11 +190,11 @@ public static async Task Create721Collection(string _bearerT collectionData.banner, _isMintingPublic }; - var contract = Web3Accessor.Web3.ContractBuilder.Build(ABI.MarketplaceFactory, ChainSafeContracts.MarketplaceContracts[Web3Accessor.Web3.ChainConfig.ChainId]); - var data = await contract.SendWithReceipt(method, args); - return data.receipt; + var contract = Web3Accessor.Web3.ContractBuilder.Build(ABI.MarketplaceFactory, ChainSafeContracts.MarketplaceContracts[Web3Accessor.Web3.ChainConfig.ChainId]); + var data = await contract.SendWithReceipt(method, args); + return data.receipt; } - + /// /// Creates a 1155 collection /// Path https://api.gaming.chainsafe.io/v1/projects/8524f420-ecd1-4cfd-a651-706ade97cac7/collections/ @@ -235,7 +235,7 @@ public static async Task Create1155Collection(string _bearer _isMintingPublic }; var contract = Web3Accessor.Web3.ContractBuilder.Build(ABI.MarketplaceFactory, ChainSafeContracts.MarketplaceContracts[Web3Accessor.Web3.ChainConfig.ChainId]); - var data = await contract.SendWithReceipt(method, args); + var data = await contract.SendWithReceipt(method, args); return data.receipt; } catch (Web3Exception e) @@ -244,7 +244,7 @@ public static async Task Create1155Collection(string _bearer throw; } } - + /// /// /// Mints a 721 collection nft to the collection /// @@ -262,7 +262,7 @@ public static async Task Mint721CollectionNft(string _collec _uri }; var contract = Web3Accessor.Web3.ContractBuilder.Build(ABI.GeneralErc721, _collectionContract); - var data = await contract.SendWithReceipt(method, args); + var data = await contract.SendWithReceipt(method, args); return data.receipt; } catch (Web3Exception e) @@ -271,7 +271,7 @@ public static async Task Mint721CollectionNft(string _collec throw; } } - + /// /// Mints a 1155 collection nft to the collection /// @@ -291,9 +291,9 @@ public static async Task Mint1155CollectionNft(string _colle _uri, amount }; - + var contract = Web3Accessor.Web3.ContractBuilder.Build(ABI.GeneralErc1155, _collectionContract); - var data = await contract.SendWithReceipt(method, args); + var data = await contract.SendWithReceipt(method, args); return data.receipt; } catch (Web3Exception e) @@ -302,7 +302,7 @@ public static async Task Mint1155CollectionNft(string _colle throw; } } - + /// /// Deletes a collection that isn't on chain yet by ID /// Path https://api.gaming.chainsafe.io/v1/projects/8524f420-ecd1-4cfd-a651-706ade97cac7/collections/e38e9465-fb9b-4316-8d1d-c77e81b50d6a @@ -316,7 +316,7 @@ public static async Task DeleteCollection(string _bearerToken, string _c var response = await CSServer.DeleteData(_bearerToken, path); return response; } - + /// /// Creates a marketplace /// Path: https://api.gaming.chainsafe.io/v1/projects/8524f420-ecd1-4cfd-a651-706ade97cac7/marketplaces @@ -350,7 +350,7 @@ public static async Task CreateMarketplace(string _bearerTok _whitelisting }; var contract = Web3Accessor.Web3.ContractBuilder.Build(ABI.MarketplaceFactory, ChainSafeContracts.MarketplaceContracts[Web3Accessor.Web3.ChainConfig.ChainId]); - var data = await contract.SendWithReceipt(method, args); + var data = await contract.SendWithReceipt(method, args); return data.receipt; } catch (Web3Exception e) @@ -359,7 +359,7 @@ public static async Task CreateMarketplace(string _bearerTok throw; } } - + /// /// Deletes a marketplace that isn't on chain yet by ID /// Path: https://api.gaming.chainsafe.io/v1/projects/8524f420-ecd1-4cfd-a651-706ade97cac7/marketplaces/{marketplaceId} @@ -373,7 +373,7 @@ public static async Task DeleteMarketplace(string _bearerToken, string _ var response = await CSServer.DeleteData(_bearerToken, path); return response; } - + /// /// Approves the marketplace to list 721 Nfts /// @@ -393,7 +393,7 @@ public static async Task SetApprovalMarketplace(string _nftC }; var abi = _type == "721" ? Token.ABI.GeneralErc721 : Token.ABI.GeneralErc1155; var contract = Web3Accessor.Web3.ContractBuilder.Build(abi, _nftContract); - var data = await contract.SendWithReceipt(method, args); + var data = await contract.SendWithReceipt(method, args); return data.receipt; } catch (Web3Exception e) @@ -402,7 +402,7 @@ public static async Task SetApprovalMarketplace(string _nftC throw; } } - + /// /// Purchases NFT from the marketplace /// @@ -425,7 +425,7 @@ public static async Task PurchaseNft(string _marketplaceCont Value = new HexBigInteger(BigInteger.Parse(_amountToSend).ToString("X")) }; var contract = Web3Accessor.Web3.ContractBuilder.Build(ABI.Marketplace, _marketplaceContract); - var data = await contract.SendWithReceipt(method, args, tx); + var data = await contract.SendWithReceipt(method, args, tx); return data.receipt; } catch (Web3Exception e) @@ -434,7 +434,7 @@ public static async Task PurchaseNft(string _marketplaceCont throw; } } - + /// /// Lists Nfts to the marketplace /// @@ -459,7 +459,7 @@ public static async Task ListNftsToMarketplace(string _marke deadline }; var contract = Web3Accessor.Web3.ContractBuilder.Build(ABI.Marketplace, _marketplaceContract); - var data = await contract.SendWithReceipt(method, args); + var data = await contract.SendWithReceipt(method, args); return data.receipt; } catch (Web3Exception e) @@ -486,7 +486,7 @@ public static void PrintObject(object obj) } #endregion - + #endregion } } \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Editor/ABICSharpConverter.cs b/Packages/io.chainsafe.web3-unity/Editor/ABICSharpConverter.cs index e4d41b8a4..2c1b68bba 100644 --- a/Packages/io.chainsafe.web3-unity/Editor/ABICSharpConverter.cs +++ b/Packages/io.chainsafe.web3-unity/Editor/ABICSharpConverter.cs @@ -36,7 +36,7 @@ public static ABICSharpConverter Instance } // UI rendering method - private void OnGUI() + private void OnGUI() { var style = new GUIStyle(GUI.skin.label) { richText = true }; diff --git a/Packages/io.chainsafe.web3-unity/Editor/ABIConverter.cs b/Packages/io.chainsafe.web3-unity/Editor/ABIConverter.cs index 30955c748..a14b6dc0d 100644 --- a/Packages/io.chainsafe.web3-unity/Editor/ABIConverter.cs +++ b/Packages/io.chainsafe.web3-unity/Editor/ABIConverter.cs @@ -18,7 +18,7 @@ public static void ShowWindow() { GetWindow("ChainSafe ABI Formatter"); } - + private void OnGUI() { diff --git a/Packages/io.chainsafe.web3-unity/Editor/ConnectionHandlerEditor.cs b/Packages/io.chainsafe.web3-unity/Editor/ConnectionHandlerEditor.cs index c6d77fe42..ba53bab5a 100644 --- a/Packages/io.chainsafe.web3-unity/Editor/ConnectionHandlerEditor.cs +++ b/Packages/io.chainsafe.web3-unity/Editor/ConnectionHandlerEditor.cs @@ -12,13 +12,13 @@ public struct Provider { [JsonProperty("name")] public string Name { get; private set; } - + [JsonProperty("path")] public string Path { get; private set; } } - + private bool _foldout; - + public override void OnInspectorGUI() { base.OnInspectorGUI(); @@ -26,31 +26,31 @@ public override void OnInspectorGUI() var providers = Resources.LoadAll(string.Empty); _foldout = EditorGUILayout.Foldout(_foldout, "Connection Providers"); - + if (_foldout) { List availableProviders = new List(); - + var providersProperty = serializedObject.FindProperty("providers"); int arraySize = providersProperty.arraySize; - + for (int i = 0; i < arraySize; i++) { var providerProperty = providersProperty.GetArrayElementAtIndex(i); - + if (providerProperty.objectReferenceValue == null) { providersProperty.DeleteArrayElementAtIndex(i); - + serializedObject.ApplyModifiedProperties(); - + return; } - + availableProviders.Add(providerProperty.objectReferenceValue as ConnectionProvider); } - + foreach (var provider in providers) { var loadedProvider = provider.ProviderRow; @@ -58,14 +58,14 @@ public override void OnInspectorGUI() if (loadedProvider == null) { Debug.LogWarning($"Error loading {provider.Name} Provider."); - + continue; } - + EditorGUI.BeginChangeCheck(); bool isAvailable = availableProviders.Contains(loadedProvider); - + isAvailable = GUILayout.Toggle(isAvailable, provider.Name); if (EditorGUI.EndChangeCheck()) @@ -83,7 +83,7 @@ public override void OnInspectorGUI() } serializedObject.ApplyModifiedProperties(); - + return; } } diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Resources/ABIContractClassTemplate.txt b/Packages/io.chainsafe.web3-unity/Runtime/Resources/ABIContractClassTemplate.txt index 255f83f97..55f13339b 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Resources/ABIContractClassTemplate.txt +++ b/Packages/io.chainsafe.web3-unity/Runtime/Resources/ABIContractClassTemplate.txt @@ -16,6 +16,7 @@ namespace ChainSafe.Gaming.Evm.Contracts.Custom { public class {CLASS_NAME} : ICustomContract { + public string Address => OriginalContract.Address; public string ABI => "{CONTRACT_ABI}"; diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Resources/TestContract.cs b/Packages/io.chainsafe.web3-unity/Runtime/Resources/TestContract.cs index 18948d3f9..a0afdfb57 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Resources/TestContract.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Resources/TestContract.cs @@ -15,6 +15,8 @@ namespace ChainSafe.Gaming.Evm.Contracts.Custom { public class TestContract : ICustomContract { + public string Address => OriginalContract.Address; + public string ABI => "[ { \"inputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"constructor\" }, { \"inputs\": [], \"name\": \"AlreadySameStatus\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"AmountInvalid\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"CanNotModify\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"DeadlineInvalid\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"EtherTransferFailed\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"FeeReceiverInvalid\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"IncorrectAmountSupplied\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"IncorrectLength\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ItemExpired\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ItemIdInvalid\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"MaxFeeInvalid\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NFTAlreadyWhitelisted\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NftTokenInvalid\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NotEnoughBalance\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"NotExpired\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"OperatorInvalid\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"TotalFeePercentInvalid\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"Unauthorized\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"WhitelistingDisabled\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ZeroAddress\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ZeroFeePercent\", \"type\": \"error\" }, { \"inputs\": [], \"name\": \"ZeroPrice\", \"type\": \"error\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"treasury\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"feePercent\", \"type\": \"uint256\" } ], \"name\": \"ChainSafeFeeUpdated\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"feeCollector\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"receiver\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"amount\", \"type\": \"uint256\" } ], \"name\": \"FeeClaimed\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"feeReceiver\", \"type\": \"address\" } ], \"name\": \"FeeReceiverRemoved\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"feeReceiver\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"feePercent\", \"type\": \"uint256\" } ], \"name\": \"FeeReceiverSet\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint8\", \"name\": \"version\", \"type\": \"uint8\" } ], \"name\": \"Initialized\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"itemId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"owner\", \"type\": \"address\" } ], \"name\": \"ItemCancelled\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address\", \"name\": \"nftContract\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"itemId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"seller\", \"type\": \"address\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"price\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"deadline\", \"type\": \"uint256\" } ], \"name\": \"ItemListed\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"itemId\", \"type\": \"uint256\" }, { \"indexed\": false, \"internalType\": \"address\", \"name\": \"buyer\", \"type\": \"address\" } ], \"name\": \"ItemSold\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"uint256\", \"name\": \"feePercent\", \"type\": \"uint256\" } ], \"name\": \"MaxFeeUpdated\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address[]\", \"name\": \"nftAddresses\", \"type\": \"address[]\" } ], \"name\": \"NFTBlacklisted\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"address[]\", \"name\": \"nftAddresses\", \"type\": \"address[]\" } ], \"name\": \"NFTWhitelisted\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"previousAdminRole\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"newAdminRole\", \"type\": \"bytes32\" } ], \"name\": \"RoleAdminChanged\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" } ], \"name\": \"RoleGranted\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": true, \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" }, { \"indexed\": true, \"internalType\": \"address\", \"name\": \"sender\", \"type\": \"address\" } ], \"name\": \"RoleRevoked\", \"type\": \"event\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"internalType\": \"bool\", \"name\": \"isEnabled\", \"type\": \"bool\" } ], \"name\": \"WhitelistingStatusUpdated\", \"type\": \"event\" }, { \"inputs\": [], \"name\": \"CREATOR_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"DEFAULT_ADMIN_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"UPDATER_ROLE\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"name\": \"_feeReceiverDetails\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"feePercent\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"feeCollected\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"activeItems\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"nftContract\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"internalType\": \"address\", \"name\": \"seller\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"price\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"deadline\", \"type\": \"uint256\" } ], \"internalType\": \"struct Marketplace.MarketItem[]\", \"name\": \"\", \"type\": \"tuple[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"nftAddresses\", \"type\": \"address[]\" } ], \"name\": \"blacklistNFTContracts\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"itemIds\", \"type\": \"uint256[]\" } ], \"name\": \"cancelExpiredListings\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"itemId\", \"type\": \"uint256\" } ], \"name\": \"cancelListing\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"chainsafeTreasury\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"receiver\", \"type\": \"address\" } ], \"name\": \"claimFee\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bool\", \"name\": \"isEnable\", \"type\": \"bool\" } ], \"name\": \"enableWhitelisting\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"from\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"to\", \"type\": \"uint256\" } ], \"name\": \"expiredListingIds\", \"outputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"feeReceiver\", \"type\": \"address\" } ], \"name\": \"feeCollectedByReceiver\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"feeReceiver\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"feeReceiver\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"feePercent\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"feeReceiversNumber\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" } ], \"name\": \"getRoleAdmin\", \"outputs\": [ { \"internalType\": \"bytes32\", \"name\": \"\", \"type\": \"bytes32\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"grantRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"hasRole\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"string\", \"name\": \"projectID\", \"type\": \"string\" }, { \"internalType\": \"string\", \"name\": \"marketplaceID\", \"type\": \"string\" }, { \"internalType\": \"address\", \"name\": \"creator\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"updater\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"treasury\", \"type\": \"address\" }, { \"internalType\": \"bool\", \"name\": \"isWhitelistingEnable\", \"type\": \"bool\" }, { \"internalType\": \"uint256\", \"name\": \"chainsafeFeePercent\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"maxPercent\", \"type\": \"uint256\" } ], \"name\": \"initialize\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"name\": \"isNftToken\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"itemId\", \"type\": \"uint256\" } ], \"name\": \"itemById\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"nftContract\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"internalType\": \"address\", \"name\": \"seller\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"price\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"deadline\", \"type\": \"uint256\" } ], \"internalType\": \"struct Marketplace.MarketItem\", \"name\": \"\", \"type\": \"tuple\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"nftContract\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"price\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"deadline\", \"type\": \"uint256\" } ], \"name\": \"listItem\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"nftContracts\", \"type\": \"address[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"tokenIds\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"amounts\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"prices\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"deadlines\", \"type\": \"uint256[]\" } ], \"name\": \"listItems\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"marketplaceID\", \"outputs\": [ { \"internalType\": \"string\", \"name\": \"\", \"type\": \"string\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"maxFeePercent\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" } ], \"name\": \"nftToken\", \"outputs\": [ { \"internalType\": \"address\", \"name\": \"token\", \"type\": \"address\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"uint256[]\", \"name\": \"ids\", \"type\": \"uint256[]\" }, { \"internalType\": \"uint256[]\", \"name\": \"values\", \"type\": \"uint256[]\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"onERC1155BatchReceived\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"value\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"onERC1155Received\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"operator\", \"type\": \"address\" }, { \"internalType\": \"address\", \"name\": \"from\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"id\", \"type\": \"uint256\" }, { \"internalType\": \"bytes\", \"name\": \"data\", \"type\": \"bytes\" } ], \"name\": \"onERC721Received\", \"outputs\": [ { \"internalType\": \"bytes4\", \"name\": \"\", \"type\": \"bytes4\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"projectID\", \"outputs\": [ { \"internalType\": \"string\", \"name\": \"\", \"type\": \"string\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"itemId\", \"type\": \"uint256\" } ], \"name\": \"purchaseItem\", \"outputs\": [], \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"feeReceiver\", \"type\": \"address\" } ], \"name\": \"removeFeeReceiver\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"renounceRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes32\", \"name\": \"role\", \"type\": \"bytes32\" }, { \"internalType\": \"address\", \"name\": \"account\", \"type\": \"address\" } ], \"name\": \"revokeRole\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"feeReceiver\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"feePercent\", \"type\": \"uint256\" } ], \"name\": \"setFeeReceiver\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"uint256\", \"name\": \"feePercent\", \"type\": \"uint256\" } ], \"name\": \"setMaxFeePercent\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"bytes4\", \"name\": \"interfaceId\", \"type\": \"bytes4\" } ], \"name\": \"supportsInterface\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"totalFeePercent\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"feePercent\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"totalListings\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"treasury\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"feePercent\", \"type\": \"uint256\" } ], \"name\": \"updateChainSafeTreasury\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"user\", \"type\": \"address\" } ], \"name\": \"usersListingIds\", \"outputs\": [ { \"internalType\": \"uint256[]\", \"name\": \"\", \"type\": \"uint256[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address\", \"name\": \"user\", \"type\": \"address\" } ], \"name\": \"usersListings\", \"outputs\": [ { \"components\": [ { \"internalType\": \"address\", \"name\": \"nftContract\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"tokenId\", \"type\": \"uint256\" }, { \"internalType\": \"address\", \"name\": \"seller\", \"type\": \"address\" }, { \"internalType\": \"uint256\", \"name\": \"price\", \"type\": \"uint256\" }, { \"internalType\": \"uint256\", \"name\": \"deadline\", \"type\": \"uint256\" } ], \"internalType\": \"struct Marketplace.MarketItem[]\", \"name\": \"\", \"type\": \"tuple[]\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"inputs\": [ { \"internalType\": \"address[]\", \"name\": \"nftAddresses\", \"type\": \"address[]\" } ], \"name\": \"whitelistNFTContracts\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"whitelistingEnable\", \"outputs\": [ { \"internalType\": \"bool\", \"name\": \"\", \"type\": \"bool\" } ], \"stateMutability\": \"view\", \"type\": \"function\" }, { \"stateMutability\": \"payable\", \"type\": \"receive\" } ]"; diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionHandler.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionHandler.cs index 51d59ae07..8ce3774c9 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionHandler.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionHandler.cs @@ -14,8 +14,8 @@ public class ConnectionHandler : MonoBehaviour, IConnectionHandler [Space] [SerializeField] private ConnectModal connectModal; // Handed in ConnectionHandlerEditor - [HideInInspector] [SerializeField] private ConnectionProvider[] providers; - + [HideInInspector][SerializeField] private ConnectionProvider[] providers; + public string GelatoApiKey => gelatoApiKey; public IWeb3BuilderServiceAdapter[] Web3BuilderServiceAdapters { get; private set; } public IWeb3InitializedHandler[] Web3InitializedHandlers { get; private set; } @@ -34,7 +34,7 @@ protected virtual async void Initialize() Web3BuilderServiceAdapters = GetComponents(); Web3InitializedHandlers = GetComponents(); - + foreach (var provider in providers) { if (provider != null && provider.IsAvailable) @@ -42,11 +42,11 @@ protected virtual async void Initialize() var instantiatedProvider = connectModal.AddProvider(provider); await instantiatedProvider.Initialize(); - + instantiatedProvider.ConnectButton.onClick.AddListener(delegate { ConnectionProvider = instantiatedProvider; - + ConnectClicked(); }); } @@ -57,7 +57,7 @@ private async void ConnectClicked() { await TryConnect(); } - + /// /// Try to Connect and displays error and throws exception on a failed attempt. /// @@ -75,7 +75,7 @@ public virtual async Task TryConnect() { connectModal.DisplayError( $"Connection failed, please try again."); - + ConnectionProvider.HandleException(e); } } diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionProvider.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionProvider.cs index 0197afda3..c5b1c07e6 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionProvider.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionProvider.cs @@ -16,18 +16,18 @@ public abstract class ConnectionProvider : MonoBehaviour, IWeb3BuilderServiceAda /// Could be platform specific or other conditions. /// public abstract bool IsAvailable { get; } - + /// /// Button to connect to the wallet. /// [field: SerializeField] public Button ConnectButton { get; private set; } - + /// /// Initialize Connection provider. /// /// Awaitable Task. public abstract Task Initialize(); - + /// /// Configure services for the Web3 instance. /// This is where you add wallet connection services to . diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionProviderConfig.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionProviderConfig.cs index 437c94d72..87cc3bea7 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionProviderConfig.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/ConnectionProviderConfig.cs @@ -12,7 +12,7 @@ public class ConnectionProviderConfig : ScriptableObject /// Name of connection provider. /// [field: SerializeField] public string Name { get; private set; } - + /// /// Row Prefab of connection provider. /// diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/IConnectionHandler.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/IConnectionHandler.cs index 12188f790..2dc806009 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/IConnectionHandler.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/IConnectionHandler.cs @@ -30,7 +30,7 @@ public interface IConnectionHandler /// All Web3 initialized handlers called when Web3 instance is initialized. /// public IWeb3InitializedHandler[] Web3InitializedHandlers { get; } - + /// /// Connection Provider used to create connection. /// diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/WalletConnectConnectionProvider.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/WalletConnectConnectionProvider.cs index e25580af5..81dbc6515 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/WalletConnectConnectionProvider.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Connection/WalletConnectConnectionProvider.cs @@ -12,14 +12,14 @@ namespace ChainSafe.Gaming.UnityPackage.Connection public class WalletConnectConnectionProvider : ConnectionProvider { [SerializeField] private WalletConnectConfigSO walletConnectConfig; - + public override bool IsAvailable => Application.isEditor || Application.platform != RuntimePlatform.WebGLPlayer; - + public override Task Initialize() { return Task.CompletedTask; } - + public override Web3Builder ConfigureServices(Web3Builder web3Builder) { return web3Builder.Configure(services => diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Remote/CSServer.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Remote/CSServer.cs index 6c10608c2..e5997cdd9 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Remote/CSServer.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Remote/CSServer.cs @@ -13,7 +13,7 @@ namespace Scripts.EVM.Remote public class CSServer { #region Fields - + private static readonly string host = "https://api.gaming.chainsafe.io/v1/projects/"; #endregion @@ -38,7 +38,7 @@ public static async Task GetData(string _path) var response = JsonConvert.DeserializeObject(json); return response; } - + /// /// Unity web request helper function to retrieve data. /// @@ -60,7 +60,7 @@ public static async Task GetDataWithToken(string _path, string _bearerToke var response = JsonConvert.DeserializeObject(json); return response; } - + /// /// Unity web request helper function to delete data entries from collections/marketplace. /// @@ -79,7 +79,7 @@ public static async Task DeleteData(string _bearerToken, string _path) } return "Deleted successfully"; } - + /// /// Unity web request helper function to create data entries with collections/marketplace. /// diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/MarketplaceModel.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/MarketplaceModel.cs index 70e36eeb7..3a02ea946 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/MarketplaceModel.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/MarketplaceModel.cs @@ -42,7 +42,7 @@ public class Marketplace } #endregion - + #region MarketplaceItems public class MarketplaceItemsResponse @@ -54,7 +54,7 @@ public class MarketplaceItemsResponse public List items { get; set; } public List owners { get; set; } } - + public class Item { public string id { get; set; } @@ -77,8 +77,8 @@ public class Token public string contract_address { get; set; } public string uri { get; set; } public Metadata metadata { get; set; } - } - + } + public class Metadata { public List attributes { get; set; } @@ -89,14 +89,14 @@ public class Attribute public string trait_type { get; set; } public string value { get; set; } } - + public class Owners { public string owner { get; set; } public string supply { get; set; } } - + #endregion - + } } \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/NftTokenModel.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/NftTokenModel.cs index eb6779929..ae4d92466 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/NftTokenModel.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/NftTokenModel.cs @@ -6,7 +6,7 @@ namespace ChainSafe.Gaming.UnityPackage.Model public class NftTokenModel { #region ProjectCollections - + public class ProjectCollectionsResponse { public int page_size { get; set; } @@ -14,7 +14,7 @@ public class ProjectCollectionsResponse public string cursor { get; set; } public List collections { get; set; } } - + public class Collection { public string id { get; set; } @@ -36,7 +36,7 @@ public class Collection #endregion #region CollectionItems - + public class CollectionItemsResponse { public int page_number { get; set; } @@ -58,7 +58,7 @@ public class Token public string uri { get; set; } public Metadata metadata { get; set; } } - + public class Metadata { public List attributes { get; set; } @@ -67,14 +67,14 @@ public class Metadata public string name { get; set; } public string tokenType { get; set; } } - + public class Attribute { public string trait_type { get; set; } public string value { get; set; } } - + #endregion - + } } diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/ProjectConfigUtilities.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/ProjectConfigUtilities.cs index cd8971540..19c875698 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/ProjectConfigUtilities.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/ProjectConfigUtilities.cs @@ -13,7 +13,7 @@ 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; @@ -32,7 +32,7 @@ public LocalhostChainConfig(string chainId, string symbol, string chain, string public string Ws { get; } public string BlockExplorerUrl { get; } } - + private const string AssetName = "ProjectConfigData"; public static ProjectConfigScriptableObject Load() diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/ConnectModal.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/ConnectModal.cs index 82eea833a..528d8faa5 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/ConnectModal.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/ConnectModal.cs @@ -14,9 +14,9 @@ public class ConnectModal : MonoBehaviour [SerializeField] private Button closeButton; // Closes modal when background is clicked [SerializeField] private Button closeFromBackgroundButton; - + [Space] - + [SerializeField] private RectTransform providerContainer; private void Start() @@ -33,7 +33,7 @@ public void DisplayError(string message) { errorOverlay.DisplayError(message); } - + /// /// Show Loading Overlay. /// @@ -41,7 +41,7 @@ public void ShowLoading() { loadingOverlay.gameObject.SetActive(true); } - + /// /// Hide Loading overlay. /// @@ -59,7 +59,7 @@ public ConnectionProvider AddProvider(ConnectionProvider provider) { return Instantiate(provider, providerContainer); } - + private void Close() { gameObject.SetActive(false); diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/ErrorOverlay.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/ErrorOverlay.cs index 0728725c3..cd8ec1ab3 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/ErrorOverlay.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/ErrorOverlay.cs @@ -27,10 +27,10 @@ private void Start() public void DisplayError(string message) { gameObject.SetActive(true); - + errorText.SetText(message); } - + /// /// Close error overlay. /// diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/Resizer.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/Resizer.cs index a6cbbdd5b..b42449e77 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/Resizer.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/UI/Resizer.cs @@ -10,23 +10,23 @@ public class Resizer : MonoBehaviour { [SerializeField] private bool resizeWidth; [SerializeField] private bool resizeHeight; - + [Space] - + [SerializeField] private float widthThreshold; [SerializeField] private float heightThreshold; - + [Space] - + [SerializeField] private bool resizeRelativeToParent; - + [Space] - + [Range(0f, 1f)] [SerializeField] private float normalizedWidth; [Range(0f, 1f)] [SerializeField] private float normalizedHeight; - + private RectTransform _rectTransform; private void Awake() @@ -41,13 +41,13 @@ private void Start() private void Resize() { - Vector2 parentSize = resizeRelativeToParent ? ((RectTransform) _rectTransform.parent).rect.size : new Vector2(Screen.width, Screen.height); + Vector2 parentSize = resizeRelativeToParent ? ((RectTransform)_rectTransform.parent).rect.size : new Vector2(Screen.width, Screen.height); if (resizeWidth) { ResizeAxis(RectTransform.Axis.Horizontal, parentSize.x, normalizedWidth, widthThreshold); } - + if (resizeHeight) { ResizeAxis(RectTransform.Axis.Vertical, parentSize.y, normalizedHeight, heightThreshold); @@ -56,12 +56,12 @@ private void Resize() void ResizeAxis(RectTransform.Axis axis, float parent, float normalized, float threshold) { float target = parent * normalized; - + if (threshold > 0) { - target = Mathf.Clamp(target,0f, threshold); + target = Mathf.Clamp(target, 0f, threshold); } - + _rectTransform.SetSizeWithCurrentAnchors(axis, target); } } diff --git a/scripts/data/published_dependencies.txt b/scripts/data/published_dependencies.txt index bb9bfba09..44cf01d1f 100644 --- a/scripts/data/published_dependencies.txt +++ b/scripts/data/published_dependencies.txt @@ -1,76 +1,76 @@ Packages/io.chainsafe.web3-unity/Runtime/Libraries/: - ADRaffy.ENSNormalize.dll - Nethereum.Model.dll - BouncyCastle.Crypto.dll - Nethereum.RLP.dll - ChainSafe.Gaming.Debugging.dll - Nethereum.RPC.dll - Nethereum.RPC.Reactive.dll - Nethereum.JsonRpc.WebSocketClient.dll - ChainSafe.Gaming.Gelato.dll - ChainSafe.Gaming.SygmaClient.dll - Nethereum.Signer.EIP712.dll - ChainSafe.Gaming.InProcessSigner.dll - Nethereum.Signer.dll - ChainSafe.Gaming.InProcessTransactionExecutor.dll - Nethereum.Util.dll - ChainSafe.Gaming.Unity.ThirdParty.dll - Nethereum.Web3.dll - ChainSafe.Gaming.Unity.dll - System.Buffers.dll - ChainSafe.Gaming.WalletConnect.dll - System.Memory.dll - ChainSafe.Gaming.dll - System.Numerics.Vectors.dll - Microsoft.Bcl.AsyncInterfaces.dll - System.Reactive.dll - Microsoft.Extensions.DependencyInjection.Abstractions.dll - System.Runtime.CompilerServices.Unsafe.dll - Microsoft.Extensions.DependencyInjection.dll - System.Runtime.InteropServices.WindowsRuntime.dll - Microsoft.Extensions.Logging.Abstractions.dll - System.Security.Cryptography.Cng.dll - Microsoft.IdentityModel.Abstractions.dll - System.Text.Encodings.Web.dll - Microsoft.IdentityModel.Logging.dll - System.Text.Json.dll - Microsoft.IdentityModel.Tokens.dll - System.Threading.Channels.dll - NBitcoin.dll - System.Threading.Tasks.Extensions.dll - Nethereum.ABI.dll - WalletConnectSharp.Auth.dll - Nethereum.Accounts.dll - WalletConnectSharp.Common.dll - WalletConnectSharp.Events.dll - Nethereum.BlockchainProcessing.dll - WalletConnectSharp.Core.dll - Nethereum.Contracts.dll - WalletConnectSharp.Crypto.dll - Nethereum.Hex.dll - Nethereum.JsonRpc.Client.dll - WalletConnectSharp.Network.Websocket.dll - WalletConnectSharp.Network.dll - Nethereum.JsonRpc.RpcClient.dll - WalletConnectSharp.Sign.dll - Nethereum.KeyStore.dll - WalletConnectSharp.Storage.dll - Nethereum.Merkle.Patricia.dll - WalletConnectSharp.Web3Wallet.dll - Nethereum.Merkle.dll - Websocket.Client.dll - Nethereum.Siwe.Core.dll - Nethereum.Siwe.dll - Nethereum.UI.dll - ChainSafe.Gaming.Unity.MetaMask.dll - ChainSafe.Gaming.Marketplace.dll - ChainSafe.Gaming.Unity.EthereumWindow.dll + ADRaffy.ENSNormalize + Nethereum.Model + BouncyCastle.Crypto + Nethereum.RLP + ChainSafe.Gaming.Debugging + Nethereum.RPC + Nethereum.RPC.Reactive + Nethereum.JsonRpc.WebSocketClient + ChainSafe.Gaming.Gelato + ChainSafe.Gaming.SygmaClient + Nethereum.Signer.EIP712 + ChainSafe.Gaming.InProcessSigner + Nethereum.Signer + ChainSafe.Gaming.InProcessTransactionExecutor + Nethereum.Util + ChainSafe.Gaming.Unity.ThirdParty + Nethereum.Web3 + ChainSafe.Gaming.Unity + System.Buffers + ChainSafe.Gaming.WalletConnect + System.Memory + ChainSafe.Gaming + System.Numerics.Vectors + Microsoft.Bcl.AsyncInterfaces + System.Reactive + Microsoft.Extensions.DependencyInjection.Abstractions + System.Runtime.CompilerServices.Unsafe + Microsoft.Extensions.DependencyInjection + System.Runtime.InteropServices.WindowsRuntime + Microsoft.Extensions.Logging.Abstractions + System.Security.Cryptography.Cng + Microsoft.IdentityModel.Abstractions + System.Text.Encodings.Web + Microsoft.IdentityModel.Logging + System.Text.Json + Microsoft.IdentityModel.Tokens + System.Threading.Channels + NBitcoin + System.Threading.Tasks.Extensions + Nethereum.ABI + WalletConnectSharp.Auth + Nethereum.Accounts + WalletConnectSharp.Common + WalletConnectSharp.Events + Nethereum.BlockchainProcessing + WalletConnectSharp.Core + Nethereum.Contracts + WalletConnectSharp.Crypto + Nethereum.Hex + Nethereum.JsonRpc.Client + WalletConnectSharp.Network.Websocket + WalletConnectSharp.Network + Nethereum.JsonRpc.RpcClient + WalletConnectSharp.Sign + Nethereum.KeyStore + WalletConnectSharp.Storage + Nethereum.Merkle.Patricia + WalletConnectSharp.Web3Wallet + Nethereum.Merkle + Websocket.Client + Nethereum.Siwe.Core + Nethereum.Siwe + Nethereum.UI + ChainSafe.Gaming.Unity.MetaMask + ChainSafe.Gaming.Marketplace + ChainSafe.Gaming.Unity.EthereumWindow Packages/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/: - Chainsafe.Gaming.Chainlink.dll - ChainSafe.Gaming.Lootboxes.Chainlink.dll + Chainsafe.Gaming.Chainlink + ChainSafe.Gaming.Lootboxes.Chainlink Packages/io.chainsafe.web3-unity.hyperplay/Runtime/Libraries/: - ChainSafe.Gaming.HyperPlay.dll + ChainSafe.Gaming.HyperPlay Packages/io.chainsafe.web3-unity.mud/Runtime/Libraries/: - ChainSafe.Gaming.Mud.dll - Nethereum.Mud.dll - Nethereum.Mud.Contracts.dll \ No newline at end of file + ChainSafe.Gaming.Mud + Nethereum.Mud + Nethereum.Mud.Contracts \ 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 506e5fb53..07f9a713d 100644 --- a/scripts/debug-publish-to-unity-package.bat +++ b/scripts/debug-publish-to-unity-package.bat @@ -1,3 +1,5 @@ +@echo off + SET SCRIPT_DIR=%~dp0 setlocal enabledelayedexpansion @@ -26,6 +28,7 @@ for /f "usebackq tokens=*" %%A in ("%SCRIPT_DIR%\data\published_dependencies.txt set "PACKAGE_LIB_PATH=%SCRIPT_DIR%..\!entry:~0,-1!" if exist "!PACKAGE_LIB_PATH!\" ( del /q "!PACKAGE_LIB_PATH!\*.dll" + del /q "!PACKAGE_LIB_PATH!\*.pdb" ) else ( mkdir "!PACKAGE_LIB_PATH!" ) @@ -33,7 +36,8 @@ for /f "usebackq tokens=*" %%A in ("%SCRIPT_DIR%\data\published_dependencies.txt echo Copying to !PACKAGE_LIB_PATH!... ) else ( set "DEPENDENCY=!entry: =!" - copy /y "%PUBLISH_PATH%\!DEPENDENCY!" "!PACKAGE_LIB_PATH!" + copy /y "%PUBLISH_PATH%\!DEPENDENCY!.dll" "!PACKAGE_LIB_PATH!" + copy /y "%PUBLISH_PATH%\!DEPENDENCY!.pdb" "!PACKAGE_LIB_PATH!" ) ) diff --git a/scripts/debug-publish-to-unity-package.sh b/scripts/debug-publish-to-unity-package.sh index 74013798d..89a449766 100755 --- a/scripts/debug-publish-to-unity-package.sh +++ b/scripts/debug-publish-to-unity-package.sh @@ -23,14 +23,19 @@ do then PACKAGE_LIB_PATH="$scripts_dir/../${entry%:}" if [ -d "$PACKAGE_LIB_PATH" ]; then - rm -rf "$PACKAGE_LIB_PATH"*.dll + rm -rf "$PACKAGE_LIB_PATH"/*.dll + rm -rf "$PACKAGE_LIB_PATH"/*.pdb else mkdir -p "$PACKAGE_LIB_PATH" fi echo "Copying to $PACKAGE_LIB_PATH..." else export DEPENDENCY=$(echo "$entry" | tr -d '\t' | tr -d ' ') - cp -fr "$PUBLISH_PATH/$DEPENDENCY" $PACKAGE_LIB_PATH + cp -fr "$PUBLISH_PATH/$DEPENDENCY".dll $PACKAGE_LIB_PATH + + if [ -f "$PUBLISH_PATH/$DEPENDENCY".pdb ]; then + cp -fr "$PUBLISH_PATH/$DEPENDENCY".pdb $PACKAGE_LIB_PATH + fi fi done < "$scripts_dir/data/published_dependencies.txt" diff --git a/scripts/publish-to-unity-package.bat b/scripts/publish-to-unity-package.bat index 7baf2c810..83a99385c 100644 --- a/scripts/publish-to-unity-package.bat +++ b/scripts/publish-to-unity-package.bat @@ -1,3 +1,4 @@ +@echo off SET SCRIPT_DIR=%~dp0 setlocal enabledelayedexpansion @@ -26,6 +27,7 @@ for /f "usebackq tokens=*" %%A in ("%SCRIPT_DIR%\data\published_dependencies.txt set "PACKAGE_LIB_PATH=%SCRIPT_DIR%..\!entry:~0,-1!" if exist "!PACKAGE_LIB_PATH!\" ( del /q "!PACKAGE_LIB_PATH!\*.dll" + del /q "!PACKAGE_LIB_PATH!\*.pdb" ) else ( mkdir "!PACKAGE_LIB_PATH!" ) @@ -33,7 +35,7 @@ for /f "usebackq tokens=*" %%A in ("%SCRIPT_DIR%\data\published_dependencies.txt echo Copying to !PACKAGE_LIB_PATH!... ) else ( set "DEPENDENCY=!entry: =!" - copy /y "%PUBLISH_PATH%\!DEPENDENCY!" "!PACKAGE_LIB_PATH!" + copy /y "%PUBLISH_PATH%\!DEPENDENCY!.dll" "!PACKAGE_LIB_PATH!" ) ) diff --git a/scripts/publish-to-unity-package.sh b/scripts/publish-to-unity-package.sh index 332d28caa..150615f04 100755 --- a/scripts/publish-to-unity-package.sh +++ b/scripts/publish-to-unity-package.sh @@ -23,14 +23,15 @@ do then PACKAGE_LIB_PATH="$scripts_dir/../${entry%:}" if [ -d "$PACKAGE_LIB_PATH" ]; then - rm -rf "$PACKAGE_LIB_PATH"*.dll + rm -rf "$PACKAGE_LIB_PATH"/*.dll + rm -rf "$PACKAGE_LIB_PATH"/*.pdb else mkdir -p "$PACKAGE_LIB_PATH" fi echo "Copying to $PACKAGE_LIB_PATH..." else export DEPENDENCY=$(echo "$entry" | tr -d '\t' | tr -d ' ') - cp -fr "$PUBLISH_PATH/$DEPENDENCY" $PACKAGE_LIB_PATH + cp -fr "$PUBLISH_PATH/$DEPENDENCY".dll $PACKAGE_LIB_PATH fi done < "$scripts_dir/data/published_dependencies.txt" diff --git a/src/ChainSafe.Gaming.Mud/IMudWorld.cs b/src/ChainSafe.Gaming.Mud/IMudWorld.cs new file mode 100644 index 000000000..9316f6d92 --- /dev/null +++ b/src/ChainSafe.Gaming.Mud/IMudWorld.cs @@ -0,0 +1,23 @@ +using System.Threading.Tasks; +using Nethereum.Mud; +using Nethereum.Mud.Contracts.World; + +namespace ChainSafe.Gaming.Mud +{ + public interface IMudWorld + { + /// + /// A Nethereum World Service. Use this if you need more control over the World. + /// + WorldService WorldService { get; } + + Task Query() + where TRecord : TableRecordSingleton, new() + where TValue : class, new(); + + Task Query(TKey key) + where TRecord : TableRecord, new() + where TKey : class, new() + where TValue : class, new(); + } +} \ No newline at end of file diff --git a/src/ChainSafe.Gaming.Mud/MudFacade.cs b/src/ChainSafe.Gaming.Mud/MudFacade.cs index 87816a124..85b3d6c90 100644 --- a/src/ChainSafe.Gaming.Mud/MudFacade.cs +++ b/src/ChainSafe.Gaming.Mud/MudFacade.cs @@ -13,10 +13,11 @@ public MudFacade(MudWorldFactory worldFactory) /// Builds a MUD World Client to exchange messages with a World Contract. /// /// The address of the World Contract. + /// The ABI of the World Contract. /// The client for the MUD World Contract. - public MudWorld BuildWorld(string contractAddress) + public MudWorld BuildWorld(string contractAddress, string worldContractAbi) { - return worldFactory.Build(contractAddress); + return worldFactory.Build(contractAddress, worldContractAbi); } } } \ No newline at end of file diff --git a/src/ChainSafe.Gaming.Mud/MudWorld.cs b/src/ChainSafe.Gaming.Mud/MudWorld.cs index 13ede7d90..2a49846ab 100644 --- a/src/ChainSafe.Gaming.Mud/MudWorld.cs +++ b/src/ChainSafe.Gaming.Mud/MudWorld.cs @@ -1,29 +1,86 @@ 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 { - public class MudWorld + // todo add event subscription + public class MudWorld : IMudWorld, IContract { - private readonly WorldService worldService; + private readonly IContract contract; - public MudWorld(IWeb3 nethWeb3, string contractAddress) + public MudWorld(IWeb3 nethWeb3, IContract contract) { - worldService = new WorldService(nethWeb3, contractAddress); + this.contract = contract; + WorldService = new WorldService(nethWeb3, contract.Address); } - public Task Call() - where TFunction : FunctionMessage, new() + 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 IContract.Call(string method, object[] parameters = null, TransactionRequest overwrite = null) + { + return contract.Call(method, parameters, overwrite); + } + + object[] IContract.Decode(string method, string output) + { + return contract.Decode(method, output); + } + + Task IContract.Send(string method, object[] parameters = null, TransactionRequest overwrite = null) + { + return contract.Send(method, parameters, overwrite); + } + + Task<(object[] response, TransactionReceipt receipt)> IContract.SendWithReceipt(string method, object[] parameters = null, TransactionRequest overwrite = null) + { + return contract.SendWithReceipt(method, parameters, overwrite); + } + + Task IContract.EstimateGas(string method, object[] parameters, TransactionRequest overwrite = null) + { + return contract.EstimateGas(method, parameters, overwrite); + } + + string IContract.Calldata(string method, object[] parameters = null) { - return worldService.ContractHandler.QueryAsync(); + return contract.Calldata(method, parameters); } - public Task Send() // todo return value - where TFunction : FunctionMessage, new() + public Task PrepareTransactionRequest(string method, object[] parameters, bool isReadCall = false, TransactionRequest overwrite = null) { - return worldService.ContractHandler.SendRequestAndWaitForReceiptAsync(); + return contract.PrepareTransactionRequest(method, parameters, isReadCall, overwrite); } } } \ No newline at end of file diff --git a/src/ChainSafe.Gaming.Mud/MudWorldFactory.cs b/src/ChainSafe.Gaming.Mud/MudWorldFactory.cs index a2ff97794..0fcde3592 100644 --- a/src/ChainSafe.Gaming.Mud/MudWorldFactory.cs +++ b/src/ChainSafe.Gaming.Mud/MudWorldFactory.cs @@ -1,3 +1,4 @@ +using ChainSafe.Gaming.Evm.Contracts; using ChainSafe.Gaming.Web3.Core.Nethereum; namespace ChainSafe.Gaming.Mud @@ -5,15 +6,19 @@ namespace ChainSafe.Gaming.Mud public class MudWorldFactory { private readonly INethereumWeb3Adapter nethWeb3; + private IContractBuilder contractBuilder; - public MudWorldFactory(INethereumWeb3Adapter nethWeb3) + public MudWorldFactory(INethereumWeb3Adapter nethWeb3, IContractBuilder contractBuilder) { + this.contractBuilder = contractBuilder; this.nethWeb3 = nethWeb3; } - public MudWorld Build(string worldAddress) + public MudWorld Build(string worldAddress, string worldContractAbi) { - return new MudWorld(nethWeb3, worldAddress); + var contract = contractBuilder.Build(worldContractAbi, worldAddress); + var mudWorld = new MudWorld(nethWeb3, contract); + return mudWorld; } } } \ No newline at end of file diff --git a/src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/BuiltInContract.cs b/src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/BuiltInContract.cs index 204c96ef2..124a2a28c 100644 --- a/src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/BuiltInContract.cs +++ b/src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/BuiltInContract.cs @@ -13,6 +13,8 @@ internal BuiltInContract(Contract contract) protected Contract Original { get; private set; } + public string Address => Original.Address; + public virtual IContract Attach(string address) => Original.Attach(address); public virtual Task Call(string method, object[] parameters = null, TransactionRequest overwrite = null) => diff --git a/src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/Erc1155Contract.cs b/src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/Erc1155Contract.cs index 09217de91..2af18b84e 100644 --- a/src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/Erc1155Contract.cs +++ b/src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/Erc1155Contract.cs @@ -42,7 +42,7 @@ public Task GetBalanceOf(string tokenId) [Pure] public Task GetBalanceOf(string tokenId, string accountAddress) { - return Original.CallSingle( + return Original.Call( EthMethods.BalanceOf, accountAddress, tokenId); @@ -57,7 +57,7 @@ public Task GetBalanceOf(string tokenId, string accountAddress) [Pure] public Task> GetBalanceOfBatch(string[] accountAddresses, string[] tokenIds) // TODO refine return value format { - return Original.CallSingle, string[], string[]>( + return Original.Call, string[], string[]>( EthMethods.BalanceOfBatch, accountAddresses, tokenIds); @@ -76,7 +76,7 @@ public async Task GetUri(string tokenId) return IpfsHelper.DecodeTokenIdToUri(tokenId); } - return await Original.CallSingle(EthMethods.Uri, tokenId); + return await Original.Call(EthMethods.Uri, tokenId); } /// diff --git a/src/ChainSafe.Gaming/RPC/Contracts/Contract.cs b/src/ChainSafe.Gaming/RPC/Contracts/Contract.cs index 1f65d6636..7a47973dc 100644 --- a/src/ChainSafe.Gaming/RPC/Contracts/Contract.cs +++ b/src/ChainSafe.Gaming/RPC/Contracts/Contract.cs @@ -18,7 +18,6 @@ namespace ChainSafe.Gaming.Evm.Contracts public class Contract : IContract { private readonly string abi; - private readonly string address; private readonly IRpcProvider provider; private readonly ISigner signer; private readonly ContractAbiManager contractAbiManager; @@ -41,7 +40,7 @@ internal Contract(string abi, string address, IRpcProvider provider, ISigner sig } this.abi = abi; - this.address = address; + this.Address = address; this.provider = provider; this.signer = signer; this.transactionExecutor = transactionExecutor; @@ -49,7 +48,7 @@ internal Contract(string abi, string address, IRpcProvider provider, ISigner sig contractAbiManager = new ContractAbiManager(abi, address); } - public string Address => address; + public string Address { get; } /// /// Returns a new instance of the Contract attached to a new address. This is useful @@ -77,7 +76,7 @@ public IContract Attach(string address) /// The result of calling the method. public async Task Call(string method, object[] parameters = null, TransactionRequest overwrite = null) { - if (string.IsNullOrEmpty(address)) + if (string.IsNullOrEmpty(Address)) { throw new Exception("contract address is not set"); } @@ -103,7 +102,7 @@ public async Task Call(string method, object[] parameters = null, Tran public async Task Call(string method, object[] parameters = null, TransactionRequest overwrite = null) { - if (string.IsNullOrEmpty(address)) + if (string.IsNullOrEmpty(Address)) { throw new Exception("contract address is not set"); } @@ -184,7 +183,7 @@ public async Task Send(string method, object[] parameters = null, Transact object[] parameters = null, TransactionRequest overwrite = null) { - if (string.IsNullOrEmpty(address)) + if (string.IsNullOrEmpty(Address)) { throw new Exception("contract address is not set"); } @@ -228,7 +227,7 @@ public async Task Send(string method, object[] parameters = null, Transact object[] parameters = null, TransactionRequest overwrite = null) { - if (string.IsNullOrEmpty(address)) + if (string.IsNullOrEmpty(Address)) { throw new Exception("contract address is not set"); } @@ -268,7 +267,7 @@ public async Task EstimateGas( object[] parameters, TransactionRequest overwrite = null) { - if (string.IsNullOrEmpty(address)) + if (string.IsNullOrEmpty(Address)) { throw new Exception("contract address is not set"); } @@ -335,7 +334,7 @@ public async Task PrepareTransactionRequest(string method, o var txReq = overwrite ?? new TransactionRequest(); txReq.From ??= signer?.PublicAddress; - txReq.To ??= address; + txReq.To ??= Address; txReq.Data ??= function.GetData(parameters); if (isReadCall) { diff --git a/src/ChainSafe.Gaming/RPC/Contracts/ContractExtensions.cs b/src/ChainSafe.Gaming/RPC/Contracts/ContractExtensions.cs index 7e84410df..46f64f5a9 100644 --- a/src/ChainSafe.Gaming/RPC/Contracts/ContractExtensions.cs +++ b/src/ChainSafe.Gaming/RPC/Contracts/ContractExtensions.cs @@ -16,29 +16,20 @@ private static async void UsageExample() // TODO: move to documentation // read static game data { - var activeChaosOrbs = await contract.CallSingle("activeChaosOrbs"); + var activeChaosOrbs = await contract.Call("activeChaosOrbs"); } // get team mate addresses { var teamId = 256; - var teammateAddresses = await contract.CallMany("getTeammateAddresses", teamId); - var blockedPlayerAddresses = new[] { "0x20934800uu9283798439873298dfu2f93" }; - var allowedTeammateAddresses = teammateAddresses.Except(blockedPlayerAddresses).ToList(); + var teammateAddresses = await contract.Call, BigInteger>("getTeammateAddresses", teamId); } - // block players - { - var blockAddresses = new[] { "0x20934800uu9283798439873298dfu2f93", "0x20934800uu9283798439873298dfu2f93" }; - await contract.SendVoid("blockPlayers", blockAddresses); - } - - // greet friends, read their statuses + // greet friends { var friendIds = new[] { "0x20934800uu9283798439873298dfu2f93", "0x20934800uu9283798439873298dfu2f93" }; var onlineOnly = false; - var statuses = (await contract.SendMany("greetMany", friendIds, onlineOnly)) - .ToList(); + await contract.Send("greetMany", friendIds, onlineOnly); } } @@ -52,8 +43,8 @@ private static async void UsageExample() // TODO: move to documentation /// A task that represents the asynchronous operation. The task result contains the method return value of type . /// Thrown if the response is empty or cannot be converted to the specified type. [Pure] - public static async Task CallSingle( - this Contract contract, + public static async Task Call( + this IContract contract, string methodName, TransactionRequest requestPrototype = null) { @@ -74,8 +65,8 @@ public static async Task CallSingle( /// A task that represents the asynchronous operation. The task result contains the method return value of type . /// Thrown if the response is empty or cannot be converted to the specified type. [Pure] - public static async Task CallSingle( - this Contract contract, + public static async Task Call( + this IContract contract, string methodName, TIn1 in1, TransactionRequest requestPrototype = null) @@ -99,8 +90,8 @@ public static async Task CallSingle( /// A task that represents the asynchronous operation. The task result contains the method return value of type . /// Thrown if the response is empty or cannot be converted to the specified type. [Pure] - public static async Task CallSingle( - this Contract contract, + public static async Task Call( + this IContract contract, string methodName, TIn1 in1, TIn2 in2, @@ -127,8 +118,8 @@ public static async Task CallSingle( /// A task that represents the asynchronous operation. The task result contains the method return value of type . /// Thrown if the response is empty or cannot be converted to the specified type. [Pure] - public static async Task CallSingle( - this Contract contract, + public static async Task Call( + this IContract contract, string methodName, TIn1 in1, TIn2 in2, @@ -141,116 +132,14 @@ public static async Task CallSingle( } /// - /// Asynchronously calls a smart contract method expected to return multiple values of a specified type. - /// - /// The type of the items expected to be returned by the smart contract method. - /// The contract instance on which the method call is being made. - /// The name of the smart contract method to call. - /// Optional. A prototype object for the transaction request. - /// A task representing the asynchronous operation, with a result of an , containing the items returned by the smart contract method. - /// Thrown if the response is empty or if any items in the response cannot be converted to the specified type . - [Pure] - public static async Task> CallMany( - this Contract contract, - string methodName, - TransactionRequest requestPrototype = null) - { - var response = await contract.Call(methodName, null, requestPrototype); - AssertResponseNotEmpty(response); - AssertConversionMany(response); - return response.Cast(); - } - - /// - /// Asynchronously calls a smart contract method expected to return multiple values of a specified type. - /// - /// The type of the items expected to be returned by the smart contract method. - /// The first input type. - /// The contract instance on which the method call is being made. - /// The name of the smart contract method to call. - /// The first input value. - /// Optional. A prototype object for the transaction request. - /// A task representing the asynchronous operation, with a result of an , containing the items returned by the smart contract method. - /// Thrown if the response is empty or if any items in the response cannot be converted to the specified type . - [Pure] - public static async Task> CallMany( - this Contract contract, - string methodName, - TIn1 in1, - TransactionRequest requestPrototype = null) - { - var response = await contract.Call(methodName, new object[] { in1 }, requestPrototype); - AssertResponseNotEmpty(response); - AssertConversionMany(response); - return response.Cast(); - } - - /// - /// Asynchronously calls a smart contract method expected to return multiple values of a specified type. - /// - /// The type of the items expected to be returned by the smart contract method. - /// The first input type. - /// The second input type. - /// The contract instance on which the method call is being made. - /// The name of the smart contract method to call. - /// The first input value. - /// The second input value. - /// Optional. A prototype object for the transaction request. - /// A task representing the asynchronous operation, with a result of an , containing the items returned by the smart contract method. - /// Thrown if the response is empty or if any items in the response cannot be converted to the specified type . - [Pure] - public static async Task> CallMany( - this Contract contract, - string methodName, - TIn1 in1, - TIn2 in2, - TransactionRequest requestPrototype = null) - { - var response = await contract.Call(methodName, new object[] { in1, in2 }, requestPrototype); - AssertResponseNotEmpty(response); - AssertConversionMany(response); - return response.Cast(); - } - - /// - /// Asynchronously calls a smart contract method expected to return multiple values of a specified type. - /// - /// The type of the items expected to be returned by the smart contract method. - /// The first input type. - /// The second input type. - /// The third input type. - /// The contract instance on which the method call is being made. - /// The name of the smart contract method to call. - /// The first input value. - /// The second input value. - /// The third input value. - /// Optional. A prototype object for the transaction request. - /// A task representing the asynchronous operation, with a result of an , containing the items returned by the smart contract method. - /// Thrown if the response is empty or if any items in the response cannot be converted to the specified type . - [Pure] - public static async Task> CallMany( - this Contract contract, - string methodName, - TIn1 in1, - TIn2 in2, - TIn3 in3, - TransactionRequest requestPrototype = null) - { - var response = await contract.Call(methodName, new object[] { in1, in2, in3 }, requestPrototype); - AssertResponseNotEmpty(response); - AssertConversionMany(response); - return response.Cast(); - } - - /// - /// Asynchronously sends a transaction to a smart contract method that is not expected to have a return value. + /// Asynchronously sends a transaction to a smart contract method. /// /// The contract instance on which the transaction is sent. /// The name of the smart contract method to which the transaction is sent. /// Optional. A prototype object for the transaction request. This can include transaction parameters such as gas limit, gas price, value, etc. /// A task representing the asynchronous operation of sending the transaction. - public static Task SendVoid( - this Contract contract, + public static Task Send( + this IContract contract, string methodName, TransactionRequest requestPrototype = null) { @@ -258,7 +147,7 @@ public static Task SendVoid( } /// - /// Asynchronously sends a transaction to a smart contract method that is not expected to have a return value. + /// Asynchronously sends a transaction to a smart contract method. /// /// The type of the first input parameter. /// The contract instance on which the transaction is sent. @@ -266,8 +155,8 @@ public static Task SendVoid( /// The first input parameter. /// Optional. A prototype object for the transaction request. This can include additional parameters for the transaction such as gas limit, gas price, value, etc. /// A task representing the asynchronous operation of sending the transaction. - public static Task SendVoid( - this Contract contract, + public static Task Send( + this IContract contract, string methodName, TIn1 in1, TransactionRequest requestPrototype = null) @@ -276,7 +165,7 @@ public static Task SendVoid( } /// - /// Asynchronously sends a transaction to a smart contract method that is not expected to have a return value. + /// Asynchronously sends a transaction to a smart contract method. /// /// The type of the first input parameter. /// The type of the second input parameter. @@ -286,8 +175,8 @@ public static Task SendVoid( /// The second input parameter. /// Optional. A prototype object for the transaction request. This can include additional parameters for the transaction such as gas limit, gas price, value, etc. /// A task representing the asynchronous operation of sending the transaction. - public static Task SendVoid( - this Contract contract, + public static Task Send( + this IContract contract, string methodName, TIn1 in1, TIn2 in2, @@ -297,7 +186,7 @@ public static Task SendVoid( } /// - /// Asynchronously sends a transaction to a smart contract method that is not expected to have a return value. + /// Asynchronously sends a transaction to a smart contract method. /// /// The type of the first input parameter. /// The type of the second input parameter. @@ -309,8 +198,8 @@ public static Task SendVoid( /// The third input parameter. /// Optional. A prototype object for the transaction request. This can include additional parameters for the transaction such as gas limit, gas price, value, etc. /// A task representing the asynchronous operation of sending the transaction. - public static Task SendVoid( - this Contract contract, + public static Task Send( + this IContract contract, string methodName, TIn1 in1, TIn2 in2, @@ -320,202 +209,6 @@ public static Task SendVoid( return contract.Send(methodName, new object[] { in1, in2, in3 }, requestPrototype); } - /// - /// Asynchronously sends a transaction to a smart contract method that is expected to return a single value of a specified type. - /// - /// The expected type of the return value from the smart contract method. - /// The contract instance on which the transaction is sent. - /// The name of the smart contract method to which the transaction is sent. - /// Optional. A prototype object for the transaction request. This can include transaction parameters such as gas limit, gas price, value, etc., if necessary. - /// A task representing the asynchronous operation, with a result of the specified type , containing the return value from the smart contract method. - /// Thrown if the response from the smart contract is empty, or if the response cannot be converted to the specified type . - public static async Task SendSingle( - this Contract contract, - string methodName, - TransactionRequest requestPrototype = null) - { - var response = await contract.Send(methodName, null, requestPrototype); - AssertResponseNotEmpty(response); - return AssertAndConvertSingle(response); - } - - /// - /// Asynchronously sends a transaction to a smart contract method that is expected to return a single value of a specified type. - /// - /// The expected type of the return value from the smart contract method. - /// The type of the first input parameter. - /// The contract instance on which the transaction is sent. - /// The name of the smart contract method to which the transaction is sent. - /// The first input parameter. - /// Optional. A prototype object for the transaction request. This can include transaction parameters such as gas limit, gas price, value, etc., if necessary. - /// A task representing the asynchronous operation, with a result of the specified type , containing the return value from the smart contract method. - /// Thrown if the response from the smart contract is empty, or if the response cannot be converted to the specified type . - public static async Task SendSingle( - this Contract contract, - string methodName, - TIn1 in1, - TransactionRequest requestPrototype = null) - { - var response = await contract.Send(methodName, new object[] { in1 }, requestPrototype); - AssertResponseNotEmpty(response); - return AssertAndConvertSingle(response); - } - - /// - /// Asynchronously sends a transaction to a smart contract method that is expected to return a single value of a specified type. - /// - /// The expected type of the return value from the smart contract method. - /// The type of the first input parameter. - /// The type of the second input parameter. - /// The contract instance on which the transaction is sent. - /// The name of the smart contract method to which the transaction is sent. - /// The first input parameter. - /// The second input parameter. - /// Optional. A prototype object for the transaction request. This can include transaction parameters such as gas limit, gas price, value, etc., if necessary. - /// A task representing the asynchronous operation, with a result of the specified type , containing the return value from the smart contract method. - /// Thrown if the response from the smart contract is empty, or if the response cannot be converted to the specified type . - public static async Task SendSingle( - this Contract contract, - string methodName, - TIn1 in1, - TIn2 in2, - TransactionRequest requestPrototype = null) - { - var response = await contract.Send(methodName, new object[] { in1, in2 }, requestPrototype); - AssertResponseNotEmpty(response); - return AssertAndConvertSingle(response); - } - - /// - /// Asynchronously sends a transaction to a smart contract method that is expected to return a single value of a specified type. - /// - /// The expected type of the return value from the smart contract method. - /// The type of the first input parameter. - /// The type of the second input parameter. - /// The type of the third input parameter. - /// The contract instance on which the transaction is sent. - /// The name of the smart contract method to which the transaction is sent. - /// The first input parameter. - /// The second input parameter. - /// The third input parameter. - /// Optional. A prototype object for the transaction request. This can include transaction parameters such as gas limit, gas price, value, etc., if necessary. - /// A task representing the asynchronous operation, with a result of the specified type , containing the return value from the smart contract method. - /// Thrown if the response from the smart contract is empty, or if the response cannot be converted to the specified type . - public static async Task SendSingle( - this Contract contract, - string methodName, - TIn1 in1, - TIn2 in2, - TIn3 in3, - TransactionRequest requestPrototype = null) - { - var response = await contract.Send(methodName, new object[] { in1, in2, in3 }, requestPrototype); - AssertResponseNotEmpty(response); - return AssertAndConvertSingle(response); - } - - /// - /// Asynchronously sends a transaction to a smart contract method that is expected to return multiple values of a specified type. - /// This method is suitable for interacting with smart contract methods designed to return an array or list of elements, allowing for the retrieval of multiple items in a single transaction. - /// - /// The type of the elements expected to be returned by the smart contract method. The response will be cast to an enumerable collection of this type. - /// The contract instance on which the transaction is sent. - /// The name of the smart contract method to which the transaction is sent. - /// Optional. A prototype object for the transaction request. This can be used to specify additional parameters for the transaction such as gas limit, gas price, value, etc., if required. - /// A task representing the asynchronous operation, with a result of an , containing the items returned by the smart contract method. - /// Thrown if the response from the smart contract is empty or if any of the items in the response cannot be converted to the specified type , indicating a potential type mismatch. - public static async Task> SendMany( - this Contract contract, - string methodName, - TransactionRequest requestPrototype = null) - { - var response = await contract.Send(methodName, null, requestPrototype); - AssertResponseNotEmpty(response); - AssertConversionMany(response); - return response.Cast(); - } - - /// - /// Asynchronously sends a transaction to a smart contract method that is expected to return multiple values of a specified type. - /// This method is suitable for interacting with smart contract methods designed to return an array or list of elements, allowing for the retrieval of multiple items in a single transaction. - /// - /// The type of the elements expected to be returned by the smart contract method. The response will be cast to an enumerable collection of this type. - /// The type of the first input parameter. - /// The contract instance on which the transaction is sent. - /// The name of the smart contract method to which the transaction is sent. - /// The first input parameter. - /// Optional. A prototype object for the transaction request. This can be used to specify additional parameters for the transaction such as gas limit, gas price, value, etc., if required. - /// A task representing the asynchronous operation, with a result of an , containing the items returned by the smart contract method. - /// Thrown if the response from the smart contract is empty or if any of the items in the response cannot be converted to the specified type , indicating a potential type mismatch. - public static async Task> SendMany( - this Contract contract, - string methodName, - TIn1 in1, - TransactionRequest requestPrototype = null) - { - var response = await contract.Send(methodName, new object[] { in1 }, requestPrototype); - AssertResponseNotEmpty(response); - AssertConversionMany(response); - return response.Cast(); - } - - /// - /// Asynchronously sends a transaction to a smart contract method that is expected to return multiple values of a specified type. - /// This method is suitable for interacting with smart contract methods designed to return an array or list of elements, allowing for the retrieval of multiple items in a single transaction. - /// - /// The type of the elements expected to be returned by the smart contract method. The response will be cast to an enumerable collection of this type. - /// The type of the first input parameter. - /// The type of the second input parameter. - /// The contract instance on which the transaction is sent. - /// The name of the smart contract method to which the transaction is sent. - /// The first input parameter. - /// The second input parameter. - /// Optional. A prototype object for the transaction request. This can be used to specify additional parameters for the transaction such as gas limit, gas price, value, etc., if required. - /// A task representing the asynchronous operation, with a result of an , containing the items returned by the smart contract method. - /// Thrown if the response from the smart contract is empty or if any of the items in the response cannot be converted to the specified type , indicating a potential type mismatch. - public static async Task> SendMany( - this Contract contract, - string methodName, - TIn1 in1, - TIn2 in2, - TransactionRequest requestPrototype = null) - { - var response = await contract.Send(methodName, new object[] { in1, in2 }, requestPrototype); - AssertResponseNotEmpty(response); - AssertConversionMany(response); - return response.Cast(); - } - - /// - /// Asynchronously sends a transaction to a smart contract method that is expected to return multiple values of a specified type. - /// This method is suitable for interacting with smart contract methods designed to return an array or list of elements, allowing for the retrieval of multiple items in a single transaction. - /// - /// The type of the elements expected to be returned by the smart contract method. The response will be cast to an enumerable collection of this type. - /// The type of the first input parameter. - /// The type of the second input parameter. - /// The type of the third input parameter. - /// The contract instance on which the transaction is sent. - /// The name of the smart contract method to which the transaction is sent. - /// The first input parameter. - /// The second input parameter. - /// The third input parameter. - /// Optional. A prototype object for the transaction request. This can be used to specify additional parameters for the transaction such as gas limit, gas price, value, etc., if required. - /// A task representing the asynchronous operation, with a result of an , containing the items returned by the smart contract method. - /// Thrown if the response from the smart contract is empty or if any of the items in the response cannot be converted to the specified type , indicating a potential type mismatch. - public static async Task> SendMany( - this Contract contract, - string methodName, - TIn1 in1, - TIn2 in2, - TIn3 in3, - TransactionRequest requestPrototype = null) - { - var response = await contract.Send(methodName, new object[] { in1, in2, in3 }, requestPrototype); - AssertResponseNotEmpty(response); - AssertConversionMany(response); - return response.Cast(); - } - private static void AssertResponseNotEmpty(object[] response) { if (response.Length == 0) @@ -534,13 +227,5 @@ private static TOut AssertAndConvertSingle(object[] response) return result; } - - private static void AssertConversionMany(object[] response) - { - if (response.Any(o => o is not TOut)) - { - throw new Web3Exception("Type mismatch for response item."); - } - } } } \ No newline at end of file diff --git a/src/ChainSafe.Gaming/RPC/Contracts/IContract.cs b/src/ChainSafe.Gaming/RPC/Contracts/IContract.cs index e7283864f..07309c807 100644 --- a/src/ChainSafe.Gaming/RPC/Contracts/IContract.cs +++ b/src/ChainSafe.Gaming/RPC/Contracts/IContract.cs @@ -6,6 +6,11 @@ namespace ChainSafe.Gaming.Evm.Contracts { public interface IContract { + /// + /// The address of the contract. + /// + string Address { get; } + /// /// Returns a new instance of the Contract attached to a new address. This is useful /// if there are multiple similar or identical copies of a Contract on the network diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/IWorld.abi.json b/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/IWorld.abi.json new file mode 100644 index 000000000..ca4e1c0ef --- /dev/null +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/IWorld.abi.json @@ -0,0 +1,2021 @@ +[ + { + "type": "function", + "name": "app__increment", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "batchCall", + "inputs": [ + { + "name": "systemCalls", + "type": "tuple[]", + "internalType": "struct SystemCallData[]", + "components": [ + { + "name": "systemId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "callData", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "outputs": [ + { + "name": "returnDatas", + "type": "bytes[]", + "internalType": "bytes[]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "batchCallFrom", + "inputs": [ + { + "name": "systemCalls", + "type": "tuple[]", + "internalType": "struct SystemCallFromData[]", + "components": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "systemId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "callData", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "outputs": [ + { + "name": "returnDatas", + "type": "bytes[]", + "internalType": "bytes[]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "call", + "inputs": [ + { + "name": "systemId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "callData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "callFrom", + "inputs": [ + { + "name": "delegator", + "type": "address", + "internalType": "address" + }, + { + "name": "systemId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "callData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "creator", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "deleteRecord", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getDynamicField", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "dynamicFieldIndex", + "type": "uint8", + "internalType": "uint8" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getDynamicFieldLength", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "dynamicFieldIndex", + "type": "uint8", + "internalType": "uint8" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getDynamicFieldSlice", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "dynamicFieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "start", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "end", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getField", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "fieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "fieldLayout", + "type": "bytes32", + "internalType": "FieldLayout" + } + ], + "outputs": [ + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getField", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "fieldIndex", + "type": "uint8", + "internalType": "uint8" + } + ], + "outputs": [ + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getFieldLayout", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + } + ], + "outputs": [ + { + "name": "fieldLayout", + "type": "bytes32", + "internalType": "FieldLayout" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getFieldLength", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "fieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "fieldLayout", + "type": "bytes32", + "internalType": "FieldLayout" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getFieldLength", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "fieldIndex", + "type": "uint8", + "internalType": "uint8" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getKeySchema", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + } + ], + "outputs": [ + { + "name": "keySchema", + "type": "bytes32", + "internalType": "Schema" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRecord", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "fieldLayout", + "type": "bytes32", + "internalType": "FieldLayout" + } + ], + "outputs": [ + { + "name": "staticData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "encodedLengths", + "type": "bytes32", + "internalType": "EncodedLengths" + }, + { + "name": "dynamicData", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRecord", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + } + ], + "outputs": [ + { + "name": "staticData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "encodedLengths", + "type": "bytes32", + "internalType": "EncodedLengths" + }, + { + "name": "dynamicData", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getStaticField", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "fieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "fieldLayout", + "type": "bytes32", + "internalType": "FieldLayout" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getValueSchema", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + } + ], + "outputs": [ + { + "name": "valueSchema", + "type": "bytes32", + "internalType": "Schema" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "grantAccess", + "inputs": [ + { + "name": "resourceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "grantee", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { + "name": "initModule", + "type": "address", + "internalType": "contract IModule" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "installModule", + "inputs": [ + { + "name": "module", + "type": "address", + "internalType": "contract IModule" + }, + { + "name": "encodedArgs", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "installRootModule", + "inputs": [ + { + "name": "module", + "type": "address", + "internalType": "contract IModule" + }, + { + "name": "encodedArgs", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "popFromDynamicField", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "dynamicFieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "byteLengthToPop", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "pushToDynamicField", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "dynamicFieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "dataToPush", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerDelegation", + "inputs": [ + { + "name": "delegatee", + "type": "address", + "internalType": "address" + }, + { + "name": "delegationControlId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "initCallData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerFunctionSelector", + "inputs": [ + { + "name": "systemId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "systemFunctionSignature", + "type": "string", + "internalType": "string" + } + ], + "outputs": [ + { + "name": "worldFunctionSelector", + "type": "bytes4", + "internalType": "bytes4" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerNamespace", + "inputs": [ + { + "name": "namespaceId", + "type": "bytes32", + "internalType": "ResourceId" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerNamespaceDelegation", + "inputs": [ + { + "name": "namespaceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "delegationControlId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "initCallData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerRootFunctionSelector", + "inputs": [ + { + "name": "systemId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "worldFunctionSignature", + "type": "string", + "internalType": "string" + }, + { + "name": "systemFunctionSignature", + "type": "string", + "internalType": "string" + } + ], + "outputs": [ + { + "name": "worldFunctionSelector", + "type": "bytes4", + "internalType": "bytes4" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerStoreHook", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "hookAddress", + "type": "address", + "internalType": "contract IStoreHook" + }, + { + "name": "enabledHooksBitmap", + "type": "uint8", + "internalType": "uint8" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerSystem", + "inputs": [ + { + "name": "systemId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "system", + "type": "address", + "internalType": "contract System" + }, + { + "name": "publicAccess", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerSystemHook", + "inputs": [ + { + "name": "systemId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "hookAddress", + "type": "address", + "internalType": "contract ISystemHook" + }, + { + "name": "enabledHooksBitmap", + "type": "uint8", + "internalType": "uint8" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerTable", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "fieldLayout", + "type": "bytes32", + "internalType": "FieldLayout" + }, + { + "name": "keySchema", + "type": "bytes32", + "internalType": "Schema" + }, + { + "name": "valueSchema", + "type": "bytes32", + "internalType": "Schema" + }, + { + "name": "keyNames", + "type": "string[]", + "internalType": "string[]" + }, + { + "name": "fieldNames", + "type": "string[]", + "internalType": "string[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [ + { + "name": "namespaceId", + "type": "bytes32", + "internalType": "ResourceId" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "revokeAccess", + "inputs": [ + { + "name": "resourceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "grantee", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setDynamicField", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "dynamicFieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setField", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "fieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setField", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "fieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "fieldLayout", + "type": "bytes32", + "internalType": "FieldLayout" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRecord", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "staticData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "encodedLengths", + "type": "bytes32", + "internalType": "EncodedLengths" + }, + { + "name": "dynamicData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setStaticField", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "fieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "fieldLayout", + "type": "bytes32", + "internalType": "FieldLayout" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "spliceDynamicData", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "dynamicFieldIndex", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "startWithinField", + "type": "uint40", + "internalType": "uint40" + }, + { + "name": "deleteCount", + "type": "uint40", + "internalType": "uint40" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "spliceStaticData", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "start", + "type": "uint48", + "internalType": "uint48" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "storeVersion", + "inputs": [], + "outputs": [ + { + "name": "version", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transferBalanceToAddress", + "inputs": [ + { + "name": "fromNamespaceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "toAddress", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferBalanceToNamespace", + "inputs": [ + { + "name": "fromNamespaceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "toNamespaceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "namespaceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "unregisterDelegation", + "inputs": [ + { + "name": "delegatee", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "unregisterNamespaceDelegation", + "inputs": [ + { + "name": "namespaceId", + "type": "bytes32", + "internalType": "ResourceId" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "unregisterStoreHook", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "hookAddress", + "type": "address", + "internalType": "contract IStoreHook" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "unregisterSystemHook", + "inputs": [ + { + "name": "systemId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "hookAddress", + "type": "address", + "internalType": "contract ISystemHook" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "worldVersion", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "event", + "name": "HelloStore", + "inputs": [ + { + "name": "storeVersion", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "HelloWorld", + "inputs": [ + { + "name": "worldVersion", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Store_DeleteRecord", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "indexed": true, + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "indexed": false, + "internalType": "bytes32[]" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Store_SetRecord", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "indexed": true, + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "indexed": false, + "internalType": "bytes32[]" + }, + { + "name": "staticData", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + }, + { + "name": "encodedLengths", + "type": "bytes32", + "indexed": false, + "internalType": "EncodedLengths" + }, + { + "name": "dynamicData", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Store_SpliceDynamicData", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "indexed": true, + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "indexed": false, + "internalType": "bytes32[]" + }, + { + "name": "dynamicFieldIndex", + "type": "uint8", + "indexed": false, + "internalType": "uint8" + }, + { + "name": "start", + "type": "uint48", + "indexed": false, + "internalType": "uint48" + }, + { + "name": "deleteCount", + "type": "uint40", + "indexed": false, + "internalType": "uint40" + }, + { + "name": "encodedLengths", + "type": "bytes32", + "indexed": false, + "internalType": "EncodedLengths" + }, + { + "name": "data", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Store_SpliceStaticData", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "indexed": true, + "internalType": "ResourceId" + }, + { + "name": "keyTuple", + "type": "bytes32[]", + "indexed": false, + "internalType": "bytes32[]" + }, + { + "name": "start", + "type": "uint48", + "indexed": false, + "internalType": "uint48" + }, + { + "name": "data", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "EncodedLengths_InvalidLength", + "inputs": [ + { + "name": "length", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "FieldLayout_Empty", + "inputs": [] + }, + { + "type": "error", + "name": "FieldLayout_InvalidStaticDataLength", + "inputs": [ + { + "name": "staticDataLength", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "computedStaticDataLength", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "FieldLayout_StaticLengthDoesNotFitInAWord", + "inputs": [ + { + "name": "index", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "FieldLayout_StaticLengthIsNotZero", + "inputs": [ + { + "name": "index", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "FieldLayout_StaticLengthIsZero", + "inputs": [ + { + "name": "index", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "FieldLayout_TooManyDynamicFields", + "inputs": [ + { + "name": "numFields", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxFields", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "FieldLayout_TooManyFields", + "inputs": [ + { + "name": "numFields", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxFields", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Module_AlreadyInstalled", + "inputs": [] + }, + { + "type": "error", + "name": "Module_MissingDependency", + "inputs": [ + { + "name": "dependency", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "Module_NonRootInstallNotSupported", + "inputs": [] + }, + { + "type": "error", + "name": "Module_RootInstallNotSupported", + "inputs": [] + }, + { + "type": "error", + "name": "Schema_InvalidLength", + "inputs": [ + { + "name": "length", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Schema_StaticTypeAfterDynamicType", + "inputs": [] + }, + { + "type": "error", + "name": "Slice_OutOfBounds", + "inputs": [ + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "start", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "end", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Store_IndexOutOfBounds", + "inputs": [ + { + "name": "length", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "accessedIndex", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Store_InvalidBounds", + "inputs": [ + { + "name": "start", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "end", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Store_InvalidFieldNamesLength", + "inputs": [ + { + "name": "expected", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "received", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Store_InvalidKeyNamesLength", + "inputs": [ + { + "name": "expected", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "received", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Store_InvalidResourceType", + "inputs": [ + { + "name": "expected", + "type": "bytes2", + "internalType": "bytes2" + }, + { + "name": "resourceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "resourceIdString", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "Store_InvalidSplice", + "inputs": [ + { + "name": "startWithinField", + "type": "uint40", + "internalType": "uint40" + }, + { + "name": "deleteCount", + "type": "uint40", + "internalType": "uint40" + }, + { + "name": "fieldLength", + "type": "uint40", + "internalType": "uint40" + } + ] + }, + { + "type": "error", + "name": "Store_InvalidStaticDataLength", + "inputs": [ + { + "name": "expected", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "received", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Store_InvalidValueSchemaDynamicLength", + "inputs": [ + { + "name": "expected", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "received", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Store_InvalidValueSchemaLength", + "inputs": [ + { + "name": "expected", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "received", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Store_InvalidValueSchemaStaticLength", + "inputs": [ + { + "name": "expected", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "received", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Store_TableAlreadyExists", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "tableIdString", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "Store_TableNotFound", + "inputs": [ + { + "name": "tableId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "tableIdString", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "World_AccessDenied", + "inputs": [ + { + "name": "resource", + "type": "string", + "internalType": "string" + }, + { + "name": "caller", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "World_AlreadyInitialized", + "inputs": [] + }, + { + "type": "error", + "name": "World_CallbackNotAllowed", + "inputs": [ + { + "name": "functionSelector", + "type": "bytes4", + "internalType": "bytes4" + } + ] + }, + { + "type": "error", + "name": "World_DelegationNotFound", + "inputs": [ + { + "name": "delegator", + "type": "address", + "internalType": "address" + }, + { + "name": "delegatee", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "World_FunctionSelectorAlreadyExists", + "inputs": [ + { + "name": "functionSelector", + "type": "bytes4", + "internalType": "bytes4" + } + ] + }, + { + "type": "error", + "name": "World_FunctionSelectorNotFound", + "inputs": [ + { + "name": "functionSelector", + "type": "bytes4", + "internalType": "bytes4" + } + ] + }, + { + "type": "error", + "name": "World_InsufficientBalance", + "inputs": [ + { + "name": "balance", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "World_InterfaceNotSupported", + "inputs": [ + { + "name": "contractAddress", + "type": "address", + "internalType": "address" + }, + { + "name": "interfaceId", + "type": "bytes4", + "internalType": "bytes4" + } + ] + }, + { + "type": "error", + "name": "World_InvalidNamespace", + "inputs": [ + { + "name": "namespace", + "type": "bytes14", + "internalType": "bytes14" + } + ] + }, + { + "type": "error", + "name": "World_InvalidResourceId", + "inputs": [ + { + "name": "resourceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "resourceIdString", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "World_InvalidResourceType", + "inputs": [ + { + "name": "expected", + "type": "bytes2", + "internalType": "bytes2" + }, + { + "name": "resourceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "resourceIdString", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "World_ResourceAlreadyExists", + "inputs": [ + { + "name": "resourceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "resourceIdString", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "World_ResourceNotFound", + "inputs": [ + { + "name": "resourceId", + "type": "bytes32", + "internalType": "ResourceId" + }, + { + "name": "resourceIdString", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "World_SystemAlreadyExists", + "inputs": [ + { + "name": "system", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "World_UnlimitedDelegationNotAllowed", + "inputs": [] + } +] \ No newline at end of file diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/IWorld.abi.json.meta b/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/IWorld.abi.json.meta new file mode 100644 index 000000000..674edf606 --- /dev/null +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/IWorld.abi.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 95864876aa70fc9418d44d22c274ff16 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/MudSample.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/MudSample.cs index ee34fc5e0..266651f3c 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/MudSample.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/MudSample.cs @@ -1,82 +1,86 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using System.Numerics; using ChainSafe.Gaming.Debugging; +using ChainSafe.Gaming.Evm.Contracts; using ChainSafe.Gaming.Evm.JsonRpc; using ChainSafe.Gaming.Mud; using ChainSafe.Gaming.UnityPackage; -using ChainSafe.Gaming.WalletConnect; using ChainSafe.Gaming.Wallets; using ChainSafe.Gaming.Web3; using ChainSafe.Gaming.Web3.Build; -using ChainSafe.Gaming.Web3.Evm.Wallet; using ChainSafe.Gaming.Web3.Unity; using Nethereum.ABI.FunctionEncoding.Attributes; -using Nethereum.Contracts; -using UnityEditor.VersionControl; +using Nethereum.Mud; +using TMPro; using UnityEngine; -using Task = System.Threading.Tasks.Task; public class MudSample : MonoBehaviour { public string WorldContractAddress; + public TextAsset WorldContractAbi; + public TMP_Text CounterLabel; private Web3 web3; - - [Function("app__increment", "uint32")] - public class IncrementFunction : FunctionMessage + private MudWorld world; + + public class CounterRecord : TableRecordSingleton // singleton table record - no key required { + public class CounterValue + { + [Parameter("uint32", "value", 1)] // column name + public BigInteger Counter { get; set; } + } + + public CounterRecord() : base("app", "Counter") // table name + { + } } - - // Try implementing a new Mud System with the GetCounter function. Uncomment then: - - // [Function("app__getCounter", "uint32")] - // public class GetCounterFunction : FunctionMessage - // { - // } - private void Awake() + private async void Awake() { Debug.Log("To run this sample successfully you should have the MUD tutorial project running in the background.\n" + "Follow the link https://mud.dev/quickstart"); + + // 1. Initialize Web3 client. + web3 = await new Web3Builder(ProjectConfigUtilities.Load(), ProjectConfigUtilities.BuildLocalhostConfig()) + .Configure(services => + { + services.UseUnityEnvironment(); + services.UseRpcProvider(); + + // Initializes Wallet as the first account of the locally running Ethereum Node (Anvil). + services.Debug().UseJsonRpcWallet(new JsonRpcWalletConfig { AccountIndex = 0 }); + + // Enable MUD + services.UseMud(); + }).LaunchAsync(); + Debug.Log("Web3 client ready"); + + // 2. Create MUD World client. + world = web3.Mud().BuildWorld(WorldContractAddress, WorldContractAbi.text); + Debug.Log("MUD World client ready"); + + // 3. Query current counter value. + var counterValue = (await world.Query()).Counter; + Debug.Log($"Counter value on load: {counterValue}"); + CounterLabel.text = counterValue.ToString("d"); } public async void IncrementCounter() { - if (web3 != null) + if (web3 is null) { - Debug.Log("Terminating old web3.."); - await web3.TerminateAsync(); + Debug.LogError("Can't run sample. Web3 client was not initialized."); + return; } - - // 1. Initialize web3 client. - web3 = await new Web3Builder(ProjectConfigUtilities.Load(), ProjectConfigUtilities.BuildLocalhostConfig()) - .Configure(services => - { - services.UseUnityEnvironment(); - services.UseRpcProvider(); - - // Initializes the Wallet as the first account of the locally running Ethereum Node (Anvil). - services.Debug().UseJsonRpcWallet(new JsonRpcWalletConfig { AccountIndex = 0 }); - services.UseMud(); - }).LaunchAsync(); - Debug.Log("New Web3 client ready"); - - // 2. Create MUD World client. - var world = web3.Mud().BuildWorld(WorldContractAddress); - Debug.Log("MUD World client ready"); - - // 3. Send transaction to execute the Increment function of the World contract. - Debug.Log("Sending transaction to execute IncrementFunction.."); - await world.Send(); - Debug.Log("Increment successful"); - - - Debug.Log("You can also call read-only functions for free. Open this script in the editor to continue."); - // 4. Try implementing a new Mud System with the GetCounter function. Uncomment then: + // 4. Send transaction to execute the Increment function of the World contract. + Debug.Log("Sending transaction to execute the Increment function.."); + await world.Send("app__increment"); + Debug.Log($"Increment successful"); - // var counter = await world.Call(); - // Debug.Log($"Counter is \"{counter}\""); + // 5. Query new counter value. + var counterValue = (await world.Query()).Counter; + Debug.Log($"Counter value after increment: {counterValue}"); + CounterLabel.text = counterValue.ToString("d"); } } diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/MudSample.unity b/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/MudSample.unity index 9cbc413bb..dcaf5e85e 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/MudSample.unity +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK MUD/MudSample.unity @@ -227,7 +227,7 @@ GameObject: - component: {fileID: 279131710} - component: {fileID: 279131709} m_Layer: 5 - m_Name: Text (TMP) + m_Name: Label - See Console m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -579,6 +579,7 @@ RectTransform: m_Children: - {fileID: 1474359000} - {fileID: 279131708} + - {fileID: 1231023404} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -586,6 +587,140 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} +--- !u!1 &1231023401 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1231023404} + - component: {fileID: 1231023403} + - component: {fileID: 1231023402} + m_Layer: 5 + m_Name: Label - Counter Value + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1231023402 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1231023401} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 36 + m_fontSizeBase: 36 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 1 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &1231023403 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1231023401} + m_CullTransparentMesh: 1 +--- !u!224 &1231023404 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1231023401} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 932061821} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.75} + m_AnchorMax: {x: 0.5, y: 0.75} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 200, y: 50} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &1474358999 GameObject: m_ObjectHideFlags: 0 @@ -599,7 +734,7 @@ GameObject: - component: {fileID: 1474359002} - component: {fileID: 1474359001} m_Layer: 5 - m_Name: Button + m_Name: Button - Increment m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -749,6 +884,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: WorldContractAddress: 0x8d8b6b8414e1e3dcfd4168561b9be6bd3bf6ec4b + WorldContractAbi: {fileID: 4900000, guid: 95864876aa70fc9418d44d22c274ff16, type: 3} + CounterLabel: {fileID: 1231023402} --- !u!4 &1709610250 Transform: m_ObjectHideFlags: 0 diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.6.0/Web3.Unity Samples/Scripts/Scenes/ConnectToWallet.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.6.0/Web3.Unity Samples/Scripts/Scenes/ConnectToWallet.cs index 4d520887d..744431133 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.6.0/Web3.Unity Samples/Scripts/Scenes/ConnectToWallet.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.6.0/Web3.Unity Samples/Scripts/Scenes/ConnectToWallet.cs @@ -9,7 +9,7 @@ public class ConnectToWallet : MonoBehaviour [SerializeField] private Button connectButton; private ConnectModal _connectModalInstance; - + private void Start() { connectButton.onClick.AddListener(PromptConnectModal); @@ -20,10 +20,10 @@ private void PromptConnectModal() if (_connectModalInstance != null) { _connectModalInstance.gameObject.SetActive(true); - + return; } - + _connectModalInstance = Instantiate(connectModalPrefab, connectModalContainer); } } diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.6.0/Web3.Unity Samples/Scripts/Scenes/SampleMain/Erc20/Erc20Calls.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.6.0/Web3.Unity Samples/Scripts/Scenes/SampleMain/Erc20/Erc20Calls.cs index dad47a5d7..a337995c8 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.6.0/Web3.Unity Samples/Scripts/Scenes/SampleMain/Erc20/Erc20Calls.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.6.0/Web3.Unity Samples/Scripts/Scenes/SampleMain/Erc20/Erc20Calls.cs @@ -38,7 +38,7 @@ public class Erc20Calls : MonoBehaviour #endregion - + /// /// Balance Of ERC20 Address @@ -99,7 +99,7 @@ public async void TotalSupply() /// public async void MintErc20() { - var mintResponse = await Web3Accessor.Web3.Erc20.Mint(ChainSafeContracts.Erc20, valueToSend * weiPerEther); + var mintResponse = await Web3Accessor.Web3.Erc20.Mint(ChainSafeContracts.Erc20, valueToSend * weiPerEther); var output = SampleOutputUtil.BuildOutputValue(mintResponse); SampleOutputUtil.PrintResult(output, "ERC-20", nameof(Erc20Service.Mint)); }