Skip to content

Commit

Permalink
Merge pull request #482 from HausDAO/feat/shaman-poster-graph
Browse files Browse the repository at this point in the history
Feat/shaman poster graph
  • Loading branch information
skuhlmann authored Mar 27, 2024
2 parents df0ce97 + 362ab12 commit 454a54f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
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
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

0 comments on commit 454a54f

Please sign in to comment.