Skip to content

Commit

Permalink
Merge branch 'main' into test/test
Browse files Browse the repository at this point in the history
  • Loading branch information
Atralupus authored Dec 4, 2024
2 parents 734b456 + b12d64f commit b8f0d41
Show file tree
Hide file tree
Showing 27 changed files with 645 additions and 23 deletions.
4 changes: 3 additions & 1 deletion Lib9c.Models/Items/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace Lib9c.Models.Items;
public record Inventory : IBencodable
{
public List<InventoryItem> Items { get; init; }


public Inventory() { }

[BsonIgnore, GraphQLIgnore, JsonIgnore]
public IValue Bencoded => new List(Items
.OrderBy(i => i.Item.Id)
Expand Down
4 changes: 3 additions & 1 deletion Lib9c.Models/Items/InventoryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public record InventoryItem : IBencodable
public ItemBase Item { get; init; }
public int Count { get; init; }
public ILock? Lock { get; init; }


public InventoryItem() { }

[BsonIgnore, GraphQLIgnore, JsonIgnore]
public IValue Bencoded
{
Expand Down
2 changes: 2 additions & 0 deletions Lib9c.Models/Stake/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public record Contract : IBencodable
public long RewardInterval { get; init; }
public long LockupInterval { get; init; }

public Contract(){}

public Contract(IValue bencoded)
{
if (bencoded is not List l)
Expand Down
2 changes: 2 additions & 0 deletions Lib9c.Models/States/StakeState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public record StakeState : IBencodable
public Contract Contract { get; init; }
public long StartedBlockIndex { get; init; }
public long ReceivedBlockIndex { get; init; }

public StakeState() {}

Check warning on line 23 in Lib9c.Models/States/StakeState.cs

View workflow job for this annotation

GitHub Actions / Test (Lib9c.Models.Tests)

Non-nullable property 'Contract' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[BsonIgnore, GraphQLIgnore, JsonIgnore]
public IValue Bencoded =>
Expand Down
3 changes: 2 additions & 1 deletion Mimir.MongoDB/Bson/PledgeDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public record PledgeDocument(
Address ContractAddress,
bool Contracted,
int RefillMead
) : MimirBsonDocument(Address.ToHex(), new DocumentMetadata(1, StoredBlockIndex)) { }
) : MimirBsonDocument(Address.ToHex(), new DocumentMetadata(1, StoredBlockIndex));

1 change: 0 additions & 1 deletion Mimir.MongoDB/Repositories/ActionPointRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public interface IActionPointRepository
{
Task<ActionPointDocument> GetByAddressAsync(Address address);
}

public class ActionPointRepository(IMongoDbService dbService) : IActionPointRepository
{
public virtual async Task<ActionPointDocument> GetByAddressAsync(Address address)
Expand Down
7 changes: 6 additions & 1 deletion Mimir.MongoDB/Repositories/InventoryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

namespace Mimir.MongoDB.Repositories;

public class InventoryRepository(IMongoDbService dbService)
public interface IInventoryRepository
{
public Task<InventoryDocument> GetByAddressAsync(Address address);
}

public class InventoryRepository(IMongoDbService dbService) : IInventoryRepository
{
public async Task<InventoryDocument> GetByAddressAsync(Address address)
{
Expand Down
9 changes: 7 additions & 2 deletions Mimir.MongoDB/Repositories/MetadataRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
using MongoDB.Driver;

namespace Mimir.MongoDB.Repositories;

public class MetadataRepository(IMongoDbService dbService)
public interface IMetadataRepository{
Task<MetadataDocument> GetByCollectionAsync(string collectionName);
Task<MetadataDocument> GetByCollectionAndTypeAsync(
string pollerType,
string collectionName);
}
public class MetadataRepository(IMongoDbService dbService):IMetadataRepository
{
public async Task<MetadataDocument> GetByCollectionAsync(string collectionName)
{
Expand Down
7 changes: 6 additions & 1 deletion Mimir.MongoDB/Repositories/PledgeRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
using MongoDB.Driver;

namespace Mimir.MongoDB.Repositories;
public interface IPledgeRepository
{
Task<PledgeDocument> GetByAddressAsync(Address address);
}


public class PledgeRepository(IMongoDbService dbService)
public class PledgeRepository(IMongoDbService dbService) : IPledgeRepository
{
public async Task<PledgeDocument> GetByAddressAsync(Address address)
{
Expand Down
7 changes: 6 additions & 1 deletion Mimir.MongoDB/Repositories/ProductRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

namespace Mimir.MongoDB.Repositories;

public class ProductRepository
public interface IProductRepository
{
Task<ProductDocument> GetByProductIdAsync(Guid productId);
}

public class ProductRepository : IProductRepository
{
private static readonly Codec Codec = new();

Expand Down
6 changes: 5 additions & 1 deletion Mimir.MongoDB/Repositories/ProductsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

namespace Mimir.MongoDB.Repositories;

public class ProductsRepository(IMongoDbService dbService)
public interface IProductsRepository{
Task<ProductsStateDocument> GetByAvatarAddressAsync(Address avatarAddress);
}

public class ProductsRepository(IMongoDbService dbService):IProductsRepository
{
public async Task<ProductsStateDocument> GetByAvatarAddressAsync(Address avatarAddress)
{
Expand Down
7 changes: 6 additions & 1 deletion Mimir.MongoDB/Repositories/StakeRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

namespace Mimir.MongoDB.Repositories;

public class StakeRepository(IMongoDbService dbService)
public interface IStakeRepository
{
Task<StakeDocument> GetByAgentAddressAsync(Address agentAddress);
}

public class StakeRepository(IMongoDbService dbService) : IStakeRepository
{
public async Task<StakeDocument> GetByAgentAddressAsync(Address agentAddress)
{
Expand Down
6 changes: 6 additions & 0 deletions Mimir.Tests/Mimir.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@
<ItemGroup>
<ProjectReference Include="..\Mimir\Mimir.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="QueryTests\InventoryTest.GraphQL_Query_Inventory_Returns_CorrectValue.received.txt">
<DependentUpon>InventoryTest.cs</DependentUpon>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"data": {
"inventory": {
"items": [
{
"count": 1,
"item": {
"elementalType": "NORMAL",
"grade": 1,
"id": 1,
"itemSubType": "ARMOR",
"itemType": "EQUIPMENT"
}
},
{
"count": 2,
"item": {
"elementalType": "FIRE",
"grade": 2,
"id": 2,
"itemSubType": "FOOD",
"itemType": "MATERIAL"
}
}
]
}
}
}
Loading

0 comments on commit b8f0d41

Please sign in to comment.