Skip to content

Commit

Permalink
feat: support gltf inscription type, closes #5091
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Mar 19, 2024
1 parent 0681c93 commit a303de4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function Inscription({ rawInscription }: InscriptionProps) {
case 'html':
case 'svg':
case 'video':
case 'gltf':
return (
<CollectibleIframe
icon={<OrdinalAvatarIcon size="lg" />}
Expand Down
7 changes: 7 additions & 0 deletions src/app/query/bitcoin/ordinals/inscription.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ export function convertInscriptionToSupportedInscriptionType(inscription: Inscri
type: 'video',
...inscription,
}),
gltf: () => ({
infoUrl: createInscriptionInfoUrl(inscription.id),
src: createIframePreviewUrl(inscription.id),
title,
type: 'gltf',
...inscription,
}),
other: () => ({
infoUrl: createInscriptionInfoUrl(inscription.id),
title,
Expand Down
18 changes: 17 additions & 1 deletion src/shared/models/inscription.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { analytics } from '@shared/utils/analytics';

export interface InscriptionResponseItem {
address: string;
content_length: number;
Expand Down Expand Up @@ -42,6 +44,7 @@ const supportedInscriptionTypes = [
'svg',
'text',
'video',
'gltf',
'other',
] as const;

Expand Down Expand Up @@ -87,6 +90,11 @@ interface VideoInscription extends BaseSupportedInscription {
src: string;
}

interface GltfInscription extends BaseSupportedInscription {
type: 'gltf';
src: string;
}

interface OtherInscription extends BaseSupportedInscription {
type: 'other';
}
Expand All @@ -103,6 +111,7 @@ export type SupportedInscription =
| SvgInscription
| TextInscription
| VideoInscription
| GltfInscription
| OtherInscription;

export function whenInscriptionType<T>(
Expand Down Expand Up @@ -133,7 +142,14 @@ export function whenInscriptionType<T>(
return branches.video();
}

if (branches.other) return branches.other();
if (mimeType.startsWith('model/gltf') && branches.gltf) {
return branches.gltf();
}

if (branches.other) {
void analytics.track('unsupported_mime_type', { mimeType });
return branches.other();
}

throw new Error('Unhandled inscription type');
}

0 comments on commit a303de4

Please sign in to comment.