Skip to content

Commit

Permalink
feat: update subgraph to latest graph-cli version (#376)
Browse files Browse the repository at this point in the history
* feat: update subgraph to latest graph-cli version

* fix: build warning
  • Loading branch information
mathewmeconry authored Aug 9, 2024
1 parent 786061f commit 175fac1
Show file tree
Hide file tree
Showing 16 changed files with 2,232 additions and 1,605 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules/

# Compilation output
dist/
build/

# Tests
coverage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
startBlock: {{startBlock}}
mapping:
kind: ethereum/events
apiVersion: 0.0.1
apiVersion: 0.0.6
language: wasm/assemblyscript
entities:
- RegistryFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
startBlock: {{startBlock}}
mapping:
kind: ethereum/events
apiVersion: 0.0.1
apiVersion: 0.0.6
language: wasm/assemblyscript
entities:
- App
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{{/startBlock}}
mapping:
kind: ethereum/events
apiVersion: 0.0.1
apiVersion: 0.0.6
language: wasm/assemblyscript
entities:
- Organization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{{/startBlock}}
mapping:
kind: ethereum/events
apiVersion: 0.0.1
apiVersion: 0.0.6
language: wasm/assemblyscript
entities:
- Registry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ templates:
abi: ACL
mapping:
kind: ethereum/events
apiVersion: 0.0.1
apiVersion: 0.0.6
language: wasm/assemblyscript
entities:
- Organization
Expand All @@ -51,7 +51,7 @@ templates:
abi: Repo
mapping:
kind: ethereum/events
apiVersion: 0.0.1
apiVersion: 0.0.6
language: wasm/assemblyscript
entities:
- Repo
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-thegraph/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"deploy-xdai": "scripts/deploy.sh 1hive xdai"
},
"devDependencies": {
"@graphprotocol/graph-cli": "^0.19.0",
"@graphprotocol/graph-ts": "^0.19.0",
"@graphprotocol/graph-cli": "^0.80.0",
"@graphprotocol/graph-ts": "^0.35.1",
"graphqlviz": "^3.1.0",
"mustache": "^4.0.1"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/connect-thegraph/subgraph/src/helpers/appProxy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Address } from '@graphprotocol/graph-ts'
import { Address, log } from '@graphprotocol/graph-ts'

import { AppProxyForwarder as AppProxyForwarderContract } from '../../generated/templates/Kernel/AppProxyForwarder'

export function isForwarder(proxy: Address): boolean {
// Check if app is forwarder
log.debug('isForwarder: proxy: {}', [proxy.toHexString()])
const appForwarder = AppProxyForwarderContract.bind(proxy)
const callForwarderResult = appForwarder.try_isForwarder()
if (callForwarderResult.reverted) {
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-thegraph/subgraph/src/helpers/ens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ZERO_ADDR } from './constants'

const ENS_ADDRESS = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'

const OLD_ENS_ADDRESS = '0x112234455C3a32FD11230C42E7Bccd4A84e02010'
const OLD_ENS_ADDRESS = '0x314159265dD8dbb310642f98f50C066173C1259b'

export function resolveRepo(appId: Bytes): Address {
let ens = ENS.bind(Address.fromString(ENS_ADDRESS))
Expand Down
24 changes: 13 additions & 11 deletions packages/connect-thegraph/subgraph/src/mappings/acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ export function handleSetPermission(event: SetPermissionEvent): void {
// update permission
permission.allowed = event.params.allowed

// update org permissions
const orgPermissions = org.permissions
orgPermissions.push(permission.id)
org.permissions = orgPermissions

org.save()
permission.save()
role.save()
if(org) {
// update org permissions
const orgPermissions = org.permissions
orgPermissions.push(permission.id)
org.permissions = orgPermissions

org.save()
permission.save()
role.save()
}
}

export function handleChangePermissionManager(
Expand Down Expand Up @@ -121,7 +123,7 @@ function loadOrCreateRole(appAddress: Address, roleHash: Bytes): RoleEntity {
role.app = appAddress.toHexString()
role.manager = Bytes.fromHexString(ZERO_ADDR) as Bytes
}
return role!
return role
}

function buildPermissionId(
Expand Down Expand Up @@ -152,7 +154,7 @@ function loadOrCreatePermission(
permission.app = appAddress.toHexString()
permission.role = buildRoleId(appAddress, roleHash)
}
return permission!
return permission
}

function buildParamId(paramHash: Bytes, index: number): string {
Expand Down Expand Up @@ -183,5 +185,5 @@ function loadOrCreateParam(
param.operationType = paramData.value1
param.argumentValue = paramData.value2
}
return param!
return param
}
4 changes: 2 additions & 2 deletions packages/connect-thegraph/subgraph/src/mappings/orgFactory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address } from '@graphprotocol/graph-ts'

// Import event types from the contract ABI
import { DeployDAO as DeployDAOEvent } from '../../generated/DaoFactory/DAOFactory'
import { DeployDAO as DeployDAOEvent } from '../../generated/DAOFactory/DAOFactory'

// Import entity types from the schema
import { OrgFactory as FactoryEntity } from '../../generated/schema'
Expand Down Expand Up @@ -43,5 +43,5 @@ function loadOrCreateOrgFactory(factoryAddress: Address): FactoryEntity {
factory.orgCount = 0
factory.organizations = []
}
return factory!
return factory
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function loadOrCreateOrg(
org.permissions = []
org.createdAt = createAt
}
return org!
return org
}

function loadOrCreateApp(
Expand All @@ -131,7 +131,7 @@ function loadOrCreateApp(
app.isForwarder = isForwarder(proxyAddress)
app.isUpgradeable = isUpgradeable
}
return app!
return app
}

function addKernelApp(kernelProxy: Address, org: OrganizationEntity): void {
Expand Down Expand Up @@ -178,5 +178,5 @@ function loadOrCreateImplementation(
if (implementation === null) {
implementation = new ImplementationEntity(implementationId)
}
return implementation!
return implementation
}
4 changes: 2 additions & 2 deletions packages/connect-thegraph/subgraph/src/mappings/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function loadOrCreateRegistry(
registry.repoCount = 0
registry.repos = []
}
return registry!
return registry
}

export function loadOrCreateRepo(
Expand All @@ -90,5 +90,5 @@ export function loadOrCreateRepo(
repo.versions = []
repo.appCount = 0
}
return repo!
return repo
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ function loadOrCreateApmFactory(
factory.registryCount = 0
factory.registries = []
}
return factory!
return factory
}
2 changes: 1 addition & 1 deletion packages/connect-thegraph/subgraph/src/mappings/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ function loadOrCreateVersion(
version.contentUri = versionData.value2.toString()
}
}
return version!
return version
}
Loading

0 comments on commit 175fac1

Please sign in to comment.