Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix role's lastUpdate in subgraph #304

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ Address: `0x91B1bd7BCC5E623d5CE76b0152253499a9C819d1`

#### Subgraphs

- [Mainnet](https://api.studio.thegraph.com/query/23167/zodiac-roles-mainnet/v2.3.0)
- [Optimism](https://api.studio.thegraph.com/query/23167/zodiac-roles-optimism/v2.3.0)
- [Gnosis](https://api.studio.thegraph.com/query/23167/zodiac-roles-gnosis/v2.3.0)
- [Polygon](https://api.studio.thegraph.com/query/23167/zodiac-roles-polygon/v2.3.0)
- [Polygon zkEVM](https://api.studio.thegraph.com/query/23167/zodiac-roles-zkevm/v2.3.0)
- [Arbitrum One](https://api.studio.thegraph.com/query/23167/zodiac-roles-arbitrum-one/v2.3.0)
- [Avalanche C-Chain](https://api.studio.thegraph.com/query/23167/zodiac-roles-avalanche/v2.3.0)
- [BSC](https://api.studio.thegraph.com/query/23167/zodiac-roles-bsc/v2.3.0)
- [Base](https://api.studio.thegraph.com/query/23167/zodiac-roles-base/v2.3.0)
- [Base Sepolia](https://api.studio.thegraph.com/query/23167/zodiac-roles-base-sepolia/v2.3.0)
- [Sepolia](https://api.studio.thegraph.com/query/23167/zodiac-roles-sepolia/v2.3.0)
- [Mainnet](https://api.studio.thegraph.com/query/23167/zodiac-roles-mainnet/v2.3.1)
- [Optimism](https://api.studio.thegraph.com/query/23167/zodiac-roles-optimism/v2.3.1)
- [Gnosis](https://api.studio.thegraph.com/query/23167/zodiac-roles-gnosis/v2.3.1)
- [Polygon](https://api.studio.thegraph.com/query/23167/zodiac-roles-polygon/v2.3.1)
- [Polygon zkEVM](https://api.studio.thegraph.com/query/23167/zodiac-roles-zkevm/v2.3.1)
- [Arbitrum One](https://api.studio.thegraph.com/query/23167/zodiac-roles-arbitrum-one/v2.3.1)
- [Avalanche C-Chain](https://api.studio.thegraph.com/query/23167/zodiac-roles-avalanche/v2.3.1)
- [BSC](https://api.studio.thegraph.com/query/23167/zodiac-roles-bsc/v2.3.1)
- [Base](https://api.studio.thegraph.com/query/23167/zodiac-roles-base/v2.3.1)
- [Base Sepolia](https://api.studio.thegraph.com/query/23167/zodiac-roles-base-sepolia/v2.3.1)
- [Sepolia](https://api.studio.thegraph.com/query/23167/zodiac-roles-sepolia/v2.3.1)

### Development environment setup

Expand Down
2 changes: 1 addition & 1 deletion packages/deployments/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zodiac-roles-deployments",
"version": "2.3.1",
"version": "2.3.2",
"license": "LGPL-3.0+",
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
Expand Down
22 changes: 11 additions & 11 deletions packages/deployments/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,66 @@ export const chains = {
name: "mainnet",
prefix: "eth",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-mainnet/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-mainnet/v2.3.1",
},
[10]: {
name: "optimism",
prefix: "oeth",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-optimism/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-optimism/v2.3.1",
},
[100]: {
name: "gnosis",
prefix: "gno",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-gnosis/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-gnosis/v2.3.1",
},
[137]: {
name: "polygon",
prefix: "matic",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-polygon/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-polygon/v2.3.1",
},
[1101]: {
name: "zkevm",
prefix: "zkevm",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-zkevm/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-zkevm/v2.3.1",
},
[42161]: {
name: "arbitrumOne",
prefix: "arb1",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-arbitrum-one/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-arbitrum-one/v2.3.1",
},
[43114]: {
name: "avalanche",
prefix: "avax",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-avalanche/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-avalanche/v2.3.1",
},
[56]: {
name: "bsc",
prefix: "bnb",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-bsc/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-bsc/v2.3.1",
},
[8453]: {
name: "base",
prefix: "base",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-base/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-base/v2.3.1",
},
[84532]: {
name: "baseSepolia",
prefix: "basesep",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-base-sepolia/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-base-sepolia/v2.3.1",
},
[11155111]: {
name: "sepolia",
prefix: "sep",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-sepolia/v2.3.0",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-sepolia/v2.3.1",
},
} as const
19 changes: 18 additions & 1 deletion packages/subgraph/src/poster.mapping.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Address, Bytes, json, JSONValueKind, log, store } from "@graphprotocol/graph-ts"
import { NewPost } from "../generated/Poster/Poster"
import { getAnnotationId, getOrCreateAnnotation, getRoleId, getRolesModifier, getRolesModifierId } from "./helpers"
import {
getAnnotationId,
getOrCreateAnnotation,
getOrCreateRole,
getRoleId,
getRolesModifier,
getRolesModifierId,
} from "./helpers"

export function handleNewPost(event: NewPost): void {
// only listen for events with the tag keccak256("ROLES_PERMISSION_ANNOTATION")
Expand Down Expand Up @@ -45,6 +52,8 @@ export function handleNewPost(event: NewPost): void {

const roleId = getRoleId(rolesModifierId, roleKey)

let hasUpdates = false

const removeAnnotationsEntries =
parsedPost.get("removeAnnotations") && parsedPost.get("removeAnnotations")!.kind == JSONValueKind.ARRAY
? parsedPost.get("removeAnnotations")!.toArray()
Expand All @@ -63,6 +72,7 @@ export function handleNewPost(event: NewPost): void {
const id = getAnnotationId(uri.toString(), roleId)
store.remove("Annotation", id)
log.info("Annotation #{} has been removed", [id])
hasUpdates = true
}

for (let i = 0; i < addAnnotationsEntries.length; i++) {
Expand All @@ -87,6 +97,13 @@ export function handleNewPost(event: NewPost): void {
}
const annotation = getOrCreateAnnotation(uriEntry.toString(), schema.toString(), roleId)
log.info("Annotation #{} has been added", [annotation.id])
hasUpdates = true
}
}

if (hasUpdates) {
// update role's lastUpdate field
const role = getOrCreateRole(roleId, rolesModifierId, roleKey, event.block.number)
role.save()
}
}
Loading