@distrohelena/canton-typescript-sdk 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +333 -1
  2. package/dist/client/canton-client-options.d.ts +3 -0
  3. package/dist/client/canton-client-options.js +2 -0
  4. package/dist/client/service-registry.js +3 -2
  5. package/dist/core/errors/grpc-transport-error.d.ts +14 -0
  6. package/dist/core/errors/grpc-transport-error.js +76 -0
  7. package/dist/core/signing/command-signer.interface.d.ts +2 -0
  8. package/dist/core/transports/transport.interface.d.ts +2 -2
  9. package/dist/core/types/canton-hash-purpose.d.ts +2 -1
  10. package/dist/core/types/canton-hash-purpose.js +1 -0
  11. package/dist/core/types/daml-numeric.d.ts +6 -0
  12. package/dist/core/types/daml-numeric.js +14 -0
  13. package/dist/core/types/daml-party.d.ts +6 -0
  14. package/dist/core/types/daml-party.js +14 -0
  15. package/dist/core/types/disclosed-contract.d.ts +13 -0
  16. package/dist/core/types/disclosed-contract.js +15 -0
  17. package/dist/core/types/requests/create-decentralized-party-request.d.ts +41 -0
  18. package/dist/core/types/requests/create-decentralized-party-request.js +82 -0
  19. package/dist/core/types/requests/create-external-party-request.d.ts +42 -0
  20. package/dist/core/types/requests/create-external-party-request.js +47 -0
  21. package/dist/core/types/requests/finalize-decentralized-party-request.d.ts +39 -0
  22. package/dist/core/types/requests/finalize-decentralized-party-request.js +42 -0
  23. package/dist/core/types/requests/get-active-contracts-page-request.d.ts +15 -2
  24. package/dist/core/types/requests/get-active-contracts-page-request.js +4 -0
  25. package/dist/core/types/requests/submit-command-request.d.ts +5 -0
  26. package/dist/core/types/requests/submit-command-request.js +4 -0
  27. package/dist/core/types/topology/topology-signature-format.d.ts +2 -1
  28. package/dist/core/types/topology/topology-signature-format.js +1 -0
  29. package/dist/daml-lf/container/dar-archive-entry.d.ts +8 -0
  30. package/dist/daml-lf/container/dar-archive-entry.js +8 -0
  31. package/dist/daml-lf/container/dar-archive-loader.js +14 -0
  32. package/dist/daml-lf/container/dar-archive.d.ts +6 -0
  33. package/dist/daml-lf/container/dar-archive.js +4 -0
  34. package/dist/daml-lf/container/dar-source-bundle-loader.d.ts +5 -0
  35. package/dist/daml-lf/container/dar-source-bundle-loader.js +33 -0
  36. package/dist/daml-lf/container/dar-source-bundle.d.ts +45 -0
  37. package/dist/daml-lf/container/dar-source-bundle.js +11 -0
  38. package/dist/daml-lf/container/dar-source-file-entry.d.ts +8 -0
  39. package/dist/daml-lf/container/dar-source-file-entry.js +8 -0
  40. package/dist/daml-lf/daml-lf-compilation.d.ts +12 -0
  41. package/dist/daml-lf/daml-lf-compilation.js +35 -0
  42. package/dist/daml-lf/index.d.ts +11 -0
  43. package/dist/daml-lf/index.js +10 -0
  44. package/dist/daml-lf/interpreter/daml-lf-builtin-dispatch.d.ts +43 -0
  45. package/dist/daml-lf/interpreter/daml-lf-builtin-dispatch.js +933 -0
  46. package/dist/daml-lf/interpreter/daml-lf-evaluator.d.ts +95 -0
  47. package/dist/daml-lf/interpreter/daml-lf-evaluator.js +1131 -0
  48. package/dist/daml-lf/interpreter/daml-lf-interpreter-scaffold.d.ts +3 -0
  49. package/dist/daml-lf/interpreter/daml-lf-interpreter-scaffold.js +6 -1
  50. package/dist/daml-lf/interpreter/daml-lf-lexical-scope.d.ts +13 -0
  51. package/dist/daml-lf/interpreter/daml-lf-lexical-scope.js +46 -0
  52. package/dist/daml-lf/interpreter/daml-lf-runtime-frame.d.ts +16 -0
  53. package/dist/daml-lf/interpreter/daml-lf-runtime-frame.js +15 -0
  54. package/dist/daml-lf/interpreter/daml-lf-runtime-value.d.ts +21 -0
  55. package/dist/daml-lf/interpreter/daml-lf-runtime-value.js +4 -1
  56. package/dist/daml-lf/interpreter/daml-lf-step-kind.d.ts +7 -0
  57. package/dist/daml-lf/interpreter/daml-lf-step-kind.js +8 -0
  58. package/dist/daml-lf/interpreter/daml-lf-trace-sink.interface.d.ts +30 -0
  59. package/dist/daml-lf/interpreter/daml-lf-trace-sink.interface.js +1 -0
  60. package/dist/daml-lf/model/daml-lf-builtin-type.d.ts +3 -0
  61. package/dist/daml-lf/model/daml-lf-builtin-type.js +3 -0
  62. package/dist/daml-lf/model/daml-lf-choice.d.ts +5 -0
  63. package/dist/daml-lf/model/daml-lf-choice.js +4 -0
  64. package/dist/daml-lf/model/daml-lf-expression-path.d.ts +2 -0
  65. package/dist/daml-lf/model/daml-lf-expression-path.js +81 -0
  66. package/dist/daml-lf/model/daml-lf-expression.d.ts +146 -0
  67. package/dist/daml-lf/model/daml-lf-expression.js +71 -0
  68. package/dist/daml-lf/model/daml-lf-template.d.ts +2 -0
  69. package/dist/daml-lf/model/daml-lf-template.js +2 -0
  70. package/dist/daml-lf/model/daml-lf-type.d.ts +2 -0
  71. package/dist/daml-lf/model/daml-lf-type.js +4 -0
  72. package/dist/daml-lf/model/lf-2-model-mapper.d.ts +5 -0
  73. package/dist/daml-lf/model/lf-2-model-mapper.js +445 -12
  74. package/dist/debugger/errors/replay-determinism.exception.d.ts +3 -0
  75. package/dist/debugger/errors/replay-determinism.exception.js +3 -0
  76. package/dist/debugger/errors/replay-missing-package.exception.d.ts +3 -0
  77. package/dist/debugger/errors/replay-missing-package.exception.js +3 -0
  78. package/dist/debugger/errors/replay-missing-source.exception.d.ts +3 -0
  79. package/dist/debugger/errors/replay-missing-source.exception.js +3 -0
  80. package/dist/debugger/errors/replay-source-map.exception.d.ts +3 -0
  81. package/dist/debugger/errors/replay-source-map.exception.js +3 -0
  82. package/dist/debugger/errors/replay-state-hydration.exception.d.ts +3 -0
  83. package/dist/debugger/errors/replay-state-hydration.exception.js +3 -0
  84. package/dist/debugger/errors/replay-unsupported-lf-construct.exception.d.ts +3 -0
  85. package/dist/debugger/errors/replay-unsupported-lf-construct.exception.js +3 -0
  86. package/dist/debugger/errors/replay-unsupported-update.exception.d.ts +3 -0
  87. package/dist/debugger/errors/replay-unsupported-update.exception.js +3 -0
  88. package/dist/debugger/index.d.ts +31 -0
  89. package/dist/debugger/index.js +31 -0
  90. package/dist/debugger/ledger-replay-debugger-client.d.ts +31 -0
  91. package/dist/debugger/ledger-replay-debugger-client.js +53 -0
  92. package/dist/debugger/replay/ledger-replay-environment-builder.d.ts +95 -0
  93. package/dist/debugger/replay/ledger-replay-environment-builder.js +249 -0
  94. package/dist/debugger/replay/ledger-replay-session-loader.d.ts +78 -0
  95. package/dist/debugger/replay/ledger-replay-session-loader.js +565 -0
  96. package/dist/debugger/replay/replay-artifact-resolver.d.ts +30 -0
  97. package/dist/debugger/replay/replay-artifact-resolver.js +210 -0
  98. package/dist/debugger/replay/replay-determinism-validator.d.ts +12 -0
  99. package/dist/debugger/replay/replay-determinism-validator.js +161 -0
  100. package/dist/debugger/replay/replay-entrypoint-definition-resolver.d.ts +40 -0
  101. package/dist/debugger/replay/replay-entrypoint-definition-resolver.js +337 -0
  102. package/dist/debugger/replay/replay-entrypoint.d.ts +22 -0
  103. package/dist/debugger/replay/replay-entrypoint.js +14 -0
  104. package/dist/debugger/replay/replay-ledger-value-normalizer.d.ts +7 -0
  105. package/dist/debugger/replay/replay-ledger-value-normalizer.js +194 -0
  106. package/dist/debugger/replay/replay-update-loader.d.ts +24 -0
  107. package/dist/debugger/replay/replay-update-loader.js +94 -0
  108. package/dist/debugger/replay/replay-update-visibility-validator.d.ts +19 -0
  109. package/dist/debugger/replay/replay-update-visibility-validator.js +19 -0
  110. package/dist/debugger/session/in-memory-replay-session-store.d.ts +27 -0
  111. package/dist/debugger/session/in-memory-replay-session-store.js +109 -0
  112. package/dist/debugger/session/replay-phase.d.ts +7 -0
  113. package/dist/debugger/session/replay-phase.js +8 -0
  114. package/dist/debugger/session/replay-scope.d.ts +10 -0
  115. package/dist/debugger/session/replay-scope.js +10 -0
  116. package/dist/debugger/session/replay-session-metadata.d.ts +10 -0
  117. package/dist/debugger/session/replay-session-metadata.js +10 -0
  118. package/dist/debugger/session/replay-session-request.d.ts +6 -0
  119. package/dist/debugger/session/replay-session-request.js +10 -0
  120. package/dist/debugger/session/replay-session.d.ts +12 -0
  121. package/dist/debugger/session/replay-session.js +10 -0
  122. package/dist/debugger/session/replay-source-location.d.ts +17 -0
  123. package/dist/debugger/session/replay-source-location.js +16 -0
  124. package/dist/debugger/session/replay-stack-frame.d.ts +8 -0
  125. package/dist/debugger/session/replay-stack-frame.js +8 -0
  126. package/dist/debugger/session/replay-state-delta.d.ts +29 -0
  127. package/dist/debugger/session/replay-state-delta.js +24 -0
  128. package/dist/debugger/session/replay-step-advance-result.d.ts +24 -0
  129. package/dist/debugger/session/replay-step-advance-result.js +16 -0
  130. package/dist/debugger/session/replay-step.d.ts +30 -0
  131. package/dist/debugger/session/replay-step.js +24 -0
  132. package/dist/debugger/session/replay-value-preview.d.ts +8 -0
  133. package/dist/debugger/session/replay-value-preview.js +15 -0
  134. package/dist/debugger/source/daml-source-mapper.d.ts +12 -0
  135. package/dist/debugger/source/daml-source-mapper.js +21 -0
  136. package/dist/debugger/source/dar-source-map-metadata.d.ts +26 -0
  137. package/dist/debugger/source/dar-source-map-metadata.js +10 -0
  138. package/dist/debugger/source/source-coverage-validator.d.ts +8 -0
  139. package/dist/debugger/source/source-coverage-validator.js +16 -0
  140. package/dist/debugger/source/source-indexed-compilation.d.ts +45 -0
  141. package/dist/debugger/source/source-indexed-compilation.js +110 -0
  142. package/dist/debugger/source/source-mapping-precision.d.ts +5 -0
  143. package/dist/debugger/source/source-mapping-precision.js +4 -0
  144. package/dist/index.d.ts +21 -0
  145. package/dist/index.js +13 -0
  146. package/dist/query/cache/memory-query-cache.d.ts +9 -0
  147. package/dist/query/cache/memory-query-cache.js +24 -0
  148. package/dist/query/cache/query-cache-store.d.ts +5 -0
  149. package/dist/query/cache/query-cache-store.js +1 -0
  150. package/dist/query/canton-manager-options.d.ts +17 -0
  151. package/dist/query/canton-manager-options.js +1 -0
  152. package/dist/query/canton-manager.d.ts +11 -0
  153. package/dist/query/canton-manager.js +42 -0
  154. package/dist/query/errors/pqs-query-error.d.ts +10 -0
  155. package/dist/query/errors/pqs-query-error.js +11 -0
  156. package/dist/query/errors/pqs-schema-profile-error.d.ts +3 -0
  157. package/dist/query/errors/pqs-schema-profile-error.js +3 -0
  158. package/dist/query/errors/query-capability-error.d.ts +7 -0
  159. package/dist/query/errors/query-capability-error.js +10 -0
  160. package/dist/query/grpc/grpc-contract-query-client.d.ts +32 -0
  161. package/dist/query/grpc/grpc-contract-query-client.js +126 -0
  162. package/dist/query/model-types.d.ts +258 -0
  163. package/dist/query/model-types.js +14 -0
  164. package/dist/query/pqs/pqs-pool.d.ts +13 -0
  165. package/dist/query/pqs/pqs-pool.js +18 -0
  166. package/dist/query/pqs/pqs-query-client.d.ts +49 -0
  167. package/dist/query/pqs/pqs-query-client.js +324 -0
  168. package/dist/query/pqs/pqs-schema-profile.d.ts +25 -0
  169. package/dist/query/pqs/pqs-schema-profile.js +120 -0
  170. package/dist/query/pqs/pqs-sql-compiler.d.ts +7 -0
  171. package/dist/query/pqs/pqs-sql-compiler.js +132 -0
  172. package/dist/query/pqs/read-only-sql.d.ts +1 -0
  173. package/dist/query/pqs/read-only-sql.js +35 -0
  174. package/dist/query/query-client.d.ts +61 -0
  175. package/dist/query/query-client.js +1 -0
  176. package/dist/query/query-source.d.ts +4 -0
  177. package/dist/query/query-source.js +5 -0
  178. package/dist/services/command/command-service-client.d.ts +2 -2
  179. package/dist/services/commands/command-submission-pipeline.d.ts +2 -2
  180. package/dist/services/party-management/decentralized-party-lifecycle.d.ts +6 -0
  181. package/dist/services/party-management/decentralized-party-lifecycle.js +82 -0
  182. package/dist/services/party-management/party-management-service-client.d.ts +16 -1
  183. package/dist/services/party-management/party-management-service-client.js +142 -1
  184. package/dist/services/topology-manager-write/topology-signed-transaction-assembler.js +4 -0
  185. package/dist/testing/campaign/campaign-artifact.d.ts +20 -0
  186. package/dist/testing/campaign/campaign-artifact.js +147 -0
  187. package/dist/testing/campaign/campaign-definition.d.ts +9 -0
  188. package/dist/testing/campaign/campaign-definition.js +78 -0
  189. package/dist/testing/campaign/campaign-metrics.d.ts +32 -0
  190. package/dist/testing/campaign/campaign-metrics.js +26 -0
  191. package/dist/testing/campaign/campaign-model.d.ts +11 -0
  192. package/dist/testing/campaign/campaign-model.js +21 -0
  193. package/dist/testing/campaign/campaign-runner.d.ts +99 -0
  194. package/dist/testing/campaign/campaign-runner.js +194 -0
  195. package/dist/testing/campaign/campaign-scheduler.d.ts +40 -0
  196. package/dist/testing/campaign/campaign-scheduler.js +75 -0
  197. package/dist/testing/campaign/campaign-types.d.ts +52 -0
  198. package/dist/testing/campaign/campaign-types.js +11 -0
  199. package/dist/testing/daml/daml-action-arbitrary.d.ts +13 -0
  200. package/dist/testing/daml/daml-action-arbitrary.js +24 -0
  201. package/dist/testing/daml/daml-choice-action-arbitrary.d.ts +18 -0
  202. package/dist/testing/daml/daml-choice-action-arbitrary.js +27 -0
  203. package/dist/testing/daml/daml-create-action-arbitrary.d.ts +19 -0
  204. package/dist/testing/daml/daml-create-action-arbitrary.js +34 -0
  205. package/dist/testing/daml/daml-testing-catalog.d.ts +38 -0
  206. package/dist/testing/daml/daml-testing-catalog.js +40 -0
  207. package/dist/testing/daml/daml-value-arbitrary.d.ts +8 -0
  208. package/dist/testing/daml/daml-value-arbitrary.js +43 -0
  209. package/dist/testing/daml/declarative-campaign-arbitrary.d.ts +15 -0
  210. package/dist/testing/daml/declarative-campaign-arbitrary.js +30 -0
  211. package/dist/testing/errors/invariant-campaign-failure.d.ts +24 -0
  212. package/dist/testing/errors/invariant-campaign-failure.js +37 -0
  213. package/dist/testing/errors/testing-configuration-error.d.ts +3 -0
  214. package/dist/testing/errors/testing-configuration-error.js +6 -0
  215. package/dist/testing/handlers/handler.d.ts +19 -0
  216. package/dist/testing/handlers/handler.js +31 -0
  217. package/dist/testing/index.d.ts +22 -0
  218. package/dist/testing/index.js +22 -0
  219. package/dist/testing/runtime/campaign-isolation.d.ts +14 -0
  220. package/dist/testing/runtime/campaign-isolation.js +23 -0
  221. package/dist/testing/runtime/canton-test-runtime.d.ts +58 -0
  222. package/dist/testing/runtime/canton-test-runtime.js +138 -0
  223. package/dist/testing/runtime/declarative-action-executor.d.ts +16 -0
  224. package/dist/testing/runtime/declarative-action-executor.js +41 -0
  225. package/dist/testing/targets/target.d.ts +49 -0
  226. package/dist/testing/targets/target.js +121 -0
  227. package/dist/transports/grpc/grpc-channel-factory.js +31 -1
  228. package/dist/transports/grpc/grpc-transport.d.ts +2 -2
  229. package/dist/transports/grpc/grpc-transport.js +11 -8
  230. package/dist/transports/grpc/mappers/commands-mapper.js +23 -2
  231. package/dist/transports/grpc/mappers/contracts-mapper.d.ts +3 -1
  232. package/dist/transports/grpc/mappers/contracts-mapper.js +16 -3
  233. package/dist/transports/grpc/mappers/interactive-command-mapper.d.ts +4 -1
  234. package/dist/transports/grpc/mappers/interactive-command-mapper.js +3 -8
  235. package/dist/transports/grpc/mappers/topology-manager-write-mapper.js +59 -1
  236. package/dist/transports/json/mappers/commands-mapper.js +20 -6
  237. package/node/.generated/start-local/additional-config.extra-participants.conf +37 -0
  238. package/node/.generated/start-local/additional-config.extra-validators.conf +35 -0
  239. package/node/.generated/start-local/compose-extra-participants.yaml +147 -0
  240. package/node/.generated/start-local/extra-participants.env +30 -0
  241. package/node/es256-jwt.mjs +177 -0
  242. package/node/start-local.sh +886 -0
  243. package/node/stop-local.sh +200 -0
  244. package/node/test-start-local.sh +354 -0
  245. package/node/test-stop-local.sh +112 -0
  246. package/package.json +21 -2
@@ -0,0 +1,94 @@
1
+ import { GetUpdateByOffsetRequest } from "../../core/types/requests/get-update-by-offset-request.js";
2
+ import { ReplayUnsupportedUpdateException } from "../errors/replay-unsupported-update.exception.js";
3
+ import { ReplayEntrypoint } from "./replay-entrypoint.js";
4
+ import { validateReplayVisibilityOrThrow } from "./replay-update-visibility-validator.js";
5
+ import { TransactionShape } from "../../transports/grpc/generated/canton/com/daml/ledger/api/v2/transaction_filter.js";
6
+ export class ReplayUpdateLoader {
7
+ dependencies;
8
+ constructor(dependencies) {
9
+ this.dependencies = dependencies;
10
+ }
11
+ async loadOrThrowAsync(offset) {
12
+ const response = await this.dependencies.updateService.getUpdateByOffsetAsync(new GetUpdateByOffsetRequest({
13
+ offset,
14
+ updateFormat: createReplayUpdateFormat(this.dependencies.visibleParties),
15
+ }));
16
+ const transaction = response.update;
17
+ if (transaction === undefined ||
18
+ !Array.isArray(transaction.events) ||
19
+ transaction.offset === undefined) {
20
+ throw new ReplayUnsupportedUpdateException("update is not a replayable transaction payload");
21
+ }
22
+ validateReplayVisibilityOrThrow(transaction);
23
+ return {
24
+ kind: "transaction",
25
+ offset: transaction.offset,
26
+ updateId: transaction.updateId,
27
+ actAs: transaction.actAs,
28
+ readAs: transaction.readAs,
29
+ events: transaction.events,
30
+ entrypoint: this.deriveEntrypointOrThrow(transaction.events),
31
+ };
32
+ }
33
+ deriveEntrypointOrThrow(events) {
34
+ const firstEvent = events[0]?.event;
35
+ if (firstEvent?.oneofKind === "created" &&
36
+ firstEvent.created?.templateId !== undefined &&
37
+ firstEvent.created.createArguments !== undefined) {
38
+ return new ReplayEntrypoint({
39
+ kind: "create",
40
+ templateId: firstEvent.created.templateId,
41
+ argument: firstEvent.created.createArguments,
42
+ });
43
+ }
44
+ if (firstEvent?.oneofKind === "exercised" &&
45
+ firstEvent.exercised?.templateId !== undefined &&
46
+ firstEvent.exercised.contractId !== undefined &&
47
+ firstEvent.exercised.choice !== undefined &&
48
+ firstEvent.exercised.choiceArgument !== undefined) {
49
+ return new ReplayEntrypoint({
50
+ kind: "exercise",
51
+ templateId: firstEvent.exercised.templateId,
52
+ contractId: firstEvent.exercised.contractId,
53
+ choice: firstEvent.exercised.choice,
54
+ argument: firstEvent.exercised.choiceArgument,
55
+ });
56
+ }
57
+ throw new ReplayUnsupportedUpdateException("could not derive a replay entrypoint from the visible update payload");
58
+ }
59
+ }
60
+ function createReplayUpdateFormat(visibleParties) {
61
+ return {
62
+ includeTransactions: {
63
+ eventFormat: createReplayEventFormat(visibleParties),
64
+ transactionShape: TransactionShape.LEDGER_EFFECTS,
65
+ },
66
+ };
67
+ }
68
+ function createReplayEventFormat(visibleParties) {
69
+ const wildcardFilter = {
70
+ cumulative: [
71
+ {
72
+ identifierFilter: {
73
+ oneofKind: "wildcardFilter",
74
+ wildcardFilter: {
75
+ includeCreatedEventBlob: true,
76
+ },
77
+ },
78
+ },
79
+ ],
80
+ };
81
+ if (Array.isArray(visibleParties) && visibleParties.length > 0) {
82
+ return {
83
+ filtersByParty: Object.fromEntries([...new Set(visibleParties)]
84
+ .filter((party) => typeof party === "string" && party.length > 0)
85
+ .map((party) => [party, wildcardFilter])),
86
+ verbose: true,
87
+ };
88
+ }
89
+ return {
90
+ filtersByParty: {},
91
+ filtersForAnyParty: wildcardFilter,
92
+ verbose: true,
93
+ };
94
+ }
@@ -0,0 +1,19 @@
1
+ type ReplayLikeEvent = {
2
+ event?: {
3
+ oneofKind?: string;
4
+ created?: {
5
+ templateId?: unknown;
6
+ createArguments?: unknown;
7
+ };
8
+ exercised?: {
9
+ templateId?: unknown;
10
+ contractId?: string;
11
+ choice?: string;
12
+ choiceArgument?: unknown;
13
+ };
14
+ };
15
+ };
16
+ export declare function validateReplayVisibilityOrThrow(update: {
17
+ events?: ReplayLikeEvent[];
18
+ }): void;
19
+ export {};
@@ -0,0 +1,19 @@
1
+ import { ReplayUnsupportedUpdateException } from "../errors/replay-unsupported-update.exception.js";
2
+ export function validateReplayVisibilityOrThrow(update) {
3
+ for (const event of update.events ?? []) {
4
+ if (event.event?.oneofKind === "created") {
5
+ if (event.event.created?.templateId === undefined ||
6
+ event.event.created.createArguments === undefined) {
7
+ throw new ReplayUnsupportedUpdateException("created events must include template id and create arguments for replay");
8
+ }
9
+ }
10
+ if (event.event?.oneofKind === "exercised") {
11
+ if (event.event.exercised?.templateId === undefined ||
12
+ event.event.exercised.contractId === undefined ||
13
+ event.event.exercised.choice === undefined ||
14
+ event.event.exercised.choiceArgument === undefined) {
15
+ throw new ReplayUnsupportedUpdateException("exercised events must include template id, contract id, choice, and choice argument for replay");
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,27 @@
1
+ import { ILoadedReplaySession } from "../replay/ledger-replay-session-loader.js";
2
+ import { ReplayScope } from "./replay-scope.js";
3
+ import { ReplaySession } from "./replay-session.js";
4
+ import { ReplaySessionMetadata } from "./replay-session-metadata.js";
5
+ import { ReplayStackFrame } from "./replay-stack-frame.js";
6
+ import { ReplayStep } from "./replay-step.js";
7
+ import { ReplayStepAdvanceResult } from "./replay-step-advance-result.js";
8
+ export declare class InMemoryReplaySessionStore {
9
+ private readonly sessions;
10
+ put(session: ILoadedReplaySession): ReplaySession;
11
+ getSessionMetadataOrThrow(sessionId: string): ReplaySessionMetadata;
12
+ getCurrentStepOrThrow(sessionId: string): ReplayStep;
13
+ advanceIntoOrThrow(sessionId: string): ReplayStepAdvanceResult;
14
+ advanceBackOrThrow(sessionId: string): ReplayStepAdvanceResult;
15
+ advanceOverOrThrow(sessionId: string): ReplayStepAdvanceResult;
16
+ advanceOutOrThrow(sessionId: string): ReplayStepAdvanceResult;
17
+ continueOrThrow(sessionId: string): ReplayStepAdvanceResult;
18
+ setCurrentStepByIdOrThrow(sessionId: string, stepId: string): ReplayStepAdvanceResult;
19
+ getStackOrThrow(sessionId: string): readonly ReplayStackFrame[];
20
+ getScopesOrThrow(sessionId: string, frameId: string): readonly ReplayScope[];
21
+ getTraceSliceOrThrow(sessionId: string, startIndex: number, endIndex: number): readonly ReplayStep[];
22
+ dispose(sessionId: string): void;
23
+ private getRecordOrThrow;
24
+ private toReplaySession;
25
+ private toAdvanceResult;
26
+ private findNextIndexOrCurrent;
27
+ }
@@ -0,0 +1,109 @@
1
+ import { ValidationError } from "../../core/errors/validation-error.js";
2
+ import { ReplaySession } from "./replay-session.js";
3
+ import { ReplayStepAdvanceResult } from "./replay-step-advance-result.js";
4
+ export class InMemoryReplaySessionStore {
5
+ sessions = new Map();
6
+ put(session) {
7
+ this.sessions.set(session.sessionId, {
8
+ ...session,
9
+ currentStepIndex: session.currentStepIndex,
10
+ });
11
+ return this.toReplaySession(this.getRecordOrThrow(session.sessionId));
12
+ }
13
+ getSessionMetadataOrThrow(sessionId) {
14
+ return this.getRecordOrThrow(sessionId).metadata;
15
+ }
16
+ getCurrentStepOrThrow(sessionId) {
17
+ const record = this.getRecordOrThrow(sessionId);
18
+ return record.steps[record.currentStepIndex];
19
+ }
20
+ advanceIntoOrThrow(sessionId) {
21
+ const record = this.getRecordOrThrow(sessionId);
22
+ const nextIndex = Math.min(record.currentStepIndex + 1, record.steps.length - 1);
23
+ record.currentStepIndex = nextIndex;
24
+ return this.toAdvanceResult(record);
25
+ }
26
+ advanceBackOrThrow(sessionId) {
27
+ const record = this.getRecordOrThrow(sessionId);
28
+ record.currentStepIndex = Math.max(0, record.currentStepIndex - 1);
29
+ return this.toAdvanceResult(record);
30
+ }
31
+ advanceOverOrThrow(sessionId) {
32
+ const record = this.getRecordOrThrow(sessionId);
33
+ const currentStep = record.steps[record.currentStepIndex];
34
+ if (currentStep.phase !== "call") {
35
+ return this.advanceIntoOrThrow(sessionId);
36
+ }
37
+ record.currentStepIndex = this.findNextIndexOrCurrent(record, (step) => step.stackFrames.length < currentStep.stackFrames.length);
38
+ return this.toAdvanceResult(record);
39
+ }
40
+ advanceOutOrThrow(sessionId) {
41
+ const record = this.getRecordOrThrow(sessionId);
42
+ const currentStep = record.steps[record.currentStepIndex];
43
+ record.currentStepIndex = this.findNextIndexOrCurrent(record, (step) => step.stackFrames.length < currentStep.stackFrames.length);
44
+ return this.toAdvanceResult(record);
45
+ }
46
+ continueOrThrow(sessionId) {
47
+ const record = this.getRecordOrThrow(sessionId);
48
+ record.currentStepIndex = record.steps.length - 1;
49
+ return this.toAdvanceResult(record);
50
+ }
51
+ setCurrentStepByIdOrThrow(sessionId, stepId) {
52
+ const record = this.getRecordOrThrow(sessionId);
53
+ const nextIndex = record.steps.findIndex((step) => step.stepId === stepId);
54
+ if (nextIndex < 0) {
55
+ throw new ValidationError(`unknown replay step '${stepId}'`);
56
+ }
57
+ record.currentStepIndex = nextIndex;
58
+ return this.toAdvanceResult(record);
59
+ }
60
+ getStackOrThrow(sessionId) {
61
+ return this.getCurrentStepOrThrow(sessionId).stackFrames;
62
+ }
63
+ getScopesOrThrow(sessionId, frameId) {
64
+ const currentStep = this.getCurrentStepOrThrow(sessionId);
65
+ const frame = currentStep.stackFrames.find((candidate) => candidate.frameId === frameId);
66
+ if (frame === undefined) {
67
+ return [];
68
+ }
69
+ return (this.getRecordOrThrow(sessionId).scopesByStep[this.getRecordOrThrow(sessionId).currentStepIndex] ?? []).filter((scope) => scope.frameId === frameId);
70
+ }
71
+ getTraceSliceOrThrow(sessionId, startIndex, endIndex) {
72
+ return this.getRecordOrThrow(sessionId).steps.slice(startIndex, endIndex);
73
+ }
74
+ dispose(sessionId) {
75
+ this.sessions.delete(sessionId);
76
+ }
77
+ getRecordOrThrow(sessionId) {
78
+ const session = this.sessions.get(sessionId);
79
+ if (session === undefined) {
80
+ throw new ValidationError(`replay session '${sessionId}' does not exist`);
81
+ }
82
+ return session;
83
+ }
84
+ toReplaySession(session) {
85
+ return new ReplaySession({
86
+ sessionId: session.sessionId,
87
+ metadata: session.metadata,
88
+ currentStep: session.steps[session.currentStepIndex],
89
+ });
90
+ }
91
+ toAdvanceResult(session) {
92
+ return new ReplayStepAdvanceResult({
93
+ sessionId: session.sessionId,
94
+ step: session.steps[session.currentStepIndex],
95
+ isTerminal: session.currentStepIndex >= session.steps.length - 1,
96
+ nextStepIndex: session.currentStepIndex >= session.steps.length - 1
97
+ ? undefined
98
+ : session.currentStepIndex + 1,
99
+ });
100
+ }
101
+ findNextIndexOrCurrent(session, predicate) {
102
+ for (let index = session.currentStepIndex + 1; index < session.steps.length; index += 1) {
103
+ if (predicate(session.steps[index])) {
104
+ return index;
105
+ }
106
+ }
107
+ return session.steps.length - 1;
108
+ }
109
+ }
@@ -0,0 +1,7 @@
1
+ export declare enum ReplayPhase {
2
+ enterExpression = "enterExpression",
3
+ exitExpression = "exitExpression",
4
+ call = "call",
5
+ return = "return",
6
+ stateEffect = "stateEffect"
7
+ }
@@ -0,0 +1,8 @@
1
+ export var ReplayPhase;
2
+ (function (ReplayPhase) {
3
+ ReplayPhase["enterExpression"] = "enterExpression";
4
+ ReplayPhase["exitExpression"] = "exitExpression";
5
+ ReplayPhase["call"] = "call";
6
+ ReplayPhase["return"] = "return";
7
+ ReplayPhase["stateEffect"] = "stateEffect";
8
+ })(ReplayPhase || (ReplayPhase = {}));
@@ -0,0 +1,10 @@
1
+ export declare class ReplayScope {
2
+ readonly frameId?: string;
3
+ readonly name?: string;
4
+ readonly variables: readonly unknown[];
5
+ constructor(init?: {
6
+ frameId?: string;
7
+ name?: string;
8
+ variables?: readonly unknown[];
9
+ });
10
+ }
@@ -0,0 +1,10 @@
1
+ export class ReplayScope {
2
+ frameId;
3
+ name;
4
+ variables;
5
+ constructor(init) {
6
+ this.frameId = init?.frameId;
7
+ this.name = init?.name;
8
+ this.variables = init?.variables ?? [];
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ export declare class ReplaySessionMetadata {
2
+ readonly sessionId?: string;
3
+ readonly offset?: string;
4
+ readonly stepCount?: number;
5
+ constructor(init?: {
6
+ sessionId?: string;
7
+ offset?: string;
8
+ stepCount?: number;
9
+ });
10
+ }
@@ -0,0 +1,10 @@
1
+ export class ReplaySessionMetadata {
2
+ sessionId;
3
+ offset;
4
+ stepCount;
5
+ constructor(init) {
6
+ this.sessionId = init?.sessionId;
7
+ this.offset = init?.offset;
8
+ this.stepCount = init?.stepCount;
9
+ }
10
+ }
@@ -0,0 +1,6 @@
1
+ export declare class ReplaySessionRequest {
2
+ readonly offset: string;
3
+ constructor(init: {
4
+ offset: string;
5
+ });
6
+ }
@@ -0,0 +1,10 @@
1
+ import { ValidationError } from "../../core/errors/validation-error.js";
2
+ export class ReplaySessionRequest {
3
+ offset;
4
+ constructor(init) {
5
+ if (!init.offset) {
6
+ throw new ValidationError("replay session requests require an offset");
7
+ }
8
+ this.offset = init.offset;
9
+ }
10
+ }
@@ -0,0 +1,12 @@
1
+ import { ReplaySessionMetadata } from "./replay-session-metadata.js";
2
+ import { ReplayStep } from "./replay-step.js";
3
+ export declare class ReplaySession {
4
+ readonly sessionId?: string;
5
+ readonly metadata?: ReplaySessionMetadata;
6
+ readonly currentStep?: ReplayStep;
7
+ constructor(init?: {
8
+ sessionId?: string;
9
+ metadata?: ReplaySessionMetadata;
10
+ currentStep?: ReplayStep;
11
+ });
12
+ }
@@ -0,0 +1,10 @@
1
+ export class ReplaySession {
2
+ sessionId;
3
+ metadata;
4
+ currentStep;
5
+ constructor(init) {
6
+ this.sessionId = init?.sessionId;
7
+ this.metadata = init?.metadata;
8
+ this.currentStep = init?.currentStep;
9
+ }
10
+ }
@@ -0,0 +1,17 @@
1
+ import { SourceMappingPrecision } from "../source/source-mapping-precision.js";
2
+ export declare class ReplaySourceLocation {
3
+ readonly path?: string;
4
+ readonly startLine?: number;
5
+ readonly startColumn?: number;
6
+ readonly endLine?: number;
7
+ readonly endColumn?: number;
8
+ readonly precision: SourceMappingPrecision;
9
+ constructor(init: {
10
+ path?: string;
11
+ startLine?: number;
12
+ startColumn?: number;
13
+ endLine?: number;
14
+ endColumn?: number;
15
+ precision: SourceMappingPrecision;
16
+ });
17
+ }
@@ -0,0 +1,16 @@
1
+ export class ReplaySourceLocation {
2
+ path;
3
+ startLine;
4
+ startColumn;
5
+ endLine;
6
+ endColumn;
7
+ precision;
8
+ constructor(init) {
9
+ this.path = init?.path;
10
+ this.startLine = init?.startLine;
11
+ this.startColumn = init?.startColumn;
12
+ this.endLine = init?.endLine;
13
+ this.endColumn = init?.endColumn;
14
+ this.precision = init.precision;
15
+ }
16
+ }
@@ -0,0 +1,8 @@
1
+ export declare class ReplayStackFrame {
2
+ readonly frameId?: string;
3
+ readonly name?: string;
4
+ constructor(init?: {
5
+ frameId?: string;
6
+ name?: string;
7
+ });
8
+ }
@@ -0,0 +1,8 @@
1
+ export class ReplayStackFrame {
2
+ frameId;
3
+ name;
4
+ constructor(init) {
5
+ this.frameId = init?.frameId;
6
+ this.name = init?.name;
7
+ }
8
+ }
@@ -0,0 +1,29 @@
1
+ export interface IReplayStateDeltaTemplateId {
2
+ readonly packageId?: string;
3
+ readonly moduleName?: string;
4
+ readonly entityName?: string;
5
+ }
6
+ export declare class ReplayStateDelta {
7
+ readonly kind: string;
8
+ readonly eventOrdinal?: number;
9
+ readonly comparisonKey?: string;
10
+ readonly createdContractId?: string;
11
+ readonly targetContractId?: string;
12
+ readonly templateId?: IReplayStateDeltaTemplateId;
13
+ readonly choice?: string;
14
+ readonly choiceArgument?: unknown;
15
+ readonly payload?: unknown;
16
+ readonly consuming?: boolean;
17
+ constructor(init: {
18
+ kind: string;
19
+ eventOrdinal?: number;
20
+ comparisonKey?: string;
21
+ createdContractId?: string;
22
+ targetContractId?: string;
23
+ templateId?: IReplayStateDeltaTemplateId;
24
+ choice?: string;
25
+ choiceArgument?: unknown;
26
+ payload?: unknown;
27
+ consuming?: boolean;
28
+ });
29
+ }
@@ -0,0 +1,24 @@
1
+ export class ReplayStateDelta {
2
+ kind;
3
+ eventOrdinal;
4
+ comparisonKey;
5
+ createdContractId;
6
+ targetContractId;
7
+ templateId;
8
+ choice;
9
+ choiceArgument;
10
+ payload;
11
+ consuming;
12
+ constructor(init) {
13
+ this.kind = init.kind;
14
+ this.eventOrdinal = init.eventOrdinal;
15
+ this.comparisonKey = init.comparisonKey;
16
+ this.createdContractId = init.createdContractId;
17
+ this.targetContractId = init.targetContractId;
18
+ this.templateId = init.templateId;
19
+ this.choice = init.choice;
20
+ this.choiceArgument = init.choiceArgument;
21
+ this.payload = init.payload;
22
+ this.consuming = init.consuming;
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ import { ReplayStep } from "./replay-step.js";
2
+ export declare class ReplayStepAdvanceResult {
3
+ readonly sessionId: string;
4
+ readonly step: ReplayStep;
5
+ readonly isTerminal: boolean;
6
+ readonly nextStepIndex?: number;
7
+ constructor(init: {
8
+ sessionId: string;
9
+ step: {
10
+ stepId?: string;
11
+ stepIndex: number;
12
+ phase: ReplayStep["phase"];
13
+ stackFrames?: ReplayStep["stackFrames"];
14
+ scopes?: ReplayStep["scopes"];
15
+ locals?: ReplayStep["locals"];
16
+ arguments?: ReplayStep["arguments"];
17
+ sourceLocation?: ReplayStep["sourceLocation"];
18
+ valuePreview?: ReplayStep["valuePreview"];
19
+ stateDelta?: ReplayStep["stateDelta"];
20
+ } | ReplayStep;
21
+ isTerminal: boolean;
22
+ nextStepIndex?: number;
23
+ });
24
+ }
@@ -0,0 +1,16 @@
1
+ import { ReplayStep } from "./replay-step.js";
2
+ export class ReplayStepAdvanceResult {
3
+ sessionId;
4
+ step;
5
+ isTerminal;
6
+ nextStepIndex;
7
+ constructor(init) {
8
+ this.sessionId = init.sessionId;
9
+ this.step =
10
+ init.step instanceof ReplayStep
11
+ ? init.step
12
+ : new ReplayStep(init.step);
13
+ this.isTerminal = init.isTerminal;
14
+ this.nextStepIndex = init.nextStepIndex;
15
+ }
16
+ }
@@ -0,0 +1,30 @@
1
+ import { ReplayPhase } from "./replay-phase.js";
2
+ import { ReplayScope } from "./replay-scope.js";
3
+ import { ReplaySourceLocation } from "./replay-source-location.js";
4
+ import { ReplayStackFrame } from "./replay-stack-frame.js";
5
+ import { ReplayStateDelta } from "./replay-state-delta.js";
6
+ import { ReplayValuePreview } from "./replay-value-preview.js";
7
+ export declare class ReplayStep {
8
+ readonly stepId: string;
9
+ readonly stepIndex: number;
10
+ readonly phase: ReplayPhase;
11
+ readonly stackFrames: readonly ReplayStackFrame[];
12
+ readonly scopes: readonly ReplayScope[];
13
+ readonly locals: readonly unknown[];
14
+ readonly arguments: readonly unknown[];
15
+ readonly sourceLocation?: ReplaySourceLocation;
16
+ readonly valuePreview?: ReplayValuePreview;
17
+ readonly stateDelta?: ReplayStateDelta;
18
+ constructor(init: {
19
+ stepId?: string;
20
+ stepIndex: number;
21
+ phase: ReplayPhase;
22
+ stackFrames?: readonly ReplayStackFrame[];
23
+ scopes?: readonly ReplayScope[];
24
+ locals?: readonly unknown[];
25
+ arguments?: readonly unknown[];
26
+ sourceLocation?: ReplaySourceLocation;
27
+ valuePreview?: ReplayValuePreview;
28
+ stateDelta?: ReplayStateDelta;
29
+ });
30
+ }
@@ -0,0 +1,24 @@
1
+ export class ReplayStep {
2
+ stepId;
3
+ stepIndex;
4
+ phase;
5
+ stackFrames;
6
+ scopes;
7
+ locals;
8
+ arguments;
9
+ sourceLocation;
10
+ valuePreview;
11
+ stateDelta;
12
+ constructor(init) {
13
+ this.stepId = init.stepId ?? `step-${init.stepIndex}`;
14
+ this.stepIndex = init.stepIndex;
15
+ this.phase = init.phase;
16
+ this.stackFrames = init.stackFrames ?? [];
17
+ this.scopes = init.scopes ?? [];
18
+ this.locals = init.locals ?? [];
19
+ this.arguments = init.arguments ?? [];
20
+ this.sourceLocation = init.sourceLocation;
21
+ this.valuePreview = init.valuePreview;
22
+ this.stateDelta = init.stateDelta;
23
+ }
24
+ }
@@ -0,0 +1,8 @@
1
+ export declare class ReplayValuePreview {
2
+ readonly kind: string;
3
+ readonly display: string;
4
+ constructor(init: {
5
+ kind: string;
6
+ display: string;
7
+ });
8
+ }
@@ -0,0 +1,15 @@
1
+ import { ValidationError } from "../../core/errors/validation-error.js";
2
+ export class ReplayValuePreview {
3
+ kind;
4
+ display;
5
+ constructor(init) {
6
+ if (!init.kind) {
7
+ throw new ValidationError("replay value previews require a kind");
8
+ }
9
+ if (!init.display) {
10
+ throw new ValidationError("replay value previews require a display value");
11
+ }
12
+ this.kind = init.kind;
13
+ this.display = init.display;
14
+ }
15
+ }
@@ -0,0 +1,12 @@
1
+ import { SourceIndexedCompilation } from "./source-indexed-compilation.js";
2
+ import { DamlLfExpression } from "../../daml-lf/model/daml-lf-expression.js";
3
+ import { DamlLfValueDefinition } from "../../daml-lf/model/daml-lf-value-definition.js";
4
+ export declare class DamlSourceMapper {
5
+ private readonly indexedCompilation;
6
+ constructor(indexedCompilation: SourceIndexedCompilation);
7
+ getDefinitionSourceOrThrow(packageId: string, moduleName: string, definitionName: string): import("./source-indexed-compilation.js").IndexedExecutableSource;
8
+ getModuleSourceOrThrow(packageId: string, moduleName: string): import("./source-indexed-compilation.js").IndexedDefinitionSource;
9
+ getExpressionSource(expression: DamlLfExpression): import("./source-indexed-compilation.js").IndexedExpressionSource | undefined;
10
+ getValueDefinitionOrThrow(packageId: string, moduleName: string, definitionName: string): DamlLfValueDefinition;
11
+ findExecutableSourceAt(path: string, line: number, column: number): import("./source-indexed-compilation.js").IndexedExecutableSource | undefined;
12
+ }
@@ -0,0 +1,21 @@
1
+ export class DamlSourceMapper {
2
+ indexedCompilation;
3
+ constructor(indexedCompilation) {
4
+ this.indexedCompilation = indexedCompilation;
5
+ }
6
+ getDefinitionSourceOrThrow(packageId, moduleName, definitionName) {
7
+ return this.indexedCompilation.getDefinitionSourceOrThrow(packageId, moduleName, definitionName);
8
+ }
9
+ getModuleSourceOrThrow(packageId, moduleName) {
10
+ return this.indexedCompilation.getModuleSourceOrThrow(packageId, moduleName);
11
+ }
12
+ getExpressionSource(expression) {
13
+ return this.indexedCompilation.getExpressionSource(expression);
14
+ }
15
+ getValueDefinitionOrThrow(packageId, moduleName, definitionName) {
16
+ return this.indexedCompilation.compilation.getValueDefinitionOrThrow(packageId, moduleName, definitionName);
17
+ }
18
+ findExecutableSourceAt(path, line, column) {
19
+ return this.indexedCompilation.findExecutableSourceAt(path, line, column);
20
+ }
21
+ }