Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed Aug 2, 2021
1 parent 552a642 commit 5b3fd92
Show file tree
Hide file tree
Showing 68 changed files with 8,876 additions and 8,823 deletions.
2 changes: 1 addition & 1 deletion Tzkt.Api/Controllers/AccountsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public async Task<ActionResult<IEnumerable<RelatedContract>>> GetContracts(
/// <returns></returns>
[HttpGet("{address}/delegators")]
public async Task<ActionResult<IEnumerable<Delegator>>> GetDelegators(
[Required][Address] string address,
[Required][TzAddress] string address,
AccountTypeParameter type,
Int64Parameter balance,
Int32Parameter delegationLevel,
Expand Down
44 changes: 22 additions & 22 deletions Tzkt.Api/Controllers/ContractsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public Task<int> GetCount(ContractKindParameter kind)
/// <param name="address">Contract address (starting with KT)</param>
/// <returns></returns>
[HttpGet("{address}")]
public Task<Contract> GetByAddress([Required][Address] string address)
public Task<Contract> GetByAddress([Required][KTAddress] string address)
{
return Accounts.GetContract(address);
}
Expand All @@ -170,7 +170,7 @@ public Task<Contract> GetByAddress([Required][Address] string address)
/// <returns></returns>
[HttpGet("{address}/same")]
public async Task<ActionResult<IEnumerable<Contract>>> GetSame(
[Required][Address] string address,
[Required][KTAddress] string address,
SelectParameter select,
SortParameter sort,
OffsetParameter offset,
Expand Down Expand Up @@ -229,7 +229,7 @@ public async Task<ActionResult<IEnumerable<Contract>>> GetSame(
/// <returns></returns>
[HttpGet("{address}/similar")]
public async Task<ActionResult<IEnumerable<Contract>>> GetSimilar(
[Required][Address] string address,
[Required][KTAddress] string address,
SelectParameter select,
SortParameter sort,
OffsetParameter offset,
Expand Down Expand Up @@ -282,7 +282,7 @@ public async Task<ActionResult<IEnumerable<Contract>>> GetSimilar(
/// <param name="format">Code format (`0` - micheline, `1` - michelson, `2` - bytes (base64))</param>
/// <returns></returns>
[HttpGet("{address}/code")]
public async Task<object> GetCode([Required][Address] string address, [Range(0, 2)] int format = 0)
public async Task<object> GetCode([Required][KTAddress] string address, [Range(0, 2)] int format = 0)
{
if (format == 0)
return await Accounts.GetMichelineCode(address);
Expand All @@ -300,7 +300,7 @@ public async Task<object> GetCode([Required][Address] string address, [Range(0,
/// <param name="address">Contract address</param>
/// <returns></returns>
[HttpGet("{address}/interface")]
public Task<ContractInterface> GetInterface([Required][Address] string address)
public Task<ContractInterface> GetInterface([Required][KTAddress] string address)
{
return Accounts.GetContractInterface(address);
}
Expand All @@ -321,7 +321,7 @@ public Task<ContractInterface> GetInterface([Required][Address] string address)
/// <param name="michelson">Include parameters schema in michelson format</param>
/// <returns></returns>
[HttpGet("{address}/entrypoints")]
public Task<IEnumerable<Entrypoint>> GetEntrypoints([Required][Address] string address, bool all = false, bool json = true, bool micheline = false, bool michelson = false)
public Task<IEnumerable<Entrypoint>> GetEntrypoints([Required][KTAddress] string address, bool all = false, bool json = true, bool micheline = false, bool michelson = false)
{
return Accounts.GetEntrypoints(address, all, json, micheline, michelson);
}
Expand All @@ -339,7 +339,7 @@ public Task<IEnumerable<Entrypoint>> GetEntrypoints([Required][Address] string a
/// <param name="michelson">Include parameters schema in michelson format</param>
/// <returns></returns>
[HttpGet("{address}/entrypoints/{name}")]
public Task<Entrypoint> GetEntrypointByName([Required][Address] string address, [Required] string name, bool json = true, bool micheline = false, bool michelson = false)
public Task<Entrypoint> GetEntrypointByName([Required][KTAddress] string address, [Required] string name, bool json = true, bool micheline = false, bool michelson = false)
{
return Accounts.GetEntrypoint(address, name, json, micheline, michelson);
}
Expand All @@ -355,7 +355,7 @@ public Task<Entrypoint> GetEntrypointByName([Required][Address] string address,
/// <param name="value">Json parameters</param>
/// <returns></returns>
[HttpGet("{address}/entrypoints/{name}/build")]
public async Task<ActionResult> BuildEntrypointParameters([Required][Address] string address, [Required] string name, string value)
public async Task<ActionResult> BuildEntrypointParameters([Required][KTAddress] string address, [Required] string name, string value)
{
try
{
Expand All @@ -379,7 +379,7 @@ public async Task<ActionResult> BuildEntrypointParameters([Required][Address] st
/// <param name="value">Json parameters</param>
/// <returns></returns>
[HttpPost("{address}/entrypoints/{name}/build")]
public async Task<ActionResult> BuildEntrypointParameters([Required][Address] string address, [Required] string name, [FromBody] object value)
public async Task<ActionResult> BuildEntrypointParameters([Required][KTAddress] string address, [Required] string name, [FromBody] object value)
{
try
{
Expand All @@ -402,7 +402,7 @@ public async Task<ActionResult> BuildEntrypointParameters([Required][Address] st
/// <param name="path">Path in the JSON value (point-separated list of field names, e.g. `path=settings.refund_time` to return</param>
/// <returns></returns>
[HttpGet("{address}/storage")]
public async Task<ActionResult> GetStorage([Required][Address] string address, [Min(0)] int level = 0, string path = null)
public async Task<ActionResult> GetStorage([Required][KTAddress] string address, [Min(0)] int level = 0, string path = null)
{
#region safe path
JsonPath[] jsonPath = null;
Expand Down Expand Up @@ -433,7 +433,7 @@ public async Task<ActionResult> GetStorage([Required][Address] string address, [
/// <param name="level">Level at which storage schema should be taken. If `0` or not specified, the current schema will be returned.</param>
/// <returns></returns>
[HttpGet("{address}/storage/schema")]
public async Task<ActionResult> GetStorageSchema([Required][Address] string address, [Min(0)] int level = 0)
public async Task<ActionResult> GetStorageSchema([Required][KTAddress] string address, [Min(0)] int level = 0)
{
if (level == 0)
return this.Json(await Accounts.GetStorageSchema(address));
Expand All @@ -451,7 +451,7 @@ public async Task<ActionResult> GetStorageSchema([Required][Address] string addr
/// <param name="limit">Maximum number of items to return</param>
/// <returns></returns>
[HttpGet("{address}/storage/history")]
public Task<IEnumerable<StorageRecord>> GetStorageHistory([Required][Address] string address, [Min(0)] int lastId = 0, [Range(0, 1000)] int limit = 10)
public Task<IEnumerable<StorageRecord>> GetStorageHistory([Required][KTAddress] string address, [Min(0)] int lastId = 0, [Range(0, 1000)] int limit = 10)
{
return Accounts.GetStorageHistory(address, lastId, limit);
}
Expand All @@ -466,7 +466,7 @@ public Task<IEnumerable<StorageRecord>> GetStorageHistory([Required][Address] st
/// <param name="level">Level at which storage value should be taken. If `0` or not specified, the current value will be returned.</param>
/// <returns></returns>
[HttpGet("{address}/storage/raw")]
public Task<IMicheline> GetRawStorage([Required][Address] string address, [Min(0)] int level = 0)
public Task<IMicheline> GetRawStorage([Required][KTAddress] string address, [Min(0)] int level = 0)
{
if (level == 0)
return Accounts.GetRawStorageValue(address);
Expand All @@ -483,7 +483,7 @@ public Task<IMicheline> GetRawStorage([Required][Address] string address, [Min(0
/// <param name="level">Level at which storage schema should be taken. If `0` or not specified, the current schema will be returned.</param>
/// <returns></returns>
[HttpGet("{address}/storage/raw/schema")]
public Task<IMicheline> GetRawStorageSchema([Required][Address] string address, [Min(0)] int level = 0)
public Task<IMicheline> GetRawStorageSchema([Required][KTAddress] string address, [Min(0)] int level = 0)
{
if (level == 0)
return Accounts.GetRawStorageSchema(address);
Expand All @@ -501,7 +501,7 @@ public Task<IMicheline> GetRawStorageSchema([Required][Address] string address,
/// <param name="limit">Maximum number of items to return</param>
/// <returns></returns>
[HttpGet("{address}/storage/raw/history")]
public Task<IEnumerable<StorageRecord>> GetRawStorageHistory([Required][Address] string address, [Min(0)] int lastId = 0, [Range(0, 1000)] int limit = 10)
public Task<IEnumerable<StorageRecord>> GetRawStorageHistory([Required][KTAddress] string address, [Min(0)] int lastId = 0, [Range(0, 1000)] int limit = 10)
{
return Accounts.GetRawStorageHistory(address, lastId, limit);
}
Expand All @@ -523,7 +523,7 @@ public Task<IEnumerable<StorageRecord>> GetRawStorageHistory([Required][Address]
/// <returns></returns>
[HttpGet("{address}/bigmaps")]
public async Task<ActionResult<IEnumerable<BigMap>>> GetBigMaps(
[Required][Address] string address,
[Required][KTAddress] string address,
BigMapTagsParameter tags,
SelectParameter select,
SortParameter sort,
Expand Down Expand Up @@ -581,7 +581,7 @@ public async Task<ActionResult<IEnumerable<BigMap>>> GetBigMaps(
/// <returns></returns>
[HttpGet("{address}/bigmaps/{name}")]
public async Task<ActionResult<BigMap>> GetBigMapByName(
[Required][Address] string address,
[Required][KTAddress] string address,
[Required] string name,
MichelineFormat micheline = MichelineFormat.Json)
{
Expand Down Expand Up @@ -616,7 +616,7 @@ public async Task<ActionResult<BigMap>> GetBigMapByName(
/// <returns></returns>
[HttpGet("{address}/bigmaps/{name}/keys")]
public async Task<ActionResult<IEnumerable<BigMapKey>>> GetBigMapByNameKeys(
[Required][Address] string address,
[Required][KTAddress] string address,
[Required] string name,
bool? active,
JsonParameter key,
Expand Down Expand Up @@ -682,7 +682,7 @@ public async Task<ActionResult<IEnumerable<BigMapKey>>> GetBigMapByNameKeys(
/// <returns></returns>
[HttpGet("{address}/bigmaps/{name}/keys/{key}")]
public async Task<ActionResult<BigMapKey>> GetKey(
[Required][Address] string address,
[Required][KTAddress] string address,
[Required] string name,
[Required] string key,
MichelineFormat micheline = MichelineFormat.Json)
Expand Down Expand Up @@ -732,7 +732,7 @@ public async Task<ActionResult<BigMapKey>> GetKey(
/// <returns></returns>
[HttpGet("{address}/bigmaps/{name}/keys/{key}/updates")]
public async Task<ActionResult<IEnumerable<BigMapKeyUpdate>>> GetKeyUpdates(
[Required][Address] string address,
[Required][KTAddress] string address,
[Required] string name,
[Required] string key,
SortParameter sort,
Expand Down Expand Up @@ -795,7 +795,7 @@ public async Task<ActionResult<IEnumerable<BigMapKeyUpdate>>> GetKeyUpdates(
/// <returns></returns>
[HttpGet("{address}/bigmaps/{name}/historical_keys/{level:int}")]
public async Task<ActionResult<IEnumerable<BigMapKeyHistorical>>> GetHistoricalKeys(
[Required][Address] string address,
[Required][KTAddress] string address,
[Required] string name,
[Min(0)] int level,
bool? active,
Expand Down Expand Up @@ -862,7 +862,7 @@ public async Task<ActionResult<IEnumerable<BigMapKeyHistorical>>> GetHistoricalK
/// <returns></returns>
[HttpGet("{address}/bigmaps/{name}/historical_keys/{level:int}/{key}")]
public async Task<ActionResult<BigMapKeyHistorical>> GetKey(
[Required][Address] string address,
[Required][KTAddress] string address,
[Required] string name,
[Min(0)] int level,
[Required] string key,
Expand Down
2 changes: 1 addition & 1 deletion Tzkt.Api/Controllers/DelegatesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Task<int> GetCount(BoolParameter active)
/// <param name="address">Delegate address (starting with tz)</param>
/// <returns></returns>
[HttpGet("{address}")]
public Task<Models.Delegate> GetByAddress([Required][Address] string address)
public Task<Models.Delegate> GetByAddress([Required][TzAddress] string address)
{
return Accounts.GetDelegate(address);
}
Expand Down
16 changes: 8 additions & 8 deletions Tzkt.Api/Controllers/RewardsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public RewardsController(RewardsRepository rewards)
/// <param name="address">Baker address</param>
/// <returns></returns>
[HttpGet("bakers/{address}/count")]
public Task<int> GetBakerRewardsCount([Required][Address] string address)
public Task<int> GetBakerRewardsCount([Required][TzAddress] string address)
{
return Rewards.GetBakerRewardsCount(address);
}
Expand All @@ -51,7 +51,7 @@ public Task<int> GetBakerRewardsCount([Required][Address] string address)
/// <returns></returns>
[HttpGet("bakers/{address}")]
public async Task<ActionResult<IEnumerable<BakerRewards>>> GetBakerRewards(
[Required][Address] string address,
[Required][TzAddress] string address,
Int32Parameter cycle,
SelectParameter select,
SortParameter sort,
Expand Down Expand Up @@ -100,7 +100,7 @@ public async Task<ActionResult<IEnumerable<BakerRewards>>> GetBakerRewards(
/// <param name="quote">Comma-separated list of ticker symbols to inject historical prices into response</param>
/// <returns></returns>
[HttpGet("bakers/{address}/{cycle:int}")]
public Task<BakerRewards> GetBakerRewardsByCycle([Required][Address] string address, [Min(0)] int cycle, Symbols quote = Symbols.None)
public Task<BakerRewards> GetBakerRewardsByCycle([Required][TzAddress] string address, [Min(0)] int cycle, Symbols quote = Symbols.None)
{
return Rewards.GetBakerRewards(address, cycle, quote);
}
Expand Down Expand Up @@ -195,15 +195,15 @@ public Task<DelegatorRewards> GetDelegatorRewardsByCycle([Required][Address] str
/// <remarks>
/// Returns baker rewards for the specified cycle with all delegator balances at that cycle to allow rewards distribution in proportion to shares.
/// </remarks>
/// <param name="address">Baker address</param>
/// <param name="baker">Baker address</param>
/// <param name="cycle">Rewards cycle</param>
/// <param name="offset">Specifies how many delegators in the reward split should be skipped</param>
/// <param name="limit">Maximum number of delegators to return</param>
/// <returns></returns>
[HttpGet("split/{address}/{cycle:int}")]
public Task<RewardSplit> GetRewardSplit([Required][Address] string address, [Min(0)] int cycle, int offset = 0, [Range(0, 10000)] int limit = 100)
[HttpGet("split/{baker}/{cycle:int}")]
public Task<RewardSplit> GetRewardSplit([Required][TzAddress] string baker, [Min(0)] int cycle, int offset = 0, [Range(0, 10000)] int limit = 100)
{
return Rewards.GetRewardSplit(address, cycle, offset, limit);
return Rewards.GetRewardSplit(baker, cycle, offset, limit);
}

/// <summary>
Expand All @@ -217,7 +217,7 @@ public Task<RewardSplit> GetRewardSplit([Required][Address] string address, [Min
/// <param name="delegator">Delegator address</param>
/// <returns></returns>
[HttpGet("split/{baker}/{cycle:int}/{delegator}")]
public Task<SplitDelegator> GetRewardSplitDelegator([Required][Address] string baker, [Min(0)] int cycle, [Required][Address] string delegator)
public Task<SplitDelegator> GetRewardSplitDelegator([Required][TzAddress] string baker, [Min(0)] int cycle, [Required][Address] string delegator)
{
return Rewards.GetRewardSplitDelegator(baker, cycle, delegator);
}
Expand Down
2 changes: 1 addition & 1 deletion Tzkt.Api/Controllers/RightsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public async Task<ActionResult<IEnumerable<BakingRight>>> Get(
[OpenApiIgnore]
[HttpGet("schedule")]
public async Task<ActionResult<IEnumerable<BakingRight>>> GetSchedule(
[Required][Address] string baker,
[Required][TzAddress] string baker,
[Required] DateTimeOffset from,
[Required] DateTimeOffset to,
[Min(0)] int maxPriority = 0)
Expand Down
4 changes: 2 additions & 2 deletions Tzkt.Api/Controllers/VotingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public async Task<ActionResult<IEnumerable<VoterSnapshot>>> GetPeriodVoters(
/// <param name="address">Voter address</param>
/// <returns></returns>
[HttpGet("periods/{index:int}/voters/{address}")]
public Task<VoterSnapshot> GetPeriodVoter([Min(0)] int index, [Required][Address] string address)
public Task<VoterSnapshot> GetPeriodVoter([Min(0)] int index, [Required][TzAddress] string address)
{
return Voting.GetVoter(index, address);
}
Expand Down Expand Up @@ -257,7 +257,7 @@ public async Task<ActionResult<IEnumerable<VoterSnapshot>>> GetPeriodVoters(
/// <param name="address">Voter address</param>
/// <returns></returns>
[HttpGet("periods/current/voters/{address}")]
public Task<VoterSnapshot> GetPeriodVoter([Required][Address] string address)
public Task<VoterSnapshot> GetPeriodVoter([Required][TzAddress] string address)
{
return Voting.GetVoter(State.Current.VotingPeriod, address);
}
Expand Down
Loading

0 comments on commit 5b3fd92

Please sign in to comment.