Skip to content

Commit

Permalink
Merge pull request #180 from ReserveBlockIO/staging
Browse files Browse the repository at this point in the history
Staging to main
  • Loading branch information
mathis1337 committed Apr 27, 2023
2 parents 5cbc03c + d67ee8a commit a4e401c
Show file tree
Hide file tree
Showing 19 changed files with 917 additions and 46 deletions.
5 changes: 3 additions & 2 deletions ReserveBlockCore/Controllers/ActionFilterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ public override void OnActionExecuting(ActionExecutingContext filterContext)
"GetAllLocalTX", "GetSuccessfulLocalTX", "GetFailedLocalTX", "GetPendingLocalTX", "GetMinedLocalTX", "GetAllTopics",
"GetActiveTopics", "GetInactiveTopics", "GetMyTopics", "GetAllSmartContracts", "GetMintedSmartContracts", "CheckStatus",
"GetIsWalletEncrypted", "GetMyVotes", "GetSingleSmartContract", "GetNFTAssetLocation", "GetCLIVersion", "CheckPasswordNeeded",
"GetBeacons", "GetValidatorInfo", "IsValidating", "NetworkMetrics", "Network", "Height", "LastBlock"};

"GetBeacons", "GetValidatorInfo", "IsValidating", "NetworkMetrics", "Network", "Height", "LastBlock", "GetDecShop", "GetSummaryChatMessages",
"GetAllCollections", "GetAllReserveAccounts", "GetSimpleShopChatMessages", "GetDecShopData", "GetShopSpecificAuction"};


if(!APIExclusionList.Contains(action))
{
if (Globals.GUI || Globals.LogAPI)
Expand Down
97 changes: 92 additions & 5 deletions ReserveBlockCore/Controllers/DSTV1Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using ReserveBlockCore.Utilities;
using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Net;

namespace ReserveBlockCore.Controllers
Expand Down Expand Up @@ -830,10 +831,13 @@ public async Task<string> GetDeleteLocalDecShop()
if(decDb != null)
{
var result = decDb.DeleteSafe(localShop.Id);
output = JsonConvert.SerializeObject(new { Success = true, Message = $"Local Dec Shop Deleted : {result}" });
}

var listingDeleteResult = await Listing.DeleteAllListingsByCollection(localShop.Id);
var auctionsDeleteResult = await Auction.DeleteAllAuctionsByCollection(localShop.Id);
var bidDeleteResult = await Bid.DeleteAllBidsByCollection(localShop.Id);

output = JsonConvert.SerializeObject(new { Success = true, Message = $"Delete Results - Shop : {result}, Listings : {listingDeleteResult.Item1}, Auctions : {auctionsDeleteResult.Item1}, Bids : {bidDeleteResult.Item1}" });
}
}
else
{
Expand Down Expand Up @@ -893,6 +897,21 @@ public async Task<string> GetNetworkDecShopInfo(string url)

}

/// <summary>
/// Get network dec shop list
/// </summary>
/// <returns></returns>
[HttpGet("GetDecShopStateTreiList")]
public async Task<string> GetDecShopStateTreiList()
{
var decshops = await DecShop.GetDecShopStateTreiList();

if(decshops?.Count() == 0)
return JsonConvert.SerializeObject(new { Success = false, Message = $"Could not find any DecShops." });

return JsonConvert.SerializeObject(new { Success = true, Message = $"Shops Found", DecShops = decshops }, Formatting.Indented);
}


/// <summary>
/// Connects to a shop : 'rbx://someurlgoeshere'
Expand All @@ -908,16 +927,45 @@ public async Task<bool> ConnectToDecShop(string address, string url)
if (decshop != null)
{
ConnectingAddress = address;
var accountExist = AccountData.GetSingleAccount(address);
if(!Debugger.IsAttached)
{
if (accountExist == null)
return false;
}
//removes current connection to shop
await DSTClient.DisconnectFromShop();
var connectionResult = await DSTClient.ConnectToShop(url);
var connectionResult = await DSTClient.ConnectToShop(url, address);

//if connectionResult == true create some looping event.

if (connectionResult)
_ = DSTClient.GetShopData(ConnectingAddress);

return connectionResult;
}

return false;
}

/// <summary>
/// Gets shop info
/// </summary>
/// <returns></returns>
[HttpGet("GetConnections")]
public async Task<string> GetConnections()
{
var connectedShop = Globals.ConnectedClients.Where(x => x.Value.IsConnected).Take(1);
if (connectedShop.Count() > 0)
{
var decShop = connectedShop.FirstOrDefault().Value;

if(decShop != null)
return JsonConvert.SerializeObject(new { Success = true, Message = $"Shop Found", DecShop = decShop, Connected = true });
}
return JsonConvert.SerializeObject(new { Success = true, Message = $"Shop Found", DecShop = "", Connected = false }); ;
}

/// <summary>
/// Gets shop info : 'rbx://someurlgoeshere'
/// </summary>
Expand Down Expand Up @@ -1073,6 +1121,31 @@ public async Task<bool> GetShopSpecificListing(string scUID)
return false;
}

/// <summary>
/// Gets shop Listings by collection
/// </summary>
/// <param name="listingId"></param>
/// <returns></returns>
[HttpGet("GetShopSpecificAuction/{listingId}")]
public async Task<bool> GetShopSpecificAuction(string listingId)
{
var connectedShop = Globals.ConnectedClients.Where(x => x.Value.IsConnected).Take(1);
if (connectedShop.Count() > 0)
{
Message message = new Message
{
Address = ConnectingAddress,
Data = $"{DecShopRequestOptions.SpecificAuction},{listingId}",
Type = MessageType.DecShop,
ComType = MessageComType.Request
};

_ = DSTClient.SendShopMessageFromClient(message, true);
return true;
}
return false;
}

/// <summary>
/// Send a bid to a listing
/// </summary>
Expand Down Expand Up @@ -1786,7 +1859,7 @@ public async Task<string> GetDecShopData()
{
if (Globals.DecShopData != null)
{
return JsonConvert.SerializeObject(new { Success = true, Message = "Data Found.", Globals.DecShopData });
return JsonConvert.SerializeObject(new { Success = true, Message = "Data Found.", Globals.DecShopData }, Formatting.Indented);
}
else
{
Expand Down Expand Up @@ -1838,7 +1911,21 @@ public async Task<string> Debug()
var shops = Globals.ConnectedShops;
var stunServer = Globals.STUNServer;

return JsonConvert.SerializeObject(new { Success = true, Clients = clients, Shops = shops, StunServer = stunServer });
return JsonConvert.SerializeObject(new { Success = true, Clients = clients, Shops = shops, StunServer = stunServer }, Formatting.Indented);
}

/// <summary>
/// Debug Data for DST
/// </summary>
/// <returns></returns>
[HttpGet("DebugData")]
public async Task<string> DebugData()
{
var CollectionCount = Collection.GetLiveCollections();
var ListingCount = Listing.GetLiveListingsCount();
var AuctionCount = Auction.GetLiveAuctionsCount();

return JsonConvert.SerializeObject(new { Success = true, CollectionCount, ListingCount, AuctionCount }, Formatting.Indented);
}
}
}
Loading

0 comments on commit a4e401c

Please sign in to comment.