diff --git a/Assets/Treasure/Example/Scripts/HarvesterUI.cs b/Assets/Treasure/Example/Scripts/HarvesterUI.cs index efce0ee2..41ad8dc9 100644 --- a/Assets/Treasure/Example/Scripts/HarvesterUI.cs +++ b/Assets/Treasure/Example/Scripts/HarvesterUI.cs @@ -1,5 +1,7 @@ using System; using System.Numerics; +using System.Threading.Tasks; + #if TDK_THIRDWEB using Thirdweb; @@ -23,6 +25,7 @@ public class HarvesterUI : MonoBehaviour public TMP_Text InfoText; private Harvester _harvester; + private HarvesterCorruptionRemoval _harvesterCorruptionRemoval; private BigInteger _magicAmount = BigInteger.Parse(Utils.ToWei("1000")); void Start() @@ -33,26 +36,38 @@ void Start() private async void refreshHarvester() { #if TDK_THIRDWEB - _harvester = await TDK.Bridgeworld.GetHarvester(Treasure.Contract.HarvesterEmberwing); + var harvesterTask = TDK.Bridgeworld.GetHarvester(Treasure.Contract.HarvesterEmberwing); + var harvesterCorruptionRemovalTask = TDK.Bridgeworld.GetHarvesterCorruptionRemoval(Treasure.Contract.HarvesterEmberwing); + + await Task.WhenAll(harvesterTask, harvesterCorruptionRemovalTask); + + _harvester = harvesterTask.Result; + _harvesterCorruptionRemoval = harvesterCorruptionRemovalTask.Result; + string smartAccountAddress = null; if (TDK.Identity.IsAuthenticated) { smartAccountAddress = await TDK.Identity.GetWalletAddress(); } - InfoText.text = $@"Smart Account: {(smartAccountAddress != null ? smartAccountAddress : '-')} + InfoText.text = $@" +Smart Account: {(smartAccountAddress != null ? smartAccountAddress : '-')} {Utils.ToEth(_harvester.userMagicBalance.ToString())} MAGIC balance {_harvester.userPermitsBalance} Ancient Permits -Harvester: {_harvester.id} +Harvester Details - Global Details Mining Power: {_harvester.totalBoost}X Corruption: {Utils.ToEth(_harvester.totalCorruption.ToString())} / {Utils.ToEth(_harvester.corruptionMaxGenerated.ToString())} {Utils.ToEth(_harvester.totalMagicStaked.ToString())} MAGIC staked - User Details +Corruption Removal + + {_harvesterCorruptionRemoval.corruptionRemovalRecipes.Count} recipe(s) available + +Harvester User Details + Mining Power: {_harvester.userTotalBoost}X {_harvester.userPermitsStaked} Ancient Permits staked {Utils.ToEth(_harvester.userMagicMaxStakeable.ToString())} MAGIC max stakeable diff --git a/Assets/Treasure/TDK/Runtime/API/Corruption.cs b/Assets/Treasure/TDK/Runtime/API/Corruption.cs index 4fa9241b..10447fb9 100644 --- a/Assets/Treasure/TDK/Runtime/API/Corruption.cs +++ b/Assets/Treasure/TDK/Runtime/API/Corruption.cs @@ -40,7 +40,7 @@ public struct HarvesterCorruptionRemoval { public List corruptionRemovalRecipes; public List userInventoryCorruptionRemovalRecipeItems; - public List> userApprovalsCorruptionRemovalRecipeItems; + public Dictionary userApprovalsCorruptionRemovalRecipeItems; public List userCorruptionRemovals; } @@ -51,5 +51,11 @@ public async Task GetHarvesterCorruptionRemoval(stri var response = await Get($"/harvesters/{id}/corruption-removal"); return JsonConvert.DeserializeObject(response); } + + public async Task GetHarvesterCorruptionRemoval(Contract contract) + { + var chainId = await TDK.Identity.GetChainId(); + return await GetHarvesterCorruptionRemoval(Constants.ContractAddresses[chainId][contract]); + } } } diff --git a/Assets/Treasure/TDK/Runtime/Bridgeworld/TDK.Bridgeworld.cs b/Assets/Treasure/TDK/Runtime/Bridgeworld/TDK.Bridgeworld.cs index 1aa3f2a9..adf67753 100644 --- a/Assets/Treasure/TDK/Runtime/Bridgeworld/TDK.Bridgeworld.cs +++ b/Assets/Treasure/TDK/Runtime/Bridgeworld/TDK.Bridgeworld.cs @@ -23,7 +23,7 @@ private void InitBridgeworld() } } - public class Bridgeworld + public partial class Bridgeworld { public Bridgeworld() { } @@ -31,6 +31,11 @@ public async Task GetHarvester(Contract contract) { return await TDK.API.GetHarvester(contract); } + + public async Task GetHarvesterCorruptionRemoval(Contract contract) + { + return await TDK.API.GetHarvesterCorruptionRemoval(contract); + } } public partial class Harvester diff --git a/Assets/Treasure/TDK/Runtime/TDKVersion.cs b/Assets/Treasure/TDK/Runtime/TDKVersion.cs index 4275faf0..70a24e64 100644 --- a/Assets/Treasure/TDK/Runtime/TDKVersion.cs +++ b/Assets/Treasure/TDK/Runtime/TDKVersion.cs @@ -3,6 +3,6 @@ public static class TDKVersion { public static string name = "tdk-unity"; - public static string version = "0.2.5"; + public static string version = "0.2.6"; } }