10.1 谓词订单构建者服务 (Predicate orders builder service)

Service for orders(backend) that generates predicate instance for a specific order, builds it and returns binary and abi files

为订单提供服务(后台),为特定的订单生成谓词实例,构建它并返回其二进制和abi文件。

https://github.com/compolabs/spark/tree/master/services/predicate-orders-builder

如何生效? (How it works? )

  • 1.Alice opens the app and clicks "create order" button, having filled all the required data like asset price, amount Alice打开应用,点击 "创建订单 "按钮,并填写所有需要的数据,如资产价格、金额等

  • 2.Request is sent to the backend, predicates get to build specially for this order, and artifacts are going back to the frontend 请求被发送到后台,谓词为这个订单专门建立,工单被送回前台

  • 3.Alice sends money to predicate Alice向谓词发送金钱

  • 4.Bob sees Alice's order in the interface ( for now order list comes from backend). Client part creates inputs and outputs for UTXO, and calls predicate ith attached money Bob在界面上看到Alice的订单(目前订单列表来自于后台)。客户端部分为UTXO创建输入和输出,并且用所附的钱调用谓词

  • 5.Predicate transfers money to Alice and Bob like if it was usual transfer 谓词将钱转给Alice和Bob,就像平时的转账一样。

  • 6.Everyone is happy I have created simple mvp of this approach, repo is here: If we've done this correctly, it doesn't seem to be a traditional decentralized app approach, that would include an open source code, and implementation of partially fulfilled orders is another task that should be done. Tx fee would be low though 每个人都很高兴 我已经创建了这个方法的简单mvp,repo在这里: 如果我们做得正确,这似乎不是一个传统的去中心化应用的方法—一般来说会包括一个开放的源代码,并且部分完成订单的实现是另一个应该做的任务。当然,交易费用会很低

测试 (Testing)

  1. Clone the repo: 克隆repo:

  git clone git@github.com:compolabs/spark.git
  1. Go to the predicate-orders-builder directory: 进入 predicate-orders-builder 目录:

  cd spark/services/predicate-orders-builder/
  1. Build the create order script. This command will go into the folder with the script, compile the script to be used to create the predicate order, and exit back: 建立创建订单的脚本。这个命令将进入带有脚本的文件夹,编译用于创建谓词订单的脚本,然后退出:

cd create_order_script && forc build && cd ../
  1. Run the predicate orders builder service: 运行谓词订单构建器服务:

cargo run

Output 输出:

  1. Open a new terminal window in the predicate-orders-builder directory. 在 predicate-orders-builder 目录下打开一个新的终端窗口。

  2. Run the test: 运行测试

cargo test --package predicat-order-builder --test harness -- local_tests::fulfill_order_test::fulfill_order_test --exact --nocapture

Output 输出:

Last updated