Skip to content

Commit

Permalink
refactor(backend): rm ilpQuoteDetails service
Browse files Browse the repository at this point in the history
  • Loading branch information
BlairCurrey committed Oct 23, 2024
1 parent b0897d9 commit 2d8048a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 125 deletions.
2 changes: 0 additions & 2 deletions packages/backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ import { LoggingPlugin } from './graphql/plugin'
import { LocalPaymentService } from './payment-method/local/service'
import { GrantService } from './open_payments/grant/service'
import { AuthServerService } from './open_payments/authServer/service'
import { IlpQuoteDetailsService } from './payment-method/ilp/quote-details/service'
export interface AppContextData {
logger: Logger
container: AppContainer
Expand Down Expand Up @@ -257,7 +256,6 @@ export interface AppServices {
paymentMethodHandlerService: Promise<PaymentMethodHandlerService>
ilpPaymentService: Promise<IlpPaymentService>
localPaymentService: Promise<LocalPaymentService>
ilpQuoteDetailsService: Promise<IlpQuoteDetailsService>
}

export type AppContainer = IocContract<AppServices>
Expand Down
9 changes: 0 additions & 9 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import {
import { createHttpTokenService } from './payment-method/ilp/peer-http-token/service'
import { createPeerService } from './payment-method/ilp/peer/service'
import { createIlpPaymentService } from './payment-method/ilp/service'
import { createIlpQuoteDetailsService } from './payment-method/ilp/quote-details/service'
import {
createLocalPaymentService,
ServiceDependencies as LocalPaymentServiceDependencies
Expand Down Expand Up @@ -428,21 +427,13 @@ export function initIocContainer(
})
})

container.singleton('ilpQuoteDetailsService', async (deps) => {
return await createIlpQuoteDetailsService({
logger: await deps.use('logger'),
knex: await deps.use('knex')
})
})

container.singleton('ilpPaymentService', async (deps) => {
return await createIlpPaymentService({
logger: await deps.use('logger'),
knex: await deps.use('knex'),
config: await deps.use('config'),
makeIlpPlugin: await deps.use('makeIlpPlugin'),
ratesService: await deps.use('ratesService'),
ilpQuoteDetailsService: await deps.use('ilpQuoteDetailsService'),
telemetry: await deps.use('telemetry')
})
})
Expand Down
30 changes: 16 additions & 14 deletions packages/backend/src/open_payments/quote/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
PaymentMethodHandlerErrorCode
} from '../../payment-method/handler/errors'
import { Receiver } from '../receiver/model'
import { IlpQuoteDetailsService } from '../../payment-method/ilp/quote-details/service'
import { IlpQuoteDetails } from '../../payment-method/ilp/quote-details/model'

describe('QuoteService', (): void => {
let deps: IocContract<AppServices>
Expand All @@ -48,7 +48,6 @@ describe('QuoteService', (): void => {
let sendingWalletAddress: MockWalletAddress
let receivingWalletAddress: MockWalletAddress
let config: IAppConfig
let ilpQuoteDetailsService: IlpQuoteDetailsService
let receiverGet: typeof receiverService.get
let receiverGetSpy: jest.SpyInstance<
Promise<Receiver | undefined>,
Expand Down Expand Up @@ -88,7 +87,6 @@ describe('QuoteService', (): void => {
quoteService = await deps.use('quoteService')
paymentMethodHandlerService = await deps.use('paymentMethodHandlerService')
receiverService = await deps.use('receiverService')
ilpQuoteDetailsService = await deps.use('ilpQuoteDetailsService')
})

beforeEach(async (): Promise<void> => {
Expand Down Expand Up @@ -156,9 +154,9 @@ describe('QuoteService', (): void => {
return
}

quote.ilpQuoteDetails = await ilpQuoteDetailsService.getByQuoteId(
quote.id
)
quote.ilpQuoteDetails = await IlpQuoteDetails.query()
.where({ quoteId: quote.id })
.first()

return quote
},
Expand All @@ -167,7 +165,9 @@ describe('QuoteService', (): void => {

const quotesWithDetails = await Promise.all(
quotes.map(async (q) => {
q.ilpQuoteDetails = await ilpQuoteDetailsService.getByQuoteId(q.id)
q.ilpQuoteDetails = await IlpQuoteDetails.query()
.where({ quoteId: q.id })
.first()
return q
})
)
Expand Down Expand Up @@ -283,8 +283,9 @@ describe('QuoteService', (): void => {
id: quote.id
})
assert(foundQuote)
foundQuote.ilpQuoteDetails =
await ilpQuoteDetailsService.getByQuoteId(quote.id)
foundQuote.ilpQuoteDetails = await IlpQuoteDetails.query()
.where({ quoteId: quote.id })
.first()
expect(foundQuote).toEqual(quote)
}
)
Expand Down Expand Up @@ -374,8 +375,9 @@ describe('QuoteService', (): void => {
id: quote.id
})
assert(foundQuote)
foundQuote.ilpQuoteDetails =
await ilpQuoteDetailsService.getByQuoteId(quote.id)
foundQuote.ilpQuoteDetails = await IlpQuoteDetails.query()
.where({ quoteId: quote.id })
.first()
expect(foundQuote).toEqual(quote)
}
)
Expand Down Expand Up @@ -493,9 +495,9 @@ describe('QuoteService', (): void => {
})
assert.ok(!isQuoteError(quote))

const ilpQuoteDetails = await ilpQuoteDetailsService.getByQuoteId(
quote.id
)
const ilpQuoteDetails = await IlpQuoteDetails.query()
.where({ quoteId: quote.id })
.first()

expect(quote).toMatchObject({
debitAmount: mockedQuote.debitAmount,
Expand Down

This file was deleted.

32 changes: 0 additions & 32 deletions packages/backend/src/payment-method/ilp/quote-details/service.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/backend/src/payment-method/ilp/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
PaymentMethodHandlerErrorCode
} from '../handler/errors'
import { TelemetryService } from '../../telemetry/service'
import { IlpQuoteDetailsService } from './quote-details/service'
import { IlpQuoteDetails } from './quote-details/model'

export interface IlpPaymentService extends PaymentMethodService {}
Expand All @@ -24,7 +23,6 @@ export interface ServiceDependencies extends BaseService {
config: IAppConfig
ratesService: RatesService
makeIlpPlugin: (options: IlpPluginOptions) => IlpPlugin
ilpQuoteDetailsService: IlpQuoteDetailsService
telemetry: TelemetryService
}

Expand Down

0 comments on commit 2d8048a

Please sign in to comment.