Skip to content

Commit

Permalink
Fixes after adding job requester to contract (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
portuu3 authored Sep 1, 2023
1 parent b21b382 commit cf84bdb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 135 deletions.
57 changes: 0 additions & 57 deletions .github/workflows/cd-deploy-contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,61 +135,4 @@ jobs:
run: npx hardhat verify --network ${{ github.event.inputs.network }} ${{ steps.networks.outputs.reward_pool }}
working-directory: ./packages/core

#Deploy subgraph
- run: yarn global add @graphprotocol/graph-cli
name: Install Graph CLI
- run: graph auth --product hosted-service ${API_KEY}
name: Authenticate Graph CLI
env:
API_KEY: ${{ secrets.HP_GRAPH_API_KEY }}
- run: yarn generate
name: Generate Subgraph
working-directory: ./packages/sdk/typescript/subgraph
env:
NETWORK: ${{ steps.networks.outputs.subgraph }}
- run: graph deploy --product hosted-service humanprotocol/${NETWORK}
name: Deploy Subgraph
working-directory: ./packages/sdk/typescript/subgraph
env:
NETWORK: ${{ steps.networks.outputs.subgraph }}
#Commit changes to develop
- name: Check for Changes
if: always()
id: check_changes
run: |
git fetch
if [[ -n "$(git diff --name-only)" ]]; then
echo "Changes detected."
echo "::set-output name=changes::true"
else
echo "No changes detected."
echo "::set-output name=changes::false"
fi
- name: stash
if: always() && steps.check_changes.outputs.changes == 'true'
run: |
git status
git stash --include-untracked
- name: Checkout develop
if: always() && steps.check_changes.outputs.changes == 'true'
uses: actions/checkout@v3
with:
ref: develop
token: ${{ secrets.GH_TOKEN_CD_CONTRACTS }}
- name: pop
if: always() && steps.check_changes.outputs.changes == 'true'
run: |
git stash pop
git status
- name: Commit changes
if: always() && steps.check_changes.outputs.changes == 'true'
uses: EndBug/add-and-commit@v9
with:
add: "['./packages/core/.openzeppelin', './packages/sdk/typescript/subgraph/config']"
message: 'Update grafting and upgrade file from CD'
default_author: github_actions
tag_push: '--force'
github_token: ${{ secrets.GH_TOKEN_CD_CONTRACTS }}


Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ describe('JobService', () => {
fundAmount,
status: JobStatus.PENDING,
save: jest.fn().mockResolvedValue(true),
userId: 1,
};

const jobEntityResult = await jobService.launchJob(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export class JobService {
const escrowAddress = await escrowClient.createAndSetupEscrow(
NETWORKS[jobEntity.chainId as ChainId]!.hmtAddress,
[],
jobEntity.userId.toString(),
escrowConfig,
);

Expand Down
83 changes: 5 additions & 78 deletions packages/core/scripts/upgrade-proxies.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
/* eslint-disable no-console */
import { ethers, upgrades } from 'hardhat';
import fs from 'fs';
import prettier from 'prettier';
import { ApolloClient, gql, InMemoryCache } from '@apollo/client';

async function main() {
const subgraph = process.env.SUBGRAPH;
const escrowFactoryAddress = process.env.ESCROW_FACTORY_ADDRESS;
const deployEscrowFactory = process.env.DEPLOY_ESCROW_FACTORY;
const stakingAddress = process.env.STAKING_ADDRESS;
const deployStaking = process.env.DEPLOY_STAKING;
const rewardPoolAddress = process.env.REWARD_POOL_ADDRESS;
const deployRewardPool = process.env.DEPLOY_REWARD_POOL;
let blockNumber = 0;
if (
(!escrowFactoryAddress && !stakingAddress && !rewardPoolAddress) ||
!subgraph
) {

if (!escrowFactoryAddress && !stakingAddress && !rewardPoolAddress) {
console.error('Env variable missing');
return;
}
Expand All @@ -31,17 +24,10 @@ async function main() {
EscrowFactory
);
const contract = await escrowFactoryContract.deployed();
const txReceipt = await ethers.provider.getTransactionReceipt(
await ethers.provider.getTransactionReceipt(
contract.deployTransaction.hash
);

if (
txReceipt.blockNumber &&
(txReceipt.blockNumber < blockNumber || blockNumber == 0)
) {
blockNumber = txReceipt.blockNumber;
}

console.log(
'Escrow Factory Proxy Address: ',
escrowFactoryContract.address
Expand All @@ -62,17 +48,10 @@ async function main() {
Staking
);
const contract = await stakingContract.deployed();
const txReceipt = await ethers.provider.getTransactionReceipt(
await ethers.provider.getTransactionReceipt(
contract.deployTransaction.hash
);

if (
txReceipt.blockNumber &&
(txReceipt.blockNumber < blockNumber || blockNumber == 0)
) {
blockNumber = txReceipt.blockNumber;
}

console.log('Staking Proxy Address: ', stakingContract.address);
console.log(
'New Staking Implementation Address: ',
Expand All @@ -88,17 +67,10 @@ async function main() {
RewardPool
);
const contract = await rewardPoolContract.deployed();
const txReceipt = await ethers.provider.getTransactionReceipt(
await ethers.provider.getTransactionReceipt(
contract.deployTransaction.hash
);

if (
txReceipt.blockNumber &&
(txReceipt.blockNumber < blockNumber || blockNumber == 0)
) {
blockNumber = txReceipt.blockNumber;
}

console.log('Reward Pool Proxy Address: ', rewardPoolContract.address);
console.log(
'New Reward Pool Implementation Address: ',
Expand All @@ -107,51 +79,6 @@ async function main() {
)
);
}

if (blockNumber > 0)
updateGraftingConfig(blockNumber, await getSubgraphId(subgraph), subgraph);
}

interface JSONData {
[key: string]: any;
}

const GET_SUBGRAPH_ID = gql`
query MyQuery {
_meta {
deployment
}
}
`;

function getSubgraphId(subgraphName: string) {
const hostedServiceEndpoint = `https://api.thegraph.com/subgraphs/name/humanprotocol/${subgraphName}`;
const client = new ApolloClient({
uri: hostedServiceEndpoint,
cache: new InMemoryCache(),
});

return client.query({ query: GET_SUBGRAPH_ID }).then((result) => {
const subgraphId: string = result.data._meta.deployment;
return subgraphId;
});
}

function updateGraftingConfig(
blockNumber: number,
subgraphId: string,
subgraphName: string
) {
const filename = `../sdk/typescript/subgraph/config/${subgraphName}.json`;
const data: JSONData = JSON.parse(fs.readFileSync(filename, 'utf8'));
const currentObject = data;
currentObject['graft']['block'] = blockNumber;
currentObject['graft']['base'] = subgraphId;
const formattedData = prettier.format(JSON.stringify(data), {
parser: 'json',
});

fs.writeFileSync(filename, formattedData);
}

main().catch((error) => {
Expand Down

1 comment on commit cf84bdb

@vercel
Copy link

@vercel vercel bot commented on cf84bdb Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

job-launcher-server – ./packages/apps/job-launcher/server

job-launcher-server-nine.vercel.app
job-launcher-server-humanprotocol.vercel.app
job-launcher-server-git-develop-humanprotocol.vercel.app

Please sign in to comment.