Skip to content

Commit

Permalink
rename "contracts" to "events" in JSON API exercise response
Browse files Browse the repository at this point in the history
CHANGELOG_BEGIN
- [JSON API - Experimental] Exercise response field "contracts" renamed to "events".
  See `issue #4385 <https://github.com/digital-asset/daml/issues/4385>`_.
CHANGELOG_END
  • Loading branch information
S11001001 committed Feb 6, 2020
1 parent 0583f57 commit 33f8af6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/source/json-api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ HTTP Response
"status": 200,
"result": {
"exerciseResult": "#201:1",
"contracts": [
"events": [
{
"archived": {
"contractId": "#124:0",
Expand Down
16 changes: 8 additions & 8 deletions language-support/ts/daml-ledger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ class Ledger {
};
const json = await this.submit('command/exercise', payload);
// Decode the server response into a tuple.
const responseDecoder: jtv.Decoder<{exerciseResult: R; contracts: Event<object>[]}> = jtv.object({
const responseDecoder: jtv.Decoder<{exerciseResult: R; events: Event<object>[]}> = jtv.object({
exerciseResult: choice.resultDecoder(),
contracts: jtv.array(decodeEventUnknown),
events: jtv.array(decodeEventUnknown),
});
const {exerciseResult, contracts} = jtv.Result.withException(responseDecoder.run(json));
return [exerciseResult, contracts];
const {exerciseResult, events} = jtv.Result.withException(responseDecoder.run(json));
return [exerciseResult, events];
}

/**
Expand All @@ -238,12 +238,12 @@ class Ledger {
};
const json = await this.submit('command/exercise', payload);
// Decode the server response into a tuple.
const responseDecoder: jtv.Decoder<{exerciseResult: R; contracts: Event<object>[]}> = jtv.object({
const responseDecoder: jtv.Decoder<{exerciseResult: R; events: Event<object>[]}> = jtv.object({
exerciseResult: choice.resultDecoder(),
contracts: jtv.array(decodeEventUnknown),
events: jtv.array(decodeEventUnknown),
});
const {exerciseResult, contracts} = jtv.Result.withException(responseDecoder.run(json));
return [exerciseResult, contracts];
const {exerciseResult, events} = jtv.Result.withException(responseDecoder.run(json));
return [exerciseResult, events];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ object domain {

final case class ExerciseResponse[+LfV](
exerciseResult: LfV,
contracts: List[Contract[LfV]],
events: List[Contract[LfV]],
)

object PartyDetails {
Expand Down Expand Up @@ -477,11 +477,11 @@ object domain {
)(f: A => G[B]): G[ExerciseResponse[B]] = {
import scalaz.syntax.applicative._
val gb: G[B] = f(fa.exerciseResult)
val gbs: G[List[Contract[B]]] = fa.contracts.traverse(_.traverse(f))
^(gb, gbs) { (exerciseResult, contracts) =>
val gbs: G[List[Contract[B]]] = fa.events.traverse(_.traverse(f))
^(gb, gbs) { (exerciseResult, events) =>
ExerciseResponse(
exerciseResult = exerciseResult,
contracts = contracts,
events = events,
)
}
}
Expand Down

0 comments on commit 33f8af6

Please sign in to comment.