From 991fde2b20ece8c94d2605a74582423b5507ef5e Mon Sep 17 00:00:00 2001 From: oleksandr <59798783+creeppak@users.noreply.github.com> Date: Mon, 13 May 2024 18:47:20 +0100 Subject: [PATCH 01/11] Removed static Erc20, Erc721, Erc1155 utility classes from package scripts and added corresponding built-in contracts (ErcXXContract) and services (ErcXXService) to the core solution. Introduced IpfsHelper. --- .../Runtime/Scripts/EVM/Token/Erc1155.cs | 191 ------- .../Runtime/Scripts/EVM/Token/Erc1155.cs.meta | 11 - .../Scripts/EVM/Token/Erc1155Metadata.cs | 7 + .../Scripts/EVM/Token/Erc1155Metadata.cs.meta | 3 + .../EVM/Token/Erc1155UnityExtensions.cs | 46 ++ .../EVM/Token/Erc1155UnityExtensions.cs.meta | 3 + .../Runtime/Scripts/EVM/Token/Erc20.cs | 145 ----- .../Runtime/Scripts/EVM/Token/Erc20.cs.meta | 11 - .../Runtime/Scripts/EVM/Token/Erc721.cs | 170 ------ .../Runtime/Scripts/EVM/Token/Erc721.cs.meta | 11 - .../Runtime/Scripts/EVM/Token/Methods.cs.meta | 11 - .../Scripts/Model/OwnerOfBatchModel.cs.meta | 3 - src/ChainSafe.Gaming/ChainSafe.Gaming.csproj | 8 + src/ChainSafe.Gaming/Ipfs/IpfsHelper.cs | 28 + .../RPC/Contracts/BuiltIn/BuiltInContract.cs | 44 ++ .../RPC/Contracts/BuiltIn/ContractMethods.cs | 4 +- .../RPC/Contracts/BuiltIn/Erc1155Contract.cs | 135 +++++ .../RPC/Contracts/BuiltIn/Erc1155Service.cs | 41 ++ .../RPC/Contracts/BuiltIn/Erc20Contract.cs | 137 +++++ .../RPC/Contracts/BuiltIn/Erc20Service.cs | 42 ++ .../RPC/Contracts/BuiltIn/Erc721Contract.cs | 195 +++++++ .../RPC/Contracts/BuiltIn/Erc721Service.cs | 49 ++ .../Contracts/BuiltIn}/OwnerOfBatchModel.cs | 5 +- .../RPC/Contracts/Contract.cs | 6 +- .../RPC/Contracts/IContract.cs | 78 +++ .../Resources/erc-1155-abi.json | 489 +++++++++++++++++ .../Resources/erc-20-abi.json | 345 ++++++++++++ .../Resources/erc-721-abi.json | 508 ++++++++++++++++++ .../Scene/Rewards/Erc1155NftRewardFactory.cs | 3 +- .../Scripts/StringExtensions.cs | 8 - 30 files changed, 2170 insertions(+), 567 deletions(-) delete mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155.cs delete mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155.cs.meta create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155Metadata.cs create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155Metadata.cs.meta create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155UnityExtensions.cs create mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155UnityExtensions.cs.meta delete mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc20.cs delete mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc20.cs.meta delete mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc721.cs delete mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc721.cs.meta delete mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Methods.cs.meta delete mode 100644 Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/OwnerOfBatchModel.cs.meta create mode 100644 src/ChainSafe.Gaming/Ipfs/IpfsHelper.cs create mode 100644 src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/BuiltInContract.cs rename Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Methods.cs => src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/ContractMethods.cs (88%) create mode 100644 src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/Erc1155Contract.cs create mode 100644 src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/Erc1155Service.cs create mode 100644 src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/Erc20Contract.cs create mode 100644 src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/Erc20Service.cs create mode 100644 src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/Erc721Contract.cs create mode 100644 src/ChainSafe.Gaming/RPC/Contracts/BuiltIn/Erc721Service.cs rename {Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model => src/ChainSafe.Gaming/RPC/Contracts/BuiltIn}/OwnerOfBatchModel.cs (74%) create mode 100644 src/ChainSafe.Gaming/RPC/Contracts/IContract.cs create mode 100644 src/ChainSafe.Gaming/Resources/erc-1155-abi.json create mode 100644 src/ChainSafe.Gaming/Resources/erc-20-abi.json create mode 100644 src/ChainSafe.Gaming/Resources/erc-721-abi.json diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155.cs deleted file mode 100644 index ae8b2fccc..000000000 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155.cs +++ /dev/null @@ -1,191 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Numerics; -using System.Threading.Tasks; -using ChainSafe.Gaming.UnityPackage.Model; -using ChainSafe.Gaming.Web3; -using UnityEngine; -using UnityEngine.Networking; - -namespace Scripts.EVM.Token -{ - public static class Erc1155 - { - /// - /// Balance of ERC1155 Token (string parameter) - /// - /// - /// - /// - /// - /// - public static async Task BalanceOf(Web3 web3, string contractAddress, string account, string tokenId) - { - return await BalanceOf(web3, contractAddress, account, new object[] - { - account, - tokenId - }); - } - - /// - /// Balance of ERC1155 Token (biginteger parameter) - /// - /// - /// - /// - /// - /// - public static async Task BalanceOf(Web3 web3, string contractAddress, string account, BigInteger tokenId) - { - return await BalanceOf(web3, contractAddress, account, new object[] - { - account, - tokenId - }); - } - private static async Task BalanceOf(Web3 web3, string contractAddress, string account, object[] parameters) - { - var contract = web3.ContractBuilder.Build(ABI.Erc1155, contractAddress); - var contractData = await contract.Call(EthMethod.BalanceOf, parameters); - return BigInteger.Parse(contractData[0].ToString()); - } - - /// - /// Balance of Batch ERC1155 - /// - /// - /// - /// - /// - /// - public static async Task> BalanceOfBatch(Web3 web3, string contractAddress, string[] accounts, string[] tokenIds) - { - var contract = web3.ContractBuilder.Build(ABI.Erc1155, contractAddress); - var contractData = await contract.Call(EthMethod.BalanceOfBatch, new object[] - { - accounts, - tokenIds - }); - return contractData[0] as List ?? throw new System.Exception("Unexpected result from contract call"); - } - - /// - /// Token URI of ERC1155 Token - /// - /// - /// - /// - /// - public static async Task Uri(Web3 web3, string contractAddress, string tokenId) - { - const string ipfsPath = "https://ipfs.io/ipfs/"; - var contract = web3.ContractBuilder.Build(ABI.Erc1155, contractAddress); - if (tokenId.StartsWith("0x")) - { - string convertUri = tokenId.Replace("0x", "f"); - return ipfsPath + convertUri; - } - var contractData = await contract.Call(EthMethod.Uri, new object[] - { - tokenId - }); - return contractData[0].ToString(); - } - - /// - /// Mints ERC721 token - /// - /// - /// - /// - /// - /// - /// - public static async Task MintErc1155(Web3 web3, string abi, string contractAddress, BigInteger id, BigInteger amount) - { - byte[] dataObject = { }; - const string method = EthMethod.Mint; - var destination = web3.Signer.PublicAddress; - var contract = web3.ContractBuilder.Build(abi, contractAddress); - var response = await contract.Send(method, new object[] - { - destination, - id, - amount, - dataObject - }); - return response; - } - - /// - /// Transfers ERC721 token - /// - /// - /// - /// - /// - /// - /// - public static async Task TransferErc1155(Web3 web3, string contractAddress, BigInteger tokenId, BigInteger amount, string toAccount) - { - var account = web3.Signer.PublicAddress; - var abi = ABI.Erc1155; - var method = EthMethod.SafeTransferFrom; - byte[] dataObject = { }; - var contract = web3.ContractBuilder.Build(abi, contractAddress); - var response = await contract.Send(method, new object[] - { - account, - toAccount, - tokenId, - amount, - dataObject - }); - return response; - } - - /// - /// Imports an NFT texture via Uri data - /// - /// - /// - /// - /// - /// - public static async Task ImportNftTexture1155(Web3 web3, string contract, string tokenId) - { - // fetch uri from chain - string uri = await Uri(web3, contract, tokenId); - // fetch json from uri - UnityWebRequest webRequest = UnityWebRequest.Get(uri); - await webRequest.SendWebRequest(); - if (webRequest.result != UnityWebRequest.Result.Success) - { - throw new System.Exception(webRequest.error); - } - // Deserialize the data into the response class - Response data = - JsonUtility.FromJson(System.Text.Encoding.UTF8.GetString(webRequest.downloadHandler.data)); - // parse json to get image uri - string imageUri = data.image; - Debug.Log("imageUri: " + imageUri); - if (imageUri.StartsWith("ipfs://")) - { - imageUri = imageUri.Replace("ipfs://", "https://ipfs.io/ipfs/"); - } - Debug.Log("Revised URI: " + imageUri); - // fetch image and display in game - UnityWebRequest textureRequest = UnityWebRequestTexture.GetTexture(imageUri); - await textureRequest.SendWebRequest(); - var response = ((DownloadHandlerTexture)textureRequest.downloadHandler).texture; - return response; - } - - // Response class for the texture call above - public class Response - { - public string image; - } - } -} \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155.cs.meta deleted file mode 100644 index 5f5e2f3da..000000000 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c08a3b38196e24b31a3e35b41053a2cf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155Metadata.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155Metadata.cs new file mode 100644 index 000000000..d5cf15451 --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155Metadata.cs @@ -0,0 +1,7 @@ +namespace Scripts.EVM.Token +{ + public class Erc1155Metadata + { + public string image { get; set; } + } +} \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155Metadata.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155Metadata.cs.meta new file mode 100644 index 000000000..e29df799b --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155Metadata.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5c150d3e3858475db6446dccd3e3c383 +timeCreated: 1715619285 \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155UnityExtensions.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155UnityExtensions.cs new file mode 100644 index 000000000..0a96d06b1 --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155UnityExtensions.cs @@ -0,0 +1,46 @@ +using System.Diagnostics.Contracts; +using System.Text; +using System.Threading.Tasks; +using ChainSafe.Gaming.Evm.Contracts.BuiltIn; +using ChainSafe.Gaming.Ipfs; +using ChainSafe.Gaming.Web3; +using UnityEngine; +using UnityEngine.Networking; + +namespace Scripts.EVM.Token +{ + public static class Erc1155UnityExtensions + { + [Pure] + public static async Task ImportTexture(Erc1155Contract contract, string tokenId) + { + // fetch uri from chain + var uri = await contract.GetUri(tokenId); + + // fetch metadata from uri + var metaRequest = UnityWebRequest.Get(uri); + + if (metaRequest.result != UnityWebRequest.Result.Success) + { + throw new Web3Exception($"Metadata request failure: {metaRequest.error}"); + } + + // prepare texture uri + var metadata = JsonUtility.FromJson(Encoding.UTF8.GetString(metaRequest.downloadHandler.data)); + var textureUri = IpfsHelper.RollupIpfsUri(metadata.image); + + // fetch texture + var textureRequest = UnityWebRequestTexture.GetTexture(textureUri); + await textureRequest.SendWebRequest(); + + if (textureRequest.result != UnityWebRequest.Result.Success) + { + throw new Web3Exception($"Texture request failure: {metaRequest.error}"); + } + + var texture = ((DownloadHandlerTexture)textureRequest.downloadHandler).texture; + + return texture; + } + } +} \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155UnityExtensions.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155UnityExtensions.cs.meta new file mode 100644 index 000000000..5b43e34cd --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc1155UnityExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 127e124a404b4e068b8436f5b18638cb +timeCreated: 1715601274 \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc20.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc20.cs deleted file mode 100644 index 08d8b68a1..000000000 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc20.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System.Numerics; -using System.Threading.Tasks; -using ChainSafe.Gaming.Evm.Providers; -using ChainSafe.Gaming.Web3; - -namespace Scripts.EVM.Token -{ - public static class Erc20 - { - /// - /// Balance Of ERC20 Address - /// - /// - /// - /// - /// - public static async Task BalanceOf(Web3 web3, string contractAddress, string account) - { - var contract = web3.ContractBuilder.Build(ABI.Erc20, contractAddress); - var contractData = await contract.Call(EthMethod.BalanceOf, new object[] - { - account - }); - return BigInteger.Parse(contractData[0].ToString()); - } - - /// - /// Custom ERC20 token balance of an address - /// - /// - /// - /// - /// - public static async Task CustomTokenBalance(Web3 web3, string contractAbi, string contractAddress) - { - var contract = web3.ContractBuilder.Build(contractAbi, contractAddress); - string address = web3.Signer.PublicAddress; - var contractData = await contract.Call(EthMethod.BalanceOf, new object[] { address }); - return BigInteger.Parse(contractData[0].ToString()); - } - - /// - /// Native ERC20 balance of an Address - /// - /// - /// - /// - public static async Task NativeBalanceOf(Web3 web3, string account) - { - return await web3.RpcProvider.GetBalance(account); - } - - /// - /// Name of ERC20 Token - /// - /// - /// - /// - public static async Task Name(Web3 web3, string contractAddress) - { - var contract = web3.ContractBuilder.Build(ABI.Erc20, contractAddress); - var name = await contract.Call(EthMethod.Name); - return name[0].ToString(); - } - - /// - /// Symbol of ERC20 Token - /// - /// - /// - /// - public static async Task Symbol(Web3 web3, string contractAddress) - { - var contract = web3.ContractBuilder.Build(ABI.Erc20, contractAddress); - var symbol = await contract.Call(EthMethod.Symbol); - return symbol[0].ToString(); - } - - /// - /// Decimals of ERC20 Token - /// - /// - /// - /// - public static async Task Decimals(Web3 web3, string contractAddress) - { - var contract = web3.ContractBuilder.Build(ABI.Erc20, contractAddress); - var decimals = await contract.Call(EthMethod.Decimals); - return BigInteger.Parse(decimals[0].ToString()); - } - - /// - /// Total Supply of ERC20 Token - /// - /// - /// - /// - public static async Task TotalSupply(Web3 web3, string contractAddress) - { - var contract = web3.ContractBuilder.Build(ABI.Erc20, contractAddress); - var totalSupply = await contract.Call(EthMethod.TotalSupply); - return BigInteger.Parse(totalSupply[0].ToString()); - } - - /// - /// Mints ERC20 Tokens - /// - /// - /// - /// - /// - public static async Task MintErc20(Web3 web3, string contractAddress, string toAccount, BigInteger amount) - { - const string method = EthMethod.Mint; - var contract = web3.ContractBuilder.Build(ABI.Erc20, contractAddress); - var response = await contract.Send(method, new object[] - { - toAccount, - amount - }); - return response; - } - - /// - /// Transfers ERC20 Tokens - /// - /// - /// - /// - /// - /// - /// - public static async Task TransferErc20(Web3 web3, string contractAddress, string toAccount, BigInteger amount) - { - var method = EthMethod.Transfer; - var contract = web3.ContractBuilder.Build(ABI.Erc20, contractAddress); - var response = await contract.Send(method, new object[] - { - toAccount, - amount - }); - return response; - } - } -} \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc20.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc20.cs.meta deleted file mode 100644 index b0e9a2140..000000000 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc20.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8ddf9b9e7e8044c65b37afde7fc153d6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc721.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc721.cs deleted file mode 100644 index 73763d6ed..000000000 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc721.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System.Collections.Generic; -using System.Numerics; -using System.Threading.Tasks; -using ChainSafe.Gaming.MultiCall; -using ChainSafe.Gaming.UnityPackage.Model; -using ChainSafe.Gaming.Web3; -using Nethereum.Contracts.QueryHandlers.MultiCall; -using Nethereum.Hex.HexConvertors.Extensions; - -namespace Scripts.EVM.Token -{ - public static class Erc721 - { - /// - /// Balance Of ERC721 Token - /// - /// - /// - /// - /// - public static async Task BalanceOf(Web3 web3, string contractAddress, string account) - { - var contract = web3.ContractBuilder.Build(ABI.Erc721, contractAddress); - var contractData = await contract.Call(EthMethod.BalanceOf, new object[] - { - account - }); - return int.Parse(contractData[0].ToString()); - } - - /// - /// Owner Of ERC721 Token (string parameter) - /// - /// - /// - /// - /// - public static async Task OwnerOf(Web3 web3, string contractAddress, string tokenId) - { - return await OwnerOf(web3, contractAddress, new object[] { tokenId, }); - } - - /// - /// Owner Of ERC721 Token (biginteger parameter) - /// - /// - /// - /// - /// - public static async Task OwnerOf(Web3 web3, string contractAddress, BigInteger tokenId) - { - return await OwnerOf(web3, contractAddress, new object[] { tokenId, }); - } - private static async Task OwnerOf(Web3 web3, string contractAddress, object[] parameters) - { - var method = EthMethod.OwnerOf; - var contract = web3.ContractBuilder.Build(ABI.Erc721, contractAddress); - var contractData = await contract.Call(method, parameters); - return contractData[0].ToString(); - } - - /// - /// Returns owners of batch - /// - public static async Task> OwnerOfBatch( - Web3 web3, - string contractAddress, - string[] tokenIds) - { - var erc721Contract = web3.ContractBuilder.Build(ABI.Erc721, contractAddress); - List calls = new List(); - for (int i = 0; i < tokenIds.Length; i++) - { - var callData = erc721Contract.Calldata(EthMethod.OwnerOf, new object[] - { - tokenIds[i].StartsWith("0x") ? tokenIds[i] : BigInteger.Parse(tokenIds[i]) - }); - var call3Value = new Call3Value() - { - Target = contractAddress, - AllowFailure = true, - CallData = callData.HexToByteArray() - }; - calls.Add(call3Value); - }; - - var multiCallResultResponse = await web3.MultiCall().MultiCallAsync(calls.ToArray()); - var owners = new List(); - for (int i = 0; i < multiCallResultResponse.Count; i++) - { - if (multiCallResultResponse[i] != null && multiCallResultResponse[i].Success) - { - var owner = erc721Contract.Decode(EthMethod.OwnerOf, multiCallResultResponse[i].ReturnData.ToHex()); - owners.Add(new OwnerOfBatchModel() { TokenId = tokenIds[i], Owner = owner[0].ToString() }); - } - } - return owners; - } - - /// - /// Token URI Of ERC721 Token - /// - /// - /// - /// - /// - public static async Task Uri(Web3 web3, string contractAddress, string tokenId) - { - const string ipfsPath = "https://ipfs.io/ipfs/"; - var contract = web3.ContractBuilder.Build(ABI.Erc721, contractAddress); - if (tokenId.StartsWith("0x")) - { - var convertUri = tokenId.Replace("0x", "f"); - return ipfsPath + convertUri; - } - - var contractData = await contract.Call(EthMethod.TokenUri, new object[] - { - tokenId - }); - return contractData[0].ToString(); - } - - /// - /// Mints ERC721 token - /// - /// - /// - /// - /// - /// - public static async Task MintErc721(Web3 web3, string abi, string contractAddress, string uri) - { - const string method = EthMethod.SafeMint; - var destination = web3.Signer.PublicAddress; - var contract = web3.ContractBuilder.Build(abi, contractAddress); - var response = await contract.Send(method, new object[] - { - destination, - uri - }); - return response; - } - - /// - /// Transfers ERC721 token - /// - /// - /// - /// - /// - /// - public static async Task TransferErc721(Web3 web3, string contractAddress, string toAccount, BigInteger tokenId) - { - var abi = ABI.Erc721; - var method = EthMethod.SafeTransferFrom; - var account = web3.Signer.PublicAddress; - var contract = web3.ContractBuilder.Build(abi, contractAddress); - - var response = await contract.Send(method, new object[] - { - account, - toAccount, - tokenId.ToString() - }); - - return response; - } - } -} \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc721.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc721.cs.meta deleted file mode 100644 index 0e0cea078..000000000 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Erc721.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0cc525932e1f34ad7b1d2140d47856aa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Methods.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Methods.cs.meta deleted file mode 100644 index b1bcae6a4..000000000 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/EVM/Token/Methods.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cd0841fdefde87b40a16f2ded8443040 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/OwnerOfBatchModel.cs.meta b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/OwnerOfBatchModel.cs.meta deleted file mode 100644 index d704d7afe..000000000 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Model/OwnerOfBatchModel.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 5f33373a980b4a13b40a1a940b622f97 -timeCreated: 1708607850 \ No newline at end of file diff --git a/src/ChainSafe.Gaming/ChainSafe.Gaming.csproj b/src/ChainSafe.Gaming/ChainSafe.Gaming.csproj index 5225af0ac..cb395f804 100644 --- a/src/ChainSafe.Gaming/ChainSafe.Gaming.csproj +++ b/src/ChainSafe.Gaming/ChainSafe.Gaming.csproj @@ -35,6 +35,14 @@ + + + + + + + +