Skip to content

Commit

Permalink
Merge pull request #2102 from decentdao/roles-0.1.0/decenthats-contract
Browse files Browse the repository at this point in the history
Roles 0.1.0/decenthats contract
  • Loading branch information
adamgall authored Jul 9, 2024
2 parents efb6f1b + ef46722 commit b2de6ea
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 14 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@fontsource/space-mono": "^5.0.19",
"@fractal-framework/fractal-contracts": "^0.7.1",
"@fractal-framework/fractal-contracts": "^0.8.0",
"@graphprotocol/client-apollo": "^1.0.16",
"@hatsprotocol/sdk-v1-core": "^0.9.0",
"@hatsprotocol/sdk-v1-subgraph": "^1.0.0",
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/utils/rolesProposalFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import { DecentRoleHat } from '../../state/useRolesState';
import { CreateProposalMetadata } from '../../types';
import { SENTINEL_MODULE } from '../../utils/address';

const decentHatsAddress = getAddress('0xa66696f25816D5635a7dd1c0f162D66549C69e97'); // @todo: sepolia only. Move to, and read from, network config
const hatsContractAddress = getAddress('0x3bc1A0Ad72417f2d411118085256fC53CBdDd137'); // @todo: move to network configs?
const ha75Address = getAddress('0x0000000000000000000000000000000000004a75');

const hatsDetailsBuilder = (data: { name: string; description: string }) => {
return JSON.stringify({
type: '1.0',
Expand Down Expand Up @@ -92,6 +88,7 @@ const prepareMintHatsTxArgs = (addedHats: HatStruct[], adminHatId: Hex, hatsCoun
*/
export const parseEditedHatsFormValues = async (
editedHats: RoleValue[],
ha75Address: Address,
getHat: (hatId: Hex) => DecentRoleHat | null,
uploadHatDescription: (hatDescription: string) => Promise<string>,
) => {
Expand Down Expand Up @@ -181,6 +178,8 @@ export const prepareCreateTopHatProposalData = async (
safeAddress: Address,
uploadHatDescription: (hatDescription: string) => Promise<string>,
safeName: string,
decentHatsAddress: Address,
ha75Address: Address,
) => {
const enableModuleData = encodeFunctionData({
abi: GnosisSafeL2,
Expand Down Expand Up @@ -250,6 +249,7 @@ export const prepareEditHatsProposalData = (
},
adminHatId: Hex,
hatsCount: number,
hatsContractAddress: Address,
) => {
const { addedHats, removedHatIds, memberChangedHats, roleDetailsChangedHats } = edits;

Expand Down
21 changes: 16 additions & 5 deletions src/pages/daos/[daoAddress]/roles/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ function RolesEdit() {
const {
node: { daoAddress, safe, daoName },
} = useFractal();
const { addressPrefix } = useNetworkConfig();
const {
addressPrefix,
contracts: { hatsProtocol, decentHatsMasterCopy },
constants: { ha75Address },
} = useNetworkConfig();

const { rolesSchema } = useRolesSchema();
const { hatsTree, hatsTreeId, getHat } = useRolesState();
Expand Down Expand Up @@ -66,6 +70,7 @@ function RolesEdit() {

const editedHatStructs = await parseEditedHatsFormValues(
modifiedHats,
getAddress(ha75Address),
getHat,
uploadHatDescriptionCallback,
);
Expand All @@ -79,6 +84,8 @@ function RolesEdit() {
getAddress(safe.address),
uploadHatDescriptionCallback,
daoName ?? safe.address,
getAddress(decentHatsMasterCopy),
getAddress(ha75Address),
);
} else {
if (!hatsTree) {
Expand All @@ -90,6 +97,7 @@ function RolesEdit() {
editedHatStructs,
hatsTree.adminHat.id,
hatsTree.roleHatsTotalCount,
getAddress(hatsProtocol),
);
}

Expand All @@ -108,15 +116,18 @@ function RolesEdit() {
}
},
[
safe,
daoName,
decentHatsMasterCopy,
getHat,
ha75Address,
hatsProtocol,
hatsTree,
hatsTreeId,
submitProposal,
t,
ipfsClient,
hatsTree,
safe,
submitProposal,
submitProposalSuccessCallback,
t,
],
);

Expand Down
6 changes: 6 additions & 0 deletions src/providers/NetworkConfig/networks/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Azorius from '@fractal-framework/fractal-contracts/deployments/base/Azorius.json' assert { type: 'json' };
import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/base/AzoriusFreezeGuard.json' assert { type: 'json' };
import DecentHats from '@fractal-framework/fractal-contracts/deployments/base/DecentHats.json' assert { type: 'json ' };
import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/base/ERC20Claim.json' assert { type: 'json' };
import ERC20FreezeVoting from '@fractal-framework/fractal-contracts/deployments/base/ERC20FreezeVoting.json' assert { type: 'json' };
import ERC721FreezeVoting from '@fractal-framework/fractal-contracts/deployments/base/ERC721FreezeVoting.json' assert { type: 'json' };
Expand Down Expand Up @@ -74,6 +75,11 @@ const baseConfig: NetworkConfig = {
})?.networkAddresses[base.id.toString()]!,
votesERC20WrapperMasterCopy: VotesERC20Wrapper.address,
keyValuePairs: KeyValuePairs.address,
decentHatsMasterCopy: DecentHats.address,
hatsProtocol: '0x3bc1A0Ad72417f2d411118085256fC53CBdDd137',
},
constants: {
ha75Address: '0x0000000000000000000000000000000000004a75',
},
staking: {},
createOptions: [GovernanceType.MULTISIG, GovernanceType.AZORIUS_ERC20],
Expand Down
6 changes: 6 additions & 0 deletions src/providers/NetworkConfig/networks/mainnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Azorius from '@fractal-framework/fractal-contracts/deployments/mainnet/Azorius.json' assert { type: 'json' };
import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/mainnet/AzoriusFreezeGuard.json' assert { type: 'json' };
import DecentHats from '@fractal-framework/fractal-contracts/deployments/mainnet/DecentHats.json' assert { type: 'json ' };
import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/mainnet/ERC20Claim.json' assert { type: 'json' };
import ERC20FreezeVoting from '@fractal-framework/fractal-contracts/deployments/mainnet/ERC20FreezeVoting.json' assert { type: 'json' };
import ERC721FreezeVoting from '@fractal-framework/fractal-contracts/deployments/mainnet/ERC721FreezeVoting.json' assert { type: 'json' };
Expand Down Expand Up @@ -74,6 +75,11 @@ const mainnetConfig: NetworkConfig = {
})?.networkAddresses[mainnet.id.toString()]!,
votesERC20WrapperMasterCopy: VotesERC20Wrapper.address,
keyValuePairs: KeyValuePairs.address,
decentHatsMasterCopy: DecentHats.address,
hatsProtocol: '0x3bc1A0Ad72417f2d411118085256fC53CBdDd137',
},
constants: {
ha75Address: '0x0000000000000000000000000000000000004a75',
},
staking: {
lido: {
Expand Down
6 changes: 6 additions & 0 deletions src/providers/NetworkConfig/networks/optimism.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Azorius from '@fractal-framework/fractal-contracts/deployments/optimism/Azorius.json' assert { type: 'json' };
import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/optimism/AzoriusFreezeGuard.json' assert { type: 'json' };
import DecentHats from '@fractal-framework/fractal-contracts/deployments/optimism/DecentHats.json' assert { type: 'json ' };
import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/optimism/ERC20Claim.json' assert { type: 'json' };
import ERC20FreezeVoting from '@fractal-framework/fractal-contracts/deployments/optimism/ERC20FreezeVoting.json' assert { type: 'json' };
import ERC721FreezeVoting from '@fractal-framework/fractal-contracts/deployments/optimism/ERC721FreezeVoting.json' assert { type: 'json' };
Expand Down Expand Up @@ -74,6 +75,11 @@ const optimismConfig: NetworkConfig = {
})?.networkAddresses[optimism.id.toString()]!,
votesERC20WrapperMasterCopy: VotesERC20Wrapper.address,
keyValuePairs: KeyValuePairs.address,
decentHatsMasterCopy: DecentHats.address,
hatsProtocol: '0x3bc1A0Ad72417f2d411118085256fC53CBdDd137',
},
constants: {
ha75Address: '0x0000000000000000000000000000000000004a75',
},
staking: {},
createOptions: [GovernanceType.MULTISIG, GovernanceType.AZORIUS_ERC20],
Expand Down
6 changes: 6 additions & 0 deletions src/providers/NetworkConfig/networks/polygon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Azorius from '@fractal-framework/fractal-contracts/deployments/polygon/Azorius.json' assert { type: 'json' };
import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/polygon/AzoriusFreezeGuard.json' assert { type: 'json' };
import DecentHats from '@fractal-framework/fractal-contracts/deployments/polygon/DecentHats.json' assert { type: 'json ' };
import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/polygon/ERC20Claim.json' assert { type: 'json' };
import ERC20FreezeVoting from '@fractal-framework/fractal-contracts/deployments/polygon/ERC20FreezeVoting.json' assert { type: 'json' };
import ERC721FreezeVoting from '@fractal-framework/fractal-contracts/deployments/polygon/ERC721FreezeVoting.json' assert { type: 'json' };
Expand Down Expand Up @@ -74,6 +75,11 @@ const polygonConfig: NetworkConfig = {
})?.networkAddresses[polygon.id.toString()]!,
votesERC20WrapperMasterCopy: VotesERC20Wrapper.address,
keyValuePairs: KeyValuePairs.address,
decentHatsMasterCopy: DecentHats.address,
hatsProtocol: '0x3bc1A0Ad72417f2d411118085256fC53CBdDd137',
},
constants: {
ha75Address: '0x0000000000000000000000000000000000004a75',
},
staking: {},
createOptions: [GovernanceType.MULTISIG, GovernanceType.AZORIUS_ERC20],
Expand Down
6 changes: 6 additions & 0 deletions src/providers/NetworkConfig/networks/sepolia.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Azorius from '@fractal-framework/fractal-contracts/deployments/sepolia/Azorius.json' assert { type: 'json' };
import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/sepolia/AzoriusFreezeGuard.json' assert { type: 'json' };
import DecentHats from '@fractal-framework/fractal-contracts/deployments/sepolia/DecentHats.json' assert { type: 'json ' };
import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/sepolia/ERC20Claim.json' assert { type: 'json' };
import ERC20FreezeVoting from '@fractal-framework/fractal-contracts/deployments/sepolia/ERC20FreezeVoting.json' assert { type: 'json' };
import ERC721FreezeVoting from '@fractal-framework/fractal-contracts/deployments/sepolia/ERC721FreezeVoting.json' assert { type: 'json' };
Expand Down Expand Up @@ -74,6 +75,11 @@ const sepoliaConfig: NetworkConfig = {
})?.networkAddresses[sepolia.id.toString()]!,
votesERC20WrapperMasterCopy: VotesERC20Wrapper.address,
keyValuePairs: KeyValuePairs.address,
decentHatsMasterCopy: DecentHats.address,
hatsProtocol: '0x3bc1A0Ad72417f2d411118085256fC53CBdDd137',
},
constants: {
ha75Address: '0x0000000000000000000000000000000000004a75',
},
staking: {},
createOptions: [
Expand Down
5 changes: 5 additions & 0 deletions src/types/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export type NetworkConfig = {
erc721FreezeVotingMasterCopy: string;
votesERC20WrapperMasterCopy: string;
keyValuePairs: string;
decentHatsMasterCopy: string;
hatsProtocol: string;
};
constants: {
ha75Address: string;
};
staking: {
lido?: {
Expand Down

0 comments on commit b2de6ea

Please sign in to comment.