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

Automatically publish @celo/contracts and @celo/abis with contract releases #10297

Merged
merged 65 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
6030487
chore: npm publish scripts WIP
nicolasbrugneaux May 5, 2023
720fd4d
feat: add types
nicolasbrugneaux May 10, 2023
b997d18
release v9
nicolasbrugneaux May 19, 2023
3584a83
chore: add wagmi types generation
nicolasbrugneaux May 24, 2023
9e76902
chore: [email protected]
nicolasbrugneaux May 30, 2023
ef5f56f
chore: change licensing
nicolasbrugneaux Oct 5, 2023
7bb3dd9
fix: typings in build.ts
nicolasbrugneaux Oct 5, 2023
8e891ad
fix: remove unnecessary step from build
nicolasbrugneaux Oct 6, 2023
10d0682
fix: update dependencies in order to make everything work
nicolasbrugneaux Oct 11, 2023
912c562
chore: update actions
nicolasbrugneaux Oct 11, 2023
b0521e4
chore: update actions
nicolasbrugneaux Oct 11, 2023
52668e5
chore: disable akyeless for testing
nicolasbrugneaux Oct 11, 2023
9fc9a87
chore: install yarn
nicolasbrugneaux Oct 11, 2023
b974821
fix: add run?
nicolasbrugneaux Oct 11, 2023
eaaa728
chore: change version in package.jsons
nicolasbrugneaux Oct 12, 2023
399492a
chore: disable akyeless for testing
nicolasbrugneaux Oct 12, 2023
eef905b
chore: add back the cd
nicolasbrugneaux Oct 12, 2023
e2ef7ec
chore: i dont even know
nicolasbrugneaux Oct 12, 2023
7cfc549
chore: use working-directory
nicolasbrugneaux Oct 12, 2023
4a2ae80
Merge branch 'master' into chore/contract-publishing
nicolasbrugneaux Oct 12, 2023
d2ccba5
chore: change runner
nicolasbrugneaux Oct 12, 2023
1ca9b42
chore: correct version number
nicolasbrugneaux Oct 12, 2023
4221d75
chore: handle workflow input and remove custom branch push rule
nicolasbrugneaux Oct 12, 2023
4a9f388
Merge branch 'master' into chore/contract-publishing
nicolasbrugneaux Oct 16, 2023
5e368df
Merge branch 'master' into chore/contract-publishing
nicolasbrugneaux Oct 16, 2023
c7e3149
fix: contractkit wrapper spelling changed for some reason
nicolasbrugneaux Oct 16, 2023
8f2dc4c
chore: add changeset
nicolasbrugneaux Oct 16, 2023
30deaab
fix: CLI importing generated file path
nicolasbrugneaux Oct 16, 2023
f3b6a65
fix: tslint errors
nicolasbrugneaux Oct 17, 2023
91beae3
Merge branch 'master' into chore/contract-publishing
nicolasbrugneaux Oct 17, 2023
7295f3e
fix: core-contract version
nicolasbrugneaux Oct 17, 2023
7593231
Update celo-monorepo.yml
martinvol Oct 18, 2023
d2c152c
Merge branch 'master' into chore/contract-publishing
nicolasbrugneaux Nov 2, 2023
d040cde
Merge branch 'master' into chore/contract-publishing
nicolasbrugneaux Nov 3, 2023
14ebac6
fix: generate devchain if not exists
nicolasbrugneaux Nov 6, 2023
a5bc73a
Merge branch 'master' into chore/contract-publishing
martinvol Nov 6, 2023
7a0ec0f
chore: remove unecessary file
nicolasbrugneaux Nov 7, 2023
228a42e
fix: repo url in the abis and contracts packages
nicolasbrugneaux Nov 7, 2023
c7bce48
fix: try fixing errors coming from the CR10 merge
nicolasbrugneaux Nov 7, 2023
771c0ec
Merge branch 'master' into chore/contract-publishing
nicolasbrugneaux Nov 7, 2023
2a7b44e
chore: rollback to es5 for tsconfig.json
nicolasbrugneaux Nov 7, 2023
ddfa7bd
fix: action typo
nicolasbrugneaux Nov 7, 2023
399fe8f
fix: dependency graph
nicolasbrugneaux Nov 7, 2023
67b272b
fixed build for protocol
martinvol Nov 7, 2023
9be5fe7
turn on SSH
martinvol Nov 7, 2023
03f67a5
fixed syntax
martinvol Nov 7, 2023
3afe965
Try to fix a git submodule bug
martinvol Nov 7, 2023
04b4626
Fixed submodules issue
martinvol Nov 8, 2023
ddb4030
forgot to comming package.json
martinvol Nov 8, 2023
34398cf
force remove of all submodules
martinvol Nov 8, 2023
0295409
disabled ssh
martinvol Nov 8, 2023
40b7cf1
try not to remove the modules folder
martinvol Nov 8, 2023
ed330df
enabled ssh in Protocol Test Release
martinvol Nov 8, 2023
73da5fa
turn on the right ssh
martinvol Nov 8, 2023
9c372ae
Fixed chain submodules after checkout
martinvol Nov 8, 2023
f995d8e
Merge branch 'master' of github.com:celo-org/celo-monorepo into chore…
martinvol Nov 8, 2023
edc04ba
deleted checkouts and see if it works
martinvol Nov 8, 2023
80c8f29
retrigger ci, didn't start last commit
martinvol Nov 8, 2023
a9424ca
Merge branch 'master' of github.com:celo-org/celo-monorepo into chore…
martinvol Nov 8, 2023
2c56ad3
Merge branch 'master' into chore/contract-publishing
martinvol Nov 9, 2023
c1fc2f8
commit yarn lock
martinvol Nov 9, 2023
a0ef94e
Merge branch 'master' into chore/contract-publishing
martinvol Nov 9, 2023
d98f427
yarn lock, again
martinvol Nov 9, 2023
cdecfd8
Merge branch 'master' of github.com:celo-org/celo-monorepo into chore…
martinvol Nov 13, 2023
da74a13
better yarn.lock merge
martinvol Nov 13, 2023
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: 2 additions & 0 deletions .changeset/itchy-tips-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
nicolasbrugneaux marked this conversation as resolved.
Show resolved Hide resolved
---
13 changes: 3 additions & 10 deletions .github/workflows/celo-monorepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ env:
TERM: dumb
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.parallel=false -Dorg.gradle.configureondemand=true -Dorg.gradle.jvmargs="-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError"'
# Git Tag for contract release to use
#RELEASE_TAG: ganache-v7-core-contracts.v9
RELEASE_TAG: core-contracts.v10
# CELO_BLOCKCHAIN_BRANCH_TO_TEST: master
CELO_BLOCKCHAIN_BRANCH_TO_TEST: release/1.7.x
Expand Down Expand Up @@ -215,7 +214,7 @@ jobs:
# image: us-west1-docker.pkg.dev/devopsre/actions-runner-controller/celo-monorepo:node18
# # Required root to install node12
# options: --user root
timeout-minutes: 30
timeout-minutes: 300
martinvol marked this conversation as resolved.
Show resolved Hide resolved
# Comment lint-checks dependency to speed up (as this is a dependency for many other jobs)
# needs: [install-dependencies, lint-checks]
needs: [install-dependencies]
Expand Down Expand Up @@ -255,12 +254,6 @@ jobs:
# Workaround for https://stackoverflow.com/questions/72978485/git-submodule-update-failed-with-fatal-detected-dubious-ownership-in-repositor
- name: Configure git safe directories
run: git config --global --add safe.directory '*'
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
timeout-minutes: 60
if: false
with:
limit-access-to-actor: true
- name: Generate devchain of previous release
run: |
echo "Comparing against $RELEASE_TAG"
Expand Down Expand Up @@ -302,11 +295,11 @@ jobs:
sudo apt-get update
sudo apt-get install vim lsof --yes
BUILD_AND_DEVCHAIN_DIR=$(echo build/$(echo $RELEASE_TAG | sed -e 's/\//_/g'))
yarn --cwd packages/protocol test:devchain-release -b $RELEASE_TAG -d $BUILD_AND_DEVCHAIN_DIR -l /dev/stdout
yarn --cwd packages/protocol test:devchain-release -b $RELEASE_TAG -d $BUILD_AND_DEVCHAIN_DIR -l /dev/stdout || echo "failed"
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
timeout-minutes: 500
martinvol marked this conversation as resolved.
Show resolved Hide resolved
if: false
if: true
with:
limit-access-to-actor: true
protocol-test-matrix:
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/publish-contracts-abi-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Publish ABIs and Solidity files to NPM
on:
release:
types: [released]

workflow_dispatch:
inputs:
npm_version:
description: 'NPM version'
required: true
type: string
jobs:
publish:
runs-on: ['self-hosted', 'org', '8-cpu']
container:
# Update image at https://github.com/celo-org/infrastructure/blob/master/terraform/root-modules/gcp/integration-tests-gke/files/github-arc/Dockerfiles/Dockerfile-monorepo
image: us-west1-docker.pkg.dev/devopsre/actions-runner-controller/celo-monorepo:node18
permissions:
contents: write
id-token: write
repository-projects: read
steps:
- uses: actions/checkout@v4
- name: Akeyless Get Secrets
id: get_auth_token
uses: docker://us-west1-docker.pkg.dev/devopsre/akeyless-public/akeyless-action:latest
with:
api-url: https://api.gateway.akeyless.celo-networks-dev.org
access-id: p-kf9vjzruht6l
static-secrets: '{"/static-secrets/apps-tooling-circle/npm-publish-token":"NPM_TOKEN"}'
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
scope: '@celo'

- name: 'Setup yarn'
shell: bash
run: |
npm install --global yarn
source ~/.bashrc

- name: 'Install packages'
run: yarn

- name: Check if a release should be published
run: yarn --silent is_contract_release >> "$GITHUB_ENV"
working-directory: packages/protocol
env:
GITHUB_TAG: ${{ github.ref_name }}
INPUT_VERSION: ${{ inputs.npm_version }}

- if: ${{ env.RELEASE_VERSION != '' }}
name: Compile solidity contracts and typescript files
run: yarn build && yarn prepare_contracts_and_abis_publishing
working-directory: packages/protocol
env:
RELEASE_TYPE: ${{ env.RELEASE_TYPE }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}

- if: ${{ env.RELEASE_VERSION != '' }}
name: Publish @celo/contracts
run: yarn publish contracts --tag latest --version $RELEASE_VERSION --no-git-tag-version
working-directory: packages/protocol
env:
RELEASE_TYPE: ${{ env.RELEASE_TYPE }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
NPM_TOKEN: ${{ env.NPM_TOKEN }}

- if: ${{ env.RELEASE_VERSION != '' }}
name: Publish @celo/abis
run: yarn publish build/contracts --tag latest --version $RELEASE_VERSION --no-git-tag-version
working-directory: packages/protocol
env:
RELEASE_TYPE: ${{ env.RELEASE_TYPE }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
NPM_TOKEN: ${{ env.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions packages/cli/src/commands/transfer/erc20.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Ierc20 } from '@celo/contractkit/lib/generated/IERC20'
import { IERC20 } from '@celo/contractkit/lib/generated/IERC20'
import { Erc20Wrapper } from '@celo/contractkit/lib/wrappers/Erc20Wrapper'
import { flags } from '@oclif/command'
import BigNumber from 'bignumber.js'
Expand Down Expand Up @@ -42,7 +42,7 @@ export default class TransferErc20 extends BaseCommand {
const value = new BigNumber(res.flags.value)

this.kit.defaultAccount = from
let celoToken: Erc20Wrapper<Ierc20>
let celoToken: Erc20Wrapper<IERC20>
try {
celoToken = await this.kit.contracts.getErc20(res.flags.erc20Address)
// this call allow us to check if it is a valid erc20
Expand Down
2 changes: 2 additions & 0 deletions packages/protocol/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ deployedGrants.json
cache/
out/

wagmi.config.js
wagmi.config.js.map
4 changes: 2 additions & 2 deletions packages/protocol/contractPackages.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export interface ContractPackage {
path?: string
folderPath?: string
name?: string
contracstFolder?: string
name: string
contracts: string[]
contracstFolder?: string
proxyContracts?: string[]
truffleConfig?: string
solidityVersion?: string
Expand Down
3 changes: 3 additions & 0 deletions packages/protocol/contracts/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test/*
package.abis.json
README.abis.md
37 changes: 37 additions & 0 deletions packages/protocol/contracts/README.abis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Celo core contracts ABIS

Smart contracts ABIS for the Celo protocol.

## Usage

### Installation

```bash
npm install @celo/abis
```

or

```bash
yarn add @celo/abis
```

### In your javascript or ts

```ts
// json abi
import Accounts from '@celo/abis/Accounts.json'

// ethers
import { Accounts } from '@celo/abis/types/ethers'

// web3
import Accounts from '@celo/abis/types/web3/Accounts'

// truffle
import { AccountsContract } from '@celo/abis/types/truffle'
```

## License

All packages are licensed under the terms of the Apache 2.0 License unless otherwise specified in the LICENSE file at package's root.
36 changes: 36 additions & 0 deletions packages/protocol/contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Celo core contracts

Smart contracts for the Celo protocol.

## Usage

### Installation

```bash
npm install @celo/contracts
```

or

```bash
yarn add @celo/contracts
```

### In your Solidity contracts

```solidity
pragma solidity ^0.5.13;

import '@celo/contracts/common/UsingRegistryV2.sol';

contract Example is UsingRegistryV2 {
constructor() public {
require(getAccounts().createAccount());
}
}

```

## License

The contents of this package are licensed under the terms of the GNU Lesser Public License V3
14 changes: 14 additions & 0 deletions packages/protocol/contracts/package.abis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@celo/abis",
"version": "0.0.0-template.version",
"author": "cLabs",
"license": "LGPL-3.0",
"repository": {
"type": "git",
"url": "https://github.com/celo-org/celo-monorepo.git",
"directory": "packages/protocol/contracts"
},
"scripts": {},
"dependencies": {},
"types": "./types/ethers/index.d.ts"
}
13 changes: 13 additions & 0 deletions packages/protocol/contracts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@celo/contracts",
"version": "0.0.0-template.version",
"author": "cLabs",
"license": "LGPL-3.0",
"repository": {
"type": "git",
"url": "https://github.com/celo-org/celo-monorepo.git",
"directory": "packages/protocol/contracts"
},
"scripts": {},
"dependencies": {}
}
11 changes: 4 additions & 7 deletions packages/protocol/lib/registry-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* an environment.
*/

import { ContractPackage, MENTO_PACKAGE } from "../contractPackages"
import { ContractPackage, MENTO_PACKAGE, SOLIDITY_08_PACKAGE } from "../contractPackages"

export const celoRegistryAddress = '0x000000000000000000000000000000000000ce10'

Expand Down Expand Up @@ -54,6 +54,7 @@ export const usesRegistry = [

export const hasEntryInRegistry: ContractPackage[]= [
{
name: "default",
contracts:[
CeloContractName.Accounts,
CeloContractName.Attestations,
Expand All @@ -72,12 +73,8 @@ export const hasEntryInRegistry: ContractPackage[]= [
CeloContractName.SortedOracles,
]
},
{
contracts:[
CeloContractName.GasPriceMinimum,
],
path: "contracts-0.8"
},
SOLIDITY_08_PACKAGE
,
{
...MENTO_PACKAGE,
// not all Mentro contracts are supposed to be in the Registry
Expand Down
17 changes: 13 additions & 4 deletions packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
"build:ts": "rm -f migrations/*.js* && ts-node --preferTsExts ./scripts/build.ts --truffleTypes ./types/typechain && tsc -b && mv migrations_ts/*.js* migrations",
"gas": "yarn run test --gas",
"pull-submodules": "git submodule update --init --recursive",
"delete-submodules": "rm -rf $(git submodule | awk '{ print $2 }')",
"build:sol": "yarn pull-submodules && mkdir -p migrations && ts-node --preferTsExts ./scripts/build.ts --solidity ${BUILD_DIR:-./build}",
"build": "yarn build:sol && yarn build:ts",
"prebuild": "rm -rf ./build",
"is_contract_release": "ts-node ./scripts/is-contract-release.ts",
"prepare_contracts_and_abis_publishing": "ts-node ./scripts/prepare-contracts-and-abis-publishing.ts",
"sourcify-publish": "ts-node ./scripts/sourcify-publish.ts",
"migrate": "./scripts/bash/migrate.sh",
"set_block_gas_limit": "./scripts/bash/set_block_gas_limit.sh",
Expand Down Expand Up @@ -101,8 +105,9 @@
"web3-utils": "1.10.0"
},
"devDependencies": {
"@celo/odis-identifiers": "^1.0.0",
"@celo/phone-utils": "^5.0.5",
"@celo/typechain-target-web3-v1-celo": "0.2.0",
"@celo/typechain-target-web3-v1-celo": "^1.0.0",
"@celo/typescript": "0.0.1",
"@types/bn.js": "^5.1.0",
"@types/chai": "^4.1.3",
Expand All @@ -113,16 +118,20 @@
"@types/targz": "^1.0.0",
"@types/tmp": "^0.1.0",
"@types/yargs": "^13.0.2",
"@wagmi/cli": "^1.0.1",
"cross-env": "^5.1.6",
"eth-gas-reporter": "^0.2.16",
"merkle-patricia-tree": "4.0.0",
"rimraf": "^5.0.5",
"semver": "^7.5.4",
"targz": "^1.0.1",
"tmp": "^0.1.0",
"truffle-typings": "^1.0.6",
"ts-generator": "^0.0.8",
"ts-node": "^10.9.1",
"typechain": "1.0.5",
"typechain-target-truffle": "1.0.2",
"ts-generator": "^0.0.8",
"typechain": "^4.0.3",
"typechain-target-truffle": "^1.0.2",
"typechain-target-ethers-v5": "^5.0.1",
"yargs": "^14.0.0"
}
}
17 changes: 9 additions & 8 deletions packages/protocol/scripts/bash/release-on-devchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ fi


rm -rf build/contracts*
cd ../..
yarn run reset
yarn install >> $LOG_FILE
yarn build >> $LOG_FILE
cd packages/protocol

echo "- Run local network"
yarn devchain run-tar-in-bg packages/protocol/$BUILD_DIR/devchain.tar.gz >> $LOG_FILE
TAR_FILE="packages/protocol/$BUILD_DIR/devchain.tar.gz"
if [ ! -f "$TAR_FILE" ]; then
echo "Generating $TAR_FILE"
yarn devchain generate-tar $TAR_FILE
fi

yarn devchain run-tar-in-bg $TAR_FILE >> $LOG_FILE

GANACHE_PID=
if command -v lsof; then
Expand All @@ -59,14 +60,14 @@ echo "- Check versions of current branch"
BASE_COMMIT=$(git rev-parse HEAD)
echo " - Base commit $BASE_COMMIT"
echo " - Checkout migrationsConfig.js at $BRANCH"
git checkout $BRANCH -- migrationsConfig.js
# git checkout $BRANCH -- migrationsConfig.js

OLD_BRANCH=$BRANCH
source scripts/bash/contract-exclusion-regex.sh
yarn ts-node scripts/check-backward.ts sem_check --old_contracts $BUILD_DIR/contracts --new_contracts build/contracts --exclude $CONTRACT_EXCLUSION_REGEX --output_file report.json

echo "Undo checkout for migrationsConfig.js from $(git rev-parse HEAD) to $BASE_COMMIT"
git checkout - -- migrationsConfig.js
# git checkout - -- migrationsConfig.js

# From make-release.sh
echo "- Deploy release of current branch"
Expand Down
Loading
Loading