diff --git a/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs b/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs index da86a41a3c..8018965c50 100644 --- a/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs +++ b/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs @@ -440,10 +440,10 @@ commandParser = subparser $ fold cantonSandboxCmd = do cantonOptions <- do - cantonLedgerApi <- option auto (long "port" <> value 6865) - cantonAdminApi <- option auto (long "admin-api-port" <> value 6866) - cantonDomainPublicApi <- option auto (long "domain-public-port" <> value 6867) - cantonDomainAdminApi <- option auto (long "domain-admin-port" <> value 6868) + cantonLedgerApi <- option auto (long "port" <> value (ledger defaultSandboxPorts)) + cantonAdminApi <- option auto (long "admin-api-port" <> value (admin defaultSandboxPorts)) + cantonDomainPublicApi <- option auto (long "domain-public-port" <> value (domainPublic defaultSandboxPorts)) + cantonDomainAdminApi <- option auto (long "domain-admin-port" <> value (domainAdmin defaultSandboxPorts)) cantonPortFileM <- optional $ option str (long "canton-port-file" <> metavar "PATH" <> help "File to write canton participant ports when ready") cantonStaticTime <- StaticTime <$> diff --git a/daml-assistant/daml-helper/src/DA/Daml/Helper/Start.hs b/daml-assistant/daml-helper/src/DA/Daml/Helper/Start.hs index 5f88e04ffe..7d51891405 100644 --- a/daml-assistant/daml-helper/src/DA/Daml/Helper/Start.hs +++ b/daml-assistant/daml-helper/src/DA/Daml/Helper/Start.hs @@ -68,10 +68,10 @@ getPortForSandbox defaultPortSpec portSpecM = determineCantonOptions :: Maybe SandboxPortSpec -> SandboxCantonPortSpec -> FilePath -> IO CantonOptions determineCantonOptions ledgerApiSpec SandboxCantonPortSpec{..} portFile = do - cantonLedgerApi <- getPortForSandbox (SpecifiedPort (SandboxPort 6865)) ledgerApiSpec - cantonAdminApi <- getPortForSandbox FreePort adminApiSpec - cantonDomainPublicApi <- getPortForSandbox FreePort domainPublicApiSpec - cantonDomainAdminApi <- getPortForSandbox FreePort domainAdminApiSpec + cantonLedgerApi <- getPortForSandbox (SpecifiedPort (SandboxPort (ledger defaultSandboxPorts))) ledgerApiSpec + cantonAdminApi <- getPortForSandbox (SpecifiedPort (SandboxPort (admin defaultSandboxPorts))) adminApiSpec + cantonDomainPublicApi <- getPortForSandbox (SpecifiedPort (SandboxPort (domainPublic defaultSandboxPorts))) domainPublicApiSpec + cantonDomainAdminApi <- getPortForSandbox (SpecifiedPort (SandboxPort (domainAdmin defaultSandboxPorts))) domainAdminApiSpec let cantonPortFileM = Just portFile -- TODO allow canton port file to be passed in from command line? let cantonStaticTime = StaticTime False let cantonHelp = False diff --git a/daml-assistant/daml-helper/src/DA/Daml/Helper/Util.hs b/daml-assistant/daml-helper/src/DA/Daml/Helper/Util.hs index 27a664c3f4..d8783c2207 100644 --- a/daml-assistant/daml-helper/src/DA/Daml/Helper/Util.hs +++ b/daml-assistant/daml-helper/src/DA/Daml/Helper/Util.hs @@ -25,6 +25,8 @@ module DA.Daml.Helper.Util , waitForHttpServer , tokenFor , StaticTime(..) + , SandboxPorts(..) + , defaultSandboxPorts , CantonOptions(..) , decodeCantonSandboxPort , CantonReplApi(..) @@ -250,6 +252,16 @@ tokenFor parties ledgerId applicationId = ] } +data SandboxPorts = SandboxPorts + { ledger :: Int + , admin :: Int + , domainPublic :: Int + , domainAdmin :: Int + } + +defaultSandboxPorts :: SandboxPorts +defaultSandboxPorts = SandboxPorts 6865 6866 6867 6868 + runCantonSandbox :: CantonOptions -> [String] -> IO () runCantonSandbox options args = withCantonSandbox options args (const $ pure ())