From 5d4f625aee5d34f88af325cdf3f23d2d78f6716b Mon Sep 17 00:00:00 2001 From: Jaynti Kanani Date: Wed, 6 Jan 2021 09:22:58 +0530 Subject: [PATCH] fix: network template --- root/.gitignore | 2 +- root/package.json | 4 ++-- root/src/mappings/staking-info.ts | 6 +++--- root/src/network.template.ts | 2 ++ 4 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 root/src/network.template.ts 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/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 }}'