Skip to content

Commit

Permalink
added script to update chainlink functions source code
Browse files Browse the repository at this point in the history
  • Loading branch information
yashgo0018 committed Dec 16, 2023
1 parent b1defad commit 5ba0335
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions scripts/updateFunctionsSourceCode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { viem } from "hardhat";
import fs from "fs";

const fundManagerAddress = "0xf13887480011b84cb6f80474562ba786c5f29a5e";

async function main() {
const fundManager = await viem.getContractAt(
"FundManager",
fundManagerAddress
);

const fetchPastPricesFunctionSourceCode = fs.readFileSync(
"./chainlinkFunctions/fetchPastPrices.js"
);

await fundManager.write.setPriceFetchSourceCode([
fetchPastPricesFunctionSourceCode.toString("utf-8"),
]);

const scheduleOptimizationFunctionSourceCode = fs.readFileSync(
"./chainlinkFunctions/scheduleOptimization.js"
);

await fundManager.write.setScheduleOptimizationSourceCode([
scheduleOptimizationFunctionSourceCode.toString("utf-8"),
]);

const fetchResultFunctionSourceCode = fs.readFileSync(
"./chainlinkFunctions/fetchResult.js"
);

await fundManager.write.setResultFetchSourceCode([
fetchResultFunctionSourceCode.toString("utf-8"),
]);
}

main().catch((err) => {
console.error(err);
process.exitCode = 1;
});

0 comments on commit 5ba0335

Please sign in to comment.