From 7ac438e87b729994770a4f9bb597ef637d204fcf Mon Sep 17 00:00:00 2001 From: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com> Date: Thu, 25 Apr 2019 14:30:25 +0200 Subject: [PATCH] Remove //language-support/js (#691) The JavaScript ecosystem support is being spun off in its own repository. The new home is https://github.com/digital-asset/daml-js For further details, here is the counterpart issue in the new repo: https://github.com/digital-asset/daml-js/issues/1 --- docs/BUILD.bazel | 5 - .../app-dev/bindings-js/daml-as-json.rst | 41 - .../app-dev/bindings-js/getting-started.rst | 41 - docs/source/app-dev/bindings-js/index.rst | 22 - docs/source/app-dev/bindings-js/tutorial.rst | 951 ------------- docs/source/experimental/warning.rst | 3 +- docs/source/support/release-notes.rst | 2 + docs/source/support/roadmap.rst | 4 +- language-support/js/BUILD | 38 - language-support/js/README.md | 21 - language-support/js/codegen.sh | 15 - language-support/js/daml-codegen/BUILD | 46 - language-support/js/daml-codegen/index.ts | 44 - .../js/daml-codegen/module_tree.ts | 38 - language-support/js/daml-codegen/options.ts | 79 -- language-support/js/daml-codegen/package.json | 22 - language-support/js/daml-codegen/processor.ts | 131 -- .../js/daml-codegen/tsconfig.json | 10 - language-support/js/daml-grpc/BUILD | 184 --- language-support/js/daml-grpc/index.ts | 50 - language-support/js/daml-grpc/lf/index.ts | 9 - language-support/js/daml-grpc/package.json | 22 - language-support/js/daml-grpc/test.sh | 20 - language-support/js/daml-grpc/test.ts | 97 -- .../js/daml-grpc/testing/index.ts | 8 - language-support/js/daml-grpc/tsconfig.json | 10 - language-support/js/daml-ledger/BUILD | 80 -- language-support/js/daml-ledger/README.md | 4 - language-support/js/daml-ledger/UNRELEASED.md | 16 - language-support/js/daml-ledger/VALIDATION.md | 31 - language-support/js/daml-ledger/package.json | 21 - .../src/call/client_cancellable_call.ts | 54 - .../src/call/client_readable_object_stream.ts | 88 -- .../js/daml-ledger/src/call/index.ts | 5 - .../daml-ledger/src/call/mapping_transform.ts | 26 - .../src/client/active_contracts_client.ts | 61 - .../daml-ledger/src/client/command_client.ts | 68 - .../src/client/command_completion_client.ts | 102 -- .../src/client/command_submission_client.ts | 93 -- .../js/daml-ledger/src/client/index.ts | 14 - .../src/client/ledger_configuration_client.ts | 42 - .../src/client/ledger_identity_client.ts | 48 - .../daml-ledger/src/client/package_client.ts | 88 -- .../daml-ledger/src/client/testing/index.ts | 9 - .../src/client/testing/reset_client.ts | 26 - .../src/client/testing/time_client.ts | 77 - .../src/client/transaction_client.ts | 150 -- .../js/daml-ledger/src/daml_ledger_client.ts | 133 -- language-support/js/daml-ledger/src/index.ts | 18 - .../js/daml-ledger/src/ledger_client.ts | 130 -- .../js/daml-ledger/src/mapping/any.ts | 21 - .../daml-ledger/src/mapping/archived_event.ts | 25 - .../js/daml-ledger/src/mapping/checkpoint.ts | 21 - .../js/daml-ledger/src/mapping/command.ts | 31 - .../js/daml-ledger/src/mapping/commands.ts | 39 - .../js/daml-ledger/src/mapping/completion.ts | 27 - .../src/mapping/completion_end_response.ts | 19 - .../src/mapping/completion_stream_request.ts | 23 - .../src/mapping/completion_stream_response.ts | 30 - .../daml-ledger/src/mapping/create_command.ts | 21 - .../daml-ledger/src/mapping/created_event.ts | 27 - .../js/daml-ledger/src/mapping/duration.ts | 21 - .../js/daml-ledger/src/mapping/event.ts | 41 - .../src/mapping/exercise_command.ts | 25 - .../src/mapping/exercised_event.ts | 43 - .../js/daml-ledger/src/mapping/filters.ts | 23 - .../mapping/get_active_contracts_request.ts | 27 - .../mapping/get_active_contracts_response.ts | 34 - .../get_ledger_configuration_response.ts | 19 - .../src/mapping/get_ledger_end_response.ts | 19 - .../mapping/get_ledger_identity_response.ts | 19 - .../src/mapping/get_package_response.ts | 23 - .../mapping/get_package_status_response.ts | 19 - .../src/mapping/get_time_response.ts | 19 - .../get_transaction_by_event_id_request.ts | 21 - .../mapping/get_transaction_by_id_request.ts | 21 - .../src/mapping/get_transaction_response.ts | 19 - .../mapping/get_transaction_trees_response.ts | 19 - .../src/mapping/get_transactions_request.ts | 35 - .../src/mapping/get_transactions_response.ts | 19 - .../js/daml-ledger/src/mapping/identifier.ts | 23 - .../src/mapping/inclusive_filters.ts | 19 - .../js/daml-ledger/src/mapping/index.ts | 52 - .../src/mapping/ledger_configuration.ts | 21 - .../daml-ledger/src/mapping/ledger_offset.ts | 54 - .../src/mapping/list_packages_response.ts | 19 - .../js/daml-ledger/src/mapping/mapping.ts | 20 - .../js/daml-ledger/src/mapping/optional.ts | 23 - .../daml-ledger/src/mapping/package_status.ts | 28 - .../js/daml-ledger/src/mapping/record.ts | 37 - .../src/mapping/set_time_request.ts | 21 - .../js/daml-ledger/src/mapping/status.ts | 24 - .../src/mapping/submit_and_wait_request.ts | 19 - .../daml-ledger/src/mapping/submit_request.ts | 19 - .../js/daml-ledger/src/mapping/timestamp.ts | 21 - .../js/daml-ledger/src/mapping/transaction.ts | 40 - .../src/mapping/transaction_filter.ts | 24 - .../src/mapping/transaction_tree.ts | 49 - .../js/daml-ledger/src/mapping/tree_event.ts | 29 - .../js/daml-ledger/src/mapping/value.ts | 100 -- .../js/daml-ledger/src/model/any.ts | 21 - .../daml-ledger/src/model/archived_event.ts | 35 - .../js/daml-ledger/src/model/checkpoint.ts | 23 - .../js/daml-ledger/src/model/command.ts | 23 - .../js/daml-ledger/src/model/commands.ts | 53 - .../js/daml-ledger/src/model/completion.ts | 23 - .../src/model/completion_end_response.ts | 17 - .../src/model/completion_stream_request.ts | 29 - .../src/model/completion_stream_response.ts | 23 - .../daml-ledger/src/model/create_command.ts | 23 - .../js/daml-ledger/src/model/created_event.ts | 41 - .../js/daml-ledger/src/model/duration.ts | 21 - .../js/daml-ledger/src/model/empty.ts | 10 - .../js/daml-ledger/src/model/event.ts | 29 - .../daml-ledger/src/model/exercise_command.ts | 35 - .../daml-ledger/src/model/exercised_event.ts | 71 - .../js/daml-ledger/src/model/filters.ts | 17 - .../src/model/get_active_contracts_request.ts | 23 - .../model/get_active_contracts_response.ts | 30 - .../get_ledger_configuration_response.ts | 17 - .../src/model/get_ledger_end_response.ts | 17 - .../src/model/get_ledger_identity_response.ts | 15 - .../src/model/get_package_response.ts | 29 - .../src/model/get_package_status_response.ts | 17 - .../src/model/get_time_response.ts | 17 - .../get_transaction_by_event_id_request.ts | 21 - .../model/get_transaction_by_id_request.ts | 21 - .../src/model/get_transaction_response.ts | 17 - .../model/get_transaction_trees_response.ts | 17 - .../src/model/get_transactions_request.ts | 35 - .../src/model/get_transactions_response.ts | 17 - .../js/daml-ledger/src/model/hash_function.ts | 16 - .../js/daml-ledger/src/model/identifier.ts | 27 - .../src/model/inclusive_filters.ts | 17 - .../js/daml-ledger/src/model/index.ts | 63 - .../src/model/ledger_configuration.ts | 23 - .../js/daml-ledger/src/model/ledger_offset.ts | 50 - .../src/model/list_packages_response.ts | 15 - .../js/daml-ledger/src/model/optional.ts | 16 - .../daml-ledger/src/model/package_status.ts | 21 - .../js/daml-ledger/src/model/record.ts | 25 - .../daml-ledger/src/model/set_time_request.ts | 23 - .../js/daml-ledger/src/model/status.ts | 28 - .../src/model/submit_and_wait_request.ts | 16 - .../daml-ledger/src/model/submit_request.ts | 16 - .../js/daml-ledger/src/model/timestamp.ts | 43 - .../js/daml-ledger/src/model/transaction.ts | 47 - .../src/model/transaction_filter.ts | 19 - .../daml-ledger/src/model/transaction_tree.ts | 53 - .../js/daml-ledger/src/model/tree_event.ts | 9 - .../js/daml-ledger/src/model/value.ts | 100 -- .../js/daml-ledger/src/model/variant.ts | 29 - .../js/daml-ledger/src/reporting/index.ts | 9 - .../src/reporting/json_reporter.ts | 9 - .../src/reporting/simple_reporter.ts | 39 - .../js/daml-ledger/src/util/callback.ts | 25 - .../js/daml-ledger/src/util/index.ts | 8 - .../js/daml-ledger/src/validation/any.ts | 15 - .../src/validation/archived_event.ts | 18 - .../daml-ledger/src/validation/base/array.ts | 26 - .../src/validation/base/enumeration.ts | 28 - .../daml-ledger/src/validation/base/error.ts | 26 - .../daml-ledger/src/validation/base/index.ts | 48 - .../daml-ledger/src/validation/base/native.ts | 23 - .../daml-ledger/src/validation/base/object.ts | 64 - .../daml-ledger/src/validation/base/record.ts | 26 - .../daml-ledger/src/validation/base/tree.ts | 13 - .../src/validation/base/typelevel.ts | 30 - .../daml-ledger/src/validation/base/union.ts | 57 - .../daml-ledger/src/validation/checkpoint.ts | 17 - .../js/daml-ledger/src/validation/command.ts | 16 - .../js/daml-ledger/src/validation/commands.ts | 27 - .../daml-ledger/src/validation/completion.ts | 21 - .../src/validation/completion_end_response.ts | 15 - .../validation/completion_stream_request.ts | 17 - .../validation/completion_stream_response.ts | 17 - .../src/validation/create_command.ts | 17 - .../src/validation/created_event.ts | 20 - .../js/daml-ledger/src/validation/duration.ts | 15 - .../js/daml-ledger/src/validation/empty.ts | 7 - .../js/daml-ledger/src/validation/event.ts | 18 - .../src/validation/exercise_command.ts | 19 - .../src/validation/exercised_event.ts | 30 - .../js/daml-ledger/src/validation/filters.ts | 15 - .../get_active_contracts_request.ts | 21 - .../get_active_contracts_response.ts | 23 - .../get_ledger_configuration_response.ts | 15 - .../src/validation/get_ledger_end_response.ts | 15 - .../get_ledger_identity_response.ts | 14 - .../src/validation/get_package_response.ts | 17 - .../validation/get_package_status_response.ts | 15 - .../src/validation/get_time_response.ts | 15 - .../get_transaction_by_event_id_request.ts | 15 - .../get_transaction_by_id_request.ts | 15 - .../validation/get_transaction_response.ts | 15 - .../get_transaction_trees_response.ts | 15 - .../validation/get_transactions_request.ts | 24 - .../validation/get_transactions_response.ts | 15 - .../src/validation/hash_function.ts | 7 - .../daml-ledger/src/validation/identifier.ts | 16 - .../src/validation/inclusive_filters.ts | 15 - .../js/daml-ledger/src/validation/index.ts | 66 - .../src/validation/ledger_configuration.ts | 16 - .../src/validation/ledger_offset.ts | 14 - .../src/validation/list_packages_response.ts | 14 - .../js/daml-ledger/src/validation/optional.ts | 15 - .../src/validation/package_status.ts | 7 - .../js/daml-ledger/src/validation/record.ts | 23 - .../src/validation/set_time_request.ts | 16 - .../js/daml-ledger/src/validation/status.ts | 17 - .../src/validation/submit_and_wait_request.ts | 15 - .../src/validation/submit_request.ts | 15 - .../daml-ledger/src/validation/timestamp.ts | 15 - .../daml-ledger/src/validation/transaction.ts | 26 - .../src/validation/transaction_filter.ts | 16 - .../src/validation/transaction_tree.ts | 28 - .../daml-ledger/src/validation/tree_event.ts | 16 - .../js/daml-ledger/src/validation/value.ts | 30 - .../js/daml-ledger/src/validation/variant.ts | 23 - language-support/js/daml-ledger/test.sh | 23 - .../tests/active_contracts_client.spec.ts | 162 --- .../js/daml-ledger/tests/arbitrary/any.ts | 18 - .../daml-ledger/tests/arbitrary/checkpoint.ts | 20 - .../js/daml-ledger/tests/arbitrary/command.ts | 20 - .../daml-ledger/tests/arbitrary/commands.ts | 23 - .../daml-ledger/tests/arbitrary/completion.ts | 18 - .../arbitrary/completion_end_response.ts | 15 - .../arbitrary/completion_stream_request.ts | 17 - .../arbitrary/completion_stream_response.ts | 18 - .../tests/arbitrary/create_command.ts | 17 - .../daml-ledger/tests/arbitrary/duration.ts | 18 - .../js/daml-ledger/tests/arbitrary/empty.ts | 8 - .../js/daml-ledger/tests/arbitrary/event.ts | 86 -- .../tests/arbitrary/exercise_command.ts | 19 - .../js/daml-ledger/tests/arbitrary/filters.ts | 18 - .../arbitrary/get_active_contracts_request.ts | 23 - .../get_active_contracts_response.ts | 27 - .../get_ledger_configuration_response.ts | 15 - .../arbitrary/get_ledger_end_response.ts | 15 - .../arbitrary/get_ledger_identity_response.ts | 14 - .../tests/arbitrary/get_package_response.ts | 19 - .../arbitrary/get_package_status_response.ts | 14 - .../tests/arbitrary/get_time_response.ts | 15 - .../get_transaction_by_event_id_request.ts | 15 - .../get_transaction_by_id_request.ts | 15 - .../arbitrary/get_transaction_response.ts | 15 - .../get_transaction_trees_response.ts | 15 - .../arbitrary/get_transactions_request.ts | 28 - .../arbitrary/get_transactions_response.ts | 15 - .../daml-ledger/tests/arbitrary/identifier.ts | 19 - .../tests/arbitrary/inclusive_filters.ts | 19 - .../js/daml-ledger/tests/arbitrary/index.ts | 46 - .../tests/arbitrary/ledger_configuration.ts | 19 - .../tests/arbitrary/ledger_offset.ts | 29 - .../tests/arbitrary/list_packages_response.ts | 14 - .../js/daml-ledger/tests/arbitrary/maybe.ts | 8 - .../daml-ledger/tests/arbitrary/optional.ts | 16 - .../tests/arbitrary/record_value_variant.ts | 121 -- .../tests/arbitrary/set_time_request.ts | 16 - .../js/daml-ledger/tests/arbitrary/status.ts | 17 - .../arbitrary/submit_and_wait_request.ts | 15 - .../tests/arbitrary/submit_request.ts | 15 - .../daml-ledger/tests/arbitrary/timestamp.ts | 18 - .../tests/arbitrary/transaction.ts | 29 - .../tests/arbitrary/transaction_filter.ts | 17 - .../tests/arbitrary/transaction_tree.ts | 38 - .../js/daml-ledger/tests/certs/ca.crt | 32 - .../js/daml-ledger/tests/certs/ca.key | 54 - .../js/daml-ledger/tests/certs/client.crt | 30 - .../js/daml-ledger/tests/certs/client.csr | 27 - .../js/daml-ledger/tests/certs/client.key | 51 - .../js/daml-ledger/tests/certs/index.ts | 10 - .../js/daml-ledger/tests/certs/server.crt | 30 - .../js/daml-ledger/tests/certs/server.csr | 27 - .../js/daml-ledger/tests/certs/server.key | 51 - .../client_readable_object_stream.spec.ts | 77 - .../daml-ledger/tests/command_client.spec.ts | 169 --- .../tests/command_completion_client.spec.ts | 202 --- .../tests/command_submission_client.spec.ts | 173 --- .../daml-ledger/tests/end_to_end_ssl.spec.ts | 85 -- .../tests/end_to_end_stream.spec.ts | 58 - .../daml-ledger/tests/ledger_client.spec.ts | 236 ---- .../tests/ledger_configuration_client.spec.ts | 86 -- .../tests/ledger_identity_client.spec.ts | 23 - .../daml-ledger/tests/mapping/mapping.spec.ts | 1246 ----------------- .../tests/mapping/mapping_reference.spec.ts | 630 --------- .../tests/mock/client_readable_stream.ts | 49 - .../tests/mock/client_unary_call.ts | 34 - .../js/daml-ledger/tests/mock/index.ts | 16 - .../mocked_active_contracts_service_client.ts | 24 - .../tests/mock/mocked_command_client.ts | 28 - .../mock/mocked_command_completion_client.ts | 38 - .../mock/mocked_command_submission_client.ts | 29 - .../mocked_ledger_configuration_client.ts | 29 - .../mock/mocked_ledger_identity_client.ts | 27 - .../tests/mock/mocked_package_client.ts | 68 - .../tests/mock/mocked_reset_client.ts | 35 - .../tests/mock/mocked_time_client.ts | 46 - .../tests/mock/mocked_transaction_client.ts | 86 -- .../tests/mock/mocked_transaction_server.ts | 45 - .../tests/mock/spying_dummy_server.ts | 145 -- .../js/daml-ledger/tests/model.spec.ts | 40 - .../daml-ledger/tests/package_client.spec.ts | 108 -- .../js/daml-ledger/tests/reset_client.spec.ts | 30 - .../js/daml-ledger/tests/time_client.spec.ts | 155 -- .../tests/transaction_client.spec.ts | 390 ------ .../tests/validation/base/array.spec.ts | 429 ------ .../tests/validation/base/enumeration.spec.ts | 42 - .../tests/validation/base/native.spec.ts | 42 - .../tests/validation/base/object.spec.ts | 278 ---- .../tests/validation/base/record.spec.ts | 114 -- .../tests/validation/base/tree.spec.ts | 71 - .../tests/validation/base/union.spec.ts | 108 -- .../js/daml-ledger/tests/validation/index.ts | 29 - .../tests/validation/object.spec.ts | 135 -- .../tests/validation/union.spec.ts | 75 - language-support/js/daml-ledger/tsconfig.json | 10 - language-support/js/docs/BUILD | 20 - language-support/js/docs/jsdoc.json | 32 - language-support/js/install.sh | 20 - package.json | 16 - 321 files changed, 5 insertions(+), 14847 deletions(-) delete mode 100644 docs/source/app-dev/bindings-js/daml-as-json.rst delete mode 100644 docs/source/app-dev/bindings-js/getting-started.rst delete mode 100644 docs/source/app-dev/bindings-js/index.rst delete mode 100644 docs/source/app-dev/bindings-js/tutorial.rst delete mode 100644 language-support/js/BUILD delete mode 100644 language-support/js/README.md delete mode 100755 language-support/js/codegen.sh delete mode 100644 language-support/js/daml-codegen/BUILD delete mode 100644 language-support/js/daml-codegen/index.ts delete mode 100644 language-support/js/daml-codegen/module_tree.ts delete mode 100644 language-support/js/daml-codegen/options.ts delete mode 100644 language-support/js/daml-codegen/package.json delete mode 100644 language-support/js/daml-codegen/processor.ts delete mode 100644 language-support/js/daml-codegen/tsconfig.json delete mode 100644 language-support/js/daml-grpc/BUILD delete mode 100644 language-support/js/daml-grpc/index.ts delete mode 100644 language-support/js/daml-grpc/lf/index.ts delete mode 100644 language-support/js/daml-grpc/package.json delete mode 100755 language-support/js/daml-grpc/test.sh delete mode 100644 language-support/js/daml-grpc/test.ts delete mode 100644 language-support/js/daml-grpc/testing/index.ts delete mode 100644 language-support/js/daml-grpc/tsconfig.json delete mode 100644 language-support/js/daml-ledger/BUILD delete mode 100644 language-support/js/daml-ledger/README.md delete mode 100644 language-support/js/daml-ledger/UNRELEASED.md delete mode 100644 language-support/js/daml-ledger/VALIDATION.md delete mode 100644 language-support/js/daml-ledger/package.json delete mode 100644 language-support/js/daml-ledger/src/call/client_cancellable_call.ts delete mode 100644 language-support/js/daml-ledger/src/call/client_readable_object_stream.ts delete mode 100644 language-support/js/daml-ledger/src/call/index.ts delete mode 100644 language-support/js/daml-ledger/src/call/mapping_transform.ts delete mode 100644 language-support/js/daml-ledger/src/client/active_contracts_client.ts delete mode 100644 language-support/js/daml-ledger/src/client/command_client.ts delete mode 100644 language-support/js/daml-ledger/src/client/command_completion_client.ts delete mode 100644 language-support/js/daml-ledger/src/client/command_submission_client.ts delete mode 100644 language-support/js/daml-ledger/src/client/index.ts delete mode 100644 language-support/js/daml-ledger/src/client/ledger_configuration_client.ts delete mode 100644 language-support/js/daml-ledger/src/client/ledger_identity_client.ts delete mode 100644 language-support/js/daml-ledger/src/client/package_client.ts delete mode 100644 language-support/js/daml-ledger/src/client/testing/index.ts delete mode 100644 language-support/js/daml-ledger/src/client/testing/reset_client.ts delete mode 100644 language-support/js/daml-ledger/src/client/testing/time_client.ts delete mode 100644 language-support/js/daml-ledger/src/client/transaction_client.ts delete mode 100644 language-support/js/daml-ledger/src/daml_ledger_client.ts delete mode 100644 language-support/js/daml-ledger/src/index.ts delete mode 100644 language-support/js/daml-ledger/src/ledger_client.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/any.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/archived_event.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/checkpoint.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/command.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/commands.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/completion.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/completion_end_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/completion_stream_request.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/completion_stream_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/create_command.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/created_event.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/duration.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/event.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/exercise_command.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/exercised_event.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/filters.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_active_contracts_request.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_active_contracts_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_ledger_configuration_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_ledger_end_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_ledger_identity_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_package_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_package_status_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_time_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_transaction_by_event_id_request.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_transaction_by_id_request.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_transaction_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_transaction_trees_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_transactions_request.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/get_transactions_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/identifier.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/inclusive_filters.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/index.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/ledger_configuration.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/ledger_offset.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/list_packages_response.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/mapping.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/optional.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/package_status.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/record.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/set_time_request.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/status.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/submit_and_wait_request.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/submit_request.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/timestamp.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/transaction.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/transaction_filter.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/transaction_tree.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/tree_event.ts delete mode 100644 language-support/js/daml-ledger/src/mapping/value.ts delete mode 100644 language-support/js/daml-ledger/src/model/any.ts delete mode 100644 language-support/js/daml-ledger/src/model/archived_event.ts delete mode 100644 language-support/js/daml-ledger/src/model/checkpoint.ts delete mode 100644 language-support/js/daml-ledger/src/model/command.ts delete mode 100644 language-support/js/daml-ledger/src/model/commands.ts delete mode 100644 language-support/js/daml-ledger/src/model/completion.ts delete mode 100644 language-support/js/daml-ledger/src/model/completion_end_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/completion_stream_request.ts delete mode 100644 language-support/js/daml-ledger/src/model/completion_stream_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/create_command.ts delete mode 100644 language-support/js/daml-ledger/src/model/created_event.ts delete mode 100644 language-support/js/daml-ledger/src/model/duration.ts delete mode 100644 language-support/js/daml-ledger/src/model/empty.ts delete mode 100644 language-support/js/daml-ledger/src/model/event.ts delete mode 100644 language-support/js/daml-ledger/src/model/exercise_command.ts delete mode 100644 language-support/js/daml-ledger/src/model/exercised_event.ts delete mode 100644 language-support/js/daml-ledger/src/model/filters.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_active_contracts_request.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_active_contracts_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_ledger_configuration_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_ledger_end_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_ledger_identity_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_package_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_package_status_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_time_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_transaction_by_event_id_request.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_transaction_by_id_request.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_transaction_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_transaction_trees_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_transactions_request.ts delete mode 100644 language-support/js/daml-ledger/src/model/get_transactions_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/hash_function.ts delete mode 100644 language-support/js/daml-ledger/src/model/identifier.ts delete mode 100644 language-support/js/daml-ledger/src/model/inclusive_filters.ts delete mode 100644 language-support/js/daml-ledger/src/model/index.ts delete mode 100644 language-support/js/daml-ledger/src/model/ledger_configuration.ts delete mode 100644 language-support/js/daml-ledger/src/model/ledger_offset.ts delete mode 100644 language-support/js/daml-ledger/src/model/list_packages_response.ts delete mode 100644 language-support/js/daml-ledger/src/model/optional.ts delete mode 100644 language-support/js/daml-ledger/src/model/package_status.ts delete mode 100644 language-support/js/daml-ledger/src/model/record.ts delete mode 100644 language-support/js/daml-ledger/src/model/set_time_request.ts delete mode 100644 language-support/js/daml-ledger/src/model/status.ts delete mode 100644 language-support/js/daml-ledger/src/model/submit_and_wait_request.ts delete mode 100644 language-support/js/daml-ledger/src/model/submit_request.ts delete mode 100644 language-support/js/daml-ledger/src/model/timestamp.ts delete mode 100644 language-support/js/daml-ledger/src/model/transaction.ts delete mode 100644 language-support/js/daml-ledger/src/model/transaction_filter.ts delete mode 100644 language-support/js/daml-ledger/src/model/transaction_tree.ts delete mode 100644 language-support/js/daml-ledger/src/model/tree_event.ts delete mode 100644 language-support/js/daml-ledger/src/model/value.ts delete mode 100644 language-support/js/daml-ledger/src/model/variant.ts delete mode 100644 language-support/js/daml-ledger/src/reporting/index.ts delete mode 100644 language-support/js/daml-ledger/src/reporting/json_reporter.ts delete mode 100644 language-support/js/daml-ledger/src/reporting/simple_reporter.ts delete mode 100644 language-support/js/daml-ledger/src/util/callback.ts delete mode 100644 language-support/js/daml-ledger/src/util/index.ts delete mode 100644 language-support/js/daml-ledger/src/validation/any.ts delete mode 100644 language-support/js/daml-ledger/src/validation/archived_event.ts delete mode 100644 language-support/js/daml-ledger/src/validation/base/array.ts delete mode 100644 language-support/js/daml-ledger/src/validation/base/enumeration.ts delete mode 100644 language-support/js/daml-ledger/src/validation/base/error.ts delete mode 100644 language-support/js/daml-ledger/src/validation/base/index.ts delete mode 100644 language-support/js/daml-ledger/src/validation/base/native.ts delete mode 100644 language-support/js/daml-ledger/src/validation/base/object.ts delete mode 100644 language-support/js/daml-ledger/src/validation/base/record.ts delete mode 100644 language-support/js/daml-ledger/src/validation/base/tree.ts delete mode 100644 language-support/js/daml-ledger/src/validation/base/typelevel.ts delete mode 100644 language-support/js/daml-ledger/src/validation/base/union.ts delete mode 100644 language-support/js/daml-ledger/src/validation/checkpoint.ts delete mode 100644 language-support/js/daml-ledger/src/validation/command.ts delete mode 100644 language-support/js/daml-ledger/src/validation/commands.ts delete mode 100644 language-support/js/daml-ledger/src/validation/completion.ts delete mode 100644 language-support/js/daml-ledger/src/validation/completion_end_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/completion_stream_request.ts delete mode 100644 language-support/js/daml-ledger/src/validation/completion_stream_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/create_command.ts delete mode 100644 language-support/js/daml-ledger/src/validation/created_event.ts delete mode 100644 language-support/js/daml-ledger/src/validation/duration.ts delete mode 100644 language-support/js/daml-ledger/src/validation/empty.ts delete mode 100644 language-support/js/daml-ledger/src/validation/event.ts delete mode 100644 language-support/js/daml-ledger/src/validation/exercise_command.ts delete mode 100644 language-support/js/daml-ledger/src/validation/exercised_event.ts delete mode 100644 language-support/js/daml-ledger/src/validation/filters.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_active_contracts_request.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_active_contracts_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_ledger_configuration_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_ledger_end_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_ledger_identity_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_package_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_package_status_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_time_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_transaction_by_event_id_request.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_transaction_by_id_request.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_transaction_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_transaction_trees_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_transactions_request.ts delete mode 100644 language-support/js/daml-ledger/src/validation/get_transactions_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/hash_function.ts delete mode 100644 language-support/js/daml-ledger/src/validation/identifier.ts delete mode 100644 language-support/js/daml-ledger/src/validation/inclusive_filters.ts delete mode 100644 language-support/js/daml-ledger/src/validation/index.ts delete mode 100644 language-support/js/daml-ledger/src/validation/ledger_configuration.ts delete mode 100644 language-support/js/daml-ledger/src/validation/ledger_offset.ts delete mode 100644 language-support/js/daml-ledger/src/validation/list_packages_response.ts delete mode 100644 language-support/js/daml-ledger/src/validation/optional.ts delete mode 100644 language-support/js/daml-ledger/src/validation/package_status.ts delete mode 100644 language-support/js/daml-ledger/src/validation/record.ts delete mode 100644 language-support/js/daml-ledger/src/validation/set_time_request.ts delete mode 100644 language-support/js/daml-ledger/src/validation/status.ts delete mode 100644 language-support/js/daml-ledger/src/validation/submit_and_wait_request.ts delete mode 100644 language-support/js/daml-ledger/src/validation/submit_request.ts delete mode 100644 language-support/js/daml-ledger/src/validation/timestamp.ts delete mode 100644 language-support/js/daml-ledger/src/validation/transaction.ts delete mode 100644 language-support/js/daml-ledger/src/validation/transaction_filter.ts delete mode 100644 language-support/js/daml-ledger/src/validation/transaction_tree.ts delete mode 100644 language-support/js/daml-ledger/src/validation/tree_event.ts delete mode 100644 language-support/js/daml-ledger/src/validation/value.ts delete mode 100644 language-support/js/daml-ledger/src/validation/variant.ts delete mode 100755 language-support/js/daml-ledger/test.sh delete mode 100644 language-support/js/daml-ledger/tests/active_contracts_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/any.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/checkpoint.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/command.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/commands.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/completion.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/completion_end_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/completion_stream_request.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/completion_stream_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/create_command.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/duration.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/empty.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/event.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/exercise_command.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/filters.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_active_contracts_request.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_active_contracts_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_ledger_configuration_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_ledger_end_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_ledger_identity_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_package_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_package_status_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_time_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_transaction_by_event_id_request.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_transaction_by_id_request.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_transaction_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_transaction_trees_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_transactions_request.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/get_transactions_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/identifier.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/inclusive_filters.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/index.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/ledger_configuration.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/ledger_offset.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/list_packages_response.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/maybe.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/optional.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/record_value_variant.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/set_time_request.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/status.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/submit_and_wait_request.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/submit_request.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/timestamp.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/transaction.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/transaction_filter.ts delete mode 100644 language-support/js/daml-ledger/tests/arbitrary/transaction_tree.ts delete mode 100644 language-support/js/daml-ledger/tests/certs/ca.crt delete mode 100644 language-support/js/daml-ledger/tests/certs/ca.key delete mode 100644 language-support/js/daml-ledger/tests/certs/client.crt delete mode 100644 language-support/js/daml-ledger/tests/certs/client.csr delete mode 100644 language-support/js/daml-ledger/tests/certs/client.key delete mode 100644 language-support/js/daml-ledger/tests/certs/index.ts delete mode 100644 language-support/js/daml-ledger/tests/certs/server.crt delete mode 100644 language-support/js/daml-ledger/tests/certs/server.csr delete mode 100644 language-support/js/daml-ledger/tests/certs/server.key delete mode 100644 language-support/js/daml-ledger/tests/client_readable_object_stream.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/command_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/command_completion_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/command_submission_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/end_to_end_ssl.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/end_to_end_stream.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/ledger_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/ledger_configuration_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/ledger_identity_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/mapping/mapping.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/mapping/mapping_reference.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/client_readable_stream.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/client_unary_call.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/index.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_active_contracts_service_client.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_command_client.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_command_completion_client.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_command_submission_client.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_ledger_configuration_client.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_ledger_identity_client.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_package_client.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_reset_client.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_time_client.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_transaction_client.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/mocked_transaction_server.ts delete mode 100644 language-support/js/daml-ledger/tests/mock/spying_dummy_server.ts delete mode 100644 language-support/js/daml-ledger/tests/model.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/package_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/reset_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/time_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/transaction_client.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/validation/base/array.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/validation/base/enumeration.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/validation/base/native.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/validation/base/object.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/validation/base/record.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/validation/base/tree.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/validation/base/union.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/validation/index.ts delete mode 100644 language-support/js/daml-ledger/tests/validation/object.spec.ts delete mode 100644 language-support/js/daml-ledger/tests/validation/union.spec.ts delete mode 100644 language-support/js/daml-ledger/tsconfig.json delete mode 100644 language-support/js/docs/BUILD delete mode 100644 language-support/js/docs/jsdoc.json delete mode 100755 language-support/js/install.sh diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 6d7cfcbdad5..4675c3e333c 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -158,7 +158,6 @@ genrule( "//daml-foundations/daml-ghc:daml-base-rst-docs", "//daml-foundations/daml-ghc:daml-base-hoogle-docs", "//language-support/java:javadocs", - "//language-support/js/docs", ], outs = ["html-only.tar.gz"], cmd = (""" @@ -190,10 +189,6 @@ genrule( # Copy Javadoc tar -zxf ../$(locations //language-support/java:javadocs) -C html/app-dev/bindings-java - # Copy in JS docs - tar -zxf ../$(location //language-support/js/docs) -C html/app-dev/bindings-js - mv html/app-dev/bindings-js/docs html/app-dev/bindings-js/reference - # Copy in hoogle DB mkdir -p html/hoogle_db cp -rL ../$(location //daml-foundations/daml-ghc:daml-base-hoogle-docs) html/hoogle_db/base.txt diff --git a/docs/source/app-dev/bindings-js/daml-as-json.rst b/docs/source/app-dev/bindings-js/daml-as-json.rst deleted file mode 100644 index 45ec059cf71..00000000000 --- a/docs/source/app-dev/bindings-js/daml-as-json.rst +++ /dev/null @@ -1,41 +0,0 @@ -.. Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -.. SPDX-License-Identifier: Apache-2.0 - -.. _bindings-js-daml-as-json: - -DAML as JSON -############ - -The Node.js bindings accept as parameters and return as results plain JavaScript objects. - -More specifically, these objects are subset that is fully compatible with the JSON data-interchange format. This means that any request and response to and from the ledger can be easily used with other services that accept JSON as an input format. - -The `reference documentation`_ is more specific about the expected shape of objects sent to and received from the ledger, but to give you a sense of how these objects look, the following represents the creation of a ``Pvp`` record. - -.. code-block:: javascript - - { - create: { - templateId: { packageId: '934023fa9c89e8f89b8a', name: 'Pvp.Pvp' }, - arguments: { - recordId: { packageId: '934023fa9c89e8f89b8a', name: 'Pvp.Pvp' }, - fields: { - buyer : { party: 'some-buyer' }, - seller : { party: 'some-seller' }, - baseIssuer : { party: 'some-base-issuer' }, - baseCurrency : { text: 'CHF' }, - baseAmount : { decimal: '1000000.00' }, - baseIouCid : { variant: { variantId: { packageId: 'ba777d8d7c88e87f7', name: 'Maybe' }, constructor: 'Just', value: { contractId: '76238b8998a98d98e978f' } } }, - quoteIssuer : { party: 'some-quote-issuer' }, - quoteCurrency: { text: 'USD' }, - quoteAmount : { decimal: '1000001.00' }, - quoteIouCid : { variant: { variantId: { packageId: 'ba777d8d7c88e87f7', name: 'Maybe' }, constructor: 'Just', value: { contractId: '76238b8998a98d98e978f' } } }, - settleTime : { timestamp: 93641099000000000 } - } - } - } - } - -Notice that fields of a template are represented as keys in ``fields``. Each value is then another object, where the key is the type. This is necessary for the ledger to disambiguate between, for example, strings that represent ``text`` and strings that represent a ``decimal``. - -.. _reference documentation: ./reference/index.html diff --git a/docs/source/app-dev/bindings-js/getting-started.rst b/docs/source/app-dev/bindings-js/getting-started.rst deleted file mode 100644 index ec31f70b20a..00000000000 --- a/docs/source/app-dev/bindings-js/getting-started.rst +++ /dev/null @@ -1,41 +0,0 @@ -.. Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -.. SPDX-License-Identifier: Apache-2.0 - -.. _bindings-js-getting-started: - -Getting started -############### - -1. Set up NPM -************* - -The Node.js bindings are published on NPM. - -To set up NPM: - -1. `login to Bintray`_ -2. go to the `Digital Asset NPM repository home page on Bintray`_ -3. click on the "Set me up!" button -4. follow the instructions for scoped packages with scope `da` - -2. Start a new project -********************** - -Use ``npm init`` to create a new project. - -3. Install the bindings -*********************** - -Use the NPM command line interface: - -.. code-block:: bash - - npm install @da/daml-ledger - -4. Start coding -*************** - -To guide you through using the Node.js bindings, we provide a tutorial template and a :doc:`tutorial `. - -.. _login to Bintray: https://bintray.com/login?forwardedFrom=%2Fdigitalassetsdk -.. _Digital Asset NPM repository home page on Bintray: https://bintray.com/digitalassetsdk/npm \ No newline at end of file diff --git a/docs/source/app-dev/bindings-js/index.rst b/docs/source/app-dev/bindings-js/index.rst deleted file mode 100644 index 884465440a0..00000000000 --- a/docs/source/app-dev/bindings-js/index.rst +++ /dev/null @@ -1,22 +0,0 @@ -.. Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -.. SPDX-License-Identifier: Apache-2.0 - -Node.js bindings -################ - -.. toctree:: - :hidden: - - getting-started - tutorial - daml-as-json - -The Node.js bindings let you access the Ledger API from Node.js code. - -The Installing page guides you through the process of :doc:`getting-started`. - -After that, a tutorial teaches you :doc:`how to build a simple application from scratch `. - -Finally, `the API reference documentation`_ and :doc:`an introduction to DAML as JSON ` are also available. - -.. _the API reference documentation: ./reference/index.html diff --git a/docs/source/app-dev/bindings-js/tutorial.rst b/docs/source/app-dev/bindings-js/tutorial.rst deleted file mode 100644 index cf0166d8487..00000000000 --- a/docs/source/app-dev/bindings-js/tutorial.rst +++ /dev/null @@ -1,951 +0,0 @@ -.. Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -.. SPDX-License-Identifier: Apache-2.0 - -.. _bindings-js-tutorial: - -Tutorial -######## - -This tutorial guides you through a series of steps to write a simple application. - -The purpose is to learn the basics of how to use the Node.js bindings. - -The task is to build an application able to send and receive "ping" messages. - -The focus is not on the complexity of the model, but rather on how to use the bindings to interact with the ledger. - -Create the project -****************** - -Start from the skeleton available `here `_. - -To set it up, clone the repo: - -.. code-block:: bash - - git clone https://github.com/digital-asset/ex-tutorial-nodejs.git - cd ex-tutorial-nodejs - -The skeleton includes ``daml/PingPong.daml``, which is the source for a DAML module with two templates: ``Ping`` and ``Pong``. The app uses these. - -Run the sandbox -*************** - -Use the sandbox to run and test your application. - -Now that you created the project and you're in its directory, start the sandbox by running: - -.. code-block:: bash - - da sandbox - -Starting the sandbox automatically compiles ``PingPong.daml`` and loads it. - -Run the skeleton app -******************** - -You are now set to write your own application. The template includes a skeleton app that connects to a running ledger and quits. - -1. Install the dependencies for your package (including the bindings): - -.. code-block:: bash - - npm install - -2. Start the application: - -.. code-block:: bash - - npm start - -3. Verify the output is correct - -.. code-block:: bash - - hello from - -Understand the skeleton -*********************** - -The code for the script you just ran is ``index.js``. - -Let's go through the skeleton part by part to understand what's going on: - -.. code-block:: javascript - - const da = require('@da/daml-ledger').data; - - const uuidv4 = require('uuid/v4'); - -The first line loads the bindings and allows you to refer to them through the ``da`` object. - -The second one introduces a dependency that is going to be later used to generate unique identifiers; no need to worry about it now. - -.. code-block:: javascript - - let [, , host, port] = process.argv; - - host = host || 'localhost'; - port = port || 6865; - -These lines read the command-line arguments and provide some sensible defaults. - -Now to the juicy part: - -.. code-block:: javascript - - da.DamlLedgerClient.connect({ host: host, port: port }, (error, client) => { - if (error) throw error; - console.log('hello from', client.ledgerId); - }); - -Here the application connects to the ledger with the ``DamlLedgerClient.connect`` method. - -It accepts two arguments: - -- an object with the connection options -- a callback to be invoked when the connection either fails or succeeds - -The connection options require you to pass the ``host`` and ``port`` of the ledger instance you are connecting to. - -The callback follows the common pattern in Node.js of being invoked with two arguments: the first is an error in case of failure while the latter is the response in case of success. - -In this case in particular, the response in case of success is a ``client`` object that can be used to communicate with the ledger. - -The skeleton application just prints the greeting message with the ledger identifier and quits. - -Retrieve the package identifiers -******************************** - -Now that the sandbox is running, the ``PingPong.daml`` file has been compiled and the module loaded onto the ledger. - -In order for you to refer to the templates therein you need its package identifier. - -This template includes a script that connects to a running ledger instance and downloads the package identifiers for the templates. - -Run it now: - -.. code-block:: javascript - - npm run fetch-template-ids - -If the program ran successfully, the project root now contains the ``template-ids.json`` file. - -It's time to write some code to verify that you're good to go. Open the ``index.js`` file and edit it. - -First of all, right after the first ``require`` statement, add a new one to load the ``template-ids.json`` file that has just been created. - -.. code-block:: javascript - - const da = require('@da/daml-ledger').data; - const templateIds = require('./template-ids.json'); - -Right beneath that line, initialize two constants to hold the ``Ping`` and ``Pong`` template identifiers: - -.. code-block:: javascript - - const PING = templateIds['PingPong.Ping']; - const PONG = templateIds['PingPong.Pong']; - -Finally print the template identifiers: - -.. code-block:: bash - - da.DamlLedgerClient.connect({ host: host, port: port }, (error, client) => { - if (error) throw error; - console.log('hello from', client.ledgerId); - console.log('Ping', PING); - console.log('Pong', PONG); - }); - -Run the application again (``npm start``) to see an output like the following: - -.. code-block:: bash - - hello from sandbox-3957952d-f475-4d2f-be89-245a0799d2c0 - Ping { packageId: - '5976641aeea761fa8946ea004b318a74d869ee305fafcdc6bf98d31fa354304d', - name: 'PingPong.Ping' } - Pong { packageId: - '5976641aeea761fa8946ea004b318a74d869ee305fafcdc6bf98d31fa354304d', - name: 'PingPong.Pong' } - -The ``PingPong`` module -*********************** - -Before moving on to the implementation of the application, have a look at ``daml/PingPong.daml`` to understand the module the app uses. - -``Ping`` and ``Pong`` are almost identical. Looking at them in detail: - -- both have a ``sender`` signatory and a ``receiver`` observer -- the receiver of a ``Ping`` can exercise the ``ReplyPong`` choice, creating a ``Pong`` contract with swapped ``sender`` and ``receiver`` -- symmetrically, the receiver of a ``Pong`` contract can exercise the ``ReplyPing`` choice, creating a ``Ping`` contract with swapped parties - -Note that the contracts carry a counter: when the counter reaches 3, no new contract is created and the exchange stops. - -Pass the parties as parameters -****************************** - -Everything's now ready to start working. Edit the ``index.js`` file. - -Each contract has a sender and a receiver, so your application needs to establish it. - -Read those from the command line by editing the part where the arguments are read as follows: - -.. code-block:: javascript - - let [, , sender, receiver, host, port] = process.argv; - host = host || 'localhost'; - port = port || 6865; - if (!sender || !receiver) { - console.log('Missing sender and/or receiver arguments, exiting.'); - process.exit(-1); - } - -Try to run it without arguments (or with just one) to see the error popping up. - -Try to run it with both arguments to see the application working just as it did before. - -Create a contract -***************** - -To kickstart the exchange between two parties you have to first make one party *"send"* the initial ping to the other. - -To do this you need to create a ``Ping`` contract. - -This requires you to submit a command to the ledger. For this, use the ``CommandService``. - -The ``client`` object returned by the ``DamlLedgerClient.connect`` method contains a reference to all services exposed by the ledger, including the ``CommandService``. - -First of all, the following is the ``request`` for the ``CommandService``. Have a look at it: - -.. code-block:: javascript - - const request = { - commands: { - applicationId: 'PingPongApp', - workflowId: `Ping-${sender}`, - commandId: uuidv4(), - ledgerEffectiveTime: { seconds: 0, nanoseconds: 0 }, - maximumRecordTime: { seconds: 5, nanoseconds: 0 }, - party: sender, - list: [ - { - create: { - templateId: PING, - arguments: { - fields: { - sender: { party: sender }, - receiver: { party: receiver }, - count: { int64: 0 } - } - } - } - } - ] - } - }; - -This object represents the submission of a set of commands to be applied atomically. Let's see what each bit of it means: - -- ``applicationId`` - the name of your application -- ``commandId`` - a unique identifier for the set of submitted commands -- ``workflowId`` - an (optional) identifier you can use to group together commands pertaining to one of your workflows -- ``ledgerEffectiveTime`` - the time at which the set of submitted commands are applied; normally the client's current epoch time, but, since the sandbox (by default) runs with a static time fixed at epoch 0, use this value -- ``maximumRecordTime`` - the time at which the command is considered expired if it's not been applied yet; the difference with the ``maximumRecordTime`` is the time-to-live (TTL) of the command -- ``party`` - who's submitting the command - -Finally, ``list`` contains all the commands to be applied. In this case, it submits a ``create`` command. - -Have a look at the only command: - -- ``templateId`` - the identifier of the template of the contract you wish to create (``Ping``) -- ``arguments`` - an object containing the ``fields`` necessary to create the contract - -The keys of the ``fields`` object are the template parameter names as they appear on ``daml/PingPong.daml``, while the values are a pair with the type and the value being passed (in this case two parties). - -The request can now be passed to the ``CommandService`` as follows: - -.. code-block:: javascript - - client.commandClient.submitAndWait(request, (error, _) => { - if (error) throw error; - console.log(`Created Ping contract from ${sender} to ${receiver}.`); - }); - -This is already a sizeable chunk of code that performs a clearly defined task. Within the body of the ``connect`` callback, wrap the code from this section in a function called ``createFirstPing`` and call it. - -The code should now look like the following: - -.. code-block:: javascript - - da.DamlLedgerClient.connect({ host: host, port: port }, (error, client) => { - if (error) throw error; - - createFirstPing(); - - function createFirstPing() { - const request = { - commands: { - applicationId: 'PingPongApp', - workflowId: `Ping-${sender}`, - commandId: uuidv4(), - ledgerEffectiveTime: { seconds: 0, nanoseconds: 0 }, - maximumRecordTime: { seconds: 5, nanoseconds: 0 }, - party: sender, - list: [ - { - create: { - templateId: PING, - arguments: { - fields: { - sender: { party: sender }, - receiver: { party: receiver }, - count: { int64: 0 } - } - } - } - } - ] - } - }; - client.commandClient.submitAndWait(request, (error, _) => { - if (error) throw error; - console.log(`Created Ping contract from ${sender} to ${receiver}.`); - }); - } - - }); - -Time to test your application. Run it like this: - -.. code-block:: bash - - npm start Alice Bob - -You should see the following output: - -.. code-block:: bash - - Created Ping contract from Alice to Bob. - -Your application now successfully creates a ``Ping`` contract on the ledger, congratulations! - -Read the transactions -********************* - -Now that the application can create a contract to send a *ping*, it must also be able to listen to *pongs* on the ledger so that it can react to those. - -The ``TransactionService`` exposes the functionality to read transactions from the ledger via the ``getTransactions`` method. - -This method takes the following request: - -.. code-block:: javascript - - const filtersByParty = {}; - filtersByParty[sender] = { inclusive: { templateIds: [PING, PONG] } }; - const request = { - begin: { boundary: da.LedgerOffset.Boundary.END }, - filter: { filtersByParty: filtersByParty } - }; - -Have a look at the request: - -- ``begin`` - the offset at which you'll start reading transactions from the ledger. In this case you want to listen starting from the latest one (represented by the constant ``da.LedgerOffset.Boundary.END``) -- ``end`` - the optional offset at which you want the reads to end -- if absent (as in this case) the application keeps listening to incoming transactions -- ``filter`` - represents which contracts you want the ledger to show you: in this case you are asking for the transactions visible to ``sender`` containing contracts whose ``templateId`` matches either ``PING`` or ``PONG``. - -When the ``getTransactions`` method is invoked with this request the application listens to the latest transactions coming to the ledger. - -The output of this method is a Node.js stream. As such, you can register callbacks on the ``'data'`` and ``'error'`` events. - -The following code prints the incoming transaction and quits in case of ``'error'``. - -.. code-block:: javascript - - const transactions = client.transactionClient.getTransactions(request); - console.log(`${sender} starts reading transactions.`); - transactions.on('data', response => { - for (const transaction of response.transactions) { - console.log('Transaction read:', transaction.transactionId); - } - }); - transactions.on('error', error => { - console.error(`${sender} encountered an error while processing transactions!`); - console.error(error); - process.exit(-1); - }); - -.. note:: - - If your request specified an ``end``, it would most probably make sense to register an ``'end'`` event callback on the stream as well. - -Again, this code represents a sizeable chunk of code with a clearly defined purpose. - -Wrap this code in a new function called ``listenForTransactions``, place it within the ``connect`` callback and call ``listenForTransactions`` right before you call ``createFirstPing``. - -When you are done, your code should look like the following: - -.. code-block:: javascript - - da.DamlLedgerClient.connect({ host: host, port: port }, (error, client) => { - if (error) throw error; - - listenForTransactions(); - createFirstPing(); - - function createFirstPing() { - const request = { - commands: { - applicationId: 'PingPongApp', - workflowId: `Ping-${sender}`, - commandId: uuidv4(), - ledgerEffectiveTime: { seconds: 0, nanoseconds: 0 }, - maximumRecordTime: { seconds: 5, nanoseconds: 0 }, - party: sender, - list: [ - { - create: { - templateId: PING, - arguments: { - fields: { - sender: { party: sender }, - receiver: { party: receiver }, - count: { int64: 0 } - } - } - } - } - ] - } - }; - client.commandClient.submitAndWait(request, error => { - if (error) throw error; - console.log(`Created Ping contract from ${sender} to ${receiver}.`); - }); - } - - function listenForTransactions() { - console.log(`${sender} starts reading transactions.`); - const filtersByParty = {}; - filtersByParty[sender] = { inclusive: { templateIds: [PING, PONG] } }; - const request = { - begin: { boundary: da.LedgerOffset.Boundary.END }, - filter: { filtersByParty: filtersByParty } - }; - const transactions = client.transactionClient.getTransactions(request); - transactions.on('data', response => { - for (const transaction of response.transactions) { - console.log('Transaction read:', transaction.transactionId); - } - }); - transactions.on('error', error => { - console.error(`${sender} encountered an error while processing transactions!`); - console.error(error); - process.exit(-1); - }); - } - - }); - -Your application now should: - -- start listening to pings and pongs visible to the sender -- create the first ping -- receive the ping it created and print its transaction identifer - -If you now run - -.. code-block:: bash - - npm start Alice Bob - -You should see an output like the following: - -.. code-block:: bash - - Alice starts reading transactions. - Created Ping contract from Alice to Bob. - Transaction read: 1 - -Your application is now able to create contracts and listen to transactions on the ledger. Very good! -You can now hit CTRL-C to quit the application. - -Exercise a choice -***************** - -The last piece of functionality you need consists of reacting to pings and pongs that you read from the ledger, represented by the creation of contracts. - -For this, use again the ``submitAndWait`` method. - -In particular, make your program exercise a choice: ``ReplyPing`` when you receive a ``Pong`` and vice versa. - -You need to react to events in transactions as they are received in the ``listenForTransactions`` function. - -The ``transaction`` object whose ``transactionId`` you printed so far contains an array of ``event`` objects, each representing an ``archived`` or ``created`` event on a contract. - -What you want to do is loop through the events in the transaction and extract the ``receiver`` and ``count`` fields from ``created`` events. - -You then want to decide which reply to give (either ``ReplyPing`` or ``ReplyPong``) based on the contract that has been read. - -For each created event, you want to send a command that reacts to it, specifying that you want to either exercise the ``ReplyPing`` choice of a ``Pong`` contract or vice versa. - -The following snippet of code does precisely this. - -.. code-block:: javascript - - const reactions = []; - for (const event of events) { - const { receiver: { party: receiver }, count: { int64: count } } = event.arguments.fields; - if (receiver === sender) { - const templateId = event.templateId; - const contractId = event.contractId; - const reaction = templateId.name == PING.name ? 'ReplyPong' : 'ReplyPing'; - console.log(`${sender} (workflow ${workflowId}): ${reaction} at count ${count}`); - reactions.push({ - exercise: { - templateId: templateId, - contractId: contractId, - choice: reaction, - argument: { record: { fields: {} } } - } - }); - } - } - -You can now use the ``submitAndWait`` command to send the ``reactions`` to the ledger. - -.. code-block:: javascript - - if (reactions.length > 0) { - const request = { - commands: { - applicationId: 'PingPongApp', - workflowId: workflowId, - commandId: uuidv4(), - ledgerEffectiveTime: { seconds: 0, nanoseconds: 0 }, - maximumRecordTime: { seconds: 5, nanoseconds: 0 }, - party: sender, - list: reactions - } - } - client.commandClient.submitAndWait(request, error => { - if (error) throw error; - }); - } - -Wrap this code into a new function ``react`` that takes a ``workflowId`` and an ``events`` array with the ``created`` events. Then edit the ``listenForTransactions`` function to: - -- accept one parameter called ``callback`` -- instead of printing the transaction identifier, for each transaction - - * push the ``created`` events to an array - * pass that array to the ``callback`` (along with the workflow identifier) - -Finally, pass the ``react`` function as a parameter to the only call of ``listenForTransactions``. - -Your code should now look like the following: - -.. code-block:: javascript - - da.DamlLedgerClient.connect({ host: host, port: port }, (error, client) => { - if (error) throw error; - - listenForTransactions(react); - createFirstPing(); - - function createFirstPing() { - const request = { - commands: { - applicationId: 'PingPongApp', - workflowId: `Ping-${sender}`, - commandId: uuidv4(), - ledgerEffectiveTime: { seconds: 0, nanoseconds: 0 }, - maximumRecordTime: { seconds: 5, nanoseconds: 0 }, - party: sender, - list: [ - { - create: { - templateId: PING, - arguments: { - fields: { - sender: { party: sender }, - receiver: { party: receiver }, - count: { int64: 0 } - } - } - } - } - ] - } - }; - client.commandClient.submitAndWait(request, error => { - if (error) throw error; - console.log(`Created Ping contract from ${sender} to ${receiver}.`); - }); - } - - function listenForTransactions(callback) { - console.log(`${sender} starts reading transactions.`); - const filtersByParty = {}; - filtersByParty[sender] = { inclusive: { templateIds: [PING, PONG] } }; - const request = { - begin: { boundary: da.LedgerOffset.Boundary.END }, - filter: { filtersByParty: filtersByParty } - }; - const transactions = client.transactionClient.getTransactions(request); - transactions.on('data', response => { - for (const transaction of response.transactions) { - const events = []; - for (const event of transaction.events) { - if (event.created) { - events.push(event.created); - } - } - if (events.length > 0) { - callback(transaction.workflowId, events); - } - } - }); - transactions.on('error', error => { - console.error(`${sender} encountered an error while processing transactions!`); - console.error(error); - process.exit(-1); - }); - } - - function react(workflowId, events) { - const reactions = []; - for (const event of events) { - const { receiver: { party: receiver }, count: { int64: count } } = event.arguments.fields; - if (receiver === sender) { - const templateId = event.templateId; - const contractId = event.contractId; - const reaction = templateId.name == PING.name ? 'ReplyPong' : 'ReplyPing'; - console.log(`${sender} (workflow ${workflowId}): ${reaction} at count ${count}`); - reactions.push({ - exercise: { - templateId: templateId, - contractId: contractId, - choice: reaction, - argument: { record: { fields: {} } } - } - }); - } - } - if (reactions.length > 0) { - const request = { - commands: { - applicationId: 'PingPongApp', - workflowId: workflowId, - commandId: uuidv4(), - ledgerEffectiveTime: { seconds: 0, nanoseconds: 0 }, - maximumRecordTime: { seconds: 5, nanoseconds: 0 }, - party: sender, - list: reactions - } - } - client.commandClient.submitAndWait(request, error => { - if (error) throw error; - }); - } - } - }); - -To test your code you need to run two different commands in two different terminals. - -First, run: - -.. code-block:: bash - - npm start Alice Bob - -After starting this, the application creates a ping contract on the ledger and waits for replies. - -.. code-block:: bash - - Alice starts reading transactions. - Created Ping contract from Alice to Bob. - -Keep this command running, open a new shell and run the following command: - -.. code-block:: bash - - npm start Bob Alice - -You should now see the exchange happening on both terminals. - -``npm start Alice Bob`` - -.. code-block:: bash - - Alice starts reading transactions. - Created Ping contract from Alice to Bob. - Alice (workflow Ping-Bob): Pong at count 0 - Alice (workflow Ping-Bob): Pong at count 2 - -``npm start Bob Alice`` - -.. code-block:: bash - - Bob starts reading transactions. - Created Ping contract from Bob to Alice. - Bob (workflow Ping-Bob): Ping at count 1 - Bob (workflow Ping-Bob): Ping at count 3 - -You can now close both applications. - -Your application is now able to complete the full exchange. Very well done! - - -The Active Contracts Service -**************************** - -So far so good, but there is a flaw. You might have noticed that the application is subscribing for transactions using ``boundary: da.LedgerOffset.Boundary.END``. This means that wherever the ledger is at that time, the application is going to see transactions only after that, missing contracts created earlier. This problem could be addressed by subscribing for transactions from ``boundary: da.LedgerOffset.Boundary.BEGIN``, but then in case of a downtime your application would need to be prepared to handle contracts it has already processed before. To make this recovery easier the API offers a service which returns the set of active contracts on the ledger and an offset with which one can subscribe for transactions. This facilitates ramping up new applications and you can be sure to see contracts only once. - -In this new example the application first processes the current active contracts. Since that process is asynchronous the rest of the program should be passed in as a callback. - -.. code-block:: javascript - - function processActiveContracts(transactionFilter, callback, onComplete) { - const request = { filter: transactionFilter }; - const activeContracts = client.activeContractsClient.getActiveContracts(request); - let offset = undefined; - activeContracts.on('data', response => { - if (response.activeContracts) { - const events = []; - for (const activeContract of response.activeContracts) { - events.push(activeContract); - } - - if (events.length > 0) { - callback(response.workflowId, events); - } - } - - if (response.offset) { - offset = response.offset; - } - }); - - activeContracts.on('error', error => { - console.error(`${sender} encountered an error while processing active contracts!`); - console.error(error); - process.exit(-1); - }); - - activeContracts.on('end', () => onComplete(offset)); - } - - -Note that the transaction filter was factored out as it can be shared. The final code would look like this: - -.. code-block:: javascript - - const da = require('@da/daml-ledger').data; - const templateIds = require('./template-ids.json'); - - const PING = templateIds['PingPong.Ping']; - const PONG = templateIds['PingPong.Pong']; - - const uuidv4 = require('uuid/v4'); - - let [, , sender, receiver, host, port] = process.argv; - host = host || 'localhost'; - port = port || 6865; - if (!sender || !receiver) { - console.log('Missing sender and/or receiver arguments, exiting.'); - process.exit(-1); - } - - da.DamlLedgerClient.connect({ host: host, port: port }, (error, client) => { - if (error) throw error; - - const filtersByParty = {}; - filtersByParty[sender] = { inclusive: { templateIds: [PING, PONG] } }; - const transactionFilter = { filtersByParty: filtersByParty }; - - processActiveContracts(transactionFilter, react, offset => { - listenForTransactions(offset, transactionFilter, react); - createFirstPing(); - }); - - function createFirstPing() { - const request = { - commands: { - applicationId: 'PingPongApp', - workflowId: `Ping-${sender}`, - commandId: uuidv4(), - ledgerEffectiveTime: { seconds: 0, nanoseconds: 0 }, - maximumRecordTime: { seconds: 5, nanoseconds: 0 }, - party: sender, - list: [ - { - create: { - templateId: PING, - arguments: { - fields: { - sender: { party: sender }, - receiver: { party: receiver }, - count: { int64: 0 } - } - } - } - } - ] - } - }; - client.commandClient.submitAndWait(request, error => { - if (error) throw error; - console.log(`Created Ping contract from ${sender} to ${receiver}.`); - }); - } - - function listenForTransactions(offset, transactionFilter, callback) { - console.log(`${sender} starts reading transactions from offset: ${offset.absolute}.`); - const request = { - begin: { boundary: da.LedgerOffset.Boundary.END }, - filter: transactionFilter - }; - const transactions = client.transactionClient.getTransactions(request); - transactions.on('data', response => { - for (const transaction of response.transactions) { - const events = []; - for (const event of transaction.events) { - if (event.created) { - events.push(event.created); - } - } - if (events.length > 0) { - callback(transaction.workflowId, events); - } - } - }); - transactions.on('error', error => { - console.error(`${sender} encountered an error while processing transactions!`); - console.error(error); - process.exit(-1); - }); - } - - function processActiveContracts(transactionFilter, callback, onComplete) { - console.log(`processing active contracts for ${sender}`); - const request = { filter: transactionFilter }; - const activeContracts = client.activeContractsClient.getActiveContracts(request); - let offset = undefined; - activeContracts.on('data', response => { - if (response.activeContracts) { - const events = []; - for (const activeContract of response.activeContracts) { - events.push(activeContract); - } - if (events.length > 0) { - callback(response.workflowId, events); - } - } - - if (response.offset) { - offset = response.offset; - } - }); - - activeContracts.on('error', error => { - console.error(`${sender} encountered an error while processing active contracts!`); - console.error(error); - process.exit(-1); - }); - - activeContracts.on('end', () => onComplete(offset)); - } - - function react(workflowId, events) { - const reactions = []; - for (const event of events) { - const { receiver: { party: receiver }, count: { int64: count } } = event.arguments.fields; - if (receiver === sender) { - const templateId = event.templateId; - const contractId = event.contractId; - const reaction = templateId.name == PING.name ? 'ReplyPong' : 'ReplyPing'; - console.log(`${sender} (workflow ${workflowId}): ${reaction} at count ${count}`); - reactions.push({ - exercise: { - templateId: templateId, - contractId: contractId, - choice: reaction, - argument: { record: { fields: {} } } - } - }); - } - } - if (reactions.length > 0) { - const request = { - commands: { - applicationId: 'PingPongApp', - workflowId: workflowId, - commandId: uuidv4(), - ledgerEffectiveTime: { seconds: 0, nanoseconds: 0 }, - maximumRecordTime: { seconds: 5, nanoseconds: 0 }, - party: sender, - list: reactions - } - }; - client.commandClient.submitAndWait(request, error => { - if (error) throw error; - }); - } - } - }); - -Before running this you should start with a clean ledger to avoid being confused by the unprocessed contracts from previous examples. - -.. code-block:: bash - - da stop - da sandbox - -Then run: - -.. code-block:: bash - - npm start Alice Bob - -in another shell: - -.. code-block:: bash - - npm start Bob Alice - -You should see the following outputs respectively: - -.. code-block:: bash - - processing active contracts for Alice - Alice starts reading transactions from offset: 0. - Created Ping contract from Alice to Bob. - Alice (workflow Ping-Bob): Pong at count 0 - Alice (workflow Ping-Alice): Ping at count 1 - Alice (workflow Ping-Bob): Pong at count 2 - Alice (workflow Ping-Alice): Ping at count 3 - -.. code-block:: bash - - processing active contracts for Bob - Bob (workflow Ping-Alice): Pong at count 0 - Bob starts reading transactions from offset: 1. - Created Ping contract from Bob to Alice. - Bob (workflow Ping-Bob): Ping at count 1 - Bob (workflow Ping-Alice): Pong at count 2 - Bob (workflow Ping-Bob): Ping at count 3 - -Alice joining an empty ledger has no active contracts to process. Bob however, who joins later, will see Alice's ``Ping`` contract and process it. Afterwards he will continue listening to transactions from offset 1. diff --git a/docs/source/experimental/warning.rst b/docs/source/experimental/warning.rst index c3e456df97d..90d736e1cf7 100644 --- a/docs/source/experimental/warning.rst +++ b/docs/source/experimental/warning.rst @@ -10,7 +10,6 @@ The tools described in this section are actively being designed and are subject :titlesonly: :maxdepth: 2 - /app-dev/bindings-js/index Navigator Console Navigator Database - Extractor \ No newline at end of file + Extractor diff --git a/docs/source/support/release-notes.rst b/docs/source/support/release-notes.rst index 9616fc8086e..2bec81798a0 100644 --- a/docs/source/support/release-notes.rst +++ b/docs/source/support/release-notes.rst @@ -9,6 +9,8 @@ This page contains release notes for the SDK. HEAD — ongoing -------------- +- Node.js bindings have been moved `here `` + 0.12.10 — 2019-04-25 -------------------- diff --git a/docs/source/support/roadmap.rst b/docs/source/support/roadmap.rst index fbcae99ab50..09f57134c82 100644 --- a/docs/source/support/roadmap.rst +++ b/docs/source/support/roadmap.rst @@ -15,9 +15,9 @@ We plan to update this roadmap roughly every three months. `More about this on GitHub `__. - **JavaScript / TypeScript ecosystem** - Improve the currently experimental :doc:`JavaScript bindings ` so they are stable, and add TypeScript code generation to generate code from DAML types. + Improve the currently experimental `Node.js bindings `__ so they are stable, and add TypeScript code generation to generate code from DAML types. - `More about this on GitHub `__. + `More about this on GitHub `__. - **Simplified da assistant** Rewritten :doc:`command line for the SDK ` with improved usability. diff --git a/language-support/js/BUILD b/language-support/js/BUILD deleted file mode 100644 index 8186a937dec..00000000000 --- a/language-support/js/BUILD +++ /dev/null @@ -1,38 +0,0 @@ -load("@build_bazel_rules_typescript//:defs.bzl", "ts_config", "ts_library") -load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "nodejs_test", "npm_package") - -nodejs_binary( - name = "grpc_tools_node_protoc", - data = [ - "@npm//grpc-tools", - ], - entry_point = "grpc-tools/bin/protoc.js", - visibility = ["//language-support/js:__subpackages__"], -) - -nodejs_binary( - name = "grpc_tools_node_protoc_js", - data = [ - "@npm//grpc-tools", - ], - entry_point = "grpc-tools/bin/protoc_plugin.js", - visibility = ["//language-support/js:__subpackages__"], -) - -nodejs_binary( - name = "grpc_tools_node_protoc_ts", - data = [ - "@npm//grpc_tools_node_protoc_ts", - ], - entry_point = "grpc_tools_node_protoc_ts/bin/protoc-gen-ts", - visibility = ["//language-support/js:__subpackages__"], -) - -nodejs_binary( - name = "tsc", - data = [ - "@npm//typescript", - ], - entry_point = "typescript/bin/tsc", - visibility = ["//language-support/js:__subpackages__"], -) diff --git a/language-support/js/README.md b/language-support/js/README.md deleted file mode 100644 index a44d79e8d93..00000000000 --- a/language-support/js/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# language-support/js - -Official DAML Ledger API support for JavaScript and TypeScript on the Node.js platform. - ---- - -**WARNING:** The support is currently shipped as an **EXPERIMENTAL** feature. - ---- - -## Prepare the development environment - -As with the rest of the repository, Bazel is used as a build system. - -The build rules currently used have Bazel managing the dependencies centrally throughout the repository. - -The following step is optional but it enables IDEs and editors to pick up the dependencies between packages within this project; in order to build the modules locally and install them in the `node_modules` directory of each package, run the [install.sh](install.sh) script: - - language-support/js/install.sh - -Re-run the script every time you make a change that affects other projects (e.g.: something changes in `daml-grpc` that needs to be picked up by `daml-ledger`). \ No newline at end of file diff --git a/language-support/js/codegen.sh b/language-support/js/codegen.sh deleted file mode 100755 index d9fa890e9e0..00000000000 --- a/language-support/js/codegen.sh +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -#!/usr/bin/env bash - -set -euo pipefail - -cd "$(dirname "$0")" - -bazel build //language-support/js/daml-codegen - -mkdir -p daml-codegen/target/ -tar xzf ../../bazel-genfiles/language-support/js/daml-codegen/daml-codegen.tgz --strip-components=1 -C daml-codegen/target - -node daml-codegen/target/dist/index.js "$@" \ No newline at end of file diff --git a/language-support/js/daml-codegen/BUILD b/language-support/js/daml-codegen/BUILD deleted file mode 100644 index b90a5ace804..00000000000 --- a/language-support/js/daml-codegen/BUILD +++ /dev/null @@ -1,46 +0,0 @@ -load("@build_bazel_rules_typescript//:defs.bzl", "ts_config") - -ts_config( - name = "tsconfig", - src = "tsconfig.json", - deps = ["//:tsconfig.json"], -) - -filegroup( - name = "src", - srcs = glob(["*.ts"]), -) - -# ts_library does not accept arbitrary inputs, so we use a genrule -genrule( - name = "daml-codegen", - srcs = [ - ":src", - "//language-support/js/daml-grpc", - "//language-support/js/daml-ledger", - "package.json", - ":tsconfig", - "@npm//@types/google-protobuf", - "@npm//@types/node", - "@npm//google-protobuf", - "@npm//grpc", - "@npm//typescript", - ], - outs = ["daml-codegen.tgz"], - cmd = """ - set -e - ln -s external/npm/node_modules - mkdir -p node_modules/daml-grpc - tar xzf $(location //language-support/js/daml-grpc) --strip-components=1 -C node_modules/daml-grpc - mkdir -p node_modules/daml-ledger - tar xzf $(location //language-support/js/daml-ledger) --strip-components=1 -C node_modules/daml-ledger - $(execpath //language-support/js:tsc) --build $(location tsconfig) - mkdir -p package - cp -R language-support/js/daml-codegen/dist package - cp $(location package.json) package - tar czf $@ package - """, - tools = [ - "//language-support/js:tsc", - ], -) diff --git a/language-support/js/daml-codegen/index.ts b/language-support/js/daml-codegen/index.ts deleted file mode 100644 index 64cdcd20d8b..00000000000 --- a/language-support/js/daml-codegen/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as opts from './options'; -import { OptionsReadError } from './options'; -import * as fs from 'fs'; -import * as ts from 'typescript'; -import { DalfProcessor } from './processor'; - -const options = opts.read(process.argv.slice(2)); - -if (typeof options === 'number') { - switch (options) { - case OptionsReadError.PARSE_MISSING_INPUT: - console.log('no parameter for -i flag'); - break; - case OptionsReadError.PARSE_MISSING_OUTPUT: - console.log('no parameter for -o flag'); - break; - case OptionsReadError.PARSE_UNRECOGNIZED: - console.log('unrecognized option'); - break; - case OptionsReadError.READ_INPUT_IS_MISSING: - console.log('input file is missing'); - break; - case OptionsReadError.READ_INPUT_DOES_NOT_EXIST: - console.log('input file does not exist'); - break; - case OptionsReadError.READ_OUTPUT_DIRECTORY_DOES_NOT_EXIST: - console.log('output directory does not exist'); - break; - } - console.log(`usage ${process.argv[0]} ${process.argv[1]} -i [-o output.ts]`) - process.exit(1); -} else { - fs.readFile(options.inputDalf, (error, data) => { - if (error) throw error; - const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); - const processor = new DalfProcessor(options.outputTs, printer); - const source = processor.process(data); - console.log(source.text); - printer.printFile(source); - }); -} \ No newline at end of file diff --git a/language-support/js/daml-codegen/module_tree.ts b/language-support/js/daml-codegen/module_tree.ts deleted file mode 100644 index 02732c1eced..00000000000 --- a/language-support/js/daml-codegen/module_tree.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { lf } from 'daml-grpc'; - -export interface ModuleTree { - children: Record, - modules: lf.v1.Module[] -} - -function empty(): ModuleTree { - return { - children: {}, - modules: [] - }; -} - -function insert(module: lf.v1.Module, tree: ModuleTree, depth: number = 0): void { - const segments = module.getName().getSegmentsList(); - const last = segments.length - 1; - if (depth < last) { - const segment = segments[depth]; - if (!tree.children[segment]) { - tree.children[segment] = empty(); - } - insert(module, tree.children[segment], depth + 1); - } else { - tree.modules.push(module); - } -} - -export function treeify(modules: lf.v1.Module[]): ModuleTree { - const tree: ModuleTree = empty(); - for (const m of modules) { - insert(m, tree); - } - return tree; -} diff --git a/language-support/js/daml-codegen/options.ts b/language-support/js/daml-codegen/options.ts deleted file mode 100644 index b4c0c0b3e03..00000000000 --- a/language-support/js/daml-codegen/options.ts +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as fs from 'fs'; -import * as path from 'path'; - -interface OptionsBuffer { - inputDalf?: string - outputTs?: string -} - -export interface Options { - inputDalf: string - outputTs: string -} - -export enum OptionsReadError { - PARSE_MISSING_INPUT, - PARSE_MISSING_OUTPUT, - PARSE_UNRECOGNIZED, - READ_INPUT_IS_MISSING, - READ_INPUT_DOES_NOT_EXIST, - READ_OUTPUT_DIRECTORY_DOES_NOT_EXIST -} - -function parse(argv: string[]): OptionsBuffer | OptionsReadError { - const buffer: OptionsBuffer = {}; - for (let i = 0; i < argv.length; i++) { - switch (argv[i]) { - case '-i': - if (i + 1 >= argv.length) { - return OptionsReadError.PARSE_MISSING_INPUT; - } - buffer.inputDalf = argv[++i]; - break; - case '-o': - if (i + 1 >= argv.length) { - return OptionsReadError.PARSE_MISSING_OUTPUT; - } - buffer.outputTs = argv[++i]; - break; - default: - return OptionsReadError.PARSE_UNRECOGNIZED; - break; - } - } - return buffer; -} - -function interpret(buffer: OptionsBuffer): Options | OptionsReadError { - if (!buffer.inputDalf) { - return OptionsReadError.READ_INPUT_IS_MISSING; - } else if (!fs.existsSync(buffer.inputDalf)) { - return OptionsReadError.READ_INPUT_DOES_NOT_EXIST; - } else if (!buffer.outputTs) { - const { root, dir, name } = path.parse(buffer.inputDalf) - buffer.outputTs = path.resolve(root, dir, `${name}.ts`); - return { - inputDalf: buffer.inputDalf, - outputTs: buffer.outputTs - }; - } else if (!fs.statSync(path.dirname(buffer.outputTs)).isDirectory()) { - return OptionsReadError.READ_OUTPUT_DIRECTORY_DOES_NOT_EXIST; - } else { - return { - inputDalf: buffer.inputDalf, - outputTs: buffer.outputTs - }; - } -} - -export function read(argv: string[]): Options | OptionsReadError { - const parseResult = parse(argv); - if (typeof parseResult === 'number') { - return parseResult; - } else { - return interpret(parseResult); - } -} \ No newline at end of file diff --git a/language-support/js/daml-codegen/package.json b/language-support/js/daml-codegen/package.json deleted file mode 100644 index 2e9663e4fb5..00000000000 --- a/language-support/js/daml-codegen/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "daml-codegen", - "version": "0.5.0", - "description": "DAML Ledger API Node.js code generation", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/digital-asset/daml", - "directory": "language-support/js/daml-codegen" - }, - "license": "Apache-2.0", - "author": "Digital Asset (Switzerland) GmbH and/or its affiliates", - "contributors": [ - "Stefano Baghino " - ], - "dependencies": { - "daml-ledger": "0.5.0", - "typescript": "3.1.6" - } -} - diff --git a/language-support/js/daml-codegen/processor.ts b/language-support/js/daml-codegen/processor.ts deleted file mode 100644 index 87f2f7494a7..00000000000 --- a/language-support/js/daml-codegen/processor.ts +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ts from 'typescript'; -import { lf } from 'daml-grpc'; -import { ModuleTree, treeify } from './module_tree'; - -export class DalfProcessor { - private readonly src: ts.SourceFile; - private readonly printer: ts.Printer; - constructor(outputPath: string, printer: ts.Printer) { - this.src = ts.createSourceFile(outputPath, '', ts.ScriptTarget.ES2015); - this.printer = printer; - } - - process(dalf: Buffer): ts.SourceFile { - const payload = lf.Archive.deserializeBinary(dalf).getPayload_asU8(); - const modules = lf.ArchivePayload.deserializeBinary(payload).getDamlLf1().getModulesList(); - this.src.text += generate(treeify(modules)).map(decl => this.printer.printNode(ts.EmitHint.Unspecified, decl, this.src)).join('\n\n'); - return this.src; - } - -} - -function generate(tree: ModuleTree): ts.ModuleDeclaration[] { - const declarations: ts.ModuleDeclaration[] = []; - for (const lfModuleName in tree.children) { - const child = tree.children[lfModuleName]; - const tsModuleName = ts.createIdentifier(lfModuleName); - declarations.push(ts.createModuleDeclaration([], [], tsModuleName, ts.createModuleBlock(generate(child)))); - } - for (const lfModule of tree.modules) { - const lfModuleName = lfModule.getName().getSegmentsList(); - const tsModuleName = ts.createIdentifier(lfModuleName[lfModuleName.length - 1]); - const templates = lfModule.getTemplatesList().map(t => generateTemplate(t)); - const dataTypes = lfModule.getDataTypesList().map(t => generateDataType(t)); - declarations.push(ts.createModuleDeclaration([], [], tsModuleName, ts.createModuleBlock([...templates, ...dataTypes]))); - } - return declarations; -} - -function generateTemplate(template: lf.v1.DefTemplate): ts.ClassDeclaration { - const templateNameSegments = template.getTycon().getSegmentsList(); - const templateName = templateNameSegments[templateNameSegments.length - 1]; - const choices = template.getChoicesList().map(c => ts.createMethod([], [], undefined, c.getName(), undefined, [], [], undefined, undefined)); - return ts.createClassDeclaration([], [], templateName, [], [], choices); -} - -function generateDataType(dataType: lf.v1.DefDataType): ts.ClassDeclaration { - const typeNameSegments = dataType.getName().getSegmentsList(); - const typeName = typeNameSegments[typeNameSegments.length - 1]; - const members: ts.ClassElement[] = []; - if (dataType.hasRecord()) { - const fields = dataType.getRecord().getFieldsList(); - for (const field of fields) { - const lfType = field.getType(); - const tsType = generateType(lfType); - members.push(ts.createProperty([], [], field.getField(), undefined, tsType, undefined)); - } - } - return ts.createClassDeclaration([], [], typeName, [], [], members); -} - -function generateType(lfType: lf.v1.Type): ts.TypeNode { - if (lfType.hasPrim()) { - switch (lfType.getPrim().getPrim()) { - case lf.v1.PrimType.UNIT: - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - break; - case lf.v1.PrimType.BOOL: - return ts.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword); - break; - case lf.v1.PrimType.INT64: - return ts.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); - break; - case lf.v1.PrimType.DECIMAL: - return ts.createKeywordTypeNode(ts.SyntaxKind.StringKeyword); - break; - case lf.v1.PrimType.TEXT: - return ts.createKeywordTypeNode(ts.SyntaxKind.StringKeyword); - break; - case lf.v1.PrimType.TIMESTAMP: - return ts.createTypeReferenceNode('Date', []); - break; - case lf.v1.PrimType.PARTY: - return ts.createKeywordTypeNode(ts.SyntaxKind.StringKeyword); - break; - case lf.v1.PrimType.LIST: - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - break; - case lf.v1.PrimType.UPDATE: - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - break; - case lf.v1.PrimType.SCENARIO: - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - break; - case lf.v1.PrimType.DATE: - return ts.createTypeReferenceNode('Date', []); - break; - case lf.v1.PrimType.CONTRACT_ID: - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - break; - case lf.v1.PrimType.OPTIONAL: - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - break; - case lf.v1.PrimType.ARROW: - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - break; - default: - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - break; - } - } else if (lfType.hasCon()) { - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - } else if (lfType.hasTuple()) { - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - } else { - return ts.createTypeReferenceNode('MISSING', []); - throw new Error(`unsupported type ${lfType}`); - } -} \ No newline at end of file diff --git a/language-support/js/daml-codegen/tsconfig.json b/language-support/js/daml-codegen/tsconfig.json deleted file mode 100644 index a0302eb0bf5..00000000000 --- a/language-support/js/daml-codegen/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "declaration": true, - "sourceMap": true, - "outDir": "./dist/", - "lib": [ "es2015" ] - } -} \ No newline at end of file diff --git a/language-support/js/daml-grpc/BUILD b/language-support/js/daml-grpc/BUILD deleted file mode 100644 index 3c364713557..00000000000 --- a/language-support/js/daml-grpc/BUILD +++ /dev/null @@ -1,184 +0,0 @@ -load("@build_bazel_rules_typescript//:defs.bzl", "ts_config") -load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") -load("//bazel_tools:proto.bzl", "proto_gen") - -proto_gen( - name = "ledger-api-nodejs", - srcs = ["//ledger-api/grpc-definitions:protos"], - plugin_exec = "//language-support/js:grpc_tools_node_protoc_js", - plugin_name = "js", - plugin_options = [ - "import_style=commonjs", - "binary", - ], - deps = [ - "@com_github_googleapis_googleapis//google/rpc:status_proto", - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:descriptor_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:wrappers_proto", - ], -) - -proto_gen( - name = "ledger-api-nodejs-grpc", - srcs = ["//ledger-api/grpc-definitions:protos"], - plugin_exec = "//language-support/js:grpc_tools_node_protoc_js", - plugin_name = "grpc", - deps = [ - "@com_github_googleapis_googleapis//google/rpc:status_proto", - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:descriptor_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:wrappers_proto", - ], -) - -proto_gen( - name = "ledger-api-d.ts", - srcs = ["//ledger-api/grpc-definitions:protos"], - plugin_exec = "//language-support/js:grpc_tools_node_protoc_ts", - plugin_name = "ts", - deps = [ - "@com_github_googleapis_googleapis//google/rpc:status_proto", - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:descriptor_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:wrappers_proto", - ], -) - -proto_gen( - name = "daml_lf_proto-nodejs", - srcs = ["//daml-lf/archive:daml_lf_proto"], - plugin_exec = "//language-support/js:grpc_tools_node_protoc_js", - plugin_name = "js", - plugin_options = [ - "import_style=commonjs", - "binary", - ], -) - -proto_gen( - name = "daml_lf_proto-d.ts", - srcs = ["//daml-lf/archive:daml_lf_proto"], - plugin_exec = "//language-support/js:grpc_tools_node_protoc_ts", - plugin_name = "ts", -) - -proto_gen( - name = "com_google_protobuf-nodejs", - srcs = [ - "@com_github_googleapis_googleapis//google/rpc:status_proto", - ], - plugin_exec = "//language-support/js:grpc_tools_node_protoc_js", - plugin_name = "js", - plugin_options = [ - "import_style=commonjs", - "binary", - ], - deps = [ - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:descriptor_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:wrappers_proto", - ], -) - -proto_gen( - name = "com_google_protobuf-d.ts", - srcs = [ - "@com_github_googleapis_googleapis//google/rpc:status_proto", - ], - plugin_exec = "//language-support/js:grpc_tools_node_protoc_ts", - plugin_name = "ts", - deps = [ - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:descriptor_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:wrappers_proto", - ], -) - -ts_config( - name = "tsconfig", - src = "tsconfig.json", - deps = ["//:tsconfig.json"], -) - -# ts_library does not accept arbitrary inputs, so we use a genrule -genrule( - name = "daml-grpc", - srcs = [ - "index.ts", - "lf/index.ts", - "testing/index.ts", - ":ledger-api-nodejs", - ":ledger-api-nodejs-grpc", - ":ledger-api-d.ts", - ":daml_lf_proto-nodejs", - ":daml_lf_proto-d.ts", - ":com_google_protobuf-nodejs", - ":com_google_protobuf-d.ts", - "package.json", - ":tsconfig", - "@npm//@types/google-protobuf", - "@npm//@types/node", - "@npm//google-protobuf", - "@npm//grpc", - ], - outs = ["daml-grpc.tgz"], - cmd = """ - set -e - ln -s external/npm/node_modules - unzip -q $(location ledger-api-nodejs) -d language-support/js/daml-grpc/ - unzip -q $(location ledger-api-nodejs-grpc) -d language-support/js/daml-grpc/ - unzip -q $(location ledger-api-d.ts) -d language-support/js/daml-grpc/ - unzip -q $(location daml_lf_proto-nodejs) -d language-support/js/daml-grpc/ - unzip -q $(location daml_lf_proto-d.ts) -d language-support/js/daml-grpc/ - unzip -q $(location com_google_protobuf-nodejs) -d language-support/js/daml-grpc/ - unzip -q $(location com_google_protobuf-d.ts) -d language-support/js/daml-grpc/ - $(execpath //language-support/js:tsc) --build $(location tsconfig) - cp -R language-support/js/daml-grpc/dist package - cp -RL language-support/js/daml-grpc/com package - cp -RL language-support/js/daml-grpc/da package - cp -RL language-support/js/daml-grpc/google package - cp -RL language-support/js/daml-grpc/grpc package - cp $(location package.json) package - tar czf $@ package - """, - tools = [ - "//language-support/js:tsc", - ], - visibility = ["//:__subpackages__"], -) - -# nodejs_test does not support mocha, so we use sh_test -sh_test( - name = "test", - srcs = ["test.sh"], - data = [ - "test.ts", - ":daml-grpc", - "@nodejs//:node", - "@npm//@types/chai", - "@npm//@types/google-protobuf", - "@npm//@types/mocha", - "@npm//@types/node", - "@npm//chai", - "@npm//google-protobuf", - "@npm//grpc", - "@npm//mocha", - "@npm//ts-node", - ], -) diff --git a/language-support/js/daml-grpc/index.ts b/language-support/js/daml-grpc/index.ts deleted file mode 100644 index 71087e231b3..00000000000 --- a/language-support/js/daml-grpc/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as testing from './testing'; -export { testing }; - -import * as lf from './lf'; -export { lf }; - -export { ActiveContractsServiceService as ActiveContractsService, ActiveContractsServiceClient as ActiveContractsClient, IActiveContractsServiceClient as IActiveContractsClient } from './com/digitalasset/ledger/api/v1/active_contracts_service_grpc_pb'; -export { GetActiveContractsRequest, GetActiveContractsResponse } from './com/digitalasset/ledger/api/v1/active_contracts_service_pb'; - -export { CommandCompletionServiceService as CommandCompletionService, CommandCompletionServiceClient as CommandCompletionClient, ICommandCompletionServiceClient as ICommandCompletionClient } from './com/digitalasset/ledger/api/v1/command_completion_service_grpc_pb'; -export { Checkpoint, CompletionEndRequest, CompletionEndResponse, CompletionStreamRequest, CompletionStreamResponse } from './com/digitalasset/ledger/api/v1/command_completion_service_pb'; - -export { CommandServiceService as CommandService, CommandServiceClient as CommandClient, ICommandServiceClient as ICommandClient } from './com/digitalasset/ledger/api/v1/command_service_grpc_pb'; -export { SubmitAndWaitRequest } from './com/digitalasset/ledger/api/v1/command_service_pb'; - -export { CommandSubmissionServiceService as CommandSubmissionService, CommandSubmissionServiceClient as CommandSubmissionClient, ICommandSubmissionServiceClient as ICommandSubmissionClient } from './com/digitalasset/ledger/api/v1/command_submission_service_grpc_pb'; -export { SubmitRequest } from './com/digitalasset/ledger/api/v1/command_submission_service_pb'; - -export { Command, Commands, CreateCommand, ExerciseCommand } from './com/digitalasset/ledger/api/v1/commands_pb'; - -export { Completion } from './com/digitalasset/ledger/api/v1/completion_pb'; - -export { ArchivedEvent, CreatedEvent, Event, ExercisedEvent } from './com/digitalasset/ledger/api/v1/event_pb'; - -export { LedgerConfigurationServiceService as LedgerConfigurationService, LedgerConfigurationServiceClient as LedgerConfigurationClient, ILedgerConfigurationServiceClient as ILedgerConfigurationClient } from './com/digitalasset/ledger/api/v1/ledger_configuration_service_grpc_pb'; -export { GetLedgerConfigurationRequest, GetLedgerConfigurationResponse, LedgerConfiguration } from './com/digitalasset/ledger/api/v1/ledger_configuration_service_pb'; - -export { LedgerIdentityServiceService as LedgerIdentityService, LedgerIdentityServiceClient as LedgerIdentityClient, ILedgerIdentityServiceClient as ILedgerIdentityClient } from './com/digitalasset/ledger/api/v1/ledger_identity_service_grpc_pb'; -export { GetLedgerIdentityRequest, GetLedgerIdentityResponse } from './com/digitalasset/ledger/api/v1/ledger_identity_service_pb'; - -export { LedgerOffset } from './com/digitalasset/ledger/api/v1/ledger_offset_pb' - -export { PackageServiceService as PackageService, PackageServiceClient as PackageClient, IPackageServiceClient as IPackageClient } from './com/digitalasset/ledger/api/v1/package_service_grpc_pb'; -export { GetPackageRequest, GetPackageResponse, GetPackageStatusRequest, GetPackageStatusResponse, HashFunction, ListPackagesRequest, ListPackagesResponse, PackageStatus } from './com/digitalasset/ledger/api/v1/package_service_pb'; - -export { TraceContext } from './com/digitalasset/ledger/api/v1/trace_context_pb'; - -export { Filters, InclusiveFilters, TransactionFilter } from './com/digitalasset/ledger/api/v1/transaction_filter_pb'; - -export { Transaction, TransactionTree, TreeEvent } from './com/digitalasset/ledger/api/v1/transaction_pb'; - -export { TransactionServiceService as TransactionService, TransactionServiceClient as TransactionClient, ITransactionServiceClient as ITransactionClient } from './com/digitalasset/ledger/api/v1/transaction_service_grpc_pb'; -export { GetLedgerEndRequest, GetLedgerEndResponse, GetTransactionByEventIdRequest, GetTransactionByIdRequest, GetTransactionResponse, GetTransactionsRequest, GetTransactionsResponse, GetTransactionTreesResponse } from './com/digitalasset/ledger/api/v1/transaction_service_pb'; - -export { Identifier, List, Optional, Record, RecordField, Value, Variant } from './com/digitalasset/ledger/api/v1/value_pb'; - -export { Status } from './google/rpc/status_pb'; diff --git a/language-support/js/daml-grpc/lf/index.ts b/language-support/js/daml-grpc/lf/index.ts deleted file mode 100644 index ce91426c5e0..00000000000 --- a/language-support/js/daml-grpc/lf/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -export { Archive, ArchivePayload, HashFunction } from '../da/daml_lf_pb'; - -import * as v0 from '../da/daml_lf_0_pb'; -import * as v1 from '../da/daml_lf_1_pb'; -import * as dev from '../da/daml_lf_dev_pb'; -export { v0, v1, dev }; \ No newline at end of file diff --git a/language-support/js/daml-grpc/package.json b/language-support/js/daml-grpc/package.json deleted file mode 100644 index 78bee89842a..00000000000 --- a/language-support/js/daml-grpc/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "daml-grpc", - "version": "0.5.0", - "description": "DAML Ledger API Node.js gRPC bindings", - "main": "./dist/index.js", - "types": "./dist/index.d.js", - "repository": { - "type": "git", - "url": "https://github.com/digital-asset/daml", - "directory": "language-support/js/daml-grpc" - }, - "license": "Apache-2.0", - "author": "Digital Asset (Switzerland) GmbH and/or its affiliates", - "contributors": [ - "Stefano Baghino ", - "Mario Pastorelli " - ], - "dependencies": { - "google-protobuf": "3.6.1", - "grpc": "1.15.1" - } -} diff --git a/language-support/js/daml-grpc/test.sh b/language-support/js/daml-grpc/test.sh deleted file mode 100755 index 8e19e7325bc..00000000000 --- a/language-support/js/daml-grpc/test.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -set -ex - -export PATH=$PATH:external/nodejs/bin:external/npm/node_modules/mocha/bin -ln -s external/npm/node_modules - -mkdir -p node_modules/daml-grpc -tar xzf language-support/js/daml-grpc/daml-grpc.tgz --strip-components=1 -C node_modules/daml-grpc - -echo '{"compilerOptions":{"lib":["es2015"]}}' > tsconfig.json - -# Resolve the symbolic link to have the test import statements point to -# the generated code folder so that the dependencies on generated code can -# be resolved -cp -L language-support/js/daml-grpc/test.ts . - -mocha -r ts-node/register test.ts \ No newline at end of file diff --git a/language-support/js/daml-grpc/test.ts b/language-support/js/daml-grpc/test.ts deleted file mode 100644 index b17cf1073ce..00000000000 --- a/language-support/js/daml-grpc/test.ts +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from 'daml-grpc'; -import { expect } from 'chai'; - -describe('daml-grpc', () => { - - it('should include all necessary definitions', () => { - expect(ledger.testing).to.not.be.undefined; - expect(ledger.testing.TimeService).to.not.be.undefined; - expect(ledger.testing.TimeClient).to.not.be.undefined; - expect(ledger.testing.GetTimeRequest).to.not.be.undefined; - expect(ledger.testing.GetTimeResponse).to.not.be.undefined; - expect(ledger.testing.SetTimeRequest).to.not.be.undefined; - expect(ledger.testing.ResetService).to.not.be.undefined; - expect(ledger.testing.ResetClient).to.not.be.undefined; - expect(ledger.testing.ResetRequest).to.not.be.undefined; - expect(ledger.ActiveContractsService).to.not.be.undefined; - expect(ledger.ActiveContractsClient).to.not.be.undefined; - expect(ledger.GetActiveContractsRequest).to.not.be.undefined; - expect(ledger.GetActiveContractsResponse).to.not.be.undefined; - expect(ledger.CommandCompletionService).to.not.be.undefined; - expect(ledger.CommandCompletionClient).to.not.be.undefined; - expect(ledger.Checkpoint).to.not.be.undefined; - expect(ledger.CompletionEndRequest).to.not.be.undefined; - expect(ledger.CompletionEndResponse).to.not.be.undefined; - expect(ledger.CompletionStreamRequest).to.not.be.undefined; - expect(ledger.CompletionStreamResponse).to.not.be.undefined; - expect(ledger.CommandService).to.not.be.undefined; - expect(ledger.CommandClient).to.not.be.undefined; - expect(ledger.SubmitAndWaitRequest).to.not.be.undefined; - expect(ledger.CommandSubmissionService).to.not.be.undefined; - expect(ledger.CommandSubmissionClient).to.not.be.undefined; - expect(ledger.SubmitRequest).to.not.be.undefined; - expect(ledger.Command).to.not.be.undefined; - expect(ledger.Commands).to.not.be.undefined; - expect(ledger.CreateCommand).to.not.be.undefined; - expect(ledger.ExerciseCommand).to.not.be.undefined; - expect(ledger.Completion).to.not.be.undefined; - expect(ledger.ArchivedEvent).to.not.be.undefined; - expect(ledger.CreatedEvent).to.not.be.undefined; - expect(ledger.Event).to.not.be.undefined; - expect(ledger.ExercisedEvent).to.not.be.undefined; - expect(ledger.LedgerConfigurationService).to.not.be.undefined; - expect(ledger.LedgerConfigurationClient).to.not.be.undefined; - expect(ledger.GetLedgerConfigurationRequest).to.not.be.undefined; - expect(ledger.GetLedgerConfigurationResponse).to.not.be.undefined; - expect(ledger.LedgerConfiguration).to.not.be.undefined; - expect(ledger.LedgerIdentityService).to.not.be.undefined; - expect(ledger.LedgerIdentityClient).to.not.be.undefined; - expect(ledger.GetLedgerIdentityRequest).to.not.be.undefined; - expect(ledger.GetLedgerIdentityResponse).to.not.be.undefined; - expect(ledger.LedgerOffset).to.not.be.undefined; - expect(ledger.PackageService).to.not.be.undefined; - expect(ledger.PackageClient).to.not.be.undefined; - expect(ledger.GetPackageRequest).to.not.be.undefined; - expect(ledger.GetPackageResponse).to.not.be.undefined; - expect(ledger.GetPackageStatusRequest).to.not.be.undefined; - expect(ledger.GetPackageStatusResponse).to.not.be.undefined; - expect(ledger.HashFunction).to.not.be.undefined; - expect(ledger.ListPackagesRequest).to.not.be.undefined; - expect(ledger.ListPackagesResponse).to.not.be.undefined; - expect(ledger.PackageStatus).to.not.be.undefined; - expect(ledger.TraceContext).to.not.be.undefined; - expect(ledger.Filters).to.not.be.undefined; - expect(ledger.InclusiveFilters).to.not.be.undefined; - expect(ledger.TransactionFilter).to.not.be.undefined; - expect(ledger.Transaction).to.not.be.undefined; - expect(ledger.TransactionTree).to.not.be.undefined; - expect(ledger.TreeEvent).to.not.be.undefined; - expect(ledger.TransactionService).to.not.be.undefined; - expect(ledger.TransactionClient).to.not.be.undefined; - expect(ledger.GetLedgerEndRequest).to.not.be.undefined; - expect(ledger.GetLedgerEndResponse).to.not.be.undefined; - expect(ledger.GetTransactionByEventIdRequest).to.not.be.undefined; - expect(ledger.GetTransactionByIdRequest).to.not.be.undefined; - expect(ledger.GetTransactionResponse).to.not.be.undefined; - expect(ledger.GetTransactionsRequest).to.not.be.undefined; - expect(ledger.GetTransactionsResponse).to.not.be.undefined; - expect(ledger.GetTransactionTreesResponse).to.not.be.undefined; - expect(ledger.TransactionTree).to.not.be.undefined; - expect(ledger.Identifier).to.not.be.undefined; - expect(ledger.List).to.not.be.undefined; - expect(ledger.Optional).to.not.be.undefined; - expect(ledger.Record).to.not.be.undefined; - expect(ledger.RecordField).to.not.be.undefined; - expect(ledger.Value).to.not.be.undefined; - expect(ledger.Variant).to.not.be.undefined; - expect(ledger.Status).to.not.be.undefined; - expect(ledger.lf).to.not.be.undefined; - expect(ledger.lf.Archive).to.not.be.undefined; - expect(ledger.lf.ArchivePayload).to.not.be.undefined; - expect(ledger.lf.HashFunction).to.not.be.undefined; - }); - -}); diff --git a/language-support/js/daml-grpc/testing/index.ts b/language-support/js/daml-grpc/testing/index.ts deleted file mode 100644 index ce52241333e..00000000000 --- a/language-support/js/daml-grpc/testing/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -export { TimeServiceService as TimeService, TimeServiceClient as TimeClient, ITimeServiceClient as ITimeClient } from '../com/digitalasset/ledger/api/v1/testing/time_service_grpc_pb'; -export { GetTimeRequest, GetTimeResponse, SetTimeRequest } from '../com/digitalasset/ledger/api/v1/testing/time_service_pb'; - -export { ResetServiceService as ResetService, ResetServiceClient as ResetClient, IResetServiceClient as IResetClient } from '../com/digitalasset/ledger/api/v1/testing/reset_service_grpc_pb'; -export { ResetRequest } from '../com/digitalasset/ledger/api/v1/testing/reset_service_pb'; \ No newline at end of file diff --git a/language-support/js/daml-grpc/tsconfig.json b/language-support/js/daml-grpc/tsconfig.json deleted file mode 100644 index a0302eb0bf5..00000000000 --- a/language-support/js/daml-grpc/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "declaration": true, - "sourceMap": true, - "outDir": "./dist/", - "lib": [ "es2015" ] - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/BUILD b/language-support/js/daml-ledger/BUILD deleted file mode 100644 index d5748efaf0f..00000000000 --- a/language-support/js/daml-ledger/BUILD +++ /dev/null @@ -1,80 +0,0 @@ -load("@build_bazel_rules_typescript//:defs.bzl", "ts_config") - -ts_config( - name = "tsconfig", - src = "tsconfig.json", - deps = ["//:tsconfig.json"], -) - -filegroup( - name = "README", - srcs = ["README.md"], - visibility = ["//language-support/js:__subpackages__"], -) - -filegroup( - name = "src", - srcs = glob(["src/**/*.ts"]), - visibility = ["//language-support/js:__subpackages__"], -) - -filegroup( - name = "tests", - srcs = glob(["tests/**/*"]), -) - -# ts_library does not accept arbitrary inputs, so we use a genrule -genrule( - name = "daml-ledger", - srcs = [ - ":src", - "//language-support/js/daml-grpc", - "package.json", - ":tsconfig", - "@npm//@types/google-protobuf", - "@npm//@types/node", - "@npm//google-protobuf", - "@npm//grpc", - ], - outs = ["daml-ledger.tgz"], - cmd = """ - set -e - ln -s external/npm/node_modules - mkdir -p node_modules/daml-grpc - tar xzf $(location //language-support/js/daml-grpc) --strip-components=1 -C node_modules/daml-grpc - $(execpath //language-support/js:tsc) --build $(location tsconfig) - mkdir -p package - cp -R language-support/js/daml-ledger/dist package - cp $(location package.json) package - tar czf $@ package - """, - tools = [ - "//language-support/js:tsc", - ], - visibility = ["//:__subpackages__"], -) - -# nodejs_test does not support mocha, so we use sh_test -sh_test( - name = "test", - srcs = ["test.sh"], - data = [ - ":src", - ":tests", - "//language-support/js/daml-grpc", - "@nodejs//:node", - "@npm//@types/chai", - "@npm//@types/google-protobuf", - "@npm//@types/mocha", - "@npm//@types/node", - "@npm//@types/sinon", - "@npm//chai", - "@npm//google-protobuf", - "@npm//grpc", - "@npm//jsverify", - "@npm//mocha", - "@npm//sinon", - "@npm//ts-node", - "@npm//typescript", - ], -) diff --git a/language-support/js/daml-ledger/README.md b/language-support/js/daml-ledger/README.md deleted file mode 100644 index a93b6b53ffd..00000000000 --- a/language-support/js/daml-ledger/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# language-support/js/daml-ledger - -This are the bindings for the Ledger API for JavaScript, targeting the Node.js runtime environment. - diff --git a/language-support/js/daml-ledger/UNRELEASED.md b/language-support/js/daml-ledger/UNRELEASED.md deleted file mode 100644 index ccf916e2361..00000000000 --- a/language-support/js/daml-ledger/UNRELEASED.md +++ /dev/null @@ -1,16 +0,0 @@ -# Unreleased changes - -All notable unreleased changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). - -Summarizing, for every big change the contributor adds a corresponding entry into this -file (`UNRELEASED.md`). Once a release is ready, the maintainer needs to move entries -from this file into the section with the corresponding version number and release date -in [`CHANGELOG.md`](CHANGELOG.md). - -## Unreleased - -### Changed -- support Ledger API 1.5.0 diff --git a/language-support/js/daml-ledger/VALIDATION.md b/language-support/js/daml-ledger/VALIDATION.md deleted file mode 100644 index 0eff783ddcc..00000000000 --- a/language-support/js/daml-ledger/VALIDATION.md +++ /dev/null @@ -1,31 +0,0 @@ -# JavaScript bindings client-side validation - -This document outlines the scope of client-side validation in the JS bindings. - -## Scope - -The chosen serialization format, Protocol Buffers, provides no way to enforce -whether some part of a message is required or optional, delegating this check -to the application layer. - -As the glue that binds together the code generated by Protocol Buffers and the -client-side applications, the bindings are the perfect place to enforce this -kind of semantics on our APIs. - -The bindings can serve as the layer to: -- ensure only well-formed message are sent to the server -- report error information which: - - covers all detected discrepancies at once - - is propagated via callbacks and streams (rather than exceptions) - -By "well-formed" we mean a message that contains: -- if it represents a plain object: - - all the required fields, each with the correct type - - zero or more optional fields, each with the correct type -- if it represents a union: - - exactly one field, with the correct type -- in any case: - - no unknown (i.e. extra) field (to easily catch crass mistakes) - -Any other kind of check is delegated to the server as the ultimate judge of the -semantics of messages. diff --git a/language-support/js/daml-ledger/package.json b/language-support/js/daml-ledger/package.json deleted file mode 100644 index d12b682b99e..00000000000 --- a/language-support/js/daml-ledger/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "daml-ledger", - "version": "0.5.0", - "description": "DAML Ledger API Node.js bindings", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/digital-asset/daml", - "directory": "language-support/js/daml-ledger" - }, - "license": "Apache-2.0", - "author": "Digital Asset (Switzerland) GmbH and/or its affiliates", - "contributors": [ - "Stefano Baghino ", - "Mario Pastorelli " - ], - "dependencies": { - "daml-grpc": "0.5.0" - } -} diff --git a/language-support/js/daml-ledger/src/call/client_cancellable_call.ts b/language-support/js/daml-ledger/src/call/client_cancellable_call.ts deleted file mode 100644 index 18da2c838aa..00000000000 --- a/language-support/js/daml-ledger/src/call/client_cancellable_call.ts +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { ClientUnaryCall } from "grpc"; - -/** - * @interface ClientCancellableCall - * @memberof ledger - */ -export class ClientCancellableCall { - - private readonly wrapped: ClientUnaryCall | undefined; - - private constructor(wrapped?: ClientUnaryCall) { - this.wrapped = wrapped; - } - - public static accept(wrapped: ClientUnaryCall) { - return new ClientCancellableCall(wrapped); - } - - public static readonly rejected = new ClientCancellableCall(); - - /** - * Cancel the ongoing call. Results in the call ending with a CANCELLED status, - * unless it has already ended with some other status. - * - * @method cancel - * @memberof ledger.ClientCancellableCall - * @instance - */ - cancel(): void { - if (this.wrapped) { - this.wrapped.cancel(); - } - } - - /** - * Get the endpoint this call/stream is connected to. - * - * @method getPeer - * @memberof ledger.ClientCancellableCall - * @instance - * @returns {string} The URI of the endpoint or an empty string if the call never reached the server - */ - getPeer(): string { - if (this.wrapped !== undefined) { - return this.wrapped.getPeer(); - } else { - return ''; - } - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/call/client_readable_object_stream.ts b/language-support/js/daml-ledger/src/call/client_readable_object_stream.ts deleted file mode 100644 index f9715ec8d8f..00000000000 --- a/language-support/js/daml-ledger/src/call/client_readable_object_stream.ts +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Readable, ReadableOptions } from "stream"; -import { Mapping } from "../mapping"; -import { ClientReadableStream } from "grpc"; -import { MappingTransform } from "./mapping_transform"; - -/** - * A stream of objects that are pushed from the server and are readable from - * the client. It it a {@link external:Readble} Node.js stream and wraps the - * call to gRPC. - * - * @interface ClientReadableObjectStream - * @memberof ledger - */ -export class ClientReadableObjectStream extends Readable { - - private readonly wrapped?: ClientReadableStream - private readonly mapped?: MappingTransform - - private constructor(wrapped: Error | ClientReadableStream, mapping?: Mapping, opts?: ReadableOptions) { - super(Object.assign(opts || {}, { objectMode: true })); - if (!(wrapped instanceof Error) && mapping !== undefined) { - this.wrapped = wrapped; - this.mapped = this.wrapped.pipe(new MappingTransform(mapping)); - this.mapped.on('readable', () => this._read()); - this.mapped.on('finish', () => this.emit('end')); - } else if (wrapped instanceof Error) { - process.nextTick(() => { - this.emit('error', wrapped); - process.nextTick(() => { - this.emit('end'); - }); - }); - } - } - - static from(wrapped: Error): ClientReadableObjectStream - static from(wrapped: ClientReadableStream, mapping: Mapping, opts?: ReadableOptions): ClientReadableObjectStream - static from(wrapped: Error | ClientReadableStream, mapping?: Mapping, opts?: ReadableOptions): ClientReadableObjectStream{ - if (wrapped instanceof Error) { - return new ClientReadableObjectStream(wrapped); - } else { - return new ClientReadableObjectStream(wrapped, mapping, opts); - } - } - - _read(): void { - if (this.mapped) { - const object = this.mapped.read(); - if (object) { - this.push(object); - } - } - } - - /** - * Cancel the ongoing call. Results in the call ending with a CANCELLED status, - * unless it has already ended with some other status. - * - * @method cancel - * @memberof ledger.ClientReadableObjectStream - * @instance - */ - cancel(): void { - if (this.wrapped) { - this.wrapped.cancel(); - } - } - - /** - * Get the endpoint this call/stream is connected to. - * - * @method getPeer - * @memberof ledger.ClientReadableObjectStream - * @returns {string} The URI of the endpoint - * @instance - */ - getPeer(): string { - if (this.wrapped) { - return this.wrapped.getPeer(); - } else { - return ''; - } - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/call/index.ts b/language-support/js/daml-ledger/src/call/index.ts deleted file mode 100644 index 9ec30f7e985..00000000000 --- a/language-support/js/daml-ledger/src/call/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -export { ClientCancellableCall } from './client_cancellable_call'; -export { ClientReadableObjectStream } from './client_readable_object_stream'; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/call/mapping_transform.ts b/language-support/js/daml-ledger/src/call/mapping_transform.ts deleted file mode 100644 index f8dd0194b57..00000000000 --- a/language-support/js/daml-ledger/src/call/mapping_transform.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Transform, TransformOptions } from "stream"; -import { Mapping } from "../mapping"; - -export class MappingTransform extends Transform { - - private readonly mapping: Mapping - - constructor(mapping: Mapping, opts?: TransformOptions) { - super(Object.assign(opts || {}, { objectMode: true })); - this.mapping = mapping; - } - - _transform(message: M, _encoding: string, callback: Function): void { - try { - const next = message ? this.mapping.toObject(message) : null; - this.push(next); - callback(); - } catch (error) { - callback(error); - } - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/client/active_contracts_client.ts b/language-support/js/daml-ledger/src/client/active_contracts_client.ts deleted file mode 100644 index fbbdd3cca7f..00000000000 --- a/language-support/js/daml-ledger/src/client/active_contracts_client.ts +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as ledger from '..'; -import * as mapping from '../mapping'; -import * as reporting from '../reporting'; -import * as validation from '../validation'; -import { ClientReadableObjectStream } from '../call/client_readable_object_stream'; - -/** - * Allows clients to initialize themselves according to a fairly recent state - * of the ledger without reading through all transactions that were committed - * since the ledger's creation. - * - * @class ActiveContractsClient - * @memberof ledger - * @param {string} ledgerId - * @param {grpc.IActiveContractsClient} client - */ -export class ActiveContractsClient { - - private readonly ledgerId: string; - private readonly client: grpc.IActiveContractsClient; - private readonly reporter: reporting.Reporter; - - constructor(ledgerId: string, client: grpc.IActiveContractsClient, reporter: reporting.Reporter) { - this.ledgerId = ledgerId; - this.client = client; - this.reporter = reporter; - } - - /** - * Returns a stream of the latest snapshot of active contracts. Getting an - * empty stream means that the active contracts set is empty and the client - * should listen to transactions using LEDGER_BEGIN. - * - * Clients SHOULD NOT assume that the set of active contracts they receive - * reflects the state at the ledger end. - * - * @method getActiveContracts - * @memberof ledger.ActiveContractsClient - * @instance - * @param {ledger.GetActiveContractsRequest} requestObject - * @returns {ledger.ClientReadableObjectStream} - */ - getActiveContracts(requestObject: ledger.GetActiveContractsRequest): ClientReadableObjectStream { - const tree = validation.GetActiveContractsRequest.validate(requestObject); - if (validation.ok(tree)) { - const request = mapping.GetActiveContractsRequest.toMessage(requestObject); - request.setLedgerId(this.ledgerId); - if (requestObject.verbose === undefined) { - request.setVerbose(true); - } - return ClientReadableObjectStream.from(this.client.getActiveContracts(request), mapping.GetActiveContractsResponse); - } else { - return ClientReadableObjectStream.from(this.reporter(tree)); - } - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/client/command_client.ts b/language-support/js/daml-ledger/src/client/command_client.ts deleted file mode 100644 index 7935e488b75..00000000000 --- a/language-support/js/daml-ledger/src/client/command_client.ts +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as ledger from '..'; -import * as mapping from '../mapping'; -import * as reporting from '../reporting'; -import * as validation from '../validation'; - -import { ClientCancellableCall } from '../call/client_cancellable_call'; -import { Callback } from '../util'; -import { justForward } from '../util/callback'; - -/** - * Command Service is able to correlate submitted commands with completion - * ledger, identify timeouts, and return contextual information with each - * tracking result. This supports the implementation of stateless clients. - * - * @class CommandClient - * @memberof ledger - * @param {string} ledgerId - * @param {grpc.ICommandClient} client - */ -export class CommandClient { - - private readonly ledgerId: string - private readonly client: grpc.ICommandClient - private readonly reporter: reporting.Reporter - - constructor(ledgerId: string, client: grpc.ICommandClient, reporter: reporting.Reporter) { - this.ledgerId = ledgerId; - this.client = client; - this.reporter = reporter; - } - - /** - * Submits a single composite command and waits for its result. - * - * Returns RESOURCE_EXHAUSTED if the number of in-flight commands reached - * the maximum (if a limit is configured). - * - * Propagates the gRPC error of failed submissions including DAML - * interpretation errors. - * - * @method submitAndWait - * @memberof ledger.CommandClient - * @instance - * @param {ledger.SubmitAndWaitRequest} requestObject - * @param {util.Callback} callback - * @returns {ledger.ClientCancellableCall} - */ - submitAndWait(requestObject: ledger.SubmitAndWaitRequest, callback: Callback): ClientCancellableCall { - const tree = validation.SubmitAndWaitRequest.validate(requestObject); - if (validation.ok(tree)) { - const request = mapping.SubmitAndWaitRequest.toMessage(requestObject); - if (request.hasCommands()) { - request.getCommands()!.setLedgerId(this.ledgerId); - } - return ClientCancellableCall.accept(this.client.submitAndWait(request, (error, _) => { - justForward(callback, error, null) - })); - } else { - setImmediate(() => callback(this.reporter(tree))); - return ClientCancellableCall.rejected; - } - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/client/command_completion_client.ts b/language-support/js/daml-ledger/src/client/command_completion_client.ts deleted file mode 100644 index 13b3d9df1a1..00000000000 --- a/language-support/js/daml-ledger/src/client/command_completion_client.ts +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as ledger from '..'; -import * as mapping from '../mapping'; -import * as reporting from '../reporting'; -import * as validation from '../validation'; -import { ClientReadableObjectStream } from '../call/client_readable_object_stream'; -import { ClientCancellableCall } from '../call/client_cancellable_call'; -import { Callback } from '../util'; -import { forward } from '../util/callback'; - -/** - * Allows clients to observe the status of their submissions. - * - * Commands may be submitted via the Command Submission Service. - * - * The on-ledger effects of their submissions are disclosed by the - * Transaction Service. - * - * Commands may fail in 4 distinct manners: - * - * 1. INVALID_PARAMETER gRPC error on malformed payloads and missing - * required fields. - * - * 2. Failure communicated in the SubmitResponse. - * - * 3. Failure communicated in a Completion. - * - * 4. A Checkpoint with record_time > command mrt arrives through the - * Completion Stream, and the command's Completion was not visible - * before. In this case the command is lost. - * - * Clients that do not receive a successful completion about their - * submission MUST NOT assume that it was successful. - * - * Clients SHOULD subscribe to the CompletionStream before starting to - * submit commands to prevent race conditions. - * - * Interprocess tracing of command submissions may be achieved via Zipkin - * by filling out the trace_context field. - * - * The server will return a child context of the submitted one, (or a new - * one if the context was missing) on both the Completion and Transaction streams. - * - * @class CommandCompletionClient - * @memberof ledger - * @param {string} ledgerId - * @param {grpc.ICommandCompletionClient} client - */ -export class CommandCompletionClient { - - private readonly completionEndRequest: grpc.CompletionEndRequest - private readonly client: grpc.ICommandCompletionClient - private readonly ledgerId: string - private readonly reporter: reporting.Reporter - - constructor(ledgerId: string, client: grpc.ICommandCompletionClient, reporter: reporting.Reporter) { - this.completionEndRequest = new grpc.CompletionEndRequest(); - this.completionEndRequest.setLedgerId(ledgerId); - this.ledgerId = ledgerId; - this.client = client; - this.reporter = reporter; - } - - /** - * Subscribe to command completion events. - * - * @method completionStream - * @memberof ledger.CommandCompletionClient - * @instance - * @param {ledger.CompletionStreamRequest} requestObject - * @returns {ledger.ClientReadableObjectStream} - */ - completionStream(requestObject: ledger.CompletionStreamRequest): ClientReadableObjectStream { - const tree = validation.CompletionStreamRequest.validate(requestObject); - if (validation.ok(tree)) { - const request = mapping.CompletionStreamRequest.toMessage(requestObject); - request.setLedgerId(this.ledgerId); - return ClientReadableObjectStream.from(this.client.completionStream(request), mapping.CompletionStreamResponse); - } else { - return ClientReadableObjectStream.from(this.reporter(tree)); - } - } - - /** - * Returns the offset after the latest completion. - * - * @method completionEnd - * @memberof ledger.CommandCompletionClient - * @instance - * @param {util.Callback} callback - * @returns {ledger.ClientCancellableCall} - */ - completionEnd(callback: Callback): ClientCancellableCall { - return ClientCancellableCall.accept(this.client.completionEnd(this.completionEndRequest, (error, response) => { - forward(callback, error, response, mapping.CompletionEndResponse.toObject); - })); - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/client/command_submission_client.ts b/language-support/js/daml-ledger/src/client/command_submission_client.ts deleted file mode 100644 index 5af3da7a46e..00000000000 --- a/language-support/js/daml-ledger/src/client/command_submission_client.ts +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as ledger from '..'; -import * as mapping from '../mapping'; -import * as reporting from '../reporting'; -import * as validation from '../validation'; - -import { Callback } from '../util'; -import { ClientCancellableCall } from '../call/client_cancellable_call'; -import { justForward } from '../util/callback'; - -/** - * Allows clients to attempt advancing the ledger's state by submitting - * commands. - * - * The final states of their submissions are disclosed by the Command - * Completion Service. - * - * The on-ledger effects of their submissions are disclosed by the - * Transaction Service. - * - * Commands may fail in 4 distinct manners: - * - * 1) INVALID_PARAMETER gRPC error on malformed payloads and missing - * required fields. - * - * 2) Failure communicated in the SubmitResponse. - * - * 3) Failure communicated in a Completion. - * - * 4) A Checkoint with record_time > command mrt arrives through the - * Completion Stream, and the command's Completion was not visible - * before. In this case the command is lost. - * - * Clients that do not receive a successful completion about their - * submission MUST NOT assume that it was successful. - * - * Clients SHOULD subscribe to the CompletionStream before starting to - * submit commands to prevent race conditions. - * - * Interprocess tracing of command submissions may be achieved via Zipkin - * by filling out the trace_context field. - * - * The server will return a child context of the submitted one, (or a new - * one if the context was missing) on both the Completion and Transaction - * streams. - * - * @class CommandSubmissionClient - * @memberof ledger - * @param {string} ledgerId - * @param {grpc.ICommandSubmissionClient} client - */ -export class CommandSubmissionClient { - - private readonly ledgerId: string; - private readonly client: grpc.ICommandSubmissionClient; - private readonly reporter: reporting.Reporter; - - constructor(ledgerId: string, client: grpc.ICommandSubmissionClient, reporter: reporting.Reporter) { - this.ledgerId = ledgerId; - this.client = client; - this.reporter = reporter; - } - - /** - * Submit a single composite command. - * - * @method submit - * @memberof ledger.CommandSubmissionClient - * @instance - * @param {ledger.SubmitRequest} requestObject - * @param {util.Callback} callback - * @returns {ledger.ClientCancellableCall} - */ - submit(requestObject: ledger.SubmitRequest, callback: Callback): ClientCancellableCall { - const tree = validation.SubmitRequest.validate(requestObject); - if (validation.ok(tree)) { - const request = mapping.SubmitRequest.toMessage(requestObject); - if (request.hasCommands()) { - request.getCommands()!.setLedgerId(this.ledgerId); - } - return ClientCancellableCall.accept(this.client.submit(request, (error, _) => { - justForward(callback, error, null); - })); - } else { - setImmediate(() => callback(this.reporter(tree))); - return ClientCancellableCall.rejected; - } - } - -} diff --git a/language-support/js/daml-ledger/src/client/index.ts b/language-support/js/daml-ledger/src/client/index.ts deleted file mode 100644 index 9ca70994301..00000000000 --- a/language-support/js/daml-ledger/src/client/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as testing from './testing'; -export { testing }; - -export { ActiveContractsClient } from './active_contracts_client'; -export { CommandClient } from './command_client'; -export { CommandCompletionClient } from './command_completion_client'; -export { CommandSubmissionClient } from './command_submission_client'; -export { LedgerConfigurationClient } from './ledger_configuration_client'; -export { LedgerIdentityClient } from './ledger_identity_client'; -export { PackageClient } from './package_client'; -export { TransactionClient } from './transaction_client'; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/client/ledger_configuration_client.ts b/language-support/js/daml-ledger/src/client/ledger_configuration_client.ts deleted file mode 100644 index 6ddb4f5546e..00000000000 --- a/language-support/js/daml-ledger/src/client/ledger_configuration_client.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as ledger from '..'; -import * as mapping from '../mapping'; - -import { ClientReadableObjectStream } from '../call/client_readable_object_stream'; - -/** - * LedgerConfigurationService allows clients to subscribe to changes of - * the ledger configuration. - * - * @class LedgerConfigurationClient - * @memberof ledger - * @param {string} ledgerId - * @param {grpc.ILedgerConfigurationClient} client - */ -export class LedgerConfigurationClient { - - private readonly request: grpc.GetLedgerConfigurationRequest - private readonly client: grpc.ILedgerConfigurationClient - - constructor(ledgerId: string, client: grpc.ILedgerConfigurationClient) { - this.request = new grpc.GetLedgerConfigurationRequest() - this.request.setLedgerId(ledgerId); - this.client = client; - } - - /** - * GetLedgerConfiguration returns the latest configuration as the first response, and publishes configuration updates in the same stream. - * - * @method getLedgerConfiguration - * @memberof ledger.LedgerConfigurationClient - * @instance - * @returns {ledger.ClientReadableObjectStream} - */ - getLedgerConfiguration(): ClientReadableObjectStream { - return ClientReadableObjectStream.from(this.client.getLedgerConfiguration(this.request), mapping.GetLedgerConfigurationResponse); - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/client/ledger_identity_client.ts b/language-support/js/daml-ledger/src/client/ledger_identity_client.ts deleted file mode 100644 index e8472bf9bb8..00000000000 --- a/language-support/js/daml-ledger/src/client/ledger_identity_client.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as ledger from '..'; -import * as mapping from '../mapping'; - -import { Callback } from '../util'; -import { ClientCancellableCall } from '../call/client_cancellable_call'; -import { forward } from '../util/callback'; - -/** - * Allows clients to verify that the server they are communicating with - * exposes the ledger they wish to operate on. - * - * Note that every ledger has a unique id. - * - * @class LedgerIdentityClient - * @memberof ledger - * @param {grpc.ILedgerIdentityClient} client - */ -export class LedgerIdentityClient { - - private static request = new grpc.GetLedgerIdentityRequest(); - - private readonly client: grpc.ILedgerIdentityClient - - constructor(client: grpc.ILedgerIdentityClient) { - this.client = client; - } - - /** - * Clients may call this RPC to return the identifier of the ledger they - * are connected to. - * - * @method getLedgerIdentity - * @memberof ledger.LedgerIdentityClient - * @instance - * @param {util.Callback} callback - * @returns {ledger.ClientCancellableCall} - */ - getLedgerIdentity(callback: Callback): ClientCancellableCall { - return ClientCancellableCall.accept(this.client.getLedgerIdentity(LedgerIdentityClient.request, (error, response) => { - forward(callback, error, response, mapping.GetLedgerIdentityResponse.toObject); - })); - } - -} diff --git a/language-support/js/daml-ledger/src/client/package_client.ts b/language-support/js/daml-ledger/src/client/package_client.ts deleted file mode 100644 index 2c868850249..00000000000 --- a/language-support/js/daml-ledger/src/client/package_client.ts +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as ledger from '..'; -import * as mapping from '../mapping'; - -import { Callback } from '../util'; -import { ClientCancellableCall } from '../call/client_cancellable_call'; -import { forward } from '../util/callback'; - -/** - * Allows clients to query the DAML LF packages that are supported by the - * server. - * - * @class PackageClient - * @memberof ledger - * @param {string} ledgerId - * @param {grpc.IPackageClient} client - */ -export class PackageClient { - - private ledgerId: string; - private listPackagesRequest: grpc.ListPackagesRequest - private client: grpc.IPackageClient; - - constructor(ledgerId: string, client: grpc.IPackageClient) { - this.client = client; - this.ledgerId = ledgerId; - this.listPackagesRequest = new grpc.ListPackagesRequest(); - this.listPackagesRequest.setLedgerId(this.ledgerId); - } - - /** - * Returns the identifiers of all supported packages. - * - * @method listPackages - * @memberof ledger.PackageClient - * @instance - * @param {util.Callback} callback - * @returns {ledger.ClientCancellableCall} - */ - listPackages(callback: Callback): ClientCancellableCall { - return ClientCancellableCall.accept(this.client.listPackages(this.listPackagesRequest, (error, response) => { - forward(callback, error, response, mapping.ListPackagesResponse.toObject); - })); - } - - /** - * Returns the contents of a single package, or a NOT_FOUND error if the - * requested package is unknown. - * - * @method getPackage - * @memberof ledger.PackageClient - * @instance - * @param {string} packageId - * @param {util.Callback} callback - * @returns {ledger.ClientCancellableCall} - */ - getPackage(packageId: string, callback: Callback): ClientCancellableCall { - const request = new grpc.GetPackageRequest(); - request.setLedgerId(this.ledgerId); - request.setPackageId(packageId); - return ClientCancellableCall.accept(this.client.getPackage(request, (error, response) => { - forward(callback, error, response, mapping.GetPackageResponse.toObject); - })); - } - - /** - * Returns the status of a single package. - * - * @method getPackageStatus - * @memberof ledger.PackageClient - * @instance - * @param {string} packageId - * @param {util.Callback} callback - * @returns {ledger.ClientCancellableCall} - */ - getPackageStatus(packageId: string, callback: Callback): ClientCancellableCall { - const request = new grpc.GetPackageStatusRequest(); - request.setLedgerId(this.ledgerId); - request.setPackageId(packageId); - return ClientCancellableCall.accept(this.client.getPackageStatus(request, (error, response) => { - forward(callback, error, response, mapping.GetPackageStatusResponse.toObject); - })); - } - -} diff --git a/language-support/js/daml-ledger/src/client/testing/index.ts b/language-support/js/daml-ledger/src/client/testing/index.ts deleted file mode 100644 index b61c375a97b..00000000000 --- a/language-support/js/daml-ledger/src/client/testing/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @namespace ledger.testing - */ - -export { TimeClient } from './time_client'; -export { ResetClient } from './reset_client'; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/client/testing/reset_client.ts b/language-support/js/daml-ledger/src/client/testing/reset_client.ts deleted file mode 100644 index 55e69a68375..00000000000 --- a/language-support/js/daml-ledger/src/client/testing/reset_client.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import { ClientCancellableCall } from '../../call'; -import { Callback } from '../../util'; -import { justForward } from '../../util/callback'; - -export class ResetClient { - - private readonly request: grpc.testing.ResetRequest - private readonly client: grpc.testing.IResetClient - - constructor(ledgerId: string, client: grpc.testing.IResetClient) { - this.client = client; - this.request = new grpc.testing.ResetRequest(); - this.request.setLedgerId(ledgerId); - } - - reset(callback: Callback) { - return ClientCancellableCall.accept(this.client.reset(this.request, (error, _) => { - justForward(callback, error, null) - })); - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/client/testing/time_client.ts b/language-support/js/daml-ledger/src/client/testing/time_client.ts deleted file mode 100644 index e50391b1f41..00000000000 --- a/language-support/js/daml-ledger/src/client/testing/time_client.ts +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as ledger from '../..'; -import * as mapping from '../../mapping'; -import * as reporting from '../../reporting'; -import * as validation from '../../validation'; -import { ClientReadableObjectStream, ClientCancellableCall } from '../../call'; -import { Callback } from '../../util'; -import { justForward } from '../../util/callback'; - -/** - * Optional service, exposed for testing static time scenarios. - * - * @class TimeClient - * @memberof ledger.testing - * @param {string} ledgerId - * @param {grpc.testing.ITimeClient} client - */ -export class TimeClient { - - private readonly ledgerId: string - private readonly client: grpc.testing.ITimeClient - private readonly reporter: reporting.Reporter; - - constructor(ledgerId: string, client: grpc.testing.ITimeClient, reporter: reporting.Reporter) { - this.ledgerId = ledgerId; - this.client = client; - this.reporter = reporter; - } - - /** - * Returns a stream of time updates. - * - * Always returns at least one response, where the first one is the current - * time. - * - * Subsequent responses are emitted whenever the ledger server's time is - * updated. - * - * @method getTime - * @memberof ledger.testing.TimeClient - * @instance - * @returns {ledger.ClientReadableObjectStream} - */ - getTime(): ClientReadableObjectStream { - const request = new grpc.testing.GetTimeRequest(); - request.setLedgerId(this.ledgerId); - return ClientReadableObjectStream.from(this.client.getTime(request), mapping.GetTimeResponse); - } - - /** - * Allows clients to change the ledger's clock in an atomic get-and-set - * operation. - * - * @method setTime - * @memberof ledger.testing.TimeClient - * @instance - * @param {ledger.SetTimeRequest} requestObject - * @param {util.Callback} callback - */ - setTime(requestObject: ledger.SetTimeRequest, callback: Callback): ClientCancellableCall { - const tree = validation.SetTimeRequest.validate(requestObject); - if (validation.ok(tree)) { - const request = mapping.SetTimeRequest.toMessage(requestObject); - request.setLedgerId(this.ledgerId); - return ClientCancellableCall.accept(this.client.setTime(request, (error, _) => { - justForward(callback, error, null) - })); - } else { - setImmediate(() => { callback(this.reporter(tree)); }); - return ClientCancellableCall.rejected; - } - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/client/transaction_client.ts b/language-support/js/daml-ledger/src/client/transaction_client.ts deleted file mode 100644 index 3f658c381d5..00000000000 --- a/language-support/js/daml-ledger/src/client/transaction_client.ts +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as ledger from '..'; -import * as mapping from '../mapping'; -import * as validation from '../validation'; -import * as reporting from '../reporting'; - -import { Callback } from '../util'; -import { ClientReadableObjectStream } from '../call/client_readable_object_stream'; -import { ClientCancellableCall } from '../call/client_cancellable_call'; -import { forward } from '../util/callback'; - -/** - * Allows clients to read transactions from the ledger. - * - * @class TransactionClient - * @memberof ledger - * @param {string} ledgerId - * @param {grpc.ITransactionClient} client - */ -export class TransactionClient { - - private readonly ledgerId: string; - private readonly client: grpc.ITransactionClient; - private readonly reporter: reporting.Reporter; - - constructor(ledgerId: string, client: grpc.ITransactionClient, reporter: reporting.Reporter) { - this.ledgerId = ledgerId; - this.client = client; - this.reporter = reporter; - } - - /** - * Get the current ledger end. - * - * Subscriptions started with the returned offset will serve transactions - * created after this RPC was called. - * - * @method getLedgerEnd - * @memberof ledger.TransactionClient - * @instance - * @param {util.Callback} callback - * @returns {ledger.ClientCancellableCall} - */ - getLedgerEnd(callback: Callback): ClientCancellableCall { - const request = new grpc.GetLedgerEndRequest(); - request.setLedgerId(this.ledgerId); - return ClientCancellableCall.accept(this.client.getLedgerEnd(request, (error, response) => { - forward(callback, error, response, mapping.GetLedgerEndResponse.toObject); - })); - } - - /** - * Lookup a transaction by the ID of an event that appears within it. - * - * This call is a future extension point and is currently not supported. - * - * Returns NOT_FOUND if no such transaction exists. - * - * @method getTransactionByEventId - * @memberof ledger.TransactionClient - * @instance - * @param {ledger.GetTransactionByEventIdRequest} requestObject - * @param {util.Callback} callback - * @returns {ledger.ClientCancellableCall} - */ - getTransactionByEventId(requestObject: ledger.GetTransactionByEventIdRequest, callback: Callback): ClientCancellableCall { - const tree = validation.GetTransactionByEventIdRequest.validate(requestObject); - if (validation.ok(tree)) { - const request = mapping.GetTransactionByEventIdRequest.toMessage(requestObject); - request.setLedgerId(this.ledgerId); - return ClientCancellableCall.accept(this.client.getTransactionByEventId(request, (error, response) => { - forward(callback, error, response, mapping.GetTransactionResponse.toObject); - })); - } else { - setImmediate(() => callback(this.reporter(tree))); - return ClientCancellableCall.rejected; - } - } - - /** - * Lookup a transaction by its ID. - * - * This call is a future extension point and is currently not supported. - * - * Returns NOT_FOUND if no such transaction exists. - * - * @method getTransactionById - * @memberof ledger.TransactionClient - * @instance - * @param {ledger.GetTransactionByIdRequest} requestObject - * @param {util.Callback} callback - * @returns {ledger.ClientCancellableCall} - */ - getTransactionById(requestObject: ledger.GetTransactionByIdRequest, callback: Callback): ClientCancellableCall { - const request = mapping.GetTransactionByIdRequest.toMessage(requestObject); - request.setLedgerId(this.ledgerId); - return ClientCancellableCall.accept(this.client.getTransactionById(request, (error, response) => { - forward(callback, error, response, mapping.GetTransactionResponse.toObject); - })); - } - - /** - * Read the ledger's filtered transaction stream for a set of parties. - * - * @method getTransactions - * @memberof ledger.TransactionClient - * @instance - * @param {ledger.GetTransactionsRequest} requestObject - * @returns {ledger.ClientReadableObjectStream} - */ - getTransactions(requestObject: ledger.GetTransactionsRequest): ClientReadableObjectStream { - const tree = validation.GetTransactionsRequest.validate(requestObject); - if (validation.ok(tree)) { - const request = mapping.GetTransactionsRequest.toMessage(requestObject); - request.setLedgerId(this.ledgerId); - if (requestObject.verbose === undefined) { - request.setVerbose(true); - } - return ClientReadableObjectStream.from(this.client.getTransactions(request), mapping.GetTransactionsResponse); - } else { - return ClientReadableObjectStream.from(this.reporter(tree)); - } - } - - /** - * Read the ledger's complete transaction stream for a set of parties. - * - * This call is a future extension point and is currently not supported. - * - * @method getTransactionTrees - * @memberof ledger.TransactionClient - * @instance - * @param {ledger.GetTransactionsRequest} requestObject - * @returns {ledger.ClientReadableObjectStream} - */ - getTransactionTrees(requestObject: ledger.GetTransactionsRequest): ClientReadableObjectStream { - const tree = validation.GetTransactionsRequest.validate(requestObject); - if (validation.ok(tree)) { - const request = mapping.GetTransactionsRequest.toMessage(requestObject); - request.setLedgerId(this.ledgerId); - return ClientReadableObjectStream.from(this.client.getTransactionTrees(request), mapping.GetTransactionTreesResponse); - } else { - return ClientReadableObjectStream.from(this.reporter(tree)); - } - } - -} diff --git a/language-support/js/daml-ledger/src/daml_ledger_client.ts b/language-support/js/daml-ledger/src/daml_ledger_client.ts deleted file mode 100644 index ebd8118e784..00000000000 --- a/language-support/js/daml-ledger/src/daml_ledger_client.ts +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { ChannelCredentials, credentials } from 'grpc'; - -import * as ledger from '.'; -import * as grpc from 'daml-grpc'; - -import { Callback, forward } from './util/callback'; - -/** - * A {@link ledger.LedgerClient} implementation that connects to an existing Ledger and provides clients to query it. To use the {@link ledger.DamlLedgerClient} - * call the static `connect` method, passing an instance of {@link ledger.Options} with the host, port and (for secure connection) the - * necessary certificates. - * - * @interface DamlLedgerClient - * @memberof ledger - * @implements ledger.LedgerClient - */ -export class DamlLedgerClient implements ledger.LedgerClient { - - /** - * Connects a new instance of the {@link ledger.DamlLedgerClient} to the Ledger. - * - * @method connect - * @memberof ledger.DamlLedgerClient - * @param {ledger.LedgerClient.Options} options The host, port and certificates needed to reach the ledger - * @param {util.Callback} callback A callback that will be either passed an error or the LedgerClient instance in case of successfull connection - */ - static connect(options: ledger.LedgerClient.Options, callback: Callback): void { - - let creds: ChannelCredentials; - if (!options.certChain && !options.privateKey && !options.rootCerts) { - creds = credentials.createInsecure(); - } else if (options.certChain && options.privateKey && options.rootCerts) { - creds = credentials.createSsl(options.rootCerts, options.privateKey, options.certChain) - } else { - setImmediate(() => { - callback(new Error(`Incomplete information provided to establish a secure connection (certChain: ${!!options.certChain}, privateKey: ${!!options.privateKey}, rootCerts: ${!!options.rootCerts})`)); - }); - return; - } - - const reporter = options.reporter || ledger.reporting.SimpleReporter; - const address = `${options.host}:${options.port}`; - const client = new grpc.LedgerIdentityClient(address, creds); - - client.getLedgerIdentity(new grpc.GetLedgerIdentityRequest(), (error, response) => { - forward(callback, error, response, (response) => { - return new DamlLedgerClient(response.getLedgerId(), address, creds, reporter); - }); - }); - - } - - public readonly ledgerId: string; - - private readonly _activeContractsClient: ledger.ActiveContractsClient; - private readonly _commandClient: ledger.CommandClient; - private readonly _commandCompletionClient: ledger.CommandCompletionClient; - private readonly _commandSubmissionClient: ledger.CommandSubmissionClient; - private readonly _ledgerIdentityClient: ledger.LedgerIdentityClient; - private readonly _packageClient: ledger.PackageClient; - private readonly _ledgerConfigurationClient: ledger.LedgerConfigurationClient; - private readonly _timeClient: ledger.testing.TimeClient; - private readonly _transactionClient: ledger.TransactionClient; - private readonly _resetClient: ledger.testing.ResetClient; - - private constructor(ledgerId: string, address: string, creds: ChannelCredentials, reporter: ledger.reporting.Reporter) { - this.ledgerId = ledgerId; - this._activeContractsClient = - new ledger.ActiveContractsClient(ledgerId, new grpc.ActiveContractsClient(address, creds), reporter); - this._commandClient = - new ledger.CommandClient(ledgerId, new grpc.CommandClient(address, creds), reporter); - this._commandCompletionClient = - new ledger.CommandCompletionClient(ledgerId, new grpc.CommandCompletionClient(address, creds), reporter); - this._commandSubmissionClient = - new ledger.CommandSubmissionClient(ledgerId, new grpc.CommandSubmissionClient(address, creds), reporter); - this._ledgerIdentityClient = - new ledger.LedgerIdentityClient(new grpc.LedgerIdentityClient(address, creds)); - this._packageClient = - new ledger.PackageClient(ledgerId, new grpc.PackageClient(address, creds)); - this._ledgerConfigurationClient = - new ledger.LedgerConfigurationClient(ledgerId, new grpc.LedgerConfigurationClient(address, creds)); - this._timeClient = - new ledger.testing.TimeClient(ledgerId, new grpc.testing.TimeClient(address, creds), reporter); - this._transactionClient = - new ledger.TransactionClient(ledgerId, new grpc.TransactionClient(address, creds), reporter); - this._resetClient = - new ledger.testing.ResetClient(ledgerId, new grpc.testing.ResetClient(address, creds)); - } - - get activeContractsClient(): ledger.ActiveContractsClient { - return this._activeContractsClient; - } - - get commandClient(): ledger.CommandClient { - return this._commandClient; - } - - get commandCompletionClient(): ledger.CommandCompletionClient { - return this._commandCompletionClient; - } - - get commandSubmissionClient(): ledger.CommandSubmissionClient { - return this._commandSubmissionClient; - } - - get ledgerIdentityClient(): ledger.LedgerIdentityClient { - return this._ledgerIdentityClient; - } - - get packageClient(): ledger.PackageClient { - return this._packageClient; - } - - get ledgerConfigurationClient(): ledger.LedgerConfigurationClient { - return this._ledgerConfigurationClient; - } - - get timeClient(): ledger.testing.TimeClient { - return this._timeClient; - } - - get transactionClient(): ledger.TransactionClient { - return this._transactionClient; - } - - get resetClient(): ledger.testing.ResetClient { - return this._resetClient; - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/index.ts b/language-support/js/daml-ledger/src/index.ts deleted file mode 100644 index 59cd3846093..00000000000 --- a/language-support/js/daml-ledger/src/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @namespace ledger - */ - -export * from './model'; - -export * from './call'; - -export * from './client'; - -export * from './ledger_client'; -export * from './daml_ledger_client'; - -import * as reporting from './reporting'; -export { reporting }; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/ledger_client.ts b/language-support/js/daml-ledger/src/ledger_client.ts deleted file mode 100644 index 6de67f53db9..00000000000 --- a/language-support/js/daml-ledger/src/ledger_client.ts +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from "."; - -export namespace LedgerClient { - - /** - * The ledger required to connect to a {@link ledger.LedgerClient} - * - * @interface Options - * @memberof ledger.LedgerClient - */ - export interface Options { - /** - * @member {string} host - * @memberof ledger.LedgerClient.Options - * @instance - */ - host: string - /** - * @member {number} port - * @memberof ledger.LedgerClient.Options - * @instance - */ - port: number - /** - * @member {ledger.reporting.Reporter} reporter - * @memberof ledger.LedgerClient.Options - * @instance - */ - reporter?: ledger.reporting.Reporter - /** - * @member {Buffer} rootCerts The root certificate ledger - * @memberof ledger.LedgerClient.Options - * @instance - */ - rootCerts?: Buffer - /** - * @member {Buffer} privateKey The client certificate private key - * @memberof ledger.LedgerClient.Options - * @instance - */ - privateKey?: Buffer - /** - * @member {Buffer} certChain The client certificate cert chain - * @memberof ledger.LedgerClient.Options - * @instance - */ - certChain?: Buffer - } - -} - -/** - * Contains the set of services provided by a ledger implementation - * - * @interface LedgerClient - * @memberof ledger - */ -export interface LedgerClient { - /** - * The identifier of the ledger connected to this {@link LedgerClient} - * - * @member {string} ledgerId - * @memberof ledger.LedgerClient - * @instance - */ - ledgerId: string - /** - * @member {ledger.ActiveContractsClient} activeContractsClient - * @memberof ledger.LedgerClient - * @instance - */ - activeContractsClient: ledger.ActiveContractsClient - /** - * @member {ledger.CommandClient} commandClient - * @memberof ledger.LedgerClient - * @instance - */ - commandClient: ledger.CommandClient - /** - * @member {ledger.CommandCompletionClient} commandCompletionClient - * @memberof ledger.LedgerClient - * @instance - */ - commandCompletionClient: ledger.CommandCompletionClient - /** - * @member {ledger.CommandSubmissionClient} commandSubmissionClient - * @memberof ledger.LedgerClient - * @instance - */ - commandSubmissionClient: ledger.CommandSubmissionClient - /** - * @member {ledger.LedgerIdentityClient} ledgerIdentityClient - * @memberof ledger.LedgerClient - * @instance - */ - ledgerIdentityClient: ledger.LedgerIdentityClient - /** - * @member {ledger.PackageClient} packageClient - * @memberof ledger.LedgerClient - * @instance - */ - packageClient: ledger.PackageClient - /** - * @member {ledger.LedgerConfigurationClient} ledgerConfigurationClient - * @memberof ledger.LedgerClient - * @instance - */ - ledgerConfigurationClient: ledger.LedgerConfigurationClient - /** - * @member {ledger.testing.TimeClient} timeClient - * @memberof ledger.LedgerClient - * @instance - */ - timeClient: ledger.testing.TimeClient - /** - * @member {ledger.TransactionClient} transactionClient - * @memberof ledger.LedgerClient - * @instance - */ - transactionClient: ledger.TransactionClient - /** - * @member {ledger.testing.ResetClient} resetClient - * @memberof ledger.LedgerClient - * @instance - */ - resetClient: ledger.testing.ResetClient -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/any.ts b/language-support/js/daml-ledger/src/mapping/any.ts deleted file mode 100644 index 76a00fc8aea..00000000000 --- a/language-support/js/daml-ledger/src/mapping/any.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as protobuf from 'google-protobuf/google/protobuf/any_pb'; - -export const Any: mapping.Mapping = { - toObject(message: protobuf.Any): ledger.Any { - return { - value: message.getValue_asB64(), - typeUrl: message.getTypeUrl() - } - }, - toMessage(object: ledger.Any): protobuf.Any { - const message = new protobuf.Any(); - message.setValue(object.value); - message.setTypeUrl(object.typeUrl); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/archived_event.ts b/language-support/js/daml-ledger/src/mapping/archived_event.ts deleted file mode 100644 index 752b7c0937c..00000000000 --- a/language-support/js/daml-ledger/src/mapping/archived_event.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const ArchivedEvent: mapping.Mapping = { - toObject(message: grpc.ArchivedEvent): ledger.ArchivedEvent { - return { - contractId: message.getContractId(), - eventId: message.getEventId(), - templateId: mapping.Identifier.toObject(message.getTemplateId()!), - witnessParties: message.getWitnessPartiesList() - }; - }, - toMessage(object: ledger.ArchivedEvent): grpc.ArchivedEvent { - const message = new grpc.ArchivedEvent(); - message.setContractId(object.contractId); - message.setEventId(object.eventId); - message.setTemplateId(mapping.Identifier.toMessage(object.templateId)); - message.setWitnessPartiesList(object.witnessParties); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/checkpoint.ts b/language-support/js/daml-ledger/src/mapping/checkpoint.ts deleted file mode 100644 index e00b1fe4a06..00000000000 --- a/language-support/js/daml-ledger/src/mapping/checkpoint.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const Checkpoint: mapping.Mapping = { - toObject(message: grpc.Checkpoint): ledger.Checkpoint { - return { - offset: mapping.LedgerOffset.toObject(message.getOffset()!), - recordTime: mapping.Timestamp.toObject(message.getRecordTime()!) - }; - }, - toMessage(object: ledger.Checkpoint): grpc.Checkpoint { - const message = new grpc.Checkpoint(); - message.setOffset(mapping.LedgerOffset.toMessage(object.offset)); - message.setRecordTime(mapping.Timestamp.toMessage(object.recordTime)); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/command.ts b/language-support/js/daml-ledger/src/mapping/command.ts deleted file mode 100644 index 63e91735d73..00000000000 --- a/language-support/js/daml-ledger/src/mapping/command.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -import { inspect } from 'util'; - -export const Command: mapping.Mapping = { - toObject(command: grpc.Command): ledger.Command { - if (command.hasCreate()) { - return { create: mapping.CreateCommand.toObject(command.getCreate()!) }; - } else if (command.hasExercise()) { - return { exercise: mapping.ExerciseCommand.toObject(command.getExercise()!) }; - } else { - throw new Error(`Expected either CreateCommand or ExerciseCommand, found ${inspect(command)}`); - } - }, - toMessage(command: ledger.Command): grpc.Command { - const result = new grpc.Command(); - if (command.create !== undefined) { - result.setCreate(mapping.CreateCommand.toMessage(command.create)); - } else if (command.exercise !== undefined) { - result.setExercise(mapping.ExerciseCommand.toMessage(command.exercise)); - } else { - throw new Error(`Expected either LedgerOffset Absolute or LedgerOffset Boundary, found ${inspect(command)}`); - } - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/commands.ts b/language-support/js/daml-ledger/src/mapping/commands.ts deleted file mode 100644 index 033d8e00bb6..00000000000 --- a/language-support/js/daml-ledger/src/mapping/commands.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const Commands: mapping.Mapping = { - toObject(commands: grpc.Commands): ledger.Commands { - const result: ledger.Commands = { - applicationId: commands.getApplicationId(), - commandId: commands.getCommandId(), - party: commands.getParty(), - ledgerEffectiveTime: mapping.Timestamp.toObject(commands.getLedgerEffectiveTime()!), - maximumRecordTime: mapping.Timestamp.toObject(commands.getMaximumRecordTime()!), - list: commands.getCommandsList().map((command) => mapping.Command.toObject(command)) - }; - const workflowId = commands.getWorkflowId(); - if (workflowId !== undefined && workflowId !== '') { - result.workflowId = workflowId; - } - return result; - }, - toMessage(commands: ledger.Commands): grpc.Commands { - const result = new grpc.Commands(); - result.setCommandId(commands.commandId); - result.setParty(commands.party); - result.setLedgerEffectiveTime(mapping.Timestamp.toMessage(commands.ledgerEffectiveTime)); - result.setMaximumRecordTime(mapping.Timestamp.toMessage(commands.maximumRecordTime)); - result.setCommandsList(commands.list.map(mapping.Command.toMessage)); - if (commands.workflowId) { - result.setWorkflowId(commands.workflowId); - } - if (commands.applicationId) { - result.setApplicationId(commands.applicationId); - } - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/completion.ts b/language-support/js/daml-ledger/src/mapping/completion.ts deleted file mode 100644 index 67cd6f62326..00000000000 --- a/language-support/js/daml-ledger/src/mapping/completion.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const Completion: mapping.Mapping = { - toObject(message: grpc.Completion): ledger.Completion { - const completion: ledger.Completion = { - commandId: message.getCommandId() - } - const status = message.getStatus(); - if (status !== undefined) { - completion.status = mapping.Status.toObject(status); - } - return completion; - }, - toMessage(object: ledger.Completion): grpc.Completion { - const message = new grpc.Completion(); - message.setCommandId(object.commandId); - if (object.status) { - message.setStatus(mapping.Status.toMessage(object.status)); - } - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/completion_end_response.ts b/language-support/js/daml-ledger/src/mapping/completion_end_response.ts deleted file mode 100644 index ac4f8a39b38..00000000000 --- a/language-support/js/daml-ledger/src/mapping/completion_end_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const CompletionEndResponse: mapping.Mapping = { - toObject(message: grpc.CompletionEndResponse): ledger.CompletionEndResponse { - return { - offset: mapping.LedgerOffset.toObject(message.getOffset()!) - }; - }, - toMessage(response: ledger.CompletionEndResponse): grpc.CompletionEndResponse { - const result = new grpc.CompletionEndResponse(); - result.setOffset(mapping.LedgerOffset.toMessage(response.offset)); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/completion_stream_request.ts b/language-support/js/daml-ledger/src/mapping/completion_stream_request.ts deleted file mode 100644 index c60cc4661c9..00000000000 --- a/language-support/js/daml-ledger/src/mapping/completion_stream_request.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const CompletionStreamRequest: mapping.Mapping = { - toObject(message: grpc.CompletionStreamRequest): ledger.CompletionStreamRequest { - return { - applicationId: message.getApplicationId(), - offset: mapping.LedgerOffset.toObject(message.getOffset()!), - parties: message.getPartiesList() - }; - }, - toMessage(object: ledger.CompletionStreamRequest): grpc.CompletionStreamRequest { - const result = new grpc.CompletionStreamRequest(); - result.setApplicationId(object.applicationId); - result.setOffset(mapping.LedgerOffset.toMessage(object.offset)); - result.setPartiesList(object.parties); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/completion_stream_response.ts b/language-support/js/daml-ledger/src/mapping/completion_stream_response.ts deleted file mode 100644 index fca05666ed1..00000000000 --- a/language-support/js/daml-ledger/src/mapping/completion_stream_response.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const CompletionStreamResponse: mapping.Mapping = { - toObject(message: grpc.CompletionStreamResponse): ledger.CompletionStreamResponse { - const response: ledger.CompletionStreamResponse = {}; - const completions = message.getCompletionsList(); - if (completions) { - response.completions = completions.map(c => mapping.Completion.toObject(c)); - } - if (message.hasCheckpoint()) { - response.checkpoint = mapping.Checkpoint.toObject(message.getCheckpoint()!) - } - return response; - }, - toMessage(object: ledger.CompletionStreamResponse): grpc.CompletionStreamResponse { - const result = new grpc.CompletionStreamResponse(); - if (object.checkpoint) { - result.setCheckpoint(mapping.Checkpoint.toMessage(object.checkpoint)); - } - if (object.completions) { - result.setCompletionsList(object.completions.map((c: ledger.Completion) => mapping.Completion.toMessage(c))); - } - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/create_command.ts b/language-support/js/daml-ledger/src/mapping/create_command.ts deleted file mode 100644 index c81b24c6001..00000000000 --- a/language-support/js/daml-ledger/src/mapping/create_command.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const CreateCommand: mapping.Mapping = { - toObject(command: grpc.CreateCommand): ledger.CreateCommand { - return { - templateId: mapping.Identifier.toObject(command.getTemplateId()!), - arguments: mapping.Record.toObject(command.getCreateArguments()!) - } - }, - toMessage(command: ledger.CreateCommand): grpc.CreateCommand { - const result = new grpc.CreateCommand(); - result.setTemplateId(mapping.Identifier.toMessage(command.templateId)); - result.setCreateArguments(mapping.Record.toMessage(command.arguments)); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/created_event.ts b/language-support/js/daml-ledger/src/mapping/created_event.ts deleted file mode 100644 index b048c6f5bc4..00000000000 --- a/language-support/js/daml-ledger/src/mapping/created_event.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const CreatedEvent: mapping.Mapping = { - toObject(event: grpc.CreatedEvent): ledger.CreatedEvent { - return { - eventId: event.getEventId(), - contractId: event.getContractId(), - templateId: mapping.Identifier.toObject(event.getTemplateId()!), - arguments: mapping.Record.toObject(event.getCreateArguments()!), - witnessParties: event.getWitnessPartiesList() - }; - }, - toMessage(event: ledger.CreatedEvent): grpc.CreatedEvent { - const result = new grpc.CreatedEvent(); - result.setEventId(event.eventId); - result.setContractId(event.contractId); - result.setTemplateId(mapping.Identifier.toMessage(event.templateId)); - result.setCreateArguments(mapping.Record.toMessage(event.arguments)); - result.setWitnessPartiesList(event.witnessParties); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/duration.ts b/language-support/js/daml-ledger/src/mapping/duration.ts deleted file mode 100644 index cf5a3fed5e6..00000000000 --- a/language-support/js/daml-ledger/src/mapping/duration.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as protobuf from 'google-protobuf/google/protobuf/duration_pb'; - -export const Duration: mapping.Mapping = { - toObject(message: protobuf.Duration): ledger.Duration { - return { - seconds: message.getSeconds(), - nanoseconds: message.getNanos() - }; - }, - toMessage(object: ledger.Duration): protobuf.Duration { - const message = new protobuf.Duration(); - message.setSeconds(object.seconds); - message.setNanos(object.nanoseconds); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/event.ts b/language-support/js/daml-ledger/src/mapping/event.ts deleted file mode 100644 index 763bc66e9fa..00000000000 --- a/language-support/js/daml-ledger/src/mapping/event.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -import { inspect } from 'util'; - -export const Event: mapping.Mapping = { - toObject(message: grpc.Event): ledger.Event { - if (message.hasArchived()) { - return { - archived: mapping.ArchivedEvent.toObject(message.getArchived()!) - } - } else if (message.hasCreated()) { - return { - created: mapping.CreatedEvent.toObject(message.getCreated()!) - } - } else if (message.hasExercised()) { - return { - exercised: mapping.ExercisedEvent.toObject(message.getExercised()!) - } - } else { - throw new Error(`Expected one of ArchivedEvent, CreatedEvent or ExercisedEvent, found ${inspect(message)}`); - } - }, - toMessage(object: ledger.Event): grpc.Event { - const message = new grpc.Event(); - if (object.archived !== undefined) { - message.setArchived(mapping.ArchivedEvent.toMessage(object.archived)); - } else if (object.created !== undefined) { - message.setCreated(mapping.CreatedEvent.toMessage(object.created)); - } else if (object.exercised !== undefined) { - message.setExercised(mapping.ExercisedEvent.toMessage(object.exercised)); - } else { - throw new Error(`Expected one of ArchivedEvent, CreatedEvent or ExercisedEvent, found ${inspect(object)}`); - } - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/exercise_command.ts b/language-support/js/daml-ledger/src/mapping/exercise_command.ts deleted file mode 100644 index aab5e3cdc29..00000000000 --- a/language-support/js/daml-ledger/src/mapping/exercise_command.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const ExerciseCommand: mapping.Mapping = { - toObject(command: grpc.ExerciseCommand): ledger.ExerciseCommand { - return { - templateId: mapping.Identifier.toObject(command.getTemplateId()!), - contractId: command.getContractId(), - choice: command.getChoice(), - argument: mapping.Value.toObject(command.getChoiceArgument()!), - }; - }, - toMessage(command: ledger.ExerciseCommand): grpc.ExerciseCommand { - const result = new grpc.ExerciseCommand(); - result.setTemplateId(mapping.Identifier.toMessage(command.templateId)); - result.setContractId(command.contractId); - result.setChoice(command.choice); - result.setChoiceArgument(mapping.Value.toMessage(command.argument)); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/exercised_event.ts b/language-support/js/daml-ledger/src/mapping/exercised_event.ts deleted file mode 100644 index a985bdae65e..00000000000 --- a/language-support/js/daml-ledger/src/mapping/exercised_event.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const ExercisedEvent: mapping.Mapping = { - toObject(message: grpc.ExercisedEvent): ledger.ExercisedEvent { - const event: ledger.ExercisedEvent = { - actingParties: message.getActingPartiesList(), - choice: message.getChoice(), - argument: mapping.Value.toObject(message.getChoiceArgument()!), - consuming: message.getConsuming(), - contractCreatingEventId: message.getContractCreatingEventId(), - contractId: message.getContractId(), - eventId: message.getEventId(), - templateId: mapping.Identifier.toObject(message.getTemplateId()!), - witnessParties: message.getWitnessPartiesList() - }; - const childEventIds = message.getChildEventIdsList(); - if (childEventIds) { - event.childEventIds = [...childEventIds]; - } - return event; - }, - toMessage(object: ledger.ExercisedEvent): grpc.ExercisedEvent { - const message = new grpc.ExercisedEvent(); - message.setActingPartiesList(object.actingParties); - message.setChoice(object.choice); - message.setChoiceArgument(mapping.Value.toMessage(object.argument)); - message.setConsuming(object.consuming); - message.setContractCreatingEventId(object.contractCreatingEventId); - message.setContractId(object.contractId); - message.setEventId(object.eventId); - message.setTemplateId(mapping.Identifier.toMessage(object.templateId)); - message.setWitnessPartiesList(object.witnessParties) - if (object.childEventIds) { - message.setChildEventIdsList([...object.childEventIds]); - } - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/filters.ts b/language-support/js/daml-ledger/src/mapping/filters.ts deleted file mode 100644 index 1d22a5e31f4..00000000000 --- a/language-support/js/daml-ledger/src/mapping/filters.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const Filters: mapping.Mapping = { - toObject(filters: grpc.Filters): ledger.Filters { - let result: ledger.Filters = {}; - if (filters.hasInclusive()) { - result.inclusive = mapping.InclusiveFilters.toObject(filters.getInclusive()!); - } - return result; - }, - toMessage(filter: ledger.Filters): grpc.Filters { - const result = new grpc.Filters(); - if (filter.inclusive) { - result.setInclusive(mapping.InclusiveFilters.toMessage(filter.inclusive)); - } - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_active_contracts_request.ts b/language-support/js/daml-ledger/src/mapping/get_active_contracts_request.ts deleted file mode 100644 index 7ef364f0c35..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_active_contracts_request.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetActiveContractsRequest: mapping.Mapping = { - toObject(message: grpc.GetActiveContractsRequest): ledger.GetActiveContractsRequest { - const object: ledger.GetActiveContractsRequest = { - filter: mapping.TransactionFilter.toObject(message.getFilter()!) - } - const verbose = message.getVerbose(); - if (verbose !== undefined) { - object.verbose = verbose; - } - return object; - }, - toMessage(object: ledger.GetActiveContractsRequest): grpc.GetActiveContractsRequest { - const result = new grpc.GetActiveContractsRequest(); - if (object.verbose) { - result.setVerbose(object.verbose); - } - result.setFilter(mapping.TransactionFilter.toMessage(object.filter)); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_active_contracts_response.ts b/language-support/js/daml-ledger/src/mapping/get_active_contracts_response.ts deleted file mode 100644 index 185ad122cf3..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_active_contracts_response.ts +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetActiveContractsResponse: mapping.Mapping = { - toObject(response: grpc.GetActiveContractsResponse): ledger.GetActiveContractsResponse { - const result: ledger.GetActiveContractsResponse = { - offset: { absolute: response.getOffset() }, - }; - const workflowId = response.getWorkflowId(); - if (response.getWorkflowId() !== undefined && response.getWorkflowId() !== '') { - result.workflowId = workflowId; - } - const activeContracts = response.getActiveContractsList(); - if (activeContracts) { - result.activeContracts = activeContracts.map(event => mapping.CreatedEvent.toObject(event)); - } - return result; - }, - toMessage(response: ledger.GetActiveContractsResponse): grpc.GetActiveContractsResponse { - const result = new grpc.GetActiveContractsResponse(); - result.setOffset(response.offset.absolute!); - if (response.activeContracts) { - result.setActiveContractsList(response.activeContracts.map(mapping.CreatedEvent.toMessage)); - } - if (response.workflowId) { - result.setWorkflowId(response.workflowId) - } - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_ledger_configuration_response.ts b/language-support/js/daml-ledger/src/mapping/get_ledger_configuration_response.ts deleted file mode 100644 index 32b2a86dbec..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_ledger_configuration_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetLedgerConfigurationResponse: mapping.Mapping = { - toObject(message: grpc.GetLedgerConfigurationResponse): ledger.GetLedgerConfigurationResponse { - return { - config: mapping.LedgerConfiguration.toObject(message.getLedgerConfiguration()!) - }; - }, - toMessage(object: ledger.GetLedgerConfigurationResponse): grpc.GetLedgerConfigurationResponse { - const message = new grpc.GetLedgerConfigurationResponse(); - message.setLedgerConfiguration(mapping.LedgerConfiguration.toMessage(object.config)); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_ledger_end_response.ts b/language-support/js/daml-ledger/src/mapping/get_ledger_end_response.ts deleted file mode 100644 index 0539052bffd..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_ledger_end_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetLedgerEndResponse: mapping.Mapping = { - toObject(message: grpc.GetLedgerEndResponse): ledger.GetLedgerEndResponse { - return { - offset: mapping.LedgerOffset.toObject(message.getOffset()!) - }; - }, - toMessage(object: ledger.GetLedgerEndResponse): grpc.GetLedgerEndResponse { - const message = new grpc.GetLedgerEndResponse(); - message.setOffset(mapping.LedgerOffset.toMessage(object.offset)); - return message; - } -}; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_ledger_identity_response.ts b/language-support/js/daml-ledger/src/mapping/get_ledger_identity_response.ts deleted file mode 100644 index d6fa8e85e87..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_ledger_identity_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetLedgerIdentityResponse: mapping.Mapping = { - toObject(response: grpc.GetLedgerIdentityResponse): ledger.GetLedgerIdentityResponse { - return { - ledgerId: response.getLedgerId() - } - }, - toMessage(response: ledger.GetLedgerIdentityResponse): grpc.GetLedgerIdentityResponse { - const result = new grpc.GetLedgerIdentityResponse(); - result.setLedgerId(response.ledgerId); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_package_response.ts b/language-support/js/daml-ledger/src/mapping/get_package_response.ts deleted file mode 100644 index 5defea597cb..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_package_response.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetPackageResponse: mapping.Mapping = { - toObject(response: grpc.GetPackageResponse): ledger.GetPackageResponse { - return { - hash: response.getHash(), - hashFunction: ledger.HashFunction.SHA256, - archivePayload: response.getArchivePayload_asB64() - } - }, - toMessage(response: ledger.GetPackageResponse): grpc.GetPackageResponse { - const result = new grpc.GetPackageResponse(); - result.setHash(response.hash); - result.setHashFunction(response.hashFunction); - result.setArchivePayload(response.archivePayload); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_package_status_response.ts b/language-support/js/daml-ledger/src/mapping/get_package_status_response.ts deleted file mode 100644 index 73d79a46921..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_package_status_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetPackageStatusResponse: mapping.Mapping = { - toObject(response: grpc.GetPackageStatusResponse): ledger.GetPackageStatusResponse { - return { - status: mapping.PackageStatus.toObject(response.getPackageStatus()) - }; - }, - toMessage(response: ledger.GetPackageStatusResponse): grpc.GetPackageStatusResponse { - const result = new grpc.GetPackageStatusResponse(); - result.setPackageStatus(mapping.PackageStatus.toMessage(response.status)); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_time_response.ts b/language-support/js/daml-ledger/src/mapping/get_time_response.ts deleted file mode 100644 index a00be387026..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_time_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetTimeResponse: mapping.Mapping = { - toObject(message: grpc.testing.GetTimeResponse): ledger.GetTimeResponse { - return { - currentTime: mapping.Timestamp.toObject(message.getCurrentTime()!) - }; - }, - toMessage(object: ledger.GetTimeResponse) { - const message = new grpc.testing.GetTimeResponse(); - message.setCurrentTime(mapping.Timestamp.toMessage(object.currentTime)); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_transaction_by_event_id_request.ts b/language-support/js/daml-ledger/src/mapping/get_transaction_by_event_id_request.ts deleted file mode 100644 index a6612e66032..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_transaction_by_event_id_request.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetTransactionByEventIdRequest: mapping.Mapping = { - toObject(message: grpc.GetTransactionByEventIdRequest): ledger.GetTransactionByEventIdRequest { - return { - eventId: message.getEventId(), - requestingParties: message.getRequestingPartiesList() - }; - }, - toMessage(object: ledger.GetTransactionByEventIdRequest): grpc.GetTransactionByEventIdRequest { - const message = new grpc.GetTransactionByEventIdRequest(); - message.setEventId(object.eventId); - message.setRequestingPartiesList(object.requestingParties); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_transaction_by_id_request.ts b/language-support/js/daml-ledger/src/mapping/get_transaction_by_id_request.ts deleted file mode 100644 index 47ccf7100c5..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_transaction_by_id_request.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetTransactionByIdRequest: mapping.Mapping = { - toObject(message: grpc.GetTransactionByIdRequest): ledger.GetTransactionByIdRequest { - return { - transactionId: message.getTransactionId(), - requestingParties: message.getRequestingPartiesList() - }; - }, - toMessage(object: ledger.GetTransactionByIdRequest): grpc.GetTransactionByIdRequest { - const message = new grpc.GetTransactionByIdRequest(); - message.setTransactionId(object.transactionId); - message.setRequestingPartiesList(object.requestingParties); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_transaction_response.ts b/language-support/js/daml-ledger/src/mapping/get_transaction_response.ts deleted file mode 100644 index 1404f0370af..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_transaction_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetTransactionResponse: mapping.Mapping = { - toObject(message: grpc.GetTransactionResponse): ledger.GetTransactionResponse { - return { - transaction: mapping.TransactionTree.toObject(message.getTransaction()!) - }; - }, - toMessage(object: ledger.GetTransactionResponse): grpc.GetTransactionResponse { - const message = new grpc.GetTransactionResponse(); - message.setTransaction(mapping.TransactionTree.toMessage(object.transaction)); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_transaction_trees_response.ts b/language-support/js/daml-ledger/src/mapping/get_transaction_trees_response.ts deleted file mode 100644 index a9619b5d545..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_transaction_trees_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetTransactionTreesResponse: mapping.Mapping = { - toObject(message: grpc.GetTransactionTreesResponse): ledger.GetTransactionTreesResponse { - return { - transactions: message.getTransactionsList().map(t => mapping.TransactionTree.toObject(t)) - }; - }, - toMessage(object: ledger.GetTransactionTreesResponse): grpc.GetTransactionTreesResponse { - const message = new grpc.GetTransactionTreesResponse(); - message.setTransactionsList(object.transactions.map(t => mapping.TransactionTree.toMessage(t))) - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_transactions_request.ts b/language-support/js/daml-ledger/src/mapping/get_transactions_request.ts deleted file mode 100644 index 8cea30b7389..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_transactions_request.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetTransactionsRequest: mapping.Mapping = { - toObject(request: grpc.GetTransactionsRequest): ledger.GetTransactionsRequest { - const result: ledger.GetTransactionsRequest = { - begin: mapping.LedgerOffset.toObject(request.getBegin()!), - filter: mapping.TransactionFilter.toObject(request.getFilter()!) - }; - if (request.hasEnd()) { - result.end = mapping.LedgerOffset.toObject(request.getEnd()!); - } - const verbose = request.getVerbose(); - if (verbose !== undefined) { - result.verbose = verbose; - } - return result; - }, - toMessage(request: ledger.GetTransactionsRequest): grpc.GetTransactionsRequest { - const result = new grpc.GetTransactionsRequest(); - result.setBegin(mapping.LedgerOffset.toMessage(request.begin)); - if (request.end) { - result.setEnd(mapping.LedgerOffset.toMessage(request.end)); - } - result.setFilter(mapping.TransactionFilter.toMessage(request.filter)); - if (request.verbose !== undefined) { - result.setVerbose(request.verbose); - } - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/get_transactions_response.ts b/language-support/js/daml-ledger/src/mapping/get_transactions_response.ts deleted file mode 100644 index feb4ebe1571..00000000000 --- a/language-support/js/daml-ledger/src/mapping/get_transactions_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const GetTransactionsResponse: mapping.Mapping = { - toObject(message: grpc.GetTransactionsResponse): ledger.GetTransactionsResponse { - return { - transactions: message.getTransactionsList().map((t: grpc.Transaction) => mapping.Transaction.toObject(t)) - }; - }, - toMessage(object: ledger.GetTransactionsResponse): grpc.GetTransactionsResponse { - const message = new grpc.GetTransactionsResponse(); - message.setTransactionsList(object.transactions.map((t: ledger.Transaction) => mapping.Transaction.toMessage(t))) - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/identifier.ts b/language-support/js/daml-ledger/src/mapping/identifier.ts deleted file mode 100644 index 3c6d070b444..00000000000 --- a/language-support/js/daml-ledger/src/mapping/identifier.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const Identifier: mapping.Mapping = { - toObject(identifier: grpc.Identifier): ledger.Identifier { - return { - packageId: identifier.getPackageId(), - moduleName: identifier.getModuleName(), - entityName: identifier.getEntityName() - }; - }, - toMessage(identifier: ledger.Identifier): grpc.Identifier { - const value = new grpc.Identifier(); - value.setPackageId(identifier.packageId); - value.setModuleName(identifier.moduleName); - value.setEntityName(identifier.entityName); - return value; - } -}; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/inclusive_filters.ts b/language-support/js/daml-ledger/src/mapping/inclusive_filters.ts deleted file mode 100644 index 1423300be8b..00000000000 --- a/language-support/js/daml-ledger/src/mapping/inclusive_filters.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const InclusiveFilters: mapping.Mapping = { - toObject(inclusiveFilters: grpc.InclusiveFilters): ledger.InclusiveFilters { - return { - templateIds: inclusiveFilters.getTemplateIdsList().map((id) => mapping.Identifier.toObject(id)) - } - }, - toMessage(inclusiveFilters: ledger.InclusiveFilters): grpc.InclusiveFilters { - const result = new grpc.InclusiveFilters(); - result.setTemplateIdsList(inclusiveFilters.templateIds.map((id) => mapping.Identifier.toMessage(id))); - return result; - } -}; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/index.ts b/language-support/js/daml-ledger/src/mapping/index.ts deleted file mode 100644 index 8d1c3e0fa54..00000000000 --- a/language-support/js/daml-ledger/src/mapping/index.ts +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -export { Any } from './any'; -export { ArchivedEvent } from './archived_event'; -export { Checkpoint } from './checkpoint'; -export { Command } from './command'; -export { Commands } from './commands'; -export { CompletionEndResponse } from './completion_end_response'; -export { CompletionStreamRequest } from './completion_stream_request'; -export { CompletionStreamResponse } from './completion_stream_response'; -export { Completion } from './completion'; -export { CreateCommand } from './create_command'; -export { CreatedEvent } from './created_event'; -export { Duration } from './duration'; -export { Event } from './event'; -export { ExerciseCommand } from './exercise_command'; -export { ExercisedEvent } from './exercised_event'; -export { Filters } from './filters'; -export { GetActiveContractsRequest } from './get_active_contracts_request'; -export { GetActiveContractsResponse } from './get_active_contracts_response'; -export { GetLedgerConfigurationResponse } from './get_ledger_configuration_response'; -export { GetLedgerEndResponse } from './get_ledger_end_response'; -export { GetLedgerIdentityResponse } from './get_ledger_identity_response'; -export { GetPackageResponse } from './get_package_response'; -export { GetPackageStatusResponse } from './get_package_status_response'; -export { GetTimeResponse } from './get_time_response'; -export { GetTransactionByEventIdRequest } from './get_transaction_by_event_id_request'; -export { GetTransactionByIdRequest } from './get_transaction_by_id_request'; -export { GetTransactionResponse } from './get_transaction_response'; -export { GetTransactionTreesResponse } from './get_transaction_trees_response'; -export { GetTransactionsRequest } from './get_transactions_request'; -export { GetTransactionsResponse } from './get_transactions_response'; -export { Identifier } from './identifier'; -export { InclusiveFilters } from './inclusive_filters'; -export { Optional } from './optional'; -export { LedgerConfiguration } from './ledger_configuration'; -export { LedgerOffset } from './ledger_offset'; -export { ListPackagesResponse } from './list_packages_response'; -export { Mapping } from './mapping'; -export { PackageStatus } from './package_status'; -export { Record } from './record'; -export { SetTimeRequest } from './set_time_request'; -export { Status } from './status'; -export { SubmitAndWaitRequest } from './submit_and_wait_request'; -export { SubmitRequest } from './submit_request'; -export { Timestamp } from './timestamp'; -export { TreeEvent } from './tree_event'; -export { Transaction } from './transaction'; -export { TransactionFilter } from './transaction_filter'; -export { TransactionTree } from './transaction_tree'; -export { Value } from './value'; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/ledger_configuration.ts b/language-support/js/daml-ledger/src/mapping/ledger_configuration.ts deleted file mode 100644 index abba8684e34..00000000000 --- a/language-support/js/daml-ledger/src/mapping/ledger_configuration.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const LedgerConfiguration: mapping.Mapping = { - toObject(message: grpc.LedgerConfiguration): ledger.LedgerConfiguration { - return { - minTtl: mapping.Duration.toObject(message.getMinTtl()!), - maxTtl: mapping.Duration.toObject(message.getMaxTtl()!) - }; - }, - toMessage(object: ledger.LedgerConfiguration): grpc.LedgerConfiguration { - const message = new grpc.LedgerConfiguration(); - message.setMinTtl(mapping.Duration.toMessage(object.minTtl)); - message.setMaxTtl(mapping.Duration.toMessage(object.maxTtl)); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/ledger_offset.ts b/language-support/js/daml-ledger/src/mapping/ledger_offset.ts deleted file mode 100644 index 6acb73a42ec..00000000000 --- a/language-support/js/daml-ledger/src/mapping/ledger_offset.ts +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -import { inspect } from 'util'; - -export const LedgerOffset: mapping.Mapping = { - toObject(ledgerOffset: grpc.LedgerOffset): ledger.LedgerOffset { - if (ledgerOffset.hasAbsolute()) { - return { absolute: ledgerOffset.getAbsolute() } - } else if (ledgerOffset.hasBoundary()) { - const boundary = ledgerOffset.getBoundary(); - switch (boundary) { - case grpc.LedgerOffset.LedgerBoundary.LEDGER_BEGIN: { - return { boundary: ledger.LedgerOffset.Boundary.BEGIN } - } - case grpc.LedgerOffset.LedgerBoundary.LEDGER_END: { - return { boundary: ledger.LedgerOffset.Boundary.END } - } - default: { - throw new Error(`Expected LedgerOffset Boundary, found ${inspect(boundary)}`); - } - } - } else { - throw new Error(`Expected either LedgerOffset Absolute or LedgerOffset Boundary, found ${inspect(ledgerOffset)}`); - } - }, - toMessage(ledgerOffset: ledger.LedgerOffset): grpc.LedgerOffset { - const result = new grpc.LedgerOffset(); - if (ledgerOffset.boundary !== undefined) { - switch (ledgerOffset.boundary) { - case ledger.LedgerOffset.Boundary.BEGIN: { - result.setBoundary(grpc.LedgerOffset.LedgerBoundary.LEDGER_BEGIN); - break; - } - case ledger.LedgerOffset.Boundary.END: { - result.setBoundary(grpc.LedgerOffset.LedgerBoundary.LEDGER_END); - break; - } - default: { - throw new Error(`Expected boundary, found ${inspect(ledgerOffset.boundary!)}`); - } - } - } else if (ledgerOffset.absolute) { - result.setAbsolute(ledgerOffset.absolute); - } else { - throw new Error(`Expected either LedgerOffset Absolute or LedgerOffset Boundary, found ${inspect(ledgerOffset)}`); - } - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/list_packages_response.ts b/language-support/js/daml-ledger/src/mapping/list_packages_response.ts deleted file mode 100644 index deb06801afd..00000000000 --- a/language-support/js/daml-ledger/src/mapping/list_packages_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const ListPackagesResponse: mapping.Mapping = { - toObject(response: grpc.ListPackagesResponse): ledger.ListPackagesResponse { - return { - packageIds: response.getPackageIdsList() - } - }, - toMessage(response: ledger.ListPackagesResponse): grpc.ListPackagesResponse { - const result = new grpc.ListPackagesResponse(); - result.setPackageIdsList(response.packageIds); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/mapping.ts b/language-support/js/daml-ledger/src/mapping/mapping.ts deleted file mode 100644 index 1fb0342b61e..00000000000 --- a/language-support/js/daml-ledger/src/mapping/mapping.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - - /** - * A Mapping between a Protocol Buffers message M and a plain object specified by an interface O - */ -export interface Mapping { - - /** - * Converts a plain JS object to a Protocol Buffers message following this mapping - * @param object A plain JS object - */ - toMessage(object: O): M - - /** - * Converts a Protocol Buffers message to a plain JS object following this mapping - */ - toObject(message: M): O - -} diff --git a/language-support/js/daml-ledger/src/mapping/optional.ts b/language-support/js/daml-ledger/src/mapping/optional.ts deleted file mode 100644 index 540ef9206ca..00000000000 --- a/language-support/js/daml-ledger/src/mapping/optional.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const Optional: mapping.Mapping = { - toObject(message: grpc.Optional): ledger.Optional { - const object: ledger.Optional = {}; - if (message.hasValue()) { - object.value = mapping.Value.toObject(message.getValue()!); - } - return object; - }, - toMessage(object: ledger.Optional): grpc.Optional { - const message = new grpc.Optional(); - if (object.value !== undefined) { - message.setValue(mapping.Value.toMessage(object.value)); - } - return message; - } -}; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/package_status.ts b/language-support/js/daml-ledger/src/mapping/package_status.ts deleted file mode 100644 index 71c014d02b6..00000000000 --- a/language-support/js/daml-ledger/src/mapping/package_status.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const PackageStatus: mapping.Mapping = { - toObject(status: grpc.PackageStatus): ledger.PackageStatus { - if (status === grpc.PackageStatus.REGISTERED) { - return ledger.PackageStatus.REGISTERED; - } else if (status === grpc.PackageStatus.UNKNOWN) { - return ledger.PackageStatus.UNKNOWN; - } else { - throw new Error(`Unknown PackageStatus ${status}`); - } - }, - toMessage(status: ledger.PackageStatus): grpc.PackageStatus { - if (status === ledger.PackageStatus.REGISTERED) { - return grpc.PackageStatus.REGISTERED; - } else if (status === ledger.PackageStatus.UNKNOWN) { - return grpc.PackageStatus.UNKNOWN; - } else { - throw new Error(`Unknown PackageStatus ${status}`); - - } - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/record.ts b/language-support/js/daml-ledger/src/mapping/record.ts deleted file mode 100644 index 25f9d8a1535..00000000000 --- a/language-support/js/daml-ledger/src/mapping/record.ts +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const Record: mapping.Mapping = { - toObject(record: grpc.Record): ledger.Record { - let fieldIndex = 0; // used for records returned in non-verbose mode - const fields: {[k: string]: ledger.Value} = {}; - record.getFieldsList().forEach((field: grpc.RecordField) => { - fields[field.getLabel() || fieldIndex++] = mapping.Value.toObject(field.getValue()!); - }); - const result: ledger.Record = { fields: fields } - if (record.hasRecordId()) { - result.recordId = mapping.Identifier.toObject(record.getRecordId()!); - } - return result; - }, - toMessage(record: ledger.Record): grpc.Record { - const result = new grpc.Record(); - if (record.recordId) { - result.setRecordId(mapping.Identifier.toMessage(record.recordId)); - } - const list: grpc.RecordField[] = [] - Object.keys(record.fields).forEach((label: string) => { - const value = mapping.Value.toMessage(record.fields[label]); - const field = new grpc.RecordField(); - field.setLabel(label); - field.setValue(value); - list.push(field); - }); - result.setFieldsList(list); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/set_time_request.ts b/language-support/js/daml-ledger/src/mapping/set_time_request.ts deleted file mode 100644 index 66b313b0fc5..00000000000 --- a/language-support/js/daml-ledger/src/mapping/set_time_request.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const SetTimeRequest: mapping.Mapping = { - toObject(message: grpc.testing.SetTimeRequest): ledger.SetTimeRequest { - return { - currentTime: mapping.Timestamp.toObject(message.getCurrentTime()!), - newTime: mapping.Timestamp.toObject(message.getNewTime()!) - }; - }, - toMessage(object: ledger.SetTimeRequest): grpc.testing.SetTimeRequest { - const message = new grpc.testing.SetTimeRequest(); - message.setCurrentTime(mapping.Timestamp.toMessage(object.currentTime)); - message.setNewTime(mapping.Timestamp.toMessage(object.newTime)); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/status.ts b/language-support/js/daml-ledger/src/mapping/status.ts deleted file mode 100644 index 09a9f02fff2..00000000000 --- a/language-support/js/daml-ledger/src/mapping/status.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; -import * as protobuf from 'google-protobuf/google/protobuf/any_pb'; - -export const Status: mapping.Mapping = { - toObject(message: grpc.Status): ledger.Status { - return { - code: message.getCode(), - message: message.getMessage(), - details: message.getDetailsList().map((a: protobuf.Any) => mapping.Any.toObject(a)) - }; - }, - toMessage(object: ledger.Status): grpc.Status { - const message = new grpc.Status(); - message.setCode(object.code); - message.setMessage(object.message); - message.setDetailsList(object.details.map((a: ledger.Any) => mapping.Any.toMessage(a))); - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/submit_and_wait_request.ts b/language-support/js/daml-ledger/src/mapping/submit_and_wait_request.ts deleted file mode 100644 index 13c6952543b..00000000000 --- a/language-support/js/daml-ledger/src/mapping/submit_and_wait_request.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const SubmitAndWaitRequest: mapping.Mapping = { - toObject(request: grpc.SubmitAndWaitRequest): ledger.SubmitAndWaitRequest { - return { - commands: mapping.Commands.toObject(request.getCommands()!) - }; - }, - toMessage(request: ledger.SubmitAndWaitRequest): grpc.SubmitAndWaitRequest { - const result = new grpc.SubmitAndWaitRequest(); - result.setCommands(mapping.Commands.toMessage(request.commands)); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/submit_request.ts b/language-support/js/daml-ledger/src/mapping/submit_request.ts deleted file mode 100644 index e14b1cfdb64..00000000000 --- a/language-support/js/daml-ledger/src/mapping/submit_request.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const SubmitRequest: mapping.Mapping = { - toObject(request: grpc.SubmitRequest): ledger.SubmitRequest { - return { - commands: mapping.Commands.toObject(request.getCommands()!) - }; - }, - toMessage(request: ledger.SubmitRequest): grpc.SubmitRequest { - const result = new grpc.SubmitRequest(); - result.setCommands(mapping.Commands.toMessage(request.commands)); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/timestamp.ts b/language-support/js/daml-ledger/src/mapping/timestamp.ts deleted file mode 100644 index 01233c6050a..00000000000 --- a/language-support/js/daml-ledger/src/mapping/timestamp.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as protobuf from 'google-protobuf/google/protobuf/timestamp_pb'; - -export const Timestamp: mapping.Mapping = { - toObject(timestamp: protobuf.Timestamp): ledger.Timestamp { - return { - seconds: timestamp.getSeconds(), - nanoseconds: timestamp.getNanos() - } - }, - toMessage(timestamp: ledger.Timestamp): protobuf.Timestamp { - const result = new protobuf.Timestamp(); - result.setSeconds(timestamp.seconds); - result.setNanos(timestamp.nanoseconds); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/transaction.ts b/language-support/js/daml-ledger/src/mapping/transaction.ts deleted file mode 100644 index 6c5dbc71722..00000000000 --- a/language-support/js/daml-ledger/src/mapping/transaction.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const Transaction: mapping.Mapping = { - toObject(message: grpc.Transaction): ledger.Transaction { - const transaction: ledger.Transaction = { - effectiveAt: mapping.Timestamp.toObject(message.getEffectiveAt()!), - events: message.getEventsList().map((e: grpc.Event) => mapping.Event.toObject(e)), - offset: message.getOffset(), - transactionId: message.getTransactionId(), - }; - const commandId = message.getCommandId(); - if (commandId !== undefined && commandId !== '') { - transaction.commandId = commandId; - } - const workflowId = message.getWorkflowId(); - if (workflowId !== undefined && workflowId !== '') { - transaction.workflowId = workflowId; - } - return transaction; - }, - toMessage(object: ledger.Transaction): grpc.Transaction { - const message = new grpc.Transaction(); - message.setEffectiveAt(mapping.Timestamp.toMessage(object.effectiveAt)); - message.setEventsList(object.events.map((e: ledger.Event) => mapping.Event.toMessage(e))); - message.setOffset(object.offset); - message.setTransactionId(object.transactionId); - if (object.commandId) { - message.setCommandId(object.commandId); - } - if (object.workflowId) { - message.setWorkflowId(object.workflowId); - } - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/transaction_filter.ts b/language-support/js/daml-ledger/src/mapping/transaction_filter.ts deleted file mode 100644 index 318b3e6cab0..00000000000 --- a/language-support/js/daml-ledger/src/mapping/transaction_filter.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const TransactionFilter: mapping.Mapping = { - toObject(transactionFilter: grpc.TransactionFilter): ledger.TransactionFilter { - let filtersByParty: {[k: string]: ledger.Filters} = {}; - transactionFilter.getFiltersByPartyMap().forEach((filters: grpc.Filters, party: string) => { - filtersByParty[party] = mapping.Filters.toObject(filters); - }); - return { filtersByParty: filtersByParty }; - }, - toMessage(transactionFilter: ledger.TransactionFilter): grpc.TransactionFilter { - const result = new grpc.TransactionFilter(); - const map = result.getFiltersByPartyMap(); - Object.keys(transactionFilter.filtersByParty).forEach((party: string) => { - map.set(party, mapping.Filters.toMessage(transactionFilter.filtersByParty[party])); - }); - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/transaction_tree.ts b/language-support/js/daml-ledger/src/mapping/transaction_tree.ts deleted file mode 100644 index ea937a95b22..00000000000 --- a/language-support/js/daml-ledger/src/mapping/transaction_tree.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const TransactionTree: mapping.Mapping = { - toObject(message: grpc.TransactionTree): ledger.TransactionTree { - const eventsById: Record = {}; - message.getEventsByIdMap().forEach((event, id) => { - eventsById[id] = mapping.TreeEvent.toObject(event); - }); - const transactionTree: ledger.TransactionTree = { - effectiveAt: mapping.Timestamp.toObject(message.getEffectiveAt()!), - eventsById: eventsById, - rootEventIds: [...message.getRootEventIdsList()], - offset: message.getOffset(), - transactionId: message.getTransactionId(), - }; - const commandId = message.getCommandId(); - if (commandId !== undefined && commandId !== '') { - transactionTree.commandId = commandId; - } - const workflowId = message.getWorkflowId(); - if (workflowId !== undefined && workflowId !== '') { - transactionTree.workflowId = workflowId; - } - return transactionTree; - }, - toMessage(object: ledger.TransactionTree): grpc.TransactionTree { - const message = new grpc.TransactionTree(); - message.setEffectiveAt(mapping.Timestamp.toMessage(object.effectiveAt)); - for (const id in object.eventsById) { - const event = mapping.TreeEvent.toMessage(object.eventsById[id]); - message.getEventsByIdMap().set(id, event); - } - message.setRootEventIdsList([... object.rootEventIds]); - message.setOffset(object.offset); - message.setTransactionId(object.transactionId); - if (object.commandId) { - message.setCommandId(object.commandId); - } - if (object.workflowId) { - message.setWorkflowId(object.workflowId); - } - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/tree_event.ts b/language-support/js/daml-ledger/src/mapping/tree_event.ts deleted file mode 100644 index bd4816e9f11..00000000000 --- a/language-support/js/daml-ledger/src/mapping/tree_event.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; - -export const TreeEvent: mapping.Mapping = { - toObject(message: grpc.TreeEvent): ledger.TreeEvent { - const object: ledger.TreeEvent = {}; - if (message.hasCreated()) { - object.created = mapping.CreatedEvent.toObject(message.getCreated()!); - } - if (message.hasExercised()) { - object.exercised = mapping.ExercisedEvent.toObject(message.getExercised()!); - } - return object; - }, - toMessage(object: ledger.TreeEvent): grpc.TreeEvent { - const message = new grpc.TreeEvent(); - if (object.created) { - message.setCreated(mapping.CreatedEvent.toMessage(object.created)); - } - if (object.exercised) { - message.setExercised(mapping.ExercisedEvent.toMessage(object.exercised)); - } - return message; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/mapping/value.ts b/language-support/js/daml-ledger/src/mapping/value.ts deleted file mode 100644 index 8cd5964b3d3..00000000000 --- a/language-support/js/daml-ledger/src/mapping/value.ts +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as mapping from '.'; -import * as ledger from '..'; -import * as grpc from 'daml-grpc'; -import * as protobuf from 'google-protobuf/google/protobuf/empty_pb'; - -import { inspect } from 'util'; - -export const Value: mapping.Mapping = { - toObject(value: grpc.Value): ledger.Value { - if (value.hasBool()) { - return { bool: value.getBool() } - } else if (value.hasContractId()) { - return { contractId: value.getContractId() } - } else if (value.hasDate()) { - return { date: '' + value.getDate() } - } else if (value.hasDecimal()) { - return { decimal: value.getDecimal() } - } else if (value.hasInt64()) { - return { int64: value.getInt64() } - } else if (value.hasList()) { - const values: ledger.Value[] = []; - if (value.hasList()) { - value.getList()!.getElementsList().forEach(v => { - values.push(Value.toObject(v)); - }); - } - return { list: values } - } else if (value.hasParty()) { - return { party: value.getParty() } - } else if (value.hasRecord()) { - return { record: mapping.Record.toObject(value.getRecord()!) } - } else if (value.hasText()) { - return { text: value.getText() } - } else if (value.hasTimestamp()) { - return { timestamp: value.getTimestamp() } - } else if (value.hasUnit()) { - return { unit: {} } - } else if (value.hasVariant()) { - const variant = value.getVariant()!; - const result: ledger.Variant = { - constructor: variant.getConstructor(), - value: Value.toObject(variant.getValue()!), - } - if (variant.hasVariantId()) { - result.variantId = mapping.Identifier.toObject(variant.getVariantId()!); - } - return { variant: result } - } else if (value.hasOptional()) { - return { optional: mapping.Optional.toObject(value.getOptional()!) } - } else { - throw new Error(`Message Value of unknown type '${inspect(value)}'`); - } - }, - toMessage(value: ledger.Value): grpc.Value { - const result = new grpc.Value(); - if (value.bool !== undefined) { - result.setBool(value.bool); - } else if (value.contractId !== undefined) { - result.setContractId(value.contractId); - } else if (value.date !== undefined) { - result.setDate(parseInt(value.date)); - } else if (value.decimal !== undefined) { - result.setDecimal(value.decimal); - } else if (value.int64 !== undefined) { - result.setInt64(value.int64); - } else if (value.list !== undefined) { - const values: grpc.Value[] = [] - value.list.forEach(v => values.push(Value.toMessage(v))); - const list = new grpc.List(); - list.setElementsList(values); - result.setList(list); - } else if (value.party !== undefined) { - result.setParty(value.party); - } else if (value.record !== undefined) { - result.setRecord(mapping.Record.toMessage(value.record)); - } else if (value.text !== undefined) { - result.setText(value.text); - } else if (value.timestamp !== undefined) { - result.setTimestamp(value.timestamp); - } else if (value.unit !== undefined) { - result.setUnit(new protobuf.Empty()); - } else if (value.variant !== undefined) { - const variant = new grpc.Variant(); - variant.setConstructor(value.variant.constructor); - variant.setValue(Value.toMessage(value.variant.value)); - if (value.variant.variantId) { - variant.setVariantId(mapping.Identifier.toMessage(value.variant.variantId)); - } - result.setVariant(variant); - } else if (value.optional) { - result.setOptional(mapping.Optional.toMessage(value.optional)); - } else { - throw new Error(`Object Value of unknown type '${inspect(value)}'`); - } - return result; - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/any.ts b/language-support/js/daml-ledger/src/model/any.ts deleted file mode 100644 index 54c85f75e85..00000000000 --- a/language-support/js/daml-ledger/src/model/any.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @interface Any - * @memberof ledger - */ -export interface Any { - /** - * @member {string} typeUrl - * @memberof ledger.Any - * @instance - */ - typeUrl: string - /** - * @member {string} value - * @memberof ledger.Any - * @instance - */ - value: string -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/archived_event.ts b/language-support/js/daml-ledger/src/model/archived_event.ts deleted file mode 100644 index 632574309a2..00000000000 --- a/language-support/js/daml-ledger/src/model/archived_event.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface ArchivedEvent - * @memberof ledger - */ -export interface ArchivedEvent { - /** - * @member {string} contractId - * @memberof ledger.ArchivedEvent - * @instance - */ - contractId: string - /** - * @member {string} eventId - * @memberof ledger.ArchivedEvent - * @instance - */ - eventId: string - /** - * @member {ledger.Identifier} templateId - * @memberof ledger.ArchivedEvent - * @instance - */ - templateId: ledger.Identifier - /** - * @member {Array} witnessParties - * @memberof ledger.ArchivedEvent - * @instance - */ - witnessParties: string[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/checkpoint.ts b/language-support/js/daml-ledger/src/model/checkpoint.ts deleted file mode 100644 index aaf1dcebeb2..00000000000 --- a/language-support/js/daml-ledger/src/model/checkpoint.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface Checkpoint - * @memberof ledger - */ -export interface Checkpoint { - /** - * @member {ledger.Timestamp} recordTime - * @memberof ledger.Checkpoint - * @instance - */ - recordTime: ledger.Timestamp - /** - * @member {ledger.LedgerOffset} offset - * @memberof ledger.Checkpoint - * @instance - */ - offset: ledger.LedgerOffset -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/command.ts b/language-support/js/daml-ledger/src/model/command.ts deleted file mode 100644 index 52bbeb3f344..00000000000 --- a/language-support/js/daml-ledger/src/model/command.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface Command - * @memberof ledger - */ -export interface Command { - /** - * @member {ledger.CreateCommand} create - * @memberof ledger.Command - * @instance - */ - create?: ledger.CreateCommand - /** - * @member {ledger.ExerciseCommand} exercise - * @memberof ledger.Command - * @instance - */ - exercise?: ledger.ExerciseCommand -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/commands.ts b/language-support/js/daml-ledger/src/model/commands.ts deleted file mode 100644 index 3bc20120965..00000000000 --- a/language-support/js/daml-ledger/src/model/commands.ts +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface Commands - * @memberof ledger - */ -export interface Commands { - /** - * @member {string} applicationId - * @memberof ledger.Commands - * @instance - */ - applicationId: string - /** - * @member {string} commandId - * @memberof ledger.Commands - * @instance - */ - commandId: string - /** - * @member {string} party - * @memberof ledger.Commands - * @instance - */ - party: string - /** - * @member {string} workflowId - * @memberof ledger.Commands - * @instance - */ - workflowId?: string - /** - * @member {ledger.Timestamp} ledgerEffectiveTime - * @memberof ledger.Commands - * @instance - */ - ledgerEffectiveTime: ledger.Timestamp - /** - * @member {ledger.Timestamp} maximumRecordTime - * @memberof ledger.Commands - * @instance - */ - maximumRecordTime: ledger.Timestamp - /** - * @member {Array} list - * @memberof ledger.Commands - * @instance - */ - list: ledger.Command[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/completion.ts b/language-support/js/daml-ledger/src/model/completion.ts deleted file mode 100644 index 63d9296b8f7..00000000000 --- a/language-support/js/daml-ledger/src/model/completion.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface Completion - * @memberof ledger - */ -export interface Completion { - /** - * @member {string} commandId - * @memberof ledger.Completion - * @instance - */ - commandId: string - /** - * @member {Status} status - * @memberof ledger.Completion - * @instance - */ - status?: ledger.Status -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/completion_end_response.ts b/language-support/js/daml-ledger/src/model/completion_end_response.ts deleted file mode 100644 index a0df52a208a..00000000000 --- a/language-support/js/daml-ledger/src/model/completion_end_response.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface CompletionEndResponse - * @memberof ledger - */ -export interface CompletionEndResponse { - /** - * @member {ledger.LedgerOffset} offset - * @memberof ledger.CompletionEndResponse - * @instance - */ - offset: ledger.LedgerOffset -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/completion_stream_request.ts b/language-support/js/daml-ledger/src/model/completion_stream_request.ts deleted file mode 100644 index fea7c6d865c..00000000000 --- a/language-support/js/daml-ledger/src/model/completion_stream_request.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface CompletionStreamRequest - * @memberof ledger - */ -export interface CompletionStreamRequest { - /** - * @member {string} applicationId - * @memberof ledger.CompletionStreamRequest - * @instance - */ - applicationId: string - /** - * @member {ledger.LedgerOffset} offset - * @memberof ledger.CompletionStreamRequest - * @instance - */ - offset: ledger.LedgerOffset - /** - * @member {Array} parties - * @memberof ledger.CompletionStreamRequest - * @instance - */ - parties: string[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/completion_stream_response.ts b/language-support/js/daml-ledger/src/model/completion_stream_response.ts deleted file mode 100644 index 085d55703a6..00000000000 --- a/language-support/js/daml-ledger/src/model/completion_stream_response.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface CompletionStreamResponse - * @memberof ledger - */ -export interface CompletionStreamResponse { - /** - * @member {ledger.Checkpoint} checkpoint - * @memberof ledger.CompletionStreamResponse - * @instance - */ - checkpoint?: ledger.Checkpoint - /** - * @member {Array} completions - * @memberof ledger.CompletionStreamResponse - * @instance - */ - completions?: ledger.Completion[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/create_command.ts b/language-support/js/daml-ledger/src/model/create_command.ts deleted file mode 100644 index 41ba84fe16e..00000000000 --- a/language-support/js/daml-ledger/src/model/create_command.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface CreateCommand - * @memberof ledger - */ -export interface CreateCommand { - /** - * @member {ledger.Identifier} templateId - * @memberof ledger.CreateCommand - * @instance - */ - templateId: ledger.Identifier - /** - * @member {ledger.Record} arguments - * @memberof ledger.CreateCommand - * @instance - */ - arguments: ledger.Record -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/created_event.ts b/language-support/js/daml-ledger/src/model/created_event.ts deleted file mode 100644 index efcd359510a..00000000000 --- a/language-support/js/daml-ledger/src/model/created_event.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface CreatedEvent - * @memberof ledger - */ -export interface CreatedEvent { - /** - * @member {string} eventId - * @memberof ledger.CreatedEvent - * @instance - */ - eventId: string - /** - * @member {string} contractId - * @memberof ledger.CreatedEvent - * @instance - */ - contractId: string - /** - * @member {ledger.Identifier} templateId - * @memberof ledger.CreatedEvent - * @instance - */ - templateId: ledger.Identifier - /** - * @member {ledger.Record} arguments - * @memberof ledger.CreatedEvent - * @instance - */ - arguments: ledger.Record - /** - * @member {Array} witnessParties - * @memberof ledger.CreatedEvent - * @instance - */ - witnessParties: string[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/duration.ts b/language-support/js/daml-ledger/src/model/duration.ts deleted file mode 100644 index b96fcd78d19..00000000000 --- a/language-support/js/daml-ledger/src/model/duration.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @interface Duration - * @memberof ledger - */ -export interface Duration { - /** - * @member {number} seconds - * @memberof ledger.Duration - * @instance - */ - seconds: number - /** - * @member {number} nanoseconds - * @memberof ledger.Duration - * @instance - */ - nanoseconds: number -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/empty.ts b/language-support/js/daml-ledger/src/model/empty.ts deleted file mode 100644 index 6d1607fdfe2..00000000000 --- a/language-support/js/daml-ledger/src/model/empty.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @interface Empty - * @memberof ledger - */ -export interface Empty { - // The empty interface -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/event.ts b/language-support/js/daml-ledger/src/model/event.ts deleted file mode 100644 index 1d89e102349..00000000000 --- a/language-support/js/daml-ledger/src/model/event.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface Event - * @memberof ledger - */ -export interface Event { - /** - * @member {ledger.ArchivedEvent} archived - * @memberof ledger.Event - * @instance - */ - archived?: ledger.ArchivedEvent - /** - * @member {ledger.CreatedEvent} created - * @memberof ledger.Event - * @instance - */ - created?: ledger.CreatedEvent - /** - * @member {ledger.ExercisedEvent} exercised - * @memberof ledger.Event - * @instance - */ - exercised?: ledger.ExercisedEvent -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/exercise_command.ts b/language-support/js/daml-ledger/src/model/exercise_command.ts deleted file mode 100644 index dd22f8af230..00000000000 --- a/language-support/js/daml-ledger/src/model/exercise_command.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface ExerciseCommand - * @memberof ledger - */ -export interface ExerciseCommand { - /** - * @member {ledger.Identifier} templateId - * @memberof ledger.ExerciseCommand - * @instance - */ - templateId: ledger.Identifier - /** - * @member {string} choice - * @memberof ledger.ExerciseCommand - * @instance - */ - choice: string - /** - * @member {string} contractId - * @memberof ledger.ExerciseCommand - * @instance - */ - contractId: string - /** - * @member {ledger.Value} argument - * @memberof ledger.ExerciseCommand - * @instance - */ - argument: ledger.Value -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/exercised_event.ts b/language-support/js/daml-ledger/src/model/exercised_event.ts deleted file mode 100644 index 031b804ddca..00000000000 --- a/language-support/js/daml-ledger/src/model/exercised_event.ts +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface ExercisedEvent - * @memberof ledger - */ -export interface ExercisedEvent { - /** - * @member {Array} actingParties - * @memberof ledger.ExercisedEvent - * @instance - */ - actingParties: string[] - /** - * @member {Array} childEventIds - * @memberof ledger.ExercisedEvent - * @instance - */ - childEventIds?: string[] - /** - * @member {string} choice - * @memberof ledger.ExercisedEvent - * @instance - */ - choice: string - /** - * @member {ledger.Value} argument - * @memberof ledger.ExercisedEvent - * @instance - */ - argument: ledger.Value - /** - * @member {boolean} consuming - * @memberof ledger.ExercisedEvent - * @instance - */ - consuming: boolean - /** - * @member {string} contractCreatingEventId - * @memberof ledger.ExercisedEvent - * @instance - */ - contractCreatingEventId: string - /** - * @member {string} contractId - * @memberof ledger.ExercisedEvent - * @instance - */ - contractId: string - /** - * @member {string} eventId - * @memberof ledger.ExercisedEvent - * @instance - */ - eventId: string - /** - * @member {ledger.Identifier} templateId - * @memberof ledger.ExercisedEvent - * @instance - */ - templateId: ledger.Identifier - /** - * @member {Array} witnessParties - * @memberof ledger.ExercisedEvent - * @instance - */ - witnessParties: string[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/filters.ts b/language-support/js/daml-ledger/src/model/filters.ts deleted file mode 100644 index 5b4debd2b93..00000000000 --- a/language-support/js/daml-ledger/src/model/filters.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface Filters - * @memberof ledger - */ -export interface Filters { - /** - * @member {ledger.InclusiveFilters} inclusive - * @memberof ledger.Filters - * @instance - */ - inclusive?: ledger.InclusiveFilters -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_active_contracts_request.ts b/language-support/js/daml-ledger/src/model/get_active_contracts_request.ts deleted file mode 100644 index 9409544b7b2..00000000000 --- a/language-support/js/daml-ledger/src/model/get_active_contracts_request.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface GetActiveContractsRequest - * @memberof ledger - */ -export interface GetActiveContractsRequest { - /** - * @member {ledger.TransactionFilter} filter - * @memberof ledger.GetActiveContractsRequest - * @instance - */ - filter: ledger.TransactionFilter - /** - * @member {boolean} verbose - * @memberof ledger.GetActiveContractsRequest - * @instance - */ - verbose?: boolean -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_active_contracts_response.ts b/language-support/js/daml-ledger/src/model/get_active_contracts_response.ts deleted file mode 100644 index 3652e84b48d..00000000000 --- a/language-support/js/daml-ledger/src/model/get_active_contracts_response.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { LedgerOffset } from "./ledger_offset"; -import { CreatedEvent } from "./created_event"; - -/** - * @interface GetActiveContractsResponse - * @memberof ledger - */ -export interface GetActiveContractsResponse { - /** - * @member {ledger.LedgerOffset} offset - * @memberof ledger.GetActiveContractsResponse - * @instance - */ - offset: LedgerOffset - /** - * @member {string} workflowId - * @memberof ledger.GetActiveContractsResponse - * @instance - */ - workflowId?: string - /** - * @member {Array} activeContracts - * @memberof ledger.GetActiveContractsResponse - * @instance - */ - activeContracts?: CreatedEvent[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_ledger_configuration_response.ts b/language-support/js/daml-ledger/src/model/get_ledger_configuration_response.ts deleted file mode 100644 index 70657a2f50e..00000000000 --- a/language-support/js/daml-ledger/src/model/get_ledger_configuration_response.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface GetLedgerConfigurationResponse - * @memberof ledger - */ -export interface GetLedgerConfigurationResponse { - /** - * @member {ledger.LedgerConfiguration} config - * @memberof GetLedgerConfigurationResponse - * @instance - */ - config: ledger.LedgerConfiguration -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_ledger_end_response.ts b/language-support/js/daml-ledger/src/model/get_ledger_end_response.ts deleted file mode 100644 index b0aee052485..00000000000 --- a/language-support/js/daml-ledger/src/model/get_ledger_end_response.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface GetLedgerEndResponse - * @memberof ledger - */ -export interface GetLedgerEndResponse { - /** - * @member {ledger.LedgerOffset} offset - * @memberof ledger.GetLedgerEndResponse - * @instance - */ - offset: ledger.LedgerOffset -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_ledger_identity_response.ts b/language-support/js/daml-ledger/src/model/get_ledger_identity_response.ts deleted file mode 100644 index 3dfd7f2a64c..00000000000 --- a/language-support/js/daml-ledger/src/model/get_ledger_identity_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @interface GetLedgerIdentityResponse - * @memberof ledger - */ -export interface GetLedgerIdentityResponse { - /** - * @member {string} ledgerId - * @memberof ledger.GetLedgerIdentityResponse - * @instance - */ - ledgerId: string -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_package_response.ts b/language-support/js/daml-ledger/src/model/get_package_response.ts deleted file mode 100644 index d69f2c67159..00000000000 --- a/language-support/js/daml-ledger/src/model/get_package_response.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface GetPackageResponse - * @memberof ledger - */ -export interface GetPackageResponse { - /** - * @member {ledger.HashFunction} hashFunction - * @memberof ledger.GetPackageResponse - * @instance - */ - hashFunction: ledger.HashFunction - /** - * @member {string} hash - * @memberof ledger.GetPackageResponse - * @instance - */ - hash: string - /** - * @member {string} payload - * @memberof ledger.GetPackageResponse - * @instance - */ - archivePayload: string -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_package_status_response.ts b/language-support/js/daml-ledger/src/model/get_package_status_response.ts deleted file mode 100644 index ea32eaed46e..00000000000 --- a/language-support/js/daml-ledger/src/model/get_package_status_response.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface GetPackageStatusResponse - * @memberof ledger - */ -export interface GetPackageStatusResponse { - /** - * @member {ledger.PackageStatus} status - * @memberof ledger.GetPackageStatusResponse - * @instance - */ - status: ledger.PackageStatus -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_time_response.ts b/language-support/js/daml-ledger/src/model/get_time_response.ts deleted file mode 100644 index 7e7c786d344..00000000000 --- a/language-support/js/daml-ledger/src/model/get_time_response.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface GetTimeResponse - * @memberof ledger - */ -export interface GetTimeResponse { - /** - * @member {ledger.Timestamp} currentTime - * @memberof ledger.GetTimeResponse - * @instance - */ - currentTime: ledger.Timestamp -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_transaction_by_event_id_request.ts b/language-support/js/daml-ledger/src/model/get_transaction_by_event_id_request.ts deleted file mode 100644 index d0fbb278c22..00000000000 --- a/language-support/js/daml-ledger/src/model/get_transaction_by_event_id_request.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @interface GetTransactionByEventIdRequest - * @memberof ledger - */ -export interface GetTransactionByEventIdRequest { - /** - * @member {string} eventId - * @memberof ledger.GetTransactionByEventIdRequest - * @instance - */ - eventId: string - /** - * @member {Array} requestingParties - * @memberof ledger.GetTransactionByEventIdRequest - * @instance - */ - requestingParties: string[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_transaction_by_id_request.ts b/language-support/js/daml-ledger/src/model/get_transaction_by_id_request.ts deleted file mode 100644 index be1f65c7f49..00000000000 --- a/language-support/js/daml-ledger/src/model/get_transaction_by_id_request.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @interface GetTransactionByIdRequest - * @memberof ledger - */ -export interface GetTransactionByIdRequest { - /** - * @member {string} transactionId - * @memberof ledger.GetTransactionByIdRequest - * @instance - */ - transactionId: string - /** - * @member {Array} requestingParties - * @memberof ledger.GetTransactionByIdRequest - * @instance - */ - requestingParties: string[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_transaction_response.ts b/language-support/js/daml-ledger/src/model/get_transaction_response.ts deleted file mode 100644 index a291738845d..00000000000 --- a/language-support/js/daml-ledger/src/model/get_transaction_response.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface GetTransactionResponse - * @memberof ledger - */ -export interface GetTransactionResponse { - /** - * @member {ledger.TransactionTree} transaction - * @memberof ledger.GetTransactionResponse - * @instance - */ - transaction: ledger.TransactionTree -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_transaction_trees_response.ts b/language-support/js/daml-ledger/src/model/get_transaction_trees_response.ts deleted file mode 100644 index 43843f98696..00000000000 --- a/language-support/js/daml-ledger/src/model/get_transaction_trees_response.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface GetTransactionTreesResponse - * @memberof ledger - */ -export interface GetTransactionTreesResponse { - /** - * @member {Array} transactions - * @memberof ledger.GetTransactionTreesResponse - * @instance - */ - transactions: ledger.TransactionTree[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_transactions_request.ts b/language-support/js/daml-ledger/src/model/get_transactions_request.ts deleted file mode 100644 index 18baa8d21e2..00000000000 --- a/language-support/js/daml-ledger/src/model/get_transactions_request.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface GetTransactionsRequest - * @memberof ledger - */ -export interface GetTransactionsRequest { - /** - * @member {ledger.LedgerOffset} begin - * @memberof ledger.GetTransactionsRequest - * @instance - */ - begin: ledger.LedgerOffset - /** - * @member {ledger.LedgerOffset} end - * @memberof ledger.GetTransactionsRequest - * @instance - */ - end?: ledger.LedgerOffset - /** - * @member {ledger.TransactionFilter} filter - * @memberof ledger.GetTransactionsRequest - * @instance - */ - filter: ledger.TransactionFilter - /** - * @member {boolean} verbose - * @memberof ledger.GetTransactionsRequest - * @instance - */ - verbose?: boolean -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/get_transactions_response.ts b/language-support/js/daml-ledger/src/model/get_transactions_response.ts deleted file mode 100644 index 2a4be15ea7b..00000000000 --- a/language-support/js/daml-ledger/src/model/get_transactions_response.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface GetTransactionsResponse - * @memberof ledger - */ -export interface GetTransactionsResponse { - /** - * @member {Array} transactions - * @memberof ledger.GetTransactionsResponse - * @instance - */ - transactions: ledger.Transaction[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/hash_function.ts b/language-support/js/daml-ledger/src/model/hash_function.ts deleted file mode 100644 index ca3bb9b69b7..00000000000 --- a/language-support/js/daml-ledger/src/model/hash_function.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * An enumeration of supported hashing functions - * - * @interface HashFunction - * @memberof ledger - */ -export enum HashFunction { - /** - * @member SHA256 - * @memberof ledger.HashFunction - */ - SHA256 -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/identifier.ts b/language-support/js/daml-ledger/src/model/identifier.ts deleted file mode 100644 index 43273184afb..00000000000 --- a/language-support/js/daml-ledger/src/model/identifier.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @interface Identifier - * @memberof ledger - */ -export interface Identifier { - /** - * @member {string} packageId - * @memberof ledger.Identifier - * @instance - */ - packageId: string - /** - * @member {string} moduleName - * @memberof ledger.Identifier - * @instance - */ - moduleName: string - /** - * @member {string} entityName - * @memberof ledger.Identifier - * @instance - */ - entityName: string -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/inclusive_filters.ts b/language-support/js/daml-ledger/src/model/inclusive_filters.ts deleted file mode 100644 index 9541b0d9033..00000000000 --- a/language-support/js/daml-ledger/src/model/inclusive_filters.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface InclusiveFilters - * @memberof ledger - */ -export interface InclusiveFilters { - /** - * @member {Array} templateIds - * @memberof ledger.InclusiveFilters - * @instance - */ - templateIds: ledger.Identifier[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/index.ts b/language-support/js/daml-ledger/src/model/index.ts deleted file mode 100644 index e4dc5046b50..00000000000 --- a/language-support/js/daml-ledger/src/model/index.ts +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -export { Any } from './any'; -export { ArchivedEvent } from './archived_event'; -export { Checkpoint } from './checkpoint'; -export { Command } from './command'; -export { Commands } from './commands'; -export { Completion } from './completion'; -export { CreateCommand } from './create_command'; -export { CreatedEvent } from './created_event'; -export { Duration } from './duration'; -export { Empty } from './empty'; -export { Event } from './event'; -export { ExerciseCommand } from './exercise_command'; -export { ExercisedEvent } from './exercised_event'; -export { Filters } from './filters'; -export { HashFunction } from './hash_function'; -export { Identifier } from './identifier'; -export { InclusiveFilters } from './inclusive_filters'; -export { LedgerConfiguration } from './ledger_configuration'; -export { LedgerOffset } from './ledger_offset'; -export { Optional } from './optional'; -export { PackageStatus } from './package_status'; -export { Record } from './record'; -export { Status } from './status'; -export { Timestamp } from './timestamp'; -export { Transaction } from './transaction'; -export { TransactionFilter } from './transaction_filter'; -export { TransactionTree } from './transaction_tree'; -export { TreeEvent } from './tree_event'; -export { Value } from './value'; -export { Variant } from './variant'; - -export { GetActiveContractsRequest } from './get_active_contracts_request'; -export { GetActiveContractsResponse } from './get_active_contracts_response' - -export { SubmitAndWaitRequest } from './submit_and_wait_request'; - -export { CompletionEndResponse } from './completion_end_response'; -export { CompletionStreamRequest } from './completion_stream_request'; -export { CompletionStreamResponse } from './completion_stream_response'; - -export { SubmitRequest } from './submit_request'; - -export { GetLedgerConfigurationResponse } from './get_ledger_configuration_response'; - -export { GetLedgerIdentityResponse } from './get_ledger_identity_response'; - -export { GetPackageResponse } from './get_package_response'; -export { GetPackageStatusResponse } from './get_package_status_response'; -export { ListPackagesResponse } from './list_packages_response'; - -export { GetTimeResponse } from './get_time_response'; -export { SetTimeRequest } from './set_time_request'; - -export { GetLedgerEndResponse } from './get_ledger_end_response'; -export { GetTransactionByEventIdRequest } from './get_transaction_by_event_id_request'; -export { GetTransactionByIdRequest } from './get_transaction_by_id_request'; -export { GetTransactionResponse } from './get_transaction_response'; -export { GetTransactionsRequest } from './get_transactions_request'; -export { GetTransactionsResponse } from './get_transactions_response'; -export { GetTransactionTreesResponse } from './get_transaction_trees_response'; diff --git a/language-support/js/daml-ledger/src/model/ledger_configuration.ts b/language-support/js/daml-ledger/src/model/ledger_configuration.ts deleted file mode 100644 index cc1d5e8e555..00000000000 --- a/language-support/js/daml-ledger/src/model/ledger_configuration.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface LedgerConfiguration - * @memberof ledger - */ -export interface LedgerConfiguration { - /** - * @member {ledger.Duration} maxTtl - * @memberof ledger.LedgerConfiguration - * @instance - */ - maxTtl: ledger.Duration - /** - * @member {ledger.Duration} minTtl - * @memberof ledger.LedgerConfiguration - * @instance - */ - minTtl: ledger.Duration -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/ledger_offset.ts b/language-support/js/daml-ledger/src/model/ledger_offset.ts deleted file mode 100644 index 753fe18faa2..00000000000 --- a/language-support/js/daml-ledger/src/model/ledger_offset.ts +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @interface LedgerOffset - * @memberof ledger - */ -export interface LedgerOffset { - /** - * @member {ledger.LedgerOffset.Boundary} boundary - * @memberof ledger.LedgerOffset - * @instance - */ - boundary?: LedgerOffset.Boundary - /** - * @member {ledger.LedgerOffset.Absolute} absolute - * @memberof ledger.LedgerOffset - * @instance - */ - absolute?: LedgerOffset.Absolute -} - -export namespace LedgerOffset { - - /** - * An enumeration of possible boundaries of a ledger. - * - * @interface Boundary - * @memberof ledger.LedgerOffset - */ - export enum Boundary { - /** - * @member BEGIN - * @memberof ledger.LedgerOffset.Boundary - */ - BEGIN, - /** - * @member END - * @memberof ledger.LedgerOffset.Boundary - */ - END - } - - /** - * @typedef {string} Absolute - * @memberof ledger.LedgerOffset - */ - export type Absolute = string - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/list_packages_response.ts b/language-support/js/daml-ledger/src/model/list_packages_response.ts deleted file mode 100644 index 668076510bd..00000000000 --- a/language-support/js/daml-ledger/src/model/list_packages_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @interface ListPackagesResponse - * @memberof ledger - */ -export interface ListPackagesResponse { - /** - * @member {Array} packageIds - * @memberof ledger.ListPackagesResponse - * @instance - */ - packageIds: string[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/optional.ts b/language-support/js/daml-ledger/src/model/optional.ts deleted file mode 100644 index 88fc7d1f5b5..00000000000 --- a/language-support/js/daml-ledger/src/model/optional.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface ledger.Optional - */ -export interface Optional { - /** - * @member {ledger.Value} value - * @memberof ledger.Optional - * @instance - */ - value?: ledger.Value -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/package_status.ts b/language-support/js/daml-ledger/src/model/package_status.ts deleted file mode 100644 index 80ee7bb9546..00000000000 --- a/language-support/js/daml-ledger/src/model/package_status.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * An enumeration of possible statuses of a package - * - * @interface PackageStatus - * @memberof ledger - */ -export enum PackageStatus { - /** - * @member UNKNOWN - * @memberof ledger.PackageStatus - */ - UNKNOWN, - /** - * @member REGISTERED - * @memberof ledger.PackageStatus - */ - REGISTERED -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/record.ts b/language-support/js/daml-ledger/src/model/record.ts deleted file mode 100644 index f8bad75ccbe..00000000000 --- a/language-support/js/daml-ledger/src/model/record.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface Record - * @memberof ledger - */ -export interface Record { - /** - * @member {ledger.Identifier} recordId - * @memberof ledger.Record - * @instance - */ - recordId?: ledger.Identifier - /** - * A plain object with {@link ledger.Value} values. - * - * @member {object} fields - * @memberof ledger.Record - * @instance - */ - fields: { [k: string]: ledger.Value } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/set_time_request.ts b/language-support/js/daml-ledger/src/model/set_time_request.ts deleted file mode 100644 index 8bb473623df..00000000000 --- a/language-support/js/daml-ledger/src/model/set_time_request.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface SetTimeRequest - * @memberof ledger - */ -export interface SetTimeRequest { - /** - * @member {ledger.Timestamp} currentTime - * @memberof ledger.SetTimeRequest - * @instance - */ - currentTime: ledger.Timestamp - /** - * @member {ledger.Timestamp} newTime - * @memberof ledger.SetTimeRequest - * @instance - */ - newTime: ledger.Timestamp -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/status.ts b/language-support/js/daml-ledger/src/model/status.ts deleted file mode 100644 index da15ba80cc2..00000000000 --- a/language-support/js/daml-ledger/src/model/status.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface ledger.Status - */ -export interface Status { - /** - * @member {number} code - * @memberof ledger.Status - * @instance - */ - code: number - /** - * @member {string} message - * @memberof ledger.Status - * @instance - */ - message: string - /** - * @member {Array} details - * @memberof ledger.Status - * @instance - */ - details: ledger.Any[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/submit_and_wait_request.ts b/language-support/js/daml-ledger/src/model/submit_and_wait_request.ts deleted file mode 100644 index cd3a25d7f6b..00000000000 --- a/language-support/js/daml-ledger/src/model/submit_and_wait_request.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface ledger.SubmitAndWaitRequest - */ -export interface SubmitAndWaitRequest { - /** - * @member {ledger.Commands} commands - * @memberof ledger.SubmitAndWaitRequest - * @instance - */ - commands: ledger.Commands -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/submit_request.ts b/language-support/js/daml-ledger/src/model/submit_request.ts deleted file mode 100644 index 577998e28f4..00000000000 --- a/language-support/js/daml-ledger/src/model/submit_request.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface ledger.SubmitRequest - */ -export interface SubmitRequest { - /** - * @member {ledger.Commands} commands - * @memberof ledger.SubmitRequest - * @instance - */ - commands: ledger.Commands -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/timestamp.ts b/language-support/js/daml-ledger/src/model/timestamp.ts deleted file mode 100644 index 5f0a84d07b8..00000000000 --- a/language-support/js/daml-ledger/src/model/timestamp.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @interface Timestamp - * @memberof ledger - */ -export interface Timestamp { - /** - * @member {number} seconds - * @memberof ledger.Timestamp - * @instance - */ - seconds: number - /** - * @member {number} nanoseconds - * @memberof ledger.Timestamp - * @instance - */ - nanoseconds: number -} - -export namespace Timestamp { - - /** - * True if `left` represents an instant that precedes or is simulatenous to `right` - * - * @function lessThanOrEqual - * @memberof ledger.Timestamp - * @param {ledger.Timestamp} left - * @param {ledger.Timestamp} right - */ - export function lessThanOrEqual(left: Timestamp, right: Timestamp): boolean { - if (left.seconds < right.seconds) { - return true; - } else if (left.seconds === right.seconds) { - return left.nanoseconds <= right.nanoseconds; - } else { - return false; - } - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/transaction.ts b/language-support/js/daml-ledger/src/model/transaction.ts deleted file mode 100644 index 32d11bec6c7..00000000000 --- a/language-support/js/daml-ledger/src/model/transaction.ts +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface Transaction - * @memberof ledger - */ -export interface Transaction { - /** - * @member {string} commandId - * @memberof ledger.Transaction - * @instance - */ - commandId?: string - /** - * @member {ledger.Timestamp} effectiveAt - * @memberof ledger.Transaction - * @instance - */ - effectiveAt: ledger.Timestamp - /** - * @member {Array} events - * @memberof ledger.Transaction - * @instance - */ - events: ledger.Event[] - /** - * @member {string} offset - * @memberof ledger.Transaction - * @instance - */ - offset: string - /** - * @member {string} transactionId - * @memberof ledger.Transaction - * @instance - */ - transactionId: string - /** - * @member {string} workflowId - * @memberof ledger.Transaction - * @instance - */ - workflowId?: string -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/transaction_filter.ts b/language-support/js/daml-ledger/src/model/transaction_filter.ts deleted file mode 100644 index 0aa4a6f58f7..00000000000 --- a/language-support/js/daml-ledger/src/model/transaction_filter.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface TransactionFilter - * @memberof ledger - */ -export interface TransactionFilter { - /** - * A plain object with {@link ledger.Filters} as values. - * - * @member {object} filtersByParty - * @memberof ledger.TransactionFilter - * @instance - */ - filtersByParty: Record -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/transaction_tree.ts b/language-support/js/daml-ledger/src/model/transaction_tree.ts deleted file mode 100644 index 25749897004..00000000000 --- a/language-support/js/daml-ledger/src/model/transaction_tree.ts +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface TransactionTree - * @memberof ledger - */ -export interface TransactionTree { - /** - * @member {string} commandId - * @memberof ledger.TransactionTree - * @instance - */ - commandId?: string - /** - * @member {ledger.Timestamp} effectiveAt - * @memberof ledger.TransactionTree - * @instance - */ - effectiveAt: ledger.Timestamp - /** - * @member {string} offset - * @memberof ledger.TransactionTree - * @instance - */ - offset: string - /** - * @member {string} transactionId - * @memberof ledger.TransactionTree - * @instance - */ - transactionId: string - /** - * @member {string} workflowId - * @memberof ledger.TransactionTree - * @instance - */ - workflowId?: string - /** - * @member {object} eventsByIds - * @memberof ledger.TransactionTree - * @instance - */ - eventsById: Record - /** - * @member {Array} rootEventIds - * @memberof ledger.TransactionTree - * @instance - */ - rootEventIds: string[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/tree_event.ts b/language-support/js/daml-ledger/src/model/tree_event.ts deleted file mode 100644 index b7e4098b446..00000000000 --- a/language-support/js/daml-ledger/src/model/tree_event.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -export interface TreeEvent { - created?: ledger.CreatedEvent, - exercised?: ledger.ExercisedEvent -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/value.ts b/language-support/js/daml-ledger/src/model/value.ts deleted file mode 100644 index 9d09048e89c..00000000000 --- a/language-support/js/daml-ledger/src/model/value.ts +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface ledger.Value - */ -export interface Value { - /** - * @member {ledger.Record} record - * @memberof ledger.Value - * @instance - */ - record?: ledger.Record - /** - * @member {ledger.Variant} variant - * @memberof ledger.Value - * @instance - */ - variant?: ledger.Variant - /** - * @member {string} contractId - * @memberof ledger.Value - * @instance - */ - contractId?: string - /** - * @member {Array} list - * @memberof ledger.Value - * @instance - */ - list?: Value[] - /** - * @member {string} int64 - * @memberof ledger.Value - * @instance - * - * Represented as a {string} to avoid losing precision - */ - int64?: string - /** - * @member {string} decimal - * @memberof ledger.Value - * @instance - * - * Represented as a {string} to avoid losing precision - */ - decimal?: string - /** - * @member {string} text - * @memberof ledger.Value - * @instance - */ - text?: string - /** - * @member {string} timestamp - * @memberof ledger.Value - * @instance - * - * Represented as a {string} to avoid losing precision - */ - timestamp?: string - /** - * @member {string} party - * @memberof ledger.Value - * @instance - */ - party?: string - /** - * @member {boolean} bool - * @memberof ledger.Value - * @instance - */ - bool?: boolean - /** - * @member {ledger.Empty} unit - * @memberof ledger.Value - * @instance - */ - unit?: ledger.Empty - /** - * @member {string} date - * @memberof ledger.Value - * @instance - * - * Represented as a {string} for consistency with - * other numeric types in this union. This also - * allows the type to remain stable in the face - * of prospective expansions of the underlying - * type to a 64-bit encoding. - */ - date?: string - /** - * @member {ledger.Optional} optional - * @memberof ledger.Value - * @instance - */ - optional?: ledger.Optional -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/model/variant.ts b/language-support/js/daml-ledger/src/model/variant.ts deleted file mode 100644 index 9baba7d3228..00000000000 --- a/language-support/js/daml-ledger/src/model/variant.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '..'; - -/** - * @interface Variant - * @memberof ledger - */ -export interface Variant { - /** - * @member {ledger.Identifier} variantId - * @memberof ledger.Variant - * @instance - */ - variantId?: ledger.Identifier - /** - * @member {string} constructor - * @memberof ledger.Variant - * @instance - */ - constructor: string - /** - * @member {ledger.Value} value - * @memberof ledger.Variant - * @instance - */ - value: ledger.Value -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/reporting/index.ts b/language-support/js/daml-ledger/src/reporting/index.ts deleted file mode 100644 index 0e61ef70f15..00000000000 --- a/language-support/js/daml-ledger/src/reporting/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as validation from "../validation"; - -export type Reporter = (_: validation.Tree) => Error - -export { SimpleReporter } from './simple_reporter'; -export { JSONReporter } from './json_reporter'; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/reporting/json_reporter.ts b/language-support/js/daml-ledger/src/reporting/json_reporter.ts deleted file mode 100644 index a552da52706..00000000000 --- a/language-support/js/daml-ledger/src/reporting/json_reporter.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Reporter } from "."; -import * as validation from '../validation'; - -export const JSONReporter: Reporter = (tree: validation.Tree) => { - return new Error(JSON.stringify(tree)); -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/reporting/simple_reporter.ts b/language-support/js/daml-ledger/src/reporting/simple_reporter.ts deleted file mode 100644 index 88c6b2f69c7..00000000000 --- a/language-support/js/daml-ledger/src/reporting/simple_reporter.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Reporter } from "."; -import * as validation from '../validation'; - -function spellOutError(error: validation.Error): string { - switch (error.kind) { - case 'missing-key': - return `Missing key ${error.expectedKey} of type ${error.expectedType}`; - case 'non-unique-union': - if (error.keys.length === 0) { - return `Exactly one value must be defined in an union but none are`; - } else { - return `Exactly one value must be defined in an union but ${error.keys.length} are (${error.keys.join(', ')})`; - } - case 'type-error': - return `Type error, ${error.expectedType} expected but got ${error.actualType}`; - case 'unexpected-key': - return `Unexpected key ${error.key} found`; - } -} - -function buildErrorMessage(tree: validation.Tree, indent: number = 0): string { - let errors = ''; - for (const error of tree.errors) { - errors += `\n${' '.repeat(indent)}✗ ${spellOutError(error)}`; - } - for (const child in tree.children) { - if (!validation.ok(tree.children[child])) { - return `${errors}\n${' '.repeat(indent)}▸ ${child}${buildErrorMessage(tree.children[child], indent + 2)}`; - } - } - return errors; -} - -export const SimpleReporter: Reporter = (tree: validation.Tree) => { - return new Error(`! Validation error${buildErrorMessage(tree)}`); -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/util/callback.ts b/language-support/js/daml-ledger/src/util/callback.ts deleted file mode 100644 index ba84ffe8077..00000000000 --- a/language-support/js/daml-ledger/src/util/callback.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * A callback that will either receive an {@link Error} or a valid response, - * depending on the result of the operation. - * - * @callback Callback - * @memberof util - * @param {Error | null} error Passed in case of error, otherwise null - * @param {A | undefined} response The return value for the success case - */ -export type Callback = (error: Error | null, response?: A) => void - -export function justForward(callback: Callback, error: Error | null, response: A): void { - forward(callback, error, response, (a: A) => a); -} - -export function forward(callback: Callback, error: Error | null, response: A, process: (_: A) => B): void { - if (error) { - callback(error); - } else { - callback(null, process(response)); - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/util/index.ts b/language-support/js/daml-ledger/src/util/index.ts deleted file mode 100644 index 435344a3ea3..00000000000 --- a/language-support/js/daml-ledger/src/util/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -/** - * @namespace util - */ - -export { Callback } from './callback'; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/any.ts b/language-support/js/daml-ledger/src/validation/any.ts deleted file mode 100644 index 51be7583806..00000000000 --- a/language-support/js/daml-ledger/src/validation/any.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; - -function required(): RequiredValidation { - return { - typeUrl: native('string'), - value: native('string') - }; -} - -export const Any: Validation = object('Any', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/archived_event.ts b/language-support/js/daml-ledger/src/validation/archived_event.ts deleted file mode 100644 index bd3638b626e..00000000000 --- a/language-support/js/daml-ledger/src/validation/archived_event.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation, array } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { Identifier } from "./identifier"; - -function required(): RequiredValidation { - return { - contractId: native('string'), - eventId: native('string'), - templateId: Identifier, - witnessParties: array(native('string')) - }; -} - -export const ArchivedEvent: Validation = object('ArchivedEvent', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/base/array.ts b/language-support/js/daml-ledger/src/validation/base/array.ts deleted file mode 100644 index 9f224d9621c..00000000000 --- a/language-support/js/daml-ledger/src/validation/base/array.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Error, Tree, Validation, init, typeOf } from "."; - -export function array(items: Validation): Validation { - return { - type: `Array<${items.type}>`, - validate(value: any, key?: string, validation?: Tree): Tree { - const node = init(key, validation); - if (Array.isArray(value)) { - value.forEach((item, index) => { - items.validate(item, index.toString(), node); - }); - } else { - const error: Error = { - kind: 'type-error', - expectedType: this.type, - actualType: typeOf(value) - }; - node.errors.push(error); - } - return validation || node; - } - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/base/enumeration.ts b/language-support/js/daml-ledger/src/validation/base/enumeration.ts deleted file mode 100644 index c9a788088bd..00000000000 --- a/language-support/js/daml-ledger/src/validation/base/enumeration.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Error, Tree, Validation, init, typeOf } from "."; - -function valuesOf(enumeration: { [_: number]: string }): string[] { - return Object.keys(enumeration).filter(k => typeof enumeration[k as any] === "number").map(k => enumeration[k as any]); -} - -// NOTE: works only for `enum`s without custom initializers -export function enumeration(enumeration: { [_: number]: string }, type: string): Validation { - return { - type: type, - validate(value: any, key?: string, validation?: Tree): Tree { - const node = init(key, validation); - const values = valuesOf(enumeration); - if (!values.some(v => v === value)) { - const error: Error = { - kind: 'type-error', - expectedType: this.type, - actualType: typeOf(value) - }; - node.errors.push(error); - } - return validation || node; - } - } -}; \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/base/error.ts b/language-support/js/daml-ledger/src/validation/base/error.ts deleted file mode 100644 index f6ff8e309f0..00000000000 --- a/language-support/js/daml-ledger/src/validation/base/error.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -export type Error = MissingKey | TypeError | UnexpectedKey | NonUniqueUnion - -export interface MissingKey { - kind: 'missing-key' - expectedKey: string - expectedType: string -} - -export interface TypeError { - kind: 'type-error' - expectedType: string - actualType: string -} - -export interface UnexpectedKey { - kind: 'unexpected-key' - key: string -} - -export interface NonUniqueUnion { - kind: 'non-unique-union', - keys: string[] -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/base/index.ts b/language-support/js/daml-ledger/src/validation/base/index.ts deleted file mode 100644 index 7ebe8e7721e..00000000000 --- a/language-support/js/daml-ledger/src/validation/base/index.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Error, MissingKey, TypeError, UnexpectedKey } from './error'; -import { ok, Tree } from "./tree"; -import { OptionalKeys, OptionalValidation, RequiredKeys, RequiredSlice, RequiredValidation } from './typelevel'; -export { array } from './array'; -export { enumeration } from './enumeration'; -export { native } from './native'; -export { object } from './object'; -export { union } from './union'; -export { Tree, ok }; -export { Error, MissingKey, TypeError, UnexpectedKey }; -export { OptionalKeys, RequiredKeys, RequiredSlice }; - -export interface Validation { - type: string - validate(value: any): Tree - validate(value: any, key: string, validation: Tree): Tree -} - -export interface UnionValidation extends Validation { - values(): Record -} - -export interface ObjectValidation extends Validation { - required(): RequiredValidation - optional(): OptionalValidation -} - -export const noFields = () => ({}); - -export function init(key?: string, validation?: Tree): Tree { - const node: Tree = { - children: {}, - errors: [] - }; - if (key && validation) { - validation.children[key] = node; - } - return node; -} - -export function typeOf(value: any): 'string' | 'number' | 'boolean' | 'symbol' | 'undefined' | 'null' | 'object' | 'function' | 'array' { - if (value === null) return 'null'; - const t = typeof value; - return t === 'object' && Array.isArray(value) ? 'array' : t; -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/base/native.ts b/language-support/js/daml-ledger/src/validation/base/native.ts deleted file mode 100644 index 9f5c5de2375..00000000000 --- a/language-support/js/daml-ledger/src/validation/base/native.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Error, Tree, Validation, init, typeOf } from "."; - -export function native(type: 'number' | 'string' | 'boolean'): Validation { - return { - type: type, - validate(value: any, key?: string, validation?: Tree): Tree { - const node = init(key, validation); - const actualType = typeOf(value); - if (actualType !== type) { - const error: Error = { - kind: 'type-error', - expectedType: type, - actualType: actualType - }; - node.errors.push(error); - } - return validation || node; - } - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/base/object.ts b/language-support/js/daml-ledger/src/validation/base/object.ts deleted file mode 100644 index 5558cfdad19..00000000000 --- a/language-support/js/daml-ledger/src/validation/base/object.ts +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { init, ObjectValidation, Tree, typeOf, Validation } from "."; -import { OptionalValidation, RequiredValidation } from "./typelevel"; - -function checkRequired(object: any, required: {[_: string]: Validation}, node: Tree): void { - for (const key in required) { - if (object.hasOwnProperty(key)) { - required[key].validate(object[key], key, node); - } else { - node.errors.push({ - kind: 'missing-key', - expectedKey: key, - expectedType: required[key].type - }); - } - } -} - -function checkOptional(object: any, optional: {[_: string]: Validation}, node: Tree): void { - for (const key in optional) { - if (object.hasOwnProperty(key) && object[key] !== undefined) { - optional[key].validate(object[key], key, node); - } - } -} - -function checkUnexpected(object: any, keys: Record, node: Tree): void { - for (const key in object) { - if (!keys || !keys.hasOwnProperty(key)) { - node.errors.push({ - kind: 'unexpected-key', - key: key - }) - } - } -} - -export function object(type: string, required: () => RequiredValidation, optional: () => OptionalValidation): ObjectValidation { - return { - type: type, - required: required, - optional: optional, - validate(value: any, key?: string, validation?: Tree): Tree { - const node = init(key, validation); - const actualType = typeOf(value); - if (actualType !== 'object') { - node.errors.push({ - kind: 'type-error', - expectedType: type, - actualType: actualType - }) - } else { - const required = this.required(); - const optional = this.optional(); - checkRequired(value, required, node); - checkOptional(value, optional, node); - checkUnexpected(value, Object.assign({}, required, optional), node); - } - return validation || node; - } - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/base/record.ts b/language-support/js/daml-ledger/src/validation/base/record.ts deleted file mode 100644 index dbf378868f2..00000000000 --- a/language-support/js/daml-ledger/src/validation/base/record.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { init, Tree, Validation, typeOf } from "."; - -export function record(values: Validation): Validation { - return { - type: `Record`, - validate(value: any, key?: string, validation?: Tree): Tree { - const node = init(key, validation); - const actualType = typeOf(value); - if (actualType !== 'object') { - node.errors.push({ - kind: 'type-error', - expectedType: this.type, - actualType: actualType - }) - } else { - for (const key in value) { - values.validate(value[key], key, node); - } - } - return validation || node; - } - } -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/base/tree.ts b/language-support/js/daml-ledger/src/validation/base/tree.ts deleted file mode 100644 index 5853cd2419e..00000000000 --- a/language-support/js/daml-ledger/src/validation/base/tree.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Error } from "./error"; - -export interface Tree { - errors: Error[] - children: Record -} - -export function ok(tree: Tree): boolean { - return tree.errors.length === 0 && Object.keys(tree.children).every(child => ok(tree.children[child])) -} diff --git a/language-support/js/daml-ledger/src/validation/base/typelevel.ts b/language-support/js/daml-ledger/src/validation/base/typelevel.ts deleted file mode 100644 index 1c69982b2bd..00000000000 --- a/language-support/js/daml-ledger/src/validation/base/typelevel.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Validation } from "."; - -/** - * Extracts required keys as a literal type union - */ -export type RequiredKeys = { [K in keyof T]: {} extends Pick ? never : K } extends { [_ in keyof T]: infer U } - ? {} extends U - ? never - : U - : never - -/** - * Extracts optional keys as a literal type union - */ -export type OptionalKeys = { [K in keyof T]: T extends Record ? never : K } extends { - [_ in keyof T]: infer U -} - ? {} extends U - ? never - : U - : never - -export type RequiredSlice = Record, V> -export type RequiredValidation = RequiredSlice - -export type OptionalSlice = Record, V> -export type OptionalValidation = OptionalSlice \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/base/union.ts b/language-support/js/daml-ledger/src/validation/base/union.ts deleted file mode 100644 index 0580bcb53ad..00000000000 --- a/language-support/js/daml-ledger/src/validation/base/union.ts +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { init, Tree, Validation, typeOf, UnionValidation } from "."; - -function checkUniqueness(object: any, node: Tree): void { - const defined: string[] = Object.keys(object).filter(key => object[key] !== undefined); - if (defined.length !== 1) { - node.errors.push({ - kind: 'non-unique-union', - keys: defined - }) - } -} - -function checkValue(object: any, values: {[_: string]: Validation}, node: Tree): void { - for (const key in values) { - if (object.hasOwnProperty(key)) { - values[key].validate(object[key], key, node); - } - } -} - -function checkUnexpected(object: any, keys: Record, node: Tree): void { - for (const key in object) { - if (!keys || !keys.hasOwnProperty(key)) { - node.errors.push({ - kind: 'unexpected-key', - key: key - }) - } - } -} - -export function union(type: string, values: () => Record): UnionValidation { - return { - type: type, - values: values, - validate(value: any, key?: string, validation?: Tree): Tree { - const node = init(key, validation); - const actualType = typeOf(value); - if (actualType !== 'object') { - node.errors.push({ - kind: 'type-error', - expectedType: type, - actualType: actualType - }); - } else { - const values = this.values(); - checkUniqueness(value, node); - checkValue(value, values, node); - checkUnexpected(value, values, node); - } - return validation || node; - } - }; -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/checkpoint.ts b/language-support/js/daml-ledger/src/validation/checkpoint.ts deleted file mode 100644 index a0a3c166ebe..00000000000 --- a/language-support/js/daml-ledger/src/validation/checkpoint.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { LedgerOffset } from "./ledger_offset"; -import { Timestamp } from "./timestamp"; - -function required(): RequiredValidation { - return { - offset: LedgerOffset, - recordTime: Timestamp - }; -} - -export const Checkpoint: Validation = object('Checkpoint', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/command.ts b/language-support/js/daml-ledger/src/validation/command.ts deleted file mode 100644 index bc06b233144..00000000000 --- a/language-support/js/daml-ledger/src/validation/command.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { union, Validation } from "./base"; -import { CreateCommand } from "./create_command"; -import { ExerciseCommand } from "./exercise_command"; - -function values(): Record { - return { - create: CreateCommand, - exercise: ExerciseCommand - }; -} - -export const Command: Validation = union('Command', values); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/commands.ts b/language-support/js/daml-ledger/src/validation/commands.ts deleted file mode 100644 index 63e74ef871c..00000000000 --- a/language-support/js/daml-ledger/src/validation/commands.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { array, native, object, Validation } from "./base"; -import { OptionalValidation, RequiredValidation } from "./base/typelevel"; -import { Command } from "./command"; -import { Timestamp } from "./timestamp"; - -function required(): RequiredValidation { - return { - applicationId: native('string'), - commandId: native('string'), - ledgerEffectiveTime: Timestamp, - list: array(Command), - maximumRecordTime: Timestamp, - party: native('string') - }; -} - -function optional(): OptionalValidation { - return { - workflowId: native('string') - }; -} - -export const Commands: Validation = object('Commands', required, optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/completion.ts b/language-support/js/daml-ledger/src/validation/completion.ts deleted file mode 100644 index cc8f5def6d9..00000000000 --- a/language-support/js/daml-ledger/src/validation/completion.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation } from "./base"; -import { OptionalValidation, RequiredValidation } from "./base/typelevel"; -import { Status } from "./status"; - -function required(): RequiredValidation { - return { - commandId: native('string'), - }; -} - -function optional(): OptionalValidation { - return { - status: Status - }; -} - -export const Completion: Validation = object('Completion', required, optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/completion_end_response.ts b/language-support/js/daml-ledger/src/validation/completion_end_response.ts deleted file mode 100644 index 6f366d4f607..00000000000 --- a/language-support/js/daml-ledger/src/validation/completion_end_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { LedgerOffset } from "./ledger_offset"; - -function required(): RequiredValidation { - return { - offset: LedgerOffset - }; -} - -export const CompletionEndResponse: Validation = object('CompletionEndResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/completion_stream_request.ts b/language-support/js/daml-ledger/src/validation/completion_stream_request.ts deleted file mode 100644 index 821aa9bf36a..00000000000 --- a/language-support/js/daml-ledger/src/validation/completion_stream_request.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation, array, native } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { LedgerOffset } from "./ledger_offset"; - -function required(): RequiredValidation { - return { - applicationId: native('string'), - offset: LedgerOffset, - parties: array(native('string')), - }; -} - -export const CompletionStreamRequest: Validation = object('CompletionStreamRequest', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/completion_stream_response.ts b/language-support/js/daml-ledger/src/validation/completion_stream_response.ts deleted file mode 100644 index 963c8ee3244..00000000000 --- a/language-support/js/daml-ledger/src/validation/completion_stream_response.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { array, object, Validation } from "./base"; -import { OptionalValidation } from "./base/typelevel"; -import { Checkpoint } from "./checkpoint"; -import { Completion } from "./completion"; - -function optional(): OptionalValidation { - return { - checkpoint: Checkpoint, - completions: array(Completion), - }; -} - -export const CompletionStreamResponse: Validation = object('CompletionStreamResponse', () => ({}), optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/create_command.ts b/language-support/js/daml-ledger/src/validation/create_command.ts deleted file mode 100644 index 0281a53d84d..00000000000 --- a/language-support/js/daml-ledger/src/validation/create_command.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { Identifier } from "./identifier"; -import { Record } from "./record"; - -function required(): RequiredValidation { - return { - arguments: Record, - templateId: Identifier - }; -} - -export const CreateCommand: Validation = object('CreateCommand', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/created_event.ts b/language-support/js/daml-ledger/src/validation/created_event.ts deleted file mode 100644 index 0fc8bfb31fa..00000000000 --- a/language-support/js/daml-ledger/src/validation/created_event.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation, native, array } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { Identifier } from "./identifier"; -import { Record } from "./record"; - -function required(): RequiredValidation { - return { - arguments: Record, - contractId: native('string'), - eventId: native('string'), - templateId: Identifier, - witnessParties: array(native('string')), - }; -} - -export const CreatedEvent: Validation = object('CreatedEvent', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/duration.ts b/language-support/js/daml-ledger/src/validation/duration.ts deleted file mode 100644 index 83ccf922f6c..00000000000 --- a/language-support/js/daml-ledger/src/validation/duration.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; - -function required(): RequiredValidation { - return { - nanoseconds: native('number'), - seconds: native('number') - }; -} - -export const Duration: Validation = object('Duration', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/empty.ts b/language-support/js/daml-ledger/src/validation/empty.ts deleted file mode 100644 index 6b9e0559986..00000000000 --- a/language-support/js/daml-ledger/src/validation/empty.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; - -export const Empty: Validation = object('Empty', () => ({}), () => ({})) \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/event.ts b/language-support/js/daml-ledger/src/validation/event.ts deleted file mode 100644 index 75a865f0061..00000000000 --- a/language-support/js/daml-ledger/src/validation/event.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { ArchivedEvent } from "./archived_event"; -import { union, Validation } from "./base"; -import { CreatedEvent } from "./created_event"; -import { ExercisedEvent } from "./exercised_event"; - -function values(): Record { - return { - archived: ArchivedEvent, - created: CreatedEvent, - exercised: ExercisedEvent - }; -} - -export const Event: Validation = union('Event', values); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/exercise_command.ts b/language-support/js/daml-ledger/src/validation/exercise_command.ts deleted file mode 100644 index a4df0b0168f..00000000000 --- a/language-support/js/daml-ledger/src/validation/exercise_command.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation, native } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { Identifier } from "./identifier"; -import { Value } from "./value"; - -function required(): RequiredValidation { - return { - argument: Value, - choice: native('string'), - contractId: native('string'), - templateId: Identifier - }; -} - -export const ExerciseCommand: Validation = object('ExerciseCommand', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/exercised_event.ts b/language-support/js/daml-ledger/src/validation/exercised_event.ts deleted file mode 100644 index abb14bb8328..00000000000 --- a/language-support/js/daml-ledger/src/validation/exercised_event.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { array, native, object, Validation } from "./base"; -import { OptionalValidation, RequiredValidation } from "./base/typelevel"; -import { Identifier } from "./identifier"; -import { Value } from "./value"; - -function required(): RequiredValidation { - return { - actingParties: array(native('string')), - choice: native('string'), - argument: Value, - consuming: native('boolean'), - contractCreatingEventId: native('string'), - contractId: native('string'), - eventId: native('string'), - templateId: Identifier, - witnessParties: array(native('string')) - }; -} - -function optional(): OptionalValidation { - return { - childEventIds: array(native('string')) - }; -} - -export const ExercisedEvent: Validation = object('ExercisedEvent', required, optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/filters.ts b/language-support/js/daml-ledger/src/validation/filters.ts deleted file mode 100644 index 88ecfdf3c56..00000000000 --- a/language-support/js/daml-ledger/src/validation/filters.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Validation, object } from "./base"; -import * as ledger from ".."; -import { InclusiveFilters } from './inclusive_filters'; -import { OptionalValidation } from "./base/typelevel"; - -function optional(): OptionalValidation { - return { - inclusive: InclusiveFilters - }; -} - -export const Filters: Validation = object('Filters', () => ({}), optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_active_contracts_request.ts b/language-support/js/daml-ledger/src/validation/get_active_contracts_request.ts deleted file mode 100644 index 80d497dac57..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_active_contracts_request.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation } from "./base"; -import { RequiredValidation, OptionalValidation } from "./base/typelevel"; -import { TransactionFilter } from "./transaction_filter"; - -function required(): RequiredValidation { - return { - filter: TransactionFilter, - }; -} - -function optional(): OptionalValidation { - return { - verbose: native('boolean'), - } -} - -export const GetActiveContractsRequest: Validation = object('GetActiveContractsRequest', required, optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_active_contracts_response.ts b/language-support/js/daml-ledger/src/validation/get_active_contracts_response.ts deleted file mode 100644 index 20bd4d30ef5..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_active_contracts_response.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { array, native, object, Validation } from "./base"; -import { OptionalValidation, RequiredValidation } from "./base/typelevel"; -import { CreatedEvent } from "./created_event"; -import { LedgerOffset } from "./ledger_offset"; - -function required(): RequiredValidation { - return { - offset: LedgerOffset - }; -} - -function optional(): OptionalValidation { - return { - activeContracts: array(CreatedEvent), - workflowId: native('string') - } -} - -export const GetActiveContractsResponse: Validation = object('GetActiveContractsResponse', required, optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_ledger_configuration_response.ts b/language-support/js/daml-ledger/src/validation/get_ledger_configuration_response.ts deleted file mode 100644 index fa63ab87422..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_ledger_configuration_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { LedgerConfiguration } from "./ledger_configuration"; - -function required(): RequiredValidation { - return { - config: LedgerConfiguration - }; -} - -export const GetLedgerConfigurationResponse: Validation = object('GetLedgerConfigurationResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_ledger_end_response.ts b/language-support/js/daml-ledger/src/validation/get_ledger_end_response.ts deleted file mode 100644 index e7ac23e9227..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_ledger_end_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { LedgerOffset } from "./ledger_offset"; - -function required(): RequiredValidation { - return { - offset: LedgerOffset - }; -} - -export const GetLedgerEndResponse: Validation = object('GetLedgerEndResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_ledger_identity_response.ts b/language-support/js/daml-ledger/src/validation/get_ledger_identity_response.ts deleted file mode 100644 index 4940e4436e0..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_ledger_identity_response.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation, native } from "./base"; -import { RequiredValidation } from "./base/typelevel"; - -function required(): RequiredValidation { - return { - ledgerId: native('string') - }; -} - -export const GetLedgerIdentityResponse: Validation = object('GetLedgerIdentityResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_package_response.ts b/language-support/js/daml-ledger/src/validation/get_package_response.ts deleted file mode 100644 index 301cde17424..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_package_response.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { HashFunction } from "./hash_function"; - -function required(): RequiredValidation { - return { - archivePayload: native('string'), - hash: native('string'), - hashFunction: HashFunction - }; -} - -export const GetPackageResponse: Validation = object('GetPackageResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_package_status_response.ts b/language-support/js/daml-ledger/src/validation/get_package_status_response.ts deleted file mode 100644 index c5cfff984a8..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_package_status_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { PackageStatus } from "./package_status"; - -function required(): RequiredValidation { - return { - status: PackageStatus - }; -} - -export const GetPackageStatusResponse: Validation = object('GetPackageStatusResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_time_response.ts b/language-support/js/daml-ledger/src/validation/get_time_response.ts deleted file mode 100644 index c7fdf13d730..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_time_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { Timestamp } from "./timestamp"; - -function required(): RequiredValidation { - return { - currentTime: Timestamp - }; -} - -export const GetTimeResponse: Validation = object('GetTimeResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_transaction_by_event_id_request.ts b/language-support/js/daml-ledger/src/validation/get_transaction_by_event_id_request.ts deleted file mode 100644 index 223a117c454..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_transaction_by_event_id_request.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { array, native, object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; - -function required(): RequiredValidation { - return { - eventId: native('string'), - requestingParties: array(native('string')), - }; -} - -export const GetTransactionByEventIdRequest: Validation = object('GetTransactionByEventIdRequest', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_transaction_by_id_request.ts b/language-support/js/daml-ledger/src/validation/get_transaction_by_id_request.ts deleted file mode 100644 index e4103dcdb1a..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_transaction_by_id_request.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { array, native, object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; - -function required(): RequiredValidation { - return { - transactionId: native('string'), - requestingParties: array(native('string')), - }; -} - -export const GetTransactionByIdRequest: Validation = object('GetTransactionByIdRequest', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_transaction_response.ts b/language-support/js/daml-ledger/src/validation/get_transaction_response.ts deleted file mode 100644 index 613e74fd29d..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_transaction_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { TransactionTree } from "./transaction_tree"; - -function required(): RequiredValidation { - return { - transaction: TransactionTree, - }; -} - -export const GetTransactionResponse: Validation = object('GetTransactionResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_transaction_trees_response.ts b/language-support/js/daml-ledger/src/validation/get_transaction_trees_response.ts deleted file mode 100644 index a2f54f6a506..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_transaction_trees_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation, array } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { TransactionTree } from "./transaction_tree"; - -function required(): RequiredValidation { - return { - transactions: array(TransactionTree), - }; -} - -export const GetTransactionTreesResponse: Validation = object('GetTransactionTreesResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_transactions_request.ts b/language-support/js/daml-ledger/src/validation/get_transactions_request.ts deleted file mode 100644 index 1ed8e0fe8bb..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_transactions_request.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation, native } from "./base"; -import { OptionalValidation, RequiredValidation } from "./base/typelevel"; -import { LedgerOffset } from "./ledger_offset"; -import { TransactionFilter } from "./transaction_filter"; - -function required(): RequiredValidation { - return { - begin: LedgerOffset, - filter: TransactionFilter - }; -} - -function optional(): OptionalValidation { - return { - end: LedgerOffset, - verbose: native('boolean') - }; -} - -export const GetTransactionsRequest: Validation = object('GetTransactionsRequest', required, optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/get_transactions_response.ts b/language-support/js/daml-ledger/src/validation/get_transactions_response.ts deleted file mode 100644 index fa87f5235ec..00000000000 --- a/language-support/js/daml-ledger/src/validation/get_transactions_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation, array } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { Transaction } from "./transaction"; - -function required(): RequiredValidation { - return { - transactions: array(Transaction), - }; -} - -export const GetTransactionsResponse: Validation = object('GetTransactionsResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/hash_function.ts b/language-support/js/daml-ledger/src/validation/hash_function.ts deleted file mode 100644 index 2a350269c2e..00000000000 --- a/language-support/js/daml-ledger/src/validation/hash_function.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { enumeration } from "./base"; - -export const HashFunction = enumeration(ledger.HashFunction, 'HashFunction') \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/identifier.ts b/language-support/js/daml-ledger/src/validation/identifier.ts deleted file mode 100644 index 55213e41d76..00000000000 --- a/language-support/js/daml-ledger/src/validation/identifier.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; - -function required(): RequiredValidation { - return { - packageId: native('string'), - moduleName: native('string'), - entityName: native('string') - }; -} - -export const Identifier: Validation = object('Identifier', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/inclusive_filters.ts b/language-support/js/daml-ledger/src/validation/inclusive_filters.ts deleted file mode 100644 index 915dabb1686..00000000000 --- a/language-support/js/daml-ledger/src/validation/inclusive_filters.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { array, object, Validation } from "./base"; -import { RequiredValidation } from './base/typelevel'; -import { Identifier } from './identifier'; - -function required(): RequiredValidation { - return { - templateIds: array(Identifier), - }; -} - -export const InclusiveFilters: Validation = object('InclusiveFilters', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/index.ts b/language-support/js/daml-ledger/src/validation/index.ts deleted file mode 100644 index e05c9b3f95a..00000000000 --- a/language-support/js/daml-ledger/src/validation/index.ts +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -export { ok, Tree, Error } from './base'; - -export { Any } from './any'; -export { ArchivedEvent } from './archived_event'; -export { Checkpoint } from './checkpoint'; -export { Command } from './command'; -export { Commands } from './commands'; -export { Completion } from './completion'; -export { CreateCommand } from './create_command'; -export { CreatedEvent } from './created_event'; -export { Duration } from './duration'; -export { Empty } from './empty'; -export { Event } from './event'; -export { TreeEvent } from './tree_event'; -export { ExerciseCommand } from './exercise_command'; -export { ExercisedEvent } from './exercised_event'; -export { HashFunction } from './hash_function'; -export { Identifier } from './identifier'; -export { InclusiveFilters } from './inclusive_filters'; -export { Filters } from './filters'; -export { LedgerConfiguration } from './ledger_configuration'; -export { LedgerOffset } from './ledger_offset'; -export { Optional } from './optional'; -export { PackageStatus } from './package_status'; -export { Record } from './record'; -export { Status } from './status'; -export { Timestamp } from './timestamp'; -export { Transaction } from './transaction'; -export { TransactionFilter } from './transaction_filter'; -export { TransactionTree } from './transaction_tree'; -export { Value } from './value'; -export { Variant } from './variant'; - -export { GetActiveContractsRequest } from './get_active_contracts_request'; -export { GetActiveContractsResponse } from './get_active_contracts_response'; - -export { SubmitAndWaitRequest } from './submit_and_wait_request'; - -export { CompletionEndResponse } from './completion_end_response'; -export { CompletionStreamRequest } from './completion_stream_request'; -export { CompletionStreamResponse } from './completion_stream_response'; - -export { SubmitRequest } from './submit_request'; - -export { GetLedgerConfigurationResponse } from './get_ledger_configuration_response'; - -export { GetLedgerIdentityResponse } from './get_ledger_identity_response'; - -export { GetPackageResponse } from './get_package_response'; -export { GetPackageStatusResponse } from './get_package_status_response'; -export { ListPackagesResponse } from './list_packages_response'; - -export { GetTimeResponse } from './get_time_response'; -export { SetTimeRequest } from './set_time_request'; - -export { GetLedgerEndResponse } from './get_ledger_end_response'; -export { GetTransactionByEventIdRequest } from './get_transaction_by_event_id_request'; -export { GetTransactionByIdRequest } from './get_transaction_by_id_request'; -export { GetTransactionResponse } from './get_transaction_response'; -export { GetTransactionsRequest } from './get_transactions_request'; -export { GetTransactionsResponse } from './get_transactions_response'; -export { GetTransactionTreesResponse } from './get_transaction_trees_response'; - diff --git a/language-support/js/daml-ledger/src/validation/ledger_configuration.ts b/language-support/js/daml-ledger/src/validation/ledger_configuration.ts deleted file mode 100644 index 1c42f1d210b..00000000000 --- a/language-support/js/daml-ledger/src/validation/ledger_configuration.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { Duration } from "./duration"; - -function required(): RequiredValidation { - return { - maxTtl: Duration, - minTtl: Duration - }; -} - -export const LedgerConfiguration: Validation = object('LedgerConfiguration', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/ledger_offset.ts b/language-support/js/daml-ledger/src/validation/ledger_offset.ts deleted file mode 100644 index e1b1ffc7e67..00000000000 --- a/language-support/js/daml-ledger/src/validation/ledger_offset.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { enumeration, native, union, Validation } from "./base"; - -function values(): Record { - return { - absolute: native('string'), - boundary: enumeration(ledger.LedgerOffset.Boundary, 'LedgerOffset.Boundary'), - }; -} - -export const LedgerOffset: Validation = union('LedgerOffset', values); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/list_packages_response.ts b/language-support/js/daml-ledger/src/validation/list_packages_response.ts deleted file mode 100644 index 4bc5db0fd39..00000000000 --- a/language-support/js/daml-ledger/src/validation/list_packages_response.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation, native, array } from "./base"; -import { RequiredValidation } from "./base/typelevel"; - -function required(): RequiredValidation { - return { - packageIds: array(native('string')) - }; -} - -export const ListPackagesResponse: Validation = object('ListPackagesResponse', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/optional.ts b/language-support/js/daml-ledger/src/validation/optional.ts deleted file mode 100644 index 770b511c3f6..00000000000 --- a/language-support/js/daml-ledger/src/validation/optional.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { OptionalValidation } from "./base/typelevel"; -import { Value } from "./value"; - -function optional(): OptionalValidation { - return { - value: Value - }; -} - -export const Optional: Validation = object('Optional', () => ({}), optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/package_status.ts b/language-support/js/daml-ledger/src/validation/package_status.ts deleted file mode 100644 index 11a8238a37f..00000000000 --- a/language-support/js/daml-ledger/src/validation/package_status.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { enumeration } from "./base"; - -export const PackageStatus = enumeration(ledger.PackageStatus, 'PackageStatus') \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/record.ts b/language-support/js/daml-ledger/src/validation/record.ts deleted file mode 100644 index e61d5eb27b3..00000000000 --- a/language-support/js/daml-ledger/src/validation/record.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { record } from "./base/record"; -import { OptionalValidation, RequiredValidation } from "./base/typelevel"; -import { Identifier } from "./identifier"; -import { Value } from './value'; - -function required(): RequiredValidation { - return { - fields: record(Value) - }; -} - -function optional(): OptionalValidation { - return { - recordId: Identifier - }; -} - -export const Record: Validation = object('Record', required, optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/set_time_request.ts b/language-support/js/daml-ledger/src/validation/set_time_request.ts deleted file mode 100644 index babe841f3bf..00000000000 --- a/language-support/js/daml-ledger/src/validation/set_time_request.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { Timestamp } from "./timestamp"; - -function required(): RequiredValidation { - return { - currentTime: Timestamp, - newTime: Timestamp, - }; -} - -export const SetTimeRequest: Validation = object('SetTimeRequest', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/status.ts b/language-support/js/daml-ledger/src/validation/status.ts deleted file mode 100644 index 2ab72ec68de..00000000000 --- a/language-support/js/daml-ledger/src/validation/status.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { Any } from "./any"; -import { array, native, object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; - -function required(): RequiredValidation { - return { - code: native('number'), - details: array(Any), - message: native('string') - }; -} - -export const Status: Validation = object('Status', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/submit_and_wait_request.ts b/language-support/js/daml-ledger/src/validation/submit_and_wait_request.ts deleted file mode 100644 index a75a4d0e5df..00000000000 --- a/language-support/js/daml-ledger/src/validation/submit_and_wait_request.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { Commands } from "./commands"; - -function required(): RequiredValidation { - return { - commands: Commands - }; -} - -export const SubmitAndWaitRequest: Validation = object('SubmitAndWaitRequest', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/submit_request.ts b/language-support/js/daml-ledger/src/validation/submit_request.ts deleted file mode 100644 index a484e9b2449..00000000000 --- a/language-support/js/daml-ledger/src/validation/submit_request.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; -import { Commands } from "./commands"; - -function required(): RequiredValidation { - return { - commands: Commands - }; -} - -export const SubmitRequest: Validation = object('SubmitRequest', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/timestamp.ts b/language-support/js/daml-ledger/src/validation/timestamp.ts deleted file mode 100644 index 04dc73ab541..00000000000 --- a/language-support/js/daml-ledger/src/validation/timestamp.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation } from "./base"; -import { RequiredValidation } from "./base/typelevel"; - -function required(): RequiredValidation { - return { - nanoseconds: native('number'), - seconds: native('number') - }; -} - -export const Timestamp: Validation = object('Timestamp', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/transaction.ts b/language-support/js/daml-ledger/src/validation/transaction.ts deleted file mode 100644 index 022ccd4df17..00000000000 --- a/language-support/js/daml-ledger/src/validation/transaction.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation, array } from "./base"; -import { RequiredValidation, OptionalValidation } from "./base/typelevel"; -import { Timestamp } from "./timestamp"; -import { Event } from "./event"; - -function required(): RequiredValidation { - return { - effectiveAt: Timestamp, - events: array(Event), - offset: native('string'), - transactionId: native('string') - }; -} - -function optional(): OptionalValidation { - return { - commandId: native('string'), - workflowId: native('string'), - }; -} - -export const Transaction: Validation = object('Transaction', required, optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/transaction_filter.ts b/language-support/js/daml-ledger/src/validation/transaction_filter.ts deleted file mode 100644 index 24a377d2616..00000000000 --- a/language-support/js/daml-ledger/src/validation/transaction_filter.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { object, Validation } from "./base"; -import { record } from "./base/record"; -import { RequiredValidation } from "./base/typelevel"; -import { Filters } from "./filters"; - -function required(): RequiredValidation { - return { - filtersByParty: record(Filters) - }; -} - -export const TransactionFilter: Validation = object('TransactionFilter', required, () => ({})); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/transaction_tree.ts b/language-support/js/daml-ledger/src/validation/transaction_tree.ts deleted file mode 100644 index 94a13fed99a..00000000000 --- a/language-support/js/daml-ledger/src/validation/transaction_tree.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation, array } from "./base"; -import { RequiredValidation, OptionalValidation } from "./base/typelevel"; -import { Timestamp } from "./timestamp"; -import { TreeEvent } from "./tree_event"; -import { record } from "./base/record"; - -function required(): RequiredValidation { - return { - effectiveAt: Timestamp, - eventsById: record(TreeEvent), - rootEventIds: array(native('string')), - offset: native('string'), - transactionId: native('string') - }; -} - -function optional(): OptionalValidation { - return { - commandId: native('string'), - workflowId: native('string'), - }; -} - -export const TransactionTree: Validation = object('TransactionTree', required, optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/tree_event.ts b/language-support/js/daml-ledger/src/validation/tree_event.ts deleted file mode 100644 index 56052c22462..00000000000 --- a/language-support/js/daml-ledger/src/validation/tree_event.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { union, Validation } from "./base"; -import * as ledger from ".."; -import { CreatedEvent } from "./created_event"; -import { ExercisedEvent } from "./exercised_event"; - -function values(): Record { - return { - created: CreatedEvent, - exercised: ExercisedEvent - }; -} - -export const TreeEvent: Validation = union("TreeEvent", values) \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/value.ts b/language-support/js/daml-ledger/src/validation/value.ts deleted file mode 100644 index 329d1d17b3a..00000000000 --- a/language-support/js/daml-ledger/src/validation/value.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { array, native, union, Validation } from "./base"; -import { Empty } from "./empty"; -import { Optional } from "./optional"; -import { Record } from "./record"; -import { Timestamp } from "./timestamp"; -import { Variant } from "./variant"; - -function values(): Record { - return { - bool: native('boolean'), - contractId: native('string'), - date: native('string'), - decimal: native('string'), - int64: native('string'), - list: array(Value), - party: native('string'), - record: Record, - text: native('string'), - timestamp: native('string'), - unit: Empty, - variant: Variant, - optional: Optional - }; -} - -export const Value: Validation = union('Value', values); \ No newline at end of file diff --git a/language-support/js/daml-ledger/src/validation/variant.ts b/language-support/js/daml-ledger/src/validation/variant.ts deleted file mode 100644 index 9f84bdabe81..00000000000 --- a/language-support/js/daml-ledger/src/validation/variant.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from ".."; -import { native, object, Validation } from "./base"; -import { Identifier } from "./identifier"; -import { Value } from './value' -import { RequiredValidation, OptionalValidation } from "./base/typelevel"; - -function required(): RequiredValidation { - return { - constructor: native('string'), - value: Value, - }; -} - -function optional(): OptionalValidation { - return { - variantId: Identifier, - }; -} - -export const Variant: Validation = object('Variant', required, optional); \ No newline at end of file diff --git a/language-support/js/daml-ledger/test.sh b/language-support/js/daml-ledger/test.sh deleted file mode 100755 index 943414dbaaa..00000000000 --- a/language-support/js/daml-ledger/test.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -set -ex - -export PATH=$PATH:external/nodejs/bin - -cp -LR external/npm/node_modules . - -# simulate `npm install daml-grpc` -- sh_test makes sure transitive deps are there -mkdir -p node_modules/daml-grpc -tar xzf language-support/js/daml-grpc/daml-grpc.tgz --strip-components=1 -C node_modules/daml-grpc - -# Resolve the symbolic link to have the test import statements point to -# the generated code folder so that the dependencies on generated code can -# be resolved -cp -LR language-support/js/daml-ledger/src . -cp -LR language-support/js/daml-ledger/tests . - -echo '{"compilerOptions":{"lib":["es2015"]}}' > tsconfig.json - -node_modules/mocha/bin/mocha -r ts-node/register --recursive 'tests/**/*.ts' \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/active_contracts_client.spec.ts b/language-support/js/daml-ledger/tests/active_contracts_client.spec.ts deleted file mode 100644 index bf3f9177e37..00000000000 --- a/language-support/js/daml-ledger/tests/active_contracts_client.spec.ts +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { test } from 'mocha'; -import { expect, assert } from 'chai'; -import { MockedActiveContractsServiceClient } from './mock'; -import * as grpc from 'daml-grpc'; -import * as ledger from '../src'; -import { reporting } from '../src'; -import * as mapping from '../src/mapping'; -import * as validation from '../src/validation'; -import * as client from '../src/client'; -import * as sinon from 'sinon'; - -describe("ActiveContractClient", () => { - - const ledgerId = 'some-ledger-id'; - const latestRequestSpy = sinon.spy(); - - afterEach(() => { - sinon.restore(); - latestRequestSpy.resetHistory(); - }); - - test('[1.2] Transaction filter and verbose flag are passed to the ledger', (done) => { - const response = new grpc.GetActiveContractsResponse(); - response.setOffset("10"); - const responses = [response]; - const acs = new MockedActiveContractsServiceClient(responses, latestRequestSpy); - const acc = new client.ActiveContractsClient(ledgerId, acs, reporting.JSONReporter); - const request = { - verbose: false, - filter: { - filtersByParty: { - alice: { inclusive: { templateIds: [{ packageId: 'packageId', moduleName: 'mod1', entityName: 'ent1' }] } } - } - } - }; - - const call = acc.getActiveContracts(request); - call.on('end', () => { - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(mapping.GetActiveContractsRequest.toObject(latestRequestSpy.lastCall.lastArg)).to.deep.equal(request); - done(); - }); - call.on('error', (error) => { - done(error); - }); - - }); - - test('[1.2] The verbose flag defaults to true when not specified', (done) => { - const response = new grpc.GetActiveContractsResponse(); - response.setOffset("10"); - const responses = [response]; - const acs = new MockedActiveContractsServiceClient(responses, latestRequestSpy); - const acc = new client.ActiveContractsClient(ledgerId, acs, reporting.JSONReporter); - const request = { - filter: { - filtersByParty: { - alice: { inclusive: { templateIds: [{ packageId: 'packageId', moduleName: 'mod1', entityName: 'ent1' }] } } - } - } - }; - - const call = acc.getActiveContracts(request); - call.on('end', () => { - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.GetActiveContractsRequest; - expect(spiedRequest.getVerbose()).to.be.true; - done(); - }); - call.on('error', (error) => { - done(error); - }); - - }); - - test("[1.3] ACS is requested with the correct ledger ID", (done) => { - const response = new grpc.GetActiveContractsResponse(); - response.setOffset("10"); - const responses = [response]; - const acs = new MockedActiveContractsServiceClient(responses, latestRequestSpy); - const acc = new client.ActiveContractsClient(ledgerId, acs, reporting.JSONReporter); - const request = { - verbose: true, - filter: { - filtersByParty: { - alice: { inclusive: { templateIds: [{ packageId: 'packageId', moduleName: 'mod1', entityName: 'ent1' }] } } - } - } - }; - - const call = acc.getActiveContracts(request); - call.on('end', () => { - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.GetActiveContractsRequest); - const request = latestRequestSpy.lastCall.lastArg as grpc.GetActiveContractsRequest; - expect(request.getLedgerId()).to.equal(ledgerId); - done(); - }); - call.on('error', (error) => { - done(error); - }); - - }); - - test('Validation: an ill-formed message does not pass validation (getActiveContracts)', (done) => { - - const response = new grpc.GetActiveContractsResponse(); - response.setOffset("10"); - const responses = [response]; - const acs = new MockedActiveContractsServiceClient(responses, latestRequestSpy); - const acc = new client.ActiveContractsClient(ledgerId, acs, reporting.JSONReporter); - - const invalidRequest = { - filter: { - filtersByarty: { - barbara: { - inclusive: {} - } - } - } - }; - - const expectedValidationTree: validation.Tree = { - errors: [], - children: { - filter: { - errors: [{ - kind: 'missing-key', - expectedKey: 'filtersByParty', - expectedType: 'Record' - }, { - kind: 'unexpected-key', - key: 'filtersByarty' - }], - children: {} - } - } - }; - - let passed = false; - const call = acc.getActiveContracts(invalidRequest as any as ledger.GetActiveContractsRequest); - call.on('data', (_data) => { - done(new Error('unexpected data received')); - }); - call.on('error', (error) => { - expect(JSON.parse(error.message)).to.deep.equal(expectedValidationTree); - passed = true; - }); - call.on('end', () => { - assert(passed); - done(); - }); - - }); - -}); diff --git a/language-support/js/daml-ledger/tests/arbitrary/any.ts b/language-support/js/daml-ledger/tests/arbitrary/any.ts deleted file mode 100644 index a1a01f6bc6c..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/any.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const Any: jsc.Arbitrary = - jsc.pair(jsc.string, jsc.string).smap( - ([typeUrl, value]) => { - return { - typeUrl: typeUrl, - value: value - } - }, - (any) => { - return [any.typeUrl, any.typeUrl] - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/checkpoint.ts b/language-support/js/daml-ledger/tests/arbitrary/checkpoint.ts deleted file mode 100644 index b7c81a8c152..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/checkpoint.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { LedgerOffset } from './ledger_offset'; -import { Timestamp } from './timestamp'; - -export const Checkpoint: jsc.Arbitrary = - jsc.pair(LedgerOffset, Timestamp).smap( - ([offset, recordTime]) => { - return { - offset: offset, - recordTime: recordTime - } - }, - (checkpoint) => { - return [checkpoint.offset, checkpoint.recordTime] - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/command.ts b/language-support/js/daml-ledger/tests/arbitrary/command.ts deleted file mode 100644 index 92a3c1349d5..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/command.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { CreateCommand } from './create_command'; -import { ExerciseCommand } from './exercise_command'; - -const Create: jsc.Arbitrary = - CreateCommand.smap<{ create: ledger.CreateCommand }>( - create => ({ create: create }), - command => command.create - ); -const Exercise: jsc.Arbitrary = - ExerciseCommand.smap<{ exercise: ledger.ExerciseCommand }>( - exercise => ({ exercise: exercise }), - command => command.exercise - ); - -export const Command: jsc.Arbitrary = jsc.oneof([Create, Exercise]); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/commands.ts b/language-support/js/daml-ledger/tests/arbitrary/commands.ts deleted file mode 100644 index eee184c1fc4..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/commands.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Command } from './command'; -import { maybe } from './maybe'; -import { Timestamp } from './timestamp'; - -export const Commands: jsc.Arbitrary = - jsc.tuple([jsc.string, jsc.string, Timestamp, jsc.array(Command), Timestamp, jsc.string, maybe(jsc.string)]).smap( - ([applicationId, commandId, ledgerEffectiveTime, list, maximumRecordTime, party, workflowId]) => ({ - applicationId: applicationId, - commandId: commandId, - ledgerEffectiveTime: ledgerEffectiveTime, - list: list, - maximumRecordTime: maximumRecordTime, - party: party, - workflowId: workflowId - }), - (commands) => - [commands.applicationId, commands.commandId, commands.ledgerEffectiveTime, commands.list, commands.maximumRecordTime, commands.party, commands.workflowId] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/completion.ts b/language-support/js/daml-ledger/tests/arbitrary/completion.ts deleted file mode 100644 index bc312767907..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/completion.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { maybe } from './maybe'; -import { Status } from './status'; - -export const Completion: jsc.Arbitrary = - jsc.pair(jsc.string, maybe(Status)).smap( - ([commandId, status]) => ({ - commandId: commandId, - status: status - }) - , - (completion) => - [completion.commandId, completion.status] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/completion_end_response.ts b/language-support/js/daml-ledger/tests/arbitrary/completion_end_response.ts deleted file mode 100644 index 725636febd0..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/completion_end_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { LedgerOffset } from './ledger_offset'; - -export const CompletionEndResponse: jsc.Arbitrary = - LedgerOffset.smap( - offset => ({ - offset: offset, - }), - request => - request.offset - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/completion_stream_request.ts b/language-support/js/daml-ledger/tests/arbitrary/completion_stream_request.ts deleted file mode 100644 index 68219caddbe..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/completion_stream_request.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { LedgerOffset } from './ledger_offset'; - -export const CompletionStreamRequest: jsc.Arbitrary = - jsc.tuple([jsc.string, LedgerOffset, jsc.array(jsc.string)]).smap( - ([applicationId, offset, parties]) => ({ - applicationId: applicationId, - offset: offset, - parties: parties - }), - (request) => - [request.applicationId, request.offset, request.parties] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/completion_stream_response.ts b/language-support/js/daml-ledger/tests/arbitrary/completion_stream_response.ts deleted file mode 100644 index 18a80221d1c..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/completion_stream_response.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Checkpoint } from './checkpoint'; -import { Completion } from './completion'; -import { maybe } from './maybe'; - -export const CompletionStreamResponse: jsc.Arbitrary = - jsc.pair(maybe(Checkpoint), maybe(jsc.array(Completion))).smap( - ([checkpoint, completions]) => ({ - checkpoint: checkpoint, - completions: completions - }), - (request) => - [request.checkpoint, request.completions] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/create_command.ts b/language-support/js/daml-ledger/tests/arbitrary/create_command.ts deleted file mode 100644 index 48319adad29..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/create_command.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Record } from './record_value_variant'; -import { Identifier } from './identifier'; - -export const CreateCommand: jsc.Arbitrary = - jsc.pair(Record, Identifier).smap( - ([args, templateId]) => ({ - arguments: args, - templateId: templateId - }), - (createCommand) => - [createCommand.arguments, createCommand.templateId] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/duration.ts b/language-support/js/daml-ledger/tests/arbitrary/duration.ts deleted file mode 100644 index de6ac0b24da..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/duration.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const Duration: jsc.Arbitrary = - jsc.pair(jsc.number, jsc.number).smap( - ([seconds, nanoseconds]) => { - return { - seconds: seconds, - nanoseconds: nanoseconds - } - }, - (timestamp) => { - return [timestamp.seconds, timestamp.nanoseconds] - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/empty.ts b/language-support/js/daml-ledger/tests/arbitrary/empty.ts deleted file mode 100644 index 0522d0222d9..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/empty.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -// Can't use jsc.constant: we are going to mutate the object for test purposes and `constant` returns always the same instance -export const Empty: jsc.Arbitrary = jsc.bless({ generator: jsc.generator.bless(() => ({})) }); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/event.ts b/language-support/js/daml-ledger/tests/arbitrary/event.ts deleted file mode 100644 index 82077787681..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/event.ts +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Identifier } from './identifier'; -import { Record, Value } from './record_value_variant'; -import { maybe } from './maybe'; - -export const ArchivedEvent: jsc.Arbitrary = - jsc.tuple([jsc.string, jsc.string, Identifier, jsc.array(jsc.string)]).smap( - ([contractId, eventId, templateId, witnessParties]) => { - return { - contractId: contractId, - eventId: eventId, - templateId: templateId, - witnessParties: witnessParties - } - }, - (archivedEvent) => { - return [archivedEvent.contractId, archivedEvent.eventId, archivedEvent.templateId, archivedEvent.witnessParties] - } - ); - -export const CreatedEvent: jsc.Arbitrary = - jsc.tuple([jsc.string, jsc.string, Identifier, Record, jsc.array(jsc.string)]).smap( - ([contractId, eventId, templateId, args, witnessParties]) => { - return { - contractId: contractId, - eventId: eventId, - templateId: templateId, - arguments: args, - witnessParties: witnessParties - } - }, - (createdEvent) => { - return [createdEvent.contractId, createdEvent.eventId, createdEvent.templateId, createdEvent.arguments, createdEvent.witnessParties] - } - ); - -export const ExercisedEvent: jsc.Arbitrary = - jsc.tuple([jsc.array(jsc.string), maybe(jsc.array(jsc.string)), jsc.string, Value, jsc.bool, jsc.string, jsc.string, jsc.string, Identifier, jsc.array(jsc.string)]).smap( - ([actingParties, childEventIds, choice, argument, consuming, contractCreatingEventId, contractId, eventId, templateId, witnessParties]) => ({ - actingParties: actingParties, - childEventIds: childEventIds, - choice: choice, - argument: argument, - consuming: consuming, - contractCreatingEventId: contractCreatingEventId, - contractId: contractId, - eventId: eventId, - templateId: templateId, - witnessParties: witnessParties - }), (exercisedEvent) => - [ - exercisedEvent.actingParties, - exercisedEvent.childEventIds, - exercisedEvent.choice, - exercisedEvent.argument, - exercisedEvent.consuming, - exercisedEvent.contractCreatingEventId, - exercisedEvent.contractId, - exercisedEvent.eventId, - exercisedEvent.templateId, - exercisedEvent.witnessParties - ] - ); - -const Archived: jsc.Arbitrary = - ArchivedEvent.smap<{ archived: ledger.ArchivedEvent }>( - archived => ({ archived: archived }), - event => event.archived - ); -const Created: jsc.Arbitrary = - CreatedEvent.smap<{ created: ledger.CreatedEvent }>( - created => ({ created: created }), - event => event.created - ); -const Exercised: jsc.Arbitrary = - ExercisedEvent.smap<{ exercised: ledger.ExercisedEvent }>( - exercised => ({ exercised: exercised }), - event => event.exercised - ); - -export const Event = jsc.oneof([Archived, Created, Exercised]); -export const TreeEvent = jsc.oneof([Created, Exercised]); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/exercise_command.ts b/language-support/js/daml-ledger/tests/arbitrary/exercise_command.ts deleted file mode 100644 index f03916b81cf..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/exercise_command.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Value } from './record_value_variant'; -import { Identifier } from './identifier'; - -export const ExerciseCommand: jsc.Arbitrary = - jsc.tuple([Value, jsc.string, jsc.string, Identifier]).smap( - ([args, choice, contractId, templateId]) => ({ - argument: args, - choice: choice, - contractId: contractId, - templateId: templateId - }), - (exerciseCommand) => - [exerciseCommand.argument, exerciseCommand.choice, exerciseCommand.contractId, exerciseCommand.templateId] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/filters.ts b/language-support/js/daml-ledger/tests/arbitrary/filters.ts deleted file mode 100644 index 2f926a48578..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/filters.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as ledger from '../../src'; - -import * as jsc from 'jsverify'; -import { InclusiveFilters } from './inclusive_filters'; -import { maybe } from './maybe'; - -export const Filters: jsc.Arbitrary = - maybe(InclusiveFilters).smap( - (inclusive) => { - return inclusive ? { inclusive: inclusive } : {}; - }, - (filters) => { - return filters.inclusive - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_active_contracts_request.ts b/language-support/js/daml-ledger/tests/arbitrary/get_active_contracts_request.ts deleted file mode 100644 index a970756c994..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_active_contracts_request.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { maybe } from './maybe'; -import { TransactionFilter } from './transaction_filter'; - -export const GetActiveContractsRequest: jsc.Arbitrary = - jsc.tuple([TransactionFilter, maybe(jsc.bool)]).smap( - ([filter, verbose]) => { - const request: ledger.GetActiveContractsRequest = { - filter: filter - } - if (verbose) { - request.verbose = verbose; - } - return request; - }, - (request) => { - return [request.filter, request.verbose]; - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_active_contracts_response.ts b/language-support/js/daml-ledger/tests/arbitrary/get_active_contracts_response.ts deleted file mode 100644 index 7b4ec2effd5..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_active_contracts_response.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { CreatedEvent } from './event'; -import { LedgerOffset } from './ledger_offset'; -import { maybe } from './maybe'; - -export const GetActiveContractsResponse: jsc.Arbitrary = - jsc.tuple([LedgerOffset, maybe(jsc.string), maybe(jsc.array(CreatedEvent))]).smap( - ([offset, workflowId, activeContracts]) => { - const request: ledger.GetActiveContractsResponse = { - offset: offset - } - if (workflowId) { - request.workflowId = workflowId; - } - if (activeContracts) { - request.activeContracts = activeContracts; - } - return request; - }, - (request) => { - return [request.offset, request.workflowId, request.activeContracts]; - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_ledger_configuration_response.ts b/language-support/js/daml-ledger/tests/arbitrary/get_ledger_configuration_response.ts deleted file mode 100644 index 2f1b82a892a..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_ledger_configuration_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { LedgerConfiguration } from './ledger_configuration'; - -export const GetLedgerConfigurationResponse: jsc.Arbitrary = - LedgerConfiguration.smap( - config => ({ - config: config, - }), - request => - request.config - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_ledger_end_response.ts b/language-support/js/daml-ledger/tests/arbitrary/get_ledger_end_response.ts deleted file mode 100644 index 6c7dc4a8407..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_ledger_end_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { LedgerOffset } from './ledger_offset'; - -export const GetLedgerEndResponse: jsc.Arbitrary = - LedgerOffset.smap( - offset => ({ - offset: offset, - }), - request => - request.offset - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_ledger_identity_response.ts b/language-support/js/daml-ledger/tests/arbitrary/get_ledger_identity_response.ts deleted file mode 100644 index 2a029e7e3ad..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_ledger_identity_response.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const GetLedgerIdentityResponse: jsc.Arbitrary = - jsc.string.smap( - ledgerId => ({ - ledgerId: ledgerId, - }), - request => - request.ledgerId - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_package_response.ts b/language-support/js/daml-ledger/tests/arbitrary/get_package_response.ts deleted file mode 100644 index 8338297b476..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_package_response.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const GetPackageResponse: jsc.Arbitrary = - jsc.tuple([jsc.elements([ledger.HashFunction.SHA256]), jsc.string, jsc.string]).smap( - ([hashFunction, hash, archivePayload]) => { - return { - hashFunction: hashFunction, - hash: hash, - archivePayload: archivePayload - } - }, - (request) => { - return [request.hashFunction, request.hash, request.archivePayload]; - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_package_status_response.ts b/language-support/js/daml-ledger/tests/arbitrary/get_package_status_response.ts deleted file mode 100644 index 71f1b515865..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_package_status_response.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const GetPackageStatusResponse: jsc.Arbitrary = - jsc.elements([ledger.PackageStatus.REGISTERED, ledger.PackageStatus.UNKNOWN]).smap( - status => ({ - status: status, - }), - request => - request.status - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_time_response.ts b/language-support/js/daml-ledger/tests/arbitrary/get_time_response.ts deleted file mode 100644 index 86d8947894a..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_time_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Timestamp } from './timestamp'; - -export const GetTimeResponse: jsc.Arbitrary = - Timestamp.smap( - currentTime => ({ - currentTime: currentTime, - }), - request => - request.currentTime - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_transaction_by_event_id_request.ts b/language-support/js/daml-ledger/tests/arbitrary/get_transaction_by_event_id_request.ts deleted file mode 100644 index acc9d0f932f..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_transaction_by_event_id_request.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const GetTransactionByEventIdRequest: jsc.Arbitrary = - jsc.tuple([jsc.string, jsc.array(jsc.string)]).smap( - ([eventId, requestingParties]) => ({ - eventId: eventId, - requestingParties: requestingParties - }), - (request) => - [request.eventId, request.requestingParties] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_transaction_by_id_request.ts b/language-support/js/daml-ledger/tests/arbitrary/get_transaction_by_id_request.ts deleted file mode 100644 index d68248a534f..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_transaction_by_id_request.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const GetTransactionByIdRequest: jsc.Arbitrary = - jsc.tuple([jsc.string, jsc.array(jsc.string)]).smap( - ([transactionId, requestingParties]) => ({ - transactionId: transactionId, - requestingParties: requestingParties - }), - (request) => - [request.transactionId, request.requestingParties] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_transaction_response.ts b/language-support/js/daml-ledger/tests/arbitrary/get_transaction_response.ts deleted file mode 100644 index 4fd10dad00f..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_transaction_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { TransactionTree } from './transaction_tree'; - -export const GetTransactionResponse: jsc.Arbitrary = - TransactionTree.smap( - transaction => ({ - transaction: transaction, - }), - request => - request.transaction - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_transaction_trees_response.ts b/language-support/js/daml-ledger/tests/arbitrary/get_transaction_trees_response.ts deleted file mode 100644 index 867eb9b95fe..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_transaction_trees_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { TransactionTree } from './transaction_tree'; - -export const GetTransactionTreesResponse: jsc.Arbitrary = - jsc.array(TransactionTree).smap( - transactions => ({ - transactions: transactions, - }), - request => - request.transactions - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_transactions_request.ts b/language-support/js/daml-ledger/tests/arbitrary/get_transactions_request.ts deleted file mode 100644 index 48bb1212ff7..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_transactions_request.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { LedgerOffset } from './ledger_offset'; -import { maybe } from './maybe'; -import { TransactionFilter } from './transaction_filter'; - -export const GetTransactionsRequest: jsc.Arbitrary = - jsc.tuple([LedgerOffset, maybe(LedgerOffset), TransactionFilter, maybe(jsc.bool)]).smap( - ([begin, end, filter, verbose]) => { - const request: ledger.GetTransactionsRequest = { - begin: begin, - filter: filter - } - if (end) { - request.end = end; - } - if (verbose !== undefined) { - request.verbose = verbose; - } - return request; - }, - (request) => { - return [request.begin, request.end, request.filter, request.verbose]; - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/get_transactions_response.ts b/language-support/js/daml-ledger/tests/arbitrary/get_transactions_response.ts deleted file mode 100644 index be192bb7b82..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/get_transactions_response.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Transaction } from './transaction'; - -export const GetTransactionsResponse: jsc.Arbitrary = - jsc.array(Transaction).smap( - transactions => ({ - transactions: transactions, - }), - request => - request.transactions - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/identifier.ts b/language-support/js/daml-ledger/tests/arbitrary/identifier.ts deleted file mode 100644 index c3f7e42549b..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/identifier.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const Identifier: jsc.Arbitrary = - jsc.tuple([jsc.string, jsc.string, jsc.string]).smap( - ([packageId, moduleName, entityName]) => { - return { - packageId: packageId, - moduleName: moduleName, - entityName: entityName - } - }, - (identifier) => { - return [identifier.packageId, identifier.moduleName, identifier.entityName] - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/inclusive_filters.ts b/language-support/js/daml-ledger/tests/arbitrary/inclusive_filters.ts deleted file mode 100644 index 5a3a020e125..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/inclusive_filters.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -import { Identifier } from './identifier'; - -export const InclusiveFilters: jsc.Arbitrary = - jsc.array(Identifier).smap( - (templateIds) => { - return { - templateIds: templateIds - } - }, - (inclusiveFilters) => { - return inclusiveFilters.templateIds - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/index.ts b/language-support/js/daml-ledger/tests/arbitrary/index.ts deleted file mode 100644 index 86d817e835f..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/index.ts +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -export { Identifier } from './identifier'; -export { InclusiveFilters } from './inclusive_filters'; -export { Filters } from './filters'; -export { LedgerOffset } from './ledger_offset'; -export { TransactionFilter } from './transaction_filter'; -export { GetTransactionsRequest } from './get_transactions_request'; -export { Any } from './any'; -export { Timestamp } from './timestamp'; -export { Checkpoint } from './checkpoint'; -export { Empty } from './empty'; -export { Record, Value, Variant } from './record_value_variant'; -export { CreateCommand } from './create_command'; -export { ExerciseCommand } from './exercise_command'; -export { Command } from './command'; -export { Commands } from './commands'; -export { Status } from './status'; -export { Completion } from './completion'; -export { Duration } from './duration'; -export { TreeEvent, Event, ArchivedEvent, CreatedEvent, ExercisedEvent } from './event'; -export { LedgerConfiguration } from './ledger_configuration'; -export { Transaction } from './transaction'; -export { TransactionTree } from './transaction_tree'; -export { GetActiveContractsRequest } from './get_active_contracts_request'; -export { GetActiveContractsResponse } from './get_active_contracts_response'; -export { SubmitAndWaitRequest } from './submit_and_wait_request'; -export { CompletionEndResponse } from './completion_end_response'; -export { CompletionStreamRequest } from './completion_stream_request'; -export { CompletionStreamResponse } from './completion_stream_response'; -export { SubmitRequest } from './submit_request'; -export { GetLedgerConfigurationResponse } from './get_ledger_configuration_response'; -export { GetLedgerIdentityResponse } from './get_ledger_identity_response'; -export { GetPackageResponse } from './get_package_response'; -export { GetPackageStatusResponse } from './get_package_status_response'; -export { ListPackagesResponse } from './list_packages_response'; -export { GetTimeResponse } from './get_time_response'; -export { SetTimeRequest } from './set_time_request'; -export { GetLedgerEndResponse } from './get_ledger_end_response'; -export { GetTransactionByEventIdRequest } from './get_transaction_by_event_id_request'; -export { GetTransactionByIdRequest } from './get_transaction_by_id_request'; -export { GetTransactionResponse } from './get_transaction_response'; -export { GetTransactionsResponse } from './get_transactions_response'; -export { GetTransactionTreesResponse } from './get_transaction_trees_response'; -export { Optional } from './optional'; \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/ledger_configuration.ts b/language-support/js/daml-ledger/tests/arbitrary/ledger_configuration.ts deleted file mode 100644 index f3530d3c75b..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/ledger_configuration.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Duration } from './duration'; - -export const LedgerConfiguration: jsc.Arbitrary = - jsc.pair(Duration, Duration).smap( - ([maxTtl, minTtl]) => { - return { - maxTtl: maxTtl, - minTtl: minTtl - } - }, - (ledgerConfiguration) => { - return [ledgerConfiguration.maxTtl, ledgerConfiguration.minTtl] - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/ledger_offset.ts b/language-support/js/daml-ledger/tests/arbitrary/ledger_offset.ts deleted file mode 100644 index c8125a8c25b..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/ledger_offset.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const LedgerOffset: jsc.Arbitrary = - jsc.oneof([jsc.elements([ledger.LedgerOffset.Boundary.BEGIN, ledger.LedgerOffset.Boundary.END]), jsc.string]).smap( - (value) => { - if (typeof value === 'string') { - return { - absolute: value - } - } else { - return { - boundary: value - } - } - }, - (ledgerOffset) => { - if (ledgerOffset.absolute !== undefined) { - return ledgerOffset.absolute; - } else if (ledgerOffset.boundary !== undefined) { - return ledgerOffset.boundary; - } else { - throw new Error('one of the cases must be defined'); - } - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/list_packages_response.ts b/language-support/js/daml-ledger/tests/arbitrary/list_packages_response.ts deleted file mode 100644 index c6988eaa61d..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/list_packages_response.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const ListPackagesResponse: jsc.Arbitrary = - jsc.array(jsc.string).smap( - packageIds => ({ - packageIds: packageIds, - }), - request => - request.packageIds - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/maybe.ts b/language-support/js/daml-ledger/tests/arbitrary/maybe.ts deleted file mode 100644 index 42222211e06..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/maybe.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; - -export function maybe(arbitrary: jsc.Arbitrary): jsc.Arbitrary { - return jsc.oneof([arbitrary, jsc.constant(undefined)]); -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/optional.ts b/language-support/js/daml-ledger/tests/arbitrary/optional.ts deleted file mode 100644 index ba0dba71866..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/optional.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Value } from './record_value_variant'; -import { maybe } from './maybe' - -export const Optional: jsc.Arbitrary = - maybe(Value).smap( - value => ({ - value: value, - }), - request => - request.value - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/record_value_variant.ts b/language-support/js/daml-ledger/tests/arbitrary/record_value_variant.ts deleted file mode 100644 index a6ac56db5b8..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/record_value_variant.ts +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Identifier } from './identifier'; -import { maybe } from './maybe'; -import { Empty } from './empty'; - -declare module 'jsverify' { - function letrec(tie: (f: (key: string) => jsc.Arbitrary) => { [key: string]: jsc.Arbitrary }): { [key: string]: jsc.Arbitrary } -} - -const BoolValue: jsc.Arbitrary = - jsc.bool.smap<{ bool: boolean }>( - boolean => ({ bool: boolean }), - value => value.bool - ); -const ContractIdValue: jsc.Arbitrary = - jsc.string.smap<{ contractId: string }>( - string => ({ contractId: string }), - value => value.contractId - ); -const DateValue: jsc.Arbitrary = - jsc.string.smap<{ date: string }>( - number => ({ date: number }), - value => value.date - ); -const DecimalValue: jsc.Arbitrary = - jsc.string.smap<{ decimal: string }>( - string => ({ decimal: string }), - value => value.decimal - ); -const Int64Value: jsc.Arbitrary = - jsc.string.smap<{ int64: string }>( - number => ({ int64: number }), - value => value.int64 - ); -const PartyValue: jsc.Arbitrary = - jsc.string.smap<{ party: string }>( - string => ({ party: string }), - value => value.party - ); -const TextValue: jsc.Arbitrary = - jsc.string.smap<{ text: string }>( - string => ({ text: string }), - value => value.text - ); -const TimestampValue: jsc.Arbitrary = - jsc.string.smap<{ timestamp: string }>( - string => ({ timestamp: string }), - value => value.timestamp - ); -const UnitValue: jsc.Arbitrary = - Empty.smap<{ unit: ledger.Empty }>( - empty => ({ unit: empty }), - value => value.unit - ); - -const { Record: record, Value: value, Variant: variant }: { [key: string]: jsc.Arbitrary } = - jsc.letrec(tie => ({ - ListValue: jsc.array(tie('Value') as jsc.Arbitrary).smap<{ list: ledger.Value[] }>( - list => ({ list: list }), - value => value.list - ), - Record: jsc.pair(maybe(Identifier), jsc.dict(tie('Value') as jsc.Arbitrary)).smap( - ([recordId, fields]) => { - const record: ledger.Record = { - fields: fields - }; - if (recordId) { - record.recordId = recordId; - } - return record; - }, - (record) => { - return [record.recordId, record.fields] - } - ), - RecordValue: (tie('Record') as jsc.Arbitrary).smap<{ record: ledger.Record }>( - record => ({ record: record }), - value => value.record - ), - VariantValue: (tie('Variant') as jsc.Arbitrary).smap<{ variant: ledger.Variant }>( - variant => ({ variant: variant }), - value => value.variant - ), - Value: jsc.oneof([ - BoolValue, - ContractIdValue, - DateValue, - DecimalValue, - Int64Value, - tie('ListValue'), - PartyValue, - tie('RecordValue'), - TextValue, - TimestampValue, - UnitValue, - tie('VariantValue') - ]), - Variant: jsc.tuple([jsc.string, tie('Value') as jsc.Arbitrary, maybe(Identifier)]).smap( - ([constructor, value, variantId]) => { - const variant: ledger.Variant = { - constructor: constructor, - value: value - }; - if (variantId) { - variant.variantId = variantId; - } - return variant; - }, - (variant) => { - return [variant.constructor, variant.value, variant.variantId] - } - ) - })); - - export const Record = record as jsc.Arbitrary; - export const Value = value as jsc.Arbitrary; - export const Variant = variant as jsc.Arbitrary; diff --git a/language-support/js/daml-ledger/tests/arbitrary/set_time_request.ts b/language-support/js/daml-ledger/tests/arbitrary/set_time_request.ts deleted file mode 100644 index c9a75ff0385..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/set_time_request.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Timestamp } from './timestamp'; - -export const SetTimeRequest: jsc.Arbitrary = - jsc.tuple([Timestamp, Timestamp]).smap( - ([currentTime, newTime]) => ({ - currentTime: currentTime, - newTime: newTime, - }), - (request) => - [request.currentTime, request.newTime] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/status.ts b/language-support/js/daml-ledger/tests/arbitrary/status.ts deleted file mode 100644 index 50fcb3142b9..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/status.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Any } from './any'; - -export const Status: jsc.Arbitrary = - jsc.tuple([jsc.number, jsc.array(Any), jsc.string]).smap( - ([code, details, message]) => ({ - code: code, - details: details, - message: message - }), - status => - [status.code, status.details, status.message] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/submit_and_wait_request.ts b/language-support/js/daml-ledger/tests/arbitrary/submit_and_wait_request.ts deleted file mode 100644 index 95a45c32f40..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/submit_and_wait_request.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Commands } from './commands'; - -export const SubmitAndWaitRequest: jsc.Arbitrary = - Commands.smap( - commands => ({ - commands: commands, - }), - request => - request.commands - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/submit_request.ts b/language-support/js/daml-ledger/tests/arbitrary/submit_request.ts deleted file mode 100644 index 5c5cd54e517..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/submit_request.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Commands } from './commands'; - -export const SubmitRequest: jsc.Arbitrary = - Commands.smap( - commands => ({ - commands: commands, - }), - request => - request.commands - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/timestamp.ts b/language-support/js/daml-ledger/tests/arbitrary/timestamp.ts deleted file mode 100644 index 95158022513..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/timestamp.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; - -export const Timestamp: jsc.Arbitrary = - jsc.pair(jsc.number, jsc.number).smap( - ([seconds, nanoseconds]) => { - return { - seconds: seconds, - nanoseconds: nanoseconds - } - }, - (timestamp) => { - return [timestamp.seconds, timestamp.nanoseconds] - } - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/transaction.ts b/language-support/js/daml-ledger/tests/arbitrary/transaction.ts deleted file mode 100644 index b190941c997..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/transaction.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Timestamp } from './timestamp'; -import { Event } from './event'; -import { maybe } from './maybe'; - -export const Transaction: jsc.Arbitrary = - jsc.tuple([maybe(jsc.string), Timestamp, jsc.array(Event), jsc.string, jsc.string, maybe(jsc.string)]).smap( - ([commandId, effectiveAt, events, offset, transactionId, workflowId]) => { - const transaction: ledger.Transaction = { - effectiveAt: effectiveAt, - events: events, - offset: offset, - transactionId: transactionId - } - if (commandId) { - transaction.commandId = commandId; - } - if (workflowId) { - transaction.workflowId = workflowId; - } - return transaction; - }, - (transaction) => - [transaction.commandId, transaction.effectiveAt, transaction.events, transaction.offset, transaction.transactionId, transaction.workflowId] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/transaction_filter.ts b/language-support/js/daml-ledger/tests/arbitrary/transaction_filter.ts deleted file mode 100644 index 65310a14f0a..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/transaction_filter.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Filters } from './filters'; - -export const TransactionFilter: jsc.Arbitrary = - jsc.dict(Filters).smap( - (filtersByParty) => { - return { - filtersByParty: filtersByParty - } - }, - (transactionFilter) => - transactionFilter.filtersByParty - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/arbitrary/transaction_tree.ts b/language-support/js/daml-ledger/tests/arbitrary/transaction_tree.ts deleted file mode 100644 index d5f96e19a59..00000000000 --- a/language-support/js/daml-ledger/tests/arbitrary/transaction_tree.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as ledger from '../../src'; -import { Timestamp } from './timestamp'; -import { TreeEvent } from './event'; -import { maybe } from './maybe'; - -export const TransactionTree: jsc.Arbitrary = - jsc.tuple([maybe(jsc.string), Timestamp, jsc.dict(TreeEvent), jsc.array(jsc.string), jsc.string, jsc.string, maybe(jsc.string)]).smap( - ([commandId, effectiveAt, eventsById, rootEventsId, offset, transactionId, workflowId]) => { - const transactionTree: ledger.TransactionTree = { - effectiveAt: effectiveAt, - eventsById: eventsById, - rootEventIds: rootEventsId, - offset: offset, - transactionId: transactionId - } - if (commandId) { - transactionTree.commandId = commandId; - } - if (workflowId) { - transactionTree.workflowId = workflowId; - } - return transactionTree; - }, - (transactionTree) => - [ - transactionTree.commandId, - transactionTree.effectiveAt, - transactionTree.eventsById, - transactionTree.rootEventIds, - transactionTree.offset, - transactionTree.transactionId, - transactionTree.workflowId - ] - ); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/certs/ca.crt b/language-support/js/daml-ledger/tests/certs/ca.crt deleted file mode 100644 index 050ce4b0a47..00000000000 --- a/language-support/js/daml-ledger/tests/certs/ca.crt +++ /dev/null @@ -1,32 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFgzCCA2ugAwIBAgIJAKVNuQuez/v2MA0GCSqGSIb3DQEBCwUAMFgxCzAJBgNV -BAYTAkNMMQswCQYDVQQIDAJSTTERMA8GA1UEBwwIU2FudGlhZ28xDTALBgNVBAoM -BFRlc3QxDTALBgNVBAsMBFRlc3QxCzAJBgNVBAMMAmNhMB4XDTE4MTEyMTA4MzYz -N1oXDTE5MTEyMTA4MzYzN1owWDELMAkGA1UEBhMCQ0wxCzAJBgNVBAgMAlJNMREw -DwYDVQQHDAhTYW50aWFnbzENMAsGA1UECgwEVGVzdDENMAsGA1UECwwEVGVzdDEL -MAkGA1UEAwwCY2EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDFbZP2 -A9ezreax8E1gXF7tH5FGlGTsogZ+cyi9ZMgWoS4P1G/7b0h9ialD7gyH/n0qGpHV -Tllg10rO8Q5l0mdRrK3gTs71ahAdc7xiDYWKCv18GOGZhQkXdmf1V38CrVFlBXP8 -aERQmT2JYg8WapWmOg98Oew7VuasUEwk4hAi4MmHHBOKLrQDb7tQW4VpwXwVaZ5+ -5h4nShL0GioErLHxiOfNHusD0AYWUv3TdPCt9WCuGc/hZOwolpLx1AmpzuH/Dtg8 -NlkKBwuG5eVhGLMgwpdY4XWHDKxKXE8D2nJyY3nZ3jQN6NVYCs1JgQkaj6l6HtLX -xCe2mQEbng1KbG52kSijykJg2k9/Hevn8RrORIw67crhNG2osKa97Tk4EdH7hmAn -FHrl/VJYqcgQlQCiKC2Tv+o3hLOUmdqFxjGVsVffu/kob8j2m/Wi2kOEooX/leCB -hZ8ydCIJg/88ETB9pKxiX8IM4qNPscG06vftx/gb+3loUBCxg0kc5LaupYLGZj21 -PEzQdQWHcI7dg0vMojTbLpEOppbn5AMJB/1nzErJ1mZogwEnp37BDj3Z80h9qWCq -Q+cxKGShg1ToM/ZUp4CUpmllXCtzmEJxMc+ejkHXmTtrHnVQyN07qyZK3g4kjNdf -4+tYXCfqg+Y54KSo4pZNM4eRFremBGytgiRVJQIDAQABo1AwTjAdBgNVHQ4EFgQU -bAnJaxLRN20GkNoBrqD2D17HlaswHwYDVR0jBBgwFoAUbAnJaxLRN20GkNoBrqD2 -D17HlaswDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAVrcYwd5TBmuD -idvNS2jfIoZ+eixuZGDy/hDvb76ZcoWOYw1okq1RodCqP2LK12dzpsAoS5wlfDNh -ATGnLVDWn31JgxZOpt+UtttWjeVjtevUEV+9vSQnyRvQISoAgKDoMvdK8aDZD34+ -8pvW6cozbgkXCT8VIDiL7EXa94eHSVpNn3QhCpxZaFowAHi+FbCUkdCNcy0eu0Xl -yB97e89CSBp9ULJDJIsfSHkduLYXgrZZLG8fDbNKFutA/0kQvV4Z/z+25U+qDmja -cfv9+xYY7yBc3eWgINELYRfkfrA/9h1vXbqP+vf58XFlNeSFq1mEuU5KfrF7P3sZ -nm6is72qD8wPT/28s771K4VuIaByqdJ/qrmFD7KpSiEMWoei36qcCH2RNNALIxE/ -T4hBNGb+YQjkYC+t+EEkPI2LfUwKCA6mLrDJg8FDaoRzc9LrmLhIhryJqqOXCtLR -5v4j3jiDuKKtmennFsy/Z3IpvHJ6vnoseeTT2u/TvMYLZgQN9EP3w9iKoeiRL/MS -AL3jzXb+Hs8rLrbEpr4I/FNC6IKELR8oP8v0gKmqB4aPHC8h5hCKBOkEVD6HkOTi -cmCaMG7lmcDY8bUlEUe59Vx392oGq5g8hwdNwhevFbMRxBSa+M0VxDblGMssIpSf -cWhDHogavW7jRmHQ7HcARz/XuTHPCDM= ------END CERTIFICATE----- diff --git a/language-support/js/daml-ledger/tests/certs/ca.key b/language-support/js/daml-ledger/tests/certs/ca.key deleted file mode 100644 index 9ca4e1774e9..00000000000 --- a/language-support/js/daml-ledger/tests/certs/ca.key +++ /dev/null @@ -1,54 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,F268EF3064C3E968 - -9Pb7ocW6iplgX4Z+1WBBxB+LX/lD+48dDqiweDJFd81eU2TV/XLI/l8aK52Ybmcj -tPi1b0lufDXVg7Dgt+PdT9qC26sH6iJ3+7lxN4ldwSuvfJylw7P7huRyHg48BkAI -ps3FHoNdzEGcb0i2GHH6upn1Ay5s4mBMxya6rWtw36mL6wLIbsdr3KXYMZ/J32ON -cBHMBO6bTjfosixbzuZZesdkye0ZNblV0JZe1zE52skoUxknd/tWOch0UtX61510 -Z1sPL+Jweha36TZOlRaVPb7y0SCqlDrzDDYcJi1XN6itkeWvwsItlZ2j2K4Jgu4N -xqleVQ5VwGjPldO29mG4r49xfFFzVqeDsAYre9w/i4dX5XTHB/YB7cdHW21QIH5v -o/D69r/fpOX4VgFusQQd12WYxouoVxvdAGgs3bjOg7IcDvVvySFhyXatzTz8AE9C -j5ZCAoNQy+JJL09LNcqqGUrYdzgyAprHP6xVHDTsOMc+vyqVldRW0oxDTPHtyGau -QsuCTBWR1Fph2z9vh0sbXcFAe9CQ2Op5d+MrXYCheWEz9fy4w6elwEF9ZWdyF4ZN -SgtLIGuCzALYwLHDskGFHZ7XOZV2t5ScSSDUq4iXbzPCT6W3gtYwm8uVheOWy521 -3ZmLaIFXpRmzgx33TpUssvhcqC0HqotdlX5+xwEf9cEgRoWdBJNbtLLjbDtFL9AU -026NaJ3Xk3rTmRlhgEbC8KC33QvHzQve78E2T5GLPlm6fkD+m7BXEWEDqocHvYoJ -5VzdCbQfnUKlVcjy7oARogGcpqysUaEeKmVq6KtOek47ViAv/7SzgEwMIbg+Ty6T -zGxGIrujoCP4wXhumcJcFNdZuZUabChN5AQ4BLXLuk58goS4eg6wejXwrajDnLDp -Y+WeUAo1hr7zcA03OXht4vSx2lJirghveBzWHnVy7Y7XlS66AVSVvEvWmtC2l571 -E2vFekxCOgie3luh0l8UWDw1Q5VO54Zjo7WMFwANWJ7yNpX2idKujMC0vejxPJjA -mu41pkMraaSAm76YSLFlzqLO1Wjj7UVbsch903UuJKTl6DWIn0KivMxOWXsdewTd -PxN93WL0dQ9Btr7GpDbqk1k8FsQBj6QuQm9Uuu8ToJXm9U+Twn14P8JGFlImkTgq -+5SvwU7WZGsEJXrGxPbBAMbiQ73h0vhZETKpxnnatFq1l6NqVZGICF8Bwe9PK1Hz -fGDLyylTW4eJjb9Hayw+ZdiI5NqLwR6O4qJogxQBAvkmL2+LkN8fORfubjZAtXAu -tOprI2fc+XT00ES1KSasmiMWm+j8cRghhbCqobq2wSDdjOcxbNpRDT/8jiLzF96d -CtP324UrJU9dPpBXADa0NyQBbI2WWHR//O1wjRE1rQ2nRWxdaPGW/GZaPn/huRvw -RUcOUhHZMDx/5Xt7i7FNgSA4yxbkr+t/XJDg8pRsSRAmg/Ggr5SO4XNNESGp6qq+ -9Q63X4U+paVqY6UOdp/6PLHoZsjv/ZHCQBOWqTAUkHLcIRMDkC/AlenBM69+Ruf+ -6ejRyyR5LyEJk4/JAjCkx1qDbAJylu0hb/wTPMEWiyx1LdU6Fbd7UqlHwNtCHjJD -RmEXZi5ZMjA8VrFVfWYp1KJP+mLDQ8Icze5+3uvjlTalCrXjDhwf2RINeoLEZTbz -kyUZghW5I0eMX4ie2QSy4HDIOC+NaYqe0TwxvlXPECDDynk+fK5kDn2JpJjxtvLC -tDmS1qTimU/O9RFpAlaF6jK2X797mg5Ywv4G2+TIOAN/w9nQesk2SOjkXMdaB/7l -1RuNDh/O8ucuYTcE5eBdvleS6V65TZOAvF5vCIJZ5J0GjszBSI8tij6a+P7DYJeW -utWAWDVI5EZ+o+VSyfgKCzOro0YcMJVYPkHkGluU5GsXqVACJfB8COiCM4mxfkFr -OMiyLxTrWrqhiZ9geUlB9UybvHrbViiF+hHkILaNw7UhvAsJgQOeVLt6W7xJfQB+ -F2e4xsKGAAN5z3deWGZQ6um6yaN9SqMsDav6A85kVkhnOCDoulKtMcq/ym8ZwLst -VUlfvbj+DPTtpMx6XW2Mv3h8U1iKn436yFtCh1Hy6YO+dDXK9CAx1o29z7HXGUtg -jaBpbhJ5tBLayNw2JJ6UFGmOrZ+P2m4gg3ZxD6JTxUGr1bvLGxsuJ0If8MzZyw4P -5TQS4MIU+r01/QpZqIJVglE227jzflEU+D2NmE9WjAJkPtP+pO0Wa87SHWFy/hUv -PEXCltJH9e2gAQkUYPwu45rIoFT3o71RA90qSOzeBSX945YEWLiQ6jFwD+QDKDHX -91dLb4qWz+GAVQLyCdokmDbXPga4V7c9m9S+VJopJ1wy9bx7AnvbL7WjvkQazF2k -6OdeVgUAuqiy7SdpQ1yF6qqRXppV5KdqC4EUEdDu2sPOf7c9jmaW4tuoHdUEzIoC -0L/H/KHTNB6ZDIcxwtrDEVhD2fKaOTBm/37BWvM4932wmducMw6oL6u6e4vkGYaj -ftvyNMrKxse9bABaECYtiFAhmo7AqHtTcfiLqZwfPaUZnJC0h2207dI7GlRPV/SS -I8ptZXjPjoPjQp+pxND4fac6uucPkSFuGL26oHLceXw6nDcfrttwwn8L/MXvlqXC -mUMqdPZNV1pc3bow56Y11Eh9eSstHVlmGpD8fbvYA0bzSGxVDvuPiFmsRZYP54GE -66d7nE1oq1aT+w/5h68EpCvtY+c1F0L22W4GukQoKvHSGTPa421FRIed7AfkEWGq -fo6TBQJUTHItJK5FOebQsCdN4JPe+jIN+Nyug4YJ8sBU0k/bMd7hKP95DbKN9oS+ -rBVz8nOet+8PSPMaPW7qSFKIQHTY3yLV82Pa14zAFvQ/Gt9ND1f2BzFUndsqxvTK -e7j8Unz8HaN6QT8ETq1oEofUZFsUe2VsX7yM2tDr6mdBqo0kzBSmpkYsdnr5HMYQ -7WwHYK8nbixrEIZZI4bZfoeXgd/EIqvNaMnRQscSERUyknr9eQ/gSmr8KmXrVEAD -T52YummfGCPTBBqcSHMdTvRu+Pndb8aLOBiy2MSfsTZy4Mp+lFP1VF1MEsDBzRG0 -gNYb5s0uwtk1xV4VgRs6lFIOmbbYKGSbHY7emUXWA26e5Bnv+SRPbHMrwd3SswT3 ------END RSA PRIVATE KEY----- diff --git a/language-support/js/daml-ledger/tests/certs/client.crt b/language-support/js/daml-ledger/tests/certs/client.crt deleted file mode 100644 index 0bd93e02e61..00000000000 --- a/language-support/js/daml-ledger/tests/certs/client.crt +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFLTCCAxUCAQEwDQYJKoZIhvcNAQELBQAwWDELMAkGA1UEBhMCQ0wxCzAJBgNV -BAgMAlJNMREwDwYDVQQHDAhTYW50aWFnbzENMAsGA1UECgwEVGVzdDENMAsGA1UE -CwwEVGVzdDELMAkGA1UEAwwCY2EwHhcNMTgxMTIxMDgzNjM4WhcNMTkxMTIxMDgz -NjM4WjBhMQswCQYDVQQGEwJDTDELMAkGA1UECAwCUk0xETAPBgNVBAcMCFNhbnRp -YWdvMQ0wCwYDVQQKDARUZXN0MQ8wDQYDVQQLDAZDbGllbnQxEjAQBgNVBAMMCWxv -Y2FsaG9zdDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALBEsXMWf6rs -w7e1aBKjfW/ZwBhjoP0rI/Fs+y62gcB33I9qayqjL2aaYyRBWAuuLMUK3tNHVEGA -yXbKuQLv9+7PFurkRH5eCR46ey9IQvVW5eXpEd4oidaJA7vd7oksXd0H9Arbskv8 -55uRcHeWu1IqVJIdcA4T6hYwh+9EecPTUaSjNoiExkyQB2LypG85Lb3XRFcjBrE6 -0qJU8O8zRu+O9oGgnFSAjeDRyYwlWJu6WBG9P+QvpLDeJwCVVbbtBXOKjRLQ5rVk -T9IYgaknC4pT0roc0dTPHvFdMvEK/1OyOSbL1H+rFmF4Qv5KtvwDnEza9xSZBI/N -SVEnvSbMDZL82GdMlIUQE0wyYJAwhNQUTewCGe5QviPBRY3FcM97odo76goa1ASY -eOAAfX/zV6LmoSKd3DXmF9aSfACFv8VN64UDaSNPTqWGX4EfOIH0aESefG9tWbzW -mSLv+gn+JkMpjPHUVWvyfAje1avCxGXCvvWoDK8xcMXCvLqaDHkp4G79vfulKhd8 -v4b7i4e6HZv9FkbQBtteUYcDdyiy1cVj9vrPjwJrr//sXscX2hpxihcuY0ElWCXh -uHfiiX5m9Rpg43zFr5ZumgBtGiQTcyZKwYgECb1SWXfvm/sSTE4ToT9Lb+Og5HQ0 -vbuH6S34KrewLKB6RLRMIlyhWyvc93g/AgMBAAEwDQYJKoZIhvcNAQELBQADggIB -AGLVYKFSoIc0kdPXi2UmrSBwRjWzUrbfF8eYZsw70QHWqvRY8y1CCgsxTGw2Guso -hVpqclnDnZt7vmMZXOwOxJ1C8w76rMq5Ocy0/yKwIadp/S4azUs0Xe8i8bGAL2Rt -IREBVrtaJOlcLUx0KHWNiHsGm12YJHaDO75wtpW77PTVfczvW1Zz7A15j5R4stQl -z5SXt3MrzyUUUEHonGL/dVIVS5Kc4qTZKxxMg0orrkfQymN+8rgncwrudV/XsdBC -rX5BCJ+fuvIrXjl22PSR1MiT4X2sAR/k2g54VG2mRyBYFKLfhpcT+QVVTH9sMZTL -vDY+au6Nd5ylpcSrHUOTFGKGo2o5iTvzxZCfdtZYRtO9NqREqV30t6JKY/2bpxvq -I0oOIUoaQf+i3nGmmJYoOA5kemCi5JOhRw1J7nrqn6ozDPkVHZtlBtRZPGXG+2AN -Hx3VxGymd2Jcj5RQHizqtcS0/ms94j1BTALAUe7YYk25WiLBXxwanXsTeLCi62U1 -B5QZEeJSk6E+U6h/RNjtyT6a35xFk0M/QXzuOrSTbqFR5u1hxXFBM7CLSwqXqFhd -jdnm647xE8tPLIECvLWVKJXbvuPNnDLe/oEspIuYXoRM1ZMzJKjSgtT7WvWnwxwk -kXY8ThHmrBMNg9twU4n9Fmh0zLdgv+VExwlEBKO8/HOy ------END CERTIFICATE----- diff --git a/language-support/js/daml-ledger/tests/certs/client.csr b/language-support/js/daml-ledger/tests/certs/client.csr deleted file mode 100644 index fc130dfc52b..00000000000 --- a/language-support/js/daml-ledger/tests/certs/client.csr +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN CERTIFICATE REQUEST----- -MIIEpjCCAo4CAQAwYTELMAkGA1UEBhMCQ0wxCzAJBgNVBAgMAlJNMREwDwYDVQQH -DAhTYW50aWFnbzENMAsGA1UECgwEVGVzdDEPMA0GA1UECwwGQ2xpZW50MRIwEAYD -VQQDDAlsb2NhbGhvc3QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCw -RLFzFn+q7MO3tWgSo31v2cAYY6D9KyPxbPsutoHAd9yPamsqoy9mmmMkQVgLrizF -Ct7TR1RBgMl2yrkC7/fuzxbq5ER+XgkeOnsvSEL1VuXl6RHeKInWiQO73e6JLF3d -B/QK27JL/OebkXB3lrtSKlSSHXAOE+oWMIfvRHnD01GkozaIhMZMkAdi8qRvOS29 -10RXIwaxOtKiVPDvM0bvjvaBoJxUgI3g0cmMJVibulgRvT/kL6Sw3icAlVW27QVz -io0S0Oa1ZE/SGIGpJwuKU9K6HNHUzx7xXTLxCv9Tsjkmy9R/qxZheEL+Srb8A5xM -2vcUmQSPzUlRJ70mzA2S/NhnTJSFEBNMMmCQMITUFE3sAhnuUL4jwUWNxXDPe6Ha -O+oKGtQEmHjgAH1/81ei5qEindw15hfWknwAhb/FTeuFA2kjT06lhl+BHziB9GhE -nnxvbVm81pki7/oJ/iZDKYzx1FVr8nwI3tWrwsRlwr71qAyvMXDFwry6mgx5KeBu -/b37pSoXfL+G+4uHuh2b/RZG0AbbXlGHA3costXFY/b6z48Ca6//7F7HF9oacYoX -LmNBJVgl4bh34ol+ZvUaYON8xa+WbpoAbRokE3MmSsGIBAm9Ull375v7EkxOE6E/ -S2/joOR0NL27h+kt+Cq3sCygekS0TCJcoVsr3Pd4PwIDAQABoAAwDQYJKoZIhvcN -AQELBQADggIBADZH4cBr3uU6XUuNv4y/E917ovSXQymGVMRgn2o1CJVQeMslpUgX -s9LLBwBYwd/rcE0O+9ygLrzRxJqZcxn073tWRwzZBTlcGXhNPPeFhsQI0sQ2mJ7U -6l5JhlpYbfKg7+ab3mYDwfj3d0irPn3xZfV6rCzev3cXKjRavE//K/R8dk2PV30X -AGQxPIIqlDam3JUaajtDcufRoCcSkYqFZisTXwjPcnxVVeGzw8thsWULn5h+41Jh -VHIFceJTDfAJpFMCtLZKGmHF24KxsqDBLoTNYWagMBibI+A/9NqyURTtS6hP9v5Y -6W5wHOUcTGIqvOxyfPmJ+CBILasrGXc/N/L+u4giWoca4QDc7X8BktkFcxLa1Yu0 -99awX5J7I2FqYV1BR4SpmBnjD9HcBGsepUOqg3nS8J7/2hPIJLsLxRsCK712zejc -Jei0RDxLmLHvxIiP1kMHOTnDIQk6CWB2wHtelThbLss/e0i/b+CpKHoHDxir5MGg -8HinYzaDUOKyH9LPIjsbMOyGfM8/Dk2pzDUbOf4ZfXyb4fyCOo3NE/+XhQvEsEmB -s7dtSXbxURUDisl9RzMo+ht1UbC/wN6towBpRsmfy45iL+rsaW1ii54cTMeJnbAM -nYOojQNjFAEwKDP1ujR3YOEVqNX/dxGOv9appHzJJ6piizvGH32dwo8b ------END CERTIFICATE REQUEST----- diff --git a/language-support/js/daml-ledger/tests/certs/client.key b/language-support/js/daml-ledger/tests/certs/client.key deleted file mode 100644 index 1aaeb804534..00000000000 --- a/language-support/js/daml-ledger/tests/certs/client.key +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIJKAIBAAKCAgEAsESxcxZ/quzDt7VoEqN9b9nAGGOg/Ssj8Wz7LraBwHfcj2pr -KqMvZppjJEFYC64sxQre00dUQYDJdsq5Au/37s8W6uREfl4JHjp7L0hC9Vbl5ekR -3iiJ1okDu93uiSxd3Qf0CtuyS/znm5Fwd5a7UipUkh1wDhPqFjCH70R5w9NRpKM2 -iITGTJAHYvKkbzktvddEVyMGsTrSolTw7zNG7472gaCcVICN4NHJjCVYm7pYEb0/ -5C+ksN4nAJVVtu0Fc4qNEtDmtWRP0hiBqScLilPSuhzR1M8e8V0y8Qr/U7I5JsvU -f6sWYXhC/kq2/AOcTNr3FJkEj81JUSe9JswNkvzYZ0yUhRATTDJgkDCE1BRN7AIZ -7lC+I8FFjcVwz3uh2jvqChrUBJh44AB9f/NXouahIp3cNeYX1pJ8AIW/xU3rhQNp -I09OpYZfgR84gfRoRJ58b21ZvNaZIu/6Cf4mQymM8dRVa/J8CN7Vq8LEZcK+9agM -rzFwxcK8upoMeSngbv29+6UqF3y/hvuLh7odm/0WRtAG215RhwN3KLLVxWP2+s+P -Amuv/+xexxfaGnGKFy5jQSVYJeG4d+KJfmb1GmDjfMWvlm6aAG0aJBNzJkrBiAQJ -vVJZd++b+xJMThOhP0tv46DkdDS9u4fpLfgqt7AsoHpEtEwiXKFbK9z3eD8CAwEA -AQKCAgEAqzxwbm9i4vdTQro2OjUc/HW7CXZvxMIODtFiSoT+E63dVG17YlZZDAHb -YjMgh2hTEbB3uyRGE8Q68u4JQXNBlnsTtmi+qUxM61LArLQ0aAZdHDaJJxqWnRVJ -zU3SFuxE2x6I06uN0AgGL7jgWyzRGQcKVU/HtcVe2OOYirYo3DYD0D7GEWV7BpG8 -u0EgwPP5Hb1sJIJgU/fi+9QsoxNbTAnEKzWN6QFh0w+6Di2RoOcr+z+wO8qU4UVO -+mAYfrZPX2kvlyHdnkWuzVkFTQAjU+QOiMLKjUQQuUVi4Ytfcz1mC+xjqQrZmSKt -Yj/O94/CXV8yPI5SQiiZmv9R38jHPW+4X5JMUWsV1Vg5MKS7ck34Z9tXAaCoRY8d -Uwh495DMXK2IlMhIeMji8OWBZXgIMYc1K+vb15MqF4IEWgm6rMm9uhdYIH1Pv0fg -WfsAbsnt4yR/ALCkR2X+d6MODfYRZauN9K41lHOLmlGkFkOP9w2kdKFdEpAhD+Vt -eOP1+dkgvDVSeZw2GqNJMggUTcjow3672Ei9qWW48PglM6+mFGJLPpucIslhcuvn -3s9SedF+xaBNn8yiIOA9dG1GFF0yI5Y25osOMICqNehPqYjIrnkbO98ZImsVetNt -Kbdkz5Axsy7nRgRpNGkzf9M5kalyLZq80e+siE2gpViBjGhYQaECggEBAOcK52d0 -g1eN3ozPMGVxazH/YRjjHqdOAh/0IWVOIF0MbOC+u7e0LseSGfVZ3vlaiEqPDTr6 -9oR+nQye5uIyzKJI+nwnfKWppMlrkzqvux7WuEC/VXfH7krQVgLxPXX7uEiU+NPn -P3pTNOmnT1i9MWNb3TNJMzbOYwB4G3godmRsdeqPfBiHk25FCicEF1XP32U4wtpi -h3/isIMjHNN7a6b8XZZj/21jNLhe+2QvMpMW2e8B4QK91cWA6KOMK+15uQBEKCX+ -ZQwqcnF5bv5c7s4/F4z7hzIwGWN7J9Catng8Ks0RI9RdcGcgGg74W+tKxzmD1lNz -vr1DdHYIrLFtXXcCggEBAMNPGUjrE1v2Deo4Um2F8oIxwtgKgQuAj2vsgxpa9ivU -QM3VpFH5TUYlfFpoXh4tzMH8V3BX1CVE3qoPptj0W1oOHHYutn3UuLc6e2bcW5O5 -6ih549BpaW7qDCdfPvwV8KVlLoEVsXyv2FoIpw+mzZLdnzM06JS8bPIxU+C/Sr4T -gRB8HZZd4+tV8pmGFqmluOVcQLfhOphvLlCx7dMCa2WYrvfvxeBXusi1RqSE95li -IzQPb3x66ThEHlFa+OwNyhD9JSb4oam9tETFbXeC9papxtWgAZg4duchlakzJP0j -0F4gxitgpLBuingv7BopJjAvlBFA++LwClnbhzqCzXkCggEAYs8q//e4ZC1sTFQf -ooLLEWrin74iUfLuvbOuxKCQ/rpdphBsP7hzeS5mo6N31LR/LUPYqKzD2Q49JDSh -EYQgOBd16LsKd98BdpLnOGYHZLz3t9kcOEntA1nuLvv1CQxKV+A+OoHfh/Ul3/eJ -262t/YxAIbrgiEPj20OCm/TSDUjFdTdAH018I+Cq4tzBDhYEuEl6K+OPh4Xvb2YI -4fkapSOw8qx5hNK0rVURtlrpCjbvpWPsUzvUvM7Qr4E3GCzCjfaYJQeTN4y/vP/u -FCKyjso0zDqWK0Se1wjIklJYTzuMIn9+D0iW1cPI4TYeOZaVdWeItc/+dvruR7yV -/puDKQKCAQAmBsiNgfeK+CVNbRnfaS0GXFnrZmAptSY3hR0hjIRRlEnpyabsrvV0 -qufDUn7AsXokatU7cl5Dw1z3D4UUyL7gkc7I09+EMF6mjiRoqo7J/HCy4MiSU3PL -vJYRNGI3Aq6QBVtAltCvziz5mqWsTnXIGo5ckfiWvPkZTrFeGOCckX+XjhLUrAMs -VtedPJY9AZ82SPfw1VFrTHpgC8SaSOZQKaInc++69lnPqjvO3HS40Hq6MCcsvWGb -KugcPvIoQ6cMF72cENypB96JZUci9cS9IOEtxrGIybWc2tUg1GxnPQncydTLrU1j -bKJZNDtr/IcK6riRg22HieT6CdwScFVBAoIBABFelqpsMJsuBK9DVF//czTpGJpU -+wtxWXAYF9l8eUGmDdNCwdyWfrbhOH0P4AYYPK0k1RZ2tjoXF4tAYcec/xjrkaDp -pzjO3oFLmLeEbVSQP23X0V0/YagU+Z8guQh4cf4lG0Mml2GIEL0ZgymfFm58MOhH -EfgCb1u93IaHf179rHY54dTMalaFiWZNTcvTxn4Q4M8xv+txe7PWg9BQVcq5zkUR -de4FaPeEHbNobNR/5KZAmc6Rz2ryXLwpzAaKA4TQgQfqGaQSTXuYJmX+ePDLfx8m -5w7qB+Kf2PXbMfFWJP3n+2iGvzZcetSecugmxxrLQuThQfhQjSq7b1AT+UI= ------END RSA PRIVATE KEY----- diff --git a/language-support/js/daml-ledger/tests/certs/index.ts b/language-support/js/daml-ledger/tests/certs/index.ts deleted file mode 100644 index 2090ef20b5a..00000000000 --- a/language-support/js/daml-ledger/tests/certs/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { readFileSync } from 'fs'; - -export const rootCertChain: Buffer = readFileSync(`${__dirname}/ca.crt`); -export const serverCertChain: Buffer = readFileSync(`${__dirname}/server.crt`); -export const serverPrivateKey: Buffer = readFileSync(`${__dirname}/server.key`); -export const clientCertChain: Buffer = readFileSync(`${__dirname}/client.crt`); -export const clientPrivateKey: Buffer = readFileSync(`${__dirname}/client.key`); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/certs/server.crt b/language-support/js/daml-ledger/tests/certs/server.crt deleted file mode 100644 index a1c8a9ee6ba..00000000000 --- a/language-support/js/daml-ledger/tests/certs/server.crt +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFLTCCAxUCAQEwDQYJKoZIhvcNAQELBQAwWDELMAkGA1UEBhMCQ0wxCzAJBgNV -BAgMAlJNMREwDwYDVQQHDAhTYW50aWFnbzENMAsGA1UECgwEVGVzdDENMAsGA1UE -CwwEVGVzdDELMAkGA1UEAwwCY2EwHhcNMTgxMTIxMDgzNjM4WhcNMTkxMTIxMDgz -NjM4WjBhMQswCQYDVQQGEwJDTDELMAkGA1UECAwCUk0xETAPBgNVBAcMCFNhbnRp -YWdvMQ0wCwYDVQQKDARUZXN0MQ8wDQYDVQQLDAZTZXJ2ZXIxEjAQBgNVBAMMCWxv -Y2FsaG9zdDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAOqGF1a8vLrf -4gBIEISzkAM5MANpBy2G/uI2UEVmfIUcGIPXuMQlPUNaVadGLG3L+rgiJwVw+7SU -9xm7tqNdpCWEgytdPSqL0H1l3Kox6y+6r7ih+cs4MXF9oYPg2Ra4MDLowEK21zNX -J3AZ3i9PxSqs63MSbCQJm61cTz+Np1ekeWvBaPj6kX9TrLIEmc7sEnLys35Uabyb -uCelOGmtkosYXao60VLv9Dlh0Mn/4ktFfze4dxlacVUkvcniHXfqVsdyph5K+T8z -gIZS1yIFSOOcV8ZdlHndPNInMjamx0twh2Hr5P+ZNXM19qS4zcXx/CcVfOlcq8Jg -X9q/YzVtBsWXkyDdmj9Uc1TTaHNec1hNAWGfEdfWNE4tt9q8AEzVJh7nXcxCuqDs -wKR3+uBKBlK80uyxRQOR6uACccDji1XpP6Z+41e8dozC+EN5T7sFFAIU7Xu05ShM -HJsM2J596nVjKNZyIo4sFspdEv2kdmo60dqBW6IQESevRqMooMtMazG7834js7x1 -Dce08FBPFYaxHdZGEYYvK1yf4H+3Mct53SxN221Ki1c3g6PkQ5zZsGbRi7Pwo/58 -96izpzHApBu9zeoQzjz9bOkp1cWCxhG4Mdb6HD4u2BgumdazmlwawIcBuI2Hk6Du -NneVdkijt/v0MvCjdTP/cS5PLtN2HbvrAgMBAAEwDQYJKoZIhvcNAQELBQADggIB -ALOMFcgYLiLv1ugUf6A97N1FwOEyPSlyOWiOPXNYM9dSwViM8ljTf4yY3HylIdci -rx7wqFCCgwmnm0d8V2akDU7k86WdjIv6lpQzMJ/Bktax8VP5pq81QDUl5U5PR/+7 -VEqOHwv8N6YDyDgKp+X5nCzDFYTekbsBhIdDYB8MF82nfnfhKesbu1bytk5XN8VY -UIjKk2zJMijTmJi870k2+9vlSxJk5cO8SV8NM08zEdJxzlZafrmowBHUThXYNS6e -X8UzqozHjHbr6fIESkRuNumtKOO0gdYenx/32DFuEYkM86IBfQZqwfKB1oKtvs67 -fEPaBQBdzoaVLp6izBRFcIh1lfL75LDSkaC81vJEvsJNP1ujnS0WiD8PnqqsKKM4 -AvbLmihkn9Msmtth7lYSlirezKQkEbdwXzYMt1N4pAw34AhFlUZWpUVDiNPeGItp -wCaNXW7xLGbzbwpD8lSWUUB4tRPLLeUnXrEdxu9A6GmjSmTS6EeBMuFP3g6PgL2Z -A6PjczLoCy0J5ZObMfv4eJDeNdskXksQYR9WiYoGiqibuPRCh+zQ6nCNi6Zp6J7X -am2bV0u9LxEi/8z4ogLuN4Rx/h8jI8wJx/38oFLEDiZ0m/YUhVHBu3l9BkwTB1Cx -tpdxean+EIfMSf4GBlaUd3T3cY4ocKK23NXHAb6K1cra ------END CERTIFICATE----- diff --git a/language-support/js/daml-ledger/tests/certs/server.csr b/language-support/js/daml-ledger/tests/certs/server.csr deleted file mode 100644 index 40dcb7c2516..00000000000 --- a/language-support/js/daml-ledger/tests/certs/server.csr +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN CERTIFICATE REQUEST----- -MIIEpjCCAo4CAQAwYTELMAkGA1UEBhMCQ0wxCzAJBgNVBAgMAlJNMREwDwYDVQQH -DAhTYW50aWFnbzENMAsGA1UECgwEVGVzdDEPMA0GA1UECwwGU2VydmVyMRIwEAYD -VQQDDAlsb2NhbGhvc3QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDq -hhdWvLy63+IASBCEs5ADOTADaQcthv7iNlBFZnyFHBiD17jEJT1DWlWnRixty/q4 -IicFcPu0lPcZu7ajXaQlhIMrXT0qi9B9ZdyqMesvuq+4ofnLODFxfaGD4NkWuDAy -6MBCttczVydwGd4vT8UqrOtzEmwkCZutXE8/jadXpHlrwWj4+pF/U6yyBJnO7BJy -8rN+VGm8m7gnpThprZKLGF2qOtFS7/Q5YdDJ/+JLRX83uHcZWnFVJL3J4h136lbH -cqYeSvk/M4CGUtciBUjjnFfGXZR53TzSJzI2psdLcIdh6+T/mTVzNfakuM3F8fwn -FXzpXKvCYF/av2M1bQbFl5Mg3Zo/VHNU02hzXnNYTQFhnxHX1jROLbfavABM1SYe -513MQrqg7MCkd/rgSgZSvNLssUUDkergAnHA44tV6T+mfuNXvHaMwvhDeU+7BRQC -FO17tOUoTBybDNiefep1YyjWciKOLBbKXRL9pHZqOtHagVuiEBEnr0ajKKDLTGsx -u/N+I7O8dQ3HtPBQTxWGsR3WRhGGLytcn+B/tzHLed0sTdttSotXN4Oj5EOc2bBm -0Yuz8KP+fPeos6cxwKQbvc3qEM48/WzpKdXFgsYRuDHW+hw+LtgYLpnWs5pcGsCH -AbiNh5Og7jZ3lXZIo7f79DLwo3Uz/3EuTy7Tdh276wIDAQABoAAwDQYJKoZIhvcN -AQELBQADggIBADgOj3gGdjfOrgbG39X2AISHCM0711yBfFLEUwemL7BRTF++wW2c -WXFnmOWUzyTPaeeAWJk9zxq/3NktSEtSuMq+Dd6IB+J4qQteXpNs++Byy7+9QNY4 -+lzYZxwRp5HPLJrRa8IpO2ooAacmGDdeuAfOBV61h7O5I31SpHkDqKd4m3daIvxr -6cGGUPZrOk2oNhXSWv+qL9pOAEujcU2cSEOiUm1aG/TWGM8rRVtSvqkNr8n3IYlX -BgP8AoPjurmaX4OzJkMpC1hM5ynTKSxfO05bDZj5d5oL7nOOu5dh+7ixwH4X06hz -koQac1iJHNJFCPWA9u5PAb4UrzNKtKH3mKbfQoFXpkPIFfiFvw/xOd1lO9XVmR0+ -y6XD92AW4xs4gaCUKRTMe+V0febwALmcVdLt7YC9d7mAvCbhazLB+gU96Ka39Hhs -4BsnKPjWFWtcBQSkDCYcziKPmpnjykq2I4yz5JqVALU6xFRjYqAuMfvT+NuW8OT0 -etS8kfgvoGyKxuvlnJQXjXEnVUPWrCFmvwA6gKN1ZCq0Lxtfc6wTWInYUDk+BhYR -8vAWYb6L5Qh5YtIMetFD3kDOThgyk71Zka3cCPfO6deK32b4y7XBGa5gy58u2FtD -I8ph6KexKr8+nf2Dt5zs4FYaQ895lv0LTUDF/byBekLkeSiT4YrvnI/3 ------END CERTIFICATE REQUEST----- diff --git a/language-support/js/daml-ledger/tests/certs/server.key b/language-support/js/daml-ledger/tests/certs/server.key deleted file mode 100644 index 0438fad45be..00000000000 --- a/language-support/js/daml-ledger/tests/certs/server.key +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIJJwIBAAKCAgEA6oYXVry8ut/iAEgQhLOQAzkwA2kHLYb+4jZQRWZ8hRwYg9e4 -xCU9Q1pVp0Ysbcv6uCInBXD7tJT3Gbu2o12kJYSDK109KovQfWXcqjHrL7qvuKH5 -yzgxcX2hg+DZFrgwMujAQrbXM1cncBneL0/FKqzrcxJsJAmbrVxPP42nV6R5a8Fo -+PqRf1OssgSZzuwScvKzflRpvJu4J6U4aa2SixhdqjrRUu/0OWHQyf/iS0V/N7h3 -GVpxVSS9yeIdd+pWx3KmHkr5PzOAhlLXIgVI45xXxl2Ued080icyNqbHS3CHYevk -/5k1czX2pLjNxfH8JxV86VyrwmBf2r9jNW0GxZeTIN2aP1RzVNNoc15zWE0BYZ8R -19Y0Ti232rwATNUmHuddzEK6oOzApHf64EoGUrzS7LFFA5Hq4AJxwOOLVek/pn7j -V7x2jML4Q3lPuwUUAhTte7TlKEwcmwzYnn3qdWMo1nIijiwWyl0S/aR2ajrR2oFb -ohARJ69Goyigy0xrMbvzfiOzvHUNx7TwUE8VhrEd1kYRhi8rXJ/gf7cxy3ndLE3b -bUqLVzeDo+RDnNmwZtGLs/Cj/nz3qLOnMcCkG73N6hDOPP1s6SnVxYLGEbgx1voc -Pi7YGC6Z1rOaXBrAhwG4jYeToO42d5V2SKO3+/Qy8KN1M/9xLk8u03Ydu+sCAwEA -AQKCAgAGz1P4KczVJFEcrvsDz278GPoC71bNBKF8EhWsnjg5aUJw+Z+c2nP387SP -AeOiYIzsMdmuN8SnTrgKIEBCaCKvEDT62l8/UAYCziVlL8Pjg+k8VD+7nesZn4tE -GBBVr41+vPFwPnzrObmkcKvZ9dgE0DaaBcvsE/dYRljqwIM+cUExVtFkgWoeJ2DZ -XnbU4lf6zH9XyL21Q1RKmmqT7v1VWqTFn6WaYetWizeT1gFNLDxwcsPKkay+yy1T -omQ2qjBQ5ExcjtLD+gveWqNyknK2YUDPOsJn83ujoo27toYM87yKpF3m6hz6NnPt -/ovDFq66t84DvLQkFcZSxMHtuDe9ENka9FdKI10rMRlDgn+sRh+S9gUbGhxcn6qt -OyDHncja3pXz67JCJpCoEYr3X9m5MT47uY3+mr2IPRbHFjRUkraaBE/r7ESMFb+R -0PNBwKxLTXh5SgOVQCJUIuRrKGDkaKVrRLnOQ3zfVHWzJjt4BnTOm4uu8msJhtp0 -DQDgyIiCiteCuGw+QRzRQUZhlqdqxbXkTLPZCUvHujPKlVtSgMyEIxLTzYswfO3t -sAlfsTjoxiPbcpBKl2H2rJLxeb0BASFrWrAhsucQaffyNzlTFDSr3HcSw1VKe10Z -kJyhPeDQTII66YH7X3+nkjpGIows5eX8Zk4WRODcKBNKd8zSOQKCAQEA+e6avc6n -34TPEVt272M0ByBmL77kWZVobhKX2StqWOFVlNeeYa6b40taKAttN6I54TBM4Yim -nWfri7cDGx8QmvgqiX84W+vVaq+ABJopy1J0PNc4R1esoMIwlvVEWhM0lsKg8/4C -xN1IUXZ3AnBPywvMX0JsqpFnkMG6vGEG8ek1TRO6R76O2tY1Y7lEF5tzS7XbAWSz -yU4VQIXANWn6NyIJ7pEzK5FAemy899VaDS+RNa8+rvCkBUB1jwSkOmTPm1S7NjtO -hKeqdlj4XplDgxJFYg5Ev4AxM9EG46HYusavmonqF917IPhNIsQQ75+ROy3htAR9 -IGavDB40EBOT9wKCAQEA8De4YFWMm11LvfQm10t/X5fsjqjC5PMCzVOeY5HtCXS5 -QTHDpuiGm5Pgaim1r6MMfHgebW+pq3JG1/0JyqdbXKZcOO4/XlODg2Dm5oHQuwcb -QsuACGhRmevvV0bCSgn/WN2tmoR2Pk+YMnwoeZVWT2A2LI1fFdzZSj4Gw5ClFqsB -f2nYlb2puHm1R/tWVb59yawMrS5E/k4kQ5KawwmeZOXJgbul0z2dppFe7I6VURA8 -6r35+cPhCTJIMO2cXWv+fvgb3xUZYWUm4sqqi6+oM0YIoTYILY28pqDeHFq8WEz0 -Jd3d/WFHXkGnb+RYr51EX5OdORgeupFJMRztAceyrQKCAQBJFXiyYCe+uLtEPBa/ -Uab5HoRDGfL0LzhmV5GHs6ZZbyrzZ0mtDr4O7Q3j/9NkHVAHhXQ1zxvJk4XRSSbj -W2YjqsXlhwoX9xJlLASnU90801OiJt0SH5UfPSmwOvBN1qfeHfOq5XAx2PM4vwd1 -8xmiKkUM5gOYrQQ31C6iv0ykmKk5bLdgG1zyqQjbrGU48f/496ie86+PAgI859+Y -vvCoBpAY7uSjrMnKAtoPLpgymuI/bItL5JpR3tOBir3rRWdf6JsF9Lm1GMJD8ShP -oUmYnlMjpUB9LyM0H79/+OfDVi4rZoDJkb5bmcAUlnjNWT/CqlwBo/5i5yPwyzQ2 -L0NpAoIBAF4mGJd5MDC8cjEy/f4n0vZOfyKytiAxtolvGob/7J1mKC2LKZnDTO6x -GKXDTzhVeVFXauWNfDx7/5Qr0qigy0gW09JkXmXD6amWUylI+9wxvteBFt80s7bW -J+pXC1Mlc/UKfT4waH+nholS7DIq+7cEiHcRuZDCDE/y24fOq0WlJGMhwwd9XIW2 -/fwGYCIfFQHz8sv1dIkPa1sonIuQu4nkHgRA3Y9beOyN0Vx5zcAF0zpV1yGzSgHm -uTCkEEL1TrvI1nOqu1XW5VTCBfHVmODvs/YrTS09fhD4v9TxIxygnJgyywzCEcy5 -grxyDOhXhTLIkjiMYY7R3pPnOGUYNckCggEAI1H7YWidzFg255hJqYYBAAXpJS8c -ila1Mm8fbdAVNbwTTLYKMpe1BWB21NKgwK3Forfuwzgk3tdkczFh8up4Jxo3EWQC -Me2zXtrpN9pnY0wqK6FH/pFa+1624fjeJuxAq/8Mq6vo9oQnC1RSmbuSzYmLEoPm -XZRG5Sr9SKIba9ZtQSRaZa/U2M+LLf/J8lCqzyVFLM2YWR3RCeQhd7Wbivr/7eVf -/3bPJn+simhhvTT4yyVw/V1sDhhNhE28amN+I4S8JqXVzJA6cY7cw0VJ8tEnFN4K -9sZVFtxls/ECAbt6xkSos68v6D5+DXP4AYufk9eGRCHalsFhdd/veaZZUQ== ------END RSA PRIVATE KEY----- diff --git a/language-support/js/daml-ledger/tests/client_readable_object_stream.spec.ts b/language-support/js/daml-ledger/tests/client_readable_object_stream.spec.ts deleted file mode 100644 index 8409c050084..00000000000 --- a/language-support/js/daml-ledger/tests/client_readable_object_stream.spec.ts +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect, assert } from 'chai'; -import * as grpc from 'daml-grpc'; -import { MockedClientReadableStream } from './mock/client_readable_stream'; -import * as mapping from '../src/mapping'; -import * as call from '../src/call'; - -describe("ClientReadableObjectStream", () => { - - it("should support empty stream", (done) => { - - const wrapped = MockedClientReadableStream.with([]); - const wrapper = call.ClientReadableObjectStream.from(wrapped, mapping.Identifier); - - let counter = 0; - wrapper.on('data', (_id) => { - counter = counter + 1; - }); - - wrapper.on('end', () => { - expect(counter).to.equal(0); - done(); - }); - - }); - - it("should read the expected items out of the wrapped stream", (done) => { - - const id1 = new grpc.Identifier(); - id1.setModuleName('firstModuleName'); - id1.setEntityName('firstEntityName'); - id1.setPackageId('firstPackageId'); - const id2 = new grpc.Identifier(); - id2.setModuleName('secondModuleName'); - id2.setEntityName('secondEntityName'); - id2.setPackageId('secondPackageId'); - - const fixture = [id1, id2]; - - const wrapped = MockedClientReadableStream.with(fixture); - const wrapper = call.ClientReadableObjectStream.from(wrapped, mapping.Identifier); - - let counter = 0; - wrapper.on('data', (id) => { - expect(id).to.haveOwnProperty('moduleName'); - expect(id).to.haveOwnProperty('entityName'); - expect(id).to.haveOwnProperty('packageId'); - expect(id).to.deep.equal(mapping.Identifier.toObject(fixture[counter])); - counter = counter + 1; - }); - - wrapper.on('end', () => { - expect(counter).to.equal(2); - done(); - }); - - }); - - it('should correctly wrap an error', (done) => { - const wrapper = call.ClientReadableObjectStream.from(new Error('hello, error')); - let passed = false; - wrapper.on('data', (_data) => { - done(new Error('received unexpected data')); - }); - wrapper.on('error', (error) => { - expect(error.message).to.equal('hello, error'); - passed = true; - }); - wrapper.on('end', () => { - assert(passed); - done(); - }) - }); - -}); diff --git a/language-support/js/daml-ledger/tests/command_client.spec.ts b/language-support/js/daml-ledger/tests/command_client.spec.ts deleted file mode 100644 index 81b67ba5764..00000000000 --- a/language-support/js/daml-ledger/tests/command_client.spec.ts +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { test } from 'mocha'; -import { expect, assert } from 'chai'; -import { MockedCommandClient } from './mock'; -import * as sinon from 'sinon'; -import * as ledger from '../src'; -import { reporting } from '../src'; -import * as mapping from '../src/mapping'; -import * as validation from '../src/validation'; - -describe("CommandClient", () => { - - afterEach(() => { - sinon.restore(); - lastRequestSpy.resetHistory(); - }); - - const emptyRequest: ledger.SubmitAndWaitRequest = { - commands: { - applicationId: 'some-application-id', - commandId: 'some-command-id', - ledgerEffectiveTime: { seconds: 42, nanoseconds: 47 }, - maximumRecordTime: { seconds: 37, nanoseconds: 999 }, - party: 'birthday-party', - workflowId: 'some-workflow-id', - list: [] - } - }; - - const request: ledger.SubmitAndWaitRequest = { - commands: { - applicationId: 'some-application-id', - commandId: 'some-command-id', - ledgerEffectiveTime: { seconds: 42, nanoseconds: 47 }, - maximumRecordTime: { seconds: 37, nanoseconds: 999 }, - party: 'birthday-party', - workflowId: 'some-workflow-id', - list: [ - { - create: { - templateId: { packageId: 'tmplt', moduleName: 'cpluspls', entityName: 'ent' }, - arguments: { - recordId: { packageId: 'pkg', moduleName: 'fernando', entityName: 'ent' }, - fields: { - someValue: { bool: true } - } - } - } - } - ] - } - }; - - const lastRequestSpy = sinon.spy(); - const mockedClient = new MockedCommandClient(lastRequestSpy); - const client = new ledger.CommandClient('some-ledger-id', mockedClient, reporting.JSONReporter); - - test('[2.1] When a command is sent to the bindings, it is sent to the ledger', (done) => { - client.submitAndWait(emptyRequest, (error, _) => { - expect(error).to.be.null; - assert(lastRequestSpy.calledOnce); - expect(lastRequestSpy.lastCall.args).to.have.length(1); - expect(mapping.SubmitAndWaitRequest.toObject(lastRequestSpy.lastCall.lastArg)).to.deep.equal(emptyRequest); - done(); - }); - }); - - test('[2.2] Command is sent to the correct ledger ID', (done) => { - client.submitAndWait(request, (error, _) => { - expect(error).to.be.null; - assert(lastRequestSpy.calledOnce); - expect(lastRequestSpy.lastCall.args).to.have.length(1); - expect(mapping.SubmitAndWaitRequest.toObject(lastRequestSpy.lastCall.lastArg)).to.deep.equal(request); - done(); - }); - }); - - test('Validation: an ill-formed message does not pass validation (submitAndWait)', (done) => { - - const invalidRequest = { - commands: { - applicationId: 'app', - commandId: 'cmd', - party: 'birthday', - ledgerEffectiveTime: { seconds: 0, nanoseconds: 1 }, - maximumRecordTime: { seconds: 1, nanoseconds: 2 }, - list: [ - { - archive: { - templateId: { - name: 'foo', - packageId: 'bar' - } - } - } - ] - } - }; - - const expectedValidationTree: validation.Tree = { - errors: [], - children: { - commands: { - errors: [], - children: { - applicationId: { - errors: [], - children: {} - }, - commandId: { - errors: [], - children: {} - }, - party: { - errors: [], - children: {} - }, - ledgerEffectiveTime: { - errors: [], - children: { - seconds: { - errors: [], - children: {} - }, - nanoseconds: { - errors: [], - children: {} - }} - }, - maximumRecordTime: { - errors: [], - children: { - seconds: { - errors: [], - children: {} - }, - nanoseconds: { - errors: [], - children: {} - }} - }, - list: { - errors: [], - children: { - '0': { - errors: [{ - kind: 'unexpected-key', - key: 'archive' - }], - children: {} - } - } - } - } - }, - } - } - - client.submitAndWait(invalidRequest as any as ledger.SubmitAndWaitRequest, error => { - expect(error).to.not.be.null; - expect(JSON.parse(error!.message)).to.deep.equal(expectedValidationTree); - done(); - }); - - }); - -}); diff --git a/language-support/js/daml-ledger/tests/command_completion_client.spec.ts b/language-support/js/daml-ledger/tests/command_completion_client.spec.ts deleted file mode 100644 index 903fc74fe37..00000000000 --- a/language-support/js/daml-ledger/tests/command_completion_client.spec.ts +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { test } from 'mocha'; -import { expect, assert } from 'chai'; -import * as sinon from 'sinon'; - -import { MockedCommandCompletionClient } from './mock' - -import * as ledger from '../src'; -import * as grpc from 'daml-grpc'; -import { reporting } from '../src'; -import * as mapping from '../src/mapping'; -import * as validation from '../src/validation'; - -describe('CommandCompletionClient', () => { - - const ledgerId = 'cafebabe'; - - const completion1: ledger.CompletionStreamResponse = { - checkpoint: { - offset: { - absolute: 'some-absolute-offset' - }, - recordTime: { seconds: 47, nanoseconds: 42 } - }, - completions: [ - { - commandId: 'befehl-1', - status: { - code: 404, - details: [], - message: 'the sound of silence' - } - } - ] - } - - const completion2: ledger.CompletionStreamResponse = { - checkpoint: { - offset: { - boundary: ledger.LedgerOffset.Boundary.END - }, - recordTime: { seconds: 99, nanoseconds: 999 } - }, - completions: [ - { - commandId: 'befehl-21', - status: { - code: 443, - details: [ - { - typeUrl: 'some-type-url', - value: 'cafebabe' - } - ], - message: 'chatty chatty' - } - }, - { - commandId: 'befehl-22', - status: { - code: 444, - details: [ - { - typeUrl: 'some-other-type-url', - value: 'deadbeef' - } - ], - message: 'fully fully' - } - } - ] - } - - const dummyCompletions = [completion1, completion2]; - - const dummyCompletionsMessage: grpc.CompletionStreamResponse[] = - dummyCompletions.map((object) => mapping.CompletionStreamResponse.toMessage(object)); - - const dummyEnd: ledger.CompletionEndResponse = { - offset: { - absolute: 'some-absolute-offset' - } - } - const dummyEndMessage = mapping.CompletionEndResponse.toMessage(dummyEnd); - - const lastRequestSpy = sinon.spy(); - const mockedGrpcClient = new MockedCommandCompletionClient(dummyCompletionsMessage, dummyEndMessage, lastRequestSpy); - const client = new ledger.CommandCompletionClient(ledgerId, mockedGrpcClient, reporting.JSONReporter); - - afterEach(() => { - sinon.restore(); - lastRequestSpy.resetHistory(); - }); - - test('[4.1] When the completion end is requested, it is provided from the ledger', (done) => { - - client.completionEnd((error, response) => { - expect(error).to.be.null; - expect(response).to.deep.equal(dummyEnd); - done(); - }); - - }); - - test('[4.2] The completion end is requested with the correct ledger ID', (done) => { - - client.completionEnd((error, _response) => { - expect(error).to.be.null; - assert(lastRequestSpy.calledOnce); - expect(lastRequestSpy.lastCall.args).to.have.length(1); - expect(lastRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.CompletionEndRequest); - const request = lastRequestSpy.lastCall.lastArg as grpc.CompletionEndRequest; - expect(request.getLedgerId()).to.equal(ledgerId); - done(); - }); - - }); - - test('[4.4] The completion stream is requested with the correct ledger ID, start offset, application ID and requested parties are provided with the request', (done) => { - - const request = { applicationId: 'foobar', offset: { absolute: '31' }, parties: ['alice', 'bob'] }; - const call = client.completionStream(request); - call.on('end', () => { - assert(lastRequestSpy.calledOnce); - expect(lastRequestSpy.lastCall.args).to.have.length(1); - expect(lastRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.CompletionStreamRequest); - const spiedRequest = lastRequestSpy.lastCall.lastArg as grpc.CompletionStreamRequest; - expect(spiedRequest.getLedgerId()).to.equal(ledgerId); - expect(mapping.CompletionStreamRequest.toObject(spiedRequest)).to.deep.equal(request); - done(); - }); - call.on('error', (error) => { - done(error); - }); - - }); - - test('Validation: an ill-formed message does not pass validation (getTransactions)', (done) => { - - const invalidRequest = { - applicationId: 'app', - offset: { - absolute: '1' - }, - parties: ['birthday', 42] - }; - - const expectedValidationTree: validation.Tree = { - errors: [], - children: { - applicationId: { - errors: [], - children: {} - }, - offset: { - errors: [], - children: { - absolute: { - errors: [], - children: {} - } - } - }, - parties: { - errors: [], - children: { - '0': { - errors: [], - children: {} - }, - '1': { - errors: [{ - kind: 'type-error', - expectedType: 'string', - actualType: 'number' - }], - children: {} - } - } - } - } - } - - let passed = false; - const call = client.completionStream(invalidRequest as any as ledger.CompletionStreamRequest); - call.on('data', (_data) => { - done(new Error('unexpected data received')); - }); - call.on('error', (error) => { - expect(JSON.parse(error.message)).to.deep.equal(expectedValidationTree); - passed = true; - }); - call.on('end', () => { - assert(passed); - done(); - }); - - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/command_submission_client.spec.ts b/language-support/js/daml-ledger/tests/command_submission_client.spec.ts deleted file mode 100644 index ba78b441bd3..00000000000 --- a/language-support/js/daml-ledger/tests/command_submission_client.spec.ts +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { test } from 'mocha'; -import { expect, assert } from 'chai'; -import * as sinon from 'sinon'; -import { MockedCommandSubmissionClient } from './mock'; -import * as ledger from '../src' -import * as grpc from 'daml-grpc' -import { reporting } from '../src'; -import * as mapping from '../src/mapping'; -import * as validation from '../src/validation'; - -describe('CommandSubmissionClient', () => { - - const ledgerId = 'watman'; - const latestRequestSpy = sinon.spy(); - const mockedGrpcClient = new MockedCommandSubmissionClient(latestRequestSpy); - const client = new ledger.CommandSubmissionClient(ledgerId, mockedGrpcClient, reporting.JSONReporter); - - const request: ledger.SubmitRequest = { - commands: { - applicationId: '2345', - commandId: 'sfdgsdfg', - ledgerEffectiveTime: { seconds: 5445, nanoseconds: 2342 }, - maximumRecordTime: { seconds: 656, nanoseconds: 634 }, - party: '452g245', - workflowId: 'dfg346', - list: [ - { - create: { - templateId: { packageId: 'fgdfg', moduleName: 'dwgwdfg', entityName: 'alkhksjhd' }, - arguments: { - recordId: { packageId: 'g3g42', moduleName: '314tgg5', entityName: '235lkj23' }, - fields: { - contract: { contractId: 'sdg4tr34' }, - someFlag: { bool: true } - } - } - } - }, { - exercise: { - choice: 'sdfgv34g', - argument: { - decimal: '999' - }, - contractId: 'f4f34f34f', - templateId: { packageId: 'f1234f34f', moduleName: '341f43f3', entityName: '239874hb' } - } - } - ] - } - }; - - afterEach(() => { - sinon.restore(); - latestRequestSpy.resetHistory(); - }); - - test('[3.1] When a command is sent to the binding, it is sent to the ledger', (done) => { - client.submit(request, (error, _) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.SubmitRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.SubmitRequest; - expect(mapping.SubmitRequest.toObject(spiedRequest)).to.deep.equal(request); - done(); - }); - }); - - test('[3.2] Command is sent to the correct ledger ID', (done) => { - client.submit(request, (error, _) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.SubmitRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.SubmitRequest; - expect(spiedRequest.getCommands()!.getLedgerId()).to.equal(ledgerId); - done(); - }); - }); - - test('Validation: an ill-formed message does not pass validation (submit)', (done) => { - - const invalidRequest = { - commands: { - applicationId: 'app', - commandId: 'cmd', - party: 'birthday', - ledgerEffectiveTime: { seconds: 0, nanoseconds: 1 }, - maximumRecordTime: { seconds: 1, nanoseconds: 2 }, - list: [ - { - archive: { - templateId: { - name: 'foo', - packageId: 'bar' - } - } - } - ] - } - }; - - const expectedValidationTree: validation.Tree = { - errors: [], - children: { - commands: { - errors: [], - children: { - applicationId: { - errors: [], - children: {} - }, - commandId: { - errors: [], - children: {} - }, - party: { - errors: [], - children: {} - }, - ledgerEffectiveTime: { - errors: [], - children: { - seconds: { - errors: [], - children: {} - }, - nanoseconds: { - errors: [], - children: {} - }} - }, - maximumRecordTime: { - errors: [], - children: { - seconds: { - errors: [], - children: {} - }, - nanoseconds: { - errors: [], - children: {} - }} - }, - list: { - errors: [], - children: { - '0': { - errors: [{ - kind: 'unexpected-key', - key: 'archive' - }], - children: {} - } - } - } - } - }, - } - } - - client.submit(invalidRequest as any as ledger.SubmitRequest, error => { - expect(error).to.not.be.null; - expect(JSON.parse(error!.message)).to.deep.equal(expectedValidationTree); - done(); - }); - - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/end_to_end_ssl.spec.ts b/language-support/js/daml-ledger/tests/end_to_end_ssl.spec.ts deleted file mode 100644 index e82dee68905..00000000000 --- a/language-support/js/daml-ledger/tests/end_to_end_ssl.spec.ts +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { test } from 'mocha'; -import { expect } from 'chai'; -import { MockedTransactionServer } from './mock'; -import * as ledger from '../src'; -import * as mapping from '../src/mapping'; -import { ServerCredentials } from 'grpc'; -import { rootCertChain, serverCertChain, serverPrivateKey, clientCertChain, clientPrivateKey } from './certs' - -describe("End-to-end SSL support", () => { - - const ledgerId = 'cafebabe'; - - const serverCredentials = ServerCredentials.createSsl(rootCertChain, [{ cert_chain: serverCertChain, private_key: serverPrivateKey }], true); - - const transactions: ledger.GetTransactionsResponse[] = [ - { - transactions: [ - { - commandId: 'some-command-id', - effectiveAt: { seconds: 47, nanoseconds: 42 }, - events: [], - offset: '42', - transactionId: 'some-transaction-id', - workflowId: 'some-workflow-id' - } - ] - } - ] - const server = new MockedTransactionServer(ledgerId, transactions.map((tx) => mapping.GetTransactionsResponse.toMessage(tx))); - const port = server.bind('localhost:0', serverCredentials); - - before(() => { - server.start(); - }); - - after(() => { - server.forceShutdown(); - }); - - test('Refuse connections from insecure clients', (done) => { - ledger.DamlLedgerClient.connect({ host: 'localhost', port: port }, (error, _) => { - expect(error).to.not.be.null; - done(); - }); - }); - - test('Refuse connections from client providing an incomplete set of certificates', (done) => { - ledger.DamlLedgerClient.connect({ host: 'localhost', port: port, certChain: clientCertChain, privateKey: clientPrivateKey }, (error, _) => { - expect(error).to.not.be.null; - done(); - }); - }); - - test('Accept a connection from a secure client, have the correct ledgerId', (done) => { - ledger.DamlLedgerClient.connect({ host: 'localhost', port: port, rootCerts: rootCertChain, certChain: clientCertChain, privateKey: clientPrivateKey }, (error, client) => { - expect(error).to.be.null; - expect(client!.ledgerId).to.equal(ledgerId); - done(); - }); - }); - - test('Accept a connection from a secure client, read data from clients', (done) => { - ledger.DamlLedgerClient.connect({ host: 'localhost', port: port, rootCerts: rootCertChain, certChain: clientCertChain, privateKey: clientPrivateKey }, (error, client) => { - expect(error).to.be.null; - const call = client!.transactionClient.getTransactions({ filter: { filtersByParty: {} }, begin: { absolute: '0' } }); - let counter = 0; - call.on('error', (error) => { - done(error); - }); - call.on('data', (response) => { - expect(response).to.deep.equal(transactions[counter]); - counter = counter + 1; - }) - call.on('end', () => { - expect(counter).to.equal(transactions.length) - done(); - }); - }); - }); - -}); - diff --git a/language-support/js/daml-ledger/tests/end_to_end_stream.spec.ts b/language-support/js/daml-ledger/tests/end_to_end_stream.spec.ts deleted file mode 100644 index c8b348201b3..00000000000 --- a/language-support/js/daml-ledger/tests/end_to_end_stream.spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { MockedTransactionServer } from './mock'; -import { ServerCredentials } from 'grpc'; -import * as mapping from '../src/mapping'; -import * as ledger from '../src'; -import { expect } from 'chai'; - -describe('End-to-end stream', () => { - - const ledgerId = 'cafebabe'; - - const transactions: ledger.GetTransactionsResponse[] = [ - { - transactions: [ - { - commandId: 'some-command-id', - effectiveAt: { seconds: 47, nanoseconds: 42 }, - events: [], - offset: '42', - transactionId: 'some-transaction-id', - workflowId: 'some-workflow-id' - } - ] - } - ] - const server = new MockedTransactionServer(ledgerId, transactions.map((tx) => mapping.GetTransactionsResponse.toMessage(tx))); - const port = server.bind('0.0.0.0:0', ServerCredentials.createInsecure()); - - before(() => { - server.start(); - }); - - after(() => { - server.forceShutdown(); - }); - - it('should correctly move one transaction end-to-end', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - const call = client!.transactionClient.getTransactions({ filter: { filtersByParty: {} }, begin: { absolute: '0' } }); - let counter = 0; - call.on('error', (error) => { - done(error); - }); - call.on('data', (response) => { - expect(response).to.deep.equal(transactions[counter]); - counter = counter + 1; - }) - call.on('end', () => { - expect(counter).to.equal(transactions.length) - done(); - }); - }); - }) - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/ledger_client.spec.ts b/language-support/js/daml-ledger/tests/ledger_client.spec.ts deleted file mode 100644 index b35f093fe1e..00000000000 --- a/language-support/js/daml-ledger/tests/ledger_client.spec.ts +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect, assert } from 'chai'; -import { SpyingDummyServer } from './mock'; -import * as ledger from '../src'; -import * as sinon from 'sinon'; -import { ServerCredentials } from 'grpc'; - -describe("DamlLedgerClient", () => { - - const ledgerId = 'cafebabe'; - - const spy = sinon.spy(); - const server = new SpyingDummyServer(ledgerId, spy); - const port = server.bind('0.0.0.0:0', ServerCredentials.createInsecure()); - - const emptyCommands = { - commands: { - applicationId: '', - commandId: '', party: '', - ledgerEffectiveTime: { seconds: 0, nanoseconds: 0 }, - maximumRecordTime: { seconds: 0, nanoseconds: 0 }, - list: [] - } - }; - - before(() => { - server.start(); - }); - - after(() => { - server.forceShutdown(); - }); - - beforeEach(() => { - spy.resetHistory(); - sinon.restore(); - }); - - it('should properly initialize the ledgerId', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - expect(client!.ledgerId).to.equal(ledgerId); - done(); - }); - }); - - it('should correctly set the ledgerId of the ActiveContractService', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - const call = client!.activeContractsClient.getActiveContracts({ verbose: true, filter: { filtersByParty: {} } }); - call.on('end', () => { - expect(spy.calledOnceWithExactly(ledgerId)).to.be.true - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the CommandService', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.commandClient.submitAndWait(emptyCommands, (error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the CommandCompletionService (completionStream)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - const call = client!.commandCompletionClient.completionStream({ applicationId: '', offset: { absolute: '0' }, parties: [] }); - call.on('end', () => { - expect(spy.calledOnceWithExactly(ledgerId)).to.be.true - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the CommandCompletionService (completionEnd)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.commandCompletionClient.completionEnd((error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }) - }); - - it('should correctly set the ledgerId of the CommandSubmissionService', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.commandSubmissionClient.submit(emptyCommands, (error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the PackageService (listPackages)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.packageClient.listPackages((error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the PackageService (getPackage)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.packageClient.getPackage('', (error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the PackageService (getPackageStatus)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.packageClient.getPackageStatus('', (error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the LedgerConfigurationService', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - const call = client!.ledgerConfigurationClient.getLedgerConfiguration() - call.on('end', () => { - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the TransactionsClient (getLedgerEnd)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.transactionClient.getLedgerEnd((error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the TransactionsClient (getTransactionByEventId)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.transactionClient.getTransactionByEventId({ eventId: '', requestingParties: [] }, (error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the TransactionsClient (getTransactionById)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.transactionClient.getTransactionById({ transactionId: '', requestingParties: [] }, (error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the TransactionsClient (getTransactions)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - const call = client!.transactionClient.getTransactions({ filter: { filtersByParty: {} }, begin: { absolute: '0' } }) - call.on('end', () => { - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the TransactionsClient (getTransactionTrees)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - const call = client!.transactionClient.getTransactionTrees({ filter: { filtersByParty: {} }, begin: { absolute: '0' } }) - call.on('end', () => { - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the TimeClient (getTime)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - const call = client!.timeClient.getTime(); - call.on('end', () => { - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the TimeClient (setTime)', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.timeClient.setTime({ currentTime: { seconds: 0, nanoseconds: 0 }, newTime: { seconds: 0, nanoseconds: 1 } }, (error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - - it('should correctly set the ledgerId of the ResetClient', (done) => { - ledger.DamlLedgerClient.connect({ host: '0.0.0.0', port: port }, (error, client) => { - expect(error).to.be.null; - client!.resetClient.reset((error, _) => { - expect(error).to.be.null; - assert(spy.calledOnceWithExactly(ledgerId)); - done(); - }); - }); - }); - -}); diff --git a/language-support/js/daml-ledger/tests/ledger_configuration_client.spec.ts b/language-support/js/daml-ledger/tests/ledger_configuration_client.spec.ts deleted file mode 100644 index da3a69ff137..00000000000 --- a/language-support/js/daml-ledger/tests/ledger_configuration_client.spec.ts +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { test } from 'mocha'; -import { expect, assert } from 'chai'; -import * as grpc from 'daml-grpc'; -import * as ledger from '../src'; -import { MockedLedgerConfigurationClient } from './mock'; -import * as mapping from '../src/mapping'; -import * as sinon from 'sinon'; - -describe('LedgerConfigurationClient', () => { - - const ledgerId = 'cafebabe'; - const latestRequestSpy = sinon.spy(); - const responses: ledger.GetLedgerConfigurationResponse[] = [ - { - config: { - maxTtl: { - seconds: 10, - nanoseconds: 10 - }, - minTtl: { - seconds: 5, - nanoseconds: 5 - } - } - }, - { - config: { - maxTtl: { - seconds: 20, - nanoseconds: 20 - }, - minTtl: { - seconds: 2, - nanoseconds: 2 - } - } - } - ] - const responseMessages = responses.map((response) => mapping.GetLedgerConfigurationResponse.toMessage(response)); - const mockedGrpcClient = new MockedLedgerConfigurationClient(responseMessages, latestRequestSpy); - const client = new ledger.LedgerConfigurationClient(ledgerId, mockedGrpcClient); - - afterEach(() => { - sinon.restore(); - latestRequestSpy.resetHistory(); - }); - - test('[5.1] When the configuration is requested, then the configuration is returned from the ledger', (done) => { - - const call = client.getLedgerConfiguration(); - let counter = 0; - call.on('error', (error) => { - done(error); - }); - call.on('data', (response) => { - expect(response).to.deep.equal(responses[counter]); - counter = counter + 1; - }); - call.on('end', () => { - expect(counter).to.equal(responses.length); - done(); - }); - - }); - - test('[5.2] The configuration is requested with the correct ledger ID', (done) => { - - const call = client.getLedgerConfiguration(); - call.on('error', (error) => { - done(error); - }); - call.on('end', () => { - assert(latestRequestSpy.calledOnce, 'The latestRequestSpy has not been called exactly once'); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.GetLedgerConfigurationRequest); - const request = latestRequestSpy.lastCall.lastArg as grpc.GetLedgerConfigurationRequest; - expect(request.getLedgerId()).to.equal(ledgerId); - done(); - }); - - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/ledger_identity_client.spec.ts b/language-support/js/daml-ledger/tests/ledger_identity_client.spec.ts deleted file mode 100644 index f1df37edd9c..00000000000 --- a/language-support/js/daml-ledger/tests/ledger_identity_client.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { test } from 'mocha'; -import { expect } from 'chai'; -import { MockedLedgerIdentityClient } from './mock'; -import * as ledger from '../src'; - -describe("LedgerIdentityClient", () => { - - const ledgerId = 'cafebabe'; - - test("[6.1] When the ledger ID is requested, it is returned from the ledger", (done) => { - const lis = new MockedLedgerIdentityClient(ledgerId); - const lic = new ledger.LedgerIdentityClient(lis); - lic.getLedgerIdentity((error, response) => { - expect(error).to.be.null; - expect(response!.ledgerId).to.equal(ledgerId); - done(); - }); - }); - -}); diff --git a/language-support/js/daml-ledger/tests/mapping/mapping.spec.ts b/language-support/js/daml-ledger/tests/mapping/mapping.spec.ts deleted file mode 100644 index 903fffce94d..00000000000 --- a/language-support/js/daml-ledger/tests/mapping/mapping.spec.ts +++ /dev/null @@ -1,1246 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect } from 'chai'; - -import * as mapping from '../../src/mapping'; -import * as ledger from '../../src'; -import * as grpc from 'daml-grpc'; - -import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb'; -import { Duration } from 'google-protobuf/google/protobuf/duration_pb'; -import { Empty } from 'google-protobuf/google/protobuf/empty_pb'; -import { Any } from 'google-protobuf/google/protobuf/any_pb'; - -describe("Mapping", () => { - - const packageId = 'packageId'; - const moduleName = 'moduleName'; - const entityName = 'entityName'; - - const identifierObject: ledger.Identifier = { - packageId: packageId, - moduleName: moduleName, - entityName: entityName, - } - - const inclusiveFiltersObject: ledger.InclusiveFilters = { - templateIds: [identifierObject] - } - - const filtersObject: ledger.Filters = { - inclusive: inclusiveFiltersObject - } - - const transactionFilterObject: ledger.TransactionFilter = { - filtersByParty: { - 'Alice': filtersObject, - 'Bob': {} - } - } - - const identifierMessage = new grpc.Identifier(); - identifierMessage.setPackageId(packageId); - identifierMessage.setModuleName(moduleName); - identifierMessage.setEntityName(entityName); - - const inclusiveFiltersMessage = new grpc.InclusiveFilters(); - inclusiveFiltersMessage.setTemplateIdsList([identifierMessage]); - - const filtersMessage = new grpc.Filters(); - filtersMessage.setInclusive(inclusiveFiltersMessage); - - const transactionFilterMessage = new grpc.TransactionFilter(); - transactionFilterMessage.getFiltersByPartyMap().set('Alice', filtersMessage); - transactionFilterMessage.getFiltersByPartyMap().set('Bob', new grpc.Filters()); - - const textValue = new grpc.Value(); - textValue.setText('text'); - const textField = new grpc.RecordField(); - textField.setLabel('textLabel'); - textField.setValue(textValue); - const dateValue = new grpc.Value(); - dateValue.setDate(40); - const dateField = new grpc.RecordField(); - dateField.setLabel('dateLabel'); - dateField.setValue(dateValue); - const partyValue = new grpc.Value(); - partyValue.setParty('Bob'); - const partyField = new grpc.RecordField(); - partyField.setLabel('partyLabel'); - partyField.setValue(partyValue); - const nestedRecord = new grpc.Record(); - nestedRecord.setRecordId(identifierMessage); - nestedRecord.setFieldsList([partyField]); - const nestedValue = new grpc.Value(); - nestedValue.setRecord(nestedRecord); - const nestedField = new grpc.RecordField(); - nestedField.setLabel('nestedLabel'); - nestedField.setValue(nestedValue); - const recordMessage = new grpc.Record(); - recordMessage.setRecordId(identifierMessage); - recordMessage.setFieldsList([textField, dateField, nestedField]); - - const recordObject: ledger.Record = { - recordId: identifierObject, - fields: { - textLabel: { text: 'text' }, - dateLabel: { date: '40' }, - nestedLabel: { - record: { - recordId: identifierObject, - fields: { - partyLabel: { party: 'Bob' } - } - } - } - } - } - - const createCommandMessage = new grpc.CreateCommand(); - createCommandMessage.setTemplateId(identifierMessage); - createCommandMessage.setCreateArguments(recordMessage); - const createCommandObject: ledger.CreateCommand = { - templateId: identifierObject, - arguments: recordObject - } - - const choiceArgument = new grpc.Value(); - choiceArgument.setBool(true); - const exerciseCommandMessage = new grpc.ExerciseCommand(); - exerciseCommandMessage.setTemplateId(identifierMessage); - exerciseCommandMessage.setContractId('contractId2'); - exerciseCommandMessage.setChoice('choice'); - exerciseCommandMessage.setChoiceArgument(choiceArgument); - const exerciseCommandObject: ledger.ExerciseCommand = { - templateId: identifierObject, - contractId: 'contractId2', - choice: 'choice', - argument: { bool: true } - }; - - - const command1 = new grpc.Command(); - command1.setCreate(createCommandMessage); - const command2 = new grpc.Command(); - command2.setExercise(exerciseCommandMessage); - const ledgerEffectiveTime = new Timestamp(); - ledgerEffectiveTime.setSeconds(60); - ledgerEffectiveTime.setNanos(61); - const maximumRecordTime = new Timestamp(); - maximumRecordTime.setSeconds(62); - maximumRecordTime.setNanos(63); - const commandsMessage = new grpc.Commands(); - commandsMessage.setApplicationId('applicationId'); - commandsMessage.setCommandId('commandId'); - commandsMessage.setLedgerEffectiveTime(ledgerEffectiveTime); - commandsMessage.setMaximumRecordTime(maximumRecordTime); - commandsMessage.setParty('Alice'); - commandsMessage.setWorkflowId('workflowId'); - commandsMessage.setCommandsList([command1, command2]); - const commandsObject: ledger.Commands = { - applicationId: 'applicationId', - commandId: 'commandId', - ledgerEffectiveTime: { seconds: 60, nanoseconds: 61 }, - maximumRecordTime: { seconds: 62, nanoseconds: 63 }, - party: 'Alice', - workflowId: 'workflowId', - list: [{ create: createCommandObject }, { exercise: exerciseCommandObject }] - } - - const createdEventMessage = new grpc.CreatedEvent(); - createdEventMessage.setEventId('eventId'); - createdEventMessage.setContractId('contractId'); - createdEventMessage.setTemplateId(identifierMessage); - createdEventMessage.setCreateArguments(recordMessage); - createdEventMessage.setWitnessPartiesList(['Alice', 'Bob']); - const createdEventObject: ledger.CreatedEvent = { - eventId: 'eventId', - contractId: 'contractId', - templateId: identifierObject, - arguments: recordObject, - witnessParties: ['Alice', 'Bob'] - }; - - itShouldConvert("Identifier", () => { - mappingCheck(mapping.Identifier, identifierMessage, identifierObject); - }); - - itShouldConvert('InclusiveFilters', () => { - mappingCheck(mapping.InclusiveFilters, inclusiveFiltersMessage, inclusiveFiltersObject); - }); - - itShouldConvert('Filters', () => { - mappingCheck(mapping.Filters, filtersMessage, filtersObject); - }); - - itShouldConvert('TransactionsFilter', () => { - mappingCheck(mapping.TransactionFilter, transactionFilterMessage, transactionFilterObject); - }); - - itShouldConvert('LedgerOffset.Absolute', () => { - const absoluteObject = { absolute: '20' }; - const beginObject = { boundary: ledger.LedgerOffset.Boundary.BEGIN }; - const endObject = { boundary: ledger.LedgerOffset.Boundary.END }; - const absoluteMessage = new grpc.LedgerOffset(); - absoluteMessage.setAbsolute('20'); - const beginMessage = new grpc.LedgerOffset(); - beginMessage.setBoundary(grpc.LedgerOffset.LedgerBoundary.LEDGER_BEGIN); - const endMessage = new grpc.LedgerOffset(); - endMessage.setBoundary(grpc.LedgerOffset.LedgerBoundary.LEDGER_END); - expect(mapping.LedgerOffset.toMessage(absoluteObject)).to.deep.equal(absoluteMessage); - expect(mapping.LedgerOffset.toMessage(beginObject)).to.deep.equal(beginMessage); - expect(mapping.LedgerOffset.toMessage(endObject)).to.deep.equal(endMessage); - expect(mapping.LedgerOffset.toObject(absoluteMessage)).to.deep.equal(absoluteObject); - expect(mapping.LedgerOffset.toObject(beginMessage)).to.deep.equal(beginObject); - expect(mapping.LedgerOffset.toObject(endMessage)).to.deep.equal(endObject); - }); - - itShouldConvert('Timestamp', () => { - const timestampMessage = new Timestamp(); - timestampMessage.setSeconds(20); - timestampMessage.setNanos(21); - - const timestampObject: ledger.Timestamp = { - seconds: 20, - nanoseconds: 21 - }; - - mappingCheck(mapping.Timestamp, timestampMessage, timestampObject); - }); - - itShouldConvert('Value(Bool)', () => { - const boolMessage = new grpc.Value(); - boolMessage.setBool(true); - const boolObject = { bool: true }; - mappingCheck(mapping.Value, boolMessage, boolObject); - }); - - itShouldConvert('Value(ContractId)', () => { - const contractIdMessage = new grpc.Value(); - contractIdMessage.setContractId('contractId'); - const contractIdObject: ledger.Value = { contractId: 'contractId' }; - mappingCheck(mapping.Value, contractIdMessage, contractIdObject); - }); - - itShouldConvert('Value(Date)', () => { - const dateMessage = new grpc.Value(); - dateMessage.setDate(1); - const dateObject: ledger.Value = { date: '1' } - mappingCheck(mapping.Value, dateMessage, dateObject); - }); - - itShouldConvert('Value(Decimal)', () => { - const decimalMessage = new grpc.Value(); - decimalMessage.setDecimal('30'); - const decimalObject: ledger.Value = { decimal: '30' }; - mappingCheck(mapping.Value, decimalMessage, decimalObject); - }); - - itShouldConvert('Value(Int64)', () => { - const int64Message = new grpc.Value(); - int64Message.setInt64('40'); - const int64Object: ledger.Value = { int64: '40' }; - mappingCheck(mapping.Value, int64Message, int64Object); - }); - - itShouldConvert('Value(List)', () => { - const emptyList = new grpc.List(); - emptyList.setElementsList([]); - const emptyListMessage = new grpc.Value(); - emptyListMessage.setList(emptyList); - const emptyListObject = { list: [] }; - mappingCheck(mapping.Value, emptyListMessage, emptyListObject); - - const dateMessage = new grpc.Value(); - dateMessage.setDate(2); - const singletonList = new grpc.List(); - singletonList.setElementsList([dateMessage]); - const singletonListMessage = new grpc.Value(); - singletonListMessage.setList(singletonList); - const singletonListObject: ledger.Value = { list: [{ date: '2' }] }; - mappingCheck(mapping.Value, singletonListMessage, singletonListObject); - }); - - itShouldConvert('Value(Party)', () => { - const partyMessage = new grpc.Value(); - partyMessage.setParty('Alice'); - const partyObject = { party: 'Alice' }; - mappingCheck(mapping.Value, partyMessage, partyObject); - }); - - itShouldConvert('Value(Record)', () => { - const recordValueMessage = new grpc.Value(); - recordValueMessage.setRecord(recordMessage); - const recordValueObject: ledger.Value = { record: recordObject }; - mappingCheck(mapping.Value, recordValueMessage, recordValueObject); - }); - - itShouldConvert('Value(Text)', () => { - const textMessage = new grpc.Value(); - textMessage.setText('text2'); - const textObject: ledger.Value = { text: 'text2' }; - mappingCheck(mapping.Value, textMessage, textObject); - }); - - itShouldConvert('Value(Timestamp)', () => { - const timestampMessage = new grpc.Value(); - timestampMessage.setTimestamp('50'); - const timestampObject: ledger.Value = { timestamp: '50' }; - mappingCheck(mapping.Value, timestampMessage, timestampObject); - }); - - itShouldConvert('Value(Unit)', () => { - const unitMessage = new grpc.Value(); - unitMessage.setUnit(new Empty()); - expect(unitMessage.hasUnit()).to.be.true; - const unitObject: ledger.Value = { unit: {} }; - mappingCheck(mapping.Value, unitMessage, unitObject); - }); - - itShouldConvert('Value(Variant)', () => { - const recordValueMessage = new grpc.Value(); - recordValueMessage.setRecord(recordMessage); - const variant = new grpc.Variant(); - variant.setConstructor('constructor'); - variant.setVariantId(identifierMessage); - variant.setValue(recordValueMessage); - const variantMessage = new grpc.Value(); - variantMessage.setVariant(variant); - const variantObject: ledger.Value = { - variant: { - constructor: 'constructor', - variantId: identifierObject, - value: { record: recordObject } - } - } - mappingCheck(mapping.Value, variantMessage, variantObject); - }); - - itShouldConvert('Record', () => { - mappingCheck(mapping.Record, recordMessage, recordObject); - }); - - itShouldConvert('Command.Create', () => { - mappingCheck(mapping.CreateCommand, createCommandMessage, createCommandObject); - }); - - itShouldConvert('Command.Exercise', () => { - mappingCheck(mapping.ExerciseCommand, exerciseCommandMessage, exerciseCommandObject); - }); - - itShouldConvert('Command', () => { - const commandMessage = new grpc.Command(); - commandMessage.setCreate(createCommandMessage); - mappingCheck(mapping.Command, commandMessage, { create: createCommandObject }); - - const commandMessage2 = new grpc.Command(); - commandMessage2.setExercise(exerciseCommandMessage); - mappingCheck(mapping.Command, commandMessage2, { exercise: exerciseCommandObject }); - }); - - itShouldConvert('Commands', () => { - mappingCheck(mapping.Commands, commandsMessage, commandsObject); - }); - - itShouldConvert('SubmitRequest', () => { - const submitRequestMessage = new grpc.SubmitRequest(); - submitRequestMessage.setCommands(commandsMessage); - const submitRequestObject = { commands: commandsObject }; - mappingCheck(mapping.SubmitRequest, submitRequestMessage, submitRequestObject); - }); - - itShouldConvert('GetTransactionsRequest', () => { - const offset = new grpc.LedgerOffset(); - offset.setAbsolute('70'); - const requestMessage = new grpc.GetTransactionsRequest(); - requestMessage.setBegin(offset); - requestMessage.setFilter(transactionFilterMessage); - requestMessage.setVerbose(true); - const requestObject: ledger.GetTransactionsRequest = { - begin: { absolute: '70' }, - filter: transactionFilterObject, - verbose: true - } - mappingCheck(mapping.GetTransactionsRequest, requestMessage, requestObject); - requestMessage.setEnd(offset); - requestObject.end = requestObject.begin; - mappingCheck(mapping.GetTransactionsRequest, requestMessage, requestObject); - }); - - itShouldConvert('GetActiveContractsRequest', () => { - const requestMessage = new grpc.GetActiveContractsRequest(); - requestMessage.setVerbose(true); - requestMessage.setFilter(transactionFilterMessage); - const requestObject: ledger.GetActiveContractsRequest = { - verbose: true, - filter: transactionFilterObject - }; - mappingCheck(mapping.GetActiveContractsRequest, requestMessage, requestObject); - }); - - itShouldConvert('CreatedEvent', () => { - mappingCheck(mapping.CreatedEvent, createdEventMessage, createdEventObject); - }); - - itShouldConvert('GetActiveContractsResponse', () => { - const responseMessage = new grpc.GetActiveContractsResponse(); - responseMessage.setOffset('7'); - responseMessage.setWorkflowId('wid'); - responseMessage.setActiveContractsList([createdEventMessage]); - const responseObject: ledger.GetActiveContractsResponse = { - offset: { absolute: '7' }, - workflowId: 'wid', - activeContracts: [createdEventObject] - }; - mappingCheck(mapping.GetActiveContractsResponse, responseMessage, responseObject); - }); - - itShouldConvert('GetLedgerIdentityResponse', () => { - const responseMessage = new grpc.GetLedgerIdentityResponse(); - responseMessage.setLedgerId('ledgerId2'); - const responseObject: ledger.GetLedgerIdentityResponse = { - ledgerId: 'ledgerId2' - } - mappingCheck(mapping.GetLedgerIdentityResponse, responseMessage, responseObject); - }); - - itShouldConvert('GetPackageResponse', () => { - const responseMessage = new grpc.GetPackageResponse(); - responseMessage.setArchivePayload('cafebabe'); - responseMessage.setHash('deadbeef'); - responseMessage.setHashFunction(grpc.HashFunction.SHA256); - const responseObject: ledger.GetPackageResponse = { - archivePayload: 'cafebabe', - hash: 'deadbeef', - hashFunction: ledger.HashFunction.SHA256 - }; - mappingCheck(mapping.GetPackageResponse, responseMessage, responseObject); - }); - - itShouldConvert('ListPackagesResponse', () => { - const responseMessage = new grpc.ListPackagesResponse(); - responseMessage.setPackageIdsList(['package1', 'package2']); - const responseObject: ledger.ListPackagesResponse = { - packageIds: ['package1', 'package2'] - }; - mappingCheck(mapping.ListPackagesResponse, responseMessage, responseObject); - }); - - itShouldConvert('SubmitAndWaitRequest', () => { - const submitRequestMessage = new grpc.SubmitAndWaitRequest() - submitRequestMessage.setCommands(commandsMessage); - const submitRequestObject = { commands: commandsObject }; - mappingCheck(mapping.SubmitAndWaitRequest, submitRequestMessage, submitRequestObject); - }); - - itShouldConvert('CompletionEndResponse', () => { - const message = new grpc.CompletionEndResponse(); - const offset = new grpc.LedgerOffset(); - offset.setAbsolute('20'); - message.setOffset(offset) - const object: ledger.CompletionEndResponse = { offset: { absolute: '20' } }; - mappingCheck(mapping.CompletionEndResponse, message, object); - }); - - itShouldConvert('CompletionStreamRequest', () => { - const message = new grpc.CompletionStreamRequest(); - const offset = new grpc.LedgerOffset(); - offset.setAbsolute('20'); - message.setApplicationId('space-invaders-on-the-blockchain'); - message.setOffset(offset); - message.setPartiesList(['pool', 'birthday']); - const object: ledger.CompletionStreamRequest = { - applicationId: 'space-invaders-on-the-blockchain', - offset: { absolute: '20' }, - parties: ['pool', 'birthday'] - }; - mappingCheck(mapping.CompletionStreamRequest, message, object) - }) - - itShouldConvert('Checkpoint', () => { - const message = new grpc.Checkpoint(); - const offset = new grpc.LedgerOffset(); - offset.setAbsolute('20'); - message.setOffset(offset); - const recordTime = new Timestamp(); - recordTime.setSeconds(42); - recordTime.setNanos(999); - message.setRecordTime(recordTime); - const object: ledger.Checkpoint = { - offset: { absolute: '20' }, - recordTime: { seconds: 42, nanoseconds: 999 } - }; - mappingCheck(mapping.Checkpoint, message, object); - }); - - itShouldConvert('Any', () => { - const message = new Any(); - message.setValue('deadbeef'); - message.setTypeUrl('some-url'); - const object: ledger.Any = { - value: 'deadbeef', - typeUrl: 'some-url' - } - mappingCheck(mapping.Any, message, object); - }); - - itShouldConvert('Status', () => { - const message = new grpc.Status(); - message.setCode(42); - message.setMessage('we come in peace'); - const any1 = new Any(); - any1.setValue('deadbeef'); - any1.setTypeUrl('some-url'); - const any2 = new Any(); - any2.setValue('cafebabe'); - any2.setTypeUrl('some-other-url'); - message.setDetailsList([any1, any2]); - const object: ledger.Status = { - code: 42, - message: 'we come in peace', - details: [ - { - value: 'deadbeef', - typeUrl: 'some-url' - }, - { - value: 'cafebabe', - typeUrl: 'some-other-url' - } - ] - } - mappingCheck(mapping.Status, message, object); - }); - - itShouldConvert('Completion', () => { - const message = new grpc.Completion(); - message.setCommandId('befehl'); - - const status = new grpc.Status(); - status.setCode(42); - status.setMessage('we come in peace'); - const any1 = new Any(); - any1.setValue('deadbeef'); - any1.setTypeUrl('some-url'); - const any2 = new Any(); - any2.setValue('cafebabe'); - any2.setTypeUrl('some-other-url'); - status.setDetailsList([any1, any2]); - - message.setStatus(status); - - const object: ledger.Completion = { - commandId: 'befehl', - status: { - code: 42, - message: 'we come in peace', - details: [ - { - value: 'deadbeef', - typeUrl: 'some-url' - }, - { - value: 'cafebabe', - typeUrl: 'some-other-url' - } - ] - } - } - - mappingCheck(mapping.Completion, message, object) - }); - - itShouldConvert('CompletionStreamResponse', () => { - const message = new grpc.CompletionStreamResponse(); - - const checkpoint = new grpc.Checkpoint(); - const offset = new grpc.LedgerOffset(); - offset.setAbsolute('20'); - checkpoint.setOffset(offset); - const recordTime = new Timestamp(); - recordTime.setSeconds(42); - recordTime.setNanos(999); - checkpoint.setRecordTime(recordTime); - - message.setCheckpoint(checkpoint); - - const completion1 = new grpc.Completion(); - completion1.setCommandId('befehl1'); - - const status1 = new grpc.Status(); - status1.setCode(42); - status1.setMessage('we come in peace1'); - const any11 = new Any(); - any11.setValue('deadbeef'); - any11.setTypeUrl('some-url'); - const any12 = new Any(); - any12.setValue('cafebabe'); - any12.setTypeUrl('some-other-url'); - status1.setDetailsList([any11, any12]); - - completion1.setStatus(status1); - - const completion2 = new grpc.Completion(); - completion2.setCommandId('befehl2'); - - const status2 = new grpc.Status(); - status2.setCode(47); - status2.setMessage('we come in peace2'); - const any21 = new Any(); - any21.setValue('deadcafe'); - any21.setTypeUrl('some-url'); - const any22 = new Any(); - any22.setValue('cafebeef'); - any22.setTypeUrl('some-other-url'); - status2.setDetailsList([any21, any22]); - - completion2.setStatus(status2); - - message.setCompletionsList([completion1, completion2]); - - const object: ledger.CompletionStreamResponse = { - checkpoint: { - offset: { absolute: '20' }, - recordTime: { seconds: 42, nanoseconds: 999 } - }, - completions: [ - { - commandId: 'befehl1', - status: { - code: 42, - message: 'we come in peace1', - details: [ - { - value: 'deadbeef', - typeUrl: 'some-url' - }, - { - value: 'cafebabe', - typeUrl: 'some-other-url' - } - ] - } - }, - { - commandId: 'befehl2', - status: { - code: 47, - message: 'we come in peace2', - details: [ - { - value: 'deadcafe', - typeUrl: 'some-url' - }, - { - value: 'cafebeef', - typeUrl: 'some-other-url' - } - ] - } - } - ] - } - - mappingCheck(mapping.CompletionStreamResponse, message, object); - }); - - itShouldConvert('Duration', () => { - const message = new Duration(); - message.setSeconds(20); - message.setNanos(21); - - const object: ledger.Duration = { - seconds: 20, - nanoseconds: 21 - }; - - mappingCheck(mapping.Duration, message, object); - }); - - itShouldConvert('LedgerConfiguration', () => { - const maxTtl = new Duration(); - maxTtl.setSeconds(20); - maxTtl.setNanos(21); - - const minTtl = new Duration(); - minTtl.setSeconds(22); - minTtl.setNanos(23); - - const message = new grpc.LedgerConfiguration(); - message.setMaxTtl(maxTtl); - message.setMinTtl(minTtl); - - const object: ledger.LedgerConfiguration = { - maxTtl: { - seconds: 20, - nanoseconds: 21 - }, - minTtl: { - seconds: 22, - nanoseconds: 23 - } - } - - mappingCheck(mapping.LedgerConfiguration, message, object); - - }), - - itShouldConvert('GetLedgerConfigurationResponse', () => { - - const maxTtl = new Duration(); - maxTtl.setSeconds(20); - maxTtl.setNanos(21); - - const minTtl = new Duration(); - minTtl.setSeconds(22); - minTtl.setNanos(23); - - const ledgerConfiguration = new grpc.LedgerConfiguration(); - ledgerConfiguration.setMaxTtl(maxTtl); - ledgerConfiguration.setMinTtl(minTtl); - - const message = new grpc.GetLedgerConfigurationResponse(); - message.setLedgerConfiguration(ledgerConfiguration); - - const object: ledger.GetLedgerConfigurationResponse = { - config: { - maxTtl: { - seconds: 20, - nanoseconds: 21 - }, - minTtl: { - seconds: 22, - nanoseconds: 23 - } - } - } - mappingCheck(mapping.GetLedgerConfigurationResponse, message, object); - - }); - - itShouldConvert('GetLedgerEndResponse', () => { - const message = new grpc.GetLedgerEndResponse(); - const offset = new grpc.LedgerOffset(); - offset.setAbsolute('47'); - message.setOffset(offset); - const object: ledger.GetLedgerEndResponse = { - offset: { - absolute: '47' - } - } - mappingCheck(mapping.GetLedgerEndResponse, message, object); - }); - - itShouldConvert('GetTransactionByEventIdRequest', () => { - const message = new grpc.GetTransactionByEventIdRequest(); - message.setEventId('some-id'); - message.setRequestingPartiesList(['birthday', 'pool', 'house-warming']); - const object: ledger.GetTransactionByEventIdRequest = { - eventId: 'some-id', - requestingParties: ['birthday', 'pool', 'house-warming'] - } - mappingCheck(mapping.GetTransactionByEventIdRequest, message, object); - }); - - itShouldConvert('GetTransactionByIdRequest', () => { - const message = new grpc.GetTransactionByIdRequest(); - message.setTransactionId('some-id'); - message.setRequestingPartiesList(['birthday', 'pool', 'house-warming']); - const object: ledger.GetTransactionByIdRequest = { - transactionId: 'some-id', - requestingParties: ['birthday', 'pool', 'house-warming'] - } - mappingCheck(mapping.GetTransactionByIdRequest, message, object); - }); - - itShouldConvert('ArchivedEvent', () => { - const message = new grpc.ArchivedEvent(); - const templateId = new grpc.Identifier(); - templateId.setPackageId('pkg'); - templateId.setModuleName('alejandro'); - templateId.setEntityName('roberto'); - message.setTemplateId(templateId); - message.setContractId('some-contract-id'); - message.setEventId('some-event-id'); - message.setWitnessPartiesList(['birthday', 'pool', 'house-warming']); - const object: ledger.ArchivedEvent = { - contractId: 'some-contract-id', - eventId: 'some-event-id', - templateId: { packageId: 'pkg', moduleName: 'alejandro', entityName: 'roberto' }, - witnessParties: ['birthday', 'pool', 'house-warming'] - } - mappingCheck(mapping.ArchivedEvent, message, object); - }); - - itShouldConvert('ExercisedEvent', () => { - const message = new grpc.ExercisedEvent(); - const templateId = new grpc.Identifier(); - templateId.setPackageId('pkg'); - templateId.setModuleName('alejandro'); - templateId.setEntityName('roberto'); - message.setTemplateId(templateId); - message.setContractId('some-contract-id'); - message.setEventId('some-event-id'); - message.setActingPartiesList(['birthday']); - message.setWitnessPartiesList(['house-warming']); - const argument = new grpc.Value(); - const list = new grpc.List(); - const party = new grpc.Value(); - party.setParty('patricians'); - list.setElementsList([party]); - argument.setList(list); - message.setChoiceArgument(argument); - message.setChoice('freedom'); - message.setConsuming(true); - message.setContractCreatingEventId('father'); - message.setChildEventIdsList(['event']); - - const object: ledger.ExercisedEvent = { - contractId: 'some-contract-id', - eventId: 'some-event-id', - templateId: { packageId: 'pkg', moduleName: 'alejandro', entityName: 'roberto' }, - actingParties: ['birthday'], - argument: { list: [{ party: 'patricians' }] }, - childEventIds: ['event'], - choice: 'freedom', - consuming: true, - contractCreatingEventId: 'father', - witnessParties: ['house-warming'] - } - - mappingCheck(mapping.ExercisedEvent, message, object); - }); - - itShouldConvert('Event', () => { - - const templateId = new grpc.Identifier(); - templateId.setPackageId('pkg'); - templateId.setModuleName('alejandro'); - templateId.setEntityName('roberto'); - const event = new grpc.Event(); - const archived = new grpc.ArchivedEvent(); - const archivedTemplateId = new grpc.Identifier(); - archivedTemplateId.setPackageId('pkg'); - archivedTemplateId.setModuleName('alejandro'); - archivedTemplateId.setEntityName('roberto'); - archived.setTemplateId(templateId); - archived.setContractId('some-contract-id'); - archived.setEventId('some-event-id'); - archived.setWitnessPartiesList(['pool']); - event.setArchived(archived); - - const object = { - archived: { - contractId: 'some-contract-id', - eventId: 'some-event-id', - templateId: { packageId: 'pkg', moduleName: 'alejandro', entityName: 'roberto' }, - witnessParties: ['pool'] - } - }; - - mappingCheck(mapping.Event, event, object); - - }); - - itShouldConvert('TransactionTree', () => { - - const templateId = new grpc.Identifier(); - templateId.setPackageId('pkg'); - templateId.setModuleName('alejandro'); - templateId.setEntityName('roberto'); - const event = new grpc.TreeEvent(); - const created = new grpc.CreatedEvent() - const createdTemplateId = new grpc.Identifier(); - const createdArgs = new grpc.Record(); - const createdArgsField = new grpc.RecordField(); - const createdArgsFieldValue = new grpc.Value(); - createdArgsFieldValue.setContractId('boo'); - createdArgsField.setLabel('foo'); - createdArgsField.setValue(createdArgsFieldValue); - createdArgs.setFieldsList([createdArgsField]); - createdTemplateId.setPackageId('pkg'); - createdTemplateId.setModuleName('alejandro'); - createdTemplateId.setEntityName('roberto'); - created.setTemplateId(templateId); - created.setContractId('some-contract-id'); - created.setEventId('some-event-id'); - created.setWitnessPartiesList(['pool']); - created.setCreateArguments(createdArgs); - event.setCreated(created); - - const effectiveAt = new Timestamp(); - effectiveAt.setSeconds(10); - effectiveAt.setNanos(20); - const message = new grpc.TransactionTree(); - message.getEventsByIdMap().set('someId', event); - message.addRootEventIds('root'); - message.setCommandId('befehl'); - message.setEffectiveAt(effectiveAt); - message.setOffset('zero'); - message.setTransactionId('tx'); - message.setWorkflowId('workflow'); - message.getEventsByIdMap().set('someId', event); - - const object: ledger.TransactionTree = { - commandId: 'befehl', - effectiveAt: { seconds: 10, nanoseconds: 20 }, - eventsById: { - someId: { - created: { - templateId: { - packageId: 'pkg', - moduleName: 'alejandro', - entityName: 'roberto' - }, - contractId: 'some-contract-id', - eventId: 'some-event-id', - witnessParties: ['pool'], - arguments: { - fields: { - foo: { contractId: 'boo' } - } - } - } - } - }, - rootEventIds: ['root'], - offset: 'zero', - transactionId: 'tx', - workflowId: 'workflow' - } - - mappingCheck(mapping.TransactionTree, message, object); - - }); - - itShouldConvert('GetTransactionResponse', () => { - - const templateId = new grpc.Identifier(); - templateId.setPackageId('pkg'); - templateId.setModuleName('alejandro'); - templateId.setEntityName('roberto'); - const event = new grpc.TreeEvent(); - const created = new grpc.CreatedEvent() - const createdTemplateId = new grpc.Identifier(); - const createdArgs = new grpc.Record(); - const createdArgsField = new grpc.RecordField(); - const createdArgsFieldValue = new grpc.Value(); - createdArgsFieldValue.setContractId('boo'); - createdArgsField.setLabel('foo'); - createdArgsField.setValue(createdArgsFieldValue); - createdArgs.setFieldsList([createdArgsField]); - createdTemplateId.setPackageId('pkg'); - createdTemplateId.setModuleName('alejandro'); - createdTemplateId.setEntityName('roberto'); - created.setTemplateId(templateId); - created.setContractId('some-contract-id'); - created.setEventId('some-event-id'); - created.setWitnessPartiesList(['pool']); - created.setCreateArguments(createdArgs); - event.setCreated(created); - - const effectiveAt = new Timestamp(); - effectiveAt.setSeconds(10); - effectiveAt.setNanos(20); - const transaction = new grpc.TransactionTree(); - transaction.getEventsByIdMap().set('someId', event); - transaction.addRootEventIds('root'); - transaction.setCommandId('befehl'); - transaction.setEffectiveAt(effectiveAt); - transaction.setOffset('zero'); - transaction.setTransactionId('tx'); - transaction.setWorkflowId('workflow'); - transaction.getEventsByIdMap().set('someId', event); - - const message = new grpc.GetTransactionResponse() - message.setTransaction(transaction); - - const object: ledger.GetTransactionResponse = { - transaction: { - commandId: 'befehl', - effectiveAt: { seconds: 10, nanoseconds: 20 }, - eventsById: { - someId: { - created: { - templateId: { - packageId: 'pkg', - moduleName: 'alejandro', - entityName: 'roberto' - }, - contractId: 'some-contract-id', - eventId: 'some-event-id', - witnessParties: ['pool'], - arguments: { - fields: { - foo: { contractId: 'boo' } - } - } - } - } - }, - rootEventIds: ['root'], - offset: 'zero', - transactionId: 'tx', - workflowId: 'workflow' - } - }; - - mappingCheck(mapping.GetTransactionResponse, message, object); - - }); - - itShouldConvert('Transaction', () => { - - const templateId = new grpc.Identifier(); - templateId.setPackageId('pkg'); - templateId.setModuleName('alejandro'); - templateId.setEntityName('roberto'); - const event = new grpc.Event(); - const archived = new grpc.ArchivedEvent(); - const archivedTemplateId = new grpc.Identifier(); - archivedTemplateId.setPackageId('pkg'); - archivedTemplateId.setModuleName('alejandro'); - archivedTemplateId.setEntityName('roberto'); - archived.setTemplateId(templateId); - archived.setContractId('some-contract-id'); - archived.setEventId('some-event-id'); - archived.setWitnessPartiesList(['pool']); - event.setArchived(archived); - - const effectiveAt = new Timestamp(); - effectiveAt.setSeconds(10); - effectiveAt.setNanos(20); - const message = new grpc.Transaction(); - message.setEventsList([event]); - message.setCommandId('befehl'); - message.setEffectiveAt(effectiveAt); - message.setOffset('zero'); - message.setTransactionId('tx'); - message.setWorkflowId('workflow'); - - const object: ledger.Transaction = { - commandId: 'befehl', - effectiveAt: { seconds: 10, nanoseconds: 20 }, - events: [{ - archived: { - contractId: 'some-contract-id', - eventId: 'some-event-id', - templateId: { packageId: 'pkg', moduleName: 'alejandro', entityName: 'roberto' }, - witnessParties: ['pool'] - } - }], - offset: 'zero', - transactionId: 'tx', - workflowId: 'workflow' - } - - mappingCheck(mapping.Transaction, message, object); - - }); - - itShouldConvert('GetTransactionsResponse', () => { - - const templateId = new grpc.Identifier(); - templateId.setPackageId('pkg'); - templateId.setModuleName('alejandro'); - templateId.setEntityName('roberto'); - const event = new grpc.Event(); - const archived = new grpc.ArchivedEvent(); - const archivedTemplateId = new grpc.Identifier(); - archivedTemplateId.setPackageId('pkg'); - archivedTemplateId.setModuleName('alejandro'); - archivedTemplateId.setEntityName('roberto'); - archived.setTemplateId(templateId); - archived.setContractId('some-contract-id'); - archived.setEventId('some-event-id'); - archived.setWitnessPartiesList(['pool']); - event.setArchived(archived); - - const effectiveAt = new Timestamp(); - effectiveAt.setSeconds(10); - effectiveAt.setNanos(20); - const transaction = new grpc.Transaction(); - transaction.setEventsList([event]); - transaction.setCommandId('befehl'); - transaction.setEffectiveAt(effectiveAt); - transaction.setOffset('zero'); - transaction.setTransactionId('tx'); - transaction.setWorkflowId('workflow'); - - const message = new grpc.GetTransactionsResponse() - message.setTransactionsList([transaction]); - - const object: ledger.GetTransactionsResponse = { - transactions: [{ - commandId: 'befehl', - effectiveAt: { seconds: 10, nanoseconds: 20 }, - events: [{ - archived: { - contractId: 'some-contract-id', - eventId: 'some-event-id', - templateId: { packageId: 'pkg', moduleName: 'alejandro', entityName: 'roberto' }, - witnessParties: ['pool'] - } - }], - offset: 'zero', - transactionId: 'tx', - workflowId: 'workflow' - }] - }; - - mappingCheck(mapping.GetTransactionsResponse, message, object); - - }); - - itShouldConvert('GetTransactionTreesResponse', () => { - - const templateId = new grpc.Identifier(); - templateId.setPackageId('pkg'); - templateId.setModuleName('alejandro'); - templateId.setEntityName('roberto'); - const event = new grpc.TreeEvent(); - const created = new grpc.CreatedEvent() - const createdTemplateId = new grpc.Identifier(); - const createdArgs = new grpc.Record(); - const createdArgsField = new grpc.RecordField(); - const createdArgsFieldValue = new grpc.Value(); - createdArgsFieldValue.setContractId('boo'); - createdArgsField.setLabel('foo'); - createdArgsField.setValue(createdArgsFieldValue); - createdArgs.setFieldsList([createdArgsField]); - createdTemplateId.setPackageId('pkg'); - createdTemplateId.setModuleName('alejandro'); - createdTemplateId.setEntityName('roberto'); - created.setTemplateId(templateId); - created.setContractId('some-contract-id'); - created.setEventId('some-event-id'); - created.setWitnessPartiesList(['pool']); - created.setCreateArguments(createdArgs); - event.setCreated(created); - - const effectiveAt = new Timestamp(); - effectiveAt.setSeconds(10); - effectiveAt.setNanos(20); - const transaction = new grpc.TransactionTree(); - transaction.getEventsByIdMap().set('someId', event); - transaction.addRootEventIds('root'); - transaction.setCommandId('befehl'); - transaction.setEffectiveAt(effectiveAt); - transaction.setOffset('zero'); - transaction.setTransactionId('tx'); - transaction.setWorkflowId('workflow'); - transaction.getEventsByIdMap().set('someId', event); - - const message = new grpc.GetTransactionTreesResponse() - message.setTransactionsList([transaction]); - - const object: ledger.GetTransactionTreesResponse = { - transactions: [{ - commandId: 'befehl', - effectiveAt: { seconds: 10, nanoseconds: 20 }, - eventsById: { - someId: { - created: { - templateId: { - packageId: 'pkg', - moduleName: 'alejandro', - entityName: 'roberto' - }, - contractId: 'some-contract-id', - eventId: 'some-event-id', - witnessParties: ['pool'], - arguments: { - fields: { - foo: { contractId: 'boo' } - } - } - } - } - }, - rootEventIds: ['root'], - offset: 'zero', - transactionId: 'tx', - workflowId: 'workflow' - }] - }; - - mappingCheck(mapping.GetTransactionTreesResponse, message, object); - - }); - - itShouldConvert('GetTimeResponse', () => { - - const timestamp = new Timestamp(); - timestamp.setSeconds(20); - timestamp.setNanos(21); - - const message = new grpc.testing.GetTimeResponse(); - message.setCurrentTime(timestamp); - - const object: ledger.GetTimeResponse = { - currentTime: { - seconds: 20, - nanoseconds: 21 - } - }; - - mappingCheck(mapping.GetTimeResponse, message, object); - - }); - - itShouldConvert('SetTimeRequest', () => { - - const currentTime = new Timestamp(); - currentTime.setSeconds(20); - currentTime.setNanos(21); - - const newTime = new Timestamp(); - newTime.setSeconds(42); - newTime.setNanos(47); - - const message = new grpc.testing.SetTimeRequest(); - message.setCurrentTime(currentTime); - message.setNewTime(newTime); - - const object: ledger.SetTimeRequest = { - currentTime: { - seconds: 20, - nanoseconds: 21 - }, - newTime: { - seconds: 42, - nanoseconds: 47 - } - }; - - mappingCheck(mapping.SetTimeRequest, message, object); - - }); - - itShouldConvert('Optional', () => { - - const message = new grpc.Optional(); - const value = new grpc.Value(); - const none = new grpc.Optional(); - value.setOptional(none); - message.setValue(value); - - const object: ledger.Optional = { - value: { optional: {} } - }; - - mappingCheck(mapping.Optional, message, object); - - }); - -}); - -function itShouldConvert(typeName: String, fn?: Mocha.Func): Mocha.Test { - return it(`should convert model.${typeName} to/from grpc.${typeName}`, fn); -} - -function mappingCheck(mapping: mapping.Mapping, m: M, o: O): void { - expect(mapping.toObject(m)).to.deep.equal(o); - expect(mapping.toMessage(o)).to.deep.equal(m); -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mapping/mapping_reference.spec.ts b/language-support/js/daml-ledger/tests/mapping/mapping_reference.spec.ts deleted file mode 100644 index d618acfd6b6..00000000000 --- a/language-support/js/daml-ledger/tests/mapping/mapping_reference.spec.ts +++ /dev/null @@ -1,630 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect } from 'chai'; -import * as mapping from '../../src/mapping'; -import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb'; - -import * as ledger from '../../src'; -import * as grpc from 'daml-grpc'; - -describe('Reference Mapping (InclusiveFilters)', () => { - - it('should not throw an error with a valid input', () => { - const object = { - templateIds: [ - { packageId: 'bar', moduleName: 'foo', entityName: 'baz' } - ] - }; - expect(() => mapping.InclusiveFilters.toMessage(object)).to.not.throw(Error); - }); - - it('should push the right number of items into the populated array', () => { - const object = { - templateIds: [ - { packageId: 'bar', moduleName: 'foo', entityName: 'baz' } - ] - }; - const result = mapping.InclusiveFilters.toMessage(object); - expect(result.getTemplateIdsList()).to.have.lengthOf(1); - }); - - it('should push the correctly built items to the array', () => { - const object = { - templateIds: [ - { packageId: 'bar', moduleName: 'foo', entityName: 'baz' } - ] - }; - const result = mapping.InclusiveFilters.toMessage(object); - const identifier = result.getTemplateIdsList()[0]; - expect(identifier.getModuleName()).to.equal('foo'); - expect(identifier.getEntityName()).to.equal('baz'); - expect(identifier.getPackageId()).to.equal('bar'); - }); - - it('should work for more than one item as well', () => { - const object = { - templateIds: [ - { packageId: 'bar1', moduleName: 'foo1', entityName: 'baz1' }, - { packageId: 'bar2', moduleName: 'foo2', entityName: 'baz2' }, - ] - }; - const result = mapping.InclusiveFilters.toMessage(object); - const identifier1 = result.getTemplateIdsList()[0]; - const identifier2 = result.getTemplateIdsList()[1]; - expect(identifier1.getPackageId()).to.equal('bar1'); - expect(identifier1.getModuleName()).to.equal('foo1'); - expect(identifier1.getEntityName()).to.equal('baz1'); - expect(identifier2.getPackageId()).to.equal('bar2'); - expect(identifier2.getModuleName()).to.equal('foo2'); - expect(identifier2.getEntityName()).to.equal('baz2'); - }); - - it('should not throw exception with a valid "bean"', () => { - const message = new grpc.InclusiveFilters(); - const identifier = new grpc.Identifier(); - identifier.setPackageId('bar'); - identifier.setModuleName('foo'); - identifier.setEntityName('baz'); - message.setTemplateIdsList([identifier]); - expect(() => mapping.InclusiveFilters.toObject(message)).to.not.throw(Error); - }); - - it('should map array items with the correct values from beans to objects', () => { - const message = new grpc.InclusiveFilters(); - const identifier = new grpc.Identifier(); - identifier.setPackageId('bar'); - identifier.setModuleName('foo'); - identifier.setEntityName('baz'); - message.setTemplateIdsList([identifier]); - expect(mapping.InclusiveFilters.toObject(message).templateIds[0]).to.deep.equal({ packageId: 'bar', moduleName: 'foo', entityName: 'baz' }); - }); - - it('should map array items with the correct values from beans to objects with multiple items', () => { - const message = new grpc.InclusiveFilters(); - const identifier1 = new grpc.Identifier(); - identifier1.setPackageId('bar1'); - identifier1.setModuleName('foo1'); - identifier1.setEntityName('baz1'); - const identifier2 = new grpc.Identifier(); - identifier2.setPackageId('bar2'); - identifier2.setModuleName('foo2'); - identifier2.setEntityName('baz2'); - message.setTemplateIdsList([identifier1, identifier2]); - expect(mapping.InclusiveFilters.toObject(message)).to.deep.equal({ - templateIds: [ - { packageId: 'bar1', moduleName: 'foo1', entityName: 'baz1' }, - { packageId: 'bar2', moduleName: 'foo2', entityName: 'baz2' }, - ] - }); - }); - -}); - -describe('Reference Mapping (Filters)', () => { - - it('should not set any property unless explicitly told to', () => { - const message = mapping.Filters.toMessage({}); - expect(message.getInclusive()).to.be.undefined; - }); - - it('should not throw an error when converting an empty array', () => { - const conversion = () => mapping.Filters.toMessage({ inclusive: { templateIds: [] } }); - expect(conversion).to.not.throw(Error); - }); - - it('should yield the expected value for nested properties of an empty object', () => { - const result = mapping.Filters.toMessage({ inclusive: { templateIds: [] } }); - expect(result.getInclusive()!.getTemplateIdsList()).to.have.length(0); - }); - - it('should not throw an error when converting an array with one item', () => { - const conversion = () => mapping.Filters.toMessage({ - inclusive: { - templateIds: [ - { packageId: 'bar', moduleName: 'foo', entityName: 'baz' } - ] - } - }); - expect(conversion).to.not.throw(Error); - }); - - it('should convert a valid object with a one-item array to its properly sized value', () => { - const result = mapping.Filters.toMessage({ - inclusive: { - templateIds: [ - { packageId: 'bar', moduleName: 'foo', entityName: 'baz' } - ] - } - }); - expect(result.getInclusive()!.getTemplateIdsList()).to.have.length(1); - }); - - it('should convert a valid object with a one-item array to its proper value for nested properties', () => { - const result = mapping.Filters.toMessage({ - inclusive: { - templateIds: [ - { packageId: 'bar', moduleName: 'foo', entityName: 'baz' } - ] - } - }); - expect(result.getInclusive()!.getTemplateIdsList()[0].getPackageId()).to.equal('bar'); - expect(result.getInclusive()!.getTemplateIdsList()[0].getModuleName()).to.equal('foo'); - expect(result.getInclusive()!.getTemplateIdsList()[0].getEntityName()).to.equal('baz'); - }); - - it('should not throw an error when converting an array with two items', () => { - const conversion = () => mapping.Filters.toMessage({ - inclusive: { - templateIds: [ - { packageId: 'bar1', moduleName: 'foo1', entityName: 'baz1' }, - { packageId: 'bar2', moduleName: 'foo2', entityName: 'baz2' }, - ] - } - }); - expect(conversion).to.not.throw(Error); - }); - - it('should convert a valid object with a two-item array to its properly sized value', () => { - const result = mapping.Filters.toMessage({ - inclusive: { - templateIds: [ - { packageId: 'bar1', moduleName: 'foo1', entityName: 'baz1' }, - { packageId: 'bar2', moduleName: 'foo2', entityName: 'baz2' }, - ] - } - }); - expect(result.getInclusive()!.getTemplateIdsList()).to.have.length(2); - }); - -}); - -describe('Reference Mapping (TransactionFilter)', () => { - - it('should not throw when converting a valid, empty input', () => { - const filter = { filtersByParty: {} }; - const conversion = () => mapping.TransactionFilter.toMessage(filter); - expect(conversion).to.not.throw(Error); - }); - - it('should result in the correct content value for an empty object', () => { - const filter = { filtersByParty: {} }; - const result = mapping.TransactionFilter.toMessage(filter); - expect(result.getFiltersByPartyMap().toArray()).to.have.lengthOf(0); - }); - - it('should add a key for a valid empty object as input', () => { - const filter = { - filtersByParty: { - someKey: {} - } - }; - const result = mapping.TransactionFilter.toMessage(filter); - const map = result.getFiltersByPartyMap(); - expect(map.has('someKey')).to.be.true; - }); - - it('should add a correctly empty value for a valid empty object as input', () => { - const filter = { - filtersByParty: { - someKey: {} - } - }; - const result = mapping.TransactionFilter.toMessage(filter); - const map = result.getFiltersByPartyMap(); - expect(map.get('someKey')!.getInclusive()).to.be.undefined; - }); - - it('should add a fully built value for a valid object as input', () => { - const filter = { - filtersByParty: { - someKey: { inclusive: { templateIds: [] } } - } - }; - const result = mapping.TransactionFilter.toMessage(filter); - const map = result.getFiltersByPartyMap(); - expect(map.get('someKey')!.getInclusive()).to.not.be.undefined; - }); - - it('should not throw when converting a valid, empty message', () => { - const message = new grpc.TransactionFilter(); - const conversion = () => mapping.TransactionFilter.toObject(message); - expect(conversion).to.not.throw(Error); - }); - - it('should fill in the properties correctly for an empty input message', () => { - const message = new grpc.TransactionFilter(); - const result = mapping.TransactionFilter.toObject(message); - expect(result.filtersByParty).to.be.empty; - }); - - it('should fill in the properties for a non-empty input message with empty nested properties', () => { - const message = new grpc.TransactionFilter(); - const map = message.getFiltersByPartyMap(); - map.set('someKey', new grpc.Filters()); - const result = mapping.TransactionFilter.toObject(message); - expect(result.filtersByParty).to.not.be.empty; - }); - - it('should fill in the properties correctly for a non-empty input message with non-empty nested properties', () => { - const transactionFilter = new grpc.TransactionFilter(); - const map = transactionFilter.getFiltersByPartyMap(); - const filters = new grpc.Filters(); - const inclusive = new grpc.InclusiveFilters(); - const identifier1 = new grpc.Identifier(); - identifier1.setPackageId('bar1'); - identifier1.setModuleName('foo1'); - identifier1.setEntityName('baz1'); - const identifier2 = new grpc.Identifier(); - identifier2.setPackageId('bar2'); - identifier2.setModuleName('foo2'); - identifier2.setEntityName('baz2'); - inclusive.setTemplateIdsList([identifier1, identifier2]); - filters.setInclusive(inclusive); - map.set('someKey', filters); - const result = mapping.TransactionFilter.toObject(transactionFilter); - expect(result).to.deep.equal({ - filtersByParty: { - someKey: { - inclusive: { - templateIds: [ - { packageId: 'bar1', moduleName: 'foo1', entityName: 'baz1' }, - { packageId: 'bar2', moduleName: 'foo2', entityName: 'baz2' }, - ] - } - } - } - }); - }); - - it('should fill in the properties correctly for a non-empty input message with empty and non-empty nested properties', () => { - const transactionFilter = new grpc.TransactionFilter(); - const map = transactionFilter.getFiltersByPartyMap(); - const filters = new grpc.Filters(); - const inclusive = new grpc.InclusiveFilters(); - const identifier1 = new grpc.Identifier(); - identifier1.setPackageId('bar1'); - identifier1.setModuleName('foo1'); - identifier1.setEntityName('baz1'); - const identifier2 = new grpc.Identifier(); - identifier2.setPackageId('bar2'); - identifier2.setModuleName('foo2'); - identifier2.setEntityName('baz2'); - inclusive.setTemplateIdsList([identifier1, identifier2]); - filters.setInclusive(inclusive); - map.set('someKey', filters); - map.set('someOtherKey', new grpc.Filters()); - const result = mapping.TransactionFilter.toObject(transactionFilter); - expect(result).to.deep.equal({ - filtersByParty: { - someOtherKey: {}, - someKey: { - inclusive: { - templateIds: [ - { packageId: 'bar1', moduleName: 'foo1', entityName: 'baz1' }, - { packageId: 'bar2', moduleName: 'foo2', entityName: 'baz2' }, - ] - } - } - } - }); - }); - -}); - -describe('Reference Mapping (SubmitRequest)', () => { - - const command = new grpc.Command(); - - const templateId = new grpc.Identifier(); - templateId.setModuleName('templateId-moduleName'); - templateId.setEntityName('templateId-entityName'); - templateId.setPackageId('templateId-packageId'); - - const recordId = new grpc.Identifier(); - recordId.setModuleName('recordId-moduleName'); - recordId.setEntityName('recordId-entityName'); - recordId.setPackageId('recordId-packageId'); - - const create = new grpc.CreateCommand(); - create.setTemplateId(templateId); - - const record = new grpc.Record(); - record.setRecordId(recordId); - - const senderField = new grpc.RecordField(); - senderField.setLabel('sender'); - const senderValue = new grpc.Value(); - senderValue.setParty('sender-party'); - senderField.setValue(senderValue); - record.addFields(senderField); - - const receiverField = new grpc.RecordField(); - receiverField.setLabel('receiver'); - const receiverValue = new grpc.Value(); - receiverValue.setParty('receiver-party'); - receiverField.setValue(receiverValue); - record.addFields(receiverField); - - const countField = new grpc.RecordField(); - countField.setLabel('count'); - const countValue = new grpc.Value(); - countValue.setInt64('42'); - countField.setValue(countValue); - record.addFields(countField); - create.setCreateArguments(record); - - command.setCreate(create); - - const message = new grpc.SubmitRequest(); - - const commands = new grpc.Commands(); - commands.setLedgerId('ledgerId'); - - const ledgerEffectiveTime = new Timestamp(); - ledgerEffectiveTime.setSeconds(47); - ledgerEffectiveTime.setNanos(68); - commands.setLedgerEffectiveTime(ledgerEffectiveTime); - - const maximumRecordTime = new Timestamp(); - maximumRecordTime.setSeconds(94); - maximumRecordTime.setNanos(140); - commands.setMaximumRecordTime(maximumRecordTime); - - commands.setCommandId('command-commandId'); - commands.setWorkflowId('command-workflowId'); - commands.setParty('command-party'); - commands.setApplicationId('command-applicationId'); - commands.setCommandsList([command]); - - message.setCommands(commands); - - const object: ledger.SubmitRequest = { - commands: { - ledgerEffectiveTime: { seconds: 47, nanoseconds: 68 }, - maximumRecordTime: { seconds: 94, nanoseconds: 140 }, - commandId: 'command-commandId', - workflowId: 'command-workflowId', - party: 'command-party', - applicationId: 'command-applicationId', - list: [ - { - create: { - templateId: { packageId: 'templateId-packageId', moduleName: 'templateId-moduleName', entityName: 'templateId-entityName' }, - arguments: { - recordId: { packageId: 'recordId-packageId', moduleName: 'recordId-moduleName', entityName: 'recordId-entityName' }, - fields: { - sender: { party: 'sender-party' }, - receiver: { party: 'receiver-party' }, - count: { int64: '42' } - } - } - } - } - ] - } - } - - it('should correctly translate a message to an object', () => { - - expect(mapping.SubmitRequest.toObject(message)).to.deep.equal(object); - - }); - - it('should translate an object to a message both ways while preserving meaning', () => { - - expect(mapping.SubmitRequest.toObject(mapping.SubmitRequest.toMessage(object))).to.deep.equal(object); - - }); - -}); - -describe('Reference Mapping (SubmitRequest/Pvp)', () => { - - const command = new grpc.Command(); - - const pvpId = new grpc.Identifier(); - pvpId.setModuleName('mod1'); - pvpId.setEntityName('PvP'); - pvpId.setPackageId('934023fa9c89e8f89b8a'); - - const create = new grpc.CreateCommand(); - create.setTemplateId(pvpId); - - const record = new grpc.Record(); - record.setRecordId(pvpId); - - const baseAmountField = new grpc.RecordField(); - baseAmountField.setLabel('baseAmount'); - const baseAmountValue = new grpc.Value(); - baseAmountValue.setDecimal('1000000.00'); - baseAmountField.setValue(baseAmountValue); - record.addFields(baseAmountField); - - const baseCurrencyField = new grpc.RecordField(); - baseCurrencyField.setLabel('baseCurrency'); - const baseCurrencyValue = new grpc.Value(); - baseCurrencyValue.setText('CHF'); - baseCurrencyField.setValue(baseCurrencyValue); - record.addFields(baseCurrencyField); - - const baseIouCidField = new grpc.RecordField(); - baseIouCidField.setLabel('baseIouCid'); - const baseIouCidValue = new grpc.Value(); - const baseIouCidVariant = new grpc.Variant(); - baseIouCidVariant.setConstructor('Maybe'); - const baseIouCidVariantId = new grpc.Identifier(); - baseIouCidVariantId.setModuleName('mod2'); - baseIouCidVariantId.setEntityName('Maybe'); - baseIouCidVariantId.setPackageId('ba777d8d7c88e87f7'); - baseIouCidVariant.setVariantId(baseIouCidVariantId); - const baseIouCidVariantValue = new grpc.Value(); - baseIouCidVariantValue.setContractId('76238b8998a98d98e978f'); - baseIouCidVariant.setValue(baseIouCidVariantValue); - baseIouCidValue.setVariant(baseIouCidVariant); - baseIouCidField.setValue(baseIouCidValue); - record.addFields(baseIouCidField); - - const baseIssuerField = new grpc.RecordField(); - baseIssuerField.setLabel('baseIssuer'); - const baseIssuerValue = new grpc.Value(); - baseIssuerValue.setParty('some-base-issuer'); - baseIssuerField.setValue(baseIssuerValue); - record.addFields(baseIssuerField); - - const buyerField = new grpc.RecordField(); - buyerField.setLabel('buyer'); - const buyerValue = new grpc.Value(); - buyerValue.setParty('some-buyer'); - buyerField.setValue(buyerValue); - record.addFields(buyerField); - - const quoteAmountField = new grpc.RecordField(); - quoteAmountField.setLabel('quoteAmount'); - const quoteAmountValue = new grpc.Value(); - quoteAmountValue.setDecimal('1000001.00'); - quoteAmountField.setValue(quoteAmountValue); - record.addFields(quoteAmountField); - - const quoteCurrencyField = new grpc.RecordField(); - quoteCurrencyField.setLabel('quoteCurrency'); - const quoteCurrencyValue = new grpc.Value(); - quoteCurrencyValue.setText('USD'); - quoteCurrencyField.setValue(quoteCurrencyValue); - record.addFields(quoteCurrencyField); - - const quoteIouCidField = new grpc.RecordField(); - quoteIouCidField.setLabel('quoteIouCid'); - const quoteIouCidValue = new grpc.Value(); - const quoteIouCidVariant = new grpc.Variant(); - quoteIouCidVariant.setConstructor('Maybe'); - const quoteIouCidVariantId = new grpc.Identifier(); - quoteIouCidVariantId.setModuleName('mod2'); - quoteIouCidVariantId.setEntityName('Maybe'); - quoteIouCidVariantId.setPackageId('ba777d8d7c88e87f7'); - quoteIouCidVariant.setVariantId(quoteIouCidVariantId); - const quoteIouCidVariantValue = new grpc.Value(); - quoteIouCidVariantValue.setContractId('76238b8998a98d98e978f'); - quoteIouCidVariant.setValue(quoteIouCidVariantValue); - quoteIouCidValue.setVariant(quoteIouCidVariant); - quoteIouCidField.setValue(quoteIouCidValue); - record.addFields(quoteIouCidField); - - const quoteIssuerField = new grpc.RecordField(); - quoteIssuerField.setLabel('quoteIssuer'); - const quoteIssuerValue = new grpc.Value(); - quoteIssuerValue.setParty('some-quote-issuer'); - quoteIssuerField.setValue(quoteIssuerValue); - record.addFields(quoteIssuerField); - - const sellerField = new grpc.RecordField(); - sellerField.setLabel('seller'); - const sellerValue = new grpc.Value(); - sellerValue.setParty('some-seller'); - sellerField.setValue(sellerValue); - record.addFields(sellerField); - - const settleTimeField = new grpc.RecordField(); - settleTimeField.setLabel('settleTime'); - const settleTimeValue = new grpc.Value(); - settleTimeValue.setTimestamp('93641099000000000'); - settleTimeField.setValue(settleTimeValue); - record.addFields(settleTimeField); - - create.setCreateArguments(record); - - command.setCreate(create); - - const message = new grpc.SubmitRequest(); - - const commands = new grpc.Commands(); - commands.setLedgerId('ledgerId'); - - const ledgerEffectiveTime = new Timestamp(); - ledgerEffectiveTime.setSeconds(0); - ledgerEffectiveTime.setNanos(0); - commands.setLedgerEffectiveTime(ledgerEffectiveTime); - - const maximumRecordTime = new Timestamp(); - maximumRecordTime.setSeconds(5); - maximumRecordTime.setNanos(0); - commands.setMaximumRecordTime(maximumRecordTime); - - commands.setCommandId('78676d87b86d86'); - commands.setWorkflowId('some-workflow-id'); - commands.setParty('some-sender'); - commands.setApplicationId('some-app-id'); - commands.setCommandsList([command]); - - message.setCommands(commands); - - const reference = { - commands: { - ledgerEffectiveTime: { seconds: 0, nanoseconds: 0 }, - maximumRecordTime: { seconds: 5, nanoseconds: 0 }, - commandId: '78676d87b86d86', - workflowId: 'some-workflow-id', - party: 'some-sender', - applicationId: 'some-app-id', - list: [ - { - create: { - templateId: { packageId: '934023fa9c89e8f89b8a', moduleName: 'mod1', entityName: 'PvP' }, - arguments: { - recordId: { packageId: '934023fa9c89e8f89b8a', moduleName: 'mod1', entityName: 'PvP' }, - fields: { - buyer : { party: 'some-buyer' }, - seller : { party: 'some-seller' }, - baseIssuer : { party: 'some-base-issuer' }, - baseCurrency : { text: 'CHF' }, - baseAmount : { decimal: '1000000.00' }, - baseIouCid : { variant: { variantId: { packageId: 'ba777d8d7c88e87f7', moduleName: 'mod2', entityName: 'Maybe' }, constructor: 'Maybe', value: { contractId: '76238b8998a98d98e978f' } } }, - quoteIssuer : { party: 'some-quote-issuer' }, - quoteCurrency: { text: 'USD' }, - quoteAmount : { decimal: '1000001.00' }, - quoteIouCid : { variant: { variantId: { packageId: 'ba777d8d7c88e87f7', moduleName: 'mod2', entityName: 'Maybe' }, constructor: 'Maybe', value: { contractId: '76238b8998a98d98e978f' } } }, - settleTime : { timestamp: '93641099000000000' } - } - } - } - } - ] - } - }; - - it('should match exactly the expected result', () => { - - expect(mapping.SubmitRequest.toObject(message)).to.deep.equal(reference); - - }); - -}); - -describe('Non-verbose records', () => { - - it('should be mapped to numeric indexes', () => { - const expected: ledger.Record = { - fields: { - '0': { int64: '42' }, - '1': { contractId: '0123456789abcdef' }, - '2': { bool: true } - } - } - const record: grpc.Record = new grpc.Record(); - const value0: grpc.Value = new grpc.Value(); - const field0: grpc.RecordField = new grpc.RecordField(); - const value1: grpc.Value = new grpc.Value(); - const field1: grpc.RecordField = new grpc.RecordField(); - const value2: grpc.Value = new grpc.Value(); - const field2: grpc.RecordField = new grpc.RecordField(); - field0.setValue(value0); - value0.setInt64('42'); - field1.setValue(value1); - value1.setContractId('0123456789abcdef'); - field2.setValue(value2); - value2.setBool(true); - record.setFieldsList([field0, field1, field2]); - expect(mapping.Record.toObject(record)).to.deep.equal(expected); - }); - -}); diff --git a/language-support/js/daml-ledger/tests/mock/client_readable_stream.ts b/language-support/js/daml-ledger/tests/mock/client_readable_stream.ts deleted file mode 100644 index 6f594dc9897..00000000000 --- a/language-support/js/daml-ledger/tests/mock/client_readable_stream.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'grpc'; -import { Readable } from 'stream'; - -export class MockedClientReadableStream extends Readable { - - public static with(items: Iterable): grpc.ClientReadableStream { - return new MockedClientReadableStream(items) as grpc.ClientReadableStream; - } - - private readonly iterator: Iterator; - - private constructor(items: Iterable) { - super({ objectMode: true }); - this.iterator = items[Symbol.iterator](); - } - - _read(): void { - const next = this.iterator.next(); - if (next.done) { - this.push(null); - } else { - this.push(next.value); - } - } - - /** - * HACK! Leverage dynamic structural typing to mock non-extensible `ClientReadableStream`s - * - * Cancel the ongoing call. Results in the call ending with a CANCELLED status, - * unless it has already ended with some other status. - */ - cancel(): void { - throw new Error('MOCK!'); - } - - /** - * HACK! Leverage dynamic structural typing to mock non-extensible `ClientReadableStream`s - * - * Get the endpoint this call/stream is connected to. - * @return The URI of the endpoint - */ - getPeer(): string { - throw new Error('MOCK!'); - } - -} diff --git a/language-support/js/daml-ledger/tests/mock/client_unary_call.ts b/language-support/js/daml-ledger/tests/mock/client_unary_call.ts deleted file mode 100644 index 7bc384af811..00000000000 --- a/language-support/js/daml-ledger/tests/mock/client_unary_call.ts +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'grpc'; - -export class MockedClientUnaryCall { - - private constructor() { - // Do nothing, constructor is private to prevent instantiation outside of this class - } - - public static Instance: grpc.ClientUnaryCall = new MockedClientUnaryCall() as grpc.ClientUnaryCall; - - /** - * HACK! Leverage dynamic structural typing to mock non-extensible `ClientReadableStream`s - * - * Cancel the ongoing call. Results in the call ending with a CANCELLED status, - * unless it has already ended with some other status. - */ - cancel(): void { - throw new Error('MOCK!'); - } - - /** - * HACK! Leverage dynamic structural typing to mock non-extensible `ClientReadableStream`s - * - * Get the endpoint this call/stream is connected to. - * @return The URI of the endpoint - */ - getPeer(): string { - throw new Error('MOCK!'); - } - -} diff --git a/language-support/js/daml-ledger/tests/mock/index.ts b/language-support/js/daml-ledger/tests/mock/index.ts deleted file mode 100644 index 59e491d9109..00000000000 --- a/language-support/js/daml-ledger/tests/mock/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -export * from './mocked_active_contracts_service_client'; -export * from './mocked_command_client'; -export * from './mocked_command_completion_client'; -export * from './mocked_command_submission_client'; -export * from './mocked_ledger_configuration_client'; -export * from './mocked_ledger_identity_client'; -export * from './mocked_package_client'; -export * from './mocked_reset_client'; -export * from './mocked_time_client'; -export * from './mocked_transaction_client'; - -export * from './mocked_transaction_server'; -export * from './spying_dummy_server'; diff --git a/language-support/js/daml-ledger/tests/mock/mocked_active_contracts_service_client.ts b/language-support/js/daml-ledger/tests/mock/mocked_active_contracts_service_client.ts deleted file mode 100644 index d214e3a2abd..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_active_contracts_service_client.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import { ClientReadableStream } from 'grpc'; -import { MockedClientReadableStream } from './client_readable_stream'; -import { SinonSpy } from 'sinon'; - -export class MockedActiveContractsServiceClient implements grpc.IActiveContractsClient { - - private responses: grpc.GetActiveContractsResponse[] - private readonly lastRequestSpy: SinonSpy - - constructor(responses: grpc.GetActiveContractsResponse[], lastRequestSpy: SinonSpy) { - this.responses = responses; - this.lastRequestSpy = lastRequestSpy; - } - - getActiveContracts(request: grpc.GetActiveContractsRequest): ClientReadableStream { - this.lastRequestSpy(request); - return MockedClientReadableStream.with(this.responses); - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mock/mocked_command_client.ts b/language-support/js/daml-ledger/tests/mock/mocked_command_client.ts deleted file mode 100644 index 823be45c543..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_command_client.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import { MockedClientUnaryCall } from './client_unary_call'; -import { Empty } from 'google-protobuf/google/protobuf/empty_pb'; -import { CallOptions, ClientUnaryCall, Metadata } from 'grpc'; -import { SinonSpy } from 'sinon'; - -export class MockedCommandClient implements grpc.ICommandClient { - - private readonly lastRequestSpy: SinonSpy - - constructor(lastRequestSpy: SinonSpy) { - this.lastRequestSpy = lastRequestSpy; - } - - submitAndWait(request: grpc.SubmitAndWaitRequest, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - submitAndWait(request: grpc.SubmitAndWaitRequest, metadata: Metadata, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - submitAndWait(request: grpc.SubmitAndWaitRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - submitAndWait(request: grpc.SubmitAndWaitRequest, metadata: any, options?: any, callback?: any): ClientUnaryCall { - this.lastRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options ) : callback; - cb(null, Empty); - return MockedClientUnaryCall.Instance; - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mock/mocked_command_completion_client.ts b/language-support/js/daml-ledger/tests/mock/mocked_command_completion_client.ts deleted file mode 100644 index 0a50d79c63f..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_command_completion_client.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as sinon from 'sinon'; -import { MockedClientReadableStream } from './client_readable_stream'; -import { MockedClientUnaryCall } from './client_unary_call'; -import { Metadata, CallOptions, ClientReadableStream, ClientUnaryCall } from 'grpc'; - -export class MockedCommandCompletionClient implements grpc.ICommandCompletionClient { - - private readonly end: grpc.CompletionEndResponse - private readonly completions: grpc.CompletionStreamResponse[] - private readonly lastRequestSpy: sinon.SinonSpy - - constructor(completions: grpc.CompletionStreamResponse[], end: grpc.CompletionEndResponse, lastRequestSpy: sinon.SinonSpy) { - this.end = end; - this.completions = completions; - this.lastRequestSpy = lastRequestSpy; - } - - completionEnd(request: grpc.CompletionEndRequest, callback: (error: Error | null, response: grpc.CompletionEndResponse) => void): ClientUnaryCall; - completionEnd(request: grpc.CompletionEndRequest, metadata: Metadata, callback: (error: Error | null, response: grpc.CompletionEndResponse) => void): ClientUnaryCall; - completionEnd(request: grpc.CompletionEndRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: grpc.CompletionEndResponse) => void): ClientUnaryCall; - completionEnd(request: grpc.CompletionEndRequest, metadata: any, options?: any, callback?: any) { - this.lastRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options ) : callback; - cb(null, this.end); - return MockedClientUnaryCall.Instance; - } - - completionStream(request: grpc.CompletionStreamRequest, options?: Partial | undefined): ClientReadableStream; completionStream(request: grpc.CompletionStreamRequest, metadata?: Metadata | undefined, options?: Partial | undefined): ClientReadableStream; - completionStream(request: grpc.CompletionStreamRequest, _metadata?: any, _options?: any) { - this.lastRequestSpy(request); - return MockedClientReadableStream.with(this.completions); - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mock/mocked_command_submission_client.ts b/language-support/js/daml-ledger/tests/mock/mocked_command_submission_client.ts deleted file mode 100644 index 8e97e8e5bf5..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_command_submission_client.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as grpc from 'daml-grpc'; -import * as sinon from 'sinon'; -import { MockedClientUnaryCall } from './client_unary_call'; -import { Metadata, CallOptions, ClientUnaryCall } from 'grpc'; -import { Empty } from 'google-protobuf/google/protobuf/empty_pb'; - -export class MockedCommandSubmissionClient implements grpc.ICommandSubmissionClient { - - private readonly lastRequestSpy: sinon.SinonSpy - private static readonly empty = new Empty(); - - constructor(lastRequestSpy: sinon.SinonSpy) { - this.lastRequestSpy = lastRequestSpy; - } - - submit(request: grpc.SubmitRequest, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - submit(request: grpc.SubmitRequest, metadata: Metadata, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - submit(request: grpc.SubmitRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - submit(request: any, metadata: any, options?: any, callback?: any) { - this.lastRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options ) : callback; - cb(null, MockedCommandSubmissionClient.empty); - return MockedClientUnaryCall.Instance; - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mock/mocked_ledger_configuration_client.ts b/language-support/js/daml-ledger/tests/mock/mocked_ledger_configuration_client.ts deleted file mode 100644 index 30c418da3bb..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_ledger_configuration_client.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as sinon from 'sinon'; - -import * as grpc from 'daml-grpc'; - -import { CallOptions, ClientReadableStream, Metadata } from 'grpc'; -import { MockedClientReadableStream } from './client_readable_stream'; - -export class MockedLedgerConfigurationClient implements grpc.ILedgerConfigurationClient { - - private responses: grpc.GetLedgerConfigurationResponse[] - private readonly latestRequestSpy: sinon.SinonSpy - - constructor(responses: grpc.GetLedgerConfigurationResponse[], latestRequestSpy: sinon.SinonSpy) { - this.responses = responses; - this.latestRequestSpy = latestRequestSpy; - } - - getLedgerConfiguration(request: grpc.GetLedgerConfigurationRequest, options?: Partial | undefined): ClientReadableStream; - getLedgerConfiguration(request: grpc.GetLedgerConfigurationRequest, metadata?: Metadata | undefined, options?: Partial | undefined): ClientReadableStream; - getLedgerConfiguration(request: grpc.GetLedgerConfigurationRequest, _metadata?: any, _options?: any) { - this.latestRequestSpy(request); - return MockedClientReadableStream.with(this.responses); - } - - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mock/mocked_ledger_identity_client.ts b/language-support/js/daml-ledger/tests/mock/mocked_ledger_identity_client.ts deleted file mode 100644 index 09f7fce4f30..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_ledger_identity_client.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { ClientUnaryCall, Metadata, CallOptions } from 'grpc'; - -import * as grpc from 'daml-grpc'; -import { MockedClientUnaryCall } from './client_unary_call'; - -export class MockedLedgerIdentityClient implements grpc.ILedgerIdentityClient { - - private readonly ledgerId: grpc.GetLedgerIdentityResponse; - - constructor(ledgerId: string) { - this.ledgerId = new grpc.GetLedgerIdentityResponse(); - this.ledgerId.setLedgerId(ledgerId); - } - - getLedgerIdentity(request: grpc.GetLedgerIdentityRequest, callback: (error: Error | null, response: grpc.GetLedgerIdentityResponse) => void): ClientUnaryCall; - getLedgerIdentity(request: grpc.GetLedgerIdentityRequest, metadata: Metadata, callback: (error: Error | null, response: grpc.GetLedgerIdentityResponse) => void): ClientUnaryCall; - getLedgerIdentity(request: grpc.GetLedgerIdentityRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: grpc.GetLedgerIdentityResponse) => void): ClientUnaryCall; - getLedgerIdentity(_request: grpc.GetLedgerIdentityRequest, metadata: any, options?: any, callback?: any) { - const cb = callback === undefined ? (options === undefined ? metadata : options ) : callback; - cb(null, this.ledgerId); - return MockedClientUnaryCall.Instance; - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mock/mocked_package_client.ts b/language-support/js/daml-ledger/tests/mock/mocked_package_client.ts deleted file mode 100644 index 96a2a2f2589..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_package_client.ts +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { ClientUnaryCall, Metadata, CallOptions } from 'grpc'; - -import * as grpc from 'daml-grpc'; -import { MockedClientUnaryCall } from './client_unary_call'; -import * as ledger from '../../src'; -import * as mapping from '../../src/mapping'; - -import * as sinon from 'sinon'; - -export class MockedPackageClient implements grpc.IPackageClient { - - private static NOT_FOUND_ERROR = new Error('NOT_FOUND'); - - private readonly data: Map; - private readonly listPackagesResponse: grpc.ListPackagesResponse; - private readonly latestRequestSpy: sinon.SinonSpy; - - constructor(data: [ string, [ledger.GetPackageResponse, ledger.GetPackageStatusResponse]][], latestRequestSpy: sinon.SinonSpy) { - this.data = new Map(data); - this.latestRequestSpy = latestRequestSpy; - this.listPackagesResponse = new grpc.ListPackagesResponse(); - this.data.forEach((_, packageId) => { - this.listPackagesResponse.addPackageIds(packageId); - }); - } - - listPackages(request: grpc.ListPackagesRequest, callback: (error: Error | null, response: grpc.ListPackagesResponse) => void): ClientUnaryCall; - listPackages(request: grpc.ListPackagesRequest, metadata: Metadata, callback: (error: Error | null, response: grpc.ListPackagesResponse) => void): ClientUnaryCall; - listPackages(request: grpc.ListPackagesRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: grpc.ListPackagesResponse) => void): ClientUnaryCall; - listPackages(request: grpc.ListPackagesRequest, metadata: any, options?: any, callback?: any) { - this.latestRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options ) : callback; - cb(null, this.listPackagesResponse); - return MockedClientUnaryCall.Instance; - } - getPackage(request: grpc.GetPackageRequest, callback: (error: Error | null, response: grpc.GetPackageResponse) => void): ClientUnaryCall; - getPackage(request: grpc.GetPackageRequest, metadata: Metadata, callback: (error: Error | null, response: grpc.GetPackageResponse) => void): ClientUnaryCall; - getPackage(request: grpc.GetPackageRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: grpc.GetPackageResponse) => void): ClientUnaryCall; - getPackage(request: grpc.GetPackageRequest, metadata: any, options?: any, callback?: any) { - this.latestRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options ) : callback; - const packageId = request.getPackageId(); - if (this.data.has(packageId)) { - cb(null, mapping.GetPackageResponse.toMessage(this.data.get(packageId)![0])); - } else { - cb(MockedPackageClient.NOT_FOUND_ERROR, null); - } - return MockedClientUnaryCall.Instance; - } - getPackageStatus(request: grpc.GetPackageStatusRequest, callback: (error: Error | null, response: grpc.GetPackageStatusResponse) => void): ClientUnaryCall; - getPackageStatus(request: grpc.GetPackageStatusRequest, metadata: Metadata, callback: (error: Error | null, response: grpc.GetPackageStatusResponse) => void): ClientUnaryCall; - getPackageStatus(request: grpc.GetPackageStatusRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: grpc.GetPackageStatusResponse) => void): ClientUnaryCall; - getPackageStatus(request: grpc.GetPackageStatusRequest, metadata: any, options?: any, callback?: any) { - this.latestRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options ) : callback; - const packageId = request.getPackageId(); - if (this.data.has(packageId)) { - cb(null, mapping.GetPackageStatusResponse.toMessage(this.data.get(packageId)![1])); - } else { - cb(MockedPackageClient.NOT_FOUND_ERROR, null); - } - return MockedClientUnaryCall.Instance; - } - -} diff --git a/language-support/js/daml-ledger/tests/mock/mocked_reset_client.ts b/language-support/js/daml-ledger/tests/mock/mocked_reset_client.ts deleted file mode 100644 index b296312f41c..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_reset_client.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { ClientUnaryCall, Metadata, CallOptions } from 'grpc'; - -import * as grpc from 'daml-grpc'; -import { MockedClientUnaryCall } from './client_unary_call'; - -import * as sinon from 'sinon'; - -import { Empty } from 'google-protobuf/google/protobuf/empty_pb'; - -export class MockedResetClient implements grpc.testing.IResetClient { - - private static readonly empty = new Empty(); - - private readonly latestRequestSpy: sinon.SinonSpy - - constructor(latestRequestSpy: sinon.SinonSpy) { - this.latestRequestSpy = latestRequestSpy; - } - - reset(request: grpc.testing.ResetRequest, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - reset(request: grpc.testing.ResetRequest, metadata: Metadata, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - reset(request: grpc.testing.ResetRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - reset(request: grpc.testing.ResetRequest, metadata: any, options?: any, callback?: any) { - this.latestRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options ) : callback; - cb(null, MockedResetClient.empty); - return MockedClientUnaryCall.Instance; - } - - - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mock/mocked_time_client.ts b/language-support/js/daml-ledger/tests/mock/mocked_time_client.ts deleted file mode 100644 index 52d03e2b639..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_time_client.ts +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { ClientUnaryCall, Metadata, CallOptions } from 'grpc'; - -import * as grpc from 'daml-grpc'; -import { MockedClientUnaryCall } from './client_unary_call'; - -import * as sinon from 'sinon'; - -import { ClientReadableStream } from 'grpc'; -import { Empty } from 'google-protobuf/google/protobuf/empty_pb'; -import { MockedClientReadableStream } from './client_readable_stream'; - -export class MockedTimeClient implements grpc.testing.ITimeClient { - - private static readonly empty = new Empty(); - - private responses: grpc.testing.GetTimeResponse[] - private readonly latestRequestSpy: sinon.SinonSpy - - constructor(responses: grpc.testing.GetTimeResponse[], latestRequestSpy: sinon.SinonSpy) { - this.responses = responses; - this.latestRequestSpy = latestRequestSpy; - } - - getTime(request: grpc.testing.GetTimeRequest, options?: Partial | undefined): ClientReadableStream; - getTime(request: grpc.testing.GetTimeRequest, metadata?: Metadata | undefined, options?: Partial | undefined): ClientReadableStream; - getTime(request: grpc.testing.GetTimeRequest, _metadata?: any, _options?: any) { - this.latestRequestSpy(request); - return MockedClientReadableStream.with(this.responses); - } - - setTime(request: grpc.testing.SetTimeRequest, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - setTime(request: grpc.testing.SetTimeRequest, metadata: Metadata, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - setTime(request: grpc.testing.SetTimeRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: Empty) => void): ClientUnaryCall; - setTime(request: grpc.testing.SetTimeRequest, metadata: any, options?: any, callback?: any) { - this.latestRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options ) : callback; - cb(null, MockedTimeClient.empty); - return MockedClientUnaryCall.Instance; - } - - - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mock/mocked_transaction_client.ts b/language-support/js/daml-ledger/tests/mock/mocked_transaction_client.ts deleted file mode 100644 index 57c9ce33d07..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_transaction_client.ts +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as sinon from 'sinon'; - -import * as grpc from 'daml-grpc'; - -import { CallOptions, ClientReadableStream, ClientUnaryCall, Metadata } from 'grpc'; -import { MockedClientReadableStream } from './client_readable_stream'; -import { MockedClientUnaryCall } from './client_unary_call'; -import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb'; - -export class MockedTransactionClient implements grpc.ITransactionClient { - - // private readonly ledgerId: string - private readonly latestRequestSpy: sinon.SinonSpy - - private readonly ledgerEndResponse = new grpc.GetLedgerEndResponse(); - private initEmptyLedgerEndResponse() { - const offset = new grpc.LedgerOffset(); - offset.setBoundary(grpc.LedgerOffset.LedgerBoundary.LEDGER_BEGIN); - this.ledgerEndResponse.setOffset(offset); - } - private readonly transactionResponse = new grpc.GetTransactionResponse(); - private initEmptyTransactionResponse() { - const effectiveAt = new Timestamp(); - effectiveAt.setSeconds(0); - effectiveAt.setNanos(0); - const tree = new grpc.TransactionTree(); - tree.setEffectiveAt(effectiveAt); - tree.setOffset('mock'); - tree.setTransactionId('mock'); - this.transactionResponse.setTransaction(tree); - } - - constructor(_ledgerId: string, latestRequestSpy: sinon.SinonSpy) { - this.latestRequestSpy = latestRequestSpy; - this.initEmptyLedgerEndResponse(); - this.initEmptyTransactionResponse(); - } - - getTransactions(request: grpc.GetTransactionsRequest, options?: Partial | undefined): ClientReadableStream; - getTransactions(request: grpc.GetTransactionsRequest, metadata?: Metadata | undefined, options?: Partial | undefined): ClientReadableStream; - getTransactions(request: grpc.GetTransactionsRequest, _metadata?: any, _options?: any) { - this.latestRequestSpy(request); - return MockedClientReadableStream.with([]); - } - - getTransactionTrees(request: grpc.GetTransactionsRequest, options?: Partial | undefined): ClientReadableStream; - getTransactionTrees(request: grpc.GetTransactionsRequest, metadata?: Metadata | undefined, options?: Partial | undefined): ClientReadableStream; - getTransactionTrees(request: grpc.GetTransactionsRequest, _metadata?: any, _options?: any) { - this.latestRequestSpy(request); - return MockedClientReadableStream.with([]); - } - - getTransactionByEventId(request: grpc.GetTransactionByEventIdRequest, callback: (error: Error | null, response: grpc.GetTransactionResponse) => void): ClientUnaryCall; - getTransactionByEventId(request: grpc.GetTransactionByEventIdRequest, metadata: Metadata, callback: (error: Error | null, response: grpc.GetTransactionResponse) => void): ClientUnaryCall; - getTransactionByEventId(request: grpc.GetTransactionByEventIdRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: grpc.GetTransactionResponse) => void): ClientUnaryCall; - getTransactionByEventId(request: grpc.GetTransactionByEventIdRequest, metadata: any, options?: any, callback?: any) { - this.latestRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options) : callback; - setImmediate(() => cb(null, this.transactionResponse)); - return MockedClientUnaryCall.Instance; - } - - getTransactionById(request: grpc.GetTransactionByIdRequest, callback: (error: Error | null, response: grpc.GetTransactionResponse) => void): ClientUnaryCall; - getTransactionById(request: grpc.GetTransactionByIdRequest, metadata: Metadata, callback: (error: Error | null, response: grpc.GetTransactionResponse) => void): ClientUnaryCall; - getTransactionById(request: grpc.GetTransactionByIdRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: grpc.GetTransactionResponse) => void): ClientUnaryCall; - getTransactionById(request: grpc.GetTransactionByIdRequest, metadata: any, options?: any, callback?: any) { - this.latestRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options) : callback; - setImmediate(() => cb(null, this.transactionResponse)); - return MockedClientUnaryCall.Instance; - } - - getLedgerEnd(request: grpc.GetLedgerEndRequest, callback: (error: Error | null, response: grpc.GetLedgerEndResponse) => void): ClientUnaryCall; - getLedgerEnd(request: grpc.GetLedgerEndRequest, metadata: Metadata, callback: (error: Error | null, response: grpc.GetLedgerEndResponse) => void): ClientUnaryCall; - getLedgerEnd(request: grpc.GetLedgerEndRequest, metadata: Metadata, options: Partial, callback: (error: Error | null, response: grpc.GetLedgerEndResponse) => void): ClientUnaryCall; - getLedgerEnd(request: grpc.GetLedgerEndRequest, metadata: any, options?: any, callback?: any) { - this.latestRequestSpy(request); - const cb = callback === undefined ? (options === undefined ? metadata : options) : callback; - setImmediate(() => cb(null, this.ledgerEndResponse)); - return MockedClientUnaryCall.Instance; - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mock/mocked_transaction_server.ts b/language-support/js/daml-ledger/tests/mock/mocked_transaction_server.ts deleted file mode 100644 index 52cbd9dbf3f..00000000000 --- a/language-support/js/daml-ledger/tests/mock/mocked_transaction_server.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Server, ServerUnaryCall, Metadata, ServiceError, ServerWriteableStream } from 'grpc'; - -import * as grpc from 'daml-grpc'; - -export class MockedTransactionServer extends Server { - - constructor(ledgerId: string, transactions: grpc.GetTransactionsResponse[]) { - super(); - - const ledgerIdentityResponse: grpc.GetLedgerIdentityResponse = new grpc.GetLedgerIdentityResponse(); - ledgerIdentityResponse.setLedgerId(ledgerId); - - this.addService(grpc.LedgerIdentityService, { - getLedgerIdentity(_call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.GetLedgerIdentityResponse | null, trailer?: Metadata, flags?: number) => void): void { - callback(null, ledgerIdentityResponse); - } - }); - - this.addService(grpc.TransactionService, { - getTransactions(call: ServerWriteableStream): void { - for (const tx of transactions) { - call.write(tx); - } - call.end(); - }, - getTransactionTrees(call: ServerWriteableStream): void { - call.end(); - }, - getTransactionByEventId(_call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.GetTransactionResponse | null, trailer?: Metadata, flags?: number) => void): void { - callback(null, null); - }, - getTransactionById(_call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.GetTransactionResponse | null, trailer?: Metadata, flags?: number) => void): void { - callback(null, null); - }, - getLedgerEnd(_call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.GetLedgerEndResponse | null, trailer?: Metadata, flags?: number) => void): void { - callback(null, null); - } - }); - - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/mock/spying_dummy_server.ts b/language-support/js/daml-ledger/tests/mock/spying_dummy_server.ts deleted file mode 100644 index 38992fe3085..00000000000 --- a/language-support/js/daml-ledger/tests/mock/spying_dummy_server.ts +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { Server, ServerUnaryCall, Metadata, ServiceError, ServerWriteableStream } from 'grpc'; - -import * as grpc from 'daml-grpc'; -import { Empty } from 'google-protobuf/google/protobuf/empty_pb'; -import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb'; -import { SinonSpy } from 'sinon'; - -export class SpyingDummyServer extends Server { - - constructor(ledgerId: string, spy: SinonSpy) { - super(); - - const ledgerIdentityResponse: grpc.GetLedgerIdentityResponse = new grpc.GetLedgerIdentityResponse(); - ledgerIdentityResponse.setLedgerId(ledgerId); - - const empty = new Empty(); - - const offset = new grpc.LedgerOffset(); - offset.setBoundary(grpc.LedgerOffset.LedgerBoundary.LEDGER_BEGIN); - - const completionEndResponse = new grpc.CompletionEndResponse(); - completionEndResponse.setOffset(offset); - - const listPackagesResponse = new grpc.ListPackagesResponse(); - - const getPackageResponse = new grpc.GetPackageResponse(); - - const getPackageStatusResponse = new grpc.GetPackageStatusResponse(); - - const effectiveAt = new Timestamp(); - const transactionTree = new grpc.TransactionTree(); - transactionTree.setEffectiveAt(effectiveAt); - const getTransactionResponse = new grpc.GetTransactionResponse(); - getTransactionResponse.setTransaction(transactionTree); - - const getLedgerEndResponse = new grpc.GetLedgerEndResponse(); - getLedgerEndResponse.setOffset(offset); - - this.addService(grpc.ActiveContractsService, { - getActiveContracts(call: ServerWriteableStream): void { - spy(call.request.getLedgerId()); - call.end(); - } - }); - - this.addService(grpc.CommandService, { - submitAndWait(call: ServerUnaryCall, callback: (error: ServiceError | null, value: Empty | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getCommands()!.getLedgerId()); - callback(null, empty); - } - }); - - this.addService(grpc.CommandCompletionService, { - completionStream(call: ServerWriteableStream): void { - spy(call.request.getLedgerId()); - call.end(); - }, - completionEnd(call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.CompletionEndResponse | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getLedgerId()); - callback(null, completionEndResponse); - } - }); - - this.addService(grpc.CommandSubmissionService, { - submit(call: ServerUnaryCall, callback: (error: ServiceError | null, value: Empty | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getCommands()!.getLedgerId()); - callback(null, empty); - } - }); - - this.addService(grpc.LedgerIdentityService, { - getLedgerIdentity(_call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.GetLedgerIdentityResponse | null, trailer?: Metadata, flags?: number) => void): void { - callback(null, ledgerIdentityResponse); - } - }); - - this.addService(grpc.PackageService, { - listPackages(call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.ListPackagesResponse | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getLedgerId()); - callback(null, listPackagesResponse); - }, - getPackage(call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.GetPackageResponse | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getLedgerId()); - callback(null, getPackageResponse); - }, - getPackageStatus(call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.GetPackageStatusResponse | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getLedgerId()); - callback(null, getPackageStatusResponse); - } - }); - - this.addService(grpc.LedgerConfigurationService, { - getLedgerConfiguration(call: ServerWriteableStream): void { - spy(call.request.getLedgerId()); - call.end(); - } - }); - - this.addService(grpc.testing.TimeService, { - getTime(call: ServerWriteableStream): void { - spy(call.request.getLedgerId()); - call.end(); - }, - setTime(call: ServerUnaryCall, callback: (error: ServiceError | null, value: Empty | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getLedgerId()); - callback(null, empty); - } - }); - - this.addService(grpc.TransactionService, { - getTransactions(call: ServerWriteableStream): void { - spy(call.request.getLedgerId()); - call.end(); - }, - getTransactionTrees(call: ServerWriteableStream): void { - spy(call.request.getLedgerId()); - call.end(); - }, - getTransactionByEventId(call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.GetTransactionResponse | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getLedgerId()); - callback(null, getTransactionResponse); - }, - getTransactionById(call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.GetTransactionResponse | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getLedgerId()); - callback(null, getTransactionResponse); - }, - getLedgerEnd(call: ServerUnaryCall, callback: (error: ServiceError | null, value: grpc.GetLedgerEndResponse | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getLedgerId()); - callback(null, getLedgerEndResponse); - } - }); - - this.addService(grpc.testing.ResetService, { - reset(call: ServerUnaryCall, callback: (error: ServiceError | null, value: Empty | null, trailer?: Metadata, flags?: number) => void): void { - spy(call.request.getLedgerId()); - callback(null, empty); - } - }); - - } - -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/model.spec.ts b/language-support/js/daml-ledger/tests/model.spec.ts deleted file mode 100644 index 2a0e80cce74..00000000000 --- a/language-support/js/daml-ledger/tests/model.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect } from 'chai'; -import * as ledger from '../src'; - -describe('Timestamp.lessThen', () => { - - it('should work as expected', () => { - - expect(ledger.Timestamp.lessThanOrEqual({ seconds: 1, nanoseconds: 1 }, { seconds: 1, nanoseconds: 1 }), - 'when left side has same seconds, same nanos result should be true').to.be.true; - - expect(ledger.Timestamp.lessThanOrEqual({ seconds: 1, nanoseconds: 0 }, { seconds: 1, nanoseconds: 1 }), - 'when left side has when left side has same seconds, less nanos result should be true').to.be.true; - - expect(ledger.Timestamp.lessThanOrEqual({ seconds: 1, nanoseconds: 2 }, { seconds: 1, nanoseconds: 1 }), - 'when left side has same seconds, more nanos result should be false').to.be.false; - - expect(ledger.Timestamp.lessThanOrEqual({ seconds: 0, nanoseconds: 1 }, { seconds: 1, nanoseconds: 1 }), - 'when left side has less seconds, same nanos result should be true').to.be.true; - - expect(ledger.Timestamp.lessThanOrEqual({ seconds: 0, nanoseconds: 0 }, { seconds: 1, nanoseconds: 1 }), - 'when left side has less seconds, less nanos result should be true').to.be.true; - - expect(ledger.Timestamp.lessThanOrEqual({ seconds: 0, nanoseconds: 2 }, { seconds: 1, nanoseconds: 1 }), - 'when left side has less seconds, more nanos result should be true').to.be.true; - - expect(ledger.Timestamp.lessThanOrEqual({ seconds: 2, nanoseconds: 1 }, { seconds: 1, nanoseconds: 1 }), - 'when left side has more seconds, same nanos result should be false').to.be.false; - - expect(ledger.Timestamp.lessThanOrEqual({ seconds: 2, nanoseconds: 0 }, { seconds: 1, nanoseconds: 1 }), - 'when left side has more seconds, less nanos result should be false').to.be.false; - - expect(ledger.Timestamp.lessThanOrEqual({ seconds: 2, nanoseconds: 2 }, { seconds: 1, nanoseconds: 1 }), - 'when left side has more seconds, more nanos result should be false').to.be.false; - - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/package_client.spec.ts b/language-support/js/daml-ledger/tests/package_client.spec.ts deleted file mode 100644 index da1f5858e36..00000000000 --- a/language-support/js/daml-ledger/tests/package_client.spec.ts +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { test } from 'mocha'; -import { expect, assert } from 'chai'; -import * as sinon from 'sinon'; -import { MockedPackageClient } from './mock'; -import * as grpc from 'daml-grpc'; -import * as ledger from '../src'; - -describe("PackageClient", () => { - - const ledgerId = 'some-cool-id'; - const latestRequestSpy = sinon.spy(); - const packageData: [string, [ledger.GetPackageResponse, ledger.GetPackageStatusResponse]][] = [ - ['package-1', [{ hashFunction: 0, hash: 'cafebabe', archivePayload: 'cafebabe' }, { status: 0 }]], - ['package-2', [{ hashFunction: 0, hash: 'deadbeef', archivePayload: 'deadbeef' }, { status: 1 }]] - ]; - - const ps = new MockedPackageClient(packageData, latestRequestSpy); - const pc = new ledger.PackageClient(ledgerId, ps); - - afterEach(() => { - sinon.restore(); - latestRequestSpy.resetHistory(); - }); - - test("[7.1] When supported packages are requested, it returns them from the ledger", (done) => { - pc.listPackages((error, response) => { - expect(error).to.be.null; - expect(response!.packageIds).to.deep.equal(['package-1', 'package-2']); - done(); - }); - }); - - test("[7.2] The supported packages are requested with the correct ledger ID", (done) => { - pc.listPackages((error, _response) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce, 'The latestRequestSpy has not been called exactly once'); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.ListPackagesRequest); - const request = latestRequestSpy.lastCall.lastArg as grpc.ListPackagesRequest; - expect(request.getLedgerId()).to.equal(ledgerId); - done(); - }); - }); - - test('[7.3] When a package is requested, it is returned from the ledger (present)', (done) => { - pc.getPackage('package-2', (error, response) => { - expect(error).to.be.null; - expect(response).to.deep.equal({ hashFunction: 0, hash: 'deadbeef', archivePayload: 'deadbeef' }); - done(); - }); - }); - - test('[7.3] When a package is requested, it is returned from the ledger (absent)', (done) => { - pc.getPackage('package-3', (error, response) => { - expect(response).to.be.undefined; - expect(error).to.not.be.null; - expect(error!.message).to.contain('NOT_FOUND'); - done(); - }); - }); - - test("[7.4] The package is requested with the correct ledger ID", (done) => { - pc.getPackage('package-2', (error, _response) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce, 'The latestRequestSpy has not been called exactly once'); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.GetPackageRequest); - const request = latestRequestSpy.lastCall.lastArg as grpc.GetPackageRequest; - expect(request.getLedgerId()).to.equal(ledgerId); - expect(request.getPackageId()).to.equal('package-2'); - done(); - }); - }); - - test('[7.5] When the status of a package is requested, it is returned from the ledger (present)', (done) => { - pc.getPackageStatus('package-2', (error, response) => { - expect(error).to.be.null; - expect(response).to.deep.equal({ status: 1 }); - done(); - }); - }); - - test('[7.5] When the status of a package is requested, it is returned from the ledger (absent)', (done) => { - pc.getPackageStatus('package-3', (error, response) => { - expect(response).to.be.undefined; - expect(error).to.not.be.null; - expect(error!.message).to.contain('NOT_FOUND'); - done(); - }); - }); - - test("[7.6] The status is requested with the correct ledger ID", (done) => { - pc.getPackageStatus('package-2', (error, _response) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce, 'The latestRequestSpy has not been called exactly once'); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.GetPackageStatusRequest); - const request = latestRequestSpy.lastCall.lastArg as grpc.GetPackageStatusRequest; - expect(request.getLedgerId()).to.equal(ledgerId); - expect(request.getPackageId()).to.equal('package-2'); - done(); - }); - }); - -}); diff --git a/language-support/js/daml-ledger/tests/reset_client.spec.ts b/language-support/js/daml-ledger/tests/reset_client.spec.ts deleted file mode 100644 index 1cf9cc9209e..00000000000 --- a/language-support/js/daml-ledger/tests/reset_client.spec.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect, assert } from 'chai'; -import * as sinon from 'sinon'; -import { MockedResetClient } from './mock'; -import * as ledger from '../src'; -import * as grpc from 'daml-grpc'; - -describe("ResetClient", () => { - - const ledgerId = 'cafebabe'; - - const latestRequestSpy = sinon.spy(); - - const client = new ledger.testing.ResetClient(ledgerId, new MockedResetClient(latestRequestSpy)); - - it("should pass the correct ledgerId", (done) => { - client.reset((error, _response) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce, 'The latestRequestSpy has not been called exactly once'); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.testing.ResetRequest); - const request = latestRequestSpy.lastCall.lastArg as grpc.testing.ResetRequest; - expect(request.getLedgerId()).to.equal(ledgerId); - done(); - }); - }); - -}); diff --git a/language-support/js/daml-ledger/tests/time_client.spec.ts b/language-support/js/daml-ledger/tests/time_client.spec.ts deleted file mode 100644 index 4f2cec26928..00000000000 --- a/language-support/js/daml-ledger/tests/time_client.spec.ts +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { test } from 'mocha'; -import { expect, assert } from 'chai'; -import * as sinon from 'sinon'; -import { MockedTimeClient } from './mock'; -import * as grpc from 'daml-grpc'; -import * as ledger from '../src'; -import { reporting } from '../src'; -import * as mapping from '../src/mapping'; -import * as validation from '../src/validation'; - -describe('TimeClient', () => { - - const ledgerId = 'cafebabe'; - const latestRequestSpy = sinon.spy(); - const responses: ledger.GetTimeResponse[] = [ - { currentTime: { seconds: 10, nanoseconds: 1 } }, - { currentTime: { seconds: 11, nanoseconds: 1 } }, - { currentTime: { seconds: 12, nanoseconds: 1 } }, - { currentTime: { seconds: 13, nanoseconds: 1 } } - ]; - const responseMessages = responses.map(response => mapping.GetTimeResponse.toMessage(response)); - const mockedGrpcClient = new MockedTimeClient(responseMessages, latestRequestSpy); - const client = new ledger.testing.TimeClient(ledgerId, mockedGrpcClient, reporting.JSONReporter); - - const setTimeRequest: ledger.SetTimeRequest = { - currentTime: { seconds: 4, nanoseconds: 1 }, - newTime: { seconds: 5, nanoseconds: 1 } - } - const invalidSetTimeRequest: ledger.SetTimeRequest = { - currentTime: { seconds: 4, nanoseconds: 1 }, - newTime: { seconds: 3, nanoseconds: 1 } - } - - afterEach(() => { - sinon.restore(); - latestRequestSpy.resetHistory(); - }); - - test('[9.1] The correct ledger ID, current and new time of the set time request are passed to the ledger', (done) => { - - client.setTime(setTimeRequest, (error, _) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.testing.SetTimeRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.testing.SetTimeRequest; - expect(mapping.SetTimeRequest.toObject(spiedRequest)).to.deep.equal(setTimeRequest); - expect(spiedRequest.getLedgerId()).to.equal(ledgerId); - done(); - }); - - }); - - test('[9.2] When ledger times are requested, ledger times are returned from the ledger', (done) => { - - const call = client.getTime(); - - let counter = 0; - call.on('data', (response) => { - expect(response).to.deep.equal(responses[counter]); - counter = counter + 1; - }); - call.on('end', () => { - expect(counter).to.equal(responses.length); - done(); - }); - call.on('error', (error) => { - done(error); - }); - - }); - - test('[9.3] Ledger times stream is requested with the correct ledger ID', (done) => { - - const call = client.getTime(); - call.on('end', () => { - assert(latestRequestSpy.calledOnce, 'The latestRequestSpy has not been called exactly once'); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.instanceof(grpc.testing.GetTimeRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.testing.GetTimeRequest; - expect(spiedRequest.getLedgerId()).to.equal(ledgerId); - done(); - }); - call.on('error', (error) => { - done(error); - }); - - }); - - // The client in the JS bindings performs no check about the semantics of the message - // This check is fully delegated to the server, who already implements this logic - test.skip('[9.4] When ledger time is set, an error is returned if current time >= new time', (done) => { - - client.setTime(invalidSetTimeRequest, (error, _) => { - expect(error).to.not.be.null; - done(); - }); - - }); - - test('Validation: an ill-formed message does not pass validation (setTime)', (done) => { - - const invalidRequest = { - currentTime: { seconds: 3, nanoseconds: '0' }, - newTime: { seconds: 4, nanoseconds: 0 } - }; - - const expectedValidationTree: validation.Tree = { - errors: [], - children: { - currentTime: { - errors: [], - children: { - seconds: { - errors: [], - children: {} - }, - nanoseconds: { - errors: [{ - kind: 'type-error', - expectedType: 'number', - actualType: 'string' - }], - children: {} - } - } - }, - newTime: { - errors: [], - children: { - seconds: { - errors: [], - children: {} - }, - nanoseconds: { - errors: [], - children: {} - } - } - } - } - } - - client.setTime(invalidRequest as any as ledger.SetTimeRequest, error => { - expect(error).to.not.be.null; - expect(JSON.parse(error!.message)).to.deep.equal(expectedValidationTree); - done(); - }); - - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/transaction_client.spec.ts b/language-support/js/daml-ledger/tests/transaction_client.spec.ts deleted file mode 100644 index f29e2bbe750..00000000000 --- a/language-support/js/daml-ledger/tests/transaction_client.spec.ts +++ /dev/null @@ -1,390 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { test } from 'mocha'; -import { assert, expect } from 'chai'; -import * as sinon from 'sinon'; -import * as grpc from 'daml-grpc'; -import * as ledger from '../src'; -import { MockedTransactionClient } from './mock'; -import { reporting } from '../src'; -import * as mapping from '../src/mapping'; -import * as validation from '../src/validation'; - -describe('TransactionClient', () => { - - const transactionsRequest: ledger.GetTransactionsRequest = { - begin: { - absolute: '42' - }, - filter: { - filtersByParty: { - someParty: { - inclusive: { - templateIds: [ - { packageId: 'foo1', moduleName: 'bar1', entityName: 'baz1' }, - { packageId: 'foo2', moduleName: 'bar2', entityName: 'baz2' }, - ] - } - }, - someOtherParty: {} - } - }, - verbose: false - }; - - const transactionByIdRequest: ledger.GetTransactionByIdRequest = { - requestingParties: [], - transactionId: 'cafebabe' - }; - - const transactionByEventIdRequest: ledger.GetTransactionByEventIdRequest = { - requestingParties: [], - eventId: 'some-created-id' - }; - - const latestRequestSpy = sinon.spy(); - const ledgerId = 'deadbeef'; - const mockedGrpcClient = new MockedTransactionClient(ledgerId, latestRequestSpy); - const client = new ledger.TransactionClient(ledgerId, mockedGrpcClient, reporting.JSONReporter); - - afterEach(() => { - latestRequestSpy.resetHistory(); - sinon.restore(); - }); - - test.skip('[8.1] When transactions are requested, transactions are returned from the ledger', (done) => { - - done(new Error('UNTESTED')); - - }); - - test('[8.2] Start offset, end offset, transaction filter and verbose flag are passed with the transactions request to the ledger', (done) => { - - const call = client.getTransactions(transactionsRequest); - call.on('error', (error) => { - done(error); - }); - call.on('end', () => { - assert(latestRequestSpy.calledOnce, 'The latestRequestSpy has not been called exactly once'); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.instanceof(grpc.GetTransactionsRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.GetTransactionsRequest; - expect(mapping.GetTransactionsRequest.toObject(spiedRequest)).to.deep.equal(transactionsRequest); - done(); - }); - - }); - - test('[8.2] The verbose flag defaults to true when not specified', (done) => { - - const requestWithoutExplicitVerbose = { ...transactionsRequest }; - delete requestWithoutExplicitVerbose.verbose; - - const call = client.getTransactions(requestWithoutExplicitVerbose); - call.on('error', (error) => { - done(error); - }); - call.on('end', () => { - assert(latestRequestSpy.calledOnce, 'The latestRequestSpy has not been called exactly once'); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.instanceof(grpc.GetTransactionsRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.GetTransactionsRequest; - expect(spiedRequest.getVerbose()).to.be.true; - done(); - }); - - }); - - test('[8.3] Transaction stream is requested with the correct ledger ID', (done) => { - - const call = client.getTransactions(transactionsRequest); - call.on('error', (error) => { - done(error); - }); - call.on('end', () => { - assert(latestRequestSpy.calledOnce, 'The latestRequestSpy has not been called exactly once'); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.instanceof(grpc.GetTransactionsRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.GetTransactionsRequest; - expect(spiedRequest.getLedgerId()).to.equal(ledgerId); - done(); - }); - - }); - - it.skip('[8.4] Transaction stream handles backpressure', (done) => { - - done(new Error('UNTESTED')); - - }); - - it.skip('[8.5] When transaction trees are requested, transaction trees are returned from the ledger', (done) => { - - done(new Error('UNTESTED')); - - }); - - it.skip('[8.6] Start offset, end offset transaction filter and verbose flag are passed with the transaction trees request to the ledger', (done) => { - - done(new Error('UNTESTED')); - - }); - - it.skip('[8.7] Transaction tree stream is requested with the correct ledger ID', (done) => { - - done(new Error('UNTESTED')); - - }); - - it.skip('[8.8] Transaction tree stream handles backpressure', (done) => { - - done(new Error('UNTESTED')); - - }); - - test.skip('[8.9] Transactions can be looked up by a contained event ID', (done) => { - - done(new Error('UNTESTED')); - - }); - - test('[8.10] The requesting parties are passed with the transaction lookup by event ID', (done) => { - - client.getTransactionByEventId(transactionByEventIdRequest, (error, _response) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.GetTransactionByEventIdRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.GetTransactionByEventIdRequest; - expect(mapping.GetTransactionByEventIdRequest.toObject(spiedRequest)).to.deep.equal(transactionByEventIdRequest); - done(); - }); - - }); - - test('[8.11] The transaction lookup by event ID happens with the correct ledger ID', (done) => { - - client.getTransactionByEventId(transactionByEventIdRequest, (error, _response) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.GetTransactionByEventIdRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.GetTransactionByEventIdRequest; - expect(spiedRequest.getLedgerId()).to.equal(ledgerId); - done(); - }); - - }); - - test.skip('[8.12] Transactions can be looked up by transaction ID', (done) => { - - done(new Error('UNTESTED')); - - }); - - test('[8.13] The requesting parties are passed with the transaction lookup by transaction ID', (done) => { - - client.getTransactionById(transactionByIdRequest, (error, _response) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.GetTransactionByIdRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.GetTransactionByIdRequest; - expect(mapping.GetTransactionByIdRequest.toObject(spiedRequest)).to.deep.equal(transactionByIdRequest); - done(); - }); - }); - - test('[8.14] The transaction lookup by transaction ID happens with the correct ledger ID', (done) => { - - client.getTransactionById(transactionByIdRequest, (error, _response) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.GetTransactionByIdRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.GetTransactionByIdRequest; - expect(spiedRequest.getLedgerId()).to.equal(ledgerId); - done(); - }); - - }); - - test.skip('[8.15] When the ledger end is requested, it is provided from the ledger (non-empty ledger)', (done) => { - - done(new Error('UNTESTED')); - - }); - - test.skip('[8.15] When the ledger end is requested, it is provided from the ledger (empty ledger)', (done) => { - - done(new Error('UNTESTED')); - - }); - - test('[8.16] The ledger end is requested with the correct ledger ID', (done) => { - - client.getLedgerEnd((error, _response) => { - expect(error).to.be.null; - assert(latestRequestSpy.calledOnce); - expect(latestRequestSpy.lastCall.args).to.have.length(1); - expect(latestRequestSpy.lastCall.lastArg).to.be.an.instanceof(grpc.GetLedgerEndRequest); - const spiedRequest = latestRequestSpy.lastCall.lastArg as grpc.GetLedgerEndRequest; - expect(spiedRequest.getLedgerId()).to.equal(ledgerId); - done(); - }); - - }); - - test('Validation: an ill-formed message does not pass validation (getTransactionByEventId)', (done) => { - - const invalidRequest = { - eventId: 'some-event-id', - requestingParties: 42 - }; - - const expectedValidationTree: validation.Tree = { - errors: [], - children: { - eventId: { - errors: [], - children: {} - }, - requestingParties: { - errors: [{ - kind: 'type-error', - expectedType: 'Array', - actualType: 'number' - }], - children: {} - } - } - } - - client.getTransactionByEventId(invalidRequest as any as ledger.GetTransactionByEventIdRequest, error => { - expect(error).to.not.be.null; - expect(JSON.parse(error!.message)).to.deep.equal(expectedValidationTree); - done(); - }); - - }); - - test('Validation: an ill-formed message does not pass validation (getTransactions)', (done) => { - - const invalidTransactionsRequest: ledger.GetTransactionsRequest = { - begin: { - absolute: '42', - boundary: ledger.LedgerOffset.Boundary.BEGIN - }, - filter: { - filtersByParty: {} - } - }; - - const expectedValidationTree: validation.Tree = { - errors: [], - children: { - begin: { - errors: [{ - kind: 'non-unique-union', - keys: ['absolute', 'boundary'] - }], - children: { - absolute: { - errors: [], - children: {} - }, - boundary: { - errors: [], - children: {} - } - } - }, - filter: { - errors: [], - children: { - filtersByParty: { - errors: [], - children: {} - } - } - } - } - } - - let passed = false; - const call = client.getTransactions(invalidTransactionsRequest); - call.on('data', (_data) => { - done(new Error('unexpected data received')); - }); - call.on('error', (error) => { - expect(JSON.parse(error.message)).to.deep.equal(expectedValidationTree); - passed = true; - }); - call.on('end', () => { - assert(passed); - done(); - }); - - }); - - test('Validation: an ill-formed message does not pass validation (getTransactionTrees)', (done) => { - - const invalidTransactionsRequest: ledger.GetTransactionsRequest = { - begin: { - absolute: '42', - boundary: ledger.LedgerOffset.Boundary.BEGIN - }, - filter: { - filtersByParty: {} - } - }; - - const expectedValidationTree: validation.Tree = { - errors: [], - children: { - begin: { - errors: [{ - kind: 'non-unique-union', - keys: ['absolute', 'boundary'] - }], - children: { - absolute: { - errors: [], - children: {} - }, - boundary: { - errors: [], - children: {} - } - } - }, - filter: { - errors: [], - children: { - filtersByParty: { - errors: [], - children: {} - } - } - } - } - } - - let passed = false; - const call = client.getTransactionTrees(invalidTransactionsRequest); - call.on('data', (_data) => { - done(new Error('unexpected data received')); - }); - call.on('error', (error) => { - expect(JSON.parse(error.message)).to.deep.equal(expectedValidationTree); - passed = true; - }); - call.on('end', () => { - assert(passed); - done(); - }); - - }); - -}); diff --git a/language-support/js/daml-ledger/tests/validation/base/array.spec.ts b/language-support/js/daml-ledger/tests/validation/base/array.spec.ts deleted file mode 100644 index 7269fbd1c35..00000000000 --- a/language-support/js/daml-ledger/tests/validation/base/array.spec.ts +++ /dev/null @@ -1,429 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect } from 'chai'; -import { array, native } from '../../../src/validation/base' -import { Tree, Identifier, InclusiveFilters } from '../../../src/validation'; -import * as ledger from '../../../src'; - -describe('Validation: Array', () => { - - it('should validate an empty array correctly', () => { - const expected: Tree = { - errors: [], - children: {} - } - expect(array(native('number')).validate([])).to.deep.equal(expected); - }); - - it('should not validate a number', () => { - const expected: Tree = { - errors: [{ - kind: 'type-error', - expectedType: 'Array', - actualType: 'number' - }], - children: {} - } - expect(array(native('number')).validate(42)).to.deep.equal(expected); - }); - - it('should not validate a string', () => { - const expected: Tree = { - errors: [{ - kind: 'type-error', - expectedType: 'Array', - actualType: 'string' - }], - children: {} - } - expect(array(native('number')).validate('42')).to.deep.equal(expected); - }); - - it('should validate an array with one number', () => { - const expected: Tree = { - errors: [], - children: { - '0': { - errors: [], - children: {} - } - } - } - expect(array(native('number')).validate([42])).to.deep.equal(expected); - }); - - it('should validate an array with two numbers', () => { - const expected: Tree = { - errors: [], - children: { - '0': { - errors: [], - children: {} - }, - '1': { - errors: [], - children: {} - } - } - } - expect(array(native('number')).validate([42, 47])).to.deep.equal(expected); - }); - - it('should correctly report an error if an underlying item is of the wrong type', () => { - const expected: Tree = { - errors: [], - children: { - '0': { - errors: [], - children: {} - }, - '1': { - errors: [{ - kind: 'type-error', - expectedType: 'number', - actualType: 'string' - }], - children: {} - } - } - } - expect(array(native('number')).validate([42, '47'])).to.deep.equal(expected); - }); - - it('should validate an array with two objects', () => { - const identifiers: ledger.Identifier[] = [ - { - packageId: 'bar1', - moduleName: 'foo1', - entityName: 'baz1' - }, - { - packageId: 'bar2', - moduleName: 'foo2', - entityName: 'baz2' - } - ] - const expected: Tree = { - errors: [], - children: { - '0': { - errors: [], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - packageId: { - errors: [], - children: {} - } - } - }, - '1': { - errors: [], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - packageId: { - errors: [], - children: {} - } - } - } - } - } - expect(array(Identifier).validate(identifiers)).to.deep.equal(expected); - }); - - it('should correctly report errors in an array with invalid objects', () => { - const invalidIdentifiers = [ - 'not-an-identifier :(', - { - moduleName: 'foo', - entityName: 'baz' - } - ] - const expected: Tree = { - errors: [], - children: { - '0': { - errors: [{ - kind: 'type-error', - expectedType: 'Identifier', - actualType: 'string' - }], - children: {} - }, - '1': { - errors: [{ - kind: 'missing-key', - expectedKey: 'packageId', - expectedType: 'string' - }], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - } - } - } - } - expect(array(Identifier).validate(invalidIdentifiers)).to.deep.equal(expected); - }); - - it('should validate an empty set of filters', () => { - const inclusiveFilters: ledger.InclusiveFilters = { - templateIds: [] - }; - const expected: Tree = { - errors: [], - children: { - templateIds: { - errors: [], - children: {} - } - } - }; - expect(InclusiveFilters.validate(inclusiveFilters)).to.deep.equal(expected); - }); - - it('should validate an set of filters with one identifier', () => { - const inclusiveFilters: ledger.InclusiveFilters = { - templateIds: [{ - packageId: 'bar', - moduleName: 'foo', - entityName: 'baz', - }] - }; - const expected: Tree = { - errors: [], - children: { - templateIds: { - errors: [], - children: { - '0': { - errors: [], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - packageId: { - errors: [], - children: {} - } - } - } - } - } - } - }; - expect(InclusiveFilters.validate(inclusiveFilters)).to.deep.equal(expected); - }); - - it('should validate an set of filters with two identifiers', () => { - const inclusiveFilters: ledger.InclusiveFilters = { - templateIds: [{ - packageId: 'bar1', - moduleName: 'foo1', - entityName: 'baz1', - }, { - packageId: 'bar2', - moduleName: 'foo2', - entityName: 'baz2', - }] - }; - const expected: Tree = { - errors: [], - children: { - templateIds: { - errors: [], - children: { - '0': { - errors: [], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - packageId: { - errors: [], - children: {} - } - } - }, - '1': { - errors: [], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - packageId: { - errors: [], - children: {} - } - } - } - } - } - } - }; - expect(InclusiveFilters.validate(inclusiveFilters)).to.deep.equal(expected); - }); - - it('should not validate a string', () => { - const invalidInclusiveFilters = 'not a valid object :('; - const expected: Tree = { - errors: [{ - kind: 'type-error', - expectedType: 'InclusiveFilters', - actualType: 'string' - }], - children: {} - }; - expect(InclusiveFilters.validate(invalidInclusiveFilters)).to.deep.equal(expected); - }); - - it('should provide precise feedback about a single mistake', () => { - const invalidInclusiveFilters = { - templateIds: [{ - packageId: 'bar1', - moduleName: 'foo1', - entityName: 'baz1', - }, { - packageId: 42, - moduleName: 'foo2', - entityName: 'baz2', - }] - }; - const expected: Tree = { - errors: [], - children: { - templateIds: { - errors: [], - children: { - '0': { - errors: [], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - packageId: { - errors: [], - children: {} - } - } - }, - '1': { - errors: [], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - packageId: { - errors: [{ - kind: 'type-error', - expectedType: 'string', - actualType: 'number' - }], - children: {} - } - } - } - } - } - } - }; - expect(InclusiveFilters.validate(invalidInclusiveFilters)).to.deep.equal(expected); - }); - - it('should provide thorough feedback about extensive mistakes', () => { - const invalidInclusiveFilters = { - templateIds: [{ - moduleName: false - }, - 42 - ] - }; - const expected: Tree = { - errors: [], - children: { - templateIds: { - errors: [], - children: { - '0': { - errors: [{ - kind: 'missing-key', - expectedKey: 'packageId', - expectedType: 'string' - },{ - kind: 'missing-key', - expectedKey: 'entityName', - expectedType: 'string' - }], - children: { - moduleName: { - errors: [{ - kind: 'type-error', - expectedType: 'string', - actualType: 'boolean' - }], - children: {} - } - } - }, - '1': { - errors: [{ - kind: 'type-error', - expectedType: 'Identifier', - actualType: 'number' - }], - children: {} - } - } - } - } - }; - expect(InclusiveFilters.validate(invalidInclusiveFilters)).to.deep.equal(expected); - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/validation/base/enumeration.spec.ts b/language-support/js/daml-ledger/tests/validation/base/enumeration.spec.ts deleted file mode 100644 index 53e113e5f24..00000000000 --- a/language-support/js/daml-ledger/tests/validation/base/enumeration.spec.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect } from 'chai'; -import { enumeration } from '../../../src/validation/base'; -import * as validation from '../../../src/validation'; -import { LedgerOffset } from '../../../src' - -describe('Validation: Enumeration', () => { - - it('should validate a value of the enumeration correctly', () => { - const expected: validation.Tree = { - errors: [], - children: {} - } - const validation = enumeration(LedgerOffset.Boundary, 'LedgerOffset.Boundary') - expect(validation.validate(LedgerOffset.Boundary.BEGIN)).to.deep.equal(expected); - }); - - it('should validate a second value of the enumeration correctly', () => { - const expected: validation.Tree = { - errors: [], - children: {} - } - const validation = enumeration(LedgerOffset.Boundary, 'LedgerOffset.Boundary') - expect(validation.validate(LedgerOffset.Boundary.END)).to.deep.equal(expected); - }); - - it('should not validate a value which is not part of the enumeration', () => { - const expected: validation.Tree = { - errors: [{ - kind: 'type-error', - expectedType: 'LedgerOffset.Boundary', - actualType: 'number' - }], - children: {} - } - const validation = enumeration(LedgerOffset.Boundary, 'LedgerOffset.Boundary') - expect(validation.validate(42)).to.deep.equal(expected); - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/validation/base/native.spec.ts b/language-support/js/daml-ledger/tests/validation/base/native.spec.ts deleted file mode 100644 index 22308cc04bf..00000000000 --- a/language-support/js/daml-ledger/tests/validation/base/native.spec.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect } from 'chai'; -import { native } from '../../../src/validation/base' -import { Tree } from '../../../src/validation'; - -describe('Validation: Native', () => { - - it('should validate a simple string correctly', () => { - const expected: Tree = { - errors: [], - children: {} - } - expect(native('string').validate('hello, world')).to.deep.equal(expected); - }); - - it('should fail to validate a number when a string is expected', () => { - const expected: Tree = { - errors: [{ - kind: 'type-error', - expectedType: 'string', - actualType: 'number' - }], - children: {} - } - expect(native('string').validate(42)).to.deep.equal(expected); - }); - - it('should fail to validate a string when a boolean is expected', () => { - const expected: Tree = { - errors: [{ - kind: 'type-error', - expectedType: 'boolean', - actualType: 'string' - }], - children: {} - } - expect(native('boolean').validate('true')).to.deep.equal(expected); - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/validation/base/object.spec.ts b/language-support/js/daml-ledger/tests/validation/base/object.spec.ts deleted file mode 100644 index 41ec25aed99..00000000000 --- a/language-support/js/daml-ledger/tests/validation/base/object.spec.ts +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect } from 'chai'; -import * as ledger from '../../../src'; -import * as validation from '../../../src/validation'; - -describe('Validation: Object', () => { - - it('should report a correct tree as such', () => { - const identifier: ledger.Identifier = { - packageId: 'bar', - moduleName: 'foo', - entityName: 'baz', - }; - const expected: validation.Tree = { - errors: [], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - packageId: { - errors: [], - children: {} - } - } - }; - expect(validation.Identifier.validate(identifier)).to.deep.equal(expected); - }); - - it('should correctly report a missing key', () => { - const invalidIdentifier = { - packageId: 'bar' - }; - const expected: validation.Tree = { - errors: [{ - kind: 'missing-key', - expectedKey: 'moduleName', - expectedType: 'string' - },{ - kind: 'missing-key', - expectedKey: 'entityName', - expectedType: 'string' - }], - children: { - packageId: { - errors: [], - children: {} - } - } - }; - expect(validation.Identifier.validate(invalidIdentifier)).to.deep.equal(expected); - }); - - it('should correctly report a type error in a child', () => { - const invalidIdentifier = { - packageId: 'bar', - moduleName: 42, - entityName: 'baz', - }; - const expected: validation.Tree = { - errors: [], - children: { - moduleName: { - errors: [ - { - kind: 'type-error', - expectedType: 'string', - actualType: 'number' - } - ], - children: {} - }, - packageId: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - } - }; - expect(validation.Identifier.validate(invalidIdentifier)).to.deep.equal(expected); - }); - - it('should correctly report multiple type errors in the children', () => { - const invalidIdentifier = { - packageId: true, - moduleName: 42, - entityName: false, - }; - const expected: validation.Tree = { - errors: [], - children: { - moduleName: { - errors: [ - { - kind: 'type-error', - expectedType: 'string', - actualType: 'number' - } - ], - children: {} - }, - packageId: { - errors: [ - { - kind: 'type-error', - expectedType: 'string', - actualType: 'boolean' - } - ], - children: {} - }, - entityName: { - errors: [ - { - kind: 'type-error', - expectedType: 'string', - actualType: 'boolean' - } - ], - children: {} - }, - } - }; - expect(validation.Identifier.validate(invalidIdentifier)).to.deep.equal(expected); - }); - - it('should correctly report a type error at the root (passing a native)', () => { - const invalidIdentifier = 42; - const expected: validation.Tree = { - errors: [ - { - kind: 'type-error', - expectedType: 'Identifier', - actualType: 'number' - } - ], - children: {} - } - expect(validation.Identifier.validate(invalidIdentifier)).to.deep.equal(expected); - }); - - it('should correctly report a type error at the root (passing an array)', () => { - const invalidIdentifier = [ 42, 47 ]; - const expected: validation.Tree = { - errors: [ - { - kind: 'type-error', - expectedType: 'Identifier', - actualType: 'array' - } - ], - children: {} - } - expect(validation.Identifier.validate(invalidIdentifier)).to.deep.equal(expected); - }); - - it('should validate the filters without the optional fields', () => { - const emptyFilters: ledger.Filters = {} - const expected: validation.Tree = { - errors: [], - children: {} - }; - expect(validation.Filters.validate(emptyFilters)).to.deep.equal(expected); - }); - - it('should validate a filter with an empty set of inclusive filters', () => { - const filters: ledger.Filters = { - inclusive: { - templateIds: [] - } - } - const expected: validation.Tree = { - errors: [], - children: { - inclusive: { - errors: [], - children: { - templateIds: { - errors: [], - children: {} - } - } - } - } - }; - expect(validation.Filters.validate(filters)).to.deep.equal(expected); - }); - - it('should validate a filter with a set of inclusive filters with one identifier', () => { - const filters: ledger.Filters = { - inclusive: { - templateIds: [{ - packageId: 'bar', - moduleName: 'foo', - entityName: 'baz', - }] - } - } - const expected: validation.Tree = { - errors: [], - children: { - inclusive: { - errors: [], - children: { - templateIds: { - errors: [], - children: { - '0': { - errors: [], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - packageId: { - errors: [], - children: {} - } - } - } - } - } - } - } - } - }; - expect(validation.Filters.validate(filters)).to.deep.equal(expected); - }); - - it('should not validate a string', () => { - const invalidFilters = 'not a valid object :('; - const expected: validation.Tree = { - errors: [{ - kind: 'type-error', - expectedType: 'Filters', - actualType: 'string' - }], - children: {} - }; - expect(validation.Filters.validate(invalidFilters)).to.deep.equal(expected); - }); - - it('should report in case of a crass mistake', () => { - const actuallyInclusiveFilters: ledger.InclusiveFilters = { - templateIds: [{ - packageId: 'bar1', - moduleName: 'foo1', - entityName: 'baz1', - }, { - packageId: 'bar2', - moduleName: 'foo2', - entityName: 'baz2', - }] - }; - const expected: validation.Tree = { - errors: [{ - kind: 'unexpected-key', - key: 'templateIds' - }], - children: {} - }; - expect(validation.Filters.validate(actuallyInclusiveFilters)).to.deep.equal(expected); - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/validation/base/record.spec.ts b/language-support/js/daml-ledger/tests/validation/base/record.spec.ts deleted file mode 100644 index e324b902958..00000000000 --- a/language-support/js/daml-ledger/tests/validation/base/record.spec.ts +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect } from 'chai'; -import * as ledger from '../../../src'; -import * as validation from '../../../src/validation'; - -describe('Validation: Record', () => { - - it('should validate an empty object', () => { - const transactionFilter: ledger.TransactionFilter = { - filtersByParty: {} - }; - const expected: validation.Tree = { - errors: [], - children: { - filtersByParty: { - errors: [], - children: {} - } - } - }; - expect(validation.TransactionFilter.validate(transactionFilter)).to.deep.equal(expected); - }); - - it('should validate a simple correct object', () => { - const transactionFilter: ledger.TransactionFilter = { - filtersByParty: { - birthday: { - inclusive: { - templateIds: [ - { - packageId: 'pkg', - moduleName: 'mdl', - entityName: 'ent', - } - ] - } - } - } - }; - const expected: validation.Tree = { - errors: [], - children: { - filtersByParty: { - errors: [], - children: { - birthday: { - errors: [], - children: { - inclusive: { - errors: [], - children: { - templateIds: { - errors: [], - children: { - '0': { - errors: [], - children: { - moduleName: { - errors: [], - children: {} - }, - entityName: { - errors: [], - children: {} - }, - packageId: { - errors: [], - children: {} - } - } - } - } - } - } - } - } - } - } - } - } - }; - expect(validation.TransactionFilter.validate(transactionFilter)).to.deep.equal(expected); - }); - - it('should not validate an ill-formed object', () => { - const invalidTransactionFilter = { - filtersByParty: { - birthday: 42 - } - }; - const expected: validation.Tree = { - errors: [], - children: { - filtersByParty: { - errors: [], - children: { - birthday: { - errors: [{ - kind: 'type-error', - expectedType: 'Filters', - actualType: 'number' - }], - children: {} - } - } - } - } - }; - expect(validation.TransactionFilter.validate(invalidTransactionFilter)).to.deep.equal(expected); - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/validation/base/tree.spec.ts b/language-support/js/daml-ledger/tests/validation/base/tree.spec.ts deleted file mode 100644 index 6438314fde1..00000000000 --- a/language-support/js/daml-ledger/tests/validation/base/tree.spec.ts +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect } from 'chai'; -import { ok, Tree } from '../../../src/validation'; - -describe('Tree: ok', () => { - - it('should tell the empty tree is valid', () => { - const tree: Tree = { - errors: [], - children: {} - } - expect(ok(tree)).to.be.true; - }); - - it('should tell a well-formed tree is such', () => { - const tree: Tree = { - errors: [], - children: { - inclusive: { - errors: [], - children: { - templateIds: { - errors: [], - children: { - '0': { - errors: [], - children: { - name: { - errors: [], - children: {} - }, - packageId: { - errors: [], - children: {} - } - } - } - } - } - } - } - } - } - expect(ok(tree)).to.be.true; - }); - - it('should tell an ill-formed tree is such', () => { - const tree: Tree = { - errors: [], - children: { - filtersByParty: { - errors: [], - children: { - birthday: { - errors: [{ - kind: 'type-error', - expectedType: 'Filters', - actualType: 'string' - }], - children: {} - } - } - } - } - } - expect(ok(tree)).to.be.false; - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/validation/base/union.spec.ts b/language-support/js/daml-ledger/tests/validation/base/union.spec.ts deleted file mode 100644 index 6ebac2222c9..00000000000 --- a/language-support/js/daml-ledger/tests/validation/base/union.spec.ts +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import { expect } from 'chai'; -import * as ledger from '../../../src'; -import * as validation from '../../../src/validation'; - -describe('Validation: Union', () => { - - it('should validate an absolute offset', () => { - const offset: ledger.LedgerOffset = { - absolute: '20' - }; - const expected: validation.Tree = { - errors: [], - children: { - absolute: { - errors: [], - children: {} - } - } - }; - expect(validation.LedgerOffset.validate(offset)).to.deep.equal(expected); - }); - - it('should validate a valid boundary (begin)', () => { - const offset: ledger.LedgerOffset = { - boundary: ledger.LedgerOffset.Boundary.BEGIN - }; - const expected: validation.Tree = { - errors: [], - children: { - boundary: { - errors: [], - children: {} - } - } - }; - expect(validation.LedgerOffset.validate(offset)).to.deep.equal(expected); - }); - - it('should validate a valid boundary (end)', () => { - const offset: ledger.LedgerOffset = { - boundary: ledger.LedgerOffset.Boundary.END - }; - const expected: validation.Tree = { - errors: [], - children: { - boundary: { - errors: [], - children: {} - } - } - }; - expect(validation.LedgerOffset.validate(offset)).to.deep.equal(expected); - }); - - it('should not validate a ledger offset with both (valid) absolute and boundary values', () => { - const offset: ledger.LedgerOffset = { - absolute: '20', - boundary: ledger.LedgerOffset.Boundary.END - }; - const expected: validation.Tree = { - errors: [{ - kind: 'non-unique-union', - keys: ['absolute', 'boundary'] - }], - children: { - absolute: { - errors: [], - children: {} - }, - boundary: { - errors: [], - children: {} - } - } - }; - expect(validation.LedgerOffset.validate(offset)).to.deep.equal(expected); - }); - - it('should not validate a ledger offset without values', () => { - const offset: ledger.LedgerOffset = {}; - const expected: validation.Tree = { - errors: [{ - kind: 'non-unique-union', - keys: [] - }], - children: {} - }; - expect(validation.LedgerOffset.validate(offset)).to.deep.equal(expected); - }); - - it('should not validate a ledger offset with an unexpected key', () => { - const offset = { - wrong: '20' - }; - const expected: validation.Tree = { - errors: [{ - kind: 'unexpected-key', - key: 'wrong' - }], - children: {} - }; - expect(validation.LedgerOffset.validate(offset)).to.deep.equal(expected); - }); - -}); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/validation/index.ts b/language-support/js/daml-ledger/tests/validation/index.ts deleted file mode 100644 index c9664f0157a..00000000000 --- a/language-support/js/daml-ledger/tests/validation/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as validation from "../../src/validation"; - -export function pickFrom(as: A[]): A { - return as[(Math.floor(Math.random()) * as.length) % as.length]; -} - -function looselyEqual(left: string[], right: string[]): boolean { - const l = [...left].sort(); - const r = [...right].sort(); - return l.every((v, i) => v === r[i]); -} - -export function containsError(errors: validation.Error[], check: validation.Error): boolean { - return errors.some(error => { - switch (error.kind) { - case 'type-error': - return check.kind === 'type-error' && check.actualType === error.actualType && check.expectedType === error.expectedType; - case 'unexpected-key': - return check.kind === 'unexpected-key' && check.key === error.key; - case 'non-unique-union': - return check.kind === 'non-unique-union' && looselyEqual(check.keys, error.keys); - case 'missing-key': - return check.kind === 'missing-key' && check.expectedType === error.expectedType && check.expectedKey === error.expectedKey; - } - }); -} \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/validation/object.spec.ts b/language-support/js/daml-ledger/tests/validation/object.spec.ts deleted file mode 100644 index 56bb8ad94b5..00000000000 --- a/language-support/js/daml-ledger/tests/validation/object.spec.ts +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as arbitrary from '../arbitrary'; -import * as validation from '../../src/validation'; -import { ok, ObjectValidation } from '../../src/validation/base'; - -import { containsError, pickFrom } from '.'; - -function test([validation, arbitrary]: [ObjectValidation, jsc.Arbitrary]): void { - describe(`Validation: ${validation.type}`, () => { - const required = validation.required(); - const optional = validation.optional(); - const requiredKeys = Object.keys(required); - const optionalKeys = Object.keys(optional); - const validations = Object.assign({}, required, optional); - const keys = Object.keys(validations); - if (validation.type !== 'null') { - jsc.property('not validate a null', () => { - return !ok(validation.validate(null)); - }); - jsc.property('signal a type error on a null', () => { - return containsError(validation.validate(null).errors, { - kind: 'type-error', - expectedType: validation.type, - actualType: 'null' - }); - }); - } - jsc.property('validate well-formed objects', arbitrary, value => { - return ok(validation.validate(value)); - }); - if (requiredKeys.length > 0) { - jsc.property('not validate objects without a required key', arbitrary, value => { - delete value[pickFrom(requiredKeys)]; - return !ok(validation.validate(value)); - }); - jsc.property('signal a missing key error on objects without a required key', arbitrary, value => { - const removedKey = pickFrom(requiredKeys); - const removedKeyType = (required)[removedKey].type; - delete value[removedKey]; - return containsError(validation.validate(value).errors, { - kind: 'missing-key', - expectedKey: removedKey, - expectedType: removedKeyType - }); - }); - } - if (optionalKeys.length > 0) { - jsc.property('still validate objects without an optional key', arbitrary, value => { - delete value[pickFrom(optionalKeys)]; - return ok(validation.validate(value)); - }); - } - if (keys.length > 0) { - jsc.property('not validate object with a nulled out property', arbitrary, value => { - const key = pickFrom(keys); - value[key] = null; - return !ok(validation.validate(value)); - }); - jsc.property('signal a type error on object with a nulled out property', arbitrary, value => { - const key = pickFrom(keys); - value[key] = null; - const children = validation.validate(value).children; - return Object.keys(children).some(key => containsError(children[key].errors, { - kind: 'type-error', - expectedType: (validations)[key].type, - actualType: 'null' - })); - }); - } - jsc.property('not validate objects with an extra key', arbitrary, value => { - const extraKey = 'supercalifragilisticexpialidocious'; // reasonably no one will ever use this as a key - value[extraKey] = null; - return !ok(validation.validate(value)); - }); - jsc.property('signal an unexpected key error on objects with an extra key', arbitrary, value => { - const extraKey = 'supercalifragilisticexpialidocious'; // reasonably no one will ever use this as a key - value[extraKey] = null; - return containsError(validation.validate(value).errors, { - kind: 'unexpected-key', - key: extraKey - }); - }); - }); -} - -[ - [validation.Any, arbitrary.Any], - [validation.ArchivedEvent, arbitrary.ArchivedEvent], - [validation.Checkpoint, arbitrary.Checkpoint], - [validation.Commands, arbitrary.Commands], - [validation.Completion, arbitrary.Completion], - [validation.CompletionEndResponse, arbitrary.CompletionEndResponse], - [validation.CompletionStreamRequest, arbitrary.CompletionStreamRequest], - [validation.CompletionStreamResponse, arbitrary.CompletionStreamResponse], - [validation.CreateCommand, arbitrary.CreateCommand], - [validation.CreatedEvent, arbitrary.CreatedEvent], - [validation.Duration, arbitrary.Duration], - [validation.Empty, arbitrary.Empty], - [validation.ExercisedEvent, arbitrary.ExercisedEvent], - [validation.ExerciseCommand, arbitrary.ExerciseCommand], - [validation.Filters, arbitrary.Filters], - [validation.GetActiveContractsRequest, arbitrary.GetActiveContractsRequest], - [validation.GetActiveContractsResponse, arbitrary.GetActiveContractsResponse], - [validation.GetLedgerConfigurationResponse, arbitrary.GetLedgerConfigurationResponse], - [validation.GetLedgerEndResponse, arbitrary.GetLedgerEndResponse], - [validation.GetLedgerIdentityResponse, arbitrary.GetLedgerIdentityResponse], - [validation.GetPackageResponse, arbitrary.GetPackageResponse], - [validation.GetPackageStatusResponse, arbitrary.GetPackageStatusResponse], - [validation.GetTimeResponse, arbitrary.GetTimeResponse], - [validation.GetTransactionByEventIdRequest, arbitrary.GetTransactionByEventIdRequest], - [validation.GetTransactionByIdRequest, arbitrary.GetTransactionByIdRequest], - [validation.GetTransactionResponse, arbitrary.GetTransactionResponse], - [validation.GetTransactionsRequest, arbitrary.GetTransactionsRequest], - [validation.GetTransactionsResponse, arbitrary.GetTransactionsResponse], - [validation.GetTransactionTreesResponse, arbitrary.GetTransactionTreesResponse], - [validation.Identifier, arbitrary.Identifier], - [validation.InclusiveFilters, arbitrary.InclusiveFilters], - [validation.LedgerConfiguration, arbitrary.LedgerConfiguration], - [validation.ListPackagesResponse, arbitrary.ListPackagesResponse], - [validation.Optional, arbitrary.Optional], - [validation.Record, arbitrary.Record], - [validation.SetTimeRequest, arbitrary.SetTimeRequest], - [validation.Status, arbitrary.Status], - [validation.SubmitRequest, arbitrary.SubmitRequest], - [validation.SubmitAndWaitRequest, arbitrary.SubmitAndWaitRequest], - [validation.Timestamp, arbitrary.Timestamp], - [validation.TransactionFilter, arbitrary.TransactionFilter], - [validation.Transaction, arbitrary.Transaction], - [validation.TransactionTree, arbitrary.TransactionTree], - [validation.Variant, arbitrary.Variant], - -].forEach(test); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tests/validation/union.spec.ts b/language-support/js/daml-ledger/tests/validation/union.spec.ts deleted file mode 100644 index fc0ff528431..00000000000 --- a/language-support/js/daml-ledger/tests/validation/union.spec.ts +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -import * as jsc from 'jsverify'; -import * as arbitrary from '../arbitrary'; -import * as validation from '../../src/validation'; -import { ok, UnionValidation } from "../../src/validation/base"; - -import { containsError } from '.'; - -function test([validation, arbitrary]: [UnionValidation, jsc.Arbitrary]): void { - describe(`Validation: ${validation.type}`, () => { - if (validation.type !== 'null') { - jsc.property('not validate a null', () => { - return !ok(validation.validate(null)); - }); - jsc.property('signal a type error on a null', () => { - return containsError(validation.validate(null).errors, { - kind: 'type-error', - expectedType: validation.type, - actualType: 'null' - }); - }); - } - jsc.property('validate well-formed objects', arbitrary, value => { - return ok(validation.validate(value)); - }); - jsc.property('not validate objects with an extra key', arbitrary, value => { - const extraKey = 'supercalifragilisticexpialidocious'; // reasonably no one will ever use this as a key - value[extraKey] = null; - return !ok(validation.validate(value)); - }); - jsc.property('signal an unexpected key error on objects with an extra key', arbitrary, value => { - const extraKey = 'supercalifragilisticexpialidocious'; // reasonably no one will ever use this as a key - value[extraKey] = null; - return containsError(validation.validate(value).errors, { - kind: 'unexpected-key', - key: extraKey - }); - }); - jsc.property('not validate objects without at least one defined key', () => { - return !ok(validation.validate({})); - }); - jsc.property('signal a non-unique union error on objects without at least one defined key', () => { - return containsError(validation.validate({}).errors, { - kind: 'non-unique-union', - keys: [] - }); - }); - jsc.property('not validate objects with more than one defined key', arbitrary, value => { - const values = validation.values(); - const keys = Object.keys(values); - let set = keys.filter(key => value[key] !== undefined); - for (const key of keys) { - if (set.some(set => set === key)) continue; - value[key] = null; - set.push(key); - break; - } - return containsError(validation.validate(value).errors, { - kind: 'non-unique-union', - keys: set - }); - }); - }); -} - -[ - [validation.Command, arbitrary.Command], - [validation.Event, arbitrary.Event], - [validation.TreeEvent, arbitrary.TreeEvent], - [validation.LedgerOffset, arbitrary.LedgerOffset], - [validation.Value, arbitrary.Value], - -].forEach(test); \ No newline at end of file diff --git a/language-support/js/daml-ledger/tsconfig.json b/language-support/js/daml-ledger/tsconfig.json deleted file mode 100644 index a0302eb0bf5..00000000000 --- a/language-support/js/daml-ledger/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "declaration": true, - "sourceMap": true, - "outDir": "./dist/", - "lib": [ "es2015" ] - } -} \ No newline at end of file diff --git a/language-support/js/docs/BUILD b/language-support/js/docs/BUILD deleted file mode 100644 index f1694adc8bb..00000000000 --- a/language-support/js/docs/BUILD +++ /dev/null @@ -1,20 +0,0 @@ -genrule( - name = "docs", - srcs = [ - "//language-support/js/daml-ledger:src", - "//language-support/js/daml-ledger:README", - "jsdoc.json", - "@npm//ink-docstrap", - ], - outs = ["docs.tar.gz"], - cmd = """ - mv language-support/js/daml-ledger/* . - ln -s external/npm/node_modules . - $(execpath @npm//jsdoc/bin:jsdoc) -c $(location jsdoc.json) - tar czf $@ docs - """, - tools = ["@npm//jsdoc/bin:jsdoc"], - visibility = [ - "//:__subpackages__", - ], -) diff --git a/language-support/js/docs/jsdoc.json b/language-support/js/docs/jsdoc.json deleted file mode 100644 index 4f563cefc53..00000000000 --- a/language-support/js/docs/jsdoc.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "plugins": [ - "plugins/commentsOnly", - "plugins/markdown" - ], - "source": { - "include": [ "./src" ], - "exclude": [ "./src/tests" ], - "includePattern": ".+\\.ts$", - "excludePattern": ".+\\.spec.ts$" - }, - "sourceType": "module", - "tags": { - "allowUnknownTags": false, - "dictionaries": [ "jsdoc" ] - }, - "templates": { - "cleverLinks": false, - "monospaceLinks": false, - "copyright": "©2019 Digital Asset Holdings, LLC", - "outputSourceFiles": false, - "outputSourcePath": false, - "includeDate": false - }, - "opts": { - "template": "./node_modules/ink-docstrap/template", - "readme": "./README.md", - "encoding": "utf8", - "destination": "./docs/", - "recurse": true - } -} diff --git a/language-support/js/install.sh b/language-support/js/install.sh deleted file mode 100755 index d1e7f47d550..00000000000 --- a/language-support/js/install.sh +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -#!/usr/bin/env bash - -set -euo pipefail - -cd "$(dirname "$0")" - -bazel build //language-support/js/daml-grpc -bazel build //language-support/js/daml-ledger - -mkdir -p daml-ledger/node_modules/daml-grpc -tar xzf ../../bazel-genfiles/language-support/js/daml-grpc/daml-grpc.tgz --strip-components=1 -C daml-ledger/node_modules/daml-grpc - -mkdir -p daml-codegen/node_modules/daml-grpc -tar xzf ../../bazel-genfiles/language-support/js/daml-grpc/daml-grpc.tgz --strip-components=1 -C daml-codegen/node_modules/daml-grpc - -mkdir -p daml-codegen/node_modules/daml-ledger -tar xzf ../../bazel-genfiles/language-support/js/daml-ledger/daml-ledger.tgz --strip-components=1 -C daml-codegen/node_modules/daml-ledger diff --git a/package.json b/package.json index 633341e919e..f5c01c95a11 100644 --- a/package.json +++ b/package.json @@ -6,21 +6,11 @@ "version": "0.0.0", "dependencies": { "@bazel/typescript": "0.23.2", - "@types/chai": "4.1.6", - "@types/google-protobuf": "3.2.7", - "@types/mocha": "5.2.5", - "@types/node": "8.10.40", - "@types/sinon": "5.0.5", "bower": "1.8.8", "browserify": "16.2.3", - "chai": "4.2.0", "dockerode": "^2.5.8", "express": "^4.16.4", "express-session": "^1.15.6", - "google-protobuf": "3.6.1", - "grpc": "1.15.1", - "grpc-tools": "1.6.6", - "grpc_tools_node_protoc_ts": "2.5.0", "grunt": "1.0.3", "grunt-banner": "0.6.0", "grunt-browserify": "5.3.0", @@ -34,14 +24,8 @@ "grunt-exec": "3.0.0", "grunt-open": "0.2.3", "http-proxy": "^1.17.0", - "ink-docstrap": "1.3.2", - "jsdoc": "3.5.5", - "jsverify": "0.8.4", "matchdep": "2.0.0", - "mocha": "5.2.0", "node-cache": "^4.2.0", - "sinon": "7.1.1", - "ts-node": "7.0.1", "typescript": "3.1.6", "url": "^0.11.0" },