Skip to content

Commit

Permalink
call it Escrow Delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsayo committed Jan 5, 2025
1 parent 76449e7 commit d8c5ce6
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 33 deletions.
8 changes: 4 additions & 4 deletions apps/web/src/data/contract/requests/getDAOAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AddressType, CHAIN_ID } from 'src/typings'
import { unpackOptionalArray } from 'src/utils/helpers'

import { managerAbi } from '../abis'
import { getDaoMultiSig } from './getDAOMultisig'
import { getEscrowDelegate } from './getEscrowDelegate'

const getDAOAddresses = async (chainId: CHAIN_ID, tokenAddress: AddressType) => {
const addresses = await readContract({
Expand All @@ -18,7 +18,7 @@ const getDAOAddresses = async (chainId: CHAIN_ID, tokenAddress: AddressType) =>

const [metadata, auction, treasury, governor] = unpackOptionalArray(addresses, 4)

const multiSig = await getDaoMultiSig(treasury as AddressType, chainId)
const escrowDelegate = await getEscrowDelegate(treasury as AddressType, chainId)

const hasMissingAddresses = Object.values(addresses).includes(NULL_ADDRESS)
if (hasMissingAddresses) return null
Expand All @@ -29,7 +29,7 @@ const getDAOAddresses = async (chainId: CHAIN_ID, tokenAddress: AddressType) =>
governor,
metadata,
treasury,
multiSig,
escrowDelegate,
})

return {
Expand All @@ -38,7 +38,7 @@ const getDAOAddresses = async (chainId: CHAIN_ID, tokenAddress: AddressType) =>
governor,
metadata,
treasury,
multiSig,
escrowDelegate,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface DecodedData {

const ATTESTATION_SCHEMA_UID = `0x1289c5f988998891af7416d83820c40ba1c6f5ba31467f2e611172334dc53a0e`
const SMART_INVOICE_MULTISIG = `0x503a5161D1c5D9d82BF35a4c80DA0C3Ad72d9244` // TODO: replace with actual multisig address
const BUILDER_DAO_TREASURY= `0xcf325a4c78912216249b818521b0798a0f904c10`
const BUILDER_DAO_TREASURY = `0xcf325a4c78912216249b818521b0798a0f904c10`
const BUILDER_DAO_OPS_MULTISIG = `0x58eAEfBEd9EEFbC564E302D0AfAE0B113E42eAb3`

const ATTESTATION_URL: Record<CHAIN_ID, string> = {
Expand All @@ -39,7 +39,7 @@ const ATTESTATION_URL: Record<CHAIN_ID, string> = {
[CHAIN_ID.FOUNDRY]: '',
}

export async function getDaoMultiSig(
export async function getEscrowDelegate(
daoTreasuryAddress: string,
chainId: CHAIN_ID
): Promise<string | null> {
Expand All @@ -53,20 +53,19 @@ export async function getDaoMultiSig(
return null
}

const multiSigIssuerPriorityOrder = [
const attestationIssuerPriorityOrder = [
checksumAddress(daoTreasuryAddress),
checksumAddress(BUILDER_DAO_TREASURY),
checksumAddress(BUILDER_DAO_OPS_MULTISIG),
checksumAddress(SMART_INVOICE_MULTISIG)
];

checksumAddress(BUILDER_DAO_OPS_MULTISIG),
checksumAddress(SMART_INVOICE_MULTISIG),
]

const query = `
query Attestations {
attestations(
where: {
schemaId: { equals: "${ATTESTATION_SCHEMA_UID}" }
attester: { in: ["${multiSigIssuerPriorityOrder.join('","')}"] }
attester: { in: ["${attestationIssuerPriorityOrder.join('","')}"] }
recipient: { equals: "${checksumAddress(daoTreasuryAddress)}" }
}
) {
Expand All @@ -77,7 +76,6 @@ export async function getDaoMultiSig(
}
`


try {
const response = await axios.post<AttestationResponse>(
attestationUrl,
Expand All @@ -91,11 +89,10 @@ export async function getDaoMultiSig(

const attestations = response?.data?.data?.attestations


// Sort attestations based on priority order
const sortedAttestations = attestations.sort((a, b) => {
const indexA = multiSigIssuerPriorityOrder.indexOf(a.attester as `0x${string}`)
const indexB = multiSigIssuerPriorityOrder.indexOf(b.attester as `0x${string}`)
const indexA = attestationIssuerPriorityOrder.indexOf(a.attester as `0x${string}`)
const indexB = attestationIssuerPriorityOrder.indexOf(b.attester as `0x${string}`)
return indexA - indexB
})

Expand All @@ -105,14 +102,16 @@ export async function getDaoMultiSig(

try {
// Get the first attestation from priority
const decodedData = JSON.parse(sortedAttestations[0].decodedDataJson) as DecodedData[]
const decodedData = JSON.parse(
sortedAttestations[0].decodedDataJson
) as DecodedData[]

const multisigAddress = decodedData[0]?.value?.value
if (!multisigAddress || !isAddress(multisigAddress)) {
const escrowDelegateAddress = decodedData[0]?.value?.value
if (!escrowDelegateAddress || !isAddress(escrowDelegateAddress)) {
return null
}

return multisigAddress
return escrowDelegateAddress
} catch (parseError) {
console.error('Error parsing attestation data:', parseError)
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const EscrowForm: React.FC<EscrowFormProps> = ({

const { formValues, setFormValues } = useEscrowFormStore()
const {
addresses: { multiSig, treasury },
addresses: { escrowDelegate, treasury },
} = useDaoStore()

const handleSubmit = useCallback(
Expand Down Expand Up @@ -157,7 +157,7 @@ const EscrowForm: React.FC<EscrowFormProps> = ({
<Formik
initialValues={{
...formValues,
clientAddress: multiSig || treasury || '',
clientAddress: escrowDelegate || treasury || '',
}}
validationSchema={EscrowFormSchema}
onSubmit={handleSubmit}
Expand Down Expand Up @@ -192,7 +192,7 @@ const EscrowForm: React.FC<EscrowFormProps> = ({
'The wallet address to which funds will be released on milestone completions.'
}
/>
{!multiSig && (
{!escrowDelegate && (
<SmartInput
type={TEXT}
formik={formik}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/modules/dao/components/SmartContracts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export const SmartContracts = () => {
<ContractLink title="Governor" address={addresses.governor} />
<ContractLink title="Treasury" address={addresses.treasury} />
<ContractLink title="Metadata" address={addresses.metadata} />
{addresses?.multiSig && (
<ContractLink title="MultiSig" address={addresses.multiSig} />
{addresses?.escrowDelegate && (
<ContractLink title="Escrow Delegate" address={addresses.escrowDelegate} />
)}
</Flex>
</Flex>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/modules/dao/stores/useDaoStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface DaoContractAddresses {
auction?: AddressType
treasury?: AddressType
governor?: AddressType
multiSig?: AddressType
escrowDelegate?: AddressType
}

export interface DaoContracts {
Expand All @@ -39,7 +39,7 @@ export const useDaoStore = create<DaoStoreProps>((set) => ({
auction: undefined,
treasury: undefined,
governor: undefined,
multiSig: undefined,
escrowDelegate: undefined,
},
setAddresses: (addresses: DaoContractAddresses) => set({ addresses }),
}))
6 changes: 3 additions & 3 deletions apps/web/src/pages/dao/[network]/[token]/[tokenId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CACHE_TIMES } from 'src/constants/cacheTimes'
import { PUBLIC_ALL_CHAINS, PUBLIC_DEFAULT_CHAINS } from 'src/constants/defaultChains'
import { CAST_ENABLED } from 'src/constants/farcasterEnabled'
import { SUCCESS_MESSAGES } from 'src/constants/messages'
import { getDaoMultiSig } from 'src/data/contract/requests/getDAOMultisig'
import { getEscrowDelegate } from 'src/data/contract/requests/getEscrowDelegate'
import { SDK } from 'src/data/subgraph/client'
import { TokenWithDaoQuery } from 'src/data/subgraph/sdk.generated'
import { useVotes } from 'src/hooks'
Expand Down Expand Up @@ -213,7 +213,7 @@ export const getServerSideProps: GetServerSideProps = async ({
auctionAddress,
} = token.dao

const multiSigAddress = (await getDaoMultiSig(
const escrowDelegateAddress = (await getEscrowDelegate(
treasuryAddress,
chain.id
)) as AddressType
Expand All @@ -224,7 +224,7 @@ export const getServerSideProps: GetServerSideProps = async ({
treasury: treasuryAddress,
governor: governorAddress,
auction: auctionAddress,
multiSig: multiSigAddress,
escrowDelegate: escrowDelegateAddress,
}

const daoOgMetadata: DaoOgMetadata = {
Expand Down
9 changes: 6 additions & 3 deletions apps/web/src/pages/dao/[network]/[token]/vote/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Meta } from 'src/components/Meta'
import { CACHE_TIMES } from 'src/constants/cacheTimes'
import { PUBLIC_DEFAULT_CHAINS } from 'src/constants/defaultChains'
import SWR_KEYS from 'src/constants/swrKeys'
import { getDaoMultiSig } from 'src/data/contract/requests/getDAOMultisig'
import { getEscrowDelegate } from 'src/data/contract/requests/getEscrowDelegate'
import { SDK } from 'src/data/subgraph/client'
import {
formatAndFetchState,
Expand Down Expand Up @@ -212,7 +212,10 @@ export const getServerSideProps: GetServerSideProps = async ({ params, req, res
auctionAddress,
} = data.dao

const multiSigAddress = (await getDaoMultiSig(treasuryAddress, chain.id)) as AddressType
const escrowDelegateAddress = (await getEscrowDelegate(
treasuryAddress,
chain.id
)) as AddressType

const ogMetadata: ProposalOgMetadata = {
proposal: {
Expand All @@ -233,7 +236,7 @@ export const getServerSideProps: GetServerSideProps = async ({ params, req, res
governor: governorAddress,
treasury: treasuryAddress,
auction: auctionAddress,
multiSig: multiSigAddress,
escrowDelegate: escrowDelegateAddress,
}

const ogImageURL = `${protocol}://${
Expand Down

0 comments on commit d8c5ce6

Please sign in to comment.