Skip to content

Commit bb2198b

Browse files
fix(APP-517): Resolve cryptex voting escrow addresses dynamically (#1066)
* fix: resolve cryptex voting escrow addresses dynamically * fix: rename cryptex token voting rewards test dao * chore: include changeset * chore: generalize VE token lookup * chore: docs, revert minor return change
1 parent ef68d72 commit bb2198b

File tree

22 files changed

+188
-61
lines changed

22 files changed

+188
-61
lines changed

.changeset/some-bats-lose.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aragon/app": patch
3+
---
4+
5+
Resolve cryptex voting escrow addresses dynamically

src/actions/capitalDistributor/components/capitalDistributorCreateCampaignActionCreate/capitalDistributorCampaignPayoutField.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import { InputContainer, RadioCard, RadioGroup } from '@aragon/gov-ui-kit';
44
import { useWatch } from 'react-hook-form';
55
import type { Hex } from 'viem';
6-
import { CapitalFlowDaoSlotId } from '@/modules/capitalFlow/constants/moduleDaoSlots';
6+
import {
7+
CapitalFlowDaoSlotId,
8+
type ICapitalDistributorVotingEscrowAddressParams,
9+
} from '@/modules/capitalFlow/constants/moduleDaoSlots';
710
import { useTranslations } from '@/shared/components/translationsProvider';
811
import { useFormField } from '@/shared/hooks/useFormField';
912
import { useSlotSingleFunction } from '@/shared/hooks/useSlotSingleFunction';
@@ -29,10 +32,13 @@ export const CapitalDistributorCampaignPayoutField: React.FC<
2932
const { fieldPrefix, daoId } = props;
3033
const { t } = useTranslations();
3134

32-
const escrowAddress = useSlotSingleFunction<void, Hex | undefined>({
35+
const escrowAddress = useSlotSingleFunction<
36+
ICapitalDistributorVotingEscrowAddressParams,
37+
Hex | undefined
38+
>({
3339
slotId: CapitalFlowDaoSlotId.CAPITAL_DISTRIBUTOR_VOTING_ESCROW_ADDRESS,
3440
pluginId: daoId,
35-
params: undefined,
41+
params: { daoId },
3642
});
3743

3844
const { onChange, ...payoutTypeField } = useFormField<

src/actions/capitalDistributor/components/capitalDistributorCreateCampaignActionCreate/capitalDistributorCreateCampaignActionCreate.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import {
1212
type Hex,
1313
zeroHash,
1414
} from 'viem';
15-
import { CapitalFlowDaoSlotId } from '@/modules/capitalFlow/constants/moduleDaoSlots';
15+
import {
16+
CapitalFlowDaoSlotId,
17+
type ICapitalDistributorVotingEscrowAddressParams,
18+
} from '@/modules/capitalFlow/constants/moduleDaoSlots';
1619
import {
1720
type IProposalActionData,
1821
useCreateProposalFormContext,
@@ -50,10 +53,13 @@ export const CapitalDistributorCreateCampaignActionCreate: React.FC<
5053
const { addPrepareAction } =
5154
useCreateProposalFormContext<ICapitalDistributorActionCreateCampaign>();
5255

53-
const escrowAddress = useSlotSingleFunction<void, Hex | undefined>({
56+
const escrowAddress = useSlotSingleFunction<
57+
ICapitalDistributorVotingEscrowAddressParams,
58+
Hex | undefined
59+
>({
5460
slotId: CapitalFlowDaoSlotId.CAPITAL_DISTRIBUTOR_VOTING_ESCROW_ADDRESS,
5561
pluginId: daoId,
56-
params: undefined,
62+
params: { daoId },
5763
});
5864

5965
const fieldName = `actions.[${index.toString()}]`;

src/daos/cryptex/components/cryptexMembersFileDownload/cryptexMembersFileDownload.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ import { useTranslations } from '@/shared/components/translationsProvider';
77
import {
88
cryptex,
99
cryptexTokenVotingPluginAddress,
10-
tokenCDTest,
11-
tokenCDTestTokenVotingPluginAddress,
10+
tokenVotingRewardsTest,
11+
tokenVotingRewardsTestTokenVotingPluginAddress,
1212
} from '../../constants';
1313
import { CryptexDialogId } from '../../constants/cryptexDialogId';
1414
import type { ICryptexMembersFileDownloadDialogParams } from '../../dialogs/cryptexMembersFileDownloadDialog';
1515
import type { ICryptexMembersFileDownloadProps } from './cryptexMembersFileDownload.api';
1616

17-
// TODO: Remove tokenCDTest entry when mainnet capital distributor is live (APP-558)
1817
const tokenVotingPluginAddresses: Record<string, `0x${string}`> = {
1918
[cryptex.id]: cryptexTokenVotingPluginAddress,
20-
[tokenCDTest.id]: tokenCDTestTokenVotingPluginAddress,
19+
[tokenVotingRewardsTest.id]: tokenVotingRewardsTestTokenVotingPluginAddress,
2120
};
2221

2322
export const CryptexMembersFileDownload: React.FC<

src/daos/cryptex/constants/domains/tokenCDTest.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../../tokenVotingRewardsTest/tokenVotingRewardsTest';

src/daos/cryptex/constants/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export * from './actions';
22
export * from './cryptexDialogId';
33
export * from './cryptexDialogsDefinitions';
44
export * from './domains/cryptexMainnet';
5-
export * from './domains/tokenCDTest';
5+
export * from './domains/tokenVotingRewardsTest';
66
export * from './tokens';
7+
export * from './tokenVotingPluginAddresses';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {
2+
cryptex,
3+
cryptexTokenVotingPluginAddress,
4+
} from '../cryptexMainnet/constants/cryptexMainnet';
5+
import {
6+
tokenVotingRewardsTest,
7+
tokenVotingRewardsTestTokenVotingPluginAddress,
8+
} from '../tokenVotingRewardsTest/tokenVotingRewardsTest';
9+
10+
export const cryptexTokenVotingPluginAddressByDaoId = {
11+
[cryptex.id]: cryptexTokenVotingPluginAddress,
12+
[tokenVotingRewardsTest.id]: tokenVotingRewardsTestTokenVotingPluginAddress,
13+
} satisfies Record<string, `0x${string}`>;

src/daos/cryptex/cryptexMainnet/constants/cryptexMainnet.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,3 @@ export const cryptex = {
99
*/
1010
export const cryptexTokenVotingPluginAddress: `0x${string}` =
1111
'0x17a1688C56087aDe762721180e1cC1E831C73719';
12-
13-
/**
14-
* Hardcoded voting escrow (veLocker) address shared by Cryptex DAOs.
15-
*/
16-
export const cryptexVotingEscrowAddress: `0x${string}` =
17-
'0x2DE5aE18750FBf82821212194D59aCc989469CDd';
18-
19-
export const getCryptexVotingEscrowAddress = (): `0x${string}` =>
20-
cryptexVotingEscrowAddress;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use client';
2+
3+
import { createCapitalDistributorVotingEscrowAddressResolver } from '@/modules/capitalFlow/hooks';
4+
import { cryptexTokenVotingPluginAddressByDaoId } from '../constants';
5+
6+
export const useCryptexVotingEscrowAddress =
7+
createCapitalDistributorVotingEscrowAddressResolver({
8+
pluginAddressByDaoId: cryptexTokenVotingPluginAddressByDaoId,
9+
});

0 commit comments

Comments
 (0)