From 028dfcf6d4384fa333115f75d702b2cc69d1afb8 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Sat, 9 Nov 2019 19:00:00 +0100 Subject: [PATCH] Expose projection from contract key to maintainers (#3396) --- WORKSPACE | 6 +++--- compiler/damlc/daml-stdlib-src/DA/Internal/Template.daml | 2 ++ compiler/damlc/tests/daml-test-files/ContractKeys.daml | 2 ++ compiler/damlc/tests/daml-test-files/ProposalDesugared.daml | 1 + ghc-lib/template-desugaring.md | 1 + unreleased.rst | 1 + 6 files changed, 10 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index eadb6ff1fa..3297606d1e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -481,12 +481,12 @@ GRPC_HASKELL_COMMIT = "11681ec6b99add18a8d1315f202634aea343d146" GRPC_HASKELL_HASH = "c6201f4e2fd39f25ca1d47b1dac4efdf151de88a2eb58254d61abc2760e58fda" -GHC_LIB_VERSION = "8.8.1.20191015" +GHC_LIB_VERSION = "8.8.1.20191108" http_archive( name = "haskell_ghc__lib__parser", build_file = "//3rdparty/haskell:BUILD.ghc-lib-parser", - sha256 = "1f86522a1c554839fa5a5c1a0bc0462c055fb93c925f912689bc7af24c7118c1", + sha256 = "1954f2170bb789341359e91b957875664ba175d83aaa96bea036e5cb946aae70", strip_prefix = "ghc-lib-parser-{}".format(GHC_LIB_VERSION), urls = ["https://digitalassetsdk.bintray.com/ghc-lib/ghc-lib-parser-{}.tar.gz".format(GHC_LIB_VERSION)], ) @@ -568,7 +568,7 @@ hazel_repositories( # Read [Working on ghc-lib] for ghc-lib update instructions at # https://github.com/digital-asset/daml/blob/master/ghc-lib/working-on-ghc-lib.md. - hazel_ghclibs(GHC_LIB_VERSION, "0000000000000000000000000000000000000000000000000000000000000000", "237246bf2b473f370470fa7949582ba381884979876535573b9212cf4dd0b856") + + hazel_ghclibs(GHC_LIB_VERSION, "0000000000000000000000000000000000000000000000000000000000000000", "2982c8f85c25df382dd35247ccf94abb783434817a3e258b900bf01578bd772b") + hazel_github_external("digital-asset", "hlint", "951fdb6d28d7eed8ea1c7f3be69da29b61fcbe8f", "f5fb4cf98cde3ecf1209857208369a63ba21b04313d570c41dffe9f9139a1d34") + hazel_github_external("awakesecurity", "proto3-wire", "4f355bbac895d577d8a28f567ab4380f042ccc24", "031e05d523a887fbc546096618bc11dceabae224462a6cdd6aab11c1658e17a3") + hazel_github_external( diff --git a/compiler/damlc/daml-stdlib-src/DA/Internal/Template.daml b/compiler/damlc/daml-stdlib-src/DA/Internal/Template.daml index 9823a1a0f5..88fd7bab50 100644 --- a/compiler/damlc/daml-stdlib-src/DA/Internal/Template.daml +++ b/compiler/damlc/daml-stdlib-src/DA/Internal/Template.daml @@ -98,6 +98,8 @@ class Template t => TemplateKey t k | t -> k where -- stakeholders of the fetched contract are, which requires -- getting the contract instance. + -- | The list of maintainers of a contract key. + maintainer : k -> [Party] -- | Exercise a choice on the contract associated with the given key. -- diff --git a/compiler/damlc/tests/daml-test-files/ContractKeys.daml b/compiler/damlc/tests/daml-test-files/ContractKeys.daml index cb90fb8432..e81d8cc54f 100644 --- a/compiler/damlc/tests/daml-test-files/ContractKeys.daml +++ b/compiler/damlc/tests/daml-test-files/ContractKeys.daml @@ -45,3 +45,5 @@ test = scenario do fetchByKey accountKey accountCid' === accountCid account' === account + + maintainer @Account accountKey === [bank] diff --git a/compiler/damlc/tests/daml-test-files/ProposalDesugared.daml b/compiler/damlc/tests/daml-test-files/ProposalDesugared.daml index 2c0c4e4903..7933981c7e 100644 --- a/compiler/damlc/tests/daml-test-files/ProposalDesugared.daml +++ b/compiler/damlc/tests/daml-test-files/ProposalDesugared.daml @@ -38,6 +38,7 @@ instance ProposalInstance t => TemplateKey (Proposal t) ([Party], Text) where key = _keyProposal fetchByKey = _fetchByKeyProposal lookupByKey = _lookupByKeyProposal + maintainer = _maintainerProposal (_hasKeyProposal : HasKey (Proposal t)) data Accept = Accept{} deriving (Eq, Show) diff --git a/ghc-lib/template-desugaring.md b/ghc-lib/template-desugaring.md index 974c8f3703..440d0199f8 100644 --- a/ghc-lib/template-desugaring.md +++ b/ghc-lib/template-desugaring.md @@ -259,6 +259,7 @@ instance TemplateKey Enrollment Registration where key = _keyEnrollment fetchByKey = _fetchByKeyEnrollment lookupByKey = _lookupByKeyEnrollment + maintainer = _maintainerEnrollment (_hasKeyEnrollment : HasKey Enrollment) ``` ### Example (3) diff --git a/unreleased.rst b/unreleased.rst index ee3d5a7819..5babdd9552 100644 --- a/unreleased.rst +++ b/unreleased.rst @@ -25,3 +25,4 @@ HEAD — ongoing - [Sandbox] Add the option to start the sandbox with JWT based authentication. See `issue #3363 `__. - [Sandbox] Fixed a bug in the SQL backend that caused the database to be flooded with requests when streaming out transactions. - [Extractor - Experimental] Fix bug in reading TLS parameters. +- [DAML Stdlib] Add a ``maintainer`` function that will give you the list of maintainers of a contract key.