Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABI generation for NPM #47

Merged
merged 26 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## The network used for testing purposes
NETWORK_NAME="sepolia" # ["mainnet", "sepolia", "polygon", "mumbai","baseMainnet", "baseGoerli", "baseSepolia", "arbitrum", "arbitrumSepolia"]

## To deploy contracts, you need to set:
## To upload the metadata for deployed contracts
PUB_PINATA_JWT=

# CONTRACTS
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/contracts-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
node-version: 18

- name: 'Install the dependencies'
run: 'yarn install --frozen-lockfile'
run: 'yarn --frozen-lockfile --ignore-scripts'

- name: 'Build the contracts'
run: 'yarn build'
Expand All @@ -38,3 +38,4 @@ jobs:
env:
NETWORK_NAME: ${{ vars.NETWORK_NAME }}
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
PUB_PINATA_JWT: ${{ secrets.PUB_PINATA_JWT }}
2 changes: 1 addition & 1 deletion .github/workflows/formatting-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
node-version: 18

- name: 'Install the dependencies'
run: 'yarn install --frozen-lockfile'
run: 'yarn --frozen-lockfile --ignore-scripts'

- name: 'Check code formatting'
run: 'yarn prettier:check'
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/publish-npm-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish NPM Artifacts

on:
workflow_dispatch:

jobs:
publish-artifacts-to-npm:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org/'

- name: Configure NPM for Scoped Package
run: |
cd packages/artifacts
SCOPE=$(jq -r '.name' package.json | cut -d'/' -f1)
echo "$SCOPE:registry=https://registry.npmjs.org/" > ~/.npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc

- name: Get Version from package.json
id: get_version
run: |
cd packages/artifacts
VERSION=$(jq -r '.version' package.json)
TAG_VERSION="v$VERSION"
echo "VERSION=$TAG_VERSION" >> $GITHUB_ENV

- name: Create Git Tag
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git tag $VERSION
git push origin $VERSION

- name: Install Dependencies
run: |
cd packages/artifacts
yarn install

- name: Build Package
env:
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
run: |
cd packages/artifacts
yarn build

- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd packages/artifacts
if [[ "$VERSION" == *"-alpha"* ]]; then
npm publish --tag alpha --access public
else
npm publish --tag latest --access public
fi
6 changes: 3 additions & 3 deletions .github/workflows/subgraph-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ jobs:
node-version: 18

- name: 'Install root dependencies'
run: 'yarn install --frozen-lockfile'
run: 'yarn --frozen-lockfile --ignore-scripts'
working-directory: .

- name: 'Install dependencies for contracts'
run: 'yarn install --frozen-lockfile'
run: 'yarn --frozen-lockfile --ignore-scripts'
working-directory: packages/contracts

- name: 'Install the dependencies for subgraph'
run: 'yarn install --frozen-lockfile'
run: 'yarn --frozen-lockfile --ignore-scripts'
working-directory: packages/subgraph

- name: 'Build the subgraph'
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.coverage_artifacts
.coverage_cache
.coverage_contracts
artifacts
build
cache
coverage
Expand All @@ -17,6 +16,9 @@ packages/subgraph/tests/.bin
packages/contracts/.upgradable
packages/contracts/deployments
packages/contracts/createVersionProposalData*.json
packages/contracts/artifacts

packages/artifacts/src/abi.ts

# files
*.env
Expand All @@ -32,4 +34,4 @@ packages/subgraph/tests/helpers/extended-schema.ts

artifacts-zk
cache-zk
deployments-zk
deployments-zk
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The root folder of the repo includes two subfolders:
The root-level `package.json` file contains global `dev-dependencies` for formatting and linting. After installing the dependencies with

```sh
yarn install
yarn --ignore-scripts
```

you can run the associated [formatting](#formatting) and [linting](#linting) commands.
Expand Down Expand Up @@ -79,7 +79,7 @@ Before deploying, you MUST also change the default hardhat private key (`PRIVATE
This package is located in `packages/contracts`, first run

```sh
yarn install
yarn --ignore-scripts
```

### Building
Expand Down Expand Up @@ -235,7 +235,7 @@ yarn deploy:zksync --network zksyncMainnet --tags ...
In `packages/subgraph`, first run

```sh
yarn install
yarn --ignore-scripts
```

which will also run
Expand Down
11 changes: 11 additions & 0 deletions packages/artifacts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Multisig Plugin artifacts

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.3.0

### Added

- First NPM release of the Plugin's ABI (release 1, build 3)

58 changes: 58 additions & 0 deletions packages/artifacts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Multisig Plugin artifacts

This package contains the ABI of the Multisig Plugin for OSx, as well as the address of its plugin repository on each supported network. Install it with:

```sh
yarn add @aragon/multisig-plugin-artifacts
```

## Usage

```typescript
// ABI definitions
import {
MultisigABI,
IMultisigABI,
ListedCheckConditionABI,
MultisigSetupABI
} from "@aragon/multisig-plugin-artifacts";

// Plugin Repository addresses per-network
import { addresses } from "@aragon/multisig-plugin-artifacts";
```

You can also open [addresses.json](./src/addresses.json) directly.

## Development

### Building the package

Install the dependencies and generate the local ABI definitions.

```sh
yarn --ignore-scripts
yarn build
```

The `build` script will:
1. Move to `packages/contracts`.
2. Install its dependencies.
3. Compile the contracts using Hardhat.
4. Generate their ABI.
5. Extract their ABI and embed it into on `src/abi.ts`.

## Documentation

You can find all documentation regarding how to use this plugin in [Aragon's documentation here](https://docs.aragon.org/multisig/1.x/index.html).

## Contributing

If you like what we're doing and would love to support, please review our `CONTRIBUTING_GUIDE.md` [here](https://github.com/aragon/multisig-plugin/blob/main/CONTRIBUTIONS.md). We'd love to build with you.

## Security

If you believe you've found a security issue, we encourage you to notify us. We welcome working with you to resolve the issue promptly.

Security Contact Email: [email protected]

Please do not use the issue tracker for security issues.
22 changes: 22 additions & 0 deletions packages/artifacts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@aragon/multisig-plugin-artifacts",
"author": "Aragon X",
"version": "1.3.0-alpha",
"license": "AGPL-3.0-or-later",
"description": "The Multisig Plugin ABI definition",
"typings": "dist/index.d.ts",
"main": "dist/index.js",
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "yarn prepare-abi && rm -Rf dist && tsc -p tsconfig.json",
"prepare-abi": "bash prepare-abi.sh"
},
"devDependencies": {
"typescript": "^5.5.4"
}
}
35 changes: 35 additions & 0 deletions packages/artifacts/prepare-abi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

# Exit on error
set -e

# Constants
CONTRACTS_FOLDER="../contracts"
TARGET_ABI_FILE="./src/abi.ts"

# Move into contracts package and install dependencies
cd $CONTRACTS_FOLDER

yarn --ignore-scripts && yarn build

# Move back to artifacts package
cd - > /dev/null

# Wipe the destination file
echo "// NOTE: Do not edit this file. It is generated automatically." > $TARGET_ABI_FILE

# Extract the abi field and create a TS file
for SRC_CONTRACT_FILE in $(ls $CONTRACTS_FOLDER/src/*.sol )
do
SRC_FILE_NAME=$(basename $(echo $SRC_CONTRACT_FILE))
SRC_FILE_PATH=$CONTRACTS_FOLDER/artifacts/src/$SRC_FILE_NAME/${SRC_FILE_NAME%".sol"}.json

ABI=$(node -e "console.log(JSON.stringify(JSON.parse(fs.readFileSync(\"$SRC_FILE_PATH\").toString()).abi))")
CONTRACT_NAME=${SRC_FILE_NAME%".sol"}

echo "const ${CONTRACT_NAME}ABI = $ABI as const;" >> $TARGET_ABI_FILE
echo "export {${CONTRACT_NAME}ABI};" >> $TARGET_ABI_FILE
echo "" >> $TARGET_ABI_FILE
done

echo "ABI prepared: $TARGET_ABI_FILE"
18 changes: 18 additions & 0 deletions packages/artifacts/src/addresses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"pluginRepo": {
"mainnet": "0x8c278e37D0817210E18A7958524b7D0a1fAA6F7b",
"sepolia": "0x9e7956C8758470dE159481e5DD0d08F8B59217A2",
"holesky": "0xde1414F52A885cb9b899870f85bDCdb2Dec7C5dd",
"devSepolia": "0xA0901B5BC6e04F14a9D0d094653E047644586DdE",
"polygon": "0x5A5035E7E8aeff220540F383a9cf8c35929bcF31",
"mumbai": "0x2c4690b8be39adAd4F15A69340d5035aC6E53eEF",
"base": "0xcDC4b0BC63AEfFf3a7826A19D101406C6322A585",
"baseSepolia": "0x9e7956C8758470dE159481e5DD0d08F8B59217A2",
"arbitrum": "0x7553E6Fb020c5740768cF289e603770AA09b7aE2",
"arbitrumSepolia": "0x9e7956C8758470dE159481e5DD0d08F8B59217A2",
"linea": "0x2667636E0f5eA63c771509e1d3377177E9Da056D",
"lineaSepolia": "0x86B433017Ce556ED93e6D34d6Ba0e3a9EB19015C",
"zksync": "0x83f88d380073c8F929fAB649F3d016649c101D3A",
"zksyncSepolia": "0x2cae809b6ca149b49cBcA8B887Da2805174052F3"
}
}
4 changes: 4 additions & 0 deletions packages/artifacts/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./abi";

import * as addresses from "./addresses.json";
export {addresses};
10 changes: 10 additions & 0 deletions packages/artifacts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"resolveJsonModule": true
},
"include": ["src"]
}
8 changes: 8 additions & 0 deletions packages/artifacts/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


typescript@^5.5.4:
version "5.7.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.3.tgz#919b44a7dbb8583a9b856d162be24a54bf80073e"
integrity sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==
17 changes: 8 additions & 9 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,23 @@
"@openzeppelin/contracts-upgradeable": "^4.9.6"
},
"devDependencies": {
"@aragon/osx": "^1.4.0",
"@aragon/osx-commons-configs": "^0.8.0",
"@aragon/osx-commons-sdk": "^0.2.0",
"@aragon/osx-ethers": "^1.4.0",
"@aragon/osx": "^1.4.0",
"@aragon/osx-v1.0.0": "npm:@aragon/[email protected]",
"@aragon/osx-v1.3.0": "npm:@aragon/[email protected]",
"@matterlabs/hardhat-zksync-deploy": "0.8",
"@matterlabs/hardhat-zksync-node": "0.1.0",
"@matterlabs/hardhat-zksync-solc": "1.2.5",
"@matterlabs/hardhat-zksync-upgradable": "0.4.0",
"@matterlabs/hardhat-zksync-verify": "0.7.0",
"@matterlabs/hardhat-zksync-ethers": "0.0.1-beta.2",
"zksync-ethers": "5.7.0",
"@ethersproject/abi": "5.7.0",
"@ethersproject/abstract-signer": "5.7.0",
"@ethersproject/bignumber": "5.7.0",
"@ethersproject/bytes": "5.7.0",
"@ethersproject/providers": "5.7.2",
"@matterlabs/hardhat-zksync-deploy": "0.8",
"@matterlabs/hardhat-zksync-ethers": "0.0.1-beta.2",
"@matterlabs/hardhat-zksync-node": "0.1.0",
"@matterlabs/hardhat-zksync-solc": "1.2.5",
"@matterlabs/hardhat-zksync-upgradable": "0.4.0",
"@matterlabs/hardhat-zksync-verify": "0.7.0",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
Expand Down Expand Up @@ -77,6 +76,6 @@
"ts-node": "^10.9.1",
"typechain": "^8.3.2",
"typescript": "^5.2.2",
"undici": "^6.11.1"
"zksync-ethers": "5.7.0"
}
}
Loading
Loading