Coder Social home page Coder Social logo

cairo-bootcamp-23's People

Contributors

manoahlinks avatar sprtd avatar

Stargazers

 avatar  avatar

Watchers

 avatar

cairo-bootcamp-23's Issues

Issue in the transfer_from function in bwc_erc20_token contract

  1. The logic in the transfer_from function is flawed and was discovered while testing for edge cases using Starknet Foundry.
  2. In the function scope, the wrong arguments were passed into the spend_allowance token.

Initial Code for transfer_from function

fn transfer_from(
            ref self: ContractState,
            sender: ContractAddress,
            recipient: ContractAddress,
            amount: u256
        ) {
            let caller = get_caller_address();
            let my_allowance = self.allowances.read((sender, recipient));
            assert(my_allowance <= amount, 'Amount Not Allowed');
            self
                .spend_allowance(
                    sender, caller, amount
                ); //responsible for deduction of the amount allowed to spend
            self.transfer_helper(sender, recipient, amount);
        }

Suggested corrections

  1. The my_allowance variable should be gotten from (sender,caller) tuple instead of (sender, recipient).
  2. The logic symbol in the assert function should be changed to >= because we are supposed to ensure that the amount to be spent be less than the approved allowance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.