fix transferable NFTs (#1309)

- send along `transferable` param when creating NFT
- new optional `transferable` param in our `generateNftCreateData()` helper, default to `true`. So we don't need to bother adding this to the publish tx fee component
- capture new key in form data, `metadata.transferable`, set to `true` by default. This prepares this to be added as a UI option later on
This commit is contained in:
Matthias Kretschmann 2022-04-04 20:13:39 +01:00 committed by GitHub
parent 3dd21bd20d
commit fc2681231b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 6 deletions

View File

@ -5,7 +5,8 @@ import {
Nft,
ProviderInstance,
DDO,
MetadataAndTokenURI
MetadataAndTokenURI,
NftCreateData
} from '@oceanprotocol/lib'
import { SvgWaves } from './SvgWaves'
import Web3 from 'web3'
@ -64,13 +65,15 @@ const tokenUriPrefix = 'data:application/json;base64,'
export function generateNftCreateData(
nftMetadata: NftMetadata,
accountId: string
accountId: string,
transferable = true
): any {
const nftCreateData = {
const nftCreateData: NftCreateData = {
name: nftMetadata.name,
symbol: nftMetadata.symbol,
templateIndex: 1,
tokenURI: '',
transferable,
owner: accountId
}

View File

@ -53,6 +53,7 @@ export const initialValues: FormPublishData = {
},
metadata: {
nft: { name: '', symbol: '', description: '', image_data: '' },
transferable: true,
type: 'dataset',
name: '',
author: '',

View File

@ -29,6 +29,7 @@ export interface FormPublishData {
}
metadata: {
nft: NftMetadata
transferable: boolean
type: 'dataset' | 'algorithm'
name: string
description: string

View File

@ -181,8 +181,7 @@ export async function transformPublishFormToDdo(
}
],
nft: {
...generateNftCreateData(values?.metadata.nft, accountId),
owner: accountId
...generateNftCreateData(values?.metadata.nft, accountId)
}
})
}
@ -199,7 +198,8 @@ export async function createTokensAndPricing(
) {
const nftCreateData: NftCreateData = generateNftCreateData(
values.metadata.nft,
accountId
accountId,
values.metadata.transferable
)
const { appConfig } = getSiteMetadata()
LoggerInstance.log('[publish] Creating NFT with metadata', nftCreateData)