Skip to content

Commit

Permalink
Merge a55dd6b into a02ae9e
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Nov 9, 2021
2 parents a02ae9e + a55dd6b commit 45081f5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/ThirdParty/ThirdParty.router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ describe('ThirdParty router', () => {
thirdParty: { name: 'a name', description: 'a description' },
}
fragments = [
{ id: '1', managers: ['0x1'], maxItems: 3, totalItems: 2, metadata },
{ id: '1', managers: ['0x1'], maxItems: '3', totalItems: '2', metadata },
{
id: '2',
managers: ['0x2', '0x3'],
maxItems: 2,
totalItems: 1,
maxItems: '2',
totalItems: '1',
metadata,
},
]
Expand Down
5 changes: 2 additions & 3 deletions src/ThirdParty/ThirdParty.router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { server } from 'decentraland-server'

import { Router } from '../common/Router'
import { withAuthentication, AuthRequest } from '../middleware/authentication'
import { AuthRequest, withAuthentication } from '../middleware/authentication'
import { thirdPartyAPI } from '../ethereum/api/thirdParty'
import { ThirdParty } from './ThirdParty.types'
import { toThirdParty } from './utils'
Expand All @@ -19,13 +19,12 @@ export class ThirdPartyRouter extends Router {
}

async getThirdParties(req: AuthRequest): Promise<ThirdParty[]> {
let manager = ''
let manager: string | undefined
try {
manager = server.extractFromReq(req, 'manager')
} catch (e) {
// We support empty manager filters on the query string
}

const fragments = await thirdPartyAPI.fetchThirdParties(manager)
return fragments.map(toThirdParty)
}
Expand Down
8 changes: 4 additions & 4 deletions src/ThirdParty/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('toThirdParty', () => {
fragment = {
id: 'some:id',
managers: ['0x1', '0x2'],
maxItems: 1,
totalItems: 1,
maxItems: '1',
totalItems: '1',
metadata: {
type: ThirdPartyMetadataType.THIRD_PARTY_V1,
thirdParty: {
Expand Down Expand Up @@ -47,8 +47,8 @@ describe('toThirdParty', () => {
fragment = {
id: 'some:other:id',
managers: ['0x2'],
maxItems: 2,
totalItems: 1,
maxItems: '2',
totalItems: '1',
metadata: {
type: ThirdPartyMetadataType.THIRD_PARTY_V1,
thirdParty: null,
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/api/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ export type CollectionFragment = {
export type ThirdPartyFragment = {
id: string
managers: string[]
maxItems: number
totalItems: number
maxItems: string
totalItems: string
metadata: ThirdPartyMetadata
}

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/api/thirdParty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ const getThirdPartyCollectionItemsQuery = () => gql`

export class ThirdPartyAPI extends BaseGraphAPI {
fetchThirdParties = async (
manager: string = ''
manager?: string
): Promise<ThirdPartyFragment[]> => {
return this.paginate(['thirdParties'], {
query: getThirdPartiesQuery(),
variables: { managers: [manager.toLowerCase()] },
variables: { managers: manager ? [manager.toLowerCase()] : [] },
})
}

Expand Down

0 comments on commit 45081f5

Please sign in to comment.