Skip to content

Commit

Permalink
feat: tenanted quotes - formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sanducb committed Dec 17, 2024
1 parent ed89fb9 commit 5991a8c
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 48 deletions.
16 changes: 4 additions & 12 deletions packages/backend/src/graphql/resolvers/outgoing_payment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ describe('OutgoingPayment Resolvers', (): void => {
let walletAddressId: string

beforeEach(async (): Promise<void> => {
tenantId = (
await createTenant(deps)
).id
tenantId = (await createTenant(deps)).id
walletAddressId = (
await createWalletAddress(deps, {
assetId: asset.id
Expand Down Expand Up @@ -565,9 +563,7 @@ describe('OutgoingPayment Resolvers', (): void => {
}

beforeEach(async (): Promise<void> => {
tenantId = (
await createTenant(deps)
).id
tenantId = (await createTenant(deps)).id
})

test('success (metadata)', async (): Promise<void> => {
Expand Down Expand Up @@ -715,9 +711,7 @@ describe('OutgoingPayment Resolvers', (): void => {
const mockIncomingPaymentUrl = `https://${faker.internet.domainName()}/incoming-payments/${uuid()}`

beforeEach(async (): Promise<void> => {
tenantId = (
await createTenant(deps)
).id
tenantId = (await createTenant(deps)).id
})

test('create', async (): Promise<void> => {
Expand Down Expand Up @@ -999,9 +993,7 @@ describe('OutgoingPayment Resolvers', (): void => {
let tenantId: string

beforeEach(async (): Promise<void> => {
tenantId = (
await createTenant(deps)
).id
tenantId = (await createTenant(deps)).id
walletAddressId = (
await createWalletAddress(deps, {
assetId: asset.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ describe('Combined Payment Service', (): void => {
})

beforeEach(async (): Promise<void> => {
tenantId = (
await createTenant(deps)
).id
tenantId = (await createTenant(deps)).id
sendAsset = await createAsset(deps)
receiveAsset = await createAsset(deps)
sendWalletAddressId = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,7 @@ async function createOutgoingPayment(
description: 'Time to retrieve receiver in outgoing payment'
}
)
const receiver = await deps.receiverService.get(
payment.receiver
)
const receiver = await deps.receiverService.get(payment.receiver)
stopTimerReceiver()
if (!receiver) {
throw OutgoingPaymentError.InvalidQuote
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/open_payments/quote/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Quote Routes', (): void => {
walletAddressId,
client
}: {
tenantId: string,
tenantId: string
walletAddressId: string
client?: string
}): Promise<Quote> => {
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('Quote Routes', (): void => {
})

beforeEach(async (): Promise<void> => {
tenant = await createTenant(deps)
tenant = await createTenant(deps)
const { id: assetId } = await createAsset(deps, {
code: debitAmount.assetCode,
scale: debitAmount.assetScale
Expand Down
4 changes: 1 addition & 3 deletions packages/backend/src/open_payments/quote/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ describe('QuoteService', (): void => {
})

beforeEach(async (): Promise<void> => {
tenantId = (
await createTenant(deps)
).id
tenantId = (await createTenant(deps)).id
const { id: sendAssetId } = await createAsset(deps, {
code: debitAmount.assetCode,
scale: debitAmount.assetScale
Expand Down
8 changes: 2 additions & 6 deletions packages/backend/src/open_payments/quote/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ async function createQuote(
callName: 'QuoteService:create',
description: 'Time to create a quote'
})
const tenant = await deps.tenantService.get(
options.tenantId
)
const tenant = await deps.tenantService.get(options.tenantId)
if (!tenant) {
stopTimer()
return QuoteError.InvalidTenant
Expand Down Expand Up @@ -263,9 +261,7 @@ export async function resolveReceiver(
deps: ServiceDependencies,
options: CreateQuoteOptions
): Promise<Receiver> {
const receiver = await deps.receiverService.get(
options.receiver
)
const receiver = await deps.receiverService.get(options.receiver)
if (!receiver) {
deps.logger.info(
{ receiver: options.receiver },
Expand Down
14 changes: 5 additions & 9 deletions packages/backend/src/open_payments/receiver/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async function createLocalIncomingPayment(

async function getReceiver(
deps: ServiceDependencies,
url: string,
url: string
): Promise<Receiver | undefined> {
const stopTimer = deps.telemetry.startTimer('getReceiver', {
callName: 'ReceiverService:get'
Expand All @@ -148,10 +148,7 @@ async function getReceiver(
return receiver
}

const remoteIncomingPayment = await getRemoteIncomingPayment(
deps,
url
)
const remoteIncomingPayment = await getRemoteIncomingPayment(deps, url)
if (remoteIncomingPayment) {
const receiver = new Receiver(remoteIncomingPayment, false)
return receiver
Expand Down Expand Up @@ -223,11 +220,10 @@ export async function getLocalIncomingPayment(

async function getRemoteIncomingPayment(
deps: ServiceDependencies,
url: string,
url: string
): Promise<OpenPaymentsIncomingPaymentWithPaymentMethods | undefined> {
const incomingPaymentOrError = await deps.remoteIncomingPaymentService.get(
url
)
const incomingPaymentOrError =
await deps.remoteIncomingPaymentService.get(url)

if (isRemoteIncomingPaymentError(incomingPaymentOrError)) {
return undefined
Expand Down
8 changes: 4 additions & 4 deletions packages/backend/src/payment-method/handler/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('PaymentMethodHandlerService', (): void => {

describe('getQuote', (): void => {
test('calls ilpPaymentService for ILP payment type', async (): Promise<void> => {
const tenantId = ( await createTenant(deps) ).id
const tenantId = (await createTenant(deps)).id
const asset = await createAsset(deps)
const walletAddress = await createWalletAddress(deps, {
assetId: asset.id
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('PaymentMethodHandlerService', (): void => {
)
})
test('calls localPaymentService for local payment type', async (): Promise<void> => {
const tenantId = ( await createTenant(deps) ).id
const tenantId = (await createTenant(deps)).id
const asset = await createAsset(deps)
const walletAddress = await createWalletAddress(deps, {
assetId: asset.id
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('PaymentMethodHandlerService', (): void => {

describe('pay', (): void => {
test('calls ilpPaymentService for ILP payment type', async (): Promise<void> => {
const tenantId = ( await createTenant(deps) ).id
const tenantId = (await createTenant(deps)).id
const asset = await createAsset(deps)
const walletAddress = await createWalletAddress(deps, {
assetId: asset.id
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('PaymentMethodHandlerService', (): void => {
expect(ilpPaymentServicePaySpy).toHaveBeenCalledWith(options)
})
test('calls localPaymentService for local payment type', async (): Promise<void> => {
const tenantId = ( await createTenant(deps) ).id
const tenantId = (await createTenant(deps)).id
const asset = await createAsset(deps)
const walletAddress = await createWalletAddress(deps, {
assetId: asset.id
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/src/payment-method/local/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { IncomingPaymentService } from '../../open_payments/payment/incoming/ser
import { errorToMessage, TransferError } from '../../accounting/errors'
import { PaymentMethodHandlerError } from '../handler/errors'
import { ConvertError } from '../../rates/service'
import { v4 as uuid } from 'uuid'
import { createTenant } from '../../tests/tenant'

const nock = (global as unknown as { nock: typeof import('nock') }).nock
Expand Down Expand Up @@ -56,7 +55,7 @@ describe('LocalPaymentService', (): void => {
})

beforeEach(async (): Promise<void> => {
tenantId = ( await createTenant(deps) ).id
tenantId = (await createTenant(deps)).id
assetMap['USD'] = await createAsset(deps, {
code: 'USD',
scale: 2
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/shared/pagination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('Pagination', (): void => {
outgoingPaymentService = await deps.use('outgoingPaymentService')
quoteService = await deps.use('quoteService')

tenantId = (await createTenant(deps) ).id
tenantId = (await createTenant(deps)).id
const asset = await createAsset(deps)
defaultWalletAddress = await createWalletAddress(deps, {
assetId: asset.id
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/src/tests/outgoingPayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ export async function createOutgoingPaymentWithReceiver(

const outgoingPayment = await createOutgoingPayment(deps, {
//TODO fix this in outgoing payments changes
tenantId:
args.quoteOptions?.tenantId || uuid(),
tenantId: args.quoteOptions?.tenantId || uuid(),
walletAddressId: args.sendingWalletAddress.id,
method: args.method,
receiver: receiver.incomingPayment!.id!,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/webhook/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('Webhook Service', (): void => {
let events: WebhookEvent[] = []

beforeEach(async (): Promise<void> => {
tenantId = ( await createTenant(deps) ).id
tenantId = (await createTenant(deps)).id
walletAddressIn = await createWalletAddress(deps)
walletAddressOut = await createWalletAddress(deps)
incomingPaymentIds = [
Expand Down

0 comments on commit 5991a8c

Please sign in to comment.