Skip to content

Commit ff9aa3e

Browse files
committed
feat(graphql): add 'burned' field to various types and inputs
- Introduced a 'burned' Boolean field to AllowlistRecordHypercertWhereInput, AttestationHypercertWhereInput, CollectionHypercertWhereInput, Fraction, Hypercert, HypercertBaseType, and several other input types. - Updated FractionSortOptions and HypercertSortOptions to include sorting by 'burned'. - Enhanced database entity definitions to accommodate the new 'burned' field in relevant tables and views.
1 parent 1cbf4ac commit ff9aa3e

File tree

11 files changed

+133
-25
lines changed

11 files changed

+133
-25
lines changed

lib/hypercerts-indexer

Submodule hypercerts-indexer updated 56 files

schema.graphql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type AllowlistRecord {
4444

4545
input AllowlistRecordHypercertWhereInput {
4646
attestations_count: NumberSearchOptions
47+
burned: BooleanSearchOptions
4748
creation_block_number: BigIntSearchOptions
4849
creation_block_timestamp: BigIntSearchOptions
4950
creator_address: StringSearchOptions
@@ -134,6 +135,7 @@ input AttestationAttestationSchemaWhereInput {
134135

135136
input AttestationHypercertWhereInput {
136137
attestations_count: NumberSearchOptions
138+
burned: BooleanSearchOptions
137139
creation_block_number: BigIntSearchOptions
138140
creation_block_timestamp: BigIntSearchOptions
139141
creator_address: StringSearchOptions
@@ -331,6 +333,7 @@ input CollectionBlueprintWhereInput {
331333

332334
input CollectionHypercertWhereInput {
333335
attestations_count: NumberSearchOptions
336+
burned: BooleanSearchOptions
334337
creation_block_number: BigIntSearchOptions
335338
creation_block_timestamp: BigIntSearchOptions
336339
creator_address: StringSearchOptions
@@ -398,6 +401,9 @@ scalar EthBigInt
398401

399402
"""Fraction of an hypercert"""
400403
type Fraction {
404+
"""Whether the fraction has been burned"""
405+
burned: Boolean
406+
401407
"""The ID of the claims"""
402408
claims_id: String
403409

@@ -461,6 +467,7 @@ input FractionMetadataWhereInput {
461467
}
462468

463469
input FractionSortOptions {
470+
burned: SortOrder = null
464471
creation_block_number: SortOrder = null
465472
creation_block_timestamp: SortOrder = null
466473
fraction_id: SortOrder = null
@@ -474,6 +481,7 @@ input FractionSortOptions {
474481
}
475482

476483
input FractionWhereInput {
484+
burned: BooleanSearchOptions
477485
creation_block_number: BigIntSearchOptions
478486
creation_block_timestamp: BigIntSearchOptions
479487
fraction_id: StringSearchOptions
@@ -667,6 +675,9 @@ type Hypercert {
667675
"""Count of attestations referencing this hypercert"""
668676
attestations_count: Int
669677

678+
"""Whether the hypercert has been burned"""
679+
burned: Boolean
680+
670681
"""The contract that the hypercert is associated with"""
671682
contract: Contract
672683

@@ -729,6 +740,9 @@ type HypercertBaseType {
729740
"""Count of attestations referencing this hypercert"""
730741
attestations_count: Int
731742

743+
"""Whether the hypercert has been burned"""
744+
burned: Boolean
745+
732746
"""The UUID of the contract as stored in the database"""
733747
contracts_id: ID
734748
creation_block_number: EthBigInt
@@ -765,6 +779,7 @@ input HypercertContractWhereInput {
765779
}
766780

767781
input HypercertFractionWhereInput {
782+
burned: BooleanSearchOptions
768783
creation_block_number: BigIntSearchOptions
769784
creation_block_timestamp: BigIntSearchOptions
770785
fraction_id: StringSearchOptions
@@ -796,6 +811,7 @@ input HypercertMetadataWhereInput {
796811

797812
input HypercertSortOptions {
798813
attestations_count: SortOrder = null
814+
burned: SortOrder = null
799815
creation_block_number: SortOrder = null
800816
creation_block_timestamp: SortOrder = null
801817
creator_address: SortOrder = null
@@ -812,6 +828,7 @@ input HypercertSortOptions {
812828
input HypercertWhereInput {
813829
attestations: HypercertAttestationWhereInput = {}
814830
attestations_count: NumberSearchOptions
831+
burned: BooleanSearchOptions
815832
contract: HypercertContractWhereInput = {}
816833
creation_block_number: BigIntSearchOptions
817834
creation_block_timestamp: BigIntSearchOptions
@@ -835,6 +852,9 @@ type HypercertWithMetadata {
835852
"""Count of attestations referencing this hypercert"""
836853
attestations_count: Int
837854

855+
"""Whether the hypercert has been burned"""
856+
burned: Boolean
857+
838858
"""The UUID of the contract as stored in the database"""
839859
contracts_id: ID
840860
creation_block_number: EthBigInt
@@ -931,6 +951,7 @@ type Metadata {
931951

932952
input MetadataHypercertWhereInput {
933953
attestations_count: NumberSearchOptions
954+
burned: BooleanSearchOptions
934955
creation_block_number: BigIntSearchOptions
935956
creation_block_timestamp: BigIntSearchOptions
936957
creator_address: StringSearchOptions
@@ -1029,6 +1050,7 @@ type Order {
10291050

10301051
input OrderHypercertWhereInput {
10311052
attestations_count: NumberSearchOptions
1053+
burned: BooleanSearchOptions
10321054
creation_block_number: BigIntSearchOptions
10331055
creation_block_timestamp: BigIntSearchOptions
10341056
creator_address: StringSearchOptions
@@ -1146,6 +1168,7 @@ type Sale {
11461168

11471169
input SaleHypercertWhereInput {
11481170
attestations_count: NumberSearchOptions
1171+
burned: BooleanSearchOptions
11491172
creation_block_number: BigIntSearchOptions
11501173
creation_block_timestamp: BigIntSearchOptions
11511174
creator_address: StringSearchOptions

src/graphql/schemas/typeDefs/baseTypes/hypercertBaseType.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class HypercertBaseType extends BasicTypeDef {
5656
description: "Count of sales of fractions that belong to this hypercert",
5757
})
5858
sales_count?: number;
59+
60+
@Field({
61+
nullable: true,
62+
description: "Whether the hypercert has been burned",
63+
})
64+
burned?: boolean;
5965
}
6066

6167
export { HypercertBaseType };

src/graphql/schemas/typeDefs/fractionTypeDefs.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ export class Fraction extends BasicTypeDef {
8787
description: "Sales related to this fraction",
8888
})
8989
sales?: GetSalesResponse;
90+
91+
@Field({
92+
nullable: true,
93+
description: "Whether the fraction has been burned",
94+
})
95+
burned?: boolean;
9096
}
9197

9298
@ObjectType()

src/lib/graphql/whereFieldDefinitions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const WhereFieldDefinitions = {
9595
hypercert_id: "string",
9696
fraction_id: "string",
9797
token_id: "bigint",
98+
burned: "boolean",
9899
},
99100
},
100101
Hypercert: {
@@ -111,6 +112,7 @@ export const WhereFieldDefinitions = {
111112
sales_count: "number",
112113
attestations_count: "number",
113114
uri: "string",
115+
burned: "boolean",
114116
},
115117
},
116118
Hyperboard: {

src/services/database/entities/HypercertsEntityService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type HypercertSelect = Selectable<CachingDatabase["claims"]>;
2828
@injectable()
2929
export class HypercertsService {
3030
private entityService: EntityService<
31-
CachingDatabase["claims"],
31+
CachingDatabase["claims_view"],
3232
GetHypercertsArgs
3333
>;
3434

@@ -38,9 +38,9 @@ export class HypercertsService {
3838
) {
3939
this.entityService = createEntityService<
4040
CachingDatabase,
41-
"claims",
41+
"claims_view",
4242
GetHypercertsArgs
43-
>("claims", "HypercertsEntityService", kyselyCaching);
43+
>("claims_view", "HypercertsEntityService", kyselyCaching);
4444
}
4545

4646
/**

src/services/database/strategies/ClaimsQueryStrategy.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import { QueryStrategy } from "./QueryStrategy.js";
2222
*/
2323
export class ClaimsQueryStrategy extends QueryStrategy<
2424
CachingDatabase,
25-
"claims",
25+
"claims_view",
2626
GetHypercertsArgs
2727
> {
28-
protected readonly tableName = "claims" as const;
28+
protected readonly tableName = "claims_view" as const;
2929

3030
/**
3131
* Builds a query to retrieve claim data.
@@ -63,7 +63,7 @@ export class ClaimsQueryStrategy extends QueryStrategy<
6363
selectFrom("contracts").whereRef(
6464
"contracts.id",
6565
"=",
66-
"claims.contracts_id",
66+
"claims_view.contracts_id",
6767
),
6868
),
6969
);
@@ -74,15 +74,19 @@ export class ClaimsQueryStrategy extends QueryStrategy<
7474
selectFrom("fractions_view").whereRef(
7575
"fractions_view.claims_id",
7676
"=",
77-
"claims.id",
77+
"claims_view.id",
7878
),
7979
),
8080
);
8181
})
8282
.$if(!isWhereEmpty(args.where?.metadata), (qb) => {
8383
return qb.where(({ exists, selectFrom }) =>
8484
exists(
85-
selectFrom("metadata").whereRef("metadata.uri", "=", "claims.uri"),
85+
selectFrom("metadata").whereRef(
86+
"metadata.uri",
87+
"=",
88+
"claims_view.uri",
89+
),
8690
),
8791
);
8892
})
@@ -92,7 +96,7 @@ export class ClaimsQueryStrategy extends QueryStrategy<
9296
selectFrom("attestations").whereRef(
9397
"attestations.claims_id",
9498
"=",
95-
"claims.id",
99+
"claims_view.id",
96100
),
97101
),
98102
);
@@ -138,7 +142,7 @@ export class ClaimsQueryStrategy extends QueryStrategy<
138142
selectFrom("contracts").whereRef(
139143
"contracts.id",
140144
"=",
141-
"claims.contracts_id",
145+
"claims_view.contracts_id",
142146
),
143147
),
144148
),
@@ -149,15 +153,19 @@ export class ClaimsQueryStrategy extends QueryStrategy<
149153
selectFrom("fractions_view").whereRef(
150154
"fractions_view.claims_id",
151155
"=",
152-
"claims.id",
156+
"claims_view.id",
153157
),
154158
),
155159
),
156160
)
157161
.$if(!isWhereEmpty(args.where?.metadata), (qb) =>
158162
qb.where(({ exists, selectFrom }) =>
159163
exists(
160-
selectFrom("metadata").whereRef("metadata.uri", "=", "claims.uri"),
164+
selectFrom("metadata").whereRef(
165+
"metadata.uri",
166+
"=",
167+
"claims_view.uri",
168+
),
161169
),
162170
),
163171
)
@@ -167,7 +175,7 @@ export class ClaimsQueryStrategy extends QueryStrategy<
167175
selectFrom("attestations").whereRef(
168176
"attestations.claims_id",
169177
"=",
170-
"claims.id",
178+
"claims_view.id",
171179
),
172180
),
173181
),

src/services/database/strategies/QueryStrategyFactory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class QueryStrategyFactory {
6767
blueprints_with_admins: BlueprintsQueryStrategy,
6868
blueprints: BlueprintsQueryStrategy,
6969
claims: ClaimsQueryStrategy,
70+
claims_view: ClaimsQueryStrategy,
7071
hypercerts: ClaimsQueryStrategy,
7172
collections: CollectionsQueryStrategy,
7273
contracts: ContractsQueryStrategy,

src/services/graphql/resolvers/hyperboardResolver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ class HyperboardResolver {
245245
hypercertIds,
246246
),
247247
hypercerts: this.enrichHypercertsWithMetadata(
248+
// @ts-expect-error - claim_attestation_count is not in the type
248249
hypercerts,
249250
metadataByUri,
250251
),

0 commit comments

Comments
 (0)