From d8c5ce698c101cc4d7a4d13bb09309603aafc68c Mon Sep 17 00:00:00 2001 From: Sayo <82053242+wtfsayo@users.noreply.github.com> Date: Sun, 5 Jan 2025 17:55:32 +0530 Subject: [PATCH] call it `Escrow Delegate` --- .../data/contract/requests/getDAOAddresses.ts | 8 ++--- ...getDAOMultisig.ts => getEscrowDelegate.ts} | 31 +++++++++---------- .../TransactionForm/Escrow/EscrowForm.tsx | 6 ++-- .../modules/dao/components/SmartContracts.tsx | 4 +-- .../web/src/modules/dao/stores/useDaoStore.ts | 4 +-- .../pages/dao/[network]/[token]/[tokenId].tsx | 6 ++-- .../pages/dao/[network]/[token]/vote/[id].tsx | 9 ++++-- 7 files changed, 35 insertions(+), 33 deletions(-) rename apps/web/src/data/contract/requests/{getDAOMultisig.ts => getEscrowDelegate.ts} (76%) diff --git a/apps/web/src/data/contract/requests/getDAOAddresses.ts b/apps/web/src/data/contract/requests/getDAOAddresses.ts index 90f87a3f..9d0dca89 100644 --- a/apps/web/src/data/contract/requests/getDAOAddresses.ts +++ b/apps/web/src/data/contract/requests/getDAOAddresses.ts @@ -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({ @@ -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 @@ -29,7 +29,7 @@ const getDAOAddresses = async (chainId: CHAIN_ID, tokenAddress: AddressType) => governor, metadata, treasury, - multiSig, + escrowDelegate, }) return { @@ -38,7 +38,7 @@ const getDAOAddresses = async (chainId: CHAIN_ID, tokenAddress: AddressType) => governor, metadata, treasury, - multiSig, + escrowDelegate, } } diff --git a/apps/web/src/data/contract/requests/getDAOMultisig.ts b/apps/web/src/data/contract/requests/getEscrowDelegate.ts similarity index 76% rename from apps/web/src/data/contract/requests/getDAOMultisig.ts rename to apps/web/src/data/contract/requests/getEscrowDelegate.ts index 12892298..73d695e6 100644 --- a/apps/web/src/data/contract/requests/getDAOMultisig.ts +++ b/apps/web/src/data/contract/requests/getEscrowDelegate.ts @@ -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 = { @@ -39,7 +39,7 @@ const ATTESTATION_URL: Record = { [CHAIN_ID.FOUNDRY]: '', } -export async function getDaoMultiSig( +export async function getEscrowDelegate( daoTreasuryAddress: string, chainId: CHAIN_ID ): Promise { @@ -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)}" } } ) { @@ -77,7 +76,6 @@ export async function getDaoMultiSig( } ` - try { const response = await axios.post( attestationUrl, @@ -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 }) @@ -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 diff --git a/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/EscrowForm.tsx b/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/EscrowForm.tsx index 32ab9f72..bc9908c1 100644 --- a/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/EscrowForm.tsx +++ b/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/EscrowForm.tsx @@ -120,7 +120,7 @@ const EscrowForm: React.FC = ({ const { formValues, setFormValues } = useEscrowFormStore() const { - addresses: { multiSig, treasury }, + addresses: { escrowDelegate, treasury }, } = useDaoStore() const handleSubmit = useCallback( @@ -157,7 +157,7 @@ const EscrowForm: React.FC = ({ = ({ 'The wallet address to which funds will be released on milestone completions.' } /> - {!multiSig && ( + {!escrowDelegate && ( { - {addresses?.multiSig && ( - + {addresses?.escrowDelegate && ( + )} diff --git a/apps/web/src/modules/dao/stores/useDaoStore.ts b/apps/web/src/modules/dao/stores/useDaoStore.ts index 18047012..dd82b9d7 100644 --- a/apps/web/src/modules/dao/stores/useDaoStore.ts +++ b/apps/web/src/modules/dao/stores/useDaoStore.ts @@ -16,7 +16,7 @@ export interface DaoContractAddresses { auction?: AddressType treasury?: AddressType governor?: AddressType - multiSig?: AddressType + escrowDelegate?: AddressType } export interface DaoContracts { @@ -39,7 +39,7 @@ export const useDaoStore = create((set) => ({ auction: undefined, treasury: undefined, governor: undefined, - multiSig: undefined, + escrowDelegate: undefined, }, setAddresses: (addresses: DaoContractAddresses) => set({ addresses }), })) diff --git a/apps/web/src/pages/dao/[network]/[token]/[tokenId].tsx b/apps/web/src/pages/dao/[network]/[token]/[tokenId].tsx index 8aa68bef..5e03f19f 100644 --- a/apps/web/src/pages/dao/[network]/[token]/[tokenId].tsx +++ b/apps/web/src/pages/dao/[network]/[token]/[tokenId].tsx @@ -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' @@ -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 @@ -224,7 +224,7 @@ export const getServerSideProps: GetServerSideProps = async ({ treasury: treasuryAddress, governor: governorAddress, auction: auctionAddress, - multiSig: multiSigAddress, + escrowDelegate: escrowDelegateAddress, } const daoOgMetadata: DaoOgMetadata = { diff --git a/apps/web/src/pages/dao/[network]/[token]/vote/[id].tsx b/apps/web/src/pages/dao/[network]/[token]/vote/[id].tsx index be82e269..2049c42e 100644 --- a/apps/web/src/pages/dao/[network]/[token]/vote/[id].tsx +++ b/apps/web/src/pages/dao/[network]/[token]/vote/[id].tsx @@ -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, @@ -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: { @@ -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}://${