olisystems / BEST-Energy

Integritee off-chain worker and sidechain validateer
Apache License 2.0
2 stars 0 forks source link

Supply orders with the RPC request directly instead of reading from local file #18

Closed clangenb closed 1 year ago

clangenb commented 1 year ago

OLI wants to send the orders from the market engine directly and with their own client instead of our rust-cli. The first step would be to change the rust-cli to handle this, which is straight forward.

  1. Change the argument of the pay_as_bid command to be the json content of the orders instead of the path
  2. In the pay_as_bid command, we parse the input: let orders: Vec<Orders> = serde_json::from_str(input).
  3. The TrustedCall field is no longer a String, but a Vec<Orders>
m-yahya commented 1 year ago

Can you please explain point 3 a bit more? I see we now have to pass the file contents as string and the parameter type is already String e.g orders_file: String,. I think we just need to remove one extra step of reading the contents from the file.

clangenb commented 1 year ago

You are right: in step 2 we can actually still just supply the path to the file. It is ok if the CLI reads it from the file, but the enclave must not. This is why the trusted call needs to look like this now:

enum TrustedCall {
   pay_as_bid(AccountId, Vec<Orders>)
}

So here we need to read the file in the CLI and supply it as a field of the trusted call: https://github.com/olisystems/BEST-Energy/blob/0d80464657d91feff6106cda7db3c12ee0eb7f95/cli/src/trusted_base_cli/commands/pay_as_bid.rs#L51

clangenb commented 1 year ago

Closing this one as completed, the tracking issue of enabling sending the requests from other clients is in #34.