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

OS-265 : builder testing #327

Merged
merged 21 commits into from
Apr 12, 2023
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
1 change: 1 addition & 0 deletions packages/subgraph/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ artifacts
deploy-output.txt
dev-data
tests/.latest.json
tests/helpers/extended-schema.ts
2 changes: 2 additions & 0 deletions packages/subgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added `method-classes`.
- Added `schema-extender.ts`.
- Added `installations` to `IPlugin`.
- Added `PluginRelease`.
- Added `metadata` to `PluginVersion`.
Expand Down
8 changes: 6 additions & 2 deletions packages/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
"lint": "eslint . --ext .ts",
"build:contracts": "cd ../contracts && yarn build",
"manifest": "scripts/build-manifest.sh",
"build": "scripts/build-subgraph.sh",
"extend:schema": "yarn ts-node tests/schema-extender.ts",
"build": "scripts/build-subgraph.sh && yarn extend:schema",
"deploy": "scripts/deploy-subgraph.sh",
"create:local": "graph create aragon/aragon-core-rinkeby --node http://localhost:8020",
"deploy:local": "LOCAL=true scripts/deploy-subgraph.sh",
"start:dev": "docker-compose -f docker/docker-compose.yml up -d && sleep 15 && yarn create:local && yarn deploy:local",
"stop:dev": "docker-compose -f docker/docker-compose.yml down",
"test:fast": "graph test",
"test": "graph test -r",
"coverage": "graph test -c",
"formatting:check": "prettier '**/*.{json,ts,js}' -c",
Expand All @@ -26,6 +28,8 @@
"@typescript-eslint/parser": "^5.18.0",
"eslint": "^8.12.0",
"matchstick-as": "^0.5.1",
"mustache": "^4.2.0"
"mustache": "^4.2.0",
"ts-morph": "^17.0.1",
"typescript": "^4.9.5"
}
}
4 changes: 2 additions & 2 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ type TokenVotingPlugin implements IPlugin @entity {
minParticipation: BigInt
minDuration: BigInt
minProposerVotingPower: BigInt
proposalCount: BigInt
proposalCount: BigInt!
token: Token
members: [TokenVotingMember!]! @derivedFrom(field: "plugin")
}
Expand All @@ -362,7 +362,7 @@ type TokenVotingMember @entity {

type TokenVotingVoter @entity {
id: ID! # address
address: String # address as string to facilitate filtering by address on the UI
address: String! # address as string to facilitate filtering by address on the UI
proposals: [TokenVotingVote!]! @derivedFrom(field: "voter")
plugin: TokenVotingPlugin!
lastUpdated: BigInt
Expand Down
4 changes: 4 additions & 0 deletions packages/subgraph/src/plugin/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ethereum,
crypto,
ByteArray,
BigInt
} from '@graphprotocol/graph-ts';

import {TokenVoting as TokenVotingContract} from '../../generated/templates/TokenVoting/TokenVoting';
Expand Down Expand Up @@ -44,6 +45,7 @@ function createTokenVotingPlugin(plugin: Address, daoId: string): void {
packageEntity = new TokenVotingPlugin(pluginId);
packageEntity.pluginAddress = plugin;
packageEntity.dao = daoId;
packageEntity.proposalCount = BigInt.zero();
let contract = TokenVotingContract.bind(plugin);
let supportThreshold = contract.try_supportThreshold();
let minParticipation = contract.try_minParticipation();
Expand Down Expand Up @@ -80,6 +82,7 @@ function createAddresslistVotingPlugin(plugin: Address, daoId: string): void {
packageEntity = new AddresslistVotingPlugin(plugin.toHexString());
packageEntity.pluginAddress = plugin;
packageEntity.dao = daoId;
packageEntity.proposalCount = BigInt.zero();

let contract = AddresslistVotingContract.bind(plugin);

Expand Down Expand Up @@ -136,6 +139,7 @@ function createMultisigPlugin(plugin: Address, daoId: string): void {
packageEntity.onlyListed = false;
packageEntity.pluginAddress = plugin;
packageEntity.dao = daoId;
packageEntity.proposalCount = BigInt.zero();

// Create template
let context = new DataSourceContext();
Expand Down
11 changes: 11 additions & 0 deletions packages/subgraph/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@ export const VOTER_OPTIONS = new Map<number, string>()
.set(2, 'Yes')
.set(3, 'No');

export const VOTE_OPTIONS = new Map<string, string>()
.set('None', '0')
.set('Abstain', '1')
.set('Yes', '2')
.set('No', '3');

export const VOTING_MODES = new Map<number, string>()
.set(0, 'Standard')
.set(1, 'EarlyExecution')
.set(2, 'VoteReplacement');

export const VOTING_MODE_INDEXES = new Map<string, string>()
.set('Standard', '0')
.set('EarlyExecution', '1')
.set('VoteReplacement', '2');

export const TOKEN_VOTING_INTERFACE = '0x50eb001e';
export const ADDRESSLIST_VOTING_INTERFACE = '0x5f21eb8b';
export const ADMIN_INTERFACE = '0xa5793356';
Expand Down
2 changes: 1 addition & 1 deletion packages/subgraph/tests/admin/adminMembers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
test,
describe,
beforeEach,
afterEach,
afterEach
} from 'matchstick-as/assembly/index';

import {ADDRESS_ONE, ADDRESS_TWO, DAO_ADDRESS} from '../constants';
Expand Down
19 changes: 10 additions & 9 deletions packages/subgraph/tests/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ export const TWO = '2';
export const THREE = '3';

export const PROPOSAL_ID = ZERO;
export const PROPOSAL_ENTITY_ID = getProposalId(
Address.fromString(CONTRACT_ADDRESS),
BigInt.fromString(PROPOSAL_ID)
);

export const PLUGIN_ENTITY_ID = Address.fromString(
CONTRACT_ADDRESS
).toHexString();

export const STRING_DATA = 'Some String Data ...';

Expand Down Expand Up @@ -54,7 +46,7 @@ export const ALLOW_FAILURE_MAP = '1';

export const MIN_VOTING_POWER = TWO;
export const TOTAL_VOTING_POWER = THREE;
export const CREATED_AT = '1644850000';
export const CREATED_AT = ONE;

export const ZERO_BYTES32 =
'0x0000000000000000000000000000000000000000000000000000000000000000';
Expand All @@ -72,3 +64,12 @@ export const PLUGIN_SETUP_ID =
'0xfb3fd2c4cd4e19944dd3f8437e67476240cd9e3efb2294ebd10c59c8f1d6817c';
export const APPLIED_PLUGIN_SETUP_ID =
'0x00000000cd4e19944dd3f8437e67476240cd9e3efb2294ebd10c59c8f1d6817c';

export const PROPOSAL_ENTITY_ID = getProposalId(
Address.fromString(CONTRACT_ADDRESS),
BigInt.fromString(PROPOSAL_ID)
);

export const PLUGIN_ENTITY_ID = Address.fromString(
CONTRACT_ADDRESS
).toHexString();
Loading