Skip to content

Commit

Permalink
Merge pull request #60 from octo-technology/review_alex
Browse files Browse the repository at this point in the history
Adding more instructions in exercise
  • Loading branch information
AymericBethencourt authored Nov 30, 2020
2 parents cba64fb + 9e46a11 commit 935d32e
Show file tree
Hide file tree
Showing 34 changed files with 180 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/frontend/src/pages/Chapter/Chapter.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export const ChapterView = ({
{Object.keys(supports).length > 0 && (
<div style={{ overflow: 'scroll' }}>
<ChapterTab isSelected={display === 'solution'} onClick={() => setDisplay('solution')}>
Exercice
Exercise
</ChapterTab>
{Object.keys(supports).map((key, index) => (
<ChapterTab isSelected={display === key} onClick={() => setDisplay(key)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ We want to conditionally change the engine attribute (third number) to 1 only if
<!-- prettier-ignore -->1- Define a condition _if_ the engine attribute equal 0. Don't forget the attributes are defined as strings.

<!-- prettier-ignore -->2- If the condition is met, apply changes and return resulting new ship code. Otherwise, return the given ship code (parameter *my\_ship*).

<!-- prettier-ignore -->⚠️ If you have installed LIGO then you can test the execution of the *modify\_ship* function by running the following command:

```
ligo run-function main.ligo modify_ship '("010433")'
```
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,5 @@ let main (action,store : parameter * storage): return =

<!-- prettier-ignore -->1- Write the _compile-storage_ command and the LIGO expression for initializing the *Sol* system containing planet "earth" with coordinates (2,7,1).

<!-- prettier-ignore -->2- Write the _dry-run_ command and the LIGO expression for adding a planet "mars" with coordinates (4,15,2) in our *Sol* system. Reuse the *Sol* system of step 1.
<!-- prettier-ignore -->2- Write the _dry-run_ command and the LIGO expression for adding a planet "mars" with coordinates (4,15,2) in our *Sol* system.
<!-- prettier-ignore -->⚠️ Remind that the _dry-run_ command expects a parameter "<entrypoint(p)>" and a parameter "<storage_state>" as shown in Simulating section. For this _dry-run_ command you must write the "<entrypoint(p)>" parameter and reuse the *Sol* system of step 1 as "<storage_state>" parameter.
15 changes: 13 additions & 2 deletions src/frontend/src/pages/Chapters/Camel/ChapterFA12/course.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ERC721 is the standard rule set for non-fungible tokens.
This Fungible token standard provides basic functionality to transfer tokens, as well as to allow tokens to be approved so they can be spent by another on-chain third party.

Possible actions :
_Appove_ - Sender can specify an amount of token that can be spent by someone else (from his account)
_Approve_ - Sender can specify an amount of token that can be spent by someone else (from his account)
_Transfer_ - Transfer an amount of tokens from an account to another account (or third-party on-chain smart contract)
_GetAllowance_ - Return the amount that can be spent by someone from sender's account
_GetBalance_ - Return the sender's account balance
Expand Down Expand Up @@ -167,7 +167,7 @@ Let's assume that the _TezosAcamedyToken_ has been deployed.
Consider your account is _me_ (at address tz1SdT62G8tQp9fdHh4f2m4VtL8aGG6NUcmJ) which has been granted 1,000,000 tokens.
Consider alice's account (at address tz1NiAGZgRV8F1E3qYFEPgajntzTRDYkU9h7)

<!-- prettier-ignore -->1- We want you to simulate the transfer of 2 TAT (Tezos Academy Token) to *alice*. Write a ligo command line for preparing a simulated storage where you (tz1SdT62G8tQp9fdHh4f2m4VtL8aGG6NUcmJ) possess 1,000,000 tokens and no allowance.
<!-- prettier-ignore -->1- We want you to simulate the transfer of 2 TAT (Tezos Academy Token) to *alice*. Complete the ligo command line for preparing a storage state where you (tz1SdT62G8tQp9fdHh4f2m4VtL8aGG6NUcmJ) possess 1,000,000 tokens and no allowance. Write the storage state (all values of the storage must be filled).

<!-- prettier-ignore -->2- Write a ligo command line for preparing the invocation of an *Approval* of 2 TAT (Tezos Academy Token) for *alice*.

Expand All @@ -194,3 +194,14 @@ Consider alice's account (at address tz1NiAGZgRV8F1E3qYFEPgajntzTRDYkU9h7)
```

<!-- prettier-ignore -->10- Write a Tezos command line that simulates your *Transfer* invocation.

<!-- prettier-ignore -->Remind the syntax of the tezos-client transfer command:

```
tezos-client transfer <tx_amount> from <tx_user> to <contract_name> --arg '<entrypoint_invocation>' --dry-run
```

<!-- prettier-ignore --><tx\_amount> = number of mutez of the transaction
<!-- prettier-ignore --><tx\_user> = account who is emitting the transaction
<!-- prettier-ignore --><contract_name> = name of the contract
<!-- prettier-ignore --><entrypoint_invocation> = michelson expression representing the entrypoint and its related parameters
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ligo dry-run --sender=tz1SdT62G8tQp9fdHh4f2m4VtL8aGG6NUcmJ fa12.mligo main '<par
// Modify the code below
tezos-client transfer <amount> from <user> to <contract_name> --arg '<entrypoint_invocation>' --dry-run
// Modify the code below
ligo compile-parameter refa12.mligo main ''
ligo compile-parameter fa12.mligo main ''
// Modify the code below
ligo compile-storage fa12.mligo main ''
// Modify the code below
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Our NFT "token" is almost ready but to allow a new rule. We need Bob to transfer

- Vera account is owner of the token 1

<!-- prettier-ignore -->2- Complete the _ligo dry-run_ command for authorizing Bob to transfer tokens taken from Vera account, transaction emitted by Vera. (reuse the storage you made on step 1). You can use *operator\_update\_to\_michelson* function to convert your parameters into the format expected by *Update\_operators* entry point.
<!-- prettier-ignore -->2- Complete the _ligo dry-run_ command for authorizing Bob to transfer tokens taken from Vera account, transaction emitted by Vera. (reuse the storage you made on step 1). You can use *operator\_update\_to\_michelson* function to convert your parameters into the format expected by *Update\_operators* entry point. Don't forget to refer to fa2_interface to know the the expected type of *Update\_operators* entry point.

<!-- prettier-ignore -->3- Complete the _ligo dry-run_ command for simulating the transfer of 1 token from Vera'account to Alice's account, transaction emitted by Bob. The transferred token id is number 1 (token\_id and and amount must be 1). You can use the *transfer\_to\_michelson* function to convert your parameters into the format expected by *Transfer* entry point.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ let main (action, store : parameter * storage) : return is
)
```

<!-- prettier-ignore -->2- Consider the contract in the editor. Notice the addresses of each weapon, and that the _orders_ function fetch the corresponding contracts. Your job is now to define the list of operations to send to the weapons. For this, start by creating _operations_ a list of type _operation_.
<!-- prettier-ignore -->⚠️ Notice that the weapon smart contract provides two entrypoints Fire and Stop.

<!-- prettier-ignore -->2- Consider the contract in the editor which is responsible to control the left and right weapons.
<!-- prettier-ignore -->⚠️ Notice the addresses of each weapon, and that the _orders_ function fetch the corresponding contracts. (Variables *right\_laser* and *left\_laser* can be used as the target of a transaction).
Your job is now to define the list of transactions sent to the weapon contracts. For this, start by creating _operations_ a list of type _operation_.

<!-- prettier-ignore -->⚠️ Notice that _operations_ must be filled with transactions and is returned by the function _orders_.

<!-- prettier-ignore -->3- Send a _Fire(5)_ transaction to the *right\_laser* contract, then _Stop_. Send a _Fire(5)_ transaction to the *left\_laser* contract, then _Stop_.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Map.map applyDeduceCatg store.celestialbodies

We want you to update our "starmap" contract in order to take this new rule into account.

<!-- prettier-ignore -->1- Write the _dry-run_ command and the associated invocation (entry point) for taking the new rule into account.
<!-- prettier-ignore -->1- Write the _dry-run_ command and the associated invocation (entry point) for taking the new rule into account. You must write a lambda function within the parentheses of _DeduceCategoryChange_ as shown in the Lambda definition section. The lambda function must implement the three following rules.

<!-- prettier-ignore -->2- First rule : if the coordinates of a planet is (0,0,0) then the celestial body is considered as a STAR.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,28 @@ Entry point names are written in the form of: _%myEntryPoint_ for the entry poin

## Your mission

Consider the following smart contracts : Squadron and Central (Exercice).
Consider the following smart contracts : Squadron and Central (Exercise).

The Central contract acts as an inventory of ships (an entry point _RegisterShip_ is provided to register a ship).
The Central contract can provide information of a ship to a calling contract via a callback transaction (an entry point _RetrieveShip_ is provided to query a ship).
The Squadron contract provides an entry point _ModuleRequest_ to ask for ship information to the central contract.
The Squadron contract provides an entry point _ModuleResponse_ which is called by the central contract when sending back the expected ship information.

As you can see, the entry point _RetrieveShip_ calls the function _sendTx_ which is responsible to send a transaction to a the calling contract. The implementation of the Central contract has not been finished. We need you to finish the _sendTx_ function!
As you can see, the entry point _RetrieveShip_ calls the function _sendTx_ which is responsible to send the requested ship information to the caller (by sending a transaction to the calling contract). The implementation of the Central contract has not been finished. We need you to finish the _sendTx_ function!

<!-- prettier-ignore -->1- Try to retrieve the entry point %moduleResponse of the given *callbackAddress* and store the result in a variable called *contractInterfaceOpt* of type _actionSquadron contract option_
<!-- prettier-ignore -->⚠️ Notice that there are multiple tabs for displaying Squadron and Central smart contracts. Your goal is to complete the Central contract displayed in tab "Exercise".

<!-- prettier-ignore -->2- Use a _match_ operator to extract the entry point if it exists (use temporary variable name *ci* in the _Some_). Otherwise throw an exception with error message "Entrypoint not found in contract Squadron" (and don't forget to cast the exception in the right type). The extracted entry point must be stored in a variable called *contractInterface*.

<!-- prettier-ignore -->3- In order to prepare the ship information that need to be sent back to the Squadron contract. Check the expected type of entry point _ModuleResponse_ and prepare a variable *ee* of this expected type containing the expected ship *e*.
<!-- prettier-ignore -->1- First we want to call the moduleResponse entrypoint of the Squadron but we need to ensure that the *callbackAddress* is a squadron contract and has the expected entrypoint. Try to retrieve the entry point %moduleResponse of the given *callbackAddress* and store the result in a variable called *contractInterfaceOpt* of type _actionSquadron contract option_.
<!-- prettier-ignore -->⚠️Remind that the entry point must be in quotations.
<!-- prettier-ignore -->⚠️Remind that _option_ type means that maybe there is a value
<!-- prettier-ignore -->⚠️Remind that _actionSquadron contract_ represents entrypoints following the _actionSquadron_ format.
<!-- prettier-ignore -->⚠️So the type _actionSquadron contract option_ stands for "Maybe there are entrypoints which follow the _actionSquadron_ format".

<!-- prettier-ignore -->2- Use a _match_ operator to extract the entry point from *contractInterfaceOpt* if it exists (use temporary variable name *ci* in the _Some_). Otherwise throw an exception with error message "Entrypoint not found in contract Squadron" (and don't forget to cast the exception in the right type). The extracted entry point must be stored in a variable called *contractInterface*.

<!-- prettier-ignore -->3- In order to prepare the ship information that need to be sent back to the Squadron contract. Prepare a variable called *ee* of type _actionModuleResponse_ containing the expected ship *e*.
<!-- prettier-ignore -->⚠️ Notice that in Squadron smart contract the entry point _ModuleResponse_ expects a type _actionModuleResponse_. So when Central smart contract sends back the requested ship information it must respect the expected format (in our case it is a _actionModuleResponse_ containing a _ship_ record).


<!-- prettier-ignore -->4- Send a transaction to the retrieved entry point of the Squadron contract. The transaction must point to the _moduleResponse_ entrypoint of squadron contract and passing the right argument prepared in step 3. This transaction sends no money. The transaction is an _operation_ type that you can store in a variable *sendbackOperation*.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ let full_greeting: string = greeting ^ " " ^ name

## Slicing Strings

Strings can be sliced using a built-in function _String.sub_ as follows:
Strings can be sliced using a built-in function _String.sub_ which takes three parameters:
- an _offset_ describing the index of first character that will be copied
- the _length_ describing the number of characters that will be copied (starting from the given offset)
- the _string_ being sliced

The function _String.sub_ can be used as follows:

```
let name: string = "Captain Rogers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,10 @@ We want to conditionally change the engine attribute (third number) to 1 only if
<!-- prettier-ignore -->2- Then define a condition _if_ the engine attribute equal 0. Don't forget the attributes are defined as strings.

<!-- prettier-ignore -->3- If the condition is met, change *modified\_ship* to it new value. Otherwise, _skip_ the instructions.

<!-- prettier-ignore -->⚠️ If you have installed LIGO then you can test the execution of the *modify\_ship* function by running the following command:

```
ligo run-function main.ligo modify_ship '("010433")'
```

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ const my_ship_price : tez = 3tez * 1.20
function modify_ship (const my_ship : ship_code) : ship_code is
block {
// Type your solution below
const modified_ship := String.sub(0n, 2n, my_ship) ^ "1" ^ String.sub(3n, 3n, my_ship)
const modified_ship = String.sub(0n, 2n, my_ship) ^ "1" ^ String.sub(3n, 3n, my_ship)
} with modified_ship
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,5 @@ block { skip } with case action of

<!-- prettier-ignore -->1- Write the _compile-storage_ command and the LIGO expression for initializing the *Sol* system containing planet "earth" with coordinates (2,7,1).

<!-- prettier-ignore -->2- Write the _dry-run_ command and the LIGO expression for adding a planet "mars" with coordinates (4,15,2) in our *Sol* system. Reuse the *Sol* system of step 1.
<!-- prettier-ignore -->2- Write the _dry-run_ command and the LIGO expression for adding a planet "mars" with coordinates (4,15,2) in our *Sol* system.
<!-- prettier-ignore -->⚠️ Remind that the _dry-run_ command expects a parameter "<entrypoint(p)>" and a parameter "<storage_state>" as shown in Simulating section. For this _dry-run_ command you must write the "<entrypoint(p)>" parameter and reuse the *Sol* system of step 1 as "<storage_state>" parameter.
15 changes: 13 additions & 2 deletions src/frontend/src/pages/Chapters/Pascal/ChapterFA12/course.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ERC721 is the standard rule set for non-fungible tokens.
This Fungible token standard provides basic functionality to transfer tokens, as well as allowing tokens to be approved so they can be spent by another on-chain third party.

Possible actions :
_Appove_ - Sender can specify an amount of token that can be spent by someone else (from his account)
_Approve_ - Sender can specify an amount of token that can be spent by someone else (from his account)
_Transfer_ - Transfer an amount of tokens from an account to another account (or third-party on-chain smart contract)
_GetAllowance_ - Return the amount that can be spent by someone from sender's account
_GetBalance_ - Return the sender's account balance
Expand Down Expand Up @@ -203,7 +203,7 @@ Let's assume _TezosAcamedyToken_ has been deployed.
Consider your account is _me_ (at address tz1SdT62G8tQp9fdHh4f2m4VtL8aGG6NUcmJ) which has been granted 1,000,000 token.
Consider alice's account (at address tz1NiAGZgRV8F1E3qYFEPgajntzTRDYkU9h7)

<!-- prettier-ignore -->1- We want you to simulate the transfer of 2 TAT (Tezos Academy Token) to *alice*. Write a ligo command line for preparing a simulated storage where you (tz1SdT62G8tQp9fdHh4f2m4VtL8aGG6NUcmJ) possess 1,000,000 tokens and no allowance.
<!-- prettier-ignore -->1- We want you to simulate the transfer of 2 TAT (Tezos Academy Token) to *alice*. Complete the ligo command line for preparing a storage state where you (tz1SdT62G8tQp9fdHh4f2m4VtL8aGG6NUcmJ) possess 1,000,000 tokens and no allowance. Write the storage state (all values of the storage must be filled).

<!-- prettier-ignore -->2- Write a ligo command line for preparing the invocation of an *Approval* of 2 TAT (Tezos Academy Token) for *alice*.

Expand All @@ -230,3 +230,14 @@ Consider alice's account (at address tz1NiAGZgRV8F1E3qYFEPgajntzTRDYkU9h7)
```

<!-- prettier-ignore -->10- Write a Tezos command line that simulates your *Transfer* invocation.

<!-- prettier-ignore -->Remind the syntax of the tezos-client transfer command:

```
tezos-client transfer <tx_amount> from <tx_user> to <contract_name> --arg '<entrypoint_invocation>' --dry-run
```

<!-- prettier-ignore --><tx\_amount> = number of mutez of the transaction
<!-- prettier-ignore --><tx\_user> = account who is emitting the transaction
<!-- prettier-ignore --><contract_name> = name of the contract
<!-- prettier-ignore --><entrypoint_invocation> = michelson expression representing the entrypoint and its related parameters
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ligo dry-run --sender=tz1SdT62G8tQp9fdHh4f2m4VtL8aGG6NUcmJ fa12.ligo main '<para
// Modify the code below
tezos-client transfer <amount> from <user> to <contract_name> --arg '<entrypoint_invocation>' --dry-run
// Modify the code below
ligo compile-parameter refa12.ligo main ''
ligo compile-parameter fa12.ligo main ''
// Modify the code below
ligo compile-storage fa12.ligo main ''
// Modify the code below
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Our NFT "token" is almost ready but to allow a new rule. We need Bob to transfer

- Vera account is owner of the token 1

<!-- prettier-ignore -->2- Complete the _ligo dry-run_ command for authorizing Bob to transfer tokens taken from Vera account, transaction emitted by Vera. (reuse the storage you made on step 1). You can use *Layout.convert\_to\_right\_comb* function to convert your parameters into the format expected by *Update\_operators* entry point.
<!-- prettier-ignore -->2- Complete the _ligo dry-run_ command for authorizing Bob to transfer tokens taken from Vera account, transaction emitted by Vera. (reuse the storage you made on step 1). You can use *Layout.convert\_to\_right\_comb* function to convert your parameters into the format expected by *Update\_operators* entry point. Don't forget to refer to fa2_interface to know the the expected type of *Update\_operators* entry point.

<!-- prettier-ignore -->3- Complete the _ligo dry-run_ command for simulating the transfer of 1 token from Vera'account to Alice's account, transaction emitted by Bob. The transferred token id is number 1 (token\_id and and amount must be 1). You can use the *Layout.convert\_to\_right\_comb* function to convert your parameters into the format expected by *Transfer* entry point.

Expand Down
Loading

0 comments on commit 935d32e

Please sign in to comment.