Skip to content

update roles to lowercase #3790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/builder/src/actions/grantsMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ export const transformAndDispatchProject =
};

// todo: should we lowercase the owner addresses?
console.log("project.projectRoles", project.projectRoles);
const ownerAddresses: string[] = project.projectRoles
.filter((role: AddressAndRole) => role.role === "OWNER")
.filter((role: AddressAndRole) => role.role === "owner")
.map((role) => ethers.utils.getAddress(role.address));

dispatch(projectOwnersLoaded(id, ownerAddresses));
Expand Down
2 changes: 1 addition & 1 deletion packages/data-layer/src/data-layer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const mockProjects: v2Project[] = [
projectRoles: [
{
address: "0xe849b2a694184b8739a04c915518330757cdb18b",
role: "OWNER",
role: "owner",
createdAtBlock: "5146499",
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export default function ViewProject() {
const poolId = directAllocationPoolId.toString();

const recipient = project?.projectRoles?.filter(
(role) => role.role === "OWNER"
(role) => role.role === "owner"
)[0].address;

const nonce = project?.nonce;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe("listPrograms", () => {
// createdByAddress: expectedProgram.operatorWallets[0],
// };
// const expectedPrograms: Program[] = [expectedProgram];

// const actualPrograms = await listPrograms("0x0", 1, {
// getProgramsByUser: jest.fn().mockResolvedValue({
// programs: [
Expand All @@ -48,7 +47,6 @@ describe("listPrograms", () => {
// ],
// }),
// } as unknown as DataLayer);

// expect(actualPrograms).toEqual(expectedPrograms);
// });
});
Expand All @@ -70,7 +68,7 @@ describe("getProgramById", () => {
roles: [
{
address: expectedProgram.operatorWallets[0],
role: "OWNER",
role: "owner",
createdAtBlock: "0",
},
],
Expand Down
21 changes: 11 additions & 10 deletions packages/round-manager/src/features/program/ViewManageProgram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { PlusIcon } from "@heroicons/react/solid";

const sortDataByRole = (data: AddressAndRole[]): AddressAndRole[] => {
return data.sort((a, b) => {
if (a.role === "OWNER") return -1;
if (b.role === "OWNER") return 1;
if (a.role === "owner") return -1;
if (b.role === "owner") return 1;
return a.role.localeCompare(b.role);
});
};
Expand All @@ -35,8 +35,8 @@ const filterRoles = (data: AddressAndRole[]): AddressAndRole[] => {
// If not included, simply add the current item
acc.push(current);
} else if (
acc[existingIndex].role !== "OWNER" &&
current.role === "OWNER"
acc[existingIndex].role !== "owner" &&
current.role === "owner"
) {
// If the existing item is not an Owner but the current is, replace it
acc[existingIndex] = current;
Expand Down Expand Up @@ -64,7 +64,7 @@ export function ViewManageProgram(props: {
const isOwner = props.program?.roles?.some(
(role) =>
role.address.toLowerCase() === props.userAddress.toLowerCase() &&
role.role === "OWNER"
role.role === "owner"
);

// Show Owner role first, then Operator
Expand All @@ -84,7 +84,7 @@ export function ViewManageProgram(props: {
name: "Updating",
description: `Updating the team members for the profile`,
status: contractUpdatingStatus,
}
},
];

const handleUpdateTeam = async () => {
Expand Down Expand Up @@ -192,9 +192,9 @@ export function ViewManageProgram(props: {
<tr key={index}>
<AddressRow address={item.address} />
<td className="w-1/4 px-6 py-4 whitespace-nowrap text-sm text-gray-400">
{item.role === "OWNER" ? "Owner" : "Member"}
{item.role === "owner" ? "Owner" : "Member"}
</td>
{isOwner && item.role !== "OWNER" ? (
{isOwner && item.role !== "owner" ? (
<td>
<XIcon
className="text-red-100 w-6 cursor-pointer"
Expand All @@ -205,8 +205,9 @@ export function ViewManageProgram(props: {
}}
/>
</td>
) :
<td className="bg-white"></td>}
) : (
<td className="bg-white"></td>
)}
</tr>
))}
</tbody>
Expand Down
15 changes: 7 additions & 8 deletions packages/round-manager/src/features/round/ViewManageTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { PlusIcon } from "@heroicons/react/solid";

const sortDataByRole = (data: AddressAndRole[]): AddressAndRole[] => {
return data.sort((a, b) => {
if (a.role === "ADMIN") return -1;
if (b.role === "ADMIN") return 1;
if (a.role === "admin") return -1;
if (b.role === "admin") return 1;
return a.role.localeCompare(b.role);
});
};
Expand All @@ -36,8 +36,8 @@ const filterRoles = (data: AddressAndRole[]): AddressAndRole[] => {
// If not included, simply add the current item
acc.push(current);
} else if (
acc[existingIndex].role !== "ADMIN" &&
current.role === "ADMIN"
acc[existingIndex].role !== "admin" &&
current.role === "admin"
) {
// If the existing item is not an Admin but the current is, replace it
acc[existingIndex] = current;
Expand Down Expand Up @@ -75,7 +75,7 @@ export default function ViewManageTeam(props: {
const isAdmin = props.round?.roles?.some(
(role) =>
role.address.toLowerCase() === props.userAddress.toLowerCase() &&
role.role === "ADMIN"
role.role === "admin"
);

// Show Admin role first, then Operator
Expand All @@ -90,7 +90,6 @@ export default function ViewManageTeam(props: {

const isTeamMembersLoading = indexingStatus == ProgressStatus.IN_PROGRESS;


const progressSteps: ProgressStep[] = [
{
name: "Updating",
Expand Down Expand Up @@ -257,9 +256,9 @@ export default function ViewManageTeam(props: {
<tr key={index}>
<AddressRow address={item.address} />
<td className="w-1/4 px-6 py-4 whitespace-nowrap text-sm text-gray-400">
{item.role === "ADMIN" ? "Admin" : "Operator"}
{item.role === "admin" ? "Admin" : "Operator"}
</td>
{editMode && item.role !== "ADMIN" && (
{editMode && item.role !== "admin" && (
<td>
<XIcon
className="text-red-100 w-6 cursor-pointer"
Expand Down
12 changes: 7 additions & 5 deletions packages/round-manager/src/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const makeProgramData = (overrides: Partial<Program> = {}): Program => ({
roles: [
{
address: mockedOperatorWallet,
role: "OWNER",
role: "owner",
createdAtBlock: "0",
},
],
Expand All @@ -72,7 +72,8 @@ export const makeRoundData = (overrides: Partial<Round> = {}): Round => {
const protocolFeePercentage = 10000;
return {
id: faker.finance.ethereumAddress(),
strategyName: "allov2.DonationVotingMerkleDistributionDirectTransferStrategy",
strategyName:
"allov2.DonationVotingMerkleDistributionDirectTransferStrategy",
chainId: 1,
roundMetadata: {
name: faker.company.name(),
Expand Down Expand Up @@ -113,7 +114,7 @@ export const makeRoundData = (overrides: Partial<Round> = {}): Round => {
roles: [
{
address: mockedOperatorWallet,
role: "OWNER",
role: "owner",
createdAtBlock: "0",
},
],
Expand All @@ -140,7 +141,8 @@ export const makeDirectGrantRoundData = (
const protocolFeePercentage = 10000;
return {
id: faker.finance.ethereumAddress(),
strategyName: "allov2.DonationVotingMerkleDistributionDirectTransferStrategy",
strategyName:
"allov2.DonationVotingMerkleDistributionDirectTransferStrategy",
chainId: 1,
roundMetadata: {
name: faker.company.name(),
Expand Down Expand Up @@ -181,7 +183,7 @@ export const makeDirectGrantRoundData = (
roles: [
{
address: mockedOperatorWallet,
role: "OWNER",
role: "owner",
createdAtBlock: "0",
},
],
Expand Down