Skip to content

Commit

Permalink
Update small changes from audit to launch new phase2 subgraphs
Browse files Browse the repository at this point in the history
  • Loading branch information
davekaj committed Oct 7, 2020
1 parent dcdb031 commit 53d1bb9
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 59 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphprotocol/staging-testnet-subgraph",
"version": "v0.5.0-testnet-phase1",
"version": "v0.7.1-testnet-phase2",
"description": "Subgraph for the Graph Network",
"repository": "https://github.com/graphprotocol/graph-network-subgraph",
"license": "MIT",
Expand All @@ -26,7 +26,7 @@
"prettier-write": "prettier --write '**/*.ts'"
},
"devDependencies": {
"@graphprotocol/contracts": "^0.7.0-testnet-phase2",
"@graphprotocol/contracts": "^0.7.1-testnet-phase2-staging",
"@graphprotocol/graph-cli": "^0.18.0",
"@graphprotocol/graph-ts": "^0.18.1",
"@types/node": "^14.0.13",
Expand Down
14 changes: 5 additions & 9 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,6 @@ State channel allocation representing Indexer-SubgraphDeployment stake
type Allocation @entity {
"Channel Address"
id: ID!
"Uncompressed public key of the channel"
publicKey: Bytes!
"Asset holder (proxy) of the channel"
assetHolder: Bytes!
"Price of the queries"
price: BigInt!
"Indexer of this allocation"
Expand Down Expand Up @@ -535,9 +531,9 @@ type Delegator @entity {
account: GraphAccount!
"Stakes of this delegator"
stakes: [DelegatedStake!]! @derivedFrom(field: "delegator")
"Summation of all staked amounts in DelegatorStakes of this Delegator"
"Summation of all staked tokens in DelegatorStakes of this Delegator"
totalStakedTokens: BigInt!
"Summation of all unstaked amounts in DelegatorStakes of this Delegator"
"Summation of all unstaked tokens in DelegatorStakes of this Delegator"
totalUnstakedTokens: BigInt!
"Time created at"
createdAt: Int!
Expand All @@ -553,15 +549,15 @@ type DelegatedStake @entity {
indexer: Indexer!
"Delegator"
delegator: Delegator!
"Amount delegated"
"Amount delegated all time (static)"
stakedTokens: BigInt!
"Amount un-delegated"
"Amount un-delegated all time (static)"
unstakedTokens: BigInt!
"Amount currently locked"
lockedTokens: BigInt!
"Epoch the locked tokens are unlocked"
lockedUntil: Int!
"Shares owned in the delegator pool"
"Shares owned in the delegator pool. Used to calculate total amount delegated"
shareAmount: BigInt!
}

Expand Down
15 changes: 7 additions & 8 deletions src/mappings/curation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Collected,
Curation,
ParameterUpdated,
ImplementationUpdated
} from '../types/Curation/Curation'
import { Curator, GraphNetwork, Signal, SubgraphDeployment } from '../types/schema'
import { Address } from '@graphprotocol/graph-ts'
Expand Down Expand Up @@ -142,10 +141,10 @@ export function handleParameterUpdated(event: ParameterUpdated): void {
graphNetwork.save()
}

export function handleImplementationUpdated(event: ImplementationUpdated): void {
let graphNetwork = GraphNetwork.load('1')
let implementations = graphNetwork.curationImplementations
implementations.push(event.params.newImplementation)
graphNetwork.curationImplementations = implementations
graphNetwork.save()
}
// export function handleImplementationUpdated(event: ImplementationUpdated): void {
// let graphNetwork = GraphNetwork.load('1')
// let implementations = graphNetwork.curationImplementations
// implementations.push(event.params.newImplementation)
// graphNetwork.curationImplementations = implementations
// graphNetwork.save()
// }
15 changes: 7 additions & 8 deletions src/mappings/epochManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { GraphNetwork } from '../types/schema'
import {
EpochRun,
EpochLengthUpdate,
ImplementationUpdated,
} from '../types/EpochManager/EpochManager'
import { createOrLoadEpoch, createEpoch } from './helpers'
import { log, BigInt } from '@graphprotocol/graph-ts'
Expand Down Expand Up @@ -61,10 +60,10 @@ export function handleEpochLengthUpdate(event: EpochLengthUpdate): void {
graphNetwork.save()
}

export function handleImplementationUpdated(event: ImplementationUpdated): void {
let graphNetwork = GraphNetwork.load('1')
let implementations = graphNetwork.epochManagerImplementations
implementations.push(event.params.newImplementation)
graphNetwork.epochManagerImplementations = implementations
graphNetwork.save()
}
// export function handleImplementationUpdated(event: ImplementationUpdated): void {
// let graphNetwork = GraphNetwork.load('1')
// let implementations = graphNetwork.epochManagerImplementations
// implementations.push(event.params.newImplementation)
// graphNetwork.epochManagerImplementations = implementations
// graphNetwork.save()
// }
15 changes: 7 additions & 8 deletions src/mappings/rewardsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Address } from '@graphprotocol/graph-ts'
import { Indexer, Allocation, GraphNetwork, Epoch, SubgraphDeployment } from '../types/schema'
import {
RewardsAssigned,
ImplementationUpdated,
ParameterUpdated,
RewardsManager,
RewardsDenylistUpdated,
Expand Down Expand Up @@ -57,13 +56,13 @@ export function handleParameterUpdated(event: ParameterUpdated): void {
graphNetwork.save()
}

export function handleImplementationUpdated(event: ImplementationUpdated): void {
let graphNetwork = GraphNetwork.load('1')
let implementations = graphNetwork.rewardsManagerImplementations
implementations.push(event.params.newImplementation)
graphNetwork.rewardsManagerImplementations = implementations
graphNetwork.save()
}
// export function handleImplementationUpdated(event: ImplementationUpdated): void {
// let graphNetwork = GraphNetwork.load('1')
// let implementations = graphNetwork.rewardsManagerImplementations
// implementations.push(event.params.newImplementation)
// graphNetwork.rewardsManagerImplementations = implementations
// graphNetwork.save()
// }

export function handleRewardsDenyListUpdated(event: RewardsDenylistUpdated): void {
let subgraphDeployment = SubgraphDeployment.load(event.params.subgraphDeploymentID.toHexString())
Expand Down
19 changes: 8 additions & 11 deletions src/mappings/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
StakeDelegatedWithdrawn,
AllocationCollected,
DelegationParametersUpdated,
ImplementationUpdated,
} from '../types/Staking/Staking'
import {
Indexer,
Expand Down Expand Up @@ -242,8 +241,6 @@ export function handleAllocationCreated(event: AllocationCreated): void {

// create allocation
let allocation = new Allocation(allocationID)
allocation.publicKey = event.params.channelPubKey
allocation.assetHolder = event.params.assetHolder
allocation.price = BigInt.fromI32(0) // TODO - fix, this doesnt exist anymore
allocation.indexer = indexerID
allocation.subgraphDeployment = subgraphDeploymentID
Expand Down Expand Up @@ -428,7 +425,7 @@ export function handleParameterUpdated(event: ParameterUpdated): void {
} else if (parameter == 'maxAllocationEpochs') {
graphNetwork.maxAllocationEpochs = staking.maxAllocationEpochs().toI32()
} else if (parameter == 'delegationCapacity') {
graphNetwork.delegationCapacity = staking.delegationCapacity().toI32()
graphNetwork.delegationCapacity = staking.delegationRatio().toI32()
} else if (parameter == 'delegationParametersCooldown') {
graphNetwork.delegationParametersCooldown = staking.delegationParametersCooldown().toI32()
} else if (parameter == 'delegationUnbondingPeriod') {
Expand Down Expand Up @@ -462,10 +459,10 @@ export function handleSetOperator(event: SetOperator): void {
graphAccount.save()
}

export function handleImplementationUpdated(event: ImplementationUpdated): void {
let graphNetwork = GraphNetwork.load('1')
let implementations = graphNetwork.stakingImplementations
implementations.push(event.params.newImplementation)
graphNetwork.stakingImplementations = implementations
graphNetwork.save()
}
// export function handleImplementationUpdated(event: ImplementationUpdated): void {
// let graphNetwork = GraphNetwork.load('1')
// let implementations = graphNetwork.stakingImplementations
// implementations.push(event.params.newImplementation)
// graphNetwork.stakingImplementations = implementations
// graphNetwork.save()
// }
18 changes: 9 additions & 9 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ dataSources:
handler: handleStakeDelegatedLocked
- event: StakeDelegatedWithdrawn(indexed address,indexed address,uint256)
handler: handleStakeDelegatedWithdrawn
- event: AllocationCreated(indexed address,indexed bytes32,uint256,uint256,address,bytes,bytes32,address)
- event: AllocationCreated(indexed address,indexed bytes32,uint256,uint256,address,bytes32)
handler: handleAllocationCreated
- event: AllocationCollected(indexed address,indexed bytes32,uint256,uint256,address,address,uint256,uint256)
handler: handleAllocationCollected
Expand All @@ -156,8 +156,8 @@ dataSources:
handler: handleParameterUpdated
- event: SetOperator(indexed address,address,bool)
handler: handleSetOperator
- event: ImplementationUpdated(address,address)
handler: handleImplementationUpdated
# - event: ImplementationUpdated(address,address)
# handler: handleImplementationUpdated
- kind: ethereum/contract
name: Curation
network: {{network}}
Expand Down Expand Up @@ -188,8 +188,8 @@ dataSources:
handler: handleCollected
- event: ParameterUpdated(string)
handler: handleParameterUpdated
- event: ImplementationUpdated(address,address)
handler: handleImplementationUpdated
# - event: ImplementationUpdated(address,address)
# handler: handleImplementationUpdated
- kind: ethereum/contract
name: GraphToken
network: {{network}}
Expand Down Expand Up @@ -256,8 +256,8 @@ dataSources:
handler: handleEpochRun
- event: EpochLengthUpdate(indexed uint256,uint256)
handler: handleEpochLengthUpdate
- event: ImplementationUpdated(address,address)
handler: handleImplementationUpdated
# - event: ImplementationUpdated(address,address)
# handler: handleImplementationUpdated
- kind: ethereum/contract
name: RewardsManager
network: {{network}}
Expand All @@ -282,7 +282,7 @@ dataSources:
eventHandlers:
- event: RewardsAssigned(indexed address,indexed address,uint256,uint256)
handler: handleRewardsAssigned
- event: ImplementationUpdated(address,address)
handler: handleImplementationUpdated
# - event: ImplementationUpdated(address,address)
# handler: handleImplementationUpdated
- event: ParameterUpdated(string)
handler: handleParameterUpdated
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,10 @@
"@ethersproject/properties" "^5.0.3"
"@ethersproject/strings" "^5.0.4"

"@graphprotocol/contracts@^0.7.0-testnet-phase2":
version "0.7.0-testnet-phase2"
resolved "https://registry.yarnpkg.com/@graphprotocol/contracts/-/contracts-0.7.0-testnet-phase2.tgz#6e349bb4e0872aff825117a4125a72e843bb7114"
integrity sha512-zjKajxPmx3alIiB0V4+1e+efGQn/q0si6F/6m7PUlMf/zMypG3z+57edg8dK/Mz74MIdgOZvtWJFZKYmnyk+pg==
"@graphprotocol/contracts@^0.7.1-testnet-phase2-staging":
version "0.7.1-testnet-phase2-staging"
resolved "https://registry.yarnpkg.com/@graphprotocol/contracts/-/contracts-0.7.1-testnet-phase2-staging.tgz#c5640eed5884475f4672ed16a8593b114481c298"
integrity sha512-moMfM6NTl7eK04QRhkO6lLWOAx+OzkZpODo+uheYUHJHIs+D7twUBHz8Jin+VqJXuQD+Qo3jRF+adugdGOnAVw==
dependencies:
"@ethersproject/contracts" "^5.0.3"
ethers "^5.0.9"
Expand Down

0 comments on commit 53d1bb9

Please sign in to comment.