From b139346b353c916735103e717eb6eaef6ec0b0e2 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 12 Jan 2022 14:42:46 +0000 Subject: [PATCH] output transaction links --- .../Publish/Submission/Feedback.module.css | 11 ++++++++ .../Publish/Submission/Feedback.tsx | 14 +++++++++- src/components/Publish/_constants.tsx | 4 +-- src/components/Publish/_types.ts | 1 + src/components/Publish/_utils.ts | 8 ++++-- src/components/Publish/index.tsx | 28 +++++++++++-------- 6 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/components/Publish/Submission/Feedback.module.css b/src/components/Publish/Submission/Feedback.module.css index e91c11346..a4e3ec6ea 100644 --- a/src/components/Publish/Submission/Feedback.module.css +++ b/src/components/Publish/Submission/Feedback.module.css @@ -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 { diff --git a/src/components/Publish/Submission/Feedback.tsx b/src/components/Publish/Submission/Feedback.tsx index e0967e756..256c73dfb 100644 --- a/src/components/Publish/Submission/Feedback.tsx +++ b/src/components/Publish/Submission/Feedback.tsx @@ -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) => (
  • -

    {value.name}

    +

    + {value.name}{' '} + {value.txHash && ( + + View Transaction + + )} +

    {value.description}

  • )) diff --git a/src/components/Publish/_constants.tsx b/src/components/Publish/_constants.tsx index 09066517e..d54a918fd 100644 --- a/src/components/Publish/_constants.tsx +++ b/src/components/Publish/_constants.tsx @@ -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' } } diff --git a/src/components/Publish/_types.ts b/src/components/Publish/_types.ts index e25bd5506..15b635e9a 100644 --- a/src/components/Publish/_types.ts +++ b/src/components/Publish/_types.ts @@ -58,5 +58,6 @@ export interface PublishFeedback { description: string status: 'success' | 'error' | 'pending' | 'active' message?: string + txHash?: string } } diff --git a/src/components/Publish/_utils.ts b/src/components/Publish/_utils.ts index 77de5dcc1..813c15683 100644 --- a/src/components/Publish/_utils.ts +++ b/src/components/Publish/_utils.ts @@ -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 } } diff --git a/src/components/Publish/index.tsx b/src/components/Publish/index.tsx index 360feb44d..1936e5d68 100644 --- a/src/components/Publish/index.tsx +++ b/src/components/Publish/index.tsx @@ -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) {