Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Tzkt.Api/Controllers/AccountsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public async Task<ActionResult> GetBalanceReport(
[Required][Address] string address,
DateTimeOffset? from,
DateTimeOffset? to,
string currency,
string? currency,
bool historical = false,
string delimiter = "comma",
string separator = "point")
Expand Down
15 changes: 15 additions & 0 deletions Tzkt.Api/Models/Accounts/Ghost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ public class Ghost : Account
/// </summary>
public string? Alias { get; set; }

/// <summary>
/// Number of all transaction (tez transfer) operations, related to the account
/// </summary>
public int NumTransactions { get; set; }

/// <summary>
/// Number of transfer ticket operations sent by the account
/// </summary>
public int TransferTicketCount { get; set; }

/// <summary>
/// Number of `increase_paid_storage` operations sent by the account
/// </summary>
public int IncreasePaidStorageCount { get; set; }

/// <summary>
/// Number of account tokens with non-zero balances
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Tzkt.Api/Models/Operations/IncreasePaidStorageOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class IncreasePaidStorageOperation : Operation
/// <summary>
/// Information about the contract for which paid storage was increased
/// </summary>
public Alias? Contract { get; set; }
public required Alias Contract { get; set; }

/// <summary>
/// Amount of storage in bytes prepaid.
Expand Down
2 changes: 1 addition & 1 deletion Tzkt.Api/Models/Operations/TransactionOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class TransactionOperation : Operation
/// <summary>
/// Information about the target of the transaction
/// </summary>
public Alias? Target { get; set; }
public required Alias Target { get; set; }

/// <summary>
/// Hash of the target contract code, or `null` is the target is not a contract
Expand Down
4 changes: 2 additions & 2 deletions Tzkt.Api/Models/Operations/TransferTicketOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public class TransferTicketOperation : Operation
/// <summary>
/// Information about the target to which the operation was sent
/// </summary>
public Alias? Target { get; set; }
public required Alias Target { get; set; }

/// <summary>
/// Information about the ticketer
/// </summary>
public Alias? Ticketer { get; set; }
public required Alias Ticketer { get; set; }

/// <summary>
/// Amount sent
Expand Down
2 changes: 1 addition & 1 deletion Tzkt.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
}

var state = db.AppState.Single();
if (state.Level < 1)
if (state.BlocksCount < 2)
{
logger.LogWarning("No data in the database. Let's wait for the indexer to index at least two blocks, and try again.");
Thread.Sleep(3000);
Expand Down
31 changes: 31 additions & 0 deletions Tzkt.Api/Repositories/AccountRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ public async Task<int> GetCounterAsync(string address)
Id = rawAccount.Id,
Alias = rawAccount.Alias,
Address = rawAccount.Address,
NumTransactions = rawAccount.TransactionsCount,
TransferTicketCount = rawAccount.TransferTicketCount,
IncreasePaidStorageCount = rawAccount.IncreasePaidStorageCount,
ActiveTokensCount = rawAccount.ActiveTokensCount,
TokenBalancesCount = rawAccount.TokenBalancesCount,
TokenTransfersCount = rawAccount.TokenTransfersCount,
Expand Down Expand Up @@ -712,6 +715,9 @@ public async Task<IEnumerable<Account>> Get(
Id = row.Id,
Alias = row.Alias,
Address = row.Address,
NumTransactions = row.TransactionsCount,
TransferTicketCount = row.TransferTicketCount,
IncreasePaidStorageCount = row.IncreasePaidStorageCount,
ActiveTokensCount = row.ActiveTokensCount,
TokenBalancesCount = row.TokenBalancesCount,
TokenTransfersCount = row.TokenTransfersCount,
Expand Down Expand Up @@ -2965,6 +2971,31 @@ await Task.WhenAll(
result.AddRange(smartRollupSrRecoverBondOps.Result);
result.AddRange(smartRollupSrRefuteOps.Result);

break;
case RawAccount ghost:
var _ghost = new AccountParameter { Eq = ghost.Id };

var ghostTransactions = ghost.TransactionsCount > 0 && types.Contains(ActivityTypes.Transaction)
? Operations.GetTransactions(null, new AnyOfParameter { Fields = ["initiator", "sender", "target"], Eq = ghost.Id }, initiator, sender, target, null, null, level, timestamp, null, null, null, entrypoint, parameter, hasInternals, status, sort, offset, limit, format, quote)
: Task.FromResult(Enumerable.Empty<TransactionOperation>());

var ghostTransferTicketOps = ghost.TransferTicketCount > 0 && types.Contains(ActivityTypes.TransferTicket)
? Operations.GetTransferTicketOps(null, null, _ghost, null, null, null, level, timestamp, status, sort, offset, limit, format, quote)
: Task.FromResult(Enumerable.Empty<TransferTicketOperation>());

var ghostIncreasePaidStorageOps = ghost.IncreasePaidStorageCount > 0 && types.Contains(ActivityTypes.IncreasePaidStorage)
? Operations.GetIncreasePaidStorageOps(null, _ghost, null, level, timestamp, status, sort, offset, limit, quote)
: Task.FromResult(Enumerable.Empty<IncreasePaidStorageOperation>());

await Task.WhenAll(
ghostTransactions,
ghostTransferTicketOps,
ghostIncreasePaidStorageOps);

result.AddRange(ghostTransactions.Result);
result.AddRange(ghostTransferTicketOps.Result);
result.AddRange(ghostIncreasePaidStorageOps.Result);

break;
default:
break;
Expand Down
52 changes: 26 additions & 26 deletions Tzkt.Api/Repositories/BalanceHistoryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,19 @@
if (user.StakingUpdatesCount > 0) SumStakingUpdates(union, from, to);
}

if (account is RawDelegate delegat)
{
if (delegat.AttestationRewardsCount > 0) SumAttestationRewards(union, from, to);
if (delegat.DalAttestationRewardsCount > 0) SumDalAttestationRewards(union, from, to);
if (delegat.BlocksCount > 0) SumBaking(union, from, to);
if (delegat.AttestationsCount > 0) SumAttestations(union, from, to);
if (delegat.DoubleBakingCount > 0) SumDoubleBaking(union, from, to);
if (delegat.DoubleConsensusCount > 0) SumDoubleConsensus(union, from, to);
if (delegat.NonceRevelationsCount > 0) SumNonceRevelations(union, from, to);
if (delegat.VdfRevelationsCount > 0) SumVdfRevelations(union, from, to);
if (delegat.RevelationPenaltiesCount > 0) SumRevelationPenalties(union, from, to);
if (delegat.UpdateSecondaryKeyCount > 0) SumUpdateSecondaryKeyOps(union, from, to);
}
//if (account is RawDelegate delegat)
//{

Check warning on line 293 in Tzkt.Api/Repositories/BalanceHistoryRepository.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this commented out code.

See more on https://sonarcloud.io/project/issues?id=baking-bad_tzkt&issues=AZ2qRtDjOfY8PksrzGdc&open=AZ2qRtDjOfY8PksrzGdc&pullRequest=203
// if (delegat.AttestationRewardsCount > 0) SumAttestationRewards(union, from, to);
// if (delegat.DalAttestationRewardsCount > 0) SumDalAttestationRewards(union, from, to);
// if (delegat.BlocksCount > 0) SumBaking(union, from, to);
// if (delegat.AttestationsCount > 0) SumAttestations(union, from, to);
// if (delegat.DoubleBakingCount > 0) SumDoubleBaking(union, from, to);
// if (delegat.DoubleConsensusCount > 0) SumDoubleConsensus(union, from, to);
// if (delegat.NonceRevelationsCount > 0) SumNonceRevelations(union, from, to);
// if (delegat.VdfRevelationsCount > 0) SumVdfRevelations(union, from, to);
// if (delegat.RevelationPenaltiesCount > 0) SumRevelationPenalties(union, from, to);
// if (delegat.UpdateSecondaryKeyCount > 0) SumUpdateSecondaryKeyOps(union, from, to);
//}

return union.ToString();
}
Expand Down Expand Up @@ -373,7 +373,7 @@
#endregion
}

void SumAttestations(StringBuilder sql, int from, int to)

Check warning on line 376 in Tzkt.Api/Repositories/BalanceHistoryRepository.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused private method 'SumAttestations'.

See more on https://sonarcloud.io/project/issues?id=baking-bad_tzkt&issues=AZ2qRtDjOfY8PksrzGdh&open=AZ2qRtDjOfY8PksrzGdh&pullRequest=203
{
sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT ");

Expand Down Expand Up @@ -1176,7 +1176,7 @@
#endregion
}

void SumRevelationPenalties(StringBuilder sql, int from, int to)

Check warning on line 1179 in Tzkt.Api/Repositories/BalanceHistoryRepository.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused private method 'SumRevelationPenalties'.

See more on https://sonarcloud.io/project/issues?id=baking-bad_tzkt&issues=AZ2qRtDjOfY8PksrzGdn&open=AZ2qRtDjOfY8PksrzGdn&pullRequest=203
{
sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT ");

Expand Down Expand Up @@ -1250,19 +1250,19 @@
if (user.StakingUpdatesCount > 0) UnionStakingUpdates(union);
}

if (account is RawDelegate delegat)
{
if (delegat.AttestationRewardsCount > 0) UnionAttestationRewards(union);
if (delegat.DalAttestationRewardsCount > 0) UnionDalAttestationRewards(union);
if (delegat.BlocksCount > 0) UnionBaking(union);
if (delegat.AttestationsCount > 0) UnionAttestations(union);
if (delegat.DoubleBakingCount > 0) UnionDoubleBaking(union);
if (delegat.DoubleConsensusCount > 0) UnionDoubleConsensus(union);
if (delegat.NonceRevelationsCount > 0) UnionNonceRevelations(union);
if (delegat.VdfRevelationsCount > 0) UnionVdfRevelations(union);
if (delegat.RevelationPenaltiesCount > 0) UnionRevelationPenalties(union);
if (delegat.UpdateSecondaryKeyCount > 0) UnionUpdateSecondaryKeyOps(union);
}
//if (account is RawDelegate delegat)
//{

Check warning on line 1254 in Tzkt.Api/Repositories/BalanceHistoryRepository.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this commented out code.

See more on https://sonarcloud.io/project/issues?id=baking-bad_tzkt&issues=AZ2qRtDjOfY8PksrzGdd&open=AZ2qRtDjOfY8PksrzGdd&pullRequest=203
// if (delegat.AttestationRewardsCount > 0) UnionAttestationRewards(union);
// if (delegat.DalAttestationRewardsCount > 0) UnionDalAttestationRewards(union);
// if (delegat.BlocksCount > 0) UnionBaking(union);
// if (delegat.AttestationsCount > 0) UnionAttestations(union);
// if (delegat.DoubleBakingCount > 0) UnionDoubleBaking(union);
// if (delegat.DoubleConsensusCount > 0) UnionDoubleConsensus(union);
// if (delegat.NonceRevelationsCount > 0) UnionNonceRevelations(union);
// if (delegat.VdfRevelationsCount > 0) UnionVdfRevelations(union);
// if (delegat.RevelationPenaltiesCount > 0) UnionRevelationPenalties(union);
// if (delegat.UpdateSecondaryKeyCount > 0) UnionUpdateSecondaryKeyOps(union);
//}

return union.ToString();
}
Expand Down Expand Up @@ -1376,7 +1376,7 @@
#endregion
}

void UnionDoubleConsensus(StringBuilder sql)

Check warning on line 1379 in Tzkt.Api/Repositories/BalanceHistoryRepository.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused private method 'UnionDoubleConsensus'.

See more on https://sonarcloud.io/project/issues?id=baking-bad_tzkt&issues=AZ2qRtDjOfY8PksrzGdt&open=AZ2qRtDjOfY8PksrzGdt&pullRequest=203
{
sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT ");

Expand Down
8 changes: 4 additions & 4 deletions Tzkt.Api/Repositories/OperationRepository.Baking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
BonusStakedOwn = row.BonusStakedOwn,
BonusStakedEdge = row.BonusStakedEdge,
BonusStakedShared = row.BonusStakedShared,
Fees = row.Fees,
Fees = 0,//row.Fees,
Quote = Quotes.Get(quote, row.Level)
};
}
Expand Down Expand Up @@ -139,7 +139,7 @@
BonusStakedOwn = row.BonusStakedOwn,
BonusStakedEdge = row.BonusStakedEdge,
BonusStakedShared = row.BonusStakedShared,
Fees = row.Fees,
Fees = 0,//row.Fees,
Quote = Quotes.Get(quote, row.Level)
});
}
Expand Down Expand Up @@ -278,7 +278,7 @@
break;
case "fees":
foreach (var row in rows)
result[j++][i] = row.Fees;
result[j++][i] = 0;// row.Fees;

Check warning on line 281 in Tzkt.Api/Repositories/OperationRepository.Baking.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this commented out code.

See more on https://sonarcloud.io/project/issues?id=baking-bad_tzkt&issues=AZ2qRtIEOfY8PksrzGdy&open=AZ2qRtIEOfY8PksrzGdy&pullRequest=203
break;
case "quote":
foreach (var row in rows)
Expand Down Expand Up @@ -419,7 +419,7 @@
break;
case "fees":
foreach (var row in rows)
result[j++] = row.Fees;
result[j++] = 0;// row.Fees;
break;
case "quote":
foreach (var row in rows)
Expand Down
12 changes: 6 additions & 6 deletions Tzkt.Api/Repositories/OperationRepository.IncreasePaidStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ INNER JOIN ""Blocks"" as b
BakerFee = row.BakerFee,
StorageFee = row.StorageFee ?? 0,
Status = OpStatuses.ToString(row.Status),
Contract = row.ContractId == null ? null : Accounts.GetAlias(row.ContractId),
Contract = Accounts.GetAlias(row.ContractId),
Amount = row.Amount,
Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null,
Quote = Quotes.Get(quote, row.Level)
Expand Down Expand Up @@ -83,7 +83,7 @@ INNER JOIN ""Blocks"" as b
BakerFee = row.BakerFee,
StorageFee = row.StorageFee ?? 0,
Status = OpStatuses.ToString(row.Status),
Contract = row.ContractId == null ? null : Accounts.GetAlias(row.ContractId),
Contract = Accounts.GetAlias(row.ContractId),
Amount = row.Amount,
Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null,
Quote = Quotes.Get(quote, row.Level)
Expand Down Expand Up @@ -117,7 +117,7 @@ SELECT o.*
BakerFee = row.BakerFee,
StorageFee = row.StorageFee ?? 0,
Status = OpStatuses.ToString(row.Status),
Contract = row.ContractId == null ? null : Accounts.GetAlias(row.ContractId),
Contract = Accounts.GetAlias(row.ContractId),
Amount = row.Amount,
Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null,
Quote = Quotes.Get(quote, row.Level)
Expand Down Expand Up @@ -221,7 +221,7 @@ INNER JOIN ""Blocks"" as b
BakerFee = row.BakerFee,
StorageFee = row.StorageFee ?? 0,
Status = OpStatuses.ToString(row.Status),
Contract = row.ContractId == null ? null : Accounts.GetAlias(row.ContractId),
Contract = Accounts.GetAlias(row.ContractId),
Amount = row.Amount,
Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null,
Quote = Quotes.Get(quote, row.Level)
Expand Down Expand Up @@ -359,7 +359,7 @@ INNER JOIN ""Blocks"" as b
break;
case "contract":
foreach (var row in rows)
result[j++][i] = row.ContractId == null ? null : Accounts.GetAlias(row.ContractId);
result[j++][i] = Accounts.GetAlias(row.ContractId);
break;
case "amount":
foreach (var row in rows)
Expand Down Expand Up @@ -505,7 +505,7 @@ INNER JOIN ""Blocks"" as b
break;
case "contract":
foreach (var row in rows)
result[j++] = row.ContractId == null ? null : Accounts.GetAlias(row.ContractId);
result[j++] = Accounts.GetAlias(row.ContractId);
break;
case "amount":
foreach (var row in rows)
Expand Down
14 changes: 7 additions & 7 deletions Tzkt.Api/Repositories/OperationRepository.Transactions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ INNER JOIN ""Blocks"" as b
BakerFee = row.BakerFee,
StorageFee = row.StorageFee ?? 0,
AllocationFee = row.AllocationFee ?? 0,
Target = row.TargetId != null ? Accounts.GetAlias(row.TargetId) : null,
Target = Accounts.GetAlias(row.TargetId),
TargetCodeHash = row.TargetCodeHash,
Amount = row.Amount,
Parameter = row.Entrypoint == null ? null : new TxParameter
Expand Down Expand Up @@ -167,7 +167,7 @@ INNER JOIN ""Blocks"" as b
BakerFee = row.BakerFee,
StorageFee = row.StorageFee ?? 0,
AllocationFee = row.AllocationFee ?? 0,
Target = row.TargetId != null ? Accounts.GetAlias(row.TargetId) : null,
Target = Accounts.GetAlias(row.TargetId),
TargetCodeHash = row.TargetCodeHash,
Amount = row.Amount,
Parameter = row.Entrypoint == null ? null : new TxParameter
Expand Down Expand Up @@ -242,7 +242,7 @@ INNER JOIN ""Blocks"" as b
BakerFee = row.BakerFee,
StorageFee = row.StorageFee ?? 0,
AllocationFee = row.AllocationFee ?? 0,
Target = row.TargetId != null ? Accounts.GetAlias(row.TargetId) : null,
Target = Accounts.GetAlias(row.TargetId),
TargetCodeHash = row.TargetCodeHash,
Amount = row.Amount,
Parameter = row.Entrypoint == null ? null : new TxParameter
Expand Down Expand Up @@ -299,7 +299,7 @@ public async Task<IEnumerable<TransactionOperation>> GetTransactions(Block block
BakerFee = row.BakerFee,
StorageFee = row.StorageFee ?? 0,
AllocationFee = row.AllocationFee ?? 0,
Target = row.TargetId != null ? Accounts.GetAlias(row.TargetId) : null,
Target = Accounts.GetAlias(row.TargetId),
TargetCodeHash = row.TargetCodeHash,
Amount = row.Amount,
Parameter = row.Entrypoint == null ? null : new TxParameter
Expand Down Expand Up @@ -501,7 +501,7 @@ INNER JOIN ""Blocks"" as b
BakerFee = row.BakerFee,
StorageFee = row.StorageFee ?? 0,
AllocationFee = row.AllocationFee ?? 0,
Target = row.TargetId != null ? Accounts.GetAlias(row.TargetId) : null,
Target = Accounts.GetAlias(row.TargetId),
TargetCodeHash = row.TargetCodeHash,
Amount = row.Amount,
Parameter = row.Entrypoint == null ? null : new TxParameter
Expand Down Expand Up @@ -743,7 +743,7 @@ INNER JOIN ""Blocks"" as b
break;
case "target":
foreach (var row in rows)
result[j++][i] = row.TargetId != null ? await Accounts.GetAliasAsync(row.TargetId) : null;
result[j++][i] = await Accounts.GetAliasAsync(row.TargetId);
break;
case "targetCodeHash":
foreach (var row in rows)
Expand Down Expand Up @@ -1038,7 +1038,7 @@ INNER JOIN ""Blocks"" as b
break;
case "target":
foreach (var row in rows)
result[j++] = row.TargetId != null ? await Accounts.GetAliasAsync(row.TargetId) : null;
result[j++] = await Accounts.GetAliasAsync(row.TargetId);
break;
case "targetCodeHash":
foreach (var row in rows)
Expand Down
Loading
Loading