Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaDataAPI V2 #266

Merged
merged 38 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
291904d
- save
ArdenHide Jun 14, 2024
2791787
- remove old saved requests
ArdenHide Jun 14, 2024
096d351
- code cleanup
ArdenHide Jun 17, 2024
6ba209e
- code refactor
ArdenHide Jun 17, 2024
8fcf2e1
- update code
ArdenHide Jun 17, 2024
096f8c9
- use latest version of `Net.Cache.DynamoDb.ERC20` package
ArdenHide Jun 17, 2024
5b114b8
- setting properties in `PoolInfo`
ArdenHide Jun 17, 2024
bce3412
- refactor code
ArdenHide Jun 18, 2024
81b641d
- refactor code
ArdenHide Jun 18, 2024
697a037
- write a comment
ArdenHide Jun 18, 2024
7fdd9ab
- update `CollateralProvider`
ArdenHide Jun 18, 2024
72ad667
- remove `OnDescriptionCreating()`
ArdenHide Jun 18, 2024
0ed090d
- update `GetDescription`
ArdenHide Jun 19, 2024
85c4664
- save
ArdenHide Jun 19, 2024
8f60f5f
- fix bug in Refund Provider
ArdenHide Jun 20, 2024
2160c1b
- bugfix in `CollateralProvider`
ArdenHide Jun 20, 2024
8402d14
- reorganize
ArdenHide Jun 21, 2024
a4e05da
- build fix
ArdenHide Jun 21, 2024
347bcfc
- save
ArdenHide Jun 21, 2024
d1c3c4d
- move `CollateralType` to `CollateralProvider`
ArdenHide Jun 21, 2024
55b9a2c
- rename `Erc721Attribute` to `Erc721MetadataItem`
ArdenHide Jun 21, 2024
e7f7cab
- draw MainCoin for `RefundProvider`
ArdenHide Jun 21, 2024
b9e6dc7
- update response logic
ArdenHide Jun 21, 2024
61db4cc
- update `IChainmanager` and implementation.
ArdenHide Jun 21, 2024
481349a
Merge branch 'master' into meta-data-api-v2
ArdenHide Jun 21, 2024
dea6201
- fix auto-validation for LambdaRequest
ArdenHide Jun 26, 2024
9e12262
- returns `provider name` in metadata response
ArdenHide Jun 26, 2024
b031026
- rename `protected` members in `AbstractProvider`
ArdenHide Jun 26, 2024
4ccd275
- register `ILockDealNFTService` in `DefaultServiceProvider`
ArdenHide Jun 26, 2024
02b52e1
- check if pool id less then total supply
ArdenHide Jun 26, 2024
a8f97b7
- remove old saved requests
ArdenHide Jun 26, 2024
484a02c
- remove all exist tests
ArdenHide Jun 28, 2024
a897aee
Merge branch 'master' into meta-data-api-v2
ArdenHide Jul 1, 2024
8ec1b47
MetaDataAPI V2 - Tests (#270)
ArdenHide Jul 1, 2024
7bb0589
Merge branch 'master' into meta-data-api-v2
ArdenHide Jul 1, 2024
7c63a13
Merge branch 'master' into meta-data-api-v2
ArdenHide Jul 1, 2024
e123ddb
Update `IChainManager` (#272)
ArdenHide Jul 1, 2024
abbfd68
Meta data api v2 description (#276)
ArdenHide Jul 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"queryStringParameters": {
"id": 20
"poolId": 0,
"chainId": 97
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"queryStringParameters": {
"id": 2
"poolId":1,
"chainId": 97
}
}
15 changes: 0 additions & 15 deletions src/MetaDataAPI/Attributes/ErrorMessageAttribute.cs

This file was deleted.

9 changes: 9 additions & 0 deletions src/MetaDataAPI/BlockchainManager/IChainManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Numerics;
using MetaDataAPI.BlockchainManager.Models;

namespace MetaDataAPI.BlockchainManager;

public interface IChainManager
{
public ChainInfo FetchChainInfo(BigInteger chainId);
}
17 changes: 17 additions & 0 deletions src/MetaDataAPI/BlockchainManager/LocalChainManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Numerics;
using MetaDataAPI.BlockchainManager.Models;

namespace MetaDataAPI.BlockchainManager;

public class LocalChainManager : IChainManager
{
private readonly IDictionary<BigInteger, ChainInfo> localChainInfo = new Dictionary<BigInteger, ChainInfo>
{
{ 97, new ChainInfo(97, "https://data-seed-prebsc-1-s1.binance.org:8545/", "0xe42876a77108E8B3B2af53907f5e533Cba2Ce7BE") }
};

public ChainInfo FetchChainInfo(BigInteger chainId)
{
return localChainInfo[chainId];
}
}
18 changes: 18 additions & 0 deletions src/MetaDataAPI/BlockchainManager/Models/ChainInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Numerics;
using Net.Web3.EthereumWallet;

namespace MetaDataAPI.BlockchainManager.Models;

public class ChainInfo
{
public BigInteger ChainId { get; set; }
public string RpcUrl { get; set; }
public EthereumAddress LockDealNFT { get; set; }

public ChainInfo(BigInteger chainId, string rpcUrl, EthereumAddress lockDealNft)
{
ChainId = chainId;
RpcUrl = rpcUrl;
LockDealNFT = lockDealNft;
}
}
6 changes: 1 addition & 5 deletions src/MetaDataAPI/Environments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ namespace MetaDataAPI;

public enum Environments
{
[EnvironmentVariable(isRequired: true)]
LOCK_DEAL_NFT_ADDRESS,
[EnvironmentVariable(isRequired: true)]
RPC_URL,
[EnvironmentVariable(isRequired: true)]
NFT_HTML_ENDPOINT,
[EnvironmentVariable(isRequired: true)]
HTML_TO_IMAGE_ENDPOINT_TEMPLATE,
HTML_TO_IMAGE_ENDPOINT,
[EnvironmentVariable(isRequired: true)]
TLY_API_KEY
}
34 changes: 34 additions & 0 deletions src/MetaDataAPI/Erc20Manager/Erc20Provider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Numerics;
using Net.Web3.EthereumWallet;
using Net.Cache.DynamoDb.ERC20;
using Net.Cache.DynamoDb.ERC20.Models;

namespace MetaDataAPI.Erc20Manager;

public class Erc20Provider : IErc20Provider
{
private readonly ERC20CacheProvider provider;

public Erc20Provider()
{
provider = new ERC20CacheProvider();
}

public Erc20Provider(ERC20CacheProvider provider)
{
this.provider = provider;
}

public Erc20Token GetErc20Token(string rpcUrl, BigInteger chainId, EthereumAddress address)
ArdenHide marked this conversation as resolved.
Show resolved Hide resolved
{
var cache = provider.GetOrAdd(
new GetCacheRequest(
chainId: (long)chainId, //TODO: Check for potential overflow or data loss when upcasting BigInteger to Int64
address,
rpcUrl,
false
)
);
return new Erc20Token(cache);
}
}
22 changes: 22 additions & 0 deletions src/MetaDataAPI/Erc20Manager/Erc20Token.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Net.Cache.DynamoDb.ERC20.Models;
using Net.Web3.EthereumWallet.Extensions;

namespace MetaDataAPI.Erc20Manager;

public class Erc20Token
{
public string Name { get; set; }
public string Symbol { get; set; }
public string Address { get; set; }
public byte Decimals { get; set; }

public Erc20Token(ERC20DynamoDbTable cacheErc20)
{
Name = cacheErc20.Name;
Symbol = cacheErc20.Symbol;
Address = cacheErc20.Address;
Decimals = cacheErc20.Decimals;
}

public override string ToString() => $"{Name} ({Symbol}@{Address.ToShortAddress(5)})";
}
9 changes: 9 additions & 0 deletions src/MetaDataAPI/Erc20Manager/IErc20Provider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Numerics;
using Net.Web3.EthereumWallet;

namespace MetaDataAPI.Erc20Manager;

public interface IErc20Provider
{
public Erc20Token GetErc20Token(string rpcUrl, BigInteger chainId, EthereumAddress address);
}
9 changes: 0 additions & 9 deletions src/MetaDataAPI/Extensions/BigIntegerExtensions.cs

This file was deleted.

10 changes: 10 additions & 0 deletions src/MetaDataAPI/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Numerics;

namespace MetaDataAPI.Extensions;

public static class DateTimeExtensions
{
public static string DateTimeStringFormat(this DateTime dateTime) => $"{dateTime:MM/dd/yyyy} {dateTime:HH:mm:ss}";
public static string DateTimeStringFormat(this BigInteger timestamp) =>
DateTimeStringFormat(DateTimeOffset.FromUnixTimeSeconds((long)timestamp).UtcDateTime);
}
8 changes: 0 additions & 8 deletions src/MetaDataAPI/ImageGeneration/IImageGenerator.cs

This file was deleted.

28 changes: 0 additions & 28 deletions src/MetaDataAPI/ImageGeneration/ImageGenerator.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/MetaDataAPI/ImageGeneration/Services/IImageRenderer.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/MetaDataAPI/ImageGeneration/Services/IUrlShortener.cs

This file was deleted.

15 changes: 0 additions & 15 deletions src/MetaDataAPI/ImageGeneration/Services/ImageRenderer.cs

This file was deleted.

27 changes: 0 additions & 27 deletions src/MetaDataAPI/ImageGeneration/Services/UrlShortener.cs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading