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 18 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)
19 changes: 14 additions & 5 deletions packages/subgraph/manifest/subgraph.placeholder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dataSources:
{{/dataSources.PluginSetupProcessors}}
# templates
templates:
# Plugin (package)
# Plugin
- name: Plugin
kind: ethereum/contract
network: {{network}}
Expand All @@ -46,9 +46,18 @@ templates:
- Dao
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

86 changes: 81 additions & 5 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,86 @@
interface IPlugin {
id: ID! # PluginInstallationEntityId
dao: Dao!
pluginAddress: Bytes!
}

# Types
type DaoPlugin @entity {
"OSX related data"
id: ID! # psp installationId
type MultisigPlugin implements IPlugin @entity {
id: ID! # PluginInstallationEntityId
dao: 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
dao: 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!
dao: 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
dao: 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")
}
26 changes: 8 additions & 18 deletions packages/subgraph/scripts/import-plugin-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,18 @@ import path from 'path';
const rootDir = path.join(__dirname, '../../../'); // Adjust the path as necessary
dotenv.config({path: path.join(rootDir, '.env')});

// Extract Repo address from the production-network-deployments.json
function extractAndWriteAddressToTS(jsonPath: string): void {
// Read the production-network-deployments.json file
const aragonDeploymentsInfo = JSON.parse(fs.readFileSync(jsonPath, 'utf8'));

// Get the network from environment variables
// Temporary hotfix until task OS-1028 is finished.
function writeAddressToTS(): void {
// TODO Refactor this after OS-1028.
const network = process.env.SUBGRAPH_NETWORK_NAME;

// Check if the network is defined in aragonDeploymentsInfo
if (!network || !aragonDeploymentsInfo[network]) {
throw new Error(
`Network '${network}' not found in production-network-deployments.json`
);
if (network !== 'sepolia') {
throw 'The plugin repo address has been hardcoded only for sepolia for now until.';
}
const sepoliaAddr = '0x9e7956C8758470dE159481e5DD0d08F8B59217A2';

// Start the Map creation code with the specific network address
const tsContent: string[] = [
`export const PLUGIN_REPO_ADDRESS = '${aragonDeploymentsInfo[network].address}';`,
`export const PLUGIN_REPO_ADDRESS = '${sepoliaAddr}';`,
];

const outputDir = path.join(__dirname, '../imported');
Expand All @@ -42,8 +36,4 @@ function extractAndWriteAddressToTS(jsonPath: string): void {
);
}

const aragonDeploymentsInfoPath = path.join(
rootDir,
'production-network-deployments.json'
);
extractAndWriteAddressToTS(aragonDeploymentsInfoPath);
writeAddressToTS();
6 changes: 3 additions & 3 deletions packages/subgraph/src/osx/pluginSetupProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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';
Expand Down Expand Up @@ -30,9 +30,9 @@ export function handleInstallationPrepared(event: InstallationPrepared): void {
return;
}
// Load or create a new entry for the this plugin using the generated installation ID.
let pluginEntity = DaoPlugin.load(installationId!);
let pluginEntity = MultisigPlugin.load(installationId!);
if (!pluginEntity) {
pluginEntity = new DaoPlugin(installationId!);
pluginEntity = new MultisigPlugin(installationId!);
}

// Set the DAO and plugin address for the plugin entity.
Expand Down
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