diff --git a/Lib9c.GraphQL/Types/Items/InventoryItemType.cs b/Lib9c.GraphQL/Types/Items/InventoryItemType.cs new file mode 100644 index 00000000..032f4d9a --- /dev/null +++ b/Lib9c.GraphQL/Types/Items/InventoryItemType.cs @@ -0,0 +1,12 @@ +using HotChocolate.Types; +using Lib9c.Models.Items; + +namespace Lib9c.GraphQL.Types.Items; + +public class InventoryItemType : ObjectType +{ + protected override void Configure(IObjectTypeDescriptor descriptor) + { + descriptor.Ignore(f => f.Lock); + } +} diff --git a/Mimir.MongoDB/Repositories/InventoryRepository.cs b/Mimir.MongoDB/Repositories/InventoryRepository.cs index c10c0066..f983dff3 100644 --- a/Mimir.MongoDB/Repositories/InventoryRepository.cs +++ b/Mimir.MongoDB/Repositories/InventoryRepository.cs @@ -8,17 +8,17 @@ namespace Mimir.MongoDB.Repositories; public class InventoryRepository(MongoDbService dbService) { - public async Task GetByAddressAsync(Address avatarAddress) + public async Task GetByAddressAsync(Address address) { var collectionName = CollectionNames.GetCollectionName(); var collection = dbService.GetCollection(collectionName); - var filter = Builders.Filter.Eq("Address", avatarAddress.ToHex()); + var filter = Builders.Filter.Eq("Address", address.ToHex()); var document = await collection.Find(filter).FirstOrDefaultAsync(); if (document is null) { throw new DocumentNotFoundInMongoCollectionException( collection.CollectionNamespace.CollectionName, - $"'Address' equals to '{avatarAddress.ToHex()}'"); + $"'Address' equals to '{address.ToHex()}'"); } return document; diff --git a/Mimir/GraphQL/Queries/Query.cs b/Mimir/GraphQL/Queries/Query.cs index f0efa245..6d388890 100644 --- a/Mimir/GraphQL/Queries/Query.cs +++ b/Mimir/GraphQL/Queries/Query.cs @@ -1,6 +1,7 @@ using HotChocolate.AspNetCore; using Lib9c.GraphQL.Extensions; using Lib9c.GraphQL.InputObjects; +using Lib9c.Models.Items; using Lib9c.Models.Market; using Lib9c.Models.States; using Libplanet.Crypto; @@ -100,6 +101,14 @@ public async Task> GetCombinationSlotsAsyn public async Task GetDailyRewardReceivedBlockIndexAsync(Address address, [Service] DailyRewardRepository repo) => (await repo.GetByAddressAsync(address)).Object; + /// + /// Get the inventory state by avatar address. + /// + /// The address of the avatar. + /// The inventory state for the specified avatar address. + public async Task GetInventoryAsync(Address address, [Service] InventoryRepository repo) => + (await repo.GetByAddressAsync(address)).Object; + /// /// Get metadata by collection name. /// diff --git a/Mimir/Program.cs b/Mimir/Program.cs index e930e9b1..cc5dce38 100644 --- a/Mimir/Program.cs +++ b/Mimir/Program.cs @@ -44,7 +44,7 @@ builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); -// builder.Services.AddSingleton(); +builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton();