Proto/CLST: token metadata

This MRs adds the following according to the FA2.1 standard:

  • token_metadata to the contract storage
  • get_token_metadata view
  • token_metadata_update event

Manually testing the MR

dune exec src/proto_alpha/lib_protocol/test/integration/main.exe -- --file test_clst.ml -m "get_token_metadata" or in sandbox:

octez-client run view get_token_metadata on contract KT1WCsbJx996ebZfutAitHYsZ8FUZFsTdaD7 with input "0"

{ Elt "decimals" 0x36 ;
  Elt "name" 0x5374616b65642054657a ;
  Elt "symbol" 0x7354657a ;
  Elt "tokenKind" 0x66756e6769626c65 }

octez-client run view get_token_metadata on contract KT1WCsbJx996ebZfutAitHYsZ8FUZFsTdaD7 with input "1"
{}

deposit triggers the token_metadata_update event:

        Internal Event:
          From: KT1WCsbJx996ebZfutAitHYsZ8FUZFsTdaD7
          Type: (pair %token_metadata_update
                   (nat %token_id)
                   (option %new_metadata (map string bytes)))
          Tag: deposit
          Payload: (Pair 0
                         (Some { Elt "decimals" 0x36 ;
                                 Elt "name" 0x5374616b65642054657a ;
                                 Elt "symbol" 0x7354657a ;
                                 Elt "tokenKind" 0x66756e6769626c65 }))
          This event was successfully applied
          Consumed gas: 100

redeem triggers the token_metadata_update event:

        Internal Event:
          From: KT1WCsbJx996ebZfutAitHYsZ8FUZFsTdaD7
          Type: (pair %token_metadata_update
                   (nat %token_id)
                   (option %new_metadata (map string bytes)))
          Tag: redeem
          Payload: (Pair 0 None)
          This event was successfully applied
          Consumed gas: 100

In the block metadata, for deposit:

                  { "kind": "event",
                      "source": "KT1WCsbJx996ebZfutAitHYsZ8FUZFsTdaD7",
                      "nonce": 2,
                      "type":
                        { "prim": "pair",
                          "args":
                            [ { "prim": "nat", "annots": [ "%token_id" ] },
                              { "prim": "option",
                                "args":
                                  [ { "prim": "map",
                                      "args":
                                        [ { "prim": "string" },
                                          { "prim": "bytes" } ] } ],
                                "annots": [ "%new_metadata" ] } ],
                          "annots": [ "%token_metadata_update" ] },
                      "tag": "deposit",
                      "payload":
                        { "prim": "Pair",
                          "args":
                            [ { "int": "0" },
                              { "prim": "Some",
                                "args":
                                  [ [ { "prim": "Elt",
                                        "args":
                                          [ { "string": "decimals" },
                                            { "bytes": "36" } ] },
                                      { "prim": "Elt",
                                        "args":
                                          [ { "string": "name" },
                                            { "bytes": "5374616b65642054657a" } ] },
                                      { "prim": "Elt",
                                        "args":
                                          [ { "string": "symbol" },
                                            { "bytes": "7354657a" } ] },
                                      { "prim": "Elt",
                                        "args":
                                          [ { "string": "tokenKind" },
                                            { "bytes": "66756e6769626c65" } ] } ] ] } ] },
                      "result":
                        { "status": "applied",
                          "consumed_milligas": "100000" } } ] } } ],

for redeem:

                { "kind": "event",
                      "source": "KT1WCsbJx996ebZfutAitHYsZ8FUZFsTdaD7",
                      "nonce": 2,
                      "type":
                        { "prim": "pair",
                          "args":
                            [ { "prim": "nat", "annots": [ "%token_id" ] },
                              { "prim": "option",
                                "args":
                                  [ { "prim": "map",
                                      "args":
                                        [ { "prim": "string" },
                                          { "prim": "bytes" } ] } ],
                                "annots": [ "%new_metadata" ] } ],
                          "annots": [ "%token_metadata_update" ] },
                      "tag": "redeem",
                      "payload":
                        { "prim": "Pair",
                          "args": [ { "int": "0" }, { "prim": "None" } ] },
                      "result":
                        { "status": "applied",
                          "consumed_milligas": "100000" } } ] } } ],

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Marina Polubelova

Merge request reports

Loading