Skip to content

Commit

Permalink
Merge pull request #776 from radixdlt/tweak/fix-docs-and-formatting
Browse files Browse the repository at this point in the history
Merging this because the changes aren't contentious after markups, I rebased twice now,  and don't want to keep doing that :)
  • Loading branch information
dhedey authored Aug 13, 2024
2 parents 86ce908 + 1acddc0 commit ffe0ee3
Show file tree
Hide file tree
Showing 27 changed files with 415 additions and 402 deletions.
3 changes: 2 additions & 1 deletion apps/DataAggregator/Controllers/RootController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public JsonResult GetRootResponse()
docs = "https://docs.radixdlt.com",
repo = "https://github.com/radixdlt/babylon-gateway",
ledger_commit_health = healthReport,
}) { StatusCode = healthReport.IsHealthy ? 200 : 500 };
})
{ StatusCode = healthReport.IsHealthy ? 200 : 500 };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private KnownGatewayErrorException HandleException(HttpContext httpContext, Exce
{
switch (exception)
{
case BadHttpRequestException badHttpRequestException :
case BadHttpRequestException badHttpRequestException:
_logger.LogWarning(exception, "Bad http request. [RequestTrace={TraceId}]", traceId);
return new GenericBadRequestException("Bad http request", badHttpRequestException.Message);

Expand Down
32 changes: 23 additions & 9 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Pre-requisites

The following are pre-requisites:
* We use [dotnet 7](https://dotnet.microsoft.com/download/dotnet/7.0) - ensure `dotnet --version` returns at least 7.x
* We use [dotnet 8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) - ensure `dotnet --version` returns at least `8.x`
* Install docker

Whilst any IDE supporting dotnet core can be used for development, we would recommend Jetbrains Rider.
Expand All @@ -14,7 +14,7 @@ In development, configuration comes from a few places, with items lower down the

* `apps/[X]/appsettings.json`
* `apps/[X]/appsettings.Development.json`
* `apps/[X]/appsettings.PersonalOverrides.json` (under .gitignore)
* `apps/[X]/appsettings.overrides.json` (under .gitignore)
* Environment variables

By default, the configuration is set up to point to a full node's Core API running locally at http://localhost:3333, but you may wish to use non-local Core API, to have a synced-up system to read from, and to avoid hammering your computer too much! (see sections below).
Expand All @@ -23,7 +23,7 @@ If you wish to easily spin up a local Core API, follow the instructions in [the

### Custom development configuration

As referenced above, the `appsettings.PersonalOverrides.json` files can be used to (eg) override configuration locally without risking updating source control. The schema for this file is the same as the main `appsettings.json` and `appsettings.Development.json`. Some example use cases include:
As referenced above, the `appsettings.overrides.json` files can be used to (eg) override configuration locally without risking updating source control. The schema for this file is the same as the main `appsettings.json` and `appsettings.Development.json`. Some example use cases include:

* Changing the `NetworkName` so it matches the core nodes you're connected to
* Connecting to a non-local Core Node (typically by adjusting `DisableCoreApiHttpsCertificateChecks`, and the `CoreApiAddress`, `CoreApiAuthorizationHeader` fields under the first configured node in `CoreApiNodes`)
Expand All @@ -48,15 +48,27 @@ You'll need to run a version 1.1.0 or higher in order for the node to have the C

Run following tasks:

* `Postgres` (this runs `docker-compose up`)
* `Database Migrations with Wipe Database` (this runs database migrations)
* `./deployment/run-only-network-gateway-resources.sh` from the command line to start the PostgreSQL DB container.
* `Migrations (Wipe)` (this runs database migrations)

And then, depending on what you're working on, you can run one or both of these. Note that the `Data Aggregator` needs to have run successfully at least once to start the ledger, for the `Gateway API` to be able to connect.

* `Data Aggregator`
* `Gateway API`
* `Gateway Api`

You can use the `Database Migrations with Wipe Database` task if you ever need to clear the database. (Say, because the DB ledger got corrupted; or you wish to change which network you're connected to)
You can use the `Migrations (Wipe)` task if you ever need to clear the database. (Say, because the DB ledger got corrupted; or you wish to change which network you're connected to)

### Configuring the dev DB as a Data Source

To get checking and auto-complete on your SQL, you may wish to configure a Data Source in Rider. Note that currently it often doesn't give any auto-complete for [CTEs](https://www.postgresql.org/docs/current/queries-with.html), and some of our queries are dynamically created, but it's still often useful to inspect data.

To do this, add a PostgreSQL Database connection with parameters:
* Host: `localhost`
* Port: `5432`
* Authentication: `User & Password`
* User: `db_dev_superuser`
* Password: `db_dev_password`
* Database: `radixdlt_ledger`

## Developing using the command line

Expand All @@ -66,7 +78,7 @@ Run the following in separate terminals:

```bash
# Spin up PostgreSQL first
docker-compose up
./deployment/run-only-network-gateway-resources.sh
```

```bash
Expand Down Expand Up @@ -108,7 +120,9 @@ For more information, see the [Tests project](../../src/Tests).

## Reformatting

Run `dotnet format` to fix whitespace and other formatting issues across all files. Rider runs this as you save each file, so this likely won't be needed regularly.
Run `./generation/ensure-license-headers.sh` when adding new files to ensure they get license headers.

You can also run `dotnet format` manually to fix whitespace and other formatting issues across all files. Rider runs this as you save each file, so this likely won't be needed regularly.

## Code Generation - Migrations, Open API specs etc

Expand Down
2 changes: 1 addition & 1 deletion src/RadixDlt.CoreApiSdk/Model/EventTypeIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public IEnumerable<string> GetEntityAddresses()
{
yield return TypeReference.FullTypeId.EntityAddress;

foreach (var address in this.Emitter.GetEntityAddresses())
foreach (var address in Emitter.GetEntityAddresses())
{
yield return address;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ public partial class FunctionEventEmitterIdentifier
{
public override IEnumerable<string> GetEntityAddresses()
{
yield return this.PackageAddress;
yield return PackageAddress;
}
}
2 changes: 1 addition & 1 deletion src/RadixDlt.CoreApiSdk/Model/SchemaDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private SchemaDetails ExtractSchemaDetailsFromGenericSubstitution(GenericSubstit
remoteGenericSubstitution.ResolvedFullTypeId.EntityAddress,
remoteGenericSubstitution.ResolvedFullTypeId.LocalTypeId.Id,
remoteGenericSubstitution.ResolvedFullTypeId.LocalTypeId.Kind),
_ => throw new UnreachableException($"Unexpected type of generic substitution {genericSubstitution.GetType()}")
_ => throw new UnreachableException($"Unexpected type of generic substitution {genericSubstitution.GetType()}"),
};
}
}
2 changes: 1 addition & 1 deletion src/RadixDlt.NetworkGateway.Abstractions/EntityAddress.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

namespace RadixDlt.NetworkGateway.DataAggregator.Services;

public interface IPendingTransactionResubmissionServiceObserver: ITransactionSubmitterObserver
public interface IPendingTransactionResubmissionServiceObserver : ITransactionSubmitterObserver
{
ValueTask ObserveResubmissionQueueSize(int totalTransactionsNeedingResubmission);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,43 +250,43 @@ public DefaultTransactionHandler(
switch (decidingFactorItem.ResourcePreferenceRule)
{
case GatewayModel.AccountResourcePreferenceRule.Allowed:
{
var resourceSpecificResponseItem = new GatewayModel.AccountDepositPreValidationResourceSpecificBehaviourItem(decidingFactorItem.ResourceAddress, true);
resourceSpecificResponseCollection.Add(resourceSpecificResponseItem);
break;
}
{
var resourceSpecificResponseItem = new GatewayModel.AccountDepositPreValidationResourceSpecificBehaviourItem(decidingFactorItem.ResourceAddress, true);
resourceSpecificResponseCollection.Add(resourceSpecificResponseItem);
break;
}

case GatewayModel.AccountResourcePreferenceRule.Disallowed:
{
var resourceSpecificResponseItem = new GatewayModel.AccountDepositPreValidationResourceSpecificBehaviourItem(decidingFactorItem.ResourceAddress, false);
resourceSpecificResponseCollection.Add(resourceSpecificResponseItem);
break;
}
{
var resourceSpecificResponseItem = new GatewayModel.AccountDepositPreValidationResourceSpecificBehaviourItem(decidingFactorItem.ResourceAddress, false);
resourceSpecificResponseCollection.Add(resourceSpecificResponseItem);
break;
}

case null:
switch (decidingFactors.DefaultDepositRule)
{
case GatewayModel.AccountDefaultDepositRule.Reject:
{
var resourceSpecificResponseItem = new GatewayModel.AccountDepositPreValidationResourceSpecificBehaviourItem(decidingFactorItem.ResourceAddress, false);
resourceSpecificResponseCollection.Add(resourceSpecificResponseItem);
break;
}
{
var resourceSpecificResponseItem = new GatewayModel.AccountDepositPreValidationResourceSpecificBehaviourItem(decidingFactorItem.ResourceAddress, false);
resourceSpecificResponseCollection.Add(resourceSpecificResponseItem);
break;
}

case GatewayModel.AccountDefaultDepositRule.Accept:
{
var resourceSpecificResponseItem = new GatewayModel.AccountDepositPreValidationResourceSpecificBehaviourItem(decidingFactorItem.ResourceAddress, true);
resourceSpecificResponseCollection.Add(resourceSpecificResponseItem);
break;
}
{
var resourceSpecificResponseItem = new GatewayModel.AccountDepositPreValidationResourceSpecificBehaviourItem(decidingFactorItem.ResourceAddress, true);
resourceSpecificResponseCollection.Add(resourceSpecificResponseItem);
break;
}

case GatewayModel.AccountDefaultDepositRule.AllowExisting:
{
var allowsTryDeposit = decidingFactorItem.IsXrd || decidingFactorItem.VaultExists;
var resourceSpecificResponseItem = new GatewayModel.AccountDepositPreValidationResourceSpecificBehaviourItem(decidingFactorItem.ResourceAddress, allowsTryDeposit);
resourceSpecificResponseCollection.Add(resourceSpecificResponseItem);
break;
}
{
var allowsTryDeposit = decidingFactorItem.IsXrd || decidingFactorItem.VaultExists;
var resourceSpecificResponseItem = new GatewayModel.AccountDepositPreValidationResourceSpecificBehaviourItem(decidingFactorItem.ResourceAddress, allowsTryDeposit);
resourceSpecificResponseCollection.Add(resourceSpecificResponseItem);
break;
}

default:
throw new ArgumentOutOfRangeException($"Unexpected value of {decidingFactors.DefaultDepositRule}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

namespace RadixDlt.NetworkGateway.GatewayApi.Services;

public interface ISubmissionTrackingServiceObserver: ITransactionSubmitterObserver
public interface ISubmissionTrackingServiceObserver : ITransactionSubmitterObserver
{
ValueTask OnSubmissionTrackedInDatabase(bool isDuplicate);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model;

public partial class StateAccountLockerPageVaultsRequest : IPaginableRequest
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model;

public partial class StateEntitySchemaPageRequest : IPaginableRequest
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -233,28 +233,28 @@ AccountAuthorizedDepositorsChangePointerLookup lookup
switch (accountAuthorizedDepositorEntrySubstate.Key.Badge)
{
case CoreModel.ResourceAuthorizedDepositorBadge resourceBadge:
{
var resourceEntityId = _referencedEntityDictionary.Get((EntityAddress)resourceBadge.ResourceAddress).DatabaseId;

entryLookup = new AccountAuthorizedDepositorsDbLookup(
AccountEntityId: lookup.AccountEntityId,
ResourceEntityId: resourceEntityId,
NonFungibleId: null
);
break;
}
{
var resourceEntityId = _referencedEntityDictionary.Get((EntityAddress)resourceBadge.ResourceAddress).DatabaseId;

entryLookup = new AccountAuthorizedDepositorsDbLookup(
AccountEntityId: lookup.AccountEntityId,
ResourceEntityId: resourceEntityId,
NonFungibleId: null
);
break;
}

case CoreModel.NonFungibleAuthorizedDepositorBadge nonFungibleBadge:
{
var resourceEntityId = _referencedEntityDictionary.Get((EntityAddress)nonFungibleBadge.NonFungibleGlobalId.ResourceAddress).DatabaseId;

entryLookup = new AccountAuthorizedDepositorsDbLookup(
AccountEntityId: lookup.AccountEntityId,
ResourceEntityId: resourceEntityId,
NonFungibleId: nonFungibleBadge.NonFungibleGlobalId.LocalId.SimpleRep
);
break;
}
{
var resourceEntityId = _referencedEntityDictionary.Get((EntityAddress)nonFungibleBadge.NonFungibleGlobalId.ResourceAddress).DatabaseId;

entryLookup = new AccountAuthorizedDepositorsDbLookup(
AccountEntityId: lookup.AccountEntityId,
ResourceEntityId: resourceEntityId,
NonFungibleId: nonFungibleBadge.NonFungibleGlobalId.LocalId.SimpleRep
);
break;
}

default:
throw new UnreachableException(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down Expand Up @@ -159,18 +159,18 @@ private static List<PresentedProof> ExtractProofs(Dictionary<string, ToolkitMode
switch (proof)
{
case ToolkitModel.ResourceSpecifier.Amount fungibleProof:
{
var resourceAddress = (EntityAddress)fungibleProof.resourceAddress.AddressString();
mapped.Add(new PresentedProof(accountAddress, resourceAddress));
break;
}
{
var resourceAddress = (EntityAddress)fungibleProof.resourceAddress.AddressString();
mapped.Add(new PresentedProof(accountAddress, resourceAddress));
break;
}

case ToolkitModel.ResourceSpecifier.Ids nonFungibleProof:
{
var resourceAddress = (EntityAddress)nonFungibleProof.resourceAddress.AddressString();
mapped.Add(new PresentedProof(accountAddress, resourceAddress));
break;
}
{
var resourceAddress = (EntityAddress)nonFungibleProof.resourceAddress.AddressString();
mapped.Add(new PresentedProof(accountAddress, resourceAddress));
break;
}

default:
throw new UnreachableException($"Unexpected proof type {proof.GetType()}");
Expand Down
Loading

0 comments on commit ffe0ee3

Please sign in to comment.