Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): tenanted quotes and outgoing payments #3171

Merged
merged 43 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8ef2027
feat: tenanted quotes - first iteration with dummy tenant
sanducb Dec 10, 2024
77a9a26
Merge branch '2893/multi-tenancy-v1' of https://github.com/interledge…
sanducb Dec 12, 2024
ed89fb9
feat: tenanted quotes - replace hardcoded tenantId values with creati…
sanducb Dec 17, 2024
5991a8c
feat: tenanted quotes - formatting
sanducb Dec 17, 2024
1fb446d
feat: tenanted quotes - fix outgoing payments service test
sanducb Dec 17, 2024
8dd4ebd
Merge branch '2893/multi-tenancy-v1' of https://github.com/interledge…
sanducb Dec 18, 2024
2194e97
WIP
sanducb Dec 28, 2024
2780cb9
Merge branch '2893/multi-tenancy-v1' of https://github.com/interledge…
sanducb Jan 21, 2025
3c574ee
Fix tests - TODOs not resolved yet
sanducb Jan 21, 2025
e689be9
Merge branch '2893/multi-tenancy-v1' of https://github.com/interledge…
sanducb Jan 28, 2025
6ede5ea
feat: tenanted quotes and outgoing payments - update resolvers and fi…
sanducb Jan 31, 2025
eaba290
feat: tenanted quotes and outgoing payments - remove unnecessary comm…
sanducb Jan 31, 2025
d8bbefb
feat: tenanted quotes and outgoing payments - fix integration tests
sanducb Feb 4, 2025
8844e14
feat: tenanted quotes and outgoing payments - fix vulnerabilities scan
sanducb Feb 4, 2025
69279c0
feat: tenanted quotes and outgoing payments - partially fix vulnerabi…
sanducb Feb 4, 2025
b9323cf
feat: tenanted quotes and outgoing payments - fix get routes for quot…
sanducb Feb 4, 2025
c0b7af7
feat: tenanted quotes and outgoing payments - fix outgoing payments r…
sanducb Feb 5, 2025
0adcf53
chore: fix docker image scans (#3272)
mkurapov Feb 5, 2025
f72390f
feat: tenanted quotes and outgoing payments - remove tenantId from IL…
sanducb Feb 6, 2025
c0ca55c
feat: tenanted quotes and outgoing payments - remove tenantId from St…
sanducb Feb 6, 2025
babf2bb
Merge branch '2893/multi-tenancy-v1' of https://github.com/interledge…
sanducb Feb 6, 2025
a8b8f73
feat: tenanted quotes and outgoing payments - fix unit tests
sanducb Feb 6, 2025
6b00c00
feat: tenanted quotes and outgoing payments - remove tenantId from Gr…
sanducb Feb 10, 2025
cec31f8
feat: tenanted quotes and outgoing payments - format
sanducb Feb 10, 2025
6eedfe6
Merge branch '2893/multi-tenancy-v1' of https://github.com/interledge…
sanducb Feb 10, 2025
274fd5b
feat: tenanted quotes and outgoing payments - remove tenantId from in…
sanducb Feb 10, 2025
b9324cd
feat: tenanted quotes and outgoing payments - remove unnecessary tena…
sanducb Feb 10, 2025
df90532
Merge branch '2893/multi-tenancy-v1' of https://github.com/interledge…
sanducb Feb 10, 2025
30e608f
feat: tenanted quotes and outgoing payments - update Bruno collection
sanducb Feb 10, 2025
06d0d18
feat: tenanted quotes and outgoing payments - address PR comments
sanducb Feb 12, 2025
092e15c
Merge branch '2893/multi-tenancy-v1' of https://github.com/interledge…
sanducb Feb 12, 2025
dd7299c
feat: tenanted quotes and outgoing payments - fix Bruno collection me…
sanducb Feb 12, 2025
799026a
feat: tenanted quotes and outgoing payments - add tenantId to outgoin…
sanducb Feb 12, 2025
f4b141e
feat: tenanted quotes and outgoing payments - update comments for Gra…
sanducb Feb 13, 2025
1376e62
feat: tenanted quotes and outgoing payments - update quote resolver c…
sanducb Feb 13, 2025
f02d1d7
feat: tenanted quotes and outgoing payments - add tenantId to outgoin…
sanducb Feb 14, 2025
59b6f05
feat: tenanted quotes and outgoing payments - add test for getting ou…
sanducb Feb 17, 2025
96816dc
feat: tenanted quotes and outgoing payments - modify get outgoing pay…
sanducb Feb 17, 2025
1499e5e
feat: tenanted quotes and outgoing payments - add test for getting WA…
sanducb Feb 17, 2025
f16b26c
feat: tenanted quotes and outgoing payments - remove unused import
sanducb Feb 17, 2025
3d99892
Merge branch '2893/multi-tenancy-v1' of https://github.com/interledge…
sanducb Feb 17, 2025
eac6e59
feat: tenanted quotes and outgoing payments - remove unused import
sanducb Feb 17, 2025
ec3d256
feat: tenanted quotes and outgoing payments - format
sanducb Feb 17, 2025
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 @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path );
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path );
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path );
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path );
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path );
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
8 changes: 8 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('quotes', (table) => {
table.uuid('tenantId').references('tenants.id').index()
})
.then(() => {
return knex.raw(
`UPDATE "quotes" SET "tenantId" = (SELECT id from "tenants" LIMIT 1)`
)
})
.then(() => {
return knex.schema.alterTable('quotes', (table) => {
table.uuid('tenantId').notNullable().alter()
})
})
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return Promise.all([
knex.schema.alterTable('quotes', function (table) {
table.dropColumn('tenantId')
})
])
}
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('outgoingPayments', (table) => {
table.uuid('tenantId').references('tenants.id').index()
})
.then(() => {
return knex.raw(
`UPDATE "outgoingPayments" SET "tenantId" = (SELECT id from "tenants" LIMIT 1)`
)
})
.then(() => {
return knex.schema.alterTable('outgoingPayments', (table) => {
table.uuid('tenantId').notNullable().alter()
})
})
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return Promise.all([
knex.schema.alterTable('outgoingPayments', function (table) {
table.dropColumn('tenantId')
})
])
}
10 changes: 5 additions & 5 deletions packages/backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ export class App {
// POST /outgoing-payment
// Create outgoing payment
router.post<DefaultState, SignedCollectionContext<OutgoingCreateBody>>(
'/outgoing-payments',
'/:tenantId/outgoing-payments',
createValidatorMiddleware<
ContextType<SignedCollectionContext<OutgoingCreateBody>>
>(
Expand All @@ -577,7 +577,7 @@ export class App {
DefaultState,
SignedCollectionContext<never, GetCollectionQuery>
>(
'/outgoing-payments',
'/:tenantId/outgoing-payments',
createValidatorMiddleware<
ContextType<SignedCollectionContext<never, GetCollectionQuery>>
>(
Expand All @@ -601,7 +601,7 @@ export class App {
// POST /quotes
// Create quote
router.post<DefaultState, SignedCollectionContext<QuoteCreateBody>>(
'/quotes',
'/:tenantId/quotes',
createValidatorMiddleware<
ContextType<SignedCollectionContext<QuoteCreateBody>>
>(
Expand Down Expand Up @@ -672,7 +672,7 @@ export class App {
// GET /outgoing-payments/{id}
// Read outgoing payment
router.get<DefaultState, SignedSubresourceContext>(
'/outgoing-payments/:id',
'/:tenantId/outgoing-payments/:id',
createValidatorMiddleware<ContextType<SignedSubresourceContext>>(
resourceServerSpec,
{
Expand All @@ -694,7 +694,7 @@ export class App {
// GET /quotes/{id}
// Read quote
router.get<DefaultState, SignedSubresourceContext>(
'/quotes/:id',
'/:tenantId/quotes/:id',
createValidatorMiddleware<ContextType<SignedSubresourceContext>>(
resourceServerSpec,
{
Expand Down
52 changes: 52 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.

8 changes: 8 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 @@ -56,6 +56,7 @@ describe('Payment', (): void => {

const client = 'client-test'
const outgoingPayment = await createOutgoingPayment(deps, {
tenantId: Config.operatorTenantId,
walletAddressId: outWalletAddressId,
client: client,
method: 'ilp',
Expand Down Expand Up @@ -164,6 +165,7 @@ describe('Payment', (): void => {

const client = 'client-test-type-wallet-address'
const outgoingPayment = await createOutgoingPayment(deps, {
tenantId: Config.operatorTenantId,
walletAddressId: outWalletAddressId,
client: client,
method: 'ilp',
Expand All @@ -175,6 +177,7 @@ describe('Payment', (): void => {
assetId: asset.id
})
await createOutgoingPayment(deps, {
tenantId: Config.operatorTenantId,
walletAddressId: outWalletAddressId2,
client: client,
method: 'ilp',
Expand Down
6 changes: 5 additions & 1 deletion packages/backend/src/graphql/resolvers/liquidity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1743,13 +1743,15 @@ describe('Liquidity Resolvers', (): void => {
)

describe('Event Liquidity', (): void => {
let tenantId: string
let walletAddress: WalletAddress
let incomingPayment: IncomingPayment
let payment: OutgoingPayment

beforeEach(async (): Promise<void> => {
tenantId = Config.operatorTenantId
walletAddress = await createWalletAddress(deps, {
tenantId: Config.operatorTenantId
tenantId
})
const walletAddressId = walletAddress.id
incomingPayment = await createIncomingPayment(deps, {
Expand All @@ -1762,6 +1764,7 @@ describe('Liquidity Resolvers', (): void => {
expiresAt: new Date(Date.now() + 60 * 1000)
})
payment = await createOutgoingPayment(deps, {
tenantId,
walletAddressId,
method: 'ilp',
receiver: `${Config.openPaymentsUrl}/incoming-payments/${uuid()}`,
Expand Down Expand Up @@ -2174,6 +2177,7 @@ describe('Liquidity Resolvers', (): void => {
expiresAt: new Date(Date.now() + 60 * 1000)
})
outgoingPayment = await createOutgoingPayment(deps, {
tenantId: Config.operatorTenantId,
walletAddressId,
method: 'ilp',
receiver: `${
Expand Down
Loading
Loading