Skip to content

Commit

Permalink
fix: network template
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkanani committed Jan 6, 2021
1 parent df5ebd0 commit 5d4f625
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
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
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 }}'

0 comments on commit 5d4f625

Please sign in to comment.