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

satellite/payments: token deposit #3283

Merged
merged 20 commits into from Oct 17, 2019

Conversation

rikysya
Copy link
Contributor

@rikysya rikysya commented Oct 15, 2019

What: add functionality to deposit tokens

Why:

Please describe the tests:

  • Test 1:
  • Test 2:

Please describe the performance impact:

Code Review Checklist (to be filled out by reviewer)

  • Does the PR describe what changes are being made?
  • Does the PR describe why the changes are being made?
  • Does the code follow our style guide?
  • Does the code follow our testing guide?
  • Is the PR appropriately sized? (If it could be broken into smaller PRs it should be)
  • Does the new code have enough tests? (every PR should have tests or justification otherwise. Bug-fix PRs especially)
  • Does the new code have enough documentation that answers "how do I use it?" and "what does it do?"? (both source documentation and higher level, diagrams?)
  • Does any documentation need updating?
  • Do the database access patterns make sense?

@rikysya rikysya added Request Code Review Code review requested Sprint Release Goal Sprint Release Goal labels Oct 15, 2019
@rikysya rikysya requested a review from a team October 15, 2019 17:16
@rikysya rikysya self-assigned this Oct 15, 2019
@cla-bot cla-bot bot added the cla-signed label Oct 15, 2019
@ghost ghost requested review from bryanchriswhite and thepaul and removed request for a team October 15, 2019 17:16
@ifraixedes ifraixedes added the Code Review In-Progress Code review in-progress label Oct 16, 2019
Copy link
Member

@ifraixedes ifraixedes left a comment

Choose a reason for hiding this comment

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

Some changes to be applied right away through Github code snippet suggestions.
The rest of the comments are questions.


key := u.Query().Get("key")
if key == "" {
return "", errs.New("no key value found")
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 that's good to have a class or a sentinel error value for this matter.

)

// GetTransacationKeyFromURL parses provided raw url string
// and extracts authorization key from it.
Copy link
Member

Choose a reason for hiding this comment

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

I would add to this documentation that an error is returned if the URL is from an invalid format or it doesn't have an authorization key.

In case that you create the commented error class or sentinel error value, mention that in case that such error is returned when there is no authorization key.

satellite/payments/coinpayments/utils.go Outdated Show resolved Hide resolved
satellite/payments/stripecoinpayments/tokens.go Outdated Show resolved Hide resolved
satellite/payments/stripecoinpayments/tokens.go Outdated Show resolved Hide resolved
func (db *coinpaymentsTransactions) Insert(ctx context.Context, tx stripecoinpayments.Transaction) (*stripecoinpayments.Transaction, error) {
amount, err := tx.Amount.GobEncode()
if err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we have to wrap all the errors returned by the methods of this type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't we have a wrapper for all dbx errors? If that is the policy we follow that I will add another error

Copy link
Member

Choose a reason for hiding this comment

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

Checking dbx autogenerated code could be because there is an option to set a wrap error function. I don't know if it's set, I suppose that it's

Anyway, this one and some others of this function aren't errors returned by DBX so they should be wrapped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, yeah you are right


// TransactionStatus defines allowed statuses
// for deposit transactions.
type TransactionStatus string
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering, for consistency reasons, if this type shouldn't be an int like

Copy link
Contributor Author

Choose a reason for hiding this comment

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

coinpayments is an implementation detail, it could possibly be different provider for token payment, with different status type. My idea is that it might be easier for caller to work with string value of statuses, but yeah it might be no difference actually.

@ifraixedes ifraixedes removed the Code Review In-Progress Code review in-progress label Oct 16, 2019
rikysya and others added 4 commits October 17, 2019 14:26
Co-Authored-By: Ivan Fraixedes <ifcdev@gmail.com>
Co-Authored-By: Ivan Fraixedes <ifcdev@gmail.com>
Co-Authored-By: Ivan Fraixedes <ifcdev@gmail.com>
Co-Authored-By: Ivan Fraixedes <ifcdev@gmail.com>
ifraixedes
ifraixedes previously approved these changes Oct 17, 2019
Copy link
Member

@ifraixedes ifraixedes left a comment

Choose a reason for hiding this comment

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

Just an improvement in the doc function comment but it's good to go.

satellite/payments/coinpayments/utils.go Outdated Show resolved Hide resolved
Co-Authored-By: Ivan Fraixedes <ifcdev@gmail.com>
@rikysya rikysya dismissed stale reviews from ifraixedes via 7a7aab6 October 17, 2019 13:08
ifraixedes
ifraixedes previously approved these changes Oct 17, 2019
egonelbre
egonelbre previously approved these changes Oct 17, 2019
"storj.io/storj/satellite/payments/coinpayments"
)

// hack to ensure that storjTokens implements payments.StorjTokens.
Copy link
Member

Choose a reason for hiding this comment

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

This is not really an hack, since it's so widely used :D.


transactions := db.CoinpaymentsTransactions()

t.Run("test insert", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

No need to rewrite "test", since it's running in a test, it's obviously a test :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense)

@rikysya rikysya merged commit 24e72f3 into storj:master Oct 17, 2019
@rikysya rikysya deleted the yv/satellite/payments_token_deposit branch October 17, 2019 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed Request Code Review Code review requested Sprint Release Goal Sprint Release Goal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants