Skip to content

Commit

Permalink
Remove DA.Experimental.Interfaces (digital-asset#12619)
Browse files Browse the repository at this point in the history
The functions are available through typeclasses / typeclass instances
generated during desugaring. Moved the test over to use these, and
discovered a bug in our implementation of `observer`.

changelog_begin
changelog_end
  • Loading branch information
sofiafaro-da authored Jan 27, 2022
1 parent 5810c25 commit f5c9a67
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ convertPrim _ "ESignatoryInterface" (TCon interface :-> TList TParty) =

convertPrim _ "EObserverInterface" (TCon interface :-> TList TParty) =
ETmLam (mkVar "this", TCon interface) $
EExperimental "RESOLVE_VIRTUAL_OBSERVERS"
EExperimental "RESOLVE_VIRTUAL_OBSERVER"
(TCon interface :-> TCon interface :-> TList TParty)
`ETmApp` EVar (mkVar "this") `ETmApp` EVar (mkVar "this")

Expand Down
23 changes: 0 additions & 23 deletions compiler/damlc/daml-stdlib-src/DA/Experimental/Interface.daml

This file was deleted.

1 change: 0 additions & 1 deletion compiler/damlc/daml-stdlib-src/LibraryModules.daml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import DA.Validation

#ifdef DAML_EXPERIMENTAL
import DA.Experimental.Example
import DA.Experimental.Interface
#endif

import Prelude
105 changes: 0 additions & 105 deletions compiler/damlc/tests/daml-test-files/InterfaceExperimental.daml

This file was deleted.

41 changes: 41 additions & 0 deletions compiler/damlc/tests/daml-test-files/InterfaceFunctions.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

-- @SINCE-LF-FEATURE DAML_INTERFACE
-- | Check that `create`, `signatory`, `observer`, `interfaceTypeRep` work as expected on interface payloads.
module InterfaceFunctions where

import DA.Assert ((===))

interface Token where
getAmount : Int

template Asset
with
issuer : Party
owner : Party
amount : Int
where
signatory issuer
observer issuer, owner
implements Token where
let getAmount = amount

main = scenario do
alice <- getParty "Alice"
bob <- getParty "Bob"
let asset = Asset alice bob 15
let token = toInterface @Token asset
fromInterface token === Some asset
getAmount token === 15
submit alice do
cid <- create token
token' <- fetch cid
fromInterface token' === Some asset
getAmount token' === 15
signatory token === [alice]
observer token === [bob, alice]
assert (TemplateTypeRep (interfaceTypeRep token) == templateTypeRep @Asset)
assert (TemplateTypeRep (interfaceTypeRep token) /= templateTypeRep @Token)

-- @ENABLE-SCENARIOS

0 comments on commit f5c9a67

Please sign in to comment.