include required(file("/app/storage.conf"))

_client_credentials_auth_config {
  type = "client-credentials"
  well-known-config-url = ${?SPLICE_APP_VALIDATOR_LEDGER_API_AUTH_URL}
  client-id = ${?SPLICE_APP_VALIDATOR_LEDGER_API_AUTH_CLIENT_ID}
  client-secret = ${?SPLICE_APP_VALIDATOR_LEDGER_API_AUTH_CLIENT_SECRET}
  # TODO(DACH-NY/canton-network-internal#502) use actual audience of the target participant
  audience = ${SPLICE_APP_VALIDATOR_LEDGER_API_AUTH_AUDIENCE}
  scope = ${?SPLICE_APP_VALIDATOR_LEDGER_API_AUTH_SCOPE}
}

_onboarding {
  sv-client.admin-api.address = ${?SPLICE_APP_VALIDATOR_SV_SPONSOR_ADDRESS}
}

_scan {
  admin-api.address = ${SPLICE_APP_VALIDATOR_SCAN_ADDRESS}
}

canton {
  validator-apps {
    validator_backend {
      storage = ${_storage}
      admin-api = {
        address = "0.0.0.0"
        port = 5003
      }
      participant-client = {
        admin-api = {
          address = ${SPLICE_APP_VALIDATOR_PARTICIPANT_ADDRESS}
          port = 5002
        }
        ledger-api = {
          client-config = {
            address = ${SPLICE_APP_VALIDATOR_PARTICIPANT_ADDRESS}
            port = 5001
          }
          auth-config = ${_client_credentials_auth_config}
        }
      }
      ledger-api-user = ${SPLICE_APP_VALIDATOR_LEDGER_API_AUTH_USER_NAME}
      validator-wallet-users.0 = ${?SPLICE_APP_VALIDATOR_WALLET_USER_NAME}
      validator-party-hint = ${?SPLICE_APP_VALIDATOR_PARTY_HINT}
      auth {
        algorithm = "rs-256"
        audience = ${SPLICE_APP_VALIDATOR_AUTH_AUDIENCE}
        jwks-url = ${SPLICE_APP_VALIDATOR_AUTH_JWKS_URL}
        connection-timeout = ${?SPLICE_APP_VALIDATOR_AUTH_JWKS_CONNECTION_TIMEOUT}
        read-timeout = ${?SPLICE_APP_VALIDATOR_AUTH_JWKS_READ_TIMEOUT}
      }
      app-instances {
      }
      onboarding = {
        sv-client.admin-api.url = ${_onboarding.sv-client.admin-api.address}
        secret = ${?SPLICE_APP_VALIDATOR_ONBOARDING_SECRET}
      }
      domains {
        global {
          alias = "global"
        }
      }
      sv-validator = ${?SPLICE_APP_VALIDATOR_SV_VALIDATOR}
      sv-user = ${?SPLICE_APP_SV_LEDGER_API_AUTH_USER_NAME}
      contact-point = ${SPLICE_APP_CONTACT_POINT}
      canton-identifier-config = {
        participant = ${SPLICE_APP_VALIDATOR_PARTICIPANT_IDENTIFIER}
      }
    }
  }
  features.enable-testing-commands = yes

  # TODO(DACH-NY/canton-network-internal#2125) Revisit timeouts on 3.4
  # Note: This is the client-side request timeout
  parameters.timeouts.request-timeout = 20 minutes
}
