Skip to content

Commit

Permalink
Merge branch 'develop' into tweak/fix-docs-and-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dhedey committed Aug 13, 2024
2 parents 600c5dc + 86ce908 commit 1acddc0
Show file tree
Hide file tree
Showing 49 changed files with 5,809 additions and 238 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ dotnet_diagnostic.SA1649.severity = none # SA1649FileNameMustMatchTypeName - it
# > Inherited from other projects
dotnet_diagnostic.SA0001.severity = none # SA0001XmlCommentAnalysisDisabled
dotnet_diagnostic.SA1101.severity = none # SA1101PrefixLocalCallsWithThis
dotnet_diagnostic.SA1118.severity = none # SA1118ParameterMustNotSpanMultipleLines - SQL queries
dotnet_diagnostic.SA1124.severity = none # SA1124DoNotUseRegions
dotnet_diagnostic.SA1129.severity = none # SA1129DoNotUseDefaultValueTypeConstructor - does not comply with the use of HashCode
dotnet_diagnostic.SA1201.severity = none # SA1201ElementsMustAppearInTheCorrectOrder
Expand Down
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ Release built: _not released yet_
- New `event_global_emitters_filter` filter added to `/stream/transactions` endpoint. It allows filtering transactions by the global ancestor of an event emitter. For events emitted by a global entity it is going to be that entity, for internal entities it is going to be a global ancestor.
- Changed `variant_id` of `ProgrammaticScryptoSborValueEnum` from numeric (`type: integer`) to string-encoded numeric (`type: string`) to make it compatible with the rest of the ecosystem.
- Optimized `/statistics/validators/uptime` endpoint processing time.
- Added support for two-way linked dApps in the `/state/entity/details` endpoint.
- Brand-new `two_way_linked_*` properties on the `details` property of Resources, Accounts, Packages and other global components.
- Added support for two-way linked dApps in the `/state/entity/details` endpoint, returned when the `dapp_two_way_links` opt-in is enabled.
- Brand-new `two_way_linked_*` properties on the `details` property of the Resources, Accounts, Packages and other global entities.
- See https://docs.radixdlt.com/docs/metadata-for-verification#metadata-standards-for-verification-of-onledger-entities for detailed specification.
- Added support for the Native Resource Details in the `/state/entity/details` endpoint, returned when the `native_resource_details` opt-in is enabled.
- Brand-new `native_resource_details` property on the `details` property.
- Includes **unit** redemption value for the Validator LSU token and the unit tokens of various Pools.

### Database changes
- Replaced relationship-related columns (`*_entity_id`) in the `entities` table with more generic collection implementation using `correlated_entity_*` columns.
- Replaced per-epoch validator emissions (`validator_emission_statistics` table) with their cumulative statistics (`validator_cumulative_emission_history` table).
- Added `non_fungible_data_mutable_fields` to `entities` table. Which contains list of all mutable non fungible data fields for non fungible resource entities.
- New `ledger_transaction_markers` type with the `event_global_emitter` discriminator. It represents the global emitter for each event.
- Added new `unverified_standard_metadata_*` tables. They hold **some** of the metadata entries using db-friendly (normalized) model. See https://docs.radixdlt.com/docs/metadata-standards
- Added new `unverified_standard_metadata_*` tables. They hold **some** of the metadata entries using db-friendly (normalized) model. See https://docs.radixdlt.com/docs/metadata-standards
- Extended list of supported entity correlations in the `entities` table.
- Renamed values of the `entity_relationship` enum type.

## 1.6.3
Release built: 06.08.2024
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,43 @@ namespace RadixDlt.NetworkGateway.Abstractions.Model;

public enum EntityRelationship
{
ComponentPackage,
ValidatorStakeVault,
ValidatorPendingXrdWithdrawVault,
ValidatorLockedOwnerStakeUnitVault,
ValidatorPendingOwnerStakeUnitUnlockVault,
VaultResource,
VaultRoyalty,
VaultResourcePool,
AccountLockerLocker,
AccountLockerAccount,
ResourcePoolUnit,
ResourcePoolResource,
// Components

ComponentToInstantiatingPackage,

// Vaults

VaultToResource,

RoyaltyVaultOfComponent,

// Validators

ValidatorToStakeVault,
ValidatorToPendingXrdWithdrawVault,
ValidatorToLockedOwnerStakeUnitVault,
ValidatorToPendingOwnerStakeUnitUnlockVault,

StakeVaultOfValidator,
ClaimTokenOfValidator,

// Account Lockers (used on related Vaults and KeyValueStores)

AccountLockerOfLocker,
AccountLockerOfAccount,

// Resource Pools (used on One-, Two- and Multi-Resource Pools)

ResourcePoolToUnitResource,
ResourcePoolToResource,
ResourcePoolToResourceVault,

UnitVaultOfResourcePool,
ResourceVaultOfResourcePool,

// Access Controllers

AccessControllerToRecoveryBadge,

RecoveryBadgeOfAccessController,
}
40 changes: 39 additions & 1 deletion src/RadixDlt.NetworkGateway.Abstractions/Numerics/TokenAmount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static TokenAmount FromDecimalString(string decimalString)

public static TokenAmount operator *(TokenAmount a, TokenAmount b) => (a.IsNaN() || b.IsNaN()) ? NaN : new TokenAmount(a._subUnits * b._subUnits);

public static TokenAmount operator /(TokenAmount a, TokenAmount b) => (a.IsNaN() || b.IsNaN()) ? NaN : new TokenAmount(a._subUnits / b._subUnits);
public static TokenAmount operator /(TokenAmount a, TokenAmount b) => (a.IsNaN() || b.IsNaN()) ? NaN : Divide(a, b);

// ReSharper disable SimplifyConditionalTernaryExpression - As it's clearer as written
#pragma warning disable IDE0075
Expand Down Expand Up @@ -269,4 +269,42 @@ public int CompareTo(TokenAmount other)
var isNaNComparison = _isNaN.CompareTo(other._isNaN);
return isNaNComparison != 0 ? isNaNComparison : _subUnits.CompareTo(other._subUnits);
}

// Heavily inspired by https://www.codeproject.com/Articles/5366079/BigDecimal-in-Csharp
// Licensed under CPOL: https://en.wikipedia.org/wiki/Code_Project_Open_License
// Author: Paulo Francisco Zemek. August, 01, 2023.
private static TokenAmount Divide(TokenAmount dividend, TokenAmount divisor)
{
if (divisor == Zero)
{
// This rule might look odd, but when simplifying expressions, x/x (x divided by x) is 1.
// So, to keep the rule true, 0 divided by 0 is also 1.
if (dividend == Zero)
{
return OneFullUnit;
}

throw new DivideByZeroException($"{nameof(divisor)} can only be zero if {nameof(dividend)} is zero.");
}

var doublePrecisionDividendSubUnits = dividend._subUnits * _divisor;
var divisorSubUnits = divisor._subUnits;

return FromSubUnits(doublePrecisionDividendSubUnits / divisorSubUnits);
}

// Is there a faster approach that works with BigIntegers?
// It seems Log10 isn't faster at all.
private static int CountDigits(BigInteger value)
{
int count = 0;

while (value > 0)
{
count++;
value /= 10;
}

return count;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,14 @@

namespace RadixDlt.NetworkGateway.Abstractions.StandardMetadata;

public abstract record ResolvedTwoWayLink(string? InvalidReason)
{
public bool IsValid => InvalidReason == null;
}
public abstract record ResolvedTwoWayLink;

public sealed record DappClaimedEntityResolvedTwoWayLink(EntityAddress EntityAddress, string? InvalidReason) : ResolvedTwoWayLink(InvalidReason);
public sealed record DappClaimedEntityResolvedTwoWayLink(EntityAddress EntityAddress) : ResolvedTwoWayLink;

public sealed record DappClaimedWebsiteResolvedTwoWayLink(Uri Origin, string? InvalidReason) : ResolvedTwoWayLink(InvalidReason);
public sealed record DappClaimedWebsiteResolvedTwoWayLink(Uri Origin) : ResolvedTwoWayLink;

public sealed record DappDefinitionResolvedTwoWayLink(EntityAddress EntityAddress, string? InvalidReason) : ResolvedTwoWayLink(InvalidReason);
public sealed record DappDefinitionResolvedTwoWayLink(EntityAddress EntityAddress) : ResolvedTwoWayLink;

public sealed record DappDefinitionsResolvedTwoWayLink(EntityAddress EntityAddress, string? InvalidReason) : ResolvedTwoWayLink(InvalidReason);
public sealed record DappDefinitionsResolvedTwoWayLink(EntityAddress EntityAddress) : ResolvedTwoWayLink;

public sealed record DappAccountLockerResolvedTwoWayLink(EntityAddress LockerAddress, string? InvalidReason) : ResolvedTwoWayLink(InvalidReason);
public sealed record DappAccountLockerResolvedTwoWayLink(EntityAddress LockerAddress) : ResolvedTwoWayLink;
Loading

0 comments on commit 1acddc0

Please sign in to comment.