From e88a7f5c7280355ecf88812592ab45b26516df7d Mon Sep 17 00:00:00 2001 From: Dekan Date: Thu, 8 Feb 2024 08:46:03 -0700 Subject: [PATCH 1/5] add shaman validation --- apps/moloch-v3-subgraph/src/poster-mapping.ts | 12 +++++++++ apps/moloch-v3-subgraph/src/util/constants.ts | 3 +++ .../moloch-v3-subgraph/src/util/validators.ts | 27 ++++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/apps/moloch-v3-subgraph/src/poster-mapping.ts b/apps/moloch-v3-subgraph/src/poster-mapping.ts index b487f47b..80e54e59 100644 --- a/apps/moloch-v3-subgraph/src/poster-mapping.ts +++ b/apps/moloch-v3-subgraph/src/poster-mapping.ts @@ -12,6 +12,7 @@ import { constants } from './util/constants'; import { hasDaoDatabaseFields, isDaoSafe, + isDaoShaman, isMember, isShareholder, } from './util/validators'; @@ -116,4 +117,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; + } } diff --git a/apps/moloch-v3-subgraph/src/util/constants.ts b/apps/moloch-v3-subgraph/src/util/constants.ts index e5a39b6a..8aa4efac 100644 --- a/apps/moloch-v3-subgraph/src/util/constants.ts +++ b/apps/moloch-v3-subgraph/src/util/constants.ts @@ -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'; } diff --git a/apps/moloch-v3-subgraph/src/util/validators.ts b/apps/moloch-v3-subgraph/src/util/validators.ts index c5c6fabe..b39f3fd4 100644 --- a/apps/moloch-v3-subgraph/src/util/validators.ts +++ b/apps/moloch-v3-subgraph/src/util/validators.ts @@ -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'; @@ -65,6 +65,31 @@ export function isMember( return true; } +export function isDaoShaman( + object: TypedMap, + 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; + } + + return true; +} + + export function isDaoSafe( object: TypedMap, senderAddress: Bytes From 08673d91f657a69ba08c7ecbecd2bfc7f5261dd4 Mon Sep 17 00:00:00 2001 From: Dekan Date: Thu, 8 Feb 2024 09:03:35 -0700 Subject: [PATCH 2/5] add permission check --- apps/moloch-v3-subgraph/src/util/validators.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/moloch-v3-subgraph/src/util/validators.ts b/apps/moloch-v3-subgraph/src/util/validators.ts index b39f3fd4..38af7e81 100644 --- a/apps/moloch-v3-subgraph/src/util/validators.ts +++ b/apps/moloch-v3-subgraph/src/util/validators.ts @@ -86,10 +86,17 @@ export function isDaoShaman( return false; } + if ( + shaman.permissions == constants.BIGINT_ZERO + ) { + log.info('shaman has been disabled', []); + + return false; + } + return true; } - export function isDaoSafe( object: TypedMap, senderAddress: Bytes From be24dd58c41d5d7e589bfbc7105eebe750dfa5a6 Mon Sep 17 00:00:00 2001 From: Dekan Date: Tue, 26 Mar 2024 14:03:32 -0600 Subject: [PATCH 3/5] add to valid poster tags --- apps/moloch-v3-subgraph/src/poster-mapping.ts | 1 + apps/moloch-v3-subgraph/src/util/validators.ts | 4 +--- libs/moloch-v3-data/src/members.ts | 1 + .../src/components/MemberList/MemberList.tsx | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/moloch-v3-subgraph/src/poster-mapping.ts b/apps/moloch-v3-subgraph/src/poster-mapping.ts index 80e54e59..3351725f 100644 --- a/apps/moloch-v3-subgraph/src/poster-mapping.ts +++ b/apps/moloch-v3-subgraph/src/poster-mapping.ts @@ -29,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) { diff --git a/apps/moloch-v3-subgraph/src/util/validators.ts b/apps/moloch-v3-subgraph/src/util/validators.ts index 38af7e81..855a101b 100644 --- a/apps/moloch-v3-subgraph/src/util/validators.ts +++ b/apps/moloch-v3-subgraph/src/util/validators.ts @@ -86,9 +86,7 @@ export function isDaoShaman( return false; } - if ( - shaman.permissions == constants.BIGINT_ZERO - ) { + if (shaman.permissions == constants.BIGINT_ZERO) { log.info('shaman has been disabled', []); return false; diff --git a/libs/moloch-v3-data/src/members.ts b/libs/moloch-v3-data/src/members.ts index 003186c8..8837eeb8 100644 --- a/libs/moloch-v3-data/src/members.ts +++ b/libs/moloch-v3-data/src/members.ts @@ -89,6 +89,7 @@ export const listMembers = async ({ throw formatFetchError({ type: 'INVALID_NETWORK_ERROR' }); } + console.log('filter', filter) const res = await graphFetchList( ListMembersDocument, url, diff --git a/libs/moloch-v3-macro-ui/src/components/MemberList/MemberList.tsx b/libs/moloch-v3-macro-ui/src/components/MemberList/MemberList.tsx index b43eb40c..91fff5ec 100644 --- a/libs/moloch-v3-macro-ui/src/components/MemberList/MemberList.tsx +++ b/libs/moloch-v3-macro-ui/src/components/MemberList/MemberList.tsx @@ -46,6 +46,7 @@ export const MemberList = ({ allowMemberMenu = false, }: MemberListProps) => { const { dao, isLoading: isLoadingDao } = useDaoData(); + console.log('dao', dao); const { members, @@ -54,6 +55,7 @@ export const MemberList = ({ hasNextPage, orderMembers, } = useDaoMembers(); + console.log('members', members); const isMd = useBreakpoint(widthQuery.md); const tableData = useMemo(() => { From 2703a0e723e1ed03f76e7b42d35adfeee7afa994 Mon Sep 17 00:00:00 2001 From: Dekan Date: Tue, 26 Mar 2024 14:09:59 -0600 Subject: [PATCH 4/5] remove extra logs --- libs/moloch-v3-data/src/members.ts | 2 +- .../src/components/MemberList/MemberList.tsx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/moloch-v3-data/src/members.ts b/libs/moloch-v3-data/src/members.ts index 8837eeb8..5f482167 100644 --- a/libs/moloch-v3-data/src/members.ts +++ b/libs/moloch-v3-data/src/members.ts @@ -89,7 +89,7 @@ export const listMembers = async ({ throw formatFetchError({ type: 'INVALID_NETWORK_ERROR' }); } - console.log('filter', filter) + console.log('filter', filter); const res = await graphFetchList( ListMembersDocument, url, diff --git a/libs/moloch-v3-macro-ui/src/components/MemberList/MemberList.tsx b/libs/moloch-v3-macro-ui/src/components/MemberList/MemberList.tsx index 91fff5ec..3b34ea99 100644 --- a/libs/moloch-v3-macro-ui/src/components/MemberList/MemberList.tsx +++ b/libs/moloch-v3-macro-ui/src/components/MemberList/MemberList.tsx @@ -46,7 +46,6 @@ export const MemberList = ({ allowMemberMenu = false, }: MemberListProps) => { const { dao, isLoading: isLoadingDao } = useDaoData(); - console.log('dao', dao); const { members, @@ -55,7 +54,7 @@ export const MemberList = ({ hasNextPage, orderMembers, } = useDaoMembers(); - console.log('members', members); + const isMd = useBreakpoint(widthQuery.md); const tableData = useMemo(() => { From 362ab1287eb8aa2925f4b1938cde296854266af5 Mon Sep 17 00:00:00 2001 From: Sam Kuhlmann Date: Wed, 27 Mar 2024 08:59:25 -0600 Subject: [PATCH 5/5] Update members.ts --- libs/moloch-v3-data/src/members.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/moloch-v3-data/src/members.ts b/libs/moloch-v3-data/src/members.ts index 5f482167..003186c8 100644 --- a/libs/moloch-v3-data/src/members.ts +++ b/libs/moloch-v3-data/src/members.ts @@ -89,7 +89,6 @@ export const listMembers = async ({ throw formatFetchError({ type: 'INVALID_NETWORK_ERROR' }); } - console.log('filter', filter); const res = await graphFetchList( ListMembersDocument, url,