From aafd7f83af04b637b96636d7e22319fd31feef2f Mon Sep 17 00:00:00 2001 From: Ivan Tsoninski Date: Wed, 4 Aug 2021 09:19:25 +0300 Subject: [PATCH] Update course.md Changed type of transfer to match fa1.2 standard when the code is compiled to Michelson. --- .../Chapters/Camel/ChapterFA12/course.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/frontend/src/pages/Chapters/Camel/ChapterFA12/course.md b/src/frontend/src/pages/Chapters/Camel/ChapterFA12/course.md index ff304a7..767716a 100644 --- a/src/frontend/src/pages/Chapters/Camel/ChapterFA12/course.md +++ b/src/frontend/src/pages/Chapters/Camel/ChapterFA12/course.md @@ -57,12 +57,12 @@ type storage = { total_amount : nat; } -type transfer = { - address_from : address; - address_to : address; - value : nat; +type transfer = +[@layout:comb] { + from : address; + [@annot:to]to_: address; + value: nat; } - type approve = { spender : address; value : nat; @@ -92,17 +92,17 @@ type action = let transfer (p,s : transfer * storage) : operation list * storage = let new_allowances = - if Tezos.sender = p.address_from then s.allowances + if Tezos.sender = p.from then s.allowances else - let authorized_value = match Big_map.find_opt (Tezos.sender,p.address_from) s.allowances with + let authorized_value = match Big_map.find_opt (Tezos.sender,p.from) s.allowances with Some value -> value | None -> 0n in if (authorized_value < p.value) then (failwith "Not Enough Allowance" : allowances) - else Big_map.update (Tezos.sender,p.address_from) (Some (abs(authorized_value - p.value))) s.allowances + else Big_map.update (Tezos.sender,p.from) (Some (abs(authorized_value - p.value))) s.allowances in - let sender_balance = match Big_map.find_opt p.address_from s.tokens with + let sender_balance = match Big_map.find_opt p.from s.tokens with Some value -> value | None -> 0n in @@ -110,11 +110,11 @@ let transfer (p,s : transfer * storage) : operation list * storage = then (failwith "Not Enough Balance" : operation list * storage) else let new_tokens = Big_map.update p.address_from (Some (abs(sender_balance - p.value))) s.tokens in - let receiver_balance = match Big_map.find_opt p.address_to s.tokens with + let receiver_balance = match Big_map.find_opt p.to_ s.tokens with Some value -> value | None -> 0n in - let new_tokens = Big_map.update p.address_to (Some (receiver_balance + p.value)) new_tokens in + let new_tokens = Big_map.update p.to_ (Some (receiver_balance + p.value)) new_tokens in ([]:operation list), {s with tokens = new_tokens; allowances = new_allowances} let approve (p,s : approve * storage) : operation list * storage = @@ -204,4 +204,4 @@ tezos-client transfer from to --arg ' = number of mutez of the transaction = account who is emitting the transaction = name of the contract - = michelson expression representing the entrypoint and its related parameters \ No newline at end of file + = michelson expression representing the entrypoint and its related parameters