Deprecated

This Splice documentation site is deprecated. Use the current Canton Network docs.

Open current docs

Splice.TokenStandard.Utils.Internal.Choices

Internal modules defining utility functions for implementing token standard v2 choices.

Import ‘Splice.TokenStandard.Utils’ to get access to the public ones.

Functions

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.

require’

: (Show a, Show b) => (Text, a) -> (Text, a -> b -> Bool) -> (Text, b) -> Update ()

Improved variant of ‘require’ that checks a requirement and raises a user-friendly error in case the requirement is not met.

isEqualR

: Eq a => (Text, a -> a -> Bool)

Predicate to check equality.

isGreaterOrEqualR

: Ord a => (Text, a -> a -> Bool)

Predicate to check >=.

isGreaterR

: Ord a => (Text, a -> a -> Bool)

Predicate to check >.

isLessR

: Ord a => (Text, a -> a -> Bool)

Predicate to check <.

isLessOrEqualR

: Ord a => (Text, a -> a -> Bool)

Predicate to check <=.

isMemberR

: Ord a => (Text, a -> [a] -> Bool)

Predicate to check list membership.

isSubsetOfR

: Ord a => (Text, [a] -> [a] -> Bool)

Predicate to test that the list on the LHS is a subset of the list on the RHS.

isEqualSetR

: Ord a => (Text, [a] -> [a] -> Bool)

Predicate to check equality of two lists interpreted as sets, i.e., ignoring the order and count of elements.

oneOfR

: (Text, a -> b -> Bool) -> (Text, a -> [b] -> Bool)

Predicate combinator that requires the given predicate to be true for one of the elements on the RHS.

notR

: (Text, a -> b -> Bool) -> (Text, a -> b -> Bool)

requireMatchExpected

: (Eq a, Show a) => (Text, a) -> a -> Update ()

Abbreviation to check that an actual value matches its expected value.

requireUnique

: (Ord a, Show a) => Text -> [a] -> Update ()

Check that the elements in a list are unique, and raise a user-friendly message if not.

expectOneElement

: ActionFail m => Text -> (a -> Text) -> [a] -> m a

checkActor

: Party -> [Party] -> Update ()

Check that the actor is one of the allowed actors.

Useful for V1 implementations that use a single actor.

checkActors

: [Party] -> [[Party]] -> Update ()

Check that the actor is one of the allowed actors.

archiveAndCheckActors

: HasArchive i => ContractId i -> [Party] -> [[Party]] -> Update ()

Preamble for V2 choices that follow the actors pattern and are meant to consume the contract on which they are exercised.

SHOULD be used consistently as the first action in all non-factory V2 choices.

publicFetchDefaultImpl

: (HasInterfaceView i v, HasToInterface t i) => t -> ContractId i -> arg -> Update v

Default implementation for public fetch choices.

textMapSingleton

: Text -> a -> TextMap a

Create a text map with a single key-value pair.

textMapValues

: TextMap a -> [a]

Values of a text map.

textMapKeys

: TextMap a -> [Text]

Keys of a text map.

textMapUnionWith

: (a -> a -> a) -> TextMap a -> TextMap a -> TextMap a

Union of two text maps, using the provided function to resolve conflicts.

textMapMergeWithDefault

: (a, b) -> TextMap a -> TextMap b -> TextMap (a, b)

Merge two text maps, adding the default values for missing entries on either side.

textMapZip

: TextMap a -> TextMap b -> TextMap (Optional a, Optional b)

Zip two text maps together, keeping all keys from both maps.

textMapTraverseWithKey

: Applicative f => TextMap a -> (Text -> a -> f b) -> f (TextMap b)

Like Traversable.traverse but with access to the key of each element as well.

Comments