From e31dd85629c42b7144a4fd19e9f8edd962bf7bb2 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Thu, 12 Dec 2024 20:43:46 +0100 Subject: [PATCH 1/3] feat: handle arbitrary transaction motion --- .../handlers/makeArbitraryTransactions.ts | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts b/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts index ef77cc9dd..78a759916 100644 --- a/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts +++ b/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts @@ -1,7 +1,11 @@ import { TransactionDescription } from 'ethers/lib/utils'; import { Id } from '@colony/colony-js'; import { ContractEvent, motionNameMapping } from '~types'; -import { getDomainDatabaseId } from '~utils'; +import { + argsByTypeToString, + decodeArbitraryFunction, + getDomainDatabaseId, +} from '~utils'; import { createMotionInDB } from '../helpers'; @@ -13,9 +17,39 @@ export const handleMakeArbitraryTransactionsMotion = async ( const { name, args: actionArgs } = parsedAction; const [recipients] = actionArgs; + const { _targets: contractAddresses, _actions: encodedFunctions } = + parsedAction.args; + + const currentArbitraryTransactions = await Promise.all( + contractAddresses.map(async (contractAddress: string, index: number) => { + const currentEncodedFunction = encodedFunctions[index]; + const decodedFunction = await decodeArbitraryFunction( + currentEncodedFunction, + ); + const functionInputs = decodedFunction?.functionFragment.inputs; + const functionArgs = decodedFunction?.args; + + const mappedArgs = functionInputs?.map((item, index) => { + return { + name: item.name, + type: item.type, + value: argsByTypeToString(functionArgs?.[index], item.type), + }; + }); + return { + contractAddress, + method: decodedFunction?.name, + methodSignature: decodedFunction?.signature, + args: mappedArgs, + encodedFunction: currentEncodedFunction, + }; + }), + ); + await createMotionInDB(colonyAddress, event, { type: motionNameMapping[name], recipientAddress: recipients[0], fromDomainId: getDomainDatabaseId(colonyAddress, Id.RootDomain), + arbitraryTransactions: currentArbitraryTransactions, }); }; From c4202e46d3360bdcad62f98849b4975e5038149b Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Mon, 16 Dec 2024 22:19:48 +0100 Subject: [PATCH 2/3] fix: update block ingestor hash --- src/handlers/actions/makeArbitraryTransaction.ts | 1 - .../motionCreated/handlers/makeArbitraryTransactions.ts | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/handlers/actions/makeArbitraryTransaction.ts b/src/handlers/actions/makeArbitraryTransaction.ts index dc4b49d52..056698423 100644 --- a/src/handlers/actions/makeArbitraryTransaction.ts +++ b/src/handlers/actions/makeArbitraryTransaction.ts @@ -52,7 +52,6 @@ export default async (event: ContractEvent): Promise => { await writeActionFromEvent(event, colonyAddress, { type: ColonyActionType.MakeArbitraryTransaction, initiatorAddress: receipt.from, - recipientAddress: receipt.to, fromDomainId: getDomainDatabaseId(colonyAddress, Id.RootDomain), arbitraryTransactions: [currentArbitraryTransaction], }); diff --git a/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts b/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts index 78a759916..7ff319033 100644 --- a/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts +++ b/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts @@ -14,8 +14,7 @@ export const handleMakeArbitraryTransactionsMotion = async ( event: ContractEvent, parsedAction: TransactionDescription, ): Promise => { - const { name, args: actionArgs } = parsedAction; - const [recipients] = actionArgs; + const { name } = parsedAction; const { _targets: contractAddresses, _actions: encodedFunctions } = parsedAction.args; @@ -48,7 +47,6 @@ export const handleMakeArbitraryTransactionsMotion = async ( await createMotionInDB(colonyAddress, event, { type: motionNameMapping[name], - recipientAddress: recipients[0], fromDomainId: getDomainDatabaseId(colonyAddress, Id.RootDomain), arbitraryTransactions: currentArbitraryTransactions, }); From de081f29d5e9f842c218841f4cdf06df5177ceaa Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Thu, 19 Dec 2024 16:17:18 +0100 Subject: [PATCH 3/3] feat: refactor accoring to Jakub's refactoring changes --- .../handlers/makeArbitraryTransactions.ts | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts b/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts index 7ff319033..ec6177ea2 100644 --- a/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts +++ b/src/handlers/motions/motionCreated/handlers/makeArbitraryTransactions.ts @@ -1,11 +1,7 @@ import { TransactionDescription } from 'ethers/lib/utils'; import { Id } from '@colony/colony-js'; import { ContractEvent, motionNameMapping } from '~types'; -import { - argsByTypeToString, - decodeArbitraryFunction, - getDomainDatabaseId, -} from '~utils'; +import { getDomainDatabaseId } from '~utils'; import { createMotionInDB } from '../helpers'; @@ -22,24 +18,9 @@ export const handleMakeArbitraryTransactionsMotion = async ( const currentArbitraryTransactions = await Promise.all( contractAddresses.map(async (contractAddress: string, index: number) => { const currentEncodedFunction = encodedFunctions[index]; - const decodedFunction = await decodeArbitraryFunction( - currentEncodedFunction, - ); - const functionInputs = decodedFunction?.functionFragment.inputs; - const functionArgs = decodedFunction?.args; - const mappedArgs = functionInputs?.map((item, index) => { - return { - name: item.name, - type: item.type, - value: argsByTypeToString(functionArgs?.[index], item.type), - }; - }); return { contractAddress, - method: decodedFunction?.name, - methodSignature: decodedFunction?.signature, - args: mappedArgs, encodedFunction: currentEncodedFunction, }; }),