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 {
margin-left: calc(var(--spacer) * 1.3);
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 {

View File

@ -1,3 +1,4 @@
import ExplorerLink from '@shared/ExplorerLink'
import { useFormikContext } from 'formik'
import React, { ReactElement } from 'react'
import { FormPublishData } from '../_types'
@ -8,7 +9,18 @@ export function Feedback(): ReactElement {
const items = Object.entries(values.feedback).map(([key, value], index) => (
<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>
</li>
))

View File

@ -131,13 +131,13 @@ export const initialPublishFeedback: PublishFeedback = {
2: {
name: 'Construct & Encrypt DDO',
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'
},
3: {
name: 'Publish DDO',
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'
}
}

View File

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

View File

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

View File

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