Skip to content

Commit

Permalink
Removing the IPFS and metadata dependency from plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed May 29, 2024
1 parent a25346d commit eec5909
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 646 deletions.
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
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 @@ -42,7 +41,6 @@ const release = 1;
const hardhatForkNetwork = process.env.NETWORK_NAME ?? 'mainnet';
const pluginSettings: MajorityVotingBase.VotingSettingsStruct = {
duration: 60 * 60 * 24,
minParticipation: 1,
supportThreshold: 1,
votingMode: 0,
};
Expand Down Expand Up @@ -108,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
52 changes: 33 additions & 19 deletions packages/contracts/test/integration-testing/plugin-upgrader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
hashHelpers,
osxContracts,
} from '../../utils/helpers';
import {toHex} from '../../utils/ipfs';
import {installPlugin} from '../helpers/setup';
import {deployTestDao} from '../helpers/test-dao';
import {
Expand All @@ -50,7 +49,6 @@ const release = 1;
const hardhatForkNetwork = process.env.NETWORK_NAME ?? 'mainnet';
const pluginSettings: MajorityVotingBase.VotingSettingsStruct = {
duration: 60 * 60 * 24,
minParticipation: 1,
supportThreshold: 1,
votingMode: 0,
};
Expand Down Expand Up @@ -123,15 +121,15 @@ describe('Plugin upgrader', () => {
tx = await pluginRepo.createVersion(
1,
pSetupBuild1.address,
toHex('build'),
toHex('release')
'0x00',
'0x00'
);
// Publish build 2
tx = await pluginRepo.createVersion(
1,
pSetupBuild2.address,
toHex('build'),
toHex('release')
'0x00',
'0x00'
);
await tx.wait();
});
Expand Down Expand Up @@ -243,25 +241,33 @@ describe('Plugin upgrader', () => {
// Should not allow to execute other than the expected 3 actions
{
await expect(
dao.execute(toHex('01234123412341234123412341234123'), [], 0)
dao.execute(
'0x0123412341234123412341234123412301234123412341234123412341234123',
[],
0
)
).to.be.reverted;
await expect(
dao
.connect(pluginUpgrader)
.execute(toHex('01234123412341234123412341234123'), [], 0)
.execute(
'0x0123412341234123412341234123412301234123412341234123412341234123',
[],
0
)
).to.be.reverted;
await expect(
dao
.connect(pluginUpgrader)
.execute(
toHex('01234123412341234123412341234123'),
'0x0123412341234123412341234123412301234123412341234123412341234123',
[{to: dao.address, value: 0, data: '0x'}],
0
)
).to.be.reverted;
await expect(
dao.connect(pluginUpgrader).execute(
toHex('01234123412341234123412341234123'),
'0x0123412341234123412341234123412301234123412341234123412341234123',
[
{
to: mainVotingPlugin.address,
Expand Down Expand Up @@ -530,8 +536,8 @@ describe('Plugin upgrader', () => {
tx = await pluginRepo.createVersion(
1,
pSetupBuild1.address,
toHex('build'),
toHex('release')
'0x00',
'0x00'
);
});

Expand All @@ -558,7 +564,7 @@ describe('Plugin upgrader', () => {

// Install build 1
const data1 = await pSetupBuild1.encodeInstallationParams(
toHex('ipfs://1234'),
'0x1234',
ADDRESS_ZERO,
pluginUpgrader.address
);
Expand Down Expand Up @@ -605,8 +611,8 @@ describe('Plugin upgrader', () => {
let tx = await pluginRepo.createVersion(
1,
pSetupBuild2.address,
toHex('build'),
toHex('release')
'0x00',
'0x00'
);
await tx.wait();

Expand Down Expand Up @@ -638,25 +644,33 @@ describe('Plugin upgrader', () => {
// Should not allow to execute other than the expected 3 actions
{
await expect(
dao.execute(toHex('23412341234123412341234123412341'), [], 0)
dao.execute(
'0x2341234123412341234123412341234123412341234123412341234123412341',
[],
0
)
).to.be.reverted;
await expect(
dao
.connect(pluginUpgrader)
.execute(toHex('23412341234123412341234123412341'), [], 0)
.execute(
'0x2341234123412341234123412341234123412341234123412341234123412341',
[],
0
)
).to.be.reverted;
await expect(
dao
.connect(pluginUpgrader)
.execute(
toHex('23412341234123412341234123412341'),
'0x2341234123412341234123412341234123412341234123412341234123412341',
[{to: dao.address, value: 0, data: '0x'}],
0
)
).to.be.reverted;
await expect(
dao.connect(pluginUpgrader).execute(
toHex('23412341234123412341234123412341'),
'0x2341234123412341234123412341234123412341234123412341234123412341',
[
{
to: spacePlugin.address,
Expand Down
3 changes: 1 addition & 2 deletions packages/contracts/test/integration-testing/space-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from '../../typechain';
import {PluginSetupRefStruct} from '../../typechain/@aragon/osx/framework/dao/DAOFactory';
import {osxContracts} from '../../utils/helpers';
import {toHex} from '../../utils/ipfs';
import {getPluginRepoInfo} from '../../utils/plugin-repo-info';
import {installPlugin, uninstallPlugin} from '../helpers/setup';
import {deployTestDao} from '../helpers/test-dao';
Expand Down Expand Up @@ -104,7 +103,7 @@ describe('SpacePluginSetup processing', function () {
beforeEach(async () => {
// Install build 1.
const data = await setup.encodeInstallationParams(
toHex('ipfs://1234'),
'0x1234',
ADDRESS_ZERO,
pluginUpgrader
);
Expand Down
19 changes: 8 additions & 11 deletions packages/contracts/test/unit-testing/space-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {DAO, IDAO, SpacePlugin, SpacePlugin__factory} from '../../typechain';
import {deployWithProxy} from '../../utils/helpers';
import {toHex} from '../../utils/ipfs';
import {deployTestDao} from '../helpers/test-dao';
import {
ADDRESS_ONE,
Expand Down Expand Up @@ -184,14 +183,12 @@ describe('Space Plugin', function () {

it('Only the DAO can emit content on the space plugin', async () => {
// They cannot
await expect(
spacePlugin.connect(alice).publishEdits(toHex('ipfs://1234'))
).to.be.reverted;
await expect(spacePlugin.connect(bob).publishEdits(toHex('ipfs://1234')))
.to.be.reverted;
await expect(
spacePlugin.connect(carol).publishEdits(toHex('ipfs://1234'))
).to.be.reverted;
await expect(spacePlugin.connect(alice).publishEdits('0x1234')).to.be
.reverted;
await expect(spacePlugin.connect(bob).publishEdits('0x1234')).to.be
.reverted;
await expect(spacePlugin.connect(carol).publishEdits('0x1234')).to.be
.reverted;

// The DAO can
const actions: IDAO.ActionStruct[] = [
Expand All @@ -200,14 +197,14 @@ describe('Space Plugin', function () {
value: 0,
data: SpacePlugin__factory.createInterface().encodeFunctionData(
'publishEdits',
[toHex('ipfs://1234')]
['0x1234']
),
},
];

await expect(dao.execute(ZERO_BYTES32, actions, 0))
.to.emit(spacePlugin, 'EditsPublished')
.withArgs(dao.address, toHex('ipfs://1234'));
.withArgs(dao.address, '0x1234');
});

it('Only the DAO can accept subspaces', async () => {
Expand Down
24 changes: 0 additions & 24 deletions packages/contracts/utils/ipfs.ts

This file was deleted.

Loading

0 comments on commit eec5909

Please sign in to comment.