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: handle arbitrary transaction motion #304

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
1 change: 0 additions & 1 deletion src/handlers/actions/makeArbitraryTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default async (event: ContractEvent): Promise<void> => {
await writeActionFromEvent(event, colonyAddress, {
type: ColonyActionType.MakeArbitraryTransaction,
initiatorAddress: receipt.from,
recipientAddress: receipt.to,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean now, it makes sense to remove this as it would always point to the colony rather than the target contract address of the arbitrary transaction.

fromDomainId: getDomainDatabaseId(colonyAddress, Id.RootDomain),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we actually need this as it is only possible to create arbitrary transactions in the root domain, although looking at some of the other actions we use this fromDomainId even if can only be created in the root domain so maybe it is still required.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, there's no concept of domain when it comes to arbitrary transactions. I would opt for removing this to avoid confusion.

arbitraryTransactions: [currentArbitraryTransaction],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,25 @@ export const handleMakeArbitraryTransactionsMotion = async (
event: ContractEvent,
parsedAction: TransactionDescription,
): Promise<void> => {
const { name, args: actionArgs } = parsedAction;
const [recipients] = actionArgs;
const { name } = parsedAction;

const { _targets: contractAddresses, _actions: encodedFunctions } =
parsedAction.args;

const currentArbitraryTransactions = await Promise.all(
contractAddresses.map(async (contractAddress: string, index: number) => {
const currentEncodedFunction = encodedFunctions[index];

return {
contractAddress,
encodedFunction: currentEncodedFunction,
};
}),
);

await createMotionInDB(colonyAddress, event, {
type: motionNameMapping[name],
recipientAddress: recipients[0],
fromDomainId: getDomainDatabaseId(colonyAddress, Id.RootDomain),
arbitraryTransactions: currentArbitraryTransactions,
});
};