Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add artifactUri, thumbnailUri, and displayUri to top level of Objkt #32

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
23 changes: 23 additions & 0 deletions src/Entity/Objkt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,29 @@ export class Objkt extends BaseEntity {
@Column({ nullable: true })
metadataUri: string

@Field({
nullable: true,
description:
"IPFS uri pointing to the web page hosting the Generator code.",
})
@Column({ nullable: true })
artifactUri?: string;

@Field({
nullable: true,
description:
"IPFS uri pointing to the 300x300 (contained) thumbnail of the gentk",
})
@Column({ nullable: true })
thumbnailUri?: string;

@Field({
nullable: true,
description: "IPFS uri pointing to the full res image of the gentk",
})
@Column({ nullable: true })
displayUri?: string;

@Field(() => [String], {
nullable: true,
description: "A list of tags, set by the author(s) at mint time. Corresponds the the Generative Token tags."
Expand Down
24 changes: 24 additions & 0 deletions src/Resolver/ObjktResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,30 @@ export class ObjktResolver {
return ctx.genTokLoader.load(objkt.issuerId)
}

@FieldResolver((returns) => String, {
description: "IPFS uri pointing to the web page hosting the Generator code.",
})
artifactUri(@Root() objkt: Objkt, @Ctx() ctx: RequestContext) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This resolver should be removed as it can be derived from the Generative Token generativeUri and the objkt generationHash

https://gateway.fxhash.xyz/ipfs/${cid(generativeUri)}/?fxhash=${generationHash}

if (objkt.artifactUri) return objkt.artifactUri;
return ctx.genTokLoader.load(objkt.metadata?.artifactUri);
}

@FieldResolver((returns) => String, {
description: "IPFS uri pointing to the 300x300 (contained) thumbnail",
})
thumbnailUri(@Root() objkt: Objkt, @Ctx() ctx: RequestContext) {
if (objkt.thumbnailUri) return objkt.thumbnailUri;
return ctx.genTokLoader.load(objkt.metadata?.thumbnailUri);
Copy link
Contributor

Choose a reason for hiding this comment

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

The genTokLoader is a DataLoader designed to batch queries to get a Generative Token from the database. Its load function accepts a Generative Token ID.

Ultimately, requesting the DataLoader in here is not required, as the data is already available in objkt.metadata.thumbnailUri already stored in memory at this point of execution.

}

@FieldResolver((returns) => String, {
description: "IPFS uri pointing to the full res image",
})
displayUri(@Root() objkt: Objkt, @Ctx() ctx: RequestContext) {
if (objkt.displayUri) return objkt.displayUri;
return ctx.genTokLoader.load(objkt.metadata?.displayUri);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same remark as thumbnailUri

}

@FieldResolver(returns => [Split], {
description: "A list of the royalties split for this gentk."
})
Expand Down