-
Notifications
You must be signed in to change notification settings - Fork 5
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
Subgraph update #60
Subgraph update #60
Changes from all commits
ab3b969
60a8e69
c2d2cd0
3fbead3
11aeeff
eedc565
9eae142
60af1fc
705543b
66c9df1
bcf8952
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,72 @@ | ||
# TODO | ||
# get total donated from correct field | ||
# handling of generated pools from factory contract | ||
# per collective donor/steward record | ||
# update nft with stewards on claim | ||
type Donor @entity { | ||
id: String! # The address of the donor | ||
joined: BigInt! | ||
totalDonated: BigInt! | ||
collectives: [DonorCollective!]! | ||
} | ||
|
||
"""Represents the relationship between a Donor and a Collective""" | ||
type DonorCollective @entity { | ||
id: String! # donorAddress + " " + collectiveAddress | ||
donor: Donor! @derivedFrom(field: "collectives") | ||
collective: Collective! @derivedFrom(field: "donors") | ||
contribution: BigInt! # This is the total contribution of the donor to the collective | ||
flowRate: BigInt! | ||
} | ||
|
||
type Steward @entity { | ||
"{ user address} " | ||
"""{ user address}""" | ||
id: String! | ||
" Number of actions performed " | ||
"""Number of actions performed""" | ||
actions: Int! | ||
totalEarned: BigInt! | ||
" NFT's minted to steward" | ||
nfts: [ProvableNFT!]! @derivedFrom(field: "steward") | ||
" Collectives the steward is apart of " | ||
collectives: [Collective!]! @derivedFrom(field: "stewards") | ||
} | ||
|
||
type Donor @entity { | ||
id: String! # This will be the contract address from which the transaction originated | ||
supporter: Bytes! # Address of the supporter | ||
joined: Int! | ||
totalDonated: BigInt! | ||
previousContribution: BigInt | ||
contribution: BigInt | ||
previousFlowRate: BigInt | ||
flowRate: BigInt | ||
isFlowUpdate: Boolean | ||
collectives: [Collective!]! | ||
} | ||
|
||
type CollectiveDonor @entity { | ||
id: String! #collective_donor | ||
totalDonated: BigInt! | ||
flowRate: BigInt | ||
"""NFT's minted to steward""" | ||
nfts: [ProvableNFT!]! | ||
"""Collectives the steward is apart of""" | ||
collectives: [StewardCollective!]! | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as on DonorCollective There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved in #63 |
||
|
||
type CollectiveSteward @entity { | ||
id: String! #collective_donor | ||
"""Represents the relationship between a Steward and a Collective""" | ||
type StewardCollective @entity { | ||
id: String! # stewardAddress + " " + collectiveAddress | ||
steward: Steward! @derivedFrom(field: "collectives") | ||
collective: Collective! @derivedFrom(field: "stewards") | ||
actions: Int! | ||
Comment on lines
+32
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as on donorcollective There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved in #63 |
||
totalEarned: BigInt! | ||
nft: [ProvableNFT!]! | ||
} | ||
|
||
type Collective @entity { | ||
"This is the address source" | ||
id: String! | ||
ipfs: String | ||
nftType: BigInt | ||
manager: Bytes | ||
contributions: BigInt! | ||
membersValidator: Bytes | ||
uniquenessValidator: String | ||
donors: [Donor!] @derivedFrom(field: "collectives") | ||
stewards: [Steward!]! | ||
rewardToken: String | ||
projectId: String | ||
isVerified: Boolean | ||
limits: SafetyLimits | ||
nft: ProvableNFT | ||
poolAddress: String | ||
timestamp: Int | ||
id: String! # pool address | ||
ipfs: String! | ||
settings: PoolSettings! | ||
limits: SafetyLimits! | ||
donors: [DonorCollective!]! | ||
stewards: [StewardCollective!]! | ||
projectId: String! | ||
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment on collectivedonor/steward probably should have derivedfrom field There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved in #63 |
||
isVerified: Boolean! | ||
poolFactory: String! # pool factory (event source) | ||
timestamp: BigInt! | ||
paymentsMade: Int! | ||
totalDonations: BigInt! | ||
totalRewards: BigInt! | ||
} | ||
|
||
type IpfsCollective @entity { | ||
id: String! # collective address | ||
name: String! | ||
description: String! | ||
email: String | ||
website: String | ||
twitter: String | ||
instagram: String | ||
threads: String | ||
headerImage: String | ||
logo: String | ||
images: [String!] | ||
} | ||
|
||
type PoolSettings @entity { | ||
id: String! | ||
id: String! # collective address | ||
nftType: BigInt! | ||
manager: Bytes! | ||
membersValidator: Bytes! | ||
|
@@ -72,34 +75,33 @@ type PoolSettings @entity { | |
} | ||
|
||
type SafetyLimits @entity { | ||
id: String! | ||
maxTotalPerMonth: BigInt | ||
maxMemberPerMonth: BigInt | ||
maxMemberPerDay: BigInt | ||
id: String! # collective address | ||
maxTotalPerMonth: BigInt! | ||
maxMemberPerMonth: BigInt! | ||
maxMemberPerDay: BigInt! | ||
} | ||
|
||
type ProvableNFT @entity { | ||
id: ID! | ||
owner: String! | ||
hash: String! | ||
steward: [Steward!]! | ||
steward: [Steward!]! @derivedFrom(field: "nfts") | ||
collective: Collective! | ||
} | ||
|
||
type EventData @entity { | ||
id: String! | ||
id: String! # event uri | ||
eventType: Int! | ||
timestamp: BigInt! | ||
quantity: BigInt! | ||
uri: String! | ||
rewardPerContributor: BigInt! | ||
contributors: [Steward!]! | ||
nft: ProvableNFT! | ||
claim: Claim | ||
claim: Claim! @derivedFrom(field: "events") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as in CollectiveDonor, probably should be the other way around There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved in #63 |
||
|
||
type Claim @entity { | ||
id: String! | ||
totalRewards: BigInt! | ||
events: [EventData!] @derivedFrom(field: "claim") | ||
events: [EventData!]! | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import { ProvableNftMinted } from '../../generated/ProvableNFT/ProvableNFT'; | ||
import { ProvableNFT, Steward } from '../../generated/schema'; | ||
import { ProvableNFT } from '../../generated/schema'; | ||
|
||
// Note that ProvableNFT.collective is set by steward reward event | ||
export function handleNftMint(event: ProvableNftMinted): void { | ||
const tokenID = event.params.tokenId.toString(); | ||
const to = event.params.to.toHexString(); | ||
const nftHash = event.params.nftDataHash.toHexString(); | ||
|
||
let provableNFT = ProvableNFT.load(tokenID); | ||
|
||
if (provableNFT === null) { | ||
provableNFT = new ProvableNFT(tokenID); | ||
provableNFT.id = tokenID; | ||
provableNFT.owner = to; // Fixed this line | ||
provableNFT.hash = nftHash; | ||
provableNFT.save(); | ||
} | ||
provableNFT.owner = to; | ||
provableNFT.hash = nftHash; | ||
provableNFT.save(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this will work. it has to be the other way around.
here it should just be donor: Donor! and collective: Collective!
in Collective and Donor there should be Donors: [DonorCollective!] @derivedFrom(field:"collective")
in Donor Collectives: [DonorCollective!] @derivedFrom(field:"donor")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware that the
derivedFrom
relationship only works one way. Thanks!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved in #63
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its not one way, but rather I dont think it can be derived from an array, how would it know which one?