From 05d1deff3909a529981427c580bd83c7604f2372 Mon Sep 17 00:00:00 2001 From: Corantin Date: Mon, 6 Nov 2023 14:24:43 -0500 Subject: [PATCH] Fix govenr subgraph --- packages/react-app/src/networks.ts | 4 +- .../manifest/templates/Govern.yaml | 2 +- .../manifest/templates/GovernQueue.yaml | 2 +- .../manifest/templates/GovernQueueV2.yaml | 2 +- .../templates/GovernRegistry.template.yaml | 2 +- .../manifest/templates/subgraph.template.yaml | 2 +- .../subgraphs/govern-subgraph/package.json | 6 +- .../subgraphs/govern-subgraph/src/Govern.ts | 13 +- .../govern-subgraph/src/GovernQueue.ts | 120 +++++++----- .../govern-subgraph/src/GovernQueueV2.ts | 20 ++ .../govern-subgraph/src/GovernQueueV3.ts | 22 +-- .../govern-subgraph/src/lib/MiniACL.ts | 56 +++--- .../govern-subgraph/src/utils/tokens.ts | 10 +- .../subgraphs/govern-subgraph/subgraph.yaml | 184 +++++++++--------- 14 files changed, 241 insertions(+), 204 deletions(-) create mode 100644 packages/subgraphs/govern-subgraph/src/GovernQueueV2.ts diff --git a/packages/react-app/src/networks.ts b/packages/react-app/src/networks.ts index b863cba6..2e05be46 100644 --- a/packages/react-app/src/networks.ts +++ b/packages/react-app/src/networks.ts @@ -11,7 +11,7 @@ export const networks = Object.freeze({ name: 'Goerli tesnet', explorer: 'etherscan', questsSubgraph: 'https://api.studio.thegraph.com/query/33583/quests-goerli/version/latest', - governSubgraph: 'https://api.thegraph.com/subgraphs/name/corantin/govern-goerli', + governSubgraph: 'https://api.studio.thegraph.com/query/33583/govern-goerli/version/latest', tokenPairSubgraph: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2', questFactoryAddress: HardhatDeployement[5].goerli.contracts.QuestFactory.address, celesteAddress: HardhatDeployement[5].goerli.contracts.Celeste.address, @@ -24,7 +24,7 @@ export const networks = Object.freeze({ }, goerliStaging: { stagingOf: 'goerli', - governSubgraph: 'https://api.thegraph.com/subgraphs/name/corantin/govern-goerli-staging', + // governSubgraph: 'https://api.thegraph.com/subgraphs/name/corantin/govern-goerli-staging', } as StagingNetworkModel, gnosis: { networkId: 'xdai', diff --git a/packages/subgraphs/govern-subgraph/manifest/templates/Govern.yaml b/packages/subgraphs/govern-subgraph/manifest/templates/Govern.yaml index 7d0d9c9c..975784e0 100644 --- a/packages/subgraphs/govern-subgraph/manifest/templates/Govern.yaml +++ b/packages/subgraphs/govern-subgraph/manifest/templates/Govern.yaml @@ -6,7 +6,7 @@ startBlock: {{startBlock}} mapping: kind: ethereum/events - apiVersion: 0.0.1 + apiVersion: 0.0.7 language: wasm/assemblyscript entities: - Container diff --git a/packages/subgraphs/govern-subgraph/manifest/templates/GovernQueue.yaml b/packages/subgraphs/govern-subgraph/manifest/templates/GovernQueue.yaml index 3effea67..479aa857 100644 --- a/packages/subgraphs/govern-subgraph/manifest/templates/GovernQueue.yaml +++ b/packages/subgraphs/govern-subgraph/manifest/templates/GovernQueue.yaml @@ -7,7 +7,7 @@ startBlock: {{startBlock}} mapping: kind: ethereum/events - apiVersion: 0.0.4 + apiVersion: 0.0.7 language: wasm/assemblyscript entities: - Collateral diff --git a/packages/subgraphs/govern-subgraph/manifest/templates/GovernQueueV2.yaml b/packages/subgraphs/govern-subgraph/manifest/templates/GovernQueueV2.yaml index b09e1d9a..5936d3ec 100644 --- a/packages/subgraphs/govern-subgraph/manifest/templates/GovernQueueV2.yaml +++ b/packages/subgraphs/govern-subgraph/manifest/templates/GovernQueueV2.yaml @@ -7,7 +7,7 @@ startBlock: {{startBlock}} mapping: kind: ethereum/events - apiVersion: 0.0.4 + apiVersion: 0.0.7 language: wasm/assemblyscript entities: - Collateral diff --git a/packages/subgraphs/govern-subgraph/manifest/templates/GovernRegistry.template.yaml b/packages/subgraphs/govern-subgraph/manifest/templates/GovernRegistry.template.yaml index 841e3c05..4b43c85a 100644 --- a/packages/subgraphs/govern-subgraph/manifest/templates/GovernRegistry.template.yaml +++ b/packages/subgraphs/govern-subgraph/manifest/templates/GovernRegistry.template.yaml @@ -8,7 +8,7 @@ startBlock: {{startBlock}} mapping: kind: ethereum/events - apiVersion: 0.0.1 + apiVersion: 0.0.7 language: wasm/assemblyscript entities: - RegistryEntry diff --git a/packages/subgraphs/govern-subgraph/manifest/templates/subgraph.template.yaml b/packages/subgraphs/govern-subgraph/manifest/templates/subgraph.template.yaml index 5e14e159..643577b3 100644 --- a/packages/subgraphs/govern-subgraph/manifest/templates/subgraph.template.yaml +++ b/packages/subgraphs/govern-subgraph/manifest/templates/subgraph.template.yaml @@ -1,6 +1,6 @@ # Do not edit subgraph.yaml,this is a generated file. # Instead, edit subgraph.template.yaml and run `yarn manifest--[staging]` -specVersion: 0.0.2 +specVersion: 0.0.5 description: A template for Aragon subgraphs repository: https://github.com/aragon/govern schema: diff --git a/packages/subgraphs/govern-subgraph/package.json b/packages/subgraphs/govern-subgraph/package.json index 76cf03b1..d6cdfb58 100644 --- a/packages/subgraphs/govern-subgraph/package.json +++ b/packages/subgraphs/govern-subgraph/package.json @@ -10,7 +10,7 @@ "manifest:gnosis": "node ./scripts/mustache gnosis", "build": "graph build", "codegen": "graph codegen", - "deploy:goerli": "dotenv -- cross-var yarn manifest:goerli && graph deploy corantin/govern-goerli --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --access-token %THE_GRAPH_ACCESS_TOKEN%", + "deploy:goerli": "graph deploy --studio govern-goerli", "deploy:goerli-staging": "dotenv -- cross-var yarn manifest:goerli && graph deploy corantin/govern-goerli-staging --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --access-token %THE_GRAPH_ACCESS_TOKEN%", "deploy:gnosis": "dotenv -- cross-var yarn manifest:gnosis && graph deploy corantin/govern-1hive-xdai --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --access-token %THE_GRAPH_ACCESS_TOKEN%", "deploy:gnosis-staging": "dotenv -- cross-var yarn manifest:gnosis && graph deploy corantin/govern-1hive-gnosis-staging --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --access-token %THE_GRAPH_ACCESS_TOKEN%", @@ -19,8 +19,8 @@ "graph": "graph" }, "devDependencies": { - "@graphprotocol/graph-cli": "^0.19.0", - "@graphprotocol/graph-ts": "^0.19.0", + "@graphprotocol/graph-cli": "^0.60.0", + "@graphprotocol/graph-ts": "^0.31.0", "mustache": "^4.2.0" }, "dependencies": { diff --git a/packages/subgraphs/govern-subgraph/src/Govern.ts b/packages/subgraphs/govern-subgraph/src/Govern.ts index af5b36c5..792829a9 100644 --- a/packages/subgraphs/govern-subgraph/src/Govern.ts +++ b/packages/subgraphs/govern-subgraph/src/Govern.ts @@ -1,4 +1,4 @@ -import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; +import { Address } from "@graphprotocol/graph-ts"; import { Executed as ExecutedEvent, Frozen as FrozenEvent, @@ -12,12 +12,15 @@ import { Govern, Deposit, Withdraw } from "../generated/schema"; import { frozenRoles, roleGranted, roleRevoked } from "./lib/MiniACL"; import { loadOrCreateContainer } from "./GovernQueue"; import { handleContainerEventExecute } from "./utils/events"; -import { buildId, buildIndexedId } from "./utils/ids"; +import { buildId } from "./utils/ids"; import { ZERO_ADDRESS } from "./utils/constants"; export function handleExecuted(event: ExecutedEvent): void { let govern = loadOrCreateGovern(event.address); - let container = loadOrCreateContainer(event.params.memo); + let container = loadOrCreateContainer( + event.params.memo, + event.address.toHex() + ); handleContainerEventExecute(container, event); @@ -71,7 +74,7 @@ export function handleWithdrawn(event: WithdrawnEvent): void { export function handleFrozen(event: FrozenEvent): void { let govern = loadOrCreateGovern(event.address); - let roles = govern.roles!; + let roles = govern.roles; frozenRoles(roles, event.params.role); } @@ -113,5 +116,5 @@ export function loadOrCreateGovern(entity: Address): Govern { govern.address = entity; govern.roles = []; } - return govern!; + return govern; } diff --git a/packages/subgraphs/govern-subgraph/src/GovernQueue.ts b/packages/subgraphs/govern-subgraph/src/GovernQueue.ts index c2b698e8..83df2592 100644 --- a/packages/subgraphs/govern-subgraph/src/GovernQueue.ts +++ b/packages/subgraphs/govern-subgraph/src/GovernQueue.ts @@ -1,11 +1,4 @@ -import { - Address, - Bytes, - BigInt, - ipfs, - json, - log, -} from "@graphprotocol/graph-ts"; +import { Address, Bytes, BigInt, log } from "@graphprotocol/graph-ts"; import { Challenged as ChallengedEvent, Configured as ConfiguredEvent, @@ -52,9 +45,13 @@ import { import { loadOrCreateGovern } from "./Govern"; export function handleScheduled(event: ScheduledEvent): void { + log.info("handleScheduled, {}", [event.params.containerHash.toHex()]); let queue = loadOrCreateQueue(event.address); let payload = loadOrCreatePayload(event.params.containerHash); - let container = loadOrCreateContainer(event.params.containerHash); + let container = loadOrCreateContainer( + event.params.containerHash, + event.address.toHex() + ); let executor = loadOrCreateGovern(event.params.payload.executor); // Builds each of the actions bundled in the payload, @@ -68,27 +65,6 @@ export function handleScheduled(event: ScheduledEvent): void { payload.allowFailuresMap = event.params.payload.allowFailuresMap; payload.proof = event.params.payload.proof; - let proofIpfsHex = event.params.payload.proof.toHexString().substring(2); - - // if cidString is ipfs v1 version hex from the cid's raw bytes and - // we add `f` as a multibase prefix and remove `0x` - let result = ipfs.cat("f" + proofIpfsHex + "/metadata.json"); - if (!result) { - // if cidString is ipfs v0 version hex from the cid's raw bytes, - // we add: - // 1. 112 (0x70 in hex) which is dag-pb format. - // 2. 01 because we want to use v1 version - // 3. f since cidString is already hex, we only add `f` without converting anything. - result = ipfs.cat("f0170" + proofIpfsHex + "/metadata.json"); - } - - if (result) { - // log.debug('title {}', [result.toHex()]) - // let data = json.fromBytes(result as Bytes) - // payload.title = data.toObject().get('title').toString() - payload.title = result.toHex(); - } - container.payload = payload.id; container.state = SCHEDULED_STATUS; container.createdAt = event.block.timestamp; @@ -99,7 +75,7 @@ export function handleScheduled(event: ScheduledEvent): void { let config = loadConfig(queue.config); let scheduleDeposit = loadCollateral(config.scheduleDeposit); - handleContainerEventSchedule(container, event, scheduleDeposit as Collateral); + handleContainerEventSchedule(container, event, scheduleDeposit); executor.save(); payload.save(); @@ -108,14 +84,19 @@ export function handleScheduled(event: ScheduledEvent): void { } export function handleExecuted(event: ExecutedEvent): void { - let container = loadOrCreateContainer(event.params.containerHash); + log.info("handleExecuted, {}", [event.params.containerHash.toHex()]); + let container = loadOrCreateContainer( + event.params.containerHash, + event.address.toHex() + ); container.state = EXECUTED_STATUS; container.save(); } export function handleChallenged(event: ChallengedEvent): void { + log.info("handleChallenged, {}", [event.params.containerHash.toHex()]); let queue = loadOrCreateQueue(event.address); - let container = loadOrCreateContainer(event.params.containerHash); + let container = loadOrCreateContainer(event.params.containerHash, queue.id); container.state = CHALLENGED_STATUS; @@ -132,7 +113,11 @@ export function handleChallenged(event: ChallengedEvent): void { } export function handleResolved(event: ResolvedEvent): void { - let container = loadOrCreateContainer(event.params.containerHash); + log.info("handleResolved, {}", [event.params.containerHash.toHex()]); + let container = loadOrCreateContainer( + event.params.containerHash, + event.address.toHex() + ); container.state = event.params.approved ? APPROVED_STATUS : REJECTED_STATUS; @@ -155,8 +140,12 @@ export function handleResolved(event: ResolvedEvent): void { } export function handleVetoed(event: VetoedEvent): void { + log.info("handleVetoed, {}", [event.params.containerHash.toHex()]); let queue = loadOrCreateQueue(event.address); - let container = loadOrCreateContainer(event.params.containerHash); + let container = loadOrCreateContainer( + event.params.containerHash, + event.address.toHex() + ); container.state = VETOED_STATUS; @@ -167,11 +156,11 @@ export function handleVetoed(event: VetoedEvent): void { } export function handleConfigured(event: ConfiguredEvent): void { + log.info("handleConfigured, {}", [event.transaction.hash.toHex()]); let queue = loadOrCreateQueue(event.address); let configId = buildId(event); let config = new Config(configId); - let scheduleDeposit = new Collateral( buildIndexedId(event.transaction.hash.toHex(), 1) ); @@ -186,13 +175,13 @@ export function handleConfigured(event: ConfiguredEvent): void { // Grab Schedule Token info let data = getERC20Info(event.params.config.scheduleDeposit.token); - scheduleDeposit.decimals = data.decimals; + scheduleDeposit.decimals = data.decimals!.toI32(); scheduleDeposit.name = data.name; scheduleDeposit.symbol = data.symbol; // Grab challenge Token info data = getERC20Info(event.params.config.challengeDeposit.token); - challengeDeposit.decimals = data.decimals; + challengeDeposit.decimals = data.decimals!.toI32(); challengeDeposit.name = data.name; challengeDeposit.symbol = data.symbol; @@ -203,6 +192,7 @@ export function handleConfigured(event: ConfiguredEvent): void { config.rules = event.params.config.rules; config.maxCalldataSize = event.params.config.maxCalldataSize; + scheduleDeposit.save(); queue.config = config.id; scheduleDeposit.save(); @@ -214,14 +204,16 @@ export function handleConfigured(event: ConfiguredEvent): void { // MiniACL Events export function handleFrozen(event: FrozenEvent): void { + log.info("handleFrozen, {}", [event.transaction.hash.toHex()]); let queue = loadOrCreateQueue(event.address); - let roles = queue.roles!; + let roles = queue.roles; frozenRoles(roles, event.params.role); } export function handleGranted(event: GrantedEvent): void { + log.info("handleGranted, {}", [event.transaction.hash.toHex()]); let queue = loadOrCreateQueue(event.address); let role = roleGranted(event.address, event.params.role, event.params.who); @@ -235,6 +227,7 @@ export function handleGranted(event: GrantedEvent): void { } export function handleRevoked(event: RevokedEvent): void { + log.info("handleRevoked, {}", [event.transaction.hash.toHex()]); let queue = loadOrCreateQueue(event.address); let role = roleRevoked(event.address, event.params.role, event.params.who); @@ -249,6 +242,7 @@ export function handleRevoked(event: RevokedEvent): void { // create a dummy config when creating queue to avoid not-null error export function createDummyConfig(queueId: string): string { + log.info("createDummyConfig, {}", [queueId]); let ZERO = BigInt.fromI32(0); let configId = queueId; @@ -266,69 +260,91 @@ export function createDummyConfig(queueId: string): string { config.scheduleDeposit = scheduleDeposit.id; config.challengeDeposit = challengeDeposit.id; config.resolver = ZERO_ADDRESS; - config.rules = Bytes.fromI32(0) as Bytes; + config.rules = Bytes.fromI32(0); config.maxCalldataSize = BigInt.fromI32(0); scheduleDeposit.save(); challengeDeposit.save(); config.save(); - return config.id!; + return config.id; } export function loadOrCreateQueue(queueAddress: Address): GovernQueue { + log.info("loadOrCreateQueue, {}", [queueAddress.toHex()]); let queueId = queueAddress.toHex(); // Create queue let queue = GovernQueue.load(queueId); if (queue === null) { + log.info("loadOrCreateQueue, create new queue, {}", [queueId]); queue = new GovernQueue(queueId); queue.address = queueAddress; queue.config = createDummyConfig(queueId); queue.roles = []; } - queue.nonce = GovernQueueContract.bind(queueAddress).nonce(); - return queue!; + return queue; } -export function loadOrCreateContainer(containerHash: Bytes): Container { +export function loadOrCreateContainer( + containerHash: Bytes, + queue: string +): Container { + log.info("loadOrCreateContainer, {}", [containerHash.toHex()]); let ContainerId = containerHash.toHex(); // Create container let container = Container.load(ContainerId); if (container === null) { + log.info("loadOrCreateContainer, create new container, {}", [ContainerId]); container = new Container(ContainerId); container.state = NONE_STATUS; + container.queue = queue; + container.config = createDummyConfig(queue); + container.payload = "temp"; + container.createdAt = BigInt.fromI32(0); } - return container!; + return container; } -function loadOrCreatePayload(containerHash: Bytes): Payload { +export function loadOrCreatePayload(containerHash: Bytes): Payload { + log.info("loadOrCreatePayload, {}", [containerHash.toHex()]); let PayloadId = containerHash.toHex(); // Create payload let payload = Payload.load(PayloadId); if (payload === null) { + log.info("loadOrCreatePayload, create new payload, {}", [PayloadId]); payload = new Payload(PayloadId); + payload.nonce = BigInt.fromI32(0); + payload.executionTime = BigInt.fromI32(0); + payload.submitter = ZERO_ADDRESS; + payload.executor = ZERO_ADDRESS.toHex(); + payload.allowFailuresMap = Bytes.fromI32(0); + payload.proof = Bytes.fromI32(0); } - return payload!; + + return payload; } -function loadConfig(configAddress: string): Config { +export function loadConfig(configAddress: string): Config { + log.info("loadConfig, {}", [configAddress]); let config = Config.load(configAddress); if (config === null) { throw new Error("Config not found."); } - return config!; + return config; } -function loadCollateral(collateralAddress: string): Collateral { +export function loadCollateral(collateralAddress: string): Collateral { + log.info("loadCollateral, {}", [collateralAddress]); let collateral = Collateral.load(collateralAddress); if (collateral === null) { throw new Error("Collateral not found."); } - return collateral!; + return collateral; } -function buildActions(event: ScheduledEvent): void { +export function buildActions(event: ScheduledEvent): void { + log.info("buildActions, {}", [event.transaction.hash.toHex()]); let actions = event.params.payload.actions; for (let index = 0; index < actions.length; index++) { let actionId = buildIndexedId(event.params.containerHash.toHex(), index); diff --git a/packages/subgraphs/govern-subgraph/src/GovernQueueV2.ts b/packages/subgraphs/govern-subgraph/src/GovernQueueV2.ts new file mode 100644 index 00000000..e0fd1ca8 --- /dev/null +++ b/packages/subgraphs/govern-subgraph/src/GovernQueueV2.ts @@ -0,0 +1,20 @@ +import { Scheduled as ScheduledEvent } from "../generated/GovernQueueV2/GovernQueue"; +import { Scheduled as ScheduledEventV1 } from "../generated/GovernQueue/GovernQueue"; +import { handleScheduled as handleScheduledV1 } from "./GovernQueue"; + +export * from "./GovernQueue"; + +export function handleScheduled(event: ScheduledEvent): void { + const scheduledEventV1 = new ScheduledEventV1( + event.address, + event.logIndex, + event.transactionLogIndex, + event.logType, + event.block, + event.transaction, + event.parameters, + event.receipt + ); + // Just ignore the challenger field withc isn't used + handleScheduledV1(scheduledEventV1); +} diff --git a/packages/subgraphs/govern-subgraph/src/GovernQueueV3.ts b/packages/subgraphs/govern-subgraph/src/GovernQueueV3.ts index d3326e8a..98b99acd 100644 --- a/packages/subgraphs/govern-subgraph/src/GovernQueueV3.ts +++ b/packages/subgraphs/govern-subgraph/src/GovernQueueV3.ts @@ -1,11 +1,6 @@ -import { - ContainerEventResolve, -} from "../generated/schema"; - -import { - Resolved as ResolvedEvent, -} from "../generated/GovernQueueV3/GovernQueue"; +import { ContainerEventResolve } from "../generated/schema"; +import { Resolved as ResolvedEvent } from "../generated/GovernQueueV3/GovernQueue"; import { buildEventHandlerId } from "./utils/ids"; import { finalizeContainerEvent } from "./utils/events"; @@ -17,14 +12,17 @@ import { import { loadOrCreateContainer } from "./GovernQueue"; -export * from "./GovernQueue"; +export * from "./GovernQueueV2"; export function handleResolved(event: ResolvedEvent): void { - let container = loadOrCreateContainer(event.params.containerHash); + let container = loadOrCreateContainer( + event.params.containerHash, + event.address.toHex() + ); - if (event.params.ruling == 4) { + if (event.params.ruling.toI32() == 4) { container.state = APPROVED_STATUS; - } else if (event.params.ruling == 3) { + } else if (event.params.ruling.toI32() == 3) { container.state = REJECTED_STATUS; } else { container.state = CANCELLED_STATUS; @@ -37,7 +35,7 @@ export function handleResolved(event: ResolvedEvent): void { ); let containerEvent = new ContainerEventResolve(eventId); - containerEvent.ruling = event.params.ruling; + containerEvent.ruling = event.params.ruling.toI32(); finalizeContainerEvent( container, diff --git a/packages/subgraphs/govern-subgraph/src/lib/MiniACL.ts b/packages/subgraphs/govern-subgraph/src/lib/MiniACL.ts index 20580fce..d284dc11 100644 --- a/packages/subgraphs/govern-subgraph/src/lib/MiniACL.ts +++ b/packages/subgraphs/govern-subgraph/src/lib/MiniACL.ts @@ -1,14 +1,14 @@ -import { Address, Bytes } from '@graphprotocol/graph-ts' -import { Role as RoleEntity } from '../../generated/schema' +import { Address, Bytes } from "@graphprotocol/graph-ts"; +import { Role as RoleEntity } from "../../generated/schema"; export function frozenRoles(roles: string[], selector: Bytes): void { - roles - .map((role) => RoleEntity.load(role)!) - .filter((role) => role.selector === selector) - .forEach((role) => { - role.frozen = true - role.save() - }) + for (let i = 0; i < roles.length; i++) { + const role = RoleEntity.load(roles[i]); + if (role && role.selector === selector) { + role.frozen = true; + role.save(); + } + } } export function roleGranted( @@ -16,12 +16,12 @@ export function roleGranted( selector: Bytes, who: Address ): RoleEntity { - let role = loadOrCreateRole(entity, selector, who) - role.granted = true + let role = loadOrCreateRole(entity, selector, who); + role.granted = true; - role.save() + role.save(); - return role + return role; } export function roleRevoked( @@ -29,12 +29,12 @@ export function roleRevoked( selector: Bytes, who: Address ): RoleEntity { - let role = loadOrCreateRole(entity, selector, who) - role.granted = false + let role = loadOrCreateRole(entity, selector, who); + role.granted = false; - role.save() + role.save(); - return role + return role; } function buildRoleId(entity: Address, selector: Bytes, who: Address): string { @@ -43,8 +43,8 @@ function buildRoleId(entity: Address, selector: Bytes, who: Address): string { // This is equivalent to storing all roles in the contract, and looking up the corresponding // entry by mapping role => who return ( - entity.toHex() + '-selector-' + selector.toHex() + '-who-' + who.toHex() - ) + entity.toHex() + "-selector-" + selector.toHex() + "-who-" + who.toHex() + ); } function loadOrCreateRole( @@ -52,16 +52,16 @@ function loadOrCreateRole( selector: Bytes, who: Address ): RoleEntity { - let roleId = buildRoleId(entity, selector, who) + let roleId = buildRoleId(entity, selector, who); // Create role - let role = RoleEntity.load(roleId) + let role = RoleEntity.load(roleId); if (role === null) { - role = new RoleEntity(roleId) - role.entity = entity - role.selector = selector - role.who = who - role.granted = false - role.frozen = false + role = new RoleEntity(roleId); + role.entity = entity; + role.selector = selector; + role.who = who; + role.granted = false; + role.frozen = false; } - return role! + return role; } diff --git a/packages/subgraphs/govern-subgraph/src/utils/tokens.ts b/packages/subgraphs/govern-subgraph/src/utils/tokens.ts index a4e14014..8fe5033c 100644 --- a/packages/subgraphs/govern-subgraph/src/utils/tokens.ts +++ b/packages/subgraphs/govern-subgraph/src/utils/tokens.ts @@ -1,11 +1,11 @@ -import { ethereum } from "@graphprotocol/graph-ts"; +import { BigInt } from "@graphprotocol/graph-ts"; import { ERC20 } from "../../generated/GovernQueue/ERC20"; import { Address } from "@graphprotocol/graph-ts"; class ERCInfo { - decimals: i32; - name: string; - symbol: string; + decimals: BigInt | null; + name: string | null; + symbol: string | null; } export function getERC20Info(address: Address): ERCInfo { @@ -16,7 +16,7 @@ export function getERC20Info(address: Address): ERCInfo { let symbol = token.try_symbol(); return { - decimals: decimals.reverted ? null : decimals.value, + decimals: decimals.reverted ? null : BigInt.fromI32(decimals.value), name: name.reverted ? null : name.value, symbol: decimals.reverted ? null : symbol.value, }; diff --git a/packages/subgraphs/govern-subgraph/subgraph.yaml b/packages/subgraphs/govern-subgraph/subgraph.yaml index 64082b88..45a98c4a 100644 --- a/packages/subgraphs/govern-subgraph/subgraph.yaml +++ b/packages/subgraphs/govern-subgraph/subgraph.yaml @@ -1,6 +1,6 @@ # Do not edit subgraph.yaml,this is a generated file. # Instead, edit subgraph.template.yaml and run `yarn manifest--[staging]` -specVersion: 0.0.2 +specVersion: 0.0.5 description: A template for Aragon subgraphs repository: https://github.com/aragon/govern schema: @@ -11,10 +11,10 @@ dataSources: network: goerli source: abi: Govern - startBlock: 9638019 + startBlock: 7985656 mapping: kind: ethereum/events - apiVersion: 0.0.4 + apiVersion: 0.0.7 language: wasm/assemblyscript entities: - Container @@ -41,102 +41,102 @@ dataSources: - event: Revoked(indexed bytes4,indexed address,indexed address) handler: handleRevoked file: ./src/Govern.ts - # - kind: ethereum/contract - # name: GovernQueue - # network: gnosis - # source: - # abi: GovernQueue - # address: "0xd8D142f13E58dFEedaF96418C0B6843108d46B94" - # startBlock: 22769097 - # mapping: - # kind: ethereum/events - # apiVersion: 0.0.4 - # language: wasm/assemblyscript - # entities: - # - Collateral - # - Config - # - Container - # - ContainerEvent - # - Payload - # - Role - # abis: - # - name: GovernQueue - # file: ./govern-core/abi/contracts/pipelines/GovernQueue.sol/GovernQueue.json - # - name: ERC20 - # file: ./govern-contract-utils/abi/contracts/erc20/ERC20.sol/ERC20.json - # eventHandlers: - # - event: Configured(indexed bytes32,indexed address,(uint256,(address,uint256),(address,uint256),address,bytes,uint256)) - # handler: handleConfigured - # - event: Frozen(indexed bytes4,indexed address) - # handler: handleFrozen - # - event: Granted(indexed bytes4,indexed address,indexed address,address) - # handler: handleGranted - # - event: Scheduled(indexed bytes32,(uint256,uint256,address,address,(address,uint256,bytes)[],bytes32,bytes)) - # handler: handleScheduled - # - event: Executed(indexed bytes32,indexed address) - # handler: handleExecuted - # - event: Challenged(indexed bytes32,indexed address,bytes,uint256,(address,uint256)) - # handler: handleChallenged - # - event: Vetoed(indexed bytes32,indexed address,bytes) - # handler: handleVetoed - # - event: Resolved(indexed bytes32,indexed address,bool) - # handler: handleResolved - # - event: Revoked(indexed bytes4,indexed address,indexed address) - # handler: handleRevoked - # file: ./src/GovernQueue.ts - # - kind: ethereum/contract - # name: GovernQueueV2 - # network: gnosis - # source: - # abi: GovernQueue - # address: "0x6D8189C979bBB6768395A78E2AB8A15133459600" - # startBlock: 25719047 - # mapping: - # kind: ethereum/events - # apiVersion: 0.0.4 - # language: wasm/assemblyscript - # entities: - # - Collateral - # - Config - # - Container - # - ContainerEvent - # - Payload - # - Role - # abis: - # - name: GovernQueue - # file: ./govern-core/abi/contracts/pipelines/GovernQueue.sol/GovernQueue.json - # - name: ERC20 - # file: ./govern-contract-utils/abi/contracts/erc20/ERC20.sol/ERC20.json - # eventHandlers: - # - event: Configured(indexed bytes32,indexed address,(uint256,(address,uint256),(address,uint256),address,bytes,uint256)) - # handler: handleConfigured - # - event: Frozen(indexed bytes4,indexed address) - # handler: handleFrozen - # - event: Granted(indexed bytes4,indexed address,indexed address,address) - # handler: handleGranted - # - event: Scheduled(indexed bytes32,(uint256,uint256,address,address,(address,uint256,bytes)[],bytes32,bytes)) - # handler: handleScheduled - # - event: Executed(indexed bytes32,indexed address) - # handler: handleExecuted - # - event: Challenged(indexed bytes32,indexed address,bytes,uint256,(address,uint256)) - # handler: handleChallenged - # - event: Vetoed(indexed bytes32,indexed address,bytes) - # handler: handleVetoed - # - event: Resolved(indexed bytes32,indexed address,bool) - # handler: handleResolved - # - event: Revoked(indexed bytes4,indexed address,indexed address) - # handler: handleRevoked - # file: ./src/GovernQueue.ts + - kind: ethereum/contract + name: GovernQueue + network: goerli + source: + abi: GovernQueue + address: "0x71aCe36baFFcEA97e934874B3F2f340C292d4f1E" + startBlock: 7543552 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Collateral + - Config + - Container + - ContainerEvent + - Payload + - Role + abis: + - name: GovernQueue + file: ./govern-core/abi/contracts/pipelines/GovernQueue.sol/GovernQueue.json + - name: ERC20 + file: ./govern-contract-utils/abi/contracts/erc20/ERC20.sol/ERC20.json + eventHandlers: + - event: Configured(indexed bytes32,indexed address,(uint256,(address,uint256),(address,uint256),address,bytes,uint256)) + handler: handleConfigured + - event: Frozen(indexed bytes4,indexed address) + handler: handleFrozen + - event: Granted(indexed bytes4,indexed address,indexed address,address) + handler: handleGranted + - event: Scheduled(indexed bytes32,(uint256,uint256,address,address,(address,uint256,bytes)[],bytes32,bytes)) + handler: handleScheduled + - event: Executed(indexed bytes32,indexed address) + handler: handleExecuted + - event: Challenged(indexed bytes32,indexed address,bytes,uint256,(address,uint256)) + handler: handleChallenged + - event: Vetoed(indexed bytes32,indexed address,bytes) + handler: handleVetoed + - event: Resolved(indexed bytes32,indexed address,bool) + handler: handleResolved + - event: Revoked(indexed bytes4,indexed address,indexed address) + handler: handleRevoked + file: ./src/GovernQueue.ts + - kind: ethereum/contract + name: GovernQueueV2 + network: goerli + source: + abi: GovernQueue + address: "0xc73BCDc0FF18Fb903FCd34de4BFfE37BE66b4E8f" + startBlock: 7986054 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Collateral + - Config + - Container + - ContainerEvent + - Payload + - Role + abis: + - name: GovernQueue + file: ./govern-core/abi/contracts/pipelines/GovernQueue.sol/GovernQueueV2.json + - name: ERC20 + file: ./govern-contract-utils/abi/contracts/erc20/ERC20.sol/ERC20.json + eventHandlers: + - event: Configured(indexed bytes32,indexed address,(uint256,(address,uint256),(address,uint256),address,bytes,uint256)) + handler: handleConfigured + - event: Frozen(indexed bytes4,indexed address) + handler: handleFrozen + - event: Granted(indexed bytes4,indexed address,indexed address,address) + handler: handleGranted + - event: Scheduled(indexed bytes32,(uint256,uint256,address,address,(address,uint256,bytes)[],bytes32,bytes,address)) + handler: handleScheduled + - event: Executed(indexed bytes32,indexed address) + handler: handleExecuted + - event: Challenged(indexed bytes32,indexed address,bytes,uint256,(address,uint256)) + handler: handleChallenged + - event: Vetoed(indexed bytes32,indexed address,bytes) + handler: handleVetoed + - event: Resolved(indexed bytes32,indexed address,bool) + handler: handleResolved + - event: Revoked(indexed bytes4,indexed address,indexed address) + handler: handleRevoked + file: ./src/GovernQueue.ts - kind: ethereum/contract name: GovernQueueV3 network: goerli source: abi: GovernQueue address: "0xce38877414ffd60c1a1e20ddb1d52fa5840d9ca6" - startBlock: 9637990 + startBlock: 9638502 mapping: kind: ethereum/events - apiVersion: 0.0.4 + apiVersion: 0.0.7 language: wasm/assemblyscript entities: - Collateral @@ -169,4 +169,4 @@ dataSources: handler: handleResolved - event: Revoked(indexed bytes4,indexed address,indexed address) handler: handleRevoked - file: ./src/GovernQueue.ts + file: ./src/GovernQueueV3.ts