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

[READY] 456 Create UI for BRLa offramp KYC #493

Open
wants to merge 50 commits into
base: staging
Choose a base branch
from

Conversation

Sharqiewicz
Copy link
Member

@Sharqiewicz Sharqiewicz commented Mar 3, 2025

💚 Ready

Implement KYC Form (and additional fields to Swap Form) for BRLA.

Changes:

Updates

  • update react-hook-form

Full KYC

  • create BrlaExtendedForm component to manage logic of showing KYC Form/Loading/Error/Success
  • create brla/KYCForm component for BRLA full KYC form
  • create brla/useKYCForm for handling BrlaExtendedForm logic
  • create VerificationStatus component to handle KYCStatus
  • create useBRLAKYCProcess hook for handling BRLA KYC submit logic
  • create useKYCStatusQuery hook for handling BRLA KYC request logic

Components

  • create BrlaField component for handling Brla-related (react-hook-form) fields/inputs
  • create Field component for handling (react-hook-form) input

Swap

  • create BrlaSwapFields which are injected to the Swap form when BRLA is chosen
  • separate Swap component from the SwapPage
  • create brla/useOfframpSubmission for BRLA Offramp submisssion

@Sharqiewicz Sharqiewicz linked an issue Mar 3, 2025 that may be closed by this pull request
Copy link

netlify bot commented Mar 3, 2025

Deploy Preview for pendulum-pay ready!

Name Link
🔨 Latest commit 168258e
🔍 Latest deploy log https://app.netlify.com/sites/pendulum-pay/deploys/67c86dc08fa2ef0008e1983e
😎 Deploy Preview https://deploy-preview-493--pendulum-pay.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -35,6 +37,7 @@ const TermsAndConditionsContent = ({
className="checkbox checkbox-primary checkbox-sm"
checked={termsChecked}
onChange={() => {
setTermsAccepted(true);
Copy link
Member Author

Choose a reason for hiding this comment

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

?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's better if we don't immediately hide the terms and conditions as soon as the user clicks on the checkbox but keep them visible until they click on the 'Confirm' button. Otherwise they might hastily toggle the checkbox and might wonder what exactly they just toggled and is now gone.

@Sharqiewicz Sharqiewicz requested review from gianfra-t and ebma and removed request for gianfra-t March 4, 2025 13:51
@Sharqiewicz Sharqiewicz changed the title 456 create a UI for brl offramp kyc [READY] 456 Create a UI for BRLa offramp KYC Mar 4, 2025
@Sharqiewicz Sharqiewicz changed the title [READY] 456 Create a UI for BRLa offramp KYC [READY] 456 Create UI for BRLa offramp KYC Mar 4, 2025
@Sharqiewicz Sharqiewicz requested a review from gianfra-t March 4, 2025 13:51
@Sharqiewicz
Copy link
Member Author

@pendulum-chain/devs Ready for review 💚

<PIXKYCForm
feeComparisonRef={feeComparisonRef}
setIsOfframpSummaryDialogVisible={setIsOfframpSummaryDialogVisible}
onSwapConfirm={onSwapConfirm}
Copy link
Contributor

Choose a reason for hiding this comment

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

We're not using onSwapConfirm right? It will directly call const proceedWithOfframp = useOfframpSubmission after the KYC passes.

Copy link
Member

@ebma ebma left a comment

Choose a reason for hiding this comment

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

I skimmed through the code. Most of the changes look reasonable to me. Also the look and feel and animations are really nice, great job with that @Sharqiewicz 👌
I tested this locally a bit and found that we are missing the call to create the subaccount when all the data is filled in on the KYC form. We should add that.

const query = `taxId=${encodeURIComponent(taxId)}`;
const response = await this.sendRequest(endpoint, 'GET', query);
const response = await this.sendRequest('/subaccounts', 'GET', query);
Copy link
Member

Choose a reason for hiding this comment

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

There is no right or wrong here but looking at the other functions we should make sure they are also using the same format. The other functions define the endpoint as an extra const so either we do it on all of them, or remove the extra const endpoint on all of them.

FAILED = 'FAILED',
}

const STATUS_MESSAGES = {
Copy link
Member

Choose a reason for hiding this comment

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

It's a nice idea to already show these messages in portuguese but to me as a user, this is more off-putting than helpful. Because a) I already use the translate function of my browser to translate from English to Portuguese or b) I can understand English well enough and am suddenly seeing content in a different language which would seem to me like a bug.

}),
pixId: Yup.string().when('to', {
is: 'brl',
then: (schema) => schema.required('PIX ID is required when converting to BRL'),
Copy link
Member

Choose a reason for hiding this comment

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

Let's call it 'selling' instead of 'converting'.

Copy link
Member

Choose a reason for hiding this comment

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

Also, I think Brazilian are more familiar with the term 'Pix key' over 'PIX ID' so let's also adjust that.

@@ -24,6 +26,16 @@ const schema = Yup.object<SwapFormValues>().shape({
toAmount: Yup.string().required(),
slippage: Yup.number().nullable().transform(transformNumber),
deadline: Yup.number().nullable().transform(transformNumber),
taxId: Yup.string().when('to', {
is: 'brl',
then: (schema) => schema.required('Tax ID is required when converting to BRL'),
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@@ -35,6 +37,7 @@ const TermsAndConditionsContent = ({
className="checkbox checkbox-primary checkbox-sm"
checked={termsChecked}
onChange={() => {
setTermsAccepted(true);
Copy link
Member

Choose a reason for hiding this comment

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

I think it's better if we don't immediately hide the terms and conditions as soon as the user clicks on the checkbox but keep them visible until they click on the 'Confirm' button. Otherwise they might hastily toggle the checkbox and might wonder what exactly they just toggled and is now gone.


const proceedWithOfframp = useOfframpSubmission(handleError, setIsOfframpSummaryDialogVisible);

const handleFormSubmit = useCallback(
Copy link
Member

Choose a reason for hiding this comment

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

This function is missing a call to the createSubaccount() endpoint of our signer service with the relevant fields. Only then, can we query the KYC status of the user and expect to get a meaningful response.

return false;
},
retry: 3,
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
Copy link
Member

Choose a reason for hiding this comment

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

I think using a constant delay would be fine. Let's choose a delay of 5 seconds and up to 5 retries. I'm not sure how long the BRLA api takes to approve the KYC data but it might take some time.

return;
}
throw new Error('Error while fetching funding account signature');
}
const { evmAddress: brlaEvmAddress } = await response.json();
const brlaOfframpExecution = { ...executionInput, brlaEvmAddress };
setOfframpExecutionInput(brlaOfframpExecution);
//const brlaEvmAddress = '0x7Ba99e99Bc669B3508AFf9CC0A898E869459F877'
Copy link
Member

Choose a reason for hiding this comment

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

Nit: remove comment

resetToDefault();
handleBackClick();
},
[KYCResponseStatus.PENDING]: async () => undefined,
[KYCResponseStatus.PENDING]: async () => {
undefined;
Copy link
Member Author

Choose a reason for hiding this comment

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

?

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.

Create a UI for BRL offramp KYC
3 participants