From 851fc4db7b1c8485b559104b699f5af7eee8d1c3 Mon Sep 17 00:00:00 2001 From: Michael Heuer <20623991+Michael-A-Heuer@users.noreply.github.com> Date: Fri, 15 Mar 2024 10:47:03 +0100 Subject: [PATCH] chore: sync with `osx-plugin-template-hardhat` `develop` branch (#5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: copied files from the simple-storage-example-plugin repo into package/contracts * set monorepo package.json * fix: CI/CD * init subgraph * fix: CI/CD * feat: CI/CD improvements * feat: cleaned devDependencies * feat: improve CI step description * subgraph bare bone (WIP) * feat: add subpackages and cleaned dependencies * feat: temporary readme * feat: move packages * fix: wrong path * add post install * plugin repo only * switch to osx-ethers * fix missing dir issue * make it build * build 1 * chore: cleaning * feat: deleted contracts-versions * feat: refactoring * feat: refactoring * feat: improvements * feat: refactoring * fix: linting and prettier * feat: print more infos, remove unused function * fix: print more info * More infos * Renaming * More info * fix: test failing because of wrong default test network * feature: add subgraph workflow * fix: rename flows * fix: adapt triggers * fix: install packages first * fix: triggers * feat: one .env file * fix: .env paths * fix: remove redundant checkout * debug: print info * debug: attempt fix * fix: missing env variable * fix: triggers * Removed summaries * WIP * improvements * fix: path * fix: empty json handling * fix: lint warnings * add psp and pluginRepos related mapping WIP * refactor PSP handlers (WIP) * refactor PSP handlers (WIP) * refactor PSP handlers (WIP) * refactor PSP handlers (WIP) * clean up * create common id functions * clean up * Feature: Add js client (#2) * add dummy js-client * update yarn.lock * update package.json * fix formatting * fix comments and add js-client github actions * update js-client test workflow * fix test workflow * fix lint * update workflow * wip * fix comments and add implementation * update yarn lock and remove docs workflow * Update packages/contracts-ethers/package.json Co-authored-by: Jør∂¡ <4456749+brickpop@users.noreply.github.com> * Update packages/js-client/src/context.ts Co-authored-by: Jør∂¡ <4456749+brickpop@users.noreply.github.com> * Update packages/js-client/test/unit/context.test.ts Co-authored-by: Jør∂¡ <4456749+brickpop@users.noreply.github.com> * add tests * fix comments * fix comments * update client-common version * fix lint command * Update packages/js-client/src/internal/modules/methods.ts Co-authored-by: Jør∂¡ <4456749+brickpop@users.noreply.github.com> * update size limit * update gh actions * update gh actions * fix gh actions * add build command * update gh actions * fix gh action * fix lint * fix lint * ignore js-client tests * minor fixes --------- Co-authored-by: Jør∂¡ <4456749+brickpop@users.noreply.github.com> * fix subgraph build * fix lint * map 1 event * chore: bump package versions * feat: added event, tests, and improved signer, renamed plugin * fix: linting and formatting errors * feature: support base goerli network * Add missing migration import for setup processing * feat: added sepolia and base support and fix IPFS returning empty strings (#10) * feat: added sepolia and base support * fix: replaced outdated IPFS server url * fix: empty return value * OS-593: refactors repo for linting and linting during workflows (#11) * chore(OS-593): Removes .editorconfig from project root Prettier uses its .prettierrc as a first priority to configure the formatter * chore(OS-593): Updates node to v18 in gitpod * chore(OS-593): same network for subgraph and contracts Use the same network for subgraph and contracts in the .env.example file * chore(OS-593): configure vscode editor correctly configures vscode to use fixed a tabsize of 4 and adds commitizen extentions into recommendations * chore(OS-593): reconfigures linting system to start from the root all linting commands have to be run from the root, then eslint merges the configs per package and lints those * build(OS-593): refactors package.json and dependency handling moves all linting commands to the root of the repo for proper config merging * chore(OS-593): adds solidity visual developer as recommmended we recommend to use the solidity visual auditor extension for development * style(OS-593): fixes linting issues fixes some linting issues in contracts and js-client * ci(OS-593): refactor workflows and include linting refactors workflows to be easier and includes formatting and linting in all workflows * style(OS-593): apply prettier formatting * ci(OS-593): lint all packages indiviually lints the packages individually and adds step summaries for important steps * ci(OS-593): remove prettier output from summary prettiers output isn't really working with step summary * ci(OS-593): uses now node 18 in workflows * chore(OS-593): fix typo in formatting-linting.yml * docs: added readme (#13) * docs: added readme * docs: fix typos * Os 782 remove the contracts ethers and do rollup in mini sdk (#12) * refactor(OS-782): removes contracts-ethers package Removes a now unecessary contracts-ethers package. js-client creates its own typechain now BREAKING CHANGE: Removal of contracts-ethers * refactor(OS-782): js-client generates typescript js-client doesn't depend on contracts-ethers anymore and creates the typechain typings during its own build * test(OS-782): ganache replacment, optimizations, use native jest replaces depricated ganache setup with hardhat for testing, removes contract interactions where they aren't necessary, upgrades jest by not using tsdx for testing * ci(OS-782): fixes js-client publish and tests workflows corrects reusable worfklow in js-client publishing workflow, adapts js-client-tests to use the new typechain integration properly * build(OS-782): removes contracts-ethers linting command * chore(OS-782): applies prettier formatting * refactor: renamed and refactored files * refactor: skip repo creation if ENS name is already taken * docs: added usage guide and improved comments * ci: fix workflow by removing outdated lint * ci: formatting & linting on every push * docs: improve migration file comment * ci: fix linting workflow * build: use the same typescript version everywhere * docs: improve usage guide * docs: improved usage guide * OS-754 : re-organize entity relations & add testing (#15) * re organize entity relations * add testing for OSx & Plugin * remove extra files * Update Satsuma deploy node url * Clean up * fix lint * fix subgraph scripts * fix subgraph test flow * ci: fixed linting work flow * add comment * OSx: Remove redundant code * flow: build contracts for subgraph testing * flow: build root for subgraph testing * flow: remove comments * subgraph: update test constants and comments * subgraph: refactor & add comments * ci: skip js-client linting * docs: fix typo --------- Co-authored-by: Michael Heuer <20623991+Michael-A-Heuer@users.noreply.github.com> * fix(js-client): exclude dist from tsconfig.json (#20) * fix(js-client): exclude dist from tsconfig.json not excluding dist would result in an error trying to run tests after the client has been built * ci(js-client): fix missing env in build * chore: added arbitrum and arbitrumGoerli (#18) * chore: added arbitrum and arbitrumGoerli * ci: fix ci pipeline by adding typescript dev dependency * ci: fix pipeline by removing leftover contracts-ethers lint * ci: do a global lint on every push * fix: etherscan arbitrum name * ci: skip js-client linting * build: add cross-env to fix subgraph ci * refactor: add event explicitly * build(js-client): replaces tsdx with dts-cli (#21) * build(js-client): replace tsdx with dts-cli deps(js-client): update to typescript 5.2.2 deps(root): update eslint packages * lint(js-client): fixes linting errors * test(js-client): fixes jest-environment import * style: apply prettier changes * chore: bump OZ dependency (#22) * docs: add readme and usage guide * OS-888 fix: Import Repo address from plugin-info (#26) * fix: Import repo address from plugin-info * fix: fix typo * update plugin-info.json location * update script * update gitignore * update osx-ethers to version 1.3.0 * Update .gitignore Co-authored-by: Michael Heuer <20623991+Michael-A-Heuer@users.noreply.github.com> * fix import * remove alias import --------- Co-authored-by: Jose Manuel Mariñas Bascoy Co-authored-by: josemarinas <36479864+josemarinas@users.noreply.github.com> Co-authored-by: Michael Heuer <20623991+Michael-A-Heuer@users.noreply.github.com> * build: clean-up of dependecy and commands (#19) * build: remove docker-related commands * build: remove local subgraphs commands * chore: bump dependencies * build: bump OZ version and fix unmet dependencies * Feature: Add Subgraph step-by-step guide (#25) * add step-by-step guide * fiux lintint * fix comments * fix lint * fix: Remove individual usage * fix: update .env.example to include Sepolia * docs: Improve usage guide * fix: replace arbitrumGoerli and baseGoerli with the sepolia replacements * fix: improve usage format * Apply suggestions from code review Co-authored-by: Michael Heuer <20623991+Michael-A-Heuer@users.noreply.github.com> * feat: improve usage guide file structure & address comments * fix: remove redundant titles * fix: link dependencies in the usage guide * fix: fix typo * Apply suggestions from code review Co-authored-by: Michael Heuer <20623991+Michael-A-Heuer@users.noreply.github.com> --------- Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> Co-authored-by: Michael Heuer <20623991+Michael-A-Heuer@users.noreply.github.com> * feat: use `osx-commons-contracts` and `osx-commons-configs` (#28) * build: use ts 5.2.2 * refactor: use osx-commons * refactor: use osx-commons * build: use osx-commons-sdk * build: use osx-commons-sdk * refactor: contract improvements * build: print coverage report * chore: bump osx-commons-sdk version * feat: use the latest osx-commons-contracts * refactor: use osx-commons-configs and deploy script refactor * build: subgraph fix * docs: improve .env example * style: fix prettier * build: use osx-commons * chore: bump subgraph osx-ethers dependency * chore: remove todo * test: remove redundant expect * fix: use unknown instead of any * fix: imports * fix: wrong type * fix: import * fix: import * feat: use typechain binding * refactor: deploy script simplification * refactor: findPluginRepo and domain * refactor: improve code, comments, and tests * refactor: improved helpers * style: fix linting issues * chore: remove todos * revert: deletion of hashHelpers * feat: catch errors properly * refactor: folder structure * refactor: help gh to track files * refactor: help gh to track files * refactor: improve folder structure (#30) * build: remove js client (#31) * ci: clean GH flows and remove gitpod (#32) * ci: improve flows * style: remove unused commitizen config file * build: update yarn.lock * docs: update README.md (#33) * docs: update README.md * doc: improve README and USAGE_GUIDE * doc: minor improvement * feat: use commons subgraph (#29) * use commons subgraph * update events folder structure * fix comments * fix tests * build: update yarn.lock --------- Co-authored-by: Michael Heuer * build: improve package.json files (#34) * feat: improvements surfaced from the admin plugin (#36) * feat: various improvements that surfaced from the admin plugin * build: remove duplicated dependency * ci: use network name env var * style: throw errors for unsupported networks or missing deployments * feat: update the env examples to change the infura api key for the alchemy one * feat: update the hardhat contracts file to use the new commons networks config * feat: update the hardhat config to use the new addRpcUrlToNetwork function from the config commons package * feat: update the config commons dependency version * ci: update the readme to add the new alchemy api key needed * feat: add new commons config version * ci: typo * Update .env.example Co-authored-by: Michael Heuer <20623991+Michael-A-Heuer@users.noreply.github.com> * Update README.md Co-authored-by: Michael Heuer <20623991+Michael-A-Heuer@users.noreply.github.com> * feat: update the api key in the workflows * ci: update readme * feat: bump commons config version on subgraph * feat: update the actions to run over the PR changes instead of the commit changes * ci: comment to check the pipeline * ci: undo the last comment added on the readme * feature: improvements (#44) * doc: added missing comment * build: remove redundant dependency * feat: add a function to generate a random ens, set the ens to the plugin settings * feat: bump commons config version in subgraph * feat: add random name function * refactor: settings --------- Co-authored-by: Claudia * feat: add manifest with psp address for missing networks and add the Plugin address to the json * feat: update the script for getting the repo address * feat: update the readme * feat: update the deployment script to avoid deploying if the plugin address is not set * ci update comment --------- Co-authored-by: Rekard0 <5880388+Rekard0@users.noreply.github.com> Co-authored-by: josemarinas <36479864+josemarinas@users.noreply.github.com> Co-authored-by: Jør∂¡ <4456749+brickpop@users.noreply.github.com> Co-authored-by: Jør∂¡ Co-authored-by: Mathias Scherer Co-authored-by: Aaron Abu Usama <50079365+pythonpete32@users.noreply.github.com> Co-authored-by: Jose Manuel Mariñas Bascoy Co-authored-by: Claudia --- .env.example | 6 +-- .github/workflows/contracts-tests.yml | 6 +-- .github/workflows/subgraph-tests.yml | 4 +- README.md | 9 +++- .../deploy/20_new_version/21_setup.ts | 2 +- .../deploy/30_upgrade_repo/31_upgrade_repo.ts | 4 ++ packages/contracts/hardhat.config.ts | 24 +++++----- packages/contracts/package.json | 2 +- packages/contracts/plugin-settings.ts | 2 + .../20_integration-testing/21_deployment.ts | 2 +- packages/contracts/utils/helpers.ts | 11 +++++ packages/contracts/yarn.lock | 8 ++-- packages/subgraph/manifest/data/arbitrum.json | 18 ++++++++ .../manifest/data/arbitrumGoerli.json | 18 ++++++++ .../manifest/data/arbitrumSepolia.json | 18 ++++++++ .../subgraph/manifest/data/baseGoerli.json | 18 ++++++++ .../subgraph/manifest/data/baseMainnet.json | 18 ++++++++ .../subgraph/manifest/data/baseSepolia.json | 18 ++++++++ packages/subgraph/manifest/data/goerli.json | 7 ++- .../subgraph/manifest/data/localhost.json | 7 ++- packages/subgraph/manifest/data/mainnet.json | 7 ++- packages/subgraph/manifest/data/mumbai.json | 7 ++- packages/subgraph/manifest/data/polygon.json | 7 ++- packages/subgraph/manifest/data/sepolia.json | 7 ++- packages/subgraph/package.json | 2 +- packages/subgraph/scripts/deploy-subgraph.sh | 11 +++++ .../subgraph/scripts/import-plugin-repo.ts | 44 ++++++++++++------- packages/subgraph/yarn.lock | 8 ++-- 28 files changed, 238 insertions(+), 57 deletions(-) create mode 100644 packages/subgraph/manifest/data/arbitrum.json create mode 100644 packages/subgraph/manifest/data/arbitrumGoerli.json create mode 100644 packages/subgraph/manifest/data/arbitrumSepolia.json create mode 100644 packages/subgraph/manifest/data/baseGoerli.json create mode 100644 packages/subgraph/manifest/data/baseMainnet.json create mode 100644 packages/subgraph/manifest/data/baseSepolia.json diff --git a/.env.example b/.env.example index d277cd52..2ffc6856 100644 --- a/.env.example +++ b/.env.example @@ -1,15 +1,15 @@ # GENERAL ## The network used for testing purposes -NETWORK_NAME="sepolia" # ["mainnet", "sepolia", "polygon", "polygonMumbai", "base", "baseSepolia", "arbitrum", "arbitrumSepolia"] +NETWORK_NAME="sepolia" # ["mainnet", "sepolia", "polygon", "mumbai","baseMainnet", "baseGoerli", "baseSepolia", "arbitrum", "arbitrumSepolia"] # CONTRACTS ## One or multiple hex encoded private keys separated by commas `,` replacing the hardhat default accounts. PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" # Default hardhat account 0 private key. DON'T USE FOR DEPLOYMENTS -## Infura credentials -INFURA_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" +## Alchemy RPC endpoint credentials +ALCHEMY_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" ## Gas Reporting REPORT_GAS='true' diff --git a/.github/workflows/contracts-tests.yml b/.github/workflows/contracts-tests.yml index e4b3728b..fb34a28e 100644 --- a/.github/workflows/contracts-tests.yml +++ b/.github/workflows/contracts-tests.yml @@ -2,7 +2,7 @@ name: 'contracts' on: workflow_dispatch: - push: + pull_request: paths: - 'packages/contracts/**' - '.github/workflows/contracts-*.yml' @@ -31,10 +31,10 @@ jobs: - name: 'Build the contracts' run: 'yarn build' env: - INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} - name: 'Test the contracts and generate the coverage report' run: 'yarn coverage' env: NETWORK_NAME: ${{ vars.NETWORK_NAME }} - INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} diff --git a/.github/workflows/subgraph-tests.yml b/.github/workflows/subgraph-tests.yml index dd492b1e..ef013b86 100644 --- a/.github/workflows/subgraph-tests.yml +++ b/.github/workflows/subgraph-tests.yml @@ -2,7 +2,7 @@ name: 'subgraph' on: workflow_dispatch: - push: + pull_request: paths: - 'packages/subgraph/**' - 'packages/contracts/**' @@ -41,7 +41,7 @@ jobs: working-directory: packages/subgraph env: SUBGRAPH_NETWORK_NAME: ${{ vars.SUBGRAPH_NETWORK_NAME }} - INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} - name: 'Test the subgraph' run: yarn test diff --git a/README.md b/README.md index 49ea2a21..cc2fdf04 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ yarn lint To be able to work on the contracts, make sure that you have created an `.env` file from the `.env.example` file and put in the API keys for -- [Infura](https://www.infura.io/) that we use as the web3 provider +- [Alchemy](https://www.alchemy.com) that we use as the web3 provider - [Alchemy Subgraphs](https://www.alchemy.com/subgraphs) that we use as the subgraph provider - the block explorer that you want to use depending on the networks that you want to deploy to @@ -268,6 +268,10 @@ and finally the subgraph itself with yarn build:subgraph ``` +When running `yarn build`, it requires a plugin address, which is obtained from the configuration file located +at `subgraph/manifest/data/.json`, based on the network specified in your `.env` file under the `SUBGRAPH_NETWORK_NAME` variable. +You do not need to provide a plugin address for building or testing purposes, but it becomes necessary when deploying the subgraph. + During development of the subgraph, you might want to clean outdated files that were build, imported, and generated. To do this, run ```sh @@ -300,7 +304,8 @@ yarn coverage ### Deployment -To deploy the subgraph to the subgraph provider, write your intended subgraph name and version into the `SUBGRAPH_NAME` and `SUBGRAPH_VERSION` variables [in the `.env` file that you created in the beginning](environment-variables) and pick a network name `SUBGRAPH_NETWORK_NAME` [being supported by the subgraph provider](https://docs.alchemy.com/reference/supported-subgraph-chains). Then run +To deploy the subgraph to the subgraph provider, write your intended subgraph name and version into the `SUBGRAPH_NAME` and `SUBGRAPH_VERSION` variables [in the `.env` file that you created in the beginning](environment-variables) and pick a network name `SUBGRAPH_NETWORK_NAME` [being supported by the subgraph provider](https://docs.alchemy.com/reference/supported-subgraph-chains). Remember to place correctly the Plugin address on the network you are going to deploy to, you can do that by adding it on `subgraph/manifest/data/.json`. +Then run ```sh yarn deploy diff --git a/packages/contracts/deploy/20_new_version/21_setup.ts b/packages/contracts/deploy/20_new_version/21_setup.ts index a52a1b28..7ef97b63 100644 --- a/packages/contracts/deploy/20_new_version/21_setup.ts +++ b/packages/contracts/deploy/20_new_version/21_setup.ts @@ -21,7 +21,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }); console.log( - `Deployed contract '${PLUGIN_SETUP_CONTRACT_NAME}' at ${res.address}.` + `Deployed '${PLUGIN_SETUP_CONTRACT_NAME}' contract at '${res.address}'` ); }; diff --git a/packages/contracts/deploy/30_upgrade_repo/31_upgrade_repo.ts b/packages/contracts/deploy/30_upgrade_repo/31_upgrade_repo.ts index 7ca2b168..d8cf19c8 100644 --- a/packages/contracts/deploy/30_upgrade_repo/31_upgrade_repo.ts +++ b/packages/contracts/deploy/30_upgrade_repo/31_upgrade_repo.ts @@ -21,6 +21,10 @@ import path from 'path'; type SemVer = [number, number, number]; +/** + * Upgrades the plugin repo to the latest implementation. + * @param {HardhatRuntimeEnvironment} hre + */ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const [deployer] = await hre.ethers.getSigners(); const productionNetworkName: string = getProductionNetworkName(hre); diff --git a/packages/contracts/hardhat.config.ts b/packages/contracts/hardhat.config.ts index 749b7d34..660e070a 100644 --- a/packages/contracts/hardhat.config.ts +++ b/packages/contracts/hardhat.config.ts @@ -1,7 +1,6 @@ import { - NetworkConfigs, - NetworkConfig, - networks, + addRpcUrlToNetwork, + networks as osxCommonsConfigNetworks, SupportedNetworks, } from '@aragon/osx-commons-configs'; import '@nomicfoundation/hardhat-chai-matchers'; @@ -18,14 +17,18 @@ import { HardhatNetworkAccountsUserConfig, HardhatRuntimeEnvironment, } from 'hardhat/types'; +import type {NetworkUserConfig} from 'hardhat/types'; import {resolve} from 'path'; import 'solidity-coverage'; const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || '../../.env'; dotenvConfig({path: resolve(__dirname, dotenvConfigPath), override: true}); -if (!process.env.INFURA_API_KEY) { - throw new Error('INFURA_API_KEY in .env not set'); +// check alchemy Api key existence +if (process.env.ALCHEMY_API_KEY) { + addRpcUrlToNetwork(process.env.ALCHEMY_API_KEY); +} else { + throw new Error('ALCHEMY_API_KEY in .env not set'); } // Fetch the accounts specified in the .env file @@ -67,15 +70,10 @@ function getHardhatNetworkAccountsConfig( return accountsConfig; } -type HardhatNetworksExtension = NetworkConfig & { - accounts?: string[]; -}; - // Add the accounts specified in the `.env` file to the networks from osx-commons-configs -const osxCommonsConfigNetworks: NetworkConfigs = - networks; +const networks: {[index: string]: NetworkUserConfig} = osxCommonsConfigNetworks; for (const network of Object.keys(networks) as SupportedNetworks[]) { - osxCommonsConfigNetworks[network].accounts = specifiedAccounts(); + networks[network].accounts = specifiedAccounts(); } // Extend HardhatRuntimeEnvironment @@ -110,7 +108,7 @@ const config: HardhatUserConfig = { Object.keys(namedAccounts).length ), }, - ...osxCommonsConfigNetworks, + ...networks, }, defaultNetwork: 'hardhat', diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 53244bb6..63ff96a2 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -19,7 +19,7 @@ "@openzeppelin/contracts-upgradeable": "^4.9.5" }, "devDependencies": { - "@aragon/osx-commons-configs": "0.1.0", + "@aragon/osx-commons-configs": "0.4.0", "@aragon/osx-commons-sdk": "0.0.1-alpha.5", "@aragon/osx-ethers": "1.4.0-alpha.0", "@aragon/osx-v1.0.0": "npm:@aragon/osx@1.0.1", diff --git a/packages/contracts/plugin-settings.ts b/packages/contracts/plugin-settings.ts index 18e3ce5a..d481d42c 100644 --- a/packages/contracts/plugin-settings.ts +++ b/packages/contracts/plugin-settings.ts @@ -6,6 +6,8 @@ export const PLUGIN_CONTRACT_NAME = 'Multisig'; export const PLUGIN_SETUP_CONTRACT_NAME = 'MultisigSetup'; export const PLUGIN_REPO_ENS_SUBDOMAIN_NAME = 'multisig'; // 'multisig.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. export const VERSION: VersionTag = { release: 1, // Increment this number ONLY if breaking/incompatible changes were made. Updates between releases are NOT possible. build: 3, // Increment this number if non-breaking/compatible changes were made. Updates to newer builds are possible. diff --git a/packages/contracts/test/20_integration-testing/21_deployment.ts b/packages/contracts/test/20_integration-testing/21_deployment.ts index eb6509e9..2e38b381 100644 --- a/packages/contracts/test/20_integration-testing/21_deployment.ts +++ b/packages/contracts/test/20_integration-testing/21_deployment.ts @@ -101,7 +101,7 @@ async function fixture(): Promise { await deployments.fixture(tags); const [deployer] = await ethers.getSigners(); - // Plugin repo + // Plugin Repo const {pluginRepo, ensDomain} = await findPluginRepo(env); if (pluginRepo === null) { throw `PluginRepo '${ensDomain}' does not exist yet.`; diff --git a/packages/contracts/utils/helpers.ts b/packages/contracts/utils/helpers.ts index 6b13eb8d..47fe645f 100644 --- a/packages/contracts/utils/helpers.ts +++ b/packages/contracts/utils/helpers.ts @@ -251,5 +251,16 @@ export async function createVersion( return tx; } +export function generateRandomName(length: number): string { + const allowedCharacters = 'abcdefghijklmnopqrstuvwxyz-0123456789'; + let result = ''; + for (let i = 0; i < length; i++) { + result += allowedCharacters.charAt( + Math.floor(Math.random() * allowedCharacters.length) + ); + } + return result; +} + export const AragonOSxAsciiArt = " ____ _____ \n /\\ / __ \\ / ____| \n / \\ _ __ __ _ __ _ ___ _ __ | | | | (_____ __ \n / /\\ \\ | '__/ _` |/ _` |/ _ \\| '_ \\ | | | |\\___ \\ \\/ / \n / ____ \\| | | (_| | (_| | (_) | | | | | |__| |____) > < \n /_/ \\_\\_| \\__,_|\\__, |\\___/|_| |_| \\____/|_____/_/\\_\\ \n __/ | \n |___/ \n"; diff --git a/packages/contracts/yarn.lock b/packages/contracts/yarn.lock index 1a23906f..4221ca0b 100644 --- a/packages/contracts/yarn.lock +++ b/packages/contracts/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@aragon/osx-commons-configs@0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@aragon/osx-commons-configs/-/osx-commons-configs-0.1.0.tgz#21bbc5a964eb144e30033a44cc352d35c62982f9" - integrity sha512-qTs/loihwqALBGmhZngORb+p7pjuQJY5UEd8TLNiEW/BGHEpAJPp4GeQu7GSnigRGEKWpPD5W96kfEsaPtLkuQ== +"@aragon/osx-commons-configs@0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@aragon/osx-commons-configs/-/osx-commons-configs-0.4.0.tgz#5b6ae025de1ccf7f9a135bfbcb0aa822c774acf9" + integrity sha512-/2wIQCbv/spMRdOjRXK0RrXG1TK5aMcbD73RvMgMwQwSrKcA1dCntUuSxmTm2W8eEtOzs8E1VPjqZk0cXL4SSQ== dependencies: tslib "^2.6.2" diff --git a/packages/subgraph/manifest/data/arbitrum.json b/packages/subgraph/manifest/data/arbitrum.json new file mode 100644 index 00000000..0428ea2c --- /dev/null +++ b/packages/subgraph/manifest/data/arbitrum.json @@ -0,0 +1,18 @@ +{ + "info": "# Do not edit subgraph.yaml,this is a generated file. \n# Instead, edit subgraph.placeholder.yaml and run: yarn manifest", + "network": "arbitrum-one", + "dataSources": { + "PluginSetupProcessors": [ + { + "name": "PluginSetupProcessor", + "address": "0x308a1DC5020c4B5d992F5543a7236c465997fecB", + "startBlock": 145462184 + } + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } + } +} diff --git a/packages/subgraph/manifest/data/arbitrumGoerli.json b/packages/subgraph/manifest/data/arbitrumGoerli.json new file mode 100644 index 00000000..ab3a4f37 --- /dev/null +++ b/packages/subgraph/manifest/data/arbitrumGoerli.json @@ -0,0 +1,18 @@ +{ + "info": "# Do not edit subgraph.yaml,this is a generated file. \n# Instead, edit subgraph.placeholder.yaml and run: yarn manifest", + "network": "arbitrum-goerli", + "dataSources": { + "PluginSetupProcessors": [ + { + "name": "PluginSetupProcessor", + "address": "0x308a1DC5020c4B5d992F5543a7236c465997fecB", + "startBlock": 51930460 + } + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } + } +} diff --git a/packages/subgraph/manifest/data/arbitrumSepolia.json b/packages/subgraph/manifest/data/arbitrumSepolia.json new file mode 100644 index 00000000..a05a2973 --- /dev/null +++ b/packages/subgraph/manifest/data/arbitrumSepolia.json @@ -0,0 +1,18 @@ +{ + "info": "# Do not edit subgraph.yaml,this is a generated file. \n# Instead, edit subgraph.placeholder.yaml and run: yarn manifest", + "network": "arbitrum-sepolia", + "dataSources": { + "PluginSetupProcessors": [ + { + "name": "PluginSetupProcessor", + "address": "0xC24188a73dc09aA7C721f96Ad8857B469C01dC9f", + "startBlock": 2827173 + } + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } + } +} diff --git a/packages/subgraph/manifest/data/baseGoerli.json b/packages/subgraph/manifest/data/baseGoerli.json new file mode 100644 index 00000000..63f49b34 --- /dev/null +++ b/packages/subgraph/manifest/data/baseGoerli.json @@ -0,0 +1,18 @@ +{ + "info": "# Do not edit subgraph.yaml,this is a generated file. \n# Instead, edit subgraph.placeholder.yaml and run: yarn manifest", + "network": "base-testnet", + "dataSources": { + "PluginSetupProcessors": [ + { + "name": "PluginSetupProcessor", + "address": "0x6095b5004c59301f8Bb98768Bd395d0bc637C893", + "startBlock": 7890981 + } + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } + } +} diff --git a/packages/subgraph/manifest/data/baseMainnet.json b/packages/subgraph/manifest/data/baseMainnet.json new file mode 100644 index 00000000..833132c5 --- /dev/null +++ b/packages/subgraph/manifest/data/baseMainnet.json @@ -0,0 +1,18 @@ +{ + "info": "# Do not edit subgraph.yaml,this is a generated file. \n# Instead, edit subgraph.placeholder.yaml and run: yarn manifest", + "network": "base", + "dataSources": { + "PluginSetupProcessors": [ + { + "name": "PluginSetupProcessor", + "address": "0x91a851E9Ed7F2c6d41b15F76e4a88f5A37067cC9", + "startBlock": 2094737 + } + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } + } +} diff --git a/packages/subgraph/manifest/data/baseSepolia.json b/packages/subgraph/manifest/data/baseSepolia.json new file mode 100644 index 00000000..474f7c3a --- /dev/null +++ b/packages/subgraph/manifest/data/baseSepolia.json @@ -0,0 +1,18 @@ +{ + "info": "# Do not edit subgraph.yaml,this is a generated file. \n# Instead, edit subgraph.placeholder.yaml and run: yarn manifest", + "network": "base-sepolia", + "dataSources": { + "PluginSetupProcessors": [ + { + "name": "PluginSetupProcessor", + "address": "0xC24188a73dc09aA7C721f96Ad8857B469C01dC9f", + "startBlock": 3654401 + } + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } + } +} diff --git a/packages/subgraph/manifest/data/goerli.json b/packages/subgraph/manifest/data/goerli.json index 5f82e606..19a0dbb6 100644 --- a/packages/subgraph/manifest/data/goerli.json +++ b/packages/subgraph/manifest/data/goerli.json @@ -8,6 +8,11 @@ "address": "0xE8B5d8D66a02CD1b9Bd32a4064D7ABa45F51305e", "startBlock": 8548226 } - ] + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } } } diff --git a/packages/subgraph/manifest/data/localhost.json b/packages/subgraph/manifest/data/localhost.json index fc78a36a..0f778a14 100644 --- a/packages/subgraph/manifest/data/localhost.json +++ b/packages/subgraph/manifest/data/localhost.json @@ -8,6 +8,11 @@ "address": "0x2B8C4DD137104d1E869105cd0106e7D9EF955BfE", "startBlock": 7727664 } - ] + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } } } diff --git a/packages/subgraph/manifest/data/mainnet.json b/packages/subgraph/manifest/data/mainnet.json index b7969f87..81ffcdeb 100644 --- a/packages/subgraph/manifest/data/mainnet.json +++ b/packages/subgraph/manifest/data/mainnet.json @@ -8,6 +8,11 @@ "address": "0xE978942c691e43f65c1B7c7F8f1dc8cDF061B13f", "startBlock": 16721812 } - ] + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } } } diff --git a/packages/subgraph/manifest/data/mumbai.json b/packages/subgraph/manifest/data/mumbai.json index 9b1a7847..a6e30681 100644 --- a/packages/subgraph/manifest/data/mumbai.json +++ b/packages/subgraph/manifest/data/mumbai.json @@ -8,6 +8,11 @@ "address": "0x9227b311C5cecB416707F1C8B7Ca1b52649AabEc", "startBlock": 33514164 } - ] + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } } } diff --git a/packages/subgraph/manifest/data/polygon.json b/packages/subgraph/manifest/data/polygon.json index 7675c9ba..c831362b 100644 --- a/packages/subgraph/manifest/data/polygon.json +++ b/packages/subgraph/manifest/data/polygon.json @@ -8,6 +8,11 @@ "address": "0x879D9dfe3F36d7684BeC1a2bB4Aa8E8871A7245B", "startBlock": 40817440 } - ] + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } } } diff --git a/packages/subgraph/manifest/data/sepolia.json b/packages/subgraph/manifest/data/sepolia.json index 18a9af1e..87c67210 100644 --- a/packages/subgraph/manifest/data/sepolia.json +++ b/packages/subgraph/manifest/data/sepolia.json @@ -8,6 +8,11 @@ "address": "0xC24188a73dc09aA7C721f96Ad8857B469C01dC9f", "startBlock": 4415294 } - ] + ], + "Plugin": { + "name": "MyPlugin", + "address": null, + "startBlock": 7727664 + } } } diff --git a/packages/subgraph/package.json b/packages/subgraph/package.json index bc4571ed..c173357d 100644 --- a/packages/subgraph/package.json +++ b/packages/subgraph/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@aragon/osx-ethers": "1.4.0-alpha.0", - "@aragon/osx-commons-configs": "0.2.0", + "@aragon/osx-commons-configs": "0.4.0", "@graphprotocol/graph-cli": "^0.51.0", "@graphprotocol/graph-ts": "^0.31.0", "cross-env": "^7.0.3", diff --git a/packages/subgraph/scripts/deploy-subgraph.sh b/packages/subgraph/scripts/deploy-subgraph.sh index fd15a08c..69c94067 100755 --- a/packages/subgraph/scripts/deploy-subgraph.sh +++ b/packages/subgraph/scripts/deploy-subgraph.sh @@ -38,6 +38,17 @@ echo '' echo '> Deploying subgraph: '$FULLNAME echo '> Subgraph version: '$SUBGRAPH_VERSION +# check if the repo address is null or zero address +FILE=manifest/data/$SUBGRAPH_NETWORK_NAME'.json' + +address=$(jq -r '.dataSources.Plugin.address' "$FILE") + +if [ "$address" = "null" ] || [ "$address" = "0x0000000000000000000000000000000000000000" ]; + then + echo "Repo address is not set properly, exiting..." + exit -1 +fi + # Deploy subgraph if [ "$LOCAL" ] then diff --git a/packages/subgraph/scripts/import-plugin-repo.ts b/packages/subgraph/scripts/import-plugin-repo.ts index 8f9d655c..59bad356 100644 --- a/packages/subgraph/scripts/import-plugin-repo.ts +++ b/packages/subgraph/scripts/import-plugin-repo.ts @@ -1,29 +1,45 @@ +import {SupportedNetworks} from '@aragon/osx-commons-configs'; import dotenv from 'dotenv'; import fs from 'fs'; import path from 'path'; +const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; + // Specify the path to the .env file at the root const rootDir = path.join(__dirname, '../../../'); // Adjust the path as necessary dotenv.config({path: path.join(rootDir, '.env')}); +// path to the networks manifests +const manifestsPath = path.join(__dirname, '../manifest/data'); -// Extract Repo address from the production-network-deployments.json -function extractAndWriteAddressToTS(jsonPath: string): void { - // Read the production-network-deployments.json file - const aragonDeploymentsInfo = JSON.parse(fs.readFileSync(jsonPath, 'utf8')); - +function extractAndWriteAddressToTS(): void { // Get the network from environment variables const network = process.env.SUBGRAPH_NETWORK_NAME; - // Check if the network is defined in aragonDeploymentsInfo - if (!network || !aragonDeploymentsInfo[network]) { - throw new Error( - `Network '${network}' not found in production-network-deployments.json` + // Check if the network is provided and supported + if ( + !network || + !Object.values(SupportedNetworks).includes(network as SupportedNetworks) + ) { + throw new Error(`Network '${network}' invalid or not Supported.`); + } + + // get the plugin address from the network manifest + const networkManifestPath = path.join(manifestsPath, `${network}.json`); + let networkRepoAddress = JSON.parse( + fs.readFileSync(networkManifestPath, 'utf8') + ).dataSources.Plugin.address; + + // check if address is null and throw warning and continue with zero address + if (!networkRepoAddress) { + console.warn( + '\x1b[33m%s\x1b[0m', + `WARNING: Plugin address for network '${network}' is null. Using zero address.` ); + networkRepoAddress = ZERO_ADDRESS; } - // Start the Map creation code with the specific network address const tsContent: string[] = [ - `export const PLUGIN_REPO_ADDRESS = '${aragonDeploymentsInfo[network].address}';`, + `export const PLUGIN_REPO_ADDRESS = '${networkRepoAddress}';`, ]; const outputDir = path.join(__dirname, '../imported'); @@ -42,8 +58,4 @@ function extractAndWriteAddressToTS(jsonPath: string): void { ); } -const aragonDeploymentsInfoPath = path.join( - rootDir, - 'production-network-deployments.json' -); -extractAndWriteAddressToTS(aragonDeploymentsInfoPath); +extractAndWriteAddressToTS(); diff --git a/packages/subgraph/yarn.lock b/packages/subgraph/yarn.lock index e209c607..7d11039e 100644 --- a/packages/subgraph/yarn.lock +++ b/packages/subgraph/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@aragon/osx-commons-configs@0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@aragon/osx-commons-configs/-/osx-commons-configs-0.2.0.tgz#32f83596f4a2e9e48aef61cf560c1c5b4d32a049" - integrity sha512-wCFtgmuGCzs8L5mCxVCYQ6uEu69IrofS7q2w7E1Fjk7/nWuSmRUpgmif3ki9BQq1qpOvDu2P+u3UNLnIz8J82g== +"@aragon/osx-commons-configs@0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@aragon/osx-commons-configs/-/osx-commons-configs-0.4.0.tgz#5b6ae025de1ccf7f9a135bfbcb0aa822c774acf9" + integrity sha512-/2wIQCbv/spMRdOjRXK0RrXG1TK5aMcbD73RvMgMwQwSrKcA1dCntUuSxmTm2W8eEtOzs8E1VPjqZk0cXL4SSQ== dependencies: tslib "^2.6.2"