Utility functions shared across all splice apps.Documentation Index
Fetch the complete documentation index at: https://docs.canton.network/llms.txt
Use this file to discover all available pages before exploring further.
Typeclasses
Contracts typically come in groups. For example, all contracts managed by a specific DSO party. We aim to always fetch with a specific contract group identifier to ensure that we do not mixup contracts from different groups. Note that we are not requiringHasFetchhere, so that we can use this typeclass also for contract groups that are not templates, e.g., interface views.contractGroupId : t -> cgid
class Patchable a where
A type class for patching values. Used in particular for changing only a subset of fields in a config value.patch : a -> a -> a -> aFor records,instance Patchable Decimal instance Patchable Int instance Patchable Text instance (Ord k, Patchable v) => Patchable (Map k v) instance Patchable Party instance Patchable Time instance Patchable a => Patchable (Optional a) instance (Patchable a, Ord a) => Patchable (Set a) instance Patchable RelTimepatch new base currentshould set all fields incurrentto their value innewiff their value was changed innewcompared tobase. For other kinds of values that have field-like values (e.g. Maps with keys) the implementation should match the one for records by analogy.
Functions
requireMatchingContract
: (Eq t, Show t, HasFetch t) => ContractId t -> t -> Update ()Require that a contract-id refers to a specific contract.
require
: CanAssert m => Text -> Bool -> m ()Check whether a required condition is true. If it’s not, abort the transaction with a message saying that the requirement was not met.
fetchChecked
: (HasFetch t, HasCheckedFetch t cgid) => cgid -> ContractId t -> Update tFetch a contract that is part of a specific contract group.The group is typically chosen by the caller to match its own group, or a more specific group.
fetchCheckedInterface
: (HasFetch i, HasInterfaceView i v, HasCheckedFetch v cgid) => cgid -> ContractId i -> Update iFetch a contract that is part of a specific contract group defined by its interface view.The group is typically chosen by the caller to match its own group, or a more specific group.
fetchAndArchive
: (HasFetch t, HasCheckedFetch t cgid, HasArchive t) => cgid -> ContractId t -> Update tFetch and archive a contract in one go.Use this when implementing choices that mutate another contract by fetching, archiving, and then creating the updated contract.
fetchReferenceData
: (HasFetch t, HasCheckedFetch t cgid) => cgid -> ContractId t -> Update tFetch a contract that serves as reference data.Use this whenever you need to fetch a contract that you do not intend to mutate.
fetchButArchiveLater
: (HasFetch t, HasCheckedFetch t cgid) => cgid -> ContractId t -> Update tFetch a contract that is not reference data, and should be archived later in some cases.Prefer
fetchAndArchive over this function, as it avoids forgetting to archive the contract.fetchPublicReferenceData
: (HasCheckedFetch t cgid, HasExercise t ch t) => cgid -> ContractId t -> ch -> Update tFetch a contract that offers a choice anybody to be read as reference data.
fetchUncheckedAndArchive
: (HasFetch b, HasArchive b) => ContractId b -> Update bFetch and archive a contract in one go.Use this when implementing choices that mutate another contract by fetching, archiving, and then creating the updated contract.
fetchUncheckedReferenceData
: HasFetch t => ContractId t -> Update tFetch a contract that serves as reference data.Use this whenever you need to fetch a contract that you do not intend to mutate.
fetchUncheckedButArchiveLater
: HasFetch t => ContractId t -> Update tFetch a contract that is not reference data, and should be archived later in some cases.Prefer
fetchAndArchive over this function, as it avoids forgetting to archive the contract.potentiallyUnsafeArchive
: HasArchive t => ContractId t -> Update ()A more appropriately named version of
archive.Please justify all its uses, and where possible prefer fetchAndArchive so that the contract group identifier is surely performed.patchScalar
: Eq a => a -> a -> a -> a
patchListAsScalar
: Eq a => [a] -> [a] -> [a] -> [a]
patchListAsSet
: (Patchable a, Ord a) => [a] -> [a] -> [a] -> [a]