Skip to content

Commit

Permalink
Fix #496 (#497)
Browse files Browse the repository at this point in the history
* Fix #496

* SchemRegistrar test

* bump version

* Bump version to 39

* version fix
  • Loading branch information
ben-kaufman authored Mar 15, 2020
1 parent e275cfc commit dbcbd3c
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 45 deletions.
91 changes: 59 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@daostack/subgraph",
"version": "0.0.38-3",
"version": "0.0.39-0",
"author": "DAOstack (https://www.daostack.io)",
"license": "GPL-3.0",
"description": "A caching layer for daostack using The Graph",
Expand Down
14 changes: 8 additions & 6 deletions src/mappings/Controller/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function insertScheme(
controllerScheme.numberOfPreBoostedProposals = BigInt.fromI32(0);
controllerScheme.numberOfBoostedProposals = BigInt.fromI32(0);
controllerScheme.numberOfExpiredInQueueProposals = BigInt.fromI32(0);
controllerScheme.isRegistered = true;
}
controllerScheme.dao = avatarAddress.toHex();
controllerScheme.paramsHash = paramsHash;
Expand All @@ -91,11 +92,12 @@ function insertScheme(
controllerScheme.save();
}

function deleteScheme(avatarAddress: Address, scheme: Address): void {
store.remove(
'ControllerScheme',
crypto.keccak256(concat(avatarAddress, scheme)).toHex(),
);
function unregisterScheme(avatarAddress: Address, scheme: Address): void {
let controllerScheme = ControllerScheme.load(crypto.keccak256(concat(avatarAddress, scheme)).toHex());
if (controllerScheme != null) {
controllerScheme.isRegistered = false;
controllerScheme.save();
}
}

function insertOrganization(
Expand Down Expand Up @@ -215,7 +217,7 @@ export function handleRegisterScheme(event: RegisterScheme): void {
export function handleUnregisterScheme(event: UnregisterScheme): void {
let controller = Controller.bind(event.address);
let avatar = controller.avatar();
deleteScheme(avatar, event.params._scheme);
unregisterScheme(avatar, event.params._scheme);

let ent = new ControllerUnregisterScheme(eventId(event));
ent.txHash = event.transaction.hash;
Expand Down
1 change: 1 addition & 0 deletions src/mappings/Controller/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type ControllerScheme @entity {
numberOfPreBoostedProposals: BigInt!
numberOfBoostedProposals: BigInt!
numberOfExpiredInQueueProposals: BigInt!
isRegistered: Boolean!
}

type ControllerGlobalConstraint @entity {
Expand Down
Loading

0 comments on commit dbcbd3c

Please sign in to comment.