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.
28 changes: 28 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 @@ -1282,6 +1303,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
10 changes: 5 additions & 5 deletions packages/open-payments/src/client/grant.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpMethod } from '@interledger/openapi'
import {
ResourceRequestArgs,
GrantOrTokenRequestArgs,
RouteDeps,
UnauthenticatedResourceRequestArgs
} from '.'
Expand All @@ -23,10 +23,10 @@ export interface GrantRoutes {
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 Down Expand Up @@ -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