Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

WIP: add rights as props #1192

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
28 changes: 27 additions & 1 deletion frontend/components/hypercert-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DataProvider } from "@plasmicapp/loader-nextjs";
import dayjs from "dayjs";
import { Formik, FormikProps } from "formik";
import html2canvas from "html2canvas";
import _ from "lodash";
import _, { get } from "lodash";
import { useRouter } from "next/router";
import qs from "qs";
import React, { ReactNode } from "react";
Expand Down Expand Up @@ -377,6 +377,7 @@ export function HypercertCreateForm(props: HypercertCreateFormProps) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
address!,
applicationName,
transferRestrictions,
image,
);
console.log(`Metadata(valid=${metaData.valid}): `, metaData.data);
Expand Down Expand Up @@ -440,10 +441,28 @@ export function HypercertCreateForm(props: HypercertCreateFormProps) {
);
}

const getTransferRights = (transferRestrictions: TransferRestrictions) => {
// enum TransferRestrictions {
// AllowAll,
// DisallowAll,
// FromCreatorOnly
// }
if (transferRestrictions === 0) {
return "Allow All Transfers";
}
if (transferRestrictions === 1) {
return "Disallow All Transfers";
}
if (transferRestrictions === 2) {
return "Transfer From Creator Only";
}
};

const formatValuesToMetaData = (
val: HypercertCreateFormData,
address: string,
applicationName: string,
transferRestrictions: TransferRestrictions,
image?: string,
) => {
// Split contributor names and addresses.
Expand Down Expand Up @@ -477,12 +496,19 @@ const formatValuesToMetaData = (
? new Date(val.workTimeEnd).getTime() / 1000
: 0;

const transferRights = getTransferRights(transferRestrictions);
const rightsProps = [...val.rights, transferRights];

let properties = [
{
trait_type: "Minted by",
value: "true",
application: applicationName,
},
{
trait_type: "Rights",
value: rightsProps.join(", "),
},
];
if (val.metadataProperties) {
try {
Expand Down