diff --git a/packages/backend/src/graphql/resolvers/combined_payments.test.ts b/packages/backend/src/graphql/resolvers/combined_payments.test.ts index c53367e749..f2699ac423 100644 --- a/packages/backend/src/graphql/resolvers/combined_payments.test.ts +++ b/packages/backend/src/graphql/resolvers/combined_payments.test.ts @@ -55,6 +55,7 @@ describe('Payment', (): void => { const outgoingPayment = await createOutgoingPayment(deps, { walletAddressId: outWalletAddressId, + method: 'ilp', receiver: `${Config.publicHost}/${uuid()}`, debitAmount: { value: BigInt(56), @@ -151,6 +152,7 @@ describe('Payment', (): void => { const outgoingPayment = await createOutgoingPayment(deps, { walletAddressId: outWalletAddressId, + method: 'ilp', ...baseOutgoingPayment }) @@ -159,6 +161,7 @@ describe('Payment', (): void => { }) await createOutgoingPayment(deps, { walletAddressId: outWalletAddressId2, + method: 'ilp', ...baseOutgoingPayment }) diff --git a/packages/backend/src/graphql/resolvers/liquidity.test.ts b/packages/backend/src/graphql/resolvers/liquidity.test.ts index e9ea1200c5..c81089197f 100644 --- a/packages/backend/src/graphql/resolvers/liquidity.test.ts +++ b/packages/backend/src/graphql/resolvers/liquidity.test.ts @@ -1585,6 +1585,7 @@ describe('Liquidity Resolvers', (): void => { }) payment = await createOutgoingPayment(deps, { walletAddressId, + method: 'ilp', receiver: `${Config.publicHost}/${uuid()}/incoming-payments/${uuid()}`, debitAmount: { value: BigInt(456), diff --git a/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts b/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts index 7ec0258353..b2f8d7e1bf 100644 --- a/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts +++ b/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts @@ -64,6 +64,7 @@ describe('OutgoingPayment Resolvers', (): void => { }): Promise => { return await createOutgoingPayment(deps, { ...options, + method: 'ilp', receiver: `${Config.publicHost}/${uuid()}`, debitAmount: { value: BigInt(56), diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index ab7875f2fe..35400f1ab5 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -435,7 +435,7 @@ export function initIocContainer( 'paymentMethodHandlerService' ), peerService: await deps.use('peerService'), - paymentPointerService: await deps.use('paymentPointerService') + walletAddressService: await deps.use('walletAddressService') }) }) container.singleton('outgoingPaymentRoutes', async (deps) => { diff --git a/packages/backend/src/open_payments/payment/combined/service.test.ts b/packages/backend/src/open_payments/payment/combined/service.test.ts index 4768c9f261..d4de0b4a6b 100644 --- a/packages/backend/src/open_payments/payment/combined/service.test.ts +++ b/packages/backend/src/open_payments/payment/combined/service.test.ts @@ -66,6 +66,7 @@ describe('Combined Payment Service', (): void => { const outgoingPayment = await createOutgoingPayment(deps, { walletAddressId: sendWalletAddressId, + method: 'ilp', receiver: receiverUrl, debitAmount: { value: BigInt(123), diff --git a/packages/backend/src/open_payments/payment/outgoing/routes.test.ts b/packages/backend/src/open_payments/payment/outgoing/routes.test.ts index cec6957b2c..0d1f0aae65 100644 --- a/packages/backend/src/open_payments/payment/outgoing/routes.test.ts +++ b/packages/backend/src/open_payments/payment/outgoing/routes.test.ts @@ -43,6 +43,7 @@ describe('Outgoing Payment Routes', (): void => { return await createOutgoingPayment(deps, { ...options, walletAddressId: walletAddress.id, + method: 'ilp', receiver: `${receivingWalletAddress}/incoming-payments/${uuid()}`, debitAmount: { value: BigInt(56), diff --git a/packages/backend/src/open_payments/payment/outgoing/service.ts b/packages/backend/src/open_payments/payment/outgoing/service.ts index 39d04968ac..a7b7bb0ebd 100644 --- a/packages/backend/src/open_payments/payment/outgoing/service.ts +++ b/packages/backend/src/open_payments/payment/outgoing/service.ts @@ -29,10 +29,6 @@ import { WalletAddressService, WalletAddressSubresourceService } from '../../wallet_address/service' -import { - IlpPlugin, - IlpPluginOptions -} from '../../../payment-method/ilp/ilp_plugin' import { sendWebhookEvent } from './lifecycle' import * as worker from './worker' import { Interval } from 'luxon' @@ -56,7 +52,7 @@ export interface ServiceDependencies extends BaseService { accountingService: AccountingService receiverService: ReceiverService peerService: PeerService - makeIlpPlugin: (options: IlpPluginOptions) => IlpPlugin + paymentMethodHandlerService: PaymentMethodHandlerService walletAddressService: WalletAddressService } diff --git a/packages/backend/src/payment-method/handler/service.test.ts b/packages/backend/src/payment-method/handler/service.test.ts index 7381c02f87..2a80feed5c 100644 --- a/packages/backend/src/payment-method/handler/service.test.ts +++ b/packages/backend/src/payment-method/handler/service.test.ts @@ -69,17 +69,18 @@ describe('PaymentMethodHandlerService', (): void => { describe('pay', (): void => { test('calls ilpPaymentService for ILP payment type', async (): Promise => { const asset = await createAsset(deps) - const paymentPointer = await createPaymentPointer(deps, { + const walletAddress = await createWalletAddress(deps, { assetId: asset.id }) const { receiver, outgoingPayment } = await createOutgoingPaymentWithReceiver(deps, { - sendingPaymentPointer: paymentPointer, - receivingPaymentPointer: paymentPointer, + sendingWalletAddress: walletAddress, + receivingWalletAddress: walletAddress, + method: 'ilp', quoteOptions: { debitAmount: { - assetCode: paymentPointer.asset.code, - assetScale: paymentPointer.asset.scale, + assetCode: walletAddress.asset.code, + assetScale: walletAddress.asset.scale, value: 100n } } diff --git a/packages/backend/src/payment-method/ilp/service.test.ts b/packages/backend/src/payment-method/ilp/service.test.ts index 7964356260..3a7381f8c7 100644 --- a/packages/backend/src/payment-method/ilp/service.test.ts +++ b/packages/backend/src/payment-method/ilp/service.test.ts @@ -368,13 +368,13 @@ describe('IlpPaymentService', (): void => { [incomingAssetCode]: exchangeRate })) - const receivingPaymentPointer = + const receivingWalletAddress = walletAddressMap[incomingAssetCode] const sendingWalletAddress = walletAddressMap[debitAssetCode] const options: StartQuoteOptions = { walletAddress: sendingWalletAddress, - receiver: await createReceiver(deps, receivingPaymentPointer), + receiver: await createReceiver(deps, receivingWalletAddress), debitAmount: { assetCode: sendingWalletAddress.asset.code, assetScale: sendingWalletAddress.asset.scale, @@ -391,8 +391,8 @@ describe('IlpPaymentService', (): void => { value: debitAmountValue }, receiveAmount: { - assetCode: receivingPaymentPointer.asset.code, - assetScale: receivingPaymentPointer.asset.scale, + assetCode: receivingWalletAddress.asset.code, + assetScale: receivingWalletAddress.asset.scale, value: expectedReceiveAmount } }) @@ -447,7 +447,8 @@ describe('IlpPaymentService', (): void => { const { incomingPayment, receiver, outgoingPayment } = await createOutgoingPaymentWithReceiver(deps, { sendingWalletAddress: walletAddressMap['USD'], - receivingPaymentPointer: walletAddressMap['USD'], + receivingWalletAddress: walletAddressMap['USD'], + method: 'ilp', quoteOptions: { debitAmount: { value: 100n, @@ -476,7 +477,8 @@ describe('IlpPaymentService', (): void => { const { incomingPayment, receiver, outgoingPayment } = await createOutgoingPaymentWithReceiver(deps, { sendingWalletAddress: walletAddressMap['USD'], - receivingPaymentPointer: walletAddressMap['USD'], + receivingWalletAddress: walletAddressMap['USD'], + method: 'ilp', quoteOptions: { exchangeRate: 1, debitAmount: { @@ -525,7 +527,8 @@ describe('IlpPaymentService', (): void => { const { incomingPayment, receiver, outgoingPayment } = await createOutgoingPaymentWithReceiver(deps, { sendingWalletAddress: walletAddressMap['USD'], - receivingPaymentPointer: walletAddressMap['USD'], + receivingWalletAddress: walletAddressMap['USD'], + method: 'ilp', quoteOptions: { debitAmount: { value: 100n, @@ -563,7 +566,8 @@ describe('IlpPaymentService', (): void => { const { incomingPayment, receiver, outgoingPayment } = await createOutgoingPaymentWithReceiver(deps, { sendingWalletAddress: walletAddressMap['USD'], - receivingPaymentPointer: walletAddressMap['USD'], + receivingWalletAddress: walletAddressMap['USD'], + method: 'ilp', quoteOptions: { debitAmount: { value: 100n, @@ -601,7 +605,8 @@ describe('IlpPaymentService', (): void => { const { receiver, outgoingPayment } = await createOutgoingPaymentWithReceiver(deps, { sendingWalletAddress: walletAddressMap['USD'], - receivingPaymentPointer: walletAddressMap['USD'], + receivingWalletAddress: walletAddressMap['USD'], + method: 'ilp', quoteOptions: { debitAmount: { value: 100n, @@ -636,7 +641,8 @@ describe('IlpPaymentService', (): void => { const { receiver, outgoingPayment } = await createOutgoingPaymentWithReceiver(deps, { sendingWalletAddress: walletAddressMap['USD'], - receivingPaymentPointer: walletAddressMap['USD'], + receivingWalletAddress: walletAddressMap['USD'], + method: 'ilp', quoteOptions: { debitAmount: { value: 100n, @@ -675,7 +681,8 @@ describe('IlpPaymentService', (): void => { const { receiver, outgoingPayment } = await createOutgoingPaymentWithReceiver(deps, { sendingWalletAddress: walletAddressMap['USD'], - receivingPaymentPointer: walletAddressMap['USD'], + receivingWalletAddress: walletAddressMap['USD'], + method: 'ilp', quoteOptions: { debitAmount: { value: 100n, diff --git a/packages/backend/src/shared/pagination.test.ts b/packages/backend/src/shared/pagination.test.ts index c12f9c74a3..d1018342a5 100644 --- a/packages/backend/src/shared/pagination.test.ts +++ b/packages/backend/src/shared/pagination.test.ts @@ -157,6 +157,7 @@ describe('Pagination', (): void => { const payment = await createOutgoingPayment(deps, { walletAddressId: defaultWalletAddress.id, receiver: secondaryWalletAddress.url, + method: 'ilp', debitAmount, validDestination: false }) diff --git a/packages/backend/src/tests/combinedPayment.ts b/packages/backend/src/tests/combinedPayment.ts index 507b348790..8ac003d13f 100644 --- a/packages/backend/src/tests/combinedPayment.ts +++ b/packages/backend/src/tests/combinedPayment.ts @@ -54,6 +54,7 @@ export async function createCombinedPayment( }) : await createOutgoingPayment(deps, { walletAddressId: sendWalletAddressId, + method: 'ilp', receiver: `${Config.publicHost}/${uuid()}`, validDestination: false }) diff --git a/packages/backend/src/tests/outgoingPayment.ts b/packages/backend/src/tests/outgoingPayment.ts index f12c20c236..de38ea5ded 100644 --- a/packages/backend/src/tests/outgoingPayment.ts +++ b/packages/backend/src/tests/outgoingPayment.ts @@ -16,7 +16,7 @@ import assert from 'assert' type CreateTestQuoteAndOutgoingPaymentOptions = Omit< CreateOutgoingPaymentOptions & CreateTestQuoteOptions, - 'quoteId' | 'method' + 'quoteId' > export async function createOutgoingPayment( @@ -29,7 +29,7 @@ export async function createOutgoingPayment( receiver: options.receiver, validDestination: options.validDestination, exchangeRate: options.exchangeRate, - method: 'ilp' + method: options.method } if (options.debitAmount) quoteOptions.debitAmount = options.debitAmount if (options.receiveAmount) quoteOptions.receiveAmount = options.receiveAmount @@ -78,6 +78,7 @@ export async function createOutgoingPayment( interface CreateOutgoingPaymentWithReceiverArgs { receivingWalletAddress: WalletAddress + method: 'ilp', incomingPaymentOptions?: Partial quoteOptions?: Partial< Pick< @@ -115,16 +116,15 @@ export async function createOutgoingPaymentWithReceiver( walletAddressId: args.receivingWalletAddress.id }) - const connectionService = await deps.use('connectionService') const receiver = new Receiver( - incomingPayment.toOpenPaymentsType( - args.receivingWalletAddress, - connectionService.get(incomingPayment)! + incomingPayment.toOpenPaymentsTypeWithMethods( + args.receivingWalletAddress ) ) const outgoingPayment = await createOutgoingPayment(deps, { walletAddressId: args.sendingWalletAddress.id, + method: args.method, receiver: receiver.incomingPayment!.id!, ...args.quoteOptions })