【问题标题】:Is there a way to send modules through the message data?有没有办法通过消息数据发送模块?
【发布时间】:2022-06-24 15:58:02
【问题描述】:

问题是,在 repl 文件中,我可以在消息数据中发送 coin 模块,因为 repl 将其解析为模块本身,并且不需要有效的 json。但是当我尝试通过真实消息发送它时,它必须是一个有效的 json,因此没有办法让它像 repl 文件中那样,它必须像 "coin"。 还有一些其他类型的读取函数 (read-decimal read-integer read-keyset read-string),但我找不到任何读取模块的函数,或者将字符串转换为模块。

【问题讨论】:

    标签: pact-lang


    【解决方案1】:

    我找到了一个解决方案,它的文档没有我能搜索到的那么好,为了发送一个模块,你所要做的就是在 json 文件中以这种方式发送它:

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

    然后这样读:

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

    干杯!嘉手纳万岁!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 2021-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-13
      相关资源
      最近更新 更多