mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Support gas modifier on addr.transfer()
This commit is contained in:
parent
ba437ef31a
commit
81006dae98
@ -2315,9 +2315,10 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
|
|||||||
case Location::Bare:
|
case Location::Bare:
|
||||||
case Location::BareCallCode:
|
case Location::BareCallCode:
|
||||||
case Location::BareDelegateCall:
|
case Location::BareDelegateCall:
|
||||||
|
case Location::Transfer:
|
||||||
{
|
{
|
||||||
MemberList::MemberMap members;
|
MemberList::MemberMap members;
|
||||||
if (m_location != Location::BareDelegateCall && m_location != Location::DelegateCall)
|
if (m_location != Location::BareDelegateCall && m_location != Location::DelegateCall && m_location != Location::Transfer)
|
||||||
{
|
{
|
||||||
if (m_isPayable)
|
if (m_isPayable)
|
||||||
members.push_back(MemberList::Member(
|
members.push_back(MemberList::Member(
|
||||||
|
@ -620,7 +620,8 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
|||||||
_functionCall.expression().accept(*this);
|
_functionCall.expression().accept(*this);
|
||||||
// Provide the gas stipend manually at first because we may send zero ether.
|
// Provide the gas stipend manually at first because we may send zero ether.
|
||||||
// Will be zeroed if we send more than zero ether.
|
// Will be zeroed if we send more than zero ether.
|
||||||
m_context << u256(eth::GasCosts::callStipend);
|
if (!function.gasSet())
|
||||||
|
m_context << u256(eth::GasCosts::callStipend);
|
||||||
arguments.front()->accept(*this);
|
arguments.front()->accept(*this);
|
||||||
utils().convertType(
|
utils().convertType(
|
||||||
*arguments.front()->annotation().type,
|
*arguments.front()->annotation().type,
|
||||||
|
@ -1693,6 +1693,10 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
|
|||||||
function b(address addr, uint amount) {
|
function b(address addr, uint amount) {
|
||||||
addr.transfer(amount);
|
addr.transfer(amount);
|
||||||
}
|
}
|
||||||
|
function c(address addr, uint amount, uint gas) returns (uint) {
|
||||||
|
addr.transfer.gas(gas)(amount);
|
||||||
|
return this.balance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract B {
|
contract B {
|
||||||
@ -1715,6 +1719,8 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
|
|||||||
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
|
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
|
||||||
BOOST_CHECK(callContractFunction("b(address,uint256)", nonPayableRecipient, 10) == encodeArgs());
|
BOOST_CHECK(callContractFunction("b(address,uint256)", nonPayableRecipient, 10) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("b(address,uint256)", oogRecipient, 10) == encodeArgs());
|
BOOST_CHECK(callContractFunction("b(address,uint256)", oogRecipient, 10) == encodeArgs());
|
||||||
|
BOOST_CHECK(callContractFunction("c(address,uint256,uint256)", payableRecipient, 1, 9000) == encodeArgs(9));
|
||||||
|
BOOST_CHECK(callContractFunction("c(address,uint256,uint256)", payableRecipient, 1, 0) == encodeArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(log0)
|
BOOST_AUTO_TEST_CASE(log0)
|
||||||
|
Loading…
Reference in New Issue
Block a user