Skip to content

Commit

Permalink
added NFTs to Steward fetching in front end
Browse files Browse the repository at this point in the history
  • Loading branch information
krisbitney committed Feb 1, 2024
1 parent 6cef11a commit 4192db1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
13 changes: 7 additions & 6 deletions packages/app/src/models/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export interface Steward {
address: string;
actions: number;
totalEarned: string;
// nfts: ProvableNFT[] | string[]; --> This can be fetched, but we are not using it in the MVP
collectives: StewardCollective[];
nfts: ProvableNFT[];
}

export interface DonorCollective {
Expand Down Expand Up @@ -55,11 +55,12 @@ export interface IpfsCollective {
images?: string[];
}

// export type ProvableNFT = {
// owner: string;
// hash: string;
// collective: Collective | string;
// };
export type ProvableNFT = {
id: string;
owner: string;
hash: string;
collective: string;
};

export interface Transaction {
hash: string;
Expand Down
12 changes: 12 additions & 0 deletions packages/app/src/models/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import {
DonorCollective,
ClaimTx,
SupportTx,
ProvableNFT,
} from './models';
import {
SubgraphClaim,
SubgraphCollective,
SubgraphDonor,
SubgraphDonorCollective,
SubgraphIpfsCollective,
SubgraphProvableNFT,
SubgraphSteward,
SubgraphStewardCollective,
SubgraphSupportEvent,
Expand All @@ -36,6 +38,7 @@ export function subgraphStewardToModel(subgraphSteward: SubgraphSteward): Stewar
actions: subgraphSteward.actions,
totalEarned: subgraphSteward.totalEarned,
collectives: subgraphSteward.collectives.map(subgraphStewardCollectiveToModel),
nfts: subgraphSteward.nfts.map(subgraphProvableNftToModel),
};
}

Expand Down Expand Up @@ -104,6 +107,15 @@ export function subgraphClaimToModel(subgraphClaim: SubgraphClaim): ClaimTx {
};
}

export function subgraphProvableNftToModel(nft: SubgraphProvableNFT): ProvableNFT {
return {
id: nft.id,
owner: nft.owner,
hash: nft.hash,
collective: nft.collective.id,
};
}

export function subgraphSupportEventToModel(subgraphSupportEvent: SubgraphSupportEvent): SupportTx {
return {
hash: subgraphSupportEvent.id,
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/subgraph/subgraphModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export type SubgraphSteward = {
id: string;
actions: number;
totalEarned: string;
nfts?: SubgraphProvableNFT[] | { id: string }[];
collectives: SubgraphStewardCollective[];
nfts: SubgraphProvableNFT[];
};

export type SubgraphStewardCollective = {
Expand Down Expand Up @@ -83,8 +83,8 @@ export type SubgraphProvableNFT = {
id: string;
owner: string;
hash: string;
steward: SubgraphSteward[] | { id: string }[];
collective: SubgraphCollective | string;
stewards?: SubgraphSteward[] | { id: string }[];
collective: SubgraphCollective | { id: string };
};

export type SubgraphClaimEvent = {
Expand Down
8 changes: 8 additions & 0 deletions packages/app/src/subgraph/useSubgraphSteward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const steward = gql`
actions
totalEarned
}
nfts {
id
owner
hash
collective {
id
}
}
}
}
`;
Expand Down

0 comments on commit 4192db1

Please sign in to comment.