mirror of
https://github.com/Instadapp/dsa-connectors-2.0.git
synced 2024-07-29 21:57:39 +00:00
18 lines
584 B
TypeScript
18 lines
584 B
TypeScript
import { web3 } from "hardhat";
|
|
import { abis } from "../constant/abis";
|
|
|
|
export function encodeSpells(spells: any[]) {
|
|
const targets = spells.map((a) => a.connector);
|
|
const calldatas = spells.map((a) => {
|
|
const functionName = a.method;
|
|
// console.log(functionName)
|
|
const abi = abis.connectors[a.connector].find((b: { name: any }) => {
|
|
return b.name === functionName;
|
|
});
|
|
// console.log(functionName)
|
|
if (!abi) throw new Error("Couldn't find function");
|
|
return web3.eth.abi.encodeFunctionCall(abi, a.args);
|
|
});
|
|
return [targets, calldatas];
|
|
}
|