market/src/components/Publish/_utils.ts

300 lines
8.6 KiB
TypeScript
Raw Normal View History

2022-01-11 12:03:54 +01:00
import {
Config,
2022-01-11 12:03:54 +01:00
DDO,
FreCreationParams,
2022-01-11 12:03:54 +01:00
generateDid,
DatatokenCreateParams,
DispenserCreationParams,
2022-01-11 12:03:54 +01:00
getHash,
LoggerInstance,
2022-01-11 12:03:54 +01:00
Metadata,
NftCreateData,
NftFactory,
Service,
ZERO_ADDRESS
2022-01-11 12:03:54 +01:00
} from '@oceanprotocol/lib'
import { mapTimeoutStringToSeconds } from '@utils/ddo'
2022-01-12 14:36:34 +01:00
import { generateNftCreateData } from '@utils/nft'
2021-12-20 15:38:54 +01:00
import { getEncryptedFiles } from '@utils/provider'
import slugify from 'slugify'
import Web3 from 'web3'
2022-08-02 11:53:22 +02:00
import { algorithmContainerPresets } from './_constants'
import { FormPublishData, MetadataAlgorithmContainer } from './_types'
Various fixes in the pool component (#1327) * remove legacy check to prevent rug pull Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add expected output to remove Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.logs Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix max calculations Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactors Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * temp fixes for build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * local calc for pice and liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove var Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix profile liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * global context, opc fee Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * comment Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor global context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove nesting from market context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix undefined appConfig Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * direct import of appConfig & siteContent * this never changes on run time, so we should never have to wait for it and have it in js bundle at all times * in utility methods, import directly * for components, import directly in MarketMetadata context and pass through * remove screen CSS fixes * put back auto-fetching indicator, move manual refresh action behind debug Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-04-22 02:38:35 +02:00
import {
marketFeeAddress,
publisherMarketOrderFee,
publisherMarketFixedSwapFee,
defaultDatatokenTemplateIndex
Various fixes in the pool component (#1327) * remove legacy check to prevent rug pull Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add expected output to remove Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.logs Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix max calculations Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactors Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * temp fixes for build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * local calc for pice and liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove var Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix profile liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * global context, opc fee Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * comment Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor global context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove nesting from market context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix undefined appConfig Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * direct import of appConfig & siteContent * this never changes on run time, so we should never have to wait for it and have it in js bundle at all times * in utility methods, import directly * for components, import directly in MarketMetadata context and pass through * remove screen CSS fixes * put back auto-fetching indicator, move manual refresh action behind debug Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-04-22 02:38:35 +02:00
} from '../../../app.config'
import { sanitizeUrl } from '@utils/url'
2022-09-20 10:30:11 +02:00
import { getContainerChecksum } from '@utils/docker'
function getUrlFileExtension(fileUrl: string): string {
const splittedFileUrl = fileUrl.split('.')
return splittedFileUrl[splittedFileUrl.length - 1]
}
2022-09-20 10:30:11 +02:00
async function getAlgorithmContainerPreset(
dockerImage: string
2022-09-20 10:30:11 +02:00
): Promise<MetadataAlgorithmContainer> {
if (dockerImage === '') return
const preset = algorithmContainerPresets.find(
(preset) => `${preset.image}:${preset.tag}` === dockerImage
)
2022-09-28 14:47:43 +02:00
preset.checksum = await (
await getContainerChecksum(preset.image, preset.tag)
).checksum
return preset
}
function dateToStringNoMS(date: Date): string {
return date.toISOString().replace(/\.[0-9]{3}Z/, 'Z')
}
Feat: autocomplete tags functionality (#1471) * feat: add autocomplete tag component * feat: pass tags aggregated list to autocomplete component * feat: add initial styling to autocomplete tag component * fix: autocomplete style types * feat: move styling elements to module.css file * feat: update placeholder text for tag input field * feat: add default value to tags if present * feat: add edit tags functionality * fix: default tag value * fix: style for automplete menu's keyboard navigation * fix: tags aggregation query size * feat: return sorted tags aggregated list suggestion in publish * fix: set tags value touched state in edit mode * add package back * enhancement: autocomplete tag component config (#1679) * fix publishing when connecting wallet on publish form * fix reset pricing on tx execution * removed changing steps * cleanup * Fix headers (#1663) * test * test * test * test * test * test * test * remove link * enhancement: tag autocomplete settings * feat: add cursor type text * feat: tweak filter and sort for matched tags * fix: tags input font color * fix: tag autocomplete component input color Co-authored-by: EnzoVezzaro <enzo-vezzaro@live.it> Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro> Co-authored-by: Ana <84312885+AnaLoznianu@users.noreply.github.com> * fix lock * test * fix * fix * minor fixes * fix cursor on remove item (x) * style updates * UX tweaks * start suggestions upon first key stroke * remove redundant help tooltip * change placeholder copy * remove input clear action * edit updates Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro> Co-authored-by: EnzoVezzaro <enzo-vezzaro@live.it> Co-authored-by: Ana <84312885+AnaLoznianu@users.noreply.github.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-10-05 16:40:00 +02:00
function transformTags(originalTags: string[]): string[] {
const transformedTags = originalTags?.map((tag) => slugify(tag).toLowerCase())
return transformedTags
}
export async function transformPublishFormToDdo(
2021-11-11 12:26:29 +01:00
values: FormPublishData,
// Those 2 are only passed during actual publishing process
// so we can always assume if they are not passed, we are on preview.
datatokenAddress?: string,
nftAddress?: string
): Promise<DDO> {
const { metadata, services, user } = values
const { chainId, accountId } = user
const {
type,
name,
description,
tags,
author,
termsAndConditions,
dockerImage,
dockerImageCustom,
dockerImageCustomTag,
dockerImageCustomEntrypoint,
dockerImageCustomChecksum
} = metadata
2021-11-23 16:34:43 +01:00
const { access, files, links, providerUrl, timeout } = services[0]
2021-12-20 15:38:54 +01:00
const did = nftAddress ? generateDid(nftAddress, chainId) : '0x...'
2021-11-26 11:35:41 +01:00
const currentTime = dateToStringNoMS(new Date())
2021-12-20 15:38:54 +01:00
const isPreview = !datatokenAddress && !nftAddress
2022-09-28 14:10:01 +02:00
const algorithmContainerPresets =
type === 'algorithm' && dockerImage !== '' && dockerImage !== 'custom'
? await getAlgorithmContainerPreset(dockerImage)
: null
2021-11-23 16:34:43 +01:00
// Transform from files[0].url to string[] assuming only 1 file
const filesTransformed = files?.length &&
files[0].valid && [sanitizeUrl(files[0].url)]
const linksTransformed = links?.length &&
links[0].valid && [sanitizeUrl(links[0].url)]
2021-11-11 10:22:22 +01:00
const newMetadata: Metadata = {
2021-11-11 10:22:22 +01:00
created: currentTime,
updated: currentTime,
type,
name,
description,
tags: transformTags(tags),
author,
license: 'https://market.oceanprotocol.com/terms',
2021-11-23 16:34:43 +01:00
links: linksTransformed,
2021-11-11 10:22:22 +01:00
additionalInformation: {
termsAndConditions
},
...(type === 'algorithm' &&
dockerImage !== '' && {
algorithm: {
language: filesTransformed?.length
? getUrlFileExtension(filesTransformed[0])
: '',
version: '0.1',
container: {
entrypoint:
dockerImage === 'custom'
? dockerImageCustomEntrypoint
2022-09-28 14:10:01 +02:00
: algorithmContainerPresets.entrypoint,
image:
dockerImage === 'custom'
? dockerImageCustom
2022-09-28 14:10:01 +02:00
: algorithmContainerPresets.image,
tag:
dockerImage === 'custom'
? dockerImageCustomTag
2022-09-28 14:10:01 +02:00
: algorithmContainerPresets.tag,
checksum:
dockerImage === 'custom'
2022-09-20 10:30:11 +02:00
? dockerImageCustomChecksum
2022-09-28 14:10:01 +02:00
: algorithmContainerPresets.checksum
}
2021-11-11 10:22:22 +01:00
}
})
2021-11-11 10:22:22 +01:00
}
2021-12-20 15:38:54 +01:00
// this is the default format hardcoded
const file = {
nftAddress,
datatokenAddress,
files: [
{
type: 'url',
index: 0,
url: files[0].url,
method: 'GET'
}
]
}
2021-11-23 16:34:43 +01:00
const filesEncrypted =
2021-12-20 15:38:54 +01:00
!isPreview &&
2021-11-23 16:34:43 +01:00
files?.length &&
files[0].valid &&
2021-12-21 21:26:08 +01:00
(await getEncryptedFiles(file, providerUrl.url))
2021-11-23 16:34:43 +01:00
const newService: Service = {
2022-01-11 12:03:54 +01:00
id: getHash(datatokenAddress + filesEncrypted),
type: access,
2021-11-23 16:34:43 +01:00
files: filesEncrypted || '',
2021-11-11 12:26:29 +01:00
datatokenAddress,
2021-11-25 15:20:00 +01:00
serviceEndpoint: providerUrl.url,
timeout: mapTimeoutStringToSeconds(timeout),
2021-11-11 10:22:22 +01:00
...(access === 'compute' && {
2021-11-29 17:55:15 +01:00
compute: values.services[0].computeOptions
2021-11-11 10:22:22 +01:00
})
}
const newDdo: DDO = {
2021-11-11 09:55:35 +01:00
'@context': ['https://w3id.org/did/v1'],
2021-11-11 12:26:29 +01:00
id: did,
nftAddress,
version: '4.1.0',
chainId,
metadata: newMetadata,
2022-01-11 21:09:14 +01:00
services: [newService],
2021-11-26 11:35:41 +01:00
// Only added for DDO preview, reflecting Asset response,
// again, we can assume if `datatokenAddress` is not passed,
// we are on preview.
2022-01-11 21:09:14 +01:00
...(!datatokenAddress && {
datatokens: [
{
name: values.services[0].dataTokenOptions.name,
symbol: values.services[0].dataTokenOptions.symbol
}
],
nft: {
...generateNftCreateData(values?.metadata.nft, accountId)
2022-01-11 21:09:14 +01:00
}
})
}
return newDdo
}
export async function createTokensAndPricing(
values: FormPublishData,
accountId: string,
config: Config,
nftFactory: NftFactory,
web3: Web3
) {
2022-01-12 14:36:34 +01:00
const nftCreateData: NftCreateData = generateNftCreateData(
values.metadata.nft,
accountId,
values.metadata.transferable
2022-01-12 14:36:34 +01:00
)
LoggerInstance.log('[publish] Creating NFT with metadata', nftCreateData)
// TODO: cap is hardcoded for now to 1000, this needs to be discussed at some point
const ercParams: DatatokenCreateParams = {
templateIndex: defaultDatatokenTemplateIndex,
minter: accountId,
2022-03-30 15:06:40 +02:00
paymentCollector: accountId,
Various fixes in the pool component (#1327) * remove legacy check to prevent rug pull Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add expected output to remove Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.logs Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix max calculations Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactors Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * temp fixes for build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * local calc for pice and liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove var Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix profile liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * global context, opc fee Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * comment Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor global context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove nesting from market context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix undefined appConfig Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * direct import of appConfig & siteContent * this never changes on run time, so we should never have to wait for it and have it in js bundle at all times * in utility methods, import directly * for components, import directly in MarketMetadata context and pass through * remove screen CSS fixes * put back auto-fetching indicator, move manual refresh action behind debug Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-04-22 02:38:35 +02:00
mpFeeAddress: marketFeeAddress,
Dynamic token list support for publishing (#1516) * feat: add approved tokens list query to subgraph * feat: add base token selector * feat: add placeholder tooltip message for base token * feat: use user selected base token for publish * fix: publish constants * feat: update base token query to include digits and symbol * feat: display correct token name and symbol in publish pricing tab * fix: publish preview token name * fix: query type * feat: add balance fetch for all approved tokens * fix: balance check for dynamic price with alternative base tokens * feat: update balance to show baseToken instead of ocean * fix: default baseToken in publish form * feat: update text content for pricing publish step * chore: update ocean.js * add decimals to token Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix dt decimals Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * update ocean.js Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix: show correct basetoken symbol under button buy * refactor: move baseToken selector to input label [WIP] * refactor: preserve baseToken value value when switching tabs * remove basetoken tooltip from content json * fix: price props * refactor: remove BaseToken component * fix: baseToken name on first load * fix: baseToken display name in dynamic price * fix: conversion tooltip text * fix: error box overlapping in Coin component * feat: add token logo component * feat: add basetoken logo to asset actions pool * fix: token images size * fix: add default appproved token list when disconnected or chainId not supported * fix: datatoken logo on asset details meta * refactor: balance fetch + move approved base tokens list in web3 provider * feat: update all datatokens to display ocean logo in violet * fix: show correct logos on polygon * fix wallet, remove dynamic * fix build * fix: reset baseToken on chainId change during publish * fix: price tabs selection indicator * feat: set the ocean token as default in pricing * add baseToken * fix price * remove firstPrice * cleanup, more affordance for token dropdown Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro> Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-08-03 14:48:57 +02:00
feeToken: values.pricing.baseToken.address,
Various fixes in the pool component (#1327) * remove legacy check to prevent rug pull Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add expected output to remove Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.logs Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix max calculations Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactors Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * temp fixes for build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * local calc for pice and liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove var Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix profile liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * global context, opc fee Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * comment Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor global context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove nesting from market context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix undefined appConfig Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * direct import of appConfig & siteContent * this never changes on run time, so we should never have to wait for it and have it in js bundle at all times * in utility methods, import directly * for components, import directly in MarketMetadata context and pass through * remove screen CSS fixes * put back auto-fetching indicator, move manual refresh action behind debug Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-04-22 02:38:35 +02:00
feeAmount: publisherMarketOrderFee,
// max number
cap: '115792089237316195423570985008687907853269984665640564039457',
name: values.services[0].dataTokenOptions.name,
symbol: values.services[0].dataTokenOptions.symbol
}
LoggerInstance.log('[publish] Creating datatoken with ercParams', ercParams)
2022-01-12 15:42:46 +01:00
let erc721Address, datatokenAddress, txHash
switch (values.pricing.type) {
case 'fixed': {
const freParams: FreCreationParams = {
fixedRateAddress: config.fixedRateExchangeAddress,
Dynamic token list support for publishing (#1516) * feat: add approved tokens list query to subgraph * feat: add base token selector * feat: add placeholder tooltip message for base token * feat: use user selected base token for publish * fix: publish constants * feat: update base token query to include digits and symbol * feat: display correct token name and symbol in publish pricing tab * fix: publish preview token name * fix: query type * feat: add balance fetch for all approved tokens * fix: balance check for dynamic price with alternative base tokens * feat: update balance to show baseToken instead of ocean * fix: default baseToken in publish form * feat: update text content for pricing publish step * chore: update ocean.js * add decimals to token Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix dt decimals Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * update ocean.js Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix: show correct basetoken symbol under button buy * refactor: move baseToken selector to input label [WIP] * refactor: preserve baseToken value value when switching tabs * remove basetoken tooltip from content json * fix: price props * refactor: remove BaseToken component * fix: baseToken name on first load * fix: baseToken display name in dynamic price * fix: conversion tooltip text * fix: error box overlapping in Coin component * feat: add token logo component * feat: add basetoken logo to asset actions pool * fix: token images size * fix: add default appproved token list when disconnected or chainId not supported * fix: datatoken logo on asset details meta * refactor: balance fetch + move approved base tokens list in web3 provider * feat: update all datatokens to display ocean logo in violet * fix: show correct logos on polygon * fix wallet, remove dynamic * fix build * fix: reset baseToken on chainId change during publish * fix: price tabs selection indicator * feat: set the ocean token as default in pricing * add baseToken * fix price * remove firstPrice * cleanup, more affordance for token dropdown Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro> Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-08-03 14:48:57 +02:00
baseTokenAddress: values.pricing.baseToken.address,
owner: accountId,
Various fixes in the pool component (#1327) * remove legacy check to prevent rug pull Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add expected output to remove Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.logs Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix max calculations Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactors Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * temp fixes for build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * local calc for pice and liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove var Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix profile liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * global context, opc fee Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * comment Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor global context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove nesting from market context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix undefined appConfig Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * direct import of appConfig & siteContent * this never changes on run time, so we should never have to wait for it and have it in js bundle at all times * in utility methods, import directly * for components, import directly in MarketMetadata context and pass through * remove screen CSS fixes * put back auto-fetching indicator, move manual refresh action behind debug Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-04-22 02:38:35 +02:00
marketFeeCollector: marketFeeAddress,
Dynamic token list support for publishing (#1516) * feat: add approved tokens list query to subgraph * feat: add base token selector * feat: add placeholder tooltip message for base token * feat: use user selected base token for publish * fix: publish constants * feat: update base token query to include digits and symbol * feat: display correct token name and symbol in publish pricing tab * fix: publish preview token name * fix: query type * feat: add balance fetch for all approved tokens * fix: balance check for dynamic price with alternative base tokens * feat: update balance to show baseToken instead of ocean * fix: default baseToken in publish form * feat: update text content for pricing publish step * chore: update ocean.js * add decimals to token Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix dt decimals Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * update ocean.js Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix: show correct basetoken symbol under button buy * refactor: move baseToken selector to input label [WIP] * refactor: preserve baseToken value value when switching tabs * remove basetoken tooltip from content json * fix: price props * refactor: remove BaseToken component * fix: baseToken name on first load * fix: baseToken display name in dynamic price * fix: conversion tooltip text * fix: error box overlapping in Coin component * feat: add token logo component * feat: add basetoken logo to asset actions pool * fix: token images size * fix: add default appproved token list when disconnected or chainId not supported * fix: datatoken logo on asset details meta * refactor: balance fetch + move approved base tokens list in web3 provider * feat: update all datatokens to display ocean logo in violet * fix: show correct logos on polygon * fix wallet, remove dynamic * fix build * fix: reset baseToken on chainId change during publish * fix: price tabs selection indicator * feat: set the ocean token as default in pricing * add baseToken * fix price * remove firstPrice * cleanup, more affordance for token dropdown Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro> Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-08-03 14:48:57 +02:00
baseTokenDecimals: values.pricing.baseToken.decimals,
datatokenDecimals: 18,
fixedRate: values.pricing.price.toString(),
Various fixes in the pool component (#1327) * remove legacy check to prevent rug pull Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add expected output to remove Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.logs Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix max calculations Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactors Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * temp fixes for build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * local calc for pice and liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove var Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix profile liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * global context, opc fee Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * comment Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor global context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove nesting from market context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix undefined appConfig Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * direct import of appConfig & siteContent * this never changes on run time, so we should never have to wait for it and have it in js bundle at all times * in utility methods, import directly * for components, import directly in MarketMetadata context and pass through * remove screen CSS fixes * put back auto-fetching indicator, move manual refresh action behind debug Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-04-22 02:38:35 +02:00
marketFee: publisherMarketFixedSwapFee,
withMint: true
}
LoggerInstance.log(
'[publish] Creating fixed pricing with freParams',
freParams
)
const result = await nftFactory.createNftWithDatatokenWithFixedRate(
accountId,
nftCreateData,
ercParams,
freParams
)
erc721Address = result.events.NFTCreated.returnValues[0]
datatokenAddress = result.events.TokenCreated.returnValues[0]
2022-01-12 15:42:46 +01:00
txHash = result.transactionHash
LoggerInstance.log('[publish] createNftErcWithFixedRate tx', txHash)
break
}
case 'free': {
// maxTokens - how many tokens cand be dispensed when someone requests . If maxTokens=2 then someone can't request 3 in one tx
// maxBalance - how many dt the user has in it's wallet before the dispenser will not dispense dt
// both will be just 1 for the market
const dispenserParams: DispenserCreationParams = {
dispenserAddress: config.dispenserAddress,
maxTokens: web3.utils.toWei('1'),
maxBalance: web3.utils.toWei('1'),
withMint: true,
allowedSwapper: ZERO_ADDRESS
}
LoggerInstance.log(
'[publish] Creating free pricing with dispenserParams',
dispenserParams
)
const result = await nftFactory.createNftWithDatatokenWithDispenser(
accountId,
nftCreateData,
ercParams,
dispenserParams
)
erc721Address = result.events.NFTCreated.returnValues[0]
datatokenAddress = result.events.TokenCreated.returnValues[0]
2022-01-12 15:42:46 +01:00
txHash = result.transactionHash
LoggerInstance.log('[publish] createNftErcWithDispenser tx', txHash)
break
}
}
2022-01-12 15:42:46 +01:00
return { erc721Address, datatokenAddress, txHash }
}