Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 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.

36 changes: 0 additions & 36 deletions packages/auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,42 +105,6 @@ export function initIocContainer(
}
)

container.singleton(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, probably due to rebasing, this got duplicated a few times.

'tenantService',
async (deps: IocContract<AppServices>) => {
const [logger, knex] = await Promise.all([
deps.use('logger'),
deps.use('knex')
])

return createTenantService({ logger, knex })
}
)

container.singleton(
'tenantService',
async (deps: IocContract<AppServices>) => {
const [logger, knex] = await Promise.all([
deps.use('logger'),
deps.use('knex')
])

return createTenantService({ logger, knex })
}
)

container.singleton(
'tenantService',
async (deps: IocContract<AppServices>) => {
const [logger, knex] = await Promise.all([
deps.use('logger'),
deps.use('knex')
])

return createTenantService({ logger, knex })
}
)

container.singleton(
'accessService',
async (deps: IocContract<AppServices>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ exports.up = function (knex) {
table.uuid('tenantId').notNullable()
table.foreign('tenantId').references('id').inTable('tenants')
})
.table('grants', function (table) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grant's don't need tenantId - they're never queried on the backend by that filter, and the tenant it is for can be determined by the auth server URL path. Having the requirement explicitly in this table introduces some backwards compatibility issues.

table.uuid('tenantId').notNullable()
table.foreign('tenantId').references('id').inTable('tenants')
})
}

/**
Expand All @@ -48,8 +44,4 @@ exports.down = function (knex) {
table.dropForeign(['tenantId'])
table.dropColumn('tenantId')
})
.table('grants', function (table) {
table.dropForeign(['tenantId'])
table.dropColumn('tenantId')
})
}
32 changes: 16 additions & 16 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.

4 changes: 2 additions & 2 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 @@ -740,6 +740,7 @@ describe('OutgoingPayment Resolvers', (): void => {

const input = {
walletAddressId: payment.walletAddressId,
tenantId,
incomingPayment: mockIncomingPaymentUrl,
debitAmount: {
value: BigInt(56),
Expand Down Expand Up @@ -781,6 +782,7 @@ describe('OutgoingPayment Resolvers', (): void => {

const input = {
walletAddressId: uuid(),
tenantId,
incomingPayment: mockIncomingPaymentUrl,
debitAmount: {
value: BigInt(56),
Expand Down Expand Up @@ -832,6 +834,7 @@ describe('OutgoingPayment Resolvers', (): void => {

const input = {
walletAddressId: uuid(),
tenantId,
incomingPayment: mockIncomingPaymentUrl,
debitAmount: {
value: BigInt(56),
Expand Down
3 changes: 0 additions & 3 deletions packages/backend/src/graphql/resolvers/quote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ describe('Quote Resolvers', (): void => {
): Promise<QuoteModel> => {
return await createQuote(deps, {
walletAddressId,
tenantId,
receiver,
debitAmount: {
value: BigInt(56),
Expand Down Expand Up @@ -195,7 +194,6 @@ describe('Quote Resolvers', (): void => {
}
input = {
walletAddressId: uuid(),
tenantId: uuid(),
receiver,
debitAmount
}
Expand All @@ -217,7 +215,6 @@ describe('Quote Resolvers', (): void => {
)
const input = {
walletAddressId,
tenantId,
debitAmount: amount,
receiveAmount,
receiver
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/graphql/resolvers/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const createQuote: MutationResolvers<ApolloContext>['createQuote'] =
const quoteService = await ctx.container.use('quoteService')
const options: CreateQuoteOptions = {
walletAddressId: args.input.walletAddressId,
tenantId: args.input.tenantId,
receiver: args.input.receiver,
method: 'ilp'
}
Expand Down
44 changes: 0 additions & 44 deletions packages/backend/src/graphql/resolvers/tenant_endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { ApolloContext } from '../../app'
import { Pagination, SortOrder } from '../../shared/baseModel'
import { getPageInfo } from '../../shared/pagination'
import { EndpointType, TenantEndpoint } from '../../tenant/endpoints/model'
import {
ResolversTypes,
TenantResolvers,
TenantEndpoint as SchemaTenantEndpoint,
TenantEndpointType
} from '../generated/graphql'
Expand All @@ -14,45 +9,6 @@ export const mapTenantEndpointTypeToModelEndpointType = {
[EndpointType.WebhookBaseUrl]: TenantEndpointType.WebhookBaseUrl
}

export const getTenantEndpoints: TenantResolvers<ApolloContext>['endpoints'] =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolver not being used anymore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it leaves the service getTenantEndpointsPage method unused... remove?

async (
parent,
args,
ctx
): Promise<ResolversTypes['TenantEndpointsConnection']> => {
if (!parent.id) {
throw new Error('missing tenant id')
}
const tenantEndpointService = await ctx.container.use(
'tenantEndpointService'
)

const { sortOrder, ...pagination } = args
const order = sortOrder === 'ASC' ? SortOrder.Asc : SortOrder.Desc

const tenantEndpoints = await tenantEndpointService.getPage(
parent.id,
pagination,
order
)

console.log('TENANT ENDPOINTS: ', tenantEndpoints)

const pageInfo = await getPageInfo({
getPage: (pagination_?: Pagination, sortOrder_?: SortOrder) =>
tenantEndpointService.getPage(parent.id!, pagination_, sortOrder_),
page: tenantEndpoints
})

return {
pageInfo,
edges: tenantEndpoints.map((endpoint: TenantEndpoint) => ({
cursor: `${endpoint.tenantId}${endpoint.type}`,
node: tenantEndpointToGraphql(endpoint)
}))
}
}

export function tenantEndpointToGraphql(
tenantEndpoint: TenantEndpoint
): SchemaTenantEndpoint {
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,6 @@ input CreateQuoteInput {
receiver: String!
"Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)"
idempotencyKey: String
"ID of the tenant"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tenantId got removed from the quote resolver input for backwards compatibility issues and it can be retrieved from the wallet address anyways

Copy link
Contributor

@BlairCurrey BlairCurrey Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be retrieved from the wallet address anyways

I think perhaps this is the better pattern. It's simpler and I don't think we need to verify against the requestor's expectation for what the tenantId should be (ie, the tenantId being removed here).

I remember you mentioning that before and not having much of an opinion but I came across it myself when dealing with checking access for the createQuote resolver and felt like passing it in wasn't really providing any value, and it does make the gql input less complicated. Since before it was required for everyone but really only needed when an operator is making it on behalf of a tenant.

tenantId: ID!
}

type QuoteResponse {
Expand Down Expand Up @@ -1110,6 +1108,8 @@ input CreateOutgoingPaymentFromIncomingPaymentInput {
metadata: JSONObject
"Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)"
idempotencyKey: String
"ID of a tenant"
tenantId: ID!
}

input CreateIncomingPaymentInput {
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/open_payments/grant/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export class Grant extends BaseModel {
public managementId!: string
public accessType!: AccessType
public accessActions!: AccessAction[]
public tenantId!: string
public expiresAt?: Date | null
public deletedAt?: Date

Expand Down
Loading
Loading