interfaces: Add to/from_interface in proto (#10937)

* interfaces: Add to/from_interface in proto

Part of #10810

changelog_begin
changelog_end

* fix typo
This commit is contained in:
Sofia Faro 2021-09-20 14:44:00 +01:00 committed by GitHub
parent 02c8a9dfb8
commit 409c0b4f60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View File

@ -636,6 +636,10 @@ decodeExprSum exprSum = mayDecode "exprSum" exprSum $ \case
<$> mayDecode "expr_ThrowReturnType" expr_ThrowReturnType decodeType
<*> mayDecode "expr_ThrowExceptionType" expr_ThrowExceptionType decodeType
<*> mayDecode "expr_ThrowExceptionExpr" expr_ThrowExceptionExpr decodeExpr
LF1.ExprSumToInterface _ -> -- TODO https://github.com/digital-asset/daml/issues/10810
error "to_interface not yet implemented"
LF1.ExprSumFromInterface _ -> -- TODO https://github.com/digital-asset/daml/issues/10810
error "from_interface not yet implemented"
LF1.ExprSumExperimental (LF1.Expr_Experimental name mbType) -> do
ty <- mayDecode "expr_Experimental" mbType decodeType
pure $ EExperimental (decodeString name) ty

View File

@ -911,6 +911,22 @@ message Expr {
Expr exception_expr = 3;
}
// Convert a template payload to an interface.
// *Available in versions >= 1.dev*
message ToInterface {
TypeConName interface_type = 1;
TypeConName template_type = 2;
Expr template_expr = 3;
}
// Convert an interface back to a template payload if possible.
// *Available in versions >= 1.dev*
message FromInterface {
TypeConName interface_type = 1;
TypeConName template_type = 2;
Expr interface_expr = 3;
}
message Experimental {
string name = 1;
Type type = 2 ;
@ -1024,6 +1040,11 @@ message Expr {
// *Available in versions >= 1.14*
Throw throw = 35;
// Convert to/from interface payloads.
// *Available in versions >= 1.dev*
ToInterface to_interface = 36;
FromInterface from_interface = 37;
Experimental experimental = 9999; // *Available only in 1.dev*
}

View File

@ -1098,6 +1098,12 @@ private[archive] class DecodeV1(minor: LV.Minor) {
value = decodeExpr(fromAnyException.getExpr, definition),
)
case PLF.Expr.SumCase.TO_INTERFACE => // TODO https://github.com/digital-asset/daml/issues/10810
throw Error.Parsing("to_interface not yet implemented")
case PLF.Expr.SumCase.FROM_INTERFACE => // TODO https://github.com/digital-asset/daml/issues/10810
throw Error.Parsing("from_interface not yet implemented")
case PLF.Expr.SumCase.SUM_NOT_SET =>
throw Error.Parsing("Expr.SUM_NOT_SET")