mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
Remove overloaded methods in command client (#15519)
* Remove overloaded methods in CommandClient * Remove overloaded methods in CommandClient * Revert destructive changes to command client * Add config for command client methods * Add stubs for new submit methods in CommandClient * Formatting * create() should be static * Add sample deprecation * params on builder methods don't need to be optional. Add some javadoc notes * Add tests for submitAndWait * Add tests for submitAndWait * Add implementation for submitAndWaitFor* methods * Update tests * Refactor CommandSubmissionClient * Deprecate overloaded methods in CommandClient * Update deprecated method use * Lint * Cleanup deprecated use * Update required params * CommandClientConfig -> CommandsBuilder * Formatting * Rename CommandsBuilder -> CommandsSubmission * Delete deprecated tests * Rename withParty(String) -> withActAs(String) * Formatting * Refactor SubmitRequest.java * Refactor SubmitRequest.java * Refactor SubmitAndWaitRequest and SubmitCommandsRequest * Move CommandsSubmission to the java-bindings package and refactor dependencies accordingly * todos for horrible casting * Update language-support/java/bindings-rxjava/src/test/scala/com/daml/ledger/rxjava/grpc/CommandClientImplTest.scala Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com> * make CommandsSubmission final * e.t.c -> etc * Remove use of singleton list for actAs * Return unmodifiable lists in CommandsSubmission * Cleanup SubmitCommandsRequest * Formatting * Update tests for SubmitCommandsRequest * PR comments * Use toCommands() in HasCommands * Reorder constructor params * Rename params and commandsSubmission -> submission * Cleanup docs * Update docs * Update docs * Cleanup test util Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
This commit is contained in:
parent
cbebd8675b
commit
448c184258
@ -580,21 +580,21 @@ It consists of the application in file ``IouMain.java``. It uses the class ``Iou
|
||||
|
||||
.. literalinclude:: quickstart/template-root/src/main/java/com/daml/quickstart/iou/IouMain.java
|
||||
:language: java
|
||||
:lines: 42-47
|
||||
:lines: 46-49
|
||||
:dedent: 4
|
||||
|
||||
#. An in-memory contract store is initialized. This is intended to provide a live view of all active contracts, with mappings between ledger and external Ids.
|
||||
|
||||
.. literalinclude:: quickstart/template-root/src/main/java/com/daml/quickstart/iou/IouMain.java
|
||||
:language: java
|
||||
:lines: 53-56
|
||||
:lines: 56-59
|
||||
:dedent: 4
|
||||
|
||||
#. The Active Contracts Service (ACS) is used to quickly build up the contract store to a recent state.
|
||||
|
||||
.. literalinclude:: quickstart/template-root/src/main/java/com/daml/quickstart/iou/IouMain.java
|
||||
:language: java
|
||||
:lines: 58-70
|
||||
:lines: 61-73
|
||||
:dedent: 4
|
||||
|
||||
``blockingForEach`` is used to ensure that the contract store is consistent with the ledger state at the latest offset observed by the client.
|
||||
@ -604,14 +604,14 @@ It consists of the application in file ``IouMain.java``. It uses the class ``Iou
|
||||
|
||||
.. literalinclude:: quickstart/template-root/src/main/java/com/daml/quickstart/iou/IouMain.java
|
||||
:language: java
|
||||
:lines: 73-94
|
||||
:lines: 76-97
|
||||
:dedent: 4
|
||||
|
||||
#. Commands are submitted via the Command Submission Service.
|
||||
|
||||
.. literalinclude:: quickstart/template-root/src/main/java/com/daml/quickstart/iou/IouMain.java
|
||||
:language: java
|
||||
:lines: 134-143
|
||||
:lines: 137-141
|
||||
:dedent: 2
|
||||
|
||||
You can find examples of ``Update`` instantiations for creating contract and exercising a choice in the bodies of the ``transfer`` and ``iou`` endpoints, respectively.
|
||||
@ -619,13 +619,13 @@ It consists of the application in file ``IouMain.java``. It uses the class ``Iou
|
||||
.. literalinclude:: quickstart/template-root/src/main/java/com/daml/quickstart/iou/IouMain.java
|
||||
:caption: Exercise a choice
|
||||
:language: java
|
||||
:lines: 118-120
|
||||
:lines: 119-121
|
||||
:dedent: 10
|
||||
|
||||
.. literalinclude:: quickstart/template-root/src/main/java/com/daml/quickstart/iou/IouMain.java
|
||||
:caption: Create a contract
|
||||
:language: java
|
||||
:lines: 107-109
|
||||
:lines: 109-111
|
||||
:dedent: 10
|
||||
|
||||
The rest of the application sets up the REST services using `Spark Java <http://sparkjava.com/>`_, and does dynamic package Id detection using the Package Service. The latter is useful during development when package Ids change frequently.
|
||||
|
@ -3,7 +3,10 @@
|
||||
|
||||
package com.daml.quickstart.iou;
|
||||
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
import com.daml.ledger.javaapi.data.*;
|
||||
import com.daml.ledger.javaapi.data.CommandsSubmission;
|
||||
import com.daml.ledger.javaapi.data.codegen.Update;
|
||||
import com.daml.ledger.rxjava.DamlLedgerClient;
|
||||
import com.daml.ledger.rxjava.LedgerClient;
|
||||
@ -131,15 +134,10 @@ public class IouMain {
|
||||
}
|
||||
|
||||
private static <U> U submit(LedgerClient client, String party, Update<U> update) {
|
||||
return client
|
||||
.getCommandClient()
|
||||
.submitAndWaitForResult(
|
||||
UUID.randomUUID().toString(),
|
||||
"IouApp",
|
||||
UUID.randomUUID().toString(),
|
||||
List.of(party),
|
||||
List.of(),
|
||||
update)
|
||||
.blockingGet();
|
||||
var params =
|
||||
CommandsSubmission.create(APP_ID, randomUUID().toString(), update.commands())
|
||||
.withActAs(party);
|
||||
|
||||
return client.getCommandClient().submitAndWaitForResult(params, update).blockingGet();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
package com.daml.ledger.rxjava;
|
||||
|
||||
import com.daml.ledger.javaapi.data.CommandsSubmission;
|
||||
import com.daml.ledger.javaapi.data.Transaction;
|
||||
import com.daml.ledger.javaapi.data.TransactionTree;
|
||||
import com.daml.ledger.javaapi.data.codegen.HasCommands;
|
||||
@ -17,7 +18,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/** An RxJava version of {@link com.daml.ledger.api.v1.CommandServiceGrpc} */
|
||||
public interface CommandClient {
|
||||
Single<Empty> submitAndWait(CommandsSubmission submission);
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #submitAndWait(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -28,6 +32,8 @@ public interface CommandClient {
|
||||
@NonNull Optional<Duration> deduplicationTime,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/** @deprecated since 2.5. Use {@link #submitAndWait(CommandsSubmission)} instead. */
|
||||
@Deprecated
|
||||
Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -39,6 +45,8 @@ public interface CommandClient {
|
||||
@NonNull Optional<Duration> deduplicationTime,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/** @deprecated since 2.5. Use {@link #submitAndWait(CommandsSubmission)} instead. */
|
||||
@Deprecated
|
||||
Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -50,6 +58,8 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #submitAndWait(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -62,6 +72,8 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #submitAndWait(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -69,6 +81,8 @@ public interface CommandClient {
|
||||
@NonNull String party,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #submitAndWait(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -77,6 +91,8 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull String> readAs,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #submitAndWait(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -85,6 +101,8 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #submitAndWait(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -94,6 +112,13 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
Single<String> submitAndWaitForTransactionId(CommandsSubmission submission);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionId(CommandsSubmission)}
|
||||
* (CommandsSubmission)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -104,6 +129,11 @@ public interface CommandClient {
|
||||
@NonNull Optional<Duration> deduplicationTime,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionId(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -115,6 +145,11 @@ public interface CommandClient {
|
||||
@NonNull Optional<Duration> deduplicationTime,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionId(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -126,6 +161,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionId(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -138,6 +178,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionId(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -145,6 +190,11 @@ public interface CommandClient {
|
||||
@NonNull String party,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionId(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -153,6 +203,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull String> readAs,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionId(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -161,6 +216,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionId(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -170,6 +230,13 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
Single<Transaction> submitAndWaitForTransaction(CommandsSubmission submission);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransaction(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -180,6 +247,11 @@ public interface CommandClient {
|
||||
@NonNull Optional<Duration> deduplicationTime,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransaction(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -191,6 +263,11 @@ public interface CommandClient {
|
||||
@NonNull Optional<Duration> deduplicationTime,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransaction(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -202,6 +279,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransaction(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -214,6 +296,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransaction(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -221,6 +308,11 @@ public interface CommandClient {
|
||||
@NonNull String party,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransaction(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -229,6 +321,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull String> readAs,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransaction(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -237,6 +334,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransaction(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -246,6 +348,13 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
Single<TransactionTree> submitAndWaitForTransactionTree(CommandsSubmission submission);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionTree(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -256,6 +365,11 @@ public interface CommandClient {
|
||||
@NonNull Optional<Duration> deduplicationTime,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionTree(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -267,6 +381,11 @@ public interface CommandClient {
|
||||
@NonNull Optional<Duration> deduplicationTime,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionTree(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -278,6 +397,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionTree(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -290,6 +414,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionTree(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -297,6 +426,11 @@ public interface CommandClient {
|
||||
@NonNull String party,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionTree(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -305,6 +439,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull String> readAs,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionTree(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -313,6 +452,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForTransactionTree(CommandsSubmission)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -322,6 +466,13 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
<U> Single<U> submitAndWaitForResult(CommandsSubmission submission, @NonNull Update<U> update);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForResult(CommandsSubmission, Update)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
<U> Single<U> submitAndWaitForResult(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -330,6 +481,11 @@ public interface CommandClient {
|
||||
@NonNull List<@NonNull String> readAs,
|
||||
@NonNull Update<U> update);
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5. Please use {@link #submitAndWaitForResult(CommandsSubmission, Update)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
<U> Single<U> submitAndWaitForResult(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
package com.daml.ledger.rxjava;
|
||||
|
||||
import com.daml.ledger.javaapi.data.CommandsSubmission;
|
||||
import com.daml.ledger.javaapi.data.codegen.HasCommands;
|
||||
import com.google.protobuf.Empty;
|
||||
import io.reactivex.Single;
|
||||
@ -15,6 +16,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
/** An RxJava version of {@link com.daml.ledger.api.v1.CommandSubmissionServiceGrpc} */
|
||||
public interface CommandSubmissionClient {
|
||||
|
||||
Single<Empty> submit(CommandsSubmission submission);
|
||||
|
||||
/** @deprecated since 2.5. PLease use {@link #submit(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -25,6 +30,8 @@ public interface CommandSubmissionClient {
|
||||
@NonNull Optional<Duration> deduplicationTime,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/** @deprecated since 2.5. PLease use {@link #submit(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -36,6 +43,8 @@ public interface CommandSubmissionClient {
|
||||
@NonNull Optional<Duration> deduplicationTime,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/** @deprecated since 2.5. PLease use {@link #submit(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -47,6 +56,8 @@ public interface CommandSubmissionClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/** @deprecated since 2.5. PLease use {@link #submit(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -59,6 +70,8 @@ public interface CommandSubmissionClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/** @deprecated since 2.5. PLease use {@link #submit(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -66,6 +79,8 @@ public interface CommandSubmissionClient {
|
||||
@NonNull String party,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/** @deprecated since 2.5. PLease use {@link #submit(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -74,6 +89,8 @@ public interface CommandSubmissionClient {
|
||||
@NonNull List<@NonNull String> readAs,
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands);
|
||||
|
||||
/** @deprecated since 2.5. PLease use {@link #submit(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -82,6 +99,8 @@ public interface CommandSubmissionClient {
|
||||
@NonNull List<@NonNull ? extends HasCommands> commands,
|
||||
@NonNull String accessToken);
|
||||
|
||||
/** @deprecated since 2.5. PLease use {@link #submit(CommandsSubmission)} instead */
|
||||
@Deprecated
|
||||
Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
|
@ -38,6 +38,17 @@ public class CommandClientImpl implements CommandClient {
|
||||
StubHelper.authenticating(CommandServiceGrpc.newFutureStub(channel), accessToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<Empty> submitAndWait(CommandsSubmission submission) {
|
||||
CommandServiceOuterClass.SubmitAndWaitRequest request =
|
||||
SubmitAndWaitRequest.toProto(this.ledgerId, submission);
|
||||
|
||||
return Single.fromFuture(
|
||||
StubHelper.authenticating(this.serviceStub, submission.getAccessToken())
|
||||
.submitAndWait(request));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -65,6 +76,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
StubHelper.authenticating(this.serviceStub, accessToken).submitAndWait(request));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@ -88,6 +100,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@ -112,6 +125,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@ -136,6 +150,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@ -161,6 +176,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@ -181,6 +197,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@ -202,6 +219,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@ -223,6 +241,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submitAndWait(
|
||||
@NonNull String workflowId,
|
||||
@ -245,6 +264,17 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<String> submitAndWaitForTransactionId(CommandsSubmission submission) {
|
||||
CommandServiceOuterClass.SubmitAndWaitRequest request =
|
||||
SubmitAndWaitRequest.toProto(this.ledgerId, submission);
|
||||
return Single.fromFuture(
|
||||
StubHelper.authenticating(this.serviceStub, submission.getAccessToken())
|
||||
.submitAndWaitForTransactionId(request))
|
||||
.map(CommandServiceOuterClass.SubmitAndWaitForTransactionIdResponse::getTransactionId);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -274,6 +304,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
.map(CommandServiceOuterClass.SubmitAndWaitForTransactionIdResponse::getTransactionId);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@ -297,6 +328,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@ -321,6 +353,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@ -345,6 +378,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@ -370,6 +404,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@ -390,6 +425,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@ -411,6 +447,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@ -432,6 +469,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<String> submitAndWaitForTransactionId(
|
||||
@NonNull String workflowId,
|
||||
@ -454,6 +492,19 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<Transaction> submitAndWaitForTransaction(CommandsSubmission submission) {
|
||||
CommandServiceOuterClass.SubmitAndWaitRequest request =
|
||||
SubmitAndWaitRequest.toProto(this.ledgerId, submission);
|
||||
|
||||
return Single.fromFuture(
|
||||
StubHelper.authenticating(this.serviceStub, submission.getAccessToken())
|
||||
.submitAndWaitForTransaction(request))
|
||||
.map(CommandServiceOuterClass.SubmitAndWaitForTransactionResponse::getTransaction)
|
||||
.map(Transaction::fromProto);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -484,6 +535,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
.map(Transaction::fromProto);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@ -507,6 +559,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@ -531,6 +584,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@ -555,6 +609,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@ -580,6 +635,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@ -600,6 +656,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@ -621,6 +678,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@ -642,6 +700,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Transaction> submitAndWaitForTransaction(
|
||||
@NonNull String workflowId,
|
||||
@ -664,6 +723,19 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<TransactionTree> submitAndWaitForTransactionTree(CommandsSubmission submission) {
|
||||
CommandServiceOuterClass.SubmitAndWaitRequest request =
|
||||
SubmitAndWaitRequest.toProto(this.ledgerId, submission);
|
||||
|
||||
return Single.fromFuture(
|
||||
StubHelper.authenticating(this.serviceStub, submission.getAccessToken())
|
||||
.submitAndWaitForTransactionTree(request))
|
||||
.map(CommandServiceOuterClass.SubmitAndWaitForTransactionTreeResponse::getTransaction)
|
||||
.map(TransactionTree::fromProto);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -694,6 +766,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
.map(TransactionTree::fromProto);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@ -717,6 +790,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@ -741,6 +815,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@ -765,6 +840,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@ -790,6 +866,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@ -810,6 +887,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@ -831,6 +909,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@ -852,6 +931,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<TransactionTree> submitAndWaitForTransactionTree(
|
||||
@NonNull String workflowId,
|
||||
@ -874,6 +954,35 @@ public class CommandClientImpl implements CommandClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <U> Single<U> submitAndWaitForResult(
|
||||
CommandsSubmission submission, @NonNull Update<U> update) {
|
||||
return update.foldUpdate(
|
||||
new Update.FoldUpdate<>() {
|
||||
@Override
|
||||
public <CtId> Single<U> created(Update.CreateUpdate<CtId, U> create) {
|
||||
var transaction = submitAndWaitForTransaction(submission);
|
||||
return transaction.map(
|
||||
tx -> {
|
||||
var createdEvent = singleCreatedEvent(tx.getEvents());
|
||||
return create.k.apply(Created.fromEvent(create.createdContractId, createdEvent));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> Single<U> exercised(Update.ExerciseUpdate<R, U> exercise) {
|
||||
var transactionTree = submitAndWaitForTransactionTree(submission);
|
||||
return transactionTree.map(
|
||||
txTree -> {
|
||||
var exercisedEvent = firstExercisedEvent(txTree);
|
||||
return exercise.k.apply(
|
||||
Exercised.fromEvent(exercise.returnTypeDecoder, exercisedEvent));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private <U> Single<U> submitAndWaitForResult(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@ -929,6 +1038,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <U> Single<U> submitAndWaitForResult(
|
||||
@NonNull String workflowId,
|
||||
@ -941,6 +1051,7 @@ public class CommandClientImpl implements CommandClient {
|
||||
workflowId, applicationId, commandId, actAs, readAs, update, Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <U> Single<U> submitAndWaitForResult(
|
||||
@NonNull String workflowId,
|
||||
|
@ -9,6 +9,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
import com.daml.ledger.api.v1.CommandSubmissionServiceGrpc;
|
||||
import com.daml.ledger.api.v1.CommandSubmissionServiceOuterClass;
|
||||
import com.daml.ledger.javaapi.data.CommandsSubmission;
|
||||
import com.daml.ledger.javaapi.data.SubmitRequest;
|
||||
import com.daml.ledger.javaapi.data.codegen.HasCommands;
|
||||
import com.daml.ledger.rxjava.CommandSubmissionClient;
|
||||
@ -39,7 +40,20 @@ public class CommandSubmissionClientImpl implements CommandSubmissionClient {
|
||||
StubHelper.authenticating(CommandSubmissionServiceGrpc.newFutureStub(channel), accessToken);
|
||||
}
|
||||
|
||||
public Single<com.google.protobuf.Empty> submit(
|
||||
@Override
|
||||
public Single<Empty> submit(CommandsSubmission submission) {
|
||||
CommandSubmissionServiceOuterClass.SubmitRequest request =
|
||||
SubmitRequest.toProto(ledgerId, submission);
|
||||
CommandSubmissionServiceGrpc.CommandSubmissionServiceFutureStub stubWithTimeout =
|
||||
this.timeout
|
||||
.map(t -> this.serviceStub.withDeadlineAfter(t.toMillis(), MILLISECONDS))
|
||||
.orElse(this.serviceStub);
|
||||
return Single.fromFuture(
|
||||
StubHelper.authenticating(stubWithTimeout, submission.getAccessToken()).submit(request));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@NonNull String commandId,
|
||||
@ -70,7 +84,8 @@ public class CommandSubmissionClientImpl implements CommandSubmissionClient {
|
||||
StubHelper.authenticating(stubWithTimeout, accessToken).submit(request));
|
||||
}
|
||||
|
||||
public Single<com.google.protobuf.Empty> submit(
|
||||
@Deprecated
|
||||
public Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@NonNull String commandId,
|
||||
@ -93,8 +108,9 @@ public class CommandSubmissionClientImpl implements CommandSubmissionClient {
|
||||
accessToken);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<com.google.protobuf.Empty> submit(
|
||||
public Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@NonNull String commandId,
|
||||
@ -112,6 +128,7 @@ public class CommandSubmissionClientImpl implements CommandSubmissionClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@ -133,8 +150,9 @@ public class CommandSubmissionClientImpl implements CommandSubmissionClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<com.google.protobuf.Empty> submit(
|
||||
public Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@NonNull String applicationId,
|
||||
@NonNull String commandId,
|
||||
@ -156,6 +174,7 @@ public class CommandSubmissionClientImpl implements CommandSubmissionClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@ -181,6 +200,7 @@ public class CommandSubmissionClientImpl implements CommandSubmissionClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@ -203,6 +223,7 @@ public class CommandSubmissionClientImpl implements CommandSubmissionClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@ -227,6 +248,7 @@ public class CommandSubmissionClientImpl implements CommandSubmissionClient {
|
||||
Optional.empty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
@ -247,6 +269,7 @@ public class CommandSubmissionClientImpl implements CommandSubmissionClient {
|
||||
Optional.of(accessToken));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Single<Empty> submit(
|
||||
@NonNull String workflowId,
|
||||
|
@ -5,10 +5,15 @@ package com.daml.ledger.rxjava
|
||||
|
||||
import java.time.Instant
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
import com.daml.ledger.javaapi.data.LedgerOffset.Absolute
|
||||
import com.daml.ledger.javaapi.data.{Command, CreateCommand, DamlRecord, Identifier}
|
||||
import com.daml.ledger.rxjava.grpc.helpers.{CommandServiceImpl, _}
|
||||
import com.daml.ledger.javaapi.data.{
|
||||
Command,
|
||||
CommandsSubmission,
|
||||
CreateCommand,
|
||||
DamlRecord,
|
||||
Identifier,
|
||||
}
|
||||
import com.daml.ledger.rxjava.grpc.helpers._
|
||||
import com.daml.ledger.api.auth.{AuthService, AuthServiceWildcard}
|
||||
import com.daml.ledger.api.v1.command_completion_service.CompletionStreamResponse
|
||||
import com.daml.ledger.api.v1.command_service.{
|
||||
@ -152,17 +157,16 @@ class DamlLedgerClientTest
|
||||
val record = new DamlRecord(recordId, List.empty[DamlRecord.Field].asJava)
|
||||
val command = new CreateCommand(new Identifier("a", "a", "b"), record)
|
||||
val commands = genCommands(List(command), Option(someParty))
|
||||
|
||||
val params = CommandsSubmission
|
||||
.create(commands.getApplicationId, commands.getCommandId, commands.getCommands)
|
||||
.withActAs(commands.getParty)
|
||||
.withMinLedgerTimeAbs(commands.getMinLedgerTimeAbsolute)
|
||||
.withMinLedgerTimeRel(commands.getMinLedgerTimeRelative)
|
||||
.withDeduplicationTime(commands.getDeduplicationTime)
|
||||
|
||||
commandClient
|
||||
.submitAndWait(
|
||||
commands.getWorkflowId,
|
||||
commands.getApplicationId,
|
||||
commands.getCommandId,
|
||||
commands.getParty,
|
||||
commands.getMinLedgerTimeAbsolute,
|
||||
commands.getMinLedgerTimeRelative,
|
||||
commands.getDeduplicationTime,
|
||||
commands.getCommands,
|
||||
)
|
||||
.submitAndWait(params)
|
||||
.timeout(1L, TimeUnit.SECONDS)
|
||||
.timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS)
|
||||
.blockingGet()
|
||||
@ -197,17 +201,16 @@ class DamlLedgerClientTest
|
||||
val record = new DamlRecord(recordId, List.empty[DamlRecord.Field].asJava)
|
||||
val command = new CreateCommand(new Identifier("a", "a", "b"), record)
|
||||
val commands = genCommands(List[Command](command), Option(someParty))
|
||||
|
||||
val params = CommandsSubmission
|
||||
.create(commands.getApplicationId, commands.getCommandId, commands.getCommands)
|
||||
.withActAs(commands.getParty)
|
||||
.withMinLedgerTimeAbs(commands.getMinLedgerTimeAbsolute)
|
||||
.withMinLedgerTimeRel(commands.getMinLedgerTimeRelative)
|
||||
.withDeduplicationTime(commands.getDeduplicationTime)
|
||||
|
||||
commandSubmissionClient
|
||||
.submit(
|
||||
commands.getWorkflowId,
|
||||
commands.getApplicationId,
|
||||
commands.getCommandId,
|
||||
commands.getParty,
|
||||
commands.getMinLedgerTimeAbsolute,
|
||||
commands.getMinLedgerTimeRelative,
|
||||
commands.getDeduplicationTime,
|
||||
commands.getCommands,
|
||||
)
|
||||
.submit(params)
|
||||
.timeout(1L, TimeUnit.SECONDS)
|
||||
.timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS)
|
||||
.blockingGet()
|
||||
|
@ -3,25 +3,30 @@
|
||||
|
||||
package com.daml.ledger.rxjava.grpc
|
||||
|
||||
import java.time.{Duration, Instant}
|
||||
import java.util.{Optional, UUID}
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
import com.daml.ledger.javaapi.data.{Command, CreateCommand, DamlRecord, Identifier}
|
||||
import com.daml.ledger.rxjava._
|
||||
import com.daml.ledger.rxjava.grpc.helpers.{DataLayerHelpers, LedgerServices, TestConfiguration}
|
||||
import com.daml.ledger.api.auth.{AuthService, AuthServiceWildcard}
|
||||
import com.daml.ledger.api.v1.command_service.{
|
||||
SubmitAndWaitForTransactionIdResponse,
|
||||
SubmitAndWaitForTransactionResponse,
|
||||
SubmitAndWaitForTransactionTreeResponse,
|
||||
}
|
||||
import com.daml.ledger.javaapi.data.{
|
||||
Command,
|
||||
CommandsSubmission,
|
||||
CreateCommand,
|
||||
DamlRecord,
|
||||
Identifier,
|
||||
}
|
||||
import com.daml.ledger.rxjava._
|
||||
import com.daml.ledger.rxjava.grpc.helpers.{DataLayerHelpers, LedgerServices, TestConfiguration}
|
||||
import com.google.protobuf.empty.Empty
|
||||
import io.reactivex.Single
|
||||
import org.scalatest.OptionValues
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
|
||||
import java.util.UUID.randomUUID
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.Optional
|
||||
import scala.concurrent.Future
|
||||
import scala.jdk.CollectionConverters._
|
||||
|
||||
@ -53,19 +58,18 @@ class CommandClientImplTest
|
||||
it should "send the given command to the Ledger" in {
|
||||
withCommandClient() { (client, service) =>
|
||||
val commands = genCommands(List.empty)
|
||||
val params = CommandsSubmission
|
||||
.create(commands.getApplicationId, commands.getCommandId, commands.getCommands)
|
||||
.withActAs(commands.getParty)
|
||||
.withMinLedgerTimeAbs(commands.getMinLedgerTimeAbsolute)
|
||||
.withMinLedgerTimeRel(commands.getMinLedgerTimeRelative)
|
||||
.withDeduplicationTime(commands.getDeduplicationTime)
|
||||
|
||||
client
|
||||
.submitAndWait(
|
||||
commands.getWorkflowId,
|
||||
commands.getApplicationId,
|
||||
commands.getCommandId,
|
||||
commands.getParty,
|
||||
commands.getMinLedgerTimeAbsolute,
|
||||
commands.getMinLedgerTimeRelative,
|
||||
commands.getDeduplicationTime,
|
||||
commands.getCommands,
|
||||
)
|
||||
.submitAndWait(params)
|
||||
.timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS)
|
||||
.blockingGet()
|
||||
|
||||
service.getLastRequest.value.getCommands.commands shouldBe empty
|
||||
}
|
||||
}
|
||||
@ -78,19 +82,20 @@ class CommandClientImplTest
|
||||
val record = new DamlRecord(recordId, List.empty[DamlRecord.Field].asJava)
|
||||
val command = new CreateCommand(new Identifier("a", "a", "b"), record)
|
||||
val commands = genCommands(List(command))
|
||||
|
||||
val params = CommandsSubmission
|
||||
.create(commands.getApplicationId, commands.getCommandId, commands.getCommands)
|
||||
.withWorkflowId(commands.getWorkflowId)
|
||||
.withActAs(commands.getParty)
|
||||
.withMinLedgerTimeAbs(commands.getMinLedgerTimeAbsolute)
|
||||
.withMinLedgerTimeRel(commands.getMinLedgerTimeRelative)
|
||||
.withDeduplicationTime(commands.getDeduplicationTime)
|
||||
|
||||
client
|
||||
.submitAndWait(
|
||||
commands.getWorkflowId,
|
||||
commands.getApplicationId,
|
||||
commands.getCommandId,
|
||||
commands.getParty,
|
||||
commands.getMinLedgerTimeAbsolute,
|
||||
commands.getMinLedgerTimeRelative,
|
||||
commands.getDeduplicationTime,
|
||||
commands.getCommands,
|
||||
)
|
||||
.submitAndWait(params)
|
||||
.timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS)
|
||||
.blockingGet()
|
||||
|
||||
service.getLastRequest.value.getCommands.applicationId shouldBe commands.getApplicationId
|
||||
service.getLastRequest.value.getCommands.commandId shouldBe commands.getCommandId
|
||||
service.getLastRequest.value.getCommands.party shouldBe commands.getParty
|
||||
@ -128,76 +133,34 @@ class CommandClientImplTest
|
||||
List(command).asJava
|
||||
}
|
||||
|
||||
private type SubmitAndWait[A] =
|
||||
(
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
Optional[Instant],
|
||||
Optional[Duration],
|
||||
Optional[Duration],
|
||||
java.util.List[Command],
|
||||
) => Single[A]
|
||||
private type SubmitAndWaitWithToken[A] =
|
||||
(
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
Optional[Instant],
|
||||
Optional[Duration],
|
||||
Optional[Duration],
|
||||
java.util.List[Command],
|
||||
String,
|
||||
) => Single[A]
|
||||
private type SubmitAndWait[A] = CommandsSubmission => Single[A]
|
||||
|
||||
private def submitAndWaitFor[A](
|
||||
noToken: SubmitAndWait[A],
|
||||
withToken: SubmitAndWaitWithToken[A],
|
||||
)(commands: java.util.List[Command], party: String, token: Option[String]): A =
|
||||
token
|
||||
.fold(
|
||||
noToken(
|
||||
UUID.randomUUID.toString,
|
||||
UUID.randomUUID.toString,
|
||||
UUID.randomUUID.toString,
|
||||
party,
|
||||
Optional.empty(),
|
||||
Optional.empty(),
|
||||
Optional.empty(),
|
||||
dummyCommands,
|
||||
)
|
||||
)(
|
||||
withToken(
|
||||
UUID.randomUUID.toString,
|
||||
UUID.randomUUID.toString,
|
||||
UUID.randomUUID.toString,
|
||||
party,
|
||||
Optional.empty(),
|
||||
Optional.empty(),
|
||||
Optional.empty(),
|
||||
commands,
|
||||
_,
|
||||
)
|
||||
submit: SubmitAndWait[A]
|
||||
)(commands: java.util.List[Command], party: String, token: Option[String]) = {
|
||||
val params = CommandsSubmission
|
||||
.create(
|
||||
randomUUID().toString,
|
||||
randomUUID().toString,
|
||||
token.fold(dummyCommands)(_ => commands),
|
||||
)
|
||||
.timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS)
|
||||
.blockingGet()
|
||||
.withActAs(party)
|
||||
.withAccessToken(Optional.ofNullable(token.orNull))
|
||||
|
||||
submit(params).timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS).blockingGet()
|
||||
}
|
||||
|
||||
private def submitAndWait(client: CommandClient) =
|
||||
submitAndWaitFor(client.submitAndWait, client.submitAndWait) _
|
||||
submitAndWaitFor(client.submitAndWait) _
|
||||
|
||||
private def submitAndWaitForTransaction(client: CommandClient) =
|
||||
submitAndWaitFor(client.submitAndWaitForTransaction, client.submitAndWaitForTransaction) _
|
||||
submitAndWaitFor(client.submitAndWaitForTransaction) _
|
||||
|
||||
private def submitAndWaitForTransactionId(client: CommandClient) =
|
||||
submitAndWaitFor(client.submitAndWaitForTransactionId, client.submitAndWaitForTransactionId) _
|
||||
submitAndWaitFor(client.submitAndWaitForTransactionId) _
|
||||
|
||||
private def submitAndWaitForTransactionTree(client: CommandClient) =
|
||||
submitAndWaitFor(
|
||||
client.submitAndWaitForTransactionTree,
|
||||
client.submitAndWaitForTransactionTree,
|
||||
) _
|
||||
submitAndWaitFor(client.submitAndWaitForTransactionTree) _
|
||||
|
||||
behavior of "Authorization"
|
||||
|
||||
|
@ -3,19 +3,24 @@
|
||||
|
||||
package com.daml.ledger.rxjava.grpc
|
||||
|
||||
import java.util.Optional
|
||||
import java.util.concurrent.TimeUnit
|
||||
import com.daml.ledger.javaapi.data.{Command, CreateCommand, DamlRecord, Identifier}
|
||||
import com.daml.ledger.javaapi.data.{
|
||||
Command,
|
||||
CommandsSubmission,
|
||||
CreateCommand,
|
||||
DamlRecord,
|
||||
Identifier,
|
||||
}
|
||||
import com.daml.ledger.rxjava._
|
||||
import com.daml.ledger.rxjava.grpc.helpers.{DataLayerHelpers, LedgerServices, TestConfiguration}
|
||||
import com.google.protobuf.empty.Empty
|
||||
|
||||
import org.scalatest.OptionValues
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
|
||||
import java.time.Duration
|
||||
import java.time.temporal.ChronoUnit
|
||||
import java.util.Optional
|
||||
import java.util.concurrent.TimeUnit
|
||||
import scala.concurrent.Future
|
||||
import scala.jdk.CollectionConverters._
|
||||
|
||||
@ -43,16 +48,17 @@ class CommandSubmissionClientImplTest
|
||||
) { (client, _) =>
|
||||
val commands = genCommands(List.empty)
|
||||
|
||||
val params = CommandsSubmission
|
||||
.create(commands.getApplicationId, commands.getCommandId, commands.getCommands)
|
||||
.withActAs(commands.getParty)
|
||||
.withMinLedgerTimeAbs(commands.getMinLedgerTimeAbsolute)
|
||||
.withMinLedgerTimeRel(commands.getMinLedgerTimeRelative)
|
||||
.withDeduplicationTime(commands.getDeduplicationTime)
|
||||
|
||||
withClue("The first command should be stuck") {
|
||||
expectDeadlineExceeded(
|
||||
client
|
||||
.submit(
|
||||
commands.getWorkflowId,
|
||||
commands.getApplicationId,
|
||||
commands.getCommandId,
|
||||
commands.getParty,
|
||||
commands.getCommands,
|
||||
)
|
||||
.submit(params)
|
||||
.timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS)
|
||||
.blockingGet()
|
||||
)
|
||||
@ -61,13 +67,7 @@ class CommandSubmissionClientImplTest
|
||||
withClue("The second command should go through") {
|
||||
val res = Option(
|
||||
client
|
||||
.submit(
|
||||
commands.getWorkflowId,
|
||||
commands.getApplicationId,
|
||||
commands.getCommandId,
|
||||
commands.getParty,
|
||||
commands.getCommands,
|
||||
)
|
||||
.submit(params)
|
||||
.timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS)
|
||||
.blockingGet()
|
||||
)
|
||||
@ -79,20 +79,22 @@ class CommandSubmissionClientImplTest
|
||||
it should "send a commands to the ledger" in {
|
||||
ledgerServices.withCommandSubmissionClient(alwaysSucceed) { (client, serviceImpl) =>
|
||||
val commands = genCommands(List.empty)
|
||||
|
||||
val params = CommandsSubmission
|
||||
.create(commands.getApplicationId, commands.getCommandId, commands.getCommands)
|
||||
.withWorkflowId(commands.getWorkflowId)
|
||||
.withActAs(commands.getParty)
|
||||
.withMinLedgerTimeAbs(commands.getMinLedgerTimeAbsolute)
|
||||
.withMinLedgerTimeRel(commands.getMinLedgerTimeRelative)
|
||||
.withDeduplicationTime(commands.getDeduplicationTime)
|
||||
|
||||
client
|
||||
.submit(
|
||||
commands.getWorkflowId,
|
||||
commands.getApplicationId,
|
||||
commands.getCommandId,
|
||||
commands.getParty,
|
||||
commands.getMinLedgerTimeAbsolute,
|
||||
commands.getMinLedgerTimeRelative,
|
||||
commands.getDeduplicationTime,
|
||||
commands.getCommands,
|
||||
)
|
||||
.submit(params)
|
||||
.timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS)
|
||||
.blockingGet()
|
||||
|
||||
val receivedCommands = serviceImpl.getSubmittedRequest.value.getCommands
|
||||
|
||||
receivedCommands.ledgerId shouldBe ledgerServices.ledgerId
|
||||
receivedCommands.applicationId shouldBe commands.getApplicationId
|
||||
receivedCommands.workflowId shouldBe commands.getWorkflowId
|
||||
@ -134,33 +136,17 @@ class CommandSubmissionClientImplTest
|
||||
val record = new DamlRecord(recordId, List.empty[DamlRecord.Field].asJava)
|
||||
val command = new CreateCommand(new Identifier("a", "a", "b"), record)
|
||||
val commands = genCommands(List[Command](command), Option(someParty))
|
||||
accessToken
|
||||
.fold(
|
||||
client
|
||||
.submit(
|
||||
commands.getWorkflowId,
|
||||
commands.getApplicationId,
|
||||
commands.getCommandId,
|
||||
commands.getParty,
|
||||
commands.getMinLedgerTimeAbsolute,
|
||||
commands.getMinLedgerTimeRelative,
|
||||
commands.getDeduplicationTime,
|
||||
commands.getCommands,
|
||||
)
|
||||
)(
|
||||
client
|
||||
.submit(
|
||||
commands.getWorkflowId,
|
||||
commands.getApplicationId,
|
||||
commands.getCommandId,
|
||||
commands.getParty,
|
||||
commands.getMinLedgerTimeAbsolute,
|
||||
commands.getMinLedgerTimeRelative,
|
||||
commands.getDeduplicationTime,
|
||||
commands.getCommands,
|
||||
_,
|
||||
)
|
||||
)
|
||||
|
||||
val params = CommandsSubmission
|
||||
.create(commands.getApplicationId, commands.getCommandId, commands.getCommands)
|
||||
.withActAs(commands.getParty)
|
||||
.withMinLedgerTimeAbs(commands.getMinLedgerTimeAbsolute)
|
||||
.withMinLedgerTimeRel(commands.getMinLedgerTimeRelative)
|
||||
.withDeduplicationTime(commands.getDeduplicationTime)
|
||||
.withAccessToken(Optional.ofNullable(accessToken.orNull))
|
||||
|
||||
client
|
||||
.submit(params)
|
||||
.timeout(TestConfiguration.timeoutInSeconds, TimeUnit.SECONDS)
|
||||
.blockingGet()
|
||||
}
|
||||
|
@ -0,0 +1,246 @@
|
||||
// Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package com.daml.ledger.javaapi.data;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
import static java.util.Optional.empty;
|
||||
|
||||
import com.daml.ledger.javaapi.data.codegen.HasCommands;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* This class can be used to build a valid submission. It provides {@link #create(String, String, List)}
|
||||
* for initial creation and methods to set optional parameters
|
||||
* e.g {@link #withActAs(List)}, {@link #withWorkflowId(String)} etc.
|
||||
*
|
||||
* Usage:
|
||||
* <pre>
|
||||
* var submission = CommandsSubmission.create(applicationId, commandId, commands)
|
||||
* .withAccessToken(token)
|
||||
* .withParty(party)
|
||||
* .with...
|
||||
* <pre/>
|
||||
*/
|
||||
public final class CommandsSubmission {
|
||||
private String applicationId;
|
||||
private String commandId;
|
||||
private List<@NonNull ? extends HasCommands> commands;
|
||||
|
||||
private Optional<String> workflowId;
|
||||
private List<@NonNull String> actAs;
|
||||
private List<@NonNull String> readAs;
|
||||
private Optional<Instant> minLedgerTimeAbs;
|
||||
private Optional<Duration> minLedgerTimeRel;
|
||||
private Optional<Duration> deduplicationTime;
|
||||
private Optional<String> accessToken;
|
||||
|
||||
private CommandsSubmission(
|
||||
String applicationId,
|
||||
String commandId,
|
||||
List<@NonNull ? extends HasCommands> commands,
|
||||
List<@NonNull String> actAs,
|
||||
List<@NonNull String> readAs,
|
||||
Optional<String> workflowId,
|
||||
Optional<Instant> minLedgerTimeAbs,
|
||||
Optional<Duration> minLedgerTimeRel,
|
||||
Optional<Duration> deduplicationTime,
|
||||
Optional<String> accessToken) {
|
||||
this.workflowId = workflowId;
|
||||
this.applicationId = applicationId;
|
||||
this.commandId = commandId;
|
||||
this.actAs = actAs;
|
||||
this.readAs = readAs;
|
||||
this.minLedgerTimeAbs = minLedgerTimeAbs;
|
||||
this.minLedgerTimeRel = minLedgerTimeRel;
|
||||
this.deduplicationTime = deduplicationTime;
|
||||
this.commands = commands;
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public static CommandsSubmission create(
|
||||
String applicationId, String commandId, List<@NonNull ? extends HasCommands> commands) {
|
||||
return new CommandsSubmission(
|
||||
applicationId,
|
||||
commandId,
|
||||
commands,
|
||||
emptyList(),
|
||||
emptyList(),
|
||||
empty(),
|
||||
empty(),
|
||||
Optional.empty(),
|
||||
empty(),
|
||||
empty());
|
||||
}
|
||||
|
||||
public Optional<String> getWorkflowId() {
|
||||
return workflowId;
|
||||
}
|
||||
|
||||
public String getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
public String getCommandId() {
|
||||
return commandId;
|
||||
}
|
||||
|
||||
public List<String> getActAs() {
|
||||
return unmodifiableList(actAs);
|
||||
}
|
||||
|
||||
public List<String> getReadAs() {
|
||||
return unmodifiableList(readAs);
|
||||
}
|
||||
|
||||
public Optional<Instant> getMinLedgerTimeAbs() {
|
||||
return minLedgerTimeAbs;
|
||||
}
|
||||
|
||||
public Optional<Duration> getMinLedgerTimeRel() {
|
||||
return minLedgerTimeRel;
|
||||
}
|
||||
|
||||
public Optional<Duration> getDeduplicationTime() {
|
||||
return deduplicationTime;
|
||||
}
|
||||
|
||||
public List<? extends HasCommands> getCommands() {
|
||||
return unmodifiableList(commands);
|
||||
}
|
||||
|
||||
public Optional<String> getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public CommandsSubmission withWorkflowId(String workflowId) {
|
||||
return new CommandsSubmission(
|
||||
applicationId,
|
||||
commandId,
|
||||
commands,
|
||||
actAs,
|
||||
readAs,
|
||||
Optional.of(workflowId),
|
||||
minLedgerTimeAbs,
|
||||
minLedgerTimeRel,
|
||||
deduplicationTime,
|
||||
accessToken);
|
||||
}
|
||||
|
||||
public CommandsSubmission withActAs(String actAs) {
|
||||
return new CommandsSubmission(
|
||||
applicationId,
|
||||
commandId,
|
||||
commands,
|
||||
List.of(actAs),
|
||||
readAs,
|
||||
workflowId,
|
||||
minLedgerTimeAbs,
|
||||
minLedgerTimeRel,
|
||||
deduplicationTime,
|
||||
accessToken);
|
||||
}
|
||||
|
||||
public CommandsSubmission withActAs(List<@NonNull String> actAs) {
|
||||
return new CommandsSubmission(
|
||||
applicationId,
|
||||
commandId,
|
||||
commands,
|
||||
actAs,
|
||||
readAs,
|
||||
workflowId,
|
||||
minLedgerTimeAbs,
|
||||
minLedgerTimeRel,
|
||||
deduplicationTime,
|
||||
accessToken);
|
||||
}
|
||||
|
||||
public CommandsSubmission withReadAs(List<@NonNull String> readAs) {
|
||||
return new CommandsSubmission(
|
||||
applicationId,
|
||||
commandId,
|
||||
commands,
|
||||
actAs,
|
||||
readAs,
|
||||
workflowId,
|
||||
minLedgerTimeAbs,
|
||||
minLedgerTimeRel,
|
||||
deduplicationTime,
|
||||
accessToken);
|
||||
}
|
||||
|
||||
public CommandsSubmission withMinLedgerTimeAbs(Optional<Instant> minLedgerTimeAbs) {
|
||||
return new CommandsSubmission(
|
||||
applicationId,
|
||||
commandId,
|
||||
commands,
|
||||
actAs,
|
||||
readAs,
|
||||
workflowId,
|
||||
minLedgerTimeAbs,
|
||||
minLedgerTimeRel,
|
||||
deduplicationTime,
|
||||
accessToken);
|
||||
}
|
||||
|
||||
public CommandsSubmission withMinLedgerTimeRel(Optional<Duration> minLedgerTimeRel) {
|
||||
return new CommandsSubmission(
|
||||
applicationId,
|
||||
commandId,
|
||||
commands,
|
||||
actAs,
|
||||
readAs,
|
||||
workflowId,
|
||||
minLedgerTimeAbs,
|
||||
minLedgerTimeRel,
|
||||
deduplicationTime,
|
||||
accessToken);
|
||||
}
|
||||
|
||||
public CommandsSubmission withDeduplicationTime(Optional<Duration> deduplicationTime) {
|
||||
return new CommandsSubmission(
|
||||
applicationId,
|
||||
commandId,
|
||||
commands,
|
||||
actAs,
|
||||
readAs,
|
||||
workflowId,
|
||||
minLedgerTimeAbs,
|
||||
minLedgerTimeRel,
|
||||
deduplicationTime,
|
||||
accessToken);
|
||||
}
|
||||
|
||||
public CommandsSubmission withCommands(List<@NonNull ? extends HasCommands> commands) {
|
||||
return new CommandsSubmission(
|
||||
applicationId,
|
||||
commandId,
|
||||
commands,
|
||||
actAs,
|
||||
readAs,
|
||||
workflowId,
|
||||
minLedgerTimeAbs,
|
||||
minLedgerTimeRel,
|
||||
deduplicationTime,
|
||||
accessToken);
|
||||
}
|
||||
|
||||
public CommandsSubmission withAccessToken(Optional<String> accessToken) {
|
||||
return new CommandsSubmission(
|
||||
applicationId,
|
||||
commandId,
|
||||
commands,
|
||||
actAs,
|
||||
readAs,
|
||||
workflowId,
|
||||
minLedgerTimeAbs,
|
||||
minLedgerTimeRel,
|
||||
deduplicationTime,
|
||||
accessToken);
|
||||
}
|
||||
}
|
@ -12,6 +12,24 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public final class SubmitAndWaitRequest {
|
||||
|
||||
public static CommandServiceOuterClass.SubmitAndWaitRequest toProto(
|
||||
@NonNull String ledgerId, @NonNull CommandsSubmission submission) {
|
||||
return CommandServiceOuterClass.SubmitAndWaitRequest.newBuilder()
|
||||
.setCommands(SubmitCommandsRequest.toProto(ledgerId, submission))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandServiceOuterClass.SubmitAndWaitRequest toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String submissionId,
|
||||
@NonNull CommandsSubmission submission) {
|
||||
return CommandServiceOuterClass.SubmitAndWaitRequest.newBuilder()
|
||||
.setCommands(SubmitCommandsRequest.toProto(ledgerId, submissionId, submission))
|
||||
.build();
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandServiceOuterClass.SubmitAndWaitRequest toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
@ -37,6 +55,8 @@ public final class SubmitAndWaitRequest {
|
||||
.build();
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandServiceOuterClass.SubmitAndWaitRequest toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
@ -64,6 +84,8 @@ public final class SubmitAndWaitRequest {
|
||||
.build();
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandServiceOuterClass.SubmitAndWaitRequest toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
@ -91,6 +113,8 @@ public final class SubmitAndWaitRequest {
|
||||
.build();
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandServiceOuterClass.SubmitAndWaitRequest toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
package com.daml.ledger.javaapi.data;
|
||||
|
||||
import static com.daml.ledger.javaapi.data.codegen.HasCommands.toCommands;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
|
||||
import com.daml.ledger.api.v1.CommandsOuterClass;
|
||||
import com.google.protobuf.Timestamp;
|
||||
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public final class SubmitCommandsRequest {
|
||||
@ -143,8 +144,8 @@ public final class SubmitCommandsRequest {
|
||||
this.applicationId = applicationId;
|
||||
this.commandId = commandId;
|
||||
this.party = actAs.get(0);
|
||||
this.actAs = unmodifiableList(new ArrayList<>(actAs));
|
||||
this.readAs = unmodifiableList(new ArrayList<>(readAs));
|
||||
this.actAs = List.copyOf(actAs);
|
||||
this.readAs = List.copyOf(readAs);
|
||||
this.minLedgerTimeAbsolute = minLedgerTimeAbsolute;
|
||||
this.minLedgerTimeRelative = minLedgerTimeRelative;
|
||||
this.deduplicationTime = deduplicationTime;
|
||||
@ -209,6 +210,8 @@ public final class SubmitCommandsRequest {
|
||||
listOfCommands);
|
||||
}
|
||||
|
||||
// TODO: Refactor this to take CommmandsSubmission when deprecated methods using it below are
|
||||
// removed
|
||||
private static CommandsOuterClass.Commands toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
@ -224,10 +227,8 @@ public final class SubmitCommandsRequest {
|
||||
if (actAs.size() == 0) {
|
||||
throw new IllegalArgumentException("actAs must have at least one element");
|
||||
}
|
||||
ArrayList<CommandsOuterClass.Command> commandsConverted = new ArrayList<>(commands.size());
|
||||
for (Command command : commands) {
|
||||
commandsConverted.add(command.toProtoCommand());
|
||||
}
|
||||
List<CommandsOuterClass.Command> commandsConverted =
|
||||
commands.stream().map(Command::toProtoCommand).collect(Collectors.toList());
|
||||
CommandsOuterClass.Commands.Builder builder =
|
||||
CommandsOuterClass.Commands.newBuilder()
|
||||
.setLedgerId(ledgerId)
|
||||
@ -261,6 +262,83 @@ public final class SubmitCommandsRequest {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static CommandsOuterClass.Commands toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull Optional<String> submissionId,
|
||||
@NonNull CommandsSubmission submission) {
|
||||
|
||||
if (submission.getActAs().size() == 0) {
|
||||
throw new IllegalArgumentException("actAs must have at least one element");
|
||||
}
|
||||
|
||||
List<Command> commands = toCommands(submission.getCommands());
|
||||
List<CommandsOuterClass.Command> commandsConverted =
|
||||
commands.stream().map(Command::toProtoCommand).collect(Collectors.toList());
|
||||
|
||||
CommandsOuterClass.Commands.Builder builder =
|
||||
CommandsOuterClass.Commands.newBuilder()
|
||||
.setLedgerId(ledgerId)
|
||||
.setApplicationId(submission.getApplicationId())
|
||||
.setCommandId(submission.getCommandId())
|
||||
.setParty(submission.getActAs().get(0))
|
||||
.addAllActAs(submission.getActAs())
|
||||
.addAllReadAs(submission.getReadAs())
|
||||
.addAllCommands(commandsConverted);
|
||||
|
||||
submission
|
||||
.getMinLedgerTimeAbs()
|
||||
.ifPresent(
|
||||
abs ->
|
||||
builder.setMinLedgerTimeAbs(
|
||||
Timestamp.newBuilder()
|
||||
.setSeconds(abs.getEpochSecond())
|
||||
.setNanos(abs.getNano())));
|
||||
|
||||
submission
|
||||
.getMinLedgerTimeRel()
|
||||
.ifPresent(
|
||||
rel ->
|
||||
builder.setMinLedgerTimeRel(
|
||||
com.google.protobuf.Duration.newBuilder()
|
||||
.setSeconds(rel.getSeconds())
|
||||
.setNanos(rel.getNano())));
|
||||
|
||||
submission
|
||||
.getDeduplicationTime()
|
||||
.ifPresent(
|
||||
dedup -> {
|
||||
@SuppressWarnings("deprecation")
|
||||
var unused =
|
||||
builder.setDeduplicationTime(
|
||||
com.google.protobuf.Duration.newBuilder()
|
||||
.setSeconds(dedup.getSeconds())
|
||||
.setNanos(dedup.getNano()));
|
||||
});
|
||||
|
||||
submission.getWorkflowId().ifPresent(builder::setWorkflowId);
|
||||
submissionId.ifPresent(builder::setSubmissionId);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static CommandsOuterClass.Commands toProto(
|
||||
@NonNull String ledgerId, @NonNull CommandsSubmission submission) {
|
||||
return toProto(
|
||||
ledgerId,
|
||||
submission.getWorkflowId().orElse(""),
|
||||
submission.getApplicationId(),
|
||||
submission.getCommandId(),
|
||||
submission.getActAs(),
|
||||
submission.getReadAs(),
|
||||
submission.getMinLedgerTimeAbs(),
|
||||
submission.getMinLedgerTimeRel(),
|
||||
submission.getDeduplicationTime(),
|
||||
Optional.empty(),
|
||||
toCommands(submission.getCommands()));
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandsOuterClass.Commands toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
@ -286,6 +364,26 @@ public final class SubmitCommandsRequest {
|
||||
commands);
|
||||
}
|
||||
|
||||
public static CommandsOuterClass.Commands toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String submissionId,
|
||||
@NonNull CommandsSubmission submission) {
|
||||
return toProto(
|
||||
ledgerId,
|
||||
submission.getWorkflowId().orElse(""),
|
||||
submission.getApplicationId(),
|
||||
submission.getCommandId(),
|
||||
submission.getActAs(),
|
||||
submission.getReadAs(),
|
||||
submission.getMinLedgerTimeAbs(),
|
||||
submission.getMinLedgerTimeRel(),
|
||||
submission.getDeduplicationTime(),
|
||||
Optional.of(submissionId),
|
||||
toCommands(submission.getCommands()));
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandsOuterClass.Commands toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
@ -312,6 +410,8 @@ public final class SubmitCommandsRequest {
|
||||
commands);
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandsOuterClass.Commands toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
@ -340,6 +440,8 @@ public final class SubmitCommandsRequest {
|
||||
commands);
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandsOuterClass.Commands toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
|
@ -12,6 +12,24 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public final class SubmitRequest {
|
||||
|
||||
public static CommandSubmissionServiceOuterClass.SubmitRequest toProto(
|
||||
@NonNull String ledgerId, @NonNull CommandsSubmission submission) {
|
||||
return CommandSubmissionServiceOuterClass.SubmitRequest.newBuilder()
|
||||
.setCommands(SubmitCommandsRequest.toProto(ledgerId, submission))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandSubmissionServiceOuterClass.SubmitRequest toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String submissionId,
|
||||
@NonNull CommandsSubmission submission) {
|
||||
return CommandSubmissionServiceOuterClass.SubmitRequest.newBuilder()
|
||||
.setCommands(SubmitCommandsRequest.toProto(ledgerId, submissionId, submission))
|
||||
.build();
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandSubmissionServiceOuterClass.SubmitRequest toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
@ -37,6 +55,8 @@ public final class SubmitRequest {
|
||||
.build();
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandSubmissionServiceOuterClass.SubmitRequest toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
@ -64,6 +84,8 @@ public final class SubmitRequest {
|
||||
.build();
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandSubmissionServiceOuterClass.SubmitRequest toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
@ -91,6 +113,8 @@ public final class SubmitRequest {
|
||||
.build();
|
||||
}
|
||||
|
||||
/** @deprecated since 2.5. Please use {@link #toProto(String, String, CommandsSubmission)} */
|
||||
@Deprecated
|
||||
public static CommandSubmissionServiceOuterClass.SubmitRequest toProto(
|
||||
@NonNull String ledgerId,
|
||||
@NonNull String workflowId,
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
package com.daml.ledger.javaapi.data
|
||||
|
||||
import java.time.{Duration, Instant}
|
||||
import java.time.Duration
|
||||
import java.util.Optional
|
||||
|
||||
import com.daml.ledger.api.v1.CommandsOuterClass
|
||||
@ -20,19 +20,17 @@ final class SubmitCommandsRequestSpec extends AnyFlatSpec with Matchers {
|
||||
behavior of "SubmitCommandsRequest.toProto/fromProto"
|
||||
|
||||
it should "return the expected submissionId in different overloads" in {
|
||||
val commandsSubmission =
|
||||
CommandsSubmission
|
||||
.create("applicationId", "commandId", List.empty[Command].asJava)
|
||||
.withWorkflowId("workflowId")
|
||||
.withActAs("Alice")
|
||||
|
||||
withClue("(String, String, String, String, String, Optional, Optional, Optional, List)") {
|
||||
withClue("[No submissionId provided]") {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
"Alice",
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.empty[Duration](),
|
||||
List.empty[Command].asJava,
|
||||
commandsSubmission,
|
||||
)
|
||||
|
||||
proto.getSubmissionId shouldBe ""
|
||||
@ -43,20 +41,13 @@ final class SubmitCommandsRequestSpec extends AnyFlatSpec with Matchers {
|
||||
}
|
||||
|
||||
withClue(
|
||||
"(String, String, String, String, String, String, Optional, Optional, Optional, List)"
|
||||
"[submissionId provided]"
|
||||
) {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
"submissionId",
|
||||
"Alice",
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.empty[Duration](),
|
||||
List.empty[Command].asJava,
|
||||
commandsSubmission,
|
||||
)
|
||||
|
||||
proto.getSubmissionId shouldBe "submissionId"
|
||||
@ -65,73 +56,23 @@ final class SubmitCommandsRequestSpec extends AnyFlatSpec with Matchers {
|
||||
|
||||
request.getSubmissionId shouldEqual Optional.of("submissionId")
|
||||
}
|
||||
|
||||
withClue("(String, String, String, String, List, List, Optional, Optional, Optional, List)") {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
List("Alice").asJava,
|
||||
List.empty[String].asJava,
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.empty[Duration](),
|
||||
List.empty[Command].asJava,
|
||||
)
|
||||
|
||||
proto.getSubmissionId shouldBe ""
|
||||
|
||||
val request = SubmitCommandsRequest.fromProto(proto)
|
||||
|
||||
request.getSubmissionId shouldEqual Optional.empty()
|
||||
}
|
||||
|
||||
withClue(
|
||||
"(String, String, String, String, String, List, List, Optional, Optional, Optional, List)"
|
||||
) {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
"submissionId",
|
||||
List("Alice").asJava,
|
||||
List.empty[String].asJava,
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.empty[Duration](),
|
||||
List.empty[Command].asJava,
|
||||
)
|
||||
|
||||
proto.getSubmissionId shouldBe "submissionId"
|
||||
|
||||
val request = SubmitCommandsRequest.fromProto(proto)
|
||||
|
||||
request.getSubmissionId shouldEqual Optional.of("submissionId")
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
it should "return the expected deduplicationTime/deduplicationDuration in different overloads (set)" in {
|
||||
|
||||
val duration = Duration.ofSeconds(42, 47)
|
||||
val commandsSubmission =
|
||||
CommandsSubmission
|
||||
.create("applicationId", "commandId", List.empty[Command].asJava)
|
||||
.withWorkflowId("workflowId")
|
||||
.withActAs("Alice")
|
||||
.withDeduplicationTime(Optional.of(duration))
|
||||
|
||||
withClue("(String, String, String, String, String, Optional, Optional, Optional, List)") {
|
||||
withClue("[submissionId not provided]") {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
"Alice",
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.of(duration),
|
||||
List.empty[Command].asJava,
|
||||
commandsSubmission,
|
||||
)
|
||||
|
||||
// We are sticking on the now deprecated deduplicationTime on purpose for backward compatibility
|
||||
@ -148,20 +89,13 @@ final class SubmitCommandsRequestSpec extends AnyFlatSpec with Matchers {
|
||||
}
|
||||
|
||||
withClue(
|
||||
"(String, String, String, String, String, String, Optional, Optional, Optional, List)"
|
||||
"[submissionId provided]"
|
||||
) {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
"submissionId",
|
||||
"Alice",
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.of(duration),
|
||||
List.empty[Command].asJava,
|
||||
commandsSubmission,
|
||||
)
|
||||
|
||||
// We are sticking on the now deprecated deduplicationTime on purpose for backward compatibility
|
||||
@ -176,83 +110,20 @@ final class SubmitCommandsRequestSpec extends AnyFlatSpec with Matchers {
|
||||
|
||||
request.getDeduplicationTime shouldEqual Optional.of(duration)
|
||||
}
|
||||
|
||||
withClue("(String, String, String, String, List, List, Optional, Optional, Optional, List)") {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
List("Alice").asJava,
|
||||
List.empty[String].asJava,
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.of(duration),
|
||||
List.empty[Command].asJava,
|
||||
)
|
||||
|
||||
// We are sticking on the now deprecated deduplicationTime on purpose for backward compatibility
|
||||
proto.getDeduplicationPeriodCase shouldBe DeduplicationPeriodCase.DEDUPLICATION_TIME
|
||||
proto.hasDeduplicationTime shouldBe true
|
||||
proto.getDeduplicationTime.getSeconds shouldBe 42
|
||||
proto.getDeduplicationTime.getNanos shouldBe 47
|
||||
|
||||
proto.hasDeduplicationDuration shouldBe false
|
||||
|
||||
val request = SubmitCommandsRequest.fromProto(proto)
|
||||
|
||||
request.getDeduplicationTime shouldEqual Optional.of(duration)
|
||||
}
|
||||
|
||||
withClue(
|
||||
"(String, String, String, String, String, List, List, Optional, Optional, Optional, List)"
|
||||
) {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
"submissionId",
|
||||
List("Alice").asJava,
|
||||
List.empty[String].asJava,
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.of(duration),
|
||||
List.empty[Command].asJava,
|
||||
)
|
||||
|
||||
// We are sticking on the now deprecated deduplicationTime on purpose for backward compatibility
|
||||
proto.getDeduplicationPeriodCase shouldBe DeduplicationPeriodCase.DEDUPLICATION_TIME
|
||||
proto.hasDeduplicationTime shouldBe true
|
||||
proto.getDeduplicationTime.getSeconds shouldBe 42
|
||||
proto.getDeduplicationTime.getNanos shouldBe 47
|
||||
|
||||
proto.hasDeduplicationDuration shouldBe false
|
||||
|
||||
val request = SubmitCommandsRequest.fromProto(proto)
|
||||
|
||||
request.getDeduplicationTime shouldEqual Optional.of(duration)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
it should "return the expected deduplicationTime/deduplicationDuration in different overloads (unset)" in {
|
||||
val commandsSubmission =
|
||||
CommandsSubmission
|
||||
.create("applicationId", "commandId", List.empty[Command].asJava)
|
||||
.withWorkflowId("workflowId")
|
||||
.withActAs("Alice")
|
||||
|
||||
withClue("(String, String, String, String, String, Optional, Optional, Optional, List)") {
|
||||
withClue("[submissionId not provided]") {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
"Alice",
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.empty[Duration](),
|
||||
List.empty[Command].asJava,
|
||||
commandsSubmission,
|
||||
)
|
||||
|
||||
// We are sticking on the now deprecated deduplicationTime on purpose for backward compatibility
|
||||
@ -267,20 +138,13 @@ final class SubmitCommandsRequestSpec extends AnyFlatSpec with Matchers {
|
||||
}
|
||||
|
||||
withClue(
|
||||
"(String, String, String, String, String, String, Optional, Optional, Optional, List)"
|
||||
"[submissionId provided]"
|
||||
) {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
"submissionId",
|
||||
"Alice",
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.empty[Duration](),
|
||||
List.empty[Command].asJava,
|
||||
commandsSubmission,
|
||||
)
|
||||
|
||||
// We are sticking on the now deprecated deduplicationTime on purpose for backward compatibility
|
||||
@ -293,82 +157,23 @@ final class SubmitCommandsRequestSpec extends AnyFlatSpec with Matchers {
|
||||
|
||||
request.getDeduplicationTime shouldEqual Optional.empty()
|
||||
}
|
||||
|
||||
withClue("(String, String, String, String, List, List, Optional, Optional, Optional, List)") {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
List("Alice").asJava,
|
||||
List.empty[String].asJava,
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.empty[Duration](),
|
||||
List.empty[Command].asJava,
|
||||
)
|
||||
|
||||
// We are sticking on the now deprecated deduplicationTime on purpose for backward compatibility
|
||||
proto.getDeduplicationPeriodCase shouldBe DeduplicationPeriodCase.DEDUPLICATIONPERIOD_NOT_SET
|
||||
proto.hasDeduplicationTime shouldBe false
|
||||
|
||||
proto.hasDeduplicationDuration shouldBe false
|
||||
|
||||
val request = SubmitCommandsRequest.fromProto(proto)
|
||||
|
||||
request.getDeduplicationTime shouldEqual Optional.empty()
|
||||
}
|
||||
|
||||
withClue(
|
||||
"(String, String, String, String, String, List, List, Optional, Optional, Optional, List)"
|
||||
) {
|
||||
val proto =
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
"submissionId",
|
||||
List("Alice").asJava,
|
||||
List.empty[String].asJava,
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.empty[Duration](),
|
||||
List.empty[Command].asJava,
|
||||
)
|
||||
|
||||
// We are sticking on the now deprecated deduplicationTime on purpose for backward compatibility
|
||||
proto.getDeduplicationPeriodCase shouldBe DeduplicationPeriodCase.DEDUPLICATIONPERIOD_NOT_SET
|
||||
proto.hasDeduplicationTime shouldBe false
|
||||
|
||||
proto.hasDeduplicationDuration shouldBe false
|
||||
|
||||
val request = SubmitCommandsRequest.fromProto(proto)
|
||||
|
||||
request.getDeduplicationTime shouldEqual Optional.empty()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
behavior of "SubmitCommandsRequest.fromProto"
|
||||
|
||||
it should "set the deduplicationTime field even when only deduplicationDuration is set" in {
|
||||
val commandsSubmission =
|
||||
CommandsSubmission
|
||||
.create("applicationId", "commandId", List.empty[Command].asJava)
|
||||
.withWorkflowId("workflowId")
|
||||
.withActAs("Alice")
|
||||
|
||||
val proto =
|
||||
CommandsOuterClass.Commands
|
||||
.newBuilder(
|
||||
SubmitCommandsRequest.toProto(
|
||||
"ledgerId",
|
||||
"workflowId",
|
||||
"applicationId",
|
||||
"commandId",
|
||||
"Alice",
|
||||
Optional.empty[Instant](),
|
||||
Optional.empty[Duration](),
|
||||
Optional.empty[Duration](),
|
||||
List.empty[Command].asJava,
|
||||
commandsSubmission,
|
||||
)
|
||||
)
|
||||
.setDeduplicationDuration(
|
||||
@ -381,5 +186,4 @@ final class SubmitCommandsRequestSpec extends AnyFlatSpec with Matchers {
|
||||
request.getDeduplicationTime shouldEqual Optional.of(Duration.ofSeconds(42, 47))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import io.grpc.Channel
|
||||
import org.scalatest.{Assertion, Suite}
|
||||
|
||||
import java.io.File
|
||||
import java.time.{Duration, Instant}
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.stream.{Collectors, StreamSupport}
|
||||
import java.util.{Optional, UUID}
|
||||
@ -92,6 +91,11 @@ object TestUtil {
|
||||
)
|
||||
|
||||
def sendCmd(channel: Channel, partyName: String, hasCmds: HasCommands*): Empty = {
|
||||
val submission = CommandsSubmission
|
||||
.create(randomId, randomId, HasCommands.toCommands(hasCmds.asJava))
|
||||
.withWorkflowId(randomId)
|
||||
.withActAs(partyName)
|
||||
|
||||
CommandServiceGrpc
|
||||
.newBlockingStub(channel)
|
||||
.withDeadlineAfter(40, TimeUnit.SECONDS)
|
||||
@ -101,14 +105,7 @@ object TestUtil {
|
||||
.setCommands(
|
||||
SubmitCommandsRequest.toProto(
|
||||
LedgerID,
|
||||
randomId,
|
||||
randomId,
|
||||
randomId,
|
||||
partyName,
|
||||
Optional.empty[Instant],
|
||||
Optional.empty[Duration],
|
||||
Optional.empty[Duration],
|
||||
HasCommands.toCommands(hasCmds.asJava),
|
||||
submission,
|
||||
)
|
||||
)
|
||||
.build
|
||||
@ -121,6 +118,12 @@ object TestUtil {
|
||||
readAs: java.util.List[String],
|
||||
hasCmds: HasCommands*
|
||||
): Empty = {
|
||||
val submission = CommandsSubmission
|
||||
.create(randomId, randomId, HasCommands.toCommands(hasCmds.asJava))
|
||||
.withWorkflowId(randomId)
|
||||
.withActAs(actAs)
|
||||
.withReadAs(readAs)
|
||||
|
||||
CommandServiceGrpc
|
||||
.newBlockingStub(channel)
|
||||
.withDeadlineAfter(40, TimeUnit.SECONDS)
|
||||
@ -130,15 +133,7 @@ object TestUtil {
|
||||
.setCommands(
|
||||
SubmitCommandsRequest.toProto(
|
||||
LedgerID,
|
||||
randomId,
|
||||
randomId,
|
||||
randomId,
|
||||
actAs,
|
||||
readAs,
|
||||
Optional.empty[Instant],
|
||||
Optional.empty[Duration],
|
||||
Optional.empty[Duration],
|
||||
HasCommands.toCommands(hasCmds.asJava),
|
||||
submission,
|
||||
)
|
||||
)
|
||||
.build
|
||||
|
@ -4,10 +4,8 @@
|
||||
package com.daml.nonrepudiation.client
|
||||
|
||||
import java.time.{Clock, Instant, ZoneId}
|
||||
import java.util.Collections
|
||||
|
||||
import com.daml.ledger.api.v1.CommandServiceOuterClass.SubmitAndWaitRequest
|
||||
import com.daml.ledger.javaapi.data.Command
|
||||
import com.daml.ledger.javaapi.data.{Command, CommandsSubmission}
|
||||
import com.daml.ledger.api.v1.CommandsOuterClass.{Command => ProtoCommand}
|
||||
import com.daml.ledger.api.v1.command_service.CommandServiceGrpc.CommandService
|
||||
import com.daml.ledger.api.v1.command_submission_service.CommandSubmissionServiceGrpc.CommandSubmissionService
|
||||
@ -26,6 +24,7 @@ import org.scalatest.Inside
|
||||
import org.scalatest.flatspec.AsyncFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
|
||||
import java.util.Collections.singletonList
|
||||
import scala.concurrent.ExecutionContext
|
||||
import scala.concurrent.duration.DurationInt
|
||||
|
||||
@ -75,14 +74,18 @@ final class SigningInterceptorSpec extends AsyncFlatSpec with Matchers with Insi
|
||||
val expectedApplicationId = "application-id"
|
||||
val expectedCommandId = "command-id"
|
||||
val expectedParty = "party-1"
|
||||
client.getCommandClient
|
||||
.submitAndWait(
|
||||
expectedWorkflowId,
|
||||
|
||||
val params = CommandsSubmission
|
||||
.create(
|
||||
expectedApplicationId,
|
||||
expectedCommandId,
|
||||
expectedParty,
|
||||
Collections.singletonList(Command.fromProtoCommand(command)),
|
||||
singletonList(Command.fromProtoCommand(command)),
|
||||
)
|
||||
.withWorkflowId(expectedWorkflowId)
|
||||
.withActAs(expectedParty)
|
||||
|
||||
client.getCommandClient
|
||||
.submitAndWait(params)
|
||||
.blockingGet()
|
||||
|
||||
withClue("Only the command should be signed, not the call to the ledger identity service") {
|
||||
|
Loading…
Reference in New Issue
Block a user