diff --git a/.env.example b/.env.example index f00dc3a..a670b6c 100644 --- a/.env.example +++ b/.env.example @@ -1,13 +1,23 @@ -# Used for fork testing -NETWORK_RPC_URL= +# GENERAL -VERIFIER= -ETHERSCAN_API_KEY= -NETWORK_RPC_URL= +# The osx supported network name used for testing purposes and deployment +NETWORK_NAME="devSepolia" # ["mainnet", "sepolia", "polygon", "polygonMumbai", "base", "baseSepolia", "arbitrum", "arbitrumSepolia"] -DEPLOYER_KEY= -DEPLOYER_ADDR= +# One or multiple hex encoded private keys separated by commas `,` replacing the hardhat default accounts. +DEPLOYER_KEY=0xe4dc625275ded38ed377253b8b5d464e8b9414b036e8fba4f49aae908384adb0 -CHAIN= -NETWORK_NAME= -PROTOCOL_VERSION= +# The osx protocol version used +PROTOCOL_VERSION="v1.3.0" + + +# Deployment + +# The chain name, this is used to determine the chain id and the rpc url +CHAIN=sepolia + +VERIFIER='etherscan' +ETHERSCAN_API_KEY=WQ7EFJVI6QCN9XKY3ET6IS4S7IX8CJ8QCW +NETWORK_RPC_URL="https://eth-sepolia.g.alchemy.com/v2/odroQEdm5NV-FzxILCFWA4bvWql6uivF" + + +PUB_PINATA_JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mb3JtYXRpb24iOnsiaWQiOiI1NTAyNjU3MS0xODQ3LTQwMGEtOWM1Ni1mNWFhNGRmMzQ0MTgiLCJlbWFpbCI6ImFjY291bnRzQGFyYWdvbi5vcmciLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwicGluX3BvbGljeSI6eyJyZWdpb25zIjpbeyJkZXNpcmVkUmVwbGljYXRpb25Db3VudCI6MSwiaWQiOiJGUkExIn1dLCJ2ZXJzaW9uIjoxfSwibWZhX2VuYWJsZWQiOmZhbHNlLCJzdGF0dXMiOiJBQ1RJVkUifSwiYXV0aGVudGljYXRpb25UeXBlIjoic2NvcGVkS2V5Iiwic2NvcGVkS2V5S2V5IjoiZTVjYTllODYxYzE5ODExYTIwMDYiLCJzY29wZWRLZXlTZWNyZXQiOiI0YzlmZjIxOGY5MWJmNGZjYWE0YmEyMjBkNDAzNzUyZmEwOTUxZmNmY2RjNjVmNjJhM2UyNGUxMTY2YjUzYjAwIiwiZXhwIjoxNzYzNDcyMDU5fQ.3I9n6RdfhVLFGPY75YgFaLOcuVr7kPac_NdFtsIrhMY diff --git a/package.json b/package.json index 57e8123..32b8030 100644 --- a/package.json +++ b/package.json @@ -35,12 +35,14 @@ "prettier": "^2.8.8", "prettier-plugin-solidity": "^1.1.3", "solhint": "^3.6.2", - "solhint-plugin-prettier": "^0.0.5" + "solhint-plugin-prettier": "^0.0.5", + "ts-node": "^10.9.2" }, "dependencies": { "@aragon/osx": "1.3.0", "@aragon/osx-commons-configs": "^0.5.0", "@aragon/osx-commons-contracts": "1.4.0-alpha.5", + "@aragon/osx-commons-sdk": "0.0.1-alpha.11", "@ensdomains/ens-contracts": "^1.1.4", "@openzeppelin/contracts": "^4.9.6", "@openzeppelin/contracts-upgradeable": "^4.9.6" diff --git a/script/Base.sol b/script/Base.sol index 443a22f..dc58a8d 100644 --- a/script/Base.sol +++ b/script/Base.sol @@ -94,12 +94,15 @@ contract BaseScript is Script, Constants { revert InvalidVersionBuild(PluginSettings.VERSION_BUILD, uint8(latestBuild)); } + // get build and release metadata ipfs cids + (string memory _buildCID, string memory _releaseCID) = _uploadMetadataToIPFS(); + // create plugin version sppRepo.createVersion( PluginSettings.VERSION_RELEASE, address(_sppSetup), - PluginSettings.BUILD_METADATA, - PluginSettings.RELEASE_METADATA + bytes(_buildCID), + bytes(_releaseCID) ); // check version was created correctly @@ -109,7 +112,7 @@ contract BaseScript is Script, Constants { console.log( "Published Staged Proposal Plugin at ", - address(sppSetup), + address(_sppSetup), " with ", _versionString(PluginSettings.VERSION_RELEASE, PluginSettings.VERSION_BUILD) ); @@ -151,4 +154,18 @@ contract BaseScript is Script, Constants { ) ); } + + function _uploadMetadataToIPFS() + internal + returns (string memory buildCID, string memory releaseCID) + { + string[] memory inputs = new string[](4); + inputs[0] = "npx"; + inputs[1] = "ts-node"; + inputs[2] = "script/upload-metadata-to-pinnata.ts"; + inputs[3] = PluginSettings.PLUGIN_REPO_ENS_SUBDOMAIN_NAME; + + bytes memory res = vm.ffi(inputs); + (buildCID, releaseCID) = abi.decode(res, (string, string)); + } } diff --git a/script/NewVersion.s.sol b/script/NewVersion.s.sol index b3fb5db..7c05097 100644 --- a/script/NewVersion.s.sol +++ b/script/NewVersion.s.sol @@ -52,7 +52,7 @@ contract NewVersion is BaseScript { function _buildProposalData( address _sppSetup - ) internal view returns (ProposalData memory _proposalData) { + ) internal returns (ProposalData memory _proposalData) { _proposalData.title = string( abi.encodePacked( "Publish Staged Proposal Plugin ", @@ -66,6 +66,10 @@ contract NewVersion is BaseScript { " of the Staged Proposal Plugin" ) ); + + // get build and release metadata ipfs cids + (string memory _buildCID, string memory _releaseCID) = _uploadMetadataToIPFS(); + _proposalData.actions = new Action[](1); _proposalData.actions[0] = Action({ to: address(sppRepo), @@ -74,8 +78,8 @@ contract NewVersion is BaseScript { sppRepo.createVersion.selector, PluginSettings.VERSION_RELEASE, _sppSetup, - PluginSettings.BUILD_METADATA, - PluginSettings.RELEASE_METADATA + bytes(_buildCID), + bytes(_releaseCID) ) }); } diff --git a/script/upload-metadata-to-pinnata.ts b/script/upload-metadata-to-pinnata.ts new file mode 100644 index 0000000..e915011 --- /dev/null +++ b/script/upload-metadata-to-pinnata.ts @@ -0,0 +1,24 @@ +import {uploadToPinata} from '@aragon/osx-commons-sdk'; + +import buildMetadata from '../src/build-metadata.json'; +import releaseMetadata from '../src/release-metadata.json'; + +import {ethers} from 'ethers'; + +async function uploadMetadataToIPFS(subdomainName: string): Promise { + const buildMetadataCIDPath = await uploadToPinata( + JSON.stringify(buildMetadata, null, 2), + `${subdomainName}-build-metadata` + ); + + const releaseMetadataCIDPath = await uploadToPinata( + JSON.stringify(releaseMetadata, null, 2), + `${subdomainName}-release-metadata` + ); + + return ethers.utils.defaultAbiCoder.encode(['string', 'string'], [buildMetadataCIDPath, releaseMetadataCIDPath]); +} + +(async () => { + console.log(await uploadMetadataToIPFS(process.argv[2])); +})(); \ No newline at end of file diff --git a/src/utils/PluginSettings.sol b/src/utils/PluginSettings.sol index ec1527c..08be6c1 100644 --- a/src/utils/PluginSettings.sol +++ b/src/utils/PluginSettings.sol @@ -9,17 +9,10 @@ pragma solidity ^0.8.18; library PluginSettings { string public constant PLUGIN_CONTRACT_NAME = "StagedProposalProcessor"; string public constant PLUGIN_SETUP_CONTRACT_NAME = "StagedProposalProcessorSetup"; - string public constant PLUGIN_REPO_ENS_SUBDOMAIN_NAME = "testting"; // 'spp.plugin.dao.eth' + string public constant PLUGIN_REPO_ENS_SUBDOMAIN_NAME = "spp"; // 'spp.plugin.dao.eth' // Specify the version of your plugin that you are currently working on. The first version is v1.1. // For more details, visit https://devs.aragon.org/docs/osx/how-it-works/framework/plugin-management/plugin-repo. uint8 public constant VERSION_RELEASE = 1; uint8 public constant VERSION_BUILD = 1; - - // 1. upload build-metadata and release-metadata jsons to the IPFS. - // 2. use ethers to convert it to utf8 bytes: - // ethers.utils.hexlify(ethers.utils.toUtf8Bytes(`ipfs://${cid}`)) - // 3. Copy/paste the bytes into BUILD_METADATA and RELEASE_METADATA - bytes public constant BUILD_METADATA = "dummy"; - bytes public constant RELEASE_METADATA = "dummy"; } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..cf01769 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "emitDecoratorMetadata": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es6"], + "module": "commonjs", + "moduleResolution": "node", + "noImplicitAny": true, + "removeComments": true, + "resolveJsonModule": true, + "sourceMap": true, + "strict": true, + "target": "es6" + }, + "exclude": ["node_modules"], + "include": [ + "script/**/*" + ] +}