diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7ac2cc..c3f2210 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/root/.gitignore b/root/.gitignore index 4049558..2757040 100644 --- a/root/.gitignore +++ b/root/.gitignore @@ -1,2 +1,2 @@ subgraph.yaml -src/network.json +src/network.ts diff --git a/root/package.json b/root/package.json index 69c729b..2f67a59 100644 --- a/root/package.json +++ b/root/package.json @@ -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", diff --git a/root/schema.graphql b/root/schema.graphql index 762a40c..7790d37 100644 --- a/root/schema.graphql +++ b/root/schema.graphql @@ -94,7 +94,7 @@ type Validator @entity { status: Int! jailEndEpoch: BigInt! auctionAmount: BigInt! - isInAuction: Bool! + isInAuction: Boolean! } type Delegator @entity { diff --git a/root/src/mappings/staking-info.ts b/root/src/mappings/staking-info.ts index c68584a..8290a72 100644 --- a/root/src/mappings/staking-info.ts +++ b/root/src/mappings/staking-info.ts @@ -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' @@ -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 @@ -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() } diff --git a/root/src/network.template.ts b/root/src/network.template.ts new file mode 100644 index 0000000..7ae0a96 --- /dev/null +++ b/root/src/network.template.ts @@ -0,0 +1,2 @@ +export const network: string = '{{ network }}' +export const stakingNftAddress: string = '{{ contracts.stakingNft.address }}' diff --git a/root/subgraph.template.yaml b/root/subgraph.template.yaml index 043fb9a..6e3954f 100644 --- a/root/subgraph.template.yaml +++ b/root/subgraph.template.yaml @@ -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: