Skip to content

Commit

Permalink
getRequiredActionsFromSignature function
Browse files Browse the repository at this point in the history
  • Loading branch information
Brenzee committed Oct 30, 2023
1 parent 4c8eee4 commit eccda3f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
31 changes: 30 additions & 1 deletion src/requiredActions/getRequiredActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function getRequiredActions<I extends string>({
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];
Expand All @@ -30,3 +30,32 @@ export async function getRequiredActions<I extends string>({
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,
});
}
4 changes: 2 additions & 2 deletions src/requiredActions/requiredAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export function createRequiredActionForPlugin<P extends Plugin<any, string>>({
chainId: ChainId;
}) => Promise<RequiredApproval[]> | 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;
}

0 comments on commit eccda3f

Please sign in to comment.