2

Somebody please help me find the correct pattern to make this solidity error disappear, I'm using specifically solc^0.8.0, here is my code snippet :

function fundAirline() 
    isAirlineRegistered(msg.sender) 
    requireIsOperational
    paidEnough(FUNDING_REQUIRED) 
    checkValue(FUNDING_REQUIRED) external payable {
flightSurety.fundAirline.value(msg.value)(msg.sender); // the problem is in this line
emit AirlineFunded(flightSurety.getAirlineName(msg.sender), msg.sender); 

}

The problem is in the line : flightSurety.fundAirline.value(msg.value)(msg.sender); it raise the following complaining :

Using ".value(...)" is deprecated. Use "{value: ...}" instead.

Thank you.

Yaa_seen
  • 49
  • 5

1 Answers1

3

I had faced this on invoking call and had found from Solidity docs that gas and value parameters need to be passed in curly brackets now:

address(nameReg).call{gas: 1000000, value: 1 ether}(abi.encodeWithSignature("register(string)", "MyName"));

Here's the code snippet reflecting the issue I faced with the fix.

CODE WITH SIMILAR PROBLEM:

(bool success, ) = payable(msg.sender).call.value(withdrawalAmt)('');

FIX:

(bool success, ) = payable(msg.sender).call{ value: withdrawalAmt }('');

Though you are NOT using call, the base principle remains the same as you are invoking a contract function and so, applying above fix to your issue:

CODE WITH PROBLEM:

flightSurety.fundAirline.value(msg.value)(msg.sender);

PROPOSED FIX*****

flightSurety.fundAirline{ value: msg.value }(msg.sender);

Also came across this on ESE, it provides relevant clarity: Ethereum.StackExchange - Calling a payable function in another contract with value and arguments

Hope this helps.