Skip to content

Commit 8ef2027

Browse files
committed
feat: tenanted quotes - first iteration with dummy tenant
1 parent ea7e660 commit 8ef2027

File tree

45 files changed

+497
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+497
-76
lines changed

bruno/collections/Rafiki/Examples/Open Payments/Create Quote.bru

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ meta {
55
}
66

77
post {
8-
url: {{senderOpenPaymentsHost}}/quotes
8+
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/quotes
99
body: json
1010
auth: none
1111
}
@@ -17,7 +17,7 @@ headers {
1717
body:json {
1818
{
1919
"walletAddress": "{{senderWalletAddress}}",
20-
"receiver": "{{receiverOpenPaymentsHost}}/incoming-payments/{{incomingPaymentId}}",
20+
"receiver": "{{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments/{{incomingPaymentId}}",
2121
"method": "ilp"
2222
}
2323
}

bruno/collections/Rafiki/Open Payments APIs/Quotes/Create Quote.bru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ meta {
55
}
66

77
post {
8-
url: {{senderOpenPaymentsHost}}/quotes
8+
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/quotes
99
body: json
1010
auth: none
1111
}

bruno/collections/Rafiki/Open Payments APIs/Quotes/Get Quote.bru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ meta {
55
}
66

77
get {
8-
url: {{senderOpenPaymentsHost}}/quotes/{{quoteId}}
8+
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/quotes/{{quoteId}}
99
body: none
1010
auth: none
1111
}

localenv/mock-account-servicing-entity/generated/graphql.ts

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @param { import("knex").Knex } knex
3+
* @returns { Promise<void> }
4+
*/
5+
exports.up = function (knex) {
6+
return knex('tenants').insert({
7+
id: '8e1db008-ab2f-4f1d-8c44-593354084100',
8+
9+
publicName: 'Super tenant',
10+
apiSecret: 'secret'
11+
})
12+
}
13+
14+
/**
15+
* @param { import("knex").Knex } knex
16+
* @returns { Promise<void> }
17+
*/
18+
exports.down = function (knex) {
19+
return knex('tenants')
20+
.where('id', '8e1db008-ab2f-4f1d-8c44-593354084100')
21+
.del()
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @param { import("knex").Knex } knex
3+
* @returns { Promise<void> }
4+
*/
5+
exports.up = function (knex) {
6+
return knex.schema.alterTable('quotes', function (table) {
7+
// TODO update default value
8+
table.uuid('tenantId').notNullable()
9+
table.foreign('tenantId').references('tenants.id').onDelete('CASCADE')
10+
})
11+
}
12+
13+
/**
14+
* @param { import("knex").Knex } knex
15+
* @returns { Promise<void> }
16+
*/
17+
exports.down = function (knex) {
18+
return knex.schema.alterTable('quotes', function (table) {
19+
table.dropForeign('tenantId')
20+
table.dropColumn('tenantId')
21+
})
22+
}

packages/backend/src/graphql/generated/graphql.schema.json

Lines changed: 65 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend/src/graphql/generated/graphql.ts

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend/src/graphql/resolvers/combined_payments.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('Payment', (): void => {
2323
let deps: IocContract<AppServices>
2424
let appContainer: TestContainer
2525
let asset: Asset
26+
let tenantId: string
2627

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

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

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

5658
const client = 'client-test'
5759
const outgoingPayment = await createOutgoingPayment(deps, {
60+
tenantId,
5861
walletAddressId: outWalletAddressId,
5962
client: client,
6063
method: 'ilp',
@@ -161,6 +164,7 @@ describe('Payment', (): void => {
161164

162165
const client = 'client-test-type-wallet-address'
163166
const outgoingPayment = await createOutgoingPayment(deps, {
167+
tenantId,
164168
walletAddressId: outWalletAddressId,
165169
client: client,
166170
method: 'ilp',
@@ -171,6 +175,7 @@ describe('Payment', (): void => {
171175
assetId: asset.id
172176
})
173177
await createOutgoingPayment(deps, {
178+
tenantId,
174179
walletAddressId: outWalletAddressId2,
175180
client: client,
176181
method: 'ilp',

packages/backend/src/graphql/resolvers/liquidity.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,11 +1742,13 @@ describe('Liquidity Resolvers', (): void => {
17421742
)
17431743

17441744
describe('Event Liquidity', (): void => {
1745+
let tenantId: string
17451746
let walletAddress: WalletAddress
17461747
let incomingPayment: IncomingPayment
17471748
let payment: OutgoingPayment
17481749

17491750
beforeEach(async (): Promise<void> => {
1751+
tenantId = '8e1db008-ab2f-4f1d-8c44-593354084100'
17501752
walletAddress = await createWalletAddress(deps)
17511753
const walletAddressId = walletAddress.id
17521754
incomingPayment = await createIncomingPayment(deps, {
@@ -1759,6 +1761,7 @@ describe('Liquidity Resolvers', (): void => {
17591761
expiresAt: new Date(Date.now() + 60 * 1000)
17601762
})
17611763
payment = await createOutgoingPayment(deps, {
1764+
tenantId,
17621765
walletAddressId,
17631766
method: 'ilp',
17641767
receiver: `${Config.openPaymentsUrl}/incoming-payments/${uuid()}`,
@@ -2152,11 +2155,13 @@ describe('Liquidity Resolvers', (): void => {
21522155
})
21532156

21542157
describe('Payment Liquidity', (): void => {
2158+
let tenantId: string
21552159
let walletAddress: WalletAddress
21562160
let incomingPayment: IncomingPayment
21572161
let outgoingPayment: OutgoingPayment
21582162

21592163
beforeEach(async (): Promise<void> => {
2164+
tenantId = '8e1db008-ab2f-4f1d-8c44-593354084100'
21602165
walletAddress = await createWalletAddress(deps)
21612166
const walletAddressId = walletAddress.id
21622167
incomingPayment = await createIncomingPayment(deps, {
@@ -2169,6 +2174,7 @@ describe('Liquidity Resolvers', (): void => {
21692174
expiresAt: new Date(Date.now() + 60 * 1000)
21702175
})
21712176
outgoingPayment = await createOutgoingPayment(deps, {
2177+
tenantId,
21722178
walletAddressId,
21732179
method: 'ilp',
21742180
receiver: `${

0 commit comments

Comments
 (0)