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

Form Integrations & KYC Support #27

Merged
merged 14 commits into from
Dec 9, 2019

Conversation

JakeUrban
Copy link
Contributor

@JakeUrban JakeUrban commented Dec 3, 2019

Docs
Design

@JakeUrban
Copy link
Contributor Author

@msfeldstein hold off on the review -- the KYC design exposed a flaw in the form integrations design. Once thats adjusted you can review.

@JakeUrban
Copy link
Contributor Author

Ok @msfeldstein This is ready for a review

@JakeUrban JakeUrban force-pushed the form-integrations branch 6 times, most recently from c0976a0 to c1ad6ea Compare December 4, 2019 22:21
@JakeUrban
Copy link
Contributor Author

We've decided to redesign parts of this feature, which will cover KYC use cases. The review can wait until this redesign is pushed.

@JakeUrban JakeUrban force-pushed the form-integrations branch 3 times, most recently from 92278bc to ea825cb Compare December 6, 2019 00:11
@JakeUrban JakeUrban changed the title Form Integrations Form Integrations & KYC Support Dec 6, 2019
@codecov-io
Copy link

codecov-io commented Dec 6, 2019

Codecov Report

Merging #27 into master will increase coverage by 0.4%.
The diff coverage is 82.5%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #27     +/-   ##
========================================
+ Coverage   78.79%   79.2%   +0.4%     
========================================
  Files          20      20             
  Lines         849     880     +31     
========================================
+ Hits          669     697     +28     
- Misses        180     183      +3
Impacted Files Coverage Δ
polaris/polaris/integrations/__init__.py 23.07% <ø> (ø) ⬆️
polaris/polaris/sep10auth/views.py 85.89% <0%> (ø) ⬆️
polaris/polaris/withdraw/forms.py 100% <100%> (+14.28%) ⬆️
polaris/polaris/integrations/forms.py 83.33% <100%> (ø)
polaris/polaris/deposit/views.py 91.11% <71.87%> (-2.39%) ⬇️
polaris/polaris/withdraw/views.py 85.71% <86.95%> (+0.42%) ⬆️
polaris/polaris/integrations/transactions.py 91.42% <95%> (+10.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c26858e...6dbfe42. Read the comment docs.

Copy link
Contributor

@msfeldstein msfeldstein left a comment

Choose a reason for hiding this comment

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

Generally looks good just a few comments

Polaris does most of the work implementing SEP-24_. However, some pieces of
SEP-24 can only be implemented by the anchor. Specifically, anchors need to
implement their own banking rails and KYC requirements. This is where
:class:`DepositIntegration` and :class:`WithdrawalIntegration` come in.
Copy link
Contributor

Choose a reason for hiding this comment

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

"This is where the Integrations classes come in" since KYC is added now and Deposit/WithdrawIntegration doesn't cover all the integrations

the box with forms for deposit and withdrawal flows.

However, the data collected may not be sufficient for your needs. Maybe you
need to do collect additional fields and some validation or processing with
Copy link
Contributor

Choose a reason for hiding this comment

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

s/Maybe you need to do collect/Maybe you need to collect

form = rdi.form_for_transaction(transaction)(request.POST)
is_transaction_form = issubclass(form.__class__, TransactionForm)
if is_transaction_form:
form.asset = asset
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need the asset to live in the form? It doesn't seem like we'd want to show this as a form element to the user, its not something they can change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

form.asset is used in the validation function for the amount field, which is called from form.is_valid(). We don't control the parameters for the validation function so we have to give the form access to the non-field object somehow.

asset is not shown in the form, only attributes of type Field are displayed.

form_class = rdi.form_for_transaction(transaction)

if form_class:
return Response(
Copy link
Contributor

Choose a reason for hiding this comment

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

I get the feeling the GET and POST methods should be different endpoints, both for code clarity, but also in case the page needs to reload.
For example POST /webapp/submit_form will process the request then redirect to GET /webapp to show the next available form. Otherwise, if the page needs to reload for any reason the browser/webview will want to rePOST the previous form.

I think this is not a big deal for now but we may want to change this in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats fair, I'll make a separate PR for it. #34

@@ -19,8 +26,8 @@ def poll_pending_deposits(cls, pending_deposits: QuerySet
**OVERRIDE REQUIRED**

This function should poll the financial entity for the state of all
`pending_deposits` transactions and return the ones ready to be
executed on the Stellar network.
`pending_deposits` and return the ones ready to be executed on the
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify that it returns the ones where the external deposit has been completed. "ready to be executed on the stellar network" implies that the external deposit has been completed but it couldn't help to be explicit

@@ -45,6 +53,7 @@ def poll_pending_deposits(cls, pending_deposits: QuerySet
memory usage.

:param pending_deposits: a django Queryset for pending Transactions
:return: a list of Transaction database objects to execute
Copy link
Contributor

Choose a reason for hiding this comment

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

a list of Transaction database objects to execute feels confusing, it sounds like its going to execute a database transaction, it should be explicit that its Transaction entries for transactions which have successful user deposits and are ready to be executed on the stellar network

@@ -16,13 +16,18 @@

{% for field in form %}
<div class="field">
{% if field.name == 'amount' %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is fa-dollar-sign a bulma attribute? If so, can we pass it in in the django.Form instead of special casing amount here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so because the <span> tag and its contents are a separate component from the form field. The fa-dollar-sign attribute probably needs to live in an <i> tag too.

@JakeUrban JakeUrban merged commit c07e81b into stellar:master Dec 9, 2019
@JakeUrban JakeUrban deleted the form-integrations branch December 9, 2019 18:27
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.

None yet

3 participants