diff --git a/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Payment/Get Outgoing Payment.bru b/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Payment/Get Outgoing Payment.bru index 3216293fbd..cfca035df3 100644 --- a/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Payment/Get Outgoing Payment.bru +++ b/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Payment/Get Outgoing Payment.bru @@ -17,6 +17,7 @@ body:graphql { error metadata id + grantId walletAddressId quote { id diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Outgoing Payment.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Outgoing Payment.bru index dd91eec3c1..ae9cd5ff47 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Outgoing Payment.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Outgoing Payment.bru @@ -17,6 +17,7 @@ body:graphql { error metadata id + grantId walletAddressId client quote { diff --git a/localenv/mock-account-servicing-entity/generated/graphql.ts b/localenv/mock-account-servicing-entity/generated/graphql.ts index 44c15b81de..e482374c2f 100644 --- a/localenv/mock-account-servicing-entity/generated/graphql.ts +++ b/localenv/mock-account-servicing-entity/generated/graphql.ts @@ -841,6 +841,8 @@ export type OutgoingPayment = BasePayment & Model & { /** Amount to send (fixed send) */ debitAmount: Amount; error?: Maybe; + /** Id of the Grant under which this outgoing payment was created */ + grantId?: Maybe; /** Outgoing payment id */ id: Scalars['ID']['output']; /** Available liquidity */ @@ -1992,6 +1994,7 @@ export type OutgoingPaymentResolvers; debitAmount?: Resolver; error?: Resolver, ParentType, ContextType>; + grantId?: Resolver, ParentType, ContextType>; id?: Resolver; liquidity?: Resolver, ParentType, ContextType>; metadata?: Resolver, ParentType, ContextType>; diff --git a/packages/backend/src/graphql/generated/graphql.schema.json b/packages/backend/src/graphql/generated/graphql.schema.json index 6cc8288adf..f0b8b64033 100644 --- a/packages/backend/src/graphql/generated/graphql.schema.json +++ b/packages/backend/src/graphql/generated/graphql.schema.json @@ -4916,6 +4916,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "grantId", + "description": "Id of the Grant under which this outgoing payment was created", + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "id", "description": "Outgoing payment id", diff --git a/packages/backend/src/graphql/generated/graphql.ts b/packages/backend/src/graphql/generated/graphql.ts index 44c15b81de..e482374c2f 100644 --- a/packages/backend/src/graphql/generated/graphql.ts +++ b/packages/backend/src/graphql/generated/graphql.ts @@ -841,6 +841,8 @@ export type OutgoingPayment = BasePayment & Model & { /** Amount to send (fixed send) */ debitAmount: Amount; error?: Maybe; + /** Id of the Grant under which this outgoing payment was created */ + grantId?: Maybe; /** Outgoing payment id */ id: Scalars['ID']['output']; /** Available liquidity */ @@ -1992,6 +1994,7 @@ export type OutgoingPaymentResolvers; debitAmount?: Resolver; error?: Resolver, ParentType, ContextType>; + grantId?: Resolver, ParentType, ContextType>; id?: Resolver; liquidity?: Resolver, ParentType, ContextType>; metadata?: Resolver, ParentType, ContextType>; diff --git a/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts b/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts index 53d7d9bb48..71c51affcc 100644 --- a/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts +++ b/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts @@ -10,7 +10,10 @@ import { AppServices } from '../../app' import { initIocContainer } from '../..' import { Config } from '../../config/app' import { createAsset } from '../../tests/asset' -import { createOutgoingPayment } from '../../tests/outgoingPayment' +import { + createOutgoingPayment, + CreateTestQuoteAndOutgoingPaymentOptions +} from '../../tests/outgoingPayment' import { createWalletAddress } from '../../tests/walletAddress' import { truncateTables } from '../../tests/tableManager' import { @@ -61,11 +64,14 @@ describe('OutgoingPayment Resolvers', (): void => { await appContainer.shutdown() }) - const createPayment = async (options: { - walletAddressId: string - metadata?: Record - }): Promise => { - return await createOutgoingPayment(deps, { + const createPayment = async ( + options: { + walletAddressId: string + metadata?: Record + }, + grantId?: string + ): Promise => { + const obj: CreateTestQuoteAndOutgoingPaymentOptions = { ...options, method: 'ilp', receiver: `${Config.openPaymentsUrl}/${uuid()}`, @@ -75,12 +81,54 @@ describe('OutgoingPayment Resolvers', (): void => { assetScale: asset.scale }, validDestination: false - }) + } + + if (grantId) { + obj.grant = { id: grantId } + } + + return await createOutgoingPayment(deps, obj) } describe('Query.outgoingPayment', (): void => { let payment: OutgoingPaymentModel + describe('grantId', (): void => { + it('should return grantId', async (): Promise => { + const grantId = uuid() + + const { id: walletAddressId } = await createWalletAddress(deps, { + assetId: asset.id + }) + + const payment = await createPayment({ walletAddressId }, grantId) + + const query = await appContainer.apolloClient + .query({ + query: gql` + query OutgoingPayment($paymentId: String!) { + outgoingPayment(id: $paymentId) { + id + grantId + walletAddressId + } + } + `, + variables: { + paymentId: payment.id + } + }) + .then((query): OutgoingPayment => query.data?.outgoingPayment) + + expect(query).toEqual({ + id: payment.id, + grantId: payment.grantId, + walletAddressId: payment.walletAddressId, + __typename: 'OutgoingPayment' + }) + }) + }) + describe('metadata', (): void => { const metadata = { description: 'rent', diff --git a/packages/backend/src/graphql/resolvers/outgoing_payment.ts b/packages/backend/src/graphql/resolvers/outgoing_payment.ts index c4907b6e58..699357de60 100644 --- a/packages/backend/src/graphql/resolvers/outgoing_payment.ts +++ b/packages/backend/src/graphql/resolvers/outgoing_payment.ts @@ -172,6 +172,7 @@ export function paymentToGraphql( receiveAmount: payment.receiveAmount, metadata: payment.metadata, createdAt: new Date(+payment.createdAt).toISOString(), - quote: quoteToGraphql(payment.quote) + quote: quoteToGraphql(payment.quote), + grantId: payment.grantId } } diff --git a/packages/backend/src/graphql/schema.graphql b/packages/backend/src/graphql/schema.graphql index 1e1d0e4489..dcf104c049 100644 --- a/packages/backend/src/graphql/schema.graphql +++ b/packages/backend/src/graphql/schema.graphql @@ -849,6 +849,8 @@ type OutgoingPayment implements BasePayment & Model { sentAmount: Amount! "Date-time of creation" createdAt: String! + "Id of the Grant under which this outgoing payment was created" + grantId: String } enum OutgoingPaymentState { diff --git a/packages/backend/src/tests/outgoingPayment.ts b/packages/backend/src/tests/outgoingPayment.ts index 13d756653d..f28b38e694 100644 --- a/packages/backend/src/tests/outgoingPayment.ts +++ b/packages/backend/src/tests/outgoingPayment.ts @@ -14,7 +14,7 @@ import { IncomingPayment } from '../open_payments/payment/incoming/model' import { createIncomingPayment } from './incomingPayment' import assert from 'assert' -type CreateTestQuoteAndOutgoingPaymentOptions = Omit< +export type CreateTestQuoteAndOutgoingPaymentOptions = Omit< CreateOutgoingPaymentOptions & CreateTestQuoteOptions, 'quoteId' > diff --git a/packages/frontend/app/generated/graphql.ts b/packages/frontend/app/generated/graphql.ts index 4e89d4245c..10e878774f 100644 --- a/packages/frontend/app/generated/graphql.ts +++ b/packages/frontend/app/generated/graphql.ts @@ -841,6 +841,8 @@ export type OutgoingPayment = BasePayment & Model & { /** Amount to send (fixed send) */ debitAmount: Amount; error?: Maybe; + /** Id of the Grant under which this outgoing payment was created */ + grantId?: Maybe; /** Outgoing payment id */ id: Scalars['ID']['output']; /** Available liquidity */ @@ -1992,6 +1994,7 @@ export type OutgoingPaymentResolvers; debitAmount?: Resolver; error?: Resolver, ParentType, ContextType>; + grantId?: Resolver, ParentType, ContextType>; id?: Resolver; liquidity?: Resolver, ParentType, ContextType>; metadata?: Resolver, ParentType, ContextType>; diff --git a/packages/mock-account-service-lib/src/generated/graphql.ts b/packages/mock-account-service-lib/src/generated/graphql.ts index 44c15b81de..e482374c2f 100644 --- a/packages/mock-account-service-lib/src/generated/graphql.ts +++ b/packages/mock-account-service-lib/src/generated/graphql.ts @@ -841,6 +841,8 @@ export type OutgoingPayment = BasePayment & Model & { /** Amount to send (fixed send) */ debitAmount: Amount; error?: Maybe; + /** Id of the Grant under which this outgoing payment was created */ + grantId?: Maybe; /** Outgoing payment id */ id: Scalars['ID']['output']; /** Available liquidity */ @@ -1992,6 +1994,7 @@ export type OutgoingPaymentResolvers; debitAmount?: Resolver; error?: Resolver, ParentType, ContextType>; + grantId?: Resolver, ParentType, ContextType>; id?: Resolver; liquidity?: Resolver, ParentType, ContextType>; metadata?: Resolver, ParentType, ContextType>; diff --git a/test/integration/lib/generated/graphql.ts b/test/integration/lib/generated/graphql.ts index 44c15b81de..e482374c2f 100644 --- a/test/integration/lib/generated/graphql.ts +++ b/test/integration/lib/generated/graphql.ts @@ -841,6 +841,8 @@ export type OutgoingPayment = BasePayment & Model & { /** Amount to send (fixed send) */ debitAmount: Amount; error?: Maybe; + /** Id of the Grant under which this outgoing payment was created */ + grantId?: Maybe; /** Outgoing payment id */ id: Scalars['ID']['output']; /** Available liquidity */ @@ -1992,6 +1994,7 @@ export type OutgoingPaymentResolvers; debitAmount?: Resolver; error?: Resolver, ParentType, ContextType>; + grantId?: Resolver, ParentType, ContextType>; id?: Resolver; liquidity?: Resolver, ParentType, ContextType>; metadata?: Resolver, ParentType, ContextType>;