pact-lang

Is there a way to send modules through the message data?


Question is, in the repl file I can send the coin module in the message data, as the repl parse it into the module itself, and it doesn't require a valid json. But when I try to send it through a real message, it must be a valid json, and therefor there is no way of making it like in the repl file, and it has to be like "coin". There are reading functions for some other types, (read-decimal read-integer read-keyset read-string), but I can't find any function that reads a module, or alternatively casts a string to a module.


Solution

  • I found a solution, which is not documented as good as I could search, all you have to do in order to send a module is to send it this way in the json file:

    'fungible: {"refName": {"name": "coin",
                            "namespace": null
                           },
                "refSpec": [
                             {
                               "name": "fungible-v2",
                               "namespace": null
                             }
                           ]
               }
    

    And then read it like that:

    (let ((f:module{fungible-v2} (read-msg 'fungible)) ...)

    Cheers! Viva la Kadena!!