From eccda3f568a6b7083340e152a4b9f3f984448adf Mon Sep 17 00:00:00 2001 From: Brenzee Date: Mon, 30 Oct 2023 15:56:53 +0200 Subject: [PATCH] getRequiredActionsFromSignature function --- src/requiredActions/getRequiredActions.ts | 31 ++++++++++++++++++++++- src/requiredActions/requiredAction.ts | 4 +-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/requiredActions/getRequiredActions.ts b/src/requiredActions/getRequiredActions.ts index 577a939..aaca898 100644 --- a/src/requiredActions/getRequiredActions.ts +++ b/src/requiredActions/getRequiredActions.ts @@ -15,7 +15,7 @@ export async function getRequiredActions({ call: IPluginCall; chainId: ChainId; }) { - const requiredActionsData = AllRequiredActions.find((data) => data[0] === pluginId); + const requiredActionsData = AllRequiredActions.find((data) => data[0].id === pluginId); if (!requiredActionsData) return []; const requiredActions = requiredActionsData[1]; @@ -30,3 +30,32 @@ export async function getRequiredActions({ vaultAddress: call.from, }); } + +export async function getRequiredActionsFromSignature({ + signature, + provider, + chainId, + call, +}: { + provider: ethers.providers.Provider; + signature: string; + chainId: ChainId; + call: IPluginCall; +}) { + const requiredActionsData = AllRequiredActions.find( + (data) => data[0].functionSignatureHash.toLowerCase() === signature.toLowerCase() + ); + + if (!requiredActionsData) return []; + const requiredActions = requiredActionsData[1]; + + const input = parseParams(call.params); + + return await requiredActions({ + input, + chainId, + contractAddress: signature, + provider, + vaultAddress: call.from, + }); +} diff --git a/src/requiredActions/requiredAction.ts b/src/requiredActions/requiredAction.ts index aeef88e..a28cad1 100644 --- a/src/requiredActions/requiredAction.ts +++ b/src/requiredActions/requiredAction.ts @@ -16,6 +16,6 @@ export function createRequiredActionForPlugin

>({ chainId: ChainId; }) => Promise | RequiredApproval[]; }) { - const pl = new plugin({ chainId: "1", rpcUrl: "none" }); - return [pl.id, requiredActions] as const; + const pl = new plugin({ chainId: "1" }); + return [pl, requiredActions] as const; }