Browse Source

adapted subjects to recent test changes

DEV-4397-piscine-ai-missing-file-for-ex-7-of-nlp
xalava 1 year ago committed by Dav Hojt
parent
commit
a4c3f8db8a
  1. 6
      subjects/blockchain/basic-swap/README.md
  2. 12
      subjects/blockchain/eventful-token/README.md
  3. 0
      subjects/blockchain/line-up/README.md
  4. 6
      subjects/blockchain/local-node/README.md
  5. 1
      subjects/blockchain/named-festival/README.md
  6. 8
      subjects/blockchain/read-secret/README.md
  7. 2
      subjects/blockchain/register-with-events/README.md
  8. 8
      subjects/blockchain/transfers-history/README.md

6
subjects/blockchain/basic-swap/README.md

@ -4,13 +4,13 @@ We will create a basic swap smart contract that will allow two users, Alice and
### Instructions
- Create a `usableToken` contract as defined before
- Create a `UsableToken` contract as defined before
- Create a Smart Contract `BasicSwap` with a constructor that takes the address of two Externally Owned Accounts.
- Create a function `swap(tokenA, AmountA, TokenB, AmountB)` that takes as parameters, two `MinimalTokenAllowance`contracts and amounts
- Create a function `swap(tokenA, AmountA, TokenB, AmountB)` that takes as parameters, two `UsableToken`contracts and amounts
- The function checks that users gave the corresponding allowances to the smart contract
- The function proceed to transfert the first amount in TokenA from Alice to Bob and the second amount from Bob to Alice
To test your smart contract, you will need to deploy two instances of `MinimalTokenAllowance`
To test your smart contract, you will need to deploy two instances of `UsableToken`
### Resources

12
subjects/blockchain/eventful-token/README.md

@ -2,10 +2,14 @@
### Instructions
- Create a Smart Conctract named `eventfulToken`
- Like MinimalToken, its constructor takes as parameter an amount that is given initially to the deployer.
- Create an event `Transfer(address, address, uint)` that returns the address from which the funds where transferred (the variable should be called `sender`), the address of the `recipient` and the `amount` of the transfer. Trigger the event within the transfer function
- Create an event `Minting(address, amount)` that returns the `address` `recipient` to which token were minted and the `amount` of tokens created. Trigger the event when appropriate.
- Create a Smart Conctract named `EventfulToken`
- Like MinimalToken, its constructor takes as parameter an amount that is given initially to the deployer.
- Create an event `Transfer(address indexed , address indexed, uint)` that returns the address from which the funds where transferred (the variable should be called `sender`), the address of the `recipient` and the `amount` of the transfer. Trigger the event within the transfer function. N
- Create an event `Minting(address, amount)` that returns the `address` `recipient` to which token were minted and the `amount` of tokens created. Trigger the event when appropriate.
### Hint
The `indexed` keyword will facilitate the filtering by this field of the event in later exercises.
### Notions

0
subjects/blockchain/lineup/README.md → subjects/blockchain/line-up/README.md

6
subjects/blockchain/local-node/README.md

@ -15,14 +15,14 @@ Launch a local test node. You can use any client (geth, openEthereum...), but I
**hardhat node**
```sh
```shell
npm i hardhat
npx hardhat node
```
**ganache**
```
```shell
npm i ganache-cli
npx ganache-cli
```
@ -31,6 +31,8 @@ npx ganache-cli
Noticeably, local javascript nodes are not connected to any network and provide already 10 account populated with test ether.
This quest self validate with an empty "local-node.js" file
### Notions
- [hardhat](https://hardhat.org)

1
subjects/blockchain/named-festival/README.md

@ -19,6 +19,7 @@ pragma solidity ^0.8.4;
```
- Then create a Smart Contract named `NamedFestival`.
- NB: The file name of the contract must be in kebab-case `named-festival.sol`, while contracts names are in PascalCase by convention
- Create a public function `setName()` that takes a string as parameter and sets the name of the festival
- Finally a function `getName()` takes no parameters and retrieves the name

8
subjects/blockchain/read-secret/README.md

@ -2,9 +2,9 @@
### Instructions
Create a web page, `readSecret.html` that loads an ethereum library, connects to ethereum testnet `kovan` and displays a secret contained in a smart contract.
Create a web page, `read-secret.html` that loads an ethereum library, connects to ethereum testnet `Sepolia` and displays a secret contained in a smart contract.
The smart contract is available at the address `0x27c8dda37a22a29cb78320bf5e1c81ca087b2f8e` on Kovan testnet. It contains one function `getSecret()` that returns a string.
The smart contract is available at the address `0x467782A5ab90af6baA6f8af0b4E69A7Ddb197fF0` on Sepolia testnet. It contains one function `getSecret()` that returns a string.
You might use the following interface :
@ -12,6 +12,10 @@ You might use the following interface :
const abi = ["function getSecret() view returns (string)"];
```
As the test does not reach the internet:
- Store in a hardcoded manner the result in an element with `storedSecret` as id.
- Detect when internet is not available and skip the connection to the provider.
### Notions
- [ethers contract](https://docs.ethers.io/v5/api/contract/contract/)

2
subjects/blockchain/register-with-events/README.md

@ -11,6 +11,8 @@ Write solidity smart contract `RegisterWithEvents` that provides:
- The functions `addDocument()` and `getDate()` as specified in the prior exercise.
- An event `event DocumentAdded(bytes32, uint)` that triggers when a new document is added to the register
As in prior exercises, the file must be named register-with-events.sol while the contract is named RegisterWithEvents.
### Notions
- [Events](https://docs.soliditylang.org/en/v0.8.4/contracts.html#events)

8
subjects/blockchain/transfers-history/README.md

@ -2,23 +2,23 @@
### Instructions
- Create a JavaScript file `transfersHistory.js`that exports the function `transfersHistory(address, address)` that takes as parameters the address of a MinimalTokenEvent Smart Contract instance and the address of an user.
- Create a JavaScript file `transfersHistory.js`that exports the function `transfersHistory(address, address)` that takes as parameters the address of a `EventfulToken` Smart Contract instance and the address of an user.
It returns an array with all the transfers from that account, starting from the most recent, positive if it is toward the user, and negative if it is outside.
The function will connect to a local node and retrieve the events. It returns an array with all the transfers from that account, starting from the most recent, positive if it is toward the user, and negative if it is outside.
#### Structure
```js
const { ethers } = require("ethers");
async function transfersHistory(contractAddress, userAddress) {}
async function transfersHistory(contractAddress, userAddress) {...}
exports.transfersHistory = transfersHistory;
```
#### Usage
```js
const { transfersHistory } = require("./transfersHistory.sl.js");
const { transfersHistory } = require("./transfersHistory.js");
transfersHistory(
"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc",

Loading…
Cancel
Save