Skip to content

Commit

Permalink
Merge pull request #12 from aragon/f/plugin-metadata-cleanup
Browse files Browse the repository at this point in the history
Plugin metadata cleanup
  • Loading branch information
brickpop authored Jun 3, 2024
2 parents 44666ad + 369eb18 commit 14f53d6
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 843 deletions.
37 changes: 0 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,35 +632,6 @@ function encodeUninstallationParams(
) public pure returns (bytes memory)
```

The JSON encoded ABI definition can also be found at the corresponding `src/<folder>/<name>-build-metadata.json` file:

```json
{
// ...
"pluginSetup": {
"prepareInstallation": {
// ...
"inputs": [
{
"name": "firstBlockContentUri",
"type": "string",
"internalType": "string",
"description": "The inital contents of the first block item."
},
{
"internalType": "address",
"name": "predecessorAddress",
"type": "address"
},
{
"internalType": "address",
"name": "pluginUpgrader",
"type": "address"
}
]
},
```

The same also applies to `prepareUpdate` (if present) and to `prepareUninstallation`.

### Available setup contracts
Expand Down Expand Up @@ -701,14 +672,6 @@ In the example, the code is making use of the existing JS client for [Aragon's T
- The deployments made will populate data to the `packages/contracts/plugin-repo-info.json` and `packages/contracts/plugin-repo-info-dev.json`.
- You need to copy `.env.template` into `.env` and provide your Infura API key

### Plugin metadata

Plugins need some basic metadata in order for JS clients to be able to handle installations and updates. Beyond a simple title and description, every contract's build metadata contains the ABI of the parameters that need to be encoded in order to prepare the plugin installation.

Every plugin has an `initialize()` methos, which acts as the constructor for UUPS upgradeable contracts. This method will be passed its DAO's address, as well as a `bytes memory data` parameter, with all the settings encoded.

The format of these settings is defined in the `packages/contracts/src/*-build.metadata.json` file. See the `pluginSetup` > `prepareInstallation` section.

## DO's and DONT's

- Never grant `ROOT_PERMISSION` unless you are just trying things out
Expand Down
23 changes: 4 additions & 19 deletions packages/contracts/deploy/02_setup/12_publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
PluginSetupParams,
SpacePluginSetupParams,
} from '../../plugin-setup-params';
import {toHex} from '../../utils/ipfs';
import {uploadToIPFS} from '../../utils/ipfs';
import {
addDeployedVersion,
getPluginRepoInfo,
Expand All @@ -32,19 +30,6 @@ async function publishPlugin(
const {deployments, network} = hre;
const [deployer] = await hre.ethers.getSigners();

// Upload the metadata to IPFS
const releaseMetadataURI = `ipfs://${await uploadToIPFS(
JSON.stringify(pluginSetupParams.METADATA.release),
false
)}`;
const buildMetadataURI = `ipfs://${await uploadToIPFS(
JSON.stringify(pluginSetupParams.METADATA.build),
false
)}`;

console.log(`Uploaded release metadata: ${releaseMetadataURI}`);
console.log(`Uploaded build metadata: ${buildMetadataURI}`);

// Get PluginSetup
const setup = await deployments.get(
pluginSetupParams.PLUGIN_SETUP_CONTRACT_NAME
Expand Down Expand Up @@ -99,8 +84,8 @@ async function publishPlugin(
const tx = await pluginRepo.createVersion(
pluginSetupParams.VERSION.release,
setup.address,
toHex(buildMetadataURI),
toHex(releaseMetadataURI)
'0x00',
'0x00'
);

const blockNumberOfPublication = (await tx.wait()).blockNumber;
Expand Down Expand Up @@ -137,13 +122,13 @@ async function publishPlugin(
blockNumberOfDeployment: setup.receipt.blockNumber,
},
helpers: [],
buildMetadataURI: buildMetadataURI,
buildMetadataURI: '',
blockNumberOfPublication: blockNumberOfPublication,
};
addDeployedVersion(
pluginSetupParams.PLUGIN_REPO_ENS_NAME,
network.name,
releaseMetadataURI,
'',
{release: pluginSetupParams.VERSION.release, build: version.tag.build},
pluginBuild
);
Expand Down
1 change: 0 additions & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"hardhat": "^2.13.1",
"hardhat-deploy": "^0.11.37",
"hardhat-gas-reporter": "^1.0.9",
"ipfs-http-client": "^51.0.0",
"mocha": "^10.1.0",
"solhint": "^3.4.0",
"solhint-plugin-prettier": "^0.0.5",
Expand Down
23 changes: 0 additions & 23 deletions packages/contracts/plugin-setup-params.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
import governanceBuildMetadata from './src/governance/governance-build-metadata.json';
import governanceReleaseMetadata from './src/governance/governance-release-metadata.json';
import personalSpaceAdminBuildMetadata from './src/personal/personal-space-admin-build-metadata.json';
import personalSpaceAdminReleaseMetadata from './src/personal/personal-space-admin-release-metadata.json';
import spaceBuildMetadata from './src/space/space-build-metadata.json';
import spaceReleaseMetadata from './src/space/space-release-metadata.json';

export const SpacePluginSetupParams: PluginSetupParams = {
PLUGIN_REPO_ENS_NAME: 'geo-browser-space',
PLUGIN_CONTRACT_NAME: 'SpacePlugin',
Expand All @@ -13,10 +6,6 @@ export const SpacePluginSetupParams: PluginSetupParams = {
release: 1, // Increment this number ONLY if breaking/incompatible changes were made. Updates between releases are NOT possible.
build: 1, // Increment this number if non-breaking/compatible changes were made. Updates to newer builds are possible.
},
METADATA: {
build: spaceBuildMetadata,
release: spaceReleaseMetadata,
},
};

export const PersonalSpaceAdminPluginSetupParams: PluginSetupParams = {
Expand All @@ -27,10 +16,6 @@ export const PersonalSpaceAdminPluginSetupParams: PluginSetupParams = {
release: 1, // Increment this number ONLY if breaking/incompatible changes were made. Updates between releases are NOT possible.
build: 1, // Increment this number if non-breaking/compatible changes were made. Updates to newer builds are possible.
},
METADATA: {
build: personalSpaceAdminBuildMetadata,
release: personalSpaceAdminReleaseMetadata,
},
};

export const GovernancePluginsSetupParams: PluginSetupParams = {
Expand All @@ -41,10 +26,6 @@ export const GovernancePluginsSetupParams: PluginSetupParams = {
release: 1, // Increment this number ONLY if breaking/incompatible changes were made. Updates between releases are NOT possible.
build: 1, // Increment this number if non-breaking/compatible changes were made. Updates to newer builds are possible.
},
METADATA: {
build: governanceBuildMetadata,
release: governanceReleaseMetadata,
},
};

// Types
Expand All @@ -57,8 +38,4 @@ export type PluginSetupParams = {
release: number;
build: number;
};
METADATA: {
build: {[k: string]: any};
release: {[k: string]: any};
};
};
64 changes: 0 additions & 64 deletions packages/contracts/src/governance/governance-build-metadata.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

38 changes: 0 additions & 38 deletions packages/contracts/src/space/space-build-metadata.json

This file was deleted.

5 changes: 0 additions & 5 deletions packages/contracts/src/space/space-release-metadata.json

This file was deleted.

30 changes: 2 additions & 28 deletions packages/contracts/test/integration-testing/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
import {PluginRepo} from '../../typechain';
import {osxContracts} from '../../utils/helpers';
import {getPluginRepoInfo} from '../../utils/plugin-repo-info';
// import { toHex } from "../../utils/ipfs";
import {PluginRepoRegistry__factory} from '@aragon/osx-ethers';
import {PluginRepoRegistry} from '@aragon/osx-ethers';
import {PluginRepo__factory} from '@aragon/osx-ethers';
Expand Down Expand Up @@ -100,36 +99,11 @@ describe('PluginRepo Deployment', function () {
).address
);

const receivedStriMetadata = Buffer.from(
const receivedStrMetadata = Buffer.from(
results.buildMetadata.slice(2),
'hex'
).toString();

switch (pluginSetupParams.PLUGIN_SETUP_CONTRACT_NAME) {
case SpacePluginSetupParams.PLUGIN_SETUP_CONTRACT_NAME:
expect(receivedStriMetadata).to.equal(
'ipfs://QmcAUbh4UmhwZp4b7aQf9nkpemhCfTVms2eSVng1bZUmmo'
);
break;

case PersonalSpaceAdminPluginSetupParams.PLUGIN_SETUP_CONTRACT_NAME:
expect(receivedStriMetadata).to.equal(
'ipfs://QmYKrFvNmsEzZmtGGBfUJXzevR6YLk7a16VEAeuPDhwzCJ'
);
break;

case GovernancePluginsSetupParams.PLUGIN_SETUP_CONTRACT_NAME:
expect(receivedStriMetadata).to.equal(
'ipfs://QmUivtg6CD3XUvArRS1BqaPYUrKU7oyw8MU59oemL3zxLQ'
);
break;

default:
throw new Error(
'Unexpected contract name: ' +
pluginSetupParams.PLUGIN_CONTRACT_NAME
);
}
expect(receivedStrMetadata).to.equal('\0');
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
getPluginRepoFactoryAddress,
osxContracts,
} from '../../utils/helpers';
import {toHex} from '../../utils/ipfs';
import {installPlugin} from '../helpers/setup';
import {deployTestDao} from '../helpers/test-dao';
import {
Expand Down Expand Up @@ -107,12 +106,7 @@ describe('Member Access Condition E2E', () => {
pluginSetup = await gpsFactory.deploy(psp.address);

// Publish build 1
tx = await pluginRepo.createVersion(
1,
pluginSetup.address,
toHex('build'),
toHex('release')
);
tx = await pluginRepo.createVersion(1, pluginSetup.address, '0x00', '0x00');

// Deploy setups
pluginSetupRef = {
Expand Down
Loading

0 comments on commit 14f53d6

Please sign in to comment.