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 #3171

Draft
wants to merge 1 commit into
base: 2893/multi-tenancy-v1
Choose a base branch
from
Draft
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 @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsHost}}/quotes
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/quotes
body: json
auth: none
}
Expand All @@ -17,7 +17,7 @@ headers {
body:json {
{
"walletAddress": "{{senderWalletAddress}}",
"receiver": "{{receiverOpenPaymentsHost}}/incoming-payments/{{incomingPaymentId}}",
"receiver": "{{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments/{{incomingPaymentId}}",
"method": "ilp"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsHost}}/quotes
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/quotes
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{senderOpenPaymentsHost}}/quotes/{{quoteId}}
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/quotes/{{quoteId}}
body: none
auth: none
}
Expand Down
13 changes: 10 additions & 3 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.

22 changes: 22 additions & 0 deletions packages/backend/migrations/20241203140018_seed_tenant_operator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex('tenants').insert({
id: '8e1db008-ab2f-4f1d-8c44-593354084100',
email: 'admin@example.com',
publicName: 'Super tenant',
apiSecret: 'secret'
})
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex('tenants')
.where('id', '8e1db008-ab2f-4f1d-8c44-593354084100')
.del()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.schema.alterTable('quotes', function (table) {
// TODO update default value
table.uuid('tenantId').notNullable()
table.foreign('tenantId').references('tenants.id').onDelete('CASCADE')
})
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.schema.alterTable('quotes', function (table) {
table.dropForeign('tenantId')
table.dropColumn('tenantId')
})
}
66 changes: 65 additions & 1 deletion 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.

13 changes: 10 additions & 3 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 @@ -23,6 +23,7 @@ describe('Payment', (): void => {
let deps: IocContract<AppServices>
let appContainer: TestContainer
let asset: Asset
let tenantId: string

beforeAll(async (): Promise<void> => {
deps = initIocContainer(Config)
Expand All @@ -31,6 +32,7 @@ describe('Payment', (): void => {

beforeEach(async (): Promise<void> => {
asset = await createAsset(deps)
tenantId = '8e1db008-ab2f-4f1d-8c44-593354084100'
})

afterEach(async (): Promise<void> => {
Expand All @@ -55,6 +57,7 @@ describe('Payment', (): void => {

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

const client = 'client-test-type-wallet-address'
const outgoingPayment = await createOutgoingPayment(deps, {
tenantId,
walletAddressId: outWalletAddressId,
client: client,
method: 'ilp',
Expand All @@ -171,6 +175,7 @@ describe('Payment', (): void => {
assetId: asset.id
})
await createOutgoingPayment(deps, {
tenantId,
walletAddressId: outWalletAddressId2,
client: client,
method: 'ilp',
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/graphql/resolvers/liquidity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1742,11 +1742,13 @@ 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 = '8e1db008-ab2f-4f1d-8c44-593354084100'
walletAddress = await createWalletAddress(deps)
const walletAddressId = walletAddress.id
incomingPayment = await createIncomingPayment(deps, {
Expand All @@ -1759,6 +1761,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 @@ -2152,11 +2155,13 @@ describe('Liquidity Resolvers', (): void => {
})

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

beforeEach(async (): Promise<void> => {
tenantId = '8e1db008-ab2f-4f1d-8c44-593354084100'
walletAddress = await createWalletAddress(deps)
const walletAddressId = walletAddress.id
incomingPayment = await createIncomingPayment(deps, {
Expand All @@ -2169,6 +2174,7 @@ describe('Liquidity Resolvers', (): void => {
expiresAt: new Date(Date.now() + 60 * 1000)
})
outgoingPayment = await createOutgoingPayment(deps, {
tenantId,
walletAddressId,
method: 'ilp',
receiver: `${
Expand Down
Loading
Loading