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

Improve balance tracking #584

Merged
merged 5 commits into from
Aug 2, 2020
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
39 changes: 39 additions & 0 deletions daos/kovan/dummydao.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "Parsimonious Designer",
"Avatar": "0x46e342972535e15776Cf31f9407975f3E8A4078c",
"DAOToken": "0x1f1DFd38F0cc6C1c7d2516d9aA9f99a4192C7249",
"Reputation": "0x3AFEebAb0eA2D0A31BB882d3C1a6B6f0C8dE4859",
"Controller": "0x9Ef023Ca8D27076b6b3823aA1108E0f03bfF9800",
"Schemes": [
{
"name": "GenericScheme",
"alias": "GenericSchemeAlias",
"address": "0x38d2AD56A9F589c2d6f0a330291F79BfF9B13C6d",
"arcVersion": "0.0.1-rc.39"
},
{
"name": "ContributionRewardExt",
"alias": "ContributionRewardExt",
"address": "0x68c29524E583380aF7896f7e63463740225Ac026",
"arcVersion": "0.0.1-rc.39"
}
],
"StandAloneContracts": [
{
"name": "Wallet",
"address": "0x9AD84A087C55F61e116df9A8c474703E3D58c536",
"arcVersion": "0.0.1-rc.39"
},
{
"name": "ContributionRewardExt",
"address": "0x68c29524E583380aF7896f7e63463740225Ac026",
"arcVersion": "0.0.1-rc.39"
},
{
"name": "Competition",
"address": "0x4b7284ac4714e27F9098c57F54306ed74454D05F",
"arcVersion": "0.0.1-rc.39"
}
],
"arcVersion": "0.0.1-rc.39"
}
2 changes: 1 addition & 1 deletion 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.39-6",
"version": "0.0.39-7",
"author": "DAOstack (https://www.daostack.io)",
"license": "GPL-3.0",
"description": "A caching layer for daostack using The Graph",
Expand Down
1 change: 1 addition & 0 deletions src/domain/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function insertNewDAO(
let avatar = Avatar.bind(avatarAddress);
let dao = getDAO(avatarAddress.toHex());
dao.name = avatar.orgName().toString();
dao.avatarContract = avatarAddress.toHex();
dao.nativeToken = nativeTokenAddress.toHex();
dao.nativeReputation = nativeReputationAddress.toHex();
dao.reputationHoldersCount = BigInt.fromI32(0);
Expand Down
1 change: 1 addition & 0 deletions src/domain/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum Outcome {
type DAO @entity {
id: ID!
name: String!
avatarContract: AvatarContract!
nativeToken: Token!
nativeReputation: Rep!
proposals: [Proposal!] @derivedFrom(field: "dao")
Expand Down
2 changes: 2 additions & 0 deletions src/mappings/Avatar/datasource.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
entities:
- AvatarContract
eventHandlers:
- event: GenericCall(indexed address,bytes,uint256,bool)
handler: handleGenericCall
- event: SendEther(uint256,indexed address)
handler: handleSendEth
- event: ReceiveEther(indexed address,uint256)
Expand Down
7 changes: 7 additions & 0 deletions src/mappings/Avatar/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Address, BigInt, store } from '@graphprotocol/graph-ts';
import { Avatar, OwnershipTransferred, ReceiveEther, SendEther } from '../../types/Avatar/Avatar';

// Import entity types generated from the GraphQL schema
import { GenericCall } from '../../types/Controller/Avatar';
import { AvatarContract } from '../../types/schema';

function handleAvatarBalance(
Expand All @@ -27,6 +28,12 @@ function handleAvatarBalance(
store.set('AvatarContract', avatar.id, avatar);
}

export function handleGenericCall(event: GenericCall): void {
if (event.params._success && BigInt.fromI32(0).lt(event.params._value)) {
handleAvatarBalance(event.address, event.params._value, false);
}
}

export function handleSendEth(event: SendEther): void {
handleAvatarBalance(event.address, event.params._amountInWei, false);
}
Expand Down