Skip to content

Commit

Permalink
Merge pull request #275 from helius-labs/feat/update-compressed-metad…
Browse files Browse the repository at this point in the history
…ata-txt-support

[Feat] Add Support for Compressed NFT Metadata Update Transactions
  • Loading branch information
0xIchigo committed Jan 17, 2024
2 parents adefbdb + b2d7893 commit 04b1824
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/components/json.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
>
<div class="mt-3 grid grid-cols-12 items-center gap-3 rounded-lg p-1">
<div class="col-span-2 p-1 md:col-span-1">
{#if label !== "token"}
{#if label !== "token" && label !== "update-cNFT"}
<div class="center h-10 w-10 rounded-full bg-secondary">
<Icon
id="json"
Expand Down Expand Up @@ -58,11 +58,11 @@
</h3>
</div>
<div class="flex items-center">
{#if label === "token"}
{#if label === "token" || label === "update-cNFT"}
<h3 class="mr-2 text-xs">Copy JSON</h3>
{/if}
<CopyButton text={JSON.stringify(data, null, 2)} />
{#if label !== "token"}
{#if label !== "token" && label !== "update-cNFT"}
<button
class="btn-ghost btn-sm btn"
on:click={() => (showCode = !showCode)}
Expand All @@ -82,7 +82,7 @@
{/if}
</div>
</div>
{#if showCode || label === "token"}
{#if showCode || label === "token" || label === "update-cNFT"}
<div class="code col-span-12 w-full overflow-hidden px-3">
<pre><code class="text-xs">{@html metadataHTML}</code></pre>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export const transactionActionsMetadata: Record<
icon: "lightning",
label: "Transfer",
},
COMPRESSED_NFT_UPDATE_METADATA: {
icon: "arrowUp",
label: "Update NFT Metadata",
},
CREATE_ORDER: {
icon: "plus",
label: "Create Order",
Expand Down
3 changes: 3 additions & 0 deletions src/lib/xray/lib/parser/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum ProtonSupportedType {
EXECUTE_TRANSACTION,
COMPRESSED_NFT_MINT,
COMPRESSED_NFT_TRANSFER,
COMPRESSED_NFT_UPDATE_METADATA,
APPROVE_TRANSACTION,
STAKE_SOL,
SFT_MINT,
Expand Down Expand Up @@ -87,6 +88,7 @@ export enum ProtonSupportedActionType {
"XNFT_UNINSTALL",
"COMPRESSED_NFT_MINT",
"COMPRESSED_NFT_TRANSFER",
"COMPRESSED_NFT_UPDATE_METADATA",
"APPROVE_TRANSACTION",
"STAKE_SOL",
"SFT_MINT",
Expand Down Expand Up @@ -155,6 +157,7 @@ export interface ProtonTransaction {
actions: ProtonTransactionAction[];
accounts: ProtonAccount[];
raw?: EnrichedTransaction;
metadata?: { [key: string]: any };
}

export interface ProtonAccount {
Expand Down
29 changes: 29 additions & 0 deletions src/routes/tx/[tx]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
let animate = false;
let isLoading = true;
let isMounted = false;
let updatedMetadata;
const signature = $page.params.tx;
Expand Down Expand Up @@ -164,6 +165,34 @@
</div>
{/if}

{#if $transaction.data?.type === "COMPRESSED_NFT_UPDATE_METADATA"}
<div class="px-3 pt-3">
<Collapse
sectionTitle="Old Metadata"
showDetails={false}
hideIcon={true}
>
<JSON
data={data.raw?.events?.compressed[0]?.metadata}
label={"update-cNFT"}
/>
</Collapse>
</div>
<div class="mb-3 px-3 pt-3">
<Collapse
sectionTitle="Metadata Changes"
showDetails={false}
hideIcon={true}
>
<JSON
data={data.raw?.events?.compressed[0]
?.updateArgs}
label={"update-cNFT"}
/>
</Collapse>
</div>
{/if}

<div class="mb-3 px-3">
<div
class="mt-3 grid grid-cols-12 items-center gap-3 rounded-lg border p-1 py-3"
Expand Down

0 comments on commit 04b1824

Please sign in to comment.