diff --git a/src/hooks/useConsume/README.md b/src/hooks/useConsume/README.md index c69a05f..cdefd71 100644 --- a/src/hooks/useConsume/README.md +++ b/src/hooks/useConsume/README.md @@ -6,18 +6,17 @@ Get access to, and download a data asset. ```tsx import React from 'react' -import { useWeb3, useMetadata, useConsume } from '@oceanprotocol/react' +import { useOcean, useConsume } from '@oceanprotocol/react' const did = 'did:op:0x000000000' export default function MyComponent() { - // Get web3 from Web3Provider context - const { web3, account } = useWeb3() + const { accountId } = useOcean() // Get metadata for this asset - const { title, metadata } = useMetadata(did) + const { title, price } = useMetadata(did) - // consume asset + // Consume helpers const { consume, consumeStep } = useConsume() async function handleDownload() { @@ -27,9 +26,9 @@ export default function MyComponent() { return (
Price: {web3.utils.fromWei(metadata.main.price)}
+Price: {price}
-Your account: {account}
+Your account: {accountId}
diff --git a/src/hooks/useConsume/useConsume.ts b/src/hooks/useConsume/useConsume.ts index 632c5bc..8e4b9e1 100644 --- a/src/hooks/useConsume/useConsume.ts +++ b/src/hooks/useConsume/useConsume.ts @@ -3,6 +3,7 @@ import { useOcean } from '../../providers' import { feedback } from '../../utils' import { DID, Logger, ServiceType } from '@oceanprotocol/lib' import { checkAndBuyDT } from '../../utils/dtUtils' + interface UseConsume { consume: ( did: DID | string, diff --git a/src/hooks/useMetadata/README.md b/src/hooks/useMetadata/README.md index b9fca6d..cfbe17c 100644 --- a/src/hooks/useMetadata/README.md +++ b/src/hooks/useMetadata/README.md @@ -3,9 +3,10 @@ Get metadata for a specific data asset. `useMetadata` has 3 uses: - - `useMetadata(did)` : it gets the ddo and then loads all the values (title, metadata etc) - - `useMetadata(ddo)` : it uses the passed ddo and the loads all the values, in case you already got a list of ddo, so you don't have to fetch the ddo once again - - `useMetadata()` : loads nothing, useful for using functions like `getBestPrice` or `getBestPool` (maybe more in the future) with minimal calls + +- `useMetadata(did)` : it gets the DDO and then loads all the values (title, metadata etc) +- `useMetadata(ddo)` : it uses the passed DDO and the loads all the values, in case you already got a list of DDOs, so you don't have to fetch the DDO once again +- `useMetadata()` : loads nothing, useful for using functions like `getPrice` or `getPool` with minimal calls ## Usage @@ -17,14 +18,14 @@ const did = 'did:op:0x000000000' export default function MyComponent() { // Get metadata for this asset - const { ddo, title, metadata, bestPrice} = useMetadata(did) + const { title, metadata, price } = useMetadata(did) const { main, additionalInformation } = metadata return (Price: {bestPrice}
+Price: {price}
Your account: {accountId}
+ +