Skip to content

Commit

Permalink
CHANGELOG_BEGIN (digital-asset#4192)
Browse files Browse the repository at this point in the history
[JSON API - Experimental] Rename ``argument`` field to ``payload`` in the ``command/create`` request. See digital-asset#4189.

CHANGELOG_END
  • Loading branch information
leo-da authored and hurryabit committed Jan 24, 2020
1 parent 63660c6 commit 9ab419f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions docs/source/json-api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ HTTP Request
{
"templateId": "Iou:Iou",
"argument": {
"payload": {
"issuer": "Alice",
"owner": "Alice",
"currency": "USD",
Expand All @@ -312,7 +312,7 @@ Where:
+ ``"<package ID>:<module>:<entity>"`` or
+ ``"<module>:<entity>"`` if contract template can be uniquely identified by it's module and entity name.

- ``argument`` field contains contract fields as defined in the DAML template and formatted according to :doc:`lf-value-specification`.
- ``payload`` field contains contract fields as defined in the DAML template and formatted according to :doc:`lf-value-specification`.

.. _create-response:

Expand Down Expand Up @@ -360,7 +360,7 @@ When creating a new contract, client may specify an optional ``meta`` field:
{
"templateId": "Iou:Iou",
"argument": {
"payload": {
"observers": [],
"issuer": "Alice",
"amount": "999.99",
Expand Down
8 changes: 4 additions & 4 deletions language-support/ts/daml-ledger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ class Ledger {
/**
* Create a contract for a given template.
*/
async create<T extends object, K>(template: Template<T, K>, argument: T): Promise<CreateEvent<T, K>> {
const payload = {
async create<T extends object, K>(template: Template<T, K>, contractPayload: T): Promise<CreateEvent<T, K>> {
const command = {
templateId: template.templateId,
argument,
payload: contractPayload,
};
const json = await this.submit('command/create', payload);
const json = await this.submit('command/create', command);
return jtv.Result.withException(decodeCreateEvent(template).run(json));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class CommandService(
resolveTemplateId(input.templateId)
.toRightDisjunction(
Error('createCommand, ErrorMessages.cannotResolveTemplateId(input.templateId)))
.map(tpId => Commands.create(refApiIdentifier(tpId), input.argument))
.map(tpId => Commands.create(refApiIdentifier(tpId), input.payload))
}

private def exerciseCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object domain {

final case class CreateCommand[+LfV](
templateId: TemplateId.OptionalPkg,
argument: LfV,
payload: LfV,
meta: Option[CommandMeta])

final case class ExerciseCommand[+LfV, +Ref](
Expand Down Expand Up @@ -375,7 +375,7 @@ object domain {
implicit val traverseInstance: Traverse[CreateCommand] = new Traverse[CreateCommand] {
override def traverseImpl[G[_]: Applicative, A, B](fa: CreateCommand[A])(
f: A => G[B]): G[CreateCommand[B]] =
f(fa.argument).map(a => fa.copy(argument = a))
f(fa.payload).map(a => fa.copy(payload = a))
}

implicit val hasTemplateId: HasTemplateId[CreateCommand] = new HasTemplateId[CreateCommand] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import scalaz.syntax.show._
object Commands extends StrictLogging {
def create(
templateId: lar.TemplateId,
arguments: lav1.value.Record): lav1.commands.Command.Command.Create = {
payload: lav1.value.Record): lav1.commands.Command.Command.Create = {

lav1.commands.Command.Command.Create(
lav1.commands.CreateCommand(
templateId = Some(lar.TemplateId.unwrap(templateId)),
createArguments = Some(arguments)))
createArguments = Some(payload)))
}

def exercise(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"templateId": "Iou:Iou",
"argument": {
"payload": {
"observers": [],
"issuer": "Alice",
"amount": "999.99",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ abstract class AbstractHttpServiceIntegrationTest
create: domain.CreateCommand[v.Record],
exercise: domain.ExerciseCommand[v.Value, _]): Assertion = {

val expectedContractFields: Seq[v.RecordField] = create.argument.fields
val expectedContractFields: Seq[v.RecordField] = create.payload.fields
val expectedNewOwner: v.Value = exercise.argument.sum.record
.flatMap(_.fields.headOption)
.flatMap(_.value)
Expand Down Expand Up @@ -471,9 +471,9 @@ abstract class AbstractHttpServiceIntegrationTest

inside(SprayJson.decode[domain.ActiveContract[JsValue]](jsVal)) {
case \/-(activeContract) =>
val expectedArgument: JsValue =
encoder.encodeUnderlyingRecord(command).map(_.argument).getOrElse(fail)
(activeContract.payload: JsValue) shouldBe expectedArgument
val expectedPayload: JsValue =
encoder.encodeUnderlyingRecord(command).map(_.payload).getOrElse(fail)
(activeContract.payload: JsValue) shouldBe expectedPayload
}
}

Expand Down Expand Up @@ -634,7 +634,7 @@ abstract class AbstractHttpServiceIntegrationTest
(uri, _, _) =>
val createCommand = jsObject("""{
"templateId": "Account:KeyedByVariantAndRecord",
"argument": {
"payload": {
"name": "ABC DEF",
"party": "Alice",
"age": 123,
Expand Down

0 comments on commit 9ab419f

Please sign in to comment.