From 2cb10961f27eeb22bec1eb241eb0b133a38efa58 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 15 Dec 2020 16:43:59 -0800 Subject: [PATCH] User command memo, better GraphQL docstring --- graphql_schema.json | 44 ++++++++++++++-------------- src/lib/coda_graphql/coda_graphql.ml | 16 +++++----- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/graphql_schema.json b/graphql_schema.json index 99ec01c49f0..463c3aa89fb 100644 --- a/graphql_schema.json +++ b/graphql_schema.json @@ -639,7 +639,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "SCALAR", @@ -751,7 +751,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "type": { "kind": "SCALAR", "name": "String", @@ -886,7 +886,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "SCALAR", @@ -998,7 +998,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "type": { "kind": "SCALAR", "name": "String", @@ -1133,7 +1133,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "SCALAR", @@ -1213,7 +1213,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "type": { "kind": "SCALAR", "name": "String", @@ -1320,7 +1320,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "SCALAR", @@ -1404,7 +1404,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "type": { "kind": "SCALAR", "name": "String", @@ -1593,7 +1593,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "SCALAR", @@ -1705,7 +1705,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "type": { "kind": "SCALAR", "name": "String", @@ -3782,7 +3782,7 @@ }, { "name": "amount", - "description": "Amount that the source is sending to receiver - this is 0 for commands that are not associated with an amount", + "description": "Amount that the source is sending to receiver; 0 for commands without an associated amount", "args": [], "type": { "kind": "NON_NULL", @@ -3830,7 +3830,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "NON_NULL", @@ -4103,7 +4103,7 @@ }, { "name": "amount", - "description": "Amount that the source is sending to receiver - this is 0 for commands that are not associated with an amount", + "description": "Amount that the source is sending to receiver; 0 for commands without an associated amount", "args": [], "type": { "kind": "NON_NULL", @@ -4151,7 +4151,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "NON_NULL", @@ -4424,7 +4424,7 @@ }, { "name": "amount", - "description": "Amount that the source is sending to receiver - this is 0 for commands that are not associated with an amount", + "description": "Amount that the source is sending to receiver; 0 for commands without an associated amount", "args": [], "type": { "kind": "NON_NULL", @@ -4472,7 +4472,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "NON_NULL", @@ -4745,7 +4745,7 @@ }, { "name": "amount", - "description": "Amount that the source is sending to receiver - this is 0 for commands that are not associated with an amount", + "description": "Amount that the source is sending to receiver; 0 for commands without an associated amount", "args": [], "type": { "kind": "NON_NULL", @@ -4793,7 +4793,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "NON_NULL", @@ -5070,7 +5070,7 @@ }, { "name": "amount", - "description": "Amount that the source is sending to receiver - this is 0 for commands that are not associated with an amount", + "description": "Amount that the source is sending to receiver; 0 for commands without an associated amount", "args": [], "type": { "kind": "NON_NULL", @@ -5118,7 +5118,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "NON_NULL", @@ -5359,7 +5359,7 @@ }, { "name": "amount", - "description": "Amount that the source is sending to receiver - 0 for commands that are not associated with an amount", + "description": "Amount that the source is sending to receiver; 0 for commands without an associated amount", "args": [], "type": { "kind": "NON_NULL", @@ -5407,7 +5407,7 @@ }, { "name": "memo", - "description": "Short arbitrary message provided by the sender", + "description": "A short message from the sender, encoded with Base58Check, version byte=0x14; byte 2 of the decoding is the message length", "args": [], "type": { "kind": "NON_NULL", diff --git a/src/lib/coda_graphql/coda_graphql.ml b/src/lib/coda_graphql/coda_graphql.ml index 2ba1709fc31..c7aa5d8f3f6 100644 --- a/src/lib/coda_graphql/coda_graphql.ml +++ b/src/lib/coda_graphql/coda_graphql.ml @@ -968,9 +968,8 @@ module Types = struct Signed_command.token cmd.With_hash.data ) ; field "amount" ~typ:(non_null uint64) ~args:[] ~doc: - "Amount that the source is sending to receiver - this is 0 for \ - commands that are not associated with an amount" - ~resolve:(fun _ cmd -> + "Amount that the source is sending to receiver; 0 for commands \ + without an associated amount" ~resolve:(fun _ cmd -> match Signed_command.amount cmd.With_hash.data with | Some amount -> Currency.Amount.to_uint64 amount @@ -985,15 +984,18 @@ module Types = struct transaction" ~resolve:(fun _ cmd -> Signed_command.fee cmd.With_hash.data |> Currency.Fee.to_uint64 ) ; field "memo" ~typ:(non_null string) ~args:[] - ~doc:"Short arbitrary message provided by the sender" + ~doc: + (sprintf + "A short message from the sender, encoded with Base58Check, \ + version byte=0x%02X; byte 2 of the decoding is the message \ + length" + (Char.to_int Base58_check.Version_bytes.user_command_memo)) ~resolve:(fun _ payment -> Signed_command_payload.memo @@ Signed_command.payload payment.With_hash.data |> Signed_command_memo.to_string ) ; field "isDelegation" ~typ:(non_null bool) ~args:[] - ~doc: - "If true, this represents a delegation of stake, otherwise it is \ - a payment" + ~doc:"If true, this command represents a delegation of stake" ~deprecated:(Deprecated (Some "use kind field instead")) ~resolve:(fun _ user_command -> match