Skip to content

Commit be924cc

Browse files
authored
Merge release/1.0.9.6. to master (#791)
* Update CirrusDev.cs * Add SignalR to CirrusMinerD (#700) * Update ContractSwaggerController.cs (#702) * Fix AddContractToSwagger method (#703) * Fix Routing (#704)
1 parent 4598973 commit be924cc

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

src/Stratis.Bitcoin.Features.SmartContracts/ReflectionExecutor/Controllers/ContractSwaggerController.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Text;
54
using System.Threading.Tasks;
65
using CSharpFunctionalExtensions;
76
using Microsoft.AspNetCore.Mvc;
8-
using Microsoft.Extensions.Options;
97
using Microsoft.OpenApi;
108
using Microsoft.OpenApi.Extensions;
119
using Microsoft.OpenApi.Models;
@@ -23,15 +21,14 @@ namespace Stratis.Bitcoin.Features.SmartContracts.ReflectionExecutor.Controllers
2321
/// <summary>
2422
/// Controller for dynamically generating swagger documents for smart contract assemblies.
2523
/// </summary>
26-
[Route("swagger/contracts")]
2724
public class ContractSwaggerController : Controller
2825
{
2926
private readonly SwaggerGeneratorOptions options;
3027
private readonly ILoader loader;
3128
private readonly IWalletManager walletmanager;
3229
private readonly IStateRepositoryRoot stateRepository;
3330
private readonly Network network;
34-
private SwaggerUIOptions uiOptions;
31+
private readonly SwaggerUIOptions uiOptions;
3532

3633
public ContractSwaggerController(
3734
SwaggerGeneratorOptions options,
@@ -55,7 +52,7 @@ public ContractSwaggerController(
5552
/// <param name="address">The contract's address.</param>
5653
/// <returns>A <see cref="SwaggerDocument"/> model.</returns>
5754
/// <exception cref="Exception"></exception>
58-
[Route("{address}")]
55+
[Route("swagger/contracts/{address}")]
5956
[HttpGet]
6057
public async Task<IActionResult> ContractSwaggerDoc(string address)
6158
{
@@ -94,25 +91,35 @@ public async Task<IActionResult> ContractSwaggerDoc(string address)
9491
/// <param name="address">The contract's address.</param>
9592
/// <returns>A success response.</returns>
9693
[HttpPost]
97-
public async Task<IActionResult> AddContractToSwagger([FromBody] string address)
94+
[Route("api/swagger/contracts")]
95+
public async Task<IActionResult> AddContractToSwagger([FromBody] AddContractRequest address)
9896
{
9997
// Check that the contract exists
100-
var code = this.stateRepository.GetCode(address.ToUint160(this.network));
98+
var code = this.stateRepository.GetCode(address.Address.ToUint160(this.network));
10199

102100
if (code == null)
103101
throw new Exception("Contract does not exist");
104102

105-
var newUrls = new List<UrlDescriptor>(this.uiOptions.ConfigObject.Urls);
106-
107-
newUrls.Add(new UrlDescriptor
103+
var newUrls = new List<UrlDescriptor>(this.uiOptions.ConfigObject.Urls)
108104
{
109-
Name = $"Contract {address}",
110-
Url = $"/swagger/contracts/{address}"
111-
});
105+
new UrlDescriptor
106+
{
107+
Name = $"Contract {address.Address}",
108+
Url = $"contracts/{address.Address}"
109+
}
110+
};
112111

113112
this.uiOptions.ConfigObject.Urls = newUrls;
114113

115114
return Ok();
116115
}
116+
117+
public class AddContractRequest
118+
{
119+
/// <summary>
120+
/// The contract address to add.
121+
/// </summary>
122+
public string Address { get; set; }
123+
}
117124
}
118-
}
125+
}

src/Stratis.CirrusMinerD/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Stratis.Bitcoin.Features.Miner;
1414
using Stratis.Bitcoin.Features.Notifications;
1515
using Stratis.Bitcoin.Features.RPC;
16+
using Stratis.Bitcoin.Features.SignalR;
1617
using Stratis.Bitcoin.Features.SmartContracts;
1718
using Stratis.Bitcoin.Features.SmartContracts.PoA;
1819
using Stratis.Bitcoin.Features.SmartContracts.Wallet;
@@ -135,6 +136,10 @@ private static IFullNode BuildDevCirrusMiningNode(string[] args)
135136
})
136137
.UseSmartContractWallet()
137138
.AddSQLiteWalletRepository()
139+
.AddSignalR(options =>
140+
{
141+
DaemonConfiguration.ConfigureSignalRForCirrus(options);
142+
})
138143
.Build();
139144

140145
return node;

src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ItemGroup>
1313
<ProjectReference Include="..\Stratis.Bitcoin.Features.Api\Stratis.Bitcoin.Features.Api.csproj" />
1414
<ProjectReference Include="..\Stratis.Bitcoin.Features.Notifications\Stratis.Bitcoin.Features.Notifications.csproj" />
15+
<ProjectReference Include="..\Stratis.Bitcoin.Features.SignalR\Stratis.Bitcoin.Features.SignalR.csproj" />
1516
<ProjectReference Include="..\Stratis.Bitcoin.Networks\Stratis.Bitcoin.Networks.csproj" />
1617
<ProjectReference Include="..\Stratis.Features.Collateral\Stratis.Features.Collateral.csproj" />
1718
<ProjectReference Include="..\Stratis.Features.SQLiteWalletRepository\Stratis.Features.SQLiteWalletRepository.csproj" />

src/Stratis.Sidechains.Networks/CirrusDev.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public CirrusDev()
3535
this.DefaultMaxInboundConnections = 109;
3636
this.DefaultRPCPort = 26175;
3737
this.DefaultAPIPort = 38223;
38+
this.DefaultAPIPort = 38223;
39+
this.DefaultSignalRPort = 39823;
3840
this.MaxTipAge = 768; // 20% of the fastest time it takes for one MaxReorgLength of blocks to be mined.
3941
this.MinTxFee = 10000;
4042
this.FallbackFee = 10000;

0 commit comments

Comments
 (0)