mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
Add Remote Schema for DAOHaus / Moloch Dao memberships
Uses the ethereum address of a specific player to fetch the Moloch DAOs that player is a member of
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
interface IConfig {
|
||||
port: number;
|
||||
graphqlURL: string;
|
||||
daoHausGraphqlURL: string;
|
||||
adminKey: string;
|
||||
ipfsEndpoint: string;
|
||||
}
|
||||
@@ -23,6 +24,10 @@ export const CONFIG: IConfig = {
|
||||
process.env.GRAPHQL_URL,
|
||||
'http://localhost:8080/v1/graphql',
|
||||
),
|
||||
daoHausGraphqlURL: parseEnv(
|
||||
process.env.DAOHAUS_GRAPHQL_URL,
|
||||
'https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus',
|
||||
),
|
||||
adminKey: parseEnv(
|
||||
process.env.HASURA_GRAPHQL_ADMIN_SECRET,
|
||||
'metagame_secret',
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
Player_Rank_Enum,
|
||||
Player_Update_Column,
|
||||
Scalars,
|
||||
} from '../../../lib/autogen/sdk';
|
||||
} from '../../../lib/autogen/hasura-sdk';
|
||||
import { client } from '../../../lib/hasuraClient';
|
||||
import { AddressBookEntry, SCAccountsData } from './types';
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { gql } from 'graphql-request/dist';
|
||||
|
||||
export const GetDaoHausMemberships = gql`
|
||||
query GetDaoHausMemberships($memberAddress: Bytes!) {
|
||||
members(
|
||||
where: { memberAddress: $memberAddress, didRagequit: false, exists: true }
|
||||
) {
|
||||
id
|
||||
shares
|
||||
molochAddress
|
||||
createdAt
|
||||
memberAddress
|
||||
loot
|
||||
exists
|
||||
kicked
|
||||
moloch {
|
||||
id
|
||||
title
|
||||
version
|
||||
summoner
|
||||
totalShares
|
||||
totalLoot
|
||||
}
|
||||
delegateKey
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,12 @@
|
||||
import { daoHausClient } from '../../../../lib/daoHausClient';
|
||||
import { QueryResolvers } from '../../autogen/types';
|
||||
|
||||
export const getDaoHausMemberships: QueryResolvers['getDaoHausMemberships'] = async (
|
||||
_,
|
||||
{ memberAddress },
|
||||
) => {
|
||||
if (!memberAddress) return [];
|
||||
const res = await daoHausClient.GetDaoHausMemberships({ memberAddress });
|
||||
|
||||
return res.members;
|
||||
};
|
||||
@@ -1,11 +1,13 @@
|
||||
import { makeExecutableSchema } from 'graphql-tools';
|
||||
|
||||
import { getDaoHausMemberships } from './resolvers/daohaus/resolver';
|
||||
import { getBoxProfile } from './resolvers/getBoxProfile/resolver';
|
||||
import { typeDefs } from './typeDefs';
|
||||
|
||||
const resolvers = {
|
||||
Query: {
|
||||
getBoxProfile,
|
||||
getDaoHausMemberships,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,16 +1,40 @@
|
||||
export const typeDefs = `
|
||||
type Query {
|
||||
getBoxProfile(address: String): BoxProfile
|
||||
}
|
||||
import { gql } from 'graphql-request/dist';
|
||||
|
||||
type BoxProfile {
|
||||
ethereumAddress : String
|
||||
name : String
|
||||
description : String
|
||||
location : String
|
||||
job : String
|
||||
emoji : String
|
||||
imageUrl : String
|
||||
}
|
||||
export const typeDefs = gql`
|
||||
type Query {
|
||||
getBoxProfile(address: String): BoxProfile
|
||||
getDaoHausMemberships(memberAddress: String): [Member!]!
|
||||
}
|
||||
|
||||
type BoxProfile {
|
||||
ethereumAddress: String
|
||||
name: String
|
||||
description: String
|
||||
location: String
|
||||
job: String
|
||||
emoji: String
|
||||
imageUrl: String
|
||||
}
|
||||
|
||||
type Moloch {
|
||||
id: ID!
|
||||
summoner: String!
|
||||
title: String
|
||||
version: String
|
||||
totalShares: Int!
|
||||
totalLoot: Int!
|
||||
}
|
||||
|
||||
type Member {
|
||||
id: ID!
|
||||
createdAt: String!
|
||||
moloch: Moloch!
|
||||
molochAddress: String!
|
||||
memberAddress: String!
|
||||
delegateKey: String!
|
||||
shares: Int!
|
||||
loot: Int
|
||||
exists: Boolean!
|
||||
kicked: Boolean
|
||||
}
|
||||
`;
|
||||
|
||||
8
packages/backend/src/lib/daoHausClient.ts
Normal file
8
packages/backend/src/lib/daoHausClient.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { GraphQLClient } from 'graphql-request';
|
||||
|
||||
import { CONFIG } from '../config';
|
||||
import { getSdk } from './autogen/daohaus-sdk';
|
||||
|
||||
export const daoHausClient = getSdk(
|
||||
new GraphQLClient(CONFIG.daoHausGraphqlURL),
|
||||
);
|
||||
@@ -1,7 +1,7 @@
|
||||
import { GraphQLClient } from 'graphql-request';
|
||||
|
||||
import { CONFIG } from '../config';
|
||||
import { getSdk } from './autogen/sdk';
|
||||
import { getSdk } from './autogen/hasura-sdk';
|
||||
|
||||
export const client = getSdk(
|
||||
new GraphQLClient(CONFIG.graphqlURL, {
|
||||
|
||||
Reference in New Issue
Block a user