-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove ExercisedEvent in Event oneof.
The Event message is only used in the Transaction message. Flat transactions do not contain exercised events, but only created and archived events. Therefore we can remove the ExercisedEvent from the Event oneof, without breaking transport compatibility. HOWEVER: The Java Bindings used the data.Event class for both flat transactions and transaction trees. To properly represent the actual event types in the two transaction structures, I added two new interfaces FlatEvent and TreeEvent for flat transactions and transaction trees respectively. Some "pathological" cases where an occurrence of an exercised event would have resulted only in an exception, are now removed (see change in LedgerApiV1.scala). Fixes #960.
- Loading branch information
Showing
27 changed files
with
190 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
language-support/java/bindings/src/main/java/com/daml/ledger/javaapi/data/FlatEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.ledger.javaapi.data; | ||
|
||
import com.digitalasset.ledger.api.v1.EventOuterClass; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* This interface represents events in {@link Transaction}s. | ||
* | ||
* @see CreatedEvent | ||
* @see ArchivedEvent | ||
* | ||
*/ | ||
public interface FlatEvent { | ||
|
||
@NonNull List<@NonNull String> getWitnessParties(); | ||
|
||
@NonNull String getEventId(); | ||
|
||
@NonNull Identifier getTemplateId(); | ||
|
||
@NonNull String getContractId(); | ||
|
||
default EventOuterClass.Event toProtoEvent() { | ||
EventOuterClass.Event.Builder eventBuilder = EventOuterClass.Event.newBuilder(); | ||
if (this instanceof ArchivedEvent) { | ||
ArchivedEvent event = (ArchivedEvent) this; | ||
eventBuilder.setArchived(event.toProto()); | ||
} else if (this instanceof CreatedEvent) { | ||
CreatedEvent event = (CreatedEvent) this; | ||
eventBuilder.setCreated(event.toProto()); | ||
} else { | ||
throw new RuntimeException("this should be ArchivedEvent or CreatedEvent or ExercisedEvent, found " + this.toString()); | ||
} | ||
return eventBuilder.build(); | ||
} | ||
|
||
static FlatEvent fromProtoEvent(EventOuterClass.Event event) { | ||
if (event.hasCreated()) { | ||
return CreatedEvent.fromProto(event.getCreated()); | ||
} else if (event.hasArchived()) { | ||
return ArchivedEvent.fromProto(event.getArchived()); | ||
} else { | ||
throw new UnsupportedEventTypeException(event.toString()); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.