Skip to content

Commit

Permalink
Merge pull request #16 from maticnetwork/jdkanani/ci
Browse files Browse the repository at this point in the history
fix: ci for build
  • Loading branch information
jdkanani authored Jan 6, 2021
2 parents a1fa95d + 5d4f625 commit fd0363b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,33 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
directory: [root, child]
include:
- SUBGRAPH_DIRECTORY: root
SUBGRAPH_NETWORK: goerli
- SUBGRAPH_DIRECTORY: root
SUBGRAPH_NETWORK: mainnet
- SUBGRAPH_DIRECTORY: child
SUBGRAPH_NETWORK: mumbai
- SUBGRAPH_DIRECTORY: child
SUBGRAPH_NETWORK: mainnet

defaults:
run:
working-directory: ${{ matrix.directory }}
working-directory: ${{ matrix.SUBGRAPH_DIRECTORY }}

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "12"
node-version: "14"
check-latest: true
- run: npm install
- run: npm run lint
- name: Install npm package
run: npm install
- name: Check lint
run: npm run lint
- name: Prepare subgraph for ${{ matrix.SUBGRAPH_NETWORK }}
run: npm run prepare:${{ matrix.SUBGRAPH_NETWORK }}
- name: Generate code for subgraph
run: npm run codegen
- name: Build subgraph
run: npm run build
2 changes: 1 addition & 1 deletion root/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
subgraph.yaml
src/network.json
src/network.ts
4 changes: 2 additions & 2 deletions root/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"graph": "graph",
"codegen": "graph codegen",
"build": "graph build",
"prepare:mainnet": "mustache config/mainnet.json subgraph.template.yaml > subgraph.yaml && cp config/mainnet.json src/network.json",
"prepare:goerli": "mustache config/goerli.json subgraph.template.yaml > subgraph.yaml && cp config/goerli.json src/network.json",
"prepare:mainnet": "mustache config/mainnet.json subgraph.template.yaml > subgraph.yaml && mustache config/mainnet.json src/network.template.ts > src/network.ts",
"prepare:goerli": "mustache config/goerli.json subgraph.template.yaml > subgraph.yaml && mustache config/goerli.json src/network.template.ts > src/network.ts",
"deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ maticnetwork/mumbai-root-subgraphs",
"create-local": "graph create --node http://localhost:8020/ maticnetwork/mumbai-root-subgraphs",
"remove-local": "graph remove --node http://localhost:8020/ maticnetwork/mumbai-root-subgraphs",
Expand Down
2 changes: 1 addition & 1 deletion root/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type Validator @entity {
status: Int!
jailEndEpoch: BigInt!
auctionAmount: BigInt!
isInAuction: Bool!
isInAuction: Boolean!
}

type Delegator @entity {
Expand Down
6 changes: 3 additions & 3 deletions root/src/mappings/staking-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
// using network address from config file
// to be passed to client when creating instance
// of contract, StakingNft, for calling `ownerOf` function
import NetworkConfig from '../network.json'
import {stakingNftAddress} from '../network'

// This is the contract we're going to interact with when `Staked` event is emitted
import {StakingNft} from '../../generated/StakingNft/StakingNft'
Expand Down Expand Up @@ -75,7 +75,7 @@ export function handleStaked(event: Staked): void {

// Keeping NFT owner address, to be helpful while responding
// client queries in staking API
let nft = StakingNft.bind(Address.fromString(NetworkConfig.contracts.stakingNft.address))
let nft = StakingNft.bind(Address.fromString(stakingNftAddress))
validator.owner = nft.ownerOf(event.params.validatorId)

validator.totalStaked = event.params.total
Expand All @@ -94,7 +94,7 @@ export function handleUnstaked(event: Unstaked): void {

// update unstaked status
validator.status = 1
validator.selfStake = 0
validator.selfStake = BigInt.fromI32(0)
validator.save()
}

Expand Down
2 changes: 2 additions & 0 deletions root/src/network.template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const network: string = '{{ network }}'
export const stakingNftAddress: string = '{{ contracts.stakingNft.address }}'
2 changes: 1 addition & 1 deletion root/subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ dataSources:
name: StakingNft
network: {{ network }}
source:
address: "{{contracts.stakingNFT.address}}"
address: "{{contracts.stakingNft.address}}"
abi: StakingNft
startBlock: {{ contracts.stakingNft.startBlock }}
mapping:
Expand Down

0 comments on commit fd0363b

Please sign in to comment.