-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exercise by key #4049
Exercise by key #4049
Conversation
dc15468
to
93966b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo forthcoming docs, but @hurryabit may prefer that reference
's JSON format always be flattened within the containing object, which is unambiguous and also backward-compatible with the current API.
Yep, I thought about keeping the existing format. But decided to change it so it is consistent with our domain model. However if @hurryabit insists, |
@@ -189,8 +189,10 @@ class Ledger { | |||
*/ | |||
async exercise<T extends object, C, R>(choice: Choice<T, C, R>, contractId: ContractId<T>, argument: C): Promise<[R , Event<object>[]]> { | |||
const payload = { | |||
templateId: choice.template().templateId, | |||
contractId, | |||
reference: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? I think the old API was fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because reference can be of ContractLocator
type:
sealed abstract class ContractLocator[+LfV] extends Product with Serializable
final case class EnrichedContractKey[+LfV](
templateId: TemplateId.OptionalPkg,
key: LfV
) extends ContractLocator[LfV]
final case class EnrichedContractId(
templateId: Option[TemplateId.OptionalPkg],
contractId: domain.ContractId
) extends ContractLocator[Nothing]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you see it groups templateId
with key
and optional templateId
with contractId
. That is what I currently have in my domain model, which I am not going to flatten that is for sure (I assumed you wanted to have something similar in TypeScript)... JSON can be flattened, but I think reference
field kind of makes sense. Again up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plus I hate writing JSON formatters manually :), if we have a reference
field, the formatter can be completely derived.
ExerciseCommand got a new required element: `reference` of polymorphic type.
CHANGELOG_BEGIN - [JSON API - Experimental] Support Exercise by Key. See #4009. CHANGELOG_END
db78b00
to
7053493
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
fields += "choice" -> obj.choice.toJson | ||
fields += "argument" -> obj.argument.toJson | ||
if (obj.meta.isDefined) | ||
fields += "meta" -> obj.meta.toJson |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no value here from not building fields in the functional style; use ++
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API and the docs look good to me. Many thanks.
I'll leave the review of the implementation and the approval to @S11001001.
Closes: #4009
TODO
reference
field, actually flatten it.reference
field is removed.Pull Request Checklist
CHANGELOG_BEGIN
andCHANGELOG_END
tagsNOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with
/AzurePipelines run
totrigger the build.