-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Preparing the ABI package for NPM * Removing the redundant rollup config * Yarn.lock update * Updated package.json definition * Minor edit * Ingoring NPM postinstall scripts * Scaffolding the addresses file * Exporting artifacts with a deprecation warning * Amending the readme using the intended import usage * Prepopulating the upgradeable protocol contracts * Minor edit * Adding the existing PSP addresses (v1.3) * Version edit * Improved readme * Minor edit * Minor edit * Adding PUB_PINATA_JWT to .env.example * add artifacts publish github flow * Adding a placeholder for Pinata JWT in .env.example * add alpha * Removing a non relevant command on contract-tests.yml --------- Co-authored-by: Rekard0 <[email protected]>
- Loading branch information
Showing
25 changed files
with
439 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Publish 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Aragon OSx 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.4.0 | ||
|
||
### Changed | ||
|
||
- Shipping the ABI and addresses for OSx v1.4 | ||
- Marking `ContractName.abi` and `ContractName.bytecode` as deprecated | ||
- Note: certain contracts that were previously exported and were not really related to OSx are no longer present. | ||
|
||
## v1.3.0 | ||
|
||
### Added | ||
|
||
- Shipping the artifacts for OSx v1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Aragon OSx artifacts | ||
|
||
This package contains the ABI definitions of the OSx contracts, as well as the address of the protocol instances deployed on each network. Install it with: | ||
|
||
```sh | ||
yarn add @aragon/osx-artifacts | ||
``` | ||
|
||
## Usage | ||
|
||
```typescript | ||
// ABI definitions | ||
import { | ||
DAOABI, | ||
IDAOABI, | ||
DAOFactoryABI, | ||
DAORegistryABI, | ||
PluginRepoABI, | ||
PluginRepoFactoryABI, | ||
PluginRepoRegistryABI, | ||
PluginSetupProcessorABI, | ||
PermissionManagerABI | ||
} from "@aragon/osx-artifacts"; | ||
|
||
console.log("DAO ABI", DAOABI); | ||
|
||
// Protocol addresses per-network | ||
import { addresses } from "@aragon/osx-artifacts"; | ||
|
||
console.log(addresses.daoFactory.mainnet); | ||
``` | ||
|
||
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/osx-contracts/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/osx/blob/main/CONTRIBUTION_GUIDE.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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "@aragon/osx-artifacts", | ||
"version": "1.4.0-alpha", | ||
"description": "The ABI definitions and addresses for Aragon OSx", | ||
"typings": "dist/index.d.ts", | ||
"main": "dist/index.js", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "yarn prepare-abi && rm -Rf dist && tsc -p tsconfig.json", | ||
"prepare-abi": "bash prepare-abi.sh", | ||
"prepublishOnly": "yarn build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/aragon/osx" | ||
}, | ||
"author": "Aragon X", | ||
"license": "AGPL-3.0-or-later", | ||
"bugs": { | ||
"url": "https://github.com/aragon/osx/issues" | ||
}, | ||
"homepage": "https://github.com/aragon/osx#readme", | ||
"devDependencies": { | ||
"typescript": "^5.7.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/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 | ||
CONTRACT_ARTIFACTS=$(ls \ | ||
$CONTRACTS_FOLDER/artifacts/src/core/*/*/*.json \ | ||
$CONTRACTS_FOLDER/artifacts/src/framework/*/*/*.json \ | ||
$CONTRACTS_FOLDER/artifacts/src/framework/*/*/*/*.json \ | ||
| grep -v ".dbg." \ | ||
| grep -v utils | ||
) | ||
for FILE in $CONTRACT_ARTIFACTS | ||
do | ||
SRC_FILE_NAME=$(basename $FILE) | ||
|
||
# Backwards compatible exports with abi and bytecode | ||
ABI=$(node -e "console.log(JSON.stringify(JSON.parse(fs.readFileSync('$FILE').toString()).abi))") | ||
BYTECODE=$(node -e "console.log(JSON.parse(fs.readFileSync('$FILE').toString()).bytecode || '')") | ||
CONTRACT_NAME=${SRC_FILE_NAME%".json"} | ||
|
||
echo "export const ${CONTRACT_NAME}ABI = $ABI as const;" >> $TARGET_ABI_FILE | ||
|
||
if [ "$BYTECODE" == "0x" -o "$BYTECODE" == "" ]; then | ||
echo "const ${CONTRACT_NAME}Bytecode = null;" >> $TARGET_ABI_FILE | ||
else | ||
echo "const ${CONTRACT_NAME}Bytecode = \"$BYTECODE\";" >> $TARGET_ABI_FILE | ||
fi | ||
|
||
echo " | ||
export class ${CONTRACT_NAME} { | ||
/** @deprecated Use \`${CONTRACT_NAME}ABI\` instead. */ | ||
static get abi() { | ||
console.warn('Warning: \`${CONTRACT_NAME}.abi\` is deprecated. Use \`${CONTRACT_NAME}ABI\` instead.'); | ||
return ${CONTRACT_NAME}ABI; | ||
} | ||
/** @deprecated Use the bytecode deployed on the target network. See addresses.json */ | ||
static get bytecode(): \`0x\${string}\` | null { | ||
console.warn('Warning: \`${CONTRACT_NAME}.bytecode\` is deprecated and may be removed in future versions.'); | ||
return ${CONTRACT_NAME}Bytecode; | ||
} | ||
} | ||
" >> $TARGET_ABI_FILE | ||
|
||
echo "" >> $TARGET_ABI_FILE | ||
done | ||
|
||
# Common interfaces JSON ABI | ||
EXTRA_CONTRACT_ABI_FILES=$(ls \ | ||
$CONTRACTS_FOLDER/artifacts/@aragon/osx-commons-contracts/src/dao/*.sol/*.json \ | ||
$CONTRACTS_FOLDER/artifacts/@aragon/osx-commons-contracts/src/executors/*.sol/*.json \ | ||
$CONTRACTS_FOLDER/artifacts/@aragon/osx-commons-contracts/src/permission/*/*.sol/*.json \ | ||
$CONTRACTS_FOLDER/artifacts/@aragon/osx-commons-contracts/src/plugin/*.sol/*.json \ | ||
$CONTRACTS_FOLDER/artifacts/@aragon/osx-commons-contracts/src/plugin/setup/*.sol/*.json \ | ||
$CONTRACTS_FOLDER/artifacts/@aragon/osx-commons-contracts/src/utils/versioning/*.sol/*.json \ | ||
| grep -v ".dbg." | ||
) | ||
|
||
# Shipping the common interfaces as well | ||
for FILE in $EXTRA_CONTRACT_ABI_FILES | ||
do | ||
SRC_FILE_NAME=$(basename $FILE) | ||
|
||
ABI=$(node -e "console.log(JSON.stringify(JSON.parse(fs.readFileSync('$FILE').toString()).abi))") | ||
BYTECODE=$(node -e "console.log(JSON.parse(fs.readFileSync('$FILE').toString()).bytecode || '')") | ||
CONTRACT_NAME=${SRC_FILE_NAME%".json"} | ||
|
||
echo "export const ${CONTRACT_NAME}ABI = $ABI as const;" >> $TARGET_ABI_FILE | ||
|
||
if [ "$BYTECODE" == "0x" -o "$BYTECODE" == "" ]; then | ||
echo "const ${CONTRACT_NAME}Bytecode = null;" >> $TARGET_ABI_FILE | ||
else | ||
echo "const ${CONTRACT_NAME}Bytecode = \"$BYTECODE\";" >> $TARGET_ABI_FILE | ||
fi | ||
|
||
echo " | ||
export class ${CONTRACT_NAME} { | ||
/** @deprecated Use \`${CONTRACT_NAME}ABI\` instead. */ | ||
static get abi() { | ||
console.warn('Warning: \`${CONTRACT_NAME}.abi\` is deprecated. Use \`${CONTRACT_NAME}ABI\` instead.'); | ||
return ${CONTRACT_NAME}ABI; | ||
} | ||
/** @deprecated Use the bytecode deployed on the target network. See addresses.json */ | ||
static get bytecode(): \`0x\${string}\` | null { | ||
console.warn('Warning: \`${CONTRACT_NAME}.bytecode\` is deprecated and may be removed in future versions.'); | ||
return ${CONTRACT_NAME}Bytecode; | ||
} | ||
} | ||
" >> $TARGET_ABI_FILE | ||
|
||
echo "" >> $TARGET_ABI_FILE | ||
done | ||
|
||
echo "ABI prepared: $TARGET_ABI_FILE" |
Oops, something went wrong.