Skip to content

Commit

Permalink
Remove TLY // Update to .NET 8 (#280)
Browse files Browse the repository at this point in the history
* - remove tly logic

* - migrate to .net8
  • Loading branch information
ArdenHide authored Nov 6, 2024
1 parent 6f9b6a1 commit 842e1dd
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 32 deletions.
5 changes: 1 addition & 4 deletions src/MetaDataAPI/DefaultServiceProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using TLY.ShortUrl;
using MetaDataAPI.Services.Erc20;
using EnvironmentManager.Extensions;
using MetaDataAPI.Services.Erc20;
using MetaDataAPI.Services.ChainsInfo;
using Microsoft.Extensions.DependencyInjection;
using poolz.finance.csharp.contracts.LockDealNFT;
Expand All @@ -15,7 +13,6 @@ public static class DefaultServiceProvider

serviceCollection.AddSingleton<IChainManager, DbChainManager>(_ => new DbChainManager());
serviceCollection.AddSingleton<IErc20Provider, Erc20Provider>(_ => new Erc20Provider());
serviceCollection.AddSingleton<ITlyContext, TlyContext>(_ => new TlyContext(Environments.TLY_API_KEY.Get()));
serviceCollection.AddSingleton<ILockDealNFTService, LockDealNFTService>(_ => new LockDealNFTService());

return serviceCollection.BuildServiceProvider();
Expand Down
4 changes: 1 addition & 3 deletions src/MetaDataAPI/Environments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ public enum Environments
[EnvironmentVariable(isRequired: true)]
NFT_HTML_ENDPOINT,
[EnvironmentVariable(isRequired: true)]
HTML_TO_IMAGE_ENDPOINT,
[EnvironmentVariable(isRequired: true)]
TLY_API_KEY
HTML_TO_IMAGE_ENDPOINT
}
3 changes: 1 addition & 2 deletions src/MetaDataAPI/MetaDataAPI.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand All @@ -20,7 +20,6 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Net.Cache.DynamoDb.ERC20" Version="1.3.3" />
<PackageReference Include="Net.Urlify" Version="1.0.1" />
<PackageReference Include="TLY.ShortUrl" Version="1.0.3" />
<PackageReference Include="Utils.EnvironmentManager" Version="3.0.4" />
<PackageReference Include="poolz.finance.csharp.contracts" Version="1.0.4" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/MetaDataAPI/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"Mock Lambda Test Tool": {
"commandName": "Executable",
"commandLineArgs": "--port 5050",
"workingDirectory": ".\\bin\\$(Configuration)\\net6.0",
"executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-6.0.exe"
"workingDirectory": ".\\bin\\$(Configuration)\\net8.0",
"executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-8.0.exe"
}
}
}
21 changes: 1 addition & 20 deletions src/MetaDataAPI/Providers/AbstractProvider.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Net.Urlify;
using TLY.ShortUrl;
using Nethereum.Web3;
using System.Numerics;
using HandlebarsDotNet;
using System.Reflection;
using Net.Urlify.Attributes;
using Net.Cryptography.SHA256;
using MetaDataAPI.Services.Erc20;
using MetaDataAPI.Providers.Image;
using EnvironmentManager.Extensions;
Expand All @@ -21,7 +19,6 @@ public abstract class AbstractProvider : Urlify
{
protected readonly ILockDealNFTService LockDealNft;
protected readonly IErc20Provider Erc20Provider;
protected readonly ITlyContext TlyContext;

public IEnumerable<BasePoolInfo> FullData { get; }
public BasePoolInfo PoolInfo { get; }
Expand Down Expand Up @@ -52,7 +49,6 @@ protected AbstractProvider(BasePoolInfo[] poolsInfo, ChainInfo chainInfo, IServi
: base((string)Environments.NFT_HTML_ENDPOINT.Get())
{
Erc20Provider = serviceProvider.GetRequiredService<IErc20Provider>();
TlyContext = serviceProvider.GetRequiredService<ITlyContext>();
LockDealNft = serviceProvider.GetRequiredService<ILockDealNFTService>();

FullData = poolsInfo;
Expand Down Expand Up @@ -84,22 +80,7 @@ private string GetDescription()

private string GetImage()
{
var url = new UrlifyProvider(this).BuildUrl();

var hash = $"{ChainInfo.ChainId}-{PoolId}-{VaultId}-{PoolInfo.Params}".ToSha256();
var description = $"ChainId: {ChainInfo.ChainId}, PoolId: {PoolId}, Hash: {hash}";

var shortUrl = TlyContext.SearchShortUrlAsync(description)
.GetAwaiter()
.GetResult()
.Data
.FirstOrDefault()
?.ShortUrl;

return shortUrl ?? TlyContext.CreateShortUrlAsync(url, description)
.GetAwaiter()
.GetResult()
.ShortUrl;
return new UrlifyProvider(this).BuildUrl();
}

private IEnumerable<Erc721MetadataItem> GetAttributes()
Expand Down
2 changes: 1 addition & 1 deletion tests/MetaDataAPI.Tests/MetaDataAPI.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>MetaDataAPI.Tests</RootNamespace>
Expand Down

0 comments on commit 842e1dd

Please sign in to comment.