From 7fa93ae5b5e57f32c43be3433865f6b91ba9e20a Mon Sep 17 00:00:00 2001 From: mihaisc Date: Wed, 19 Aug 2020 16:24:31 +0300 Subject: [PATCH] readme update --- README.md | 15 +++++++++++++-- example/src/MetadataExample.tsx | 6 +++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0aed388..aa095e2 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,8 @@ export default function MyComponent() { const { ocean, web3, account } = useOcean() // Get metadata for this asset - const { title, metadata } = useMetadata(did) + const { title, metadata, isLoaded, getBestPrice } = useMetadata(did) + const [price, setPrice] = useState() // publish asset const { publish, publishStep } = usePublish() @@ -72,6 +73,16 @@ export default function MyComponent() { // consume asset const { consume, consumeStep } = useConsume() + useEffect(() => { + async function init(): Promise { + if (isLoaded) { + const price = await getBestPrice() + setPrice(price) + } + } + init() + }, [isLoaded]) + async function handleDownload() { await consume(did) } @@ -79,7 +90,7 @@ export default function MyComponent() { return (

{title}

-

Price: {web3.utils.fromWei(metadata.main.price)}

+

Price: {price}

Your account: {account}