-
Notifications
You must be signed in to change notification settings - Fork 51
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
透明代理-解决的问题没有讲清楚 #116
Comments
好建议 你可以提个pr到 https://github.com/AmazingAng/WTF-Solidity 吗? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: