Make TransparentUpgradeableProxy deploy its ProxyAdmin and optimize proxy interfaces (#4382)

Co-authored-by: Francisco <fg@frang.io>
Co-authored-by: Eric Lau <ericglau@outlook.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Ernesto García
2023-07-13 16:25:22 -06:00
committed by GitHub
parent 9cf873ea14
commit 121be5dd09
27 changed files with 521 additions and 356 deletions

View File

@ -5,13 +5,20 @@ const TransparentUpgradeableProxy = artifacts.require('TransparentUpgradeablePro
const ITransparentUpgradeableProxy = artifacts.require('ITransparentUpgradeableProxy');
contract('TransparentUpgradeableProxy', function (accounts) {
const [proxyAdminAddress, proxyAdminOwner] = accounts;
const [owner, ...otherAccounts] = accounts;
const createProxy = async function (logic, admin, initData, opts) {
const { address } = await TransparentUpgradeableProxy.new(logic, admin, initData, opts);
return ITransparentUpgradeableProxy.at(address);
// `undefined`, `null` and other false-ish opts will not be forwarded.
const createProxy = async function (logic, initData, opts = undefined) {
const { address, transactionHash } = await TransparentUpgradeableProxy.new(
logic,
owner,
initData,
...[opts].filter(Boolean),
);
const instance = await ITransparentUpgradeableProxy.at(address);
return { ...instance, transactionHash };
};
shouldBehaveLikeProxy(createProxy, proxyAdminAddress, proxyAdminOwner);
shouldBehaveLikeTransparentUpgradeableProxy(createProxy, accounts);
shouldBehaveLikeProxy(createProxy, otherAccounts);
shouldBehaveLikeTransparentUpgradeableProxy(createProxy, owner, otherAccounts);
});