From 03ee4bcc2dd0dc80ad75dd0b82894c471ecf1fe4 Mon Sep 17 00:00:00 2001 From: Frank Hillard Date: Wed, 19 Aug 2020 16:44:36 +0200 Subject: [PATCH] 30: mission part --- .../Chapters/Camel/ChapterFA20Hook/course.md | 20 +++++++++---------- .../Chapters/Pascal/ChapterFA20Hook/course.md | 16 +++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/frontend/src/pages/Chapters/Camel/ChapterFA20Hook/course.md b/src/frontend/src/pages/Chapters/Camel/ChapterFA20Hook/course.md index cdf2d7e..060f604 100644 --- a/src/frontend/src/pages/Chapters/Camel/ChapterFA20Hook/course.md +++ b/src/frontend/src/pages/Chapters/Camel/ChapterFA20Hook/course.md @@ -201,28 +201,28 @@ We are working on a fungible token which can handle multiple assets. We decided ![](/images/small-fa2-hook-exercise.png) -1 - we want to accept a transfer if transfer receiver is registered in a whitelist. This whitelisting is done via a tranfer hook. +1 - We want to accept a transfer if the transfer receiver is registered in a whitelist. This whitelisting is done via a tranfer hook. -2 - we want to accept a transfer if transfer receiver implements *fa2\_token\_receiver* interface. +2 - We want to accept a transfer if the transfer receiver implements *fa2\_token\_receiver* interface. -If a receiver address implements *fa2\_token\_receiver* interface, its *tokens\_received* entry point must be called. +If a receiver address implements the *fa2\_token\_receiver* interface, then its *tokens\_received* entry point must be called. -Complete the hook permission smart contract by implementing our custom rules on receivers. Transfer is permitted if receiver address implements *fa2\_token\_receiver* interface OR a receiver address is in the receiver white list. +Complete the hook permission smart contract by implementing our custom rules on receivers. Transfer is permitted if the receiver address implements the *fa2\_token\_receiver* interface OR the receiver address is in the receiver whitelist. -1- Find receiver hook - Check if a receiver _r_ implements *fa2\_token\_receiver* interface, using *to\_receiver\_hook* function and a _match_ operator. +1- Finding the receiver hook - Check if a receiver _r_ implements the *fa2\_token\_receiver* interface, using *to\_receiver\_hook* function and a _match_ operator. -2- Retrieve hook - if the receiver _r_ implements *fa2\_token\_receiver* interface, introduce variable _h_ as hook entry point. +2- Retrieving the hook - if the receiver _r_ implements the *fa2\_token\_receiver* interface, introduce variable _h_ as hook entry point. -3- Prepare parameter - cast parameter _p_ into type *transfer\_descriptor\_param\_to\_michelson* and store the result in a new variable _pm_ +3- Prepare parameters - cast parameter _p_ into type *transfer\_descriptor\_param\_to\_michelson* and store the result in a new variable _pm_ 4- Call the entry point - create a variable _op_ of type *operation* which is a transaction sending variable _pm_ and no mutez to the retrieved entry point _h_ 5- Return transactions - add this newly created operation _op_ in the returned list of operation _ops_ (and return _ops_) -6- if the receiver _r_ does not implement *fa2\_token\_receiver* interface, response of *to\_receiver\_hook* provided an error message with variable _err_. +6- If the receiver _r_ does not implement *fa2\_token\_receiver* interface, response of *to\_receiver\_hook* provided an error message with variable _err_. -7- Check if receiver _r_ is registered in the whitelist _wl_. +7- Check if the receiver _r_ is registered in the whitelist _wl_. 8- If it is the case , everything is fine, just return the returned list of operation _ops_. -9- Otherwise throw an exception with _err_ message. Don't forget to cast the exception. +9- Otherwise throw an exception with _err_ error message. Don't forget to cast the exception. diff --git a/src/frontend/src/pages/Chapters/Pascal/ChapterFA20Hook/course.md b/src/frontend/src/pages/Chapters/Pascal/ChapterFA20Hook/course.md index 69eb9d4..2de8ae8 100644 --- a/src/frontend/src/pages/Chapters/Pascal/ChapterFA20Hook/course.md +++ b/src/frontend/src/pages/Chapters/Pascal/ChapterFA20Hook/course.md @@ -197,25 +197,25 @@ We are working on a fungible token which can handle multiple assets. We decided ![](/images/small-fa2-hook-exercise.png) -Rule 1 - we want to accept a transfer if transfer receiver is registered in a whitelist. This whitelisting is done via a tranfer hook. +Rule 1 - We want to accept a transfer if the transfer receiver is registered in a whitelist. This whitelisting is done via a tranfer hook. -Rule 2 - we want to accept a transfer if transfer receiver implements *fa2\_token\_receiver* interface. +Rule 2 - We want to accept a transfer if the transfer receiver implements the *fa2\_token\_receiver* interface. -If a receiver address implements *fa2\_token\_receiver* interface, its *tokens\_received* entry point must be called. +If a receiver address implements the *fa2\_token\_receiver* interface, its *tokens\_received* entry point must be called. -Complete the hook permission smart contract by implementing our custom rules on receivers. Transfer is permitted if receiver address implements *fa2\_token\_receiver* interface OR a receiver address is in the receiver white list. +Complete the hook permission smart contract by implementing our custom rules on receivers. Transfer is permitted if the receiver address implements the *fa2\_token\_receiver* interface OR the receiver address is in the receiver whitelist. -- As you can see the function *check\_receiver* verifies if a receiver _r_ implements *fa2\_token\_receiver* interface, using *to\_receiver\_hook* function and a _case_ operator. If the receiver _r_ implements *fa2\_token\_receiver* interface, the function *create\_hook\_receiver\_operation* is called with _h_ as hook entry point. +- As you can see the function *check\_receiver* verifies if a receiver _r_ implements the *fa2\_token\_receiver* interface, using *to\_receiver\_hook* function and a _case_ operator. If the receiver _r_ implements the *fa2\_token\_receiver* interface, the function *create\_hook\_receiver\_operation* is called with _h_ as hook entry point. -1 - Prepare parameter - cast parameter _p_ into type *transfer\_descriptor\_param* and store the result in a new variable _pm_. You can check the *fa2\_interface.ligo* for type definition of *transfer\_descriptor\_param* and use the *Layout.convert\_to\_right\_comb* function for conversion. +1 - Prepare parameters - cast the parameter _p_ into type *transfer\_descriptor\_param* and store the result in a new variable _pm_. You can check the *fa2\_interface.ligo* for type definition of *transfer\_descriptor\_param* and use the *Layout.convert\_to\_right\_comb* function for conversion. 2- Call the entry point - create a variable _op_ of type *operation* which is a transaction sending variable _pm_ and no mutez to the retrieved hook entry point _h_ 3- Return transactions - add this newly created operation _op_ in the returned list of operation _ops_ and return it. -- if the receiver _r_ does not implement *fa2\_token\_receiver* interface, the function *verify\_receiver\_in\_whitelist* is called. Modify function *verify\_receiver\_in\_whitelist* with following implementation requirements: +- If the receiver _r_ does not implement the *fa2\_token\_receiver* interface, the function *verify\_receiver\_in\_whitelist* is called. Modify function *verify\_receiver\_in\_whitelist* with following implementation requirements: -4- Check if receiver _r_ is registered in the whitelist _wl_. +4- Check if the receiver _r_ is registered in the whitelist _wl_. 5- If it is the case , everything is fine, just return the returned list of operation _ops_.