feat(checkout): read sol_price_usd from payment object (closes #1 widget portion)#5
Open
relayhop wants to merge 2 commits into
Open
feat(checkout): read sol_price_usd from payment object (closes #1 widget portion)#5relayhop wants to merge 2 commits into
relayhop wants to merge 2 commits into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes Cypher-CP0/fluxpay#1 (widget portion). Pairs with Cypher-CP0/fluxpay#2 (backend portion).
Problem
The widget made a second HTTP call to
GET /api/price/solto learn the SOL/USD rate, even though the issue says: Read sol_price_usd from the payment object returned by the backend.Change
src/types.ts: add optionalsol_price_usd?: numberto thePaymentinterface (optional preserves backward compatibility with backends that have not been upgraded yet).src/CheckoutModal.tsx: preferpayment.sol_price_usdonce the polled payment object provides it; fall back to a single/api/price/solGET if the backend has not been upgraded.solPricestate isnullinstead of the hardcoded165, so the widget waits for a real price before showing a SOL amount (renders0 SOLfor the brief instant before the first poll lands rather than a misleading number).Result
sol_price_usd.Tests
Manual:
payment.sol_price_usd, no/api/price/solrequest in network tab./api/price/solexactly once.