1- import { BigDecimal , BigInt , Bytes , ipfs , json } from '@graphprotocol/graph-ts'
1+ import { BigDecimal , Bytes , ipfs , json } from '@graphprotocol/graph-ts'
22import {
33 SubgraphPublished ,
44 SubgraphDeprecated ,
@@ -45,6 +45,7 @@ import {
4545 convertBigIntSubgraphIDToBase58 ,
4646 compoundId ,
4747 joinIDString ,
48+ BIGINT_ONE ,
4849} from './helpers'
4950
5051export function handleSetDefaultName ( event : SetDefaultName ) : void {
@@ -134,17 +135,16 @@ export function handleSubgraphMetadataUpdated(event: SubgraphMetadataUpdated): v
134135 */
135136export function handleSubgraphPublished ( event : SubgraphPublished ) : void {
136137 let subgraphID = getSubgraphID ( event . params . graphAccount , event . params . subgraphNumber )
137- let versionNumber : BigInt
138138
139139 // Update subgraph
140140 let subgraph = createOrLoadSubgraph ( subgraphID , event . params . graphAccount , event . block . timestamp )
141141
142- versionNumber = subgraph . versionCount
142+ let versionNumber = subgraph . versionCount
143143 let versionIDNew = compoundId ( subgraph . id , changetype < Bytes > ( Bytes . fromBigInt ( subgraph . versionCount ) ) )
144144 subgraph . creatorAddress = event . params . graphAccount
145145 subgraph . subgraphNumber = event . params . subgraphNumber
146146 subgraph . oldID = joinIDString ( [ event . params . graphAccount . toHexString ( ) , event . params . subgraphNumber . toString ( ) ] )
147- subgraph . versionCount = subgraph . versionCount . plus ( BigInt . fromI32 ( 1 ) )
147+ subgraph . versionCount = subgraph . versionCount . plus ( BIGINT_ONE )
148148 subgraph . updatedAt = event . block . timestamp . toI32 ( )
149149
150150 subgraph . currentVersion = versionIDNew
@@ -374,18 +374,18 @@ export function handleGRTWithdrawn(event: GRTWithdrawn): void {
374374export function handleSubgraphPublishedV2 ( event : SubgraphPublished1 ) : void {
375375 let bigIntID = event . params . subgraphID
376376 let subgraphID = convertBigIntSubgraphIDToBase58 ( bigIntID )
377- let versionID : Bytes
378- let versionNumber : BigInt
377+
379378
380379 // Update subgraph
381380 let subgraph = createOrLoadSubgraph (
382381 event . params . subgraphID ,
383382 event . transaction . from ,
384383 event . block . timestamp ,
385384 )
386- versionID = compoundId ( subgraph . id , changetype < Bytes > ( Bytes . fromBigInt ( subgraph . versionCount ) ) )
385+ let versionNumber = subgraph . versionCount
386+ let versionID = compoundId ( subgraph . id , changetype < Bytes > ( Bytes . fromBigInt ( subgraph . versionCount ) ) )
387387 subgraph . currentVersion = versionID
388- subgraph . versionCount = subgraph . versionCount . plus ( BigInt . fromI32 ( 1 ) )
388+ subgraph . versionCount = subgraph . versionCount . plus ( BIGINT_ONE )
389389 subgraph . updatedAt = event . block . timestamp . toI32 ( )
390390 subgraph . reserveRatio = event . params . reserveRatio . toI32 ( )
391391 subgraph . migrated = true
@@ -602,7 +602,6 @@ export function handleSubgraphVersionUpdated(event: SubgraphVersionUpdated): voi
602602 let bigIntID = event . params . subgraphID
603603 let subgraphID = convertBigIntSubgraphIDToBase58 ( bigIntID )
604604 let versionID : Bytes
605- let versionNumber : BigInt
606605
607606 // Update subgraph
608607 let subgraph = Subgraph . load ( subgraphID ) !
@@ -612,18 +611,18 @@ export function handleSubgraphVersionUpdated(event: SubgraphVersionUpdated): voi
612611 subgraph . save ( )
613612
614613 // Update already initialized subgraph version
615- versionID = compoundId ( subgraph . id , changetype < Bytes > ( Bytes . fromBigInt ( subgraph . versionCount . minus ( BigInt . fromI32 ( 1 ) ) ) ) )
614+ versionID = compoundId ( subgraph . id , changetype < Bytes > ( Bytes . fromBigInt ( subgraph . versionCount . minus ( BIGINT_ONE ) ) ) )
616615 let subgraphVersion = SubgraphVersion . load ( versionID ) !
617616 // let hexHash = changetype<Bytes>(addQm(event.params.versionMetadata))
618617 // let base58Hash = hexHash.toBase58()
619618 subgraphVersion . metadataHash = event . params . versionMetadata
620619 //subgraphVersion = fetchSubgraphVersionMetadata(subgraphVersion, base58Hash)
621620 subgraphVersion . save ( )
622621 } else {
623- versionNumber = subgraph . versionCount
622+ let versionNumber = subgraph . versionCount
624623 versionID = compoundId ( subgraph . id , changetype < Bytes > ( Bytes . fromBigInt ( subgraph . versionCount ) ) )
625624 subgraph . currentVersion = versionID
626- subgraph . versionCount = subgraph . versionCount . plus ( BigInt . fromI32 ( 1 ) )
625+ subgraph . versionCount = subgraph . versionCount . plus ( BIGINT_ONE )
627626 subgraph . updatedAt = event . block . timestamp . toI32 ( )
628627 subgraph . save ( )
629628
0 commit comments