Skip to content

Commit

Permalink
chore: sync with osx-plugin-template-hardhat and osx-commons (#21)
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

* fix: remove duplicated 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 <20623991+Michael-A-Heuer@users.noreply.github.com>

* 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

* style: formatting

* chore: add missing changelog

* revert: file renaming

* 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

* Update packages/contracts/deploy/30_upgrade_repo/31a_upgrade_repo.ts

---------

Co-authored-by: Claudia <claudiabarcelovaldes40@gmail.com>
Co-authored-by: jordaniza <jordan.imran@predixa.ai>
Co-authored-by: Jordan <45881807+jordaniza@users.noreply.github.com>
  • Loading branch information
4 people committed Apr 23, 2024
1 parent 07b7dab commit 64bc612
Show file tree
Hide file tree
Showing 30 changed files with 390 additions and 576 deletions.
4 changes: 3 additions & 1 deletion USAGE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ The standard deploy scripts in the `packages/contracts/deploy` should already be
- Fetches the plugin setup and implementation contract and queues it for block explorer verification.
- `20_new_version/23_publish.ts`
- Publishes the plugin setup contract on the plugin repo created in `10_repo/11_create_repo.ts`
- `30_upgrade_repo/31_upgrade_repo.ts`
- `30_upgrade_repo/31a_upgrade_and_reinitialize_repo.ts`
- Upgrades the plugin repo to the latest Aragon OSx protocol version and reinitializes it.
- `30_upgrade_repo/31b_upgrade_repo.ts`
- Upgrades the plugin repo to the latest Aragon OSx protocol version.
- `40_conclude/41_conclude.ts`
- Prints information on the used account's balance after deployment.
Expand Down
18 changes: 18 additions & 0 deletions packages/contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# TokenVoting Plugin

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to the [Aragon OSx Plugin Versioning Convention](https://devs.aragon.org/docs/osx/how-to-guides/plugin-development/publication/versioning).

## v1.3

### Added

- Copied files from [aragon/osx commit 1130df](https://github.com/aragon/osx/commit/1130dfce94fd294c4341e91a8f3faccc54cf43b7)

### Changed

- Bumped OpenZepplin to `4.9.6`.
- Used `ProxyLib` from `osx-commons-contracts` for the UUPS proxy deployment in `TokenVotingSetup`.
- Hard-coded the `bytes32 internal constant EXECUTE_PERMISSION_ID` constant in `TokenVotingSetup` 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
11 changes: 4 additions & 7 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
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 NOT 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 64bc612

Please sign in to comment.