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

feature: moved subgraph from OSx #4

Merged
merged 31 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
27617ab
wip: moved multisig subgraph from OSx
heueristik Mar 11, 2024
6536832
chore: maintained changelog
heueristik Mar 11, 2024
c55b18a
style: fix constness linter errors
heueristik Mar 11, 2024
c93ada9
fix: failing tests
heueristik Mar 11, 2024
6f4819a
refactor: comments and IDs
heueristik Mar 11, 2024
fb5f6b7
refactor: constants
heueristik Mar 11, 2024
41be2e7
doc: comments
heueristik Mar 11, 2024
5ee3f10
doc: remove comment
heueristik Mar 12, 2024
b03ef20
doc: added comment
heueristik Mar 12, 2024
ee8386e
style: add empty line at EOF
heueristik Mar 12, 2024
499ca48
refactor: move ids into separate file
heueristik Mar 12, 2024
8327380
style: EOF
heueristik Mar 12, 2024
ca8272e
test: descriptions
heueristik Mar 12, 2024
8e86250
test: descriptions
heueristik Mar 12, 2024
1c69e14
style: prettier
heueristik Mar 12, 2024
4c30251
fix: missing import
heueristik Mar 12, 2024
0cc1c0d
refactor: variable name
heueristik Mar 12, 2024
9b437f1
refactor: rename dao plugin
heueristik Mar 12, 2024
216d7d7
Merge branch 'develop' into feature/subgraph
heueristik Mar 15, 2024
a7dcf2c
fix: remove merge conflict artifact
heueristik Mar 15, 2024
2ce1ee3
fix: correct entities
heueristik Mar 15, 2024
e6d9a98
chore: put deployment addresses
heueristik Mar 15, 2024
45cf45c
fix: use pluginEntityId (the plugin address as a hex string)
heueristik Mar 15, 2024
86cc552
style: fix linter error
heueristik Mar 15, 2024
4aeb6ea
fix: changed plugin Id generation and added assemblyscript types
jordaniza Mar 15, 2024
86a9b38
fix: wrong manifest names
heueristik Mar 15, 2024
bdcffd2
fix: iplugin schema
jordaniza Mar 15, 2024
eb5a5a5
fix: second schema fix
jordaniza Mar 15, 2024
b90925f
fix: initialize proposalCount with zero
heueristik Mar 25, 2024
3265778
fix: improve manifests
heueristik Mar 25, 2024
47daa8f
fix: adapt deploy script
heueristik Mar 25, 2024
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
12 changes: 12 additions & 0 deletions packages/subgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Aragon OSx Subgraph

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.0.0

### Added

- Copied files from [aragon/osx commit 19f4c4](https://github.com/aragon/osx/commit/19f4c42b5ae86b10b3a9cbbcaca6af504b69b0d2)
6 changes: 3 additions & 3 deletions packages/subgraph/manifest/data/arbitrum.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
}
],
"Plugin": {
"name": "MyPlugin",
"address": null,
"startBlock": 7727664
"name": "multisig.plugin.dao.eth",
"address": "0x7553E6Fb020c5740768cF289e603770AA09b7aE2",
"startBlock": 145462482
}
}
}
18 changes: 0 additions & 18 deletions packages/subgraph/manifest/data/arbitrumGoerli.json

This file was deleted.

6 changes: 3 additions & 3 deletions packages/subgraph/manifest/data/arbitrumSepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
}
],
"Plugin": {
"name": "MyPlugin",
"address": null,
"startBlock": 7727664
"name": "multisig.plugin.dao.eth",
"address": "0x9e7956C8758470dE159481e5DD0d08F8B59217A2",
"startBlock": 2827221
}
}
}
18 changes: 0 additions & 18 deletions packages/subgraph/manifest/data/baseGoerli.json

This file was deleted.

6 changes: 3 additions & 3 deletions packages/subgraph/manifest/data/baseMainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
}
],
"Plugin": {
"name": "MyPlugin",
"address": null,
"startBlock": 7727664
"name": "multisig.plugin.dao.eth",
"address": "0xcDC4b0BC63AEfFf3a7826A19D101406C6322A585",
"startBlock": 2094807
}
}
}
6 changes: 3 additions & 3 deletions packages/subgraph/manifest/data/baseSepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
}
],
"Plugin": {
"name": "MyPlugin",
"address": null,
"startBlock": 7727664
"name": "multisig.plugin.dao.eth",
"address": "0x9e7956C8758470dE159481e5DD0d08F8B59217A2",
"startBlock": 3654521
}
}
}
18 changes: 0 additions & 18 deletions packages/subgraph/manifest/data/goerli.json

This file was deleted.

6 changes: 3 additions & 3 deletions packages/subgraph/manifest/data/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
}
],
"Plugin": {
"name": "MyPlugin",
"address": null,
"startBlock": 7727664
"name": "multisig.plugin.dao.eth",
"address": "0x8c278e37D0817210E18A7958524b7D0a1fAA6F7b",
"startBlock": 16721881
}
}
}
6 changes: 3 additions & 3 deletions packages/subgraph/manifest/data/mumbai.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
}
],
"Plugin": {
"name": "MyPlugin",
"address": null,
"startBlock": 7727664
"name": "multisig.plugin.dao.eth",
"address": "0x2c4690b8be39adAd4F15A69340d5035aC6E53eEF",
"startBlock": 33633475
}
}
}
6 changes: 3 additions & 3 deletions packages/subgraph/manifest/data/polygon.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
}
],
"Plugin": {
"name": "MyPlugin",
"address": null,
"startBlock": 7727664
"name": "multisig.plugin.dao.eth",
"address": "0x5A5035E7E8aeff220540F383a9cf8c35929bcF31",
"startBlock": 40833355
}
}
}
6 changes: 3 additions & 3 deletions packages/subgraph/manifest/data/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
}
],
"Plugin": {
"name": "MyPlugin",
"address": null,
"startBlock": 7727664
"name": "multisig.plugin.aragon-dao.eth",
"address": "0x9e7956C8758470dE159481e5DD0d08F8B59217A2",
"startBlock": 4421536
}
}
}
29 changes: 20 additions & 9 deletions packages/subgraph/manifest/subgraph.placeholder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ dataSources:
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- PluginInstallation
- PluginPreparation
- PluginPermission
- MultisigPlugin
abis:
- name: PluginSetupProcessor
file: ./imported/PluginSetupProcessor.json
Expand All @@ -32,7 +30,7 @@ dataSources:
{{/dataSources.PluginSetupProcessors}}
# templates
templates:
# Plugin (package)
# Plugin
- name: Plugin
kind: ethereum/contract
network: {{network}}
Expand All @@ -43,12 +41,25 @@ templates:
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- Dao
- Action
- MultisigPlugin
- MultisigApprover
- MultisigProposal
- MultisigProposalApprover
abis:
- name: Plugin
file: $PLUGIN_MODULE/contracts/artifacts/src/MyPlugin.sol/MyPlugin.json
file: $PLUGIN_MODULE/contracts/artifacts/src/Multisig.sol/Multisig.json
eventHandlers:
- event: NumberStored(uint256)
handler: handleNumberStored
- event: MembersAdded(address[])
handler: handleMembersAdded
- event: MembersRemoved(address[])
handler: handleMembersRemoved
- event: Approved(indexed uint256,indexed address)
handler: handleApproved
- event: ProposalCreated(indexed uint256,indexed address,uint64,uint64,bytes,(address,uint256,bytes)[],uint256)
handler: handleProposalCreated
- event: ProposalExecuted(indexed uint256)
handler: handleProposalExecuted
- event: MultisigSettingsUpdated(bool,indexed uint16)
handler: handleMultisigSettingsUpdated
file: ./src/plugin/plugin.ts

88 changes: 82 additions & 6 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,86 @@
interface IPlugin {
id: ID! # PluginEntityID
daoAddress: Bytes!
pluginAddress: Bytes!
}

# Types
type DaoPlugin @entity {
"OSX related data"
id: ID! # psp installationId
dao: Bytes!
type MultisigPlugin implements IPlugin @entity {
id: ID! # PluginEntityID
daoAddress: Bytes!
pluginAddress: Bytes!

"Set plugin specific related data below:"
number: BigInt
# Plugin specific data"
proposalCount: BigInt
proposals: [MultisigProposal!]! @derivedFrom(field: "plugin")
members: [MultisigApprover!]! @derivedFrom(field: "plugin")

minApprovals: Int
onlyListed: Boolean
}

interface IProposal {
id: ID! # ProposalEntityId
daoAddress: Bytes!
creator: Bytes!
metadata: String
actions: [Action!]! @derivedFrom(field: "proposal")
allowFailureMap: BigInt!
failureMap: BigInt
executed: Boolean!
createdAt: BigInt!
startDate: BigInt!
endDate: BigInt!
executionTxHash: Bytes
}

type Action @entity {
id: ID! # ActionEntityId
to: Bytes!
value: BigInt!
data: Bytes!
daoAddress: Bytes!
proposal: IProposal!
execResult: Bytes
}

type MultisigApprover @entity {
id: ID! # plugin_address + member_address
address: String # address as string to facilitate filtering by address on the UI
proposals: [MultisigProposalApprover!]! @derivedFrom(field: "approver")
plugin: MultisigPlugin!
}

type MultisigProposalApprover @entity(immutable: true) {
"ApproverProposal for Many-to-Many"
id: ID! # approver + proposal
approver: MultisigApprover!
proposal: MultisigProposal!
createdAt: BigInt!
}

type MultisigProposal implements IProposal @entity {
id: ID! # plugin + proposalId
daoAddress: Bytes!
actions: [Action!]! @derivedFrom(field: "proposal")
allowFailureMap: BigInt!
failureMap: BigInt
plugin: MultisigPlugin!
pluginProposalId: BigInt!
creator: Bytes!
metadata: String
createdAt: BigInt!
startDate: BigInt!
endDate: BigInt!
creationBlockNumber: BigInt!
snapshotBlock: BigInt!
minApprovals: Int!
approvals: Int
approvalReached: Boolean!
isSignaling: Boolean!
executed: Boolean!
executionDate: BigInt
executionBlockNumber: BigInt
executionTxHash: Bytes
approvers: [MultisigProposalApprover!]! @derivedFrom(field: "proposal")
}
35 changes: 13 additions & 22 deletions packages/subgraph/src/osx/pluginSetupProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {InstallationPrepared} from '../../generated/PluginSetupProcessor/PluginSetupProcessor';
import {DaoPlugin} from '../../generated/schema';
import {MultisigPlugin} from '../../generated/schema';
import {Plugin as PluginTemplate} from '../../generated/templates';
import {PLUGIN_REPO_ADDRESS} from '../../imported/repo-address';
import {generatePluginInstallationEntityId} from '@aragon/osx-commons-subgraph';
import {Address, DataSourceContext, log} from '@graphprotocol/graph-ts';
import {generatePluginEntityId} from '@aragon/osx-commons-subgraph';
import {Address, DataSourceContext} from '@graphprotocol/graph-ts';

export function handleInstallationPrepared(event: InstallationPrepared): void {
const pluginRepo = event.params.pluginSetupRepo;
Expand All @@ -16,35 +16,26 @@ export function handleInstallationPrepared(event: InstallationPrepared): void {
return;
}

const dao = event.params.dao;
const plugin = event.params.plugin;

// Generate a unique ID for the plugin installation.
const installationId = generatePluginInstallationEntityId(dao, plugin);
// Log an error and exit if unable to generate the installation ID.
if (!installationId) {
log.error('Failed to generate installationId', [
dao.toHexString(),
plugin.toHexString(),
]);
return;
}
const daoAddress = event.params.dao;
const pluginAddress = event.params.plugin;
const pluginId = generatePluginEntityId(pluginAddress);

// Load or create a new entry for the this plugin using the generated installation ID.
let pluginEntity = DaoPlugin.load(installationId!);
let pluginEntity = MultisigPlugin.load(pluginId);
if (!pluginEntity) {
pluginEntity = new DaoPlugin(installationId!);
pluginEntity = new MultisigPlugin(pluginId);
}

// Set the DAO and plugin address for the plugin entity.
pluginEntity.dao = dao;
pluginEntity.pluginAddress = plugin;
pluginEntity.daoAddress = daoAddress;
pluginEntity.pluginAddress = pluginAddress;

// Initialize a context for the plugin data source to enable indexing from the moment of preparation.
const context = new DataSourceContext();
// Include the DAO address in the context for future reference.
context.setString('daoAddress', dao.toHexString());
context.setString('daoAddress', daoAddress.toHexString());
// Deploy a template for the plugin to facilitate individual contract indexing.
PluginTemplate.createWithContext(plugin, context);
PluginTemplate.createWithContext(pluginAddress, context);

pluginEntity.save();
}
19 changes: 19 additions & 0 deletions packages/subgraph/src/plugin/id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {generateEntityIdFromAddress} from '@aragon/osx-commons-subgraph';
import {Address} from '@graphprotocol/graph-ts';

export function generateMemberEntityId(
pluginAddress: Address,
memberAddress: Address
): string {
return [
generateEntityIdFromAddress(pluginAddress),
generateEntityIdFromAddress(memberAddress),
].join('_');
}

export function generateVoterEntityId(
memberEntityId: string,
proposalId: string
): string {
return [memberEntityId, proposalId].join('_');
}
Loading
Loading