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

chore(backend): make toOpenPaymentType sync #1056

Merged

Conversation

mkurapov
Copy link
Contributor

@mkurapov mkurapov commented Feb 1, 2023

Changes proposed in this pull request

Context

Checklist

  • Related issues linked using fixes #number
  • Tests added/updated
  • Documentation added
  • Make sure that all checks pass

@github-actions github-actions bot added pkg: backend Changes in the backend package. type: source Changes business logic type: tests Testing related labels Feb 1, 2023
@mkurapov mkurapov marked this pull request as ready for review February 1, 2023 13:25
@mkurapov
Copy link
Contributor Author

mkurapov commented Feb 1, 2023

@wilsonianb let me know if this feels better than the async version of #1024

Copy link
Contributor

@wilsonianb wilsonianb left a comment

Choose a reason for hiding this comment

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

I think I like it.
I bet this would even let us remove some .withGraphFetched['paymentPointer']s in subresource service queries.

@@ -75,7 +76,11 @@ async function getIncomingPayment(
}
if (!incomingPayment) return ctx.throw(404)
const connection = deps.connectionService.get(incomingPayment)
ctx.body = await incomingPaymentToBody(incomingPayment, connection)
ctx.body = incomingPaymentToBody(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could these *toBody calls be replaced with calling *.toOpenPaymentsType directly?

Copy link
Contributor

Choose a reason for hiding this comment

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

🤔
...or we do the *withPaymentPointer subresource type idea and make *toBody the limited places where we're doing the *.paymentPointer = ctx.paymentPointer assignment.

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 think I like it.

I bet this would even let us remove some .withGraphFetched['paymentPointer']s in subresource service queries.

It's a little more straightforward than the alternatives, and will indeed allow us to remove the withGraphFetched calls. I can do that as a separate follow-up PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

toBody is a little redundant, I agree, but the reason I like toBody is it just keeps it standard across all of the routes, and if it were ever to change, we'd just need to change a single place.

"*withPaymentPointer subresource type idea"
I'm still not convinced about this idea, since having the non-null asserted paymentPointer/having throws or undefined in the model itself might end up having someone call it and open up doors for bugs... thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't feeling too strongly about toBody or *withPaymentPointer.
The latter would let getUrl be a url getter but it'd probably only be called within toOpenPaymentType.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess url getter would also be used in tests...

Copy link
Contributor

@wilsonianb wilsonianb left a comment

Choose a reason for hiding this comment

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

👍
if you're wanting to merge this into your OG pr

@mkurapov mkurapov merged commit 5733224 into 662/mk/use-open-payments-types Feb 1, 2023
@mkurapov mkurapov deleted the 662/mk/use-open-payments-types-sync branch February 1, 2023 17:15
mkurapov added a commit that referenced this pull request Feb 2, 2023
* feat(open-payments): export the different IncomingPayment types

* feat(backend): use open-payment types for IncomingPayment

* feat(backend): use open-payment types for Connection

* feat(backend): use open-payment types for OutgoingPayment

* feat(backend): use open-payment types for Quote

* chore(backend): fix IncomingPayments.toOpenPaymentsType

* chore(open-payments): update mocks

* chore(backend): formatting

* chore(backend): add better typing for incomingPayment.toOpenPaymentsType

* chore(backend): remove QuoteJSON

* chore(open-payments): fix mocks

* chore(backend): fix IncomingPayment types

* chore(open-payments): fix incoming payment types

* chore(backend): fix incoming payment method

* chore(backend): make toOpenPaymentsType async

* chore(backend): getUrl for OutgoingPayment

* chore(backend): fix tests with async toOpenPaymentsType

* chore(backend): return undefined instead of null

* chore(backend): add awaits where necessary

* chore(open-payments): make getBody async

* chore(backend): fix outgoingPayment model method

* chore(backend): fix list tests

* chore(backend): update receiver tests

* chore(backend): make toOpenPaymentType sync (#1056)

* chore(backend): make toOpenPaymentType sync

* chore(backend): make quote.toOpenPaymentsType sync

* chore(backend): convert tests to sync

* chore(backend): update tests

* chore(backend): remove $formatJson where applicable

* chore(backend): remove $formatJson where applicable

* chore(backend): add test for incomingPayment model

* chore(backend): fix incomingPayment model test

* chore(open-payments): use suggestion

* chore(backend): fix test

* chore(backend): use suggestion
mkurapov added a commit that referenced this pull request Feb 6, 2023
* feat(open-payments): export the different IncomingPayment types

* feat(backend): use open-payment types for IncomingPayment

* feat(backend): use open-payment types for Connection

* feat(backend): use open-payment types for OutgoingPayment

* feat(backend): use open-payment types for Quote

* chore(backend): fix IncomingPayments.toOpenPaymentsType

* chore(open-payments): update mocks

* chore(backend): formatting

* chore(backend): add better typing for incomingPayment.toOpenPaymentsType

* chore(backend): remove QuoteJSON

* chore(open-payments): fix mocks

* chore(backend): fix IncomingPayment types

* chore(open-payments): fix incoming payment types

* chore(backend): fix incoming payment method

* chore(backend): make toOpenPaymentsType async

* chore(backend): getUrl for OutgoingPayment

* chore(backend): fix tests with async toOpenPaymentsType

* chore(backend): return undefined instead of null

* chore(backend): add awaits where necessary

* chore(open-payments): make getBody async

* chore(backend): fix outgoingPayment model method

* chore(backend): fix list tests

* chore(backend): update receiver tests

* chore(backend): make toOpenPaymentType sync (#1056)

* chore(backend): make toOpenPaymentType sync

* chore(backend): make quote.toOpenPaymentsType sync

* chore(backend): convert tests to sync

* chore(backend): update tests

* chore(open-payments): updating AccessType type & exporting AccessToken

* chore(auth): adding toOpenPayments type methods for grants & access & accessTokens

* chore(auth): remove unused type

* chore(backend): remove $formatJson where applicable

* chore(backend): remove $formatJson where applicable

* chore(backend): add test for incomingPayment model

* chore(auth): await createGrantInitiation functions

* chore(open-payments): export AccessItem

* chore(auth): update  toOpenPaymentsAccess

* chore(open-payments): update AccessAction type

* chore(backend): fix incomingPayment model test

* chore(auth): exclude instead of Omit to give us ctx types

* chore(open-payments): use suggestion

* chore(backend): fix test

* chore(backend): use suggestion

* chore(auth): updates types for routes tests

* chore(auth): update toOpenPaymentsGrant name

* chore(auth): update accessToken tests

* chore(auth): address feedback

* feat(auth): lock grant when rotating accessToken

* chore(auth): add tests for revoked accessToken

* chore(auth): remove locking for now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: backend Changes in the backend package. type: source Changes business logic type: tests Testing related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants