Skip to content
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

feat: Proxy colonies M1 #311

Merged
merged 19 commits into from
Jan 24, 2025
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0e1d6f3
Feat: Handle disable proxy colony metadataDelta event
mmioana Dec 23, 2024
fd93b00
feat: get colonyAddress when requesting a proxy colony and the initia…
bassgeta Jan 6, 2025
2cbac4d
Feat: Re-enable deployed proxy colony
mmioana Jan 6, 2025
8996fd3
feat: create proxy colony requested motion
bassgeta Jan 7, 2025
d6eeddd
feat: link action that finalized a motion to the motion and the motio…
bassgeta Jan 10, 2025
86556a8
Feat: Allow addition of proxy colonies with multisig
davecreaser Jan 9, 2025
14e0714
Fix multisig connection to finalization action
davecreaser Jan 15, 2025
d8481a2
feat: handle enabling and disabling of a proxy colony via a motion
rumzledz Jan 9, 2025
5cb9ad8
feat: remove redundant operation parsing
rumzledz Jan 14, 2025
53afa66
feat: add support for enabling and disable proxy colonies via multi-sig
rumzledz Jan 13, 2025
75b53b7
feat: remove redundant operation parsing
rumzledz Jan 14, 2025
4fa7a94
Move targetChainId up to the top level of colonyAction
davecreaser Jan 16, 2025
fd28eee
Fixes after rebase
davecreaser Jan 21, 2025
8776d33
update main workflow to build main chain
bogdan-1337 Jan 22, 2025
ca781fe
cicd: add changes to dockerfile and new proxy build workflow
bogdan-1337 Jan 22, 2025
c11d40d
cicd: update dockerfile build target logic
bogdan-1337 Jan 22, 2025
a3cd46d
cicd: declare build target in final stage
bogdan-1337 Jan 22, 2025
ee3deac
cicd: rename cicd workflows and update ecr repo for qa prod proxy cha…
bogdan-1337 Jan 22, 2025
a927a71
Fix: Align generated.ts
mmioana Jan 22, 2025
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
Next Next commit
Feat: Handle disable proxy colony metadataDelta event
Feat: Handle disable proxy colony metadataDelta event
mmioana committed Jan 22, 2025
commit 0e1d6f38e54f0a49955c0391f584c3b8a6f3ce96
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Id } from '@colony/colony-js';
import {
ColonyActionType,
GetProxyColonyDocument,
GetProxyColonyQuery,
GetProxyColonyQueryVariables,
UpdateProxyColonyDocument,
UpdateProxyColonyMutation,
UpdateProxyColonyMutationVariables,
} from '@joincolony/graphql';
import { ContractEvent } from '@joincolony/blocks';
import {
DisableProxyColonyOperation,
getColonyFromDB,
getDomainDatabaseId,
writeActionFromEvent,
} from '~utils';
import amplifyClient from '~amplifyClient';

export const handleDisableProxyColony = async (
event: ContractEvent,
operation: DisableProxyColonyOperation,
): Promise<void> => {
const { contractAddress: colonyAddress } = event;
const { agent: initiatorAddress } = event.args;

const foreignChainId = operation.payload[0];

const colony = await getColonyFromDB(colonyAddress);
if (!colony) {
return;
}

const proxyColonyId = `${colonyAddress}_${foreignChainId}`;

const item = await amplifyClient.query<
GetProxyColonyQuery,
GetProxyColonyQueryVariables
>(GetProxyColonyDocument, {
id: proxyColonyId,
});

// If the proxy colony is already disabled, we early-return
if (!item?.data?.getProxyColony?.isActive) {
return;
}

await amplifyClient.mutate<
UpdateProxyColonyMutation,
UpdateProxyColonyMutationVariables
>(UpdateProxyColonyDocument, {
input: {
id: proxyColonyId,
isActive: false,
},
});

await writeActionFromEvent(event, colonyAddress, {
type: ColonyActionType.RemoveProxyColony,
initiatorAddress,
multiChainInfo: {
targetChainId: Number(foreignChainId),
completed: true,
},
fromDomainId: getDomainDatabaseId(colonyAddress, Id.RootDomain),
});
};
6 changes: 6 additions & 0 deletions apps/main-chain/src/handlers/metadataDelta/metadataDelta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ContractEvent } from '@joincolony/blocks';
import {
isAddVerifiedMembersOperation,
isDisableProxyColonyOperation,
isManageTokensOperation,
isRemoveVerifiedMembersOperation,
parseMetadataDeltaOperation,
@@ -9,6 +10,7 @@ import { handleAddVerifiedMembers } from './handlers/addVerifiedMembers';
import { handleRemoveVerifiedMembers } from './handlers/removeVerifiedMembers';
import { handleManageTokens } from './handlers/manageTokens';
import { verbose } from '@joincolony/utils';
import { handleDisableProxyColony } from './handlers/disableProxyColony';

export default async (event: ContractEvent): Promise<void> => {
const operationString = event.args.metadata;
@@ -33,5 +35,9 @@ export default async (event: ContractEvent): Promise<void> => {
return;
}

if (isDisableProxyColonyOperation(operation)) {
await handleDisableProxyColony(event, operation);
}

verbose('Unknown operation type: ', operation);
};
9 changes: 8 additions & 1 deletion apps/main-chain/src/utils/metadataDelta/types.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ export enum MetadataDeltaOperationType {
ADD_VERIFIED_MEMBERS = 'ADD_VERIFIED_MEMBERS',
REMOVE_VERIFIED_MEMBERS = 'REMOVE_VERIFIED_MEMBERS',
MANAGE_TOKENS = 'MANAGE_TOKENS',
DISABLE_PROXY_COLONY = 'DISABLE_PROXY_COLONY',
}

export interface AddVerifiedMembersOperation {
@@ -19,7 +20,13 @@ export interface ManageTokensOperation {
payload: string[];
}

export interface DisableProxyColonyOperation {
type: MetadataDeltaOperationType.DISABLE_PROXY_COLONY;
payload: string[];
}

export type MetadataDeltaOperation =
| AddVerifiedMembersOperation
| RemoveVerifiedMembersOperation
| ManageTokensOperation;
| ManageTokensOperation
| DisableProxyColonyOperation;
12 changes: 12 additions & 0 deletions apps/main-chain/src/utils/metadataDelta/utils.ts
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import {
MetadataDeltaOperation,
MetadataDeltaOperationType,
ManageTokensOperation,
DisableProxyColonyOperation,
} from './types';

export const isAddVerifiedMembersOperation = (
@@ -40,6 +41,17 @@ export const isManageTokensOperation = (
);
};

export const isDisableProxyColonyOperation = (
operation: MetadataDeltaOperation,
): operation is DisableProxyColonyOperation => {
return (
operation.type === MetadataDeltaOperationType.DISABLE_PROXY_COLONY &&
operation.payload !== undefined &&
Array.isArray(operation.payload) &&
operation.payload.every((item) => typeof item === 'string')
);
};

const isMetadataDeltaOperation = (
operation: any,
): operation is MetadataDeltaOperation => {
4,891 changes: 3,111 additions & 1,780 deletions packages/graphql/src/generated.ts

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions packages/graphql/src/mutations/proxyColonies.graphql
Original file line number Diff line number Diff line change
@@ -3,3 +3,9 @@ mutation CreateProxyColony($input: CreateProxyColonyInput!) {
id
}
}

mutation UpdateProxyColony($input: UpdateProxyColonyInput!) {
updateProxyColony(input: $input) {
id
}
}
8 changes: 8 additions & 0 deletions packages/graphql/src/queries/proxyColonies.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
query GetProxyColony($id: ID!) {
getProxyColony(id: $id) {
chainId
colonyAddress
id
isActive
}
}