Skip to content

Commit

Permalink
Merge pull request #95 from storyprotocol/soyoung/FND-300
Browse files Browse the repository at this point in the history
Fix `expiration` text format in `LicenseTermsList
  • Loading branch information
SoYoung210 authored Jan 7, 2025
2 parents bdba69c + c9a37c3 commit 0ed75e6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/storykit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@storyprotocol/storykit",
"author": "storyprotocol engineering <[email protected]>",
"version": "0.2.3",
"version": "0.2.4",
"type": "module",
"exports": {
".": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,36 @@ export const DESCRIPTIONS: { [key: string]: string } = {
DERIVATIVES_RECIPROCAL: "Enforce that derivatives have the same License Terms that you provide them",
NEVER_EXPIRES: "This license never expires",
}

function getTimezoneAbbr(date: Date) {
const longName =
date
.toLocaleDateString("en-US", {
timeZoneName: "long",
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
})
.split(",")[1]
?.trim() || ""

return longName
.split(" ")
.map((word) => word[0])
.join("")
}
const convertExpiration = (expiration: string): string => {
if (expiration == "never" || expiration == "0") {
return DESCRIPTIONS.NEVER_EXPIRES
}
return expiration

const date = new Date(Number(expiration))
const expirationDateString = date.toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
})

const timezone = getTimezoneAbbr(date)

return `This license expires in ${expirationDateString} (${timezone})`
}

const DescribeTerms = (selectedLicenseTerms: PILTerms) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
commercialRemixingLicenseTerms,
commercialUseLicenseTerms,
commercialUseLicenseTermsWithExpiration,
noLicenseTerms,
nonCommercialSocialRemixingLicenseTerms,
} from "@/constants/pil-flavors"
Expand Down Expand Up @@ -37,12 +38,14 @@ export const Select: Story = {
"NonCommercialSocialRemixing",
"CommercialRemixingLicenseTerms",
"CommercialUseLicenseTerms",
"CommercialUseLicenseTermsWithExpiration",
"No License",
],
mapping: {
NonCommercialSocialRemixing: nonCommercialSocialRemixingLicenseTerms,
CommercialRemixingLicenseTerms: commercialRemixingLicenseTerms,
CommercialUseLicenseTerms: commercialUseLicenseTerms,
CommercialUseLicenseTermsWithExpiration: commercialUseLicenseTermsWithExpiration,
"No License": noLicenseTerms,
},
},
Expand Down
18 changes: 17 additions & 1 deletion packages/storykit/src/constants/pil-flavors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const commercialUseLicenseTerms: PILTerms = {
commercialUse: true,
commercializerCheck: "0x0000000000000000000000000000000000000000",
currency: "0xb132a6b7ae652c974ee1557a3521d53d18f6739f",
derivativesAllowed: true,
derivativesAllowed: false,
derivativesApproval: false,
derivativesAttribution: true,
derivativesReciprocal: false,
Expand All @@ -33,6 +33,22 @@ export const commercialUseLicenseTerms: PILTerms = {
uRI: "",
}

export const commercialUseLicenseTermsWithExpiration: PILTerms = {
commercialAttribution: true,
commercialRevenueCelling: 0,
commercialRevenueShare: 0,
commercialUse: true,
commercializerCheck: "0x0000000000000000000000000000000000000000",
currency: "0xb132a6b7ae652c974ee1557a3521d53d18f6739f",
derivativesAllowed: false,
derivativesApproval: false,
derivativesAttribution: true,
derivativesReciprocal: false,
derivativesRevenueCelling: 0,
expiration: "1736866800000",
uRI: "",
}

export const nonCommercialSocialRemixingLicenseTerms: PILTerms = {
commercialAttribution: false,
commercialRevenueCelling: 0,
Expand Down

0 comments on commit 0ed75e6

Please sign in to comment.