01-edu / public

šŸ“š @01-edu's Public Repository
http://public.01-edu.org/
214 stars 440 forks source link

usable-token subject #2413

Closed MalekLahbib closed 7 months ago

MalekLahbib commented 7 months ago

usable-token

Hello, for this exercise I have this error msg: Compiled 1 Solidity file successfully (evm target: london).

Usable token (Allowances) 1) Deploy account should have 200 units āœ” Too large transaction should fail 2) Transfer should change balances 3) Owner can approve and allowance corresponds 4) Too large transferFrom should fail

1 passing (1s) 4 failing

1) Usable token (Allowances) Deploy account should have 200 units : TypeError: minito.accounts is not a function at Context. (test/usable-token.test.js:13:25)

2) Usable token (Allowances) Transfer should change balances: TypeError: minito.accounts is not a function at Context. (test/usable-token.test.js:21:25) at processTicksAndRejections (node:internal/process/task_queues:95:5) at runNextTicks (node:internal/process/task_queues:64:3) at listOnTimeout (node:internal/timers:538:9) at processTimers (node:internal/timers:512:7)

3) Usable token (Allowances) Owner can approve and allowance corresponds: Error: VM Exception while processing transaction: reverted with reason string 'Only the owner can call this function' at UsableToken.onlyOwner (contracts/usable-token.sol:25) at UsableToken.approve (contracts/usable-token.sol:29) at processTicksAndRejections (node:internal/process/task_queues:95:5) at runNextTicks (node:internal/process/task_queues:64:3) at listOnTimeout (node:internal/timers:538:9) at processTimers (node:internal/timers:512:7) at HardhatNode._mineBlockWithPendingTxs (/app/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1866:23) at HardhatNode.mineBlock (/app/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:524:16) at EthModule._sendTransactionAndReturnHash (/app/node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:1482:18)

4) Usable token (Allowances) Too large transferFrom should fail: Error: VM Exception while processing transaction: reverted with reason string 'Only the owner can call this function' at UsableToken.onlyOwner (contracts/usable-token.sol:25) at UsableToken.approve (contracts/usable-token.sol:29) at processTicksAndRejections (node:internal/process/task_queues:95:5) at runNextTicks (node:internal/process/task_queues:64:3) at listOnTimeout (node:internal/timers:538:9) at processTimers (node:internal/timers:512:7) at HardhatNode._mineBlockWithPendingTxs (/app/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1866:23) at HardhatNode.mineBlock (/app/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:524:16) at EthModule._sendTransactionAndReturnHash (/app/node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:1482:18)

It's talking about an accounts function, but no one asked to create such a function, are the instructions and the test correspondent?

MalekLahbib commented 7 months ago

it's asked that the function allowance(address,uint) takes an address and uint, is It correct?

nprimo commented 7 months ago

Hi @MalekLahbib, the instructions for this exercise can be improved. Besides the required functions, the contract needs to have two public states: accounts and allowance. I imagine your solution doesn't have accounts state or the state is defined but it's not public

I will open a PR to clarify the subject.