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

Lima #132

Merged
merged 17 commits into from
Dec 11, 2022
Merged

Lima #132

Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 17 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,27 @@ ghost-stop:
ghost-db-start:
docker-compose -f docker-compose.ghost.yml up -d ghost-db

jakarta-init:
docker-compose -f docker-compose.jakarta.yml up -d jakarta-db
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db psql -U tzkt postgres -c '\l'
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db dropdb -U tzkt --if-exists tzkt_db
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db createdb -U tzkt -T template0 tzkt_db
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db apt update
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db apt install -y wget
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db wget "https://snapshots.tzkt.io/tzkt_v1.10_jakartanet.backup" -O tzkt_db.backup
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db rm tzkt_db.backup
docker-compose -f docker-compose.jakarta.yml exec -T jakarta-db apt autoremove --purge -y wget
lima-init:
docker-compose -f docker-compose.lima.yml up -d lima-db
docker-compose -f docker-compose.lima.yml exec -T lima-db psql -U tzkt postgres -c '\l'
docker-compose -f docker-compose.lima.yml exec -T lima-db dropdb -U tzkt --if-exists tzkt_db
docker-compose -f docker-compose.lima.yml exec -T lima-db createdb -U tzkt -T template0 tzkt_db
docker-compose -f docker-compose.lima.yml exec -T lima-db apt update
docker-compose -f docker-compose.lima.yml exec -T lima-db apt install -y wget
docker-compose -f docker-compose.lima.yml exec -T lima-db wget "https://snapshots.tzkt.io/tzkt_v1.10_limanet.backup" -O tzkt_db.backup
docker-compose -f docker-compose.lima.yml exec -T lima-db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup
docker-compose -f docker-compose.lima.yml exec -T lima-db rm tzkt_db.backup
docker-compose -f docker-compose.lima.yml exec -T lima-db apt autoremove --purge -y wget
docker-compose pull

jakarta-start:
docker-compose -f docker-compose.jakarta.yml up -d
lima-start:
docker-compose -f docker-compose.lima.yml up -d

jakarta-stop:
docker-compose -f docker-compose.jakarta.yml down
lima-stop:
docker-compose -f docker-compose.lima.yml down

jakarta-db-start:
docker-compose -f docker-compose.jakarta.yml up -d jakarta-db
lima-db-start:
docker-compose -f docker-compose.lima.yml up -d lima-db

kathmandu-init:
docker-compose -f docker-compose.kathmandu.yml up -d kathmandu-db
Expand Down
6 changes: 3 additions & 3 deletions Tzkt.Api.Tests/Auth/AuthServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Netezos.Encoding;
using Netezos.Keys;
using Netezos.Utils;
Expand Down
15 changes: 7 additions & 8 deletions Tzkt.Api.Tests/Tzkt.Api.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>

<LangVersion>10</LangVersion>
<AssemblyVersion>1.10.3</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
26 changes: 14 additions & 12 deletions Tzkt.Api/Controllers/AccountsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public AccountsController(AccountRepository accounts, BalanceHistoryRepository h
/// Returns a list of accounts.
/// </remarks>
/// <param name="id">Filters by internal id.</param>
/// <param name="address">Filters by address.</param>
/// <param name="type">Filters accounts by type (`user`, `delegate`, `contract`, `ghost`).</param>
/// <param name="kind">Filters accounts by contract kind (`delegator_contract` or `smart_contract`)</param>
/// <param name="delegate">Filters accounts by delegate. Allowed fields for `.eqx` mode: none.</param>
Expand All @@ -53,6 +54,7 @@ public AccountsController(AccountRepository accounts, BalanceHistoryRepository h
[HttpGet]
public async Task<ActionResult<IEnumerable<Account>>> Get(
Int32Parameter id,
AddressParameter address,
AccountTypeParameter type,
ContractKindParameter kind,
AccountParameter @delegate,
Expand Down Expand Up @@ -87,7 +89,7 @@ public async Task<ActionResult<IEnumerable<Account>>> Get(
#endregion

var query = ResponseCacheService.BuildKey(Request.Path.Value,
("id", id), ("type", type), ("kind", kind), ("delegate", @delegate), ("balance", balance), ("staked", staked),
("id", id), ("address", address), ("type", type), ("kind", kind), ("delegate", @delegate), ("balance", balance), ("staked", staked),
("lastActivity", lastActivity), ("select", select), ("sort", sort), ("offset", offset), ("limit", limit));

if (ResponseCache.TryGet(query, out var cached))
Expand All @@ -96,25 +98,25 @@ public async Task<ActionResult<IEnumerable<Account>>> Get(
object res;
if (select == null)
{
res = await Accounts.Get(id, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit);
res = await Accounts.Get(id, address, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit);
}
else if (select.Values != null)
{
if (select.Values.Length == 1)
res = await Accounts.Get(id, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Values[0]);
res = await Accounts.Get(id, address, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Values[0]);
else
res = await Accounts.Get(id, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Values);
res = await Accounts.Get(id, address, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Values);
}
else
{
if (select.Fields.Length == 1)
res = await Accounts.Get(id, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Fields[0]);
res = await Accounts.Get(id, address, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Fields[0]);
else
{
res = new SelectionResponse
{
Cols = select.Fields,
Rows = await Accounts.Get(id, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Fields)
Rows = await Accounts.Get(id, address, type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Fields)
};
}
}
Expand Down Expand Up @@ -276,9 +278,9 @@ public async Task<ActionResult<IEnumerable<Delegator>>> GetDelegators(
/// <param name="address">Account address (starting with tz or KT)</param>
/// <param name="type">Comma separated list of operation types to return (`endorsement`, `preendorsement`, `ballot`, `proposal`, `activation`, `double_baking`,
/// `double_endorsing`, `double_preendorsing`, `nonce_revelation`, `vdf_revelation`, `delegation`, `origination`, `transaction`, `reveal`, `register_constant`,
/// `set_deposits_limit`, `increase_paid_storage`, 'tx_rollup_origination', 'tx_rollup_submit_batch', 'tx_rollup_commit', 'tx_rollup_return_bond',
/// 'tx_rollup_finalize_commitment', 'tx_rollup_remove_commitment', 'tx_rollup_rejection', 'tx_rollup_dispatch_tickets', 'transfer_ticket', `migration`,
/// `revelation_penalty`, `baking`, `endorsing_reward`). If not specified then the default set will be returned.</param>
/// `set_deposits_limit`, `increase_paid_storage`, `tx_rollup_origination`, `tx_rollup_submit_batch`, `tx_rollup_commit`, `tx_rollup_return_bond`,
/// `tx_rollup_finalize_commitment`, `tx_rollup_remove_commitment`, `tx_rollup_rejection`, `tx_rollup_dispatch_tickets`, `transfer_ticket`, `migration`,
/// `update_consensus_key`, `drain_delegate`, `revelation_penalty`, `baking`, `endorsing_reward`). If not specified then the default set will be returned.</param>
/// <param name="initiator">Filters transactions, delegations and originations by initiator. Allowed fields for `.eqx` mode: none.</param>
/// <param name="sender">Filters transactions, delegations, originations, reveals and seed nonce revelations by sender. Allowed fields for `.eqx` mode: none.</param>
/// <param name="target">Filters transactions by target. Allowed fields for `.eqx` mode: none.</param>
Expand Down Expand Up @@ -566,7 +568,7 @@ public async Task<ActionResult<long>> GetBalanceAtDate(
if (ResponseCache.TryGet(query, out var cached))
return this.Bytes(cached);

var res = await History.Get(address, datetime.DateTime);
var res = await History.Get(address, datetime.UtcDateTime);
cached = ResponseCache.Set(query, res);
return this.Bytes(cached);
}
Expand Down Expand Up @@ -704,8 +706,8 @@ public async Task<ActionResult> GetBalanceReport(
};
#endregion

var _from = from?.DateTime ?? DateTime.MinValue;
var _to = to?.DateTime ?? DateTime.MaxValue;
var _from = (from ?? DateTimeOffset.MinValue).UtcDateTime;
var _to = (to ?? DateTimeOffset.MaxValue).UtcDateTime;

var stream = new MemoryStream();
var csv = new StreamWriter(stream);
Expand Down
4 changes: 2 additions & 2 deletions Tzkt.Api/Controllers/BlocksController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public Task<Block> GetByDate(
MichelineFormat micheline = MichelineFormat.Json,
Symbols quote = Symbols.None)
{
var level = Time.FindLevel(timestamp.DateTime, SearchMode.ExactOrLower);
var level = Time.FindLevel(timestamp.UtcDateTime, SearchMode.ExactOrLower);
return Blocks.Get(level, operations, micheline, quote);
}

Expand All @@ -233,7 +233,7 @@ public Task<Block> GetByDate(
[HttpGet("{timestamp:DateTime}/level")]
public int GetByDate(DateTimeOffset timestamp)
{
return Time.FindLevel(timestamp.DateTime, SearchMode.ExactOrLower);
return Time.FindLevel(timestamp.UtcDateTime, SearchMode.ExactOrLower);
}

// BCD bootstrap
Expand Down
Loading