Skip to content

Commit

Permalink
ledger: Damlification of Scala files (#9667)
Browse files Browse the repository at this point in the history
* Damlification of Scala files (primarily comments and strings).

* Corrected a typo.
CHANGELOG_BEGIN
CHANGELOG_END

* Fixed build.

* Fixed test case for acronyms.

* Reformatted.
  • Loading branch information
miklos-da authored May 20, 2021
1 parent 40cf26f commit b1ca310
Show file tree
Hide file tree
Showing 46 changed files with 107 additions and 105 deletions.
2 changes: 1 addition & 1 deletion ledger/daml-on-sql/src/main/scala/on/sql/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scalaz.syntax.tag._

package object sql {

private[sql] val Name = LedgerName("DAML-on-SQL")
private[sql] val Name = LedgerName("Daml-on-SQL")

private[sql] val DefaultConfig = SandboxConfig.defaultConfig.copy(
participantId = v1.ParticipantId.assertFromString(Name.unwrap.toLowerCase()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ object Main {
)

cmd("generate-token")
.text("Generate a signed access token for the DAML ledger API")
.text("Generate a signed access token for the Daml ledger API")
.action((_, c) => c.copy(command = Some(GenerateToken())))
.children(
opt[File]("output")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sealed abstract class Claim
case object ClaimAdmin extends Claim

/** Authorized to use all "public" services, i.e.,
* those that do not require admin rights and do not depend on any DAML party.
* those that do not require admin rights and do not depend on any Daml party.
* Examples include the LedgerIdentityService or the PackageService.
*/
case object ClaimPublic extends Claim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final class CommandsValidator(ledgerId: LedgerId) {
.left
.map(_ =>
invalidArgument(
s"Can not represent command ledger time $ledgerEffectiveTime as a DAML timestamp"
s"Can not represent command ledger time $ledgerEffectiveTime as a Daml timestamp"
)
)
deduplicationTime <- validateDeduplicationTime(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import com.google.protobuf.timestamp.Timestamp
*
* Most conversion functions have a verbose flag:
* - If verbose mode is disabled, then all resulting Api values have missing type identifiers and record field names.
* - If verbose mode is enabled, then type identifiers and record field names are copied from the input DAML-LF values.
* - If verbose mode is enabled, then type identifiers and record field names are copied from the input Daml-LF values.
* The caller is responsible for filling in missing type information using [[com.daml.lf.engine.ValueEnricher]],
* which may involve loading DAML-LF packages.
* which may involve loading Daml-LF packages.
*/
object LfEngineToApi {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import com.daml.lf.value.Value.ContractId
trait KeyHasher {

/** @deprecated in favor of [[GlobalKey.hash]]
* Returns the hash of the given DAML-LF value
* Returns the hash of the given Daml-LF value
*/
def hashKey(key: GlobalKey): Array[Byte]

/** @deprecated in favor of [[GlobalKey.hash]]
* Returns a string representation of the hash of the given DAML-LF value
* Returns a string representation of the hash of the given Daml-LF value
*/
def hashKeyString(key: GlobalKey): String = hashKey(key).map("%02x" format _).mkString
}
Expand All @@ -31,7 +31,7 @@ trait KeyHasher {
object KeyHasher extends KeyHasher {

/** ADT for data elements that appear in the input stream of the hash function
* used to hash DAML-LF values.
* used to hash Daml-LF values.
*/
private sealed abstract class HashToken extends Product with Serializable
private final case class HashTokenText(value: String) extends HashToken
Expand All @@ -44,7 +44,7 @@ object KeyHasher extends KeyHasher {
/** Traverses the given value in a stable way, producing "hash tokens" for any encountered primitive values.
* These tokens can be used as the input to a hash function.
*
* @param value the DAML-LF value to hash
* @param value the Daml-LF value to hash
* @param z initial hash value
* @param op operation to append a hash token
* @return the final hash value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ object domain {
commands: LfCommands,
)

/** @param party The stable unique identifier of a DAML party.
/** @param party The stable unique identifier of a Daml party.
* @param displayName Human readable name associated with the party. Might not be unique.
* @param isLocal True if party is hosted by the backing participant.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ object Cli {
failure(s"$name is not a valid performance test name. Use `--list` to see valid names.")

head("""The Ledger API Test Tool is a command line tool for testing the correctness of
|ledger implementations based on DAML and Ledger API.""".stripMargin)
|ledger implementations based on Daml and Ledger API.""".stripMargin)

arg[(String, Int)]("[endpoints...]")(endpointRead)
.action((address, config) => config.copy(participants = config.participants :+ address))
Expand Down Expand Up @@ -139,8 +139,8 @@ object Cli {
opt[Unit]('x', "extract")
.action((_, c) => c.copy(extract = true))
.text(
"""Extract a DAR necessary to test a DAML ledger and exit without running tests.
|The DAR needs to be manually loaded into a DAML ledger for the tool to work.""".stripMargin
"""Extract a DAR necessary to test a Daml ledger and exit without running tests.
|The DAR needs to be manually loaded into a Daml ledger for the tool to work.""".stripMargin
)

opt[Seq[String]]("exclude")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ object LedgerApiTestTool {

private def extractResources(resources: Seq[String]): Unit = {
val pwd = Paths.get(".").toAbsolutePath
println(s"Extracting all DAML resources necessary to run the tests into $pwd.")
println(s"Extracting all Daml resources necessary to run the tests into $pwd.")
for (resource <- resources) {
val is = getClass.getClassLoader.getResourceAsStream(resource)
if (is == null) sys.error(s"Could not find $resource in classpath")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class SemanticTests extends LedgerTestSuite {
* `c` if the following hold for all its subactions `act`
* on the contract `c`:
*
* 1. `act` does not happen before any Create c action (correct by construction in DAML)
* 1. `act` does not happen before any Create c action (correct by construction in Daml)
* 2. `act` does not happen after the contract has been consumend (i.e. no double spending)
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ class TransactionServiceIT extends LedgerTestSuite {

test(
"TXUnitAsArgumentToNothing",
"DAML engine returns Unit as argument to Nothing",
"Daml engine returns Unit as argument to Nothing",
allocate(SingleParty),
)(implicit ec => { case Participants(Participant(ledger, party)) =>
val template = NothingArgument(party, Primitive.Optional.empty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ private[migration] class V2_1__Rebuild_Acs extends BaseJavaMigration {
|on conflict on constraint contract_divulgences_idx
|do nothing""".stripMargin

/** Updates the active contract set from the given DAML transaction.
* Note: This involves checking the validity of the given DAML transaction.
/** Updates the active contract set from the given Daml transaction.
* Note: This involves checking the validity of the given Daml transaction.
* Invalid transactions trigger a rollback of the current SQL transaction.
*/
private def updateActiveContractSet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ private[apiserver] final class StoreBackedCommandExecutor(
// The actAs and readAs parties are used for two kinds of checks by the ledger API server:
// When looking up contracts during command interpretation, the engine should only see contracts
// that are visible to at least one of the actAs or readAs parties. This visibility check is not part of the
// DAML ledger model.
// When checking DAML authorization rules, the engine verifies that the actAs parties are sufficient to
// Daml ledger model.
// When checking Daml authorization rules, the engine verifies that the actAs parties are sufficient to
// authorize the resulting transaction.
val commitAuthorizers = commands.actAs
val submissionResult = Timed.trackedValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object IndexerConfig {

val DefaultUpdatePreparationParallelism = 2
val DefaultRestartDelay: FiniteDuration = 10.seconds
// Should be greater than or equal to the number of pipline stages
// Should be greater than or equal to the number of pipeline stages.
val DefaultDatabaseConnectionPoolSize: Int = 3
val DefaultAsyncCommitMode: DbType.AsyncCommitMode = DbType.AsynchronousCommit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ final class LfValueTranslation(
loggingContext: LoggingContext,
): Future[CreatedEvent] = {
// Load the deserialized contract argument and contract key from the cache
// This returns the values in DAML-LF format.
// This returns the values in Daml-LF format.
val create =
cache.events
.getIfPresent(eventKey(raw.partial.eventId))
Expand All @@ -251,8 +251,8 @@ final class LfValueTranslation(

lazy val templateId: LfIdentifier = apiIdentifierToDamlLfIdentifier(raw.partial.templateId.get)

// Convert DAML-LF values to ledger API values.
// In verbose mode, this involves loading DAML-LF packages and filling in missing type information.
// Convert Daml-LF values to ledger API values.
// In verbose mode, this involves loading Daml-LF packages and filling in missing type information.
for {
createArguments <- toApiRecord(
value = create.argument,
Expand Down Expand Up @@ -286,7 +286,7 @@ final class LfValueTranslation(
loggingContext: LoggingContext,
): Future[ExercisedEvent] = {
// Load the deserialized choice argument and choice result from the cache
// This returns the values in DAML-LF format.
// This returns the values in Daml-LF format.
val exercise =
cache.events
.getIfPresent(eventKey(raw.partial.eventId))
Expand All @@ -303,8 +303,8 @@ final class LfValueTranslation(
lazy val templateId: LfIdentifier = apiIdentifierToDamlLfIdentifier(raw.partial.templateId.get)
lazy val choiceName: LfChoiceName = LfChoiceName.assertFromString(raw.partial.choice)

// Convert DAML-LF values to ledger API values.
// In verbose mode, this involves loading DAML-LF packages and filling in missing type information.
// Convert Daml-LF values to ledger API values.
// In verbose mode, this involves loading Daml-LF packages and filling in missing type information.
for {
choiceArgument <- toApiValue(
value = exercise.argument,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.daml.ledger.participant.state.v1.{CommittedTransaction, RejectionReas
* This is intended exclusively as a temporary replacement for
* [[com.daml.platform.store.ActiveLedgerState]] and [[com.daml.platform.store.ActiveLedgerStateManager]]
* so that the old post-commit validation backed by the old participant schema can be
* dropped and the DAML-on-X-backed implementation of the Sandbox can skip it entirely.
* dropped and the Daml-on-X-backed implementation of the Sandbox can skip it entirely.
*
* Post-commit validation is relevant for three reasons:
* - keys can be referenced by two concurrent interpretations, potentially leading to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}

/** @param dispatcher Executes the queries prepared by this object
* @param executionContext Runs transformations on data fetched from the database, including DAML-LF value deserialization
* @param executionContext Runs transformations on data fetched from the database, including Daml-LF value deserialization
* @param pageSize The number of events to fetch at a time the database when serving streaming calls
* @param lfValueTranslation The delegate in charge of translating serialized DAML-LF values
* @param lfValueTranslation The delegate in charge of translating serialized Daml-LF values
* @see [[PaginatingAsyncStream]]
*/
private[appendonlydao] final class TransactionsReader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ private[platform] trait LedgerReadDao extends ReportsHealth {
endInclusive: Offset,
)(implicit loggingContext: LoggingContext): Source[(Offset, PartyLedgerEntry), NotUsed]

/** Returns a list of all known DAML-LF packages */
/** Returns a list of all known Daml-LF packages */
def listLfPackages()(implicit
loggingContext: LoggingContext
): Future[Map[PackageId, PackageDetails]]

/** Returns the given DAML-LF archive */
/** Returns the given Daml-LF archive */
def getLfArchive(packageId: PackageId)(implicit
loggingContext: LoggingContext
): Future[Option[Archive]]
Expand Down Expand Up @@ -311,7 +311,7 @@ private[platform] trait LedgerWriteDao extends ReportsHealth {
rejectionReason: Option[String],
)(implicit loggingContext: LoggingContext): Future[PersistenceResponse]

/** Store a DAML-LF package upload result.
/** Store a Daml-LF package upload result.
*/
def storePackageEntry(
offsetStep: OffsetStep,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ final class LfValueTranslation(
loggingContext: LoggingContext,
): Future[CreatedEvent] = {
// Load the deserialized contract argument and contract key from the cache
// This returns the values in DAML-LF format.
// This returns the values in Daml-LF format.
val create =
cache.events
.getIfPresent(eventKey(raw.partial.eventId))
Expand All @@ -241,8 +241,8 @@ final class LfValueTranslation(

lazy val templateId: LfIdentifier = apiIdentifierToDamlLfIdentifier(raw.partial.templateId.get)

// Convert DAML-LF values to ledger API values.
// In verbose mode, this involves loading DAML-LF packages and filling in missing type information.
// Convert Daml-LF values to ledger API values.
// In verbose mode, this involves loading Daml-LF packages and filling in missing type information.
for {
createArguments <- toApiRecord(
value = create.argument,
Expand Down Expand Up @@ -276,7 +276,7 @@ final class LfValueTranslation(
loggingContext: LoggingContext,
): Future[ExercisedEvent] = {
// Load the deserialized choice argument and choice result from the cache
// This returns the values in DAML-LF format.
// This returns the values in Daml-LF format.
val exercise =
cache.events
.getIfPresent(eventKey(raw.partial.eventId))
Expand All @@ -293,8 +293,8 @@ final class LfValueTranslation(
lazy val templateId: LfIdentifier = apiIdentifierToDamlLfIdentifier(raw.partial.templateId.get)
lazy val choiceName: LfChoiceName = LfChoiceName.assertFromString(raw.partial.choice)

// Convert DAML-LF values to ledger API values.
// In verbose mode, this involves loading DAML-LF packages and filling in missing type information.
// Convert Daml-LF values to ledger API values.
// In verbose mode, this involves loading Daml-LF packages and filling in missing type information.
for {
choiceArgument <- toApiValue(
value = exercise.argument,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.daml.ledger.participant.state.v1.{CommittedTransaction, RejectionReas
* This is intended exclusively as a temporary replacement for
* [[com.daml.platform.store.ActiveLedgerState]] and [[com.daml.platform.store.ActiveLedgerStateManager]]
* so that the old post-commit validation backed by the old participant schema can be
* dropped and the DAML-on-X-backed implementation of the Sandbox can skip it entirely.
* dropped and the Daml-on-X-backed implementation of the Sandbox can skip it entirely.
*
* Post-commit validation is relevant for three reasons:
* - keys can be referenced by two concurrent interpretations, potentially leading to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}

/** @param dispatcher Executes the queries prepared by this object
* @param executionContext Runs transformations on data fetched from the database, including DAML-LF value deserialization
* @param executionContext Runs transformations on data fetched from the database, including Daml-LF value deserialization
* @param pageSize The number of events to fetch at a time the database when serving streaming calls
* @param lfValueTranslation The delegate in charge of translating serialized DAML-LF values
* @param lfValueTranslation The delegate in charge of translating serialized Daml-LF values
* @see [[PaginatingAsyncStream]]
*/
private[dao] final class TransactionsReader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ private[dao] trait JdbcLedgerDaoSuite extends JdbcLedgerDaoBackend {

// Note: *identifiers* and *values* defined below MUST correspond to //ledger/test-common/src/main/daml/model/Test.daml
// This is because some tests request values in verbose mode, which requires filling in missing type information,
// which in turn requires loading DAML-LF packages with valid DAML-LF types that correspond to the DAML-LF values.
// which in turn requires loading Daml-LF packages with valid Daml-LF types that correspond to the Daml-LF values.
//
// On the other hand, *transactions* do not need to correspond to valid transactions that could be produced by the
// above mentioned DAML code, e.g., signatories/stakeholders may not correspond to the contract/choice arguments.
// This is because JdbcLedgerDao is only concerned with serialization, and does not verify the DAML ledger model.
// above mentioned Daml code, e.g., signatories/stakeholders may not correspond to the contract/choice arguments.
// This is because JdbcLedgerDao is only concerned with serialization, and does not verify the Daml ledger model.
private def testIdentifier(name: String) = Identifier(
testPackageId,
Ref.QualifiedName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ final class MetricsNamingSpec extends AnyFlatSpec with Matchers {
}

it should "keep acronyms together and change their capitalization as a single unit" in {
camelCaseToSnakeCase("DAML") shouldBe "daml"
camelCaseToSnakeCase("DAMLFactory") shouldBe "daml_factory"
camelCaseToSnakeCase("AbstractDAML") shouldBe "abstract_daml"
camelCaseToSnakeCase("AbstractDAMLFactory") shouldBe "abstract_daml_factory"
camelCaseToSnakeCase("AbstractDAMLProxyJVMFactory") shouldBe "abstract_daml_proxy_jvm_factory"
camelCaseToSnakeCase("ACRONYM") shouldBe "acronym"
camelCaseToSnakeCase("ACRONYMFactory") shouldBe "acronym_factory"
camelCaseToSnakeCase("AbstractACRONYM") shouldBe "abstract_acronym"
camelCaseToSnakeCase("AbstractACRONYMFactory") shouldBe "abstract_acronym_factory"
camelCaseToSnakeCase(
"AbstractACRONYMProxyJVMFactory"
) shouldBe "abstract_acronym_proxy_jvm_factory"
}

it should "treat single letter words intelligently" in {
Expand Down
Loading

0 comments on commit b1ca310

Please sign in to comment.