Skip to content

Commit a80ed1f

Browse files
Configure jobs deploying & publishing contracts
We're adding jobs which will deploy and publish Threshold contracts. `NPM` workflow will build & publish contracts every time there is a change in contracts or in the files describing package dependencies. The `-dev` suffix will be used in the name of the published package. `Solidity` workflow will deploy and publish contracts every time worklfow is triggered by the `workflow_dispatch` event. Published package name will point to name of the environment on which the contracts were deployed. Note: we're temporarily switched off publishing to NPM registry using `--dry-run` flag. The flag will be removed before merging of the changes to the `main` branch.
1 parent b1b6073 commit a80ed1f

File tree

3 files changed

+171
-1
lines changed

3 files changed

+171
-1
lines changed

.github/workflows/contracts.yaml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ on:
66
- main
77
pull_request:
88
workflow_dispatch:
9+
inputs:
10+
environment:
11+
description: 'Environment for workflow execution'
12+
required: false
13+
default: 'dev'
14+
upstream_builds:
15+
description: "Upstream builds"
16+
required: false
17+
upstream_ref:
18+
description: "Git reference to checkout (e.g. branch name)"
19+
required: false
20+
default: "main"
921

1022
jobs:
1123
contracts-build-and-test:
@@ -27,6 +39,118 @@ jobs:
2739
- name: Run tests
2840
run: yarn test
2941

42+
contracts-deployment-dry-run:
43+
runs-on: ubuntu-latest
44+
if: github.event_name != 'schedule'
45+
steps:
46+
- uses: actions/checkout@v2
47+
48+
- uses: actions/setup-node@v2
49+
with:
50+
node-version: "14.x"
51+
cache: "yarn"
52+
53+
- name: Install dependencies
54+
run: yarn install
55+
56+
- name: Deploy contracts
57+
run: yarn deploy
58+
59+
contracts-deployment-testnet:
60+
needs: [contracts-build-and-test]
61+
if: github.event_name == 'workflow_dispatch'
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@v2
65+
66+
- uses: actions/setup-node@v2
67+
with:
68+
node-version: "14.x"
69+
cache: "yarn"
70+
registry-url: "https://registry.npmjs.org"
71+
72+
- name: Install dependencies
73+
run: yarn install --frozen-lockfile
74+
75+
- name: Get upstream packages versions
76+
uses: keep-network/ci/actions/upstream-builds-query@v1
77+
id: upstream-builds-query
78+
with:
79+
upstream-builds: ${{ github.event.inputs.upstream_builds }}
80+
query: keep-core-contracts-version = github.com/keep-network/keep-core/solidity-v1#version
81+
82+
- name: Resolve latest contracts
83+
run: |
84+
yarn upgrade \
85+
@keep-network/keep-core@${{ steps.upstream-builds-query.outputs.keep-core-contracts-version }}
86+
87+
- name: Configure tenderly
88+
if: github.event.inputs.environment == 'ropsten'
89+
env:
90+
TENDERLY_TOKEN: ${{ secrets.TENDERLY_TOKEN }}
91+
run: ./config_tenderly.sh
92+
93+
- name: Deploy contracts
94+
env:
95+
CHAIN_API_URL: ${{ secrets.KEEP_TEST_ETH_HOSTNAME_HTTP }}
96+
CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.KEEP_TEST_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
97+
run: yarn deploy --network ${{ github.event.inputs.environment }}
98+
99+
- name: Bump up package version
100+
id: npm-version-bump
101+
uses: keep-network/npm-version-bump@v2
102+
with:
103+
environment: ${{ github.event.inputs.environment }}
104+
branch: ${{ github.ref }}
105+
commit: ${{ github.sha }}
106+
107+
- name: Publish to npm # TODO: switch off --dry-run
108+
env:
109+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
110+
run: npm publish --access=public --network=${{ github.event.inputs.environment }} --dry-run
111+
112+
- name: Upload files needed for etherscan verification
113+
uses: actions/upload-artifact@v2
114+
with:
115+
name: Artifacts for etherscan verifcation
116+
path: |
117+
./deployments
118+
./package.json
119+
./yarn.lock
120+
121+
contracts-etherscan-verification:
122+
needs: [contracts-deployment-testnet]
123+
runs-on: ubuntu-latest
124+
steps:
125+
- uses: actions/checkout@v2
126+
127+
- name: Download files needed for etherscan verification
128+
uses: actions/download-artifact@v2
129+
with:
130+
name: Artifacts for etherscan verifcation
131+
132+
- uses: actions/setup-node@v2
133+
with:
134+
node-version: "14.x"
135+
cache: "yarn"
136+
137+
- name: Install needed dependencies
138+
run: yarn install --frozen-lockfile
139+
140+
# If we don't remove the `keep-core` contracts from `node-modules`, the
141+
# `etherscan-verify` plugins tries to verify them, which is not desired.
142+
- name: Prepare for verification on Etherscan
143+
run: |
144+
rm -rf ./node_modules/@keep-network/keep-core
145+
146+
- name: Verify contracts on Etherscan
147+
env:
148+
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
149+
CHAIN_API_URL: ${{ secrets.KEEP_TEST_ETH_HOSTNAME_HTTP }}
150+
run: |
151+
yarn run hardhat --network ${{ github.event.inputs.environment }} \
152+
etherscan-verify --license MIT
153+
30154
contracts-slither:
31155
runs-on: ubuntu-latest
32156
steps:
@@ -48,6 +172,7 @@ jobs:
48172
pip3 install solc-select
49173
solc-select install $SOLC_VERSION
50174
solc-select use $SOLC_VERSION
175+
51176
- name: Install Slither
52177
env:
53178
SLITHER_VERSION: 0.8.0

.github/workflows/npm.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: NPM
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "contracts/**"
9+
- "package.json"
10+
- "yarn.lock"
11+
workflow_dispatch:
12+
13+
jobs:
14+
npm-compile-publish-contracts:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- uses: actions/setup-node@v2
20+
with:
21+
node-version: "14.x"
22+
registry-url: "https://registry.npmjs.org"
23+
cache: "yarn"
24+
25+
- name: Resolve latest contracts
26+
run: |
27+
yarn upgrade @keep-network/keep-core
28+
29+
# Deploy contracts to a local network to generate deployment artifacts that
30+
# are required by dashboard compilation.
31+
- name: Deploy contracts
32+
run: yarn deploy --network hardhat --write true
33+
34+
- name: Bump up package version
35+
id: npm-version-bump
36+
uses: keep-network/npm-version-bump@v2
37+
with:
38+
environment: dev
39+
branch: ${{ github.ref }}
40+
commit: ${{ github.sha }}
41+
42+
- name: Publish package # TODO: switch off --dry-run
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
run: npm publish --access=public --network=hardhat --tag=development --dry-run

contracts/token/T.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ contract T is ERC20WithPermit, MisfundRecovery, Checkpoints {
5858
abi.encode(
5959
DELEGATION_TYPEHASH,
6060
delegatee,
61-
nonce[signatory]++,
61+
nonces[signatory]++,
6262
deadline
6363
)
6464
)

0 commit comments

Comments
 (0)