You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
文中的代码没有演示清楚。假设应该是admin调用了proxy的和logic 相同的selector时,proxy能区分开来,并且争取调用。而不是单单报错。
代码应该给下面的demo
`
/**
* @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.
*/
function _fallback() internal virtual override {
if (msg.sender == _proxyAdmin()) {
if (msg.sig != ITransparentUpgradeableProxy.upgradeToAndCall.selector) {
revert ProxyDeniedAdminAccess();
} else {
_dispatchUpgradeToAndCall();
}
} else {
super._fallback();
}
}
/**
* @dev Upgrade the implementation of the proxy. See {ERC1967Utils-upgradeToAndCall}.
*
* Requirements:
*
* - If `data` is empty, `msg.value` must be zero.
*/
function _dispatchUpgradeToAndCall() private {
(address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));
ERC1967Utils.upgradeToAndCall(newImplementation, data);
}
`
The text was updated successfully, but these errors were encountered:
Proxy Contract和Implementation Contract有一个名称和参数相同的函数。想象一下,如果Proxy Contract有一个owner()函数,Implementation Contract也有。在透明代理合约中,这个问题由Proxy Contract来处理,Proxy Contract根据msg.sender全局变量来决定用户的调用是在Proxy Contract本身还是在Implementation Contract中执行。
文中的代码没有演示清楚。假设应该是admin调用了proxy的和logic 相同的selector时,proxy能区分开来,并且争取调用。而不是单单报错。
代码应该给下面的demo
`
/**
* @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.
*/
function _fallback() internal virtual override {
if (msg.sender == _proxyAdmin()) {
if (msg.sig != ITransparentUpgradeableProxy.upgradeToAndCall.selector) {
revert ProxyDeniedAdminAccess();
} else {
_dispatchUpgradeToAndCall();
}
} else {
super._fallback();
}
}
`
The text was updated successfully, but these errors were encountered: