Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/bazel_tools/ghc-lib/version.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GHC_LIB_PATCHES = [
]

GHC_REPO_URL = "https://github.com/digital-asset/ghc"
GHC_REV = "8db62703d35e30f9d33aa4cee09c48b85c81e7db"
GHC_REV = "07bb3ec74fa01838fcbb3a26bfd5c0fc940478b1"
GHC_PATCHES = [
]

Expand Down
4 changes: 2 additions & 2 deletions sdk/canton/canton_version.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

CANTON_OPEN_SOURCE_TAG = "3.6.0-snapshot.20260421.18770.0.vd4dfac19"
CANTON_OPEN_SOURCE_SHA = "sha256:62dabaec0e6a3b64e2085b1c8c67f53260dbb9b169c2be00c72c017180f3378e"
CANTON_OPEN_SOURCE_TAG = "3.6.0-snapshot.20260423.18790.0.v1034969b"
CANTON_OPEN_SOURCE_SHA = "sha256:b7ecfd9d88ccf4d03d25f3db90762feeda8ea949b38b03e67bbcc6f631e3462a"

# Use an alternative canton JAR & artifacts from the local maven cache by setting this to an absolute path
# Consult canton/README.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import qualified DA.Daml.LF.Ast.Range as R
import DA.Pretty

stagingRevision :: Int
stagingRevision = 1
stagingRevision = 2

-- | Daml-LF version of an archive payload.
data Version = Version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ typeOfUpdate = \case
return (keyType :-> TUpdate (TOptional cidType))
ULookupNByKey retrieveByKey -> do
(keyType, cidType, contractType) <- checkRetrieveByKey retrieveByKey
return (TInt64 :-> keyType :-> TUpdate (TList (TTuple2 cidType contractType)))
return (TInt64 :-> keyType :-> TUpdate (TOptional (TList (TTuple2 cidType contractType))))
UTryCatch typ expr var handler -> do
checkType typ KStar
checkExpr expr (TUpdate typ)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ convertPrim _ "UExerciseByKey"
convertPrim _ "ULookupByKey" (_ :-> TUpdate (TOptional (TContractId (TCon template)))) =
pure $ EUpdate $ ULookupByKey template

convertPrim _ "ULookupNByKey" (TInt64 :-> _ :-> TUpdate (TList (TTuple2 (TContractId (TCon template)) (TCon template'))))
convertPrim _ "ULookupNByKey" (TInt64 :-> _ :-> TUpdate (TOptional (TList (TTuple2 (TContractId (TCon template)) (TCon template')))))
| template == template'
= pure $ EUpdate $ ULookupNByKey template

Expand Down
20 changes: 9 additions & 11 deletions sdk/compiler/damlc/daml-stdlib-src/DA/ContractKeys.daml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
{-# LANGUAGE CPP #-}

-- | Note: Docs TODO (https://github.com/digital-asset/daml/issues/22673)
module DA.ContractKeys where

#ifdef DAML_NUCK
import qualified DA.Internal.Template.Functions as DA

lookupNByKey : forall t k. HasLookupNByKey t k => Int -> k -> Update [(ContractId t, t)]
lookupNByKey 0 = const $ pure []
lookupNByKey k = if k > 0
then DA._lookupNByKey k
else const $ fail "lookupNByKey may not be passed a negative n"
module DA.ContractKeys
( DA.lookupNByKey,
DA.lookupAllByKey,
)
where

lookupAllByKey : forall t k. HasLookupNByKey t k => k -> Update [(ContractId t, t)]
lookupAllByKey = DA._lookupNByKey (maxBound @Int)
import qualified DA.Internal.Template.Functions as DA
#else
module DA.ContractKeys where
#endif

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module DA.Internal.Template.Functions where

import DA.Internal.Any
import DA.Internal.LF
import DA.Internal.Fail()
import DA.Internal.Prelude
import DA.Internal.Template

Expand Down Expand Up @@ -197,7 +198,7 @@ class HasFetchByKey t k | t -> k where
-- TODO(https://github.com/digital-asset/daml/issues/22673): document
class HasLookupNByKey t k | t -> k where
-- | HIDE
_lookupNByKey : Int -> k -> Update [(ContractId t, t)]
_lookupNByKey : Int -> k -> Update (Optional [(ContractId t, t)])

-- | Exposes `maintainer` function. Part of the `TemplateKey` constraint.
class HasMaintainer t k | t -> k where
Expand All @@ -215,29 +216,55 @@ class HasExerciseByKey t k c r | t -> k, t c -> r where


#ifdef DAML_NUCK
-- | Look up the contract ID `t` associated with a given contract key `k`.
-- | MOVE DA.ContractKeys
-- Look up up to n contracts associated with the passed key. Contracts created
-- within a transaction are returned first (in recency order), then disclosed
-- contracts, then nonlocal contracts.
--
-- You must pass the `t` using an explicit type application. For instance, if
-- you want to query 3 contracts of template `Account` given by its key `k`, you
-- must call `lookupNByKey @Account 3 k.
lookupNByKey : forall t k. HasLookupNByKey t k => Int -> k -> Update [(ContractId t, t)]
lookupNByKey 0 _ = pure []
lookupNByKey n k = if n > 0
then do
optlist <- _lookupNByKey n k
case optlist of
Some xs -> pure xs
None -> fail "lookupNByKey returned None"
else fail "lookupNByKey may not be passed a negative n"

-- | MOVE DA.ContractKeys
-- Shorthand for `lookupNByKey` with n larger than the amount of contracts that
-- can exist for a key (1000000), therefore returning all contracts
lookupAllByKey : forall t k. HasLookupNByKey t k => k -> Update [(ContractId t, t)]
lookupAllByKey = lookupNByKey (maxBound @Int)

-- | Look up the contract ID `t` associated with a given contract key `k` (see
-- `lookupNByKey` for more on contract order).
--
-- You must pass the `t` using an explicit type application. For
-- instance, if you want to look up a contract of template `Account` by its
-- key `k`, you must call `lookupByKey @Account k`.
lookupByKey : (HasKey t k, HasLookupNByKey t k) => k -> Update (Optional (ContractId t))
lookupByKey k = do
cids <- _lookupNByKey 1 k
cids <- lookupNByKey 1 k
pure $ fst <$> listToOptional cids
where
listToOptional [] = None
listToOptional (x::_) = Some x

-- | Fetch the contract ID and contract data associated with a given
-- contract key.
-- | Fetch the first contract ID and contract data associated with the given
-- contract key (see `lookupNByKey` for more on contract order).
--
-- You must pass the `t` using an explicit type application. For
-- instance, if you want to fetch a contract of template `Account` by its
-- key `k`, you must call `fetchByKey @Account k`.
fetchByKey : forall t k. HasFetchByKey t k => k -> Update (ContractId t, t)
fetchByKey = _fetchByKey

-- | Exercise a choice on the contract associated with the given key.
-- | Exercise a choice on the first contract associated with the given key (see
-- `lookupNByKey` for more on contract order).
--
-- You must pass the `t` using an explicit type application. For
-- instance, if you want to exercise a choice `Withdraw` on a contract of
Expand Down
4 changes: 4 additions & 0 deletions sdk/compiler/damlc/daml-stdlib-src/Prelude.daml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import DA.Internal.LF as X hiding
-- but we can hide them.
import DA.Internal.Any as X hiding (AnyContractKey (..))
import DA.Internal.Template as X
#ifdef DAML_NUCK
import DA.Internal.Template.Functions as X hiding (_lookupNByKey, lookupNByKey, lookupAllByKey)
#else
import DA.Internal.Template.Functions as X hiding (_lookupNByKey)
#endif
import DA.Internal.Compatible as X
import DA.Internal.Assert as X
import DA.Internal.Interface as X
Expand Down
Loading
Loading