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

Fix #10010 - Fetch swap quote refresh time from API #10069

Merged
merged 10 commits into from
Dec 15, 2020

Conversation

darkwing
Copy link
Contributor

Supercedes: #10017

Fixes: #10010

The MetaSwap team has implemented a new endpoint which tells us how often quotes should refresh. We were hardcoding 60 seconds as the refresh value, but moving that value to the MetaSwap API would prevent the MetaMask team from needing to create and deploy a new release in each browser to adjust that value.

As to why I've gone this route to accomplish this functionality, I like this strategy because we aren't pinging MetaSwap until we absolutely need to (i.e. when we're fetching quotes to display). We also benefit from fetchWithCache caching that value, so that we aren't pinging MetaSwap each time. @cloudonshore had mentioned this value wouldn't often change, so a fetch with cache only when we need that value should make us performant.

@darkwing darkwing requested a review from a team as a code owner December 14, 2020 19:58
@darkwing darkwing requested a review from danjm December 14, 2020 19:59
@darkwing darkwing changed the title 10010 api refresh time controller Fix #10010 - Fetch swap quote refresh time from API Dec 14, 2020
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@darkwing darkwing requested review from rekmarks and removed request for danjm December 14, 2020 20:00
app/scripts/controllers/swaps.js Outdated Show resolved Hide resolved
app/scripts/controllers/swaps.js Show resolved Hide resolved
ui/app/pages/swaps/swaps.util.js Outdated Show resolved Hide resolved
ui/app/ducks/swaps/swaps.js Outdated Show resolved Hide resolved
app/scripts/controllers/swaps.js Show resolved Hide resolved
ui/app/store/actions.js Outdated Show resolved Hide resolved
@darkwing darkwing force-pushed the 10010-api-refresh-time-controller branch 2 times, most recently from e5f2393 to 9595c93 Compare December 15, 2020 15:40
app/scripts/controllers/swaps.js Outdated Show resolved Hide resolved
ui/app/pages/swaps/swaps.util.js Outdated Show resolved Hide resolved
ui/app/pages/swaps/swaps.util.js Outdated Show resolved Hide resolved
},
}

const sandbox = sinon.createSandbox()
const fetchTradesInfoStub = sandbox.stub()
const fetchSwapsFeatureLivenessStub = sandbox.stub()
const fetchSwapsQuoteRefreshTimeStub = sandbox.stub()
Copy link
Member

Choose a reason for hiding this comment

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

Note that this stub isn't being reset correctly between tests, but we can solve that separately in a later PR. Might as well fix all of these stubs at once, since they all follow the same pattern.

@darkwing darkwing force-pushed the 10010-api-refresh-time-controller branch 2 times, most recently from 03eefe3 to 911f580 Compare December 15, 2020 19:38
Gudahtt
Gudahtt previously approved these changes Dec 15, 2020
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@Gudahtt Gudahtt merged commit 88525ec into MetaMask:develop Dec 15, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch swaps quote refresh time from the API
2 participants