scilla-docs icon indicating copy to clipboard operation
scilla-docs copied to clipboard

Add multi-message example

Open snowsledge opened this issue 5 years ago • 2 comments

Note to remove: https://github.com/Zilliqa/scilla-docs/blob/6559e81037c0090088a9a1f27c19a0617cd2df0f/docs/source/scilla-by-example.rst#L563

Example to add:

let one_msg =
  fun (msg : Message) =>
  let nil_msg = Nil {Message} in
    Cons {Message} msg nil_msg

let two_msgs =
fun (msg1 : Message) =>
fun (msg2 : Message) =>
  let msgs_tmp = one_msg msg2 in
  Cons {Message} msg1 msgs_tmp

and

(* Sequential message sending starting with msg1 *)
msg1 = {_tag : ""; _recipient : owner; _amount : bal; code : got_funds_code};
msg2 = {_tag : "", _recipient : _sender; _amount : Uint128 0; code: sent_funds_code};
msgs = two_msgs msg1 msg2;
send msgs

snowsledge avatar Jul 04 '20 15:07 snowsledge

OK, since this chapter discusses the crowdfunding contract:

Sending a message is done using the send instruction, which takes a list of messages as a parameter. Since we will only ever send one message at a time in the crowdfunding contract, we define a library function one_msg to construct a list consisting of one message:

I propose to remove the note for now and add an example for multiple messages in a separate PR.

anton-trunov avatar Jul 05 '20 12:07 anton-trunov

There is an example of a multi-message send in ZRC-2 (https://github.com/Zilliqa/ZRC/blob/master/reference/FungibleToken.scilla#L240). We might want to reuse it.

anton-trunov avatar Jul 21 '20 08:07 anton-trunov