mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
naming: NftOptions → NftMetadata
This commit is contained in:
parent
c3301fb437
commit
fee5973f81
@ -1,7 +1,7 @@
|
||||
import { renderStaticWaves } from './oceanWaves'
|
||||
|
||||
// https://docs.opensea.io/docs/metadata-standards
|
||||
export interface NftOptions {
|
||||
export interface NftMetadata {
|
||||
name: string
|
||||
symbol: string
|
||||
description: string
|
||||
@ -31,14 +31,14 @@ function encodeSvg(svgString: string): string {
|
||||
.replace(/\s+/g, ' ')
|
||||
}
|
||||
|
||||
export function generateNftOptions(): NftOptions {
|
||||
export function generateNftMetadata(): NftMetadata {
|
||||
// TODO: crop image properly in the end as generated SVG waves are a super-wide image,
|
||||
// and add a filled background deciding on either black or white.
|
||||
const image = renderStaticWaves()
|
||||
// const image = new XMLSerializer().serializeToString(waves)
|
||||
// const image = `<svg><path d="M0 10.4304L16.3396 10.4304L8.88727 17.6833L10.2401 19L20 9.5L10.2401 0L8.88727 1.31491L16.3396 8.56959L0 8.56959V10.4304Z" /></svg>`
|
||||
|
||||
const newNft: NftOptions = {
|
||||
const newNft: NftMetadata = {
|
||||
name: 'Ocean Asset v4 NFT',
|
||||
symbol: 'OCEAN-V4-NFT',
|
||||
description: `This NFT represents an asset in the Ocean Protocol v4 ecosystem.`,
|
||||
@ -56,15 +56,15 @@ export function generateNftOptions(): NftOptions {
|
||||
return newNft
|
||||
}
|
||||
|
||||
export function generateNftCreateData(nftOptions: NftOptions): any {
|
||||
export function generateNftCreateData(nftMetadata: NftMetadata): any {
|
||||
const nftCreateData = {
|
||||
name: nftOptions.name,
|
||||
symbol: nftOptions.symbol,
|
||||
name: nftMetadata.name,
|
||||
symbol: nftMetadata.symbol,
|
||||
templateIndex: 1,
|
||||
// TODO: figure out if Buffer.from method is working in browser in final build
|
||||
// as BTOA is deprecated.
|
||||
tokenURI: window?.btoa(JSON.stringify(nftOptions))
|
||||
// tokenURI: Buffer.from(JSON.stringify(nftOptions)).toString('base64') // should end up as data:application/json;base64
|
||||
tokenURI: window?.btoa(JSON.stringify(nftMetadata))
|
||||
// tokenURI: Buffer.from(JSON.stringify(nftMetadata)).toString('base64') // should end up as data:application/json;base64
|
||||
}
|
||||
|
||||
return nftCreateData
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Button from '@shared/atoms/Button'
|
||||
import { InputProps } from '@shared/FormInput'
|
||||
import { generateNftOptions } from '@utils/nft'
|
||||
import { generateNftMetadata } from '@utils/nft'
|
||||
import { useField } from 'formik'
|
||||
import React, { ReactElement, useEffect } from 'react'
|
||||
import Refresh from '@images/refresh.svg'
|
||||
@ -13,7 +13,7 @@ export default function Nft(props: InputProps): ReactElement {
|
||||
useEffect(() => {
|
||||
if (field.value?.name !== '') return
|
||||
|
||||
const nftOptions = generateNftOptions()
|
||||
const nftOptions = generateNftMetadata()
|
||||
helpers.setValue({ ...nftOptions })
|
||||
}, [field.value?.name])
|
||||
|
||||
@ -28,8 +28,8 @@ export default function Nft(props: InputProps): ReactElement {
|
||||
title="Generate new image"
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
const nftOptions = generateNftOptions()
|
||||
helpers.setValue({ ...nftOptions })
|
||||
const nftMetadata = generateNftMetadata()
|
||||
helpers.setValue({ ...nftMetadata })
|
||||
}}
|
||||
>
|
||||
<Refresh />
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ServiceComputeOptions } from '@oceanprotocol/lib'
|
||||
import { DataTokenOptions } from '@utils/datatokens'
|
||||
import { NftOptions } from '@utils/nft'
|
||||
import { NftMetadata } from '@utils/nft'
|
||||
import { ReactElement } from 'react'
|
||||
|
||||
interface FileMetadata {
|
||||
@ -28,7 +28,7 @@ export interface FormPublishData {
|
||||
chainId: number
|
||||
}
|
||||
metadata: {
|
||||
nft: NftOptions
|
||||
nft: NftMetadata
|
||||
type: 'dataset' | 'algorithm'
|
||||
name: string
|
||||
description: string
|
||||
|
Loading…
Reference in New Issue
Block a user