hat.ts
1 import { Hat } from '@hatsprotocol/sdk-v1-subgraph'; 2 import { Hex } from 'viem'; 3 4 import { Authority } from './authorities'; 5 import { SupportedChains } from './chains'; 6 7 // details-mgr 8 export type DetailsItem = { 9 link: string; 10 label: string; 11 description?: string; 12 imageUri?: string; 13 imageUrl?: string; // old field, prefer `imageUri` 14 }; 15 16 export interface HatWearer { 17 id: Hex; 18 isContract?: boolean; 19 contractName?: string; 20 ensName?: string | null; 21 } 22 23 export interface AllowlistProfile extends HatWearer { 24 eligible: boolean; 25 badStanding: boolean; 26 } 27 28 export type HatDetailsKeys = keyof HatDetails; 29 30 // details-mgr 31 export type HatDetails = { 32 name: string; 33 description?: string; 34 responsibilities?: DetailsItem[]; 35 authorities?: Authority[]; 36 guilds?: string[]; 37 spaces?: string[]; 38 eligibility?: { 39 manual?: boolean; 40 criteria?: DetailsItem[]; 41 }; 42 toggle?: { 43 manual?: boolean; 44 criteria?: DetailsItem[]; 45 }; 46 }; 47 48 export interface HatWithMetadata extends Hat { 49 detailsMetadata?: string; 50 } 51 52 export interface AppHat extends HatWithMetadata { 53 id: Hex; // Confirm `Hat` ID is Hex instead of string 54 chainId?: SupportedChains; 55 imageUrl?: string; 56 nearestImage?: string; 57 detailsObject?: { 58 type: string; 59 data: HatDetails; 60 }; 61 name?: string; 62 parentId?: Hex | undefined; 63 treeId?: Hex; 64 isLinked?: boolean; 65 url?: string; 66 active?: boolean; 67 type?: string; 68 displayName?: string; 69 extendedEligibility?: HatWearer; 70 extendedToggle?: HatWearer; 71 // object assembled to be used in the org chart wearers section 72 hatChartWearers?: { 73 color: string; 74 accent: string; 75 icon: string; 76 content: string; 77 contentWidth: string; 78 accentWidth: string; 79 }; 80 metadata?: HatDetails; 81 metadataType?: string; 82 } 83 84 export interface OrgChartHat extends AppHat { 85 _collapsed?: boolean; 86 _centeredWithDescendants?: boolean; 87 _directSubordinatesPaging?: number; 88 _directSubordinates?: number; 89 _totalSubordinates?: number; 90 _highlighted?: boolean; 91 _upToTheRootHighlighted?: boolean; 92 _expanded?: boolean; 93 _centered?: boolean; 94 } 95 96 export interface HatWithDepth extends AppHat { 97 ipId?: string; 98 depth?: number; 99 } 100 101 export interface HatExport { 102 id: Hex; 103 status: boolean; 104 createdAt?: number; 105 details: string; 106 maxSupply: number; 107 eligibility: Hex; 108 toggle: Hex; 109 mutable: boolean; 110 imageUri: string; 111 currentSupply: number; 112 wearers: Hex[]; 113 adminId: Hex; 114 // imageUrl?: string | null; 115 detailsObject?: { 116 type: string; 117 data: HatDetails; 118 }; 119 }