etherdelta / smart_contract

EtherDelta smart contract
212 stars 171 forks source link

Avoid using `call`? #2

Closed MeoMix closed 1 year ago

MeoMix commented 6 years ago

Hey,

Your smart contract generates a warning in Remix about using call here:

    function withdraw() {
        if (tokens[0][msg.sender] < amount) throw;
        tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount);
        if (!msg.sender.call.value(amount)()) throw;
        Withdraw(0, msg.sender, amount, tokens[0][msg.sender]);
    }

Shouldn't this have been written like:

    function withdraw() {
        if (tokens[0][msg.sender] < amount) throw;
        tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount);
        if (!msg.sender.send(amount)) throw;
        Withdraw(0, msg.sender, amount, tokens[0][msg.sender]);
    }

Thoughts?

MeoMix commented 6 years ago

Or perhaps using transfer if you have a need to modify the gas amount. See here: https://github.com/ethereum/solidity/issues/610

ghost commented 6 years ago

If we upgrade the contract, I would definitely update this.

Zack Coburn

NOTICE: This e-mail transmission (and/or the attachments accompanying it) may contain confidential information belonging to the sender which is protected by law. The information is intended only for the use of the intended recipient. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of this information is strictly prohibited. Any unauthorized interception of this transmission is illegal. If you have received this transmission in error, please promptly notify the sender by reply e-mail, and then destroy all copies of the transmission.

On Fri, Nov 17, 2017 at 8:08 PM, Sean Anderson notifications@github.com wrote:

Or perhaps using transfer if you have a need to modify the gas amount. See here: ethereum/solidity#610 https://github.com/ethereum/solidity/issues/610

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/etherdelta/smart_contract/issues/2#issuecomment-345352817, or mute the thread https://github.com/notifications/unsubscribe-auth/AQVtro3HPEBWKkHQ7f304fbIP7BrCzYMks5s3ee0gaJpZM4QijnG .