Skip to content
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

Add support for networks using WitnetFeeds contract #368

Merged
merged 2 commits into from
Feb 23, 2024

Conversation

Tommytrg
Copy link
Member

@Tommytrg Tommytrg commented Jan 17, 2024

Add support for networks using WitnetFeeds contract

  • Implement the NetworkRouter class that handles all the communication with each network.
  • Listen to the networks using the WitnetPriceRouter with listenLegacyPriceRouter and the new network using WitnetFeeds with listenWitnetPriceFeeds.
  • Update the configuration file. The networks still using the old witnet price router are marked using legacy: true in the network configuration. Also, the file configuration has been updated to include the feed key. This new key consists of a map with the default values of the existing price feeds. According to that, the price feeds deployed using the default configuration have been deleted from the network feeds section. If a feed configuration appears in the network feeds, it will overwrite the default configuration. Now, we get all the available price feeds in a network called the supportedFeeds method.

packages/api/src/types.ts Outdated Show resolved Hide resolved
@Tommytrg Tommytrg marked this pull request as ready for review January 26, 2024 14:22
@Tommytrg Tommytrg force-pushed the feat/price-feed-router branch 9 times, most recently from cdfcc17 to 011d4a9 Compare February 9, 2024 17:05
@Tommytrg Tommytrg changed the base branch from main to 2.0 February 9, 2024 17:07
@Tommytrg Tommytrg force-pushed the feat/price-feed-router branch 2 times, most recently from be286ee to bfc2264 Compare February 22, 2024 15:36
@Tommytrg Tommytrg changed the title Use the new price feed router Add support for networks using WitnetFeeds contract Feb 22, 2024
Add support for networks using [WitnetFeeds contract](https://github.com/witnet/witnet-solidity-bridge/blob/2.0.x/contracts/apps/WitnetFeeds.sol):
- Implement the NetworkRouter class that handles all the communication with each network.
- Listen to the networks using the `WitnetPriceRouter` with `listenLegacyPriceRouter` and the new network using `WitnetFeeds` with `listenWitnetPriceFeeds`.
- Update the configuration file. The networks still using the old witnet price router are marked using `legacy: true` in the network configuration. Also, the file configuration has been updated to include the feed key. This new key consists of a map with the default values of the existing price feeds. According to that, the price feeds deployed using the default configuration have been deleted from the network feeds section. If a feed configuration appears in the network feeds, it will overwrite the default configuration. Now, we get all the available price feeds in a network called the [supportedFeeds](https://github.com/witnet/witnet-solidity-bridge/blob/2.0.x/contracts/interfaces/IFeeds.sol#L8) method.
@Tommytrg Tommytrg force-pushed the feat/price-feed-router branch from bfc2264 to 26dda67 Compare February 22, 2024 16:10
@@ -65,6 +66,7 @@ export class ResultRequestRepository {
async getLastResult (
feedFullName: string
): Promise<ResultRequestDbObjectNormalized | null> {
console.log('inside getLastResult with feedFullname', feedFullName)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this console.log

console.log(`Error in getLastResult: ${feedFullName}`, e)
return null
})
console.log(lastResultRequest)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this console.log


describe('NetworkRouter', () => {
// FIXME: web3 library is not working with jest. It works if use use vitest instead.
it.skip('should fetch network contract', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use vitest

@@ -147,6 +147,8 @@ export default {
this.currentPage = val
},
setCurrentNetwork(options) {
console.log('options', options)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this console.log

@@ -147,6 +147,8 @@ export default {
this.currentPage = val
},
setCurrentNetwork(options) {
console.log('options', options)
console.log('this.$route.params.network', this.$route)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this console.log

@Tommytrg Tommytrg merged commit 4e0e67c into witnet:2.0 Feb 23, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants