Skip to content

Commit

Permalink
Merge pull request #11 from aragon/OS-1162/update-action-entity-and-p…
Browse files Browse the repository at this point in the history
…roposal

feat: update action entity and proposal
  • Loading branch information
clauBv23 committed Apr 3, 2024
2 parents 1839ab5 + 66bfe39 commit f0fb7fd
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@aragon/osx-commons-subgraph": "^0.0.4"
"@aragon/osx-commons-subgraph": "^0.0.5"
}
}
15 changes: 11 additions & 4 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type AdminProposal implements IProposal @entity {
metadata: String
actions: [Action!]! @derivedFrom(field: "proposal")
allowFailureMap: BigInt!
failureMap: BigInt
executed: Boolean!
createdAt: BigInt!
startDate: BigInt!
Expand All @@ -44,14 +43,23 @@ type AdminProposal implements IProposal @entity {
executionTxHash: Bytes
}

type Action @entity {
interface IAction {
id: ID! # ActionEntityId
to: Bytes!
value: BigInt!
data: Bytes!
daoAddress: Bytes!
}

type Action implements IAction @entity(immutable: true) {
id: ID! # ActionEntityId
to: Bytes!
value: BigInt!
data: Bytes!
daoAddress: Bytes!

# proposal data
proposal: IProposal!
execResult: Bytes
}

interface IProposal {
Expand All @@ -61,7 +69,6 @@ interface IProposal {
metadata: String
actions: [Action!]! @derivedFrom(field: "proposal")
allowFailureMap: BigInt!
failureMap: BigInt
executed: Boolean!
createdAt: BigInt!
startDate: BigInt!
Expand Down
7 changes: 6 additions & 1 deletion packages/subgraph/src/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ export function _handleProposalCreated(
for (let index = 0; index < actions.length; index++) {
const action = actions[index];

const actionEntityId = generateActionEntityId(proposalEntityId, index);
const actionEntityId = generateActionEntityId(
pluginAddress,
Address.fromString(daoAddress),
pluginProposalId.toString(),
index
);
const actionEntity = new Action(actionEntityId);
actionEntity.to = action.to;
actionEntity.value = action.value;
Expand Down
41 changes: 25 additions & 16 deletions packages/subgraph/tests/plugin/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,27 @@ describe('Plugin', () => {
ALLOW_FAILURE_MAP
);

// check actions
// check action
assert.entityCount('Action', 1);
const actionEntityId = generateActionEntityId(proposalEntityId, 0);
const actionEntityId = generateActionEntityId(
pluginAddress,
Address.fromString(DAO_ADDRESS),
pluginProposalId.toString(),
0
);
const actionEntity = Action.load(actionEntityId);
if (actionEntity) {
assert.fieldEquals('Action', actionEntityId, 'id', actionEntityId);
assert.fieldEquals('Action', actionEntityId, 'to', ADDRESS_TWO);
assert.fieldEquals('Action', actionEntityId, 'value', actionValue);
assert.fieldEquals('Action', actionEntityId, 'data', actionData);
assert.fieldEquals('Action', actionEntityId, 'daoAddress', DAO_ADDRESS);
assert.fieldEquals(
'Action',
actionEntityId,
'proposal',
proposalEntityId
);
}
assert.entityCount('Action', 1);
assert.fieldEquals('Action', actionEntityId, 'id', actionEntityId);
assert.fieldEquals('Action', actionEntityId, 'to', ADDRESS_TWO);
assert.fieldEquals('Action', actionEntityId, 'value', actionValue);
assert.fieldEquals('Action', actionEntityId, 'data', actionData);
assert.fieldEquals('Action', actionEntityId, 'daoAddress', DAO_ADDRESS);
assert.fieldEquals(
'Action',
actionEntityId,
'proposal',
proposalEntityId
);
});
});

Expand All @@ -194,7 +198,12 @@ describe('Plugin', () => {

createAdminProposalState(proposalEntityId, administratorAddress);

const actionEntityId = generateActionEntityId(proposalEntityId, 0);
const actionEntityId = generateActionEntityId(
pluginAddress,
Address.fromString(DAO_ADDRESS),
pluginProposalId.toString(),
0
);
let action = new Action(actionEntityId);
action.to = Address.fromString(ADDRESS_TWO);
action.value = BigInt.fromString(actionValue);
Expand Down
8 changes: 4 additions & 4 deletions packages/subgraph/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
dependencies:
tslib "^2.6.2"

"@aragon/osx-commons-subgraph@^0.0.4":
version "0.0.4"
resolved "https://registry.yarnpkg.com/@aragon/osx-commons-subgraph/-/osx-commons-subgraph-0.0.4.tgz#2aa52f3089d21189c9152d2f3d14c0d7c66d129f"
integrity sha512-cqhusJ3HNvMx+t9lXfN+Hy/5ipefNs1Tdxe+y0GvD4qgBMVU4tCbsxOpB9U2JEJNBCzFQj4E/872FFLpIErB4w==
"@aragon/osx-commons-subgraph@^0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@aragon/osx-commons-subgraph/-/osx-commons-subgraph-0.0.5.tgz#7e0c0f854e4ca52de1d937595c9bb6ef0370f840"
integrity sha512-M5edVTYyHbkcDLr2H8ySCbOpLA+5pUdN7tCYCif0pDP99Wb+/njgO23G2B2FjB4Q3hB0fCkLkQwNp9QplJjqGA==
dependencies:
"@graphprotocol/graph-ts" "0.31.0"

Expand Down

0 comments on commit f0fb7fd

Please sign in to comment.