1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

output transaction links

This commit is contained in:
Matthias Kretschmann 2022-01-12 14:42:46 +00:00
parent a65c971ea6
commit b139346b35
6 changed files with 49 additions and 17 deletions

View File

@ -52,6 +52,17 @@
.description { .description {
margin-left: calc(var(--spacer) * 1.3); margin-left: calc(var(--spacer) * 1.3);
color: var(--color-secondary); color: var(--color-secondary);
margin-bottom: 0;
}
.txHash {
display: inline-block;
margin-left: calc(var(--spacer) / 2);
margin-top: calc(var(--spacer) / 2);
font-size: var(--font-size-small);
font-family: var(--font-family-base);
font-weight: var(--font-weight-base);
color: var(--color-primary);
} }
@keyframes loader { @keyframes loader {

View File

@ -1,3 +1,4 @@
import ExplorerLink from '@shared/ExplorerLink'
import { useFormikContext } from 'formik' import { useFormikContext } from 'formik'
import React, { ReactElement } from 'react' import React, { ReactElement } from 'react'
import { FormPublishData } from '../_types' import { FormPublishData } from '../_types'
@ -8,7 +9,18 @@ export function Feedback(): ReactElement {
const items = Object.entries(values.feedback).map(([key, value], index) => ( const items = Object.entries(values.feedback).map(([key, value], index) => (
<li key={index} className={styles[value.status]}> <li key={index} className={styles[value.status]}>
<h3 className={styles.title}>{value.name}</h3> <h3 className={styles.title}>
{value.name}{' '}
{value.txHash && (
<ExplorerLink
networkId={values.user.chainId}
path={`/tx/${value.txHash}`}
className={styles.txHash}
>
View Transaction
</ExplorerLink>
)}
</h3>
<p className={styles.description}>{value.description}</p> <p className={styles.description}>{value.description}</p>
</li> </li>
)) ))

View File

@ -131,13 +131,13 @@ export const initialPublishFeedback: PublishFeedback = {
2: { 2: {
name: 'Construct & Encrypt DDO', name: 'Construct & Encrypt DDO',
description: description:
'The entered metadata and services are made into a DDO, where the file URLs are encrypted, and afterwards the whole DDO will be encrypted for storage on-chain. Indexers like Aquarius can decrypt the DDO for displaying purposes, the file URLs can only be decrypted by a user exchanging datatokens.', 'The file URLs are encrypted, and the whole DDO is encrypted too.',
status: 'pending' status: 'pending'
}, },
3: { 3: {
name: 'Publish DDO', name: 'Publish DDO',
description: description:
'The encrypted DDO is stored on-chain as part of the Data NFT.', 'The encrypted DDO is stored on-chain as part of the Data NFT. Indexers like Aquarius can decrypt the DDO for displaying purposes, but the file URLs can only be decrypted by exchanging the respective datatokens for this asset.',
status: 'pending' status: 'pending'
} }
} }

View File

@ -58,5 +58,6 @@ export interface PublishFeedback {
description: string description: string
status: 'success' | 'error' | 'pending' | 'active' status: 'success' | 'error' | 'pending' | 'active'
message?: string message?: string
txHash?: string
} }
} }

View File

@ -214,8 +214,7 @@ export async function createTokensAndPricing(
symbol: values.services[0].dataTokenOptions.symbol symbol: values.services[0].dataTokenOptions.symbol
} }
let erc721Address = '' let erc721Address, datatokenAddress, txHash
let datatokenAddress = ''
// TODO: cleaner code for this huge switch !??!? // TODO: cleaner code for this huge switch !??!?
switch (values.pricing.type) { switch (values.pricing.type) {
@ -257,6 +256,7 @@ export async function createTokensAndPricing(
erc721Address = result.events.NFTCreated.returnValues[0] erc721Address = result.events.NFTCreated.returnValues[0]
datatokenAddress = result.events.TokenCreated.returnValues[0] datatokenAddress = result.events.TokenCreated.returnValues[0]
txHash = result.transactionHash
break break
} }
case 'fixed': { case 'fixed': {
@ -281,6 +281,7 @@ export async function createTokensAndPricing(
erc721Address = result.events.NFTCreated.returnValues[0] erc721Address = result.events.NFTCreated.returnValues[0]
datatokenAddress = result.events.TokenCreated.returnValues[0] datatokenAddress = result.events.TokenCreated.returnValues[0]
txHash = result.transactionHash
break break
} }
@ -303,10 +304,11 @@ export async function createTokensAndPricing(
) )
erc721Address = result.events.NFTCreated.returnValues[0] erc721Address = result.events.NFTCreated.returnValues[0]
datatokenAddress = result.events.TokenCreated.returnValues[0] datatokenAddress = result.events.TokenCreated.returnValues[0]
txHash = result.transactionHash
break break
} }
} }
return { erc721Address, datatokenAddress } return { erc721Address, datatokenAddress, txHash }
} }

View File

@ -71,19 +71,21 @@ export default function PublishPage({
const config = getOceanConfig(chainId) const config = getOceanConfig(chainId)
LoggerInstance.log('[publish] using config: ', config) LoggerInstance.log('[publish] using config: ', config)
const { erc721Address, datatokenAddress } = await createTokensAndPricing( const { erc721Address, datatokenAddress, txHash } =
values, await createTokensAndPricing(
accountId, values,
appConfig.marketFeeAddress, accountId,
config, appConfig.marketFeeAddress,
nftFactory, config,
web3 nftFactory,
) web3
)
const isSuccess = Boolean(erc721Address && datatokenAddress) const isSuccess = Boolean(erc721Address && datatokenAddress && txHash)
_erc721Address = erc721Address _erc721Address = erc721Address
_datatokenAddress = datatokenAddress _datatokenAddress = datatokenAddress
LoggerInstance.log('[publish] createTokensAndPricing tx', txHash)
LoggerInstance.log('[publish] erc721Address', erc721Address) LoggerInstance.log('[publish] erc721Address', erc721Address)
LoggerInstance.log('[publish] datatokenAddress', datatokenAddress) LoggerInstance.log('[publish] datatokenAddress', datatokenAddress)
@ -91,7 +93,8 @@ export default function PublishPage({
...prevState, ...prevState,
1: { 1: {
...prevState[1], ...prevState[1],
status: isSuccess ? 'success' : 'error' status: isSuccess ? 'success' : 'error',
txHash
} }
})) }))
} catch (error) { } catch (error) {
@ -200,11 +203,14 @@ export default function PublishPage({
LoggerInstance.log('[publish] setMetadata result', res) LoggerInstance.log('[publish] setMetadata result', res)
const txHash = res.transactionHash
setFeedback((prevState) => ({ setFeedback((prevState) => ({
...prevState, ...prevState,
3: { 3: {
...prevState[3], ...prevState[3],
status: res ? 'success' : 'error' status: res ? 'success' : 'error',
txHash
} }
})) }))
} catch (error) { } catch (error) {