Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());
bru.setEnvVar("quoteDebitAmount", JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ get {
auth: none
}

query {
params:query {
first: 10
wallet-address: {{receiverWalletAddress}}
~cursor: ea3bf38f-2719-4473-a0f7-4ba967d1d81b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ body:graphql:vars {
},
"incomingAmount": null,
"walletAddressId": "{{walletAddressId}}"
}
},
"tenantId": "{{tenantId}}"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
meta {
name: Get Incoming Payment By Tenant
type: graphql
seq: 54
}

post {
url: {{RafikiGraphqlHost}}/{{tenantId}}/graphql
body: graphql
auth: none
}

body:graphql {
query GetIncomingPayment($id: String!) {
incomingPayment(id: $id) {
id
walletAddressId
client
state
expiresAt
incomingAmount {
value
assetCode
assetScale
}
receivedAmount {
value
assetCode
assetScale
}
metadata
createdAt
}
}
}

body:graphql:vars {
{
"id": "{{incomingPaymentId}}",
"tenantId": "{{tenantId}}"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
3 changes: 3 additions & 0 deletions localenv/mock-account-servicing-entity/generated/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.schema
.alterTable('incomingPayments', function (table) {
table.uuid('tenantId')
table.foreign('tenantId').references('id').inTable('tenants')
})
.then(() => {
knex.raw(
`UPDATE "incomingPayments" SET "tenantId" = (SELECT id from "tenants" LIMIT 1)`
)
})
.then(() => {
knex.schema.alterTable('incomingPayments', function (table) {
table.uuid('tenantId').notNullable()
})
})
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.schema.alterTable('incomingPayments', function (table) {
table.dropForeign('tenantId')
table.dropColumn('tenantId')
})
}
8 changes: 4 additions & 4 deletions packages/backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export class App {
// POST /incoming-payments
// Create incoming payment
router.post<DefaultState, SignedCollectionContext<IncomingCreateBody>>(
'/incoming-payments',
'/:tenantId/incoming-payments',
createValidatorMiddleware<
ContextType<SignedCollectionContext<IncomingCreateBody>>
>(
Expand All @@ -526,7 +526,7 @@ export class App {
DefaultState,
SignedCollectionContext<never, GetCollectionQuery>
>(
'/incoming-payments',
'/:tenantId/incoming-payments',
createValidatorMiddleware<
ContextType<SignedCollectionContext<never, GetCollectionQuery>>
>(
Expand Down Expand Up @@ -625,7 +625,7 @@ export class App {
// GET /incoming-payments/{id}
// Read incoming payment
router.get<DefaultState, SubresourceContextWithAuthenticatedStatus>(
'/incoming-payments/:id',
'/:tenantId/incoming-payments/:id',
createValidatorMiddleware<
ContextType<SubresourceContextWithAuthenticatedStatus>
>(
Expand All @@ -650,7 +650,7 @@ export class App {
// POST /incoming-payments/{id}/complete
// Complete incoming payment
router.post<DefaultState, SignedSubresourceContext>(
'/incoming-payments/:id/complete',
'/:tenantId/incoming-payments/:id/complete',
createValidatorMiddleware<ContextType<SignedSubresourceContext>>(
resourceServerSpec,
{
Expand Down
12 changes: 12 additions & 0 deletions packages/backend/src/graphql/generated/graphql.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/backend/src/graphql/generated/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ describe('Payment', (): void => {
})
const incomingPayment = await createIncomingPayment(deps, {
walletAddressId: inWalletAddressId,
client: client
client: client,
tenantId: Config.operatorTenantId
})

const query = await appContainer.apolloClient
Expand Down
29 changes: 19 additions & 10 deletions packages/backend/src/graphql/resolvers/incoming_payment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ describe('Incoming Payment Resolver', (): void => {
let incomingPaymentService: IncomingPaymentService
let accountingService: AccountingService
let asset: Asset
let tenantId: string

beforeAll(async (): Promise<void> => {
deps = await initIocContainer(Config)
appContainer = await createTestApp(deps)
incomingPaymentService = await deps.use('incomingPaymentService')
accountingService = await deps.use('accountingService')
asset = await createAsset(deps)
tenantId = Config.operatorTenantId
})

afterAll(async (): Promise<void> => {
Expand Down Expand Up @@ -78,7 +80,8 @@ describe('Incoming Payment Resolver', (): void => {
metadata: {
description: `IncomingPayment`,
externalRef: '#123'
}
},
tenantId
}),
pagedQuery: 'incomingPayments',
parent: {
Expand Down Expand Up @@ -118,7 +121,8 @@ describe('Incoming Payment Resolver', (): void => {
client,
metadata,
expiresAt,
incomingAmount
incomingAmount,
tenantId
})

const createSpy = jest
Expand Down Expand Up @@ -167,7 +171,7 @@ describe('Incoming Payment Resolver', (): void => {
query.data?.createIncomingPayment
)

expect(createSpy).toHaveBeenCalledWith(input)
expect(createSpy).toHaveBeenCalledWith({ ...input, tenantId })
expect(query).toEqual({
__typename: 'IncomingPaymentResponse',
payment: {
Expand Down Expand Up @@ -237,7 +241,7 @@ describe('Incoming Payment Resolver', (): void => {
})
)
}
expect(createSpy).toHaveBeenCalledWith(input)
expect(createSpy).toHaveBeenCalledWith({ ...input, tenantId })
})

test('Internal server error', async (): Promise<void> => {
Expand Down Expand Up @@ -282,7 +286,10 @@ describe('Incoming Payment Resolver', (): void => {
})
)
}
expect(createSpy).toHaveBeenCalledWith(input)
expect(createSpy).toHaveBeenCalledWith({
...input,
tenantId
})
})
})

Expand All @@ -299,7 +306,8 @@ describe('Incoming Payment Resolver', (): void => {
value: BigInt(56),
assetCode: asset.code,
assetScale: asset.scale
}
},
tenantId
})
}

Expand Down Expand Up @@ -475,7 +483,8 @@ describe('Incoming Payment Resolver', (): void => {
walletAddressId,
metadata,
expiresAt,
incomingAmount
incomingAmount,
tenantId
})
const input = {
id: payment.id,
Expand Down Expand Up @@ -510,7 +519,7 @@ describe('Incoming Payment Resolver', (): void => {
query.data?.updateIncomingPayment
)

expect(createSpy).toHaveBeenCalledWith(input)
expect(createSpy).toHaveBeenCalledWith({ ...input, tenantId })
expect(query).toEqual({
__typename: 'IncomingPaymentResponse',
payment: {
Expand Down Expand Up @@ -565,7 +574,7 @@ describe('Incoming Payment Resolver', (): void => {
})
)
}
expect(createSpy).toHaveBeenCalledWith(input)
expect(createSpy).toHaveBeenCalledWith({ ...input, tenantId })
})

test('Internal server error', async (): Promise<void> => {
Expand Down Expand Up @@ -611,7 +620,7 @@ describe('Incoming Payment Resolver', (): void => {
})
)
}
expect(createSpy).toHaveBeenCalledWith(input)
expect(createSpy).toHaveBeenCalledWith({ ...input, tenantId })
})
})
})
Loading
Loading