Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add receive function to Proxy #287

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contracts/proxy/IProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ import { _IProxy } from './_IProxy.sol';

interface IProxy is _IProxy {
fallback() external payable;

receive() external payable;
}
4 changes: 4 additions & 0 deletions contracts/proxy/Proxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ abstract contract Proxy is IProxy, _Proxy {
fallback() external payable {
_fallback();
}

receive() external payable {
_receive();
}
}
7 changes: 7 additions & 0 deletions contracts/proxy/_Proxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,11 @@ abstract contract _Proxy is _IProxy {

revert Proxy__ImplementationIsNotContract();
}

/**
* @notice received ether is forwarded to the fallback function
*/
function _receive() internal virtual {
_fallback();
}
}
4 changes: 1 addition & 3 deletions contracts/proxy/diamond/ISolidstateDiamondProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ interface ISolidstateDiamondProxy is
IDiamondProxyReadable,
IDiamondProxyWritable,
ISafeOwnable
{
receive() external payable;
}
{}
2 changes: 0 additions & 2 deletions contracts/proxy/diamond/SolidstateDiamondProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ abstract contract SolidstateDiamondProxy is
_setOwner(msg.sender);
}

receive() external payable {}

function _transferOwnership(
address account
)
Expand Down
4 changes: 4 additions & 0 deletions spec/proxy/Proxy.behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ export function describeBehaviorOfProxy(
).not.to.be.reverted;
});
});

describe('receive()', () => {
it('forwards value to implementation');
});
});
}
4 changes: 4 additions & 0 deletions spec/proxy/diamond/DiamondProxy.behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,9 @@ export function describeBehaviorOfDiamondProxy(
});
});
});

describe('receive()', () => {
it('todo');
});
});
}
4 changes: 4 additions & 0 deletions spec/proxy/diamond/fallback/DiamondProxyFallback.behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export function describeBehaviorOfDiamondProxyFallback(
it('forwards data without matching selector to fallback contract');
});

describe('receive()', () => {
it('forwards value to fallback contract');
});

describe('#getFallbackAddress()', () => {
it('returns the fallback address', async () => {
expect(await instance.getFallbackAddress.staticCall()).to.equal(
Expand Down