Skip to content

Commit 069f002

Browse files
committed
feat(order): add order resolver and enhance marketplace order services
- Implements and polishes marketplace order entities handlers. - Enhanced MarketplaceOrdersService with comprehensive documentation and new methods for order management - Updated test coverage for OrderResolver and MarketplaceOrdersService, including error handling and mock data generation - Introduced new utility functions for generating mock orders and collections
1 parent b796a81 commit 069f002

20 files changed

+1304
-263
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@web3-storage/w3up-client": "^16.0.0",
5555
"axios": "^1.6.5",
5656
"cors": "^2.8.5",
57+
"date-fns": "^4.1.0",
5758
"ethers": "^6.12.2",
5859
"express": "^4.19.2",
5960
"file-type": "^19.6.0",

pnpm-lock.yaml

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

src/client/kysely.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ import type { CachingDatabase } from "../types/kyselySupabaseCaching.js";
66
import type { DataDatabase } from "../types/kyselySupabaseData.js";
77
import { cachingDatabaseUrl, dataDatabaseUrl } from "../utils/constants.js";
88
import { container } from "tsyringe";
9+
import { format } from "date-fns";
10+
11+
pkg.types.setTypeParser(pkg.types.builtins.TIMESTAMPTZ, (val) => {
12+
return format(new Date(val), "t");
13+
});
14+
15+
pkg.types.setTypeParser(pkg.types.builtins.TIMESTAMP, (val) => {
16+
return format(new Date(val), "t");
17+
});
918

1019
export abstract class BaseKyselyService<
1120
DB extends CachingDatabase | DataDatabase,

src/graphql/schemas/resolvers/composed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ContractResolver } from "../../../services/graphql/resolvers/contractRe
44
import { FractionResolver } from "../../../services/graphql/resolvers/fractionResolver.js";
55
import { AttestationResolver } from "../../../services/graphql/resolvers/attestationResolver.js";
66
import { AttestationSchemaResolver } from "../../../services/graphql/resolvers/attestationSchemaResolver.js";
7-
import { OrderResolver } from "./orderResolver.js";
7+
import { OrderResolver } from "../../../services/graphql/resolvers/orderResolver.js";
88
import { HyperboardResolver } from "./hyperboardResolver.js";
99
import { AllowlistRecordResolver } from "../../../services/graphql/resolvers/allowlistRecordResolver.js";
1010
import { SalesResolver } from "../../../services/graphql/resolvers/salesResolver.js";

src/graphql/schemas/resolvers/orderResolver.ts

Lines changed: 0 additions & 124 deletions
This file was deleted.

src/graphql/schemas/typeDefs/orderTypeDefs.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Field, ObjectType } from "type-graphql";
2-
import { EthBigInt } from "../../scalars/ethBigInt.js";
1+
import { Field, Int, ObjectType } from "type-graphql";
32
import { DataResponse } from "../../../lib/graphql/DataResponse.js";
3+
import { EthBigInt } from "../../scalars/ethBigInt.js";
44
import { BasicTypeDef } from "./baseTypes/basicTypeDef.js";
55
import { HypercertBaseType } from "./baseTypes/hypercertBaseType.js";
66

@@ -11,7 +11,7 @@ export class Order extends BasicTypeDef {
1111
@Field()
1212
hypercert_id?: string;
1313
@Field()
14-
createdAt?: string;
14+
createdAt?: number;
1515
@Field()
1616
quoteType?: number;
1717
@Field()
@@ -48,8 +48,8 @@ export class Order extends BasicTypeDef {
4848
amounts?: number[];
4949
@Field()
5050
invalidated?: boolean;
51-
@Field(() => [String], { nullable: true })
52-
validator_codes?: string[];
51+
@Field(() => [Int], { nullable: true })
52+
validator_codes?: number[];
5353

5454
@Field()
5555
pricePerPercentInUSD?: string;

src/lib/db/queryModifiers/buildWhereCondition.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,31 @@ export function buildWhereCondition<
240240
and ${nestedConditions}
241241
)`,
242242
);
243+
} else if (tableName === "collections" && relatedTable === "users") {
244+
// TODO: This is a hack to support the collections.users relation
245+
// TODO: This should be removed once we have a proper relation in TABLE_RELATIONS or a view in the database
246+
conditions.push(
247+
sql<SqlBool>`exists (
248+
select 1 from "users"
249+
inner join "collection_admins" on "users".id = "collection_admins".user_id
250+
inner join "collections" on "collections".id = "collection_admins".collection_id
251+
and ${nestedConditions}
252+
)`,
253+
);
254+
} else if (
255+
tableName === "collections" &&
256+
relatedTable === "blueprints_with_admins"
257+
) {
258+
// TODO: This is a hack to support the collections.blueprints relation
259+
// TODO: This should be removed once we have a proper relation in TABLE_RELATIONS or a view in the database
260+
conditions.push(
261+
sql<SqlBool>`exists (
262+
select from "blueprints_with_admins"
263+
inner join "collection_blueprints" on "blueprints_with_admins".id = "collection_blueprints".blueprint_id
264+
inner join "collections" on "collections".id = "collection_blueprints".collection_id
265+
and ${nestedConditions}
266+
)`,
267+
);
243268
} else {
244269
// Fall back to default foreign key pattern for standard relationships
245270
conditions.push(

src/lib/db/queryModifiers/tableRelations.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ export const TABLE_RELATIONS: TableRelations = {
3535
joinCondition: "claims.hypercert_id = fractions_view.hypercert_id",
3636
},
3737
},
38-
collections: {
39-
users: {
40-
joinCondition:
41-
"users.id = collection_admins.user_id AND collections.id = collection_admins.collection_id",
42-
},
43-
},
4438
sales: {
4539
claims: {
4640
joinCondition: "claims.hypercert_id = sales.hypercert_id",

src/services/database/entities/CollectionEntityService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ export class CollectionService {
228228
hidden: eb.ref("excluded.hidden"),
229229
})),
230230
)
231+
.returningAll()
231232
.execute();
232233
}
233234

0 commit comments

Comments
 (0)