Skip to content

Commit 21a4bae

Browse files
committed
move _facetAddress to _DiamondProxy and reference in _getImplementation
1 parent abe4ff6 commit 21a4bae

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

contracts/proxy/diamond/_DiamondProxy.sol

+13-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,22 @@ abstract contract _DiamondProxy is _IDiamondProxy, _Proxy {
2525
override
2626
returns (address implementation)
2727
{
28-
implementation = address(
28+
implementation = _facetAddress(msg.sig);
29+
}
30+
31+
/**
32+
* @notice get the address of the facet associated with given selector
33+
* @param selector function selector to query
34+
* @return facet facet address (zero address if not found)
35+
*/
36+
function _facetAddress(
37+
bytes4 selector
38+
) internal view returns (address facet) {
39+
facet = address(
2940
bytes20(
3041
ERC2535Storage
3142
.layout(ERC2535Storage.DEFAULT_STORAGE_SLOT)
32-
.selectorInfo[msg.sig]
43+
.selectorInfo[selector]
3344
)
3445
);
3546
}

contracts/proxy/diamond/readable/_DiamondProxyReadable.sol

-17
Original file line numberDiff line numberDiff line change
@@ -200,21 +200,4 @@ abstract contract _DiamondProxyReadable is
200200
mstore(addresses, numFacets)
201201
}
202202
}
203-
204-
/**
205-
* @notice get the address of the facet associated with given selector
206-
* @param selector function selector to query
207-
* @return facet facet address (zero address if not found)
208-
*/
209-
function _facetAddress(
210-
bytes4 selector
211-
) internal view returns (address facet) {
212-
facet = address(
213-
bytes20(
214-
ERC2535Storage
215-
.layout(ERC2535Storage.DEFAULT_STORAGE_SLOT)
216-
.selectorInfo[selector]
217-
)
218-
);
219-
}
220203
}

0 commit comments

Comments
 (0)