-
Notifications
You must be signed in to change notification settings - Fork 45
feat(docs): add support for hardhat FTSO guide and fix FTSO interfaces #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dineshpinto
merged 21 commits into
flare-foundation:main
from
0xreflexivity:hardhat-ftso
Apr 24, 2025
Merged
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3cac60b
feat(docs): add support for hardhat FTSO guide and fix FTSO interfaces
0xreflexivity fe0e02e
fix: lint issues
swarna1101 3ff7cfc
add: codeQL check
swarna1101 344634b
fix: v2->v3
swarna1101 435dcc3
fix: codeql script
swarna1101 f092a01
fix: remove the codeQL POC
swarna1101 896a9df
fix(docs): change desc. and hardhat link
0xreflexivity 4ab621e
Merge branch 'hardhat-ftso' of https://github.com/AmadiaFlare/develop…
0xreflexivity cf3659f
Merge branch 'main' into fork/AmadiaFlare/hardhat-ftso
swarna1101 25a0e91
fix: minor change
swarna1101 a1c0eac
Merge branch 'flare-foundation:main' into hardhat-ftso
0xreflexivity d77c7d9
fix(docs): ftso hardhat contract, deploy script, and tests
0xreflexivity 1367cd8
fix(docs): lint inside js directory
0xreflexivity 250cb7e
fix: minor formatting
swarna1101 6365d97
fix(docs): change contract License to MIT
0xreflexivity 139b69b
Merge branch 'hardhat-ftso' of https://github.com/AmadiaFlare/develop…
0xreflexivity 2e31758
fix(docs): clean up
0xreflexivity bc8b44c
fix(docs): clean up
0xreflexivity 8496019
Merge branch 'flare-foundation:main' into hardhat-ftso
0xreflexivity 3481166
feat(doc): match new FTSO script in hardhat-starter
0xreflexivity a78f522
fix(docs): name change
0xreflexivity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
examples/developer-hub-javascript/FTSOV2FeedConsumer_hardhat.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { artifacts, ethers } from "hardhat"; | ||
| import { expect } from "chai"; | ||
| import { deployFlareContractRegistry } from "../lib/utils"; | ||
0xreflexivity marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const FtsoV2FeedConsumer = artifacts.require("FtsoV2FeedConsumer"); | ||
|
|
||
| describe("FtsoV2FeedConsumer", () => { | ||
| let ftsoConsumer; | ||
| const mockFtsoV2Address = "0x1234567890123456789012345678901234567890"; | ||
| const mockFeeCalcAddress = "0x2345678901234567890123456789012345678901"; | ||
| const mockFlrUsdId = "0x0123456789012345678901234567890123456789012345"; | ||
0xreflexivity marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| beforeEach(async () => { | ||
| // Deploy mock Flare Contract Registry | ||
| await deployFlareContractRegistry(); | ||
|
|
||
| // Deploy the FtsoV2FeedConsumer contract | ||
| ftsoConsumer = await FtsoV2FeedConsumer.new( | ||
| mockFtsoV2Address, | ||
| mockFeeCalcAddress, | ||
| mockFlrUsdId, | ||
| ); | ||
| }); | ||
|
|
||
| describe("Constructor", () => { | ||
| it("should set the initial values correctly", async () => { | ||
| const storedFlrUsdId = await ftsoConsumer.flrUsdId(); | ||
| expect(storedFlrUsdId).to.equal(mockFlrUsdId); | ||
|
|
||
| const feedIds = await ftsoConsumer.feedIds(0); | ||
| expect(feedIds).to.equal(mockFlrUsdId); | ||
| }); | ||
| }); | ||
|
|
||
| describe("checkFees", () => { | ||
| it("should update and return the fee", async () => { | ||
| // Since we're using mocks, we'll just verify the function can be called | ||
| const fee = await ftsoConsumer.fee(); | ||
|
|
||
| expect(fee).to.be.a("number"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getFlrUsdPrice", () => { | ||
| it("should revert if fee does not match msg.value", async () => { | ||
| const fee = ethers.parseEther("1.0"); | ||
| await ftsoConsumer.checkFees(); | ||
|
|
||
| await expect(ftsoConsumer.getFlrUsdPrice({ value: fee + 1n })).to.be | ||
| .reverted; | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { artifacts, ethers } from "hardhat"; | ||
| import { FtsoV2FeedConsumerInstance } from "../typechain-types"; | ||
|
|
||
| const FtsoV2FeedConsumer = artifacts.require("FtsoV2FeedConsumer"); | ||
0xreflexivity marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| async function main() { | ||
| const [deployer] = await ethers.getSigners(); | ||
|
|
||
| console.log("Deploying contracts with the account:", deployer.address); | ||
|
|
||
| // Deploy FtsoV2FeedConsumer | ||
| const ftsoConsumer: FtsoV2FeedConsumerInstance = await FtsoV2FeedConsumer.new( | ||
| "0x01464c522f55534400000000000000000000000000", | ||
| ); | ||
| console.log("FtsoV2FeedConsumer deployed to:", ftsoConsumer.address); | ||
|
|
||
| // Test the contract functions | ||
| try { | ||
| // Test getFLRUSDPrice | ||
| const result = await ftsoConsumer.getFlrUsdPrice(); | ||
| console.log("\nFLR/USD Price Data:"); | ||
| console.log("Price:", result[0].toString()); | ||
| console.log("Decimals:", result[1].toString()); | ||
| console.log( | ||
| "Timestamp:", | ||
| new Date(result[2].toNumber() * 1000).toISOString(), | ||
| ); | ||
|
|
||
| // Test checkFees | ||
| const fees = await ftsoConsumer.checkFees(); | ||
| console.log("\nFees:", fees.toString()); | ||
| } catch (error) { | ||
| console.error("Error testing contract:", error); | ||
| } | ||
| } | ||
|
|
||
| main() | ||
| .then(() => process.exit(0)) | ||
| .catch((error) => { | ||
| console.error(error); | ||
| process.exit(1); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.