foundry icon indicating copy to clipboard operation
foundry copied to clipboard

called `Option::unwrap()` on a `None` value

Open az0mb13 opened this issue 3 years ago • 2 comments

Component

Forge

Have you ensured that all of these are up to date?

  • [x] Foundry
  • [x] Foundryup

What version of Foundry are you on?

forge 0.2.0 (92f8951 2022-08-07T00:04:11.211707059Z)

What command(s) is the bug in?

forge script

Operating System

Linux

Describe the bug

Getting an error when trying to run a script using the following command -

forge script ./script/script.sol --private-key $PKEY --broadcast -vvvv

image

az0mb13 avatar Aug 09 '22 18:08 az0mb13

Can you share the script so we can reproduce this?

gakonst avatar Aug 09 '22 19:08 gakonst

this is an unsafe unwrap for eth_rpc_url (--rpc-url)

https://github.com/foundry-rs/foundry/blob/f77e3175701fae4dc345bf8e3894615725343d4d/cli/src/cmd/forge/script/broadcast.rs#L229

this should be handled more gracefully here

mattsse avatar Aug 09 '22 19:08 mattsse

@gakonst This was the script -

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import "forge-std/Script.sol";
import "../instances/Ilevel01.sol";

contract POC is Script {
    Fallback level1 = Fallback(0x1C7c3eDbd6567b4ecf97869CD9Dfad27b08CD697);

    function run() external {
        vm.startBroadcast();

        level1.contribute{value: 1 wei}();
        level1.getContribution();
        address(level1).call{value: 1 wei}("");
        vm.stopBroadcast();
    }
}

I was just trying to solve Ethernaut's Fallback - https://ethernaut.openzeppelin.com/level/0x9CB391dbcD447E645D6Cb55dE6ca23164130D008

It worked when I supplied --rpc-url. I thought it would take it from the foundry.toml file.

az0mb13 avatar Aug 10 '22 15:08 az0mb13