Skip to content

Commit

Permalink
chore: sync with osx-plugin-template-hardhat and osx-commons (#13)
Browse files Browse the repository at this point in the history
* feat: change the manifest data json struct

* feat: change the script to get the correct params from the manifest data

* featL change to ens name

* feat: remove the ens domain due to it is not used

* feat: update deploy script to get the correct repo address

* feat: added IAction to template

* feat: bump matchstick version

* fix: remove deprecated networks

* fix: update the repository in the placeholder

* fix: local deploy script problem with `generateRandomName`  (aragon#53)

* fix: error on local deployment

* refactor: move generateName to avoid circular dependency

* refactor: metadata encoding

* refactor: split upgrade repo script into two (aragon#60)

* refactor: renamed file

* refactor: extract skip function

* refactor: renaming and commenting

* style: satisfy linter

* chore: maintained guide

* refactor: don't alias

* fix: wrong import

* fix: change the execution order so that reinitialization happens by default

* refactor: common steps

* doc: subgraph description

* fix: remove IAction

* refactor: remove IAction (aragon#61)

* f: removed IAction from template as is opinonated solution

* style: add empty line at EOF

---------

Co-authored-by: Michael Heuer <[email protected]>

* chore: refactor helpers (aragon#57)

* refactor: delete hashHelpers

* style: fix linter

* fix: import

* build: bump OZ dependency

* chore: bump osx-commons-sdk dependency

* chore: bumped commons-contracts

* chore: maintained changelog

* chore: bump osx-commons-sdk version (aragon#62)

* chore: author change after AA dissolution

* chore: sync with `osx-commons` (aragon#63)

* chore: bump osx-commons-sdk version

* chore: bump osx-commons

* fix: yarn lock

---------

Co-authored-by: Claudia <[email protected]>
Co-authored-by: jordaniza <[email protected]>
Co-authored-by: Jordan <[email protected]>
  • Loading branch information
4 people authored Apr 23, 2024
1 parent 003ca4e commit 21c6d76
Show file tree
Hide file tree
Showing 19 changed files with 311 additions and 554 deletions.
1 change: 1 addition & 0 deletions packages/contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ and this project adheres to the [Aragon OSx Plugin Versioning Convention](https:

### Changed

- Bumped OpenZepplin to `4.9.6`.
- Used `ProxyLib` from `osx-commons-contracts` for the minimal proxy deployment in `AdminSetup`.
- Hard-coded the `bytes32 internal constant EXECUTE_PERMISSION_ID` constant in `AdminSetup` until it is available in `PermissionLib`.
5 changes: 5 additions & 0 deletions packages/contracts/deploy/00_info/01_info.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {PLUGIN_REPO_ENS_SUBDOMAIN_NAME} from '../../plugin-settings';
import {
AragonOSxAsciiArt,
getProductionNetworkName,
Expand Down Expand Up @@ -52,6 +53,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await deployer.getBalance()
)} native tokens.`
);

console.log(
`Chosen PluginRepo ENS subdomain name: '${PLUGIN_REPO_ENS_SUBDOMAIN_NAME}'`
);
};

export default func;
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/deploy/10_create_repo/11_create_repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

// Get the PluginRepo address and deployment block number from the txn and event therein
const eventLog =
await findEventTopicLog<PluginRepoRegistryEvents.PluginRepoRegisteredEvent>(
tx,
findEventTopicLog<PluginRepoRegistryEvents.PluginRepoRegisteredEvent>(
await tx.wait(),
PluginRepoRegistry__factory.createInterface(),
'PluginRepoRegistered'
);
Expand Down
19 changes: 10 additions & 9 deletions packages/contracts/deploy/20_new_version/23_publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ import {
isLocal,
pluginEnsDomain,
} from '../../utils/helpers';
import {
PLUGIN_REPO_PERMISSIONS,
toHex,
uploadToIPFS,
} from '@aragon/osx-commons-sdk';
import {PLUGIN_REPO_PERMISSIONS, uploadToIPFS} from '@aragon/osx-commons-sdk';
import {writeFile} from 'fs/promises';
import {ethers} from 'hardhat';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import path from 'path';
Expand Down Expand Up @@ -114,8 +111,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
.createVersion(
VERSION.release,
setup.address,
toHex(buildMetadataURI),
toHex(releaseMetadataURI)
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(buildMetadataURI)),
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(releaseMetadataURI))
);

await tx.wait();
Expand Down Expand Up @@ -145,8 +142,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
createVersion: {
_release: VERSION.release,
_pluginSetup: setup.address,
_buildMetadata: toHex(buildMetadataURI),
_releaseMetadata: toHex(releaseMetadataURI),
_buildMetadata: ethers.utils.hexlify(
ethers.utils.toUtf8Bytes(buildMetadataURI)
),
_releaseMetadata: ethers.utils.hexlify(
ethers.utils.toUtf8Bytes(releaseMetadataURI)
),
},
},
],
Expand Down
213 changes: 0 additions & 213 deletions packages/contracts/deploy/30_upgrade_repo/31_upgrade_repo.ts

This file was deleted.

36 changes: 36 additions & 0 deletions packages/contracts/deploy/30_upgrade_repo/31a_upgrade_repo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {fetchData, skipUpgrade} from './_common';
import {PLUGIN_REPO_PERMISSIONS} from '@aragon/osx-commons-sdk';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

/**
* Upgrades the plugin repo to the latest implementation.
* This script CAN be called if the contract does not require reinitialization.
* It MUST NOY be called if the contract requires reinitialization, because this
* would leave the proxy unreinitialized.
* @param {HardhatRuntimeEnvironment} hre
*/
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployer, pluginRepo, latestPluginRepoImplementation} =
await fetchData(hre);

// Check if deployer has the permission to upgrade the plugin repo
if (
await pluginRepo.isGranted(
pluginRepo.address,
deployer.address,
PLUGIN_REPO_PERMISSIONS.UPGRADE_REPO_PERMISSION_ID,
[]
)
) {
await pluginRepo.upgradeTo(latestPluginRepoImplementation.address);
} else {
throw Error(
`The new version cannot be published because the deployer ('${deployer.address}')
is lacking the ${PLUGIN_REPO_PERMISSIONS.UPGRADE_REPO_PERMISSION_ID} permission.`
);
}
};
export default func;
func.tags = ['UpgradeRepo'];
func.skip = skipUpgrade;
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {fetchData, skipUpgrade} from './_common';
import {PLUGIN_REPO_PERMISSIONS} from '@aragon/osx-commons-sdk';
import {BytesLike} from 'ethers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

/**
* Upgrades the plugin repo to the latest implementation and reinitializes the proxy.
* This script MUST be called if the contract requires reinitialization -- otherwise
* the proxy is left unreinitialized.
* @param {HardhatRuntimeEnvironment} hre
*/
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployer, pluginRepo, latestPluginRepoImplementation, current} =
await fetchData(hre);

// Define the `_initData` arguments
const initData: BytesLike[] = [];

// Encode the call to `function initializeFrom(uint8[3] calldata _previousProtocolVersion, bytes calldata _initData)` with `initData`.
const initializeFromCalldata =
latestPluginRepoImplementation.interface.encodeFunctionData(
// Re-initialization will happen through a call to `function initializeFrom(uint8[3] calldata _previousProtocolVersion, bytes calldata _initData)`
// that Aragon will add to the `PluginRepo` contract once it's required.
'initializeFrom',
[current, initData]
);

// Check if deployer has the permission to upgrade the plugin repo
if (
await pluginRepo.isGranted(
pluginRepo.address,
deployer.address,
PLUGIN_REPO_PERMISSIONS.UPGRADE_REPO_PERMISSION_ID,
[]
)
) {
// Use `upgradeToAndCall` to reinitialize the new `PluginRepo` implementation after the update.
if (initializeFromCalldata.length > 0) {
await pluginRepo.upgradeToAndCall(
latestPluginRepoImplementation.address,
initializeFromCalldata
);
} else {
throw Error(
`Initialization data is missing for 'upgradeToAndCall'. Stopping repo upgrade and reinitialization...`
);
}
} else {
throw Error(
`The new version cannot be published because the deployer ('${deployer.address}')
is lacking the ${PLUGIN_REPO_PERMISSIONS.UPGRADE_REPO_PERMISSION_ID} permission.`
);
}
};
export default func;
func.tags = ['UpgradeAndReinitializeRepo'];
func.skip = skipUpgrade;
Loading

0 comments on commit 21c6d76

Please sign in to comment.