Skip to content

Commit

Permalink
Merge pull request #314 from gnosisguild/subgraph-include-allowance-i…
Browse files Browse the repository at this point in the history
…n-schema

Include Allowances in Graphql schema and query
  • Loading branch information
jfschwarz authored Jan 27, 2025
2 parents 1c34598 + 97230b6 commit 01f676e
Show file tree
Hide file tree
Showing 11 changed files with 1,327 additions and 1,247 deletions.
4 changes: 2 additions & 2 deletions 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.4",
"version": "2.4.0",
"license": "LGPL-3.0+",
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
Expand Down Expand Up @@ -28,4 +28,4 @@
"installConfig": {
"hoistingLimits": "workspaces"
}
}
}
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.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-mainnet/v2.3.3",
},
[10]: {
name: "optimism",
prefix: "oeth",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-optimism/v2.3.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-optimism/v2.3.3",
},
[100]: {
name: "gnosis",
prefix: "gno",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-gnosis/v2.3.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-gnosis/v2.3.3",
},
[137]: {
name: "polygon",
prefix: "matic",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-polygon/v2.3.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-polygon/v2.3.3",
},
[1101]: {
name: "zkevm",
prefix: "zkevm",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-zkevm/v2.3.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-zkevm/v2.3.3",
},
[42161]: {
name: "arbitrumOne",
prefix: "arb1",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-arbitrum-one/v2.3.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-arbitrum-one/v2.3.3",
},
[43114]: {
name: "avalanche",
prefix: "avax",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-avalanche/v2.3.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-avalanche/v2.3.3",
},
[56]: {
name: "bsc",
prefix: "bnb",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-bsc/v2.3.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-bsc/v2.3.3",
},
[8453]: {
name: "base",
prefix: "base",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-base/v2.3.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-base/v2.3.3",
},
[84532]: {
name: "baseSepolia",
prefix: "basesep",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-base-sepolia/v2.3.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-base-sepolia/v2.3.3",
},
[11155111]: {
name: "sepolia",
prefix: "sep",
subgraph:
"https://api.studio.thegraph.com/query/93263/zodiac-roles-sepolia/v2.3.2",
"https://api.studio.thegraph.com/query/93263/zodiac-roles-sepolia/v2.3.3",
},
} as const
32 changes: 30 additions & 2 deletions packages/deployments/src/fetchRolesMod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { chains } from "./chains"
import { ChainId, Clearance, ExecutionOptions, Function } from "./types"
import {
Allowance,
ChainId,
Clearance,
ExecutionOptions,
Function,
} from "./types"

type Props = {
address: `0x${string}`
Expand Down Expand Up @@ -40,7 +46,20 @@ const QUERY = `
}
lastUpdate
}
unwrapAdapters(where: {selector: "0x8d80ff0a", adapterAddress: "0x93b7fcbc63ed8a3a24b59e1c3e6649d50b7427c0"}) {
allowances(first: 1000) {
key
refill
maxRefill
period
balance
timestamp
}
unwrapAdapters(
where: {
selector: "0x8d80ff0a",
adapterAddress: "0x93b7fcbc63ed8a3a24b59e1c3e6649d50b7427c0"
}
) {
targetAddress
}
}
Expand Down Expand Up @@ -111,12 +130,21 @@ export interface RolesModifier {
avatar: `0x${string}`
target: `0x${string}`
roles: RoleSummary[]
allowances: Allowance[]
multiSendAddresses: `0x${string}`[]
}

const mapGraphQl = (rolesModifier: any): RolesModifier => ({
...rolesModifier,
roles: rolesModifier.roles.map(mapGraphQlRole),
allowances: rolesModifier.allowances.map((allowance: any) => ({
key: allowance.key,
refill: BigInt(allowance.refill),
maxRefill: BigInt(allowance.maxRefill),
period: BigInt(allowance.period),
balance: BigInt(allowance.balance),
timestamp: BigInt(allowance.timestamp),
})),
multiSendAddresses: rolesModifier.unwrapAdapters.map(
(adapter: any) => adapter.targetAddress
),
Expand Down
9 changes: 9 additions & 0 deletions packages/deployments/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ export interface Condition {
children?: readonly Condition[]
}

export interface Allowance {
key: `0x${string}`
refill: bigint
maxRefill: bigint
period: bigint
balance: bigint
timestamp: bigint
}

export interface Annotation {
/** The URI serves as ID for the annotation. An http get request will be made to fetch the targeted permissions. */
uri: string
Expand Down
8 changes: 4 additions & 4 deletions packages/deployments/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"lib": ["es2020", "dom"],
"moduleResolution": "node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es2020",
"typeRoots": ["node_modules/@types"]
},
"include": ["./src"]
}
}
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@
"installConfig": {
"hoistingLimits": "workspaces"
}
}
}
1 change: 0 additions & 1 deletion packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ export * from "./api"

export * from "./ethSdk"
export * from "./abi"
export * from "./types"
8 changes: 0 additions & 8 deletions packages/sdk/src/types.ts

This file was deleted.

28 changes: 14 additions & 14 deletions packages/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
"format": "prettier '(test|src)/**/*.ts' -w",
"pre-commit": "yarn format",
"deploy:local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 gnosis/zodiac-roles-local",
"deploy:mainnet": "yarn prepare:mainnet && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_MAINNET'",
"deploy:sepolia": "yarn prepare:sepolia && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_SEPOLIA'",
"deploy:gnosis": "yarn prepare:gnosis && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_GNOSIS'",
"deploy:arbitrum-one": "yarn prepare:arbitrum-one && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_ARBITRUM_ONE'",
"deploy:avalanche": "yarn prepare:avalanche && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_AVALANCHE'",
"deploy:optimism": "yarn prepare:optimism && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_OPTIMISM'",
"deploy:base": "yarn prepare:base && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_BASE'",
"deploy:base-sepolia": "yarn prepare:base-sepolia && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_BASE_SEPOLIA'",
"deploy:polygon": "yarn prepare:polygon && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_POLYGON'",
"deploy:zkevm": "yarn prepare:zkevm && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_ZKEVM'",
"deploy:bsc": "yarn prepare:bsc && bash -c 'source .env || true && graph deploy --studio $SUBGRAPH_BSC'",
"deploy:mainnet": "yarn prepare:mainnet && bash -c 'source .env || true && graph deploy $SUBGRAPH_MAINNET'",
"deploy:sepolia": "yarn prepare:sepolia && bash -c 'source .env || true && graph deploy $SUBGRAPH_SEPOLIA'",
"deploy:gnosis": "yarn prepare:gnosis && bash -c 'source .env || true && graph deploy $SUBGRAPH_GNOSIS'",
"deploy:arbitrum-one": "yarn prepare:arbitrum-one && bash -c 'source .env || true && graph deploy $SUBGRAPH_ARBITRUM_ONE'",
"deploy:avalanche": "yarn prepare:avalanche && bash -c 'source .env || true && graph deploy $SUBGRAPH_AVALANCHE'",
"deploy:optimism": "yarn prepare:optimism && bash -c 'source .env || true && graph deploy $SUBGRAPH_OPTIMISM'",
"deploy:base": "yarn prepare:base && bash -c 'source .env || true && graph deploy $SUBGRAPH_BASE'",
"deploy:base-sepolia": "yarn prepare:base-sepolia && bash -c 'source .env || true && graph deploy $SUBGRAPH_BASE_SEPOLIA'",
"deploy:polygon": "yarn prepare:polygon && bash -c 'source .env || true && graph deploy $SUBGRAPH_POLYGON'",
"deploy:zkevm": "yarn prepare:zkevm && bash -c 'source .env || true && graph deploy $SUBGRAPH_ZKEVM'",
"deploy:bsc": "yarn prepare:bsc && bash -c 'source .env || true && graph deploy $SUBGRAPH_BSC'",
"prepare:mainnet": "mustache networks/mainnet.json subgraph.template.yaml > subgraph.yaml",
"prepare:sepolia": "mustache networks/sepolia.json subgraph.template.yaml > subgraph.yaml",
"prepare:gnosis": "mustache networks/gnosis.json subgraph.template.yaml > subgraph.yaml",
Expand All @@ -36,11 +36,11 @@
"prettier": "^2.8.8"
},
"dependencies": {
"@graphprotocol/graph-cli": "^0.71.0",
"@graphprotocol/graph-ts": "^0.35.1",
"@graphprotocol/graph-cli": "^0.94.0",
"@graphprotocol/graph-ts": "^0.37.0",
"assemblyscript-json": "^1.1.0"
},
"installConfig": {
"hoistingLimits": "workspaces"
}
}
}
1 change: 1 addition & 0 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ type RolesModifier @entity {
avatar: Bytes!
target: Bytes!
roles: [Role!]! @derivedFrom(field: "rolesModifier")
allowances: [Allowance!]! @derivedFrom(field: "rolesModifier")
unwrapAdapters: [UnwrapAdapter!]! @derivedFrom(field: "rolesModifier")
}

Expand Down
Loading

0 comments on commit 01f676e

Please sign in to comment.