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/3537 arbitrary via multi sig #3979

Merged
merged 3 commits into from
Jan 13, 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
2 changes: 1 addition & 1 deletion docker/colony-cdapp-dev-env-block-ingestor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM colony-cdapp-dev-env/base:latest

ENV BLOCK_INGESTOR_HASH=de081f29d5e9f842c218841f4cdf06df5177ceaa
ENV BLOCK_INGESTOR_HASH=47c65c58a82579d2ffed12dd9850b88e2b033af7

# Declare volumes to set up metadata
VOLUME [ "/colonyCDapp/amplify/mock-data" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useColonyContext } from '~context/ColonyContext/ColonyContext.ts';
import { ActionTypes } from '~redux/index.ts';
import { DecisionMethod } from '~types/actions.ts';
import { mapPayload } from '~utils/actions.ts';
import { extractColonyRoles } from '~utils/colonyRoles.ts';
import { extractColonyDomains } from '~utils/domains.ts';
import { sanitizeHTML } from '~utils/strings.ts';
import { DECISION_METHOD_FIELD_NAME } from '~v5/common/ActionSidebar/consts.ts';
Expand Down Expand Up @@ -49,10 +50,15 @@ export const useCreateArbitraryTxs = (
colonyAddress,
};

if (payload.decisionMethod === DecisionMethod.Reputation) {
if (
payload.decisionMethod === DecisionMethod.Reputation ||
payload.decisionMethod === DecisionMethod.MultiSig
) {
return {
...commonPayload,
colonyRoles: extractColonyRoles(colony.roles),
colonyDomains: extractColonyDomains(colony.domains),
isMultiSig: payload.decisionMethod === DecisionMethod.MultiSig,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const CompletedAction = ({ action }: CompletedActionProps) => {
return <EditColonyDetails action={action} />;
case ColonyActionType.MakeArbitraryTransaction:
case ColonyActionType.MakeArbitraryTransactionsMotion:
case ColonyActionType.MakeArbitraryTransactionsMultisig:
return <ArbitraryTransaction action={action} />;
/**
* @deprecated
Expand Down
37 changes: 36 additions & 1 deletion src/redux/sagas/motions/arbitraryTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BigNumber, utils } from 'ethers';
import { Interface } from 'ethers/lib/utils';
import { call, fork, put, takeEvery } from 'redux-saga/effects';

import { PERMISSIONS_NEEDED_FOR_ACTION } from '~constants/actions.ts';
import { type ColonyManager } from '~context/index.ts';
import { ActionTypes } from '~redux/actionTypes.ts';
import { type AllActions, type Action } from '~redux/types/actions/index.ts';
Expand All @@ -22,6 +23,7 @@ import {
uploadAnnotation,
initiateTransaction,
createActionMetadataInDB,
getPermissionProofsLocal,
getChildIndexLocal,
} from '../utils/index.ts';

Expand All @@ -30,8 +32,10 @@ function* arbitraryTxMotion({
colonyAddress,
annotationMessage,
customActionTitle,
colonyRoles,
colonyDomains,
transactions,
isMultiSig = false,
},
meta: { id: metaId, setTxHash },
meta,
Expand All @@ -51,12 +55,13 @@ function* arbitraryTxMotion({
contractAddresses.push(contractAddress);
methodsBytes.push(encodedFunction);
});

const colonyClient = yield colonyManager.getClient(
ClientType.ColonyClient,
colonyAddress,
);

const userAddress = yield colonyClient.signer.getAddress();

const encodedAction = colonyClient.interface.encodeFunctionData(
'makeArbitraryTransactions',
[contractAddresses, methodsBytes, true],
Expand All @@ -75,6 +80,36 @@ function* arbitraryTxMotion({

// eslint-disable-next-line no-inner-declarations
function* getCreateMotionParams() {
if (isMultiSig) {
const [, childSkillIndex] = yield call(getPermissionProofsLocal, {
networkClient: colonyClient.networkClient,
colonyRoles,
colonyDomains,
requiredDomainId: Id.RootDomain,
requiredColonyRoles: PERMISSIONS_NEEDED_FOR_ACTION.ArbitraryTxs,
permissionAddress: userAddress,
isMultiSig: true,
});

return {
context: ClientType.MultisigPermissionsClient,
methodName: 'createMotion',
identifier: colonyAddress,
params: [
Id.RootDomain,
childSkillIndex,
[AddressZero],
[encodedAction],
],
group: {
key: batchKey,
id: metaId,
index: 0,
},
ready: false,
};
}

const rootDomain = colonyDomains.find((domain) =>
BigNumber.from(domain.nativeId).eq(Id.RootDomain),
);
Expand Down
1 change: 1 addition & 0 deletions src/redux/types/actions/motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ export type MotionActionTypes =
colonyDomains: Domain[];
colonyRoles: ColonyRoleFragment[];
annotationMessage?: string;
isMultiSig?: boolean;
transactions: AddTransactionTableModel[];
},
MetaWithSetter<object>
Expand Down
3 changes: 3 additions & 0 deletions src/utils/multiSig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export const getRolesNeededForMultiSigAction = ({
case ColonyActionType.FundExpenditureMultisig:
permissions = PERMISSIONS_NEEDED_FOR_ACTION.TransferFunds;
break;
case ColonyActionType.MakeArbitraryTransactionsMultisig:
permissions = PERMISSIONS_NEEDED_FOR_ACTION.ArbitraryTxs;
break;
default:
permissions = undefined;
break;
Expand Down
Loading