dsa-connectors/scripts/tests/encodeSpells.ts

18 lines
584 B
TypeScript
Raw Normal View History

2021-12-05 05:23:21 +00:00
import { web3 } from "hardhat";
2021-12-10 19:44:04 +00:00
import { abis } from "../constant/abis";
2021-12-05 05:23:21 +00:00
2021-12-05 19:10:22 +00:00
export function encodeSpells(spells: any[]) {
2021-12-05 05:23:21 +00:00
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];
2021-12-05 19:10:22 +00:00
}