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

feat: add wallet address to subresource requests #305

Merged
merged 8 commits into from
Oct 16, 2023
5 changes: 5 additions & 0 deletions .changeset/clean-mice-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@interledger/open-payments': minor
---

Added "walletAddress" field to resource POST request bodies, added "wallet-address" query parameter to resource GET requests.
45 changes: 45 additions & 0 deletions openapi/resource-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ paths:
type: object
additionalProperties: false
properties:
walletAddress:
$ref: ./schemas.yaml#/components/schemas/walletAddress
incomingAmount:
$ref: ./schemas.yaml#/components/schemas/amount
description: The maximum amount that should be paid into the wallet address under this incoming payment.
Expand All @@ -151,6 +153,7 @@ paths:
examples:
Create incoming payment for $25 to pay invoice INV2022-02-0137:
value:
walletAddress: 'https://openpayments.guide/alice/'
incomingAmount:
value: '2500'
assetCode: USD
Expand Down Expand Up @@ -275,6 +278,7 @@ paths:
$ref: '#/components/responses/403'
description: List all incoming payments on the wallet address
parameters:
- $ref: '#/components/parameters/wallet-address'
- $ref: '#/components/parameters/cursor'
- $ref: '#/components/parameters/first'
- $ref: '#/components/parameters/last'
Expand Down Expand Up @@ -328,12 +332,15 @@ paths:
examples:
Create an outgoing payment based on a quote:
value:
walletAddress: 'https://ilp.rafiki.money/alice/'
quoteId: 'https://ilp.rafiki.money/quotes/ab03296b-0c8b-4776-b94e-7ee27d868d4d'
metadata:
externalRef: INV2022-02-0137
schema:
type: object
properties:
walletAddress:
Copy link
Contributor

Choose a reason for hiding this comment

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

POST /quote request body should also contain walletAddress

$ref: ./schemas.yaml#/components/schemas/walletAddress
quoteId:
type: string
format: uri
Expand All @@ -344,6 +351,7 @@ paths:
description: Additional metadata associated with the outgoing payment. (Optional)
required:
- quoteId
- walletAddress
additionalProperties: false
description: |-
A subset of the outgoing payments schema is accepted as input to create a new outgoing payment.
Expand Down Expand Up @@ -482,6 +490,7 @@ paths:
$ref: '#/components/responses/403'
description: List all outgoing payments on the wallet address
parameters:
- $ref: '#/components/parameters/wallet-address'
- $ref: '#/components/parameters/cursor'
- $ref: '#/components/parameters/first'
- $ref: '#/components/parameters/last'
Expand Down Expand Up @@ -531,10 +540,12 @@ paths:
examples:
Create quote for an `receiver` that is an Incoming Payment with an `incomingAmount`:
value:
walletAddress: 'https://ilp.rafiki.money/alice'
receiver: 'https://ilp.rafiki.money/incoming-payments/37a0d0ee-26dc-4c66-89e0-01fbf93156f7'
method: ilp
Create fixed-send amount quote for $25:
value:
walletAddress: 'https://ilp.rafiki.money/alice'
receiver: 'https://ilp.rafiki.money/incoming-payments/37a0d0ee-26dc-4c66-89e0-01fbf93156f7'
method: ilp
debitAmount:
Expand All @@ -543,6 +554,7 @@ paths:
assetScale: 2
Create fixed-receive amount quote for $25:
value:
walletAddress: 'https://ilp.rafiki.money/alice'
receiver: 'https://ilp.rafiki.money/incoming-payments/37a0d0ee-26dc-4c66-89e0-01fbf93156f7'
method: ilp
receiveAmount:
Expand All @@ -553,16 +565,21 @@ paths:
oneOf:
- description: Create quote for an `receiver` that is an Incoming Payment with an `incomingAmount`
properties:
walletAddress:
$ref: ./schemas.yaml#/components/schemas/walletAddress
receiver:
$ref: ./schemas.yaml#/components/schemas/receiver
method:
$ref: '#/components/schemas/payment-method'
required:
- walletAddress
- receiver
- method
additionalProperties: false
- description: Create a quote with a fixed-receive amount
properties:
walletAddress:
$ref: ./schemas.yaml#/components/schemas/walletAddress
receiver:
$ref: ./schemas.yaml#/components/schemas/receiver
method:
Expand All @@ -571,12 +588,15 @@ paths:
description: The fixed amount that would be paid into the receiving wallet address given a successful outgoing payment.
$ref: ./schemas.yaml#/components/schemas/amount
required:
- walletAddress
- receiver
- method
- receiveAmount
additionalProperties: false
- description: Create a quote with a fixed-send amount
properties:
walletAddress:
$ref: ./schemas.yaml#/components/schemas/walletAddress
receiver:
$ref: ./schemas.yaml#/components/schemas/receiver
method:
Expand All @@ -585,6 +605,7 @@ paths:
description: The fixed amount that would be sent from the sending wallet address given a successful outgoing payment.
$ref: ./schemas.yaml#/components/schemas/amount
required:
- walletAddress
- receiver
- method
- debitAmount
Expand Down Expand Up @@ -650,6 +671,7 @@ paths:
description: A client can fetch the latest state of an incoming payment to determine the amount received into the wallet address.
parameters:
- $ref: '#/components/parameters/id'
- $ref: '#/components/parameters/wallet-address'
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the wallet address is needed here because the id is unique.

Copy link
Contributor Author

@njlie njlie Oct 11, 2023

Choose a reason for hiding this comment

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

Is it also the case for completing an incoming payment (https://github.com/interledger/open-payments/pull/305/files#diff-9debc2038853698222051b2c2a428cee93e9dda6af6076de559971933879580dR722-R725) since the path still contains that unique id?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, indeed.

'/incoming-payments/{id}/complete':
post:
summary: Complete an Incoming Payment
Expand Down Expand Up @@ -690,6 +712,21 @@ paths:
$ref: '#/components/responses/403'
'404':
description: Incoming Payment Not Found
requestBody:
content:
application/json:
schema:
type: object
additionalProperties: false
properties:
walletAddress:
$ref: ./schemas.yaml#/components/schemas/walletAddress
required:
- walletAddress
examples:
Complete incoming payment for https://openpayments.guide/alice:
value:
walletAddress: 'https://openpayments.guide/alice/'
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this can just be the ilp.money wallet address one will be good so it works with Blair's PR regardless who merges first

description: |-
A client with the appropriate permissions MAY mark a non-expired **incoming payment** as `completed` indicating that the client is not going to make any further payments toward this **incoming payment**, even though the full `incomingAmount` may not have been received.

Expand Down Expand Up @@ -748,6 +785,7 @@ paths:
- $ref: '#/components/parameters/signature'
parameters:
- $ref: '#/components/parameters/id'
- $ref: '#/components/parameters/wallet-address'
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

'/quotes/{id}':
get:
summary: Get a Quote
Expand Down Expand Up @@ -1282,6 +1320,13 @@ components:
type: string
description: Sub-resource identifier
required: true
wallet-address:
name: wallet-address
in: query
schema:
type: string
description: 'URL of a wallet address hosted by a Rafiki instance.'
required: true
signature:
name: Signature
in: header
Expand Down
5 changes: 5 additions & 0 deletions openapi/schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ components:
examples:
- 'https://ilp.rafiki.money/incoming-payments/08394f02-7b7b-45e2-b645-51d04e7c330c'
- 'https://ilp.rafiki.money/connections/016da9d5-c9a4-4c80-a354-86b915a04ff8'
walletAddress:
title: Wallet Address
type: string
description: 'URL of a wallet address hosted by a Rafiki instance.'
format: uri
16 changes: 8 additions & 8 deletions packages/open-payments/src/client/grant.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { HttpMethod } from '@interledger/openapi'
import {
ResourceRequestArgs,
GrantOrTokenRequestArgs,
RouteDeps,
UnauthenticatedResourceRequestArgs
UnauthenticatedRequestArgs
} from '.'
import {
getASPath,
Expand All @@ -19,14 +19,14 @@ export interface GrantRouteDeps extends RouteDeps {

export interface GrantRoutes {
request(
postArgs: UnauthenticatedResourceRequestArgs,
postArgs: UnauthenticatedRequestArgs,
args: Omit<GrantRequest, 'client'>
): Promise<PendingGrant | Grant>
continue(
postArgs: ResourceRequestArgs,
postArgs: GrantOrTokenRequestArgs,
args: GrantContinuationRequest
): Promise<Grant>
cancel(postArgs: ResourceRequestArgs): Promise<void>
cancel(postArgs: GrantOrTokenRequestArgs): Promise<void>
}

export const createGrantRoutes = (deps: GrantRouteDeps): GrantRoutes => {
Expand All @@ -47,7 +47,7 @@ export const createGrantRoutes = (deps: GrantRouteDeps): GrantRoutes => {

return {
request: (
{ url }: UnauthenticatedResourceRequestArgs,
{ url }: UnauthenticatedRequestArgs,
args: Omit<GrantRequest, 'client'>
) =>
post(
Expand All @@ -62,7 +62,7 @@ export const createGrantRoutes = (deps: GrantRouteDeps): GrantRoutes => {
requestGrantValidator
),
continue: (
{ url, accessToken }: ResourceRequestArgs,
{ url, accessToken }: GrantOrTokenRequestArgs,
args: GrantContinuationRequest
) =>
post(
Expand All @@ -74,7 +74,7 @@ export const createGrantRoutes = (deps: GrantRouteDeps): GrantRoutes => {
},
continueGrantValidator
),
cancel: ({ url, accessToken }: ResourceRequestArgs) =>
cancel: ({ url, accessToken }: GrantOrTokenRequestArgs) =>
deleteRequest(
deps,
{
Expand Down
Loading
Loading