-
Notifications
You must be signed in to change notification settings - Fork 1
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
[DO NOT MERGE - Iceboxed] Add Iframe and Summary card for the KYC #127
Conversation
✅ Deploy Preview for pendulum-pay ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
src/pages/progress/index.tsx
Outdated
@@ -49,6 +52,7 @@ export const ProgressPage: FC<ProgressPageProps> = ({ setOfframpingPhase, offram | |||
|
|||
const main = ( | |||
<main> | |||
<SigningBox step={signingPhase} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signing now happens in the process page, as it would otherwise not be visible given the iframe screen has already popped up.
@pendulum-chain/devs and @pendulum-chain/product I think this is ready for review and final adjustments. Once the UI is fine I'll remove the commented part used for mocking. |
EDIT: Nevermind, I understand what you mean. I didn't test it since I cannot make an offramp anyway, but I can reach the error you also see. I'm a bit confused @ebma since I can see it always working |
src/components/Iframe/index.tsx
Outdated
}) => { | ||
const [cachedSrc, setCachedSrc] = useState<string | null>(null); | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove the whole cachedSrc logic. We are not using it anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, the idea was to save the kyc url since it was being reset, but since the iframe loads only once, we can remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separated. Also added reusable inner cards.
src/components/Iframe/index.tsx
Outdated
setCachedSrc(src); | ||
} | ||
}, [src, cachedSrc]); | ||
let main = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const main
src/components/Iframe/index.tsx
Outdated
<div className="flex justify-center items-center relative w-full h-[50vh] md:w-[535px] "> | ||
<iframe | ||
src={src} | ||
style={{ border: 'none' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we just use border-0
class?
src/components/Iframe/index.tsx
Outdated
@@ -0,0 +1,51 @@ | |||
import React, { useState, useEffect } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use preact not react, please import preact/compat
src/components/SummaryCard/index.tsx
Outdated
|
||
return ( | ||
|
||
<div className="bg-white p-4 rounded-lg shadow-lg w-full"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is quite big component, wdyt about breaking it down into smaller parts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I wanted to get first some feedback on the alignment with the requirements but I agree it needs breaking down for readability.
src/pages/swap/index.tsx
Outdated
@@ -36,6 +37,7 @@ export const SwapPage = () => { | |||
const [isQuoteSubmitted, setIsQuoteSubmitted] = useState(false); | |||
const formRef = useRef<HTMLDivElement | null>(null); | |||
const [api, setApi] = useState<ApiPromise | null>(null); | |||
const [isIframVisible, setIframVisible] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is unused
@pendulum-chain/devs now we need to wait for Mykobo to implement the cookies fix in production and we can test this with a full offramp. UPDATE: this has been unblocked. |
…n the iframe is already open
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added minor changes to improve the styling.
And I added code to prevent the content in the summary card to fluctuate. Because I noticed that the quote changed during the time I had the iframe open (over the course of a couple minutes). Let me know what you think.
Besides that, it looks good to me 👍 can confirm the iframe works, and it also recovers properly when the user enters a wrong amount on Mykobo's UI. In that case the toast error is thrown and when the user clicks on the 'Start offramping' button again, a fresh URL is shown in the iframe and the user can continue without the 403 error.
I think this is good to go once the mock changes are reverted.
<span className="text-md md:text-xl font-medium text-blue-800">{amount}</span> | ||
<div className="flex items-center mr-2"> | ||
<img src={icon} className="w-4 md:w-6 h-4 md:h-6" /> | ||
<span className="ml-1 text-blue-800">{symbol}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use everywhere text-blue-700
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid such confusion I think we should make a class like
vortex-text-blue {
@apply .text-blue-700
}
@ebma thanks for the improvements. I never thought about the live price change, that would have been very confusing. I will remove the commented guards. @vadaynujra It looks like it is related. What browser are you using? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested and it worked well. Great job.
My main remark is about the size of the iframe. I personally don't like that I need to scroll a small box. I didn't test on mobile but can imagine that I would like it even less there.
Another important point is that the SigningBox
it not shown anymore when the user signs the Polygon transactions. However, instead of moving the signing box to the IframeComponent
, I think it now makes sense to already move to progress screen immediately when SEP 24 is completed and move the SigningBox
to the progress screen as well (otherwise I find it slightly confusing UX that after finishing SEP24 I am still shown the iframe for quite some time).
@@ -125,7 +125,7 @@ export interface ExecutionContext { | |||
setSigningPhase: (n: SigningPhase) => void; | |||
} | |||
|
|||
const OFFRAMPING_STATE_LOCAL_STORAGE_KEY = 'offrampingState'; | |||
export const OFFRAMPING_STATE_LOCAL_STORAGE_KEY = 'offrampingState'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this exported now? It is not used outside this file.
if (config.test.mockSep24) { | ||
return { url: 'https://www.example.com', id: '1234' }; | ||
} | ||
// if (config.test.mockSep24) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove, not comment out.
@@ -227,11 +227,13 @@ export async function sep24Second( | |||
const { sep24Url } = tomlValues; | |||
|
|||
if (config.test.mockSep24) { | |||
// sleep 15 seconds, mock user completion of KYC | |||
await new Promise((resolve) => setTimeout(resolve, 150000)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually 150 seconds, not 15 seconds.
return { | ||
amount: sessionParams.offrampAmount, | ||
memo: 'MYK1722323689', | ||
memoType: 'text', | ||
offrampingAccount: (await fetchSigningServiceAccountId()).stellar.public, | ||
offrampingAccount: 'GSAPDFASJFPASFOKNASOFKNAS', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? The previous setting is better in my opinion as it sends the funds back to the funding account I use locally.
pending={isInitiating || offrampingStarted || offrampingState !== undefined} | ||
/> | ||
)} | ||
<SwapSubmitButton |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a breaking change here. The button text has been changed in the mean time, can you please change accordingly?
(also the logic for the pending
state)
@@ -25,6 +25,7 @@ import { SuccessPage } from '../success'; | |||
import { FailurePage } from '../failure'; | |||
import { useInputTokenBalance } from '../../hooks/useInputTokenBalance'; | |||
import { UserBalance } from '../../components/UserBalance'; | |||
import { IframeComponent, IframeProps } from '../../components/Iframe'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IframeProps
import not used.
<h2 className="text-md mb-4 mt-4">{subtitle}</h2> | ||
</div> | ||
</div> | ||
<div className="flex justify-center items-center relative w-full h-[50vh] md:w-[535px] "> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember that we discussed once that we want to reduce double scroll and the that the design solution was to prevent scrolling of the outer screen by making the iframe always fit into the screen (i.e., scrolling only happens within the iframe).
We then discussed the other option: make the iframe large enough that it will not scroll and only the outer screen is scrolling.
I actually remember that we decided to use that latter option, am I wrong (I don't find notes about this).
Same for the width of the iframe: it feels right now like looking through a peephole and I don't think that this is such a good UX.
|
||
const receiveAmount = calculateTotalReceive(toAmount.toString(), OUTPUT_TOKEN_CONFIG[assetOut]); | ||
|
||
const approximateExchangeRate = roundDownToSignificantDecimals(toAmount.div(fromAmount), 2).toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to also use 4 decimals as on the details box on the main page? E.g., reuse the ExchangeRate
component.
|
||
const receiveAmount = calculateTotalReceive(toAmount.toString(), OUTPUT_TOKEN_CONFIG[assetOut]); | ||
|
||
const approximateExchangeRate = roundDownToSignificantDecimals(toAmount.div(fromAmount), 2).toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use toFixed(2, 0)
instead of toString()
for every number stringification of amounts in this component. (see #171)
<LowerSummaryCard | ||
label="Offramp fees" | ||
amount={offrampFees} | ||
startIcon={<LocalGasStationIcon className="text-blue-700" fontSize="small" />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I argue that we should remove the gas station icon: #102 (comment)
@gianfra-t I used Google Chrome |
@TorstenStueber I will address your comments but regarding this one:
I agree and in fact the solution is quite quick, we just need to delete this condition, the includes one. That said, what was the rationale behind signing on the main screen (even before the iframe)? Because if it is such that the user sees the values when it is signing, then we should stay here (and potentially remove the Iframe and show a message). |
Yes, good question. I don't know what the reasoning was. @prayagd @vadaynujra can you give the reasoning? (I guess it was because of the numbers, as you said. Would it not make sense to show your |
What shall we do with this PR? Close it? |
I changed the title but we can also close it, we can always reopen it. |
I would also suggest to just close it instead of keeping it open with the warning in the title. |
@gianfra-t before closing it, can you leave a comment with a brief summary that explains why we cannot proceed with this change? Namely pointing out the restrictions with the browser settings that interferes with the cookies in the iframe etc. |
@gianfra-t let's close this PR? We can still reopen later if we want to go back to the iframe. |
Closing this. We could later use the UI perhaps. Just to recap, the reason this didn't work is because the anchor (Mykobo) is using cookies for CSRF protection, and these are being blocked when using the |
Available to test UI as offramp is mocked.
Issue #102. Any amount will work and launch the iframe page, which will complete after some seconds mocking the user finishing the process.
Changes
sep24process
is completed (response from anchor).