Skip to content

Commit 90337ce

Browse files
authored
ci: delete fork on merge (#241)
* ci: delete fork on merge * ci: test fork deploy * feat: set unlimited contract size and block gas limit on tenderly network config * revert * ci: set golden token address to github env * ci: remove setting address as an .env * refactor(getContractAddress): rename to getContractMetadata and expose abi * feat: revert and introduce new function
1 parent f7c1435 commit 90337ce

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

.github/workflows/tenderly-delete-fork.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ on:
77

88
jobs:
99
tenderly-delete:
10-
if: contains(github.event.pull_request.labels.*.name, 'tenderly')
10+
env:
11+
FORK_NAME: ${{ github.event.pull_request.title }}
12+
TENDERLY_USER: ${{ secrets.TENDERLY_USER }}
13+
TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
14+
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
15+
TENDERLY_FORK_CHAIN_ID: ${{ secrets.TENDERLY_FORK_CHAIN_ID }}
16+
if: contains(github.event.pull_request.labels.*.name, 'fork')
1117
runs-on: ubuntu-latest
1218
timeout-minutes: 10
1319
steps:
@@ -24,20 +30,13 @@ jobs:
2430
# Fetch the PR Fork ID from Tenderly to pass to allow Delete.
2531
- name: Fetch Fork mainnet on Tenderly
2632
id: get-fork-tenderly
27-
env:
28-
FORK_NAME: ${{ github.event.pull_request.title }}
29-
TENDERLY_USER: ${{ secrets.TENDERLY_USER }}
30-
TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
31-
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
3233
run: |
3334
echo "TENDERLY_FORK_ID=$(yarn get-fork)" >> $GITHUB_ENV
3435
- name: Tenderly fork id
3536
run: |
3637
echo "Tenderly fork id: ${{ env.TENDERLY_FORK_ID }}"
3738
# Delete the PR Fork ID from Tenderly
3839
- name: Delete Tenderly Fork
39-
env:
40-
TENDERLY_FORK_ID: ${{ env.TENDERLY_FORK_ID }}
4140
run: |
4241
yarn delete-fork
4342
echo "Tenderly fork id: ${{ env.TENDERLY_FORK_ID }} deleted..."

.github/workflows/tenderly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ jobs:
4141
run: |
4242
yarn hardhat clean
4343
yarn hardhat compile
44-
echo "GOLDEN_TOKEN_ADDRESS=$(yarn deploy:fork)" >> $GITHUB_ENV
44+
yarn deploy:fork

deployments/getContractAddress.ts

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ import path from 'path';
33

44
import { ethers } from 'ethers';
55

6+
const getContractPath = (contractTag: string, network: ethers.providers.Networkish) => {
7+
const networkName = getNetworkName(network);
8+
let fileName = '';
9+
10+
if (process.cwd().includes('contracts')) {
11+
fileName = path.resolve(__dirname, networkName, `${contractTag}.json`)
12+
} else {
13+
fileName = path.resolve('contracts', 'deployments', networkName, `${contractTag}.json`)
14+
}
15+
16+
return fileName
17+
}
618
// ts-prune-ignore-next
719
export const getNetworkName = (network: ethers.providers.Networkish) => {
820
if (network === 'localhost') {
@@ -18,27 +30,39 @@ export const getNetworkName = (network: ethers.providers.Networkish) => {
1830
if (standardName === 'maticmum') {
1931
return 'mumbai';
2032
}
33+
2134
if (standardName === 'arbitrum-goerli') {
2235
return 'arbitrumGoerli';
2336
}
2437

38+
if (standardName === 'tenderly') {
39+
const { chainId } = ethers.providers.getNetwork('tenderly')
40+
return `tenderly_${chainId}`;
41+
}
42+
2543
return standardName ?? network;
2644
};
2745

46+
// ts-prune-ignore-next
47+
export const getContractAbi = (contractTag: string, network: ethers.providers.Networkish): string => {
48+
try {
49+
const fileName = getContractPath(contractTag, network);
50+
const contractJSON = fs.readFileSync(fileName).toString();
51+
const abi = JSON.parse(contractJSON).abi
52+
return JSON.stringify(abi)
53+
} catch (err) {
54+
console.log(err);
55+
}
56+
57+
return '0x0'
58+
};
59+
2860
const getContractAddress = (
2961
contractTag: string,
30-
network: ethers.providers.Networkish
62+
network: ethers.providers.Networkish,
3163
) => {
3264
try {
33-
const networkName = getNetworkName(network);
34-
let fileName = '';
35-
36-
if (process.cwd().includes('contracts')) {
37-
fileName = path.resolve(__dirname, networkName, `${contractTag}.json`)
38-
} else {
39-
fileName = path.resolve('contracts', 'deployments', networkName, `${contractTag}.json`)
40-
}
41-
65+
const fileName = getContractPath(contractTag, network);
4266
const contractJSON = fs.readFileSync(fileName).toString();
4367
return JSON.parse(contractJSON).address as string;
4468
} catch (e) {

ipfs/getDecentralizedSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ethers } from 'ethers';
22

3-
import getContractAddress from '../../contracts/deployments/getContractAddress';
3+
import getContractAddress from '../deployments/getContractAddress';
44
// eslint-disable-next-line camelcase
55
import { GoldenSchema__factory } from '../../contracts/typechain/factories/contracts/GoldenSchema__factory';
66
import { bytes16ToUUID } from './utils/bytes16UUID';

0 commit comments

Comments
 (0)