I use Typechain to generate TS bindings for my Ethereum smart contracts. I'm looking to import a binding into my Autotask to call a function like:
import { Contract__factory } from "../bindings"
export async function handler(event: AutotaskEvent & RelayerParams) {
const contract = Contract__factory("0x123...456", signer)
const result = await contract.someFunction()
}
In the uploaded JS, it looks like this:
const bindings_1 = require("../bindings");
function handler(event) {
return __awaiter(this, void 0, void 0, function* () {
const contract = bindings_1.Contract__factory.connect("0x123...456", signer);
const result = yield contract.someFunction();
});
}
exports.handler = handler;
Will the ../bindings
file be uploaded and its Contract__factory
understood by the Autotask runtime?
I'd like to avoid the new ethers.Contract(...)
convention where functions are of type any
:
import { ethers } from "ethers"
export async function handler(event: AutotaskEvent & RelayerParams) {
const contract = new ethers.Contract("0x123...456", [...], signer)
// someFunction is of type any
const result = await contract.someFunction()
}