Skip to content

Commit

Permalink
Merge pull request #34 from aragon/feat/update-to-use-upload-to-pinnata
Browse files Browse the repository at this point in the history
Feat: update to use upload to pinnata
  • Loading branch information
novaknole authored Jan 20, 2025
2 parents a976099 + fffc680 commit 6eea634
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
24 changes: 16 additions & 8 deletions packages/contracts/deploy/20_new_version/23_publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
isLocal,
pluginEnsDomain,
} from '../../utils/helpers';
import {PLUGIN_REPO_PERMISSIONS, uploadToIPFS} from '@aragon/osx-commons-sdk';
import {PLUGIN_REPO_PERMISSIONS, uploadToPinata} from '@aragon/osx-commons-sdk';
import {writeFile} from 'fs/promises';
import {ethers} from 'hardhat';
import {DeployFunction} from 'hardhat-deploy/types';
Expand All @@ -31,13 +31,21 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments} = hre;
const [deployer] = await hre.ethers.getSigners();

// Upload the metadata to IPFS
const releaseMetadataURI = `ipfs://${await uploadToIPFS(
JSON.stringify(METADATA.release, null, 2)
)}`;
const buildMetadataURI = `ipfs://${await uploadToIPFS(
JSON.stringify(METADATA.build, null, 2)
)}`;
// metadata will be empty if running locally
let releaseMetadataURI = '';
let buildMetadataURI = '';

if (!isLocal(hre)) {
// Upload the metadata to IPFS
releaseMetadataURI = await uploadToPinata(
JSON.stringify(METADATA.release, null, 2),
`${PLUGIN_REPO_ENS_SUBDOMAIN_NAME}-release-metadata`
);
buildMetadataURI = await uploadToPinata(
JSON.stringify(METADATA.build, null, 2),
`${PLUGIN_REPO_ENS_SUBDOMAIN_NAME}-build-metadata`
);
}

console.log(`Uploaded release metadata: ${releaseMetadataURI}`);
console.log(`Uploaded build metadata: ${buildMetadataURI}`);
Expand Down
27 changes: 15 additions & 12 deletions packages/contracts/test/20_integration-testing/21_deployment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {METADATA, VERSION} from '../../plugin-settings';
import {VERSION, PLUGIN_SETUP_CONTRACT_NAME} from '../../plugin-settings';
import {getProductionNetworkName, findPluginRepo} from '../../utils/helpers';
import {
getLatestNetworkDeployment,
Expand All @@ -9,7 +9,6 @@ import {
PERMISSION_MANAGER_FLAGS,
PLUGIN_REPO_PERMISSIONS,
UnsupportedNetworkError,
uploadToIPFS,
} from '@aragon/osx-commons-sdk';
import {
DAO,
Expand Down Expand Up @@ -65,22 +64,16 @@ describe(`Deployment on network '${productionNetworkName}'`, function () {

context('PluginSetup Publication', async () => {
it('registers the setup', async () => {
const {pluginRepo} = await loadFixture(fixture);
const {pluginRepo, pluginSetupAddr} = await loadFixture(fixture);

const results = await pluginRepo['getVersion((uint8,uint16))']({
release: VERSION.release,
build: VERSION.build,
});

const buildMetadataURI = `ipfs://${await uploadToIPFS(
JSON.stringify(METADATA.build, null, 2)
)}`;

expect(results.buildMetadata).to.equal(
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(buildMetadataURI))
);

expect(results.pluginSetup).to.equal(pluginSetupAddr);
expect(results.tag.build).to.equal(VERSION.build);
expect(results.tag.release).to.equal(VERSION.release);
});
});
});
Expand All @@ -90,6 +83,7 @@ type FixtureResult = {
pluginRepo: PluginRepo;
pluginRepoRegistry: PluginRepoRegistry;
managementDaoProxy: DAO;
pluginSetupAddr: string;
};

async function fixture(): Promise<FixtureResult> {
Expand Down Expand Up @@ -126,5 +120,14 @@ async function fixture(): Promise<FixtureResult> {
deployer
);

return {deployer, pluginRepo, pluginRepoRegistry, managementDaoProxy};
const pluginSetupAddr = (await deployments.get(PLUGIN_SETUP_CONTRACT_NAME))
.address;

return {
deployer,
pluginRepo,
pluginRepoRegistry,
managementDaoProxy,
pluginSetupAddr,
};
}

0 comments on commit 6eea634

Please sign in to comment.