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

Feat/shaman poster graph #482

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 13 additions & 0 deletions apps/moloch-v3-subgraph/src/poster-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { constants } from './util/constants';
import {
hasDaoDatabaseFields,
isDaoSafe,
isDaoShaman,
isMember,
isShareholder,
} from './util/validators';
Expand All @@ -28,6 +29,7 @@ export function handleNewPost(event: NewPost): void {
constants.DAOHAUS_PROPOSAL_DATABASE,
constants.DAOHAUS_SHARES_DATABASE,
constants.DAOHAUS_MEMBER_DATABASE,
constants.DAOHAUS_SHAMAN_DATABASE,
];
const validTag = validTags.includes(event.params.tag.toHexString());
if (!validTag) {
Expand Down Expand Up @@ -116,4 +118,15 @@ export function handleNewPost(event: NewPost): void {
addTransaction(event.block, event.transaction, event.address);
return;
}

if (
event.params.tag.toHexString() == constants.DAOHAUS_SHAMAN_DATABASE &&
hasDaoDatabaseFields(object) &&
isDaoShaman(object, event.params.user)
) {
log.info('&&& creating database record', [event.params.content]);
createDaoDatabaseRecord(object, event);
addTransaction(event.block, event.transaction, event.address);
return;
}
}
3 changes: 3 additions & 0 deletions apps/moloch-v3-subgraph/src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ export namespace constants {
//daohaus.member.database
export const DAOHAUS_MEMBER_DATABASE =
'0x3577aebf71d9bfbe235b0b98b53c9f1865b0f0dc68290b2b64c6251dc4de7800';
//daohaus.shaman.database
export const DAOHAUS_SHAMAN_DATABASE =
'0x28669a2d28b687eb592c45bf97b13239758e5d93354d383b83d2c2c51afaf4fe';
}
32 changes: 31 additions & 1 deletion apps/moloch-v3-subgraph/src/util/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
log,
TypedMap,
} from '@graphprotocol/graph-ts';
import { Dao, Member } from '../../generated/schema';
import { Dao, Member, Shaman } from '../../generated/schema';
import { constants } from './constants';
import { getStringFromJson } from './parser';

Expand Down Expand Up @@ -65,6 +65,36 @@ export function isMember(
return true;
}

export function isDaoShaman(
object: TypedMap<string, JSONValue>,
senderAddress: Bytes
): boolean {
const daoId = getStringFromJson(object, 'daoId');
if (daoId.error != 'none') {
log.error('no table', []);
return false;
}

const shamanId = daoId.data
.concat('-shaman-')
.concat(senderAddress.toHexString());

const shaman = Shaman.load(shamanId);
if (!shaman) {
log.info('no shaman', []);

return false;
}

if (shaman.permissions == constants.BIGINT_ZERO) {
log.info('shaman has been disabled', []);

return false;
}

return true;
}

export function isDaoSafe(
object: TypedMap<string, JSONValue>,
senderAddress: Bytes
Expand Down
1 change: 1 addition & 0 deletions libs/moloch-v3-data/src/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const listMembers = async ({
throw formatFetchError({ type: 'INVALID_NETWORK_ERROR' });
}

console.log('filter', filter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove this console.log

const res = await graphFetchList<ListMembersQuery, ListMembersQueryVariables>(
ListMembersDocument,
url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const MemberList = ({
hasNextPage,
orderMembers,
} = useDaoMembers();

const isMd = useBreakpoint(widthQuery.md);

const tableData = useMemo<MolochV3Members>(() => {
Expand Down
Loading