Update docs

This commit is contained in:
github-actions
2023-05-09 19:56:30 +00:00
parent 47e38c7bda
commit 6ae39c4dc1
579 changed files with 30453 additions and 21485 deletions

View File

@ -3,8 +3,8 @@ const { ZERO_ADDRESS } = constants;
const { getSlot, ImplementationSlot, AdminSlot } = require('../../helpers/erc1967');
const { expect } = require('chai');
const { web3 } = require('hardhat');
const Proxy = artifacts.require('Proxy');
const Implementation1 = artifacts.require('Implementation1');
const Implementation2 = artifacts.require('Implementation2');
const Implementation3 = artifacts.require('Implementation3');
@ -16,7 +16,7 @@ const InitializableMock = artifacts.require('InitializableMock');
const DummyImplementation = artifacts.require('DummyImplementation');
const ClashingImplementation = artifacts.require('ClashingImplementation');
module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createProxy, accounts) {
module.exports = function shouldBehaveLikeTransparentUpgradeableProxy(createProxy, accounts) {
const [proxyAdminAddress, proxyAdminOwner, anotherAccount] = accounts;
before(async function () {
@ -60,12 +60,9 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
});
it('emits an event', async function () {
expectEvent(
await this.proxy.upgradeTo(this.implementationV1, { from }),
'Upgraded', {
implementation: this.implementationV1,
},
);
expectEvent(await this.proxy.upgradeTo(this.implementationV1, { from }), 'Upgraded', {
implementation: this.implementationV1,
});
});
});
@ -83,9 +80,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
const from = anotherAccount;
it('reverts', async function () {
await expectRevert.unspecified(
this.proxy.upgradeTo(this.implementationV1, { from }),
);
await expectRevert.unspecified(this.proxy.upgradeTo(this.implementationV1, { from }));
});
});
});
@ -127,13 +122,11 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
expect(balance.toString()).to.be.bignumber.equal(value.toString());
});
it.skip('uses the storage of the proxy', async function () {
it('uses the storage of the proxy', async function () {
// storage layout should look as follows:
// - 0: Initializable storage
// - 1-50: Initailizable reserved storage (50 slots)
// - 51: initializerRan
// - 52: x
const storedValue = await Proxy.at(this.proxyAddress).getStorageAt(52);
// - 0: Initializable storage ++ initializerRan ++ onlyInitializingRan
// - 1: x
const storedValue = await web3.eth.getStorageAt(this.proxyAddress, 1);
expect(parseInt(storedValue)).to.eq(42);
});
});
@ -178,7 +171,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
expectEvent(this.receipt, 'Upgraded', { implementation: this.behaviorV1.address });
});
it('calls the \'initialize\' function and sends given value to the proxy', async function () {
it("calls the 'initialize' function and sends given value to the proxy", async function () {
const migratable = new MigratableMockV1(this.proxyAddress);
const x = await migratable.x();
@ -194,8 +187,10 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
beforeEach(async function () {
this.behaviorV2 = await MigratableMockV2.new();
this.balancePreviousV2 = new BN(await web3.eth.getBalance(this.proxyAddress));
this.receipt =
await this.proxy.upgradeToAndCall(this.behaviorV2.address, v2MigrationData, { from, value });
this.receipt = await this.proxy.upgradeToAndCall(this.behaviorV2.address, v2MigrationData, {
from,
value,
});
});
it('upgrades to the requested version and emits an event', async function () {
@ -204,7 +199,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
expectEvent(this.receipt, 'Upgraded', { implementation: this.behaviorV2.address });
});
it('calls the \'migrate\' function and sends given value to the proxy', async function () {
it("calls the 'migrate' function and sends given value to the proxy", async function () {
const migratable = new MigratableMockV2(this.proxyAddress);
const x = await migratable.x();
@ -223,8 +218,10 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
beforeEach(async function () {
this.behaviorV3 = await MigratableMockV3.new();
this.balancePreviousV3 = new BN(await web3.eth.getBalance(this.proxyAddress));
this.receipt =
await this.proxy.upgradeToAndCall(this.behaviorV3.address, v3MigrationData, { from, value });
this.receipt = await this.proxy.upgradeToAndCall(this.behaviorV3.address, v3MigrationData, {
from,
value,
});
});
it('upgrades to the requested version and emits an event', async function () {
@ -233,7 +230,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
expectEvent(this.receipt, 'Upgraded', { implementation: this.behaviorV3.address });
});
it('calls the \'migrate\' function and sends given value to the proxy', async function () {
it("calls the 'migrate' function and sends given value to the proxy", async function () {
const migratable = new MigratableMockV3(this.proxyAddress);
const x = await migratable.x();
@ -256,9 +253,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
it('reverts', async function () {
const behaviorV1 = await MigratableMockV1.new();
const v1MigrationData = new MigratableMockV1('').contract.methods.initialize(42).encodeABI();
await expectRevert.unspecified(
this.proxy.upgradeToAndCall(behaviorV1.address, v1MigrationData, { from }),
);
await expectRevert.unspecified(this.proxy.upgradeToAndCall(behaviorV1.address, v1MigrationData, { from }));
});
});
});
@ -428,9 +423,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
await proxy.upgradeTo(instance2.address, { from: proxyAdminAddress });
const data = '0x';
await expectRevert.unspecified(
web3.eth.sendTransaction({ to: proxy.address, from: anotherAccount, data }),
);
await expectRevert.unspecified(web3.eth.sendTransaction({ to: proxy.address, from: anotherAccount, data }));
const proxyInstance2 = new Implementation2(proxy.address);
const res = await proxyInstance2.getValue();